2024-05-21 21:02:39 +05:30
|
|
|
# waku-rlnv2-contract [![Github Actions][gha-badge]][gha] [![Foundry][foundry-badge]][foundry] [![License: MIT][license-badge]][license]
|
2024-05-21 06:16:07 +05:30
|
|
|
|
|
|
|
|
[gha]: https://github.com/waku-org/waku-rlnv2-contract/actions
|
|
|
|
|
[gha-badge]: https://github.com/waku-org/waku-rlnv2-contract/actions/workflows/ci.yml/badge.svg
|
|
|
|
|
[foundry]: https://getfoundry.sh/
|
|
|
|
|
[foundry-badge]: https://img.shields.io/badge/Built%20with-Foundry-FFDB1C.svg
|
|
|
|
|
[license]: https://opensource.org/licenses/MIT
|
|
|
|
|
[license-badge]: https://img.shields.io/badge/License-MIT-blue.svg
|
|
|
|
|
|
2024-05-21 21:02:39 +05:30
|
|
|
Waku's RLNv2 contracts, which include -
|
2024-05-21 06:16:07 +05:30
|
|
|
|
2024-05-21 21:30:07 +05:30
|
|
|
- LazyIMT, which allows the root of the chain to be accessible on-chain.
|
2024-05-21 06:16:07 +05:30
|
|
|
|
|
|
|
|
## What's Inside
|
|
|
|
|
|
|
|
|
|
- [Forge](https://github.com/foundry-rs/foundry/blob/master/forge): compile, test, fuzz, format, and deploy smart
|
|
|
|
|
contracts
|
|
|
|
|
- [Forge Std](https://github.com/foundry-rs/forge-std): collection of helpful contracts and cheatcodes for testing
|
|
|
|
|
- [Solhint Community](https://github.com/solhint-community/solhint-community): linter for Solidity code
|
|
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
|
|
This is a list of the most frequently needed commands.
|
|
|
|
|
|
|
|
|
|
### Build
|
|
|
|
|
|
|
|
|
|
Build the contracts:
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
$ forge build
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Clean
|
|
|
|
|
|
|
|
|
|
Delete the build artifacts and cache directories:
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
$ forge clean
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Compile
|
|
|
|
|
|
|
|
|
|
Compile the contracts:
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
$ forge build
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Coverage
|
|
|
|
|
|
|
|
|
|
Get a test coverage report:
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
$ forge coverage
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Deploy
|
|
|
|
|
|
|
|
|
|
Deploy to Anvil:
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
$ forge script script/Deploy.s.sol --broadcast --fork-url http://localhost:8545
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
For this script to work, you need to have a `MNEMONIC` environment variable set to a valid
|
|
|
|
|
[BIP39 mnemonic](https://iancoleman.io/bip39/).
|
|
|
|
|
|
|
|
|
|
For instructions on how to deploy to a testnet or mainnet, check out the
|
|
|
|
|
[Solidity Scripting](https://book.getfoundry.sh/tutorials/solidity-scripting.html) tutorial.
|
|
|
|
|
|
|
|
|
|
### Format
|
|
|
|
|
|
|
|
|
|
Format the contracts:
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
$ forge fmt
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Gas Usage
|
|
|
|
|
|
|
|
|
|
Get a gas report:
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
$ forge test --gas-report
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Lint
|
|
|
|
|
|
|
|
|
|
Lint the contracts:
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
$ pnpm lint
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### Fixing linting issues
|
|
|
|
|
|
|
|
|
|
For any errors in solidity files, run `forge fmt`. For errors in any other file type, run `pnpm prettier:write`.
|
|
|
|
|
|
|
|
|
|
### Test
|
|
|
|
|
|
|
|
|
|
Run the tests:
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
$ forge test
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Notes
|
|
|
|
|
|
|
|
|
|
1. Foundry uses [git submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules) to manage dependencies. For
|
|
|
|
|
detailed instructions on working with dependencies, please refer to the
|
|
|
|
|
[guide](https://book.getfoundry.sh/projects/dependencies.html) in the book
|
|
|
|
|
2. You don't have to create a `.env` file, but filling in the environment variables may be useful when debugging and
|
|
|
|
|
testing against a fork.
|
|
|
|
|
|
|
|
|
|
## License
|
|
|
|
|
|
|
|
|
|
This project is licensed under MIT.
|