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

Merge develop to main following B2CA-1892 #8

Merged
merged 18 commits into from
Dec 18, 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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
- [ ] Target branch is `develop` <!-- unless you have a very good reason -->
- [ ] Application version has been bumped <!-- required if your changes are to be deployed -->

<!-- Make sure you followed the process described in https://developers.ledger.com/docs/embedded-app/maintenance/ before opening your Pull Request.
<!-- Make sure you followed the process described in https://developers.ledger.com/docs/device-app/deliver/maintenance before opening your Pull Request.
Don't hesitate to contact us directly on Discord if you have any questions ! https://developers.ledger.com/discord -->
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ doc/html
doc/latex

.DS_Store
zz-*
zz-*

output-scan-build/
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ APPNAME = "Kaspa"
# Application version
APPVERSION_M = 1
APPVERSION_N = 0
APPVERSION_P = 2
APPVERSION_P = 3
APPVERSION = "$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)"

ifeq ($(TARGET_NAME),TARGET_NANOS)
Expand All @@ -53,6 +53,7 @@ ICON_NANOS = icons/nanos_kaspa_logo.gif
ICON_NANOX = icons/nanox_kaspa_logo.gif
ICON_NANOSP = icons/nanox_kaspa_logo.gif
ICON_STAX = icons/stax_kaspa_logo_32px.gif
ICON_FLEX = icons/stax_kaspa_logo_40px.gif

# Application allowed derivation curves.
# Possibles curves are: secp256k1, secp256r1, ed25519 and bls12381g1
Expand Down
Binary file added icons/stax_kaspa_logo_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 = ["flex", "nanos", "nanox", "nanos+", "stax"]

[tests]
unit_directory = "./unit-tests/"
Expand Down
42 changes: 24 additions & 18 deletions src/ui/menu_nbgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,37 @@
#include "../globals.h"
#include "menu.h"

// -----------------------------------------------------------
// ----------------------- HOME PAGE -------------------------
// -----------------------------------------------------------

void app_quit(void) {
// exit app here
os_sched_exit(-1);
}

void ui_menu_main(void) {
nbgl_useCaseHome(APPNAME, &C_stax_app_kaspa_64px, NULL, false, ui_menu_about, app_quit);
}

// 'About' menu
// -----------------------------------------------------------
// --------------------- SETTINGS MENU -----------------------
// -----------------------------------------------------------
#define SETTING_INFO_NB 2
static const char* const INFO_TYPES[SETTING_INFO_NB] = {"Version", "Developer"};
static const char* const INFO_CONTENTS[SETTING_INFO_NB] = {APPVERSION, "coderofstuff"};

static const char* const INFO_TYPES[] = {"Version", "Developer"};
static const char* const INFO_CONTENTS[] = {APPVERSION, "coderofstuff"};
static const nbgl_contentInfoList_t infoList = {
.nbInfos = SETTING_INFO_NB,
.infoTypes = INFO_TYPES,
.infoContents = INFO_CONTENTS,
};

static bool nav_callback(uint8_t page, nbgl_pageContent_t* content) {
UNUSED(page);
content->type = INFOS_LIST;
content->infosList.nbInfos = 2;
content->infosList.infoTypes = (const char**) INFO_TYPES;
content->infosList.infoContents = (const char**) INFO_CONTENTS;
return true;
}

