Skip to content

Commit

Permalink
Merge pull request #21 from LedgerHQ/develop
Browse files Browse the repository at this point in the history
Align master with P1
  • Loading branch information
fbeutin-ledger authored May 23, 2024
2 parents 4de7283 + b11233e commit 2265ddd
Show file tree
Hide file tree
Showing 1,307 changed files with 2,777 additions and 697 deletions.
8 changes: 8 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Checklist
<!-- Put an `x` in each box when you have completed the items. -->
- [ ] App update process has been followed <!-- See comment below -->
- [ ] 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/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 -->
32 changes: 32 additions & 0 deletions .github/workflows/build_and_functional_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build and run functional tests using ragger through reusable workflow

# This workflow will build the app and then run functional tests using the Ragger framework upon Speculos emulation.
# It calls a reusable workflow developed by Ledger's internal developer team to build the application and upload the
# resulting binaries.
# It then calls another reusable workflow to run the Ragger tests on the compiled application binary.
#
# While this workflow is optional, having functional testing on your application is mandatory and this workflow and
# tooling environment is meant to be easy to use and adapt after forking your application

on:
workflow_dispatch:
push:
branches:
- master
- main
- develop
pull_request:

jobs:
build_application:
name: Build application using the reusable workflow
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_build.yml@v1
with:
upload_app_binaries_artifact: compiled_app_binaries

ragger_tests:
name: Run ragger tests using the reusable workflow
needs: build_application
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_ragger_tests.yml@v1
with:
download_app_binaries_artifact: compiled_app_binaries
38 changes: 12 additions & 26 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,36 @@
name: Compilation & tests

on: [push, pull_request]
on:
workflow_dispatch:
push:
branches:
- master
- main
- develop
pull_request:

jobs:
job_build_debug:
name: Build debug
runs-on: ubuntu-latest

container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest

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

- name: Build
run: |
make DEBUG=1
- name: Upload app binary
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: app-debug
path: bin

job_scan_build:
name: Clang Static Analyzer
needs: job_build_debug
runs-on: ubuntu-latest

container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest

steps:
- uses: actions/checkout@v2

- name: Build with Clang Static Analyzer
run: |
make clean
scan-build --use-cc=clang -analyze-headers -enable-checker security -enable-checker unix -enable-checker valist -o scan-build --status-bugs make default
- uses: actions/upload-artifact@v2
if: failure()
with:
name: scan-build
path: scan-build

job_coverity_scan:
name: Coverity Scan
needs: job_build_debug
Expand All @@ -54,7 +40,7 @@ jobs:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-scanner:latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Build with cov-build
run: |
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/guidelines_enforcer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Ensure compliance with Ledger guidelines

# This workflow is mandatory in all applications
# It calls a reusable workflow guidelines_enforcer developed by Ledger's internal developer team.
# The successful completion of the reusable workflow is a mandatory step for an app to be available on the Ledger
# application store.
#
# More information on the guidelines can be found in the repository:
# LedgerHQ/ledger-app-workflows/

on:
workflow_dispatch:
push:
branches:
- master
- main
- develop
pull_request:

jobs:
guidelines_enforcer:
name: Call Ledger guidelines_enforcer
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_guidelines_enforcer.yml@v1
34 changes: 34 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Unit testing with Codecov coverage checking

on:
workflow_dispatch:
push:
branches:
- master
- main
- develop
pull_request:

jobs:
job_unit_test:
name: Unit test
runs-on: ubuntu-latest

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

