Skip to content

Commit f07dca5

Browse files
committed
test: get good enough to merge
2 parents bb934e0 + e38349e commit f07dca5

243 files changed

Lines changed: 8257 additions & 6710 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/ISSUE_TEMPLATE/bug.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ body:
3434
- Linux
3535
validations:
3636
required: true
37-
- type: markdown
37+
- type: textarea
3838
attributes:
39-
value: |
39+
label: Ape Configuration
40+
placeholder: |
4041
### ape-config.yaml file
4142
4243
Paste your ape-config.yaml content in the following section

.github/workflows/commitlint.yaml

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,30 @@
1-
on: push
1+
name: Validate PR metadata
22

3-
name: Commit Message
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
49

5-
# NOTE: Skip check on PR so as not to confuse contributors
6-
# NOTE: Also install a PR title checker so we don't mess up merges
7-
jobs:
8-
commit-msg:
9-
10-
runs-on: ubuntu-latest
11-
12-
steps:
13-
- uses: actions/checkout@v4
14-
with:
15-
fetch-depth: 0
10+
permissions:
11+
pull-requests: read
1612

17-
- name: Setup Python
18-
uses: actions/setup-python@v5
19-
with:
20-
python-version: "3.10"
21-
22-
- name: Install Dependencies
23-
run: |
24-
python -m pip install --upgrade pip
25-
pip install -r cz-requirement.txt
13+
jobs:
14+
validate-pr:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: amannn/action-semantic-pull-request@v5
18+
name: Run conventional commit checker
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2621

27-
- name: Check commit history
28-
run: cz check --rev-range $(git rev-list --all --reverse | head -1)..HEAD
22+
with:
23+
types: |
24+
feat
25+
perf
26+
fix
27+
chore
28+
refactor
29+
docs
30+
test

.github/workflows/prtitle.yaml

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/workflows/test.yaml

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ jobs:
1515

1616
steps:
1717
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
1820

1921
- name: Setup Python
2022
uses: actions/setup-python@v5
@@ -26,14 +28,11 @@ jobs:
2628
python -m pip install --upgrade pip
2729
pip install .[lint]
2830
29-
- name: Run Black
30-
run: black --check .
31-
32-
- name: Run isort
33-
run: isort --check-only .
31+
- name: Run Ruff Lint
32+
run: ruff check .
3433

35-
- name: Run flake8
36-
run: flake8 .
34+
- name: Run Ruff Format
35+
run: ruff format --check .
3736

3837
- name: Run mdformat
3938
run: mdformat . --check
@@ -43,6 +42,8 @@ jobs:
4342

4443
steps:
4544
- uses: actions/checkout@v4
45+
with:
46+
fetch-depth: 0
4647

4748
- name: Setup Python
4849
uses: actions/setup-python@v5
@@ -63,7 +64,7 @@ jobs:
6364
strategy:
6465
matrix:
6566
os: [ubuntu-latest, macos-latest] # eventually add `windows-latest`
66-
python-version: [3.9, "3.10", "3.11", "3.12", "3.13"]
67+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
6768

6869
env:
6970
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -86,22 +87,21 @@ jobs:
8687
- name: Install Geth
8788
uses: gacts/install-geth-tools@v1
8889
with:
89-
version: 1.14.12
90+
version: 1.15.6
9091

91-
- name: Install Dependencies
92-
run: |
93-
python -m pip install --upgrade pip
94-
pip uninstall eth-ape --yes
95-
pip install .[test]
92+
- name: Setup Ape
93+
uses: ApeWorX/github-action@v3
94+
with:
95+
ape-version-pin: .[test]
9696

9797
- name: Run Functional Tests
98-
run: ape test tests/functional -m "not fuzzing" -s --cov=src --cov-append -n auto --dist loadgroup
98+
run: ape test tests/functional -m "not fuzzing" -s --cov=src --cov-append -v ERROR -n auto --dist loadgroup
9999

100100
- name: Run Integration Tests
101-
run: ape test tests/integration -m "not fuzzing" -s --cov=src --cov-append -n auto --dist loadgroup
101+
run: ape test tests/integration -m "not fuzzing" -s --cov=src --cov-append -v ERROR -n auto --dist loadgroup
102102

103103
- name: Run Performance Tests
104-
run: ape test tests/performance -s
104+
run: ape test tests/performance -s -v ERROR
105105

106106
fuzzing:
107107
runs-on: ubuntu-latest
@@ -111,6 +111,8 @@ jobs:
111111

112112
steps:
113113
- uses: actions/checkout@v4
114+
with:
115+
fetch-depth: 0
114116

115117
- name: Setup Python
116118
uses: actions/setup-python@v5

.pre-commit-config.yaml

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,15 @@ repos:
44
hooks:
55
- id: check-yaml
66

7-
- repo: https://github.com/PyCQA/isort
8-
rev: 5.13.2
7+
- repo: https://github.com/astral-sh/ruff-pre-commit
8+
rev: v0.12.0 # Latest ruff version
99
hooks:
10-
- id: isort
11-
12-
- repo: https://github.com/psf/black
13-
rev: 24.10.0
14-
hooks:
15-
- id: black
16-
name: black
17-
18-
- repo: https://github.com/pycqa/flake8
19-
rev: 7.1.1
20-
hooks:
21-
- id: flake8
22-
additional_dependencies: [flake8-breakpoint, flake8-print, flake8-pydantic, flake8-type-checking]
10+
- id: ruff
11+
args: [--fix, --exit-non-zero-on-fix]
12+
- id: ruff-format
2313

