Skip to content

Commit be47716

Browse files
authored
Merge pull request #810 from valory-xyz/feat/web3-updates
Chore: Bump `eth-account` and `web3py`
2 parents ec2720e + 0c78364 commit be47716

14 files changed

Lines changed: 65 additions & 97 deletions

File tree

Pipfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ defusedxml = "==0.6.0"
2222
# ^ still used?
2323
docker = "==4.2.0"
2424
ecdsa = ">=0.15"
25-
eth-account = "<0.9.0,>=0.8.0"
25+
eth-account = ">=0.13.0,<0.14.0"
2626
gym = "==0.15.6"
2727
hypothesis = "==6.21.6"
2828
ipfshttpclient = "==0.8.0a2"
@@ -42,7 +42,7 @@ GitPython = "<4.0.0,>=3.1.37"
4242
requests = "==2.28.1"
4343
idna = "<=3.3"
4444
cosmpy = "==0.9.2"
45-
web3 = "<7,>=6.0.0"
45+
web3 = "<8,>=7.0.0"
4646
semver = "<3.0.0,>=2.9.1"
4747
py-multibase = ">=1.0.0"
4848
py-multicodec = ">=0.2.0"
@@ -52,7 +52,7 @@ mistune = "==2.0.3"
5252
tomte = {version = "==0.4.0", extras = ["tox", "tests"]}
5353
docspec = "==2.2.1"
5454
docspec-python = "==2.2.1"
55-
hexbytes = "==0.3.0"
55+
hexbytes = "==1.3.1"
5656
ledgerwallet = "==0.1.3"
5757
construct = "<=2.10.61"
5858
werkzeug = "*"

