File tree Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change 1+ Add setter for the Eth.chain_id property
Original file line number Diff line number Diff line change 22
33
44def test_eth_protocol_version (w3 ):
5- assert w3 .eth .protocol_version == '63'
5+ with pytest .warns (DeprecationWarning ):
6+ assert w3 .eth .protocol_version == '63'
67
78
89def test_eth_protocolVersion (w3 ):
@@ -17,3 +18,13 @@ def test_eth_chain_id(w3):
1718def test_eth_chainId (w3 ):
1819 with pytest .warns (DeprecationWarning ):
1920 assert w3 .eth .chainId == 61
21+
22+
23+ def test_set_chain_id (w3 ):
24+ assert w3 .eth .chain_id == 61
25+
26+ w3 .eth .chain_id = 72
27+ assert w3 .eth .chain_id == 72
28+
29+ w3 .eth .chain_id = None
30+ assert w3 .eth .chain_id == 61
Original file line number Diff line number Diff line change 114114class BaseEth (Module ):
115115 _default_account : Union [ChecksumAddress , Empty ] = empty
116116 _default_block : BlockIdentifier = "latest"
117+ _default_chain_id : Optional [int ] = None
117118 gasPriceStrategy = None
118119
119120 _gas_price : Method [Callable [[], Wei ]] = Method (
@@ -629,7 +630,14 @@ def blockNumber(self) -> BlockNumber:
629630
630631 @property
631632 def chain_id (self ) -> int :
632- return self ._chain_id ()
633+ if self ._default_chain_id is None :
634+ return self ._chain_id ()
635+ else :
636+ return self ._default_chain_id
637+
638+ @chain_id .setter
639+ def chain_id (self , value : int ) -> None :
640+ self ._default_chain_id = value
633641
634642 @property
635643 def chainId (self ) -> int :
You can’t perform that action at this time.
0 commit comments