- name: Install make, clang, cmoka and bsd
run: |
sudo apt update
sudo apt install -y make clang libcmocka-dev libbsd-dev
- name: Run unit tests
run: |
cd tests/unit-tests
mkdir build && cd build
cmake ..
make
cd ..
./test_transaction_parser.py
build/test_bip32_path_extraction
11 changes: 6 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
bin
debug
dep
obj
build
.vscode
src/glyphs.c
src/glyphs.h
tests/build/*
*.pyc
__pycache__
tests/unit-tests/build/*
tests/unit-tests/temp_txn.raw
tests/functional/snapshots-tmp/
45 changes: 28 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ include $(BOLOS_SDK)/Makefile.defines
# 43 0x8000002b XYM SYMBOL
APPNAME = 'Symbol'

ifeq ($(TARGET_NAME), TARGET_NANOX)
ifeq ($(TARGET_NAME),$(filter $(TARGET_NAME),TARGET_NANOX TARGET_STAX))
APP_LOAD_FLAGS=--appFlags 0x200 # APPLICATION_FLAG_BOLOS_SETTINGS
else
APP_LOAD_FLAGS=--appFlags 0x000
Expand All @@ -32,15 +32,18 @@ APP_LOAD_PARAMS=$(APP_LOAD_FLAGS) --path "44'/4343'" --path "44'/1'" --curve sec

APPVERSION_M=1
APPVERSION_N=0
APPVERSION_P=6
APPVERSION_P=8
APPVERSION=$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)
DEFINES += UNUSED\(x\)=\(void\)x
DEFINES += APPNAME=\"$(APPNAME)\"
DEFINES += APPVERSION=\"$(APPVERSION)\"

DEFINES += $(DEFINES_LIB)

ifeq ($(TARGET_NAME),TARGET_NANOS)
ICONNAME=icons/nanos_app_symbol.gif
else ifeq ($(TARGET_NAME),TARGET_STAX)
ICONNAME=icons/stax_app_symbol_32px.gif
else
ICONNAME=icons/nanox_app_symbol.gif
endif
Expand All @@ -54,9 +57,7 @@ all: default
# Platform #
############
DEFINES += OS_IO_SEPROXYHAL
DEFINES += HAVE_BAGL
DEFINES += HAVE_SPRINTF HAVE_UX_FLOW
# DEFINES += HAVE_PRINTF PRINTF=screen_printf
DEFINES += HAVE_SPRINTF

DEFINES += HAVE_IO_USB HAVE_L4_USBLIB IO_USB_MAX_ENDPOINTS=6 IO_HID_EP_LENGTH=64 HAVE_USB_APDU
DEFINES += LEDGER_MAJOR_VERSION=$(APPVERSION_M) LEDGER_MINOR_VERSION=$(APPVERSION_N) LEDGER_PATCH_VERSION=$(APPVERSION_P)
Expand All @@ -73,7 +74,7 @@ DEFINES += BLE_SEGMENT_SIZE=32

DEFINES += HAVE_WEBUSB WEBUSB_URL_SIZE_B=0 WEBUSB_URL=""

ifeq ($(TARGET_NAME),TARGET_NANOX)
ifeq ($(TARGET_NAME),$(filter $(TARGET_NAME),TARGET_NANOX TARGET_STAX))
DEFINES += HAVE_BLE BLE_COMMAND_TIMEOUT_MS=2000
DEFINES += HAVE_BLE_APDU
endif
Expand All @@ -82,12 +83,21 @@ ifeq ($(TARGET_NAME),TARGET_NANOS)
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=128
else
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=300
DEFINES += HAVE_GLO096
DEFINES += BAGL_WIDTH=128 BAGL_HEIGHT=64
DEFINES += HAVE_BAGL_ELLIPSIS
DEFINES += HAVE_BAGL_FONT_OPEN_SANS_REGULAR_11PX
DEFINES += HAVE_BAGL_FONT_OPEN_SANS_EXTRABOLD_11PX
DEFINES += HAVE_BAGL_FONT_OPEN_SANS_LIGHT_16PX
endif

ifeq ($(TARGET_NAME),TARGET_STAX)
DEFINES += NBGL_QRCODE
SDK_SOURCE_PATH += qrcode
else
DEFINES += HAVE_BAGL HAVE_UX_FLOW
ifneq ($(TARGET_NAME),TARGET_NANOS)
DEFINES += HAVE_GLO096
DEFINES += BAGL_WIDTH=128 BAGL_HEIGHT=64
DEFINES += HAVE_BAGL_ELLIPSIS # long label truncation feature
DEFINES += HAVE_BAGL_FONT_OPEN_SANS_REGULAR_11PX
DEFINES += HAVE_BAGL_FONT_OPEN_SANS_EXTRABOLD_11PX
DEFINES += HAVE_BAGL_FONT_OPEN_SANS_LIGHT_16PX
endif
endif

DEBUG = 0
Expand Down Expand Up @@ -126,9 +136,13 @@ include $(BOLOS_SDK)/Makefile.glyphs

### computed variables
APP_SOURCE_PATH += src
SDK_SOURCE_PATH += lib_stusb lib_stusb_impl lib_ux
SDK_SOURCE_PATH += lib_stusb lib_stusb_impl

ifeq ($(TARGET_NAME),TARGET_NANOX)
ifneq ($(TARGET_NAME),TARGET_STAX)
SDK_SOURCE_PATH += lib_ux
endif

ifeq ($(TARGET_NAME),$(filter $(TARGET_NAME),TARGET_NANOX TARGET_STAX))
SDK_SOURCE_PATH += lib_blewbxx lib_blewbxx_impl
endif

Expand All @@ -141,8 +155,5 @@ delete:
# import generic rules from the sdk
include $(BOLOS_SDK)/Makefile.rules

#add dependency on custom makefile filename
dep/%.d: %.c Makefile

listvariants:
@echo VARIANTS COIN xym
Binary file removed glyphs/badge_symbol.gif
Binary file not shown.
Binary file removed glyphs/badge_transaction.gif
Binary file not shown.
Binary file removed glyphs/icon_toggle_reset.gif
Binary file not shown.
Binary file removed glyphs/icon_toggle_set.gif
Binary file not shown.
Binary file added glyphs/stax_app_symbol_64px.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/stax_app_symbol_32px.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions ledger_app.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[app]
build_directory = "./"
sdk = "C"
devices = ["nanos", "nanox", "nanos+", "stax"]

[tests]
unit_directory = "./tests/unit-tests/"
pytest_directory = "./tests/functional"
6 changes: 4 additions & 2 deletions src/apdu/messages/get_public_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ int send_public_key()
void on_address_confirmed()
{
send_public_key();
display_idle_menu();

display_address_confirmation_done(true);
}


Expand All @@ -66,7 +67,8 @@ void on_address_confirmed()
void on_address_rejected()
{
io_send_error(ADDRESS_REJECTED);
display_idle_menu();

display_address_confirmation_done(false);
}


Expand Down
7 changes: 3 additions & 4 deletions src/apdu/messages/sign_transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "global.h"
#include "xym/xym_helpers.h"
#include "ui/main/idle_menu.h"
#include "ui/transaction/review_menu.h"
#include "transaction/transaction.h"
#include "printers.h"
#include "io.h"
Expand Down Expand Up @@ -87,8 +88,7 @@ void sign_transaction()
io_send_response( &response, OK );
explicit_bzero( signature, sizeof(signature) );

// Display back the original UX
display_idle_menu();
display_review_done(true);
}

void reject_transaction()
Expand All @@ -103,8 +103,7 @@ void reject_transaction()
// notify of rejected transaction
handle_error( TRANSACTION_REJECTED );

// display the idle menu
display_idle_menu();
display_review_done(false);
}

bool isFirst(uint8_t p1)
Expand Down
2 changes: 2 additions & 0 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#define LEDGER_APP_XYM_COMMON_H

#include <string.h>
#include <stdint.h>
#include <stdbool.h>

typedef void (*action_t)();

Expand Down
2 changes: 1 addition & 1 deletion src/limitations.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
// Hardware dependent limits
// Ledger Nano X has 30K RAM
// Ledger Nano S has 4K RAM
#if defined(TARGET_NANOX) || defined(TARGET_NANOS2)
#if defined(TARGET_NANOX) || defined(TARGET_NANOS2) || defined(TARGET_STAX)

#define MAX_FIELD_COUNT 60
#define MAX_FIELD_LEN 1024
Expand Down
Loading

0 comments on commit 2265ddd

Please sign in to comment.