Skip to content

Commit

Permalink
Adds decodeExecutingMessage & e2e interop test (#486)
Browse files Browse the repository at this point in the history
* Adds decodeExecutingMessage

* Adds e2e interop test

* Adds changeset

* update nonce fetching in test

* update docs

* Update docs and pkg exports

* Run tests in serial to make nonce checking easier

* Update README to link to interop example

* remove nonce checking

* remove setting maxConcurrency
  • Loading branch information
nitaliano authored Sep 30, 2024
1 parent d687fbb commit 3d41611
Show file tree
Hide file tree
Showing 42 changed files with 251 additions and 57 deletions.
5 changes: 5 additions & 0 deletions .changeset/wild-pugs-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@eth-optimism/viem": patch
---

Adds decodeExecutingMessage
3 changes: 3 additions & 0 deletions packages/viem/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ This package is a TypeScript extension for Viem that provides actions and utilit
### Documentation
* [SDK Reference](./docs/README.md)

### Code Snippets
* [Interop](./src/test/e2e/interop.spec.ts)

### Running Tests

Before you can run the unit tests you'll need [supersim](https://github.com/ethereum-optimism/supersim) installed. Once you have supersim installed you can run `pnpm nx run @eth-optimism/viem:test` from the root of the monorepo to get the tests running.
3 changes: 3 additions & 0 deletions packages/viem/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

## Types

- [DecodeExecutingMessageParameters](type-aliases/DecodeExecutingMessageParameters.md)
- [DecodeExecutingMessageReturnType](type-aliases/DecodeExecutingMessageReturnType.md)
- [DecodeSentMessageParameters](type-aliases/DecodeSentMessageParameters.md)
- [DecodeSentMessageReturnType](type-aliases/DecodeSentMessageReturnType.md)
- [ExecuteL2ToL2MessageContractReturnType](type-aliases/ExecuteL2ToL2MessageContractReturnType.md)
Expand All @@ -52,5 +54,6 @@

## Utils

- [decodeExecutingMessage](functions/decodeExecutingMessage.md)
- [decodeSentMessage](functions/decodeSentMessage.md)
- [extractMessageIdentifierFromLogs](functions/extractMessageIdentifierFromLogs.md)
27 changes: 27 additions & 0 deletions packages/viem/docs/functions/decodeExecutingMessage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[**@eth-optimism/viem**](../README.md)**Docs**

***

[@eth-optimism/viem](../README.md) / decodeExecutingMessage

# decodeExecutingMessage()

> **decodeExecutingMessage**(`params`): [`DecodeExecutingMessageReturnType`](../type-aliases/DecodeExecutingMessageReturnType.md)
Utility for decoding ExecutingMessage log events

## Parameters

**params**: [`DecodeExecutingMessageParameters`](../type-aliases/DecodeExecutingMessageParameters.md)

[DecodeExecutingMessageParameters](../type-aliases/DecodeExecutingMessageParameters.md)

## Returns

[`DecodeExecutingMessageReturnType`](../type-aliases/DecodeExecutingMessageReturnType.md)

Decoded message arugments [DecodeExecutingMessageReturnType](../type-aliases/DecodeExecutingMessageReturnType.md)

## Defined in

[packages/viem/src/utils/decodeExecutingMessage.ts:28](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/utils/decodeExecutingMessage.ts#L28)
2 changes: 1 addition & 1 deletion packages/viem/docs/functions/decodeSentMessage.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ Decoded message arugments [DecodeSentMessageReturnType](../type-aliases/DecodeSe

## Defined in

[packages/viem/src/utils/decodeSentMessage.ts:32](https://github.com/ethereum-optimism/ecosystem/blob/c1e85d9590ff961efd71aa28bb561bf44dbc4c2d/packages/viem/src/utils/decodeSentMessage.ts#L32)
[packages/viem/src/utils/decodeSentMessage.ts:31](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/utils/decodeSentMessage.ts#L31)
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ The estimated gas value.

## Defined in

[packages/viem/src/actions/executeL2ToL2Message.ts:111](https://github.com/ethereum-optimism/ecosystem/blob/c1e85d9590ff961efd71aa28bb561bf44dbc4c2d/packages/viem/src/actions/executeL2ToL2Message.ts#L111)
[packages/viem/src/actions/executeL2ToL2Message.ts:107](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/actions/executeL2ToL2Message.ts#L107)
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ The estimated gas value.

## Defined in

[packages/viem/src/actions/sendL2ToL2Message.ts:109](https://github.com/ethereum-optimism/ecosystem/blob/c1e85d9590ff961efd71aa28bb561bf44dbc4c2d/packages/viem/src/actions/sendL2ToL2Message.ts#L109)
[packages/viem/src/actions/sendL2ToL2Message.ts:105](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/actions/sendL2ToL2Message.ts#L105)
2 changes: 1 addition & 1 deletion packages/viem/docs/functions/executeL2ToL2Message.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ The executeL2ToL2Message transaction hash. [ExecuteL2ToL2MessageReturnType](../t

## Defined in

[packages/viem/src/actions/executeL2ToL2Message.ts:80](https://github.com/ethereum-optimism/ecosystem/blob/c1e85d9590ff961efd71aa28bb561bf44dbc4c2d/packages/viem/src/actions/executeL2ToL2Message.ts#L80)
[packages/viem/src/actions/executeL2ToL2Message.ts:78](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/actions/executeL2ToL2Message.ts#L78)
Original file line number Diff line number Diff line change
Expand Up @@ -1377,4 +1377,4 @@ A valid message identifier. GetGameReturnType

## Defined in

[packages/viem/src/utils/extractMessageIdentifierFromLogs.ts:57](https://github.com/ethereum-optimism/ecosystem/blob/c1e85d9590ff961efd71aa28bb561bf44dbc4c2d/packages/viem/src/utils/extractMessageIdentifierFromLogs.ts#L57)
[packages/viem/src/utils/extractMessageIdentifierFromLogs.ts:55](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/utils/extractMessageIdentifierFromLogs.ts#L55)
2 changes: 1 addition & 1 deletion packages/viem/docs/functions/sendL2ToL2Message.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ The sendL2ToL2Message transaction hash. [SendL2ToL2MessageReturnType](../type-al

## Defined in

[packages/viem/src/actions/sendL2ToL2Message.ts:78](https://github.com/ethereum-optimism/ecosystem/blob/c1e85d9590ff961efd71aa28bb561bf44dbc4c2d/packages/viem/src/actions/sendL2ToL2Message.ts#L78)
[packages/viem/src/actions/sendL2ToL2Message.ts:76](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/actions/sendL2ToL2Message.ts#L76)
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ The contract functions return value. [ExecuteL2ToL2MessageContractReturnType](..

## Defined in

[packages/viem/src/actions/executeL2ToL2Message.ts:139](https://github.com/ethereum-optimism/ecosystem/blob/c1e85d9590ff961efd71aa28bb561bf44dbc4c2d/packages/viem/src/actions/executeL2ToL2Message.ts#L139)
[packages/viem/src/actions/executeL2ToL2Message.ts:133](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/actions/executeL2ToL2Message.ts#L133)
2 changes: 1 addition & 1 deletion packages/viem/docs/functions/simulateSendL2ToL2Message.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ The contract functions return value. [SendL2ToL2MessageContractReturnType](../ty

## Defined in

[packages/viem/src/actions/sendL2ToL2Message.ts:137](https://github.com/ethereum-optimism/ecosystem/blob/c1e85d9590ff961efd71aa28bb561bf44dbc4c2d/packages/viem/src/actions/sendL2ToL2Message.ts#L137)
[packages/viem/src/actions/sendL2ToL2Message.ts:131](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/actions/sendL2ToL2Message.ts#L131)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[**@eth-optimism/viem**](../README.md)**Docs**

***

[@eth-optimism/viem](../README.md) / DecodeExecutingMessageParameters

# DecodeExecutingMessageParameters

> **DecodeExecutingMessageParameters**: `object`
## Type declaration

### logs

> **logs**: `Log`[]
## Defined in

[packages/viem/src/utils/decodeExecutingMessage.ts:10](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/utils/decodeExecutingMessage.ts#L10)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[**@eth-optimism/viem**](../README.md)**Docs**

***

[@eth-optimism/viem](../README.md) / DecodeExecutingMessageReturnType

# DecodeExecutingMessageReturnType

> **DecodeExecutingMessageReturnType**: `object`
## Type declaration

### id

> **id**: [`MessageIdentifier`](MessageIdentifier.md)
### msgHash

> **msgHash**: `Hash`
## Defined in

[packages/viem/src/utils/decodeExecutingMessage.ts:17](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/utils/decodeExecutingMessage.ts#L17)
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
## Defined in

[packages/viem/src/utils/decodeSentMessage.ts:9](https://github.com/ethereum-optimism/ecosystem/blob/c1e85d9590ff961efd71aa28bb561bf44dbc4c2d/packages/viem/src/utils/decodeSentMessage.ts#L9)
[packages/viem/src/utils/decodeSentMessage.ts:9](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/utils/decodeSentMessage.ts#L9)
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@
## Defined in

[packages/viem/src/utils/decodeSentMessage.ts:16](https://github.com/ethereum-optimism/ecosystem/blob/c1e85d9590ff961efd71aa28bb561bf44dbc4c2d/packages/viem/src/utils/decodeSentMessage.ts#L16)
[packages/viem/src/utils/decodeSentMessage.ts:16](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/utils/decodeSentMessage.ts#L16)
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
## Defined in

[packages/viem/src/actions/executeL2ToL2Message.ts:57](https://github.com/ethereum-optimism/ecosystem/blob/c1e85d9590ff961efd71aa28bb561bf44dbc4c2d/packages/viem/src/actions/executeL2ToL2Message.ts#L57)
[packages/viem/src/actions/executeL2ToL2Message.ts:57](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/actions/executeL2ToL2Message.ts#L57)
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
## Defined in

[packages/viem/src/actions/executeL2ToL2Message.ts:66](https://github.com/ethereum-optimism/ecosystem/blob/c1e85d9590ff961efd71aa28bb561bf44dbc4c2d/packages/viem/src/actions/executeL2ToL2Message.ts#L66)
[packages/viem/src/actions/executeL2ToL2Message.ts:66](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/actions/executeL2ToL2Message.ts#L66)
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ Target contract or wallet address.

## Defined in

[packages/viem/src/actions/executeL2ToL2Message.ts:30](https://github.com/ethereum-optimism/ecosystem/blob/c1e85d9590ff961efd71aa28bb561bf44dbc4c2d/packages/viem/src/actions/executeL2ToL2Message.ts#L30)
[packages/viem/src/actions/executeL2ToL2Message.ts:30](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/actions/executeL2ToL2Message.ts#L30)
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
## Defined in

[packages/viem/src/actions/executeL2ToL2Message.ts:52](https://github.com/ethereum-optimism/ecosystem/blob/c1e85d9590ff961efd71aa28bb561bf44dbc4c2d/packages/viem/src/actions/executeL2ToL2Message.ts#L52)
[packages/viem/src/actions/executeL2ToL2Message.ts:52](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/actions/executeL2ToL2Message.ts#L52)
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
## Defined in

[packages/viem/src/utils/extractMessageIdentifierFromLogs.ts:35](https://github.com/ethereum-optimism/ecosystem/blob/c1e85d9590ff961efd71aa28bb561bf44dbc4c2d/packages/viem/src/utils/extractMessageIdentifierFromLogs.ts#L35)
[packages/viem/src/utils/extractMessageIdentifierFromLogs.ts:35](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/utils/extractMessageIdentifierFromLogs.ts#L35)
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ The receipt for the sendL2ToL2Message transaction.

## Defined in

[packages/viem/src/utils/extractMessageIdentifierFromLogs.ts:17](https://github.com/ethereum-optimism/ecosystem/blob/c1e85d9590ff961efd71aa28bb561bf44dbc4c2d/packages/viem/src/utils/extractMessageIdentifierFromLogs.ts#L17)
[packages/viem/src/utils/extractMessageIdentifierFromLogs.ts:17](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/utils/extractMessageIdentifierFromLogs.ts#L17)
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
## Defined in

[packages/viem/src/utils/extractMessageIdentifierFromLogs.ts:27](https://github.com/ethereum-optimism/ecosystem/blob/c1e85d9590ff961efd71aa28bb561bf44dbc4c2d/packages/viem/src/utils/extractMessageIdentifierFromLogs.ts#L27)
[packages/viem/src/utils/extractMessageIdentifierFromLogs.ts:27](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/utils/extractMessageIdentifierFromLogs.ts#L27)
2 changes: 1 addition & 1 deletion packages/viem/docs/type-aliases/MessageIdentifier.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ The timestamp that the log was emitted. Used to enforce the timestamp invariant

## Defined in

[packages/viem/src/types/interop.ts:7](https://github.com/ethereum-optimism/ecosystem/blob/c1e85d9590ff961efd71aa28bb561bf44dbc4c2d/packages/viem/src/types/interop.ts#L7)
[packages/viem/src/types/interop.ts:7](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/types/interop.ts#L7)
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
## Defined in

[packages/viem/src/actions/sendL2ToL2Message.ts:55](https://github.com/ethereum-optimism/ecosystem/blob/c1e85d9590ff961efd71aa28bb561bf44dbc4c2d/packages/viem/src/actions/sendL2ToL2Message.ts#L55)
[packages/viem/src/actions/sendL2ToL2Message.ts:55](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/actions/sendL2ToL2Message.ts#L55)
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
## Defined in

[packages/viem/src/actions/sendL2ToL2Message.ts:64](https://github.com/ethereum-optimism/ecosystem/blob/c1e85d9590ff961efd71aa28bb561bf44dbc4c2d/packages/viem/src/actions/sendL2ToL2Message.ts#L64)
[packages/viem/src/actions/sendL2ToL2Message.ts:64](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/actions/sendL2ToL2Message.ts#L64)
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ Target contract or wallet address.

## Defined in

[packages/viem/src/actions/sendL2ToL2Message.ts:28](https://github.com/ethereum-optimism/ecosystem/blob/c1e85d9590ff961efd71aa28bb561bf44dbc4c2d/packages/viem/src/actions/sendL2ToL2Message.ts#L28)
[packages/viem/src/actions/sendL2ToL2Message.ts:28](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/actions/sendL2ToL2Message.ts#L28)
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
## Defined in

[packages/viem/src/actions/sendL2ToL2Message.ts:50](https://github.com/ethereum-optimism/ecosystem/blob/c1e85d9590ff961efd71aa28bb561bf44dbc4c2d/packages/viem/src/actions/sendL2ToL2Message.ts#L50)
[packages/viem/src/actions/sendL2ToL2Message.ts:50](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/actions/sendL2ToL2Message.ts#L50)
2 changes: 1 addition & 1 deletion packages/viem/docs/variables/contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ OP Stack Predeploy Addresses
## Defined in

[packages/viem/src/contracts.ts:8](https://github.com/ethereum-optimism/ecosystem/blob/c1e85d9590ff961efd71aa28bb561bf44dbc4c2d/packages/viem/src/contracts.ts#L8)
[packages/viem/src/contracts.ts:8](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/contracts.ts#L8)
2 changes: 1 addition & 1 deletion packages/viem/docs/variables/crossL2InboxABI.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ ABI for the OP Stack contract `CrossL2Inbox`

## Defined in

[packages/viem/src/abis.ts:588](https://github.com/ethereum-optimism/ecosystem/blob/c1e85d9590ff961efd71aa28bb561bf44dbc4c2d/packages/viem/src/abis.ts#L588)
[packages/viem/src/abis.ts:588](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/abis.ts#L588)
2 changes: 1 addition & 1 deletion packages/viem/docs/variables/l1BlockABI.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ ABI for the OP Stack contract `L1Block`

## Defined in

[packages/viem/src/abis.ts:7](https://github.com/ethereum-optimism/ecosystem/blob/c1e85d9590ff961efd71aa28bb561bf44dbc4c2d/packages/viem/src/abis.ts#L7)
[packages/viem/src/abis.ts:7](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/abis.ts#L7)
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ ABI for the OP Stack contract `L2ToL2CrossDomainMessenger`

## Defined in

[packages/viem/src/abis.ts:359](https://github.com/ethereum-optimism/ecosystem/blob/c1e85d9590ff961efd71aa28bb561bf44dbc4c2d/packages/viem/src/abis.ts#L359)
[packages/viem/src/abis.ts:359](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/abis.ts#L359)
2 changes: 1 addition & 1 deletion packages/viem/docs/variables/superchainWETHABI.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ ABI for the OP Stack contract `SuperchainWETH`

## Defined in

[packages/viem/src/abis.ts:874](https://github.com/ethereum-optimism/ecosystem/blob/c1e85d9590ff961efd71aa28bb561bf44dbc4c2d/packages/viem/src/abis.ts#L874)
[packages/viem/src/abis.ts:874](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/abis.ts#L874)
2 changes: 1 addition & 1 deletion packages/viem/docs/variables/supersimL1.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,4 @@ Flag for test networks

## Defined in

[packages/viem/src/chains/supersim.ts:9](https://github.com/ethereum-optimism/ecosystem/blob/c1e85d9590ff961efd71aa28bb561bf44dbc4c2d/packages/viem/src/chains/supersim.ts#L9)
[packages/viem/src/chains/supersim.ts:8](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/chains/supersim.ts#L8)
2 changes: 1 addition & 1 deletion packages/viem/docs/variables/supersimL2A.md
Original file line number Diff line number Diff line change
Expand Up @@ -504,4 +504,4 @@ Flag for test networks

## Defined in

[packages/viem/src/chains/supersim.ts:26](https://github.com/ethereum-optimism/ecosystem/blob/c1e85d9590ff961efd71aa28bb561bf44dbc4c2d/packages/viem/src/chains/supersim.ts#L26)
[packages/viem/src/chains/supersim.ts:24](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/chains/supersim.ts#L24)
2 changes: 1 addition & 1 deletion packages/viem/docs/variables/supersimL2B.md
Original file line number Diff line number Diff line change
Expand Up @@ -504,4 +504,4 @@ Flag for test networks

## Defined in

[packages/viem/src/chains/supersim.ts:44](https://github.com/ethereum-optimism/ecosystem/blob/c1e85d9590ff961efd71aa28bb561bf44dbc4c2d/packages/viem/src/chains/supersim.ts#L44)
[packages/viem/src/chains/supersim.ts:41](https://github.com/ethereum-optimism/ecosystem/blob/c363acafc2b5c0db021f95b4e5fefe43bbcaf322/packages/viem/src/chains/supersim.ts#L41)
13 changes: 4 additions & 9 deletions packages/viem/src/actions/executeL2ToL2Message.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { encodeFunctionData, keccak256, parseEventLogs } from 'viem'
import { encodeFunctionData, keccak256 } from 'viem'
import { describe, expect, it } from 'vitest'

import { crossL2InboxABI } from '@/abis.js'
import { supersimL2A } from '@/chains/supersim.js'
import { publicClient, testAccount, walletClient } from '@/test/clients.js'
import { ticTacToeABI, ticTacToeAddress } from '@/test/setupTicTacToe.js'
import type { MessageIdentifier } from '@/types/interop.js'
import { decodeExecutingMessage } from '@/utils/decodeExecutingMessage.js'

describe('executeL2ToL2Message', () => {
const expectedId = {
Expand Down Expand Up @@ -48,14 +48,9 @@ describe('executeL2ToL2Message', () => {

const receipt = await publicClient.waitForTransactionReceipt({ hash })

const logs = parseEventLogs({
abi: crossL2InboxABI,
logs: receipt.logs,
eventName: 'ExecutingMessage',
})

const { msgHash } = logs[0].args
const { msgHash, id } = decodeExecutingMessage({ logs: receipt.logs })
expect(msgHash).toEqual(keccak256(encodedMessage))
expect(expectedId).toEqual(id)
})
})

Expand Down
21 changes: 5 additions & 16 deletions packages/viem/src/actions/sendL2ToL2Message.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { encodeFunctionData } from 'viem'
import { describe, expect, it } from 'vitest'

import { l2ToL2CrossDomainMessengerABI } from '@/abis.js'
import { supersimL2A, supersimL2B } from '@/chains/supersim.js'
import { contracts } from '@/contracts.js'
import { publicClient, testAccount, walletClient } from '@/test/clients.js'
Expand Down Expand Up @@ -41,22 +40,12 @@ describe('sendL2ToL2Message', () => {
expect(id.blockNumber).toEqual(receipt.blockNumber)
expect(id.logIndex).toEqual(BigInt(receipt.logs[0].logIndex))

// verify payload
const currentNonce = await publicClient.readContract({
abi: l2ToL2CrossDomainMessengerABI,
address: contracts.l2ToL2CrossDomainMessenger.address,
functionName: 'messageNonce',
})

const decodedPayload = decodeSentMessage({ payload })
expect(decodedPayload).toEqual({
origin: BigInt(supersimL2A.id),
destination: BigInt(supersimL2B.id),
messageNonce: currentNonce - 1n,
sender: testAccount.address,
target: ticTacToeAddress,
message: encodedMessage,
})
expect(decodedPayload.origin).toEqual(BigInt(supersimL2A.id))
expect(decodedPayload.destination).toEqual(BigInt(supersimL2B.id))
expect(decodedPayload.sender).toEqual(testAccount.address)
expect(decodedPayload.target).toEqual(ticTacToeAddress)
expect(decodedPayload.message).toEqual(encodedMessage)
})
})

Expand Down
2 changes: 0 additions & 2 deletions packages/viem/src/actions/sendL2ToL2Message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,5 @@ export async function simulateSendL2ToL2Message<
args: [destinationChainId, target, message],
} as SimulateContractParameters)

console.log('HERE', res)

return res.result as SendL2ToL2MessageContractReturnType
}
5 changes: 5 additions & 0 deletions packages/viem/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export {
} from '@/actions/sendL2ToL2Message.js'

// utils
export type {
DecodeExecutingMessageParameters,
DecodeExecutingMessageReturnType,
} from '@/utils/decodeExecutingMessage.js'
export { decodeExecutingMessage } from '@/utils/decodeExecutingMessage.js'
export type {
DecodeSentMessageParameters,
DecodeSentMessageReturnType,
Expand Down
Loading

0 comments on commit 3d41611

Please sign in to comment.