@@ -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
@@ -2230,7 +2232,8 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
22302232 * @returns {boolean }
22312233 */
22322234 verifyCoin ( txPrebuild : TransactionPrebuild ) : boolean {
2233- return txPrebuild . coin === this . getChain ( ) ;
2235+ const nativeCoin = this . getChain ( ) . split ( ':' ) [ 0 ] ;
2236+ return txPrebuild . coin === nativeCoin ;
22342237 }
22352238
22362239 /**
@@ -2446,7 +2449,7 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
24462449 /**
24472450 * Fetch the gas price from the explorer
24482451 */
2449- async getGasPriceFromExternalAPI ( ) : Promise < BN > {
2452+ async getGasPriceFromExternalAPI ( wrongChainCoin : string ) : Promise < BN > {
24502453 try {
24512454 const res = await this . recoveryBlockchainExplorerQuery ( {
24522455 module : 'proxy' ,
@@ -2456,17 +2459,18 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
24562459 console . log ( ` Got gas price: ${ gasPrice } ` ) ;
24572460 return gasPrice ;
24582461 } catch ( e ) {
2459- 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 } ` ) ;
24602463 }
24612464 }
24622465
24632466 /**
24642467 * Fetch the gas limit from the explorer
2468+ * @param intendedChain
24652469 * @param from
24662470 * @param to
24672471 * @param data
24682472 */
2469- async getGasLimitFromExternalAPI ( from : string , to : string , data : string ) : Promise < BN > {
2473+ async getGasLimitFromExternalAPI ( intendedChain : string , from : string , to : string , data : string ) : Promise < BN > {
24702474 try {
24712475 const res = await this . recoveryBlockchainExplorerQuery ( {
24722476 module : 'proxy' ,
@@ -2479,7 +2483,9 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
24792483 console . log ( `Got gas limit: ${ gasLimit } ` ) ;
24802484 return gasLimit ;
24812485 } catch ( e ) {
2482- 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+ ) ;
24832489 }
24842490 }
24852491
0 commit comments