Skip to content

Commit 16edade

Browse files
committed
fix(sdk-coin-ada): allowing fee address for sponsored tokens
Ticket: CSHLD-651
1 parent ac455f0 commit 16edade

2 files changed

Lines changed: 35 additions & 3 deletions

File tree

modules/sdk-coin-ada/src/adaToken.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Ada } from './ada';
1+
import { Ada, AdaTxInfo } from './ada';
22
import {
33
BitGoBase,
44
CoinConstructor,
@@ -145,11 +145,12 @@ export class AdaToken extends Ada {
145145
}
146146
}
147147
} else if (verification?.consolidationToBaseAddress) {
148-
// For token consolidation, verify all outputs go to the base address
148+
// For token consolidation, verify all outputs go to the base address or fee address (sponsored consolidations)
149149
const baseAddress = wallet?.coinSpecific()?.baseAddress || wallet?.coinSpecific()?.rootAddress;
150+
const feeAddress = (txPrebuild.txInfo as AdaTxInfo)?.feeAddress;
150151

151152
for (const output of txJson.outputs) {
152-
if (output.address !== baseAddress) {
153+
if (output.address !== baseAddress && output.address !== feeAddress) {
153154
throw new Error('tx outputs does not match with expected address');
154155
}
155156
}

modules/sdk-coin-ada/test/unit/ada.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,6 +1519,37 @@ describe('ADA', function () {
15191519
});
15201520

15211521
describe('Verify token consolidation transaction:', () => {
1522+
it('should verify a sponsored token consolidation when fee address output is present', async () => {
1523+
// This transaction has two outputs:
1524+
// 1. rootAddress — main consolidation output
1525+
// 2. feeAddress — ADA change returned to the fee sponsor
1526+
// Both must be permitted by verifyTransaction when consolidationToBaseAddress is true.
1527+
const consolidationTx = {
1528+
txRequestId: '1b5c79c5-ab7c-4f47-912b-de6a95fb0779',
1529+
walletId: '64fa31a94db65a0007c9691b',
1530+
txHex:
1531+
'84a40082825820227f65d20ac6e49602d79c623c51911ead824235e01eb2a1e7e33a72f0747cbb00825820227f65d20ac6e49602d79c623c51911ead824235e01eb2a1e7e33a72f0747cbb0201828258390022098270a5c19c9fb706dce0e7e4566b234ec5f0010623cd63f198ad22098270a5c19c9fb706dce0e7e4566b234ec5f0010623cd63f198ad1a0098968082581d60cf90f9fb02c88bad3c5294d90587458c4f160a2db26ba8af3da255b11a05d42fb8021a0002a491031a06d8c048a0f5f6',
1532+
txInfo: {
1533+
feeAddress: 'addr_test1vr8ep70mqtyghtfu222djpv8gkxy79s29kexh2908k39tvge02d5j',
1534+
},
1535+
};
1536+
1537+
const mockedWallet = {
1538+
coinSpecific: () => ({
1539+
rootAddress:
1540+
'addr_test1qq3qnqns5hqee8ahqmwwpely2e4jxnk97qqsvg7dv0ce3tfzpxp8pfwpnj0mwpkuurn7g4ntyd8vtuqpqc3u6cl3nzksvggu82',
1541+
}),
1542+
};
1543+
1544+
const isVerified = await basecoin.verifyTransaction({
1545+
txParams: {},
1546+
txPrebuild: consolidationTx,
1547+
wallet: mockedWallet,
1548+
verification: { consolidationToBaseAddress: true },
1549+
});
1550+
isVerified.should.equal(true);
1551+
});
1552+
15221553
it('should fail to verify a spoofed token consolidation transaction with incorrect address', async () => {
15231554
const consolidationTx = {
15241555
txRequestId: '4fdd0cae-2563-43b1-b5cf-94865158ca10',

0 commit comments

Comments
 (0)