Skip to content

Commit cd5c743

Browse files
committed
fix(sdk-coin-near): unit tests
TICKET: WP-5782
1 parent 48ac3b8 commit cd5c743

File tree

2 files changed

+97
-148
lines changed

2 files changed

+97
-148
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,8 +1101,21 @@ export class Near extends BaseCoin {
11011101
throw new Error('Error on token enablements: transaction has no outputs to validate beneficiary');
11021102
}
11031103

1104+
// NEAR token enablements only support a single recipient
1105+
if (!txParams.recipients || txParams.recipients.length === 0) {
1106+
throw new Error('Error on token enablements: missing recipients in transaction parameters');
1107+
}
1108+
1109+
if (txParams.recipients.length !== 1) {
1110+
throw new Error('Error on token enablements: token enablement only supports a single recipient');
1111+
}
1112+
1113+
if (explainedTx.outputs.length !== 1) {
1114+
throw new Error('Error on token enablements: transaction must have exactly 1 output');
1115+
}
1116+
11041117
const output = explainedTx.outputs[0];
1105-
const recipient = txParams.recipients?.[0];
1118+
const recipient = txParams.recipients[0];
11061119

11071120
if (!recipient?.address) {
11081121
throw new Error('Error on token enablements: missing beneficiary address in transaction parameters');

0 commit comments

Comments
 (0)