1- use crate :: types:: { ConfigError , KnownChains , ParseChainError , PredeployTokens } ;
1+ use crate :: {
2+ types:: { ConfigError , HostTokens , KnownChains , ParseChainError } ,
3+ HostUsdRecord ,
4+ } ;
25use alloy:: { genesis:: Genesis , primitives:: Address } ;
36use serde_json:: Value ;
47use std:: str:: FromStr ;
@@ -8,7 +11,7 @@ use std::str::FromStr;
811/// These are system constants which may vary between chains, and are used to
912/// determine the behavior of the chain, such as which contracts the Signet
1013/// node should listen to, and the addresses of system-priveleged tokens.
11- #[ derive( Debug , Clone , Copy , PartialEq , Eq , serde:: Deserialize , serde:: Serialize ) ]
14+ #[ derive( Debug , Clone , PartialEq , Eq , serde:: Deserialize , serde:: Serialize ) ]
1215#[ serde( rename_all = "camelCase" ) ]
1316pub struct HostConstants {
1417 /// Host chain ID.
@@ -23,8 +26,10 @@ pub struct HostConstants {
2326 passage : Address ,
2427 /// Host address for the transactor contract
2528 transactor : Address ,
26- /// Host chain tokens that are predeployed on the rollup.
27- tokens : PredeployTokens ,
29+ /// Host chain tokens that are special-cased on the rollup. This includes
30+ /// USD tokens for the native asset, and permissioned tokens for bridged
31+ /// assets.
32+ tokens : HostTokens ,
2833}
2934
3035impl std:: fmt:: Display for HostConstants {
@@ -46,16 +51,11 @@ impl HostConstants {
4651 orders : Address ,
4752 passage : Address ,
4853 transactor : Address ,
49- tokens : PredeployTokens ,
54+ tokens : HostTokens ,
5055 ) -> Self {
5156 Self { chain_id, deploy_height, zenith, orders, passage, transactor, tokens }
5257 }
5358
54- /// Get the hard-coded pecorino host constants.
55- pub const fn pecorino ( ) -> Self {
56- crate :: chains:: pecorino:: HOST
57- }
58-
5959 /// Get the hard-coded local test host constants.
6060 #[ cfg( any( test, feature = "test-utils" ) ) ]
6161 pub const fn test ( ) -> Self {
@@ -121,8 +121,18 @@ impl HostConstants {
121121 }
122122
123123 /// Get the host tokens.
124- pub const fn tokens ( & self ) -> PredeployTokens {
125- self . tokens
124+ pub const fn tokens ( & self ) -> & HostTokens {
125+ & self . tokens
126+ }
127+
128+ /// Get the host USD record for the given address, if it is a host USD.
129+ pub fn usd_record ( & self , address : Address ) -> Option < & HostUsdRecord > {
130+ self . tokens . usd_record ( address)
131+ }
132+
133+ /// Return true if the address is an approved USD token.
134+ pub fn is_usd ( & self , address : Address ) -> bool {
135+ self . tokens . is_usd ( address)
126136 }
127137}
128138
@@ -132,7 +142,6 @@ impl FromStr for HostConstants {
132142 fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
133143 let chain: KnownChains = s. parse ( ) ?;
134144 match chain {
135- KnownChains :: Pecorino => Ok ( Self :: pecorino ( ) ) ,
136145 #[ cfg( any( test, feature = "test-utils" ) ) ]
137146 KnownChains :: Test => Ok ( Self :: test ( ) ) ,
138147 }
0 commit comments