Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Container.sol ERC-4337 compliant #27

Merged
merged 12 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
175 changes: 90 additions & 85 deletions .gas-snapshot

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@
[submodule "lib/openzeppelin-foundry-upgrades"]
path = lib/openzeppelin-foundry-upgrades
url = https://github.com/openzeppelin/openzeppelin-foundry-upgrades
[submodule "lib/thirdweb-contracts"]
path = lib/thirdweb-contracts
url = https://github.com/thirdweb-dev/contracts
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ deploy-deterministic-container:
# Deploy a {Container} contract
# Update the following configs before running the script:
# - {INITIAL_OWNER} with the address of the initial owner
# - {MODULE_KEEPER_ADDRESS} with the address of the {ModuleKeeper} deployment
# - {DOCK_REGISTRY} with the address of the {DockRegistr} factory
# - {DOCK_ID} with the ID of the dock to which the new {Container} will be deployed
# - {INITIAL_MODULES} with the addresses of the enabled initial modules (array)
# - {RPC_URL} with the network RPC used for deployment
deploy-container:
forge script script/DeployContainer.s.sol:DeployContainer \
{INITIAL_OWNER} {MODULE_KEEPER_ADDRESS} [] \
--sig "run(address,address,address[])" --rpc-url {RPC_URL} \
{INITIAL_OWNER} {DOCK_REGISTRY} {DOCK_ID} {INITIAL_MODULES} \
--sig "run(address,address,uint256,address[])" --rpc-url {RPC_URL} \
--private-key $(PRIVATE_KEY) --etherscan-api-key $(ETHERSCAN_API_KEY) \
--broadcast --verify

Expand All @@ -67,10 +69,11 @@ deploy-deterministic-module-keeper:
# Update the following configs before running the script:
# - {INITIAL_OWNER} with the address of the initial owner
# - {MODULE_KEEPER} with the address of the {ModuleKeeper} deployment
# - {ENTRYPOINT} with the address of the {Entrypoiny} contract (currently v6)
# - {RPC_URL} with the network RPC used for deployment
deploy-deterministic-dock-registry:
forge script script/DeployDeterministicDockRegistry.s.sol:DeployDeterministicDockRegistry \
$(CREATE2SALT) {INITIAL_OWNER} {MODULE_KEEPER} \
$(CREATE2SALT) {INITIAL_OWNER} {ENTRYPOINT} {MODULE_KEEPER} \
--sig "run(string,address,address)" --rpc-url {RPC_URL} \
--private-key $(PRIVATE_KEY) --etherscan-api-key $(ETHERSCAN_API_KEY) \
--broadcast --verify
16 changes: 16 additions & 0 deletions lib/thirdweb-contracts/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# EditorConfig http://EditorConfig.org

# top-most EditorConfig file
root = true

# All files
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.sol]
indent_size = 4
5 changes: 5 additions & 0 deletions lib/thirdweb-contracts/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PRIVATE_KEY=

ALCHEMY_KEY=

SCAN_API_KEY=
13 changes: 13 additions & 0 deletions lib/thirdweb-contracts/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# folders
artifacts/
build/
cache/
coverage/
dist/
lib/
node_modules/
typechain/

