-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace contracts with rhinestonewtf/module-template
- Loading branch information
Showing
20 changed files
with
5,150 additions
and
3,232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- "main" | ||
pull_request: | ||
|
||
jobs: | ||
lint: | ||
uses: "rhinestonewtf/reusable-workflows/.github/workflows/forge-lint.yaml@main" | ||
|
||
build: | ||
uses: "rhinestonewtf/reusable-workflows/.github/workflows/forge-build.yaml@main" | ||
|
||
test: | ||
needs: ["lint", "build"] | ||
uses: "rhinestonewtf/reusable-workflows/.github/workflows/forge-test.yaml@main" | ||
with: | ||
foundry-fuzz-runs: 5000 | ||
foundry-profile: "test" | ||
match-path: "test/**/*.sol" | ||
|
||
test-simulate: | ||
needs: ["lint", "build"] | ||
uses: "rhinestonewtf/reusable-workflows/.github/workflows/forge-test-simulate.yaml@main" | ||
with: | ||
foundry-fuzz-runs: 5000 | ||
foundry-profile: "test" | ||
match-path: "test/**/*.sol" | ||
|
||
test-multi-account: | ||
needs: ["lint", "build"] | ||
uses: "rhinestonewtf/reusable-workflows/.github/workflows/forge-test-multi-account.yaml@main" | ||
with: | ||
foundry-fuzz-runs: 5000 | ||
foundry-profile: "test" | ||
match-path: "test/**/*.sol" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
PK= | ||
DEPLOYMENT_SENDER= | ||
DEPLOYMENT_RPC= | ||
ETHERSCAN_API_KEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
shamefully-hoist=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"extends": "solhint:recommended", | ||
"rules": { | ||
"avoid-low-level-calls": "off", | ||
"code-complexity": ["error", 9], | ||
"compiler-version": ["error", ">=0.8.0"], | ||
"contract-name-camelcase": "off", | ||
"const-name-snakecase": "off", | ||
"func-name-mixedcase": "off", | ||
"func-visibility": ["error", { "ignoreConstructors": true }], | ||
"max-line-length": ["error", 123], | ||
"named-parameters-mapping": "warn", | ||
"no-empty-blocks": "off", | ||
"not-rely-on-time": "off", | ||
"one-contract-per-file": "off", | ||
"var-name-mixedcase": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules/ | ||
test/ | ||
script/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,81 @@ | ||
## Foundry | ||
## Module Template | ||
|
||
**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.** | ||
**A template for building smart account modules using the [ModuleKit](https://github.com/rhinestonewtf/modulekit)** | ||
|
||
Foundry consists of: | ||
## Using the template | ||
|
||
- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools). | ||
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data. | ||
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network. | ||
- **Chisel**: Fast, utilitarian, and verbose solidity REPL. | ||
### Install dependencies | ||
|
||
## Documentation | ||
|
||
https://book.getfoundry.sh/ | ||
|
||
## Usage | ||
```shell | ||
pnpm install | ||
``` | ||
|
||
### Build | ||
### Update ModuleKit | ||
|
||
```shell | ||
$ forge build | ||
pnpm update rhinestonewtf/modulekit | ||
``` | ||
|
||
### Test | ||
### Building modules | ||
|
||
1. Create a new file in `src` and inherit from the appropriate interface (see templates) | ||
2. After you finished writing your module, run the following command: | ||
|
||
```shell | ||
$ forge test | ||
forge build | ||
``` | ||
|
||
### Format | ||
### Testing modules | ||
|
||
1. Create a new `.t.sol` file in `test` and inherit from the correct testing kit (see templates) | ||
2. After you finished writing your tests, run the following command: | ||
|
||
```shell | ||
$ forge fmt | ||
forge test | ||
``` | ||
|
||
### Gas Snapshots | ||
### Deploying modules | ||
|
||
1. Import your modules into the `script/DeployModule.s.sol` file. | ||
2. Create a `.env` file in the root directory based on the `.env.example` file and fill in the variables. | ||
3. Run the following command: | ||
|
||
```shell | ||
$ forge snapshot | ||
source .env && forge script script/DeployModule.s.sol:DeployModuleScript --rpc-url $DEPLOYMENT_RPC --broadcast --sender $DEPLOYMENT_SENDER --verify | ||
``` | ||
|
||
### Anvil | ||
Your module is now deployed to the blockchain and verified on Etherscan. | ||
|
||
If the verification fails, you can manually verify it on Etherscan using the following command: | ||
|
||
```shell | ||
$ anvil | ||
source .env && forge verify-contract --chain-id [YOUR_CHAIN_ID] --watch --etherscan-api-key $ETHERSCAN_API_KEY [YOUR_MODULE_ADDRESS] src/[PATH_TO_MODULE].sol:[MODULE_CONTRACT_NAME] | ||
``` | ||
|
||
### Deploy | ||
## Tutorials | ||
|
||
```shell | ||
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key> | ||
For general explainers and guided walkthroughs of building a module, check out our [documentation](https://docs.rhinestone.wtf/modulekit). | ||
|
||
## Using this repo | ||
|
||
To install the dependencies, run: | ||
|
||
```bash | ||
pnpm install | ||
``` | ||
|
||
### Cast | ||
To build the project, run: | ||
|
||
```shell | ||
$ cast <subcommand> | ||
```bash | ||
forge build | ||
``` | ||
|
||
### Help | ||
To run the tests, run: | ||
|
||
```shell | ||
$ forge --help | ||
$ anvil --help | ||
$ cast --help | ||
```bash | ||
forge test | ||
``` | ||
|
||
## Contributing | ||
|
||
For feature or change requests, feel free to open a PR, start a discussion or get in touch with us. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,21 @@ | ||
[profile.default] | ||
emv_version = "paris" | ||
src = "src" | ||
out = "out" | ||
script = "script" | ||
libs = ["node_modules"] | ||
fs_permissions = [{ access = "read", path = "out-optimized" }, { access = "read-write", path = "gas_calculations" }] | ||
allow_paths = ["*", "/"] | ||
|
||
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options | ||
[rpc_endpoints] | ||
mainnet = "${MAINNET_RPC_URL}" | ||
|
||
[fmt] | ||
bracket_spacing = true | ||
int_types = "long" | ||
line_length = 100 | ||
multiline_func_header = "all" | ||
number_underscore = "thousands" | ||
quote_style = "double" | ||
tab_width = 4 | ||
wrap_comments = true |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,54 @@ | ||
{ | ||
"name": "contracts", | ||
"version": "1.0.0", | ||
"license": "MIT", | ||
"name": "@rhinestone/module-template", | ||
"version": "0.4.1", | ||
"description": "A Foundry template for building modules using the ModuleKit", | ||
"license": "GPL-3.0", | ||
"author": { | ||
"name": "Rhinestone", | ||
"url": "https://rhinestone.wtf" | ||
}, | ||
"scripts": { | ||
"build": "forge build", | ||
"build:optimized": "FOUNDRY_PROFILE=optimized forge build", | ||
"build:smt": "FOUNDRY_PROFILE=smt forge build", | ||
"clean": "rm -rf artifacts broadcast cache docs out out-optimized out-svg", | ||
"gas:report": "forge test --gas-report --mp \"./test/integration/**/*.sol\" --nmt \"test(Fuzz)?_RevertWhen_\\w{1,}?\"", | ||
"gas:snapshot": "forge snapshot --mp \"./test/integration/**/*.sol\" --nmt \"test(Fuzz)?_RevertWhen_\\w{1,}?\"", | ||
"gas:snapshot:optimized": "pnpm run build:optimized && FOUNDRY_PROFILE=test-optimized forge snapshot --mp \"./test/integration/**/*.sol\" --nmt \"test(Fork)?(Fuzz)?_RevertWhen_\\w{1,}?\"", | ||
"lint": "pnpm run lint:sol && bun run prettier:check", | ||
"lint:sol": "forge fmt --check && pnpm solhint \"{script,src,test}/**/*.sol\"", | ||
"prepack": "pnpm install && bash ./shell/prepare-artifacts.sh", | ||
"prettier:check": "prettier --check \"**/*.{json,md,svg,yml}\"", | ||
"prettier:write": "prettier --write \"**/*.{json,md,svg,yml}\"", | ||
"test": "forge test", | ||
"test:lite": "FOUNDRY_PROFILE=lite forge test", | ||
"test:optimized": "pnpm run build:optimized && FOUNDRY_PROFILE=test-optimized forge test" | ||
}, | ||
"dependencies": { | ||
"@rhinestone/modulekit": "^0.4.7" | ||
}, | ||
"files": [ | ||
"src", | ||
"test", | ||
"script", | ||
"package.json", | ||
"foundry.toml", | ||
"remappings.txt" | ||
], | ||
"homepage": "https://docs.rhinestone.wtf/module-template", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/rhinestonewtf/module-template.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/rhinestonewtf/module-template/issues" | ||
}, | ||
"keywords": [ | ||
"account abstraction", | ||
"smart account modules", | ||
"module template" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
Oops, something went wrong.