Skip to content

Commit 47790e3

Browse files
committed
feat: adds mainnet chain to constants
1 parent a72b2a7 commit 47790e3

File tree

10 files changed

+147
-5
lines changed

10 files changed

+147
-5
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
//! Constants for the Mainnet.
2+
3+
use crate::{
4+
HostConstants, HostTokens, HostUsdRecord, RollupConstants, RollupTokens, SignetConstants,
5+
SignetEnvironmentConstants, SignetSystemConstants, UsdRecords,
6+
};
7+
use alloy::primitives::{address, Address};
8+
use std::borrow::Cow;
9+
10+
/// Name for the host chain.
11+
pub const HOST_NAME: &str = "Mainnet";
12+
/// Chain ID for the Mainnet host chain.
13+
pub const HOST_CHAIN_ID: u64 = 1;
14+
/// Deployment height of the rollup on Mainnet host chain.
15+
pub const DEPLOY_HEIGHT: u64 = 23734244;
16+
/// `Zenith` contract address for the Mainnet host chain.
17+
pub const HOST_ZENITH: Address = address!("0x0000000000000000000000000000000000000000"); // TODO
18+
/// `Orders` contract address for the Mainnet host chain.
19+
pub const HOST_ORDERS: Address = address!("0x0000000000000000000000000000000000000000"); // TODO
20+
/// `Passage` contract address for the Mainnet host chain.
21+
pub const HOST_PASSAGE: Address = address!("0x0000000000000000000000000000000000000000"); // TODO
22+
/// `Transactor` contract address for the Mainnet host chain.
23+
pub const HOST_TRANSACTOR: Address = address!("0x0000000000000000000000000000000000000000"); // TODO
24+
25+
/// USDC token for the Mainnet host chain (empty placeholder).
26+
pub const HOST_USDC: Address = address!("0x0000000000000000000000000000000000000000"); // TODO
27+
/// USDT token for the Mainnet host chain (empty placeholder).
28+
pub const HOST_USDT: Address = address!("0x0000000000000000000000000000000000000000"); // TODO
29+
/// WBTC token for the Mainnet host chain (empty placeholder).
30+
pub const HOST_WBTC: Address = address!("0x0000000000000000000000000000000000000000"); // TODO
31+
/// WETH token for the Mainnet host chain (empty placeholder).
32+
pub const HOST_WETH: Address = address!("0x0000000000000000000000000000000000000000"); // TODO
33+
34+
/// USDC token record for the Mainnet host chain (placeholder name/decimals).
35+
pub const HOST_USDC_RECORD: HostUsdRecord = HostUsdRecord::new(HOST_USDC, Cow::Borrowed("USDC"), 6);
36+
/// USDT token record for the Mainnet host chain (placeholder name/decimals).
37+
pub const HOST_USDT_RECORD: HostUsdRecord = HostUsdRecord::new(HOST_USDT, Cow::Borrowed("USDT"), 6);
38+
/// Host USD records for the Mainnet host chain (empty list by default).
39+
pub const HOST_USD_RECORDS: UsdRecords = {
40+
let records = UsdRecords::new();
41+
records
42+
};
43+
/// Host system tokens for Mainnet (placeholders).
44+
pub const HOST_TOKENS: HostTokens = HostTokens::new(HOST_USD_RECORDS, HOST_WBTC, HOST_WETH);
45+
46+
/// Host system constants for Mainnet.
47+
pub const HOST: HostConstants = crate::HostConstants::new(
48+
HOST_CHAIN_ID,
49+
DEPLOY_HEIGHT,
50+
HOST_ZENITH,
51+
HOST_ORDERS,
52+
HOST_PASSAGE,
53+
HOST_TRANSACTOR,
54+
HOST_TOKENS,
55+
);
56+
57+
/// Name for the network.
58+
pub const RU_NAME: &str = "Signet";
59+
/// Chain ID for the Mainnet RU chain.
60+
pub const RU_CHAIN_ID: u64 = 519;
61+
62+
/// WETH token for the Mainnet RU chain (placeholder).
63+
pub const RU_WETH: Address = address!("0x0000000000000000000000000000000000000000"); // TODO
64+
/// WBTC token for the Mainnet RU chain (placeholder).
65+
pub const RU_WBTC: Address = address!("0x0000000000000000000000000000000000000000"); // TODO
66+
/// `Orders` contract address for the Mainnet RU chain (placeholder).
67+
pub const RU_ORDERS: Address = address!("0x0000000000000000000000000000000000000000"); // TODO
68+
/// `Passage` contract address for the Mainnet RU chain (placeholder).
69+
pub const RU_PASSAGE: Address = address!("0x0000000000000000000000000000000000000000"); // TODO
70+
/// The WETH9-based wrapped native USD token contract (placeholder).
71+
pub const WRAPPED: Address = address!("0x0000000000000000000000000000000000000000"); // TODO
72+
/// RU pre-approved system tokens for Mainnet (placeholders).
73+
pub const RU_TOKENS: RollupTokens = RollupTokens::new(RU_WBTC, RU_WETH);
74+
75+
/// Base fee recipient address for the Mainnet RU chain (placeholder).
76+
pub const BASE_FEE_RECIPIENT: Address = address!("0x0000000000000000000000000000000000000000"); // TODO
77+
78+
/// RU system constants for Mainnet.
79+
pub const ROLLUP: RollupConstants =
80+
crate::RollupConstants::new(RU_CHAIN_ID, RU_ORDERS, RU_PASSAGE, BASE_FEE_RECIPIENT, RU_TOKENS);
81+
82+
/// Signet system constants for Mainnet.
83+
pub const MAINNET_SYS: SignetSystemConstants = crate::SignetSystemConstants::new(HOST, ROLLUP);
84+
85+
/// Signet environment constants for Mainnet.
86+
pub const MAINNET_ENV: SignetEnvironmentConstants = SignetEnvironmentConstants::new(
87+
Cow::Borrowed(HOST_NAME),
88+
Cow::Borrowed(RU_NAME),
89+
Cow::Borrowed(TX_CACHE_URL),
90+
);
91+
92+
/// Signet constants for Mainnet.
93+
pub const MAINNET: SignetConstants = SignetConstants::new(MAINNET_SYS, MAINNET_ENV);
94+
95+
/// The URL of the Transaction Cache endpoint (empty for mainnet placeholder).
96+
pub const TX_CACHE_URL: &str = "TODO";

