Skip to content

Commit

Permalink
chore: rename transaction history helpers (#1821)
Browse files Browse the repository at this point in the history
Co-authored-by: Fionna Chan <[email protected]>
  • Loading branch information
douglance and fionnachan authored Aug 19, 2024
1 parent 647e7d8 commit 377c191
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,15 +280,15 @@ export async function getUpdatedEthDeposit(
return tx
}

const { parentToChildMsg: l1ToL2Msg } =
const { parentToChildMsg } =
await getParentToChildMessageDataFromParentTxHash({
depositTxId: tx.txId,
isEthDeposit: true,
parentProvider: getProviderForChainId(tx.parentChainId),
childProvider: getProviderForChainId(tx.childChainId)
})

if (!l1ToL2Msg) {
if (!parentToChildMsg) {
const receipt = await getTxReceipt(tx)

if (!receipt || receipt.status !== 0) {
Expand All @@ -300,7 +300,7 @@ export async function getUpdatedEthDeposit(
return { ...tx, status: 'failure', depositStatus: DepositStatus.L1_FAILURE }
}

const status = await l1ToL2Msg?.status()
const status = await parentToChildMsg?.status()
const isDeposited = status === EthDepositMessageStatus.DEPOSITED

const newDeposit: MergedTransaction = {
Expand All @@ -312,10 +312,11 @@ export async function getUpdatedEthDeposit(
status: isDeposited
? ParentToChildMessageStatus.FUNDS_DEPOSITED_ON_CHILD
: ParentToChildMessageStatus.NOT_YET_CREATED,
retryableCreationTxID: (l1ToL2Msg as EthDepositMessage).childTxHash,
retryableCreationTxID: (parentToChildMsg as EthDepositMessage)
.childTxHash,
// Only show `childTxId` after the deposit is confirmed
childTxId: isDeposited
? (l1ToL2Msg as EthDepositMessage).childTxHash
? (parentToChildMsg as EthDepositMessage).childTxHash
: undefined
}
}
Expand All @@ -338,16 +339,15 @@ export async function getUpdatedTokenDeposit(
return tx
}

const { parentToChildMsg: l1ToL2Msg } =
const { parentToChildMsg } =
await getParentToChildMessageDataFromParentTxHash({
depositTxId: tx.txId,
isEthDeposit: false,
parentProvider: getProviderForChainId(tx.parentChainId),
childProvider: getProviderForChainId(tx.childChainId)
})
const _l1ToL2Msg = l1ToL2Msg as ParentToChildMessageReader

if (!l1ToL2Msg) {
if (!parentToChildMsg) {
const receipt = await getTxReceipt(tx)

if (!receipt || receipt.status !== 0) {
Expand All @@ -359,7 +359,8 @@ export async function getUpdatedTokenDeposit(
return { ...tx, status: 'failure', depositStatus: DepositStatus.L1_FAILURE }
}

const res = await _l1ToL2Msg.getSuccessfulRedeem()
const _parentToChildMsg = parentToChildMsg as ParentToChildMessageReader
const res = await _parentToChildMsg.getSuccessfulRedeem()

const childTxId = (() => {
if (res.status === ParentToChildMessageStatus.REDEEMED) {
Expand All @@ -371,7 +372,7 @@ export async function getUpdatedTokenDeposit(

const newDeposit: MergedTransaction = {
...tx,
status: _l1ToL2Msg.retryableCreationId ? 'success' : tx.status,
status: _parentToChildMsg.retryableCreationId ? 'success' : tx.status,
resolvedAt:
res.status === ParentToChildMessageStatus.REDEEMED
? dayjs().valueOf()
Expand All @@ -380,7 +381,7 @@ export async function getUpdatedTokenDeposit(
status: res.status,
childTxId,
fetchingUpdate: false,
retryableCreationTxID: _l1ToL2Msg.retryableCreationId
retryableCreationTxID: _parentToChildMsg.retryableCreationId
}
}

Expand Down

0 comments on commit 377c191

Please sign in to comment.