Skip to content

Commit

Permalink
Merge pull request OffchainLabs#1767 from OffchainLabs/arb-ts-cheap-q…
Browse files Browse the repository at this point in the history
…uery

Deprecate old arb-ts function and add getter without log queries
  • Loading branch information
DZGoldman authored Oct 28, 2021
2 parents 88d859e + 2f71463 commit 60b09db
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/arb-ts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "arb-ts",
"version": "1.0.0",
"version": "1.0.1",
"description": "Typescript library client-side interactions with Arbitrum",
"author": "Offchain Labs, Inc.",
"license": "Apache-2.0",
Expand Down
39 changes: 37 additions & 2 deletions packages/arb-ts/src/lib/bridge_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,41 @@ export class BridgeHelper {
/**
* Check if given outbox message has already been executed
*/
static messageHasExecutedV2 = async (
batchNumber: BigNumber,
outboxProofData: MessageBatchProofInfo,
outboxAddress: string,
l1Provider: Provider
): Promise<boolean> => {
const outbox = Outbox__factory.connect(outboxAddress, l1Provider)
try {
const outboxExecute = await outbox.callStatic.executeTransaction(
batchNumber,
outboxProofData.proof,
outboxProofData.path,
outboxProofData.l2Sender,
outboxProofData.l1Dest,
outboxProofData.l2Block,
outboxProofData.l1Block,
outboxProofData.timestamp,
outboxProofData.amount,
outboxProofData.calldataForL1
)
return false
} catch (e: any) {
if (e && e.message && e.message.toString().includes('ALREADY_SPENT')) {
return true
}
if (e && e.message && e.message.toString().includes('NO_OUTBOX_ENTRY')) {
return false
}
throw e
}
}

/**
* @deprecated The method should not be used
*/
static messageHasExecuted = async (
batchNumber: BigNumber,
path: BigNumber,
Expand Down Expand Up @@ -748,9 +783,9 @@ export class BridgeHelper {
return OutgoingMessageState.UNCONFIRMED
}

const messageExecuted = await BridgeHelper.messageHasExecuted(
const messageExecuted = await BridgeHelper.messageHasExecutedV2(
batchNumber,
proofData.path,
proofData,
outBoxAddress,
l1Provider
)
Expand Down

0 comments on commit 60b09db

Please sign in to comment.