Skip to content

Commit

Permalink
Feat/erc 7579 interfaces (bcnmy#12)
Browse files Browse the repository at this point in the history
* 🙈 Add cache_forge to .gitignore

* Add .husky to .gitignore

* 🎨 Update tab width to 4 spaces in .prettierrc

* 🚧 Disable no-inline-assembly rule in .solhint.json

* ⚡️ Add account-abstraction dependency and update husky hooks

* 🔥 Remove Git hooks for branch name validation

* 🔧 Update tsconfig.json to disable strict mode

* 🎨 Update Solidity version and remappings, delete unused contracts and tests

* 🙈 Add .vscode/settings.json to .gitignore

* 🔥 Delete unused contracts and tests

* ✨ Add utility functions for conversion and formatting

* ✨ Add buildUserOp function to utils.ts

* ✨ Add git hook to check branch names

* ✨ Add SmartAccount contract

* ✨ Add AccountConfig contract implementation

* ✨ Add Execution contract for account execution

* ✨ Add ModuleConfig contract for managing modules

* ✨ Add Storage contract for isolated storage access

* ✨ Add Validator contract for user operation validation

* ⚡️ Add ERC-7579 interfaces for smart account configuration, execution, module, and module configuration

* ✨ Add IStorage interface for ERC20 account storage

* 🚀 Add deployment of SmartAccount contract

* 🚧 Update import statement and variable name in Deploy script

* ⚡️ Add Entrypoint 0.7.0

* ⚡️ Add Imports.sol for consolidated imports

* ✅ Add SmartAccount test file

* 👷 Remove unnecessary branch from PR Automation Workflow

* ✏️ Update storage location for SmartAccount in contracts

* Feat/slither (bcnmy#14)

* 👷 Add Slither analysis workflow

* ♻️ Update Slither workflow to include Foundry installation***

* Add permissions and update Slither configuration

* Update Slither workflow to ensure tool availability

* Update Slither workflow

* Add Slither workflow to run static analysis

* 💚 add yarn.lock

* ✨ Update Slither workflow to include Node.js setup and SARIF report generation

* Remove SARIF file upload step in slither.yml

* Update Slither configuration in workflow

* 🚧 Update Slither workflow to include Foundry installation and contract building

* Remove target directory for analysis in slither.yml workflow

* 🚑 Update Slither workflow to include SARIF file upload

* Add token to SARIF file upload

* Add comment.js and update slither.yml workflow

* Update node version in slither.yml

* Update Slither workflow to fail on medium severity issues

* Add target directory for Slither analysis

* Update slither.yml with filter paths for mock contracts

* Update slither-args in slither.yml

* Fix slither-args path in GitHub workflow

* Update slither configuration to exclude node_modules directory

* Update slither-args in slither.yml workflow

* Update Slither version to 0.10.0

* Update slither.yml to fail on no severity issues

* Add check for pull request event in comment.js

* Update GitHub Actions workflow to trigger on pull requests (bcnmy#15)

* Update GitHub Actions workflow to trigger on pull requests

* Update Slither workflow permissions and arguments

* Refactor CI workflow and remove redundant coverage and slither workflows

* Update Node.js and Foundry versions

* Add Foundry to PATH

* Update CI workflow to install lcov and make other improvements

* Add cache for Foundry Toolchain

* Update CI workflow configuration

* Refactor GitHub Actions workflow***

* Update CI workflow to cache node_modules and Foundry toolchain

* Update CI workflow and add linting, unit tests, coverage, and static analysis

* Update cache keys and add Foundry toolchain

* Add Foundry cache key generation and ensure Foundry directory exists

* Update CI workflow and cache actions***

* Update CI workflow and dependencies

* Update CI workflow to install Foundry and generate coverage report

* Add lcov installation step and update Codecov upload for Foundry and Hardhat coverage reports

* Refactor CI workflow and add Slither analysis

* Update CI Workflow to include linting, unit tests, coverage, and slither analysis

* Refactor CI workflow and update Slither analysis
  • Loading branch information
Aboudjem authored Feb 21, 2024
1 parent c0292de commit fa0dcf8
Show file tree
Hide file tree
Showing 40 changed files with 6,173 additions and 461 deletions.
28 changes: 28 additions & 0 deletions .github/scripts/comment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module.exports = async ({ github, context, header, body }) => {
const comment = [header, body].join("\n");

// Check if the workflow is triggered by a pull request event
if (!context.payload.pull_request) {
console.log('This workflow is not triggered by a pull request. Skipping comment creation/update.');
return;
}

const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
});

const botComment = comments.find(
comment => comment.user.type === 'Bot' && comment.body.startsWith(header)
);

const commentFn = botComment ? 'updateComment' : 'createComment';

await github.rest.issues[commentFn]({
owner: context.repo.owner,
repo: context.repo.repo,
body: comment,
...(botComment ? { comment_id: botComment.id } : { issue_number: context.payload.pull_request.number }),
});
};
16 changes: 0 additions & 16 deletions .github/workflows/automation_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: PR Automation Workflow
on:
pull_request:
branches:
- main
- dev
- release/*
- fix/*

Expand Down Expand Up @@ -41,17 +39,3 @@ jobs:
echo "Error: The version should be updated on following files: ${MISSING_UPDATES[*]}"
exit 1
fi
mirror-fix-to-dev:
runs-on: ubuntu-latest
if: github.event.pull_request.base.ref == 'main' && contains(github.head_ref, 'fix/')
steps:
- uses: actions/checkout@v4
- name: Auto-create PR to dev for fix branches
uses: peter-evans/create-pull-request@v3
with:
branch: sync-${{ github.head_ref }}-to-dev
base: dev
title: "[AUTO] Sync ${{ github.head_ref }} to dev"
body: "Automated PR to sync changes from ${{ github.head_ref }} to dev."
token: ${{ secrets.PAT_TOKEN }}
132 changes: 116 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,77 @@
name: Test workflow
on: push
name: Unified CI Workflow

on: pull_request

permissions:
contents: read
pull-requests: write

jobs:
lint:
name: Lint sources
setup:
runs-on: ubuntu-latest
outputs:
cache-key: ${{ steps.cache-keys.outputs.cache-key }}
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/[email protected]

- name: Get cache key
id: cache-keys
run: echo "::set-output name=cache-key::$(echo ${{ runner.os }}-node-$(cat yarn.lock | sha256sum | cut -d' ' -f1))"

- name: Cache node modules
uses: actions/cache@v4
with:
path: |
**/node_modules
key: ${{ steps.cache-keys.outputs.cache-key }}

- name: Install dependencies
run: yarn install --frozen-lockfile

lint:
name: Lint sources
runs-on: ubuntu-latest
needs: setup
steps:
- name: Checkout
uses: actions/[email protected]

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
uses: foundry-rs/foundry-toolchain@v1.1.1
with:
version: nightly
cache: true

- name: Install foundry dependencies
run: forge install
- name: Cache node modules
uses: actions/cache@v4
with:
path: |
**/node_modules
key: ${{ needs.setup.outputs.cache-key }}

- name: Lint sources
run: yarn lint:sol

unit_test:
name: Unit tests
runs-on: ubuntu-latest
needs: setup
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Create a fake .secret file
run: echo "primary twist rack vendor diagram image used route theme frown either will" > .secret
uses: actions/[email protected]

- name: Cache node modules
uses: actions/cache@v4
with:
path: |
**/node_modules
key: ${{ needs.setup.outputs.cache-key }}
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
uses: foundry-rs/foundry-toolchain@v1.1.1
with:
version: nightly
cache: true

- name: Install foundry dependencies
run: forge install
Expand All @@ -48,3 +81,70 @@ jobs:

- name: Run Forge and Hardhat Tests
run: yarn test

coverage:
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]

