Skip to content

Commit 77748cb

Browse files
committed
chore: add back shortcuts
1 parent 45d2d0c commit 77748cb

File tree

9 files changed

+60
-0
lines changed

9 files changed

+60
-0
lines changed

crates/constants/src/types/chains.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ pub enum ParseChainError {
1414
/// Known chains for the Signet system.
1515
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
1616
pub enum KnownChains {
17+
/// Pecorino chain.
18+
Pecorino,
1719
/// Test chain.
1820
#[cfg(any(test, feature = "test-utils"))]
1921
Test,
@@ -27,6 +29,7 @@ impl FromStr for KnownChains {
2729
match s.as_str() {
2830
#[cfg(any(test, feature = "test-utils"))]
2931
"test" => Ok(Self::Test),
32+
"pecorino" => Ok(Self::Pecorino),
3033
_ => Err(ParseChainError::ChainNotSupported(s)),
3134
}
3235
}

crates/constants/src/types/environment.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ impl SignetEnvironmentConstants {
2222
Self { host_name, rollup_name, transaction_cache }
2323
}
2424

25+
/// Get the hard-coded Pecorino environment constants.
26+
pub const fn pecorino() -> Self {
27+
crate::chains::pecorino::PECORINO_ENV
28+
}
29+
2530
/// Get the hard-coded local test rollup constants.
2631
#[cfg(any(test, feature = "test-utils"))]
2732
pub const fn test() -> Self {
@@ -50,6 +55,7 @@ impl FromStr for SignetEnvironmentConstants {
5055
fn from_str(s: &str) -> Result<Self, Self::Err> {
5156
let chain: KnownChains = s.parse()?;
5257
match chain {
58+
KnownChains::Pecorino => Ok(Self::pecorino()),
5359
#[cfg(any(test, feature = "test-utils"))]
5460
KnownChains::Test => Ok(Self::test()),
5561
}

crates/constants/src/types/host.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ impl HostConstants {
5656
Self { chain_id, deploy_height, zenith, orders, passage, transactor, tokens }
5757
}
5858

59+
/// Get the hard-coded Pecorino host constants.
60+
pub const fn pecorino() -> Self {
61+
crate::chains::pecorino::HOST
62+
}
63+
5964
/// Get the hard-coded local test host constants.
6065
#[cfg(any(test, feature = "test-utils"))]
6166
pub const fn test() -> Self {
@@ -142,6 +147,7 @@ impl FromStr for HostConstants {
142147
fn from_str(s: &str) -> Result<Self, Self::Err> {
143148
let chain: KnownChains = s.parse()?;
144149
match chain {
150+
KnownChains::Pecorino => Ok(Self::pecorino()),
145151
#[cfg(any(test, feature = "test-utils"))]
146152
KnownChains::Test => Ok(Self::test()),
147153
}

crates/constants/src/types/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ impl SignetSystemConstants {
4747
Self { host, rollup }
4848
}
4949

50+
/// Get the hard-coded Pecorino constants.
51+
pub const fn pecorino() -> Self {
52+
crate::chains::pecorino::PECORINO_SYS
53+
}
54+
5055
/// Get the hard-coded local test constants.
5156
#[cfg(any(test, feature = "test-utils"))]
5257
pub const fn test() -> Self {
@@ -222,6 +227,7 @@ impl FromStr for SignetSystemConstants {
222227
fn from_str(s: &str) -> Result<Self, Self::Err> {
223228
let chain: KnownChains = s.parse()?;
224229
match chain {
230+
KnownChains::Pecorino => Ok(Self::pecorino()),
225231
#[cfg(any(test, feature = "test-utils"))]
226232
KnownChains::Test => Ok(Self::test()),
227233
}
@@ -246,6 +252,11 @@ impl SignetConstants {
246252
Self { system, environment }
247253
}
248254

255+
/// Get the hard-coded Pecorino rollup constants.
256+
pub const fn pecorino() -> Self {
257+
crate::chains::pecorino::PECORINO
258+
}
259+
249260
/// Get the hard-coded local test rollup constants.
250261
#[cfg(any(test, feature = "test-utils"))]
251262
pub const fn test() -> Self {
@@ -279,6 +290,7 @@ impl FromStr for SignetConstants {
279290
fn from_str(s: &str) -> Result<Self, Self::Err> {
280291
let chain: KnownChains = s.parse()?;
281292
match chain {
293+
KnownChains::Pecorino => Ok(Self::pecorino()),
282294
#[cfg(any(test, feature = "test-utils"))]
283295
KnownChains::Test => Ok(Self::test()),
284296
}

crates/constants/src/types/rollup.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ impl RollupConstants {
4343
Self { chain_id, orders, passage, base_fee_recipient, tokens }
4444
}
4545

46+
/// Get the hard-coded Pecorino rollup constants.
47+
pub const fn pecorino() -> Self {
48+
crate::chains::pecorino::ROLLUP
49+
}
50+
4651
/// Get the hard-coded local test rollup constants.
4752
#[cfg(any(test, feature = "test-utils"))]
4853
pub const fn test() -> Self {
@@ -108,6 +113,7 @@ impl FromStr for RollupConstants {
108113
fn from_str(s: &str) -> Result<Self, Self::Err> {
109114
let chain: KnownChains = s.parse()?;
110115
match chain {
116+
KnownChains::Pecorino => Ok(Self::pecorino()),
111117
#[cfg(any(test, feature = "test-utils"))]
112118
KnownChains::Test => Ok(Self::test()),
113119
}

crates/test-utils/src/specs/host_spec.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ impl HostBlockSpec {
9090
}
9191
}
9292

93+
/// Make a new block spec with Pecorino constants.
94+
pub const fn pecorino() -> Self {
95+
Self::new(SignetSystemConstants::pecorino())
96+
}
97+
9398
/// Make a new block spec with test constants.
9499
pub const fn test() -> Self {
95100
Self::new(SignetSystemConstants::test())
@@ -412,6 +417,7 @@ impl FromStr for HostBlockSpec {
412417
fn from_str(s: &str) -> Result<Self, Self::Err> {
413418
let chain: KnownChains = s.parse()?;
414419
match chain {
420+
KnownChains::Pecorino => Ok(Self::pecorino()),
415421
KnownChains::Test => Ok(Self::test()),
416422
}
417423
}

crates/test-utils/src/specs/ru_spec.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ impl RuBlockSpec {
4343
Self { constants, tx: vec![], gas_limit: None, reward_address: None }
4444
}
4545

46+
/// Create a new empty RU block spec with the Pecorino constants.
47+
pub const fn pecorino() -> Self {
48+
Self::new(SignetSystemConstants::pecorino())
49+
}
50+
4651
/// Create a new empty RU block spec with the test constants.
4752
pub const fn test() -> Self {
4853
Self::new(SignetSystemConstants::test())
@@ -147,6 +152,7 @@ impl FromStr for RuBlockSpec {
147152
fn from_str(s: &str) -> Result<Self, Self::Err> {
148153
let chain: KnownChains = s.parse()?;
149154
match chain {
155+
KnownChains::Pecorino => Ok(Self::pecorino()),
150156
KnownChains::Test => Ok(Self::test()),
151157
}
152158
}

crates/tx-cache/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ repository.workspace = true
1212

1313
[dependencies]
1414
signet-bundle.workspace = true
15+
signet-constants.workspace = true
1516
signet-types.workspace = true
1617

1718
alloy.workspace = true

crates/tx-cache/src/client.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use alloy::consensus::TxEnvelope;
66
use eyre::Error;
77
use serde::{de::DeserializeOwned, Serialize};
88
use signet_bundle::SignetEthBundle;
9+
use signet_constants::pecorino;
910
use signet_types::SignedOrder;
1011
use tracing::{instrument, warn};
1112

@@ -41,6 +42,19 @@ impl TxCache {
4142
Ok(Self::new(url))
4243
}
4344

45+
/// Connect to the transaction cache with the Pecorino URL.
46+
pub fn pecorino() -> Self {
47+
Self::new_from_string(pecorino::TX_CACHE_URL).expect("pecorino tx cache URL is invalid")
48+
}
49+
50+
/// Connect to the transaction cache with the Pecorino URL and a specific [`reqwest::Client`].
51+
pub fn pecorino_with_client(client: reqwest::Client) -> Self {
52+
Self::new_with_client(
53+
pecorino::TX_CACHE_URL.parse().expect("pecorino tx cache URL is invalid"),
54+
client,
55+
)
56+
}
57+
4458
/// Get the client used to send requests
4559
pub const fn client(&self) -> &reqwest::Client {
4660
&self.client

0 commit comments

Comments
 (0)