@@ -364,6 +364,15 @@ const ChainbridgeProvider = ({ children }: IChainbridgeContextProps) => {
364364 homeChain . approvalContract
365365 ) ;
366366
367+ // NOTE: gasPrice, from web3-context doesn't work anymore
368+ const gasLimit = 500000 ;
369+ const currentGasPrice = await signer . getGasPrice ( ) ;
370+ const txGas = BigNumber . from (
371+ homeChain . defaultGasPrice ?
372+ utils . parseUnits ( homeChain . defaultGasPrice . toString ( ) , 9 ) :
373+ currentGasPrice
374+ ) . toString ( )
375+
367376 if ( Number ( utils . formatUnits ( currentAllowance , erc20Decimals ) ) < amount ) {
368377 // if (
369378 // Number(utils.formatUnits(currentAllowance, erc20Decimals)) > 0 &&
@@ -390,14 +399,7 @@ const ChainbridgeProvider = ({ children }: IChainbridgeContextProps) => {
390399 await erc20 . approve (
391400 homeChain . approvalContract ,
392401 BigNumber . from ( utils . parseUnits ( amount . toString ( ) , erc20Decimals ) ) ,
393- {
394- gasPrice : BigNumber . from (
395- utils . parseUnits (
396- ( homeChain . defaultGasPrice || gasPrice ) . toString ( ) ,
397- 9
398- )
399- ) . toString ( ) ,
400- }
402+ { gasPrice : txGas , gasLimit }
401403 )
402404 ) . wait ( 1 ) ;
403405 }
@@ -420,10 +422,8 @@ const ChainbridgeProvider = ({ children }: IChainbridgeContextProps) => {
420422 token . resourceId ,
421423 data ,
422424 {
423- gasPrice : utils . parseUnits (
424- ( homeChain . defaultGasPrice || gasPrice ) . toString ( ) ,
425- 9
426- ) ,
425+ gasPrice : txGas ,
426+ gasLimit,
427427 value : utils . parseUnits ( ( bridgeFee || 0 ) . toString ( ) , 18 ) ,
428428 }
429429 )
0 commit comments