diff --git a/chia/data_layer/data_layer_wallet.py b/chia/data_layer/data_layer_wallet.py index 65947a6ccf3e..bc27bbab94a8 100644 --- a/chia/data_layer/data_layer_wallet.py +++ b/chia/data_layer/data_layer_wallet.py @@ -4,7 +4,7 @@ import logging import time from operator import attrgetter -from typing import TYPE_CHECKING, Any, Dict, List, Optional, Set, Tuple +from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Set, Tuple, cast from blspy import G1Element, G2Element from clvm.EvalError import EvalError @@ -104,6 +104,11 @@ def from_json_dict(cls, json_dict: Dict[str, Any]) -> "Mirror": @final class DataLayerWallet: + if TYPE_CHECKING: + from chia.wallet.wallet_protocol import WalletProtocol + + _protocol_check: ClassVar[WalletProtocol] = cast("DataLayerWallet", None) + wallet_state_manager: WalletStateManager log: logging.Logger wallet_info: WalletInfo @@ -1391,9 +1396,3 @@ def verify_offer( if taker_from_offer != taker_from_reference: raise OfferIntegrityError("taker: reference and offer inclusions do not match") - - -if TYPE_CHECKING: - from chia.wallet.wallet_protocol import WalletProtocol - - _dummy: WalletProtocol = DataLayerWallet() diff --git a/chia/pools/pool_wallet.py b/chia/pools/pool_wallet.py index 4187e9f5c59d..47890f9d5288 100644 --- a/chia/pools/pool_wallet.py +++ b/chia/pools/pool_wallet.py @@ -3,7 +3,7 @@ import dataclasses import logging import time -from typing import TYPE_CHECKING, Any, Dict, List, Optional, Set, Tuple, cast +from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Set, Tuple, cast from blspy import G1Element, G2Element, PrivateKey from typing_extensions import final @@ -59,6 +59,11 @@ @final @dataclasses.dataclass class PoolWallet: + if TYPE_CHECKING: + from chia.wallet.wallet_protocol import WalletProtocol + + _protocol_check: ClassVar[WalletProtocol] = cast("PoolWallet", None) + MINIMUM_INITIAL_BALANCE = 1 MINIMUM_RELATIVE_LOCK_HEIGHT = 5 MAXIMUM_RELATIVE_LOCK_HEIGHT = 1000 @@ -988,9 +993,3 @@ def puzzle_hash_for_pk(self, pubkey: G1Element) -> bytes32: def get_name(self) -> str: return self.wallet_info.name - - -if TYPE_CHECKING: - from chia.wallet.wallet_protocol import WalletProtocol - - _dummy: WalletProtocol = cast(PoolWallet, None) diff --git a/chia/wallet/cat_wallet/cat_wallet.py b/chia/wallet/cat_wallet/cat_wallet.py index 5a3f47d6a752..23a4b2e22067 100644 --- a/chia/wallet/cat_wallet/cat_wallet.py +++ b/chia/wallet/cat_wallet/cat_wallet.py @@ -5,7 +5,7 @@ import time import traceback from secrets import token_bytes -from typing import TYPE_CHECKING, Any, Dict, List, Optional, Set, Tuple +from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Set, Tuple, cast from blspy import AugSchemeMPL, G1Element, G2Element @@ -68,6 +68,11 @@ class CATWallet: + if TYPE_CHECKING: + from chia.wallet.wallet_protocol import WalletProtocol + + _protocol_check: ClassVar[WalletProtocol] = cast("CATWallet", None) + wallet_state_manager: WalletStateManager log: logging.Logger wallet_info: WalletInfo @@ -927,9 +932,3 @@ async def get_coins_to_offer( if balance < amount: raise Exception(f"insufficient funds in wallet {self.id()}") return await self.select_coins(amount, min_coin_amount=min_coin_amount, max_coin_amount=max_coin_amount) - - -if TYPE_CHECKING: - from chia.wallet.wallet_protocol import WalletProtocol - - _dummy: WalletProtocol = CATWallet() diff --git a/chia/wallet/did_wallet/did_wallet.py b/chia/wallet/did_wallet/did_wallet.py index b9de32938b2a..0d9d3295e0a1 100644 --- a/chia/wallet/did_wallet/did_wallet.py +++ b/chia/wallet/did_wallet/did_wallet.py @@ -6,7 +6,7 @@ import re import time from secrets import token_bytes -from typing import TYPE_CHECKING, Any, Dict, List, Optional, Set, Tuple +from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Set, Tuple, cast from blspy import AugSchemeMPL, G1Element, G2Element @@ -52,6 +52,11 @@ class DIDWallet: + if TYPE_CHECKING: + from chia.wallet.wallet_protocol import WalletProtocol + + _protocol_check: ClassVar[WalletProtocol] = cast("DIDWallet", None) + wallet_state_manager: Any log: logging.Logger wallet_info: WalletInfo @@ -1482,9 +1487,3 @@ def deserialize_backup_data(backup_data: str) -> DIDInfo: def require_derivation_paths(self) -> bool: return True - - -if TYPE_CHECKING: - from chia.wallet.wallet_protocol import WalletProtocol - - _dummy: WalletProtocol = DIDWallet() diff --git a/chia/wallet/nft_wallet/nft_wallet.py b/chia/wallet/nft_wallet/nft_wallet.py index 3d636c0a50ab..4b2277cdc250 100644 --- a/chia/wallet/nft_wallet/nft_wallet.py +++ b/chia/wallet/nft_wallet/nft_wallet.py @@ -5,7 +5,7 @@ import logging import math import time -from typing import TYPE_CHECKING, Any, Dict, List, Optional, Set, Tuple, Type, TypeVar +from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Set, Tuple, Type, TypeVar, cast from blspy import AugSchemeMPL, G1Element, G2Element from clvm.casts import int_from_bytes, int_to_bytes @@ -61,6 +61,11 @@ class NFTWallet: + if TYPE_CHECKING: + from chia.wallet.wallet_protocol import WalletProtocol + + _protocol_check: ClassVar[WalletProtocol] = cast("NFTWallet", None) + wallet_state_manager: Any log: logging.Logger wallet_info: WalletInfo @@ -1763,9 +1768,3 @@ def puzzle_hash_for_pk(self, pubkey: G1Element) -> bytes32: def get_name(self) -> str: return self.wallet_info.name - - -if TYPE_CHECKING: - from chia.wallet.wallet_protocol import WalletProtocol - - _dummy: WalletProtocol = NFTWallet() diff --git a/chia/wallet/wallet.py b/chia/wallet/wallet.py index 007def30b85d..06e46b474d30 100644 --- a/chia/wallet/wallet.py +++ b/chia/wallet/wallet.py @@ -2,7 +2,7 @@ import logging import time -from typing import TYPE_CHECKING, Any, Dict, List, Optional, Set, Tuple +from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Set, Tuple, cast from blspy import AugSchemeMPL, G1Element, G2Element @@ -55,6 +55,11 @@ class Wallet: + if TYPE_CHECKING: + from chia.wallet.wallet_protocol import WalletProtocol + + _protocol_check: ClassVar[WalletProtocol] = cast("Wallet", None) + wallet_info: WalletInfo wallet_state_manager: Any log: logging.Logger @@ -626,9 +631,3 @@ async def coin_added( def get_name(self) -> str: return "Standard Wallet" - - -if TYPE_CHECKING: - from chia.wallet.wallet_protocol import WalletProtocol - - _dummy: WalletProtocol = Wallet()