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

Release Stax porting #85

Merged
merged 53 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
c7392bb
Move IO functions form main and utils to dedicated io.c file
fbeutin-ledger Mar 23, 2023
66bfff9
Move BAGL UI code for main menu in dedicated file
fbeutin-ledger Mar 23, 2023
96a49a3
Move BAGL UI code for GET_PUBKEY instruction in dedicated file
fbeutin-ledger Mar 23, 2023
60cbae5
Move BAGL UI code for SIGN_MESSAGE instruction in dedicated file
fbeutin-ledger Mar 23, 2023
33ddeb7
Factorize functions in utils
fbeutin-ledger Mar 23, 2023
1105e63
Factorize UX for message and offchain message signing
fbeutin-ledger Mar 23, 2023
1042ade
Lint
fbeutin-ledger Mar 23, 2023
4d90622
Review
fbeutin-ledger Mar 30, 2023
0d590f1
Merge pull request #62 from LedgerHQ/fbe/separate_ui_from_parsing
fbeutin-ledger Jun 6, 2023
4534779
Enable compilation for Stax and port main menu and settings menu
fbeutin-ledger Mar 23, 2023
30761a7
Add Stax screen for GET_PUBLIC_KEY instruction
fbeutin-ledger Mar 23, 2023
a11f329
Add Stax screen for SIGN_MESSAGE instruction
fbeutin-ledger Mar 23, 2023
b00fa8d
Add Stax screen for SIGN_OFFCHAIN_MESSAGE instruction
fbeutin-ledger Mar 23, 2023
60fa447
Lint
fbeutin-ledger Mar 23, 2023
4ea8380
Review
fbeutin-ledger Mar 30, 2023
5f2417d
Update screenshots
fbeutin-ledger Jun 13, 2023
3e6b02b
Update Stax UI following product review
fbeutin-ledger Jun 14, 2023
0630d32
Review
fbeutin-ledger Jun 20, 2023
639bf61
Merge pull request #69 from LedgerHQ/fbe/stax_porting_rebased
fbeutin-ledger Jun 20, 2023
e6a110c
Hotfix Stax compilation
fbeutin-ledger Jun 20, 2023
92d146d
hotfix test snapshots
fbeutin-ledger Jun 20, 2023
715a97a
Add guidelines enforcer
fbeutin-ledger Jun 20, 2023
49226e8
Merge pull request #70 from LedgerHQ/fbe/add_guidelines_enforcer
fbeutin-ledger Jun 20, 2023
c911182
Solana now returns to Exchange after a sign
fbeutin-ledger Jun 20, 2023
e2a9f25
Update LNX snapshots for latest SDK
fbeutin-ledger Jun 26, 2023
532920c
Merge pull request #71 from LedgerHQ/fbe/return_in_exchange
fbeutin-ledger Jun 26, 2023
b6e8825
QR code source path is now used explicitly
apaillier-ledger Aug 3, 2023
e4bcb49
Merge pull request #73 from LedgerHQ/fix/apa/explicit_qrcode_source_path
apaillier-ledger Aug 4, 2023
8438b58
Add a modal when started by Exchange
fbeutin-ledger Aug 29, 2023
24d74f0
Adapt snapshots for latest Stax SDK
fbeutin-ledger Aug 29, 2023
4a99a33
Merge pull request #74 from LedgerHQ/fbe/stax_modal_on_swap
fbeutin-ledger Aug 29, 2023
bd00508
Use new 4bpp icon
fbeutin-ledger Sep 1, 2023
98a22dd
Merge pull request #75 from LedgerHQ/fbe/4bpp_icon
fbeutin-ledger Sep 1, 2023
eb23fcf
Remove unneeded param APPLICATION_FLAG_BOLOS_SETTINGS for Nanos+
fbeutin-ledger Sep 5, 2023
ef1dbca
Merge pull request #76 from LedgerHQ/fbe/fix_app_load_params
fbeutin-ledger Sep 6, 2023
59aa4ba
[auto]: add PR template
sgliner-ledger Nov 29, 2023
da26500
[add] ledger_app.toml manifest
lpascal-ledger Dec 1, 2023
1a17b33
Merge pull request #79 from LedgerHQ/add/manifest
fbeutin-ledger Dec 1, 2023
0b73d10
src: Improve crypto code using SDK crypto_helpers and LEDGER_ASSERT
Dec 12, 2023
ad37ff9
src: Cleanup unused parameter from BLE_power()
Dec 12, 2023
8198345
src: Drop deprectaed check_api_level()
Dec 12, 2023
d4098be
Merge pull request #82 from LedgerHQ/xch/fix-ci-warnings
xchapron-ledger Dec 14, 2023
cfac20e
workflows/sonarcloud.yml: Update workflow following app-bitcoin-new e…
Dec 14, 2023
9f5b1cd
Merge pull request #83 from LedgerHQ/xch/sonarcloud
xchapron-ledger Dec 14, 2023
71d0904
[auto] Update screenshot
Jan 10, 2024
2d1f62f
Merge pull request #84 from LedgerHQ/auto-update-screenshots
sgliner-ledger Jan 11, 2024
33e3cc8
[auto] Update screenshot
Feb 21, 2024
d769b7a
Merge pull request #86 from LedgerHQ/auto-update-screenshots
sgliner-ledger Feb 21, 2024
2d4f805
[auto] Update screenshot
sgliner-ledger Feb 27, 2024
3dfa53e
[auto] Update screenshot
Apr 8, 2024
5c5e1b6
Merge pull request #87 from LedgerHQ/auto-update-screenshots
sgliner-ledger Apr 8, 2024
ce8ca77
Release v1.4.3
fbeutin-ledger Apr 24, 2024
5138865
Merge pull request #88 from LedgerHQ/fbe/release_v1.4.3
fbeutin-ledger Apr 24, 2024
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
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
Loading