diff --git a/.eslintrc.js b/.eslintrc.js index ca03d171c..30b08d911 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -30,7 +30,7 @@ module.exports = { "unicorn/filename-case": "off", // use default export name "unicorn/prefer-top-level-await": "off", // unsupported in react-native }, - ignorePatterns: ["build/", "dist/", ".expo/types/**/*.ts", "expo-env.d.ts"], + ignorePatterns: ["build/", "dist/", ".expo/types/**/*.ts", "expo-env.d.ts", "contracts/lib/"], overrides: [ { files: [...nodeFiles, "pomelo/**"], diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index f0f719667..c1c634952 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -10,5 +10,12 @@ jobs: steps: - uses: actions/checkout@v4 - uses: oven-sh/setup-bun@v1 + - uses: foundry-rs/foundry-toolchain@v1 + - uses: actions/setup-python@v4 + with: + python-version: '3.11' + cache: pip + cache-dependency-path: contracts/requirements.txt + - run: pip install -r contracts/requirements.txt - run: bun install - run: bun run test diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..8ca687fe9 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "contracts/lib/forge-std"] + path = contracts/lib/forge-std + url = https://github.com/foundry-rs/forge-std +[submodule "contracts/lib/light-account"] + path = contracts/lib/light-account + url = https://github.com/alchemyplatform/light-account diff --git a/bun.lockb b/bun.lockb index f17db01a2..bae7dde12 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/contracts/.gitignore b/contracts/.gitignore new file mode 100644 index 000000000..0dd980482 --- /dev/null +++ b/contracts/.gitignore @@ -0,0 +1,9 @@ +cache/ +docs/ +out/ + +!/broadcast +/broadcast/*/31337/ +/broadcast/**/dry-run/ + +.env diff --git a/contracts/.solhint.json b/contracts/.solhint.json new file mode 100644 index 000000000..4d691136a --- /dev/null +++ b/contracts/.solhint.json @@ -0,0 +1,6 @@ +{ + "extends": "solhint:recommended", + "rules": { + "func-visibility": ["error", { "ignoreConstructors": true }] + } +} diff --git a/contracts/foundry.toml b/contracts/foundry.toml new file mode 100644 index 000000000..828a47667 --- /dev/null +++ b/contracts/foundry.toml @@ -0,0 +1,10 @@ +[profile.default] +solc = "0.8.23" +optimizer = true +optimizer_runs = 200 +verbosity = 3 + +[fmt] +tab_width = 2 +bracket_spacing = true +number_underscore = "thousands" diff --git a/contracts/lib/forge-std b/contracts/lib/forge-std new file mode 160000 index 000000000..155d547c4 --- /dev/null +++ b/contracts/lib/forge-std @@ -0,0 +1 @@ +Subproject commit 155d547c449afa8715f538d69454b83944117811 diff --git a/contracts/lib/light-account b/contracts/lib/light-account new file mode 160000 index 000000000..61e6074d0 --- /dev/null +++ b/contracts/lib/light-account @@ -0,0 +1 @@ +Subproject commit 61e6074d011891a181b6095a01ec26d9cdc8d813 diff --git a/contracts/package.json b/contracts/package.json new file mode 100644 index 000000000..d40030b62 --- /dev/null +++ b/contracts/package.json @@ -0,0 +1,15 @@ +{ + "name": "@exactly/contracts", + "scripts": { + "test": "concurrently 'npm:test:*' --group -c auto", + "test:fmt": "forge fmt --check", + "test:forge": "forge test", + "test:solhint": "solhint '{src,script,test}/**/*.sol'", + "test:slither": "slither .", + "prepare": "git submodule update --init --recursive" + }, + "devDependencies": { + "concurrently": "^8.2.2", + "solhint": "^4.0.0" + } +} diff --git a/contracts/remappings.txt b/contracts/remappings.txt new file mode 100644 index 000000000..3c725f883 --- /dev/null +++ b/contracts/remappings.txt @@ -0,0 +1,2 @@ +light-account/=lib/light-account/src/ +forge-std/=lib/forge-std/src/ diff --git a/contracts/requirements.txt b/contracts/requirements.txt new file mode 100644 index 000000000..555a03c9b --- /dev/null +++ b/contracts/requirements.txt @@ -0,0 +1 @@ +slither-analyzer==0.10.0 diff --git a/contracts/slither.config.json b/contracts/slither.config.json new file mode 100644 index 000000000..b9ac311c0 --- /dev/null +++ b/contracts/slither.config.json @@ -0,0 +1,4 @@ +{ + "detectors_to_exclude": "solc-version,naming-convention", + "filter_paths": "lib" +} diff --git a/contracts/src/Account.sol b/contracts/src/Account.sol new file mode 100644 index 000000000..53ba8f9b6 --- /dev/null +++ b/contracts/src/Account.sol @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.23; + +import { LightAccount, IEntryPoint } from "light-account/LightAccount.sol"; + +contract Account is LightAccount { + constructor(IEntryPoint anEntryPoint) LightAccount(anEntryPoint) { } +} diff --git a/package.json b/package.json index 63b403507..8b2e4c555 100644 --- a/package.json +++ b/package.json @@ -10,10 +10,12 @@ "test": "concurrently 'npm:test:*' --group -c auto", "test:ts:expo": "tsc", "test:ts:node": "tsc -p tsconfig.node.json", + "test:contracts": "bun run --cwd contracts test", "test:pomelo": "bun run --cwd pomelo test", "test:eslint": "eslint --max-warnings=0 ." }, "workspaces": [ + "contracts", "pomelo", "webauthn" ], diff --git a/tsconfig.json b/tsconfig.json index 3e61fd954..62621aa79 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,5 +8,15 @@ "noUncheckedIndexedAccess": true }, "include": ["**/*.ts", "**/*.tsx", ".expo/types/**/*.ts", "expo-env.d.ts"], - "exclude": ["**/node_modules", "**/build", "**/dist", ".tamagui", "*.config.ts", "pomelo", "webauthn", ".vercel"] + "exclude": [ + "contracts", + "pomelo", + "webauthn", + "**/node_modules", + "**/build", + "**/dist", + "*.config.ts", + ".tamagui", + ".vercel" + ] }