Skip to content

Commit

Permalink
Merge pull request #10 from LedgerHQ/stax
Browse files Browse the repository at this point in the history
Stax porting
  • Loading branch information
sgliner-ledger authored Mar 9, 2023
2 parents c191398 + 1edc562 commit 88ad823
Show file tree
Hide file tree
Showing 449 changed files with 1,132 additions and 137 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/build_and_functional_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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.

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"
test_dir: tests/python
50 changes: 1 addition & 49 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,54 +12,6 @@ on:
- develop

jobs:
nanos_build:
name: Build app for NanoS
runs-on: ubuntu-latest
container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest
steps:
- name: Clone
uses: actions/checkout@v2
- name: Build
run: make
- name: Upload app binary
uses: actions/upload-artifact@v2
with:
name: celo-app
path: bin

nanox_build:
name: Build app for NanoX
runs-on: ubuntu-latest
container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest
steps:
- name: Clone
uses: actions/checkout@v2
- name: Build
run: make BOLOS_SDK=$NANOX_SDK
- name: Upload app binary
uses: actions/upload-artifact@v2
with:
name: celo-app
path: bin

job_scan_build:
name: Clang Static Analyzer
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_unit_test:
name: Unit test
Expand All @@ -71,7 +23,7 @@ jobs:
uses: actions/checkout@v2
- name: Build unit tests
run: |
cd tests/
cd tests/unit
cmake -Bbuild -H.
make -C build
make -C build test
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
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
bin
debug
dep
obj
src/glyphs.c
src/glyphs.h

tests/python/snapshots-tmp/
__pycache__
build/
39 changes: 27 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ APPVERSION=$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)
APP_LOAD_PARAMS += --path "44'/52752'"
APPNAME = "Celo"
APP_LOAD_FLAGS=--appFlags 0
ifeq ($(TARGET_NAME), TARGET_NANOX)
ifeq ($(TARGET_NAME),$(filter $(TARGET_NAME),TARGET_NANOX TARGET_STAX))
APP_LOAD_FLAGS=--appFlags 0x200 # APPLICATION_FLAG_BOLOS_SETTINGS
endif
APP_LOAD_PARAMS += $(APP_LOAD_FLAGS)

#prepare hsm generation
ifeq ($(TARGET_NAME), TARGET_NANOS)
ICONNAME=nanos_app_celo.gif
else ifeq ($(TARGET_NAME),TARGET_STAX)
ICONNAME=stax_app_celo.gif
else
ICONNAME=nanox_app_celo.gif
endif
Expand All @@ -53,10 +55,9 @@ all: default
############

DEFINES += OS_IO_SEPROXYHAL
DEFINES += HAVE_BAGL 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 += LEDGER_MAJOR_VERSION=$(APPVERSION_M) LEDGER_MINOR_VERSION=$(APPVERSION_N) LEDGER_PATCH_VERSION=$(APPVERSION_P)
DEFINES += HAVE_UX_FLOW

# U2F
DEFINES += HAVE_U2F HAVE_IO_U2F
Expand All @@ -71,7 +72,7 @@ DEFINES += APPVERSION=\"$(APPVERSION)\"

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 # basic ledger apdu transport over BLE
endif
Expand All @@ -80,12 +81,20 @@ ifeq ($(TARGET_NAME),TARGET_NANOS)
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=128
else
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=300
DEFINES += HAVE_GLO096
DEFINES += HAVE_BAGL 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

ifeq ($(TARGET_NAME),TARGET_STAX)
DEFINES += NBGL_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

# Enabling debug PRINTF
Expand Down Expand Up @@ -137,11 +146,17 @@ include $(BOLOS_SDK)/Makefile.glyphs

### variables processed by the common makefile.rules of the SDK to grab source files and include dirs
APP_SOURCE_PATH += src_common src
SDK_SOURCE_PATH += lib_stusb lib_stusb_impl lib_u2f lib_ux
ifeq ($(TARGET_NAME),TARGET_NANOX)
SDK_SOURCE_PATH += lib_stusb lib_stusb_impl lib_u2f

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

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


load: all
python -m ledgerblue.loadApp $(APP_LOAD_PARAMS)

Expand Down
Binary file added glyphs/celo_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 removed glyphs/icon_toggle_reset.gif
Binary file not shown.
Binary file removed glyphs/icon_toggle_set.gif
Binary file not shown.
Binary file removed glyphs/icon_warning.gif
Binary file not shown.
49 changes: 21 additions & 28 deletions src/celo.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
#include "os.h"
#include "utils.h"

// TODO: remove this. This module should be independant from ui
#include "ui_flow.h"
#include "ui_common.h"

#include <string.h>

Expand Down Expand Up @@ -302,7 +301,7 @@ customStatus_e customProcessor(txContext_t *context) {
dataContext.rawDataContext.fieldOffset = 0;
if (fieldPos == 0) {
array_hexstr(strings.tmp.tmp, dataContext.rawDataContext.data, 4);
ux_flow_init(0, ux_confirm_selector_flow, NULL);
ui_confirm_selector_flow();
}
else {
uint32_t offset = 0;
Expand All @@ -314,7 +313,7 @@ customStatus_e customProcessor(txContext_t *context) {
strings.tmp.tmp[offset++] = ':';
}
}
ux_flow_init(0, ux_confirm_parameter_flow, NULL);
ui_confirm_parameter_flow();
}
}
else {
Expand Down Expand Up @@ -520,45 +519,39 @@ void finalizeParsing(bool direct) {
switch(provisionType) {
case PROVISION_LOCK:
case PROVISION_UNLOCK:
ux_flow_init(0,
ux_approval_celo_lock_unlock_flow,
NULL);
ui_approval_celo_lock_unlock_flow();
break;
case PROVISION_WITHDRAW:
ux_flow_init(0,
ux_approval_celo_withdraw_flow,
NULL);
ui_approval_celo_withdraw_flow();
break;
case PROVISION_VOTE:
case PROVISION_REVOKE:
ux_flow_init(0,
ux_approval_celo_vote_revoke_flow,
NULL);
ui_approval_celo_vote_revoke_flow();
break;
case PROVISION_ACTIVATE:
ux_flow_init(0,
ux_approval_celo_activate_flow,
NULL);
ui_approval_celo_activate_flow();
break;
case PROVISION_RELOCK:
ux_flow_init(0,
ux_approval_celo_relock_flow,
NULL);
ui_approval_celo_relock_flow();
break;
case PROVISION_CREATE_ACCOUNT:
ux_flow_init(0,
ux_approval_celo_create_account_flow,
NULL);
ui_approval_celo_create_account_flow();
break;
default:
if (tmpContent.txContent.gatewayDestinationLength != 0) {
ux_flow_init(0,
((dataPresent && !N_storage.contractDetails) ? ux_approval_celo_data_warning_gateway_tx_flow : ux_approval_celo_gateway_tx_flow),
NULL);
if (dataPresent && !N_storage.contractDetails) {
ui_approval_celo_data_warning_gateway_tx_flow();
}
else {
ui_approval_celo_gateway_tx_flow();
}
} else {
ux_flow_init(0,
((dataPresent && !N_storage.contractDetails) ? ux_approval_celo_data_warning_tx_flow : ux_approval_celo_tx_flow),
NULL);
if (dataPresent && !N_storage.contractDetails) {
ui_approval_celo_data_warning_tx_flow();
}
else {
ui_approval_celo_tx_flow();
}
}
}
#endif // NO_CONSENT
Expand Down
Loading

0 comments on commit 88ad823

Please sign in to comment.