Skip to content

Commit

Permalink
🪚 Stub of toolbox-foundry package (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
janjakubnanista authored Jan 19, 2024
1 parent 34d6ad8 commit ebddc88
Show file tree
Hide file tree
Showing 18 changed files with 187 additions and 10 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ dist
node_modules
*.md
*.sol
*.toml
pnpm-lock.yaml
3 changes: 0 additions & 3 deletions .github/workflows/actions/setup-environment/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,3 @@ runs:
with:
node-version-file: ".nvmrc"
cache: "pnpm"

- name: Setup Foundry
uses: foundry-rs/foundry-toolchain@v1
2 changes: 2 additions & 0 deletions .github/workflows/reusable-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
submodules: "true"

- name: Setup environment
uses: ./.github/workflows/actions/setup-environment
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/reusable-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
submodules: "true"

- name: Setup environment
uses: ./.github/workflows/actions/setup-environment
Expand All @@ -48,6 +50,8 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
submodules: "true"

- name: Setup environment
uses: ./.github/workflows/actions/setup-environment
Expand Down
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "toolbox-foundry/forge-std"]
path = packages/toolbox-foundry/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "toolbox-foundry/ds-test"]
path = packages/toolbox-foundry/lib/ds-test
url = https://github.com/dapphub/ds-test
27 changes: 27 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,29 @@ The code is arranged into:

## Development

### Getting the source code

This repository contains several git submodules. To clone the repository, please follow these steps:

```bash
# 1. Clone the repository

# Using HTTPS
git clone https://github.com/LayerZero-Labs/devtools.git

# Using SSH
git clone [email protected]:LayerZero-Labs/devtools.git

# 2. Install submodules

git submodules init
git submodules update
```

### Setting up the environment

This repository uses `pnpm` as its package manager and has a requirement on the minimum `node` version used. If using `nvm`, please run the following to setup the enviornment:

```bash
# or nvm install if nvm use fails
nvm use
Expand All @@ -29,7 +52,11 @@ corepack enable

# Install project dependencies
pnpm install
```

### Making changes

```bash
# Build the entire project
pnpm build

Expand Down
2 changes: 1 addition & 1 deletion examples/oft/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ src = 'contracts'
out = 'out'
test = 'test/foundry'
cache_path = 'cache'
libs = ['node_modules', '../lib']
libs = ['node_modules', 'node_modules/@layerzerolabs/toolbox-foundry/lib']

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
3 changes: 2 additions & 1 deletion examples/oft/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"@layerzerolabs/lz-evm-protocol-v2": "~2.0.11",
"@layerzerolabs/prettier-config-next": "^2.0.11",
"@layerzerolabs/solhint-config": "^2.0.11",
"@layerzerolabs/toolbox-hardhat": "~0.0.2",
"@layerzerolabs/toolbox-foundry": "~0.0.1",
"@layerzerolabs/toolbox-hardhat": "~0.0.3",
"@nomicfoundation/hardhat-ethers": "^3.0.5",
"@nomiclabs/hardhat-ethers": "^2.2.3",
"@openzeppelin/contracts": "^4.9.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-lz-oapp/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Example, PackageManager } from '@/types'
* To enable example development in a custom repository
* we open the repository URL field to be taken from the environment
*/
const repository = process.env['LAYERZERO_EXAMPLES_REPOSITORY_URL'] || '[email protected]:LayerZero-Labs/lz-utils'
const repository = process.env['LAYERZERO_EXAMPLES_REPOSITORY_URL'] || '[email protected]:LayerZero-Labs/devtools'

/**
* To enable example development in a custom branch,
Expand Down
2 changes: 1 addition & 1 deletion packages/create-lz-oapp/test/utilities/cloning.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createExampleGitURL } from '@/utilities/cloning'

describe('utilities/cloning', () => {
describe('createExampleGitURL', () => {
const REPO_URL = '[email protected]:LayerZero-Labs/lz-utils'
const REPO_URL = '[email protected]:LayerZero-Labs/devtools'

it('should return the repository field if directory and ref are not specified', () => {
expect(createExampleGitURL({ repository: REPO_URL, id: 'dummy', label: 'Dummy' })).toEqual(REPO_URL)
Expand Down
2 changes: 2 additions & 0 deletions packages/toolbox-foundry/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
lib
node_modules
3 changes: 3 additions & 0 deletions packages/toolbox-foundry/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../.eslintrc.json"
}
2 changes: 2 additions & 0 deletions packages/toolbox-foundry/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
lib/
node_modules/
29 changes: 29 additions & 0 deletions packages/toolbox-foundry/DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<p align="center">
<a href="https://layerzero.network">
<img alt="LayerZero" style="max-width: 500px" src="https://d3a2dpnnrypp5h.cloudfront.net/bridge-app/lz.png"/>
</a>
</p>

<h1 align="center">Development</h1>

## Adding libraries

To install a new library to be included with this package, please follow these steps:

```bash
# In your terminal, navigate to the root of the devtools repository

