Skip to content

Commit 58321c0

Browse files
committed
feat(sdk-coin-stx): added check for multiple reciepents
TICKET: COIN-1959
1 parent e58ad50 commit 58321c0

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ export class Stx extends BaseCoin {
4646
}
4747

4848
async verifyTransaction(params: VerifyTransactionOptions): Promise<boolean> {
49-
// TODO: Implement when available on the SDK.
49+
const { txParams } = params;
50+
if (txParams?.recipients?.length !== 1) {
51+
throw new Error(`txParams should only have 1 recipient but ${txParams?.recipients?.length} found`);
52+
}
5053
return true;
5154
}
5255

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { coins } from '@bitgo/statics';
44
import * as testData from '../fixtures';
55
import { Stx, Tstx, StxLib } from '../../src';
66
import assert from 'assert';
7+
import { Wallet } from '@bitgo/sdk-core';
78

89
const { KeyPair } = StxLib;
910

@@ -284,4 +285,25 @@ describe('STX:', function () {
284285
bufferTx.should.be.deepEqual(Buffer.from(testData.unsignedTxForExplainTransfer));
285286
});
286287
});
288+
289+
describe('Verify Transaction', function () {
290+
const address1 = '0x174cfd823af8ce27ed0afee3fcf3c3ba259116be';
291+
const address2 = '0x7e85bdc27c050e3905ebf4b8e634d9ad6edd0de6';
292+
it('should reject a txPrebuild with more than one recipient', async function () {
293+
const wallet = new Wallet(bitgo, basecoin, {});
294+
295+
const txParams = {
296+
recipients: [
297+
{ amount: '1000000000000', address: address1 },
298+
{ amount: '2500000000000', address: address2 },
299+
],
300+
wallet: wallet,
301+
walletPassphrase: 'fakeWalletPassphrase',
302+
};
303+
304+
await basecoin
305+
.verifyTransaction({ txParams })
306+
.should.be.rejectedWith('txParams should only have 1 recipient but 2 found');
307+
});
308+
});
287309
});

0 commit comments

Comments
 (0)