Skip to content

Commit

Permalink
feat [wip]: Added more code in validateUserOp() and basic code stru…
Browse files Browse the repository at this point in the history
…cture in the test code (#8)

* updated

* updated

* updated

* Updated the validateUserOp and testing code

* linted
  • Loading branch information
jimmychu0807 authored Dec 20, 2024
1 parent b49de49 commit ce2c97c
Show file tree
Hide file tree
Showing 13 changed files with 334 additions and 366 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ gas_calculations/
node_modules

# My files
src/utils/semaphore-contracts
src/utils/semaphore-*
62 changes: 11 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,25 @@
## Module Template
## Semaphore Modular Smart Contract (MSA) Validator Module

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

The module aims to adhere with **ERC-7579** standard ([introduction](https://erc7579.com/), [eip](https://eips.ethereum.org/EIPS/eip-7579)) and is forked from [rhinestonewtf/module-template](https://github.com/rhinestonewtf/module-template).

## Using the template

### Install dependencies
### Building modules

```shell
# Install dependencies
pnpm install
```

### Update ModuleKit

```shell
# Update ModuleKit
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:
# Build
pnpm build

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

### Deploying modules
Expand All @@ -52,34 +40,6 @@ If the verification fails, you can manually verify it on Etherscan using the fol
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
```

## Development Notes

- Within the validator contract context, the msg.sender is either the **smart account** contract, or the bundler. It is never the EOA that own ther smart acct, the original intender of the smart account.

## Contributing

For feature or change requests, feel free to open a PR, start a discussion or get in touch with us.
1 change: 1 addition & 0 deletions docs/assets/4337-lifecycle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions docs/design.md → docs/development.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## Semaphore

- On semaphore this is how it generate a proof
`await generateProof(identity, group, message, group.root, merkleTreeDepth)`

Expand All @@ -19,6 +21,13 @@
);
```

## ERC-4337 Lifecycle

![ERC-4337 Lifecycle](./assets/4337-lifecycle.svg)

- ERC-4337: [introduction](https://www.erc4337.io/), [eip](https://eips.ethereum.org/EIPS/eip-4337)
- ERC-7579: [introduction](https://erc7579.com/), [eip](https://eips.ethereum.org/EIPS/eip-7579)

## Tasks

- have foundry ffi communicate with @semaphore/hardhat task to generateProof that
Expand Down Expand Up @@ -54,3 +63,9 @@
- add a signature to a tx and execute:
- function interface: TODO
## TODO & Questions
- Need to implement `Identity.verifySignature()` contract function. Check if there is any open source project that have implemented that.
- How to handle **msg.value** in validateUserOp when it is a token transfer?
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
},
"devDependencies": {
"@rhinestone/modulekit": "~0.5.1",
"@semaphore-protocol/contracts": "~4.7.2",
"@semaphore-protocol/core": "~4.7.2"
"@semaphore-protocol/contracts": "^4.8.0",
"@semaphore-protocol/core": "^4.8.0",
"poseidon-solidity": "github:chancehudson/poseidon-solidity#main"
},
"files": [
"src",
Expand Down
Loading

0 comments on commit ce2c97c

Please sign in to comment.