Skip to content

Commit add31ba

Browse files
authored
Merge pull request #7634 from BitGo/revert-7545-WIN-7596
Revert "feat(sdk-coin-dot): add verify transaction function"
2 parents 2959566 + 023aef4 commit add31ba

File tree

2 files changed

+2
-92
lines changed

2 files changed

+2
-92
lines changed

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

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -651,45 +651,12 @@ export class Dot extends BaseCoin {
651651
}
652652

653653
async verifyTransaction(params: VerifyTransactionOptions): Promise<boolean> {
654-
const { txPrebuild, txParams } = params;
655-
if (!txParams) {
656-
throw new Error('missing txParams');
657-
}
658-
659-
if (!txPrebuild) {
660-
throw new Error('missing txPrebuild');
661-
}
662-
663-
if (!txPrebuild.txHex) {
664-
throw new Error('missing txHex in txPrebuild');
665-
}
666-
667-
if (!txParams.recipients || txParams.recipients.length === 0) {
668-
throw new Error('missing recipients in txParams');
669-
}
670-
671-
const factory = this.getBuilder();
672-
const txBuilder = factory.from(txPrebuild.txHex) as any;
673-
654+
const { txParams } = params;
674655
if (Array.isArray(txParams.recipients) && txParams.recipients.length > 1) {
675656
throw new Error(
676657
`${this.getChain()} doesn't support sending to more than 1 destination address within a single transaction. Try again, using only a single recipient.`
677658
);
678659
}
679-
680-
// validate recipient is same as txBuilder._to
681-
if (txParams.recipients[0].address !== txBuilder._to) {
682-
throw new Error(
683-
`Recipient address ${txParams.recipients[0].address} does not match transaction destination address ${txBuilder._to}`
684-
);
685-
}
686-
687-
// and amount is same as txBuilder._amount
688-
if (txParams.recipients[0].amount !== txBuilder._amount) {
689-
throw new Error(
690-
`Recipient amount ${txParams.recipients[0].amount} does not match transaction amount ${txBuilder._amount}`
691-
);
692-
}
693660
return true;
694661
}
695662

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

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -664,69 +664,12 @@ describe('DOT:', function () {
664664
walletPassphrase: 'fakeWalletPassphrase',
665665
};
666666

667-
const txPrebuild = {
668-
txHex:
669-
'0xa80a0300161b969b6b53ef81225feea3882284c778cd4a406d23215fcf492e83f75d42960b00204aa9d101eb600400000065900f001000000067f9723393ef76214df0118c34bbbd3dbebc8ed46a10973a8c969d48fe7598c9a7b7420ee3e4fe2b88da0fc42b30897e18d56d8b56a1934211d9de730cf96de300',
670-
};
671-
672667
await basecoin
673-
.verifyTransaction({ txPrebuild, txParams })
668+
.verifyTransaction({ txParams })
674669
.should.be.rejectedWith(
675670
`tdot doesn't support sending to more than 1 destination address within a single transaction. Try again, using only a single recipient.`
676671
);
677672
});
678-
679-
it('should reject a txPrebuild with more than invalid amount', async function () {
680-
const wallet = new Wallet(bitgo, basecoin, {});
681-
const txParams = {
682-
recipients: [{ amount: '20000000000', address: '5CZh773vKGwKFCYUjGc31AwXCbf7TPkavdeuk2XoujJMjbBD' }],
683-
wallet: wallet,
684-
walletPassphrase: 'fakeWalletPassphrase',
685-
};
686-
const txPrebuild = {
687-
txHex:
688-
'0xa80a0300161b969b6b53ef81225feea3882284c778cd4a406d23215fcf492e83f75d42960b00204aa9d101eb600400000065900f001000000067f9723393ef76214df0118c34bbbd3dbebc8ed46a10973a8c969d48fe7598c9a7b7420ee3e4fe2b88da0fc42b30897e18d56d8b56a1934211d9de730cf96de300',
689-
};
690-
691-
await basecoin
692-
.verifyTransaction({ txPrebuild, txParams })
693-
.should.be.rejectedWith(`Recipient amount 20000000000 does not match transaction amount 2000000000000`);
694-
});
695-
696-
it('should reject a txPrebuild with more than invalid recipient', async function () {
697-
const wallet = new Wallet(bitgo, basecoin, {});
698-
const txParams = {
699-
recipients: [{ amount: '2000000000000', address: '5CZh773vKGwKFCUjGc31AwXCbf7TPkavduk2XoujJMjbBD' }],
700-
wallet: wallet,
701-
walletPassphrase: 'fakeWalletPassphrase',
702-
};
703-
const txPrebuild = {
704-
txHex:
705-
'0xa80a0300161b969b6b53ef81225feea3882284c778cd4a406d23215fcf492e83f75d42960b00204aa9d101eb600400000065900f001000000067f9723393ef76214df0118c34bbbd3dbebc8ed46a10973a8c969d48fe7598c9a7b7420ee3e4fe2b88da0fc42b30897e18d56d8b56a1934211d9de730cf96de300',
706-
};
707-
708-
await basecoin
709-
.verifyTransaction({ txPrebuild, txParams })
710-
.should.be.rejectedWith(
711-
`Recipient address 5CZh773vKGwKFCUjGc31AwXCbf7TPkavduk2XoujJMjbBD does not match transaction destination address 5CZh773vKGwKFCYUjGc31AwXCbf7TPkavdeuk2XoujJMjbBD`
712-
);
713-
});
714-
715-
it('should accept a txPrebuild with more than valid recipient and amount', async function () {
716-
const wallet = new Wallet(bitgo, basecoin, {});
717-
const txParams = {
718-
recipients: [{ amount: '2000000000000', address: '5CZh773vKGwKFCYUjGc31AwXCbf7TPkavdeuk2XoujJMjbBD' }],
719-
wallet: wallet,
720-
walletPassphrase: 'fakeWalletPassphrase',
721-
};
722-
const txPrebuild = {
723-
txHex:
724-
'0xa80a0300161b969b6b53ef81225feea3882284c778cd4a406d23215fcf492e83f75d42960b00204aa9d101eb600400000065900f001000000067f9723393ef76214df0118c34bbbd3dbebc8ed46a10973a8c969d48fe7598c9a7b7420ee3e4fe2b88da0fc42b30897e18d56d8b56a1934211d9de730cf96de300',
725-
};
726-
727-
const result = await basecoin.verifyTransaction({ txPrebuild, txParams });
728-
assert.strictEqual(result, true);
729-
});
730673
});
731674

732675
describe('isWalletAddress', () => {

0 commit comments

Comments
 (0)