Skip to content

Commit 7942a4a

Browse files
kclowesantazoey
andauthored
fix: add chainId to txn params (#2450) (#2455)
* fix: add chainId to txn params * fix: error message on chain id hex to int * Add newsfragment Co-authored-by: kclowes <[email protected]> Co-authored-by: Juliya Smith <[email protected]>
1 parent d459417 commit 7942a4a

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
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: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,13 @@
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-
"The transaction declared chain ID %r, "
63-
"but the connected node is on %r" % (
64-
chain_id,
65-
web3_chain_id,
66-
)
63+
f"The transaction declared chain ID {chain_id_int!r}, "
64+
f"but the connected node is on {web3_chain_id!r}"
6765
)
6866

6967

0 commit comments

Comments
 (0)