File tree 3 files changed +22
-2
lines changed 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 2
2
3
3
4
4
def test_eth_protocol_version (w3 ):
5
- assert w3 .eth .protocol_version == '63'
5
+ with pytest .warns (DeprecationWarning ):
6
+ assert w3 .eth .protocol_version == '63'
6
7
7
8
8
9
def test_eth_protocolVersion (w3 ):
@@ -17,3 +18,13 @@ def test_eth_chain_id(w3):
17
18
def test_eth_chainId (w3 ):
18
19
with pytest .warns (DeprecationWarning ):
19
20
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 114
114
class BaseEth (Module ):
115
115
_default_account : Union [ChecksumAddress , Empty ] = empty
116
116
_default_block : BlockIdentifier = "latest"
117
+ _default_chain_id : Optional [int ] = None
117
118
gasPriceStrategy = None
118
119
119
120
_gas_price : Method [Callable [[], Wei ]] = Method (
@@ -629,7 +630,14 @@ def blockNumber(self) -> BlockNumber:
629
630
630
631
@property
631
632
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
633
641
634
642
@property
635
643
def chainId (self ) -> int :
You can’t perform that action at this time.
0 commit comments