feat(sdk-core): bulk TRX resource delegation SDK + Express layer#8572
feat(sdk-core): bulk TRX resource delegation SDK + Express layer#8572bhavidhingra wants to merge 1 commit intomasterfrom
Conversation
496a288 to
5bc64a4
Compare
|
@claude review |
5bc64a4 to
42b5824
Compare
15b4e19 to
5019af4
Compare
|
Flush, please request re-review when ready for review. |
982359a to
b22a03a
Compare
pranavjain97
left a comment
There was a problem hiding this comment.
TSS detection uses coin-level check instead of wallet-level, receiverAddress never populated, and no tests included
| const params = coin.supportsTss() ? createTSSSendParams(req, wallet) : createSendParams(req); | ||
| result = | ||
| type === 'delegateResource' | ||
| ? await wallet.sendResourceDelegations(params) |
There was a problem hiding this comment.
existing handlers check wallet._wallet.multisigType === 'tss', not coin.supportsTss(). these can diverge, should use the wallet-level check
| // Surface unexpected errors as 400 rather than 500 | ||
| (err as any).status = 400; | ||
| throw err; | ||
| } |
There was a problem hiding this comment.
all other handlers assign err.status = 400 directly without a cast. use the same pattern
| message: t.string, | ||
| /** Receiver address that failed, if available */ | ||
| receiverAddress: t.union([t.string, t.undefined]), | ||
| }); |
There was a problem hiding this comment.
t.union([t.string, t.undefined]) doesn't decode an absent JSON key correctly, use optional(t.string) consistent with the other fields
| */ | ||
| async buildResourceDelegations( | ||
| params: BuildResourceDelegationTransactionOptions | ||
| ): Promise<PrebuildTransactionResult[]> { |
There was a problem hiding this comment.
receiverAddress is typed as available but never populated here. either populate it from unsignedBuild or remove the field from the types
|
|
||
| if (!Array.isArray(buildResponse.transactions)) { | ||
| throw new Error(`Unexpected response from ${endpoint}: missing transactions array`); | ||
| } |
There was a problem hiding this comment.
build errors are swallowed at debug level. if some entries failed to build, those failures won't appear in the final { success, failure } response. should these be surfaced?
| sendResourceDelegations(params: BuildResourceDelegationTransactionOptions): Promise<{ | ||
| success: any[]; | ||
| failure: { message: string; receiverAddress?: string }[]; | ||
| }>; |
There was a problem hiding this comment.
sendResourceDelegation and sendResourceUndelegation return Promise<any>, define a typed result interface
There was a problem hiding this comment.
defined ResourceManagementSendResult
| @@ -1096,6 +1117,18 @@ export interface IWallet { | |||
| buildAccountConsolidations(params?: BuildConsolidationTransactionOptions): Promise<PrebuildTransactionResult[]>; | |||
There was a problem hiding this comment.
is resource delegation going to be used by other coins, or is this TRX-specific? if it's only TRX, every other coin gets 6 dead methods. consider keeping these on the coin class or as standalone helpers instead of bloating the wallet interface
There was a problem hiding this comment.
keeping it as is - it follows the identical pattern of buildAccountConsolidations/sendAccountConsolidation with a supportsResourceDelegation() guard
8d953a5 to
bbb4f2e
Compare
8494bff to
cf7602d
Compare
| resolved "https://registry.npmjs.org/@cosmjs/utils/-/utils-0.33.1.tgz" | ||
| integrity sha512-UnLHDY6KMmC+UXf3Ufyh+onE19xzEXjT4VZ504Acmk4PXxqyvG4cCPprlKUFnGUX7f0z8Or9MAOHXBx41uHBcg== | ||
|
|
||
| "@csstools/postcss-cascade-layers@^1.1.1": |
There was a problem hiding this comment.
why does the lock file changes without any dependency changes?
There was a problem hiding this comment.
not sure, may be it was outdated.
Adds buildAccountDelegations, sendAccountDelegation, sendAccountDelegations to the Wallet class and IWallet interface, mirroring the consolidation API. Adds Express typed route schema and handler for POST /api/v2/:coin/wallet/:id/delegateResources with TSS/custodial/hot wallet branching and partial-success (202) response handling. CHALO-287 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
cf7602d to
b35de40
Compare
Summary
Resource Delegation
buildResourceDelegations,sendResourceDelegation,sendResourceDelegationstoWalletandIWalletbuildResourceDelegations: POSTs to/:coin/wallet/:id/delegateResources/build, post-processes prebuildssendResourceDelegation: dispatches per wallet type — TSS →sendManyTxRequests, custodial →initiateTransaction, hot →prebuildAndSignTransaction+submitTransactionsendResourceDelegations: validates passphrase, builds all, sends sequentially, collects{ success, failure }PostDelegateResources) andhandleV2DelegateResourceshandler with partial-success 202/400 response logicResource Undelegation
buildResourceUndelegations,sendResourceUndelegation,sendResourceUndelegationstoWalletandIWallet— mirrors delegation API exactlybuildResourceUndelegations: POSTs to/:coin/wallet/:id/undelegateResources/buildPostUndelegateResources) andhandleV2UndelegateResourceshandlerbuildResourceManagements,sendResourceManagement,sendResourceManagements) to eliminate code duplicationstakingParams relay
stakingParams?: unknowntoPrebuildTransactionResultso staking metadata flows from the build response through tosubmitTransaction, enabling the indexer to identify resource management transfers correctlyTest plan
buildResourceDelegations/buildResourceUndelegationscall the right endpoints and post-process prebuildssendResourceDelegation/sendResourceUndelegationroute correctly per wallet type/api/v2/ttrx/wallet/:id/delegateResourcesreturns 200/202/400 as appropriate/api/v2/ttrx/wallet/:id/undelegateResourcesreturns 200/202/400 as appropriateLinear: CHALO-287