Skip to content

Commit ddde72b

Browse files
Merge pull request #5201 from BitGo/COIN-1957_send_many_error_message
refactor(wp): send many uniform error messages changes
2 parents 3f03f0c + fd59b8f commit ddde72b

File tree

20 files changed

+60
-22
lines changed

20 files changed

+60
-22
lines changed

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
/modules/sdk-coin-atom/ @BitGo/ethalt-team
5353
/modules/sdk-coin-avaxc/ @BitGo/ethalt-team
5454
/modules/sdk-coin-avaxp/ @BitGo/ethalt-team
55+
/modules/sdk-coin-bera/ @BitGo/ethalt-team
5556
/modules/sdk-coin-bsc/ @BitGo/ethalt-team
5657
/modules/sdk-coin-coredao/ @BitGo/ethalt-team
5758
/modules/sdk-coin-cspr/ @BitGo/ethalt-team

modules/abstract-eth/src/abstractEthLikeNewCoins.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2285,8 +2285,10 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
22852285
if (txParams.hop && txParams.recipients.length > 1) {
22862286
throw new Error(`tx cannot be both a batch and hop transaction`);
22872287
}
2288-
if (txPrebuild.recipients.length !== 1) {
2289-
throw new Error(`txPrebuild should only have 1 recipient but ${txPrebuild.recipients.length} found`);
2288+
if (txPrebuild.recipients.length > 1) {
2289+
throw new Error(
2290+
`${this.getChain()} doesn't support sending to more than 1 destination address within a single transaction. Try again, using only a single recipient.`
2291+
);
22902292
}
22912293
if (txParams.hop && txPrebuild.hopTransaction) {
22922294
// Check recipient amount for hop transaction

modules/abstract-eth/test/unit/coin.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,9 @@ export function runTransactionVerificationTests(coinName: string, bitgo: TestBit
348348

349349
await basecoin
350350
.verifyTransaction({ txParams, txPrebuild, wallet, verification })
351-
.should.be.rejectedWith('txPrebuild should only have 1 recipient but 2 found');
351+
.should.be.rejectedWith(
352+
`${coinTest} doesn't support sending to more than 1 destination address within a single transaction. Try again, using only a single recipient.`
353+
);
352354
});
353355

354356
it('should reject a hop txPrebuild that does not send to its hop address', async () => {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,9 @@ describe('Arbitrum', function () {
402402

403403
await basecoin
404404
.verifyTransaction({ txParams, txPrebuild, wallet, verification })
405-
.should.be.rejectedWith('txPrebuild should only have 1 recipient but 2 found');
405+
.should.be.rejectedWith(
406+
`tarbeth doesn't support sending to more than 1 destination address within a single transaction. Try again, using only a single recipient.`
407+
);
406408
});
407409

408410
it('should reject a hop txPrebuild that does not send to its hop address', async function () {

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,10 @@ export class AvaxC extends AbstractEthLikeNewCoins {
170170
if (txParams.hop && txParams.recipients.length > 1) {
171171
throw new Error(`tx cannot be both a batch and hop transaction`);
172172
}
173-
if (txPrebuild.recipients.length !== 1) {
174-
throw new Error(`txPrebuild should only have 1 recipient but ${txPrebuild.recipients.length} found`);
173+
if (txPrebuild.recipients.length > 1) {
174+
throw new Error(
175+
`${this.getChain()} doesn't support sending to more than 1 destination address within a single transaction. Try again, using only a single recipient.`
176+
);
175177
}
176178
if (txParams.hop && txPrebuild.hopTransaction) {
177179
// Check recipient amount for hop transaction

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,9 @@ describe('Avalanche C-Chain', function () {
610610

611611
await tavaxCoin
612612
.verifyTransaction({ txParams, txPrebuild, wallet, verification })
613-
.should.be.rejectedWith('txPrebuild should only have 1 recipient but 2 found');
613+
.should.be.rejectedWith(
614+
`tavaxc doesn't support sending to more than 1 destination address within a single transaction. Try again, using only a single recipient.`
615+
);
614616
});
615617

616618
it('should reject a hop txPrebuild that does not send to its hop address', async function () {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,9 @@ describe('Bera', function () {
302302

303303
await basecoin
304304
.verifyTransaction({ txParams, txPrebuild, wallet, verification })
305-
.should.be.rejectedWith('txPrebuild should only have 1 recipient but 2 found');
305+
.should.be.rejectedWith(
306+
`tbera doesn't support sending to more than 1 destination address within a single transaction. Try again, using only a single recipient.`
307+
);
306308
});
307309

308310
it('should reject a normal txPrebuild from the bitgo server with the wrong amount', async function () {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ export class Celo extends AbstractEthLikeCoin {
3232
async verifyTransaction(params: VerifyTransactionOptions): Promise<boolean> {
3333
const { txParams } = params;
3434
if (Array.isArray(txParams.recipients) && txParams.recipients.length > 1) {
35-
throw new Error(`txParams should only have 1 recipient but ${txParams?.recipients?.length} found`);
35+
throw new Error(
36+
`${this.getChain()} doesn't support sending to more than 1 destination address within a single transaction. Try again, using only a single recipient.`
37+
);
3638
}
3739
return true;
3840
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ describe('Celo Gold', function () {
4040

4141
await basecoin
4242
.verifyTransaction({ txParams })
43-
.should.be.rejectedWith('txParams should only have 1 recipient but 2 found');
43+
.should.be.rejectedWith(
44+
`celo doesn't support sending to more than 1 destination address within a single transaction. Try again, using only a single recipient.`
45+
);
4446
});
4547
});
4648
});

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,9 @@ export class Dot extends BaseCoin {
641641
async verifyTransaction(params: VerifyTransactionOptions): Promise<boolean> {
642642
const { txParams } = params;
643643
if (Array.isArray(txParams.recipients) && txParams.recipients.length > 1) {
644-
throw new Error(`txParams should only have 1 recipient but ${txParams?.recipients?.length} found`);
644+
throw new Error(
645+
`${this.getChain()} doesn't support sending to more than 1 destination address within a single transaction. Try again, using only a single recipient.`
646+
);
645647
}
646648
return true;
647649
}

0 commit comments

Comments
 (0)