Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
forge install: account-abstraction

ver0.6.0

chore: clean interface comments
  • Loading branch information
jaypaik committed Nov 20, 2023
0 parents commit c95bc28
Show file tree
Hide file tree
Showing 117 changed files with 22,735 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
DEPLOYER_PRIVATE_KEY=

RPC_URL_MAINNET=
RPC_URL_GOERLI=

ETHERSCAN_API_KEY=
385 changes: 385 additions & 0 deletions .gasestimates.md

Large diffs are not rendered by default.

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.
-->
110 changes: 110 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: account-contracts 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-5be158ba6dc7c798a6f032026fe60fc01686b33b
- 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"

# check-inspect:
# name: Verify Inspections
# 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: bash ./utils/inspect.sh

# - run: git status --untracked-files=no --porcelain
# - run: git --no-pager diff

# - name: Check Inspections
# run: if [[ -n "$(git status --untracked-files=no --porcelain)" ]]; then echo "Inspection difference detected, verify tests are passing and run \`bash ./utils/inspect.sh\` to fix." && exit 1; fi

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-5be158ba6dc7c798a6f032026fe60fc01686b33b

- name: Install forge dependencies
run: forge install

- name: Build project
run: forge build --sizes

- 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-5be158ba6dc7c798a6f032026fe60fc01686b33b

- 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
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Foundry build and cache directories
out/
cache/
node_modules/

# coverage
report/
lcov.info
14 changes: 14 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/account-abstraction"]
path = lib/account-abstraction
url = https://github.com/eth-infinitism/account-abstraction
branch = ver0.6.0
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
branch = release-v4.9
[submodule "lib/light-account"]
path = lib/light-account
url = https://github.com/alchemyplatform/light-account
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.21"],
"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"
}
}
16 changes: 16 additions & 0 deletions .solhint-test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": "solhint:recommended",
"rules": {
"func-name-mixedcase": "off",
"immutable-vars-naming": ["error"],
"no-unused-import": ["error"],
"compiler-version": ["error", ">=0.8.21"],
"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"
}
}
82 changes: 82 additions & 0 deletions .storagelayout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Storage Layouts
Generated via `bash utils/inspect.sh`.

---

`forge inspect --pretty src/account/AccountExecutor.sol:AccountExecutor storage-layout`
| Name | Type | Slot | Offset | Bytes | Contract |
|------|------|------|--------|-------|----------|

`forge inspect --pretty src/account/BaseModularAccount.sol:BaseModularAccount storage-layout`
| Name | Type | Slot | Offset | Bytes | Contract |
|------|------|------|--------|-------|----------|

`forge inspect --pretty src/account/BaseModularAccountLoupe.sol:BaseModularAccountLoupe storage-layout`
| Name | Type | Slot | Offset | Bytes | Contract |
|------|------|------|--------|-------|----------|

`forge inspect --pretty src/account/DiamondStorageInitializable.sol:DiamondStorageInitializable storage-layout`
| Name | Type | Slot | Offset | Bytes | Contract |
|------|------|------|--------|-------|----------|

`forge inspect --pretty src/account/UpgradeableModularAccount.sol:UpgradeableModularAccount storage-layout`
| Name | Type | Slot | Offset | Bytes | Contract |
|------|------|------|--------|-------|----------|

`forge inspect --pretty src/factory/ModularAccountFactory.sol:ModularAccountFactory storage-layout`
| Name | Type | Slot | Offset | Bytes | Contract |
|---------------|---------|------|--------|-------|-------------------------------------------------------------|
| _owner | address | 0 | 0 | 20 | src/factory/ModularAccountFactory.sol:ModularAccountFactory |
| _pendingOwner | address | 1 | 0 | 20 | src/factory/ModularAccountFactory.sol:ModularAccountFactory |

`forge inspect --pretty src/factory/ProxyLoader.sol:ProxyLoader storage-layout`
| Name | Type | Slot | Offset | Bytes | Contract |
|------|------|------|--------|-------|----------|

`forge inspect --pretty src/factory/verifiers/ECDSASigVerifier.sol:ECDSASigVerifier storage-layout`
| Name | Type | Slot | Offset | Bytes | Contract |
|------|------|------|--------|-------|----------|

`forge inspect --pretty src/plugins/BasePlugin.sol:BasePlugin storage-layout`
| Name | Type | Slot | Offset | Bytes | Contract |
|------|------|------|--------|-------|----------|

`forge inspect --pretty src/plugins/TokenReceiverPlugin.sol:TokenReceiverPlugin storage-layout`
| Name | Type | Slot | Offset | Bytes | Contract |
|------|------|------|--------|-------|----------|

