@@ -452,6 +452,13 @@ export function TransferPanel() {
452452 return handleTxSigningError ( error , step . payload . txRequestLabel )
453453 }
454454 }
455+
456+ case 'tx_history_add' : {
457+ addPendingTransaction ( step . payload )
458+ switchToTransactionHistoryTab ( )
459+
460+ return
461+ }
455462 }
456463 }
457464
@@ -472,22 +479,31 @@ export function TransferPanel() {
472479 const destinationAddress = latestDestinationAddress . current
473480
474481 try {
475- const { sourceChainProvider, destinationChainProvider, sourceChain } =
476- latestNetworks . current
482+ const {
483+ sourceChainProvider,
484+ destinationChainProvider,
485+ sourceChain,
486+ destinationChain
487+ } = latestNetworks . current
477488
478489 const cctpTransferStarter = new CctpTransferStarter ( {
479490 sourceChainProvider,
480491 destinationChainProvider
481492 } )
482493
483494 const returnEarly = await drive ( stepGeneratorForCctp , stepExecutor , {
495+ amount,
484496 amountBigNumber,
485497 isDepositMode,
486498 isSmartContractWallet,
487499 walletAddress,
488500 destinationAddress,
489501 transferStarter : cctpTransferStarter ,
490- wagmiConfig
502+ wagmiConfig,
503+ sourceChain,
504+ destinationChain,
505+ childChain,
506+ parentChain
491507 } )
492508
493509 // this is only necessary while we are migrating to the ui driver
@@ -498,94 +514,6 @@ export function TransferPanel() {
498514 return
499515 }
500516
501- let depositForBurnTx
502-
503- try {
504- if ( isSmartContractWallet ) {
505- showDelayedSmartContractTxRequest ( )
506- }
507- const transfer = await cctpTransferStarter . transfer ( {
508- amount : amountBigNumber ,
509- signer,
510- destinationAddress,
511- wagmiConfig
512- } )
513- depositForBurnTx = transfer . sourceChainTransaction
514- } catch ( error ) {
515- if ( isUserRejectedError ( error ) ) {
516- return
517- }
518- handleError ( {
519- error,
520- label : 'cctp_transfer' ,
521- category : 'transaction_signing'
522- } )
523- errorToast (
524- `USDC ${
525- isDepositMode ? 'Deposit' : 'Withdrawal'
526- } transaction failed: ${ ( error as Error ) ?. message ?? error } `
527- )
528- }
529-
530- const childChainName = getNetworkName ( childChain . id )
531-
532- if ( isSmartContractWallet ) {
533- // For SCW, we assume that the transaction went through
534- trackEvent ( isDepositMode ? 'CCTP Deposit' : 'CCTP Withdrawal' , {
535- accountType : 'Smart Contract' ,
536- network : childChainName ,
537- amount : Number ( amount ) ,
538- complete : false ,
539- version : 2
540- } )
541-
542- return
543- }
544-
545- if ( ! depositForBurnTx ) {
546- return
547- }
548-
549- trackEvent ( isDepositMode ? 'CCTP Deposit' : 'CCTP Withdrawal' , {
550- accountType : 'EOA' ,
551- network : childChainName ,
552- amount : Number ( amount ) ,
553- complete : false ,
554- version : 2
555- } )
556-
557- const newTransfer : MergedTransaction = {
558- txId : depositForBurnTx . hash ,
559- asset : 'USDC' ,
560- assetType : AssetType . ERC20 ,
561- blockNum : null ,
562- createdAt : dayjs ( ) . valueOf ( ) ,
563- direction : isDepositMode ? 'deposit' : 'withdraw' ,
564- isWithdrawal : ! isDepositMode ,
565- resolvedAt : null ,
566- status : 'pending' ,
567- uniqueId : null ,
568- value : amount ,
569- depositStatus : DepositStatus . CCTP_DEFAULT_STATE ,
570- destination : destinationAddress ?? walletAddress ,
571- sender : walletAddress ,
572- isCctp : true ,
573- tokenAddress : getUsdcTokenAddressFromSourceChainId ( sourceChain . id ) ,
574- cctpData : {
575- sourceChainId : sourceChain . id ,
576- attestationHash : null ,
577- messageBytes : null ,
578- receiveMessageTransactionHash : null ,
579- receiveMessageTimestamp : null
580- } ,
581- parentChainId : parentChain . id ,
582- childChainId : childChain . id ,
583- sourceChainId : networks . sourceChain . id ,
584- destinationChainId : networks . destinationChain . id
585- }
586-
587- addPendingTransaction ( newTransfer )
588- switchToTransactionHistoryTab ( )
589517 setTransferring ( false )
590518 clearAmountInput ( )
591519 clearRoute ( )
0 commit comments