Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support web3.py dependencies #16

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions ape_tenderly/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,30 @@
"ethereum": [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so realizing this whole plugins needs the "lazy root module" treatment.

("mainnet", TenderlyGatewayProvider),
("mainnet-fork", TenderlyForkProvider),
("goerli", TenderlyGatewayProvider),
("goerli-fork", TenderlyForkProvider),
("sepolia", TenderlyGatewayProvider),
("sepolia-fork", TenderlyForkProvider),
],
"polygon": [
("mainnet", TenderlyGatewayProvider),
("mainnet-fork", TenderlyForkProvider),
("mumbai", TenderlyGatewayProvider),
("mumbai-fork", TenderlyForkProvider),
("amoy", TenderlyGatewayProvider),
("amoy-fork", TenderlyForkProvider),
],
"arbitrum": [
("mainnet-fork", TenderlyForkProvider),
("goerli-fork", TenderlyForkProvider),
("sepolia-fork", TenderlyForkProvider),
],
"optimism": [
("mainnet", TenderlyGatewayProvider),
("mainnet-fork", TenderlyForkProvider),
("goerli", TenderlyGatewayProvider),
("goerli-fork", TenderlyForkProvider),
("sepolia", TenderlyGatewayProvider),
("sepolia-fork", TenderlyForkProvider),
],
"base": [
("mainnet", TenderlyGatewayProvider),
("mainnet-fork", TenderlyForkProvider),
("goerli", TenderlyGatewayProvider),
("goerli-fork", TenderlyForkProvider),
("sepolia", TenderlyGatewayProvider),
("sepolia-fork", TenderlyForkProvider),
],
"avalance": [
NotPeopling2day marked this conversation as resolved.
Show resolved Hide resolved
("mainnet-fork", TenderlyForkProvider),
Expand Down
2 changes: 1 addition & 1 deletion ape_tenderly/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def remove_fork(self, fork_id: str):

def get_gateway_rpc_uri(self, ecosystem_name: str, network_name: str) -> str:
if ecosystem_name == "ethereum":
# e.g. Sepolia, Goerli, etc.
# e.g. Sepolia, etc.
network_subdomain = network_name
elif network_name == "mainnet":
# e.g. Polygon mainnet, Optimism, etc.
Expand Down
12 changes: 8 additions & 4 deletions ape_tenderly/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
from ape_ethereum.provider import Web3Provider
from web3 import HTTPProvider, Web3
from web3.gas_strategies.rpc import rpc_gas_price_strategy
from web3.middleware import geth_poa_middleware

try:
from web3.middleware import ExtraDataToPOAMiddleware # type: ignore
except ImportError:
from web3.middleware import geth_poa_middleware as ExtraDataToPOAMiddleware # type: ignore

from .client import Fork, TenderlyClient

Expand Down Expand Up @@ -91,12 +95,12 @@ def connect(self):
raise ProviderError(f"Failed to connect to Tenderly Gateway.\n{repr(err)}") from err

# Any chain that *began* as PoA needs the middleware for pre-merge blocks
ethereum_goerli = 5
ethereum_sepolia = 11155111
optimism = (10, 420)
polygon = (137, 80001)

if chain_id in (ethereum_goerli, *optimism, *polygon):
self._web3.middleware_onion.inject(geth_poa_middleware, layer=0)
if chain_id in (ethereum_sepolia, *optimism, *polygon):
NotPeopling2day marked this conversation as resolved.
Show resolved Hide resolved
self._web3.middleware_onion.inject(ExtraDataToPOAMiddleware, layer=0)

self._web3.eth.set_gas_price_strategy(rpc_gas_price_strategy)

Expand Down
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@
url="https://github.com/ApeWorX/ape-tenderly",
include_package_data=True,
install_requires=[
"eth-ape>=0.7.0,<0.8",
"eth-pydantic-types", # Use same version as eth-ape
"requests", # Use same version as eth-ape
"eth-ape>=0.8.1,<0.9",
NotPeopling2day marked this conversation as resolved.
Show resolved Hide resolved
"eth-pydantic-types>=0.1.3,<0.2",
"web3>=6.20.3,<8",
"requests>=2.28.1,<3",
],
python_requires=">=3.8,<4",
extras_require=extras_require,
Expand Down
Loading