hww: fix HardwareClientBase not having reference to plugin
it was incorrectly documented that it did (previously only for some plugins)
This commit is contained in:
@@ -44,7 +44,8 @@ _logger = get_logger(__name__)
|
||||
|
||||
class BitBox02Client(HardwareClientBase):
|
||||
# handler is a BitBox02_Handler, importing it would lead to a circular dependency
|
||||
def __init__(self, handler: Any, device: Device, config: SimpleConfig):
|
||||
def __init__(self, handler: Any, device: Device, config: SimpleConfig, *, plugin: HW_PluginBase):
|
||||
HardwareClientBase.__init__(self, plugin=plugin)
|
||||
self.bitbox02_device = None
|
||||
self.handler = handler
|
||||
self.device_descriptor = device
|
||||
@@ -556,12 +557,11 @@ class BitBox02Plugin(HW_PluginBase):
|
||||
else:
|
||||
raise ImportError()
|
||||
|
||||
|
||||
# handler is a BitBox02_Handler
|
||||
def create_client(self, device: Device, handler: Any) -> BitBox02Client:
|
||||
if not handler:
|
||||
self.handler = handler
|
||||
return BitBox02Client(handler, device, self.config)
|
||||
return BitBox02Client(handler, device, self.config, plugin=self)
|
||||
|
||||
def setup_device(
|
||||
self, device_info: DeviceInfo, wizard: BaseWizard, purpose: int
|
||||
|
||||
@@ -60,7 +60,8 @@ CKCC_SIMULATED_PID = CKCC_PID ^ 0x55aa
|
||||
|
||||
class CKCCClient(HardwareClientBase):
|
||||
|
||||
def __init__(self, plugin, handler, dev_path, is_simulator=False):
|
||||
def __init__(self, plugin, handler, dev_path, *, is_simulator=False):
|
||||
HardwareClientBase.__init__(self, plugin=plugin)
|
||||
self.device = plugin.device
|
||||
self.handler = handler
|
||||
|
||||
@@ -515,7 +516,7 @@ class ColdcardPlugin(HW_PluginBase):
|
||||
# the 'path' is unabiguous, so we'll use that.
|
||||
try:
|
||||
rv = CKCCClient(self, handler, device.path,
|
||||
is_simulator=(device.product_key[1] == CKCC_SIMULATED_PID))
|
||||
is_simulator=(device.product_key[1] == CKCC_SIMULATED_PID))
|
||||
return rv
|
||||
except:
|
||||
self.logger.info('late failure connecting to device?')
|
||||
|
||||
@@ -66,7 +66,7 @@ CHANNEL_ID_KEY = 'comserverchannelid'
|
||||
class DigitalBitbox_Client(HardwareClientBase):
|
||||
|
||||
def __init__(self, plugin, hidDevice):
|
||||
self.plugin = plugin
|
||||
HardwareClientBase.__init__(self, plugin=plugin)
|
||||
self.dbb_hid = hidDevice
|
||||
self.opened = True
|
||||
self.password = None
|
||||
|
||||
@@ -191,9 +191,11 @@ class HW_PluginBase(BasePlugin):
|
||||
|
||||
class HardwareClientBase:
|
||||
|
||||
plugin: 'HW_PluginBase'
|
||||
handler = None # type: Optional['HardwareHandlerBase']
|
||||
|
||||
def __init__(self, *, plugin: 'HW_PluginBase'):
|
||||
self.plugin = plugin
|
||||
|
||||
def is_pairable(self) -> bool:
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
@@ -103,6 +103,7 @@ class KeepKeyClientBase(HardwareClientBase, GuiMixin, Logger):
|
||||
|
||||
def __init__(self, handler, plugin, proto):
|
||||
assert hasattr(self, 'tx_api') # ProtocolMixin already constructed?
|
||||
HardwareClientBase.__init__(self, plugin=plugin)
|
||||
self.proto = proto
|
||||
self.device = plugin.device
|
||||
self.handler = handler
|
||||
|
||||
@@ -62,7 +62,9 @@ def test_pin_unlocked(func):
|
||||
|
||||
|
||||
class Ledger_Client(HardwareClientBase):
|
||||
def __init__(self, hidDevice, *, product_key: Tuple[int, int]):
|
||||
def __init__(self, hidDevice, *, product_key: Tuple[int, int],
|
||||
plugin: HW_PluginBase):
|
||||
HardwareClientBase.__init__(self, plugin=plugin)
|
||||
self.dongleObject = btchip(hidDevice)
|
||||
self.preflightDone = False
|
||||
self._product_key = product_key
|
||||
@@ -602,7 +604,7 @@ class LedgerPlugin(HW_PluginBase):
|
||||
|
||||
client = self.get_btchip_device(device)
|
||||
if client is not None:
|
||||
client = Ledger_Client(client, product_key=device.product_key)
|
||||
client = Ledger_Client(client, product_key=device.product_key, plugin=self)
|
||||
return client
|
||||
|
||||
def setup_device(self, device_info, wizard, purpose):
|
||||
|
||||
@@ -105,6 +105,7 @@ class SafeTClientBase(HardwareClientBase, GuiMixin, Logger):
|
||||
|
||||
def __init__(self, handler, plugin, proto):
|
||||
assert hasattr(self, 'tx_api') # ProtocolMixin already constructed?
|
||||
HardwareClientBase.__init__(self, plugin=plugin)
|
||||
self.proto = proto
|
||||
self.device = plugin.device
|
||||
self.handler = handler
|
||||
|
||||
@@ -40,10 +40,10 @@ MESSAGES = {
|
||||
|
||||
class TrezorClientBase(HardwareClientBase, Logger):
|
||||
def __init__(self, transport, handler, plugin):
|
||||
HardwareClientBase.__init__(self, plugin=plugin)
|
||||
if plugin.is_outdated_fw_ignored():
|
||||
TrezorClient.is_outdated = lambda *args, **kwargs: False
|
||||
self.client = TrezorClient(transport, ui=self)
|
||||
self.plugin = plugin
|
||||
self.device = plugin.device
|
||||
self.handler = handler
|
||||
Logger.__init__(self)
|
||||
|
||||
Reference in New Issue
Block a user