`forge inspect --pretty src/plugins/owner/ExternalOwnerPlugin.sol:ExternalOwnerPlugin storage-layout`
| Name | Type | Slot | Offset | Bytes | Contract |
|---------|-----------------------------|------|--------|-------|---------------------------------------------------------------|
| _owners | mapping(address => address) | 0 | 0 | 32 | src/plugins/owner/ExternalOwnerPlugin.sol:ExternalOwnerPlugin |

`forge inspect --pretty src/plugins/recovery/SocialRecoveryPlugin.sol:SocialRecoveryPlugin storage-layout`
| Name | Type | Slot | Offset | Bytes | Contract |
|------------------|--------------------------------------------------------------|------|--------|-------|--------------------------------------------------------------------|
| _nameFallback | string | 0 | 0 | 32 | src/plugins/recovery/SocialRecoveryPlugin.sol:SocialRecoveryPlugin |
| _versionFallback | string | 1 | 0 | 32 | src/plugins/recovery/SocialRecoveryPlugin.sol:SocialRecoveryPlugin |
| _accountData | mapping(address => struct ISocialRecoveryPlugin.AccountData) | 2 | 0 | 32 | src/plugins/recovery/SocialRecoveryPlugin.sol:SocialRecoveryPlugin |

`forge inspect --pretty src/plugins/security/AccountTimelockPlugin.sol:AccountTimelockPlugin storage-layout`
| Name | Type | Slot | Offset | Bytes | Contract |
|---------------------|---------------------------------------------------------------|------|--------|-------|----------------------------------------------------------------------|
| _seed | uint64 | 0 | 0 | 8 | src/plugins/security/AccountTimelockPlugin.sol:AccountTimelockPlugin |
| _accountData | mapping(address => struct IAccountTimelockPlugin.AccountData) | 1 | 0 | 32 | src/plugins/security/AccountTimelockPlugin.sol:AccountTimelockPlugin |
| _timelockExpiration | mapping(bytes32 => uint256) | 2 | 0 | 32 | src/plugins/security/AccountTimelockPlugin.sol:AccountTimelockPlugin |

`forge inspect --pretty src/plugins/session/SessionKeyPlugin.sol:SessionKeyPlugin storage-layout`
| Name | Type | Slot | Offset | Bytes | Contract |
|------|------|------|--------|-------|----------|

`forge inspect --pretty src/plugins/session/permissions/SessionKeyPermissionsBase.sol:SessionKeyPermissionsBase storage-layout`
| Name | Type | Slot | Offset | Bytes | Contract |
|------|------|------|--------|-------|----------|

`forge inspect --pretty src/plugins/session/permissions/SessionKeyPermissionsLoupe.sol:SessionKeyPermissionsLoupe storage-layout`
| Name | Type | Slot | Offset | Bytes | Contract |
|------|------|------|--------|-------|----------|

`forge inspect --pretty src/plugins/session/permissions/SessionKeyPermissionsPlugin.sol:SessionKeyPermissionsPlugin storage-layout`
| Name | Type | Slot | Offset | Bytes | Contract |
|------|------|------|--------|-------|----------|

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.21",
"editor.formatOnSave": true,
"[solidity]": {
"editor.defaultFormatter": "JuanBlanco.solidity"
},
"solidity.formatter": "forge",
"search.exclude": { "lib": true }
}
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Alchemy Modular Smart Contract Account (MSCA)

Contracts for an upgradeable modular smart contract account that is compatible with ERC-4337 and ERC-6900, along with a set of plugins.

## Development

### Naming convention

- `selector` is used for all function selectors.
- `validation` and `validationFunction` are used to replace `validator`.
- `associated` and `associatedFunction` are used to represents `validationFunction` and `hook`

## Build

```bash
forge build

# or use the lite profile to reduce compilation time
FOUNDRY_PROFILE=lite forge build
```

## Syntax check

```bash
pnpm lint:src && pnpm lint:test
```

## Test

```bash
forge test -vvv

# or use the lite profile to reduce compilation time
FOUNDRY_PROFILE=lite forge test -vvv
```

## Generate Inspections

```bash
bash utils/inspect.sh
```

## Static Analysis

```bash
slither .
```

## External Libraries

We use Solady's highly optimized [UUPSUpgradeable](https://github.com/Vectorized/solady/blob/a061f38f27cd7ae330a86d42d3f15b4e7237f064/src/utils/UUPSUpgradeable.sol) in our contracts
Loading

0 comments on commit c95bc28

Please sign in to comment.