Skip to content

Commit

Permalink
chore: cleanup and add ci
Browse files Browse the repository at this point in the history
  • Loading branch information
kopy-kat committed May 21, 2024
1 parent 657d415 commit 4f09c63
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 47 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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"
2 changes: 1 addition & 1 deletion .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"custom-errors": "off",
"func-name-mixedcase": "off",
"func-visibility": ["error", { "ignoreConstructors": true }],
"max-line-length": ["error", 123],
"max-line-length": ["error", 140],
"named-parameters-mapping": "warn",
"no-empty-blocks": "off",
"not-rely-on-time": "off",
Expand Down
2 changes: 2 additions & 0 deletions .solhintignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
node_modules/
test/
src/lib/ERC4337.sol
53 changes: 35 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,48 +14,65 @@ It also supports both `v0.6` and `v0.7` of ERC-4337.

> This library is in active development and is subject to breaking changes. If you spot a bug, please take out an issue and we will fix it as soon as we can.
## Installation
## Using the library

### With Foundry
### Installation

#### With Foundry

```bash
forge install rhinestonewtf/erc4337-validation
```

### Using a package manager
#### With a package manager

```bash
pnpm i @rhinestone/erc4337-validation
```

## Usage
### Usage

To use this library, simply import the `Simulator` and call
To use this library, simply import the `Simulator` and set it up as follows:

```solidity
Simulator.simulateUserOp(userOp, entryPointAddress);
contract Example {
using Simulator for PackedUserOperation; // or UserOperation
function verify(PackedUserOperation memory userOp) external view {
// Verify the ERC-4337 rules
userOp.simulateUserOp(entryPointAddress);
}
}
```

If the userOp breaks any of the rules, the function will revert with a message indicating which rule was broken.

Note that the `entryPointAddress` needs to be the address of the `EntryPointSimulations` contract if you are using v0.7 of ERC-4337. For an example see the [Simulator test](./test/Simulator.t.sol), the [Simulator test v0.6](./test/SimulatorV060.t.sol) and the relevant [test bases](./test/utils).

## 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.

## Credits

- [Dror](https://github.com/drortirosh): For the implementation approach and an initial prototype

## Authors ✨

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tr>
<td align="center"><a href="https://twitter.com/abstractooor"><img src="https://avatars.githubusercontent.com/u/26718079" width="100px;" alt=""/><br /><sub><b>Konrad</b></sub></a><br /><a href="https://github.com/rhinestonewtf/erc4337-validation/commits?author=kopy-kat" title="Code">💻</a> </td>

</tr>
</table>
54 changes: 26 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
{
"name": "@rhinestone/erc4337-validation",
"version": "0.0.1-alpha.1",
"description": "A library to validate the ERC-4337 rules within Foundry",
"license": "MIT",
"version": "0.0.1-alpha.1",
"author": {
"name": "kopy-kat",
"name": "Rhinestone",
"url": "https://rhinestone.wtf"
},
"bugs": {
"url": "https://github.com/rhinestonewtf/erc4337-validation/issues"
"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",
"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": {
"@openzeppelin/contracts": "5.0.1",
Expand All @@ -23,37 +37,21 @@
"files": [
"src",
"test",
"CHANGELOG.md",
"package.json",
"foundry.toml",
"remappings.txt"
],
"homepage": "https://github.com/rhinestonewtf/erc4337-validation#readme",
"repository": "github:rhinestonewtf/erc4337-validation",
"bugs": {
"url": "https://github.com/rhinestonewtf/erc4337-validation/issues"
},
"keywords": [
"account abstraction",
"smart account modules",
"foundry",
"erc-4337"
"erc4337"
],
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "github.com/rhinestonewtf/erc4337-validation"
},
"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",
"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"
}
}

0 comments on commit 4f09c63

Please sign in to comment.