Skip to content

Commit 5d367b4

Browse files
authored
Merge pull request #22 from movementlabsxyz/l-monninger/re-fix-12
Makes 12 more ergonomic
2 parents f5e154b + 83def51 commit 5d367b4

File tree

27 files changed

+2403
-636
lines changed

27 files changed

+2403
-636
lines changed

Cargo.lock

Lines changed: 1554 additions & 507 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ members = [
99
"protocol/mcr/clients/*",
1010
"protocol/mcr/manager",
1111
"protocol/mcr/cli/*",
12+
"protocol/mcr/dlu/eth/deployer-core",
1213

1314
# pcp
1415
## protocol
@@ -39,6 +40,7 @@ members = [
3940
# util
4041
"util/signing/eth",
4142
"util/environment",
43+
"util/commander",
4244
]
4345

4446
[workspace.package]
@@ -52,7 +54,7 @@ publish = false
5254
rust-version = "1.81.0"
5355

5456
[workspace.dependencies]
55-
alloy = { git = "https://github.com/alloy-rs/alloy.git", package = "alloy", rev = "83343b172585fe4e040fb104b4d1421f58cbf9a2", features = [
57+
alloy = { git = "https://github.com/alloy-rs/alloy.git", package = "alloy", rev = "bc190c61f1bee74271a29ea6275ab674fcfe73d5", features = [
5658
"node-bindings",
5759
"rpc-types-trace",
5860
"json-rpc",
@@ -63,22 +65,22 @@ alloy = { git = "https://github.com/alloy-rs/alloy.git", package = "alloy", rev
6365
"pubsub",
6466
"providers",
6567
] }
66-
alloy-rpc-types-eth = "0.1.3"
67-
alloy-eips = { git = "https://github.com/alloy-rs/alloy.git", rev = "83343b172585fe4e040fb104b4d1421f58cbf9a2" }
68-
alloy-contract = { git = "https://github.com/alloy-rs/alloy.git", rev = "83343b172585fe4e040fb104b4d1421f58cbf9a2" }
69-
alloy-network = { git = "https://github.com/alloy-rs/alloy.git", rev = "83343b172585fe4e040fb104b4d1421f58cbf9a2" }
70-
alloy-primitives = { version = "0.7.2", default-features = false }
71-
alloy-consensus = { git = "https://github.com/alloy-rs/alloy.git", rev = "83343b172585fe4e040fb104b4d1421f58cbf9a2" }
72-
alloy-provider = { git = "https://github.com/alloy-rs/alloy.git", rev = "83343b172585fe4e040fb104b4d1421f58cbf9a2", features = [
68+
alloy-rpc-types-eth = "0.12"
69+
alloy-eips = { git = "https://github.com/alloy-rs/alloy.git", rev = "bc190c61f1bee74271a29ea6275ab674fcfe73d5" }
70+
alloy-contract = { git = "https://github.com/alloy-rs/alloy.git", rev = "bc190c61f1bee74271a29ea6275ab674fcfe73d5" }
71+
alloy-network = { git = "https://github.com/alloy-rs/alloy.git", rev = "bc190c61f1bee74271a29ea6275ab674fcfe73d5" }
72+
alloy-primitives = { version = "0.8.22", default-features = false }
73+
alloy-consensus = { git = "https://github.com/alloy-rs/alloy.git", rev = "bc190c61f1bee74271a29ea6275ab674fcfe73d5" }
74+
alloy-provider = { git = "https://github.com/alloy-rs/alloy.git", rev = "bc190c61f1bee74271a29ea6275ab674fcfe73d5", features = [
7375
"ws",
7476
] }
75-
alloy-rlp = "0.3.5"
76-
alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy.git", rev = "83343b172585fe4e040fb104b4d1421f58cbf9a2" }
77-
alloy-sol-types = { version = "0.7.2", features = ["json"] }
78-
alloy-signer = { git = "https://github.com/alloy-rs/alloy.git", rev = "83343b172585fe4e040fb104b4d1421f58cbf9a2" }
79-
alloy-transport = { git = "https://github.com/alloy-rs/alloy.git", rev = "83343b172585fe4e040fb104b4d1421f58cbf9a2" }
80-
alloy-transport-http = { git = "https://github.com/alloy-rs/alloy.git", rev = "83343b172585fe4e040fb104b4d1421f58cbf9a2", features = ["reqwest-rustls-tls"] }
81-
alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy.git", rev = "83343b172585fe4e040fb104b4d1421f58cbf9a2" }
77+
alloy-rlp = "0.3.9"
78+
alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy.git", rev = "bc190c61f1bee74271a29ea6275ab674fcfe73d5" }
79+
alloy-sol-types = { version = "0.8.22", features = ["json"] }
80+
alloy-signer = { git = "https://github.com/alloy-rs/alloy.git", rev = "bc190c61f1bee74271a29ea6275ab674fcfe73d5" }
81+
alloy-transport = { git = "https://github.com/alloy-rs/alloy.git", rev = "bc190c61f1bee74271a29ea6275ab674fcfe73d5" }
82+
alloy-transport-http = { git = "https://github.com/alloy-rs/alloy.git", rev = "bc190c61f1bee74271a29ea6275ab674fcfe73d5", features = ["reqwest-rustls-tls"] }
83+
alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy.git", rev = "bc190c61f1bee74271a29ea6275ab674fcfe73d5" }
8284
anyhow = "1.0"
8385
async-stream = "0.3.0"
8486
async-trait = "0.1.71"
@@ -95,6 +97,14 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
9597
tracing-test = "0.2.5"
9698
tokio = { version = "1.35.1", features = ["full", "tracing"] }
9799
tokio-stream = "0.1.15"
100+
hex = { version = "0.4.3", default-features = false, features = [
101+
"alloc",
102+
"serde",
103+
] }
104+
zip = { version = "2.4.2", features = ["flate2"] }
105+
walkdir = "2.3.2"
106+
tempfile = "3.5.0"
107+
itertools = "0.14.0"
98108

99109
# model checking and verification
100110

@@ -114,6 +124,7 @@ mcr-protocol-client-core-eth = { path = "protocol/mcr/clients/eth" }
114124
mcr-protocol-client-core-mock = { path = "protocol/mcr/clients/mock" }
115125
mcr-protocol-client = { path = "protocol/mcr/cli/client" }
116126
mcr-protocol = { path = "protocol/mcr/cli"}
127+
mcr-protocol-deployer-core-eth = { path = "protocol/mcr/dlu/eth/deployer-core" }
117128
### network
118129
mcr-network-client = { path = "network/mcr/cli/client" }
119130
mcr-network-coordinator = { path = "network/mcr/cli/coordinator" }
@@ -122,6 +133,7 @@ mcr-network = { path = "network/mcr/cli/network" }
122133
# util
123134
secure-signer-eth = { path = "util/signing/eth" }
124135
ffs-environment = { path = "util/environment" }
136+
commander = { path = "util/commander" }
125137

126138
[workspace.lints.clippy]
127139
debug_assert_with_mut_call = "deny"

protocol/mcr/cli/client/src/cli/eth/post_admin_commitment.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use mcr_types::block_commitment::BlockCommitment;
66
use serde::{Deserialize, Serialize};
77

88
#[derive(Parser, Serialize, Deserialize, Debug, Clone)]
9+
#[clap(help_expected = true)]
910
pub struct PostAdminCommitment {
1011
#[clap(flatten)]
1112
pub config: Option<Config>,
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[package]
2+
name = "mcr-protocol-deployer"
3+
version = { workspace = true }
4+
edition = { workspace = true }
5+
license = { workspace = true }
6+
authors = { workspace = true }
7+
homepage = { workspace = true }
8+
publish = { workspace = true }
9+
rust-version = { workspace = true }
10+
11+
[dependencies]
12+
tokio = { workspace = true }
13+
serde = { workspace = true, features = ["derive"] }
14+
clap = { workspace = true}
15+
dotenv = { workspace = true }
16+
anyhow = { workspace = true }
17+
mcr-protocol-deployer-core-eth = { workspace = true }
18+
mcr-types = { workspace = true }
19+
20+
[lints]
21+
workspace = true
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
use anyhow::Context;
2+
use clap::Parser;
3+
use mcr_protocol_deployer_core_eth::dev::config::Config;
4+
use serde::{Deserialize, Serialize};
5+
6+
#[derive(Parser, Serialize, Deserialize, Debug, Clone)]
7+
#[clap(help_expected = true)]
8+
pub struct Deploy {
9+
#[clap(flatten)]
10+
pub config: Option<Config>,
11+
}
12+
13+
impl Deploy {
14+
pub async fn execute(&self) -> Result<(), anyhow::Error> {
15+
let config = self.config.clone().context("no config provided")?;
16+
let deployer = config.build()?;
17+
deployer.deploy().await?;
18+
Ok(())
19+
}
20+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
pub mod deploy;
2+
3+
use clap::Subcommand;
4+
5+
#[derive(Subcommand)]
6+
#[clap(rename_all = "kebab-case")]
7+
pub enum Eth {
8+
Deploy(deploy::Deploy),
9+
}
10+
11+
impl Eth {
12+
pub async fn execute(&self) -> Result<(), anyhow::Error> {
13+
match self {
14+
Eth::Deploy(cmd) => cmd.execute().await?,
15+
}
16+
Ok(())
17+
}
18+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
pub mod eth;
2+
use clap::{Parser, Subcommand};
3+
4+
/// The `mcr-protocol-client` CLI.
5+
#[derive(Parser)]
6+
#[clap(rename_all = "kebab-case")]
7+
pub struct McrProtocolDeployer {
8+
#[clap(subcommand)]
9+
command: Option<McrProtocolDeployerSubcommand>,
10+
}
11+
12+
/// The subcommands of the `mcr-protocol-client` CLI.
13+
#[derive(Subcommand)]
14+
#[clap(rename_all = "kebab-case")]
15+
pub enum McrProtocolDeployerSubcommand {
16+
Run,
17+
#[clap(subcommand)]
18+
Eth(eth::Eth),
19+
}
20+
21+
/// Implement the `From` trait for `McrProtocolDeployer` to convert it into a `McrProtocolDeployerSubcommand`.
22+
impl From<McrProtocolDeployer> for McrProtocolDeployerSubcommand {
23+
fn from(client: McrProtocolDeployer) -> Self {
24+
client.command.unwrap_or(McrProtocolDeployerSubcommand::Run)
25+
}
26+
}
27+
28+
/// Implement the `McrProtocolDeployer` CLI.
29+
impl McrProtocolDeployer {
30+
pub async fn execute(self) -> Result<(), anyhow::Error> {
31+
let subcommand: McrProtocolDeployerSubcommand = self.into();
32+
subcommand.execute().await
33+
}
34+
}
35+
36+
/// Implement the `McrProtocolDeployerSubcommand` CLI.
37+
/// This is where the actual logic of the CLI is implemented.
38+
impl McrProtocolDeployerSubcommand {
39+
pub async fn execute(&self) -> Result<(), anyhow::Error> {
40+
match self {
41+
McrProtocolDeployerSubcommand::Run => {
42+
println!("mcr-protocol-client is under development. Please check back later.");
43+
}
44+
McrProtocolDeployerSubcommand::Eth(eth) => eth.execute().await?,
45+
}
46+
Ok(())
47+
}
48+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod cli;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
use clap::*;
2+
use dotenv::dotenv;
3+
use mcr_protocol_deployer::cli;
4+
5+
#[tokio::main]
6+
async fn main() -> Result<(), anyhow::Error> {
7+
// Load environment variables from .env file.
8+
dotenv().ok();
9+
10+
// Run the CLI.
11+
let mcr_protocol_deployer = cli::McrProtocolDeployer::parse();
12+
mcr_protocol_deployer.execute().await?;
13+
Ok(())
14+
}

protocol/mcr/clients/eth/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ tokio = { workspace = true }
3838
tokio-stream = { workspace = true }
3939
tracing = { workspace = true }
4040
serde = { workspace = true }
41+
hex = { workspace = true }
4142

4243
alloy-rpc-types = { workspace = true }
4344
futures = { workspace = true }

0 commit comments

Comments
 (0)