Skip to content

Commit 70c6c71

Browse files
leafyoungkclowes
andauthored
Update contract call function to use w3.eth.default_block instead of 'latest' (#2846)
* Update contract.py The default parameter "latest" ignores when w3.eth.default_block is set. * Leafyoung/master (#1) * add newsfragment * Change block_identifier to None instead of 'latest' * Classify newsfragment as 'bugfix' instead of 'internal' --------- Co-authored-by: kclowes <[email protected]>
1 parent b177f97 commit 70c6c71

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

newsfragments/2846.bugfix.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Set default block_identifier in ContractFunction.call() to None
2+

web3/contract/async_contract.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ def factory(cls, class_name: str, **kwargs: Any) -> "AsyncContractFunction":
308308
async def call(
309309
self,
310310
transaction: Optional[TxParams] = None,
311-
block_identifier: BlockIdentifier = "latest",
311+
block_identifier: BlockIdentifier = None,
312312
state_override: Optional[CallOverride] = None,
313313
ccip_read_enabled: Optional[bool] = None,
314314
) -> Any:
@@ -565,7 +565,7 @@ def __init__(
565565
w3: "AsyncWeb3",
566566
address: ChecksumAddress,
567567
transaction: Optional[TxParams] = None,
568-
block_identifier: BlockIdentifier = "latest",
568+
block_identifier: BlockIdentifier = None,
569569
ccip_read_enabled: Optional[bool] = None,
570570
decode_tuples: Optional[bool] = False,
571571
) -> None:
@@ -605,7 +605,7 @@ def __init__(
605605
def __call__(
606606
self,
607607
transaction: Optional[TxParams] = None,
608-
block_identifier: BlockIdentifier = "latest",
608+
block_identifier: BlockIdentifier = None,
609609
ccip_read_enabled: Optional[bool] = None,
610610
) -> "AsyncContractCaller":
611611
if transaction is None:

web3/contract/base_contract.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,7 @@ def call_function(
10901090
fn: TContractFn,
10911091
*args: Any,
10921092
transaction: Optional[TxParams] = None,
1093-
block_identifier: BlockIdentifier = "latest",
1093+
block_identifier: BlockIdentifier = None,
10941094
ccip_read_enabled: Optional[bool] = None,
10951095
**kwargs: Any,
10961096
) -> Any:

web3/contract/contract.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ def factory(cls, class_name: str, **kwargs: Any) -> "ContractFunction":
426426
def call(
427427
self,
428428
transaction: Optional[TxParams] = None,
429-
block_identifier: BlockIdentifier = "latest",
429+
block_identifier: BlockIdentifier = None,
430430
state_override: Optional[CallOverride] = None,
431431
ccip_read_enabled: Optional[bool] = None,
432432
) -> Any:
@@ -561,7 +561,7 @@ def __init__(
561561
w3: "Web3",
562562
address: ChecksumAddress,
563563
transaction: Optional[TxParams] = None,
564-
block_identifier: BlockIdentifier = "latest",
564+
block_identifier: BlockIdentifier = None,
565565
ccip_read_enabled: Optional[bool] = None,
566566
decode_tuples: Optional[bool] = False,
567567
) -> None:
@@ -596,7 +596,7 @@ def __init__(
596596
def __call__(
597597
self,
598598
transaction: Optional[TxParams] = None,
599-
block_identifier: BlockIdentifier = "latest",
599+
block_identifier: BlockIdentifier = None,
600600
ccip_read_enabled: Optional[bool] = None,
601601
) -> "ContractCaller":
602602
if transaction is None:

0 commit comments

Comments
 (0)