web3 7.14.0__py3-none-any.whl → 8.0.0b1__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.
- ens/_normalization.py +23 -29
- ens/async_ens.py +30 -24
- ens/base_ens.py +2 -3
- ens/ens.py +18 -20
- ens/utils.py +6 -10
- web3/__init__.py +0 -4
- web3/_utils/abi.py +38 -40
- web3/_utils/async_transactions.py +6 -9
- web3/_utils/batching.py +11 -15
- web3/_utils/blocks.py +1 -2
- web3/_utils/caching/caching_utils.py +12 -17
- web3/_utils/caching/request_caching_validation.py +7 -9
- web3/_utils/compat/__init__.py +2 -2
- web3/_utils/contract_sources/compile_contracts.py +4 -6
- web3/_utils/contracts.py +25 -29
- web3/_utils/datatypes.py +6 -10
- web3/_utils/decorators.py +1 -3
- web3/_utils/encoding.py +10 -14
- web3/_utils/ens.py +4 -5
- web3/_utils/events.py +19 -24
- web3/_utils/filters.py +23 -29
- web3/_utils/formatters.py +8 -13
- web3/_utils/http_session_manager.py +11 -15
- web3/_utils/math.py +1 -2
- web3/_utils/method_formatters.py +41 -43
- web3/_utils/module.py +3 -6
- web3/_utils/module_testing/eth_module.py +7 -9
- web3/_utils/module_testing/go_ethereum_admin_module.py +1 -2
- web3/_utils/module_testing/module_testing_utils.py +9 -5
- web3/_utils/module_testing/persistent_connection_provider.py +3 -7
- web3/_utils/module_testing/utils.py +32 -21
- web3/_utils/normalizers.py +21 -24
- web3/_utils/rpc_abi.py +8 -11
- web3/_utils/threads.py +3 -4
- web3/_utils/transactions.py +3 -6
- web3/_utils/type_conversion.py +2 -6
- web3/_utils/utility_methods.py +5 -7
- web3/_utils/validation.py +6 -8
- web3/_utils/windows.py +1 -4
- web3/beacon/async_beacon.py +51 -55
- web3/beacon/beacon.py +50 -54
- web3/contract/async_contract.py +38 -46
- web3/contract/base_contract.py +70 -75
- web3/contract/contract.py +39 -43
- web3/contract/utils.py +47 -51
- web3/datastructures.py +10 -15
- web3/eth/async_eth.py +64 -70
- web3/eth/base_eth.py +40 -44
- web3/eth/eth.py +50 -66
- web3/exceptions.py +8 -13
- web3/gas_strategies/rpc.py +1 -7
- web3/gas_strategies/time_based.py +2 -3
- web3/geth.py +17 -17
- web3/main.py +43 -52
- web3/manager.py +32 -35
- web3/method.py +22 -29
- web3/middleware/base.py +5 -8
- web3/middleware/filter.py +41 -46
- web3/middleware/formatting.py +5 -6
- web3/middleware/names.py +1 -3
- web3/middleware/signing.py +3 -4
- web3/middleware/stalecheck.py +1 -2
- web3/middleware/validation.py +1 -2
- web3/module.py +11 -14
- web3/providers/__init__.py +0 -4
- web3/providers/async_base.py +21 -27
- web3/providers/auto.py +9 -20
- web3/providers/base.py +12 -17
- web3/providers/eth_tester/defaults.py +4 -8
- web3/providers/eth_tester/main.py +4 -8
- web3/providers/eth_tester/middleware.py +2 -4
- web3/providers/ipc.py +6 -10
- web3/providers/persistent/async_ipc.py +4 -7
- web3/providers/persistent/persistent.py +22 -25
- web3/providers/persistent/persistent_connection.py +2 -4
- web3/providers/persistent/request_processor.py +11 -32
- web3/providers/persistent/subscription_container.py +5 -8
- web3/providers/persistent/subscription_manager.py +13 -19
- web3/providers/persistent/websocket.py +15 -12
- web3/providers/rpc/async_rpc.py +10 -16
- web3/providers/rpc/rpc.py +11 -17
- web3/providers/rpc/utils.py +2 -3
- web3/scripts/release/test_package.py +1 -4
- web3/testing.py +1 -5
- web3/tracing.py +9 -13
- web3/types.py +49 -56
- web3/utils/abi.py +28 -33
- web3/utils/async_exception_handling.py +1 -2
- web3/utils/caching.py +6 -10
- web3/utils/exception_handling.py +1 -2
- web3/utils/subscriptions.py +30 -34
- {web3-7.14.0.dist-info → web3-8.0.0b1.dist-info}/METADATA +13 -12
- web3-8.0.0b1.dist-info/RECORD +170 -0
- web3/providers/legacy_websocket.py +0 -159
- web3-7.14.0.dist-info/RECORD +0 -171
- {web3-7.14.0.dist-info → web3-8.0.0b1.dist-info}/WHEEL +0 -0
- {web3-7.14.0.dist-info → web3-8.0.0b1.dist-info}/licenses/LICENSE +0 -0
- {web3-7.14.0.dist-info → web3-8.0.0b1.dist-info}/top_level.txt +0 -0
web3/contract/async_contract.py
CHANGED
|
@@ -3,12 +3,8 @@ from typing import (
|
|
|
3
3
|
Any,
|
|
4
4
|
Awaitable,
|
|
5
5
|
Callable,
|
|
6
|
-
Dict,
|
|
7
6
|
Iterable,
|
|
8
|
-
List,
|
|
9
|
-
Optional,
|
|
10
7
|
Sequence,
|
|
11
|
-
Type,
|
|
12
8
|
cast,
|
|
13
9
|
)
|
|
14
10
|
|
|
@@ -108,10 +104,10 @@ class AsyncContractEvent(BaseContractEvent):
|
|
|
108
104
|
@combomethod
|
|
109
105
|
async def get_logs(
|
|
110
106
|
self,
|
|
111
|
-
argument_filters:
|
|
112
|
-
from_block:
|
|
113
|
-
to_block:
|
|
114
|
-
block_hash:
|
|
107
|
+
argument_filters: dict[str, Any] | None = None,
|
|
108
|
+
from_block: BlockIdentifier | None = None,
|
|
109
|
+
to_block: BlockIdentifier | None = None,
|
|
110
|
+
block_hash: HexBytes | None = None,
|
|
115
111
|
) -> Awaitable[Iterable[EventData]]:
|
|
116
112
|
"""
|
|
117
113
|
Get events for this contract instance using eth_getLogs API.
|
|
@@ -201,11 +197,11 @@ class AsyncContractEvent(BaseContractEvent):
|
|
|
201
197
|
async def create_filter(
|
|
202
198
|
self,
|
|
203
199
|
*, # PEP 3102
|
|
204
|
-
argument_filters:
|
|
205
|
-
from_block:
|
|
200
|
+
argument_filters: dict[str, Any] | None = None,
|
|
201
|
+
from_block: BlockIdentifier | None = None,
|
|
206
202
|
to_block: BlockIdentifier = "latest",
|
|
207
|
-
address:
|
|
208
|
-
topics:
|
|
203
|
+
address: ChecksumAddress | None = None,
|
|
204
|
+
topics: Sequence[Any] | None = None,
|
|
209
205
|
) -> AsyncLogFilter:
|
|
210
206
|
"""
|
|
211
207
|
Create filter object that tracks logs emitted by this contract event.
|
|
@@ -238,7 +234,7 @@ class AsyncContractEvent(BaseContractEvent):
|
|
|
238
234
|
|
|
239
235
|
class AsyncContractEvents(BaseContractEvents[AsyncContractEvent]):
|
|
240
236
|
def __init__(
|
|
241
|
-
self, abi: ABI, w3: "AsyncWeb3[Any]", address:
|
|
237
|
+
self, abi: ABI, w3: "AsyncWeb3[Any]", address: ChecksumAddress | None = None
|
|
242
238
|
) -> None:
|
|
243
239
|
super().__init__(abi, w3, AsyncContractEvent, address)
|
|
244
240
|
|
|
@@ -249,10 +245,10 @@ class AsyncContractFunction(BaseContractFunction):
|
|
|
249
245
|
|
|
250
246
|
async def call(
|
|
251
247
|
self,
|
|
252
|
-
transaction:
|
|
248
|
+
transaction: TxParams | None = None,
|
|
253
249
|
block_identifier: BlockIdentifier = None,
|
|
254
|
-
state_override:
|
|
255
|
-
ccip_read_enabled:
|
|
250
|
+
state_override: StateOverride | None = None,
|
|
251
|
+
ccip_read_enabled: bool | None = None,
|
|
256
252
|
) -> Any:
|
|
257
253
|
"""
|
|
258
254
|
Execute a contract function call using the `eth_call` interface.
|
|
@@ -303,7 +299,7 @@ class AsyncContractFunction(BaseContractFunction):
|
|
|
303
299
|
**self.kwargs or {},
|
|
304
300
|
)
|
|
305
301
|
|
|
306
|
-
async def transact(self, transaction:
|
|
302
|
+
async def transact(self, transaction: TxParams | None = None) -> HexBytes:
|
|
307
303
|
setup_transaction = self._transact(transaction)
|
|
308
304
|
abi_element_identifier = abi_to_signature(self.abi)
|
|
309
305
|
return await async_transact_with_contract_function(
|
|
@@ -319,9 +315,9 @@ class AsyncContractFunction(BaseContractFunction):
|
|
|
319
315
|
|
|
320
316
|
async def estimate_gas(
|
|
321
317
|
self,
|
|
322
|
-
transaction:
|
|
323
|
-
block_identifier:
|
|
324
|
-
state_override:
|
|
318
|
+
transaction: TxParams | None = None,
|
|
319
|
+
block_identifier: BlockIdentifier | None = None,
|
|
320
|
+
state_override: StateOverride | None = None,
|
|
325
321
|
) -> int:
|
|
326
322
|
setup_transaction = self._estimate_gas(transaction)
|
|
327
323
|
abi_element_identifier = abi_to_signature(self.abi)
|
|
@@ -338,9 +334,7 @@ class AsyncContractFunction(BaseContractFunction):
|
|
|
338
334
|
**self.kwargs or {},
|
|
339
335
|
)
|
|
340
336
|
|
|
341
|
-
async def build_transaction(
|
|
342
|
-
self, transaction: Optional[TxParams] = None
|
|
343
|
-
) -> TxParams:
|
|
337
|
+
async def build_transaction(self, transaction: TxParams | None = None) -> TxParams:
|
|
344
338
|
built_transaction = self._build_transaction(transaction)
|
|
345
339
|
abi_element_identifier = abi_to_signature(self.abi)
|
|
346
340
|
return await async_build_transaction_for_function(
|
|
@@ -358,7 +352,7 @@ class AsyncContractFunction(BaseContractFunction):
|
|
|
358
352
|
def get_fallback_function(
|
|
359
353
|
abi: ABI,
|
|
360
354
|
async_w3: "AsyncWeb3[Any]",
|
|
361
|
-
address:
|
|
355
|
+
address: ChecksumAddress | None = None,
|
|
362
356
|
) -> "AsyncContractFunction":
|
|
363
357
|
if abi and fallback_func_abi_exists(abi):
|
|
364
358
|
return AsyncContractFunction.factory(
|
|
@@ -374,7 +368,7 @@ class AsyncContractFunction(BaseContractFunction):
|
|
|
374
368
|
def get_receive_function(
|
|
375
369
|
abi: ABI,
|
|
376
370
|
async_w3: "AsyncWeb3[Any]",
|
|
377
|
-
address:
|
|
371
|
+
address: ChecksumAddress | None = None,
|
|
378
372
|
) -> "AsyncContractFunction":
|
|
379
373
|
if abi and receive_func_abi_exists(abi):
|
|
380
374
|
return AsyncContractFunction.factory(
|
|
@@ -392,8 +386,8 @@ class AsyncContractFunctions(BaseContractFunctions[AsyncContractFunction]):
|
|
|
392
386
|
self,
|
|
393
387
|
abi: ABI,
|
|
394
388
|
w3: "AsyncWeb3[Any]",
|
|
395
|
-
address:
|
|
396
|
-
decode_tuples:
|
|
389
|
+
address: ChecksumAddress | None = None,
|
|
390
|
+
decode_tuples: bool | None = False,
|
|
397
391
|
) -> None:
|
|
398
392
|
super().__init__(abi, w3, AsyncContractFunction, address, decode_tuples)
|
|
399
393
|
|
|
@@ -408,7 +402,7 @@ class AsyncContract(BaseContract):
|
|
|
408
402
|
#: Instance of :class:`ContractEvents` presenting available Event ABIs
|
|
409
403
|
events: AsyncContractEvents = None
|
|
410
404
|
|
|
411
|
-
def __init__(self, address:
|
|
405
|
+
def __init__(self, address: ChecksumAddress | None = None) -> None:
|
|
412
406
|
"""
|
|
413
407
|
Create a new smart contract proxy object.
|
|
414
408
|
|
|
@@ -447,8 +441,8 @@ class AsyncContract(BaseContract):
|
|
|
447
441
|
|
|
448
442
|
@classmethod
|
|
449
443
|
def factory(
|
|
450
|
-
cls, w3: "AsyncWeb3[Any]", class_name:
|
|
451
|
-
) ->
|
|
444
|
+
cls, w3: "AsyncWeb3[Any]", class_name: str | None = None, **kwargs: Any
|
|
445
|
+
) -> type[Self]:
|
|
452
446
|
kwargs["w3"] = w3
|
|
453
447
|
|
|
454
448
|
normalizers = {
|
|
@@ -459,7 +453,7 @@ class AsyncContract(BaseContract):
|
|
|
459
453
|
}
|
|
460
454
|
|
|
461
455
|
contract = cast(
|
|
462
|
-
|
|
456
|
+
type[Self],
|
|
463
457
|
PropertyCheckingFactory(
|
|
464
458
|
class_name or cls.__name__,
|
|
465
459
|
(cls,),
|
|
@@ -522,9 +516,9 @@ class AsyncContract(BaseContract):
|
|
|
522
516
|
w3: "AsyncWeb3[Any]",
|
|
523
517
|
address: ChecksumAddress,
|
|
524
518
|
callable_check: Callable[..., Any],
|
|
525
|
-
) ->
|
|
519
|
+
) -> list["AsyncContractFunction"]:
|
|
526
520
|
return cast(
|
|
527
|
-
|
|
521
|
+
list[AsyncContractFunction],
|
|
528
522
|
find_functions_by_identifier(
|
|
529
523
|
contract_abi, w3, address, callable_check, AsyncContractFunction
|
|
530
524
|
),
|
|
@@ -543,7 +537,7 @@ class AsyncContract(BaseContract):
|
|
|
543
537
|
w3: "AsyncWeb3[Any]",
|
|
544
538
|
address: ChecksumAddress,
|
|
545
539
|
callable_check: Callable[..., Any],
|
|
546
|
-
) ->
|
|
540
|
+
) -> list["AsyncContractEvent"]:
|
|
547
541
|
return find_events_by_identifier(
|
|
548
542
|
contract_abi, w3, address, callable_check, AsyncContractEvent
|
|
549
543
|
)
|
|
@@ -564,11 +558,11 @@ class AsyncContractCaller(BaseContractCaller):
|
|
|
564
558
|
abi: ABI,
|
|
565
559
|
w3: "AsyncWeb3[Any]",
|
|
566
560
|
address: ChecksumAddress,
|
|
567
|
-
transaction:
|
|
561
|
+
transaction: TxParams | None = None,
|
|
568
562
|
block_identifier: BlockIdentifier = None,
|
|
569
|
-
ccip_read_enabled:
|
|
570
|
-
decode_tuples:
|
|
571
|
-
contract_functions:
|
|
563
|
+
ccip_read_enabled: bool | None = None,
|
|
564
|
+
decode_tuples: bool | None = False,
|
|
565
|
+
contract_functions: AsyncContractFunctions | None = None,
|
|
572
566
|
) -> None:
|
|
573
567
|
super().__init__(abi, w3, address, decode_tuples=decode_tuples)
|
|
574
568
|
|
|
@@ -594,9 +588,9 @@ class AsyncContractCaller(BaseContractCaller):
|
|
|
594
588
|
|
|
595
589
|
def __call__(
|
|
596
590
|
self,
|
|
597
|
-
transaction:
|
|
591
|
+
transaction: TxParams | None = None,
|
|
598
592
|
block_identifier: BlockIdentifier = None,
|
|
599
|
-
ccip_read_enabled:
|
|
593
|
+
ccip_read_enabled: bool | None = None,
|
|
600
594
|
) -> "AsyncContractCaller":
|
|
601
595
|
if transaction is None:
|
|
602
596
|
transaction = {}
|
|
@@ -616,13 +610,11 @@ class AsyncContractConstructor(BaseContractConstructor):
|
|
|
616
610
|
w3: "AsyncWeb3[Any]"
|
|
617
611
|
|
|
618
612
|
@combomethod
|
|
619
|
-
async def transact(self, transaction:
|
|
613
|
+
async def transact(self, transaction: TxParams | None = None) -> HexBytes:
|
|
620
614
|
return await self.w3.eth.send_transaction(self._get_transaction(transaction))
|
|
621
615
|
|
|
622
616
|
@combomethod
|
|
623
|
-
async def build_transaction(
|
|
624
|
-
self, transaction: Optional[TxParams] = None
|
|
625
|
-
) -> TxParams:
|
|
617
|
+
async def build_transaction(self, transaction: TxParams | None = None) -> TxParams:
|
|
626
618
|
"""
|
|
627
619
|
Build the transaction dictionary without sending
|
|
628
620
|
"""
|
|
@@ -632,8 +624,8 @@ class AsyncContractConstructor(BaseContractConstructor):
|
|
|
632
624
|
@combomethod
|
|
633
625
|
async def estimate_gas(
|
|
634
626
|
self,
|
|
635
|
-
transaction:
|
|
636
|
-
block_identifier:
|
|
627
|
+
transaction: TxParams | None = None,
|
|
628
|
+
block_identifier: BlockIdentifier | None = None,
|
|
637
629
|
) -> int:
|
|
638
630
|
transaction = self._estimate_gas(transaction)
|
|
639
631
|
|
web3/contract/base_contract.py
CHANGED
|
@@ -3,15 +3,10 @@ from typing import (
|
|
|
3
3
|
Any,
|
|
4
4
|
Callable,
|
|
5
5
|
Collection,
|
|
6
|
-
Dict,
|
|
7
6
|
Generic,
|
|
8
7
|
Iterable,
|
|
9
|
-
List,
|
|
10
8
|
NoReturn,
|
|
11
|
-
Optional,
|
|
12
9
|
Sequence,
|
|
13
|
-
Tuple,
|
|
14
|
-
Type,
|
|
15
10
|
Union,
|
|
16
11
|
cast,
|
|
17
12
|
)
|
|
@@ -172,13 +167,13 @@ class BaseContractEvent:
|
|
|
172
167
|
w3: Union["Web3", "AsyncWeb3[Any]"] = None
|
|
173
168
|
contract_abi: ABI = None
|
|
174
169
|
abi: ABIEvent = None
|
|
175
|
-
argument_names:
|
|
176
|
-
argument_types:
|
|
170
|
+
argument_names: tuple[str, ...] = tuple()
|
|
171
|
+
argument_types: tuple[str, ...] = tuple()
|
|
177
172
|
args: Any = None
|
|
178
173
|
kwargs: Any = None
|
|
179
174
|
_topic: HexStr = None
|
|
180
175
|
|
|
181
|
-
def __init__(self, *argument_names: str, abi:
|
|
176
|
+
def __init__(self, *argument_names: str, abi: ABIEvent | None = None) -> None:
|
|
182
177
|
self.abi_element_identifier = type(self).__name__
|
|
183
178
|
self.name = get_name_from_abi_element_identifier(self.abi_element_identifier)
|
|
184
179
|
self.event_name = self.name
|
|
@@ -282,10 +277,10 @@ class BaseContractEvent:
|
|
|
282
277
|
def _get_event_filter_params(
|
|
283
278
|
self,
|
|
284
279
|
abi: ABIEvent,
|
|
285
|
-
argument_filters:
|
|
286
|
-
from_block:
|
|
287
|
-
to_block:
|
|
288
|
-
block_hash:
|
|
280
|
+
argument_filters: dict[str, Any] | None = None,
|
|
281
|
+
from_block: BlockIdentifier | None = None,
|
|
282
|
+
to_block: BlockIdentifier | None = None,
|
|
283
|
+
block_hash: HexBytes | None = None,
|
|
289
284
|
) -> FilterParams:
|
|
290
285
|
if not self.address:
|
|
291
286
|
raise Web3TypeError(
|
|
@@ -329,7 +324,7 @@ class BaseContractEvent:
|
|
|
329
324
|
|
|
330
325
|
@staticmethod
|
|
331
326
|
def check_for_forbidden_api_filter_arguments(
|
|
332
|
-
event_abi: ABIEvent, _filters:
|
|
327
|
+
event_abi: ABIEvent, _filters: dict[str, Any]
|
|
333
328
|
) -> None:
|
|
334
329
|
name_indexed_inputs = {_input["name"]: _input for _input in event_abi["inputs"]}
|
|
335
330
|
|
|
@@ -351,7 +346,7 @@ class BaseContractEvent:
|
|
|
351
346
|
def _process_get_logs_argument_filters(
|
|
352
347
|
event_abi: ABIEvent,
|
|
353
348
|
event_logs: Sequence[EventData],
|
|
354
|
-
argument_filters:
|
|
349
|
+
argument_filters: dict[str, Any] | None,
|
|
355
350
|
) -> Iterable[EventData]:
|
|
356
351
|
if (
|
|
357
352
|
argument_filters is None
|
|
@@ -398,12 +393,12 @@ class BaseContractEvent:
|
|
|
398
393
|
@combomethod
|
|
399
394
|
def _set_up_filter_builder(
|
|
400
395
|
self,
|
|
401
|
-
argument_filters:
|
|
402
|
-
from_block:
|
|
396
|
+
argument_filters: dict[str, Any] | None = None,
|
|
397
|
+
from_block: BlockIdentifier | None = None,
|
|
403
398
|
to_block: BlockIdentifier = "latest",
|
|
404
|
-
address:
|
|
405
|
-
topics:
|
|
406
|
-
filter_builder:
|
|
399
|
+
address: ChecksumAddress | None = None,
|
|
400
|
+
topics: Sequence[Any] | None = None,
|
|
401
|
+
filter_builder: EventFilterBuilder | AsyncEventFilterBuilder = None,
|
|
407
402
|
) -> None:
|
|
408
403
|
if from_block is None:
|
|
409
404
|
raise Web3TypeError(
|
|
@@ -478,8 +473,8 @@ class BaseContractEvents(Generic[TContractEvent]):
|
|
|
478
473
|
self,
|
|
479
474
|
abi: ABI,
|
|
480
475
|
w3: Union["Web3", "AsyncWeb3[Any]"],
|
|
481
|
-
contract_event_type:
|
|
482
|
-
address:
|
|
476
|
+
contract_event_type: type[TContractEvent],
|
|
477
|
+
address: ChecksumAddress | None = None,
|
|
483
478
|
) -> None:
|
|
484
479
|
self.abi = abi
|
|
485
480
|
self.w3 = w3
|
|
@@ -573,14 +568,14 @@ class BaseContractFunction:
|
|
|
573
568
|
contract_abi: ABI = None
|
|
574
569
|
abi: ABIFunction = None
|
|
575
570
|
transaction: TxParams = None
|
|
576
|
-
arguments:
|
|
577
|
-
decode_tuples:
|
|
578
|
-
argument_names:
|
|
579
|
-
argument_types:
|
|
571
|
+
arguments: tuple[Any, ...] = None
|
|
572
|
+
decode_tuples: bool | None = None
|
|
573
|
+
argument_names: tuple[str, ...] = tuple()
|
|
574
|
+
argument_types: tuple[str, ...] = tuple()
|
|
580
575
|
args: Any = None
|
|
581
576
|
kwargs: Any = None
|
|
582
577
|
|
|
583
|
-
def __init__(self, abi:
|
|
578
|
+
def __init__(self, abi: ABIFunction | None = None) -> None:
|
|
584
579
|
if not self.abi_element_identifier:
|
|
585
580
|
self.abi_element_identifier = type(self).__name__
|
|
586
581
|
|
|
@@ -638,7 +633,7 @@ class BaseContractFunction:
|
|
|
638
633
|
else:
|
|
639
634
|
raise Web3TypeError("Unsupported function identifier")
|
|
640
635
|
|
|
641
|
-
def _get_call_txparams(self, transaction:
|
|
636
|
+
def _get_call_txparams(self, transaction: TxParams | None = None) -> TxParams:
|
|
642
637
|
if transaction is None:
|
|
643
638
|
call_transaction: TxParams = {}
|
|
644
639
|
else:
|
|
@@ -669,7 +664,7 @@ class BaseContractFunction:
|
|
|
669
664
|
|
|
670
665
|
return call_transaction
|
|
671
666
|
|
|
672
|
-
def _transact(self, transaction:
|
|
667
|
+
def _transact(self, transaction: TxParams | None = None) -> TxParams:
|
|
673
668
|
if transaction is None:
|
|
674
669
|
transact_transaction: TxParams = {}
|
|
675
670
|
else:
|
|
@@ -697,7 +692,7 @@ class BaseContractFunction:
|
|
|
697
692
|
)
|
|
698
693
|
return transact_transaction
|
|
699
694
|
|
|
700
|
-
def _estimate_gas(self, transaction:
|
|
695
|
+
def _estimate_gas(self, transaction: TxParams | None = None) -> TxParams:
|
|
701
696
|
if transaction is None:
|
|
702
697
|
estimate_gas_transaction: TxParams = {}
|
|
703
698
|
else:
|
|
@@ -727,7 +722,7 @@ class BaseContractFunction:
|
|
|
727
722
|
)
|
|
728
723
|
return estimate_gas_transaction
|
|
729
724
|
|
|
730
|
-
def _build_transaction(self, transaction:
|
|
725
|
+
def _build_transaction(self, transaction: TxParams | None = None) -> TxParams:
|
|
731
726
|
if transaction is None:
|
|
732
727
|
built_transaction: TxParams = {}
|
|
733
728
|
else:
|
|
@@ -760,7 +755,7 @@ class BaseContractFunction:
|
|
|
760
755
|
def _encode_transaction_data(cls) -> HexStr:
|
|
761
756
|
return add_0x_prefix(encode_abi(cls.w3, cls.abi, cls.arguments, cls.selector))
|
|
762
757
|
|
|
763
|
-
_return_data_normalizers:
|
|
758
|
+
_return_data_normalizers: tuple[Callable[..., Any], ...] | None = tuple()
|
|
764
759
|
|
|
765
760
|
def __repr__(self) -> str:
|
|
766
761
|
if self.abi:
|
|
@@ -782,7 +777,7 @@ class BaseContractFunction:
|
|
|
782
777
|
return copy_contract_function(self, *args, **kwargs)
|
|
783
778
|
|
|
784
779
|
all_functions = cast(
|
|
785
|
-
|
|
780
|
+
list[ABIFunction],
|
|
786
781
|
filter_abi_by_type(
|
|
787
782
|
"function",
|
|
788
783
|
self.contract_abi,
|
|
@@ -797,7 +792,7 @@ class BaseContractFunction:
|
|
|
797
792
|
]
|
|
798
793
|
num_args = len(args) + len(kwargs)
|
|
799
794
|
function_abis_with_arg_count = cast(
|
|
800
|
-
|
|
795
|
+
list[ABIFunction],
|
|
801
796
|
_filter_by_argument_count(
|
|
802
797
|
num_args,
|
|
803
798
|
function_abis,
|
|
@@ -872,10 +867,10 @@ class BaseContractFunction:
|
|
|
872
867
|
|
|
873
868
|
def call(
|
|
874
869
|
self,
|
|
875
|
-
transaction:
|
|
876
|
-
block_identifier:
|
|
877
|
-
state_override:
|
|
878
|
-
ccip_read_enabled:
|
|
870
|
+
transaction: TxParams | None = None,
|
|
871
|
+
block_identifier: BlockIdentifier | None = None,
|
|
872
|
+
state_override: StateOverride | None = None,
|
|
873
|
+
ccip_read_enabled: bool | None = None,
|
|
879
874
|
) -> Any:
|
|
880
875
|
"""
|
|
881
876
|
Implementation of ``call`` should create a callable contract function
|
|
@@ -895,9 +890,9 @@ class BaseContractFunctions(Generic[TContractFn]):
|
|
|
895
890
|
self,
|
|
896
891
|
abi: ABI,
|
|
897
892
|
w3: Union["Web3", "AsyncWeb3[Any]"],
|
|
898
|
-
contract_function_class:
|
|
899
|
-
address:
|
|
900
|
-
decode_tuples:
|
|
893
|
+
contract_function_class: type[TContractFn],
|
|
894
|
+
address: ChecksumAddress | None = None,
|
|
895
|
+
decode_tuples: bool | None = False,
|
|
901
896
|
) -> None:
|
|
902
897
|
self.abi = abi
|
|
903
898
|
self.w3 = w3
|
|
@@ -1030,9 +1025,9 @@ class BaseContract:
|
|
|
1030
1025
|
def encode_abi(
|
|
1031
1026
|
cls,
|
|
1032
1027
|
abi_element_identifier: str,
|
|
1033
|
-
args:
|
|
1034
|
-
kwargs:
|
|
1035
|
-
data:
|
|
1028
|
+
args: Any | None = None,
|
|
1029
|
+
kwargs: Any | None = None,
|
|
1030
|
+
data: HexStr | None = None,
|
|
1036
1031
|
) -> HexStr:
|
|
1037
1032
|
"""
|
|
1038
1033
|
Encodes the arguments using the Ethereum ABI for the contract function
|
|
@@ -1062,7 +1057,7 @@ class BaseContract:
|
|
|
1062
1057
|
@combomethod
|
|
1063
1058
|
def all_functions(
|
|
1064
1059
|
self,
|
|
1065
|
-
) ->
|
|
1060
|
+
) -> list["BaseContractFunction"]:
|
|
1066
1061
|
"""
|
|
1067
1062
|
Return all functions in the contract.
|
|
1068
1063
|
"""
|
|
@@ -1092,7 +1087,7 @@ class BaseContract:
|
|
|
1092
1087
|
return self.get_function_by_identifier(fns, "signature")
|
|
1093
1088
|
|
|
1094
1089
|
@combomethod
|
|
1095
|
-
def find_functions_by_name(self, fn_name: str) ->
|
|
1090
|
+
def find_functions_by_name(self, fn_name: str) -> list["BaseContractFunction"]:
|
|
1096
1091
|
"""
|
|
1097
1092
|
Return all functions with matching name.
|
|
1098
1093
|
Raises a Web3ValueError if there is no match or more than one is found.
|
|
@@ -1116,7 +1111,7 @@ class BaseContract:
|
|
|
1116
1111
|
|
|
1117
1112
|
@combomethod
|
|
1118
1113
|
def get_function_by_selector(
|
|
1119
|
-
self, selector:
|
|
1114
|
+
self, selector: bytes | int | HexStr
|
|
1120
1115
|
) -> "BaseContractFunction":
|
|
1121
1116
|
"""
|
|
1122
1117
|
Return a distinct function with matching 4byte selector.
|
|
@@ -1136,7 +1131,7 @@ class BaseContract:
|
|
|
1136
1131
|
@combomethod
|
|
1137
1132
|
def decode_function_input(
|
|
1138
1133
|
self, data: HexStr
|
|
1139
|
-
) ->
|
|
1134
|
+
) -> tuple["BaseContractFunction", dict[str, Any]]:
|
|
1140
1135
|
"""
|
|
1141
1136
|
Return a Tuple of the function selector and decoded arguments.
|
|
1142
1137
|
"""
|
|
@@ -1179,7 +1174,7 @@ class BaseContract:
|
|
|
1179
1174
|
# Events API
|
|
1180
1175
|
#
|
|
1181
1176
|
@combomethod
|
|
1182
|
-
def all_events(self) ->
|
|
1177
|
+
def all_events(self) -> list["BaseContractEvent"]:
|
|
1183
1178
|
"""
|
|
1184
1179
|
Return all events in the contract.
|
|
1185
1180
|
"""
|
|
@@ -1204,7 +1199,7 @@ class BaseContract:
|
|
|
1204
1199
|
return self.get_event_by_identifier(events, "signature")
|
|
1205
1200
|
|
|
1206
1201
|
@combomethod
|
|
1207
|
-
def find_events_by_name(self, event_name: str) ->
|
|
1202
|
+
def find_events_by_name(self, event_name: str) -> list["BaseContractEvent"]:
|
|
1208
1203
|
"""
|
|
1209
1204
|
Return all events with matching name.
|
|
1210
1205
|
Raises a Web3ValueError if there is no match or more than one is found.
|
|
@@ -1228,8 +1223,8 @@ class BaseContract:
|
|
|
1228
1223
|
|
|
1229
1224
|
@combomethod
|
|
1230
1225
|
def find_events_by_selector(
|
|
1231
|
-
self, selector:
|
|
1232
|
-
) ->
|
|
1226
|
+
self, selector: bytes | int | HexStr
|
|
1227
|
+
) -> list["BaseContractEvent"]:
|
|
1233
1228
|
"""
|
|
1234
1229
|
Return all events with matching selector.
|
|
1235
1230
|
Raises a Web3ValueError if there is no match or more than one is found.
|
|
@@ -1246,7 +1241,7 @@ class BaseContract:
|
|
|
1246
1241
|
|
|
1247
1242
|
@combomethod
|
|
1248
1243
|
def get_event_by_selector(
|
|
1249
|
-
self, selector:
|
|
1244
|
+
self, selector: bytes | int | HexStr
|
|
1250
1245
|
) -> "BaseContractEvent":
|
|
1251
1246
|
"""
|
|
1252
1247
|
Return a distinct event with matching keccak selector.
|
|
@@ -1256,7 +1251,7 @@ class BaseContract:
|
|
|
1256
1251
|
return self.get_event_by_identifier(events, "selector")
|
|
1257
1252
|
|
|
1258
1253
|
@combomethod
|
|
1259
|
-
def find_events_by_topic(self, topic: HexStr) ->
|
|
1254
|
+
def find_events_by_topic(self, topic: HexStr) -> list["BaseContractEvent"]:
|
|
1260
1255
|
"""
|
|
1261
1256
|
Return all events with matching topic.
|
|
1262
1257
|
Raises a Web3ValueError if there is no match or more than one is found.
|
|
@@ -1288,7 +1283,7 @@ class BaseContract:
|
|
|
1288
1283
|
w3: Union["Web3", "AsyncWeb3[Any]"],
|
|
1289
1284
|
address: ChecksumAddress,
|
|
1290
1285
|
callable_check: Callable[..., Any],
|
|
1291
|
-
) ->
|
|
1286
|
+
) -> list[Any]:
|
|
1292
1287
|
raise NotImplementedError(
|
|
1293
1288
|
"This method should be implemented in the inherited class"
|
|
1294
1289
|
)
|
|
@@ -1308,7 +1303,7 @@ class BaseContract:
|
|
|
1308
1303
|
w3: Union["Web3", "AsyncWeb3[Any]"],
|
|
1309
1304
|
address: ChecksumAddress,
|
|
1310
1305
|
callable_check: Callable[..., Any],
|
|
1311
|
-
) ->
|
|
1306
|
+
) -> list[Any]:
|
|
1312
1307
|
raise NotImplementedError(
|
|
1313
1308
|
"This method should be implemented in the inherited class"
|
|
1314
1309
|
)
|
|
@@ -1325,8 +1320,8 @@ class BaseContract:
|
|
|
1325
1320
|
def get_fallback_function(
|
|
1326
1321
|
abi: ABI,
|
|
1327
1322
|
w3: Union["Web3", "AsyncWeb3[Any]"],
|
|
1328
|
-
function_type:
|
|
1329
|
-
address:
|
|
1323
|
+
function_type: type["BaseContractFunction"],
|
|
1324
|
+
address: ChecksumAddress | None = None,
|
|
1330
1325
|
) -> "BaseContractFunction":
|
|
1331
1326
|
if abi and fallback_func_abi_exists(abi):
|
|
1332
1327
|
fallback_abi = filter_abi_by_type("fallback", abi)[0]
|
|
@@ -1345,8 +1340,8 @@ class BaseContract:
|
|
|
1345
1340
|
def get_receive_function(
|
|
1346
1341
|
abi: ABI,
|
|
1347
1342
|
w3: Union["Web3", "AsyncWeb3[Any]"],
|
|
1348
|
-
function_type:
|
|
1349
|
-
address:
|
|
1343
|
+
function_type: type["BaseContractFunction"],
|
|
1344
|
+
address: ChecksumAddress | None = None,
|
|
1350
1345
|
) -> "BaseContractFunction":
|
|
1351
1346
|
if abi and receive_func_abi_exists(abi):
|
|
1352
1347
|
receive_abi = filter_abi_by_type("receive", abi)[0]
|
|
@@ -1364,15 +1359,15 @@ class BaseContract:
|
|
|
1364
1359
|
#
|
|
1365
1360
|
# Private Helpers
|
|
1366
1361
|
#
|
|
1367
|
-
_return_data_normalizers:
|
|
1362
|
+
_return_data_normalizers: tuple[Callable[..., Any], ...] = tuple()
|
|
1368
1363
|
|
|
1369
1364
|
@classmethod
|
|
1370
1365
|
def _prepare_transaction(
|
|
1371
1366
|
cls,
|
|
1372
1367
|
abi_element_identifier: ABIElementIdentifier,
|
|
1373
|
-
fn_args:
|
|
1374
|
-
fn_kwargs:
|
|
1375
|
-
transaction:
|
|
1368
|
+
fn_args: Any | None = None,
|
|
1369
|
+
fn_kwargs: Any | None = None,
|
|
1370
|
+
transaction: TxParams | None = None,
|
|
1376
1371
|
) -> TxParams:
|
|
1377
1372
|
return prepare_transaction(
|
|
1378
1373
|
cls.address,
|
|
@@ -1387,9 +1382,9 @@ class BaseContract:
|
|
|
1387
1382
|
@classmethod
|
|
1388
1383
|
def _find_matching_fn_abi(
|
|
1389
1384
|
cls,
|
|
1390
|
-
fn_identifier:
|
|
1385
|
+
fn_identifier: ABIElementIdentifier | None = None,
|
|
1391
1386
|
*args: Sequence[Any],
|
|
1392
|
-
**kwargs:
|
|
1387
|
+
**kwargs: dict[str, Any],
|
|
1393
1388
|
) -> ABIElement:
|
|
1394
1389
|
if not args and not kwargs:
|
|
1395
1390
|
fn_identifier = get_abi_element_signature(fn_identifier)
|
|
@@ -1405,8 +1400,8 @@ class BaseContract:
|
|
|
1405
1400
|
@classmethod
|
|
1406
1401
|
def _get_event_abi(
|
|
1407
1402
|
cls,
|
|
1408
|
-
event_name:
|
|
1409
|
-
argument_names:
|
|
1403
|
+
event_name: str | None = None,
|
|
1404
|
+
argument_names: Sequence[str] | None = None,
|
|
1410
1405
|
) -> ABIEvent:
|
|
1411
1406
|
return cast(
|
|
1412
1407
|
ABIEvent,
|
|
@@ -1419,7 +1414,7 @@ class BaseContract:
|
|
|
1419
1414
|
|
|
1420
1415
|
@combomethod
|
|
1421
1416
|
def _encode_constructor_data(
|
|
1422
|
-
cls, *args: Sequence[Any], **kwargs:
|
|
1417
|
+
cls, *args: Sequence[Any], **kwargs: dict[str, Any]
|
|
1423
1418
|
) -> HexStr:
|
|
1424
1419
|
constructor_abi = find_constructor_abi_element_by_type(cls.abi)
|
|
1425
1420
|
|
|
@@ -1470,7 +1465,7 @@ class BaseContractCaller:
|
|
|
1470
1465
|
abi: ABI,
|
|
1471
1466
|
w3: Union["Web3", "AsyncWeb3[Any]"],
|
|
1472
1467
|
address: ChecksumAddress,
|
|
1473
|
-
decode_tuples:
|
|
1468
|
+
decode_tuples: bool | None = False,
|
|
1474
1469
|
) -> None:
|
|
1475
1470
|
self.w3 = w3
|
|
1476
1471
|
self.address = address
|
|
@@ -1520,9 +1515,9 @@ class BaseContractCaller:
|
|
|
1520
1515
|
def call_function(
|
|
1521
1516
|
fn: TContractFn,
|
|
1522
1517
|
*args: Any,
|
|
1523
|
-
transaction:
|
|
1518
|
+
transaction: TxParams | None = None,
|
|
1524
1519
|
block_identifier: BlockIdentifier = None,
|
|
1525
|
-
ccip_read_enabled:
|
|
1520
|
+
ccip_read_enabled: bool | None = None,
|
|
1526
1521
|
**kwargs: Any,
|
|
1527
1522
|
) -> Any:
|
|
1528
1523
|
if transaction is None:
|
|
@@ -1573,7 +1568,7 @@ class BaseContractConstructor:
|
|
|
1573
1568
|
return data
|
|
1574
1569
|
|
|
1575
1570
|
@combomethod
|
|
1576
|
-
def _estimate_gas(self, transaction:
|
|
1571
|
+
def _estimate_gas(self, transaction: TxParams | None = None) -> TxParams:
|
|
1577
1572
|
if transaction is None:
|
|
1578
1573
|
estimate_gas_transaction: TxParams = {}
|
|
1579
1574
|
else:
|
|
@@ -1591,7 +1586,7 @@ class BaseContractConstructor:
|
|
|
1591
1586
|
|
|
1592
1587
|
return estimate_gas_transaction
|
|
1593
1588
|
|
|
1594
|
-
def _get_transaction(self, transaction:
|
|
1589
|
+
def _get_transaction(self, transaction: TxParams | None = None) -> TxParams:
|
|
1595
1590
|
if transaction is None:
|
|
1596
1591
|
transact_transaction: TxParams = {}
|
|
1597
1592
|
else:
|
|
@@ -1610,14 +1605,14 @@ class BaseContractConstructor:
|
|
|
1610
1605
|
return transact_transaction
|
|
1611
1606
|
|
|
1612
1607
|
@combomethod
|
|
1613
|
-
def _build_transaction(self, transaction:
|
|
1608
|
+
def _build_transaction(self, transaction: TxParams | None = None) -> TxParams:
|
|
1614
1609
|
built_transaction = self._get_transaction(transaction)
|
|
1615
1610
|
built_transaction["to"] = Address(b"")
|
|
1616
1611
|
return built_transaction
|
|
1617
1612
|
|
|
1618
1613
|
@staticmethod
|
|
1619
1614
|
def check_forbidden_keys_in_transaction(
|
|
1620
|
-
transaction: TxParams, forbidden_keys:
|
|
1615
|
+
transaction: TxParams, forbidden_keys: Collection[str] | None = None
|
|
1621
1616
|
) -> None:
|
|
1622
1617
|
keys_found = transaction.keys() & forbidden_keys
|
|
1623
1618
|
if keys_found:
|