-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/fiat payments #251
Conversation
a6bb1b8
to
8ab3e8a
Compare
How do you DI being implemented? I know there's some libraries to automate the instantiation based on the type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the general direction makes sense. I would tend to go with a simpler approach and not implement everything all at once (migrations + di + repositories).
As for the migrations, I'm not opposed to using another library to handle them. I haven't taken the time to do proper research for the possible solutions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that the modules should be in their separate domain specific folders, however I think these should be in the database package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? If we have a service that is responsible for working with this table. What's the reason for it to be in a package. Shouldn't other apps use api exposed by a service?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand your point, but I don't think it's a good idea to spread the same db schema into multiple projects, especially that there's relation between the user_setting
table and the user_wallet
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no relation. The relation is on user isn't it? And user is an external service anyway (auth0). This is a totally normal thing in micro services world
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might also be a good point. Every app should have own db after all. It's no issue having the same, but the point is that there is still clear domain based separation of concerns.
Schemas shouldn't be shared indeed. Services should use apis to interact.
@baktun14 DI is an approach. Instead of importing a dep and using directly it should be provided as an arg to a function/class. Like I did in the example. Although I agree some automation would be nuts. |
@baktun14 @Redm4x BTW decided to investigate DI question just a bit. Some options:
both things should be easy to use from the start. Basically the flow would be:
Say, we have these dependency flow: These classes are the same as if there's no automated DI, so no extra work. What needs to be done:
I don't see too much effort in this. If you guys think this is beneficial it's better be done imo. |
oh, this one seems even better https://www.npmjs.com/package/typedi |
Yea this is the one I saw in an article. |
Ok, added TypeDI - this is really not a big deal in terms of effort, the impact though is changing imo. UPDATE: ugh... I don't like this typestack/typedi#1235 will try some of these UPDATE: ok, TSyringe from Microsoft looks real nice and must be reliable b2cf5ac |
added drizzle 837319c this is a fully functional example. I personally see no reason not to start migrating slowly. |
0b52d37
to
b2cf5ac
Compare
import { integer, pgTable, serial, varchar } from "drizzle-orm/pg-core"; | ||
|
||
export const userWalletSchema = pgTable("user_wallets", { | ||
id: serial("serial").primaryKey(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use serial
instead of uuid
here? Is it to use it as the wallet index?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also the column name (serial
) doesn't match the property name (id
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's going to be used as address index
@Table({ | ||
modelName: "user_wallet" | ||
}) | ||
export class UserWalletModel extends Model<UserWallet> implements Omit<UserWalletModel, "createdAt" | "updatedAt"> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the goal to have a drizzle AND a sequelize model during the transition period to drizzle?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any application for this atm, so I'd drop it. But yea, we can have both. Wdyt?
e4088c1
to
bacc119
Compare
private async estimateFee(messages: readonly EncodeObject[], denom: string) { | ||
const client = await this.getClient(); | ||
const address = await this.getMasterWalletAddress(); | ||
const gasEstimation = await client.simulate(address, messages, "allowance grant"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove the memo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the address should be based on the current tx and not hardcoded to be the master wallet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it's a transaction on the master wallet, so the estimation of the fee should be also based on master wallet. Could you please elaborate on this comment a bit more because I don't not follow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove the memo
Memo is a required parameter. Can not omit it due to type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private async estimateFee(messages: readonly EncodeObject[], denom: string) { | ||
const client = await this.getClient(); | ||
const address = await this.getMasterWalletAddress(); | ||
const gasEstimation = await client.simulate(address, messages, "allowance grant"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the address should be based on the current tx and not hardcoded to be the master wallet
I tried to describe is the convention in the description of this PR. I personally like it in a different way. However, I tried to match something that we already have in the project. I am open to change this to something we can commonly agree to. I personally like nest JS convention when directories are named in snake case and files are named in snake case with an extension containing the type of the file. Like some-class.service.ts. The file should contain a class or a function that that is named the same as the file by camel case. To me, this approach reduces cognitive load when going through the code radically. |
Right, those are files and match the main exported function |
import { ApiPgDatabase, POSTGRES_DB } from "@src/core"; | ||
import { closeConnections } from "@src/db/dbConnection"; | ||
|
||
jest.setTimeout(30000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was this for testing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Request was taking more then default 5sec for me quite a bit
1afe31e
to
bd61dcf
Compare
As a part of this add: - DI container - Drizzle ORM - logging refs #247
bd61dcf
to
3dfaeff
Compare
Proposal for Billing Feature Structure
This PR proposes a structure for the upcoming billing feature. It includes some entities to showcase the structure, so please overlook any weak typing or lack of implementations for now.
Main Concepts
Dedicated Module
Flat Structure
Naming
StringService
for something that works with strings.Exports
Database
Workers
Dependency Injection (DI)
Migrations
Note: This is a proposal. I welcome counter-arguments and suggestions. The goal is to have a constructive discussion and agree on an approach we can follow consistently.