Skip to content

Commit

Permalink
Merge pull request LedgerHQ#51 from LedgerHQ/cev/B2CA-1648_Port-Flex
Browse files Browse the repository at this point in the history
B2CA-1648: Port Flex
  • Loading branch information
cedelavergne-ledger authored May 27, 2024
2 parents e397914 + d1b9f08 commit 6cbedc6
Show file tree
Hide file tree
Showing 1,294 changed files with 119 additions and 183 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/codeql_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ jobs:
analyse:
name: Analyse
strategy:
fail-fast: false
matrix:
sdk: ["$NANOS_SDK", "$NANOX_SDK", "$NANOSP_SDK", "$STAX_SDK"]
sdk: ["$NANOS_SDK", "$NANOX_SDK", "$NANOSP_SDK", "$STAX_SDK", "$FLEX_SDK"]
#'cpp' covers C and C++
language: ["cpp"]
runs-on: ubuntu-latest
Expand All @@ -26,12 +27,12 @@ jobs:

steps:
- name: Clone
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
queries: security-and-quality
Expand All @@ -42,4 +43,4 @@ jobs:
make BOLOS_SDK=${{ matrix.sdk }}
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
2 changes: 1 addition & 1 deletion .github/workflows/misspellings_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Check misspellings
uses: codespell-project/actions-codespell@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/python_client_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Installing PIP dependencies
run: |
pip install pylint
Expand All @@ -32,7 +32,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Installing PIP dependencies
run: |
pip install mypy
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

steps:
- name: Clone
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install dependencies
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ __pycache__/
tests/build/
build/
tests/snapshots-tmp
venv/
5 changes: 1 addition & 4 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"env": {
"BOLOS_SDK": "/opt/nanos-secure-sdk",
"BOLOS_ENV": "/opt/bolos-devenv"
"BOLOS_SDK": "/opt/nanos-secure-sdk"
},
"configurations": [
{
Expand Down Expand Up @@ -35,10 +34,8 @@
"HAVE_PRINTF",
"PRINTF=screen_printf"
],
"compilerPath": "${env:BOLOS_ENV}/gcc-arm-none-eabi-5_3-2016q1/bin/arm-none-eabi-gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-arm",
"browse": {
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ include $(BOLOS_SDK)/Makefile.defines
APPNAME = XRP

APPVERSION_M=2
APPVERSION_N=3
APPVERSION_P=2
APPVERSION_N=4
APPVERSION_P=0
APPVERSION=$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)

# Application source files
Expand All @@ -43,6 +43,7 @@ ICON_NANOS = img/nanos_app_xrp.gif
ICON_NANOX = img/nanox_app_xrp.gif
ICON_NANOSP = img/nanox_app_xrp.gif
ICON_STAX = img/stax_app_xrp.gif
ICON_FLEX = img/flex_app_xrp.gif

# Application allowed derivation curves.
# Possibles curves are: secp256k1, secp256r1, ed25519 and bls12381g1
Expand Down
Binary file added img/flex_app_xrp.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]
unit_directory = "./tests/"
Expand Down
16 changes: 8 additions & 8 deletions src/limitations.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@
// Hardware dependent limits
// Ledger Nano X has 30K RAM
// Ledger Nano S has 4K RAM
#if defined(TARGET_NANOX) || defined(TARGET_NANOS2) || defined(TARGET_STAX)

#define MAX_FIELD_COUNT 60
#define MAX_FIELD_LEN 1024
#define MAX_RAW_TX 10000
#define DISPLAY_SEGMENTED_ADDR false

#elif defined(TARGET_NANOS)
#if defined(TARGET_NANOS)

#define MAX_FIELD_COUNT 24
#define MAX_FIELD_LEN 128
#define MAX_RAW_TX 800
#define DISPLAY_SEGMENTED_ADDR true

#else

#define MAX_FIELD_COUNT 60
#define MAX_FIELD_LEN 1024
#define MAX_RAW_TX 10000
#define DISPLAY_SEGMENTED_ADDR false

#endif

#endif // LEDGER_APP_XRP_LIMITATIONS_H
11 changes: 8 additions & 3 deletions src/ui/address/address_ui_nbgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ static action_t rejection_action;
static void confirmationChoiceClbk(bool confirm) {
if (confirm) {
approval_action();
nbgl_useCaseStatus("ADDRESS\nVERIFIED", true, display_idle_menu);
nbgl_useCaseReviewStatus(STATUS_TYPE_ADDRESS_VERIFIED, display_idle_menu);
} else {
rejection_action();
nbgl_useCaseStatus("Address verification\ncancelled", false, display_idle_menu);
nbgl_useCaseReviewStatus(STATUS_TYPE_ADDRESS_REJECTED, display_idle_menu);
}
}

Expand All @@ -42,6 +42,11 @@ void display_address_confirmation_ui(char* address, action_t on_approve, action_
rejection_action = on_reject;
memset(full_address, 0, sizeof(full_address));
strncpy(full_address, address, sizeof(full_address));
nbgl_useCaseAddressConfirmation((char*) full_address, confirmationChoiceClbk);
nbgl_useCaseAddressReview((char*) full_address,
NULL,
&C_icon_XRP_64px,
"Verify XRP Address",
NULL,
confirmationChoiceClbk);
}
#endif // HAVE_NBGL
34 changes: 13 additions & 21 deletions src/ui/main/idle_menu_nbgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,23 @@
static const char* const infoTypes[] = {"Version", "Developer"};
static const char* const infoContents[] = {APPVERSION, "Ledger"};

