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

B2CA-1942: nbgl on nano #736

Draft
wants to merge 10 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
with:
builtin: clear,rare
check_filenames: true
path: src, src_bagl, src_features, src_nbgl, src_plugin_sdk, src_plugins, doc, client
path: src, src_bagl, src_features, src_nbgl, src_plugins, doc, client
9 changes: 5 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -14,7 +14,7 @@ repos:
- id: check-case-conflict

- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
rev: v2.3.0
hooks:
- id: codespell
args: ['--ignore-words-list', 'ontop,shft,hte', '--skip', 'makefile_conf/chain/*,tests/ragger/eip712_input_files/*']
Expand All @@ -26,7 +26,7 @@ repos:
types_or: [c]

- repo: https://github.com/Mateusz-Grzelinski/actionlint-py
rev: v1.6.27.13
rev: v1.7.6.22
hooks:
- id: actionlint
types_or: [yaml]
Expand All @@ -39,9 +39,10 @@ repos:
types_or: [markdown]

- repo: https://github.com/PyCQA/pylint
rev: v2.16.2
rev: v3.3.3
hooks:
- id: pylint
language: system
types: [python]
args: ['--jobs=0', '--rcfile=tests/ragger/setup.cfg']
files: '^tests/ragger/.*$'
18 changes: 12 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ifeq ($(BOLOS_SDK),)
$(error Environment variable BOLOS_SDK is not set)
endif

include $(BOLOS_SDK)/Makefile.defines
include $(BOLOS_SDK)/Makefile.target

########################################
# Mandatory configuration #
Expand All @@ -42,10 +42,10 @@ APPVERSION = $(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)-dev

