Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/sdk-coin-dot/src/dot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ export class Dot extends BaseCoin {
}

// validate amount is same as txBuilder['_amount']
if (txParams.recipients[0].amount !== txBuilder['_amount']) {
if (!txBuilder['_sweepFreeBalance'] && txParams.recipients[0].amount !== txBuilder['_amount']) {
throw new TxIntentMismatchRecipientError(
`Recipient amount ${txParams.recipients[0].amount} does not match transaction amount ${txBuilder['_amount']}`,
reqId,
Expand Down
52 changes: 52 additions & 0 deletions modules/sdk-coin-dot/test/unit/dot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,58 @@ describe('DOT:', function () {
'Transaction destination address 5CZh773vKGwKFCYUjGc31AwXCbf7TPkavdeuk2XoujJMjbBD does not match wallet base address 5DxD9nT16GQLrU6aB5pSS5VtxoZbVju3NHUCcawxZyZCTf74'
);
});

it('should verify a transferAll (sweep) transaction with empty txParams', async function () {
const mockedWallet = {
coinSpecific: () => ({
baseAddress: '5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq',
}),
};

// TransferAll tx (sweep) - uses method 0a04 (balances.transferAll)
const txPrebuild = {
txHex:
'0x900a04009f7b0675db59d19b4bd9c8c72eaabba75a9863d02b30115b8b3c3ca5c20f025401d50121030000009d880f001000000067f9723393ef76214df0118c34bbbd3dbebc8ed46a10973a8c969d48fe7598c9149799bc9602cb5cf201f3425fb8d253b2d4e61fc119dcab3249f307f594754d00',
};

const result = await basecoin.verifyTransaction({
txPrebuild,
txParams: {},
wallet: mockedWallet as any,
verification: {
consolidationToBaseAddress: true,
},
});
assert.strictEqual(result, true);
});

it('should verify a transferAll (sweep) transaction with recipients in txParams', async function () {
const mockedWallet = {
coinSpecific: () => ({
baseAddress: '5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq',
}),
};

// TransferAll tx (sweep) - _amount is undefined for these transactions
const txPrebuild = {
txHex:
'0x900a04009f7b0675db59d19b4bd9c8c72eaabba75a9863d02b30115b8b3c3ca5c20f025401d50121030000009d880f001000000067f9723393ef76214df0118c34bbbd3dbebc8ed46a10973a8c969d48fe7598c9149799bc9602cb5cf201f3425fb8d253b2d4e61fc119dcab3249f307f594754d00',
};

const txParams = {
recipients: [{ address: '5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq', amount: '1000000000000' }],
};

const result = await basecoin.verifyTransaction({
txPrebuild,
txParams,
wallet: mockedWallet as any,
verification: {
consolidationToBaseAddress: true,
},
});
assert.strictEqual(result, true);
});
});

describe('isWalletAddress', () => {
Expand Down