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

fix(models): coerce hex-string quantities in from_dict#78
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

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.

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