Skip to content

Commit b52c7b8

Browse files
feat(wallet): pass isTestTransaction parameter to TSS transfer txrequests API
- Add isTestTransaction parameter to PrebuildTransactionOptions interface - Pass isTestTransaction through prebuildTransactionTxRequests for transfer transactions - Include isTestTransaction in PopulatedIntent and baseIntent objects - Add unit test to verify isTestTransaction is properly passed through the call chain This ensures the isTestTransaction flag is correctly sent to the /api/v2/wallet/:walletId/txrequests endpoint for TSS wallets (e.g., NEAR) when building transfer transactions. TICKET: CS-6339
1 parent 4e3cdad commit b52c7b8

File tree

5 files changed

+48
-0
lines changed

5 files changed

+48
-0
lines changed

modules/bitgo/test/v2/unit/wallet.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2362,6 +2362,49 @@ describe('V2 Wallet:', function () {
23622362
});
23632363
});
23642364

2365+
it('should build a transfer transaction with isTestTransaction flag', async function () {
2366+
const recipients = [
2367+
{
2368+
address: '6DadkZcx9JZgeQUDbHh12cmqCpaqehmVxv6sGy49jrah',
2369+
amount: '1000',
2370+
},
2371+
];
2372+
2373+
const prebuildTxWithIntent = sandbox.stub(TssUtils.prototype, 'prebuildTxWithIntent');
2374+
prebuildTxWithIntent.resolves(txRequest);
2375+
2376+
const txPrebuild = await tssSolWallet.prebuildTransaction({
2377+
reqId,
2378+
recipients,
2379+
type: 'transfer',
2380+
isTestTransaction: true,
2381+
});
2382+
2383+
// Verify isTestTransaction is passed to prebuildTxWithIntent
2384+
sinon.assert.calledOnce(prebuildTxWithIntent);
2385+
const callArgs = prebuildTxWithIntent.getCall(0).args[0];
2386+
callArgs.should.have.property('isTestTransaction', true);
2387+
callArgs.should.have.property('intentType', 'payment');
2388+
callArgs.should.have.property('recipients');
2389+
callArgs.recipients.should.deepEqual(recipients);
2390+
2391+
txPrebuild.should.deepEqual({
2392+
walletId: tssSolWallet.id(),
2393+
wallet: tssSolWallet,
2394+
txRequestId: 'id',
2395+
txHex: 'ababcdcd',
2396+
buildParams: {
2397+
recipients,
2398+
type: 'transfer',
2399+
isTestTransaction: true,
2400+
},
2401+
feeInfo: {
2402+
fee: 5000,
2403+
feeString: '5000',
2404+
},
2405+
});
2406+
});
2407+
23652408
it('should build an enable token transaction', async function () {
23662409
const recipients = [];
23672410
const tokenName = 'tcoin:tokenName';

modules/sdk-core/src/bitgo/utils/mpcUtils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ export abstract class MpcUtils {
188188
nonce: params.nonce,
189189
recipients: intentRecipients,
190190
tokenName: params.tokenName,
191+
isTestTransaction: params.isTestTransaction,
191192
};
192193

193194
if (baseCoin.getFamily() === 'eth' || baseCoin.getFamily() === 'polygon' || baseCoin.getFamily() === 'bsc') {

modules/sdk-core/src/bitgo/utils/tss/baseTypes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ export interface PrebuildTransactionWithIntentOptions extends IntentOptionsBase
269269
abi?: any;
270270
};
271271
txRequestId?: string;
272+
isTestTransaction?: boolean;
272273
}
273274
export interface IntentRecipient {
274275
address: {
@@ -338,6 +339,7 @@ export interface PopulatedIntent extends PopulatedIntentBase {
338339
*/
339340
aptosCustomTransactionParams?: aptosCustomTransactionParams;
340341
txRequestId?: string;
342+
isTestTransaction?: boolean;
341343
}
342344

343345
export type TxRequestState =

modules/sdk-core/src/bitgo/wallet/iWallet.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ export interface PrebuildTransactionOptions {
217217
abi?: any;
218218
};
219219
txRequestId?: string;
220+
isTestTransaction?: boolean;
220221
}
221222

222223
export interface PrebuildAndSignTransactionOptions extends PrebuildTransactionOptions, WalletSignTransactionOptions {

modules/sdk-core/src/bitgo/wallet/wallet.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3434,6 +3434,7 @@ export class Wallet implements IWallet {
34343434
custodianTransactionId: params.custodianTransactionId,
34353435
unspents: params.unspents,
34363436
senderAddress: params.senderAddress,
3437+
isTestTransaction: params.isTestTransaction,
34373438
},
34383439
apiVersion,
34393440
params.preview

0 commit comments

Comments
 (0)