Skip to content

Commit b72f323

Browse files
committed
fix(sdk-coin-dot): same recipient validation as fixed ticket
Ticket: WP-5728
1 parent 9bf90a5 commit b72f323

File tree

1 file changed

+29
-27
lines changed
  • modules/sdk-coin-dot/src

1 file changed

+29
-27
lines changed

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

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -693,36 +693,38 @@ export class Dot extends BaseCoin {
693693
return true;
694694
}
695695

696-
if (!txParams.recipients || txParams.recipients.length === 0) {
697-
throw new Error('missing recipients in txParams');
698-
}
696+
if (txParams.recipients !== undefined) {
697+
if (txParams.recipients.length === 0) {
698+
throw new Error('missing recipients in txParams');
699+
}
699700

700-
if (Array.isArray(txParams.recipients) && txParams.recipients.length > 1) {
701-
throw new Error(
702-
`${this.getChain()} doesn't support sending to more than 1 destination address within a single transaction. Try again, using only a single recipient.`
703-
);
704-
}
701+
if (Array.isArray(txParams.recipients) && txParams.recipients.length > 1) {
702+
throw new Error(
703+
`${this.getChain()} doesn't support sending to more than 1 destination address within a single transaction. Try again, using only a single recipient.`
704+
);
705+
}
705706

706-
// validate recipient is same as txBuilder['_to']
707-
if (txParams.recipients[0].address !== txBuilder['_to']) {
708-
throw new TxIntentMismatchRecipientError(
709-
`Recipient address ${txParams.recipients[0].address} does not match transaction destination address ${txBuilder['_to']}`,
710-
reqId,
711-
[txParams],
712-
txPrebuild.txHex,
713-
[{ address: txBuilder['_to'], amount: txBuilder['_amount'] }]
714-
);
715-
}
707+
// validate recipient is same as txBuilder['_to']
708+
if (txParams.recipients[0].address !== txBuilder['_to']) {
709+
throw new TxIntentMismatchRecipientError(
710+
`Recipient address ${txParams.recipients[0].address} does not match transaction destination address ${txBuilder['_to']}`,
711+
reqId,
712+
[txParams],
713+
txPrebuild.txHex,
714+
[{ address: txBuilder['_to'], amount: txBuilder['_amount'] }]
715+
);
716+
}
716717

717-
// validate amount is same as txBuilder['_amount']
718-
if (txParams.recipients[0].amount !== txBuilder['_amount']) {
719-
throw new TxIntentMismatchRecipientError(
720-
`Recipient amount ${txParams.recipients[0].amount} does not match transaction amount ${txBuilder['_amount']}`,
721-
reqId,
722-
[txParams],
723-
txPrebuild.txHex,
724-
[{ address: txBuilder['_to'], amount: txBuilder['_amount'] }]
725-
);
718+
// validate amount is same as txBuilder['_amount']
719+
if (txParams.recipients[0].amount !== txBuilder['_amount']) {
720+
throw new TxIntentMismatchRecipientError(
721+
`Recipient amount ${txParams.recipients[0].amount} does not match transaction amount ${txBuilder['_amount']}`,
722+
reqId,
723+
[txParams],
724+
txPrebuild.txHex,
725+
[{ address: txBuilder['_to'], amount: txBuilder['_amount'] }]
726+
);
727+
}
726728
}
727729
return true;
728730
}

0 commit comments

Comments
 (0)