Skip to content

Commit

Permalink
Merge pull request #6 from reown-com/chore/remove-foundry-install
Browse files Browse the repository at this point in the history
chore: remove foundry install
  • Loading branch information
chris13524 authored Nov 6, 2024
2 parents eb1c194 + e409f17 commit abd2b61
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 134 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
- nightly
steps:
- uses: actions/checkout@v4
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- run: cargo test --workspace --all-features --all-targets
- run: cargo test --workspace --all-features --doc
Expand All @@ -36,3 +38,19 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: cargo fmt --all -- --check

# `git diff bytecode` shows changes but I'm not sure why. Disabling for now
# verify-bytecode:
# name: Verify Bytecode
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: Install Foundry
# uses: foundry-rs/foundry-toolchain@v1
# - run: forge build --contracts=contracts
# - run: mkdir -p bytecode/Erc6492.sol
# - run: jq -r .bytecode.object out/Erc6492.sol/ValidateSigOffchain.json | xxd -r -p > bytecode/Erc6492.sol/ValidateSigOffchain.bytecode
# - run: mkdir -p bytecode/Erc1271Mock.sol
# - run: jq -r .bytecode.object out/Erc1271Mock.sol/Erc1271Mock.json | xxd -r -p > bytecode/Erc1271Mock.sol/Erc1271Mock.bytecode
# - run: git diff bytecode
# - run: if [ -n "$(git diff bytecode)" ]; then exit 1; fi
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/target
/out
/cache
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,3 @@ alloy = { version = "0.3", features = ["signer-local"] }
alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy.git", rev = "d68a6b7" }
regex = "1"
tokio = { version = "1", features = ["full"] }

[build-dependencies]
alloy-primitives = { version = "0.8.0" }
serde_json = "1"
104 changes: 0 additions & 104 deletions build.rs

This file was deleted.

Binary file added bytecode/Erc1271Mock.sol/Erc1271Mock.bytecode
Binary file not shown.
Binary file not shown.
8 changes: 8 additions & 0 deletions devloop.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#!/bin/bash
set -e

forge build --contracts=contracts

mkdir -p bytecode/Erc6492.sol
jq -r .bytecode.object out/Erc6492.sol/ValidateSigOffchain.json | xxd -r -p > bytecode/Erc6492.sol/ValidateSigOffchain.bytecode

mkdir -p bytecode/Erc1271Mock.sol
jq -r .bytecode.object out/Erc1271Mock.sol/Erc1271Mock.json | xxd -r -p > bytecode/Erc1271Mock.sol/Erc1271Mock.bytecode

cargo fmt --all
cargo clippy --workspace --all-features --all-targets -- -D warnings
cargo test --workspace --all-features --all-targets
Expand Down
12 changes: 4 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ sol! {
constructor (address _signer, bytes32 _hash, bytes memory _signature);
}
}
const VALIDATE_SIG_OFFCHAIN_BYTECODE: &[u8] = include_bytes!(concat!(
env!("OUT_DIR"),
"/../../../../.foundry/forge/out/Erc6492.sol/ValidateSigOffchain.bytecode"
));
const VALIDATE_SIG_OFFCHAIN_BYTECODE: &[u8] =
include_bytes!("../bytecode/Erc6492.sol/ValidateSigOffchain.bytecode");

#[must_use]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
Expand Down Expand Up @@ -374,10 +372,8 @@ mod test {
);
}

const ERC1271_MOCK_BYTECODE: &[u8] = include_bytes!(concat!(
env!("OUT_DIR"),
"/../../../../.foundry/forge/out/Erc1271Mock.sol/Erc1271Mock.bytecode"
));
const ERC1271_MOCK_BYTECODE: &[u8] =
include_bytes!("../bytecode/Erc1271Mock.sol/Erc1271Mock.bytecode");
const ERC6492_MAGIC_BYTES: [u16; 16] = [
0x6492, 0x6492, 0x6492, 0x6492, 0x6492, 0x6492, 0x6492, 0x6492, 0x6492, 0x6492, 0x6492,
0x6492, 0x6492, 0x6492, 0x6492, 0x6492,
Expand Down
18 changes: 2 additions & 16 deletions src/test_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,13 @@ use {
tokio::process::Command,
};

fn format_foundry_dir(path: &str) -> String {
format!(
"{}/../../../../.foundry/{}",
std::env::var("OUT_DIR").unwrap(),
path
)
}

pub fn spawn_anvil() -> (
AnvilInstance,
String,
ReqwestProvider,
LocalSigner<SigningKey>,
) {
let anvil = Anvil::at(format_foundry_dir("bin/anvil")).spawn();
let anvil = Anvil::new().spawn();
let rpc_url = anvil.endpoint();
let provider = ReqwestProvider::<Ethereum>::new_http(anvil.endpoint_url());
let private_key = anvil.keys().first().unwrap().clone();
Expand All @@ -48,8 +40,6 @@ pub async fn deploy_contract(
constructor_arg: Option<&str>,
) -> Address {
let key_encoded = hex::encode(signer.to_bytes());
let cache_folder = format_foundry_dir("forge/cache");
let out_folder = format_foundry_dir("forge/out");
let mut args = vec![
"create",
"--contracts=contracts",
Expand All @@ -58,16 +48,12 @@ pub async fn deploy_contract(
rpc_url,
"--private-key",
&key_encoded,
"--cache-path",
&cache_folder,
"--out",
&out_folder,
];
if let Some(arg) = constructor_arg {
args.push("--constructor-args");
args.push(arg);
}
let output = Command::new(format_foundry_dir("bin/forge"))
let output = Command::new("forge")
.args(args)
.stdout(Stdio::piped())
.stderr(Stdio::piped())
Expand Down

0 comments on commit abd2b61

Please sign in to comment.