# Application source files
APP_SOURCE_PATH += src src_features src_plugins
ifeq ($(TARGET_NAME),$(filter $(TARGET_NAME),TARGET_STAX TARGET_FLEX))
APP_SOURCE_PATH += src_nbgl
else
ifeq ($(TARGET_NAME),TARGET_NANOS)
APP_SOURCE_PATH += src_bagl
else
APP_SOURCE_PATH += src_nbgl
endif
APP_SOURCE_FILES += $(filter-out ./ethereum-plugin-sdk/src/main.c, $(wildcard ./ethereum-plugin-sdk/src/*.c))
INCLUDES_PATH += ./ethereum-plugin-sdk/src
Expand All @@ -72,7 +72,11 @@ ICON_FLEX = icons/flex_app_chain_$(CHAIN_ID).gif
ifeq ($(TARGET_NAME),$(filter $(TARGET_NAME),TARGET_STAX TARGET_FLEX))
DEFINES += ICONGLYPH=C_chain_$(CHAIN_ID)_64px
DEFINES += ICONBITMAP=C_chain_$(CHAIN_ID)_64px_bitmap
DEFINES += ICONGLYPH_SMALL=C_chain_$(CHAIN_ID)
else
ifeq ($(TARGET_NAME),$(filter $(TARGET_NAME),TARGET_NANOX TARGET_NANOS2))
DEFINES += ICONGLYPH=C_chain_$(CHAIN_ID)_14px
DEFINES += ICONBITMAP=C_chain_$(CHAIN_ID)_14px_bitmap
endif
endif

# Don't define plugin function in the plugin SDK
Expand Down Expand Up @@ -127,6 +131,9 @@ HAVE_APPLICATION_FLAG_LIBRARY = 1
ENABLE_BLUETOOTH = 1
ENABLE_SWAP = 1
#ENABLE_NFC = 1
ifneq ($(TARGET_NAME),TARGET_NANOS)
ENABLE_NBGL_FOR_NANO_DEVICES = 1
endif

########################################
# NBGL custom features #
Expand All @@ -146,7 +153,6 @@ ENABLE_NBGL_QRCODE = 1
#DISABLE_STANDARD_SNPRINTF = 1
#DISABLE_STANDARD_USB = 1
#DISABLE_STANDARD_WEBUSB = 1
#DISABLE_STANDARD_BAGL_UX_FLOW = 1
#DISABLE_DEBUG_LEDGER_ASSERT = 1
#DISABLE_DEBUG_THROW = 1

Expand Down
33 changes: 15 additions & 18 deletions client/src/ledger_app_clients/ethereum/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,45 +28,42 @@ def get_device_settings(firmware: Firmware) -> list[SettingID]:
]


def get_setting_position(firmware: Firmware, setting_idx: int, per_page: int) -> tuple[int, int]:
def get_setting_position(firmware: Firmware, setting_idx: int) -> tuple[int, int]:
if firmware == Firmware.STAX:
screen_height = 672 # px
screen_width = 400 # px
header_height = 88 # px
footer_height = 92 # px
x = 245
else:
screen_height = 600 # px
screen_width = 480 # px
header_height = 96 # px
footer_height = 96 # px
x = 415

index_in_page = setting_idx % per_page
usable_height = screen_height - (header_height + footer_height)
setting_height = usable_height // per_page
offset = (setting_height * index_in_page) + (setting_height // 2)
return screen_width // 2, header_height + offset
if setting_idx % 2 == 0:
y = 135
else:
y = 300

return x, y


def settings_toggle(firmware: Firmware, nav: Navigator, to_toggle: list[SettingID]):
moves: list[Union[NavIns, NavInsID]] = []
settings = get_device_settings(firmware)
# Assume the app is on the home page
if firmware.is_nano:
moves += [NavInsID.RIGHT_CLICK] * 2
if firmware == Firmware.NANOS:
moves += [NavInsID.RIGHT_CLICK]
moves += [NavInsID.RIGHT_CLICK]
moves += [NavInsID.BOTH_CLICK]

for setting in settings:
if setting in to_toggle:
moves += [NavInsID.BOTH_CLICK]
moves += [NavInsID.RIGHT_CLICK]
moves += [NavInsID.BOTH_CLICK] # Back
else:
moves += [NavInsID.USE_CASE_HOME_SETTINGS]
settings_per_page = 3 if firmware == Firmware.STAX else 2
for setting in settings:
setting_idx = settings.index(setting)
if (setting_idx > 0) and (setting_idx % settings_per_page) == 0:
if (setting_idx > 0) and (setting_idx % 2) == 0:
moves += [NavInsID.USE_CASE_SETTINGS_NEXT]
if setting in to_toggle:
moves += [NavIns(NavInsID.TOUCH, get_setting_position(firmware, setting_idx, settings_per_page))]
moves += [NavIns(NavInsID.TOUCH, get_setting_position(firmware, setting_idx))]
moves += [NavInsID.USE_CASE_SETTINGS_MULTI_PAGE_EXIT]
nav.navigate(moves, screen_change_before_first_instruction=False)
1 change: 1 addition & 0 deletions glyphs/chain_108_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_1284_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_1285_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_1313114_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_1620_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_1666600000_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_1987_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_19_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_1_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_200625_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_20531812_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_237_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_24484_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_246529_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_246_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_248_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_269_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_2894_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_2_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_30_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_31102_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_3125659152_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_31_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_336_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_4689_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_50_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_592_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_60_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_61_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_64_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_76_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_7762959_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_78_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_820_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_846000_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_888_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_88_14px.gif
1 change: 1 addition & 0 deletions glyphs/chain_8_14px.gif
Binary file modified icons/nanos_app_chain_246.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 icons/nanos_app_ewc.gif
Binary file not shown.
Binary file removed icons/nanos_app_theta.gif
Binary file not shown.
Binary file modified icons/nanox_app_chain_246.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 icons/nanox_app_ewc.gif
Binary file not shown.
Binary file removed icons/nanox_app_theta.gif
Binary file not shown.
3 changes: 0 additions & 3 deletions src/chainConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
#ifndef _CHAIN_CONFIG_H_
#define _CHAIN_CONFIG_H_

#include <stdint.h>

#include "os.h"
#include "asset_info.h"

typedef struct chain_config_s {
Expand Down
6 changes: 1 addition & 5 deletions src/common_ui.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#ifndef _COMMON_UI_H_
#define _COMMON_UI_H_

#include <stdbool.h>
#include <stdint.h>
#include "ui_logic.h"
#include <stdbool.h>

void ui_idle(void);
void ui_warning_blind_signing(void);
Expand Down Expand Up @@ -32,7 +31,4 @@ void ui_712_switch_to_sign(void);
// Generic clear-signing
bool ui_gcs(void);

#include "ui_callbacks.h"
#include <string.h>

#endif // _COMMON_UI_H_
3 changes: 0 additions & 3 deletions src/handle_check_address.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#include "handle_check_address.h"
#include "apdu_constants.h"
#include "os.h"
#include "shared_context.h"
#include "string.h"
#include "crypto_helpers.h"

#define ZERO(x) explicit_bzero(&x, sizeof(x))
Expand Down
9 changes: 1 addition & 8 deletions src/handle_get_printable_amount.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
#include <stdint.h>
#include <os.h>

#include "os.h"
#include "eth_swap_utils.h"
#include "handle_get_printable_amount.h"
#include "shared_context.h"
#include "common_utils.h"
#include "uint256.h"
#include "string.h"
#include "network.h"
#include "apdu_constants.h"

Expand Down
7 changes: 1 addition & 6 deletions src/handle_swap_sign_transaction.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#include "os_io_seproxyhal.h"
#include "os.h"
#include "ux.h"
#include "eth_swap_utils.h"
#include "handle_swap_sign_transaction.h"
#include "shared_context.h"
#include "common_utils.h"
#include "network.h"
#include "cmd_setPlugin.h"
#ifdef HAVE_NBGL
Expand Down Expand Up @@ -162,7 +157,7 @@ void __attribute__((noreturn)) handle_swap_sign_transaction(const chain_config_t

storage_init();

#ifdef HAVE_NBGL
#ifdef SCREEN_SIZE_WALLET
nbgl_useCaseSpinner("Signing");
#endif // HAVE_NBGL

Expand Down
1 change: 0 additions & 1 deletion src/manage_asset_info.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "manage_asset_info.h"
#include "shared_context.h"

void forget_known_assets(void) {
memset(tmpCtx.transactionContext.assetSet, false, MAX_ASSETS);
Expand Down
2 changes: 0 additions & 2 deletions src/manage_asset_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#define MANAGE_ASSET_INFO_H_

#include "shared_context.h"
#include "common_utils.h"
#include "asset_info.h"

void forget_known_assets(void);
int get_asset_index_by_addr(const uint8_t *addr);
Expand Down
1 change: 0 additions & 1 deletion src/mem_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#ifdef HAVE_DYN_MEM_ALLOC

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

#define MEM_ALLOC_AND_ALIGN_TYPE(type) mem_alloc_and_align(sizeof(type), __alignof__(type))

Expand Down
1 change: 0 additions & 1 deletion src/network.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <string.h>
#include "os_utils.h"
#include "os_pic.h"
#include "network.h"
Expand Down
12 changes: 0 additions & 12 deletions src/shared_context.h
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
#ifndef _SHARED_CONTEXT_H_
#define _SHARED_CONTEXT_H_

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

#include "os.h"
#include "cx.h"
#include "bip32.h"
#include "bip32_utils.h"
#include "ethUstream.h"
#include "tx_content.h"
#include "chainConfig.h"
#include "asset_info.h"
#include "swap_utils.h"

#ifdef HAVE_NBGL
#include "nbgl_types.h"
#endif

extern void app_exit(void);
extern void common_app_init(void);

Expand Down
Loading
Loading