Skip to content

Commit

Permalink
add support for python 3.12 & 3.13, and for web3 7
Browse files Browse the repository at this point in the history
  • Loading branch information
Elnaril committed Oct 26, 2024
1 parent a945a74 commit 44030cd
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 14 deletions.
2 changes: 1 addition & 1 deletion coverage.json

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ build-backend = "setuptools.build_meta"

[project]
name = "uniswap-universal-router-decoder"
version = "1.2.0"
version = "1.2.1.dev0"
authors = [
{ name="Elnaril", email="[email protected]" },
]
description = "Decode & Encode transaction data sent to Uniswap Universal Router"
description = "Decode & Encode transactions sent to the Uniswap Universal Router"
readme = "README.md"
requires-python = ">=3.8"
classifiers = [
Expand All @@ -21,13 +21,15 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Operating System :: OS Independent",
]
license = {text = "MIT License"}
dependencies = [
"web3>=6.0.0,<7.0.0",
"web3>=6.0.0,<8.0.0",
]
keywords = ["blockchain", "ethereum", "uniswap", "universal router", "decoder", "encoder", "codec", "wrapper", "SDK"]
keywords = ["blockchain", "ethereum", "uniswap", "exchange", "dex", "universal router", "swap", "decoder", "encoder", "codec", "wrapper", "SDK"]

[tool.setuptools]
packages = ["uniswap_universal_router_decoder"]
Expand Down
2 changes: 1 addition & 1 deletion requirements_install.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web3>=6.0.0,<7.0.0
web3>=6.0.0,<8.0.0
23 changes: 19 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[tox]
skipsdist = True
envlist = py38,py39,lint,py310,coverage,py311
envlist =
py{38,39,310,311,312,313}-web3{6,7}
lint-web3{6,7}
coverage

[flake8]
max-line-length = 120
Expand All @@ -19,16 +22,27 @@ use_parentheses = True

[testenv]
description = run tests
deps = -rrequirements.txt
deps =
web36: web3>=6.0.0,<7.0.0
web37: web3>=7.0.0,<8.0.0
pytest
commands =
python --version
pip freeze
pytest tests

[testenv:lint]
[testenv:lint-web3{6,7}]
description = run lint, type and format checks
deps = -rrequirements.txt
deps =
web36: web3>=6.0.0,<7.0.0
web37: web3>=7.0.0,<8.0.0
coverage
flake8
isort
mypy
commands =
python --version
pip freeze
mypy uniswap_universal_router_decoder
flake8 uniswap_universal_router_decoder
flake8 tests
Expand All @@ -42,6 +56,7 @@ description = run coverage and output json result
deps = -rrequirements.txt
commands =
python --version
pip freeze
coverage run -m pytest tests
coverage report -m
coverage json
10 changes: 6 additions & 4 deletions uniswap_universal_router_decoder/_abi_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ class _FunctionABI:
type: str

def get_abi(self) -> Dict[str, Any]:
return asdict(self)

def get_struct_abi(self) -> Dict[str, Any]:
result = asdict(self)
if self.type == "tuple":
result["components"] = result.pop("inputs")
result["components"] = result.pop("inputs")
return result

def get_full_abi(self) -> List[Dict[str, Any]]:
Expand Down Expand Up @@ -86,7 +88,7 @@ def create_struct(arg_name: str) -> _FunctionABIBuilder:
return _FunctionABIBuilder(arg_name, "tuple")

def add_struct(self, struct: _FunctionABIBuilder) -> _FunctionABIBuilder:
self.abi.inputs.append(struct.abi.get_abi())
self.abi.inputs.append(struct.abi.get_struct_abi())
return self

def add_bytes(self, arg_name: str) -> _FunctionABIBuilder:
Expand Down Expand Up @@ -114,7 +116,7 @@ def build_abi_map(self) -> _ABIMap:
@staticmethod
def _add_mapping(build_abi_method: Callable[[], _FunctionABI]) -> _FunctionDesc:
fct_abi = build_abi_method()
selector = function_abi_to_4byte_selector(fct_abi.get_abi())
selector = function_abi_to_4byte_selector(fct_abi.get_abi()) # type: ignore[arg-type, unused-ignore]
return _FunctionDesc(fct_abi=fct_abi, selector=selector)

@staticmethod
Expand Down

0 comments on commit 44030cd

Please sign in to comment.