Skip to content

Commit 8adfa60

Browse files
committed
chore: erc-4337 infrastructure setup
1 parent 8f30614 commit 8adfa60

File tree

105 files changed

+7792
-630
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+7792
-630
lines changed

.editorconfig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
root = true
22

33
[*]
4-
indent_size = 2
4+
indent_size = 4
55
indent_style = space
66
end_of_line = lf
77
charset = utf-8
@@ -12,4 +12,5 @@ quote_type = double
1212
[*.md]
1313
trim_trailing_whitespace = false
1414
max_line_length = 80
15-
indent_size = 2
15+
indent_size = 4
16+

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
[submodule "packages/contracts"]
22
path = packages/contracts
33
url = git@github.com:matter-labs/zksync-sso-clave-contracts.git
4+
[submodule "packages/erc4337-contracts"]
5+
path = packages/erc4337-contracts
6+
url = git@github.com:matter-labs/zksync-sso-contracts.git
47
[submodule "packages/circuits"]
58
path = packages/circuits
69
url = git@github.com:Moonsong-Labs/zksync-social-login-circuit.git

packages/erc4337-contracts

Submodule erc4337-contracts added at 507c2ae
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
root = true
2+
3+
[*]
4+
indent_size = 4
5+
indent_style = space
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.rs]
12+
indent_size = 4
13+
indent_style = space
14+
max_line_length = 100
15+
16+
[*.toml]
17+
indent_size = 4
18+
indent_style = space
19+
20+
[*.md]
21+
trim_trailing_whitespace = false
22+
max_line_length = 80
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
[workspace]
2+
members = ["crates/*"]
3+
resolver = "2"
4+
5+
[workspace.package]
6+
version = "0.0.1"
7+
edition = "2024"
8+
rust-version = "1.90"
9+
license = "Apache-2.0"
10+
repository = "https://github.com/matter-labs/zksync-sso"
11+
12+
[profile.release]
13+
opt-level = "s" # Optimize for size instead of speed
14+
lto = true # Link Time Optimization - removes dead code
15+
codegen-units = 1 # Single codegen unit for better optimization
16+
panic = "abort" # Smaller panic handling
17+
strip = true # Remove debug symbols
18+
19+
[workspace.dependencies]
20+
21+
# Alloy
22+
alloy = { version = "1.0", default-features = false, features = [
23+
"rlp",
24+
"serde",
25+
"rpc-types",
26+
"rpc-types-eth",
27+
"signer-local",
28+
"contract",
29+
"provider-http",
30+
"reqwest",
31+
"network",
32+
"wasm-bindgen",
33+
"sol-types",
34+
] }
35+
alloy-dyn-abi = { version = "1.0", features = ["std", "eip712"] }
36+
alloy-signer = { version = "1.0", features = ["eip712"] }
37+
alloy-provider = { version = "1.0", features = ["default", "erc4337-api"] }
38+
39+
# Serialization
40+
serde = { version = "1.0", features = ["derive"] }
41+
serde_json = "1.0"
42+
43+
# Async
44+
tokio = { version = "1", features = ["full"] }
45+
async-trait = "0.1"
46+
futures = "0.3"
47+
48+
# Error handling
49+
eyre = "0.6"
50+
thiserror = "2"
51+
52+
# Tracing/Logging
53+
tracing = "0.1"
54+
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
55+
log = "0.4"
56+
# Logging for Android
57+
android_logger = { version = "0.15" }
58+
# Logging for Apple platforms
59+
oslog = "0.2"
60+
61+
# Uniffi
62+
uniffi = { version = "0.29" }
63+
64+
# CLI dependencies
65+
clap = { version = "4.5", features = ["derive", "env"] }
66+
67+
# Web/WASM/JS dependencies
68+
wasm-bindgen = "0.2"
69+
wasm-bindgen-futures = "0.4"
70+
web-sys = "0.3"
71+
console_error_panic_hook = "0.1"
72+
serde-wasm-bindgen = "0.6"
73+
js-sys = "0.3"
74+
console_log = "1.0"
75+
76+
# HTTP
77+
reqwest = { version = "0.12", features = ["json"] }
78+
url = "2.5.4"
79+
80+
# Test utils
81+
wiremock = "0.6"
82+
tempfile = "3"
83+
strip-ansi-escapes = "0.2"
84+
libc = "0.2"
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# zkSync SSO ERC-4337
2+
3+
A Rust workspace for integrating zkSync SSO with ERC-4337 account abstraction.
4+
5+
## Workspace Structure
6+
7+
This workspace contains the following crates:
8+
9+
- **`zksync-sso-erc4337-core`**: Core functionality and business logic
10+
- **`zksync-sso-erc4337-web-ffi`**: WebAssembly FFI bindings for web applications
11+
- **`zksync-sso-erc4337-ffi`**: FFI bindings for mobile platforms (iOS/Android)
12+
- **`zksync-sso-erc4337-cli`**: Command-line interface
13+
14+
## Dependencies
15+
16+
- **Core**: All crates depend on the core crate for shared functionality
17+
- **Web FFI**: Provides WebAssembly bindings using `wasm-bindgen`
18+
- **FFI**: Provides mobile platform bindings using `uniffi`
19+
- **CLI**: Provides command-line interface using `clap`
20+
21+
## Building
22+
23+
To build the entire workspace:
24+
25+
```bash
26+
cargo build
27+
```
28+
29+
To build a specific crate:
30+
31+
```bash
32+
cargo build -p zksync-sso-erc4337-core
33+
cargo build -p zksync-sso-erc4337-web-ffi
34+
cargo build -p zksync-sso-erc4337-ffi
35+
cargo build -p zksync-sso-erc4337-cli
36+
```
37+
38+
## Testing
39+
40+
To run tests for all crates:
41+
42+
```bash
43+
cargo test
44+
```
45+
46+
To run tests for a specific crate:
47+
48+
```bash
49+
cargo test -p zksync-sso-erc4337-core
50+
```
51+
52+
## Usage
53+
54+
### CLI
55+
56+
```bash
57+
# Initialize the client
58+
cargo run -p zksync-sso-erc4337-cli -- init
59+
60+
# Show configuration
61+
cargo run -p zksync-sso-erc4337-cli -- config
62+
63+
# Test connection
64+
cargo run -p zksync-sso-erc4337-cli -- test
65+
```
66+
67+
### Core Library
68+
69+
```rust
70+
use zksync_sso_erc4337_core::{ZkSyncSsoErc4337Client, ZkSyncSsoErc4337Config};
71+
72+
let config = ZkSyncSsoErc4337Config::new(
73+
"https://sepolia.era.zksync.dev".to_string(),
74+
"https://bundler.example.com".to_string(),
75+
"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789".to_string(),
76+
"0x9406Cc6185a346906296840746125a0E44976454".to_string(),
77+
);
78+
79+
let client = ZkSyncSsoErc4337Client::new(config);
80+
client.initialize().await?;
81+
```
82+
83+
## License
84+
85+
Licensed under the Apache License, Version 2.0.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[package]
2+
name = "zksync-sso-erc4337-cli"
3+
version.workspace = true
4+
edition.workspace = true
5+
rust-version.workspace = true
6+
license.workspace = true
7+
repository.workspace = true
8+
description = "Command-line interface for zkSync SSO ERC-4337"
9+
10+
[[bin]]
11+
name = "zksync-sso-erc4337-cli"
12+
path = "src/main.rs"
13+
14+
[dependencies]
15+
# Core dependency
16+
zksync-sso-erc4337-core = { path = "../zksync-sso-erc4337-core" }
17+
18+
# CLI framework
19+
clap.workspace = true
20+
21+
# Serialization
22+
serde.workspace = true
23+
serde_json.workspace = true
24+
25+
# Error handling
26+
eyre.workspace = true
27+
thiserror.workspace = true
28+
29+
# Logging/Tracing
30+
tracing.workspace = true
31+
tracing-subscriber.workspace = true
32+
33+
# Async
34+
tokio.workspace = true
35+
async-trait.workspace = true
36+
futures.workspace = true
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
use clap::{Parser, Subcommand};
2+
use zksync_sso_erc4337_core::config::{
3+
Config as CoreConfig, contracts::Contracts as CoreContracts,
4+
};
5+
6+
#[derive(Parser)]
7+
#[command(name = "zksync-sso-erc4337")]
8+
#[command(about = "A command-line interface for zkSync SSO ERC-4337")]
9+
#[command(version)]
10+
struct Cli {
11+
#[command(subcommand)]
12+
command: Commands,
13+
14+
#[arg(short, long)]
15+
verbose: bool,
16+
}
17+
18+
#[derive(Subcommand)]
19+
enum Commands {
20+
Init {
21+
#[arg(long, default_value = "https://sepolia.era.zksync.dev")]
22+
rpc_url: String,
23+
24+
#[arg(long, default_value = "https://bundler.example.com")]
25+
bundler_url: String,
26+
27+
#[arg(
28+
long,
29+
default_value = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"
30+
)]
31+
entry_point_address: String,
32+
33+
#[arg(
34+
long,
35+
default_value = "0x9406Cc6185a346906296840746125a0E44976454"
36+
)]
37+
account_factory_address: String,
38+
},
39+
Config,
40+
Test,
41+
}
42+
43+
async fn handle_command(command: Commands) -> eyre::Result<()> {
44+
match command {
45+
Commands::Init {
46+
rpc_url,
47+
bundler_url,
48+
entry_point_address,
49+
account_factory_address,
50+
} => {
51+
let config = CoreConfig::new(
52+
rpc_url,
53+
bundler_url,
54+
CoreContracts::from_string(
55+
entry_point_address,
56+
account_factory_address,
57+
)?,
58+
);
59+
60+
println!("Configuration: {config:?}");
61+
}
62+
63+
Commands::Config => {
64+
println!("Current configuration:");
65+
println!(" RPC URL: https://sepolia.era.zksync.dev");
66+
println!(" Bundler URL: https://bundler.example.com");
67+
println!(
68+
" Entry Point: 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"
69+
);
70+
println!(
71+
" Account Factory: 0x9406Cc6185a346906296840746125a0E44976454"
72+
);
73+
}
74+
75+
Commands::Test => {
76+
let config = CoreConfig::new(
77+
"https://sepolia.era.zksync.dev".to_string(),
78+
"https://bundler.example.com".to_string(),
79+
CoreContracts::from_string(
80+
"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789".to_string(),
81+
"0x9406Cc6185a346906296840746125a0E44976454".to_string(),
82+
)?,
83+
);
84+
85+
println!("Configuration: {config:?}");
86+
}
87+
}
88+
89+
Ok(())
90+
}
91+
92+
pub async fn run_cli() -> eyre::Result<()> {
93+
let cli = Cli::parse();
94+
95+
let log_level =
96+
if cli.verbose { tracing::Level::DEBUG } else { tracing::Level::INFO };
97+
98+
tracing_subscriber::fmt().with_max_level(log_level).init();
99+
100+
handle_command(cli.command).await?;
101+
102+
Ok(())
103+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
use zksync_sso_erc4337_cli::run_cli;
2+
3+
#[tokio::main]
4+
async fn main() -> eyre::Result<()> {
5+
run_cli().await
6+
}

0 commit comments

Comments
 (0)