Skip to content

Commit 37f8cf0

Browse files
🗞️ foundry scripts for LayerZero (#1334)
Signed-off-by: shankar <shankar@layerzerolabs.org> Co-authored-by: ravinagill15 <ravina@layerzerolabs.org>
1 parent e32dbaf commit 37f8cf0

29 files changed

Lines changed: 2969 additions & 5 deletions

File tree

.changeset/weak-ravens-exercise.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@layerzerolabs/script-devtools-evm-foundry": patch
3+
"@layerzerolabs/toolbox-foundry": patch
4+
"@layerzerolabs/oft-example": patch
5+
---
6+
7+
Added useful forge scripts and updated forge-std to latest commit

examples/oft/foundry.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ remappings = [
2828
'forge-std/=node_modules/@layerzerolabs/toolbox-foundry/lib/forge-std',
2929
'@layerzerolabs/=node_modules/@layerzerolabs/',
3030
'@openzeppelin/=node_modules/@openzeppelin/',
31+
'@layerzerolabs/script-devtools-evm-foundry/=node_modules/@layerzerolabs/script-devtools-evm-foundry/'
3132
]
3233

3334
[fuzz]

examples/oft/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"@layerzerolabs/oapp-evm": "^0.3.2",
3939
"@layerzerolabs/oft-evm": "^3.1.3",
4040
"@layerzerolabs/prettier-config-next": "^2.3.39",
41+
"@layerzerolabs/script-devtools-evm-foundry": "^0.0.1",
4142
"@layerzerolabs/solhint-config": "^3.0.12",
4243
"@layerzerolabs/test-devtools-evm-foundry": "~6.0.3",
4344
"@layerzerolabs/toolbox-foundry": "~0.1.12",

examples/oft/script/LZScript.s.sol

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.0;
3+
4+
import { console } from "forge-std/console.sol";
5+
6+
import { LZScripts } from "@layerzerolabs/script-devtools-evm-foundry/scripts/LZScripts.s.sol";
7+
8+
contract LZScript is LZScripts {
9+
function run() public pure override {
10+
console.log("Hello, World!");
11+
}
12+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.turbo
2+
dist
3+
node_modules
4+
out
5+
cache
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "../../.eslintrc.json"
3+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
cache
2+
# Ignore everything in the artifacts folder
3+
artifacts/*
4+
5+
# Do not ignore the directory structure up to the specific file
6+
!artifacts/
7+
!artifacts/*.s.sol/
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# @layerzerolabs/script-devtools-evm-foundry
2+
3+
## 0.0.1
4+
5+
### Minor Changes
6+
7+
- Initial release with foundry scripts for LayerZero EVM development
8+
- Add SimulateReceive script for simulating message reception on EVM chains
9+
- Add GasProfiler script for profiling gas usage of OFT transfers on mainnet networks
10+
- Add LZScripts.s.sol bundle for easy importing in custom foundry scripts
11+
- Include foundry configuration and build artifacts for immediate use
12+
13+
### Patch Changes
14+
15+
- @layerzerolabs/lz-evm-messagelib-v2@3.0.12
16+
- @layerzerolabs/lz-evm-protocol-v2@3.0.12
17+
- @layerzerolabs/lz-evm-v1-0.7@3.0.12
18+
- @layerzerolabs/toolbox-foundry@0.1.12
19+
- @layerzerolabs/oapp-evm@0.3.1
20+
- @layerzerolabs/oft-evm@3.1.2
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<p align="center">
2+
<a href="https://layerzero.network">
3+
<img alt="LayerZero" style="max-width: 500px" src="https://d3a2dpnnrypp5h.cloudfront.net/bridge-app/lz.png"/>
4+
</a>
5+
</p>
6+
7+
<h1 align="center">@layerzerolabs/script-devtools-evm-foundry</h1>
8+
9+
<!-- The badges section -->
10+
<p align="center">
11+
<!-- Shields.io NPM published package version -->
12+
<a href="https://www.npmjs.com/package/@layerzerolabs/script-devtools-evm-foundry"><img alt="NPM Version" src="https://img.shields.io/npm/v/@layerzerolabs/script-devtools-evm-foundry"/></a>
13+
<!-- Shields.io NPM downloads -->
14+
<a href="https://www.npmjs.com/package/@layerzerolabs/script-devtools-evm-foundry"><img alt="Downloads" src="https://img.shields.io/npm/dm/@layerzerolabs/script-devtools-evm-foundry"/></a>
15+
<!-- Shields.io license badge -->
16+
<a href="https://www.npmjs.com/package/@layerzerolabs/script-devtools-evm-foundry"><img alt="NPM License" src="https://img.shields.io/npm/l/@layerzerolabs/script-devtools-evm-foundry"/></a>
17+
</p>
18+
19+
## Installation
20+
21+
```sh
22+
$ npm install @layerzerolabs/script-devtools-evm-foundry
23+
```
24+
25+
## Usage
26+
27+
This package not only exports a bunch of scripts for you to use in your foundry projects. But since they compile into your `artifacts` folder, you can run them from your command line.
28+
29+
```sh
30+
forge script SimulateReceive --rpc-url YOUR_DESTINATION_CHAIN_RPC_URL --ffi
31+
```
32+
33+
Since all the scripts are bundled into `LZScripts.s.sol`, you can import them in your own scripts like this:
34+
35+
```solidity
36+
import { LZUtils } from "@layerzerolabs/script-devtools-evm-foundry/scripts/LZScripts.s.sol";
37+
```
38+
39+
## List of scripts
40+
41+
### 1. SimulateReceive
42+
43+
Simulate receiving a message on an EVM chain - [Read more](./script/SimulateReceive/README.md)
44+
Source code: [SimulateReceive.s.sol](./script/SimulateReceive/SimulateReceive.s.sol)
45+
Shell command:
46+
47+
```sh
48+
forge script SimulateReceive --rpc-url $DESTINATION_CHAIN_RPC_URL --ffi
49+
```
50+
51+
### 2. GasProfiler
52+
53+
Profile the gas usage of OFT transfers on multiple mainnet networks - [Read more](./script/GasProfiling/README.md)
54+
Source code: [OFTProfilerExample.s.sol](./script/GasProfiling/OFTProfilerExample.s.sol)
55+
Shell command: Not available

packages/script-devtools-evm-foundry/artifacts/GasProfiler.s.sol/GasProfilerScript.json

Lines changed: 648 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)