feat(billing): adds a unique rpc proxy header per instance of a batch signing client#2152
feat(billing): adds a unique rpc proxy header per instance of a batch signing client#2152ygrishajev merged 1 commit intomainfrom
Conversation
WalkthroughReplaces the old SyncSigningStargateClient class with a factory-based SigningStargateClient creation flow. Adds a new signing-stargate-client factory (and tests), updates consumers to use the factory, and removes the SyncSigningStargateClient implementation and its exports. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Provider as signing-client.provider
participant Factory as createSigningStargateClient
participant HttpC as HttpClient
participant Comet as Comet38Client
participant SSC as SigningStargateClient
Provider->>Factory: createSigningStargateClient(endpoint, wallet, options?)
Factory->>HttpC: new HttpClient(endpoint, { X-Proxy-Key: UUID })
HttpC-->>Factory: httpClient
Factory->>Comet: Comet38Client.create(httpClient)
Comet-->>Factory: rpcClient
Factory->>SSC: SigningStargateClient.createWithSigner(rpcClient, wallet, options?)
SSC-->>Factory: signingClient
Factory-->>Provider: SigningStargateClient instance
sequenceDiagram
autonumber
participant Provider as Provider
participant Old as SyncSigningStargateClient
participant New as createSigningStargateClient
participant BSC as BatchSigningClientService
rect rgb(220,220,255)
Note over Old,BSC: Before (class-based)
Provider->>Old: SyncSigningStargateClient.createWithEndpoint.bind(...)
Old-->>Provider: bound factory
Provider->>BSC: constructor(..., boundFactory)
end
rect rgb(220,255,220)
Note over New,BSC: After (factory-based)
Provider->>New: createSigningStargateClient
New-->>Provider: signing client factory
Provider->>BSC: constructor(..., createSigningStargateClient)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (7)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (5)
🧰 Additional context used📓 Path-based instructions (2)**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/general.mdc)
Files:
**/*.{js,ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/general.mdc)
Files:
🧠 Learnings (2)📓 Common learnings📚 Learning: 2025-08-21T04:03:23.490ZApplied to files:
🧬 Code graph analysis (1)apps/api/src/billing/providers/signing-client.provider.ts (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (2)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/api/src/billing/lib/batch-signing-client/batch-signing-client.service.ts (1)
152-162: Await the async signing client creation.
SigningStargateClient.createWithSigner(and the precedingComet38Client.create) both return promises, socreateSigningStargateClientnow yields aPromise<SigningStargateClient>. Assigning that promise tothis.clientmeans every subsequent call (e.g.,this.client.getChainId(),this.client.sign(...)) will throw at runtime becausethis.clientis not the resolved client instance. Please await the factory before storing/using the client—e.g., keep aclientPromiseandawaitit at each use site, or change the factory/type to resolve the async creation internally.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
apps/api/src/billing/lib/batch-signing-client/batch-signing-client.service.spec.ts(2 hunks)apps/api/src/billing/lib/batch-signing-client/batch-signing-client.service.ts(4 hunks)apps/api/src/billing/lib/signing-stargate-client-factory/signing-stargate-client.factory.spec.ts(1 hunks)apps/api/src/billing/lib/signing-stargate-client-factory/signing-stargate-client.factory.ts(1 hunks)apps/api/src/billing/lib/sync-signing-stargate-client/sync-signing-stargate-client.ts(0 hunks)apps/api/src/billing/providers/signing-client.provider.ts(4 hunks)apps/api/src/billing/services/dedupe-signing-client/dedupe-signing-client.service.ts(2 hunks)
💤 Files with no reviewable changes (1)
- apps/api/src/billing/lib/sync-signing-stargate-client/sync-signing-stargate-client.ts
🧰 Additional context used
📓 Path-based instructions (3)
**/*.spec.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/no-jest-mock.mdc)
Don't use
jest.mock()to mock dependencies in test files. Instead, usejest-mock-extendedto create mocks and pass mocks as dependencies to the service under test.
**/*.spec.{ts,tsx}: Usesetupfunction instead ofbeforeEachin test files
setupfunction must be at the bottom of the rootdescribeblock in test files
setupfunction creates an object under test and returns it
setupfunction should accept a single parameter with inline type definition
Don't use shared state insetupfunction
Don't specify return type ofsetupfunction
Files:
apps/api/src/billing/lib/signing-stargate-client-factory/signing-stargate-client.factory.spec.tsapps/api/src/billing/lib/batch-signing-client/batch-signing-client.service.spec.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/general.mdc)
Never use type any or cast to type any. Always define the proper TypeScript types.
Files:
apps/api/src/billing/lib/signing-stargate-client-factory/signing-stargate-client.factory.spec.tsapps/api/src/billing/services/dedupe-signing-client/dedupe-signing-client.service.tsapps/api/src/billing/providers/signing-client.provider.tsapps/api/src/billing/lib/batch-signing-client/batch-signing-client.service.tsapps/api/src/billing/lib/signing-stargate-client-factory/signing-stargate-client.factory.tsapps/api/src/billing/lib/batch-signing-client/batch-signing-client.service.spec.ts
**/*.{js,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/general.mdc)
**/*.{js,ts,tsx}: Never use deprecated methods from libraries.
Don't add unnecessary comments to the code
Files:
apps/api/src/billing/lib/signing-stargate-client-factory/signing-stargate-client.factory.spec.tsapps/api/src/billing/services/dedupe-signing-client/dedupe-signing-client.service.tsapps/api/src/billing/providers/signing-client.provider.tsapps/api/src/billing/lib/batch-signing-client/batch-signing-client.service.tsapps/api/src/billing/lib/signing-stargate-client-factory/signing-stargate-client.factory.tsapps/api/src/billing/lib/batch-signing-client/batch-signing-client.service.spec.ts
🧠 Learnings (2)
📚 Learning: 2025-07-21T08:25:07.474Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-07-21T08:25:07.474Z
Learning: Applies to **/*.spec.{ts,tsx} : `setup` function creates an object under test and returns it
Applied to files:
apps/api/src/billing/lib/signing-stargate-client-factory/signing-stargate-client.factory.spec.ts
📚 Learning: 2025-08-21T04:03:23.490Z
Learnt from: stalniy
Repo: akash-network/console PR: 1827
File: apps/api/src/console.ts:146-154
Timestamp: 2025-08-21T04:03:23.490Z
Learning: In the Akash Network console project, services like JobQueueService implement dispose() methods for resource cleanup, and the tsyringe container has been extended with a dispose() method that iterates over all registered instances and calls their dispose() methods, enabling proper shutdown orchestration.
Applied to files:
apps/api/src/billing/providers/signing-client.provider.ts
🧬 Code graph analysis (5)
apps/api/src/billing/lib/signing-stargate-client-factory/signing-stargate-client.factory.spec.ts (2)
apps/api/src/billing/lib/wallet/wallet.ts (1)
Wallet(7-65)apps/api/src/billing/lib/signing-stargate-client-factory/signing-stargate-client.factory.ts (1)
createSigningStargateClientFactory(37-52)
apps/api/src/billing/services/dedupe-signing-client/dedupe-signing-client.service.ts (1)
apps/api/src/billing/lib/signing-stargate-client-factory/signing-stargate-client.factory.ts (1)
createSigningStargateClient(60-64)
apps/api/src/billing/providers/signing-client.provider.ts (1)
apps/api/src/billing/lib/signing-stargate-client-factory/signing-stargate-client.factory.ts (1)
createSigningStargateClient(60-64)
apps/api/src/billing/lib/batch-signing-client/batch-signing-client.service.ts (1)
apps/api/src/billing/lib/signing-stargate-client-factory/signing-stargate-client.factory.ts (1)
CreateSigningStargateClient(23-23)
apps/api/src/billing/lib/signing-stargate-client-factory/signing-stargate-client.factory.ts (1)
apps/api/src/billing/lib/wallet/wallet.ts (1)
Wallet(7-65)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: validate / validate-app
- GitHub Check: test-build
apps/api/src/billing/lib/signing-stargate-client-factory/signing-stargate-client.factory.ts
Show resolved
Hide resolved
apps/api/src/billing/lib/signing-stargate-client-factory/signing-stargate-client.factory.ts
Show resolved
Hide resolved
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2152 +/- ##
==========================================
- Coverage 46.83% 46.48% -0.36%
==========================================
Files 1015 1005 -10
Lines 28734 28385 -349
Branches 7442 7419 -23
==========================================
- Hits 13458 13195 -263
- Misses 14882 14885 +3
+ Partials 394 305 -89
*This pull request uses carry forward flags. Click here to find out more.
🚀 New features to boost your workflow:
|
6f8a15d to
d7f019c
Compare
Summary by CodeRabbit