Skip to content

Commit

Permalink
feat: add Fantom support (#83)
Browse files Browse the repository at this point in the history
Co-authored-by: Juliya Smith <[email protected]>
  • Loading branch information
z80dev and antazoey authored Oct 25, 2024
1 parent d700b97 commit 19b6536
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The `ape-alchemy` plugin supports the following ecosystems:
- Ethereum
- Arbitrum
- Base
- Fantom
- Optimism
- Polygon
- Polygon-ZkEVM
Expand Down
4 changes: 4 additions & 0 deletions ape_alchemy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
"mainnet",
"sepolia",
],
"fantom": [
"opera",
"testnet",
],
"optimism": [
"mainnet",
"sepolia",
Expand Down
11 changes: 9 additions & 2 deletions ape_alchemy/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# Alchemy will try to publish private transactions for 25 blocks.
PRIVATE_TX_BLOCK_WAIT = 25

NETWORKS_SUPPORTING_WEBSOCKETS = ("ethereum", "arbitrum", "base", "optimism", "polygon")
NETWORKS_SUPPORTING_WEBSOCKETS = ("ethereum", "arbitrum", "base", "optimism", "polygon", "fantom")


class Alchemy(Web3Provider, UpstreamProvider):
Expand Down Expand Up @@ -81,10 +81,17 @@ def uri(self):
"optimism": "https://opt-{0}.g.alchemy.com/v2/{1}",
"polygon": "https://polygon-{0}.g.alchemy.com/v2/{1}",
"polygon-zkevm": "https://polygonzkevm-{0}.g.alchemy.com/v2/{1}",
"fantom": "https://fantom-{0}.g.alchemy.com/v2/{1}",
}

network_format = network_formats_by_ecosystem[ecosystem_name]
uri = network_format.format(self.network.name, key)
network_name = self.network.name

# NOTE: Fantom's mainnet is named "opera", but the Alchemy URI expects "mainnet".
if self.network.ecosystem.name == "fantom" and self.network.name == "opera":
network_name = "mainnet"

uri = network_format.format(network_name, key)
self.network_uris[(ecosystem_name, network_name)] = uri
return uri

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ include = '\.pyi?$'
[tool.pytest.ini_options]
addopts = """
-p no:ape_test
-p no:pytest_ethereum
--cov-branch
--cov-report term
--cov-report html
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[flake8]
max-line-length = 100
ignore = E704,W503,PYD002
exclude =
venv*
docs
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"test": [ # `test` GitHub Action jobs uses this
"ape-arbitrum", # Needed for testing Arbitrum integration
"ape-base", # Needed for testing Base integration
"ape-fantom", # Needed for testing fantom integration
"ape-optimism", # Needed for testing Optimism integration
"ape-polygon", # Needed for testing Polygon integration
"ape-polygon-zkevm", # Needed for testing Polygon-ZkEVM integration
Expand Down

0 comments on commit 19b6536

Please sign in to comment.