Skip to content

Commit 0985371

Browse files
committed
change cli parse type
1 parent 50d9a75 commit 0985371

File tree

5 files changed

+34
-40
lines changed

5 files changed

+34
-40
lines changed

tests/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ edition.workspace = true
66
rust-version.workspace = true
77

88
[dependencies]
9+
alloy-eips = { workspace = true }
910
alloy-primitives = { workspace = true }
1011
async-trait = { workspace = true }
1112
bytes = { workspace = true }

tests/src/tests/timeboost.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ mod transaction_order;
66
use std::net::Ipv4Addr;
77
use std::num::NonZeroUsize;
88

9+
use alloy_eips::BlockNumberOrTag;
910
use cliquenet::{Address, AddressableCommittee};
1011
use multisig::Keypair;
1112
use multisig::{Committee, x25519};
@@ -96,19 +97,16 @@ where
9697
.decrypt_committee(decrypt_committee.clone())
9798
.recover(recover_index.map(|r| r == i).unwrap_or(false))
9899
.leash_len(100)
99-
.chain_config(
100-
ChainConfig::new(
101-
1,
102-
"https://theserversroom.com/ethereum/54cmzzhcj1o/"
103-
.parse::<Url>()
104-
.expect("valid url"),
105-
"0x4dbd4fc535ac27206064b68ffcf827b0a60bab3f"
106-
.parse::<alloy_primitives::Address>()
107-
.expect("valid contract"),
108-
"finalized",
109-
)
110-
.expect("valid block tag"),
111-
)
100+
.chain_config(ChainConfig::new(
101+
1,
102+
"https://theserversroom.com/ethereum/54cmzzhcj1o/"
103+
.parse::<Url>()
104+
.expect("valid url"),
105+
"0x4dbd4fc535ac27206064b68ffcf827b0a60bab3f"
106+
.parse::<alloy_primitives::Address>()
107+
.expect("valid contract"),
108+
BlockNumberOrTag::Finalized,
109+
))
112110
.build();
113111
let pcf = CertifierConfig::builder()
114112
.sign_keypair(kpair)

tests/src/tests/timeboost/handover.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::net::Ipv4Addr;
44
use std::num::NonZeroUsize;
55
use std::time::Duration;
66

7+
use alloy_eips::BlockNumberOrTag;
78
use cliquenet::{Address, AddressableCommittee, Network, NetworkMetrics, Overlay};
89
use futures::FutureExt;
910
use futures::stream::{self, StreamExt};
@@ -138,19 +139,16 @@ where
138139
)
139140
.recover(false)
140141
.leash_len(100)
141-
.chain_config(
142-
ChainConfig::new(
143-
1,
144-
"https://theserversroom.com/ethereum/54cmzzhcj1o/"
145-
.parse::<Url>()
146-
.expect("valid url"),
147-
"0x4dbd4fc535ac27206064b68ffcf827b0a60bab3f"
148-
.parse::<alloy_primitives::Address>()
149-
.expect("valid contract"),
150-
"finalized",
151-
)
152-
.expect("valid block tag"),
153-
)
142+
.chain_config(ChainConfig::new(
143+
1,
144+
"https://theserversroom.com/ethereum/54cmzzhcj1o/"
145+
.parse::<Url>()
146+
.expect("valid url"),
147+
"0x4dbd4fc535ac27206064b68ffcf827b0a60bab3f"
148+
.parse::<alloy_primitives::Address>()
149+
.expect("valid contract"),
150+
BlockNumberOrTag::Finalized,
151+
))
154152
.build()
155153
})
156154
}

timeboost-types/src/chain_config.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
use std::str::FromStr;
2-
3-
use alloy_eips::{BlockNumberOrTag, eip1898::ParseBlockNumberError};
1+
use alloy_eips::BlockNumberOrTag;
42
use alloy_primitives::Address;
53
use serde::{Deserialize, Serialize};
64
use url::Url;
@@ -18,15 +16,14 @@ impl ChainConfig {
1816
chain_id: u64,
1917
rpc_url: Url,
2018
ibox_addr: Address,
21-
parent_block_tag: &str,
22-
) -> Result<Self, ParseBlockNumberError> {
23-
let tag = BlockNumberOrTag::from_str(parent_block_tag)?;
24-
Ok(Self {
19+
parent_block_tag: BlockNumberOrTag,
20+
) -> Self {
21+
Self {
2522
parent_chain_id: chain_id,
2623
parent_chain_rpc_url: rpc_url.to_string(),
2724
parent_ibox_contr_addr: ibox_addr,
28-
parent_block_tag: tag,
29-
})
25+
parent_block_tag,
26+
}
3027
}
3128
pub fn parent_chain_id(&self) -> u64 {
3229
self.parent_chain_id

timeboost/src/binaries/mkconfig.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::net::IpAddr;
22
use std::num::NonZeroU8;
33
use std::{io, iter};
44

5+
use alloy_eips::BlockNumberOrTag;
56
use anyhow::{Result, bail};
67
use ark_std::rand::SeedableRng as _;
78
use clap::{Parser, ValueEnum};
@@ -60,9 +61,9 @@ struct Args {
6061
#[clap(long)]
6162
parent_ibox_contr_addr: alloy_primitives::Address,
6263

63-
/// Parent chain inbox contract adddress
64+
/// Parent chain inbox block tag
6465
#[clap(long, default_value = "finalized")]
65-
parent_block_tag: String,
66+
parent_block_tag: BlockNumberOrTag,
6667
}
6768

6869
/// How should addresses be updated?
@@ -147,9 +148,8 @@ impl Args {
147148
self.parent_chain_id,
148149
self.parent_rpc_url.clone(),
149150
self.parent_ibox_contr_addr,
150-
&self.parent_block_tag,
151-
)
152-
.expect("valid block tag"),
151+
self.parent_block_tag,
152+
),
153153
})
154154
.collect();
155155
Ok(KeysetConfig {

0 commit comments

Comments
 (0)