|
25 | 25 | from ..development.transactions import TransactionAbc, TransactionStatusEnum |
26 | 26 |
|
27 | 27 |
|
| 28 | +_ORIG_ADDRESS_EQ = Address.__eq__ |
| 29 | +_ORIG_ACCOUNT_EQ = Account.__eq__ |
| 30 | + |
| 31 | +def enable_relaxed_equality_address_account(): |
| 32 | + def _address_eq(self: Address, other: Account | Address) -> bool: |
| 33 | + if isinstance(other, Account): |
| 34 | + return _ORIG_ADDRESS_EQ(self, other.address) |
| 35 | + return _ORIG_ADDRESS_EQ(self, other) |
| 36 | + |
| 37 | + def _account_eq(self: Account, other: Account | Address) -> bool: |
| 38 | + if isinstance(other, Address): |
| 39 | + return _ORIG_ADDRESS_EQ(self.address, other) |
| 40 | + return _ORIG_ACCOUNT_EQ(self, other) |
| 41 | + |
| 42 | + Address.__eq__ = _address_eq |
| 43 | + Account.__eq__ = _account_eq |
| 44 | + |
| 45 | +def disable_relaxed_equality_address_account(): |
| 46 | + Address.__eq__ = _ORIG_ADDRESS_EQ |
| 47 | + Account.__eq__ = _ORIG_ACCOUNT_EQ |
| 48 | + |
| 49 | + |
28 | 50 | class Chain(wake.development.core.Chain): |
29 | 51 | _block_gas_limit: int |
30 | 52 | _gas_price: Wei |
@@ -58,6 +80,11 @@ def _connect_setup( |
58 | 80 | ) -> None: |
59 | 81 | connected_chains.append(self) |
60 | 82 |
|
| 83 | + if len(connected_chains) == 1: # enable on first chain |
| 84 | + enable_relaxed_equality_address_account() |
| 85 | + elif len(connected_chains) == 2: # disable on second chain |
| 86 | + disable_relaxed_equality_address_account() |
| 87 | + |
61 | 88 | self._require_signed_txs = False |
62 | 89 | self._gas_price = Wei(0) |
63 | 90 | self._max_priority_fee_per_gas = Wei(0) |
|
0 commit comments