# files
.solcover.js
coverage.json
21 changes: 21 additions & 0 deletions lib/thirdweb-contracts/.eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
extends:
- "eslint:recommended"
- "plugin:@typescript-eslint/eslint-recommended"
- "plugin:@typescript-eslint/recommended"
- "prettier"
parser: "@typescript-eslint/parser"
parserOptions:
project: "tsconfig.json"
plugins:
- "@typescript-eslint"
root: true
rules:
"@typescript-eslint/no-floating-promises":
- error
- ignoreIIFE: true
ignoreVoid: true
"@typescript-eslint/no-inferrable-types": "off"
"@typescript-eslint/no-unused-vars":
- warn
- argsIgnorePattern: _
varsIgnorePattern: _
61 changes: 61 additions & 0 deletions lib/thirdweb-contracts/.gas-snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
AABenchmarkPrepare:test_prepareBenchmarkFile() (gas: 2926370)
AccountBenchmarkTest:test_state_accountReceivesNativeTokens() (gas: 11037)
AccountBenchmarkTest:test_state_addAndWithdrawDeposit() (gas: 83332)
AccountBenchmarkTest:test_state_contractMetadata() (gas: 56507)
AccountBenchmarkTest:test_state_createAccount_viaEntrypoint() (gas: 432040)
AccountBenchmarkTest:test_state_createAccount_viaFactory() (gas: 334122)
AccountBenchmarkTest:test_state_executeBatchTransaction() (gas: 39874)
AccountBenchmarkTest:test_state_executeBatchTransaction_viaAccountSigner() (gas: 392782)
AccountBenchmarkTest:test_state_executeBatchTransaction_viaEntrypoint() (gas: 82915)
AccountBenchmarkTest:test_state_executeTransaction() (gas: 35735)
AccountBenchmarkTest:test_state_executeTransaction_viaAccountSigner() (gas: 378632)
AccountBenchmarkTest:test_state_executeTransaction_viaEntrypoint() (gas: 75593)
AccountBenchmarkTest:test_state_receiveERC1155NFT() (gas: 39343)
AccountBenchmarkTest:test_state_receiveERC721NFT() (gas: 78624)
AccountBenchmarkTest:test_state_transferOutsNativeTokens() (gas: 81713)
AirdropERC1155BenchmarkTest:test_benchmark_airdropERC1155_airdrop() (gas: 38083572)
AirdropERC20BenchmarkTest:test_benchmark_airdropERC20_airdrop() (gas: 32068413)
AirdropERC721BenchmarkTest:test_benchmark_airdropERC721_airdrop() (gas: 41912536)
DropERC1155BenchmarkTest:test_benchmark_dropERC1155_claim() (gas: 185032)
DropERC1155BenchmarkTest:test_benchmark_dropERC1155_lazyMint() (gas: 123913)
DropERC1155BenchmarkTest:test_benchmark_dropERC1155_setClaimConditions_five_conditions() (gas: 492121)
DropERC20BenchmarkTest:test_benchmark_dropERC20_claim() (gas: 230505)
DropERC20BenchmarkTest:test_benchmark_dropERC20_setClaimConditions_five_conditions() (gas: 500858)
DropERC721BenchmarkTest:test_benchmark_dropERC721_claim_five_tokens() (gas: 210967)
DropERC721BenchmarkTest:test_benchmark_dropERC721_lazyMint() (gas: 124540)
DropERC721BenchmarkTest:test_benchmark_dropERC721_lazyMint_for_delayed_reveal() (gas: 226149)
DropERC721BenchmarkTest:test_benchmark_dropERC721_reveal() (gas: 13732)
DropERC721BenchmarkTest:test_benchmark_dropERC721_setClaimConditions_five_conditions() (gas: 500494)
EditionStakeBenchmarkTest:test_benchmark_editionStake_claimRewards() (gas: 65081)
EditionStakeBenchmarkTest:test_benchmark_editionStake_stake() (gas: 185144)
EditionStakeBenchmarkTest:test_benchmark_editionStake_withdraw() (gas: 46364)
MultiwrapBenchmarkTest:test_benchmark_multiwrap_unwrap() (gas: 88950)
MultiwrapBenchmarkTest:test_benchmark_multiwrap_wrap() (gas: 473462)
NFTStakeBenchmarkTest:test_benchmark_nftStake_claimRewards() (gas: 68287)
NFTStakeBenchmarkTest:test_benchmark_nftStake_stake_five_tokens() (gas: 539145)
NFTStakeBenchmarkTest:test_benchmark_nftStake_withdraw() (gas: 38076)
PackBenchmarkTest:test_benchmark_pack_addPackContents() (gas: 219188)
PackBenchmarkTest:test_benchmark_pack_createPack() (gas: 1412868)
PackBenchmarkTest:test_benchmark_pack_openPack() (gas: 141860)
PackVRFDirectBenchmarkTest:test_benchmark_packvrf_createPack() (gas: 1379604)
PackVRFDirectBenchmarkTest:test_benchmark_packvrf_openPack() (gas: 119953)
PackVRFDirectBenchmarkTest:test_benchmark_packvrf_openPackAndClaimRewards() (gas: 3621)
SignatureDropBenchmarkTest:test_benchmark_signatureDrop_claim_five_tokens() (gas: 140517)
SignatureDropBenchmarkTest:test_benchmark_signatureDrop_lazyMint() (gas: 124311)
SignatureDropBenchmarkTest:test_benchmark_signatureDrop_lazyMint_for_delayed_reveal() (gas: 225891)
SignatureDropBenchmarkTest:test_benchmark_signatureDrop_reveal() (gas: 10647)
SignatureDropBenchmarkTest:test_benchmark_signatureDrop_setClaimConditions() (gas: 73699)
TokenERC1155BenchmarkTest:test_benchmark_tokenERC1155_burn() (gas: 5728)
TokenERC1155BenchmarkTest:test_benchmark_tokenERC1155_mintTo() (gas: 122286)
TokenERC1155BenchmarkTest:test_benchmark_tokenERC1155_mintWithSignature_pay_with_ERC20() (gas: 267175)
TokenERC1155BenchmarkTest:test_benchmark_tokenERC1155_mintWithSignature_pay_with_native_token() (gas: 296172)
TokenERC20BenchmarkTest:test_benchmark_tokenERC20_mintTo() (gas: 118586)
TokenERC20BenchmarkTest:test_benchmark_tokenERC20_mintWithSignature_pay_with_ERC20() (gas: 183032)
TokenERC20BenchmarkTest:test_benchmark_tokenERC20_mintWithSignature_pay_with_native_token() (gas: 207694)
TokenERC721BenchmarkTest:test_benchmark_tokenERC721_burn() (gas: 8954)
TokenERC721BenchmarkTest:test_benchmark_tokenERC721_mintTo() (gas: 151552)
TokenERC721BenchmarkTest:test_benchmark_tokenERC721_mintWithSignature_pay_with_ERC20() (gas: 262344)
TokenERC721BenchmarkTest:test_benchmark_tokenERC721_mintWithSignature_pay_with_native_token() (gas: 286914)
TokenStakeBenchmarkTest:test_benchmark_tokenStake_claimRewards() (gas: 67554)
TokenStakeBenchmarkTest:test_benchmark_tokenStake_stake() (gas: 177180)
TokenStakeBenchmarkTest:test_benchmark_tokenStake_withdraw() (gas: 47396)
1 change: 1 addition & 0 deletions lib/thirdweb-contracts/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sol linguist-language=Solidity
22 changes: 22 additions & 0 deletions lib/thirdweb-contracts/.github/composite-actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "Install"
description: "Sets up Node.js and runs install"

