Skip to content

Commit 6e2cae1

Browse files
antazoeykclowes
authored and
pacrob
committed
fix: add chainId to txn params (#2450)
* fix: add chainId to txn params * fix: error message on chain id hex to int * Add newsfragment Co-authored-by: kclowes <[email protected]>
1 parent c90dece commit 6e2cae1

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

newsfragments/2450.misc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add ``chainId`` to tx params to ``TRANSACTION_PARAMS_ABI``

web3/_utils/rpc_abi.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ class RPC:
163163
'nonce': 'uint',
164164
'to': 'address',
165165
'value': 'uint',
166+
'chainId': 'uint',
166167
}
167168

168169
FILTER_PARAMS_ABIS = {

web3/middleware/validation.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,12 @@
5555

5656
@curry
5757
def _validate_chain_id(web3_chain_id: int, chain_id: int) -> int:
58-
if to_integer_if_hex(chain_id) == web3_chain_id:
58+
chain_id_int = to_integer_if_hex(chain_id)
59+
if chain_id_int == web3_chain_id:
5960
return chain_id
6061
else:
6162
raise ValidationError(
62-
f"The transaction declared chain ID {chain_id!r}, "
63+
f"The transaction declared chain ID {chain_id_int!r}, "
6364
f"but the connected node is on {web3_chain_id!r}"
6465
)
6566

0 commit comments

Comments
 (0)