Skip to content

Commit

Permalink
feat!: Remove python 3.8, upgrade dependencies, and add python 3.12 s…
Browse files Browse the repository at this point in the history
…upport (#44)
  • Loading branch information
antazoey authored Apr 9, 2024
1 parent 8c0db9c commit 83c3358
Show file tree
Hide file tree
Showing 16 changed files with 52 additions and 48 deletions.
7 changes: 4 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ fixes: #

### Checklist

- [ ] Passes all linting checks (pre-commit and CI jobs)
- [ ] New test cases have been added and are passing
<!-- All PRs must complete the following checklist before being merged -->

- [ ] All changes are completed
- [ ] New test cases have been added
- [ ] Documentation has been updated
- [ ] PR title follows [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/) standard (will be automatically included in the changelog)
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/commitlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.10"

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.10"

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/prtitle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.10"

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.10"

Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.10"

Expand All @@ -42,10 +42,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.10"

Expand All @@ -63,13 +63,13 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest] # eventually add `windows-latest`
python-version: [3.8, 3.9, "3.10", "3.11"]
python-version: [3.9, "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -88,10 +88,10 @@ jobs:
fail-fast: true

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.10"

Expand Down
1 change: 0 additions & 1 deletion .mdformat.toml

This file was deleted.

6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ repos:
- id: isort

- repo: https://github.com/psf/black
rev: 23.12.0
rev: 24.3.0
hooks:
- id: black
name: black

- repo: https://github.com/pycqa/flake8
rev: 6.1.0
rev: 7.0.0
hooks:
- id: flake8

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.7.1
rev: v1.9.0
hooks:
- id: mypy
additional_dependencies: [types-setuptools, pydantic]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ See [EIP-712](https://eips.ethereum.org/EIPS/eip-712) for details.

## Dependencies

- [python3](https://www.python.org/downloads) version 3.8 up to 3.11.
- [python3](https://www.python.org/downloads) version 3.9 up to 3.12.

## Installation

Expand Down
2 changes: 1 addition & 1 deletion eip712/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def create_safe_tx_def(
version: str = "1.3.0",
contract_address: Optional[str] = None,
chain_id: Optional[int] = None,
) -> Type[SafeTx]:
) -> type[SafeTx]:
if not contract_address:
raise ValueError("Must define 'contract_address'")

Expand Down
9 changes: 5 additions & 4 deletions eip712/messages.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""
Message classes for typed structured data hashing and signing in Ethereum.
"""
from typing import Any, Dict, Optional

from typing import Any, Optional

from dataclassy import asdict, dataclass, fields
from eth_abi.abi import is_encodable_type # type: ignore[import-untyped]
Expand Down Expand Up @@ -45,7 +46,7 @@ def _types_(self) -> dict:
Recursively built ``dict`` (name of type ``->`` list of subtypes) of
the underlying fields' types.
"""
types: Dict[str, list] = {repr(self): []}
types: dict[str, list] = {repr(self): []}

for field in fields(self.__class__):
value = getattr(self, field)
Expand Down Expand Up @@ -157,8 +158,8 @@ def calculate_hash(msg: SignableMessage) -> HexBytes:
return HexBytes(keccak(b"".join([bytes.fromhex("19"), *msg])))


def _prepare_data_for_hashing(data: Dict) -> Dict:
result: Dict = {}
def _prepare_data_for_hashing(data: dict) -> dict:
result: dict = {}

for key, value in data.items():
item: Any = value
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ force_grid_wrap = 0
include_trailing_comma = true
multi_line_output = 3
use_parentheses = true

[tool.mdformat]
number = true
24 changes: 12 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
"hypothesis>=6.70.0,<7", # Strategy-based fuzzer
],
"lint": [
"black>=23.12.0,<24", # auto-formatter and linter
"mypy>=1.7.1,<2", # Static type analyzer
"black>=24.3.0,<25", # auto-formatter and linter
"mypy>=1.9.0,<2", # Static type analyzer
"types-setuptools", # Needed for mypy type shed
"flake8>=6.1.0,<7", # Style linter
"flake8>=7.0.0,<8", # Style linter
"isort>=5.12.0,<6", # Import sorting linter
"mdformat>=0.7.17,<0.8", # Auto-formatter for markdown
"mdformat-gfm>=0.3.5,<0.4", # Needed for formatting GitHub-flavored markdown
"mdformat-frontmatter>=0.4.1,<0.5", # Needed for headers in GH issue templates
"mdformat-pyproject>=0.0.1", # Allows configuring in pyproject.toml
],
"release": [ # `release` GitHub Action job uses this
"setuptools", # Installation tool
Expand Down Expand Up @@ -64,15 +65,14 @@
url="https://github.com/ApeWorX/eip712",
include_package_data=True,
install_requires=[
"dataclassy>=0.8.2,<1",
"eth-abi>=4.2.1,<6",
"eth-account>=0.10.0,<0.11",
"eth-hash[pycryptodome]", # NOTE: Pinned by eth-abi
"eth-typing>=3.5.2,<4",
"eth-utils>=2.3.1,<3",
"hexbytes>=0.3.0,<1",
"dataclassy>=0.11.1,<1",
"eth-abi>=5.1.0,<6",
"eth-account>=0.12.1,<0.13",
"eth-typing>=4.1.0,<5",
"eth-utils>=4.1.0,<5",
"hexbytes>=1.2.0,<2",
],
python_requires=">=3.8,<4",
python_requires=">=3.9,<4",
extras_require=extras_require,
py_modules=["eip712"],
license="Apache-2.0",
Expand All @@ -88,9 +88,9 @@
"Operating System :: MacOS",
"Operating System :: POSIX",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
],
)
4 changes: 2 additions & 2 deletions tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def test_gnosis_safe_tx(version):
msg = tx_def(to=MAINNET_MSIG_ADDRESS, nonce=0)

assert msg.signable_message.header.hex() == (
"0x88fbc465dedd7fe71b7baef26a1f46cdaadd50b95c77cbe88569195a9fe589ab"
"88fbc465dedd7fe71b7baef26a1f46cdaadd50b95c77cbe88569195a9fe589ab"
if version in ("1.3.0",)
else "0x590e9c66b22ee4584cd655fda57748ce186b85f829a092c28209478efbe86a92"
else "590e9c66b22ee4584cd655fda57748ce186b85f829a092c28209478efbe86a92"
)

assert hash_message(msg).hex() == (
Expand Down
6 changes: 3 additions & 3 deletions tests/test_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

def test_multilevel_message(valid_message_with_name_domain_field):
msg = valid_message_with_name_domain_field.signable_message
assert msg.version.hex() == "0x01"
assert msg.header.hex() == "0x336a9d2b32d1ab7ea7bbbd2565eca1910e54b74843858dec7a81f772a3c17e17"
assert msg.body.hex() == "0x306af87567fa87e55d2bd925d9a3ed2b1ec2c3e71b142785c053dc60b6ca177b"
assert msg.version.hex() == "01"
assert msg.header.hex() == "336a9d2b32d1ab7ea7bbbd2565eca1910e54b74843858dec7a81f772a3c17e17"
assert msg.body.hex() == "306af87567fa87e55d2bd925d9a3ed2b1ec2c3e71b142785c053dc60b6ca177b"


def test_invalid_message_without_domain_fields():
Expand Down

0 comments on commit 83c3358

Please sign in to comment.