Skip to content

Commit ec190a0

Browse files
Merge pull request #6852 from BitGo/COIN-5065
fix: fixed gasPrice issue for base
2 parents 5003f60 + 743effd commit ec190a0

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

modules/abstract-eth/src/abstractEthLikeNewCoins.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,7 +1486,7 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
14861486
// Get sequence ID using contract call
14871487
// we need to wait between making two explorer api calls to avoid getting banned
14881488
await new Promise((resolve) => setTimeout(resolve, 1000));
1489-
const sequenceId = await this.querySequenceId(params.walletContractAddress);
1489+
const sequenceId = await this.querySequenceId(params.walletContractAddress, params.apiKey);
14901490

14911491
let operationHash, signature;
14921492
// Get operation hash and sign it
@@ -1681,7 +1681,7 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
16811681
? new optionalDeps.ethUtil.BN(params.eip1559.maxFeePerGas)
16821682
: params.gasPrice
16831683
? new optionalDeps.ethUtil.BN(this.setGasPrice(params.gasPrice))
1684-
: await this.getGasPriceFromExternalAPI(this.staticsCoin?.name as string);
1684+
: await this.getGasPriceFromExternalAPI(this.staticsCoin?.name as string, params.apiKey);
16851685

16861686
const bitgoFeeAddressNonce = await this.getAddressNonce(bitgoFeeAddress, params.apiKey);
16871687

@@ -1916,7 +1916,7 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
19161916
// Get sequence ID using contract call
19171917
// we need to wait between making two explorer api calls to avoid getting banned
19181918
await new Promise((resolve) => setTimeout(resolve, 1000));
1919-
const sequenceId = await this.querySequenceId(params.walletContractAddress);
1919+
const sequenceId = await this.querySequenceId(params.walletContractAddress, params.apiKey);
19201920

19211921
const txBuilder = this.getTransactionBuilder(params.common) as TransactionBuilder;
19221922
txBuilder.counter(bitgoFeeAddressNonce);
@@ -1975,7 +1975,8 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
19751975
params.intendedChain as string,
19761976
params.bitgoFeeAddress as string,
19771977
params.walletContractAddress,
1978-
sendData
1978+
sendData,
1979+
apiKey
19791980
);
19801981
txBuilder.fee({
19811982
...txFee,
@@ -1984,7 +1985,7 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
19841985
}
19851986

19861987
// Get the balance of bitgoFeeAddress to ensure funds are available to pay fees
1987-
await this.ensureSufficientBalance(params.bitgoFeeAddress as string, gasPrice, gasLimit);
1988+
await this.ensureSufficientBalance(params.bitgoFeeAddress as string, gasPrice, gasLimit, params.apiKey);
19881989

19891990
const tx = await txBuilder.build();
19901991

modules/sdk-coin-evm/src/evmCoin.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,20 @@ export class EvmCoin extends AbstractEthLikeNewCoins {
5252
/**
5353
* Make a query to chain explorer for information such as balance, token balance, solidity calls
5454
* @param {Object} query key-value pairs of parameters to append after /api
55+
* @param {string} apiKey optional API key to use for the query falls back to EVM config if not provided
5556
* @returns {Promise<Object>} response from chain explorer
5657
*/
57-
async recoveryBlockchainExplorerQuery(query: Record<string, string>): Promise<Record<string, unknown>> {
58+
async recoveryBlockchainExplorerQuery(
59+
query: Record<string, string>,
60+
apiKey?: string
61+
): Promise<Record<string, unknown>> {
5862
const evmConfig = common.Environments[this.bitgo.getEnv()].evm;
5963
assert(
6064
evmConfig && this.getFamily() in evmConfig,
6165
`env config is missing for ${this.getFamily()} in ${this.bitgo.getEnv()}`
6266
);
6367

64-
const apiToken = evmConfig[this.getFamily()].apiToken;
68+
const apiToken = apiKey || evmConfig[this.getFamily()].apiToken;
6569
const explorerUrl = evmConfig[this.getFamily()].baseUrl;
6670
return await recoveryBlockchainExplorerQuery(query, explorerUrl as string, apiToken as string);
6771
}

modules/sdk-core/src/bitgo/environments.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,9 @@ const mainnetBase: EnvironmentTemplate = {
251251
somi: {
252252
baseUrl: 'https://mainnet.somnia.w3us.site/',
253253
},
254+
baseeth: {
255+
baseUrl: 'https://api.etherscan.io/v2',
256+
},
254257
},
255258
icpNodeUrl: 'https://ic0.app',
256259
worldExplorerBaseUrl: 'https://worldscan.org/',
@@ -370,6 +373,9 @@ const testnetBase: EnvironmentTemplate = {
370373
ip: {
371374
baseUrl: 'https://api.storyscan.app/',
372375
},
376+
tbaseeth: {
377+
baseUrl: 'https://api.etherscan.io/v2',
378+
},
373379
},
374380
stxNodeUrl: 'https://api.testnet.hiro.so',
375381
vetNodeUrl: 'https://rpc-testnet.vechain.energy',

0 commit comments

Comments
 (0)