From 56639cb50b33c63f3970a6653f156165b91982ed Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 10 Oct 2024 12:20:16 +0400 Subject: [PATCH] chore: isolate contracts in single directory (#5) --- .gitmodules | 3 +++ chapter1/.gitmodules | 3 --- chapter1/README.md | 9 +++++++++ chapter1/{ => contracts}/.gitignore | 1 - chapter1/contracts/lib/forge-std | 1 + chapter1/contracts/{ => src}/BLSMultisig.sol | 0 chapter1/contracts/{ => src}/P256Delegation.sol | 0 chapter1/contracts/{ => src}/Secp256r1.sol | 0 chapter1/contracts/{ => src}/SimpleDelegateContract.sol | 0 chapter1/contracts/{ => src}/libraries/BLS.sol | 0 chapter1/contracts/{ => src}/libraries/Secp256r1.sol | 0 chapter1/{ => contracts}/test/P256.t.sol | 2 +- chapter1/foundry.toml | 8 +++++--- chapter1/simple-7702/README.md | 2 +- 14 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 .gitmodules delete mode 100644 chapter1/.gitmodules create mode 100644 chapter1/README.md rename chapter1/{ => contracts}/.gitignore (66%) create mode 160000 chapter1/contracts/lib/forge-std rename chapter1/contracts/{ => src}/BLSMultisig.sol (100%) rename chapter1/contracts/{ => src}/P256Delegation.sol (100%) rename chapter1/contracts/{ => src}/Secp256r1.sol (100%) rename chapter1/contracts/{ => src}/SimpleDelegateContract.sol (100%) rename chapter1/contracts/{ => src}/libraries/BLS.sol (100%) rename chapter1/contracts/{ => src}/libraries/Secp256r1.sol (100%) rename chapter1/{ => contracts}/test/P256.t.sol (93%) diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..7199e97 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "chapter1/contracts/lib/forge-std"] + path = chapter1/contracts/lib/forge-std + url = https://github.com/foundry-rs/forge-std diff --git a/chapter1/.gitmodules b/chapter1/.gitmodules deleted file mode 100644 index e07dc56..0000000 --- a/chapter1/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "lib/forge-std"] - path = chapter1/lib/forge-std - url = https://github.com/foundry-rs/forge-std \ No newline at end of file diff --git a/chapter1/README.md b/chapter1/README.md new file mode 100644 index 0000000..78f11db --- /dev/null +++ b/chapter1/README.md @@ -0,0 +1,9 @@ +# Chapter 1 + +## Structure + +- [contracts](./contracts): Solidity smart contracts powering the examples +- [bls-multisig](./bls-multisig): Multisig based on BLS signatures verified through precompiles from EIP-2537 +- [eof](./eof): Introduction to EOF +- [simple-7702](./simple-7702): Demo of full EIP-7702 flow with cast and forge +- [delegate-p256](./delegate-p256): Account controlled by a P256 key through EIP-7702 and EIP-7212 \ No newline at end of file diff --git a/chapter1/.gitignore b/chapter1/contracts/.gitignore similarity index 66% rename from chapter1/.gitignore rename to chapter1/contracts/.gitignore index e0b5534..d8a1d07 100644 --- a/chapter1/.gitignore +++ b/chapter1/contracts/.gitignore @@ -1,3 +1,2 @@ cache/ out/ -*.pem diff --git a/chapter1/contracts/lib/forge-std b/chapter1/contracts/lib/forge-std new file mode 160000 index 0000000..8f24d6b --- /dev/null +++ b/chapter1/contracts/lib/forge-std @@ -0,0 +1 @@ +Subproject commit 8f24d6b04c92975e0795b5868aa0d783251cdeaa diff --git a/chapter1/contracts/BLSMultisig.sol b/chapter1/contracts/src/BLSMultisig.sol similarity index 100% rename from chapter1/contracts/BLSMultisig.sol rename to chapter1/contracts/src/BLSMultisig.sol diff --git a/chapter1/contracts/P256Delegation.sol b/chapter1/contracts/src/P256Delegation.sol similarity index 100% rename from chapter1/contracts/P256Delegation.sol rename to chapter1/contracts/src/P256Delegation.sol diff --git a/chapter1/contracts/Secp256r1.sol b/chapter1/contracts/src/Secp256r1.sol similarity index 100% rename from chapter1/contracts/Secp256r1.sol rename to chapter1/contracts/src/Secp256r1.sol diff --git a/chapter1/contracts/SimpleDelegateContract.sol b/chapter1/contracts/src/SimpleDelegateContract.sol similarity index 100% rename from chapter1/contracts/SimpleDelegateContract.sol rename to chapter1/contracts/src/SimpleDelegateContract.sol diff --git a/chapter1/contracts/libraries/BLS.sol b/chapter1/contracts/src/libraries/BLS.sol similarity index 100% rename from chapter1/contracts/libraries/BLS.sol rename to chapter1/contracts/src/libraries/BLS.sol diff --git a/chapter1/contracts/libraries/Secp256r1.sol b/chapter1/contracts/src/libraries/Secp256r1.sol similarity index 100% rename from chapter1/contracts/libraries/Secp256r1.sol rename to chapter1/contracts/src/libraries/Secp256r1.sol diff --git a/chapter1/test/P256.t.sol b/chapter1/contracts/test/P256.t.sol similarity index 93% rename from chapter1/test/P256.t.sol rename to chapter1/contracts/test/P256.t.sol index c1ccd94..c81284c 100644 --- a/chapter1/test/P256.t.sol +++ b/chapter1/contracts/test/P256.t.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.23; import {Test, console} from "forge-std/Test.sol"; -import {Secp256r1} from "../contracts/Secp256r1.sol"; +import {Secp256r1} from "../src/Secp256r1.sol"; /// @notice A simple test demonstrating P256 signature verification. contract BLSTest is Test { diff --git a/chapter1/foundry.toml b/chapter1/foundry.toml index 19b62fe..2c53aca 100644 --- a/chapter1/foundry.toml +++ b/chapter1/foundry.toml @@ -1,7 +1,9 @@ [profile.default] -src = "contracts" -out = "out" -libs = ["lib"] +src = "contracts/src" +test = "contracts/test" +out = "contracts/out" +cache_path = "contracts/cache" +libs = ["contracts/lib"] eof = true odyssey = true diff --git a/chapter1/simple-7702/README.md b/chapter1/simple-7702/README.md index 152151e..2457246 100644 --- a/chapter1/simple-7702/README.md +++ b/chapter1/simple-7702/README.md @@ -26,7 +26,7 @@ export BOB_PK="0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365 - Deploy a contract which delegates calls from the user and executes on their behalf. The contract itself is very basic, it will delegate the call and emit an `Executed` event for debugging purposes: ```bash -forge create contracts/SimpleDelegateContract.sol:SimpleDelegateContract --private-key $BOB_PK +forge create SimpleDelegateContract --private-key $BOB_PK export SIMPLE_DELEGATE_ADDRESS="" ```