Skip to content

fix(models): coerce hex-string quantities in from_dict - #78

Open
devorun wants to merge 1 commit into
tempoxyz:mainfrom
devorun:fix/from-dict-hex-quantities
Open

devorun wants to merge 1 commit into
tempoxyz:mainfrom
devorun:fix/from-dict-hex-quantities

Conversation

@devorun

@devorun devorun commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

TempoTransaction.from_dict accepts camelCase keys (chainId, maxFeePerGas, gas, value, ...), which is the Ethereum JSON-RPC convention — where quantities are hex strings (e.g. "0x64"). But it passed those values through unconverted, so parsing a standard JSON-RPC transaction dict raised TypeError: '<' not supported between instances of 'str' and 'int' during validate().

TempoTransaction.from_dict({"chainId": "0xa5bd", "gas": "0x186a0", "value": "0x64", ...})  # TypeError

This coerces quantity fields (chain_id, max_fee_per_gas, max_priority_fee_per_gas, gas_limit, nonce, nonce_key, valid_before, valid_after, and per-call value) via a small as_int helper that accepts hex strings, decimal strings, and ints. Integer and snake_case inputs are unaffected. Adds tests for both hex-string and int inputs.

@devorun

devorun commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Friendly ping on this one — it fixes a real bug: TempoTransaction.from_dict raises TypeError on JSON-RPC-style dicts with hex-string quantities (e.g. {"chainId": "0xa5bd", "value": "0x64"}), which is the standard Ethereum encoding implied by the camelCase keys it already accepts. The fix coerces the quantity fields via a small as_int helper; integer/decimal inputs are unaffected, and it adds tests for both. It's a fork PR so the Actions workflows need a maintainer to approve the run. Happy to rebase or adjust anything needed.

@devorun

devorun commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for merging #90 and #91! This one is the same class of small correctness fix — TempoTransaction.from_dict raises TypeError on JSON-RPC-style dicts with hex-string quantities (e.g. {"chainId": "0xa5bd", ...}), even though from_dict advertises camelCase/JSON-RPC keys. It's green and mergeable — would be great to land it alongside the others if it looks good. Thanks!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant