Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ ENABLE_SWAP = 1
# default enabled in the SDK `Makefile.standard_app`.
DISABLE_STANDARD_APP_FILES = 1

########################################
# Hedera custom Feature flags #
########################################
DISABLE_LEDGER_STAKING_NODE = 1

########################################
# App specific configuration #
########################################
Expand All @@ -97,6 +102,9 @@ DEFINES += PRINTF_FTOA_BUFFER_SIZE=0
DEFINES += HAVE_U2F HAVE_IO_U2F
DEFINES += U2F_PROXY_MAGIC=\"BOIL\"

# Ledger Staking Node
DEFINES += DISABLE_LEDGER_STAKING_NODE=$(DISABLE_LEDGER_STAKING_NODE)

# Allow usage of function from lib_standard_app/crypto_helpers.c
APP_SOURCE_FILES += ${BOLOS_SDK}/lib_standard_app/crypto_helpers.c

Expand Down
100 changes: 42 additions & 58 deletions src/hedera_format.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,31 @@ static char *hedera_format_amount(uint64_t amount, uint8_t decimals) {

return buf;
}
#define hedera_safe_printf(element, ...) \
hedera_snprintf(element, sizeof(element) - 1, __VA_ARGS__)

static char *hedera_format_tinybar(uint64_t tinybar) {
return hedera_format_amount(tinybar, 8);
}

static void format_account_id(char senders[ACCOUNT_ID_SIZE],
const Hedera_AccountID *account_id) {
if (account_id == NULL) {
return;
}

const char *formatter = "%llu.%llu.%llu";
#ifndef DISABLE_LEDGER_STAKING_NODE
if (is_ledger_account(account_id)) {
formatter = "Ledger by %llu.%llu.%llu";
}
#endif

hedera_snprintf(senders, ACCOUNT_ID_SIZE - 1, formatter,
account_id->shardNum, account_id->realmNum,
account_id->account.accountNum);
}

static void validate_decimals(uint32_t decimals) {
if (decimals >= 20) {
// We only support decimal values less than 20
Expand All @@ -91,12 +111,10 @@ static void validate_memo(const char memo[100]) {
}
}

#define hedera_safe_printf(element, ...) \
hedera_snprintf(element, sizeof(element) - 1, __VA_ARGS__)

void reformat_key(void) {
#if defined(TARGET_NANOX) || defined(TARGET_NANOS2) || defined(TARGET_NANOS)
hedera_safe_printf(st_ctx.summary_line_2, "with Key #%u?", st_ctx.key_index);
hedera_safe_printf(st_ctx.summary_line_2, "with Key #%u?",
st_ctx.key_index);
#elif defined(TARGET_STAX) || defined(TARGET_FLEX)
hedera_safe_printf(st_ctx.summary_line_2, "#%u", st_ctx.key_index);
#endif
Expand All @@ -115,13 +133,11 @@ void reformat_summary(const char *summary) {
}

void reformat_summary_send_token(void) {
hedera_safe_printf(st_ctx.summary_line_1, "send tokens");
hedera_safe_printf(st_ctx.summary_line_1, "send tokens");
}

// TITLES



static void set_senders_title(const char *title) {
// st_ctx.senders_title --> st_ctx.title (NANOS)
hedera_safe_printf(st_ctx.senders_title, "%s", title);
Expand Down Expand Up @@ -179,27 +195,10 @@ void reformat_stake_target(void) {
} else if (st_ctx.type == Update) {
if (st_ctx.transaction.data.cryptoUpdateAccount.which_staked_id ==
Hedera_CryptoUpdateTransactionBody_staked_account_id_tag) {
// Check if this is the special Ledger account
if (is_ledger_account(&st_ctx.transaction.data.cryptoUpdateAccount
.staked_id.staked_account_id)) {
hedera_safe_printf(
st_ctx.senders, "Ledger by %llu.%llu.%llu",
st_ctx.transaction.data.cryptoUpdateAccount.staked_id
.staked_account_id.shardNum,
st_ctx.transaction.data.cryptoUpdateAccount.staked_id
.staked_account_id.realmNum,
st_ctx.transaction.data.cryptoUpdateAccount.staked_id
.staked_account_id.account.accountNum);
} else {
hedera_safe_printf(
st_ctx.senders, "%llu.%llu.%llu",
st_ctx.transaction.data.cryptoUpdateAccount.staked_id
.staked_account_id.shardNum,
st_ctx.transaction.data.cryptoUpdateAccount.staked_id
.staked_account_id.realmNum,
st_ctx.transaction.data.cryptoUpdateAccount.staked_id
.staked_account_id.account.accountNum);
}
format_account_id(st_ctx.senders,
&st_ctx.transaction.data.cryptoUpdateAccount
.staked_id.staked_account_id);

} else if (st_ctx.transaction.data.cryptoUpdateAccount
.which_staked_id ==
Hedera_CryptoUpdateTransactionBody_staked_node_id_tag) {
Expand Down Expand Up @@ -289,7 +288,7 @@ void address_to_string(const token_addr_t *addr,
if (addr == NULL || buf == NULL) {
return;
}

hedera_snprintf(buf, MAX_HEDERA_ADDRESS_LENGTH, "%llu.%llu.%llu",
addr->addr_shard, addr->addr_realm, addr->addr_account);
}
Expand All @@ -316,27 +315,9 @@ void reformat_stake_in_stake_flow(void) {
set_recipients_title("Stake to");
if (st_ctx.transaction.data.cryptoUpdateAccount.which_staked_id ==
Hedera_CryptoUpdateTransactionBody_staked_account_id_tag) {
// Check if this is the special Ledger account
if (is_ledger_account(&st_ctx.transaction.data.cryptoUpdateAccount
.staked_id.staked_account_id)) {
hedera_safe_printf(
st_ctx.recipients, "Ledger by %llu.%llu.%llu",
st_ctx.transaction.data.cryptoUpdateAccount.staked_id
.staked_account_id.shardNum,
st_ctx.transaction.data.cryptoUpdateAccount.staked_id
.staked_account_id.realmNum,
st_ctx.transaction.data.cryptoUpdateAccount.staked_id
.staked_account_id.account.accountNum);
} else {
hedera_safe_printf(
st_ctx.recipients, "%llu.%llu.%llu",
st_ctx.transaction.data.cryptoUpdateAccount.staked_id
.staked_account_id.shardNum,
st_ctx.transaction.data.cryptoUpdateAccount.staked_id
.staked_account_id.realmNum,
st_ctx.transaction.data.cryptoUpdateAccount.staked_id
.staked_account_id.account.accountNum);
}
format_account_id(st_ctx.recipients,
&st_ctx.transaction.data.cryptoUpdateAccount.staked_id
.staked_account_id);
} else if (st_ctx.transaction.data.cryptoUpdateAccount.which_staked_id ==
Hedera_CryptoUpdateTransactionBody_staked_node_id_tag) {
// TODO Node name
Expand Down Expand Up @@ -539,8 +520,9 @@ void reformat_auto_renew_period(void) {
st_ctx.transaction.data.cryptoUpdateAccount.has_autoRenewPeriod) {
uint64_t seconds =
st_ctx.transaction.data.cryptoUpdateAccount.autoRenewPeriod.seconds;

format_time_duration(st_ctx.auto_renew_period, sizeof(st_ctx.auto_renew_period), seconds);

format_time_duration(st_ctx.auto_renew_period,
sizeof(st_ctx.auto_renew_period), seconds);
} else {
hedera_safe_printf(st_ctx.auto_renew_period, "-");
}
Expand All @@ -564,18 +546,20 @@ void reformat_receiver_sig_required(void) {
hedera_safe_printf(st_ctx.receiver_sig_required, "-");
return;
}

// Check if receiver sig required field is not set
if (st_ctx.transaction.data.cryptoUpdateAccount.which_receiverSigRequiredField !=
if (st_ctx.transaction.data.cryptoUpdateAccount
.which_receiverSigRequiredField !=
Hedera_CryptoUpdateTransactionBody_receiverSigRequiredWrapper_tag) {
hedera_safe_printf(st_ctx.receiver_sig_required, "-");
return;
}

// Field is set, get the value and format accordingly
bool required = st_ctx.transaction.data.cryptoUpdateAccount
.receiverSigRequiredField.receiverSigRequiredWrapper.value;

bool required =
st_ctx.transaction.data.cryptoUpdateAccount.receiverSigRequiredField
.receiverSigRequiredWrapper.value;

hedera_safe_printf(st_ctx.receiver_sig_required, required ? "Yes" : "No");
}

Expand Down
2 changes: 2 additions & 0 deletions src/staking.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "crypto_update.pb.h"
#include <stddef.h>

#ifndef DISABLE_LEDGER_STAKING_NODE
bool is_ledger_account(const Hedera_AccountID *account_id) {
if (account_id == NULL) {
return false;
Expand All @@ -11,6 +12,7 @@ bool is_ledger_account(const Hedera_AccountID *account_id) {
account_id->realmNum == LEDGER_ACCOUNT_REALM &&
account_id->account.accountNum == LEDGER_ACCOUNT_NUM);
}
#endif

update_type_t identify_special_update(const Hedera_CryptoUpdateTransactionBody *update_body) {
if (update_body == NULL) {
Expand Down
5 changes: 4 additions & 1 deletion src/staking.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <stdbool.h>
#include "crypto_update.pb.h"

// Special Ledger account ID
// Special Ledger account ID (currently disabled by feature flag DISABLE_LEDGER_STAKING_NODE)
#define LEDGER_ACCOUNT_SHARD 0
#define LEDGER_ACCOUNT_REALM 0
#define LEDGER_ACCOUNT_NUM 1337
Expand All @@ -23,10 +23,13 @@ typedef enum {
*/
update_type_t identify_special_update(const struct _Hedera_CryptoUpdateTransactionBody *update_body);

#ifndef DISABLE_LEDGER_STAKING_NODE
/**
* Check if an account ID matches the hardcoded Ledger account (0.0.1337)
*
* @param account_id Pointer to the account ID to check
* @return true if the account ID matches 0.0.1337, false otherwise
*/
bool is_ledger_account(const Hedera_AccountID *account_id);
#endif

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.
2 changes: 1 addition & 1 deletion tests/swap/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ragger[tests,speculos] >= 1.36.1
ledger_app_clients.ethereum
ledger_app_clients.exchange >= 0.0.4
ledger_app_clients.exchange >= 0.0.5
GitPython
base58
bip32
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.
Binary file modified tests/swap/snapshots/nanosp/tests_hedera_fund_valid_1/00000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/swap/snapshots/nanosp/tests_hedera_fund_valid_1/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/swap/snapshots/nanosp/tests_hedera_fund_valid_1/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/swap/snapshots/nanosp/tests_hedera_fund_valid_1/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/swap/snapshots/nanosp/tests_hedera_fund_valid_1/00004.png
Binary file modified tests/swap/snapshots/nanosp/tests_hedera_fund_valid_1/00005.png
Binary file modified tests/swap/snapshots/nanosp/tests_hedera_fund_valid_1/00006.png
Binary file modified tests/swap/snapshots/nanox/tests_hedera_fund_valid_1/00000.png
Binary file modified tests/swap/snapshots/nanox/tests_hedera_fund_valid_1/00001.png
Binary file modified tests/swap/snapshots/nanox/tests_hedera_fund_valid_1/00002.png
Binary file modified tests/swap/snapshots/nanox/tests_hedera_fund_valid_1/00003.png
Binary file modified tests/swap/snapshots/nanox/tests_hedera_fund_valid_1/00004.png
Binary file modified tests/swap/snapshots/nanox/tests_hedera_fund_valid_1/00005.png
Binary file modified tests/swap/snapshots/nanox/tests_hedera_fund_valid_1/00006.png
Loading
Loading