@@ -21,24 +21,124 @@ class CoinType(str, Enum):
2121    ZEC  =  "ZEC" 
2222
2323
24- class  ChainId (str , Enum ):
25-     ARBITRUM  =  "0xa4b1" 
26-     AVALANCHE  =  "0xa86a" 
27-     BASE  =  "0x2105" 
28-     BNB_CHAIN  =  "0x38" 
29-     ETHEREUM  =  "0x1" 
30-     OPTIMISM  =  "0xa" 
31-     POLYGON  =  "0x89" 
32-     SOLANA  =  "0x65" 
33- 
34- 
35- ChainIdCoinTypeMap  =  {
36-     ChainId .ARBITRUM : CoinType .ETH ,
37-     ChainId .AVALANCHE : CoinType .ETH ,
38-     ChainId .BASE : CoinType .ETH ,
39-     ChainId .BNB_CHAIN : CoinType .ETH ,
40-     ChainId .ETHEREUM : CoinType .ETH ,
41-     ChainId .OPTIMISM : CoinType .ETH ,
42-     ChainId .POLYGON : CoinType .ETH ,
43-     ChainId .SOLANA : CoinType .SOL ,
44- }
24+ class  _c (BaseModel ):
25+     coin : CoinType 
26+     chain_id : str 
27+     simplehash_id : str 
28+     alchemy_id : str 
29+     has_nft_support : bool 
30+ 
31+ 
32+ class  Chain (Enum ):
33+     # EVM chains 
34+     ETHEREUM  =  _c (
35+         coin = CoinType .ETH ,
36+         chain_id = "0x1" ,
37+         simplehash_id = "ethereum" ,
38+         alchemy_id = "eth-mainnet" ,
39+         has_nft_support = True ,
40+     )
41+     ARBITRUM  =  _c (
42+         coin = CoinType .ETH ,
43+         chain_id = "0xa4b1" ,
44+         simplehash_id = "arbitrum" ,
45+         alchemy_id = "arb-mainnet" ,
46+         has_nft_support = True ,
47+     )
48+     AVALANCHE  =  _c (
49+         coin = CoinType .ETH ,
50+         chain_id = "0xa86a" ,
51+         simplehash_id = "avalanche" ,
52+         alchemy_id = "avax-mainnet" ,
53+         has_nft_support = True ,
54+     )
55+     BASE  =  _c (
56+         coin = CoinType .ETH ,
57+         chain_id = "0x2105" ,
58+         simplehash_id = "base" ,
59+         alchemy_id = "base-mainnet" ,
60+         has_nft_support = True ,
61+     )
62+     BNB_CHAIN  =  _c (
63+         coin = CoinType .ETH ,
64+         chain_id = "0x38" ,
65+         simplehash_id = "bsc" ,
66+         alchemy_id = "bnb-mainnet" ,
67+         has_nft_support = False ,
68+     )
69+     OPTIMISM  =  _c (
70+         coin = CoinType .ETH ,
71+         chain_id = "0xa" ,
72+         simplehash_id = "optimism" ,
73+         alchemy_id = "opt-mainnet" ,
74+         has_nft_support = True ,
75+     )
76+     POLYGON  =  _c (
77+         coin = CoinType .ETH ,
78+         chain_id = "0x89" ,
79+         simplehash_id = "polygon" ,
80+         alchemy_id = "polygon-mainnet" ,
81+         has_nft_support = True ,
82+     )
83+ 
84+     # Non-EVM chains 
85+     BITCOIN  =  _c (
86+         coin = CoinType .BTC ,
87+         chain_id = "bitcoin_mainnet" ,
88+         simplehash_id = "bitcoin" ,
89+         alchemy_id = "bitcoin-mainnet" ,
90+         has_nft_support = False ,
91+     )
92+     SOLANA  =  _c (
93+         coin = CoinType .SOL ,
94+         chain_id = "0x65" ,
95+         simplehash_id = "solana" ,
96+         alchemy_id = "sol-mainnet" ,
97+         has_nft_support = True ,
98+     )
99+     FILECOIN  =  _c (
100+         coin = CoinType .FIL ,
101+         chain_id = "f" ,
102+         simplehash_id = "filecoin" ,
103+         alchemy_id = "filecoin-mainnet" ,
104+         has_nft_support = False ,
105+     )
106+     CARDANO  =  _c (
107+         coin = CoinType .ADA ,
108+         chain_id = "cardano_mainnet" ,
109+         simplehash_id = "cardano" ,
110+         alchemy_id = "cardano-mainnet" ,
111+         has_nft_support = False ,
112+     )
113+     ZCASH  =  _c (
114+         coin = CoinType .ZEC ,
115+         chain_id = "zcash_mainnet" ,
116+         simplehash_id = "zcash" ,
117+         alchemy_id = "zcash-mainnet" ,
118+         has_nft_support = False ,
119+     )
120+ 
121+     def  __getattr__ (self , name ):
122+         """Delegate attribute access to the chain info""" 
123+         # Only delegate specific attributes to avoid recursion 
124+         if  name  in  [
125+             "coin" ,
126+             "chain_id" ,
127+             "simplehash_id" ,
128+             "alchemy_id" ,
129+             "has_nft_support" ,
130+         ]:
131+             return  getattr (self .value , name )
132+ 
133+         return  super ().__getattr__ (name )
134+ 
135+     @staticmethod  
136+     def  get (coin : str , chain_id : str ):
137+         for  chain  in  Chain :
138+             if  chain .coin .value  ==  coin .upper () and  chain .chain_id  ==  chain_id .lower ():
139+                 return  chain 
140+ 
141+         return  None 
142+ 
143+     def  __repr__ (self ):
144+         return  f"<{ self .__class__ .__name__ } { self .name } { self .coin .value } { self .chain_id }  
0 commit comments