Skip to content

Commit fee8b8b

Browse files
feat(sdk-api): add isTestTransaction support
for withdrawals Add isTestTransaction parameter support for wallet transactions: - Add isTestTransaction to PrebuildTransactionOptions interface (available for both TSS and multisig wallets) - Pass isTestTransaction through prebuildTransactionTxRequests for TSS transfer transactions - Include isTestTransaction in PopulatedIntent and baseIntent objects for TSS wallet flow - SendManyOptions inherits isTestTransaction via PrebuildAndSignTransactionOptions Add comprehensive test coverage: - Test isTestTransaction is passed through prebuildTransaction for TSS wallets - Test isTestTransaction flows through sendMany to prebuildAndSignTransaction - Add proper TypeScript assertions with existence checks This ensures the isTestTransaction flag is correctly sent to the /api/v2/wallet/:walletId/txrequests endpoint for TSS wallets (e.g., NEAR) and is available for multisig wallets when building transfer transactions via prebuildTransaction() or sendMany(). TICKET: CS-6399
1 parent 4e3cdad commit fee8b8b

File tree

6 files changed

+79
-0
lines changed

6 files changed

+79
-0
lines changed

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

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2362,6 +2362,50 @@ 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+
should.exist(callArgs.recipients);
2390+
callArgs.recipients!.should.deepEqual(recipients);
2391+
2392+
txPrebuild.should.deepEqual({
2393+
walletId: tssSolWallet.id(),
2394+
wallet: tssSolWallet,
2395+
txRequestId: 'id',
2396+
txHex: 'ababcdcd',
2397+
buildParams: {
2398+
recipients,
2399+
type: 'transfer',
2400+
isTestTransaction: true,
2401+
},
2402+
feeInfo: {
2403+
fee: 5000,
2404+
feeString: '5000',
2405+
},
2406+
});
2407+
});
2408+
23652409
it('should build an enable token transaction', async function () {
23662410
const recipients = [];
23672411
const tokenName = 'tcoin:tokenName';
@@ -3909,6 +3953,35 @@ describe('V2 Wallet:', function () {
39093953
setRequestTracerSpy.restore();
39103954
});
39113955

3956+
it('should pass isTestTransaction through sendMany to prebuildAndSignTransaction', async function () {
3957+
const signedTransaction = {
3958+
txRequestId: 'txRequestId',
3959+
};
3960+
3961+
const sendManyInputWithTestFlag = {
3962+
...sendManyInput,
3963+
type: 'transfer',
3964+
isTestTransaction: true,
3965+
};
3966+
3967+
const prebuildAndSignTransaction = sandbox.stub(tssSolWallet, 'prebuildAndSignTransaction');
3968+
prebuildAndSignTransaction.resolves(signedTransaction);
3969+
3970+
const sendTxRequest = sandbox.stub(TssUtils.prototype, 'sendTxRequest');
3971+
sendTxRequest.resolves('sendTxResponse');
3972+
3973+
const sendMany = await tssSolWallet.sendMany(sendManyInputWithTestFlag);
3974+
3975+
// Verify prebuildAndSignTransaction was called with isTestTransaction
3976+
sinon.assert.calledOnce(prebuildAndSignTransaction);
3977+
const callArgs = prebuildAndSignTransaction.getCall(0).args[0];
3978+
should.exist(callArgs);
3979+
callArgs!.should.have.property('isTestTransaction', true);
3980+
callArgs!.should.have.property('type', 'transfer');
3981+
3982+
sendMany.should.deepEqual('sendTxResponse');
3983+
});
3984+
39123985
it('should return transfer from sendMany for apiVersion=full', async function () {
39133986
const wallet = new Wallet(bitgo, tsol, {
39143987
...walletData,

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/BuildParams.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ export const BuildParams = t.exact(
116116
solVersionedTransactionData: t.unknown,
117117
// Aptos custom transaction parameters for smart contract calls
118118
aptosCustomTransactionParams: t.unknown,
119+
isTestTransaction: t.unknown,
119120
}),
120121
])
121122
);

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)