runs:
using: composite
steps:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: "https://registry.npmjs.org"
cache: "yarn"

- name: Install dependencies
shell: bash
run: yarn

- name: Setup lcov
shell: bash
run: |
sudo apt update
sudo apt install -y lcov
17 changes: 17 additions & 0 deletions lib/thirdweb-contracts/.github/workflows/dispatch_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Dispatch Doc Generation

on:
push:
branches:
- main

jobs:
dispatch:
runs-on: ubuntu-latest
steps:
- name: Repository Dispatch
uses: peter-evans/[email protected]
with:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
repository: thirdweb-dev/docs
event-type: generate-docs
37 changes: 37 additions & 0 deletions lib/thirdweb-contracts/.github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This is a basic workflow to help you get started with Actions

name: Solhint Lint

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [main]
pull_request:
branches: [main]

# cancel previous runs if new commits are pushed to the branch
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
lint:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 25

- name: Setup Project
uses: ./.github/composite-actions/setup

- name: Run Lint
run: yarn lint
36 changes: 36 additions & 0 deletions lib/thirdweb-contracts/.github/workflows/prettier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This is a basic workflow to help you get started with Actions

name: Prettier Formatting

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [main]
pull_request:
branches: [main]

# cancel previous runs if new commits are pushed to the branch
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
# This workflow contains a single job called "build"
lint:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 25

- name: Setup Project
uses: ./.github/composite-actions/setup

- name: Run Prettier
run: yarn prettier:contracts
47 changes: 47 additions & 0 deletions lib/thirdweb-contracts/.github/workflows/slither.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Slither Analysis

on:
push:
branches: [main]
pull_request:
branches: [main]

# cancel previous runs if new commits are pushed to the branch
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
analyze:
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 25
node-version: 18

- name: Setup Project
uses: ./.github/composite-actions/setup

- name: Install Foundry
uses: onbjerg/foundry-toolchain@v1
with:
version: nightly

- name: Run Slither
uses: crytic/[email protected]
continue-on-error: true
id: slither
with:
sarif: results.sarif
slither-args: --foundry-out-directory artifacts_forge

- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: ${{ steps.slither.outputs.sarif }}
52 changes: 52 additions & 0 deletions lib/thirdweb-contracts/.github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This is a basic workflow to help you get started with Actions

name: Tests

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [main]
pull_request:
branches: [main]

# cancel previous runs if new commits are pushed to the branch
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
test:
# The type of runner that the job will run on
# 16 core paid runner
runs-on: ubuntu-latest-16

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 25
node-version: 18

- name: Setup Project
uses: ./.github/composite-actions/setup

- name: Install Foundry
uses: onbjerg/foundry-toolchain@v1
with:
version: nightly
- name: Run coverage and tests
run: |
forge coverage --report lcov
lcov --remove lcov.info -o lcov.info 'src/test/**'
lcov --remove lcov.info -o lcov.info 'contracts/external-deps/**'
lcov --remove lcov.info -o lcov.info 'contracts/eip/**'
forge test
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
files: ./lcov.info,
Loading