@@ -140,10 +140,17 @@ import type {
140140import type { IRpcTxEvm } from './types' ;
141141import type { IJsonRpcRequest } from '@onekeyfe/cross-inpage-provider-types' ;
142142
143+ const BASE_SEPOLIA = 'evm--84532' ;
144+ const ARB_SEPOLIA = 'evm--421614' ;
145+
143146const EVM_L2_NETWORKS_REQUIRE_L1_FEE : string [ ] = [
144147 OnekeyNetwork . optimism ,
145148 OnekeyNetwork . toptimism ,
146149 OnekeyNetwork . base ,
150+ OnekeyNetwork . arbitrum ,
151+ OnekeyNetwork . tarbitrum ,
152+ BASE_SEPOLIA ,
153+ ARB_SEPOLIA ,
147154] ;
148155
149156const ERC721 = ERC721MetadataArtifact . abi ;
@@ -1273,37 +1280,49 @@ export default class Vault extends VaultBase {
12731280 // For L2 networks with L1 fee.
12741281 let baseFeeValue = '0' ;
12751282 if ( EVM_L2_NETWORKS_REQUIRE_L1_FEE . includes ( this . networkId ) ) {
1276- // Optimism & Optimism Kovan
1277- // call gasL1Fee(bytes) of GasPriceOracle at 0x420000000000000000000000000000000000000F
1278- const txData = ethers . utils . serializeTransaction ( {
1279- value : encodedTx . value ,
1280- data : encodedTx . data ,
1281- gasLimit : `0x${ ( unsignedTx ?. feeLimit ?? new BigNumber ( '0' ) ) . toString (
1282- 16 ,
1283- ) } `,
1284- to : encodedTx . to ,
1285- chainId : 10 , // any number other than 0 will lead to fixed length of data
1286- gasPrice : '0xf4240' , // 0.001 Gwei
1287- nonce : 1 ,
1288- } ) ;
1289-
1290- // keccak256(Buffer.from('getL1Fee(bytes)')) => '0x49948e0e...'
1291- const data = `0x49948e0e${ defaultAbiCoder
1292- . encode ( [ 'bytes' ] , [ txData ] )
1293- . slice ( 2 ) } `;
12941283 const client = await this . getJsonRPCClient ( ) ;
1284+ if (
1285+ this . networkId === OnekeyNetwork . arbitrum ||
1286+ this . networkId === ARB_SEPOLIA
1287+ ) {
1288+ // keccak256(Buffer.from('getL1BaseFeeEstimate()')) => '0xf5d6ded7...'
1289+ const data = '0xf5d6ded7' ;
1290+ const l1FeeHex = await client . rpc . call ( 'eth_call' , [
1291+ { to : '0x000000000000000000000000000000000000006C' , data } ,
1292+ 'latest' ,
1293+ ] ) ;
1294+
1295+ baseFeeValue = new BigNumber ( l1FeeHex as string )
1296+ . shiftedBy ( - network . feeDecimals )
1297+ . toFixed ( ) ;
1298+ } else {
1299+ const txData = ethers . utils . serializeTransaction ( {
1300+ value : encodedTx . value ,
1301+ data : encodedTx . data ,
1302+ gasLimit : `0x${ ( unsignedTx ?. feeLimit ?? new BigNumber ( '0' ) ) . toString (
1303+ 16 ,
1304+ ) } `,
1305+ to : encodedTx . to ,
1306+ chainId : 10 , // any number other than 0 will lead to fixed length of data
1307+ gasPrice : '0xf4240' , // 0.001 Gwei
1308+ nonce : 1 ,
1309+ } ) ;
12951310
1296- // RPC: eth_call
1297- const l1FeeHex = await client . rpc . call ( 'eth_call' , [
1298- { to : '0x420000000000000000000000000000000000000F' , data } ,
1299- 'latest' ,
1300- ] ) ;
1301- // RPC: eth_getBlockByNumber (rpc status check?)
1302- // RPC: eth_getBalance useManageTokensOfAccount/useReloadAccountBalance
1303- // may call multiple times
1304- baseFeeValue = new BigNumber ( l1FeeHex as string )
1305- . shiftedBy ( - network . feeDecimals )
1306- . toFixed ( ) ;
1311+ // keccak256(Buffer.from('getL1Fee(bytes)')) => '0x49948e0e...'
1312+ const data = `0x49948e0e${ defaultAbiCoder
1313+ . encode ( [ 'bytes' ] , [ txData ] )
1314+ . slice ( 2 ) } `;
1315+
1316+ // RPC: eth_call
1317+ const l1FeeHex = await client . rpc . call ( 'eth_call' , [
1318+ { to : '0x420000000000000000000000000000000000000F' , data } ,
1319+ 'latest' ,
1320+ ] ) ;
1321+
1322+ baseFeeValue = new BigNumber ( l1FeeHex as string )
1323+ . shiftedBy ( - network . feeDecimals )
1324+ . toFixed ( ) ;
1325+ }
13071326 }
13081327
13091328 const eip1559 = Boolean (
0 commit comments