Skip to content
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
21 changes: 20 additions & 1 deletion packages/sdk/src/lib/message/ChildToParentMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { Signer } from '@ethersproject/abstract-signer'
import { BigNumber } from '@ethersproject/bignumber'
import { BlockTag } from '@ethersproject/abstract-provider'

import { ContractTransaction, Overrides } from 'ethers'
import { ContractTransaction, Overrides, PopulatedTransaction } from 'ethers'
import {
SignerProviderUtils,
SignerOrProvider,
Expand Down Expand Up @@ -316,6 +316,25 @@ export class ChildToParentMessageWriter extends ChildToParentMessageReader {
}
}

/**
* Gets the execute transaction for the ChildToParentMessage on Parent chain.
* Will throw an error if the outbox entry has not been created, which happens when the
* corresponding assertion is confirmed.
* @returns The populated transaction that can be sent to execute the message
*/
public async getExecuteTransaction(
childProvider: Provider,
overrides?: Overrides
): Promise<PopulatedTransaction> {
if (this.nitroWriter)
return this.nitroWriter.getExecuteTransaction(childProvider, overrides)
else
return await this.classicWriter!.getExecuteTransaction(
childProvider,
overrides
)
}

/**
* Executes the ChildToParentMessage on Parent chain.
* Will throw an error if the outbox entry has not been created, which happens when the
Expand Down
26 changes: 20 additions & 6 deletions packages/sdk/src/lib/message/ChildToParentMessageClassic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { Outbox__factory } from '../abi/classic/factories/Outbox__factory'

import { NodeInterface__factory } from '../abi/factories/NodeInterface__factory'
import { L2ToL1TransactionEvent as ChildToParentTransactionEvent } from '../abi/ArbSys'
import { ContractTransaction, Overrides } from 'ethers'
import { ContractTransaction, Overrides, PopulatedTransaction } from 'ethers'
import { EventFetcher } from '../utils/eventFetcher'
import {
SignerProviderUtils,
Expand Down Expand Up @@ -413,15 +413,15 @@ export class ChildToParentMessageWriterClassic extends ChildToParentMessageReade
}

/**
* Executes the ChildToParentMessage on Parent Chain.
* Gets the execute transaction for the ChildToParentMessage on Parent Chain.
* Will throw an error if the outbox entry has not been created, which happens when the
* corresponding assertion is confirmed.
* @returns
* @returns The populated transaction that can be sent to execute the message
*/
public async execute(
public async getExecuteTransaction(
childProvider: Provider,
overrides?: Overrides
): Promise<ContractTransaction> {
): Promise<PopulatedTransaction> {
const status = await this.status(childProvider)
if (status !== ChildToParentMessageStatus.CONFIRMED) {
throw new ArbSdkError(
Expand All @@ -442,7 +442,7 @@ export class ChildToParentMessageWriterClassic extends ChildToParentMessageReade
const outbox = Outbox__factory.connect(outboxAddress, this.parentSigner)
// We can predict and print number of missing blocks
// if not challenged
return await outbox.functions.executeTransaction(
return await outbox.populateTransaction.executeTransaction(
this.batchNumber,
proofInfo.proof,
proofInfo.path,
Expand All @@ -456,4 +456,18 @@ export class ChildToParentMessageWriterClassic extends ChildToParentMessageReade
overrides || {}
)
}

/**
* Executes the ChildToParentMessage on Parent Chain.
* Will throw an error if the outbox entry has not been created, which happens when the
* corresponding assertion is confirmed.
* @returns
*/
public async execute(
childProvider: Provider,
overrides?: Overrides
): Promise<ContractTransaction> {
const txRequest = await this.getExecuteTransaction(childProvider, overrides)
return await this.parentSigner.sendTransaction(txRequest)
}
}
26 changes: 20 additions & 6 deletions packages/sdk/src/lib/message/ChildToParentMessageNitro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { Outbox__factory } from '../abi/factories/Outbox__factory'
import { NodeInterface__factory } from '../abi/factories/NodeInterface__factory'

import { L2ToL1TxEvent as ChildToParentTxEvent } from '../abi/ArbSys'
import { ContractTransaction, Overrides } from 'ethers'
import { ContractTransaction, Overrides, PopulatedTransaction } from 'ethers'
import { Mutex } from 'async-mutex'
import { EventFetcher, FetchedEvent } from '../utils/eventFetcher'
import { ArbSdkError } from '../dataEntities/errors'
Expand Down Expand Up @@ -742,15 +742,15 @@ export class ChildToParentMessageWriterNitro extends ChildToParentMessageReaderN
}

/**
* Executes the ChildToParentMessage on Parent Chain.
* Gets the execute transaction for the ChildToParentMessage on Parent Chain.
* Will throw an error if the outbox entry has not been created, which happens when the
* corresponding assertion is confirmed.
* @returns
* @returns The populated transaction that can be sent to execute the message
*/
public async execute(
public async getExecuteTransaction(
childProvider: Provider,
overrides?: Overrides
): Promise<ContractTransaction> {
): Promise<PopulatedTransaction> {
const status = await this.status(childProvider)
if (status !== ChildToParentMessageStatus.CONFIRMED) {
throw new ArbSdkError(
Expand All @@ -764,7 +764,7 @@ export class ChildToParentMessageWriterNitro extends ChildToParentMessageReaderN
this.parentSigner
)

return await outbox.executeTransaction(
return await outbox.populateTransaction.executeTransaction(
proof,
this.event.position,
this.event.caller,
Expand All @@ -777,4 +777,18 @@ export class ChildToParentMessageWriterNitro extends ChildToParentMessageReaderN
overrides || {}
)
}

/**
* Executes the ChildToParentMessage on Parent Chain.
* Will throw an error if the outbox entry has not been created, which happens when the
* corresponding assertion is confirmed.
* @returns
*/
public async execute(
childProvider: Provider,
overrides?: Overrides
): Promise<ContractTransaction> {
const txRequest = await this.getExecuteTransaction(childProvider, overrides)
return await this.parentSigner.sendTransaction(txRequest)
}
}
Loading