# Add a git submodule
#
# These two examples show the commands for the two existing libraries, forge-std and ds-test
git submodule add --name "toolbox-foundry/ds-test" --force https://github.com/dapphub/ds-test packages/toolbox-foundry/lib/ds-test
git submodule add --name "toolbox-foundry/forge-std" --force https://github.com/foundry-rs/forge-std packages/toolbox-foundry/lib/forge-std
```

Alternatively use the `forge install` command but since it is not playing nice with the monorepo structure, you might end up with a broken submodule state.

After adding a submodule, the pre-commit hooks setup using `husky` and `lint-staged` tend to error out on not being able to lint the submodule even though the `lib` directory has been ignored in both ESLint and Prettier. This is a known and low-priority bug, for now please just make a commit containing only the change to `.gitmodules` using `--no-verify` flag:

```bash
git commit -m "chore: Adding XXX library" --no-verify
```
46 changes: 46 additions & 0 deletions packages/toolbox-foundry/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<p align="center">
<a href="https://layerzero.network">
<img alt="LayerZero" style="max-width: 500px" src="https://d3a2dpnnrypp5h.cloudfront.net/bridge-app/lz.png"/>
</a>
</p>

<h1 align="center">@layerzerolabs/toolbox-foundry</h1>

<p align="center">One-stop-shop for developing LayerZero applications with <code>foundry</code></p>

## Installation

```bash
yarn add @layerzerolabs/toolbox-foundry

pnpm add @layerzerolabs/toolbox-foundry

npm install @layerzerolabs/toolbox-foundry
```

## Configuration

### 1. Add `@layerzerolabs/toolbox-foundry` to your config

To use `@layerzerolabs/toolbox-foundry` you will need to point to it in your `foundry.toml` config file.

```toml
libs = [
'node_modules/@layerzerolabs/toolbox-foundry/lib'
# Any other library folders you need, e.g.
'node_modules'
]
```

## Usage

### Testing

This package comes with support for `forge-std` out of the box so you can start using:

```solidity
// forge-std is automatically resolved without needing to install it
// so you can start using forge test helpers in your tests
import "forge-std/console.sol";
import { Test } from "forge-std/Test.sol";
```
33 changes: 33 additions & 0 deletions packages/toolbox-foundry/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "@layerzerolabs/toolbox-foundry",
"version": "0.0.1",
"description": "One-stop-shop for developing LayerZero applications using foundry",
"repository": {
"type": "git",
"url": "git+https://github.com/LayerZero-Labs/devtools.git",
"directory": "packages/toolbox-foundry"
},
"license": "MIT",
"files": [
"lib",
"!lib/ds-test/.github",
"!lib/ds-test/.gitignore",
"!lib/ds-test/demo",
"!lib/forge-std/.github",
"!lib/forge-std/.gitignore",
"!lib/forge-std/.gitmodules"
],
"scripts": {},
"dependencies": {},
"devDependencies": {
"@types/jest": "^29.5.11",
"jest": "^29.7.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.2",
"tsup": "~8.0.1",
"typescript": "^5.3.3"
},
"publishConfig": {
"access": "restricted"
}
}
28 changes: 26 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/devtools-evm-hardhat-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@layerzerolabs/protocol-devtools": "~0.0.2",
"@layerzerolabs/protocol-devtools-evm": "~0.0.2",
"@layerzerolabs/test-devtools": "~0.0.2",
"@layerzerolabs/toolbox-hardhat": "~0.0.2",
"@layerzerolabs/toolbox-hardhat": "~0.0.3",
"@nomicfoundation/hardhat-ethers": "^3.0.5",
"@openzeppelin/contracts": "^4.9.5",
"@openzeppelin/contracts-upgradeable": "^4.9.5",
Expand Down

0 comments on commit ebddc88

Please sign in to comment.