-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP refactor(billing): extract trial wallet creation to a service
also refactor module imports refs #247
- Loading branch information
1 parent
bacc119
commit a18a906
Showing
18 changed files
with
71 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,3 @@ export const config = { | |
...env, | ||
USDC_IBC_DENOMS | ||
}; | ||
export type BillingConfig = typeof config; |
12 changes: 5 additions & 7 deletions
12
apps/api/src/billing/controllers/wallet/WalletController.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
import { container } from "tsyringe"; | ||
import { container, inject } from "tsyringe"; | ||
|
||
import { config } from "@src/billing/config"; | ||
|
||
export const BILLING_CONFIG = "BILLING_CONFIG"; | ||
|
||
container.register(BILLING_CONFIG, { useValue: config }); | ||
|
||
export type BillingConfig = typeof config; | ||
|
||
export const InjectBillingConfig = () => inject(BILLING_CONFIG); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
import "./userWalletSchemaProvider"; | ||
import "./configProvider"; | ||
|
||
export * from "./userWalletSchemaProvider"; | ||
export * from "./configProvider"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
import { container } from "tsyringe"; | ||
import { container, inject } from "tsyringe"; | ||
|
||
import { userWalletSchema } from "@src/billing/model-schemas"; | ||
|
||
export const USER_WALLET_SCHEMA = "USER_WALLET_SCHEMA"; | ||
|
||
container.register(USER_WALLET_SCHEMA, { useValue: userWalletSchema }); | ||
|
||
export type UserWalletSchema = typeof userWalletSchema; | ||
|
||
export const InjectUserWalletSchema = () => inject(USER_WALLET_SCHEMA); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export * from "./wallet-manager/WalletManager"; | ||
export * from "./rpc-message-service/RpcMessageService"; | ||
export * from "./wallet-initializer/WalletInitializer"; |
20 changes: 20 additions & 0 deletions
20
apps/api/src/billing/services/wallet-initializer/WalletInitializer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { singleton } from "tsyringe"; | ||
|
||
import { UserInput, UserWalletRepository } from "@src/billing/repositories"; | ||
import { WalletManager } from "@src/billing/services"; | ||
import { WithTransaction } from "@src/core/services"; | ||
|
||
@singleton() | ||
export class WalletInitializer { | ||
constructor( | ||
private readonly walletManager: WalletManager, | ||
private readonly userWalletRepository: UserWalletRepository | ||
) {} | ||
|
||
@WithTransaction() | ||
async initialize(userId: UserInput["userId"]) { | ||
const userWallet = await this.userWalletRepository.create({ userId }); | ||
const wallet = await this.walletManager.createAndAuthorizeTrialSpending({ addressIndex: userWallet.id }); | ||
await this.userWalletRepository.updateById(userWallet.id, { address: wallet.address }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
import "./postgres/postgres"; | ||
export * from "./tx-manager/TxManager"; | ||
export * from "./logger/Logger"; | ||
export * from "./contextual-logger/ContextualLogger"; | ||
export * from "./postgres/postgres"; | ||
export * from "./log-http-requests/logHttpRequests"; | ||
export * from "./request-storage/RequestStorage"; |
2 changes: 1 addition & 1 deletion
2
apps/api/src/core/services/log-http-requests/logHttpRequests.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters