@@ -236,11 +236,24 @@ const ChainbridgeProvider = ({ children }: IChainbridgeContextProps) => {
236236 }
237237 } ;
238238 const getBridgeFee = async ( ) => {
239- if ( homeBridge && destinationBridge ) {
240- const targetChainID = await destinationBridge . _chainID ( ) ;
241- const fee = await homeBridge . getFee ( targetChainID ) ;
242- const bridgeFee = Number ( utils . formatEther ( fee ) ) ;
243- setBridgeFee ( bridgeFee ) ;
239+ if ( homeBridge && destinationBridge && homeChain && selectedToken ) {
240+ const targetDomainID = await destinationBridge . _domainID ( ) ;
241+ const token = homeChain . tokens . find (
242+ ( token ) => token . address === selectedToken
243+ ) ;
244+ if ( token ) {
245+ // NOTE: The v2 chainbridge contracts allow dynamic fees based on payload
246+ // this is not being used by meter passport currently so we
247+ // do not need to create the packed data for calculating the bridge fees.
248+ const fee = await homeBridge . calculateFee (
249+ targetDomainID ,
250+ token . resourceId ,
251+ "" ,
252+ ""
253+ ) ;
254+ const bridgeFee = Number ( utils . formatEther ( fee ) ) ;
255+ setBridgeFee ( bridgeFee ) ;
256+ }
244257 }
245258 } ;
246259 getRelayerThreshold ( ) ;
@@ -251,13 +264,12 @@ const ChainbridgeProvider = ({ children }: IChainbridgeContextProps) => {
251264 if ( homeChain && destinationBridge && depositNonce ) {
252265 destinationBridge . on (
253266 destinationBridge . filters . ProposalEvent (
254- homeChain . chainId ,
255- BigNumber . from ( depositNonce ) ,
267+ null ,
256268 null ,
257269 null ,
258270 null
259271 ) ,
260- ( originChainId , depositNonce , status , resourceId , dataHash , tx ) => {
272+ ( originChainId , depositNonce , status , dataHash , tx ) => {
261273 switch ( BigNumber . from ( status ) . toNumber ( ) ) {
262274 case 1 :
263275 tokensDispatch ( {
@@ -285,12 +297,12 @@ const ChainbridgeProvider = ({ children }: IChainbridgeContextProps) => {
285297
286298 destinationBridge . on (
287299 destinationBridge . filters . ProposalVote (
288- homeChain . chainId ,
289- BigNumber . from ( depositNonce ) ,
300+ null ,
301+ null ,
290302 null ,
291303 null
292304 ) ,
293- async ( originChainId , depositNonce , status , resourceId , tx ) => {
305+ async ( originChainId , depositNonce , status , dataHash , tx ) => {
294306 const txReceipt = await tx . getTransactionReceipt ( ) ;
295307 if ( txReceipt . status === 1 ) {
296308 setDepositVotes ( depositVotes + 1 ) ;
@@ -338,6 +350,7 @@ const ChainbridgeProvider = ({ children }: IChainbridgeContextProps) => {
338350 console . log ( "No signer" ) ;
339351 return ;
340352 }
353+ const sender = await signer . getAddress ( ) ;
341354
342355 const token = homeChain . tokens . find (
343356 ( token ) => token . address === tokenAddress
@@ -354,7 +367,6 @@ const ChainbridgeProvider = ({ children }: IChainbridgeContextProps) => {
354367 const controller = XCAmpleControllerFactory . connect ( homeChain . controller , signer ) ;
355368 const erc20Decimals = tokens [ tokenAddress ] . decimals ;
356369
357-
358370 const [ epoch , totalSupply ] = await controller . globalAmpleforthEpochAndAMPLSupply ( ) ;
359371 const data = packXCTransferData ( address , recipient , utils . parseUnits ( amount . toString ( ) , erc20Decimals ) , totalSupply ) ;
360372
@@ -365,7 +377,6 @@ const ChainbridgeProvider = ({ children }: IChainbridgeContextProps) => {
365377 ) ;
366378
367379 const gasLimit = 500000 ;
368-
369380 if ( Number ( utils . formatUnits ( currentAllowance , erc20Decimals ) ) < amount ) {
370381 // if (
371382 // Number(utils.formatUnits(currentAllowance, erc20Decimals)) > 0 &&
@@ -407,11 +418,14 @@ const ChainbridgeProvider = ({ children }: IChainbridgeContextProps) => {
407418
408419 homeBridge . once (
409420 homeBridge . filters . Deposit (
410- destinationChain . chainId ,
411- token . resourceId ,
412- null
421+ null ,
422+ null ,
423+ null ,
424+ sender ,
425+ null ,
426+ null ,
413427 ) ,
414- ( destChainId , resourceId , depositNonce ) => {
428+ ( destChainId , resourceId , depositNonce , user , data , handlerResponse ) => {
415429 setDepositNonce ( `${ depositNonce . toString ( ) } ` ) ;
416430 setTransactionStatus ( "In Transit" ) ;
417431 }
@@ -422,6 +436,7 @@ const ChainbridgeProvider = ({ children }: IChainbridgeContextProps) => {
422436 destinationChain . chainId ,
423437 token . resourceId ,
424438 data ,
439+ [ ] ,
425440 {
426441 gasPrice : utils . parseUnits (
427442 ( homeChain . defaultGasPrice || gasPrice ) . toString ( ) ,
0 commit comments