2
2
//!
3
3
//! Foundry EVM network custom precompiles.
4
4
5
- use crate :: celo:: transfer:: { CELO_TRANSFER_ADDRESS , PRECOMPILE_ID_CELO_TRANSFER } ;
5
+ use crate :: celo:: transfer:: {
6
+ CELO_TRANSFER_ADDRESS , CELO_TRANSFER_LABEL , PRECOMPILE_ID_CELO_TRANSFER ,
7
+ } ;
8
+ use alloy_chains:: NamedChain ;
6
9
use alloy_evm:: precompiles:: PrecompilesMap ;
7
- use alloy_primitives:: Address ;
10
+ use alloy_primitives:: { Address , map :: AddressHashMap } ;
8
11
use clap:: Parser ;
9
12
use serde:: { Deserialize , Serialize } ;
10
13
use std:: collections:: BTreeMap ;
@@ -33,6 +36,13 @@ impl NetworkConfigs {
33
36
Self { optimism : true , ..Default :: default ( ) }
34
37
}
35
38
39
+ pub fn with_chain_id ( mut self , chain_id : u64 ) -> Self {
40
+ if let Ok ( NamedChain :: Celo | NamedChain :: CeloSepolia ) = NamedChain :: try_from ( chain_id) {
41
+ self . celo = true ;
42
+ }
43
+ self
44
+ }
45
+
36
46
/// Inject precompiles for configured networks.
37
47
pub fn inject_precompiles ( self , precompiles : & mut PrecompilesMap ) {
38
48
if self . celo {
@@ -42,6 +52,15 @@ impl NetworkConfigs {
42
52
}
43
53
}
44
54
55
+ /// Returns precompiles label for configured networks, to be used in traces.
56
+ pub fn precompiles_label ( self ) -> AddressHashMap < String > {
57
+ let mut labels = AddressHashMap :: default ( ) ;
58
+ if self . celo {
59
+ labels. insert ( CELO_TRANSFER_ADDRESS , CELO_TRANSFER_LABEL . to_string ( ) ) ;
60
+ }
61
+ labels
62
+ }
63
+
45
64
/// Returns precompiles for configured networks.
46
65
pub fn precompiles ( self ) -> BTreeMap < String , Address > {
47
66
let mut precompiles = BTreeMap :: new ( ) ;
0 commit comments