Skip to content

Commit

Permalink
Merge pull request #85 from LedgerHQ/develop
Browse files Browse the repository at this point in the history
Release Stax porting
Align master with P1
  • Loading branch information
fbeutin-ledger authored May 13, 2024
2 parents 1160a67 + 5138865 commit 96c4514
Show file tree
Hide file tree
Showing 291 changed files with 1,017 additions and 628 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 -->
3 changes: 0 additions & 3 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,13 @@ jobs:
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_build.yml@v1
with:
upload_app_binaries_artifact: compiled_app_binaries
run_for_devices: '["nanos", "nanox", "nanosp"]'

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
test_dir: tests/python
run_for_devices: '["nanos", "nanox", "nanosp"]'

job_C_test:
name: C tests
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
73 changes: 28 additions & 45 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,54 +8,37 @@ on:
pull_request:

jobs:
build:
name: SonarQube analyze
sonarcloud:
runs-on: ubuntu-latest
container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-legacy:latest

env:
SONAR_SCANNER_VERSION: 4.7.0.2747
SONAR_SERVER_URL: "https://sonarcloud.io"
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Download and set up sonar-scanner
env:
SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-linux.zip
run: |
apt-get update -y
apt-get upgrade -y
DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata
curl -sL https://deb.nodesource.com/setup_16.x | bash -
apt-get install -y gcovr nodejs unzip lcov
mkdir -p $HOME/.sonar
curl -sSLo $HOME/.sonar/sonar-scanner.zip ${{ env.SONAR_SCANNER_DOWNLOAD_URL }}
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
echo "$HOME/.sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-linux/bin" >> $GITHUB_PATH
- name: Download and set up build-wrapper
env:
BUILD_WRAPPER_DOWNLOAD_URL: ${{ env.SONAR_SERVER_URL }}/static/cpp/build-wrapper-linux-x86.zip
run: |
curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip ${{ env.BUILD_WRAPPER_DOWNLOAD_URL }}
unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
echo "$HOME/.sonar/build-wrapper-linux-x86" >> $GITHUB_PATH
- name: Generate code coverage
working-directory: libsol
run: |
make COVERAGE=1
gcovr --root .. --sonarqube ../coverage.xml
- name: Run build-wrapper
run: |
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} make clean all
- name: Run sonar-scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}"
- uses: actions/checkout@v3
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- name: Install dependencies
run: |
apt-get update -y
apt-get upgrade -y
DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata
apt-get install -y libcmocka-dev gcovr unzip
- name: Install sonar-scanner and build-wrapper
uses: sonarsource/sonarcloud-github-c-cpp@v2

- name: Generate code coverage
working-directory: libsol
run: |
make COVERAGE=1
gcovr --root .. --sonarqube ../coverage.xml
- name: Run build-wrapper
run: |
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} make clean all
- name: Run sonar-scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: sonar-scanner --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" #Consult https://docs.sonarcloud.io/advanced-setup/ci-based-analysis/sonarscanner-cli/ for more information and options
46 changes: 32 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,24 @@ endif
include $(BOLOS_SDK)/Makefile.defines

APP_LOAD_PARAMS = --curve ed25519
ifeq ($(TARGET_NAME), TARGET_NANOS)
APP_LOAD_PARAMS += --appFlags 0x800 # APPLICATION_FLAG_LIBRARY
else
ifeq ($(TARGET_NAME),$(filter $(TARGET_NAME),TARGET_NANOX TARGET_STAX))
APP_LOAD_PARAMS += --appFlags 0xa00 # APPLICATION_FLAG_LIBRARY + APPLICATION_FLAG_BOLOS_SETTINGS
else
APP_LOAD_PARAMS += --appFlags 0x800 # APPLICATION_FLAG_LIBRARY
endif
APP_LOAD_PARAMS += --path "44'/501'"
APP_LOAD_PARAMS += $(COMMON_LOAD_PARAMS)

APPNAME = "Solana"
APPVERSION_M = 1
APPVERSION_N = 4
APPVERSION_P = 1
APPVERSION_P = 3
APPVERSION = "$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)"

ifeq ($(TARGET_NAME),TARGET_NANOS)
ICONNAME=icons/nanos_app_solana.gif
else ifeq ($(TARGET_NAME),TARGET_STAX)
ICONNAME=icons/stax_app_solana.gif
else
ICONNAME=icons/nanox_app_solana.gif
endif
Expand All @@ -59,27 +61,36 @@ DEFINES += APPNAME=\"$(APPNAME)\"
DEFINES += APPVERSION=\"$(APPVERSION)\"
DEFINES += MAJOR_VERSION=$(APPVERSION_M) MINOR_VERSION=$(APPVERSION_N) PATCH_VERSION=$(APPVERSION_P)
DEFINES += OS_IO_SEPROXYHAL
DEFINES += HAVE_BAGL HAVE_UX_FLOW HAVE_SPRINTF
DEFINES += HAVE_SPRINTF
DEFINES += HAVE_IO_USB HAVE_L4_USBLIB IO_USB_MAX_ENDPOINTS=6 IO_HID_EP_LENGTH=64 HAVE_USB_APDU
DEFINES += USB_SEGMENT_SIZE=64
DEFINES += BLE_SEGMENT_SIZE=32
DEFINES += HAVE_WEBUSB WEBUSB_URL_SIZE_B=0 WEBUSB_URL=""
DEFINES += UNUSED\(x\)=\(void\)x

