diff --git a/client/CHANGELOG.md b/client/CHANGELOG.md index b20c1b4..b67daf0 100644 --- a/client/CHANGELOG.md +++ b/client/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.4.1] - 2024-04-05 + +### Added + +- Add new function `send_raw`, allowing to send a raw payload APDU +- Add new error code definition + ## [0.4.0] - 2024-04-03 ### Added diff --git a/client/src/ledger_app_clients/ethereum/__init__.py b/client/src/ledger_app_clients/ethereum/__init__.py index ce05207..1f628c4 100644 --- a/client/src/ledger_app_clients/ethereum/__init__.py +++ b/client/src/ledger_app_clients/ethereum/__init__.py @@ -1,4 +1,4 @@ try: - from ledger_app_clients.ethereum.__version__ import __version__ # noqa + from __version__ import __version__ # noqa except ImportError: __version__ = "unknown version" # noqa diff --git a/client/src/ledger_app_clients/ethereum/client.py b/client/src/ledger_app_clients/ethereum/client.py index 3e1feaa..52dc06f 100644 --- a/client/src/ledger_app_clients/ethereum/client.py +++ b/client/src/ledger_app_clients/ethereum/client.py @@ -21,6 +21,7 @@ class StatusWord(IntEnum): INVALID_P1_P2 = 0x6b00 CONDITION_NOT_SATISFIED = 0x6985 REF_DATA_NOT_FOUND = 0x6a88 + EXCEPTION_OVERFLOW = 0x6807 class DomainNameTag(IntEnum): @@ -49,6 +50,15 @@ class EthAppClient: def response(self) -> Optional[RAPDU]: return self._client.last_async_response + def send_raw(self, cla: int, ins: int, p1: int, p2: int, payload: bytes): + header = bytearray() + header.append(cla) + header.append(ins) + header.append(p1) + header.append(p2) + header.append(len(payload)) + return self._exchange(header + payload) + def eip712_send_struct_def_struct_name(self, name: str): return self._exchange_async(self._cmd_builder.eip712_send_struct_def_struct_name(name)) @@ -131,6 +141,12 @@ class EthAppClient: bip32_path, chain_id)) + def get_eth2_public_addr(self, + display: bool = True, + bip32_path: str = "m/12381/3600/0/0"): + return self._exchange_async(self._cmd_builder.get_eth2_public_addr(display, + bip32_path)) + def provide_domain_name(self, challenge: int, name: str, addr: bytes) -> RAPDU: payload = format_tlv(DomainNameTag.STRUCTURE_TYPE, 3) # TrustedDomainName payload += format_tlv(DomainNameTag.STRUCTURE_VERSION, 1) diff --git a/client/src/ledger_app_clients/ethereum/command_builder.py b/client/src/ledger_app_clients/ethereum/command_builder.py index 0ba0809..9c60a6a 100644 --- a/client/src/ledger_app_clients/ethereum/command_builder.py +++ b/client/src/ledger_app_clients/ethereum/command_builder.py @@ -11,6 +11,7 @@ from .eip712 import EIP712FieldType class InsType(IntEnum): GET_PUBLIC_ADDR = 0x02 + GET_ETH2_PUBLIC_ADDR = 0x0e SIGN = 0x04 PERSONAL_SIGN = 0x08 PROVIDE_ERC20_TOKEN_INFORMATION = 0x0a @@ -250,6 +251,15 @@ class CommandBuilder: int(chaincode), payload) + def get_eth2_public_addr(self, + display: bool, + bip32_path: str) -> bytes: + payload = pack_derivation_path(bip32_path) + return self._serialize(InsType.GET_ETH2_PUBLIC_ADDR, + int(display), + 0x00, + payload) + def set_plugin(self, type_: int, version: int, diff --git a/client/src/ledger_app_clients/ethereum/eip712/InputData.py b/client/src/ledger_app_clients/ethereum/eip712/InputData.py index a19ccf3..e10bb24 100644 --- a/client/src/ledger_app_clients/ethereum/eip712/InputData.py +++ b/client/src/ledger_app_clients/ethereum/eip712/InputData.py @@ -6,8 +6,8 @@ import sys import copy from typing import Any, Callable, Optional -from ledger_app_clients.ethereum import keychain -from ledger_app_clients.ethereum.client import EthAppClient, EIP712FieldType +from client import keychain +from client.client import EthAppClient, EIP712FieldType # global variables