Skip to content

Commit 7a8cb12

Browse files
Merge pull request #5322 from BitGo/COIN-2612-update-err-msg
chore: updated error message for gas limit and price
2 parents fab30f8 + d540d76 commit 7a8cb12

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

modules/abstract-eth/src/abstractEthLikeNewCoins.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,7 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
13731373
? new optionalDeps.ethUtil.BN(params.eip1559.maxFeePerGas)
13741374
: params.gasPrice
13751375
? new optionalDeps.ethUtil.BN(this.setGasPrice(params.gasPrice))
1376-
: await this.getGasPriceFromExternalAPI();
1376+
: await this.getGasPriceFromExternalAPI(this.staticsCoin?.name as string);
13771377

13781378
const bitgoFeeAddressNonce = await this.getAddressNonce(bitgoFeeAddress);
13791379

@@ -1480,6 +1480,7 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
14801480
if (!params.gasLimit && userKey && !userKey.startsWith('xpub')) {
14811481
const sendData = txBuilder.getSendData();
14821482
gasLimit = await this.getGasLimitFromExternalAPI(
1483+
params.intendedChain as string,
14831484
params.bitgoFeeAddress as string,
14841485
params.walletContractAddress,
14851486
sendData
@@ -1650,6 +1651,7 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
16501651
if (!params.gasLimit && userKey && !userKey.startsWith('xpub')) {
16511652
const sendData = txBuilder.getSendData();
16521653
gasLimit = await this.getGasLimitFromExternalAPI(
1654+
params.intendedChain as string,
16531655
params.bitgoFeeAddress as string,
16541656
params.walletContractAddress,
16551657
sendData
@@ -2447,7 +2449,7 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
24472449
/**
24482450
* Fetch the gas price from the explorer
24492451
*/
2450-
async getGasPriceFromExternalAPI(): Promise<BN> {
2452+
async getGasPriceFromExternalAPI(wrongChainCoin: string): Promise<BN> {
24512453
try {
24522454
const res = await this.recoveryBlockchainExplorerQuery({
24532455
module: 'proxy',
@@ -2457,17 +2459,18 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
24572459
console.log(` Got gas price: ${gasPrice}`);
24582460
return gasPrice;
24592461
} catch (e) {
2460-
throw new Error('Failed to get gas price');
2462+
throw new Error(`Failed to get gas price. Please make sure to use the api key of ${wrongChainCoin}`);
24612463
}
24622464
}
24632465

24642466
/**
24652467
* Fetch the gas limit from the explorer
2468+
* @param intendedChain
24662469
* @param from
24672470
* @param to
24682471
* @param data
24692472
*/
2470-
async getGasLimitFromExternalAPI(from: string, to: string, data: string): Promise<BN> {
2473+
async getGasLimitFromExternalAPI(intendedChain: string, from: string, to: string, data: string): Promise<BN> {
24712474
try {
24722475
const res = await this.recoveryBlockchainExplorerQuery({
24732476
module: 'proxy',
@@ -2480,7 +2483,9 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
24802483
console.log(`Got gas limit: ${gasLimit}`);
24812484
return gasLimit;
24822485
} catch (e) {
2483-
throw new Error('Failed to get gas limit: ');
2486+
throw new Error(
2487+
`Failed to get gas limit. Please make sure to use the privateKey aka userKey of ${intendedChain} wallet ${to}`
2488+
);
24842489
}
24852490
}
24862491

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,11 +1212,12 @@ export class AvaxC extends AbstractEthLikeNewCoins {
12121212

12131213
/**
12141214
* Fetch the gas limit from the explorer
1215+
* @param intendedChain
12151216
* @param from
12161217
* @param to
12171218
* @param data
12181219
*/
1219-
async getGasLimitFromExternalAPI(from: string, to: string, data: string): Promise<BN> {
1220+
async getGasLimitFromExternalAPI(intendedChain: string, from: string, to: string, data: string): Promise<BN> {
12201221
try {
12211222
const res = await this.recoveryBlockchainExplorerQuery({
12221223
jsonrpc: '2.0',
@@ -1235,7 +1236,9 @@ export class AvaxC extends AbstractEthLikeNewCoins {
12351236
console.log(`Got gas limit: ${gasLimit}`);
12361237
return gasLimit;
12371238
} catch (e) {
1238-
throw new Error('Failed to get gas limit: ');
1239+
throw new Error(
1240+
`Failed to get gas limit. Please make sure to use the privateKey aka userKey of ${intendedChain} wallet ${to}`
1241+
);
12391242
}
12401243
}
12411244
}

0 commit comments

Comments
 (0)