Skip to content

Commit

Permalink
chore: add RI
Browse files Browse the repository at this point in the history
  • Loading branch information
howydev committed Oct 17, 2023
1 parent 2d5e10b commit 1f32009
Show file tree
Hide file tree
Showing 59 changed files with 7,635 additions and 4 deletions.
25 changes: 25 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--
Borrowed from foundry.
Thank you for your Pull Request. Please provide a description above and review
the requirements below.
Bug fixes and new features should include tests.
-->

## Motivation

<!--
Explain the context and why you're making that change. What is the problem
you're trying to solve? In some cases there is not a problem and this can be
thought of as being the motivation for your change.
If your PR solves a particular issue, tag that issue.
-->

## Solution

<!--
Summarize the solution and provide any necessary context needed to understand
the code change.
-->
91 changes: 91 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: ERC6900 RI Test CI

on: [pull_request, workflow_dispatch]

concurrency:
group: ${{github.workflow}}-${{github.ref}}
cancel-in-progress: true

# Runs linter, tests, and inspection checker in parallel
jobs:
lint:
name: Run Linters
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- run: forge install

- run: forge fmt --check

- name: "Check out the repo"
uses: "actions/checkout@v3"
with:
submodules: "recursive"

- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"

- name: "Install Pnpm"
uses: "pnpm/action-setup@v2"
with:
version: "8"

- name: "Install Node.js"
uses: "actions/setup-node@v3"
with:
cache: "pnpm"
node-version: "lts/*"

- name: "Install the Node.js dependencies"
run: "pnpm install"

- name: "Lint the contracts"
run: "pnpm lint"

test:
name: Run Forge Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Install forge dependencies
run: forge install

- name: Build project
run: forge build

- name: Run tests
run: FOUNDRY_PROFILE=deep forge test -vvv

test-lite:
name: Run Forge Tests [lite build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Install forge dependencies
run: forge install

- name: Build project
run: FOUNDRY_PROFILE=lite forge build

- name: Run tests
run: FOUNDRY_PROFILE=lite forge test -vvv
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Foundry build and cache directories
out/
cache/
node_modules/
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "lib/account-abstraction"]
path = lib/account-abstraction
url = https://github.com/eth-infinitism/account-abstraction
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
17 changes: 17 additions & 0 deletions .solhint-src.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": "solhint:recommended",
"rules": {
"immutable-vars-naming": ["error"],
"no-unused-import": ["error"],
"compiler-version": ["error", ">=0.8.19"],
"func-visibility": ["error", { "ignoreConstructors": true }],
"max-line-length": ["error", 120],
"func-param-name-mixedcase": ["error"],
"modifier-name-mixedcase": ["error"],
"private-vars-leading-underscore": ["error"],
"ordering": ["warn"],
"no-inline-assembly": "off",
"avoid-low-level-calls": "off",
"no-complex-fallback": "off"
}
}
17 changes: 17 additions & 0 deletions .solhint-test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": "solhint:recommended",
"rules": {
"func-name-mixedcase": "off",
"immutable-vars-naming": ["error"],
"no-unused-import": ["error"],
"compiler-version": ["error", ">=0.8.19"],
"func-visibility": ["error", { "ignoreConstructors": true }],
"max-line-length": ["error", 120],
"max-states-count": ["warn", 30],
"modifier-name-mixedcase": ["error"],
"private-vars-leading-underscore": ["error"],
"no-inline-assembly": "off",
"avoid-low-level-calls": "off"
}
}

11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"solidity.packageDefaultDependenciesContractsDirectory": "src",
"solidity.packageDefaultDependenciesDirectory": "lib",
"solidity.compileUsingRemoteVersion": "v0.8.19",
"editor.formatOnSave": true,
"[solidity]": {
"editor.defaultFormatter": "JuanBlanco.solidity"
},
"solidity.formatter": "forge",
"search.exclude": { "lib": true }
}
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ Reference implementation for [ERC-6900](https://eips.ethereum.org/EIPS/eip-6900)

The implementation includes an upgradable modular account with two plugins (`SingleOwnerPlugin` and `TokenReceiverPlugin`). It is compliant with ERC-6900 with the latest updates.

## Caveat
## Important Callouts

- **_Not audited and should not be used in production_**.
- Not optimized in both deployments and execution.
- Lack support for easy account states building. It is possible off-chain, but not easy.
- **Not audited and should NOT be used in production**.
- Not optimized in both deployments and execution. We’ve explicitly removed some optimizations for reader comprehension.

## Development

Expand Down
46 changes: 46 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[profile.default]
solc = '0.8.19'
via_ir = true
src = 'src'
out = 'out'
test = 'test'
libs = ['lib']
optimizer = true
optimizer_runs = 10_000
ignored_error_codes = [3628]

[fuzz]
runs = 500

[invariant]
runs=500
fail_on_revert = true
depth = 10

[profile.lite]
solc = '0.8.19'
via_ir = false
optimizer = true
optimizer_runs = 10_000
ignored_error_codes = [3628]

[profile.deep.fuzz]
runs = 10000

[profile.deep.invariant]
runs = 5000
depth = 32

[fmt]
line_length = 115
wrap_comments = true

[rpc_endpoints]
mainnet = "${RPC_URL_MAINNET}"
goerli = "${RPC_URL_GOERLI}"

[etherscan]
mainnet = { key = "${ETHERSCAN_API_KEY}" }
goerli = { key = "${ETHERSCAN_API_KEY}" }

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
1 change: 1 addition & 0 deletions lib/account-abstraction
Submodule account-abstraction added at 187613
1 change: 1 addition & 0 deletions lib/forge-std
Submodule forge-std added at 066ff1
1 change: 1 addition & 0 deletions lib/openzeppelin-contracts
Submodule openzeppelin-contracts added at e1b3d8
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"devDependencies": {
"pnpm": "^8.7.5",
"solhint": "^3.6.2"
},
"scripts": {
"lint": "pnpm lint:src && pnpm lint:test",
"lint:src": "solhint -c .solhint-src.json ./src/**/*.sol",
"lint:test": "solhint -c .solhint-test.json ./test/**/*.sol"
}
}
Loading

0 comments on commit 1f32009

Please sign in to comment.