Skip to content

Commit

Permalink
Merge pull request #599 from LedgerHQ/feat/apa/eip712_amount_join_exp…
Browse files Browse the repository at this point in the history
…licit_unlimited

Explicit unlimited EIP-712 amount-join
  • Loading branch information
apaillier-ledger authored Jun 24, 2024
2 parents c6a6141 + f259889 commit 0623a8c
Show file tree
Hide file tree
Showing 22 changed files with 80 additions and 8 deletions.
21 changes: 14 additions & 7 deletions src_features/signMessageEIP712/ui_logic.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,13 +413,20 @@ static bool ui_712_format_amount_join(void) {
const tokenDefinition_t *token;
token = &tmpCtx.transactionContext.extraInfo[ui_ctx->amount.idx].token;

if (!amountToString(ui_ctx->amount.joins[ui_ctx->amount.idx].value,
ui_ctx->amount.joins[ui_ctx->amount.idx].value_length,
token->decimals,
token->ticker,
strings.tmp.tmp,
sizeof(strings.tmp.tmp))) {
return false;
if ((ui_ctx->amount.joins[ui_ctx->amount.idx].value_length == INT256_LENGTH) &&
ismaxint(ui_ctx->amount.joins[ui_ctx->amount.idx].value,
ui_ctx->amount.joins[ui_ctx->amount.idx].value_length)) {
strlcpy(strings.tmp.tmp, "Unlimited ", sizeof(strings.tmp.tmp));
strlcat(strings.tmp.tmp, token->ticker, sizeof(strings.tmp.tmp));
} else {
if (!amountToString(ui_ctx->amount.joins[ui_ctx->amount.idx].value,
ui_ctx->amount.joins[ui_ctx->amount.idx].value_length,
token->decimals,
token->ticker,
strings.tmp.tmp,
sizeof(strings.tmp.tmp))) {
return false;
}
}
ui_ctx->field_flags |= UI_712_FIELD_SHOWN;
ui_712_set_title(ui_ctx->amount.joins[ui_ctx->amount.idx].name,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 66 additions & 1 deletion tests/ragger/test_eip712.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
from pathlib import Path
import json
from typing import Optional
from ctypes import c_uint64
import pytest
from eth_account.messages import encode_typed_data
import web3

from ragger.backend import BackendInterface
from ragger.firmware import Firmware
Expand Down Expand Up @@ -298,7 +300,7 @@ def __init__(self, data: dict, filters: dict, suffix: str = ""):
"chainId": 1,
},
"message": {
"owner": "0xb5a6948372defdfc5754b69dc831d21e2d5ebd74",
"owner": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
"spender": "0x5B38Da6a701c568545dCfcB03FcB875f56beddC4",
"value": 4200000000000000000,
"nonce": 0,
Expand Down Expand Up @@ -328,6 +330,69 @@ def __init__(self, data: dict, filters: dict, suffix: str = ""):
},
"_permit"
),
DataSet(
{
"types": {
"EIP712Domain": [
{"name": "name", "type": "string"},
{"name": "version", "type": "string"},
{"name": "chainId", "type": "uint256"},
{"name": "verifyingContract", "type": "address"},
],
"Root": [
{"name": "token_big", "type": "address"},
{"name": "value_big", "type": "uint256"},
{"name": "token_biggest", "type": "address"},
{"name": "value_biggest", "type": "uint256"},
]
},
"primaryType": "Root",
"domain": {
"name": "test",
"version": "1",
"verifyingContract": "0x0000000000000000000000000000000000000000",
"chainId": 1,
},
"message": {
"token_big": "0x6b175474e89094c44da98b954eedeac495271d0f",
"value_big": c_uint64(-1).value,
"token_biggest": "0x6b175474e89094c44da98b954eedeac495271d0f",
"value_biggest": int(web3.constants.MAX_INT, 0),
}
},
{
"name": "Unlimited test",
"tokens": [
{
"addr": "0x6b175474e89094c44da98b954eedeac495271d0f",
"ticker": "DAI",
"decimals": 18,
"chain_id": 1,
},
],
"fields": {
"token_big": {
"type": "amount_join_token",
"token": 0,
},
"value_big": {
"type": "amount_join_value",
"name": "Big",
"token": 0,
},
"token_biggest": {
"type": "amount_join_token",
"token": 0,
},
"value_biggest": {
"type": "amount_join_value",
"name": "Biggest",
"token": 0,
},
}
},
"_unlimited"
),
]


Expand Down

0 comments on commit 0623a8c

Please sign in to comment.