Skip to content

Commit

Permalink
Merge branch 'main' into feat/allow-forking-a-fork
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored Dec 5, 2024
2 parents 80bb774 + ae256d2 commit 6f89c0d
Show file tree
Hide file tree
Showing 62 changed files with 1,390 additions and 576 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest] # eventually add `windows-latest`
python-version: [3.9, "3.10", "3.11", "3.12"]
python-version: [3.9, "3.10", "3.11", "3.12", "3.13"]

env:
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -86,7 +86,7 @@ jobs:
- name: Install Geth
uses: gacts/install-geth-tools@v1
with:
version: 1.14.5
version: 1.14.12

- name: Install Dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ repos:
]

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.18
rev: 0.7.19
hooks:
- id: mdformat
additional_dependencies: [mdformat-gfm, mdformat-frontmatter, mdformat-pyproject]
Expand Down
2 changes: 1 addition & 1 deletion docs/methoddocs/ape_accounts.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ape-accounts

```{eval-rst}
.. automodule:: ape_accounts
.. automodule:: ape_accounts.accounts
:members:
```
2 changes: 1 addition & 1 deletion docs/methoddocs/ape_compile.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ape-compile

```{eval-rst}
.. automodule:: ape_compile
.. automodule:: ape_compile.config
:members:
```
22 changes: 21 additions & 1 deletion docs/methoddocs/ape_ethereum.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
# ape-ethereum

```{eval-rst}
.. automodule:: ape_ethereum
.. automodule:: ape_ethereum.ecosystem
:members:
```

```{eval-rst}
.. automodule:: ape_ethereum.provider
:members:
```

```{eval-rst}
.. automodule:: ape_ethereum.proxies
:members:
```

```{eval-rst}
.. automodule:: ape_ethereum.trace
:members:
```

```{eval-rst}
.. automodule:: ape_ethereum.transactions
:members:
```

Expand Down
2 changes: 1 addition & 1 deletion docs/methoddocs/ape_node.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ape-node

```{eval-rst}
.. automodule:: ape_node
.. automodule:: ape_node.provider
:members:
```
12 changes: 11 additions & 1 deletion docs/methoddocs/ape_pm.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# ape-pm

```{eval-rst}
.. automodule:: ape_pm
.. automodule:: ape_pm.compiler
:members:
```

```{eval-rst}
.. automodule:: ape_pm.dependency
:members:
```

```{eval-rst}
.. automodule:: ape_pm.project
:members:
```
12 changes: 11 additions & 1 deletion docs/methoddocs/ape_test.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# ape-test

```{eval-rst}
.. automodule:: ape_test
.. automodule:: ape_test.accounts
:members:
```

```{eval-rst}
.. automodule:: ape_test.config
:members:
```

```{eval-rst}
.. automodule:: ape_test.provider
:members:
```
2 changes: 1 addition & 1 deletion docs/userguides/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ There are two locations you can place config files.
1. In the root of your project
2. In your `$HOME/.ape` directory (global)

Project settings take precedent, but global settings allow you to configure preferences across all projects, such as your default mainnet provider (e.g. Alchemy versus running your own node).
Project settings take precedence, but global settings allow you to configure preferences across all projects, such as your default mainnet provider (e.g. Alchemy versus running your own node).

This guide serves as an index of some settings you can include in any `ape-config.yaml` file.
This guide is **PURPOSELY** alphabetized to facilitate easier look-up of keys.
Expand Down
21 changes: 18 additions & 3 deletions docs/userguides/console.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Follow [this guide](./networks.html) for more information on networks in Ape.

## Namespace Extras

You can also create scripts to be included in the console namespace by adding a file (`ape_console_extras.py`) to your root project directory. All non-internal symbols from this file will be included in the console namespace. Internal symbols are prefixed by an underscore (`_`).
You can also create scripts to be included in the console namespace by adding a file (`ape_console_extras.py`) to your root project directory. All non-internal symbols from this file will be included in the console namespace. Internal symbols are prefixed by an underscore (`_`).

An example file might look something like this:

Expand All @@ -75,7 +75,7 @@ Out[2]: '0x68f768988e9bd4be971d527f72483f321975fa52aff9692b6d0e0af71fb77aaf'

### Init Function

If you include a function named `ape_init_extras`, it will be executed with the symbols from the existing namespace being provided as keyword arguments. This allows you to alter the scripts namespace using locals already included in the Ape namespace. If you return a `dict`, these values will be added to the console namespace. For example, you could set up an initialized Web3.py object by using one from an existing Ape Provider.
If you include a function named `ape_init_extras`, it will be executed with the symbols from the existing namespace being provided as keyword arguments. This allows you to alter the scripts namespace using locals already included in the Ape namespace. If you return a `dict`, these values will be added to the console namespace. For example, you could set up an initialized Web3.py object by using one from an existing Ape Provider.

