Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flex porting #131

Merged
merged 3 commits into from
May 31, 2024
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@ build/
dist/
*.manifest
*.spec

# Temporary directory with snapshots taken during test runs
tests/snapshots-tmp/

# Virtual env for sideload (macOS and Windows)
ledger/
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file.

## 2.0.0 - 2024-05-01

- Support of Flex device

## 1.7.6 - 2021-03-30

- Support of Monero client version `0.17.2.*`
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ include $(BOLOS_SDK)/Makefile.defines
APPNAME = "Monero"

# Application version
APPVERSION_M = 1
APPVERSION_N = 9
APPVERSION_M = 2
APPVERSION_N = 0
APPVERSION_P = 0
APPVERSION = "$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)"

Expand All @@ -43,6 +43,7 @@ ICON_NANOS = icons/app_monero_16px.gif
ICON_NANOX = icons/app_monero_14px.gif
ICON_NANOSP = icons/app_monero_14px.gif
ICON_STAX = icons/app_monero_32px.gif
ICON_FLEX = icons/app_monero_40px.gif

# Application allowed derivation curves.
CURVE_APP_LOAD_PARAMS = secp256k1
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Monero Ledger App

Monero wallet application for Ledger Nano S and Nano X.
Monero wallet application for all Ledger devices.

## Install

Expand Down
Binary file added icons/app_monero_40px.gif
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 ledger_app.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[app]
build_directory = "./"
sdk = "C"
devices = ["nanos", "nanox", "nanos+", "stax"]
devices = ["nanos", "nanox", "nanos+", "stax", "flex"]

[tests]
pytest_directory = "./tests/"
6 changes: 3 additions & 3 deletions src/monero_nvram.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
#include "monero_api.h"
#include "monero_vars.h"

