web3 7.0.0b3__py3-none-any.whl → 7.0.0b5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. ens/_normalization.py +1 -3
  2. ens/async_ens.py +12 -9
  3. ens/contract_data.py +2 -2
  4. ens/ens.py +8 -5
  5. ens/exceptions.py +19 -27
  6. ens/specs/nf.json +1 -1
  7. ens/specs/normalization_spec.json +1 -1
  8. ens/utils.py +17 -10
  9. web3/__init__.py +2 -7
  10. web3/_utils/abi.py +30 -29
  11. web3/_utils/async_transactions.py +7 -4
  12. web3/_utils/blocks.py +6 -2
  13. web3/_utils/caching.py +7 -3
  14. web3/_utils/compat/__init__.py +0 -3
  15. web3/_utils/contract_sources/compile_contracts.py +1 -1
  16. web3/_utils/contracts.py +17 -17
  17. web3/_utils/datatypes.py +5 -1
  18. web3/_utils/decorators.py +6 -1
  19. web3/_utils/empty.py +1 -1
  20. web3/_utils/encoding.py +15 -10
  21. web3/_utils/error_formatters_utils.py +5 -3
  22. web3/_utils/events.py +38 -36
  23. web3/_utils/fee_utils.py +2 -4
  24. web3/_utils/filters.py +23 -18
  25. web3/_utils/formatters.py +2 -2
  26. web3/_utils/math.py +3 -2
  27. web3/_utils/method_formatters.py +24 -28
  28. web3/_utils/module.py +2 -1
  29. web3/_utils/module_testing/__init__.py +0 -3
  30. web3/_utils/module_testing/eth_module.py +494 -432
  31. web3/_utils/module_testing/module_testing_utils.py +1 -3
  32. web3/_utils/module_testing/utils.py +14 -7
  33. web3/_utils/normalizers.py +3 -3
  34. web3/_utils/request.py +4 -4
  35. web3/_utils/rpc_abi.py +5 -19
  36. web3/_utils/threads.py +8 -7
  37. web3/_utils/transactions.py +14 -12
  38. web3/_utils/type_conversion.py +5 -1
  39. web3/_utils/validation.py +12 -10
  40. web3/contract/async_contract.py +23 -18
  41. web3/contract/base_contract.py +69 -74
  42. web3/contract/contract.py +25 -19
  43. web3/contract/utils.py +11 -6
  44. web3/datastructures.py +22 -12
  45. web3/eth/async_eth.py +38 -32
  46. web3/eth/base_eth.py +7 -3
  47. web3/eth/eth.py +20 -15
  48. web3/exceptions.py +83 -78
  49. web3/gas_strategies/time_based.py +2 -4
  50. web3/geth.py +1 -191
  51. web3/main.py +6 -6
  52. web3/manager.py +128 -68
  53. web3/method.py +13 -5
  54. web3/middleware/base.py +4 -2
  55. web3/middleware/filter.py +45 -23
  56. web3/middleware/formatting.py +6 -3
  57. web3/middleware/names.py +4 -1
  58. web3/middleware/signing.py +8 -4
  59. web3/middleware/stalecheck.py +2 -1
  60. web3/providers/eth_tester/defaults.py +1 -49
  61. web3/providers/eth_tester/main.py +41 -15
  62. web3/providers/eth_tester/middleware.py +13 -9
  63. web3/providers/ipc.py +7 -3
  64. web3/providers/persistent/async_ipc.py +6 -7
  65. web3/providers/persistent/persistent.py +11 -1
  66. web3/providers/persistent/request_processor.py +7 -7
  67. web3/providers/persistent/websocket.py +3 -3
  68. web3/providers/rpc/async_rpc.py +24 -7
  69. web3/providers/rpc/rpc.py +30 -17
  70. web3/providers/rpc/utils.py +1 -10
  71. web3/testing.py +4 -4
  72. web3/tools/benchmark/main.py +13 -9
  73. web3/tools/benchmark/node.py +2 -8
  74. web3/tools/benchmark/utils.py +1 -1
  75. web3/tracing.py +9 -5
  76. web3/types.py +20 -23
  77. {web3-7.0.0b3.dist-info → web3-7.0.0b5.dist-info}/METADATA +13 -28
  78. {web3-7.0.0b3.dist-info → web3-7.0.0b5.dist-info}/RECORD +81 -82
  79. web3/_utils/module_testing/go_ethereum_personal_module.py +0 -300
  80. {web3-7.0.0b3.dist-info → web3-7.0.0b5.dist-info}/LICENSE +0 -0
  81. {web3-7.0.0b3.dist-info → web3-7.0.0b5.dist-info}/WHEEL +0 -0
  82. {web3-7.0.0b3.dist-info → web3-7.0.0b5.dist-info}/top_level.txt +0 -0
@@ -1,300 +0,0 @@
1
- import json
2
- import pytest
3
- from typing import (
4
- TYPE_CHECKING,
5
- cast,
6
- )
7
-
8
- from eth_typing import (
9
- ChecksumAddress,
10
- )
11
- from eth_utils import (
12
- is_checksum_address,
13
- is_list_like,
14
- is_same_address,
15
- is_string,
16
- )
17
- from hexbytes import (
18
- HexBytes,
19
- )
20
-
21
- from web3 import (
22
- constants,
23
- )
24
- from web3.datastructures import (
25
- AttributeDict,
26
- )
27
- from web3.types import (
28
- TxParams,
29
- Wei,
30
- )
31
-
32
- if TYPE_CHECKING:
33
- from web3 import ( # noqa: F401
34
- AsyncWeb3,
35
- Web3,
36
- )
37
-
38
- PRIVATE_KEY_HEX = "0x56ebb41875ceedd42e395f730e03b5c44989393c9f0484ee6bc05f933673458f"
39
- SECOND_PRIVATE_KEY_HEX = (
40
- "0x56ebb41875ceedd42e395f730e03b5c44989393c9f0484ee6bc05f9336712345"
41
- )
42
- THIRD_PRIVATE_KEY_HEX = (
43
- "0x56ebb41875ceedd42e395f730e03b5c44989393c9f0484ee6bc05f9336754321"
44
- )
45
- PASSWORD = "web3-testing"
46
- ADDRESS = "0x844B417c0C58B02c2224306047B9fb0D3264fE8c"
47
- SECOND_ADDRESS = "0xB96b6B21053e67BA59907E252D990C71742c41B8"
48
-
49
-
50
- PRIVATE_KEY_FOR_UNLOCK = (
51
- "0x392f63a79b1ff8774845f3fa69de4a13800a59e7083f5187f1558f0797ad0f01"
52
- )
53
- ACCOUNT_FOR_UNLOCK = "0x12efDc31B1a8FA1A1e756DFD8A1601055C971E13"
54
-
55
-
56
- class GoEthereumPersonalModuleTest:
57
- def test_personal_import_raw_key(self, w3: "Web3") -> None:
58
- actual = w3.geth.personal.import_raw_key(PRIVATE_KEY_HEX, PASSWORD)
59
- assert actual == ADDRESS
60
-
61
- def test_personal_list_accounts(self, w3: "Web3") -> None:
62
- accounts = w3.geth.personal.list_accounts()
63
- assert is_list_like(accounts)
64
- assert len(accounts) > 0
65
- assert all((is_checksum_address(item) for item in accounts))
66
-
67
- def test_personal_list_wallets(self, w3: "Web3") -> None:
68
- wallets = w3.geth.personal.list_wallets()
69
- assert is_list_like(wallets)
70
- assert len(wallets) > 0
71
- assert is_checksum_address(wallets[0]["accounts"][0]["address"])
72
- assert is_string(wallets[0]["accounts"][0]["url"])
73
- assert is_string(wallets[0]["status"])
74
- assert is_string(wallets[0]["url"])
75
-
76
- def test_personal_lock_account(
77
- self, w3: "Web3", unlockable_account_dual_type: ChecksumAddress
78
- ) -> None:
79
- # TODO: how do we test this better?
80
- w3.geth.personal.lock_account(unlockable_account_dual_type)
81
-
82
- def test_personal_unlock_account_success(
83
- self,
84
- w3: "Web3",
85
- unlockable_account_dual_type: ChecksumAddress,
86
- unlockable_account_pw: str,
87
- ) -> None:
88
- result = w3.geth.personal.unlock_account(
89
- unlockable_account_dual_type, unlockable_account_pw
90
- )
91
- assert result is True
92
-
93
- def test_personal_unlock_account_failure(
94
- self, w3: "Web3", unlockable_account_dual_type: ChecksumAddress
95
- ) -> None:
96
- with pytest.raises(ValueError):
97
- w3.geth.personal.unlock_account(
98
- unlockable_account_dual_type, "bad-password"
99
- )
100
-
101
- def test_personal_new_account(self, w3: "Web3") -> None:
102
- new_account = w3.geth.personal.new_account(PASSWORD)
103
- assert is_checksum_address(new_account)
104
-
105
- def test_personal_send_transaction(
106
- self,
107
- w3: "Web3",
108
- unlockable_account_dual_type: ChecksumAddress,
109
- unlockable_account_pw: str,
110
- ) -> None:
111
- assert (
112
- w3.eth.get_balance(unlockable_account_dual_type) > constants.WEI_PER_ETHER
113
- )
114
- txn_params: TxParams = {
115
- "from": unlockable_account_dual_type,
116
- "to": unlockable_account_dual_type,
117
- "gas": 21000,
118
- "value": Wei(1),
119
- "gasPrice": w3.to_wei(1, "gwei"),
120
- }
121
- txn_hash = w3.geth.personal.send_transaction(txn_params, unlockable_account_pw)
122
- assert txn_hash
123
- transaction = w3.eth.get_transaction(txn_hash)
124
-
125
- assert is_same_address(
126
- transaction["from"], cast(ChecksumAddress, txn_params["from"])
127
- )
128
- assert is_same_address(
129
- transaction["to"], cast(ChecksumAddress, txn_params["to"])
130
- )
131
- assert transaction["gas"] == txn_params["gas"]
132
- assert transaction["value"] == txn_params["value"]
133
- assert transaction["gasPrice"] == txn_params["gasPrice"]
134
-
135
- def test_personal_sign_and_ecrecover(
136
- self,
137
- w3: "Web3",
138
- unlockable_account_dual_type: ChecksumAddress,
139
- unlockable_account_pw: str,
140
- ) -> None:
141
- message = "test-web3-geth-personal-sign"
142
- signature = w3.geth.personal.sign(
143
- message, unlockable_account_dual_type, unlockable_account_pw
144
- )
145
- signer = w3.geth.personal.ec_recover(message, signature)
146
- assert is_same_address(signer, unlockable_account_dual_type)
147
-
148
- @pytest.mark.xfail(
149
- reason="personal_sign_typed_data JSON RPC call has not been released in geth"
150
- )
151
- def test_personal_sign_typed_data(
152
- self,
153
- w3: "Web3",
154
- unlockable_account_dual_type: ChecksumAddress,
155
- unlockable_account_pw: str,
156
- ) -> None:
157
- typed_message = """
158
- {
159
- "types": {
160
- "EIP712Domain": [
161
- {"name": "name", "type": "string"},
162
- {"name": "version", "type": "string"},
163
- {"name": "chainId", "type": "uint256"},
164
- {"name": "verifyingContract", "type": "address"}
165
- ],
166
- "Person": [
167
- {"name": "name", "type": "string"},
168
- {"name": "wallet", "type": "address"}
169
- ],
170
- "Mail": [
171
- {"name": "from", "type": "Person"},
172
- {"name": "to", "type": "Person"},
173
- {"name": "contents", "type": "string"}
174
- ]
175
- },
176
- "primaryType": "Mail",
177
- "domain": {
178
- "name": "Ether Mail",
179
- "version": "1",
180
- "chainId": "0x01",
181
- "verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"
182
- },
183
- "message": {
184
- "from": {
185
- "name": "Cow",
186
- "wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826"
187
- },
188
- "to": {
189
- "name": "Bob",
190
- "wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB"
191
- },
192
- "contents": "Hello, Bob!"
193
- }
194
- }
195
- """
196
- signature = HexBytes(
197
- w3.geth.personal.sign_typed_data(
198
- json.loads(typed_message),
199
- unlockable_account_dual_type,
200
- unlockable_account_pw,
201
- )
202
- )
203
-
204
- expected_signature = HexBytes(
205
- "0xc8b56aaeefd10ab4005c2455daf28d9082af661ac347cd"
206
- "b612d5b5e11f339f2055be831bf57a6e6cb5f6d93448fa35"
207
- "c1bd56fe1d745ffa101e74697108668c401c"
208
- )
209
- assert signature == expected_signature
210
- assert len(signature) == 32 + 32 + 1
211
-
212
-
213
- class GoEthereumAsyncPersonalModuleTest:
214
- @pytest.mark.asyncio
215
- async def test_async_sign_and_ec_recover(
216
- self,
217
- async_w3: "AsyncWeb3",
218
- async_unlockable_account_dual_type: ChecksumAddress,
219
- unlockable_account_pw: str,
220
- ) -> None:
221
- message = "This is a test"
222
- signature = await async_w3.geth.personal.sign(
223
- message, async_unlockable_account_dual_type, unlockable_account_pw
224
- )
225
- address = await async_w3.geth.personal.ec_recover(message, signature)
226
- assert is_same_address(async_unlockable_account_dual_type, address)
227
-
228
- @pytest.mark.asyncio
229
- async def test_async_import_key(self, async_w3: "AsyncWeb3") -> None:
230
- address = await async_w3.geth.personal.import_raw_key(
231
- THIRD_PRIVATE_KEY_HEX, "Testing"
232
- )
233
- assert address is not None
234
-
235
- @pytest.mark.asyncio
236
- async def test_async_list_accounts(self, async_w3: "AsyncWeb3") -> None:
237
- accounts = await async_w3.geth.personal.list_accounts()
238
- assert len(accounts) > 0
239
-
240
- @pytest.mark.asyncio
241
- async def test_async_list_wallets(self, async_w3: "AsyncWeb3") -> None:
242
- wallets = await async_w3.geth.personal.list_wallets()
243
- assert isinstance(wallets[0], AttributeDict)
244
-
245
- @pytest.mark.asyncio
246
- async def test_async_new_account(self, async_w3: "AsyncWeb3") -> None:
247
- passphrase = "Create New Account"
248
- account = await async_w3.geth.personal.new_account(passphrase)
249
- assert is_checksum_address(account)
250
-
251
- @pytest.mark.asyncio
252
- async def test_async_unlock_lock_account(
253
- self,
254
- async_w3: "AsyncWeb3",
255
- async_unlockable_account_dual_type: ChecksumAddress,
256
- unlockable_account_pw: str,
257
- ) -> None:
258
- unlocked = await async_w3.geth.personal.unlock_account(
259
- async_unlockable_account_dual_type, unlockable_account_pw
260
- )
261
- assert unlocked is True
262
- locked = await async_w3.geth.personal.lock_account(
263
- async_unlockable_account_dual_type
264
- )
265
- assert locked is True
266
-
267
- @pytest.mark.asyncio
268
- async def test_async_send_transaction(
269
- self,
270
- async_w3: "AsyncWeb3",
271
- async_unlockable_account_dual_type: ChecksumAddress,
272
- unlockable_account_pw: str,
273
- ) -> None:
274
- tx_params = TxParams()
275
- tx_params["to"] = async_unlockable_account_dual_type
276
- tx_params["from"] = async_unlockable_account_dual_type
277
- tx_params["value"] = Wei(123)
278
- response = await async_w3.geth.personal.send_transaction(
279
- tx_params, unlockable_account_pw
280
- )
281
- assert response is not None
282
-
283
- @pytest.mark.xfail(
284
- reason="personal_signTypedData JSON RPC call has not been released in geth"
285
- )
286
- @pytest.mark.asyncio
287
- async def test_async_sign_typed_data(
288
- self,
289
- async_w3: "AsyncWeb3",
290
- async_unlockable_account_dual_type: ChecksumAddress,
291
- unlockable_account_pw: str,
292
- ) -> None:
293
- message = {"message": "This is a test"}
294
- signature = await async_w3.geth.personal.sign_typed_data(
295
- message, async_unlockable_account_dual_type, unlockable_account_pw
296
- )
297
- address = await async_w3.geth.personal.ec_recover(
298
- json.dumps(message), signature
299
- )
300
- assert is_same_address(async_unlockable_account_dual_type, address)
File without changes