evmchains 0.0.11__tar.gz → 0.0.13__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,15 +26,11 @@ jobs:
26
26
  python -m pip install --upgrade pip
27
27
  pip install .[dev]
28
28
 
29
- - name: Run Black
30
- #run: black --check .
31
- run: black --diff .
29
+ - name: Run linter
30
+ run: ruff check
32
31
 
33
- - name: Run isort
34
- run: isort --check-only .
35
-
36
- - name: Run flake8
37
- run: flake8 .
32
+ - name: Run format check
33
+ run: ruff format --check --diff
38
34
 
39
35
  type-check:
40
36
  runs-on: ubuntu-latest
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: evmchains
3
- Version: 0.0.11
3
+ Version: 0.0.13
4
4
  Summary: Packaged metadata on Ethereum Virtual Machine (EVM) chains
5
5
  License: Apache License
6
6
  Version 2.0, January 2004
@@ -227,11 +227,10 @@ Requires-Dist: pydantic<3,>=2.5.3
227
227
  Provides-Extra: dev
228
228
  Requires-Dist: black~=23.12.1; extra == "dev"
229
229
  Requires-Dist: build~=1.0.3; extra == "dev"
230
- Requires-Dist: flake8~=7.0.0; extra == "dev"
231
- Requires-Dist: isort~=5.13.2; extra == "dev"
232
230
  Requires-Dist: mypy~=1.8.0; extra == "dev"
233
231
  Requires-Dist: pytest~=7.4.4; extra == "dev"
234
232
  Requires-Dist: requests~=2.31.0; extra == "dev"
233
+ Requires-Dist: ruff~=0.6.8; extra == "dev"
235
234
  Requires-Dist: setuptools-scm~=8.0.4; extra == "dev"
236
235
  Requires-Dist: types-requests>=2.31.0.20240106; extra == "dev"
237
236
 
@@ -1,3 +1,9 @@
1
+ """EVM-compatible chains metadata.
2
+
3
+ Chain data is organized by Ape-style ecosystem and network and provided by the
4
+ below utility functions.
5
+ """
6
+
1
7
  import os
2
8
  import random
3
9
  import re
@@ -10,7 +16,7 @@ ENV_VAR_REGEX = re.compile(r"\$\{([A-Za-z0-9_]+)\}")
10
16
 
11
17
 
12
18
  def get_chain_meta(ecosystem: str, network: str) -> Chain:
13
- """Return a Chain instance with metadata for an EVM chain"""
19
+ """Return a Chain instance with metadata for an EVM chain."""
14
20
  if (
15
21
  ecosystem not in PUBLIC_CHAIN_META
16
22
  or network not in PUBLIC_CHAIN_META[ecosystem]
@@ -21,7 +27,7 @@ def get_chain_meta(ecosystem: str, network: str) -> Chain:
21
27
 
22
28
 
23
29
  def get_rpcs(ecosystem: str, network: str) -> List[str]:
24
- """Get a list of valid RPC endpoints for an ecosystem:network pair"""
30
+ """Get a list of valid RPC endpoints for an ecosystem:network pair."""
25
31
  rpcs = []
26
32
 
27
33
  chain = get_chain_meta(ecosystem, network)
@@ -42,7 +48,7 @@ def get_rpcs(ecosystem: str, network: str) -> List[str]:
42
48
 
43
49
 
44
50
  def get_random_rpc(ecosystem: str, network: str) -> str:
45
- """Return a random RPC endpoint for an ecosystem:network pair"""
51
+ """Return a random RPC endpoint for an ecosystem:network pair."""
46
52
  rpcs = get_rpcs(ecosystem, network)
47
53
  return random.choice(rpcs)
48
54
 
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.0.11'
16
- __version_tuple__ = version_tuple = (0, 0, 11)
15
+ __version__ = version = '0.0.13'
16
+ __version_tuple__ = version_tuple = (0, 0, 13)
@@ -1,6 +1,12 @@
1
- # This file is auto-generated by scripts/update.py
2
- # 2024-07-03 20:26:21.491217
3
- # Do not edit this file directly.
1
+ """Constants containing metadata for EVM-comaptitble chains.
2
+
3
+ !!!!!!!!!!!!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!!!!!!!!!!
4
+ !!!! DO NOT EDIT THIS FILE DIRECTLY! !!!!
5
+ !!!! This file is auto-generated by scripts/update.py !!!!
6
+ !!!! 2024-10-15 20:35:49.075377+00:00 !!!!
7
+ !!!!!!!!!!!!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!!!!!!!!!!
8
+ """
9
+
4
10
  from typing import Any, Dict
5
11
 
6
12
  PUBLIC_CHAIN_META: Dict[str, Dict[str, Dict[str, Any]]] = {
@@ -367,6 +373,38 @@ PUBLIC_CHAIN_META: Dict[str, Dict[str, Dict[str, Any]]] = {
367
373
  "shortName": "bnbt",
368
374
  "slip44": 1,
369
375
  },
376
+ "opBNB": {
377
+ "chain": "opBNB",
378
+ "chainId": 204,
379
+ "ens": None,
380
+ "explorers": [
381
+ {
382
+ "name": "opbnbscan",
383
+ "standard": "EIP3091",
384
+ "url": "https://mainnet.opbnbscan.com",
385
+ }
386
+ ],
387
+ "faucets": [],
388
+ "features": None,
389
+ "icon": "bnbchain",
390
+ "infoURL": "https://opbnb.bnbchain.org/en",
391
+ "name": "opBNB Mainnet",
392
+ "nativeCurrency": {
393
+ "decimals": 18,
394
+ "name": "BNB Chain Native Token",
395
+ "symbol": "BNB",
396
+ },
397
+ "networkId": 204,
398
+ "rpc": [
399
+ "https://opbnb-mainnet-rpc.bnbchain.org",
400
+ "https://opbnb-mainnet.nodereal.io/v1/64a9df0874fb4a93b9d0a3849de012d3",
401
+ "https://opbnb-mainnet.nodereal.io/v1/e9a36765eb8a40b9bd12e680a1fd2bc5",
402
+ "https://opbnb-rpc.publicnode.com",
403
+ "https://opbnb.drpc.org",
404
+ ],
405
+ "shortName": "obnb",
406
+ "slip44": 714,
407
+ },
370
408
  },
371
409
  "ethereum": {
372
410
  "mainnet": {
@@ -528,13 +566,11 @@ PUBLIC_CHAIN_META: Dict[str, Dict[str, Dict[str, Any]]] = {
528
566
  "rpc": [
529
567
  "https://rpc.sepolia.org",
530
568
  "https://rpc2.sepolia.org",
531
- "https://rpc-sepolia.rockx.com",
532
569
  "https://rpc.sepolia.ethpandaops.io",
533
570
  "https://sepolia.infura.io/v3/${INFURA_API_KEY}",
534
571
  "https://sepolia.gateway.tenderly.co",
535
572
  "https://ethereum-sepolia-rpc.publicnode.com",
536
573
  "https://sepolia.drpc.org",
537
- "https://rpc-sepolia.rockx.com",
538
574
  ],
539
575
  "shortName": "sep",
540
576
  "slip44": 1,
@@ -688,6 +724,7 @@ PUBLIC_CHAIN_META: Dict[str, Dict[str, Dict[str, Any]]] = {
688
724
  "rpc": [
689
725
  "https://rpc.linea.build",
690
726
  "https://linea-mainnet.infura.io/v3/${INFURA_API_KEY}",
727
+ "https://linea-rpc.publicnode.com",
691
728
  ],
692
729
  "shortName": "linea",
693
730
  "slip44": None,
@@ -720,6 +757,7 @@ PUBLIC_CHAIN_META: Dict[str, Dict[str, Dict[str, Any]]] = {
720
757
  "rpc": [
721
758
  "https://rpc.sepolia.linea.build",
722
759
  "https://linea-sepolia.infura.io/v3/${INFURA_API_KEY}",
760
+ "https://linea-sepolia-rpc.publicnode.com",
723
761
  ],
724
762
  "shortName": "linea-sepolia",
725
763
  "slip44": 1,
@@ -892,7 +930,7 @@ PUBLIC_CHAIN_META: Dict[str, Dict[str, Dict[str, Any]]] = {
892
930
  "icon": "polygon",
893
931
  "infoURL": "https://polygon.technology/",
894
932
  "name": "Polygon Mainnet",
895
- "nativeCurrency": {"decimals": 18, "name": "MATIC", "symbol": "MATIC"},
933
+ "nativeCurrency": {"decimals": 18, "name": "POL", "symbol": "POL"},
896
934
  "networkId": 137,
897
935
  "rpc": [
898
936
  "https://polygon-rpc.com/",
@@ -905,7 +943,7 @@ PUBLIC_CHAIN_META: Dict[str, Dict[str, Dict[str, Any]]] = {
905
943
  "https://polygon.gateway.tenderly.co",
906
944
  "https://polygon.drpc.org",
907
945
  ],
908
- "shortName": "matic",
946
+ "shortName": "pol",
909
947
  "slip44": 966,
910
948
  },
911
949
  "mumbai": {
@@ -950,7 +988,7 @@ PUBLIC_CHAIN_META: Dict[str, Dict[str, Dict[str, Any]]] = {
950
988
  "icon": "polygon",
951
989
  "infoURL": "https://polygon.technology/",
952
990
  "name": "Amoy",
953
- "nativeCurrency": {"decimals": 18, "name": "MATIC", "symbol": "MATIC"},
991
+ "nativeCurrency": {"decimals": 18, "name": "POL", "symbol": "POL"},
954
992
  "networkId": 80002,
955
993
  "rpc": [
956
994
  "https://rpc-amoy.polygon.technology",
@@ -1,9 +1,14 @@
1
+ """Types used in the evmchains package."""
2
+
3
+ # ruff: noqa: N815
1
4
  from typing import Any, Dict, List, Optional
2
5
 
3
6
  from pydantic import BaseModel
4
7
 
5
8
 
6
9
  class Chain(BaseModel):
10
+ """Chain object format for chain data from ethereum-lists/chains."""
11
+
7
12
  chainId: int
8
13
  networkId: int
9
14
  name: str
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: evmchains
3
- Version: 0.0.11
3
+ Version: 0.0.13
4
4
  Summary: Packaged metadata on Ethereum Virtual Machine (EVM) chains
5
5
  License: Apache License
6
6
  Version 2.0, January 2004
@@ -227,11 +227,10 @@ Requires-Dist: pydantic<3,>=2.5.3
227
227
  Provides-Extra: dev
228
228
  Requires-Dist: black~=23.12.1; extra == "dev"
229
229
  Requires-Dist: build~=1.0.3; extra == "dev"
230
- Requires-Dist: flake8~=7.0.0; extra == "dev"
231
- Requires-Dist: isort~=5.13.2; extra == "dev"
232
230
  Requires-Dist: mypy~=1.8.0; extra == "dev"
233
231
  Requires-Dist: pytest~=7.4.4; extra == "dev"
234
232
  Requires-Dist: requests~=2.31.0; extra == "dev"
233
+ Requires-Dist: ruff~=0.6.8; extra == "dev"
235
234
  Requires-Dist: setuptools-scm~=8.0.4; extra == "dev"
236
235
  Requires-Dist: types-requests>=2.31.0.20240106; extra == "dev"
237
236
 
@@ -3,10 +3,9 @@ pydantic<3,>=2.5.3
3
3
  [dev]
4
4
  black~=23.12.1
5
5
  build~=1.0.3
6
- flake8~=7.0.0
7
- isort~=5.13.2
8
6
  mypy~=1.8.0
9
7
  pytest~=7.4.4
10
8
  requests~=2.31.0
9
+ ruff~=0.6.8
11
10
  setuptools-scm~=8.0.4
12
11
  types-requests>=2.31.0.20240106
@@ -33,13 +33,13 @@ dynamic = ["version"]
33
33
 
34
34
  [project.optional-dependencies]
35
35
  dev = [
36
+ # NOTE: black still used as a library in update.py
36
37
  "black~=23.12.1",
37
38
  "build~=1.0.3",
38
- "flake8~=7.0.0",
39
- "isort~=5.13.2",
40
39
  "mypy~=1.8.0",
41
40
  "pytest~=7.4.4",
42
41
  "requests~=2.31.0",
42
+ "ruff~=0.6.8",
43
43
  "setuptools-scm~=8.0.4",
44
44
  "types-requests>=2.31.0.20240106",
45
45
  ]
@@ -47,25 +47,31 @@ dev = [
47
47
  [tool.mypy]
48
48
  exclude = "build/"
49
49
 
50
- [tool.setuptools_scm]
51
- write_to = "evmchains/_meta.py"
50
+ [tool.ruff]
51
+ # Mimic's black's default line length
52
+ line-length = 88
52
53
 
53
- # NOTE: you have to use single-quoted strings in TOML for regular expressions.
54
- # It's the equivalent of r-strings in Python. Multiline strings are treated as
55
- # verbose regular expressions by Black. Use [ ] to denote a significant space
56
- # character.
54
+ [tool.ruff.lint]
55
+ # Ref: https://docs.astral.sh/ruff/rules
56
+ extend-select = [
57
+ "D", # pydocstyle
58
+ "E501", # Line length
59
+ "I", # isort
60
+ "N", # PEP8 naming
61
+ "UP", # pyupgrade
62
+ "RUF", # ruf-specific rules
63
+ "W", # warnings
64
+ ]
57
65
 
58
- [tool.black]
59
- target-version = ['py38', 'py39', 'py310', 'py311', 'py312']
60
- include = '\.pyi?$'
66
+ [tool.ruff.lint.per-file-ignores]
67
+ "tests/test_*.py" = ["D"]
68
+
69
+ [tool.ruff.lint.pydocstyle]
70
+ convention = "google"
71
+
72
+ [tool.setuptools_scm]
73
+ write_to = "evmchains/_meta.py"
61
74
 
62
75
  [tool.pytest.ini_options]
63
76
  python_files = "test_*.py"
64
77
  testpaths = "tests"
65
-
66
-
67
- [tool.isort]
68
- force_grid_wrap = 0
69
- include_trailing_comma = true
70
- multi_line_output = 3
71
- use_parentheses = true
@@ -1,5 +1,11 @@
1
+ """Script updates chains.py constants file with up to date data.
2
+
3
+ To add new chains to this module, update CHAIN_IDS below and re-run the script. See
4
+ README.md for more details.
5
+ """
6
+
1
7
  import logging
2
- from datetime import datetime
8
+ from datetime import datetime, timezone
3
9
  from pathlib import Path
4
10
  from pprint import PrettyPrinter
5
11
  from typing import Any, Dict
@@ -17,10 +23,13 @@ SOURCE_URL = (
17
23
  CHAIN_CONST_FILE = Path(__file__).parent.parent / "evmchains" / "chains.py"
18
24
  BLACKLIST_STRINGS = [
19
25
  # 2024-01-19: Node appears to be broken. Returning errors on simple requests.
20
- "rpc.blocknative.com"
26
+ "rpc.blocknative.com",
27
+ # 2024-09-05: Node returning 504s for days.
28
+ "rpc-sepolia.rockx.com",
21
29
  ]
22
30
 
23
- # Mapping of Ape ecosystem:network to chain IDs. These are the chains that we will be fetching.
31
+ # Mapping of Ape ecosystem:network to chain IDs. These are the chains that we will be
32
+ # fetching.
24
33
  CHAIN_IDS = {
25
34
  "arbitrum": {
26
35
  "mainnet": 42161,
@@ -42,6 +51,7 @@ CHAIN_IDS = {
42
51
  "bsc": {
43
52
  "mainnet": 56,
44
53
  "testnet": 97,
54
+ "opBNB": 204,
45
55
  },
46
56
  "ethereum": {
47
57
  "mainnet": 1,
@@ -86,7 +96,7 @@ CHAIN_IDS = {
86
96
  "shibarium": {
87
97
  "mainnet": 109,
88
98
  "puppynet": 157,
89
- }
99
+ },
90
100
  }
91
101
 
92
102
  pp = PrettyPrinter(indent=4)
@@ -95,11 +105,12 @@ logger.setLevel(logging.DEBUG)
95
105
 
96
106
 
97
107
  def stamp() -> str:
98
- """UTC timestamp for file header"""
99
- return str(datetime.utcnow())
108
+ """UTC timestamp for file header."""
109
+ return str(datetime.now(tz=timezone.utc))
100
110
 
101
111
 
102
112
  def ensure_dict(d: Dict[str, Any], key: str):
113
+ """Ensures a dict value at key."""
103
114
  if key in d and isinstance(d[key], dict):
104
115
  return
105
116
  d[key] = dict()
@@ -146,10 +157,15 @@ def fetch_chains() -> Dict[str, Dict[str, Chain]]:
146
157
 
147
158
 
148
159
  def write_chain_const(chains: Dict[str, Dict[str, Chain]]):
149
- """Write the file with Python constant"""
150
- file_str = "# This file is auto-generated by scripts/update.py\n"
151
- file_str += f"# {stamp()}\n"
152
- file_str += "# Do not edit this file directly.\n"
160
+ """Write the file with Python constant."""
161
+ stamp_str = stamp()
162
+ file_str = '"""Constants containing metadata for EVM-comaptitble chains.\n\n'
163
+ file_str += "!!!!!!!!!!!!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!!!!!!!!!!\n"
164
+ file_str += "!!!! DO NOT EDIT THIS FILE DIRECTLY! !!!!\n"
165
+ file_str += "!!!! This file is auto-generated by scripts/update.py !!!!\n"
166
+ file_str += f"!!!! {stamp_str}{' ' * (50 - len(stamp_str))}!!!!\n"
167
+ file_str += "!!!!!!!!!!!!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!!!!!!!!!!\n"
168
+ file_str += '"""\n\n'
153
169
  file_str += "from typing import Any, Dict\n\n"
154
170
  file_str += "PUBLIC_CHAIN_META: Dict[str, Dict[str, Dict[str, Any]]] = {\n"
155
171
 
@@ -169,6 +185,7 @@ def write_chain_const(chains: Dict[str, Dict[str, Chain]]):
169
185
 
170
186
 
171
187
  def main():
188
+ """Fetch data and update the constants file."""
172
189
  logger.info("Fetching chain data...")
173
190
  logger.info(f" Source: {SOURCE_URL}")
174
191
  logger.info(f" Dest: {CHAIN_CONST_FILE}")
@@ -1,3 +1,5 @@
1
+ """Setup file for the package."""
2
+
1
3
  from setuptools import setup # type: ignore
2
4
 
3
5
  setup()
File without changes
File without changes
File without changes
File without changes
File without changes