crates/constants/src/chains/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
pub mod test_utils;
1+
pub mod mainnet;
22

33
pub mod pecorino;
4+
5+
pub mod test_utils;

crates/constants/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
#![cfg_attr(docsrs, feature(doc_cfg))]
1818

1919
mod chains;
20-
pub use chains::test_utils;
21-
20+
pub use chains::mainnet;
2221
pub use chains::pecorino;
22+
pub use chains::test_utils;
2323

2424
mod types;
2525
pub use types::{

crates/constants/src/types/chains.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::str::FromStr;
22

33
/// The list of known chains as a string.
4-
const KNOWN_CHAINS: &str = "pecorino, test";
4+
const KNOWN_CHAINS: &str = "mainnet, pecorino, test";
55

66
/// Error type for parsing struct from a chain name.
77
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
@@ -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+
/// Mainnet chain.
18+
Mainnet,
1719
/// Pecorino chain.
1820
Pecorino,
1921
/// Test chain.
@@ -26,8 +28,9 @@ impl FromStr for KnownChains {
2628
fn from_str(s: &str) -> Result<Self, Self::Err> {
2729
let s = s.trim().to_lowercase();
2830
match s.as_str() {
29-
"test" => Ok(Self::Test),
31+
"mainnet" => Ok(Self::Mainnet),
3032
"pecorino" => Ok(Self::Pecorino),
33+
"test" => Ok(Self::Test),
3134
_ => Err(ParseChainError::ChainNotSupported(s)),
3235
}
3336
}

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 Mainnet environment constants.
26+
pub const fn mainnet() -> Self {
27+
crate::chains::mainnet::MAINNET_ENV
28+
}
29+
2530
/// Get the hard-coded Pecorino environment constants.
2631
pub const fn pecorino() -> Self {
2732
crate::chains::pecorino::PECORINO_ENV
@@ -53,6 +58,7 @@ impl TryFrom<KnownChains> for SignetEnvironmentConstants {
5358

5459
fn try_from(chain: KnownChains) -> Result<Self, Self::Error> {
5560
match chain {
61+
KnownChains::Mainnet => Ok(Self::mainnet()),
5662
KnownChains::Pecorino => Ok(Self::pecorino()),
5763
KnownChains::Test => Ok(Self::test()),
5864
}

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 Mainnet host constants.
60+
pub const fn mainnet() -> Self {
61+
crate::chains::mainnet::HOST
62+
}
63+
5964
/// Get the hard-coded Pecorino host constants.
6065
pub const fn pecorino() -> Self {
6166
crate::chains::pecorino::HOST
@@ -146,6 +151,7 @@ impl FromStr for HostConstants {
146151
fn from_str(s: &str) -> Result<Self, Self::Err> {
147152
let chain: KnownChains = s.parse()?;
148153
match chain {
154+
KnownChains::Mainnet => Ok(Self::mainnet()),
149155
KnownChains::Pecorino => Ok(Self::pecorino()),
150156
KnownChains::Test => Ok(Self::test()),
151157
}

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 Mainnet constants.
51+
pub const fn mainnet() -> Self {
52+
crate::chains::mainnet::MAINNET_SYS
53+
}
54+
5055
/// Get the hard-coded Pecorino constants.
5156
pub const fn pecorino() -> Self {
5257
crate::chains::pecorino::PECORINO_SYS
@@ -225,6 +230,7 @@ impl TryFrom<KnownChains> for SignetSystemConstants {
225230

226231
fn try_from(chain: KnownChains) -> Result<Self, Self::Error> {
227232
match chain {
233+
KnownChains::Mainnet => Ok(Self::mainnet()),
228234
KnownChains::Pecorino => Ok(Self::pecorino()),
229235
KnownChains::Test => Ok(Self::test()),
230236
}
@@ -257,6 +263,11 @@ impl SignetConstants {
257263
Self { system, environment }
258264
}
259265

266+
/// Get the hard-coded Mainnet rollup constants.
267+
pub const fn mainnet() -> Self {
268+
crate::chains::mainnet::MAINNET
269+
}
270+
260271
/// Get the hard-coded Pecorino rollup constants.
261272
pub const fn pecorino() -> Self {
262273
crate::chains::pecorino::PECORINO
@@ -293,6 +304,7 @@ impl TryFrom<KnownChains> for SignetConstants {
293304

294305
fn try_from(chain: KnownChains) -> Result<Self, Self::Error> {
295306
match chain {
307+
KnownChains::Mainnet => Ok(Self::mainnet()),
296308
KnownChains::Pecorino => Ok(Self::pecorino()),
297309
KnownChains::Test => Ok(Self::test()),
298310
}

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 Mainnet rollup constants.
47+
pub const fn mainnet() -> Self {
48+
crate::chains::mainnet::ROLLUP
49+
}
50+
4651
/// Get the hard-coded Pecorino rollup constants.
4752
pub const fn pecorino() -> Self {
4853
crate::chains::pecorino::ROLLUP
@@ -111,6 +116,7 @@ impl TryFrom<KnownChains> for RollupConstants {
111116

112117
fn try_from(chain: KnownChains) -> Result<Self, Self::Error> {
113118
match chain {
119+
KnownChains::Mainnet => Ok(Self::mainnet()),
114120
KnownChains::Pecorino => Ok(Self::pecorino()),
115121
KnownChains::Test => Ok(Self::test()),
116122
}

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

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

93+
pub const fn mainnet() -> Self {
94+
Self::new(SignetSystemConstants::mainnet())
95+
}
96+
9397
/// Make a new block spec with Pecorino constants.
9498
pub const fn pecorino() -> Self {
9599
Self::new(SignetSystemConstants::pecorino())
@@ -416,6 +420,7 @@ impl TryFrom<KnownChains> for HostBlockSpec {
416420

417421
fn try_from(chain: KnownChains) -> Result<Self, Self::Error> {
418422
match chain {
423+
KnownChains::Mainnet => Ok(Self::mainnet()),
419424
KnownChains::Pecorino => Ok(Self::pecorino()),
420425
KnownChains::Test => Ok(Self::test()),
421426
}

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

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

43+
/// Create a new empty RU block spec with the Mainnet constants.
44+
pub const fn mainnet() -> Self {
45+
Self::new(SignetSystemConstants::mainnet())
46+
}
47+
4348
/// Create a new empty RU block spec with the Pecorino constants.
4449
pub const fn pecorino() -> Self {
4550
Self::new(SignetSystemConstants::pecorino())
@@ -148,6 +153,7 @@ impl TryFrom<KnownChains> for RuBlockSpec {
148153

149154
fn try_from(chain: KnownChains) -> Result<Self, Self::Error> {
150155
match chain {
156+
KnownChains::Mainnet => Ok(Self::mainnet()),
151157
KnownChains::Pecorino => Ok(Self::pecorino()),
152158
KnownChains::Test => Ok(Self::test()),
153159
}

0 commit comments

Comments
 (0)