```python
def ape_init_extras(chain):
Expand All @@ -91,7 +91,7 @@ Out[1]: 1

### Global Extras

You can also add an `ape_console_extras.py` file to the global ape data directory (`$HOME/.ape/ape_console_extras.py`) and it will execute regardless of what project context you are in. This may be useful for variables and utility functions you use across all of your projects.
You can also add an `ape_console_extras.py` file to the global ape data directory (`$HOME/.ape/ape_console_extras.py`) and it will execute regardless of what project context you are in. This may be useful for variables and utility functions you use across all of your projects.

## Configure

Expand Down Expand Up @@ -164,3 +164,18 @@ Out[3]: '0.00040634 ETH'
In [4]: %bal 0xE3747e6341E0d3430e6Ea9e2346cdDCc2F8a4b5b
Out[4]: '0.00040634 ETH'
```

## Executing Code

You can also use the `ape console` to execute programs directly from strings.
This is similar to the `python -c|--code` option except it will display the output cell.
Anything available in `ape console` is also available in `ape console --code`.

```shell
ape console -c 'project.name'
Out[1]: 'my-project'
ape console -c 'x = 3\nx + 1'
Out[1]: 4
ape console -c 'networks.active_provider.name'
Out[1]: 'test'
```
8 changes: 8 additions & 0 deletions docs/userguides/developing_plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ from ape import plugins
# Here, we register our provider plugin so we can use it in 'ape'.
@plugins.register(plugins.ProviderPlugin)
def providers():
# NOTE: By keeping this import local, we avoid slower plugin load times.
from ape_my_plugin.provider import MyProvider

# NOTE: 'MyProvider' defined in a prior code-block.
yield "ethereum", "local", MyProvider
```
Expand All @@ -69,6 +72,11 @@ This decorator hooks into ape core and ties everything together by looking for a
Then, it will loop through these potential `ape` plugins and see which ones have created a plugin type registration.
If the plugin type registration is found, then `ape` knows this package is a plugin and attempts to process it according to its registration interface.

```{warning}
Ensure your plugin's `__init__.py` file imports quickly by keeping all expensive imports in the hook functions locally.
This helps Ape register plugins faster, which is required when checking for API implementations.
```

### CLI Plugins

The `ape` CLI is built using the python package [click](https://palletsprojects.com/p/click/).
Expand Down
21 changes: 18 additions & 3 deletions docs/userguides/networks.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Networks

When interacting with a blockchain, you will have to select an ecosystem (e.g. Ethereum, Arbitrum, or Fantom), a network (e.g. Mainnet or Sepolia) and a provider (e.g. Eth-Tester, Node (Geth), or Alchemy).
Networks are part of ecosystems and typically defined in plugins.
For example, the `ape-ethereum` plugin comes with Ape and can be used for handling EVM-like behavior.
The `ape-ethereum` ecosystem and network(s) plugin comes with Ape and can be used for handling EVM-like behavior.
Networks are part of ecosystems and typically defined in plugins or custom-network configurations.
However, Ape works out-of-the-box (in a limited way) with any network defined in the [evmchains](https://github.com/ApeWorX/evmchains) library.

## Selecting a Network

Expand All @@ -25,7 +26,7 @@ ape test --network ethereum:local:foundry
ape console --network arbitrum:testnet:alchemy # NOTICE: All networks, even from other ecosystems, use this.
```

To see all possible values for `--network`, run the command:
To see all networks that work with the `--network` flag (besides those _only_ defined in `evmchains`), run the command:

```shell
ape networks list
Expand Down Expand Up @@ -100,6 +101,20 @@ ape networks list

In the remainder of this guide, any example below using Ethereum, you can replace with an L2 ecosystem's name and network combination.

## evmchains Networks

If a network is in the [evmchains](https://github.com/ApeWorX/evmchains) library, it will work in Ape automatically, even without a plugin or any custom configuration for that network.

```shell
ape console --network moonbeam
```

This works because the `moonbeam` network data is available in the `evmchains` library, and Ape is able to look it up.

```{warning}
Support for networks from evm-chains alone may be limited and require additional configuration to work in production use-cases.
```

## Custom Network Connection

You can add custom networks to Ape without creating a plugin.
Expand Down
2 changes: 1 addition & 1 deletion docs/userguides/projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ project # The root project directory
└── ape-config.yaml # The ape project configuration file
```

Notice that you can configure you ape project using the `ape-config.yaml` file.
Notice that you can configure your ape project using the `ape-config.yaml` file.
See the [configuration guide](./config.html) for a more detailed explanation of settings you can adjust.

## The Local Project
Expand Down
4 changes: 2 additions & 2 deletions docs/userguides/proxy.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Proxy Contracts

Ape is able to detect proxy contracts so that it uses the target interface when interacting with a contract.
The following proxies are supporting in `ape-ethereum`:
The following proxies are supported in `ape-ethereum`:

