Skip to content

Commit

Permalink
New zxlib, no adjusmens
Browse files Browse the repository at this point in the history
this version does not work, it is here just as zxlib changes reference.
  • Loading branch information
relatko committed Aug 6, 2024
1 parent 24ba23a commit b51a0fc
Show file tree
Hide file tree
Showing 39 changed files with 1,898 additions and 694 deletions.
5 changes: 5 additions & 0 deletions deps/ledger-zxlib/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
BasedOnStyle: Google
IndentWidth: 4
ColumnLimit: 120
DerivePointerAlignment: false
PointerAlignment: Right
21 changes: 21 additions & 0 deletions deps/ledger-zxlib/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Checks: "-*,
clang-analyzer-*,
clang-diagnostic-*,
cppcoreguidelines-init-variables,
google-readability-avoid-underscore-in-googletest-name,
google-runtime-int,
misc-*,
performance-*,
portability-*,
readability-*,
-misc-no-recursion,
-readability-function-cognitive-complexity
-readability-magic-numbers"
WarningsAsErrors: "*"
CheckOptions:
- key: readability-identifier-length.MinimumVariableNameLength
value: 2
- key: readability-identifier-length.MinimumParameterNameLength
value: 2
- key: readability-identifier-length.MinimumLoopCounterNameLength
value: 1
6 changes: 3 additions & 3 deletions deps/ledger-zxlib/.github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: true
- run: cmake -DCMAKE_BUILD_TYPE=Debug . && make
Expand All @@ -26,7 +26,7 @@ jobs:
exists: ${{ steps.get-version.outputs.exists }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
Expand All @@ -53,7 +53,7 @@ jobs:
if: ${{ needs.check_version.outputs.exists != 'true' && github.ref == 'refs/heads/main' }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.check_version.outputs.version }}
35 changes: 27 additions & 8 deletions deps/ledger-zxlib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#*******************************************************************************
#* (c) 2018 Zondax GmbH
#* (c) 2018 Zondax AG
#*
#* Licensed under the Apache License, Version 2.0 (the "License");
#* you may not use this file except in compliance with the License.
Expand All @@ -13,19 +13,38 @@
#* See the License for the specific language governing permissions and
#* limitations under the License.
#********************************************************************************
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.18)
include("cmake/HunterGate.cmake")
HunterGate(
URL "https://github.com/cpp-pm/hunter/archive/v0.25.5.tar.gz"
SHA1 "a20151e4c0740ee7d0f9994476856d813cdead29"
LOCAL
)

if(CMAKE_GENERATOR MATCHES "Ninja")
message(FATAL_ERROR "This project does not support the Ninja generator. "
"Please use Unix Makefiles or another supported generator. "
"This error is typical in CLion. In this case, switch to generator Unix Makefiles.")
endif()

########################################################
project(ledger-zxlib)

set(CMAKE_CXX_STANDARD 11)
cmake_policy(SET CMP0025 NEW)
cmake_policy(SET CMP0144 NEW)

enable_testing()

add_subdirectory(cmake/gtest)
hunter_add_package(GTest)
find_package(GTest CONFIG REQUIRED)

###############

include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include
)

###############