- name: Cache node modules
uses: actions/cache@v4
with:
path: |
**/node_modules
key: ${{ needs.setup.outputs.cache-key }}

- name: Install lcov (for genhtml)
run: sudo apt-get update && sudo apt-get install -y lcov

- name: Install Foundry
uses: foundry-rs/[email protected]
with:
version: nightly
cache: true

- name: Generate Hardhat & Foundry Coverage Report
run: yarn coverage:report

- name: Upload Foundry Coverage Report to Codecov
uses: codecov/[email protected]
with:
file: ./coverage/foundry/lcov.info
flags: foundry
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

- name: Upload Hardhat Coverage Report to Codecov
uses: codecov/[email protected]
with:
file: ./coverage/lcov.info
flags: hardhat
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

analyze:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Run Slither
uses: crytic/[email protected]
id: slither
with:
slither-version: "0.10.0"
node-version: "18"
fail-on: "none"
slither-args: '--filter-paths "contracts/mock|node_modules" --checklist --markdown-root ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/contracts/'

- name: Create/update checklist as PR comment
uses: actions/github-script@v7
env:
REPORT: ${{ steps.slither.outputs.stdout }}
with:
script: |
const script = require('.github/scripts/comment')
const header = '# Slither report'
const body = process.env.REPORT
await script({ github, context, header, body })
46 changes: 0 additions & 46 deletions .github/workflows/coverage.yml

This file was deleted.

5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# directories
cache
cache_forge
coverage
node_modules
out
docs
storageLayout
.husky

# files
*.env
Expand Down Expand Up @@ -41,4 +43,5 @@ node_modules
.env

# Foundry cache
cache_forge/solidity-files-cache.json
cache_forge/solidity-files-cache.json
.vscode/settings.json
16 changes: 0 additions & 16 deletions .husky/_/post-checkout

This file was deleted.

16 changes: 0 additions & 16 deletions .husky/_/pre-commit

This file was deleted.

12 changes: 0 additions & 12 deletions .husky/_/pre-push

This file was deleted.

2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"files": "*.sol",
"options": {
"printWidth": 120,
"tabWidth": 2,
"tabWidth": 4,
"proseWrap": "always",
"useTabs": false,
"singleQuote": false,
Expand Down
3 changes: 2 additions & 1 deletion .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"no-unused-import": "error",
"one-contract-per-file": "warn",
"reason-string": "error",
"custom-errors": "off"
"custom-errors": "off",
"no-inline-assembly": "off"
},
"plugins": ["prettier"]
}
34 changes: 34 additions & 0 deletions contracts/Account/AccountConfig.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

import { IAccountConfig } from "../interfaces/IAccountConfig.sol";

contract AccountConfig is IAccountConfig {
/**
* @notice Returns the account id of the smart account.
* @return accountImplementationId The account id of the smart account.
*/
function accountId() external view returns (string memory accountImplementationId) {
return "ModularSmartAccount";
}

/**
* @notice Checks if the account supports a certain execution mode.
* @param encodedMode The encoded mode.
* @return True if the account supports the mode, false otherwise.
*/
function supportsAccountMode(bytes32 encodedMode) external view returns (bool) {
encodedMode;
return true;
}

/**
* @notice Checks if the account supports a certain module typeId.
* @param moduleTypeId The module type ID.
* @return True if the account supports the module type, false otherwise.
*/
function supportsModule(uint256 moduleTypeId) external view returns (bool) {
moduleTypeId;
return true;
}
}
Loading

0 comments on commit fa0dcf8

Please sign in to comment.