2414
- repo: https://github.com/pre-commit/mirrors-mypy
25-
rev: v1.13.0
15+
rev: v1.16.1
2616
hooks:
2717
- id: mypy
2818
additional_dependencies: [
@@ -37,7 +27,7 @@ repos:
3727
]
3828

3929
- repo: https://github.com/executablebooks/mdformat
40-
rev: 0.7.19
30+
rev: 0.7.22
4131
hooks:
4232
- id: mdformat
4333
additional_dependencies: [mdformat-gfm, mdformat-frontmatter, mdformat-pyproject]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ docker run \
102102

103103
After you have installed Ape, run `ape --version` to verify the installation was successful.
104104

105-
Interact with Ape using either the [CLI](https://docs.apeworx.io/ape/latest/index.html) or [Python code](https://docs.apeworx.io/ape/latest/index.html).
105+
You can interact with Ape using the [command line](https://docs.apeworx.io/ape/stable/userguides/clis.html) or the [Ape console](https://docs.apeworx.io/ape/stable/userguides/console.html).
106106

107107
See the following user-guides for more in-depth tutorials:
108108

cz-requirement.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/index.rst

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,25 @@
22
:plugin-prefix: ape_
33
:userguides:
44
- quickstart
5+
- projects
6+
- config
7+
- installing_plugins
8+
- dependencies
59
- accounts
10+
- compile
11+
- contracts
12+
- testing
13+
- reverts
614
- networks
715
- forking_networks
8-
- contracts
16+
- publishing
917
- proxy
10-
- installing_plugins
11-
- projects
12-
- dependencies
13-
- config
14-
- compile
18+
- contract_metadata
1519
- console
20+
- scripts
1621
- transactions
1722
- trace
18-
- scripts
19-
- testing
20-
- reverts
21-
- publishing
22-
- clis
23+
- logging
2324
- data
25+
- clis
2426
- developing_plugins
25-
- logging

docs/userguides/accounts.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ test:
4646
number_of_accounts: 5
4747
```
4848
49+
You can also change settings at run-time, such as the mnemonic:
50+
51+
```python
52+
from ape import accounts
53+
54+
accounts.test_accounts.mnemonic = "candy maple cake sugar pudding cream honey rich smooth crumble sweet treat"
55+
print(accounts.test_accounts[0])
56+
# 0x627306090abaB3A6e1400e9345bC60c78a8BEf57
57+
```
58+
4959
```{warning}
5060
NEVER put a seed phrase with real funds here.
5161
```
@@ -334,6 +344,62 @@ assert recovered_signer == account.address
334344
assert account.check_signature(message, signature)
335345
```
336346

347+
### Signing Authorizations (EIP-7702)
348+
349+
If supported by your current ecosystem and account plugins, Ape exposes the capability to set delegate contracts for EOAs via [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) signed `SetCode` Authorizations.
350+
To sign an Authorization, use `account.sign_authorization` as follows:
351+
352+
```py
353+
from ape_ethereum import Authorization
354+
sig = account.sign_authorization(contract)
355+
auth = Authorization.from_signature(
356+
address=contract.address,
357+
chain_id=<chain ID>,
358+
nonce=account.nonce,
359+
signature=sig,
360+
)
361+
# NOTE: Will execute `methodWithAuth` from `contract` *after* executing authorization
362+
# NOTE: Make sure to increment the `nonce=` kwarg, as the authorization consumes current nonce
363+
contract.methodWithAuth(..., authorizations=[auth], sender=account, nonce=account.nonce + 1)
364+
```
365+
366+
```{caution}
367+
Authorizations are **extremely dangerous** and can lead to full account compromise via signature.
368+
**DO NOT SIGN** an authorization unless you know what you are doing.
369+
```
370+
371+
```{note}
372+
Not all account plugins support signing Authorizations.
373+
For instance, most hardware wallets may reject signing EIP-7702 Authorizations unless the delegate has been previously whitelisted in their firmware.
374+
Also, smart contract wallets (such as Safe) cannot sign these message types as only EOAs can sign them.
375+
```
376+
377+
Once set, you can see if a delegate contract has been set for your EOA account via `account.delegate`.
378+
Ape exposes a [convienence subcommand](../commands/accounts.html#accounts-auth) group under `ape accounts` for use in managing your delegations.
379+
380+
Ape also exposes the following convienent higher-level API for working with authorizations in a scripting or testing context:
381+
382+
```py
383+
assert not account.delegate
384+
385+
# Set `account`'s `.delegate` to `contract`
386+
account.set_delegate(contract)
387+
assert account.delegate == contract
388+
389+
# Remove `account`'s `.delegate`
390+
account.remove_delegate()
391+
assert not account.delegate
392+
393+
# Temporarily use `contract` as `delegate` (and reset upon exiting context)
394+
# NOTE: Calls `.set_delegate(contract)` when entering context
395+
with account.delegate_to(contract) as proxy:
396+
# NOTE: `proxy` is `Contract(account, contract_type=contract.contract_type)`
397+
assert contract.contract_type == proxy.contract_type
398+
proxy.methodWithAuth(..., sender=account)
399+
# NOTE: calls `remove_delegate()` when exiting context
400+
assert not account.delegate
401+
```
402+
337403
## Automation
338404

339405
If you use your keyfile accounts in automation, such as CI/CD, you may need to programmatically unlock them and enable auto-sign.

0 commit comments

Comments
 (0)