Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(wp): send many uniform error messages changes #5201

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
/modules/sdk-coin-atom/ @BitGo/ethalt-team
/modules/sdk-coin-avaxc/ @BitGo/ethalt-team
/modules/sdk-coin-avaxp/ @BitGo/ethalt-team
/modules/sdk-coin-bera/ @BitGo/ethalt-team
/modules/sdk-coin-bsc/ @BitGo/ethalt-team
/modules/sdk-coin-coredao/ @BitGo/ethalt-team
/modules/sdk-coin-cspr/ @BitGo/ethalt-team
Expand Down
6 changes: 4 additions & 2 deletions modules/abstract-eth/src/abstractEthLikeNewCoins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2280,8 +2280,10 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
if (txParams.hop && txParams.recipients.length > 1) {
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`);
if (txPrebuild.recipients.length > 1) {
throw new Error(
`${this.getChain()} doesn't support sending to more than 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(
`${coinTest} doesn't support sending to more than 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 than 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
6 changes: 4 additions & 2 deletions modules/sdk-coin-avaxc/src/avaxc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,10 @@ export class AvaxC extends AbstractEthLikeNewCoins {
if (txParams.hop && txParams.recipients.length > 1) {
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`);
if (txPrebuild.recipients.length > 1) {
throw new Error(
`${this.getChain()} doesn't support sending to more than 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 than 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');
krupanand-bitgo marked this conversation as resolved.
Show resolved Hide resolved
.should.be.rejectedWith(
`tbera doesn't support sending to more than 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-celo/src/celo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ export class Celo extends AbstractEthLikeCoin {
async verifyTransaction(params: VerifyTransactionOptions): Promise<boolean> {
const { txParams } = params;
if (Array.isArray(txParams.recipients) && txParams.recipients.length > 1) {
throw new Error(`txParams should only have 1 recipient but ${txParams?.recipients?.length} found`);
throw new Error(
`${this.getChain()} doesn't support sending to more than 1 destination address within a single transaction. Try again, using only a single recipient.`
);
}
return true;
}
Expand Down
4 changes: 3 additions & 1 deletion modules/sdk-coin-celo/test/unit/celo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ describe('Celo Gold', function () {

await basecoin
.verifyTransaction({ txParams })
.should.be.rejectedWith('txParams should only have 1 recipient but 2 found');
.should.be.rejectedWith(
`celo doesn't support sending to more than 1 destination address within a single transaction. Try again, using only a single recipient.`
);
});
});
});
4 changes: 3 additions & 1 deletion modules/sdk-coin-dot/src/dot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,9 @@ export class Dot extends BaseCoin {
async verifyTransaction(params: VerifyTransactionOptions): Promise<boolean> {
const { txParams } = params;
if (Array.isArray(txParams.recipients) && txParams.recipients.length > 1) {
throw new Error(`txParams should only have 1 recipient but ${txParams?.recipients?.length} found`);
throw new Error(
`${this.getChain()} doesn't support sending to more than 1 destination address within a single transaction. Try again, using only a single recipient.`
);
}
return true;
}
Expand Down
4 changes: 3 additions & 1 deletion modules/sdk-coin-dot/test/unit/dot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,9 @@ describe('DOT:', function () {

await basecoin
.verifyTransaction({ txParams })
.should.be.rejectedWith('txParams should only have 1 recipient but 2 found');
.should.be.rejectedWith(
`tdot doesn't support sending to more than 1 destination address within a single transaction. Try again, using only a single recipient.`
);
});
});
});
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 than 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 than 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
5 changes: 3 additions & 2 deletions modules/sdk-coin-polygon/test/unit/polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,10 @@ 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(
`tpolygon doesn't support sending to more than 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 () {
const wallet = new Wallet(bitgo, basecoin, {});

Expand Down
4 changes: 3 additions & 1 deletion modules/sdk-coin-stx/src/stx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ export class Stx extends BaseCoin {
async verifyTransaction(params: VerifyTransactionOptions): Promise<boolean> {
const { txParams } = params;
if (Array.isArray(txParams.recipients) && txParams.recipients.length > 1) {
throw new Error(`txParams should only have 1 recipient but ${txParams?.recipients?.length} found`);
throw new Error(
`${this.getChain()} doesn't support sending to more than 1 destination address within a single transaction. Try again, using only a single recipient.`
);
}
return true;
}
Expand Down
4 changes: 3 additions & 1 deletion modules/sdk-coin-stx/test/unit/stx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,9 @@ describe('STX:', function () {

await basecoin
.verifyTransaction({ txParams })
.should.be.rejectedWith('txParams should only have 1 recipient but 2 found');
.should.be.rejectedWith(
`tstx doesn't support sending to more than 1 destination address within a single transaction. Try again, using only a single recipient.`
);
});
});
});
4 changes: 3 additions & 1 deletion modules/sdk-coin-xrp/src/xrp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,9 @@ export class Xrp extends BaseCoin {

if (txParams.type === 'enabletoken') {
if (txParams.recipients?.length !== 1) {
throw new Error('Only one recipient is allowed.');
throw new Error(
`${this.getChain()} doesn't support sending to more than 1 destination address within a single transaction. Try again, using only a single recipient.`
);
}
const recipient = txParams.recipients[0];
if (!recipient.tokenName) {
Expand Down
4 changes: 3 additions & 1 deletion modules/sdk-coin-xtz/src/xtz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ export class Xtz extends BaseCoin {
async verifyTransaction(params: VerifyTransactionOptions): Promise<boolean> {
const { txParams } = params;
if (Array.isArray(txParams.recipients) && txParams.recipients.length > 1) {
throw new Error(`txParams should only have 1 recipient but ${txParams?.recipients?.length} found`);
throw new Error(
`${this.getChain()} doesn't support sending to more than 1 destination address within a single transaction. Try again, using only a single recipient.`
);
}
return true;
}
Expand Down
4 changes: 3 additions & 1 deletion modules/sdk-coin-xtz/test/unit/xtz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ describe('Tezos:', function () {

await basecoin
.verifyTransaction({ txParams })
.should.be.rejectedWith('txParams should only have 1 recipient but 2 found');
.should.be.rejectedWith(
`txtz doesn't support sending to more than 1 destination address within a single transaction. Try again, using only a single recipient.`
);
});
});
});
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 than 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
Loading