Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroknots authored Jun 24, 2024
0 parents commit 89a028c
Show file tree
Hide file tree
Showing 19 changed files with 5,318 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
PK=
DEPLOYMENT_SENDER=
DEPLOYMENT_RPC=
ETHERSCAN_API_KEY=
37 changes: 37 additions & 0 deletions .github/workflows/ci.yaml
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"
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Compiler files
cache/
out/
broadcast

# Docs
docs/

# Dotenv file
.env
node_modules
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
shamefully-hoist=true
18 changes: 18 additions & 0 deletions .solhint.json
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"
}
}
3 changes: 3 additions & 0 deletions .solhintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
test/
script/
81 changes: 81 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
## Module Template

**A template for building smart account modules using the [ModuleKit](https://github.com/rhinestonewtf/modulekit)**

## Using the template

### Install dependencies

```shell
pnpm install
```

### Update ModuleKit

```shell
pnpm update rhinestonewtf/modulekit
```

### 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 build
```

### 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 test
```

### 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
source .env && forge script script/DeployModule.s.sol:DeployModuleScript --rpc-url $DEPLOYMENT_RPC --broadcast --sender $DEPLOYMENT_SENDER --verify
```

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
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]
```

## Tutorials

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
```

To build the project, run:

```bash
forge build
```

To run the tests, run:

```bash
forge test
```

## Contributing

For feature or change requests, feel free to open a PR, start a discussion or get in touch with us.
21 changes: 21 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +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 = ["*", "/"]

[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 added gas_calculations/.gitkeep
Empty file.
54 changes: 54 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"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.5"
},
"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"
}
}
Loading

0 comments on commit 89a028c

Please sign in to comment.