-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathchain.py
68 lines (57 loc) · 1.83 KB
/
chain.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import logging
from aleph_message.models import Chain
from pydantic import BaseModel, root_validator
logger = logging.getLogger(__name__)
class ChainInfo(BaseModel):
"""
A chain information.
"""
chain_id: int
rpc: str
standard_token: str | None = None
super_token: str | None = None
testnet: bool = False
active: bool = True
@property
def token(self) -> str | None:
return self.super_token or self.standard_token
@root_validator(pre=True)
def check_tokens(cls, values):
if not values.get("standard_token") and not values.get("super_token"):
msg = "At least one of standard_token or super_token must be provided."
raise ValueError(msg)
return values
STREAM_CHAINS: dict[Chain | str, ChainInfo] = {
# TESTNETS
"SEPOLIA": ChainInfo(
chain_id=11155111,
rpc="https://eth-sepolia.public.blastapi.io",
standard_token="0xc4bf5cbdabe595361438f8c6a187bdc330539c60",
super_token="0x22064a21fee226d8ffb8818e7627d5ff6d0fc33a",
active=False,
testnet=True,
),
# MAINNETS
Chain.ETH: ChainInfo(
chain_id=1,
rpc="https://eth-mainnet.public.blastapi.io",
standard_token="0x27702a26126e0B3702af63Ee09aC4d1A084EF628",
active=False,
),
Chain.AVAX: ChainInfo(
chain_id=43114,
rpc="https://api.avax.network/ext/bc/C/rpc",
super_token="0xc0Fbc4967259786C743361a5885ef49380473dCF",
),
Chain.BASE: ChainInfo(
chain_id=8453,
rpc="https://base-mainnet.public.blastapi.io",
super_token="0xc0Fbc4967259786C743361a5885ef49380473dCF",
),
}
def get_chain(chain: str) -> ChainInfo:
try:
return STREAM_CHAINS[chain]
except KeyError:
msg = f"Unknown chain id for chain {chain}"
raise ValueError(msg)