Merge remote-tracking branch 'ledgertech/master' into jlm-copy-for-moonriver

This commit is contained in:
estienne.antoine@gmail.com
2021-10-04 18:57:47 +02:00
231 changed files with 625 additions and 5972 deletions

2
.gitignore vendored
View File

@@ -15,6 +15,6 @@ tests/node_modules
tests/lib
tests/yarn-error.log
tests/elfs/*
tests/snapshots/tmp/*
tests/snapshots-tmp
.vscode

View File

@@ -5,6 +5,34 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [1.9.7](https://github.com/ledgerhq/app-ethereum/compare/1.9.6...1.9.7) - 2021-9-30
### Fixed
- Fixed a bug where amounts displayed where wrong when the amount was huge (>=2^87)
## [1.9.6](https://github.com/ledgerhq/app-ethereum/compare/1.9.5...1.9.6) - 2021-9-29
### Fixed
- Fixed a bug where fees displayed were wrong on Starkware transactions
## [1.9.5](https://github.com/ledgerhq/app-ethereum/compare/1.9.4...1.9.5) - 2021-9-27
### Changed
- "Contract Data" is now replaced with "Blind sign", which carries more meaning for regular users.
### Added
- When blind signing is disabled in settings, and a transaction with smart conract interactions is sent to the app, a new warning screen pops to let the user know that the setting must be enabled to sign this kind of transactions.
## [1.9.4](https://github.com/ledgerhq/app-ethereum/compare/1.9.3...1.9.4) - 2021-9-14
### Added
- Added Arbitrum network
## [1.9.3](https://github.com/ledgerhq/app-ethereum/compare/1.9.2...1.9.3) - 2021-9-03
### Added

View File

@@ -30,7 +30,7 @@ APP_LOAD_PARAMS += --path "1517992542'/1101353413'"
APPVERSION_M=1
APPVERSION_N=9
APPVERSION_P=3
APPVERSION_P=7
APPVERSION=$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)
APP_LOAD_FLAGS= --appFlags 0x240 --dep Ethereum:$(APPVERSION)

View File

@@ -8,7 +8,7 @@ To compile it and load it on a device, please check out our [developer portal](h
# Plugins
This app support external plugins. More info in [doc/ethapp_plugin.asc](https://github.com/LedgerHQ/app-ethereum/blob/master/doc/ethapp_plugins.asc). If you wish to have a look at an existing plugin, feel free to check out the [ParaSwap plugin](https://github.com/LedgerHQ/app-plugin-paraswap).
This app support external plugins. More info in [doc/ethapp_plugin.asc](https://github.com/LedgerHQ/app-ethereum/blob/master/doc/ethapp_plugins.asc). If you wish to have a look at an existing plugin, feel free to check out the [Boilerplate plugin](https://github.com/LedgerHQ/app-plugin-boilerplate).
# Testing

View File

@@ -92,6 +92,10 @@ void ui_idle(void) {
ux_flow_init(0, ux_idle_flow, NULL);
}
void ui_warning_contract_data(void) {
ux_flow_init(0, ux_warning_contract_data_flow, NULL);
}
unsigned int io_seproxyhal_touch_exit(__attribute__((unused)) const bagl_element_t *e) {
// Go back to the dashboard
os_sched_exit(0);

View File

@@ -166,7 +166,7 @@ typedef enum {
typedef struct txStringProperties_t {
char fullAddress[43];
char fullAmount[50];
char fullAmount[67];
char maxFee[50];
char nonce[8]; // 10M tx per account ought to be enough for everybody
char network_name[NETWORK_STRING_MAX_SIZE];

File diff suppressed because it is too large Load Diff

View File

@@ -64,9 +64,11 @@ static const uint8_t LEDGER_SIGNATURE_PUBLIC_KEY[] = {
#else
// These defines need to follow tokens.c
#define NUM_TOKENS_AKROMA 0
#define NUM_TOKENS_ELLAISM 1
#define NUM_TOKENS_ETHEREUM 1102
#define NUM_TOKENS_ETHEREUM 2
#define NUM_TOKENS_ETHEREUM_CLASSIC 4
#define NUM_TOKENS_ETHERSOCIAL 0
#define NUM_TOKENS_ETHER1 0

View File

@@ -16,6 +16,7 @@ unsigned int io_seproxyhal_touch_signMessage712_v0_cancel(const bagl_element_t *
unsigned int io_seproxyhal_touch_eth2_address_ok(const bagl_element_t *e);
void ui_idle(void);
void ui_warning_contract_data(void);
void io_seproxyhal_send_status(uint32_t sw);
void format_signature_out(const uint8_t *signature);

View File

@@ -2,7 +2,7 @@
#include "ui_callbacks.h"
void display_settings(const ux_flow_step_t* const start_step);
void switch_settings_contract_data(void);
void switch_settings_blind_signing(void);
void switch_settings_display_data(void);
void switch_settings_display_nonce(void);
@@ -54,9 +54,9 @@ UX_FLOW(ux_idle_flow,
UX_STEP_CB(
ux_settings_flow_1_step,
bnnn_paging,
switch_settings_contract_data(),
switch_settings_blind_signing(),
{
.title = "Contract data",
.title = "Blind signing",
.text = strings.common.fullAddress,
});
@@ -83,11 +83,11 @@ UX_STEP_CB(
UX_STEP_CB(
ux_settings_flow_1_step,
bnnn,
switch_settings_contract_data(),
switch_settings_blind_signing(),
{
"Contract data",
"Allow contract data",
"in transactions",
"Blind signing",
"Enable transaction",
"blind signing",
strings.common.fullAddress,
});
@@ -132,7 +132,7 @@ UX_FLOW(ux_settings_flow,
&ux_settings_flow_4_step);
void display_settings(const ux_flow_step_t* const start_step) {
strlcpy(strings.common.fullAddress, (N_storage.dataAllowed ? "Allowed" : "NOT Allowed"), 12);
strlcpy(strings.common.fullAddress, (N_storage.dataAllowed ? "Enabled" : "NOT Enabled"), 12);
strlcpy(strings.common.fullAddress + 12,
(N_storage.contractDetails ? "Displayed" : "NOT Displayed"),
26 - 12);
@@ -142,7 +142,7 @@ void display_settings(const ux_flow_step_t* const start_step) {
ux_flow_init(0, ux_settings_flow, start_step);
}
void switch_settings_contract_data() {
void switch_settings_blind_signing() {
uint8_t value = (N_storage.dataAllowed ? 0 : 1);
nvm_write((void*) &N_storage.dataAllowed, (void*) &value, sizeof(uint8_t));
display_settings(&ux_settings_flow_1_step);
@@ -159,3 +159,29 @@ void switch_settings_display_nonce() {
nvm_write((void*) &N_storage.displayNonce, (void*) &value, sizeof(uint8_t));
display_settings(&ux_settings_flow_3_step);
}
//////////////////////////////////////////////////////////////////////
// clang-format off
#if defined(TARGET_NANOS)
UX_STEP_CB(
ux_warning_contract_data_step,
bnnn_paging,
ui_idle(),
{
"Error",
"Blind signing must be enabled in Settings",
});
#elif defined(TARGET_NANOX)
UX_STEP_CB(
ux_warning_contract_data_step,
pnn,
ui_idle(),
{
&C_icon_crossmark,
"Blind signing must be",
"enabled in Settings",
});
#endif
// clang-format on
UX_FLOW(ux_warning_contract_data_flow, &ux_warning_contract_data_step);

View File

@@ -5,6 +5,8 @@
extern const ux_flow_step_t* const ux_idle_flow[];
extern const ux_flow_step_t* const ux_warning_contract_data_flow[];
extern const ux_flow_step_t* const ux_settings_flow[];
extern const ux_flow_step_t* const ux_display_public_flow[];

View File

@@ -118,10 +118,8 @@ void amountToString(const uint8_t *amount,
uint8_t out_buffer_size) {
char tmp_buffer[100] = {0};
bool success = uint256_to_decimal(amount, amount_size, tmp_buffer, sizeof(tmp_buffer));
if (!success) {
THROW(0x6504);
if (uint256_to_decimal(amount, amount_size, tmp_buffer, sizeof(tmp_buffer)) == false) {
THROW(EXCEPTION_OVERFLOW);
}
uint8_t amount_len = strnlen(tmp_buffer, sizeof(tmp_buffer));
@@ -129,11 +127,14 @@ void amountToString(const uint8_t *amount,
memcpy(out_buffer, ticker, MIN(out_buffer_size, ticker_len));
adjustDecimals(tmp_buffer,
amount_len,
out_buffer + ticker_len,
out_buffer_size - ticker_len - 1,
decimals);
if (adjustDecimals(tmp_buffer,
amount_len,
out_buffer + ticker_len,
out_buffer_size - ticker_len - 1,
decimals) == false) {
THROW(EXCEPTION_OVERFLOW);
}
out_buffer[out_buffer_size - 1] = '\0';
}

View File

@@ -19,6 +19,7 @@ const network_info_t NETWORK_MAPPING[] = {
{.chain_id = 100, .name = "xDai", .ticker = "xDAI "},
{.chain_id = 137, .name = "Polygon", .ticker = "MATIC "},
{.chain_id = 250, .name = "Fantom", .ticker = "FTM "},
{.chain_id = 42161, .name = "Arbitrum", .ticker = "AETH "},
{.chain_id = 42220, .name = "Celo", .ticker = "CELO "},
{.chain_id = 43114, .name = "Avalanche", .ticker = "AVAX "},
{.chain_id = 44787, .name = "Celo Alfajores", .ticker = "aCELO "},

View File

@@ -81,6 +81,7 @@ customStatus_e customProcessor(txContext_t *context) {
if (fieldPos == 0) { // not reached if a plugin is available
if (!N_storage.dataAllowed) {
PRINTF("Data field forbidden\n");
ui_warning_contract_data();
return CUSTOM_FAULT;
}
if (!N_storage.contractDetails) {
@@ -407,6 +408,7 @@ void finalizeParsing(bool direct) {
if (tmpContent.txContent.dataPresent && !N_storage.dataAllowed) {
reportFinalizeError(direct);
ui_warning_contract_data();
if (!direct) {
return;
}
@@ -438,7 +440,7 @@ void finalizeParsing(bool direct) {
displayBuffer,
sizeof(displayBuffer));
compareOrCopy(strings.common.fullAmount,
sizeof(strings.common.fullAddress),
sizeof(strings.common.fullAmount),
displayBuffer,
called_from_swap);
}

View File

@@ -187,12 +187,12 @@ UX_STEP_NOCB(
.text = strings.common.nonce,
});
UX_STEP_NOCB(ux_approval_data_warning_step,
UX_STEP_NOCB(ux_approval_blind_signing_warning_step,
pbb,
{
&C_icon_warning,
"Data",
"Present",
"Blind",
"Signing",
});
// clang-format on
@@ -203,7 +203,7 @@ void ux_approve_tx(bool fromPlugin) {
ux_approval_tx_flow[step++] = &ux_approval_review_step;
if (!fromPlugin && tmpContent.txContent.dataPresent && !N_storage.contractDetails) {
ux_approval_tx_flow[step++] = &ux_approval_data_warning_step;
ux_approval_tx_flow[step++] = &ux_approval_blind_signing_warning_step;
}
if (fromPlugin) {

View File

@@ -167,6 +167,9 @@ typedef struct starkware_parameters_t {
} starkware_parameters_t;
#define STARK_KEY_LENGTH (2 + length * 2 + 1)
#define VAULT_ID_LENGTH 10
bool is_deversify_contract(const uint8_t *address) {
uint32_t offset = 0;
uint8_t i;
@@ -271,12 +274,21 @@ bool starkware_verify_nft_token_id(uint8_t *tokenId) {
return true;
}
void starkware_print_vault_id(uint32_t vaultId, char *destination) {
snprintf(destination, 10, "%d", vaultId);
void starkware_print_vault_id(uint32_t vaultId, char *destination, size_t max_length) {
if (VAULT_ID_LENGTH > max_length) {
os_sched_exit(EXCEPTION_OVERFLOW);
}
snprintf(destination, max_length, "%d", vaultId);
}
void starkware_print_stark_key(uint8_t *starkKey, char *destination) {
snprintf(destination, 70, "0x%.*H", 32, starkKey);
void starkware_print_stark_key(uint8_t *starkKey,
size_t length,
char *destination,
size_t max_length) {
if (STARK_KEY_LENGTH > max_length) {
os_sched_exit(EXCEPTION_OVERFLOW);
}
snprintf(destination, max_length, "0x%.*H", length, starkKey);
}
// TODO : rewrite as independant code
@@ -741,7 +753,10 @@ void starkware_plugin_call(int message, void *parameters) {
case STARKWARE_WITHDRAW_NFT:
case STARKWARE_WITHDRAW_NFT_TO:
strlcpy(msg->title, "Master Account", msg->titleLength);
starkware_print_stark_key(context->starkKey, msg->msg);
starkware_print_stark_key(context->starkKey,
sizeof(context->starkKey),
msg->msg,
msg->msgLength);
break;
default:
PRINTF("Unexpected screen %d for %d\n",
@@ -758,7 +773,10 @@ void starkware_plugin_call(int message, void *parameters) {
case STARKWARE_REGISTER_AND_DEPOSIT_TOKEN:
case STARKWARE_REGISTER_AND_DEPOSIT_ETH:
strlcpy(msg->title, "Master Account", msg->titleLength);
starkware_print_stark_key(context->starkKey, msg->msg);
starkware_print_stark_key(context->starkKey,
sizeof(context->starkKey),
msg->msg,
msg->msgLength);
break;
case STARKWARE_DEPOSIT_TOKEN:
@@ -772,7 +790,9 @@ void starkware_plugin_call(int message, void *parameters) {
case STARKWARE_DEPOSIT_NFT:
case STARKWARE_DEPOSIT_NFT_RECLAIM:
strlcpy(msg->title, "Token Account", msg->titleLength);
starkware_print_vault_id(U4BE(context->vaultId, 0), msg->msg);
starkware_print_vault_id(U4BE(context->vaultId, 0),
msg->msg,
msg->msgLength);
break;
case STARKWARE_WITHDRAW:
case STARKWARE_WITHDRAW_NFT:
@@ -806,7 +826,9 @@ void starkware_plugin_call(int message, void *parameters) {
switch (context->selectorIndex) {
case STARKWARE_ESCAPE:
strlcpy(msg->title, "Token Account", msg->titleLength);
starkware_print_vault_id(U4BE(context->vaultId, 0), msg->msg);
starkware_print_vault_id(U4BE(context->vaultId, 0),
msg->msg,
msg->msgLength);
break;
case STARKWARE_DEPOSIT_TOKEN:
case STARKWARE_DEPOSIT_ETH:
@@ -839,7 +861,9 @@ void starkware_plugin_call(int message, void *parameters) {
case STARKWARE_REGISTER_AND_DEPOSIT_TOKEN:
case STARKWARE_REGISTER_AND_DEPOSIT_ETH:
strlcpy(msg->title, "Token Account", msg->titleLength);
starkware_print_vault_id(U4BE(context->vaultId, 0), msg->msg);
starkware_print_vault_id(U4BE(context->vaultId, 0),
msg->msg,
msg->msgLength);
break;
default:
@@ -858,7 +882,10 @@ void starkware_plugin_call(int message, void *parameters) {
case STARKWARE_DEPOSIT_NFT:
case STARKWARE_DEPOSIT_NFT_RECLAIM:
strlcpy(msg->title, "TokenID", msg->titleLength);
starkware_print_stark_key(dataContext.tokenContext.quantum, msg->msg);
starkware_print_stark_key(dataContext.tokenContext.quantum,
sizeof(dataContext.tokenContext.quantum),
msg->msg,
msg->msgLength);
break;
case STARKWARE_REGISTER_AND_DEPOSIT_TOKEN:

View File

@@ -1,8 +1,8 @@
#!/bin/bash
# FILL THESE WITH YOUR OWN SDKs PATHS
NANOS_SDK=$TWO
NANOX_SDK=$X
# NANOS_SDK=
# NANOX_SDK=
# list of apps required by tests that we want to build here
appnames=("ethereum" "ethereum_classic")

Binary file not shown.

Before

Width:  |  Height:  |  Size: 518 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 600 B

View File

Before

Width:  |  Height:  |  Size: 541 B

After

Width:  |  Height:  |  Size: 541 B

View File

Before

Width:  |  Height:  |  Size: 455 B

After

Width:  |  Height:  |  Size: 455 B

View File

Before

Width:  |  Height:  |  Size: 510 B

After

Width:  |  Height:  |  Size: 510 B

View File

Before

Width:  |  Height:  |  Size: 790 B

After

Width:  |  Height:  |  Size: 790 B

View File

Before

Width:  |  Height:  |  Size: 824 B

After

Width:  |  Height:  |  Size: 824 B

View File

Before

Width:  |  Height:  |  Size: 602 B

After

Width:  |  Height:  |  Size: 602 B

View File

Before

Width:  |  Height:  |  Size: 606 B

After

Width:  |  Height:  |  Size: 606 B

View File

Before

Width:  |  Height:  |  Size: 582 B

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 B

View File

Before

Width:  |  Height:  |  Size: 541 B

After

Width:  |  Height:  |  Size: 541 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 503 B

View File

Before

Width:  |  Height:  |  Size: 431 B

After

Width:  |  Height:  |  Size: 431 B

View File

Before

Width:  |  Height:  |  Size: 772 B

After

Width:  |  Height:  |  Size: 772 B

View File

Before

Width:  |  Height:  |  Size: 813 B

After

Width:  |  Height:  |  Size: 813 B

View File

Before

Width:  |  Height:  |  Size: 590 B

After

Width:  |  Height:  |  Size: 590 B

View File

Before

Width:  |  Height:  |  Size: 619 B

After

Width:  |  Height:  |  Size: 619 B

View File

Before

Width:  |  Height:  |  Size: 582 B

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 514 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 566 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 614 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 B

View File

Before

Width:  |  Height:  |  Size: 541 B

After

Width:  |  Height:  |  Size: 541 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 829 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 809 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 622 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 774 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 882 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 884 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 759 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 458 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 586 B

View File

Before

Width:  |  Height:  |  Size: 582 B

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 B

View File

Before

Width:  |  Height:  |  Size: 541 B

After

Width:  |  Height:  |  Size: 541 B

View File

Before

Width:  |  Height:  |  Size: 474 B

After

Width:  |  Height:  |  Size: 474 B

View File

Before

Width:  |  Height:  |  Size: 759 B

After

Width:  |  Height:  |  Size: 759 B

View File

Before

Width:  |  Height:  |  Size: 479 B

After

Width:  |  Height:  |  Size: 479 B

View File

Before

Width:  |  Height:  |  Size: 809 B

After

Width:  |  Height:  |  Size: 809 B

View File

Before

Width:  |  Height:  |  Size: 837 B

After

Width:  |  Height:  |  Size: 837 B

View File

Before

Width:  |  Height:  |  Size: 567 B

After

Width:  |  Height:  |  Size: 567 B

View File

Before

Width:  |  Height:  |  Size: 628 B

After

Width:  |  Height:  |  Size: 628 B

View File

Before

Width:  |  Height:  |  Size: 561 B

After

Width:  |  Height:  |  Size: 561 B

View File

Before

Width:  |  Height:  |  Size: 582 B

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 B

View File

Before

Width:  |  Height:  |  Size: 541 B

After

Width:  |  Height:  |  Size: 541 B

View File

Before

Width:  |  Height:  |  Size: 499 B

After

Width:  |  Height:  |  Size: 499 B

View File

Before

Width:  |  Height:  |  Size: 759 B

After

Width:  |  Height:  |  Size: 759 B

View File

Before

Width:  |  Height:  |  Size: 479 B

After

Width:  |  Height:  |  Size: 479 B

View File

Before

Width:  |  Height:  |  Size: 809 B

After

Width:  |  Height:  |  Size: 809 B

View File

Before

Width:  |  Height:  |  Size: 837 B

After

Width:  |  Height:  |  Size: 837 B

View File

Before

Width:  |  Height:  |  Size: 567 B

After

Width:  |  Height:  |  Size: 567 B

View File

Before

Width:  |  Height:  |  Size: 449 B

After

Width:  |  Height:  |  Size: 449 B

View File

Before

Width:  |  Height:  |  Size: 569 B

After

Width:  |  Height:  |  Size: 569 B

View File

Before

Width:  |  Height:  |  Size: 582 B

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 B

View File

Before

Width:  |  Height:  |  Size: 541 B

After

Width:  |  Height:  |  Size: 541 B

View File

Before

Width:  |  Height:  |  Size: 414 B

After

Width:  |  Height:  |  Size: 414 B

View File

Before

Width:  |  Height:  |  Size: 724 B

After

Width:  |  Height:  |  Size: 724 B

View File

Before

Width:  |  Height:  |  Size: 727 B

After

Width:  |  Height:  |  Size: 727 B

View File

Before

Width:  |  Height:  |  Size: 544 B

After

Width:  |  Height:  |  Size: 544 B

View File

Before

Width:  |  Height:  |  Size: 536 B

After

Width:  |  Height:  |  Size: 536 B

View File

Before

Width:  |  Height:  |  Size: 582 B

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 B

View File

Before

Width:  |  Height:  |  Size: 541 B

After

Width:  |  Height:  |  Size: 541 B

View File

Before

Width:  |  Height:  |  Size: 474 B

After

Width:  |  Height:  |  Size: 474 B

View File

Before

Width:  |  Height:  |  Size: 759 B

After

Width:  |  Height:  |  Size: 759 B

View File

Before

Width:  |  Height:  |  Size: 479 B

After

Width:  |  Height:  |  Size: 479 B

View File

Before

Width:  |  Height:  |  Size: 809 B

After

Width:  |  Height:  |  Size: 809 B

View File

Before

Width:  |  Height:  |  Size: 837 B

After

Width:  |  Height:  |  Size: 837 B

View File

Before

Width:  |  Height:  |  Size: 567 B

After

Width:  |  Height:  |  Size: 567 B

View File

Before

Width:  |  Height:  |  Size: 561 B

After

Width:  |  Height:  |  Size: 561 B

Some files were not shown because too many files have changed in this diff Show More