ifeq ($(TARGET_NAME),TARGET_NANOX)
ifeq ($(TARGET_NAME),$(filter $(TARGET_NAME),TARGET_NANOX TARGET_STAX))
DEFINES += HAVE_BLE BLE_COMMAND_TIMEOUT_MS=2000 HAVE_BLE_APDU
endif

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
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 @@ -118,9 +129,16 @@ LDLIBS += -lm -lgcc -lc
include $(BOLOS_SDK)/Makefile.glyphs

APP_SOURCE_PATH += src
SDK_SOURCE_PATH += lib_stusb lib_stusb_impl lib_ux
SDK_SOURCE_PATH += lib_stusb lib_stusb_impl

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

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

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

Expand Down
File renamed without changes
Binary file added glyphs/icon_solana_64x64.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_solana.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions ledger_app.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[app]
build_directory = "./"
sdk = "C"
devices = ["nanos", "nanox", "nanos+", "stax"]

[tests]
pytest_directory = "./tests/python"
3 changes: 2 additions & 1 deletion src/apdu.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ typedef enum ApduReply {
ApduReplySdkNotEnoughSpace = 0x6819,

ApduReplyNoApduReceived = 0x6982,
ApduReplyUserRefusal = 0x6985,

ApduReplySolanaInvalidMessage = 0x6a80,
ApduReplySolanaInvalidMessageHeader = 0x6a81,
Expand Down Expand Up @@ -79,4 +80,4 @@ extern ApduCommand G_command;

int apdu_handle_message(const uint8_t* apdu_message,
size_t apdu_message_len,
ApduCommand* apdu_command);
ApduCommand* apdu_command);
39 changes: 6 additions & 33 deletions src/getPubkey.c → src/handle_get_pubkey.c
Original file line number Diff line number Diff line change
@@ -1,51 +1,24 @@
#include "apdu.h"
#include "getPubkey.h"
#include "os.h"
#include "ux.h"
#include "utils.h"
#include "globals.h"
#include "handle_get_pubkey.h"
#include "sol/printer.h"
#include "ui_api.h"

static uint8_t G_publicKey[PUBKEY_LENGTH];
static char G_publicKeyStr[BASE58_PUBKEY_LENGTH];
char G_publicKeyStr[BASE58_PUBKEY_LENGTH];

void reset_getpubkey_globals(void) {
MEMCLEAR(G_publicKey);
MEMCLEAR(G_publicKeyStr);
}

static uint8_t set_result_get_pubkey() {
uint8_t set_result_get_pubkey(void) {
memcpy(G_io_apdu_buffer, G_publicKey, PUBKEY_LENGTH);
return PUBKEY_LENGTH;
}

//////////////////////////////////////////////////////////////////////

UX_STEP_NOCB(ux_display_public_flow_5_step,
bnnn_paging,
{
.title = "Pubkey",
.text = G_publicKeyStr,
});
UX_STEP_CB(ux_display_public_flow_6_step,
pb,
sendResponse(set_result_get_pubkey(), true, true),
{
&C_icon_validate_14,
"Approve",
});
UX_STEP_CB(ux_display_public_flow_7_step,
pb,
sendResponse(0, false, true),
{
&C_icon_crossmark,
"Reject",
});

UX_FLOW(ux_display_public_flow,
&ux_display_public_flow_5_step,
&ux_display_public_flow_6_step,
&ux_display_public_flow_7_step);

void handle_get_pubkey(volatile unsigned int *flags, volatile unsigned int *tx) {
if (!flags || !tx ||
(G_command.instruction != InsDeprecatedGetPubkey &&
Expand All @@ -61,7 +34,7 @@ void handle_get_pubkey(volatile unsigned int *flags, volatile unsigned int *tx)
*tx = set_result_get_pubkey();
THROW(ApduReplySuccess);
} else {
ux_flow_init(0, ux_display_public_flow, NULL);
ui_get_public_key();
*flags |= IO_ASYNCH_REPLY;
}
}
8 changes: 5 additions & 3 deletions src/getPubkey.h → src/handle_get_pubkey.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#pragma once

#include "os.h"
#include "cx.h"
#include "globals.h"
#include "sol/printer.h"

#ifndef _GET_PUBKEY_H_
#define _GET_PUBKEY_H_
extern char G_publicKeyStr[BASE58_PUBKEY_LENGTH];

void reset_getpubkey_globals(void);

void handle_get_pubkey(volatile unsigned int *flags, volatile unsigned int *tx);

#endif
uint8_t set_result_get_pubkey(void);
Loading

0 comments on commit 96c4514

Please sign in to comment.