Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
d90e7818
Unverified
Commit
d90e7818
authored
Jul 19, 2023
by
Wilson Cusack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up code comments
parent
33cafd95
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
57 deletions
+27
-57
cross-chain-messenger.ts
packages/sdk/src/cross-chain-messenger.ts
+27
-57
No files found.
packages/sdk/src/cross-chain-messenger.ts
View file @
d90e7818
...
@@ -326,13 +326,11 @@ export class CrossChainMessenger {
...
@@ -326,13 +326,11 @@ export class CrossChainMessenger {
* Transforms a legacy message into its corresponding Bedrock representation.
* Transforms a legacy message into its corresponding Bedrock representation.
*
*
* @param message Legacy message to transform.
* @param message Legacy message to transform.
* @param messageIndex The index of the message, if multiple exist from multicall
* @returns Bedrock representation of the message.
* @returns Bedrock representation of the message.
*/
*/
public
async
toBedrockCrossChainMessage
(
public
async
toBedrockCrossChainMessage
(
message
:
MessageLike
,
message
:
MessageLike
,
/**
* The index of the withdrawal if multiple are made with multicall
*/
messageIndex
=
0
messageIndex
=
0
):
Promise
<
CrossChainMessage
>
{
):
Promise
<
CrossChainMessage
>
{
const
resolved
=
await
this
.
toCrossChainMessage
(
message
,
messageIndex
)
const
resolved
=
await
this
.
toCrossChainMessage
(
message
,
messageIndex
)
...
@@ -376,13 +374,11 @@ export class CrossChainMessenger {
...
@@ -376,13 +374,11 @@ export class CrossChainMessenger {
* L2ToL1MessagePasser contract on L2.
* L2ToL1MessagePasser contract on L2.
*
*
* @param message Message to transform.
* @param message Message to transform.
* @param messageIndex The index of the message, if multiple exist from multicall
* @return Transformed message.
* @return Transformed message.
*/
*/
public
async
toLowLevelMessage
(
public
async
toLowLevelMessage
(
message
:
MessageLike
,
message
:
MessageLike
,
/**
* The index of the withdrawal if multiple are made with multicall
*/
messageIndex
=
0
messageIndex
=
0
):
Promise
<
LowLevelMessage
>
{
):
Promise
<
LowLevelMessage
>
{
const
resolved
=
await
this
.
toCrossChainMessage
(
message
,
messageIndex
)
const
resolved
=
await
this
.
toCrossChainMessage
(
message
,
messageIndex
)
...
@@ -586,13 +582,11 @@ export class CrossChainMessenger {
...
@@ -586,13 +582,11 @@ export class CrossChainMessenger {
* create an entire CrossChainProvider object.
* create an entire CrossChainProvider object.
*
*
* @param message MessageLike to resolve into a CrossChainMessage.
* @param message MessageLike to resolve into a CrossChainMessage.
* @param messageIndex The index of the message, if multiple exist from multicall
* @returns Message coerced into a CrossChainMessage.
* @returns Message coerced into a CrossChainMessage.
*/
*/
public
async
toCrossChainMessage
(
public
async
toCrossChainMessage
(
message
:
MessageLike
,
message
:
MessageLike
,
/**
* The index of the withdrawal if multiple are made with multicall
*/
messageIndex
=
0
messageIndex
=
0
):
Promise
<
CrossChainMessage
>
{
):
Promise
<
CrossChainMessage
>
{
if
(
!
message
)
{
if
(
!
message
)
{
...
@@ -651,14 +645,13 @@ export class CrossChainMessenger {
...
@@ -651,14 +645,13 @@ export class CrossChainMessenger {
* Retrieves the status of a particular message as an enum.
* Retrieves the status of a particular message as an enum.
*
*
* @param message Cross chain message to check the status of.
* @param message Cross chain message to check the status of.
* @param messageIndex The index of the message, if multiple exist from multicall
* @param fromBlockOrBlockHash The start block to use for the query filter on the RECEIVING chain
* @param toBlockOrBlockHash The end block to use for the query filter on the RECEIVING chain
* @returns Status of the message.
* @returns Status of the message.
*/
*/
public
async
getMessageStatus
(
public
async
getMessageStatus
(
message
:
MessageLike
,
message
:
MessageLike
,
/**
* The index of the withdrawal if multiple are made with multicall
*/
// consider making this an options object next breaking release
// consider making this an options object next breaking release
messageIndex
=
0
,
messageIndex
=
0
,
fromBlockOrBlockHash
?:
BlockTag
,
fromBlockOrBlockHash
?:
BlockTag
,
...
@@ -705,7 +698,6 @@ export class CrossChainMessenger {
...
@@ -705,7 +698,6 @@ export class CrossChainMessenger {
await
this
.
contracts
.
l1
.
OptimismPortal
.
provenWithdrawals
(
await
this
.
contracts
.
l1
.
OptimismPortal
.
provenWithdrawals
(
hashLowLevelMessage
(
withdrawal
)
hashLowLevelMessage
(
withdrawal
)
)
)
// If the withdrawal hash has not been proven on L1,
// If the withdrawal hash has not been proven on L1,
// return `READY_TO_PROVE`
// return `READY_TO_PROVE`
if
(
provenWithdrawal
.
timestamp
.
eq
(
BigNumber
.
from
(
0
)))
{
if
(
provenWithdrawal
.
timestamp
.
eq
(
BigNumber
.
from
(
0
)))
{
...
@@ -750,15 +742,14 @@ export class CrossChainMessenger {
...
@@ -750,15 +742,14 @@ export class CrossChainMessenger {
* Finds the receipt of the transaction that executed a particular cross chain message.
* Finds the receipt of the transaction that executed a particular cross chain message.
*
*
* @param message Message to find the receipt of.
* @param message Message to find the receipt of.
* @param messageIndex The index of the message, if multiple exist from multicall
* @param fromBlockOrBlockHash The start block to use for the query filter on the RECEIVING chain
* @param toBlockOrBlockHash The end block to use for the query filter on the RECEIVING chain
* @returns CrossChainMessage receipt including receipt of the transaction that relayed the
* @returns CrossChainMessage receipt including receipt of the transaction that relayed the
* given message.
* given message.
*/
*/
public
async
getMessageReceipt
(
public
async
getMessageReceipt
(
message
:
MessageLike
,
message
:
MessageLike
,
/**
* The index of the withdrawal if multiple are made with multicall
*/
messageIndex
=
0
,
messageIndex
=
0
,
fromBlockOrBlockHash
?:
BlockTag
,
fromBlockOrBlockHash
?:
BlockTag
,
toBlockOrHash
?:
BlockTag
toBlockOrHash
?:
BlockTag
...
@@ -864,6 +855,9 @@ export class CrossChainMessenger {
...
@@ -864,6 +855,9 @@ export class CrossChainMessenger {
* @param opts.confirmations Number of transaction confirmations to wait for before returning.
* @param opts.confirmations Number of transaction confirmations to wait for before returning.
* @param opts.pollIntervalMs Number of milliseconds to wait between polling for the receipt.
* @param opts.pollIntervalMs Number of milliseconds to wait between polling for the receipt.
* @param opts.timeoutMs Milliseconds to wait before timing out.
* @param opts.timeoutMs Milliseconds to wait before timing out.
* @param opts.fromBlockOrBlockHash The start block to use for the query filter on the RECEIVING chain
* @param opts.toBlockOrBlockHash The end block to use for the query filter on the RECEIVING chain
* @param messageIndex The index of the message, if multiple exist from multicall
* @returns CrossChainMessage receipt including receipt of the transaction that relayed the
* @returns CrossChainMessage receipt including receipt of the transaction that relayed the
* given message.
* given message.
*/
*/
...
@@ -916,6 +910,9 @@ export class CrossChainMessenger {
...
@@ -916,6 +910,9 @@ export class CrossChainMessenger {
* @param opts Options to pass to the waiting function.
* @param opts Options to pass to the waiting function.
* @param opts.pollIntervalMs Number of milliseconds to wait when polling.
* @param opts.pollIntervalMs Number of milliseconds to wait when polling.
* @param opts.timeoutMs Milliseconds to wait before timing out.
* @param opts.timeoutMs Milliseconds to wait before timing out.
* @param opts.fromBlockOrBlockHash The start block to use for the query filter on the RECEIVING chain
* @param opts.toBlockOrBlockHash The end block to use for the query filter on the RECEIVING chain
* @param messageIndex The index of the message, if multiple exist from multicall
*/
*/
public
async
waitForMessageStatus
(
public
async
waitForMessageStatus
(
message
:
MessageLike
,
message
:
MessageLike
,
...
@@ -926,10 +923,6 @@ export class CrossChainMessenger {
...
@@ -926,10 +923,6 @@ export class CrossChainMessenger {
pollIntervalMs
?:
number
pollIntervalMs
?:
number
timeoutMs
?:
number
timeoutMs
?:
number
}
=
{},
}
=
{},
/**
* The index of the withdrawal if multiple are made with multicall
*/
messageIndex
=
0
messageIndex
=
0
):
Promise
<
void
>
{
):
Promise
<
void
>
{
// Resolving once up-front is slightly more efficient.
// Resolving once up-front is slightly more efficient.
...
@@ -1050,14 +1043,13 @@ export class CrossChainMessenger {
...
@@ -1050,14 +1043,13 @@ export class CrossChainMessenger {
* amount of time until the message will be picked up and executed on L2.
* amount of time until the message will be picked up and executed on L2.
*
*
* @param message Message to estimate the time remaining for.
* @param message Message to estimate the time remaining for.
* @param messageIndex The index of the message, if multiple exist from multicall
* @param opts.fromBlockOrBlockHash The start block to use for the query filter on the RECEIVING chain
* @param opts.toBlockOrBlockHash The end block to use for the query filter on the RECEIVING chain
* @returns Estimated amount of time remaining (in seconds) before the message can be executed.
* @returns Estimated amount of time remaining (in seconds) before the message can be executed.
*/
*/
public
async
estimateMessageWaitTimeSeconds
(
public
async
estimateMessageWaitTimeSeconds
(
message
:
MessageLike
,
message
:
MessageLike
,
/**
* The index of the withdrawal if multiple are made with multicall
*/
// consider making this an options object next breaking release
// consider making this an options object next breaking release
messageIndex
=
0
,
messageIndex
=
0
,
fromBlockOrBlockHash
?:
BlockTag
,
fromBlockOrBlockHash
?:
BlockTag
,
...
@@ -1174,14 +1166,11 @@ export class CrossChainMessenger {
...
@@ -1174,14 +1166,11 @@ export class CrossChainMessenger {
* Returns the Bedrock output root that corresponds to the given message.
* Returns the Bedrock output root that corresponds to the given message.
*
*
* @param message Message to get the Bedrock output root for.
* @param message Message to get the Bedrock output root for.
* @param messageIndex The index of the message, if multiple exist from multicall
* @returns Bedrock output root.
* @returns Bedrock output root.
*/
*/
public
async
getMessageBedrockOutput
(
public
async
getMessageBedrockOutput
(
message
:
MessageLike
,
message
:
MessageLike
,
/**
* The index of the withdrawal if multiple are made with multicall
*/
messageIndex
=
0
messageIndex
=
0
):
Promise
<
BedrockOutputData
|
null
>
{
):
Promise
<
BedrockOutputData
|
null
>
{
const
resolved
=
await
this
.
toCrossChainMessage
(
message
,
messageIndex
)
const
resolved
=
await
this
.
toCrossChainMessage
(
message
,
messageIndex
)
...
@@ -1230,14 +1219,11 @@ export class CrossChainMessenger {
...
@@ -1230,14 +1219,11 @@ export class CrossChainMessenger {
* state root for the given message has not been published yet, this function returns null.
* state root for the given message has not been published yet, this function returns null.
*
*
* @param message Message to find a state root for.
* @param message Message to find a state root for.
* @param messageIndex The index of the message, if multiple exist from multicall
* @returns State root for the block in which the message was created.
* @returns State root for the block in which the message was created.
*/
*/
public
async
getMessageStateRoot
(
public
async
getMessageStateRoot
(
message
:
MessageLike
,
message
:
MessageLike
,
/**
* The index of the withdrawal if multiple are made with multicall
*/
messageIndex
=
0
messageIndex
=
0
):
Promise
<
StateRoot
|
null
>
{
):
Promise
<
StateRoot
|
null
>
{
const
resolved
=
await
this
.
toCrossChainMessage
(
message
,
messageIndex
)
const
resolved
=
await
this
.
toCrossChainMessage
(
message
,
messageIndex
)
...
@@ -1420,14 +1406,11 @@ export class CrossChainMessenger {
...
@@ -1420,14 +1406,11 @@ export class CrossChainMessenger {
* Generates the proof required to finalize an L2 to L1 message.
* Generates the proof required to finalize an L2 to L1 message.
*
*
* @param message Message to generate a proof for.
* @param message Message to generate a proof for.
* @param messageIndex The index of the message, if multiple exist from multicall
* @returns Proof that can be used to finalize the message.
* @returns Proof that can be used to finalize the message.
*/
*/
public
async
getMessageProof
(
public
async
getMessageProof
(
message
:
MessageLike
,
message
:
MessageLike
,
/**
* The index of the withdrawal if multiple are made with multicall
*/
messageIndex
=
0
messageIndex
=
0
):
Promise
<
CrossChainMessageProof
>
{
):
Promise
<
CrossChainMessageProof
>
{
const
resolved
=
await
this
.
toCrossChainMessage
(
message
,
messageIndex
)
const
resolved
=
await
this
.
toCrossChainMessage
(
message
,
messageIndex
)
...
@@ -1483,14 +1466,11 @@ export class CrossChainMessenger {
...
@@ -1483,14 +1466,11 @@ export class CrossChainMessenger {
* Generates the bedrock proof required to finalize an L2 to L1 message.
* Generates the bedrock proof required to finalize an L2 to L1 message.
*
*
* @param message Message to generate a proof for.
* @param message Message to generate a proof for.
* @param messageIndex The index of the message, if multiple exist from multicall
* @returns Proof that can be used to finalize the message.
* @returns Proof that can be used to finalize the message.
*/
*/
public
async
getBedrockMessageProof
(
public
async
getBedrockMessageProof
(
message
:
MessageLike
,
message
:
MessageLike
,
/**
* The index of the withdrawal if multiple are made with multicall
*/
messageIndex
=
0
messageIndex
=
0
):
Promise
<
BedrockCrossChainMessageProof
>
{
):
Promise
<
BedrockCrossChainMessageProof
>
{
const
resolved
=
await
this
.
toCrossChainMessage
(
message
,
messageIndex
)
const
resolved
=
await
this
.
toCrossChainMessage
(
message
,
messageIndex
)
...
@@ -1625,6 +1605,7 @@ export class CrossChainMessenger {
...
@@ -1625,6 +1605,7 @@ export class CrossChainMessenger {
* @param opts Additional options.
* @param opts Additional options.
* @param opts.signer Optional signer to use to send the transaction.
* @param opts.signer Optional signer to use to send the transaction.
* @param opts.overrides Optional transaction overrides.
* @param opts.overrides Optional transaction overrides.
* @param messageIndex The index of the message, if multiple exist from multicall
* @returns Transaction response for the finalization transaction.
* @returns Transaction response for the finalization transaction.
*/
*/
public
async
finalizeMessage
(
public
async
finalizeMessage
(
...
@@ -1633,9 +1614,6 @@ export class CrossChainMessenger {
...
@@ -1633,9 +1614,6 @@ export class CrossChainMessenger {
signer
?:
Signer
signer
?:
Signer
overrides
?:
PayableOverrides
overrides
?:
PayableOverrides
},
},
/**
* The index of the withdrawal if multiple are made with multicall
*/
messageIndex
=
0
messageIndex
=
0
):
Promise
<
TransactionResponse
>
{
):
Promise
<
TransactionResponse
>
{
return
(
opts
?.
signer
||
this
.
l1Signer
).
sendTransaction
(
return
(
opts
?.
signer
||
this
.
l1Signer
).
sendTransaction
(
...
@@ -1913,6 +1891,7 @@ export class CrossChainMessenger {
...
@@ -1913,6 +1891,7 @@ export class CrossChainMessenger {
* @param message Message to generate the proving transaction for.
* @param message Message to generate the proving transaction for.
* @param opts Additional options.
* @param opts Additional options.
* @param opts.overrides Optional transaction overrides.
* @param opts.overrides Optional transaction overrides.
* @param messageIndex The index of the message, if multiple exist from multicall
* @returns Transaction that can be signed and executed to prove the message.
* @returns Transaction that can be signed and executed to prove the message.
*/
*/
proveMessage
:
async
(
proveMessage
:
async
(
...
@@ -1920,9 +1899,6 @@ export class CrossChainMessenger {
...
@@ -1920,9 +1899,6 @@ export class CrossChainMessenger {
opts
?:
{
opts
?:
{
overrides
?:
PayableOverrides
overrides
?:
PayableOverrides
},
},
/**
* The index of the withdrawal if multiple are made with multicall
*/
messageIndex
=
0
messageIndex
=
0
):
Promise
<
TransactionRequest
>
=>
{
):
Promise
<
TransactionRequest
>
=>
{
const
resolved
=
await
this
.
toCrossChainMessage
(
message
,
messageIndex
)
const
resolved
=
await
this
.
toCrossChainMessage
(
message
,
messageIndex
)
...
@@ -1972,6 +1948,7 @@ export class CrossChainMessenger {
...
@@ -1972,6 +1948,7 @@ export class CrossChainMessenger {
* @param message Message to generate the finalization transaction for.
* @param message Message to generate the finalization transaction for.
* @param opts Additional options.
* @param opts Additional options.
* @param opts.overrides Optional transaction overrides.
* @param opts.overrides Optional transaction overrides.
* @param messageIndex The index of the message, if multiple exist from multicall
* @returns Transaction that can be signed and executed to finalize the message.
* @returns Transaction that can be signed and executed to finalize the message.
*/
*/
finalizeMessage
:
async
(
finalizeMessage
:
async
(
...
@@ -1979,9 +1956,6 @@ export class CrossChainMessenger {
...
@@ -1979,9 +1956,6 @@ export class CrossChainMessenger {
opts
?:
{
opts
?:
{
overrides
?:
PayableOverrides
overrides
?:
PayableOverrides
},
},
/**
* The index of the withdrawal if multiple are made with multicall
*/
messageIndex
=
0
messageIndex
=
0
):
Promise
<
TransactionRequest
>
=>
{
):
Promise
<
TransactionRequest
>
=>
{
const
resolved
=
await
this
.
toCrossChainMessage
(
message
,
messageIndex
)
const
resolved
=
await
this
.
toCrossChainMessage
(
message
,
messageIndex
)
...
@@ -2257,6 +2231,7 @@ export class CrossChainMessenger {
...
@@ -2257,6 +2231,7 @@ export class CrossChainMessenger {
* @param message Message to generate the proving transaction for.
* @param message Message to generate the proving transaction for.
* @param opts Additional options.
* @param opts Additional options.
* @param opts.overrides Optional transaction overrides.
* @param opts.overrides Optional transaction overrides.
* @param messageIndex The index of the message, if multiple exist from multicall
* @returns Gas estimate for the transaction.
* @returns Gas estimate for the transaction.
*/
*/
proveMessage
:
async
(
proveMessage
:
async
(
...
@@ -2264,9 +2239,6 @@ export class CrossChainMessenger {
...
@@ -2264,9 +2239,6 @@ export class CrossChainMessenger {
opts
?:
{
opts
?:
{
overrides
?:
CallOverrides
overrides
?:
CallOverrides
},
},
/**
* The index of the withdrawal if multiple are made with multicall
*/
messageIndex
=
0
messageIndex
=
0
):
Promise
<
BigNumber
>
=>
{
):
Promise
<
BigNumber
>
=>
{
return
this
.
l1Provider
.
estimateGas
(
return
this
.
l1Provider
.
estimateGas
(
...
@@ -2280,6 +2252,7 @@ export class CrossChainMessenger {
...
@@ -2280,6 +2252,7 @@ export class CrossChainMessenger {
* @param message Message to generate the finalization transaction for.
* @param message Message to generate the finalization transaction for.
* @param opts Additional options.
* @param opts Additional options.
* @param opts.overrides Optional transaction overrides.
* @param opts.overrides Optional transaction overrides.
* @param messageIndex The index of the message, if multiple exist from multicall
* @returns Gas estimate for the transaction.
* @returns Gas estimate for the transaction.
*/
*/
finalizeMessage
:
async
(
finalizeMessage
:
async
(
...
@@ -2287,9 +2260,6 @@ export class CrossChainMessenger {
...
@@ -2287,9 +2260,6 @@ export class CrossChainMessenger {
opts
?:
{
opts
?:
{
overrides
?:
CallOverrides
overrides
?:
CallOverrides
},
},
/**
* The index of the withdrawal if multiple are made with multicall
*/
messageIndex
=
0
messageIndex
=
0
):
Promise
<
BigNumber
>
=>
{
):
Promise
<
BigNumber
>
=>
{
return
this
.
l1Provider
.
estimateGas
(
return
this
.
l1Provider
.
estimateGas
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment