diff --git a/client/src/ledger_app_clients/ethereum/client.py b/client/src/ledger_app_clients/ethereum/client.py index 150cfb9..d2015a1 100644 --- a/client/src/ledger_app_clients/ethereum/client.py +++ b/client/src/ledger_app_clients/ethereum/client.py @@ -271,6 +271,16 @@ class EthAppClient: algo_id, sig)) + def set_external_plugin(self, + plugin_name: str, + contract_address: bytes, + method_selelector: bytes, + sig: Optional[bytes] = None): + if sig is None: + # Temporarily get a command with an empty signature to extract the payload and + # compute the signature on it + tmp = self._cmd_builder.set_external_plugin(plugin_name, contract_address, method_selelector, bytes()) - def external_plugin_setup(self, plugin_name: str, contract_address: bytes, method_selelector: bytes, sig: bytes): - return self._send(self._cmd_builder.external_plugin_setup(plugin_name, contract_address, method_selelector, sig)) + # skip APDU header & empty sig + sig = sign_data(Key.SET_PLUGIN, tmp[5:-1]) + return self._send(self._cmd_builder.set_external_plugin(plugin_name, contract_address, method_selelector, sig)) diff --git a/client/src/ledger_app_clients/ethereum/command_builder.py b/client/src/ledger_app_clients/ethereum/command_builder.py index caed1d9..4170a30 100644 --- a/client/src/ledger_app_clients/ethereum/command_builder.py +++ b/client/src/ledger_app_clients/ethereum/command_builder.py @@ -182,7 +182,7 @@ class CommandBuilder: P2Type.FILTERING_FIELD_NAME, self._eip712_filtering_send_name(name, sig)) - def external_plugin_setup(self, plugin_name: str, contract_address: bytes, method_selelector: bytes, sig: bytes) -> bytes: + def set_external_plugin(self, plugin_name: str, contract_address: bytes, method_selelector: bytes, sig: bytes) -> bytes: data = bytearray() data.append(len(plugin_name)) data += self._string_to_bytes(plugin_name)