Skip to content

Commit c323e7e

Browse files
committed
fix(sdk-coin-dot): throw error on sendmany API call when recipients greater than 1
TICKET: COIN-1958
1 parent 7648bd5 commit c323e7e

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

modules/sdk-coin-dot/src/dot.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,10 @@ export class Dot extends BaseCoin {
639639
}
640640

641641
async verifyTransaction(params: VerifyTransactionOptions): Promise<boolean> {
642+
const { txParams } = params;
643+
if (txParams?.recipients?.length !== 1) {
644+
throw new Error(`txParams should only have 1 recipient but ${txParams?.recipients?.length} found`);
645+
}
642646
return true;
643647
}
644648

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Dot, Tdot, KeyPair } from '../../src';
66
import * as testData from '../fixtures';
77
import { chainName, txVersion, genesisHash, specVersion } from '../resources';
88
import * as sinon from 'sinon';
9+
import { Wallet } from '@bitgo/sdk-core';
910

1011
describe('DOT:', function () {
1112
let bitgo: TestBitGoAPI;
@@ -646,4 +647,25 @@ describe('DOT:', function () {
646647
.should.rejectedWith('Did not find address with funds to recover');
647648
});
648649
});
650+
651+
describe('Verify Transaction', function () {
652+
const address1 = '5Ge59qRnZa8bxyhVFE6BDoY3kuhSrNVETRxXYLty1Hh6XTaf';
653+
const address2 = '5DiMLZugmcKEH3igPZP367FqummZkWeW5Z6zDCHLfxRjnPXe';
654+
it('should reject a txPrebuild with more than one recipient', async function () {
655+
const wallet = new Wallet(bitgo, basecoin, {});
656+
657+
const txParams = {
658+
recipients: [
659+
{ amount: '1000000000000', address: address1 },
660+
{ amount: '2500000000000', address: address2 },
661+
],
662+
wallet: wallet,
663+
walletPassphrase: 'fakeWalletPassphrase',
664+
};
665+
666+
await basecoin
667+
.verifyTransaction({ txParams })
668+
.should.be.rejectedWith('txParams should only have 1 recipient but 2 found');
669+
});
670+
});
649671
});

0 commit comments

Comments
 (0)