Skip to content

Commit

Permalink
Merge branch 'feat/08' into feat/anonpath
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored May 6, 2024
2 parents 92978e7 + 9987a48 commit 0d5c5db
Show file tree
Hide file tree
Showing 149 changed files with 3,759 additions and 3,139 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
# TODO: Replace with macos-latest when works again.
# https://github.com/actions/setup-python/issues/808
os: [ubuntu-latest, macos-12] # eventually add `windows-latest`
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
python-version: [3.9, "3.10", "3.11", "3.12"]

env:
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Read our [academic platform](https://academy.apeworx.io/) will help you master A
In the latest release, Ape requires:

- Linux or macOS
- Python 3.8 up to 3.12
- Python 3.9 up to 3.12
- **Windows**: Install Windows Subsystem Linux [(WSL)](https://docs.microsoft.com/en-us/windows/wsl/install)

Check your python version in a terminal with `python3 --version`.
Expand Down
5 changes: 2 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import sys
from functools import lru_cache
from pathlib import Path
from typing import List

import requests
from packaging.version import Version
Expand Down Expand Up @@ -43,7 +42,7 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns: List[str] = ["_build", ".DS_Store"]
exclude_patterns: list[str] = ["_build", ".DS_Store"]


# The suffix(es) of source filenames.
Expand Down Expand Up @@ -99,7 +98,7 @@ def fixpath(path: str) -> str:


@lru_cache(maxsize=None)
def get_versions() -> List[str]:
def get_versions() -> list[str]:
"""
Get all the versions from the Web.
"""
Expand Down
6 changes: 3 additions & 3 deletions docs/userguides/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ deployments:
mainnet:
- contract_type: MyContract
address: 0x5FbDB2315678afecb367f032d93F642f64180aa3
goerli:
sepolia:
- contract_type: MyContract
address: 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
```
Expand All @@ -99,9 +99,9 @@ geth:
uri: http://localhost:5030
```

Now, the `ape-geth` core plugin will use the URL `http://localhost:5030` to connect and make requests.
Now, the `ape-node` core plugin will use the URL `http://localhost:5030` to connect and make requests.

**WARN**: Instead of using `ape-geth` to connect to an Infura or Alchemy node, use the [ape-infura](https://github.com/ApeWorX/ape-infura) or [ape-alchemy](https://github.com/ApeWorX/ape-alchemy) provider plugins instead, which have their own way of managing API keys via environment variables.
**WARN**: Instead of using `ape-node` to connect to an Infura or Alchemy node, use the [ape-infura](https://github.com/ApeWorX/ape-infura) or [ape-alchemy](https://github.com/ApeWorX/ape-alchemy) provider plugins instead, which have their own way of managing API keys via environment variables.

For more information on networking as a whole, see [this guide](./networks.html).

Expand Down
2 changes: 1 addition & 1 deletion docs/userguides/contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ _ = contract.withdraw(sender=account, value="1 wei")

Notice that transacting returns a [ReceiptAPI](../methoddocs/api.html#ape.api.transactions.ReceiptAPI) object which contains all the receipt data, such as `gas_used`.

**NOTE**: If you need the `return_value` from a transaction, you have to either treat transaction as a call (see the section below!) or use a provider with tracing-features enabled (such as `ape-foundry` or `ape-geth`) and access the [return_value](../methoddocs/api.html#ape.api.transactions.ReceiptAPI.return_value) property on the receipt.
**NOTE**: If you need the `return_value` from a transaction, you have to either treat transaction as a call (see the section below!) or use a provider with tracing-features enabled (such as `ape-foundry` or `ape-node`) and access the [return_value](../methoddocs/api.html#ape.api.transactions.ReceiptAPI.return_value) property on the receipt.

```python
assert receipt.return_value == 123
Expand Down
48 changes: 24 additions & 24 deletions docs/userguides/networks.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 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 Goerli) and a provider (e.g. Eth-Tester, Geth, or Alchemy).
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.

Expand All @@ -15,7 +15,7 @@ No matter what type of network you are using in Ape, you specify the network usi

Where `ecosystem-name` refers to the ecosystem, e.g. `ethereum`, `polygon`, `fantom`, or any valid ecosystem plugin name.
The `network-name` refers to a network such as `mainnet`, `local`, or something else defined by your ecosystem or custom network config.
And `provider-name` refers to the provider plugin in Ape, such as `geth` for a generic node or `foundry` if the network is more Anvil-based, or a different plugin altogether.
And `provider-name` refers to the provider plugin in Ape, such as `node` for a generic node or `foundry` if the network is more Anvil-based, or a different plugin altogether.

Commonly, the network triplet value is specified via the `--network` option in Ape CLI commands.
The following is a list of common Ape commands that can use the `--network` option:
Expand Down Expand Up @@ -79,10 +79,10 @@ Here is a list of all L2 network plugins supported by Ape:

**NOTE**: If you are connecting an L2 network or any other network that does not have a plugin, you can use the custom network support, which is described in the [next section](#custom-network-connection).

Once you have the L2 network plugin installed, you can configure its node's URI by setting the values in the `geth` (default node) core plugin via your `ape-config.yaml` file:
Once you have the L2 network plugin installed, you can configure its node's URI by setting the values in the `node` core plugin via your `ape-config.yaml` file:

```yaml
geth:
node:
<ecosystem-name>:
<network-name>:
uri: https://path.to.node.example.com
Expand Down Expand Up @@ -120,7 +120,7 @@ networks:
chain_id: 109 # Required
ecosystem: shibarium # The ecosystem name, can either be new or an existing
base_ecosystem_plugin: polygon # The ecosystem base-class, defaults to the default ecosystem
default_provider: geth # Default is the generic node provider
default_provider: node # Default is the generic node provider
```
The following paragraphs explain the different parameters of the custom network config.
Expand Down Expand Up @@ -168,13 +168,13 @@ networks:
base_ecosystem_plugin: polygon # Closest base class.
chain_id: 109 # This must be correct or txns will fail.
geth:
node:
shibarium:
mainnet:
uri: https://www.shibrpc.com
```

Now, when using `ethereum:apenet:geth`, it will connect to the RPC URL `https://apenet.example.com/rpc`.
Now, when using `ethereum:apenet:node`, it will connect to the RPC URL `https://apenet.example.com/rpc`.

#### Explorer URL

Expand All @@ -186,7 +186,7 @@ networks:
custom:
- name: customnetwork
chain_id: 31337
default_provider: geth
default_provider: node
```

To add a corresponding entry in `ape-etherscan` (assuming you are using `ape-etherscan` as your explorer plugin), add the following to your `ape-config.yaml` file:
Expand All @@ -195,7 +195,7 @@ To add a corresponding entry in `ape-etherscan` (assuming you are using `ape-eth
etherscan:
ethereum:
rate_limit: 15 # Configure a rate limit that makes sense for retry logic.
# The name of the entry is the same as your custom network!
customnetwork:
uri: https://custom.scan # URL used for showing transactions
Expand Down Expand Up @@ -314,24 +314,24 @@ It is meant for running tests and debugging contracts.
Out-of-the-box, Ape ships with two development providers you can use for the `local` network:

- [EthTester](https://github.com/ethereum/eth-tester)
- An Ephemeral Geth process
- An Ephemeral Node (defaults to Geth) process

```bash
ape test --network ::test
ape test --network ::geth # Launch a local development geth process
ape test --network ::node # Launch a local development node (geth) process
```

To learn more about testing in ape, follow [this guide](./testing.html).

## Live Networks

Use the core plugin `ape-geth` to connect to local or remote nodes via URI.
The geth plugin is abstract in that it represents any node, not just geth nodes.
Use the core plugin `ape-node` to connect to local or remote nodes via URI.
The node plugin is abstract in that it represents any node.
However, it will work best when connected to a geth node.
To configure network URIs in geth, you can use the `ape-config.yaml` file:
To configure network URIs in `node`, you can use the `ape-config.yaml` file:

```yaml
geth:
node:
ethereum:
mainnet:
uri: https://foo.node.bar
Expand Down Expand Up @@ -360,9 +360,9 @@ ethereum:
# Most networks use 120 seconds (2 minutes).
transaction_acceptance_timeout: 60

# The amount of times to retry fetching a receipt. This is useful
# because decentralized systems may show the transaction accepted
# on some nodes but not on others, and potentially RPC requests
# The amount of times to retry fetching a receipt. This is useful
# because decentralized systems may show the transaction accepted
# on some nodes but not on others, and potentially RPC requests
# won't return a receipt immediately after sending its transaction.
# This config accounts for such delay. The default is `20`.
max_receipt_retries: 10
Expand All @@ -371,13 +371,13 @@ ethereum:
# estimates gas. Note: local networks tend to use "max" here
# by default.
gas_limit: auto

# Base-fee multipliers are useful for times when the base fee changes
# before a transaction is sent but after the base fee was derived,
# thus causing rejection. A multiplier reduces the chance of
# rejection. The default for live networks is `1.4` times the base fee.
base_fee_multiplier: 1.2

# The block time helps Ape make decisions about
# polling chain data.
block_time: 10
Expand All @@ -391,7 +391,7 @@ To run a network with a process, use the `ape networks run` command:
ape networks run
```

By default, `ape networks run` runs a development Geth process.
By default, `ape networks run` runs a development Node (geth) process.
To use a different network, such as `hardhat` or Anvil nodes, use the `--network` flag:

```shell
Expand Down Expand Up @@ -423,7 +423,7 @@ from ape import chain, networks
def main():
start_provider = chain.provider.name
with networks.ethereum.mainnet.use_provider("geth") as provider:
with networks.ethereum.mainnet.use_provider("node") as provider:
# We are using a different provider than the one we started with.
assert start_provider != provider.name
```
Expand All @@ -436,9 +436,9 @@ from ape import networks
@click.command()
def cli():
with networks.polygon.mainnet.use_provider("geth"):
with networks.polygon.mainnet.use_provider("node"):
...
with networks.ethereum.mainnet.use_provider("geth"):
with networks.ethereum.mainnet.use_provider("node"):
...
```

Expand Down
8 changes: 4 additions & 4 deletions docs/userguides/scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ from ape.cli import ape_cli_context

@click.command()
@ape_cli_context()
def cli(cli_ctx):
def cli(cli_ctx):
# There is no connection yet at this point.
testnets = {
"ethereum": ["sepolia", "goerli"],
"polygon": ["mumbai"]
"ethereum": ["sepolia"],
"polygon": ["amoy"]
}
nm = cli_ctx.network_manager

Expand Down Expand Up @@ -137,7 +137,7 @@ Without specifying `--network`, the script with connect to your default network.
Else, specify the network using the `--network` flag:

```shell
ape run foobar --network polygon:mumbai:alchemy
ape run foobar --network polygon:amoy:alchemy
```

You can also change networks within the script using the `ProviderContextManager` (see examples in the CLI-script section above).
Expand Down
Loading

0 comments on commit 0d5c5db

Please sign in to comment.