diff --git a/packages/checkout/widgets-lib/src/context/view-context/XBridgeViewContextTypes.ts b/packages/checkout/widgets-lib/src/context/view-context/XBridgeViewContextTypes.ts index b468cd7bd9..981293f8e6 100644 --- a/packages/checkout/widgets-lib/src/context/view-context/XBridgeViewContextTypes.ts +++ b/packages/checkout/widgets-lib/src/context/view-context/XBridgeViewContextTypes.ts @@ -42,10 +42,6 @@ interface XBridgeFailure extends ViewType { interface XBridgeApproveTransaction extends ViewType { type: XBridgeWidgetViews.APPROVE_TRANSACTION, - data: ApproveTransactionData -} - -export interface ApproveTransactionData { approveTransaction: ApproveBridgeResponse; transaction: BridgeTxResponse; } diff --git a/packages/checkout/widgets-lib/src/widgets/x-bridge/XBridgeWidget.tsx b/packages/checkout/widgets-lib/src/widgets/x-bridge/XBridgeWidget.tsx index 310c0b5e87..d52c3200e7 100644 --- a/packages/checkout/widgets-lib/src/widgets/x-bridge/XBridgeWidget.tsx +++ b/packages/checkout/widgets-lib/src/widgets/x-bridge/XBridgeWidget.tsx @@ -170,18 +170,29 @@ export function XBridgeWidget({ transactionHash={viewState.view.transactionHash} /> )} - {viewState.view.type === XBridgeWidgetViews.BRIDGE_FAILURE && ( - sendBridgeFailedEvent(eventTarget, viewState.view.data.reason)} - /> - )} + {viewState.view.type === XBridgeWidgetViews.BRIDGE_FAILURE + && ( + { + let reason = ''; + if (viewState.view.type === XBridgeWidgetViews.BRIDGE_FAILURE) { + reason = viewState.view.reason; + } + sendBridgeFailedEvent(eventTarget, reason); + }} + /> + )} + {viewState.view.type === XBridgeWidgetViews.APPROVE_TRANSACTION && ( - + )} {viewState.view.type === SharedViews.ERROR_VIEW && ( { let bridgeRejected = false; - if (!checkout || !from?.web3Provider || !data.transaction) { + if (!checkout || !from?.web3Provider || !transaction) { showErrorView(); return; } @@ -112,12 +114,12 @@ export function ApproveTransaction({ data }: ApproveTransactionProps) { setActionDisabled(true); // Approvals as required - if (data.approveTransaction.unsignedTx) { + if (approveTransaction.unsignedTx) { try { setTxProcessing(true); const approveSpendingResult = await checkout.sendTransaction({ provider: from.web3Provider, - transaction: data.approveTransaction.unsignedTx, + transaction: approveTransaction.unsignedTx, }); const approvalReceipt = await approveSpendingResult.transactionResponse.wait(); if (approvalReceipt.status !== 1) { @@ -150,7 +152,7 @@ export function ApproveTransaction({ data }: ApproveTransactionProps) { setTxProcessing(true); const sendResult = await checkout.sendTransaction({ provider: from.web3Provider, - transaction: data.transaction.unsignedTx, + transaction: transaction.unsignedTx, }); setLoading(true); @@ -194,8 +196,8 @@ export function ApproveTransaction({ data }: ApproveTransactionProps) { from, showErrorView, viewDispatch, - data.transaction, - data.approveTransaction, + transaction, + approveTransaction, actionDisabled, ]);