#if defined(TARGET_NANOX) || defined(TARGET_NANOS2) || defined(TARGET_STAX)
const monero_nv_state_t N_state_pic;
#else
#if defined(TARGET_NANOS)
monero_nv_state_t N_state_pic;
#else
const monero_nv_state_t N_state_pic;
#endif
5 changes: 5 additions & 0 deletions src/monero_prehash.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ int monero_apdu_mlsag_prehash_init() {
// fee str
monero_vamount2str(G_monero_vstate.io_buffer + G_monero_vstate.io_offset,
G_monero_vstate.ux_amount, 15);

cedelavergne-ledger marked this conversation as resolved.
Show resolved Hide resolved
snprintf(G_monero_vstate.ux_amount + strlen(G_monero_vstate.ux_amount),
sizeof(G_monero_vstate.ux_amount) - strlen(G_monero_vstate.ux_amount), " XMR");
// ask user
monero_io_discard(1);
ui_menu_fee_validation_display(0);
Expand Down Expand Up @@ -212,6 +215,8 @@ int monero_apdu_mlsag_prehash_update() {
amount = monero_bamount2uint64(v, sizeof(v));
if (amount) {
monero_amount2str(amount, G_monero_vstate.ux_amount, 15);
snprintf(G_monero_vstate.ux_amount + strlen(G_monero_vstate.ux_amount),
sizeof(G_monero_vstate.ux_amount) - strlen(G_monero_vstate.ux_amount), " XMR");

if ((G_monero_vstate.options & IN_OPTION_MORE_COMMAND) == 0) {
if (!is_change) {
Expand Down
4 changes: 2 additions & 2 deletions src/monero_ux_nano.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ UX_STEP_NOCB(ux_menu_validation_timelock_1_step, bn,
UX_STEP_CB(ux_menu_validation_cf_2_step, pb, ui_menu_amount_validation_action(ACCEPT),
{
&C_icon_validate_14,
"Accept",
"Sign transaction",
});

UX_STEP_CB(ux_menu_validation_cf_3_step, pb, ui_menu_amount_validation_action(REJECT),
Expand Down Expand Up @@ -241,7 +241,7 @@ UX_STEP_NOCB(ux_menu_validation_2_step,
{"Destination", G_monero_vstate.ux_address});

UX_STEP_CB(ux_menu_validation_3_step, pb, ui_menu_validation_action(ACCEPT),
{&C_icon_validate_14, "Accept"});
{&C_icon_validate_14, "Sign transaction"});

UX_STEP_CB(ux_menu_validation_4_step, pb, ui_menu_validation_action(REJECT),
{&C_icon_crossmark, "Reject"});
Expand Down
44 changes: 26 additions & 18 deletions src/monero_ux_stax.c → src/monero_ux_nbgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static void release_context(void) {
/* -------------------------------- INFO UX --------------------------------- */

void ui_menu_show_tx_aborted(void) {
nbgl_useCaseStatus("Transaction\ncancelled", false, ui_menu_main_display);
nbgl_useCaseReviewStatus(STATUS_TYPE_TRANSACTION_REJECTED, ui_menu_main_display);
}

void ui_menu_show_security_error(void) {
Expand Down Expand Up @@ -103,7 +103,7 @@ unsigned int ui_menu_transaction_start(void) {
}

unsigned int ui_menu_transaction_signed(void) {
nbgl_useCaseStatus("TRANSACTION\nSIGNED", true, ui_menu_main_display);
nbgl_useCaseReviewStatus(STATUS_TYPE_TRANSACTION_SIGNED, ui_menu_main_display);
return 0;
}

Expand Down Expand Up @@ -160,13 +160,13 @@ void ui_menu_change_validation_display_last(unsigned int value __attribute__((un
transactionContext.tagValueList.nbPairs++;

transactionContext.infoLongPress.icon = &C_Monero_64px;
transactionContext.infoLongPress.longPressText = "Approve";
transactionContext.infoLongPress.longPressText = "Hold to sign";
transactionContext.infoLongPress.longPressToken = 0;
transactionContext.infoLongPress.tuneId = TUNE_TAP_CASUAL;
transactionContext.infoLongPress.text = "Hold to confirm";
transactionContext.infoLongPress.text = "Sign transaction";

nbgl_useCaseStaticReview(&transactionContext.tagValueList, &transactionContext.infoLongPress,
"Cancel", ui_menu_validation_action);
"Reject transaction", ui_menu_validation_action);
cedelavergne-ledger marked this conversation as resolved.
Show resolved Hide resolved
}

static void timelock_callback(void) {
Expand All @@ -193,6 +193,13 @@ void ui_menu_timelock_validation_display(unsigned int value __attribute__((unuse
}

/* ----------------------------- USER DEST/AMOUNT VALIDATION ----------------------------- */

#ifdef TARGET_FLEX
#define NEXT_PAGE_TEXT ("Swipe to continue")
#else
#define NEXT_PAGE_TEXT ("Tap to continue")
#endif

static void fill_amount_and_destination(void) {
transactionContext.tagValuePair[0].item = "Amount";
transactionContext.tagValuePair[0].value = G_monero_vstate.ux_amount;
Expand Down Expand Up @@ -225,9 +232,9 @@ static void continue_display(int token, unsigned char index) {
.navType = NAV_WITH_TAP,
.progressIndicator = true,
.navWithTap.backButton = false,
.navWithTap.nextPageText = "Tap to continue",
.navWithTap.nextPageText = NEXT_PAGE_TEXT,
.navWithTap.nextPageToken = CONTINUE_TOKEN,
.navWithTap.quitText = "Cancel",
.navWithTap.quitText = "Reject transaction",
.quitToken = QUIT_TOKEN,
.tuneId = TUNE_TAP_CASUAL};

Expand All @@ -248,13 +255,13 @@ static void continue_display_last(int token, unsigned char index) {

fill_amount_and_destination();
transactionContext.infoLongPress.icon = &C_Monero_64px;
transactionContext.infoLongPress.longPressText = "Approve";
transactionContext.infoLongPress.longPressText = "Hold to sign";
transactionContext.infoLongPress.longPressToken = 0;
transactionContext.infoLongPress.tuneId = TUNE_TAP_CASUAL;
transactionContext.infoLongPress.text = "Hold to confirm";
transactionContext.infoLongPress.text = "Sign transaction";

nbgl_useCaseStaticReview(&transactionContext.tagValueList, &transactionContext.infoLongPress,
"Cancel", ui_menu_validation_action);
"Reject transaction", ui_menu_validation_action);
cedelavergne-ledger marked this conversation as resolved.
Show resolved Hide resolved
}

static void display_previous_infos(bool last) {
Expand All @@ -265,9 +272,9 @@ static void display_previous_infos(bool last) {
.navType = NAV_WITH_TAP,
.progressIndicator = true,
.navWithTap.backButton = false,
.navWithTap.nextPageText = "Tap to continue",
.navWithTap.nextPageText = NEXT_PAGE_TEXT,
.navWithTap.nextPageToken = CONTINUE_TOKEN,
.navWithTap.quitText = "Cancel",
.navWithTap.quitText = "Reject transaction",
.quitToken = QUIT_TOKEN,
.tuneId = TUNE_TAP_CASUAL};

Expand Down Expand Up @@ -315,7 +322,7 @@ static void ui_menu_pubaddr_action_cancelled(void) {
monero_io_do(IO_RETURN_AFTER_TX);
}
G_monero_vstate.disp_addr_mode = 0;
nbgl_useCaseStatus("Address display\ncancelled", false, ui_menu_main_display);
nbgl_useCaseReviewStatus(STATUS_TYPE_ADDRESS_REJECTED, ui_menu_main_display);
}

void ui_menu_pubaddr_action(bool confirm) {
Expand All @@ -325,7 +332,7 @@ void ui_menu_pubaddr_action(bool confirm) {
monero_io_do(IO_RETURN_AFTER_TX);
}
G_monero_vstate.disp_addr_mode = 0;
nbgl_useCaseStatus("ADDRESS\nVERIFIED", true, ui_menu_main_display);
nbgl_useCaseReviewStatus(STATUS_TYPE_ADDRESS_VERIFIED, ui_menu_main_display);
} else {
ui_menu_pubaddr_action_cancelled();
}
Expand Down Expand Up @@ -372,8 +379,9 @@ void display_account(void) {

transactionContext.tagValueList.pairs = transactionContext.tagValuePair;

nbgl_useCaseAddressConfirmationExt(G_monero_vstate.ux_address, ui_menu_pubaddr_action,
&transactionContext.tagValueList);
nbgl_useCaseAddressReview(G_monero_vstate.ux_address, &transactionContext.tagValueList,
&C_Monero_64px, "Verify Monero\naddress", NULL,
ui_menu_pubaddr_action);
}

int ui_menu_any_pubaddr_display(unsigned int value __attribute__((unused)), unsigned char* pub_view,
Expand All @@ -388,8 +396,8 @@ int ui_menu_any_pubaddr_display(unsigned int value __attribute__((unused)), unsi
return error;
}

nbgl_useCaseReviewStart(&C_Monero_64px, "Review Address", "", "Cancel", display_account,
ui_menu_pubaddr_action_cancelled);
display_account();

return 0;
}

Expand Down
Loading
Loading