Skip to content

Commit

Permalink
feat: make naming consistent for child tx (#514)
Browse files Browse the repository at this point in the history
  • Loading branch information
spsjvc authored Jul 10, 2024
1 parent da6d81a commit 0e0a082
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/lib/assetBridger/l1l3Bridger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ export class Erc20L1L3Bridger extends BaseL1L3Bridger {
factoryRedeem.status === ParentToChildMessageStatus.REDEEMED
? (
await new ParentTransactionReceipt(
factoryRedeem.txReceipt
factoryRedeem.childTxReceipt
).getParentToChildMessages(params.l3Provider)
)[0]
: undefined
Expand Down Expand Up @@ -1601,7 +1601,7 @@ export class EthL1L3Bridger extends BaseL1L3Bridger {

const l2l3Message = (
await new ParentEthDepositTransactionReceipt(
l1l2Redeem.txReceipt
l1l2Redeem.childTxReceipt
).getParentToChildMessages(params.l3Provider)
)[0]

Expand Down
28 changes: 14 additions & 14 deletions src/lib/message/ParentToChildMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,13 @@ export abstract class ParentToChildMessage {
}

/**
* If the status is redeemed an chainTxReceipt is populated.
* For all other statuses chainTxReceipt is not populated
* If the status is redeemed, childTxReceipt is populated.
* For all other statuses childTxReceipt is not populated
*/
export type ParentToChildMessageWaitForStatusResult =
| {
status: ParentToChildMessageStatus.REDEEMED
txReceipt: TransactionReceipt
childTxReceipt: TransactionReceipt
}
| {
status: Exclude<
Expand All @@ -250,7 +250,7 @@ export type ParentToChildMessageWaitForStatusResult =
}

export type EthDepositMessageWaitForStatusResult = {
txReceipt: TransactionReceipt | null
childTxReceipt: TransactionReceipt | null
}

export class ParentToChildMessageReader extends ParentToChildMessage {
Expand Down Expand Up @@ -337,7 +337,7 @@ export class ParentToChildMessageReader extends ParentToChildMessage {
const autoRedeem = await this.getAutoRedeemAttempt()
if (autoRedeem && autoRedeem.status === 1) {
return {
txReceipt: autoRedeem,
childTxReceipt: autoRedeem,
status: ParentToChildMessageStatus.REDEEMED,
}
}
Expand Down Expand Up @@ -395,7 +395,7 @@ export class ParentToChildMessageReader extends ParentToChildMessage {
)
if (successfulRedeem.length == 1)
return {
txReceipt: successfulRedeem[0],
childTxReceipt: successfulRedeem[0],
status: ParentToChildMessageStatus.REDEEMED,
}

Expand Down Expand Up @@ -758,8 +758,8 @@ export class ParentToChildMessageWriter extends ParentToChildMessageReader {
* A message for Eth deposits from Parent to Child
*/
export class EthDepositMessage {
public readonly childDepositTxHash: string
private childDepositTxReceipt: TransactionReceipt | undefined | null
public readonly childTxHash: string
private childTxReceipt: TransactionReceipt | undefined | null

public static calculateDepositTxId(
childChainId: number,
Expand Down Expand Up @@ -857,7 +857,7 @@ export class EthDepositMessage {
public readonly to: string,
public readonly value: BigNumber
) {
this.childDepositTxHash = EthDepositMessage.calculateDepositTxId(
this.childTxHash = EthDepositMessage.calculateDepositTxId(
childChainId,
messageNumber,
from,
Expand All @@ -868,7 +868,7 @@ export class EthDepositMessage {

public async status(): Promise<EthDepositMessageStatus> {
const receipt = await this.childProvider.getTransactionReceipt(
this.childDepositTxHash
this.childTxHash
)
if (receipt === null) return EthDepositMessageStatus.PENDING
else return EthDepositMessageStatus.DEPOSITED
Expand All @@ -877,15 +877,15 @@ export class EthDepositMessage {
public async wait(confirmations?: number, timeout?: number) {
const chosenTimeout = isDefined(timeout) ? timeout : DEFAULT_DEPOSIT_TIMEOUT

if (!this.childDepositTxReceipt) {
this.childDepositTxReceipt = await getTransactionReceipt(
if (!this.childTxReceipt) {
this.childTxReceipt = await getTransactionReceipt(
this.childProvider,
this.childDepositTxHash,
this.childTxHash,
confirmations,
chosenTimeout
)
}

return this.childDepositTxReceipt || null
return this.childTxReceipt || null
}
}
2 changes: 1 addition & 1 deletion src/lib/message/ParentTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ export class ParentEthDepositTransactionReceipt extends ParentTransactionReceipt

return {
complete: isDefined(res),
txReceipt: res,
childTxReceipt: res,
message,
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/eth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ describe('Ether', async () => {
'message inputs value error'
).to.eq(ethToDeposit.toString())

prettyLog('childDepositTxHash: ' + waitResult.message.childDepositTxHash)
prettyLog('childDepositTxHash: ' + waitResult.message.childTxHash)
prettyLog('chain transaction found!')
expect(waitResult.complete).to.eq(true, 'eth deposit not complete')
expect(waitResult.txReceipt).to.exist
expect(waitResult.txReceipt).to.not.be.null
expect(waitResult.childTxReceipt).to.exist
expect(waitResult.childTxReceipt).to.not.be.null

const testWalletChildEthBalance = await childSigner.getBalance()
expect(testWalletChildEthBalance.toString(), 'final balance').to.eq(
Expand Down

0 comments on commit 0e0a082

Please sign in to comment.