Skip to content

Commit 3d58117

Browse files
committed
Revive provider methods on ParentChain.
1 parent 8f27fac commit 3d58117

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

Cargo.lock

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

timeboost-config/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ secp256k1 = { workspace = true }
1818
serde = { workspace = true }
1919
thiserror = { workspace = true }
2020
timeboost-crypto = { path = "../timeboost-crypto" }
21+
timeboost-types = { path = "../timeboost-types" }
2122
tokio = { workspace = true }
2223
toml = { workspace = true }
2324
tracing = { workspace = true }

timeboost-config/src/chain.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
use alloy::eips::BlockNumberOrTag;
21
use alloy::primitives::Address;
2+
use alloy::providers::ProviderBuilder;
3+
use alloy::{eips::BlockNumberOrTag, network::EthereumWallet};
34
use bon::Builder;
45
use serde::{Deserialize, Serialize};
6+
use timeboost_types::{HttpProvider, HttpProviderWithWallet};
57
use url::Url;
68

79
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Builder)]
@@ -18,3 +20,15 @@ pub struct ParentChain {
1820
pub block_tag: BlockNumberOrTag,
1921
pub key_manager_contract: Address,
2022
}
23+
24+
impl ParentChain {
25+
pub fn provider(&self) -> HttpProvider {
26+
ProviderBuilder::new().connect_http(self.rpc_url.clone())
27+
}
28+
29+
pub fn provider_with_wallet(&self, wallet: EthereumWallet) -> HttpProviderWithWallet {
30+
ProviderBuilder::new()
31+
.wallet(wallet)
32+
.connect_http(self.rpc_url.clone())
33+
}
34+
}

timeboost/src/binaries/sailfish.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::{iter::repeat_with, path::PathBuf, sync::Arc, time::Duration};
22

33
use ::metrics::prometheus::PrometheusMetrics;
4-
use alloy::providers::{Provider, ProviderBuilder};
4+
use alloy::providers::Provider;
55
use anyhow::{Context, Result};
66
use cliquenet::{Network, NetworkMetrics, Overlay};
77
use committable::{Commitment, Committable, RawCommitmentBuilder};
@@ -91,7 +91,7 @@ async fn main() -> Result<()> {
9191
let dh_keypair = x25519::Keypair::from(config.keys.dh.secret.clone());
9292

9393
// syncing with contract to get peers keys and network addresses
94-
let provider = ProviderBuilder::new().connect_http(config.chain.parent.rpc_url);
94+
let provider = config.chain.parent.provider();
9595
assert_eq!(
9696
provider.get_chain_id().await?,
9797
config.chain.parent.id,

timeboost/src/binaries/timeboost.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::path::PathBuf;
22

3-
use alloy::providers::{Provider, ProviderBuilder};
3+
use alloy::providers::Provider;
44
use anyhow::{Context, Result, bail};
55
use cliquenet::AddressableCommittee;
66
use multisig::CommitteeId;
@@ -108,7 +108,7 @@ async fn main() -> Result<()> {
108108
let dh_keypair = x25519::Keypair::from(node_config.keys.dh.secret.clone());
109109

110110
// syncing with contract to get peers keys and network addresses
111-
let provider = ProviderBuilder::new().connect_http(node_config.chain.parent.rpc_url.clone());
111+
let provider = node_config.chain.parent.provider();
112112
assert_eq!(
113113
provider.get_chain_id().await?,
114114
node_config.chain.parent.id,

0 commit comments

Comments
 (0)