Update the ragger app client to support "set external plugin" APDU and take into account PR review remarks

This commit is contained in:
tdejoigny-ledger
2023-08-04 13:43:03 +02:00
committed by Alexandre Paillier
parent eeb52344df
commit 5d1d16c2de
4 changed files with 66 additions and 30 deletions

View File

@@ -1,3 +1,6 @@
# documentation about APDU format is available here:
# https://github.com/LedgerHQ/app-ethereum/blob/develop/doc/ethapp.adoc
import struct
from enum import IntEnum
from typing import Optional
@@ -18,6 +21,7 @@ class InsType(IntEnum):
EIP712_SIGN = 0x0c
GET_CHALLENGE = 0x20
PROVIDE_DOMAIN_NAME = 0x22
EXTERNAL_PLUGIN_SETUP = 0x12
class P1Type(IntEnum):
@@ -178,6 +182,19 @@ 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:
data = bytearray()
data.append(len(plugin_name))
data += self._string_to_bytes(plugin_name)
data += contract_address
data += method_selelector
data += sig
return self._serialize(InsType.EXTERNAL_PLUGIN_SETUP,
P1Type.COMPLETE_SEND,
0x00,
data)
def sign(self, bip32_path: str, rlp_data: bytes) -> list[bytes]:
apdus = list()
payload = pack_derivation_path(bip32_path)