Skip to content

Commit

Permalink
refactor(sdk-api): send many uniform error messages changes
Browse files Browse the repository at this point in the history
Ticket: WIN-3945
  • Loading branch information
krupanand-bitgo committed Dec 5, 2024
1 parent 986e2f1 commit 70ca339
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 10 deletions.
4 changes: 3 additions & 1 deletion modules/abstract-eth/src/abstractEthLikeNewCoins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2281,7 +2281,9 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
throw new Error(`tx cannot be both a batch and hop transaction`);
}
if (txPrebuild.recipients.length !== 1) {
throw new Error(`txPrebuild should only have 1 recipient but ${txPrebuild.recipients.length} found`);
throw new Error(
`${this.getChain()} doesn't support sending to more then 1 destination address within a single transaction. Try again, using only a single recipient.`
);
}
if (txParams.hop && txPrebuild.hopTransaction) {
// Check recipient amount for hop transaction
Expand Down
4 changes: 3 additions & 1 deletion modules/abstract-eth/test/unit/coin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,9 @@ export function runTransactionVerificationTests(coinName: string, bitgo: TestBit

await basecoin
.verifyTransaction({ txParams, txPrebuild, wallet, verification })
.should.be.rejectedWith('txPrebuild should only have 1 recipient but 2 found');
.should.be.rejectedWith(
`${basecoin} doesn't support sending to more then 1 destination address within a single transaction. Try again, using only a single recipient.`
);
});

it('should reject a hop txPrebuild that does not send to its hop address', async () => {
Expand Down
4 changes: 3 additions & 1 deletion modules/sdk-coin-arbeth/test/unit/arbeth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,9 @@ describe('Arbitrum', function () {

await basecoin
.verifyTransaction({ txParams, txPrebuild, wallet, verification })
.should.be.rejectedWith('txPrebuild should only have 1 recipient but 2 found');
.should.be.rejectedWith(
`tarbeth doesn't support sending to more then 1 destination address within a single transaction. Try again, using only a single recipient.`
);
});

it('should reject a hop txPrebuild that does not send to its hop address', async function () {
Expand Down
4 changes: 3 additions & 1 deletion modules/sdk-coin-avaxc/src/avaxc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ export class AvaxC extends AbstractEthLikeNewCoins {
throw new Error(`tx cannot be both a batch and hop transaction`);
}
if (txPrebuild.recipients.length !== 1) {
throw new Error(`txPrebuild should only have 1 recipient but ${txPrebuild.recipients.length} found`);
throw new Error(
`${this.getChain()} doesn't support sending to more then 1 destination address within a single transaction. Try again, using only a single recipient.`
);
}
if (txParams.hop && txPrebuild.hopTransaction) {
// Check recipient amount for hop transaction
Expand Down
4 changes: 3 additions & 1 deletion modules/sdk-coin-avaxc/test/unit/avaxc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,9 @@ describe('Avalanche C-Chain', function () {

await tavaxCoin
.verifyTransaction({ txParams, txPrebuild, wallet, verification })
.should.be.rejectedWith('txPrebuild should only have 1 recipient but 2 found');
.should.be.rejectedWith(
`tavaxc doesn't support sending to more then 1 destination address within a single transaction. Try again, using only a single recipient.`
);
});

it('should reject a hop txPrebuild that does not send to its hop address', async function () {
Expand Down
4 changes: 3 additions & 1 deletion modules/sdk-coin-bera/test/unit/bera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,9 @@ describe('Bera', function () {

await basecoin
.verifyTransaction({ txParams, txPrebuild, wallet, verification })
.should.be.rejectedWith('txPrebuild should only have 1 recipient but 2 found');
.should.be.rejectedWith(
`tbera doesn't support sending to more then 1 destination address within a single transaction. Try again, using only a single recipient.`
);
});

it('should reject a normal txPrebuild from the bitgo server with the wrong amount', async function () {
Expand Down
4 changes: 3 additions & 1 deletion modules/sdk-coin-eth/test/unit/eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,9 @@ describe('ETH:', function () {

await coin
.verifyTransaction({ txParams, txPrebuild: txPrebuild as any, wallet, verification })
.should.be.rejectedWith('txPrebuild should only have 1 recipient but 2 found');
.should.be.rejectedWith(
`teth doesn't support sending to more then 1 destination address within a single transaction. Try again, using only a single recipient.`
);
});

it('should reject a hop txPrebuild that does not send to its hop address', async function () {
Expand Down
4 changes: 3 additions & 1 deletion modules/sdk-coin-opeth/test/unit/opeth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,9 @@ describe('Optimism', function () {

await basecoin
.verifyTransaction({ txParams, txPrebuild, wallet, verification })
.should.be.rejectedWith('txPrebuild should only have 1 recipient but 2 found');
.should.be.rejectedWith(
`topeth doesn't support sending to more then 1 destination address within a single transaction. Try again, using only a single recipient.`
);
});

it('should reject a hop txPrebuild that does not send to its hop address', async function () {
Expand Down
4 changes: 3 additions & 1 deletion modules/sdk-coin-polygon/test/unit/polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,9 @@ describe('Polygon', function () {

await basecoin
.verifyTransaction({ txParams, txPrebuild, wallet, verification })
.should.be.rejectedWith('txPrebuild should only have 1 recipient but 2 found');
.should.be.rejectedWith(
`tpoloygon doesn't support sending to more then 1 destination address within a single transaction. Try again, using only a single recipient.`
);
});

it('should reject a hop txPrebuild that does not send to its hop address', async function () {
Expand Down
4 changes: 3 additions & 1 deletion modules/sdk-coin-zketh/test/unit/zketh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,9 @@ describe('zkSync', function () {

await basecoin
.verifyTransaction({ txParams, txPrebuild, wallet, verification })
.should.be.rejectedWith('txPrebuild should only have 1 recipient but 2 found');
.should.be.rejectedWith(
`tzketh doesn't support sending to more then 1 destination address within a single transaction. Try again, using only a single recipient.`
);
});

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

0 comments on commit 70ca339

Please sign in to comment.