-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a33039f
commit f8a63bc
Showing
4 changed files
with
200 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
# TODO enable these | ||
repos: | ||
|
||
- repo: https://github.com/mxr/sync-pre-commit-deps | ||
rev: v0.0.1 | ||
hooks: | ||
- id: sync-pre-commit-deps | ||
name: sync pre-commit dependencies | ||
|
||
# - repo: https://github.com/astral-sh/ruff-pre-commit | ||
# rev: v0.6.4 | ||
# hooks: | ||
# - id: ruff | ||
# name: lint code (ruff) | ||
# args: | ||
# - --fix | ||
# - id: ruff-format | ||
# name: format code (ruff) | ||
# | ||
# - repo: https://github.com/pre-commit/mirrors-mypy | ||
# rev: v1.10.0 | ||
# hooks: | ||
# - id: mypy | ||
# name: lint code typing (mypy) | ||
# additional_dependencies: | ||
# - pandas-stubs | ||
# - types-docutils | ||
# - types-PyYAML | ||
# - types-requests | ||
# - types-setuptools | ||
# - types-protobuf | ||
# - pydantic | ||
# - pytest | ||
# | ||
- repo: https://github.com/pdm-project/pdm | ||
rev: 2.18.1 | ||
hooks: | ||
- id: pdm-lock-check | ||
name: check pdm lock file | ||
|
||
- repo: https://github.com/adrienverge/yamllint.git | ||
rev: v1.29.0 | ||
hooks: | ||
- id: yamllint | ||
name: check yaml files (yamllint) | ||
|
||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.5.0 | ||
hooks: | ||
- id: check-ast | ||
- id: check-builtin-literals | ||
- id: check-case-conflict | ||
- id: check-docstring-first | ||
- id: check-executables-have-shebangs | ||
- id: check-merge-conflict | ||
- id: check-shebang-scripts-are-executable | ||
- id: check-symlinks | ||
- id: check-toml | ||
- id: check-json | ||
- id: check-yaml | ||
- id: check-vcs-permalinks | ||
- id: debug-statements | ||
- id: destroyed-symlinks | ||
- id: detect-private-key | ||
- id: end-of-file-fixer | ||
- id: forbid-new-submodules | ||
- id: mixed-line-ending | ||
- id: fix-byte-order-marker | ||
# - id: no-commit-to-branch TODO (temporary for development) | ||
|
||
# - repo: https://github.com/asottile/pyupgrade | ||
# rev: v3.15.2 | ||
# hooks: | ||
# - id: pyupgrade | ||
# name: upgrade to python 3.12 syntax (pyupgrade) | ||
# args: | ||
# - --py310-plus | ||
# | ||
# - repo: https://github.com/hadialqattan/pycln | ||
# rev: v2.4.0 | ||
# hooks: | ||
# - id: pycln | ||
# name: remove unused imports (pycln) | ||
# args: | ||
# - --all | ||
# - --disable-all-dunder-policy | ||
# | ||
# - repo: https://github.com/MarcoGorelli/absolufy-imports | ||
# rev: v0.3.1 | ||
# hooks: | ||
# - id: absolufy-imports | ||
# name: make imports absolute | ||
# | ||
# - repo: https://github.com/pycqa/isort | ||
# rev: 5.13.2 | ||
# hooks: | ||
# - id: isort | ||
# name: sort imports (isort) | ||
# language_version: python3 | ||
# args: | ||
# - --profile=black | ||
# | ||
# - repo: https://github.com/MarcoGorelli/auto-walrus | ||
# rev: 0.3.4 | ||
# hooks: | ||
# - id: auto-walrus | ||
# name: apply walrus operator | ||
# | ||
# - repo: https://github.com/PyCQA/bandit | ||
# rev: 1.7.8 | ||
# hooks: | ||
# - id: bandit | ||
# name: lint code security issues (bandit) | ||
# args: ["-c", "pyproject.toml"] | ||
# additional_dependencies: | ||
# - bandit[toml] | ||
# | ||
# - repo: https://github.com/codespell-project/codespell | ||
# rev: v2.2.6 | ||
# hooks: | ||
# - id: codespell | ||
# name: lint docs spelling (codespell) | ||
# additional_dependencies: | ||
# - tomli | ||
|
||
# FIXME false positive: unknown permission scope "attestations". | ||
# - repo: https://github.com/rhysd/actionlint | ||
# rev: v1.6.27 | ||
# hooks: | ||
# - id: actionlint | ||
# name: lint Github Actions workflows (actionlint) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,28 @@ | ||
from pathlib import Path | ||
from erc7730.common.pydantic import model_from_json_file_or_none | ||
from erc7730.model.erc7730_descriptor import ERC7730Descriptor | ||
from erc7730.mapper.mapper import to_eip712_mapper | ||
from erc7730.mapper.mapper import to_eip712_mapper, to_erc7730_mapper | ||
import pytest | ||
import glob | ||
|
||
files = glob.glob('clear-signing-erc7730-registry/registry/*/eip712*.json') | ||
|
||
@pytest.mark.parametrize("file", files) | ||
def roundtrip(file: str) -> None: | ||
erc7730Descriptor = model_from_json_file_or_none(Path(file), ERC7730Descriptor) | ||
assert erc7730Descriptor is not None | ||
eip712DappDescriptor = to_eip712_mapper(erc7730Descriptor) | ||
assert eip712DappDescriptor is not None | ||
newErc7730Descriptor = to_erc7730_mapper(eip712DappDescriptor) | ||
assert newErc7730Descriptor is not None | ||
assert newErc7730Descriptor == erc7730Descriptor | ||
|
||
def test_to_eip712_mapper() -> None: | ||
uniswap_eip712_cs_descriptor = model_from_json_file_or_none(Path("clear-signing-erc7730-registry/registry/uniswap/eip712-permit2.json"), ERC7730Descriptor) | ||
assert uniswap_eip712_cs_descriptor is not None | ||
eip712_mapper = to_eip712_mapper(uniswap_eip712_cs_descriptor) | ||
assert eip712_mapper is not None | ||
assert eip712_mapper.chain_id == 1 | ||
assert eip712_mapper.name == "Permit2" | ||
assert eip712_mapper.contracts.__len__() == 2 | ||
assert eip712_mapper.contracts[0].messages.__len__() == 1 | ||
eip712DappDescriptor = to_eip712_mapper(uniswap_eip712_cs_descriptor) | ||
assert eip712DappDescriptor is not None | ||
assert eip712DappDescriptor.chain_id == 1 | ||
assert eip712DappDescriptor.name == "Permit2" | ||
assert eip712DappDescriptor.contracts.__len__() == 2 | ||
assert eip712DappDescriptor.contracts[0].messages.__len__() == 1 |