Conversation
There was a problem hiding this comment.
Nice, I like this API. LGTM 👍
There was a problem hiding this comment.
What were the thoughts here about using a callback vs just returning a promise? (it does seem you do return a promise in addition to accepting a callback, & just curious about that choice)
There was a problem hiding this comment.
Oh also nit: should probably add a return value for this function.
(being more picky about this stuff because this is going to be a very externally facing API)
There was a problem hiding this comment.
Was trying to emulate the provider.once functionality in ethers https://docs.ethers.io/v5/single-page/#/v5/api/providers/provider/-%23-Provider-once -
There was a problem hiding this comment.
Another way to do this that is a bit more flexible I think is to make the Watcher an EventEmitter and then update this part of the code:
layer.provider.on(filter, (log: any) => {
if (log.data === msgHash) {
this.emit('relayed', log.transactionHash)
}Then the Watcher would have the on property and the once property as well as the rest of the highly used/tested EventEmitter properties
* chore: Bump `superchain-registry` version * fix: use versioned superchain primitives dep --------- Co-authored-by: refcell <abigger87@gmail.com>
### Description Adds an example to the `op-alloy` book that walks through implementing `L1BlockInfo` hardfork changes in `op-alloy`. Closes #279
Closes #296 --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
Description
This adds a cross domain watcher service. Usage is as follows:
Watcher is initialized with L1 and L2 providers + L1 and L2 messenger addresses.
User sends an L1->L2 Deposit tx. Front-end gets the L1 tx hash and calls
getMessageHashesFromL1Txwhich returns an array of all messageHashes of the L1->L2 txs that were sent in this tx (we would expect this to be a singleton array, but you could construct an L1 tx that sends multiple L1->L2 messages).Front-end now calls
onceL2Relay(messageHash, (l2TxHash) => {// do thing}). Once the L2 tx is relayed, then the callback will be triggered with the L2 tx hash.The watcher service can of course be used in the reverse direction as well, using
getMessageHashesFromL2Txfollowed byonceL1Relay(messageHash, (l1TxHash) => {// do thing})Questions
Best way to add tests for this other than the integration testing repo?
Metadata
Fixes
Contributing Agreement