aea/contracts/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
# ------------------------------------------------------------------------------
33
#
4-
# Copyright 2022 Valory AG
4+
# Copyright 2022-2025 Valory AG
55
# Copyright 2018-2019 Fetch.AI Limited
66
#
77
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -333,7 +333,7 @@ def get_method_data(
333333

334334
args = [kwargs[i] for i in input_names]
335335
# Encode and return the contract call
336-
data = instance.encodeABI(fn_name=method_name, args=args)
336+
data = instance.encode_abi(abi_element_identifier=method_name, args=args)
337337
except KeyError as e: # pragma: nocover
338338
_default_logger.warning(f"No such information in method ABI:\n{e}")
339339
return None

docs/api/plugins/aea_ledger_ethereum/ethereum.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,13 +1136,3 @@ def items() -> Dict[str, Any]
11361136

11371137
Return session items.
11381138

1139-
<a id="plugins.aea-ledger-ethereum.aea_ledger_ethereum.ethereum.set_wrapper_for_web3py_session_cache"></a>
1140-
1141-
#### set`_`wrapper`_`for`_`web3py`_`session`_`cache
1142-
1143-
```python
1144-
def set_wrapper_for_web3py_session_cache() -> None
1145-
```
1146-
1147-
Wrap web3py session cache with threading.Lock.
1148-

plugins/aea-ledger-ethereum-flashbots/aea_ledger_ethereum_flashbots/ethereum_flashbots.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
# ------------------------------------------------------------------------------
33
#
4-
# Copyright 2023 Valory AG
4+
# Copyright 2023-2025 Valory AG
55
#
66
# Licensed under the Apache License, Version 2.0 (the "License");
77
# you may not use this file except in compliance with the License.
@@ -247,7 +247,9 @@ def send_bundle(
247247
default_builder_response.wait()
248248
try:
249249
receipts = default_builder_response.receipts()
250-
tx_hashes = [tx["hash"].hex() for tx in default_builder_response.bundle]
250+
tx_hashes = [
251+
tx["hash"].to_0x_hex() for tx in default_builder_response.bundle
252+
]
251253
_default_logger.debug(
252254
f"Bundle with replacement uuid {replacement_uuid} was mined in block {receipts[0]['blockNumber']}"
253255
f"Tx hashes: {tx_hashes}"

plugins/aea-ledger-ethereum-flashbots/tests/test_ethereum.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
# ------------------------------------------------------------------------------
33
#
4-
# Copyright 2023 Valory AG
4+
# Copyright 2023-2025 Valory AG
55
#
66
# Licensed under the Apache License, Version 2.0 (the "License");
77
# you may not use this file except in compliance with the License.
@@ -144,7 +144,7 @@ def test_send_bundle_with_successful_transaction(ethereum_flashbot_api) -> None:
144144
send_bundle, target_blocks[0], opts={"replacementUuid": ANY}
145145
)
146146
assert response_mock.wait.called
147-
assert tx_hashes == [tx["hash"].hex() for tx in response_mock.bundle]
147+
assert tx_hashes == [tx["hash"].to_0x_hex() for tx in response_mock.bundle]
148148

149149

150150
def test_bundle_transactions_with_empty_list(ethereum_flashbot_api) -> None:
@@ -197,7 +197,7 @@ def test_bundle_and_send_with_successful_transaction(ethereum_flashbot_api) -> N
197197
ethereum_flashbot_api.flashbots.simulate.assert_called_once()
198198
ethereum_flashbot_api.flashbots.send_bundle.assert_called_once()
199199
assert response_mock.wait.called
200-
assert tx_hashes == [tx["hash"].hex() for tx in response_mock.bundle]
200+
assert tx_hashes == [tx["hash"].to_0x_hex() for tx in response_mock.bundle]
201201

202202

203203
def test_bundle_and_send_with_failed_simulation(ethereum_flashbot_api) -> None:

plugins/aea-ledger-ethereum-hwi/aea_ledger_ethereum_hwi/account.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
# ------------------------------------------------------------------------------
33
#
4-
# Copyright 2023 Valory AG
4+
# Copyright 2023-2025 Valory AG
55
#
66
# Licensed under the Apache License, Version 2.0 (the "License");
77
# you may not use this file except in compliance with the License.
@@ -43,9 +43,9 @@
4343
encode_transaction,
4444
serializable_unsigned_transaction_from_dict,
4545
)
46-
from eth_account._utils.typed_transactions import TypedTransaction
4746
from eth_account.datastructures import HexBytes, SignedMessage, SignedTransaction
4847
from eth_account.messages import SignableMessage
48+
from eth_account.typed_transactions import TypedTransaction
4949
from eth_keys.main import PublicKey
5050
from eth_rlp import HashableRLP
5151
from eth_typing.evm import ChecksumAddress
@@ -442,7 +442,7 @@ def sign_transaction(
442442
transaction_hash = keccak(encoded_transaction)
443443

444444
return SignedTransaction(
445-
rawTransaction=HexBytes(encoded_transaction),
445+
raw_transaction=HexBytes(encoded_transaction),
446446
hash=HexBytes(transaction_hash),
447447
r=response.r,
448448
s=response.s,

plugins/aea-ledger-ethereum-hwi/aea_ledger_ethereum_hwi/hwi.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
# ------------------------------------------------------------------------------
33
#
4-
# Copyright 2023 Valory AG
4+
# Copyright 2023-2025 Valory AG
55
#
66
# Licensed under the Apache License, Version 2.0 (the "License");
77
# you may not use this file except in compliance with the License.
@@ -29,10 +29,7 @@
2929
from aea_ledger_ethereum.ethereum import (
3030
SignedTransactionTranslator as BaseSignedTransactionTranslator,
3131
)
32-
from aea_ledger_ethereum.ethereum import (
33-
TESTNET_NAME,
34-
set_wrapper_for_web3py_session_cache,
35-
)
32+
from aea_ledger_ethereum.ethereum import TESTNET_NAME
3633
from aea_ledger_ethereum_hwi.account import HWIAccount
3734
from eth_account.messages import encode_defunct
3835
from eth_account.signers.local import LocalAccount
@@ -152,14 +149,14 @@ def sign_message(self, message: bytes, is_deprecated_mode: bool = False) -> str:
152149
if is_deprecated_mode and len(message) == 32:
153150
with warnings.catch_warnings():
154151
warnings.simplefilter("ignore")
155-
signature_dict = cast(HWIAccount, self.entity).signHash(message)
156-
signed_msg = signature_dict["signature"].hex()
152+
signature_dict = cast(HWIAccount, self.entity).unsafe_sign_hash(message)
153+
signed_msg = signature_dict["signature"].to_0x_hex()
157154
else:
158155
signable_message = encode_defunct(primitive=message)
159156
signature = cast(HWIAccount, self.entity).sign_message(
160157
signable_message=signable_message
161158
)
162-
signed_msg = signature["signature"].hex()
159+
signed_msg = signature["signature"].to_0x_hex()
163160
return signed_msg
164161

165162
def sign_transaction(self, transaction: JSONLike, **kwargs: Any) -> JSONLike:
@@ -230,6 +227,3 @@ class EthereumHWIFaucetApi(EthereumFaucetApi):
230227

231228
identifier = _ETHEREUM_HWI
232229
testnet_name = TESTNET_NAME
233-
234-
235-
set_wrapper_for_web3py_session_cache()

plugins/aea-ledger-ethereum-hwi/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939
},
4040
install_requires=[
4141
"open-aea>=2.0.0, <3.0.0",
42-
"web3>=6.0.0,<7",
42+
"web3>=7.0.0,<8",
4343
"ipfshttpclient==0.8.0a2",
44-
"eth-account>=0.8.0,<0.9.0",
44+
"eth-account>=0.13.0,<0.14.0",
4545
"open-aea-ledger-ethereum~=2.0.1",
4646
"ledgerwallet==0.1.3",
4747
"protobuf<4.25.0,>=4.21.6",

plugins/aea-ledger-ethereum-hwi/tests/test_account.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
# ------------------------------------------------------------------------------
33
#
4-
# Copyright 2023 Valory AG
4+
# Copyright 2023-2025 Valory AG
55
#
66
# Licensed under the Apache License, Version 2.0 (the "License");
77
# you may not use this file except in compliance with the License.
@@ -78,7 +78,7 @@ def test_sign_transaction_legacy() -> None:
7878
), enumerate_devices_patch:
7979
signed_tx = account.sign_transaction(transaction_dict=tx)
8080

81-
assert signed_tx.rawTransaction == HexBytes(
81+
assert signed_tx.raw_transaction == HexBytes(
8282
"0x01f8658001843b9aca0082520894e81de7001292e482d4d1851ff7ed50c56093f8bb0180c080a00e14610af513df91f0ba4580bb39876b3ad201bc878a2d34f9654454222401daa00bf694eb1a2d3e5acaa05c659ee9ef82b9f82bacf5c60b0650b2d9f033e72713"
8383
)
8484
assert signed_tx.hash == HexBytes(
@@ -117,7 +117,7 @@ def test_sign_transaction_eip1559() -> None:
117117
), enumerate_devices_patch:
118118
signed_tx = account.sign_transaction(transaction_dict=tx)
119119

120-
assert signed_tx.rawTransaction == HexBytes(
120+
assert signed_tx.raw_transaction == HexBytes(
121121
"0x02f86b050784b2d05e00852794ca240082520894f33bb476529e93bb862262f6c6d8cc324741d7aa0180c080a00e14610af513df91f0ba4580bb39876b3ad201bc878a2d34f9654454222401daa00bf694eb1a2d3e5acaa05c659ee9ef82b9f82bacf5c60b0650b2d9f033e72713"
122122
)
123123
assert signed_tx.hash == HexBytes(

0 commit comments

Comments
 (0)