Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: redeem teleport error #2321

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/arb-token-bridge-ui/src/state/app/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ export interface MergedTransaction {
}

export interface TeleporterMergedTransaction extends MergedTransaction {
/** note: in contrast to general deposits which use `parentToChildMsgData`,
* Teleport transfers still follow L1/L2/L3 terminology, so we have `l1ToL2MsgData` and `l2ToL3MsgData` */
l1ToL2MsgData?: ParentToChildMessageData
l2ToL3MsgData: L2ToL3MessageData
}
Expand Down
16 changes: 9 additions & 7 deletions packages/arb-token-bridge-ui/src/state/app/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,20 @@ export const getDepositStatus = (
}

if (isTeleportTx(tx)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only in the case of Teleport txns, we access l1ToL2MsgData

const { l2ToL3MsgData, parentToChildMsgData } = tx
/** note: in contrast to general deposits which use `parentToChildMsgData`,
* Teleport transfers still follow L1/L2/L3 terminology, so we have `l1ToL2MsgData` and `l2ToL3MsgData` */

const { l1ToL2MsgData, l2ToL3MsgData } = tx

// if any of the retryable info is missing, first fetch might be pending
if (!parentToChildMsgData || !l2ToL3MsgData) return DepositStatus.L2_PENDING
if (!l1ToL2MsgData || !l2ToL3MsgData) return DepositStatus.L2_PENDING

// if we find `l2ForwarderRetryableTxID` then this tx will need to be redeemed
if (l2ToL3MsgData.l2ForwarderRetryableTxID) return DepositStatus.L2_FAILURE

// if we find first retryable leg failing, then no need to check for the second leg
const firstLegDepositStatus = getDepositStatusFromL1ToL2MessageStatus(
parentToChildMsgData.status
l1ToL2MsgData.status
)
if (firstLegDepositStatus !== DepositStatus.L2_SUCCESS) {
return firstLegDepositStatus
Expand All @@ -85,13 +88,11 @@ export const getDepositStatus = (
if (typeof secondLegDepositStatus !== 'undefined') {
return secondLegDepositStatus
}
switch (parentToChildMsgData.status) {
switch (l1ToL2MsgData.status) {
case ParentToChildMessageStatus.REDEEMED:
return DepositStatus.L2_PENDING // tx is still pending if `l1ToL2MsgData` is redeemed (but l2ToL3MsgData is not)
default:
return getDepositStatusFromL1ToL2MessageStatus(
parentToChildMsgData.status
)
return getDepositStatusFromL1ToL2MessageStatus(l1ToL2MsgData.status)
}
}

Expand Down Expand Up @@ -172,6 +173,7 @@ export const transformDeposit = (
if (isTeleportTx(tx)) {
return {
...transaction,
l1ToL2MsgData: tx.l1ToL2MsgData,
l2ToL3MsgData: tx.l2ToL3MsgData
}
}
Expand Down
4 changes: 4 additions & 0 deletions packages/arb-token-bridge-ui/src/types/Transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ export interface Transaction extends TransactionBase {
}

export interface TeleporterTransaction extends Transaction {
/** note: in contrast to general deposits which use `parentToChildMsgData`,
* Teleport transfers still follow L1/L2/L3 terminology, so we have `l1ToL2MsgData` and `l2ToL3MsgData` */

l1ToL2MsgData: ParentToChildMessageData
l2ToL3MsgData: L2ToL3MessageData
}

Expand Down
2 changes: 1 addition & 1 deletion packages/arb-token-bridge-ui/src/util/RetryableUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const l1L2RetryableRequiresRedeem = (
tx: TeleporterMergedTransaction
) => {
return (
tx.parentToChildMsgData?.status ===
tx.l1ToL2MsgData?.status ===
ParentToChildMessageStatus.FUNDS_DEPOSITED_ON_CHILD
)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/arb-token-bridge-ui/src/util/deposits/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const updateAdditionalDepositData = async (
...depositTx,
status,
timestampResolved,
parentToChildMsgData: l1ToL2MsgData,
l1ToL2MsgData,
l2ToL3MsgData
}
}
Expand Down
Loading