Skip to content

Commit

Permalink
Merge pull request #4192 from BitGo/CE-3397-Add-pendingApprovalId-in-…
Browse files Browse the repository at this point in the history
…prebuildTransactionTss-response

fix: add pendingApprovaId in prebuildTxTss response
  • Loading branch information
ayush-9 authored Jan 11, 2024
2 parents c02cdbd + 049466b commit cb0b46a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
44 changes: 43 additions & 1 deletion modules/bitgo/test/v2/unit/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2129,7 +2129,10 @@ describe('V2 Wallet:', function () {

let tssEthWallet = new Wallet(bitgo, bitgo.coin('teth'), ethWalletData);
const tssPolygonWallet = new Wallet(bitgo, bitgo.coin('tpolygon'), polygonWalletData);
const custodialTssSolWallet = new Wallet(bitgo, tsol, { ...walletData, type: 'custodial' });
const custodialTssSolWallet = new Wallet(bitgo, tsol, {
...walletData,
type: 'custodial',
});

const txRequest: TxRequest = {
txRequestId: 'id',
Expand Down Expand Up @@ -2294,6 +2297,45 @@ describe('V2 Wallet:', function () {
});
});

it('should build a single recipient transfer with pending approval id if transaction is having one', async function () {
const recipients = [
{
address: '6DadkZcx9JZgeQUDbHh12cmqCpaqehmVxv6sGy49jrah',
amount: '1000',
},
];

const prebuildTxWithIntent = sandbox.stub(TssUtils.prototype, 'prebuildTxWithIntent');
prebuildTxWithIntent.resolves({ ...txRequest, state: 'pendingApproval', pendingApprovalId: 'some-id' });
prebuildTxWithIntent.calledOnceWithExactly({
reqId,
recipients,
intentType: 'payment',
});

const txPrebuild = await custodialTssSolWallet.prebuildTransaction({
reqId,
recipients,
type: 'transfer',
});

txPrebuild.should.deepEqual({
walletId: custodialTssSolWallet.id(),
wallet: custodialTssSolWallet,
txRequestId: 'id',
txHex: 'ababcdcd',
pendingApprovalId: 'some-id',
buildParams: {
recipients,
type: 'transfer',
},
feeInfo: {
fee: 5000,
feeString: '5000',
},
});
});

it('should build a multiple recipient transfer transaction with memo', async function () {
const recipients = [
{
Expand Down
1 change: 1 addition & 0 deletions modules/sdk-core/src/bitgo/wallet/iWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export interface PrebuildTransactionResult extends TransactionPrebuild {
fee?: number;
feeString?: string;
};
pendingApprovalId?: string;
}

export interface CustomSigningFunction {
Expand Down
1 change: 1 addition & 0 deletions modules/sdk-core/src/bitgo/wallet/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3016,6 +3016,7 @@ export class Wallet implements IWallet {
txHex: unsignedTx.serializedTxHex,
buildParams: whitelistedParams,
feeInfo: unsignedTx.feeInfo,
...(txRequest.pendingApprovalId && { pendingApprovalId: txRequest.pendingApprovalId }),
};
}

Expand Down

0 comments on commit cb0b46a

Please sign in to comment.