Skip to content

Commit 04f2a6c

Browse files
committed
fix(sdk-coin-near): unit tests for tokenEnablementValidation
Unit tests for tokenEnablementValidation changes and Making sure there is 1 user in the txParams.recipients TICKET: WP-5782
1 parent 2a4e859 commit 04f2a6c

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
@@ -1119,8 +1119,21 @@ export class Near extends BaseCoin {
11191119
throw new Error('Error on token enablements: transaction has no outputs to validate beneficiary');
11201120
}
11211121

1122+
// NEAR token enablements only support a single recipient
1123+
if (!txParams.recipients || txParams.recipients.length === 0) {
1124+
throw new Error('Error on token enablements: missing recipients in transaction parameters');
1125+
}
1126+
1127+
if (txParams.recipients.length !== 1) {
1128+
throw new Error('Error on token enablements: token enablement only supports a single recipient');
1129+
}
1130+
1131+
if (explainedTx.outputs.length !== 1) {
1132+
throw new Error('Error on token enablements: transaction must have exactly 1 output');
1133+
}
1134+
11221135
const output = explainedTx.outputs[0];
1123-
const recipient = txParams.recipients?.[0];
1136+
const recipient = txParams.recipients[0];
11241137

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

0 commit comments

Comments
 (0)