refactor 'init_wallet_wizard' hook a bit. add test_wizard trezor test
This commit is contained in:
@@ -39,6 +39,7 @@ if TYPE_CHECKING:
|
||||
import threading
|
||||
from electrum.plugin import DeviceInfo
|
||||
from electrum.wallet import Abstract_Wallet
|
||||
from electrum.wizard import AbstractWizard
|
||||
|
||||
|
||||
class HW_PluginBase(BasePlugin, ABC):
|
||||
@@ -188,6 +189,14 @@ class HW_PluginBase(BasePlugin, ABC):
|
||||
"""
|
||||
pass
|
||||
|
||||
@hook
|
||||
def init_wallet_wizard(self, wizard: 'AbstractWizard') -> None:
|
||||
self.extend_wizard(wizard)
|
||||
|
||||
@abstractmethod
|
||||
def extend_wizard(self, wizard: 'AbstractWizard') -> None:
|
||||
pass
|
||||
|
||||
|
||||
class HardwareClientBase(ABC):
|
||||
handler = None # type: Optional['HardwareHandlerBase']
|
||||
|
||||
@@ -54,10 +54,6 @@ class Plugin(BitBox02Plugin, QtPluginBase):
|
||||
device_name = "{} ({})".format(self.device, keystore.label)
|
||||
mpk_text.addButton(read_QIcon("eye1.png"), on_button_click, _("Show on {}").format(device_name))
|
||||
|
||||
@hook
|
||||
def init_wallet_wizard(self, wizard: 'QENewWalletWizard'):
|
||||
self.extend_wizard(wizard)
|
||||
|
||||
# insert bitbox02 pages in new wallet wizard
|
||||
def extend_wizard(self, wizard: 'QENewWalletWizard'):
|
||||
super().extend_wizard(wizard)
|
||||
|
||||
@@ -124,10 +124,6 @@ class Plugin(ColdcardPlugin, QtPluginBase):
|
||||
# - doesn't matter if device not connected, continue
|
||||
CKCCSettingsDialog(window, self, keystore).exec()
|
||||
|
||||
@hook
|
||||
def init_wallet_wizard(self, wizard: 'QENewWalletWizard'):
|
||||
self.extend_wizard(wizard)
|
||||
|
||||
# insert coldcard pages in new wallet wizard
|
||||
def extend_wizard(self, wizard: 'QENewWalletWizard'):
|
||||
super().extend_wizard(wizard)
|
||||
|
||||
@@ -47,10 +47,6 @@ class Plugin(DigitalBitboxPlugin, QtPluginBase):
|
||||
return
|
||||
self._add_menu_action(menu, addr, wallet)
|
||||
|
||||
@hook
|
||||
def init_wallet_wizard(self, wizard: 'QENewWalletWizard'):
|
||||
self.extend_wizard(wizard)
|
||||
|
||||
# insert digitalbitbox pages in new wallet wizard
|
||||
def extend_wizard(self, wizard: 'QENewWalletWizard'):
|
||||
super().extend_wizard(wizard)
|
||||
|
||||
@@ -41,10 +41,6 @@ class Plugin(JadePlugin, QtPluginBase):
|
||||
return
|
||||
self._add_menu_action(menu, addr, wallet)
|
||||
|
||||
@hook
|
||||
def init_wallet_wizard(self, wizard: 'QENewWalletWizard'):
|
||||
self.extend_wizard(wizard)
|
||||
|
||||
# insert jade pages in new wallet wizard
|
||||
def extend_wizard(self, wizard: 'QENewWalletWizard'):
|
||||
super().extend_wizard(wizard)
|
||||
|
||||
@@ -323,10 +323,6 @@ class Plugin(KeepKeyPlugin, QtPlugin):
|
||||
def pin_matrix_widget_class(self):
|
||||
return PinMatrixWidget
|
||||
|
||||
@hook
|
||||
def init_wallet_wizard(self, wizard: 'QENewWalletWizard'):
|
||||
self.extend_wizard(wizard)
|
||||
|
||||
# insert keepkey pages in new wallet wizard
|
||||
def extend_wizard(self, wizard: 'QENewWalletWizard'):
|
||||
super().extend_wizard(wizard)
|
||||
|
||||
@@ -40,10 +40,6 @@ class Plugin(LedgerPlugin, QtPluginBase):
|
||||
return
|
||||
self._add_menu_action(menu, addr, wallet)
|
||||
|
||||
@hook
|
||||
def init_wallet_wizard(self, wizard: 'QENewWalletWizard'):
|
||||
self.extend_wizard(wizard)
|
||||
|
||||
# insert ledger pages in new wallet wizard
|
||||
def extend_wizard(self, wizard: 'QENewWalletWizard'):
|
||||
super().extend_wizard(wizard)
|
||||
|
||||
@@ -199,10 +199,6 @@ class Plugin(SafeTPlugin, QtPlugin):
|
||||
def pin_matrix_widget_class(self):
|
||||
return PinMatrixWidget
|
||||
|
||||
@hook
|
||||
def init_wallet_wizard(self, wizard: 'QENewWalletWizard'):
|
||||
self.extend_wizard(wizard)
|
||||
|
||||
# insert safe_t pages in new wallet wizard
|
||||
def extend_wizard(self, wizard: 'QENewWalletWizard'):
|
||||
super().extend_wizard(wizard)
|
||||
|
||||
@@ -466,10 +466,6 @@ class Plugin(TrezorPlugin, QtPlugin):
|
||||
def pin_matrix_widget_class(self):
|
||||
return PinMatrixWidget
|
||||
|
||||
@hook
|
||||
def init_wallet_wizard(self, wizard: 'QENewWalletWizard'):
|
||||
self.extend_wizard(wizard)
|
||||
|
||||
# insert trezor pages in new wallet wizard
|
||||
def extend_wizard(self, wizard: 'QENewWalletWizard'):
|
||||
super().extend_wizard(wizard)
|
||||
|
||||
@@ -172,7 +172,7 @@ class AbstractWizard:
|
||||
"wallet_type", "keystore_type", "seed_variant", "seed_type", "seed_extend",
|
||||
"script_type", "derivation_path", "encrypt",
|
||||
# hardware devices:
|
||||
"hardware_device", "hw_type", "label", "soft_device_id",
|
||||
"hardware_device", "hw_type", "label", "soft_device_id", "xpub_encrypt",
|
||||
# inside keystore:
|
||||
"type", "pw_hash_version", "derivation", "root_fingerprint",
|
||||
# multisig:
|
||||
@@ -285,8 +285,8 @@ class KeystoreWizard(AbstractWizard):
|
||||
def on_hardware_device(self, wizard_data: dict, new_wallet=True) -> str:
|
||||
current_cosigner = self.current_cosigner(wizard_data)
|
||||
_type, _info = current_cosigner['hardware_device']
|
||||
run_hook('init_wallet_wizard', self) # TODO: currently only used for hww, hook name might be confusing
|
||||
plugin = self.plugins.get_plugin(_type)
|
||||
run_hook('init_wallet_wizard', self) # TODO: currently only used for hww, hook name might be confusing
|
||||
return plugin.wizard_entry_for_device(_info, new_wallet=new_wallet)
|
||||
|
||||
def validate_seed(self, seed: str, seed_variant: str, wallet_type: str) -> Tuple[bool, str, str, bool]:
|
||||
|
||||
Reference in New Issue
Block a user