void ui_menu_about() {
nbgl_useCaseSettings(APPNAME, 0, 1, false, ui_menu_main, nav_callback, NULL);
void ui_menu_main(void) {
nbgl_useCaseHomeAndSettings(APPNAME,
&C_stax_app_kaspa_64px,
NULL,
INIT_HOME_PAGE,
NULL,
&infoList,
NULL,
app_quit);
}

#endif
56 changes: 21 additions & 35 deletions src/ui/nbgl_display_address.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,17 @@
#include "os.h"
#include "glyphs.h"
#include "nbgl_use_case.h"
#include "io.h"
#include "bip32.h"
#include "format.h"

#include "display.h"
#include "constants.h"
#include "../globals.h"
#include "io.h"
#include "../sw.h"
#include "../address.h"
#include "action/validate.h"
#include "../types.h"
#include "../transaction/types.h"
#include "bip32.h"
#include "format.h"
#include "../menu.h"

static char g_address[ECDSA_ADDRESS_LEN + 6];
Expand All @@ -49,37 +48,16 @@ static char g_bip32_path[60];
static nbgl_layoutTagValue_t pairs[1];
static nbgl_layoutTagValueList_t pairList;

static void confirm_address_rejection(void) {
// display a status page and go back to main
validate_pubkey(false);
nbgl_useCaseStatus("Address verification\ncancelled", false, ui_menu_main);
}

static void confirm_address_approval(void) {
// display a success status page and go back to main
validate_pubkey(true);
nbgl_useCaseStatus("ADDRESS\nVERIFIED", true, ui_menu_main);
}

static void review_choice(bool confirm) {
// Answer, display a status page and go back to main
validate_pubkey(confirm);
if (confirm) {
confirm_address_approval();
nbgl_useCaseReviewStatus(STATUS_TYPE_ADDRESS_VERIFIED, ui_menu_main);
} else {
confirm_address_rejection();
nbgl_useCaseReviewStatus(STATUS_TYPE_ADDRESS_REJECTED, ui_menu_main);
}
}

static void continue_review(void) {
// Fill pairs
pairs[0].item = "BIP32 Path";
pairs[0].value = g_bip32_path;

pairList.nbMaxLinesForValue = 0;
pairList.nbPairs = 1;
pairList.pairs = pairs;
nbgl_useCaseAddressConfirmationExt(g_address, review_choice, &pairList);
}

int ui_display_address() {
if (G_context.req_type != CONFIRM_ADDRESS || G_context.state != STATE_NONE) {
G_context.state = STATE_NONE;
Expand All @@ -101,12 +79,20 @@ int ui_display_address() {
}
snprintf(g_address, sizeof(g_address), "%.*s", sizeof(address), address);

nbgl_useCaseReviewStart(&C_stax_app_kaspa_64px,
"Verify KAS address",
NULL,
"Cancel",
continue_review,
confirm_address_rejection);
// Fill pairs
pairs[0].item = "BIP32 Path";
pairs[0].value = g_bip32_path;

pairList.nbMaxLinesForValue = 0;
pairList.nbPairs = 1;
pairList.pairs = pairs;

nbgl_useCaseAddressReview(g_address,
&pairList,
&C_stax_app_kaspa_64px,
"Verify KAS address",
NULL,
review_choice);
return 0;
}

Expand Down
81 changes: 27 additions & 54 deletions src/ui/nbgl_display_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,85 +21,45 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*****************************************************************************/

#ifdef HAVE_NBGL

#include <stdbool.h> // bool
#include <string.h> // memset

#include "os.h"
#include "glyphs.h"
#include "os_io_seproxyhal.h"
#include "nbgl_use_case.h"
#include "io.h"
#include "bip32.h"
#include "format.h"

#include "display.h"
#include "constants.h"
#include "../globals.h"
#include "io.h"
#include "../sw.h"
#include "../address.h"
#include "action/validate.h"
#include "../types.h"
#include "../transaction/types.h"
#include "bip32.h"
#include "../common/format_local.h"
#include "format.h"
#include "../menu.h"

static char g_message[MAX_MESSAGE_LEN];
static char g_bip32_path[60];

static nbgl_layoutTagValue_t pairs[2];
static nbgl_layoutTagValueList_t pairList;
static nbgl_pageInfoLongPress_t infoLongPress;

static void confirm_message_rejection(void) {
// display a status page and go back to main
validate_message(false);
nbgl_useCaseStatus("Message signing\ncancelled", false, ui_menu_main);
}

static void ask_message_rejection_confirmation(void) {
// display a choice to confirm/cancel rejection
nbgl_useCaseConfirm("Reject message?",
NULL,
"Yes, Reject",
"Go back to message",
confirm_message_rejection);
}

static void confirm_message_approval(void) {
// display a success status page and go back to main
validate_message(true);
nbgl_useCaseStatus("MESSAGE\nSIGNED", true, ui_menu_main);
}

static void review_message_choice(bool confirm) {
validate_message(confirm);
if (confirm) {
confirm_message_approval();
nbgl_useCaseReviewStatus(STATUS_TYPE_MESSAGE_SIGNED, ui_menu_main);
} else {
ask_message_rejection_confirmation();
nbgl_useCaseReviewStatus(STATUS_TYPE_MESSAGE_REJECTED, ui_menu_main);
}
}

static void continue_message_review(void) {
// Fill pairs
pairs[0].item = "BIP32 Path";
pairs[0].value = g_bip32_path;
pairs[1].item = "Message";
pairs[1].value = g_message;

// Setup list
pairList.nbMaxLinesForValue = 0;
pairList.nbPairs = 2;
pairList.pairs = pairs;

// Info long press
infoLongPress.icon = &C_stax_app_kaspa_64px;
infoLongPress.text = "Sign message?";
infoLongPress.longPressText = "Hold to sign";

nbgl_useCaseStaticReview(&pairList, &infoLongPress, "Reject message", review_message_choice);
}

int ui_display_message() {
if (G_context.req_type != CONFIRM_MESSAGE || G_context.state != STATE_NONE) {
G_context.state = STATE_NONE;
Expand All @@ -120,12 +80,25 @@ int ui_display_message() {
(char *) G_context.msg_info.message,
G_context.msg_info.message_len);

nbgl_useCaseReviewStart(&C_stax_app_kaspa_64px,
"Review Message",
NULL,
"Reject message",
continue_message_review,
ask_message_rejection_confirmation);
// Fill pairs
pairs[0].item = "BIP32 Path";
pairs[0].value = g_bip32_path;
pairs[1].item = "Message";
pairs[1].value = g_message;

// Setup list
pairList.nbMaxLinesForValue = 0;
pairList.nbPairs = 2;
pairList.pairs = pairs;

// Start review flow
nbgl_useCaseReview(TYPE_MESSAGE,
&pairList,
&C_stax_app_kaspa_64px,
"Review message",
NULL,
"Sign message?",
review_message_choice);
return 0;
}

Expand Down
Loading
Loading