Skip to content

Commit 7dc38fd

Browse files
committed
update uses of messageHash and rawTransaction from eth-account to snakecase version per eth-account v0.12.2
1 parent ebf7203 commit 7dc38fd

File tree

8 files changed

+20
-19
lines changed

8 files changed

+20
-19
lines changed

docs/examples.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ And finally, send the transaction
635635

636636
.. code-block:: python
637637
638-
txn_hash = w3.eth.send_raw_transaction(signed_tx.rawTransaction)
638+
txn_hash = w3.eth.send_raw_transaction(signed_tx.raw_transaction)
639639
txn_receipt = w3.eth.wait_for_transaction_receipt(txn_hash)
640640
641641
Tip : afterwards you can use the value stored in ``txn_hash``, in an explorer like `etherscan`_ to view the transaction's details

docs/transactions.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ if you don't opt for the middleware, you'll need to:
129129
signed = w3.eth.account.sign_transaction(transaction, pk)
130130
131131
# 3. Send the signed transaction
132-
tx_hash = w3.eth.send_raw_transaction(signed.rawTransaction)
132+
tx_hash = w3.eth.send_raw_transaction(signed.raw_transaction)
133133
tx = w3.eth.get_transaction(tx_hash)
134134
assert tx["from"] == acct2.address
135135
@@ -186,6 +186,6 @@ Executing a function on a smart contract requires sending a transaction, which i
186186
187187
# Send the raw transaction:
188188
assert billboard.functions.message().call() == "gm"
189-
tx_hash = w3.eth.send_raw_transaction(signed_tx.rawTransaction)
189+
tx_hash = w3.eth.send_raw_transaction(signed_tx.raw_transaction)
190190
w3.eth.wait_for_transaction_receipt(tx_hash)
191191
assert billboard.functions.message().call() == "gn"

docs/web3.eth.account.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ is provided by :meth:`w3.eth.sign() <web3.eth.Eth.sign>`.
214214
>>> signed_message = w3.eth.account.sign_message(message, private_key=private_key)
215215
>>> signed_message
216216
SignedMessage(messageHash=HexBytes('0x1476abb745d423bf09273f1afd887d951181d25adc66c4834a70491911b7f750'),
217+
message_hash=HexBytes('0x1476abb745d423bf09273f1afd887d951181d25adc66c4834a70491911b7f750'),
217218
r=104389933075820307925104709181714897380569894203213074526835978196648170704563,
218219
s=28205917190874851400050446352651915501321657673772411533993420917949420456142,
219220
v=28,
@@ -251,7 +252,7 @@ You might have produced the signed_message locally, as in
251252
... return Web3.to_hex(Web3.to_bytes(val).rjust(32, b'\0'))
252253

253254
>>> ec_recover_args = (msghash, v, r, s) = (
254-
... Web3.to_hex(signed_message.messageHash),
255+
... Web3.to_hex(signed_message.message_hash),
255256
... signed_message.v,
256257
... to_32byte_hex(signed_message.r),
257258
... to_32byte_hex(signed_message.s),
@@ -356,7 +357,7 @@ with :meth:`~web3.eth.Eth.send_raw_transaction`.
356357
... }
357358
>>> key = '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318'
358359
>>> signed = w3.eth.account.sign_transaction(transaction, key)
359-
>>> signed.rawTransaction
360+
>>> signed.raw_transaction
360361
HexBytes('0x02f8e20180843b9aca008477359400831e848094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080f872f85994de0b295669a9fd93d5f28d9ec85e40f4cb697baef842a00000000000000000000000000000000000000000000000000000000000000003a00000000000000000000000000000000000000000000000000000000000000007d694bb9bc244d798123fde783fcc1c72d3bb8c189413c001a0b9ec671ccee417ff79e06e9e52bfa82b37cf1145affde486006072ca7a11cf8da0484a9beea46ff6a90ac76e7bbf3718db16a8b4b09cef477fb86cf4e123d98fde')
361362
>>> signed.hash
362363
HexBytes('0xe85ce7efa52c16cb5c469c7bde54fbd4911639fdfde08003f65525a85076d915')
@@ -368,7 +369,7 @@ with :meth:`~web3.eth.Eth.send_raw_transaction`.
368369
1
369370

370371
# When you run send_raw_transaction, you get back the hash of the transaction:
371-
>>> w3.eth.send_raw_transaction(signed.rawTransaction) # doctest: +SKIP
372+
>>> w3.eth.send_raw_transaction(signed.raw_transaction) # doctest: +SKIP
372373
'0xe85ce7efa52c16cb5c469c7bde54fbd4911639fdfde08003f65525a85076d915'
373374

374375
Sign a Contract Transaction
@@ -429,7 +430,7 @@ To sign a transaction locally that will invoke a smart contract:
429430
>>> signed_txn = w3.eth.account.sign_transaction(unicorn_txn, private_key=private_key)
430431
>>> signed_txn.hash
431432
HexBytes('0x748db062639a45e519dba934fce09c367c92043867409160c9989673439dc817')
432-
>>> signed_txn.rawTransaction
433+
>>> signed_txn.raw_transaction
433434
HexBytes('0x02f8b00180843b9aca0084773594008301117094fb6916095ca1df60bb79ce92ce3ea74c37c5d35980b844a9059cbb000000000000000000000000fb6916095ca1df60bb79ce92ce3ea74c37c5d3590000000000000000000000000000000000000000000000000000000000000001c001a0cec4150e52898cf1295cc4020ac0316cbf186071e7cdc5ec44eeb7cdda05afa2a06b0b3a09c7fb0112123c0bef1fd6334853a9dcf3cb5bab3ccd1f5baae926d449')
434435
>>> signed_txn.r
435436
93522894155654168208483453926995743737629589441154283159505514235904280342434
@@ -438,8 +439,8 @@ To sign a transaction locally that will invoke a smart contract:
438439
>>> signed_txn.v
439440
1
440441

441-
>>> w3.eth.send_raw_transaction(signed_txn.rawTransaction) # doctest: +SKIP
442+
>>> w3.eth.send_raw_transaction(signed_txn.raw_transaction) # doctest: +SKIP
442443

443444
# When you run send_raw_transaction, you get the same result as the hash of the transaction:
444-
>>> w3.to_hex(w3.keccak(signed_txn.rawTransaction))
445+
>>> w3.to_hex(w3.keccak(signed_txn.raw_transaction))
445446
'0x748db062639a45e519dba934fce09c367c92043867409160c9989673439dc817'

docs/web3.eth.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ The following methods are available on the ``web3.eth`` namespace.
795795
),
796796
private_key_for_senders_account,
797797
)
798-
>>> w3.eth.send_raw_transaction(signed_txn.rawTransaction)
798+
>>> w3.eth.send_raw_transaction(signed_txn.raw_transaction)
799799
HexBytes('0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331')
800800
801801

