Skip to content

Commit a2d4507

Browse files
committed
fix: restructure admin commitment.
1 parent 2d11d09 commit a2d4507

File tree

7 files changed

+56
-1
lines changed

7 files changed

+56
-1
lines changed

Cargo.lock

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

protocol/mcr/cli/client/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ serde = { workspace = true, features = ["derive"] }
1414
clap = { workspace = true}
1515
dotenv = { workspace = true }
1616
anyhow = { workspace = true }
17+
mcr-protocol-client-core-util = { workspace = true }
18+
mcr-protocol-client-core-eth = { workspace = true }
19+
mcr-types = { workspace = true }
1720

1821
[lints]
1922
workspace = true
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
pub mod post_admin_commitment;
2+
3+
use clap::Subcommand;
4+
5+
#[derive(Subcommand)]
6+
#[clap(rename_all = "kebab-case")]
7+
pub enum Eth {
8+
PostAdminCommitment(post_admin_commitment::PostAdminCommitment),
9+
}
10+
11+
impl Eth {
12+
pub async fn execute(&self) -> Result<(), anyhow::Error> {
13+
match self {
14+
Eth::PostAdminCommitment(cmd) => cmd.execute().await?,
15+
}
16+
Ok(())
17+
}
18+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
use anyhow::Context;
2+
use clap::Parser;
3+
use mcr_protocol_client_core_eth::config::Config;
4+
use mcr_protocol_client_core_util::McrClientOperations;
5+
use mcr_types::block_commitment::BlockCommitment;
6+
use serde::{Deserialize, Serialize};
7+
8+
#[derive(Parser, Serialize, Deserialize, Debug, Clone)]
9+
pub struct PostAdminCommitment {
10+
#[clap(flatten)]
11+
pub config: Option<Config>,
12+
}
13+
14+
impl PostAdminCommitment {
15+
pub async fn execute(&self) -> Result<(), anyhow::Error> {
16+
let config = self.config.clone().context("no config provided")?;
17+
let client = config.build().await?;
18+
client.force_block_commitment(BlockCommitment::test()).await?;
19+
20+
Ok(())
21+
}
22+
}

protocol/mcr/cli/client/src/cli/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
pub mod eth;
12
use clap::{Parser, Subcommand};
23

34
/// The `mcr-protocol-client` CLI.
@@ -13,6 +14,8 @@ pub struct McrProtocolClient {
1314
#[clap(rename_all = "kebab-case")]
1415
pub enum McrProtocolClientSubcommand {
1516
Run,
17+
#[clap(subcommand)]
18+
Eth(eth::Eth),
1619
}
1720

1821
/// Implement the `From` trait for `McrProtocolClient` to convert it into a `McrProtocolClientSubcommand`.
@@ -38,6 +41,7 @@ impl McrProtocolClientSubcommand {
3841
McrProtocolClientSubcommand::Run => {
3942
println!("mcr-protocol-client is under development. Please check back later.");
4043
}
44+
McrProtocolClientSubcommand::Eth(eth) => eth.execute().await?,
4145
}
4246
Ok(())
4347
}

protocol/mcr/clients/eth/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ alloy-transport-ws = { workspace = true }
3131
anyhow = { workspace = true }
3232
async-stream = { workspace = true }
3333
async-trait = { workspace = true }
34+
clap = { workspace = true }
3435
serde_json = { workspace = true }
3536
thiserror = { workspace = true }
3637
tokio = { workspace = true }

protocol/mcr/clients/eth/src/config/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ use alloy_primitives::Address;
1717
use alloy_transport::BoxTransport;
1818
use alloy_transport_ws::WsConnect;
1919
use anyhow::Context;
20+
use clap::Parser;
2021
use secure_signer::cryptography::secp256k1::Secp256k1;
22+
use secure_signer::key::TryFromCanonicalString;
2123
use secure_signer_eth::Signer;
2224
use secure_signer_loader::{identifiers::SignerIdentifier, Load};
2325
use serde::{Deserialize, Serialize};
2426
use tracing::info;
2527

26-
#[derive(Debug, Serialize, Deserialize)]
28+
#[derive(Parser, Debug, Serialize, Deserialize, Clone)]
2729
pub struct Config {
2830
/// The address of the MCR settlement contract.
2931
pub mcr_contract_address: String,
@@ -34,6 +36,7 @@ pub struct Config {
3436
/// The Ethereum chain ID.
3537
pub chain_id: u64,
3638
/// The signer identifier.
39+
#[arg(value_parser = SignerIdentifier::try_from_canonical_string)]
3740
pub signer_identifier: SignerIdentifier,
3841
/// Whether to run in settlement admin mode.
3942
pub run_commitment_admin_mode: bool,

0 commit comments

Comments
 (0)