Skip to content

Commit 0e21544

Browse files
feat: support web3.py dependencies (#118)
Co-authored-by: antazoey <[email protected]>
1 parent 8f6517f commit 0e21544

File tree

7 files changed

+78
-13
lines changed

7 files changed

+78
-13
lines changed

.github/workflows/docs.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Docs
2+
3+
on:
4+
push:
5+
branches: [main]
6+
release:
7+
types: [released]
8+
pull_request:
9+
types: [opened, synchronize]
10+
11+
jobs:
12+
docs:
13+
runs-on: ubuntu-latest
14+
15+
permissions:
16+
contents: write
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Setup Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.10"
25+
26+
- name: Ape Docs
27+
uses: apeworx/sphinx-ape@main
28+
with:
29+
github-token: ${{ secrets.GITHUB_TOKEN }}

CONTRIBUTING.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,34 @@ pre-commit install
3232

3333
Committing will now automatically run the local hooks and ensure that your commit passes all lint checks.
3434

35+
## Running the docs locally
36+
37+
First, make sure you have the docs-related tooling installed:
38+
39+
```bash
40+
pip install -e .'[doc]'
41+
```
42+
43+
Then, run the following from the root project directory:
44+
45+
```bash
46+
sphinx-ape build .
47+
```
48+
49+
For the best viewing experience, use a local server:
50+
51+
```bash
52+
sphinx-ape serve .
53+
```
54+
55+
Then, open your browser to `127.0.0.1:1337` and click the `ape` directory link.
56+
57+
You can also use the `--open` flag to automatically open the docs:
58+
59+
```bash
60+
sphinx-ape serve . --open
61+
```
62+
3563
## Pull Requests
3664

3765
Pull requests are welcomed! Please adhere to the following:

ape_foundry/provider.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@
3737
from web3.exceptions import ContractLogicError as Web3ContractLogicError
3838
from web3.exceptions import ExtraDataLengthError
3939
from web3.gas_strategies.rpc import rpc_gas_price_strategy
40-
from web3.middleware import geth_poa_middleware
40+
41+
try:
42+
from web3.middleware import ExtraDataToPOAMiddleware # type: ignore
43+
except ImportError:
44+
from web3.middleware import geth_poa_middleware as ExtraDataToPOAMiddleware # type: ignore
4145
from web3.middleware.validation import MAX_EXTRADATA_LENGTH
4246
from yarl import URL
4347

@@ -400,7 +404,7 @@ def check_poa(block_id) -> bool:
400404

401405
# Handle if using PoA
402406
if any(map(check_poa, (0, "latest"))):
403-
self._web3.middleware_onion.inject(geth_poa_middleware, layer=0)
407+
self._web3.middleware_onion.inject(ExtraDataToPOAMiddleware, layer=0)
404408

405409
def _start(self):
406410
if self.is_connected:
@@ -786,7 +790,9 @@ def connect(self):
786790
logger.error(
787791
f"Upstream provider '{upstream_provider.name}' missing Geth PoA middleware."
788792
)
789-
upstream_provider.web3.middleware_onion.inject(geth_poa_middleware, layer=0)
793+
upstream_provider.web3.middleware_onion.inject(
794+
ExtraDataToPOAMiddleware, layer=0
795+
)
790796
upstream_genesis_block_hash = upstream_provider.get_block(0).hash
791797
else:
792798
raise FoundryProviderError(f"Unable to get genesis block: {err}.") from err

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extensions = ["sphinx_ape"]

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.. dynamic-toc-tree::

docs/userguides/quickstart.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
```{include} ../../README.md
2+
```

setup.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@
3131
"mdformat-pyproject>=0.0.1", # Allows configuring in pyproject.toml
3232
],
3333
"doc": [
34-
"Sphinx>=6.1.3,<7", # Documentation generator
35-
"sphinx_rtd_theme>=1.2.0,<2", # Readthedocs.org theme
36-
"towncrier>=19.2.0, <20", # Generate release notes
34+
"sphinx-ape",
3735
],
3836
"release": [ # `release` GitHub Action job uses this
3937
"setuptools", # Installation tool
@@ -75,13 +73,13 @@
7573
url="https://github.com/ApeWorX/ape-foundry",
7674
include_package_data=True,
7775
install_requires=[
78-
"eth-ape>=0.8.12,<0.9",
79-
"ethpm-types", # Use same version as eth-ape
80-
"eth-pydantic-types", # Use same version as eth-ape
81-
"evm-trace", # Use same version as ape
82-
"web3", # Use same version as ape
83-
"yarl", # Use same version as ape
84-
"hexbytes", # Use same version as ape
76+
"eth-ape>=0.8.21,<0.9",
77+
"ethpm-types>=0.6.19,<0.7",
78+
"eth_pydantic_types>=0.1.3,<0.2",
79+
"evm-trace>=0.2.3,<0.3",
80+
"web3>=6.20.1,<8",
81+
"yarl>=1.9.2,<2",
82+
"hexbytes>=0.3.1,<2",
8583
],
8684
python_requires=">=3.9,<4",
8785
extras_require=extras_require,

0 commit comments

Comments
 (0)