Skip to content

Commit

Permalink
Fix tuple list parsing (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
kigawas authored Jun 20, 2024
1 parent 5cd5075 commit 78f40fb
Show file tree
Hide file tree
Showing 8 changed files with 207 additions and 198 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- run: pipx install poetry

- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "poetry"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- run: pipx install poetry

- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"

- run: brew install automake
if: matrix.os == 'macos-latest'

- run: poetry install
- run: poetry install --with test

- name: Run test
run: poetry run pytest -s --cov=web3_input_decoder tests --cov-report xml
Expand Down
3 changes: 1 addition & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
repos:

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.3
rev: v0.4.9
hooks:
- id: ruff
args: [--fix]
Expand Down
371 changes: 187 additions & 184 deletions poetry.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "web3-input-decoder"
version = "0.1.11"
version = "0.1.12"
# doc
authors = ["Weiliang Li <[email protected]>"]
description = "A simple offline web3 transaction input decoder for functions and constructors"
Expand All @@ -27,7 +27,7 @@ include = ["web3_input_decoder/py.typed"]
python = "^3.8"

# 3rd party
eth-abi = "^4.2.1"
eth-abi = "^5.1.0"
eth-utils = "^4.0.0"
pycryptodome = "^3.17.0"

Expand All @@ -39,7 +39,7 @@ ruff = ">=0.3.5,<0.5.0"
# stubs
eth-typing = "^4.0.0"

# test
[tool.poetry.group.test.dependencies]
pyinstrument = "^4.5.0"
pytest = "^8.1.0"
pytest-cov = "^5.0.0"
Expand Down
11 changes: 8 additions & 3 deletions tests/data/nft.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
)
SEAPORT_FULFILL_ORDER_CALL_ARGUMENT = [
(
"(address,uint256,uint256,address,address,address,uint256,uint256,uint8,uint256,uint256,bytes32,uint256,bytes32,bytes32,uint256,(uint256,address),bytes)",
"(address,uint256,uint256,address,address,address,uint256,uint256,uint8,uint256,uint256,bytes32,uint256,bytes32,bytes32,uint256,(uint256,address)[],bytes)",
"parameters",
(
"0x0000000000000000000000000000000000000000",
Expand All @@ -137,8 +137,13 @@
b"\x00\x00\x00{\x02#\x00\x91\xa7\xed\x01#\x00r\xf7\x00j\x00M`\xa8\xd4\xe7\x1dY\x9b\x81\x04%\x0f\x00\x00",
b"\x00\x00\x00{\x02#\x00\x91\xa7\xed\x01#\x00r\xf7\x00j\x00M`\xa8\xd4\xe7\x1dY\x9b\x81\x04%\x0f\x00\x00",
2,
(576, "0x00000000000000000000000000000000000002e0"),
b"",
(
(1800000000000000000, "0x0000a26b00c1f0df003000390027140000faa719"),
(1800000000000000000, "0xa858ddc0445d8131dac4d1de01f834ffcba52ef1"),
),
bytes.fromhex(
"046bd0fda5b934a96ef4700da1b64e03e7451e6a6ee45a5004b93823ff3baae34b9f1c4f667781b5fedd27dc67339d4fd3e4ae2a873b315090e6312853732f9a1c"
),
),
)
]
2 changes: 1 addition & 1 deletion web3_input_decoder/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def decode(cls, func_name: str, inputs: List[Input], func_args: bytes):
try:
types, names, values = decode_input(inputs, func_args)
return cls(func_name, list(zip(types, names, values)))
except OverflowError:
except (DecodingError, OverflowError):
raise INVALID_INPUT


Expand Down
2 changes: 2 additions & 0 deletions web3_input_decoder/utils/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ def __expand_tuple_types(input: Input) -> str:
for comp in input["components"]:
if "components" not in comp:
types.append(comp["type"])
elif comp["type"] == "tuple[]":
types.append(f"{__expand_tuple_types(comp)}[]")
else:
types.append(__expand_tuple_types(comp))
types_str = ",".join(types)
Expand Down

0 comments on commit 78f40fb

Please sign in to comment.