Skip to content

Commit ccc90c8

Browse files
authored
Merge pull request #29 from edgeandnode/tmigone/move-account-modules
feat: Add account-modules Solidity package
2 parents f910613 + ef1d15b commit ccc90c8

32 files changed

Lines changed: 6033 additions & 0 deletions
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Account Modules CI
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'solidity/account-modules/**'
7+
- '.github/workflows/account-modules-ci.yml'
8+
workflow_dispatch:
9+
10+
env:
11+
FOUNDRY_PROFILE: ci
12+
13+
jobs:
14+
check:
15+
name: Account Modules Foundry project
16+
runs-on: ubuntu-latest
17+
defaults:
18+
run:
19+
working-directory: solidity/account-modules
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
submodules: recursive
24+
25+
- name: Install Foundry
26+
uses: foundry-rs/foundry-toolchain@v1
27+
28+
- name: Show Forge version
29+
run: |
30+
forge --version
31+
32+
- name: Install Node dependencies
33+
run: |
34+
cd lib/modulekit && npm install
35+
36+
- name: Run Forge fmt
37+
run: |
38+
forge fmt --check
39+
id: fmt
40+
41+
- name: Run Forge build
42+
run: |
43+
forge build --sizes src/
44+
id: build
45+
46+
- name: Run Forge tests
47+
run: |
48+
ACCOUNT_TYPE=SAFE forge test -vvv
49+
id: test

.gitmodules

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[submodule "solidity/account-modules/lib/forge-std"]
2+
path = solidity/account-modules/lib/forge-std
3+
url = https://github.com/foundry-rs/forge-std
4+
[submodule "solidity/account-modules/lib/modulekit"]
5+
path = solidity/account-modules/lib/modulekit
6+
url = https://github.com/pcarranzav/modulekit
7+
[submodule "solidity/account-modules/lib/openzeppelin-contracts"]
8+
path = solidity/account-modules/lib/openzeppelin-contracts
9+
url = https://github.com/OpenZeppelin/openzeppelin-contracts
10+
[submodule "solidity/account-modules/lib/BokkyPooBahsDateTimeLibrary"]
11+
path = solidity/account-modules/lib/BokkyPooBahsDateTimeLibrary
12+
url = https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary
13+
[submodule "solidity/account-modules/lib/safe-singleton-deployer-sol"]
14+
path = solidity/account-modules/lib/safe-singleton-deployer-sol
15+
url = https://github.com/wilsoncusack/safe-singleton-deployer-sol

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ tmp/
1818
# Lock files
1919
pnpm-lock.yaml
2020
uv.lock
21+
22+
# Solidity submodules (have their own prettier configs)
23+
solidity/**/lib/
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Compiler files
2+
cache/
3+
out/
4+
5+
# Ignores development broadcast logs
6+
!/broadcast
7+
/broadcast/*/31337/
8+
/broadcast/**/dry-run/
9+
10+
# Dotenv file
11+
.env

solidity/account-modules/README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Account Modules
2+
3+
ERC-7579 compliant executor modules for smart account automation in the x402 payments system.
4+
5+
## Modules
6+
7+
### AutoTopUpModule
8+
9+
- Automatically tops up agent accounts when balance falls below threshold
10+
- Configurable per-agent limits (daily, monthly)
11+
- Permissionless triggering with proper checks
12+
- Used by: Main accounts to fund agent accounts
13+
14+
### AutoCollectModule
15+
16+
- Automatically collects payments from service accounts
17+
- Configurable collection thresholds (amount and time)
18+
- Batch collection optimization
19+
- Used by: Service accounts to collect to main accounts
20+
21+
## Architecture
22+
23+
All modules implement the ERC-7579 executor module interface:
24+
25+
- `onInstall(bytes calldata data)` - Module installation
26+
- `onUninstall(bytes calldata data)` - Module removal
27+
- `isModuleType(uint256 typeID)` - Returns true for executor type (0x01)
28+
- `isInitialized(address account)` - Check if module is initialized for account
29+
30+
## Deployment
31+
32+
The modules are deployed as immutable singletons using Safe's Singleton Factory, ensuring the same addresses across all
33+
chains:
34+
35+
- **AutoTopUpExecutor**: `0x16f13052FbFFfcE34E5752b7F4CFF881a030F40B`
36+
- **AutoCollectExecutor**: `0x29864bd91370886c38dE9Fe95F5589E7EbE15130`
37+
38+
These addresses are deterministic and will remain consistent on all supported chains (Base, Base Sepolia, etc.).
39+
40+
## Development
41+
42+
### Prerequisites
43+
44+
- [Foundry](https://book.getfoundry.sh/getting-started/installation)
45+
- [pnpm](https://pnpm.io/installation) (for ModuleKit dependencies)
46+
47+
### Setup
48+
49+
```bash
50+
# Install Forge dependencies
51+
forge install
52+
53+
# Install ModuleKit node dependencies (required for compilation)
54+
cd lib/modulekit && npm install && cd ../..
55+
56+
# Build contracts
57+
forge build
58+
59+
# Run tests
60+
forge test
61+
62+
# Deploy
63+
forge script script/Deploy.s.sol --rpc-url $RPC_URL --broadcast
64+
```
65+
66+
**Important**: ModuleKit requires its node modules to be installed for proper compilation. This step (`pnpm install` in
67+
the modulekit directory) must be performed after cloning the repository and before building.
68+
69+
## Security
70+
71+
- Non-custodial design - modules only execute based on user-defined rules
72+
- Access control via ERC-7579 standards
73+
- Immutable singleton contracts - no upgradeability, no owner
74+
- Comprehensive event logging

0 commit comments

Comments
 (0)