Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 59 additions & 59 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/erc7730/common/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,13 @@ def ledger_network_id(chain_id: int) -> str | None:
return "poa"
case _:
return None


# From https://github.com/LedgerHQ/app-ethereum/blob/d12016b11676d80da1e0eab17703fd61bf0ce3d5/src_features/generic_tx_parser/gtp_tx_info.h#L17-L21
OPERATION_TYPE_MAX_LENGTH: int = 30
CREATOR_NAME_MAX_LENGTH: int = 22
CREATOR_LEGAL_NAME_MAX_LENGTH: int = 30
CREATOR_URL_MAX_LENGTH: int = 26
CONTRACT_NAME_MAX_LENGTH: int = 30
FIELD_NAME_MAX_LENGTH: int = 20
ENUM_MAX_LENGTH: int = 20
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def erc7730_descriptor_to_calldata_descriptors(

return convert_descriptor(input_descriptor=input_descriptor, source=source, chain_id=chain_id, out=out)

except Exception:
out.warning(f"Error processing ERC-7730 file {source}, skipping it")
except Exception as e:
out.warning(f"Error processing ERC-7730 file {source}, skipping it. Error: {e}")

return []
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
from typing import assert_never, final, override

from eip712.model.schema import EIP712Type
Expand Down Expand Up @@ -187,6 +188,16 @@ def _resolve_abis(cls, abis: list[ABI] | HttpUrl, out: OutputAdder) -> list[ABI]
match abis:
case HttpUrl() as url:
try:
# TODO: move to utility function
if match := re.match(
r"^https://api.etherscan.io/api\?module=contract&action=getabi&address=(0x[a-fA-F0-9]{40})$",
url,
):
# Convert Etherscan v1 to v2 URL
address = match.group(1)
url = HttpUrl(
f"https://api.etherscan.io/v2/api?module=contract&action=getabi&address={address}&chainid=1"
)
return client.get(url=url, model=list[ABI])
except Exception as e:
return out.error(
Expand Down
7 changes: 2 additions & 5 deletions src/erc7730/lint/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from erc7730.lint.lint_transaction_type_classifier import ClassifyTransactionTypeLinter
from erc7730.lint.lint_validate_abi import ValidateABILinter
from erc7730.lint.lint_validate_display_fields import ValidateDisplayFieldsLinter
from erc7730.lint.lint_validate_max_length import ValidateMaxLengthLinter
from erc7730.list.list import get_erc7730_files
from erc7730.model.input.descriptor import InputERC7730Descriptor

Expand Down Expand Up @@ -51,11 +52,7 @@ def lint_all(paths: list[Path], out: OutputAdder) -> int:
:return: number of files checked
"""
linter = MultiLinter(
[
ValidateABILinter(),
ValidateDisplayFieldsLinter(),
ClassifyTransactionTypeLinter(),
]
[ValidateABILinter(), ValidateDisplayFieldsLinter(), ClassifyTransactionTypeLinter(), ValidateMaxLengthLinter()]
)

files = list(get_erc7730_files(*paths, out=out))
Expand Down
Loading
Loading