@@ -73,16 +73,16 @@ type FetchBridgesParams = {
7373 env : Env ;
7474 ethereumAddress : string ;
7575} & (
76- | {
76+ | {
7777 limit : number ;
7878 offset : number ;
7979 type : "load" ;
8080 }
81- | {
81+ | {
8282 quantity : number ;
8383 type : "reload" ;
8484 }
85- ) ;
85+ ) ;
8686
8787interface BridgeParams {
8888 amount : BigNumber ;
@@ -191,14 +191,14 @@ const BridgeProvider: FC<PropsWithChildren> = (props) => {
191191 claim_tx_hash !== null
192192 ? { status : "claimed" , txHash : claim_tx_hash }
193193 : ready_for_claim
194- ? { status : "ready" }
195- : { status : "pending" } ;
194+ ? { status : "ready" }
195+ : { status : "pending" } ;
196196
197197 const tokenPrice : BigNumber | undefined = env . fiatExchangeRates . areEnabled
198198 ? await getTokenPrice ( {
199- chain : from ,
200- token,
201- } ) . catch ( ( ) => undefined )
199+ chain : from ,
200+ token,
201+ } ) . catch ( ( ) => undefined )
202202 : undefined ;
203203
204204 const fiatAmount =
@@ -319,12 +319,16 @@ const BridgeProvider: FC<PropsWithChildren> = (props) => {
319319
320320 const from = env . chains . find ( ( chain ) => chain . networkId === network_id ) ;
321321 if ( from === undefined ) {
322- return acc . then ( ( accDeposits ) => { return accDeposits } )
322+ return acc . then ( ( accDeposits ) => {
323+ return accDeposits ;
324+ } ) ;
323325 }
324326
325327 const to = env . chains . find ( ( chain ) => chain . networkId === dest_net ) ;
326328 if ( to === undefined ) {
327- return acc . then ( ( accDeposits ) => { return accDeposits } )
329+ return acc . then ( ( accDeposits ) => {
330+ return accDeposits ;
331+ } ) ;
328332 }
329333
330334 return acc . then ( ( accDeposits ) =>
@@ -342,8 +346,8 @@ const BridgeProvider: FC<PropsWithChildren> = (props) => {
342346 claim_tx_hash !== null
343347 ? { status : "claimed" , txHash : claim_tx_hash }
344348 : ready_for_claim
345- ? { status : "ready" }
346- : { status : "pending" } ,
349+ ? { status : "ready" }
350+ : { status : "pending" } ,
347351 depositCount : deposit_cnt ,
348352 depositTxHash : tx_hash ,
349353 destinationAddress : dest_addr ,
@@ -364,26 +368,26 @@ const BridgeProvider: FC<PropsWithChildren> = (props) => {
364368
365369 const tokenPrices : TokenPrices = env . fiatExchangeRates . areEnabled
366370 ? await deposits . reduce (
367- async (
368- accTokenPrices : Promise < TokenPrices > ,
369- deposit : Deposit
370- ) : Promise < TokenPrices > => {
371- const tokenPrices = await accTokenPrices ;
372- const tokenCachedPrice = tokenPrices [ deposit . token . address ] ;
373- const tokenPrice =
374- tokenCachedPrice !== undefined
375- ? tokenCachedPrice
376- : await getTokenPrice ( { chain : deposit . from , token : deposit . token } ) . catch (
377- ( ) => null
378- ) ;
379-
380- return {
381- ...tokenPrices ,
382- [ deposit . token . address ] : tokenPrice ,
383- } ;
384- } ,
385- Promise . resolve ( { } )
386- )
371+ async (
372+ accTokenPrices : Promise < TokenPrices > ,
373+ deposit : Deposit
374+ ) : Promise < TokenPrices > => {
375+ const tokenPrices = await accTokenPrices ;
376+ const tokenCachedPrice = tokenPrices [ deposit . token . address ] ;
377+ const tokenPrice =
378+ tokenCachedPrice !== undefined
379+ ? tokenCachedPrice
380+ : await getTokenPrice ( { chain : deposit . from , token : deposit . token } ) . catch (
381+ ( ) => null
382+ ) ;
383+
384+ return {
385+ ...tokenPrices ,
386+ [ deposit . token . address ] : tokenPrice ,
387+ } ;
388+ } ,
389+ Promise . resolve ( { } )
390+ )
387391 : { } ;
388392
389393 const bridges = deposits . map ( ( partialDeposit ) : Bridge => {
@@ -406,16 +410,16 @@ const BridgeProvider: FC<PropsWithChildren> = (props) => {
406410 const fiatAmount =
407411 tokenPrice !== undefined && tokenPrice !== null
408412 ? multiplyAmounts (
409- {
410- precision : FIAT_DISPLAY_PRECISION ,
411- value : tokenPrice ,
412- } ,
413- {
414- precision : token . decimals ,
415- value : amount ,
416- } ,
417- FIAT_DISPLAY_PRECISION
418- )
413+ {
414+ precision : FIAT_DISPLAY_PRECISION ,
415+ value : tokenPrice ,
416+ } ,
417+ {
418+ precision : token . decimals ,
419+ value : amount ,
420+ } ,
421+ FIAT_DISPLAY_PRECISION
422+ )
419423 : undefined ;
420424
421425 const id = serializeBridgeId ( {
@@ -701,30 +705,29 @@ const BridgeProvider: FC<PropsWithChildren> = (props) => {
701705 const gasLimit =
702706 from . key === "ethereum"
703707 ? await contract . estimateGas
704- . bridgeAsset (
705- to . networkId ,
706- destinationAddress ,
707- amount ,
708- tokenAddress ,
709- forceUpdateGlobalExitRoot ,
710- "0x" ,
711- overrides
712- )
713- . then ( ( gasLimit ) => {
714- const gasLimitIncrease = gasLimit
715- . div ( BigNumber . from ( 100 ) )
716- . mul ( BRIDGE_CALL_GAS_LIMIT_INCREASE_PERCENTAGE ) ;
717-
718- const increasedGasLimit = gasLimit . add ( gasLimitIncrease ) ;
719-
720- return tokenSpendPermission . type === "permit"
721- ? increasedGasLimit . add ( BRIDGE_CALL_PERMIT_GAS_LIMIT_INCREASE )
722- : increasedGasLimit ;
723- } )
708+ . bridgeAsset (
709+ to . networkId ,
710+ destinationAddress ,
711+ amount ,
712+ tokenAddress ,
713+ forceUpdateGlobalExitRoot ,
714+ "0x" ,
715+ overrides
716+ )
717+ . then ( ( gasLimit ) => {
718+ const gasLimitIncrease = gasLimit
719+ . div ( BigNumber . from ( 100 ) )
720+ . mul ( BRIDGE_CALL_GAS_LIMIT_INCREASE_PERCENTAGE ) ;
721+
722+ const increasedGasLimit = gasLimit . add ( gasLimitIncrease ) ;
723+
724+ return tokenSpendPermission . type === "permit"
725+ ? increasedGasLimit . add ( BRIDGE_CALL_PERMIT_GAS_LIMIT_INCREASE )
726+ : increasedGasLimit ;
727+ } )
724728 : BigNumber . from ( 300000 ) ;
725729
726730 const { gasPrice, maxFeePerGas } = await from . provider . getFeeData ( ) ;
727-
728731 if ( maxFeePerGas ) {
729732 return { data : { gasLimit, maxFeePerGas } , type : "eip-1559" } ;
730733 } else {
@@ -770,21 +773,21 @@ const BridgeProvider: FC<PropsWithChildren> = (props) => {
770773 ...( gas
771774 ? gas . data
772775 : ( await estimateBridgeGas ( { destinationAddress, from, to, token, tokenSpendPermission } ) )
773- . data ) ,
776+ . data ) ,
774777 } ;
775-
778+ overrides . maxFeePerGas = Number ( overrides . maxFeePerGas ?. toString ( ) ) * 2 ;
776779 const executeBridge = async ( ) => {
777780 const permitData =
778781 tokenSpendPermission . type === "permit"
779782 ? await permit ( {
780- account : account ,
781- from : from ,
782- permit : tokenSpendPermission . permit ,
783- provider : provider ,
784- spender : from . bridgeContractAddress ,
785- token,
786- value : amount ,
787- } )
783+ account : account ,
784+ from : from ,
785+ permit : tokenSpendPermission . permit ,
786+ provider : provider ,
787+ spender : from . bridgeContractAddress ,
788+ token,
789+ value : amount ,
790+ } )
788791 : "0x" ;
789792
790793 const forceUpdateGlobalExitRoot =
@@ -813,6 +816,10 @@ const BridgeProvider: FC<PropsWithChildren> = (props) => {
813816 } ) ;
814817
815818 return txData ;
819+ } )
820+ . catch ( ( err ) => {
821+ console . log ( "xxxxxxxxxxxxx: " , err ) ;
822+ throw err ;
816823 } ) ;
817824 } ;
818825
0 commit comments