Skip to content

Commit

Permalink
chore: wasm target (#10)
Browse files Browse the repository at this point in the history
* chore: wasm target

* chore: fix stuff

* chore: missing udeps

* chore: fmt sscache

* chore: separate udeps check

* chore: rename

* chore: fix udeps
  • Loading branch information
chris13524 authored Sep 4, 2024
1 parent 9c29b40 commit 305ee0a
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 16 deletions.
41 changes: 39 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- uses: pnpm/action-setup@v4
with:
version: 9
Expand All @@ -27,10 +29,43 @@ jobs:
- run: while ! curl localhost:8545/health; do sleep 1; done
- run: while ! curl localhost:4337/health; do sleep 1; done
- run: while ! curl localhost:3000/ping; do sleep 1; done
- run: cargo build --workspace --all-features --all-targets
- run: cargo test --all-features --lib --bins
# - run: cargo clippy --workspace --all-features --all-targets -- -D warnings
# - run: cargo +nightly fmt --all -- --check
# - run: cargo +nightly udeps --workspace
- run: cargo +nightly fmt --all -- --check

udeps:
name: Unused dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- uses: pnpm/action-setup@v4
with:
version: 9
- run: rustup update stable && rustup default stable
- run: rustup toolchain install nightly -c rustfmt
- run: git submodule update --init --recursive
- run: make setup-thirdparty
- run: cargo install cargo-udeps
- run: cargo +nightly udeps --workspace

build_wasm:
name: Build on WASM
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- uses: pnpm/action-setup@v4
with:
version: 9
- run: rustup update stable && rustup default stable
- run: rustup target add wasm32-unknown-unknown
- run: git submodule update --init --recursive
- run: make setup-thirdparty
- run: cargo build --workspace --all-features --lib --bins --target wasm32-unknown-unknown --exclude=ffi

build_swift_and_test:
name: Swift Package - latest
Expand All @@ -41,6 +76,8 @@ jobs:
- debug
steps:
- uses: actions/checkout@v4
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- uses: pnpm/action-setup@v4
with:
version: 9
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ eyre = "0.6.12"
thiserror = "1.0"

# Async
tokio = { version = "1.17", features = ["full"] }
tokio = { version = "1.17", features = [] }

# Networking
reqwest = { version = "0.12.5", features = ["json"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ rust-version.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
yttrium = { path = "../yttrium" }
# yttrium = { path = "../yttrium" }
2 changes: 1 addition & 1 deletion crates/ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ swift-bridge-build = { git = "https://github.com/wooden-worm/swift-bridge.git",

[dependencies]
# See: https://github.com/kornelski/rust-security-framework/pull/204
security-framework = "2.10.0"
# security-framework = "2.10.0"

swift-bridge = { git = "https://github.com/wooden-worm/swift-bridge.git", branch = "derive_debug_serde", features = [
"async",
Expand Down
16 changes: 12 additions & 4 deletions crates/yttrium/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ rust-version.workspace = true
[dependencies]
# Ethereum
alloy = { git = "https://github.com/alloy-rs/alloy", rev = "b000e16", features = [
"full",
"contract",
"network",
"providers",
"node-bindings",
"rpc-types-trace",
"signer-mnemonic",
] }
# foundry-block-explorers = "0.2.3"
getrandom = { version = "0.2", features = ["js"] }

# Error/Result
eyre.workspace = true
Expand All @@ -25,19 +28,24 @@ tokio.workspace = true
serde.workspace = true
serde_json.workspace = true

# Networking
reqwest.workspace = true

# Env vars
dotenvy = "0.15.7"

# Other
hex = "0.4.3"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]

# Networking
reqwest.workspace = true

[dev-dependencies]
# mocking
wiremock = "0.6.0"

# Networking
reqwest.workspace = true

[build-dependencies]
alloy-primitives = { version = "0.7.0" }
serde_json = "1"
12 changes: 7 additions & 5 deletions crates/yttrium/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,11 @@ fn compile_contracts(contracts_dir: &str) {
}

// const ERC6492_FILE: &str = "forge/out/Erc6492.sol/ValidateSigOffchain.json";
// const ERC6492_BYTECODE_FILE: &str = "forge/out/Erc6492.sol/ValidateSigOffchain.bytecode";
// const ERC6492_BYTECODE_FILE: &str =
// "forge/out/Erc6492.sol/ValidateSigOffchain.bytecode";
// const ERC1271_MOCK_FILE: &str = "forge/out/Erc1271Mock.sol/Erc1271Mock.json";
// const ERC1271_MOCK_BYTECODE_FILE: &str = "forge/out/Erc1271Mock.sol/Erc1271Mock.bytecode";
// fn extract_bytecodes() {
// const ERC1271_MOCK_BYTECODE_FILE: &str =
// "forge/out/Erc1271Mock.sol/Erc1271Mock.bytecode"; fn extract_bytecodes() {
// extract_bytecode(
// &format_foundry_dir(ERC6492_FILE),
// &format_foundry_dir(ERC6492_BYTECODE_FILE),
Expand All @@ -92,8 +93,9 @@ fn compile_contracts(contracts_dir: &str) {
// }

// fn extract_bytecode(input_file: &str, output_file: &str) {
// let contents = serde_json::from_slice::<Value>(&std::fs::read(input_file).unwrap()).unwrap();
// let bytecode = contents
// let contents =
// serde_json::from_slice::<Value>(&std::fs::read(input_file).unwrap()).
// unwrap(); let bytecode = contents
// .get("bytecode")
// .unwrap()
// .get("object")
Expand Down
1 change: 1 addition & 0 deletions crates/yttrium/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod account_client;
#[cfg(not(target_arch = "wasm32"))]
pub mod bundler;
pub mod chain;
pub mod config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ mod tests {

println!("Received User Operation hash: {:?}", user_operation_hash);

// let's also wait for the userOperation to be included, by continually querying for the receipts
// let's also wait for the userOperation to be included, by continually
// querying for the receipts

// println!("Querying for receipts...");

Expand Down
10 changes: 9 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,24 @@ setup:
git submodule update --init --recursive
make setup-thirdparty

devloop: setup clippy test fmt udeps
# Note: requires running `just setup` first
# TODO replace `build` with `clippy` when clippy passes
devloop: build test fmt udeps

test:
cargo test --all-features --lib --bins

clippy:
cargo clippy --workspace --all-features --all-targets -- -D warnings
cargo clippy --workspace --all-features --lib --bins --target wasm32-unknown-unknown --exclude=ffi -- -D warnings

fmt:
cargo +nightly fmt --all

udeps:
cargo +nightly udeps --workspace

# TODO remove `build` in-favor of `clippy` when clippy passes
build:
cargo build --workspace --all-features --all-targets
cargo build --workspace --all-features --lib --bins --target wasm32-unknown-unknown --exclude=ffi

0 comments on commit 305ee0a

Please sign in to comment.