@@ -72,6 +72,7 @@ import { AbstractEthLikeCoin } from './abstractEthLikeCoin';
7272import { EthLikeToken } from './ethLikeToken' ;
7373import {
7474 calculateForwarderV1Address ,
75+ coinFamiliesWithL1Fees ,
7576 decodeTransferData ,
7677 ERC1155TransferBuilder ,
7778 ERC721TransferBuilder ,
@@ -1516,10 +1517,9 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
15161517 const backupKeyBalance = await this . queryAddressBalance ( backupKeyAddress , params . apiKey ) ;
15171518 let totalGasNeeded = gasPrice . mul ( gasLimit ) ;
15181519
1519- // On optimism chain, L1 fees is to be paid as well apart from L2 fees
1520- // So we are adding the amount that can be used up as l1 fees
1521- if ( this . staticsCoin ?. family === 'opeth' ) {
1522- totalGasNeeded = totalGasNeeded . add ( new optionalDeps . ethUtil . BN ( ethGasConfigs . opethGasL1Fees ) ) ;
1520+ // On L2 chains with L1 data fees, add buffer for L1 fees
1521+ if ( this . staticsCoin ?. family !== undefined && coinFamiliesWithL1Fees . includes ( this . staticsCoin . family ) ) {
1522+ totalGasNeeded = totalGasNeeded . add ( new optionalDeps . ethUtil . BN ( ethGasConfigs . l1GasFeeBuffer ) ) ;
15231523 }
15241524
15251525 const weiToGwei = 10 ** 9 ;
@@ -2515,7 +2515,11 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
25152515
25162516 async validateBalanceAndGetTxAmount ( baseAddress : string , gasPrice : BN , gasLimit : BN , apiKey ?: string ) {
25172517 const baseAddressBalance = await this . queryAddressBalance ( baseAddress , apiKey ) ;
2518- const totalGasNeeded = gasPrice . mul ( gasLimit ) ;
2518+ let totalGasNeeded = gasPrice . mul ( gasLimit ) ;
2519+ // On L2 chains with L1 data fees, add buffer for L1 fees
2520+ if ( this . staticsCoin ?. family !== undefined && coinFamiliesWithL1Fees . includes ( this . staticsCoin . family ) ) {
2521+ totalGasNeeded = totalGasNeeded . add ( new optionalDeps . ethUtil . BN ( ethGasConfigs . l1GasFeeBuffer ) ) ;
2522+ }
25192523 const weiToGwei = new BN ( 10 ** 9 ) ;
25202524 if ( baseAddressBalance . lt ( totalGasNeeded ) ) {
25212525 throw new Error (
0 commit comments