@@ -459,6 +459,13 @@ export function TransferPanel() {
459459 return { error : error as unknown as Error }
460460 }
461461 }
462+
463+ case 'tx_history_add' : {
464+ addPendingTransaction ( step . payload )
465+ switchToTransactionHistoryTab ( )
466+
467+ return
468+ }
462469 }
463470 }
464471
@@ -479,22 +486,31 @@ export function TransferPanel() {
479486 const destinationAddress = latestDestinationAddress . current
480487
481488 try {
482- const { sourceChainProvider, destinationChainProvider, sourceChain } =
483- latestNetworks . current
489+ const {
490+ sourceChainProvider,
491+ destinationChainProvider,
492+ sourceChain,
493+ destinationChain
494+ } = latestNetworks . current
484495
485496 const cctpTransferStarter = new CctpTransferStarter ( {
486497 sourceChainProvider,
487498 destinationChainProvider
488499 } )
489500
490501 const returnEarly = await drive ( stepGeneratorForCctp , stepExecutor , {
502+ amount,
491503 amountBigNumber,
492504 isDepositMode,
493505 isSmartContractWallet,
494506 walletAddress,
495507 destinationAddress,
496508 transferStarter : cctpTransferStarter ,
497- wagmiConfig
509+ wagmiConfig,
510+ sourceChain,
511+ destinationChain,
512+ childChain,
513+ parentChain
498514 } )
499515
500516 // this is only necessary while we are migrating to the ui driver
@@ -505,94 +521,6 @@ export function TransferPanel() {
505521 return
506522 }
507523
508- let depositForBurnTx
509-
510- try {
511- if ( isSmartContractWallet ) {
512- showDelayedSmartContractTxRequest ( )
513- }
514- const transfer = await cctpTransferStarter . transfer ( {
515- amount : amountBigNumber ,
516- signer,
517- destinationAddress,
518- wagmiConfig
519- } )
520- depositForBurnTx = transfer . sourceChainTransaction
521- } catch ( error ) {
522- if ( isUserRejectedError ( error ) ) {
523- return
524- }
525- handleError ( {
526- error,
527- label : 'cctp_transfer' ,
528- category : 'transaction_signing'
529- } )
530- errorToast (
531- `USDC ${
532- isDepositMode ? 'Deposit' : 'Withdrawal'
533- } transaction failed: ${ ( error as Error ) ?. message ?? error } `
534- )
535- }
536-
537- const childChainName = getNetworkName ( childChain . id )
538-
539- if ( isSmartContractWallet ) {
540- // For SCW, we assume that the transaction went through
541- trackEvent ( isDepositMode ? 'CCTP Deposit' : 'CCTP Withdrawal' , {
542- accountType : 'Smart Contract' ,
543- network : childChainName ,
544- amount : Number ( amount ) ,
545- complete : false ,
546- version : 2
547- } )
548-
549- return
550- }
551-
552- if ( ! depositForBurnTx ) {
553- return
554- }
555-
556- trackEvent ( isDepositMode ? 'CCTP Deposit' : 'CCTP Withdrawal' , {
557- accountType : 'EOA' ,
558- network : childChainName ,
559- amount : Number ( amount ) ,
560- complete : false ,
561- version : 2
562- } )
563-
564- const newTransfer : MergedTransaction = {
565- txId : depositForBurnTx . hash ,
566- asset : 'USDC' ,
567- assetType : AssetType . ERC20 ,
568- blockNum : null ,
569- createdAt : dayjs ( ) . valueOf ( ) ,
570- direction : isDepositMode ? 'deposit' : 'withdraw' ,
571- isWithdrawal : ! isDepositMode ,
572- resolvedAt : null ,
573- status : 'pending' ,
574- uniqueId : null ,
575- value : amount ,
576- depositStatus : DepositStatus . CCTP_DEFAULT_STATE ,
577- destination : destinationAddress ?? walletAddress ,
578- sender : walletAddress ,
579- isCctp : true ,
580- tokenAddress : getUsdcTokenAddressFromSourceChainId ( sourceChain . id ) ,
581- cctpData : {
582- sourceChainId : sourceChain . id ,
583- attestationHash : null ,
584- messageBytes : null ,
585- receiveMessageTransactionHash : null ,
586- receiveMessageTimestamp : null
587- } ,
588- parentChainId : parentChain . id ,
589- childChainId : childChain . id ,
590- sourceChainId : networks . sourceChain . id ,
591- destinationChainId : networks . destinationChain . id
592- }
593-
594- addPendingTransaction ( newTransfer )
595- switchToTransactionHistoryTab ( )
596524 setTransferring ( false )
597525 clearAmountInput ( )
598526 clearRoute ( )
0 commit comments