tests/core/eth-module/test_accounts.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def test_eth_account_sign(
265265
assert signed_message == expected_hash
266266

267267
signed = acct.sign_message(message, private_key=key)
268-
assert signed.messageHash == expected_hash
268+
assert signed.message_hash == expected_hash
269269
assert signed.v == v
270270
assert signed.r == r
271271
assert signed.s == s
@@ -418,14 +418,14 @@ def test_eth_account_sign_transaction(
418418
assert signed.r == r
419419
assert signed.s == s
420420
assert signed.v == v
421-
assert signed.rawTransaction == expected_raw_tx
421+
assert signed.raw_transaction == expected_raw_tx
422422
assert signed.hash == tx_hash
423423

424424
account = acct.from_key(private_key)
425425
assert account.sign_transaction(txn) == signed
426426

427427
expected_sender = acct.from_key(private_key).address
428-
assert acct.recover_transaction(signed.rawTransaction) == expected_sender
428+
assert acct.recover_transaction(signed.raw_transaction) == expected_sender
429429

430430

431431
@pytest.mark.parametrize(
@@ -449,7 +449,7 @@ def test_eth_account_sign_transaction_from_eth_test(acct, transaction_info):
449449

450450
# confirm that signed transaction can be recovered to the sender
451451
expected_sender = acct.from_key(key).address
452-
assert acct.recover_transaction(signed.rawTransaction) == expected_sender
452+
assert acct.recover_transaction(signed.raw_transaction) == expected_sender
453453

454454

455455
@pytest.mark.parametrize(

tests/core/eth-module/test_transactions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ def test_eth_send_raw_blob_transaction(w3):
366366

367367
signed = acct.sign_transaction(tx, blobs=[blob_data])
368368

369-
tx_hash = w3.eth.send_raw_transaction(signed.rawTransaction)
369+
tx_hash = w3.eth.send_raw_transaction(signed.raw_transaction)
370370
transaction = w3.eth.get_transaction(tx_hash)
371371

372372
assert len(transaction["blobVersionedHashes"]) == 1
@@ -417,7 +417,7 @@ async def test_async_send_raw_blob_transaction(async_w3):
417417

418418
signed = acct.sign_transaction(tx, blobs=[blob_data])
419419

420-
tx_hash = await async_w3.eth.send_raw_transaction(signed.rawTransaction)
420+
tx_hash = await async_w3.eth.send_raw_transaction(signed.raw_transaction)
421421
transaction = await async_w3.eth.get_transaction(tx_hash)
422422

423423
assert len(transaction["blobVersionedHashes"]) == 1

web3/_utils/module_testing/eth_module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3648,7 +3648,7 @@ def test_eth_send_raw_transaction(
36483648
# unlocked_account private key:
36493649
"0x392f63a79b1ff8774845f3fa69de4a13800a59e7083f5187f1558f0797ad0f01",
36503650
)
3651-
txn_hash = w3.eth.send_raw_transaction(signed_tx.rawTransaction)
3651+
txn_hash = w3.eth.send_raw_transaction(signed_tx.raw_transaction)
36523652
assert txn_hash == signed_tx.hash
36533653

36543654
def test_eth_call(self, w3: "Web3", math_contract: "Contract") -> None:

web3/middleware/signing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def request_processor(self, method: "RPCEndpoint", params: Any) -> Any:
182182
return method, params
183183
else:
184184
account = self._accounts[to_checksum_address(tx_from)]
185-
raw_tx = account.sign_transaction(filled_transaction).rawTransaction
185+
raw_tx = account.sign_transaction(filled_transaction).raw_transaction
186186

187187
return (
188188
RPCEndpoint("eth_sendRawTransaction"),
@@ -211,7 +211,7 @@ async def async_request_processor(self, method: "RPCEndpoint", params: Any) -> A
211211
return method, params
212212
else:
213213
account = self._accounts[to_checksum_address(tx_from)]
214-
raw_tx = account.sign_transaction(filled_transaction).rawTransaction
214+
raw_tx = account.sign_transaction(filled_transaction).raw_transaction
215215

216216
return (
217217
RPCEndpoint("eth_sendRawTransaction"),

0 commit comments

Comments
 (0)