Skip to content
Merged
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
5 changes: 4 additions & 1 deletion modules/sdk-coin-stx/src/stx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ export class Stx extends BaseCoin {
}

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

Expand Down
22 changes: 22 additions & 0 deletions modules/sdk-coin-stx/test/unit/stx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { coins } from '@bitgo/statics';
import * as testData from '../fixtures';
import { Stx, Tstx, StxLib } from '../../src';
import assert from 'assert';
import { Wallet } from '@bitgo/sdk-core';

const { KeyPair } = StxLib;

Expand Down Expand Up @@ -284,4 +285,25 @@ describe('STX:', function () {
bufferTx.should.be.deepEqual(Buffer.from(testData.unsignedTxForExplainTransfer));
});
});

describe('Verify Transaction', function () {
const address1 = '0x174cfd823af8ce27ed0afee3fcf3c3ba259116be';
const address2 = '0x7e85bdc27c050e3905ebf4b8e634d9ad6edd0de6';
it('should reject a txPrebuild with more than one recipient', async function () {
const wallet = new Wallet(bitgo, basecoin, {});

const txParams = {
recipients: [
{ amount: '1000000000000', address: address1 },
{ amount: '2500000000000', address: address2 },
],
wallet: wallet,
walletPassphrase: 'fakeWalletPassphrase',
};

await basecoin
.verifyTransaction({ txParams })
.should.be.rejectedWith('txParams should only have 1 recipient but 2 found');
});
});
});