static void display_about_menu();
static bool about_nav_clbk(uint8_t page, nbgl_pageContent_t* content);
static void on_quit_clbk(void);

static bool about_nav_clbk(uint8_t page, nbgl_pageContent_t* content) {
if (page == 0) {
content->type = INFOS_LIST;
content->infosList.nbInfos = NB_INFO_FIELDS;
content->infosList.infoTypes = (const char**) infoTypes;
content->infosList.infoContents = (const char**) infoContents;
} else {
return false;
}
return true;
}

static void display_about_menu(void) {
nbgl_useCaseSettings(APPNAME, 0, 1, false, display_idle_menu, about_nav_clbk, NULL);
}

static void on_quit_clbk(void) {
os_sched_exit(-1);
}

void display_idle_menu() {
nbgl_useCaseHome(APPNAME, &C_icon_XRP_64px, NULL, true, display_about_menu, on_quit_clbk);
static nbgl_contentInfoList_t infosList = {0};

infosList.nbInfos = NB_INFO_FIELDS;
infosList.infoTypes = (const char**) infoTypes;
infosList.infoContents = (const char**) infoContents;
nbgl_useCaseHomeAndSettings(APPNAME,
&C_icon_XRP_64px,
NULL,
INIT_HOME_PAGE,
NULL,
&infosList,
NULL,
on_quit_clbk);
}
#endif // HAVE_NBGL
84 changes: 23 additions & 61 deletions src/ui/transaction/review_menu_nbgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@
* limitations under the License.
********************************************************************************/
#ifdef HAVE_NBGL
#include <os.h>
#include <string.h>
#include <ux.h>
#include "global.h"
#include "transaction.h"
#include "fmt.h"
#include "idle_menu.h"
#include "review_menu.h"
Expand All @@ -29,45 +25,11 @@

// Globals
static field_value_t txFieldValueStrings[MAX_FIELDS_PER_PAGE];
static nbgl_layoutTagValue_t pair;
static nbgl_layoutTagValueList_t pairList;
static nbgl_pageInfoLongPress_t infoLongPress;
static nbgl_contentTagValue_t pair;
static nbgl_contentTagValueList_t pairList;
static parseResult_t *transaction;
static resultAction_t approval_menu_callback;

// Static functions declarations
static nbgl_layoutTagValue_t *getPair(uint8_t index);
static void reviewStart(void);
static void displayTransaction(void);
static void reviewChoice(bool confirm);
static void rejectConfirmation(void);
static void rejectChoice(void);

// Static functions definitions
static void reviewStart(void) {
// Reset globals
memset(&infoLongPress, 0, sizeof(infoLongPress));
memset(&txFieldValueStrings, 0, sizeof(txFieldValueStrings));
memset(&pair, 0, sizeof(pair));

infoLongPress.text = "Confirm Transaction";
infoLongPress.longPressText = "Hold to confirm";
infoLongPress.icon = &C_icon_XRP_64px;

pairList.pairs = NULL;
pairList.nbPairs = transaction->num_fields;
pairList.nbMaxLinesForValue = 0;
pairList.callback = getPair;
pairList.startIndex = 0;

nbgl_useCaseReviewStart(&C_icon_XRP_64px,
"Review transaction",
NULL,
"Reject",
displayTransaction,
rejectChoice);
}

// function called by NBGL to get the pair indexed by "index"
static nbgl_layoutTagValue_t *getPair(uint8_t index) {
uint8_t arr_idx = index % MAX_FIELDS_PER_PAGE;
Expand All @@ -86,36 +48,36 @@ static nbgl_layoutTagValue_t *getPair(uint8_t index) {
return &pair;
}

static void displayTransaction(void) {
nbgl_useCaseStaticReview(&pairList, &infoLongPress, "Reject", reviewChoice);
}

static void reviewChoice(bool confirm) {
if (confirm) {
nbgl_useCaseStatus("TRANSACTION\nCONFIRMED", true, display_idle_menu);
approval_menu_callback(OPTION_SIGN);
nbgl_useCaseReviewStatus(STATUS_TYPE_TRANSACTION_SIGNED, display_idle_menu);
} else {
rejectChoice();
approval_menu_callback(OPTION_REJECT);
nbgl_useCaseReviewStatus(STATUS_TYPE_TRANSACTION_REJECTED, display_idle_menu);
}
}

static void rejectConfirmation(void) {
nbgl_useCaseStatus("Transaction rejected", false, display_idle_menu);
approval_menu_callback(OPTION_REJECT);
}

static void rejectChoice(void) {
nbgl_useCaseConfirm("Reject transaction?",
NULL,
"Yes, Reject",
"Go back to transaction",
rejectConfirmation);
}

void display_review_menu(parseResult_t *transaction_param, resultAction_t callback) {
transaction = transaction_param;
approval_menu_callback = callback;
// Prepare and display transaction
reviewStart();

// Reset globals
memset(&txFieldValueStrings, 0, sizeof(txFieldValueStrings));
memset(&pair, 0, sizeof(pair));

pairList.pairs = NULL;
pairList.nbPairs = transaction->num_fields;
pairList.nbMaxLinesForValue = 0;
pairList.callback = getPair;
pairList.startIndex = 0;

nbgl_useCaseReview(TYPE_TRANSACTION,
&pairList,
&C_icon_XRP_64px,
"Review transaction",
NULL,
"Sign transaction",
reviewChoice);
}
#endif // HAVE_NBGL
Loading

0 comments on commit 6cbedc6

Please sign in to comment.