evmchains 0.0.12__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.12
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.12'
16
- __version_tuple__ = version_tuple = (0, 0, 12)
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-09-05 18:21:01.387852
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": {
@@ -686,6 +724,7 @@ PUBLIC_CHAIN_META: Dict[str, Dict[str, Dict[str, Any]]] = {
686
724
  "rpc": [
687
725
  "https://rpc.linea.build",
688
726
  "https://linea-mainnet.infura.io/v3/${INFURA_API_KEY}",
727
+ "https://linea-rpc.publicnode.com",
689
728
  ],
690
729
  "shortName": "linea",
691
730
  "slip44": None,
@@ -718,6 +757,7 @@ PUBLIC_CHAIN_META: Dict[str, Dict[str, Dict[str, Any]]] = {
718
757
  "rpc": [
719
758
  "https://rpc.sepolia.linea.build",
720
759
  "https://linea-sepolia.infura.io/v3/${INFURA_API_KEY}",
760
+ "https://linea-sepolia-rpc.publicnode.com",
721
761
  ],
722
762
  "shortName": "linea-sepolia",
723
763
  "slip44": 1,
@@ -948,7 +988,7 @@ PUBLIC_CHAIN_META: Dict[str, Dict[str, Dict[str, Any]]] = {
948
988
  "icon": "polygon",
949
989
  "infoURL": "https://polygon.technology/",
950
990
  "name": "Amoy",
951
- "nativeCurrency": {"decimals": 18, "name": "MATIC", "symbol": "MATIC"},
991
+ "nativeCurrency": {"decimals": 18, "name": "POL", "symbol": "POL"},
952
992
  "networkId": 80002,
953
993
  "rpc": [
954
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.12
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
@@ -22,7 +28,8 @@ BLACKLIST_STRINGS = [
22
28
  "rpc-sepolia.rockx.com",
23
29
  ]
24
30
 
25
- # 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.
26
33
  CHAIN_IDS = {
27
34
  "arbitrum": {
28
35
  "mainnet": 42161,
@@ -44,6 +51,7 @@ CHAIN_IDS = {
44
51
  "bsc": {
45
52
  "mainnet": 56,
46
53
  "testnet": 97,
54
+ "opBNB": 204,
47
55
  },
48
56
  "ethereum": {
49
57
  "mainnet": 1,
@@ -88,7 +96,7 @@ CHAIN_IDS = {
88
96
  "shibarium": {
89
97
  "mainnet": 109,
90
98
  "puppynet": 157,
91
- }
99
+ },
92
100
  }
93
101
 
94
102
  pp = PrettyPrinter(indent=4)
@@ -97,11 +105,12 @@ logger.setLevel(logging.DEBUG)
97
105
 
98
106
 
99
107
  def stamp() -> str:
100
- """UTC timestamp for file header"""
101
- return str(datetime.utcnow())
108
+ """UTC timestamp for file header."""
109
+ return str(datetime.now(tz=timezone.utc))
102
110
 
103
111
 
104
112
  def ensure_dict(d: Dict[str, Any], key: str):
113
+ """Ensures a dict value at key."""
105
114
  if key in d and isinstance(d[key], dict):
106
115
  return
107
116
  d[key] = dict()
@@ -148,10 +157,15 @@ def fetch_chains() -> Dict[str, Dict[str, Chain]]:
148
157
 
149
158
 
150
159
  def write_chain_const(chains: Dict[str, Dict[str, Chain]]):
151
- """Write the file with Python constant"""
152
- file_str = "# This file is auto-generated by scripts/update.py\n"
153
- file_str += f"# {stamp()}\n"
154
- 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'
155
169
  file_str += "from typing import Any, Dict\n\n"
156
170
  file_str += "PUBLIC_CHAIN_META: Dict[str, Dict[str, Dict[str, Any]]] = {\n"
157
171
 
@@ -171,6 +185,7 @@ def write_chain_const(chains: Dict[str, Dict[str, Chain]]):
171
185
 
172
186
 
173
187
  def main():
188
+ """Fetch data and update the constants file."""
174
189
  logger.info("Fetching chain data...")
175
190
  logger.info(f" Source: {SOURCE_URL}")
176
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