Skip to content

Commit f1b16aa

Browse files
committed
chore: add back shortcuts
1 parent df64390 commit f1b16aa

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 {
@@ -49,6 +54,7 @@ impl TryFrom<KnownChains> for SignetEnvironmentConstants {
4954

5055
fn try_from(chain: KnownChains) -> Result<Self, Self::Error> {
5156
match chain {
57+
KnownChains::Pecorino => Ok(Self::pecorino()),
5258
#[cfg(any(test, feature = "test-utils"))]
5359
KnownChains::Test => Ok(Self::test()),
5460
}

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 {
@@ -221,6 +226,7 @@ impl TryFrom<KnownChains> for SignetSystemConstants {
221226

222227
fn try_from(chain: KnownChains) -> Result<Self, Self::Error> {
223228
match chain {
229+
KnownChains::Pecorino => Ok(Self::pecorino()),
224230
#[cfg(any(test, feature = "test-utils"))]
225231
KnownChains::Test => Ok(Self::test()),
226232
}
@@ -253,6 +259,11 @@ impl SignetConstants {
253259
Self { system, environment }
254260
}
255261

262+
/// Get the hard-coded Pecorino rollup constants.
263+
pub const fn pecorino() -> Self {
264+
crate::chains::pecorino::PECORINO
265+
}
266+
256267
/// Get the hard-coded local test rollup constants.
257268
#[cfg(any(test, feature = "test-utils"))]
258269
pub const fn test() -> Self {
@@ -285,6 +296,7 @@ impl TryFrom<KnownChains> for SignetConstants {
285296

286297
fn try_from(chain: KnownChains) -> Result<Self, Self::Error> {
287298
match chain {
299+
KnownChains::Pecorino => Ok(Self::pecorino()),
288300
#[cfg(any(test, feature = "test-utils"))]
289301
KnownChains::Test => Ok(Self::test()),
290302
}

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 {
@@ -107,6 +112,7 @@ impl TryFrom<KnownChains> for RollupConstants {
107112

108113
fn try_from(chain: KnownChains) -> Result<Self, Self::Error> {
109114
match chain {
115+
KnownChains::Pecorino => Ok(Self::pecorino()),
110116
#[cfg(any(test, feature = "test-utils"))]
111117
KnownChains::Test => Ok(Self::test()),
112118
}

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())
@@ -411,6 +416,7 @@ impl TryFrom<KnownChains> for HostBlockSpec {
411416

412417
fn try_from(chain: KnownChains) -> Result<Self, Self::Error> {
413418
match chain {
419+
KnownChains::Pecorino => Ok(Self::pecorino()),
414420
KnownChains::Test => Ok(Self::test()),
415421
}
416422
}

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())
@@ -146,6 +151,7 @@ impl TryFrom<KnownChains> for RuBlockSpec {
146151

147152
fn try_from(chain: KnownChains) -> Result<Self, Self::Error> {
148153
match chain {
154+
KnownChains::Pecorino => Ok(Self::pecorino()),
149155
KnownChains::Test => Ok(Self::test()),
150156
}
151157
}

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)