| Proxy Type | Short Description |
| ------------ | --------------------------------- |
Expand All @@ -27,7 +27,7 @@ from ape import Contract
my_contract = Contract("0x...")
```

Ape will check the address you give it and detect if hosts a proxy contract.
Ape will check the address you give it and detect if it hosts a proxy contract.
In the case where it determines the address is a proxy contract, it resolves the address of the implementation (every proxy is different) and returns the interface for the implementation contract.
This allows you to still call methods as you normally do on proxy contracts.

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools>=51.1.1", "wheel", "setuptools_scm[toml]>=5.0,<8"]
requires = ["setuptools>=75.0.0", "wheel", "setuptools_scm[toml]>=5.0"]

[tool.mypy]
exclude = ["build/", "dist/", "docs/", "tests/integration/cli/projects/"]
Expand All @@ -21,7 +21,7 @@ write_to = "src/ape/version.py"
# character.
[tool.black]
line-length = 100
target-version = ['py39', 'py310', 'py311', 'py312']
target-version = ['py39', 'py310', 'py311', 'py312', 'py313']
include = '\.pyi?$'

[tool.pytest.ini_options]
Expand Down
17 changes: 10 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"pytest-cov>=4.0.0,<5", # Coverage analyzer plugin
"pytest-mock", # For creating mocks
"pytest-benchmark", # For performance tests
"pytest-rerunfailures", # For flakey tests
"pytest-timeout>=2.2.0,<3", # For avoiding timing out during tests
"hypothesis>=6.2.0,<7.0", # Strategy-based fuzzer
"hypothesis-jsonschema==0.19.0", # JSON Schema fuzzer extension
Expand All @@ -36,14 +37,14 @@
"flake8-pydantic", # For detecting issues with Pydantic models
"flake8-type-checking", # Detect imports to move in/out of type-checking blocks
"isort>=5.13.2,<6", # Import sorting linter
"mdformat>=0.7.18", # Auto-formatter for markdown
"mdformat>=0.7.19", # Auto-formatter for markdown
"mdformat-gfm>=0.3.5", # Needed for formatting GitHub-flavored markdown
"mdformat-frontmatter>=0.4.1", # Needed for frontmatters-style headers in issue templates
"mdformat-pyproject>=0.0.1", # Allows configuring in pyproject.toml
"mdformat-pyproject>=0.0.2", # Allows configuring in pyproject.toml
],
"doc": ["sphinx-ape"],
"release": [ # `release` GitHub Action job uses this
"setuptools", # Installation tool
"setuptools>=75", # Installation tool
"wheel", # Packaging tool
"twine==3.8.0", # Package upload tool
],
Expand Down Expand Up @@ -97,12 +98,13 @@
"ijson>=3.1.4,<4",
"ipython>=8.18.1,<9",
"lazyasd>=0.1.4",
"asttokens>=2.4.1,<3", # Peer dependency; w/o pin container build fails.
# Pandas peer-dep: Numpy 2.0 causes issues for some users.
"numpy<2",
"packaging>=23.0,<24",
"pandas>=2.2.2,<3",
"pluggy>=1.3,<2",
"pydantic>=2.6.4,<3",
"pydantic>=2.10.0,<3",
"pydantic-settings>=2.5.2,<3",
"pytest>=8.0,<9.0",
"python-dateutil>=2.8.2,<3",
Expand All @@ -119,15 +121,15 @@
# All version pins dependent on web3[tester]
"eth-abi",
"eth-account",
"eth-typing",
"eth-typing>=3.5.2,<4",
"eth-utils",
"hexbytes",
"py-geth>=5.0.0-beta.2,<6",
"py-geth>=5.1.0,<6",
"trie>=3.0.1,<4", # Peer: stricter pin needed for uv support.
"web3[tester]>=6.17.2,<7",
# ** Dependencies maintained by ApeWorX **
"eip712>=0.2.10,<0.3",
"ethpm-types>=0.6.17,<0.7",
"ethpm-types>=0.6.19,<0.7",
"eth_pydantic_types>=0.1.3,<0.2",
"evmchains>=0.1.0,<0.2",
"evm-trace>=0.2.3,<0.3",
Expand Down Expand Up @@ -169,5 +171,6 @@
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
],
)
2 changes: 1 addition & 1 deletion src/ape/api/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def prepare_transaction(self, txn: TransactionAPI) -> TransactionAPI:
:class:`~ape.api.transactions.TransactionAPI`
"""

# NOTE: Allow overriding nonce, assume user understand what this does
# NOTE: Allow overriding nonce, assume user understands what this does
if txn.nonce is None:
txn.nonce = self.nonce
elif txn.nonce < self.nonce:
Expand Down
Loading

0 comments on commit 6f89c0d

Please sign in to comment.