file(GLOB_RECURSE ZXLIB_SRC
${CMAKE_CURRENT_SOURCE_DIR}/src/*.c
)
Expand All @@ -48,10 +67,10 @@ add_executable(zxlib_tests

target_include_directories(zxlib_tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
${gtest_SOURCE_DIR}/include
${gmock_SOURCE_DIR}/include
)

target_link_libraries(zxlib_tests gtest_main zxlib)
target_link_libraries(zxlib_tests PRIVATE
GTest::gtest_main
zxlib)

add_test(ZXLIB_TESTS zxlib_tests)
2 changes: 1 addition & 1 deletion deps/ledger-zxlib/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2018-2020 Zondax GmbH
Copyright 2018-2024 Zondax AG

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion deps/ledger-zxlib/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ledger-zxlib

[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

[![GithubActions](https://github.com/zondax/ledger-zxlib/actions/workflows/main.yml/badge.svg)](https://github.com/Zondax/ledger-zxlib/blob/main/.github/workflows/main.yaml)
[![CodeFactor](https://www.codefactor.io/repository/github/zondax/ledger-zxlib/badge)](https://www.codefactor.io/repository/github/zondax/ledger-zxlib)
2 changes: 2 additions & 0 deletions deps/ledger-zxlib/app/common/app_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "tx.h"
#include "coin.h"
#include "zxmacros.h"
#include "zxcanary.h"
#include "app_mode.h"
#ifdef HAVE_SWAP
#include "swap.h"
Expand Down Expand Up @@ -132,6 +133,7 @@ void handle_generic_apdu(__Z_UNUSED volatile uint32_t *flags, volatile uint32_t

void app_init() {
io_seproxyhal_init();
init_zondax_canary();

#ifdef HAVE_BLE
// grab the current plane mode setting
Expand Down
8 changes: 6 additions & 2 deletions deps/ledger-zxlib/app/ui/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ void view_initialize_init(viewfunc_initialize_t viewFuncInit) {

void view_review_show(review_type_e reviewKind) {
// Set > 0 to reply apdu message
view_review_show_impl((unsigned int)reviewKind);
view_review_show_impl((unsigned int)reviewKind, NULL, NULL);
}

void view_review_show_generic(review_type_e reviewKind, const char *title, const char *validate) {
view_review_show_impl((unsigned int)reviewKind, title, validate);
}

void view_initialize_show(uint8_t item_idx, const char *statusString) {
Expand All @@ -88,7 +92,7 @@ void h_reject(unsigned int requireReply) {
view_idle_show(0, NULL);
UX_WAIT();

if (requireReply != REVIEW_UI) {
if (requireReply != REVIEW_UI && requireReply != REVIEW_MSG) {
app_reject();
}
}
Expand Down
74 changes: 45 additions & 29 deletions deps/ledger-zxlib/app/ui/view.h
Original file line number Diff line number Diff line change
@@ -1,34 +1,49 @@
/*******************************************************************************
* (c) 2018 - 2022 Zondax AG
* (c) 2016 Ledger
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
********************************************************************************/
* (c) 2018 - 2022 Zondax AG
* (c) 2016 Ledger
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
********************************************************************************/
#pragma once

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

#include "coin.h"
#include "zxerror.h"

#if defined(LEDGER_SPECIFIC)
#include "bolos_target.h"
#if defined(BOLOS_SDK)
#include "os.h"
#include "cx.h"
#include "os.h"
#endif
#endif

#ifndef PRODUCTION_BUILD
#define PRODUCTION_BUILD 0
#endif

// By default our builds are not production ready
// Unless we specificaly define PRODUCTION_BUILD to 1
#if (PRODUCTION_BUILD == 0)
#undef MENU_MAIN_APP_LINE1
#undef MENU_MAIN_APP_LINE2

#define MENU_MAIN_APP_LINE1 APPVERSION_LINE1 " DEMO"
#define MENU_MAIN_APP_LINE2 "DO NOT USE"
#endif

typedef struct {
uint8_t displayIdx;
char *outKey;
Expand All @@ -46,7 +61,7 @@ typedef struct {
uint8_t pageCount;
} paging_t;

#define MAX_DEPTH 10
#define MAX_DEPTH 10
typedef struct {
uint8_t level;
uint8_t trace[MAX_DEPTH];
Expand All @@ -55,10 +70,8 @@ typedef struct {

typedef zxerr_t (*viewfunc_getNumItems_t)(uint8_t *num_items);

typedef zxerr_t (*viewfunc_getItem_t)(int8_t displayIdx,
char *outKey, uint16_t outKeyLen,
char *outVal, uint16_t outValLen,
uint8_t pageIdx, uint8_t *pageCount);
typedef zxerr_t (*viewfunc_getItem_t)(int8_t displayIdx, char *outKey, uint16_t outKeyLen, char *outVal,
uint16_t outValLen, uint8_t pageIdx, uint8_t *pageCount);

typedef zxerr_t (*viewfunc_getInnerItem_t)(uint8_t depth_level, uint8_t *trace, ui_field_t *ui_field);

Expand All @@ -69,9 +82,12 @@ typedef void (*viewfunc_accept_t)();
typedef zxerr_t (*viewfunc_initialize_t)();

typedef enum {
REVIEW_UI = 0,
REVIEW_ADDRESS,
REVIEW_TXN,
REVIEW_UI = 0,
REVIEW_ADDRESS,
// Used to review keys or params that needs user confirmation before send the response
REVIEW_GENERIC,
REVIEW_TXN,
REVIEW_MSG,
} review_type_e;

#ifdef APP_SECRET_MODE_ENABLED
Expand All @@ -95,12 +111,12 @@ void view_error_show();

void view_custom_error_show(const char *upper, const char *lower);

void view_review_init(viewfunc_getItem_t viewfuncGetItem,
viewfunc_getNumItems_t viewfuncGetNumItems,
void view_review_init(viewfunc_getItem_t viewfuncGetItem, viewfunc_getNumItems_t viewfuncGetNumItems,
viewfunc_accept_t viewfuncAccept);

void view_inspect_init(viewfunc_getInnerItem_t view_funcGetInnerItem,
viewfunc_getNumItems_t view_funcGetInnerNumItems,
viewfunc_canInspectItem_t view_funcCanInspectItem);
void view_inspect_init(viewfunc_getInnerItem_t view_funcGetInnerItem, viewfunc_getNumItems_t view_funcGetInnerNumItems,
viewfunc_canInspectItem_t view_funcCanInspectItem);

void view_review_show(review_type_e reviewKind);

void view_review_show_generic(review_type_e reviewKind, const char *title, const char *validate);
Loading

0 comments on commit b51a0fc

Please sign in to comment.