Skip to content

Commit 5b845a8

Browse files
committed
feat: support polygonzkevm
1 parent 986fe61 commit 5b845a8

File tree

6 files changed

+21
-6
lines changed

6 files changed

+21
-6
lines changed

.pre-commit-config.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ repos:
1616
name: black
1717

1818
- repo: https://github.com/pycqa/flake8
19-
rev: 7.0.0
19+
rev: 7.1.0
2020
hooks:
2121
- id: flake8
2222

2323
- repo: https://github.com/pre-commit/mirrors-mypy
24-
rev: v1.10.0
24+
rev: v1.10.1
2525
hooks:
2626
- id: mypy
2727
additional_dependencies: [types-PyYAML, types-requests, pydantic, types-setuptools]

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ The `ape-alchemy` plugin supports the following ecosystems:
88
- Base
99
- Optimism
1010
- Polygon
11+
- Polygon-ZkEVM
1112

1213
## Dependencies
1314

ape_alchemy/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
"mainnet",
2424
"amoy",
2525
],
26+
"polygon-zkevm": [
27+
"mainnet",
28+
"cardona",
29+
],
2630
}
2731

2832

ape_alchemy/provider.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
# Alchemy will try to publish private transactions for 25 blocks.
2525
PRIVATE_TX_BLOCK_WAIT = 25
2626

27+
NETWORKS_SUPPORTING_WEBSOCKETS = ("ethereum", "arbitrum", "base", "optimism", "polygon")
28+
2729

2830
class Alchemy(Web3Provider, UpstreamProvider):
2931
"""
@@ -46,7 +48,9 @@ def uri(self):
4648

4749
key = None
4850

49-
expected_env_var_prefix = f"WEB3_{ecosystem_name.upper()}_{network_name.upper()}_ALCHEMY"
51+
ecosystem_nm_part = ecosystem_name.upper().replace("-", "_")
52+
network_nm_part = network_name.upper().replace("-", "_")
53+
expected_env_var_prefix = f"WEB3_{ecosystem_nm_part}_{network_nm_part}_ALCHEMY"
5054
options = (
5155
*DEFAULT_ENVIRONMENT_VARIABLE_NAMES,
5256
f"{expected_env_var_prefix}_PROJECT_ID",
@@ -68,6 +72,7 @@ def uri(self):
6872
"base": "https://base-{0}.g.alchemy.com/v2/{1}",
6973
"optimism": "https://opt-{0}.g.alchemy.com/v2/{1}",
7074
"polygon": "https://polygon-{0}.g.alchemy.com/v2/{1}",
75+
"polygon-zkevm": "https://polygonzkevm-{0}.g.alchemy.com/v2/{1}",
7176
}
7277

7378
network_format = network_formats_by_ecosystem[ecosystem_name]

setup.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"ape-base", # Needed for testing Base integration
99
"ape-optimism", # Needed for testing Optimism integration
1010
"ape-polygon", # Needed for testing Polygon integration
11+
"ape-polygon-zkevm", # Needed for testing Polygon-ZkEVM integration
1112
"pytest>=6.0", # Core testing package
1213
"pytest-xdist", # Multi-process runner
1314
"pytest-cov", # Coverage analyzer plugin
@@ -17,10 +18,10 @@
1718
],
1819
"lint": [
1920
"black>=24.4.2,<25", # Auto-formatter and linter
20-
"mypy>=1.10.0,<2", # Static type analyzer
21+
"mypy>=1.10.1,<2", # Static type analyzer
2122
"types-setuptools", # Needed for mypy type shed
2223
"types-requests", # Needed for mypy type shed
23-
"flake8>=7.0.0,<8", # Style linter
24+
"flake8>=7.1.0,<8", # Style linter
2425
"flake8-breakpoint>=1.1.0,<2", # Detect breakpoints left in code
2526
"flake8-print>=5.0.0,<6", # Detect print statements left in code
2627
"isort>=5.13.2,<6", # Import sorting linter

tests/test_integration.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from ape.utils import ZERO_ADDRESS
55

66
from ape_alchemy import NETWORKS
7-
from ape_alchemy.provider import Alchemy
7+
from ape_alchemy.provider import Alchemy, NETWORKS_SUPPORTING_WEBSOCKETS
88

99

1010
@pytest.fixture(params=[(name, net) for name, values in NETWORKS.items() for net in values])
@@ -23,6 +23,10 @@ def test_http(provider):
2323

2424

2525
def test_ws(provider):
26+
if provider.network.ecosystem.name not in NETWORKS_SUPPORTING_WEBSOCKETS:
27+
# Test will fail. Network does not support ws clients.
28+
return
29+
2630
assert provider.ws_uri.startswith("wss")
2731

2832
try:

0 commit comments

Comments
 (0)