Skip to content

Commit

Permalink
Add date/time support in client
Browse files Browse the repository at this point in the history
  • Loading branch information
apaillier-ledger committed May 21, 2024
1 parent e0d0929 commit 1caed76
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions client/src/ledger_app_clients/ethereum/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ def eip712_filtering_amount_join_value(self, token_idx: int, name: str, sig: byt
name,
sig))

def eip712_filtering_datetime(self, name: str, sig: bytes):
return self._exchange_async(self._cmd_builder.eip712_filtering_datetime(name, sig))

def eip712_filtering_raw(self, name: str, sig: bytes):
return self._exchange_async(self._cmd_builder.eip712_filtering_raw(name, sig))

Expand Down
7 changes: 7 additions & 0 deletions client/src/ledger_app_clients/ethereum/command_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class P2Type(IntEnum):
NEW_IMPLEM = 0x01
FILTERING_ACTIVATE = 0x00
FILTERING_MESSAGE_INFO = 0x0f
FILTERING_DATETIME = 0xfc
FILTERING_TOKEN_ADDR_CHECK = 0xfd
FILTERING_AMOUNT_FIELD = 0xfe
FILTERING_RAW = 0xff
Expand Down Expand Up @@ -197,6 +198,12 @@ def eip712_filtering_amount_join_value(self, token_idx: int, name: str, sig: byt
P2Type.FILTERING_AMOUNT_FIELD,
data)

def eip712_filtering_datetime(self, name: str, sig: bytes) -> bytes:
return self._serialize(InsType.EIP712_SEND_FILTERING,
P1Type.COMPLETE_SEND,
P2Type.FILTERING_DATETIME,
self._eip712_filtering_send_name(name, sig))

def eip712_filtering_raw(self, name: str, sig: bytes) -> bytes:
return self._serialize(InsType.EIP712_SEND_FILTERING,
P1Type.COMPLETE_SEND,
Expand Down
15 changes: 15 additions & 0 deletions client/src/ledger_app_clients/ethereum/eip712/InputData.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ def send_struct_impl_field(value, field):
elif filtering_paths[path]["type"] == "amount_join_value":
send_filtering_amount_join_value(filtering_paths[path]["token"],
filtering_paths[path]["name"])
elif filtering_paths[path]["type"] == "datetime":
send_filtering_datetime(filtering_paths[path]["name"])
elif filtering_paths[path]["type"] == "raw":
send_filtering_raw(filtering_paths[path]["name"])
else:
Expand Down Expand Up @@ -311,6 +313,19 @@ def send_filtering_amount_join_value(token_idx: int, display_name: str):
pass


def send_filtering_datetime(display_name: str):
global sig_ctx

path_str = ".".join(current_path)

to_sign = start_signature_payload(sig_ctx, 33)
to_sign += path_str.encode()
to_sign += display_name.encode()
sig = keychain.sign_data(keychain.Key.CAL, to_sign)
with app_client.eip712_filtering_datetime(display_name, sig):
pass


# ledgerjs doesn't actually sign anything, and instead uses already pre-computed signatures
def send_filtering_raw(display_name):
global sig_ctx
Expand Down

0 comments on commit 1caed76

Please sign in to comment.