Skip to content

Commit

Permalink
Stax UI migration (#27)
Browse files Browse the repository at this point in the history
* Check that Mode is enabled

* enable initial migration message for Stax

* enable Stax in migration tests

* bump version & update snapshots

* update snapshots

* fix API tests

* don't build Debug target for Zemu tests

* fix static analyzer

* remove duplicated paths

* feat: add testcases for kusama chain (#29)

---------

Co-authored-by: Emmanuel <[email protected]>
  • Loading branch information
ftheirs and emmanuelm41 authored Jun 18, 2024
1 parent 52234c9 commit 0ad7600
Show file tree
Hide file tree
Showing 122 changed files with 34,944 additions and 479 deletions.
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ ifeq ($(BOLOS_SDK),)
ZXLIB_COMPILE_STAX ?= 1
PRODUCTION_BUILD ?= 0
$(info ************ COIN = [$(COIN)])

ifeq ($(COIN), DOT_MIGRATION)
ZXLIB_COMPILE_STAX := 0
endif
include $(CURDIR)/deps/ledger-zxlib/dockerized_build.mk

else
Expand All @@ -43,7 +39,7 @@ build_all:
APP_TESTING=1 PRODUCTION_BUILD=1 COIN=DOT_MIGRATION make
APP_TESTING=1 PRODUCTION_BUILD=1 make

test_all: build_all
test_all:
make zemu_install
PRODUCTION_BUILD=1 COIN=DOT_MIGRATION make
PRODUCTION_BUILD=1 make
Expand Down
4 changes: 2 additions & 2 deletions app/Makefile.migration
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ APPVERSION_M=100
# This is the `spec_version` field of `Runtime`
APPVERSION_N=0
# This is the patch version of this release
APPVERSION_P=0
APPVERSION_P=1

# Declare here all the allowed paths in migration app

PATHS := "44'/434'" "44'/295'" "44'/523'" "44'/537'" "44'/594'" "44'/595'" "44'/617'" "44'/631'" \
"44'/643'" "44'/686'" "44'/718'" "44'/747'" "44'/787'" "44'/788'" "44'/788'" \
"44'/643'" "44'/686'" "44'/718'" "44'/747'" "44'/787'" "44'/788'" \
"44'/799'" "44'/810'" "44'/819'" "44'/907'" "44'/995'" "44'/1003'" "44'/1005'" \
"44'/1155'" "44'/1955'"

Expand Down
2 changes: 1 addition & 1 deletion app/Makefile.version
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ APPVERSION_M=100
# This is the `spec_version` field of `Runtime`
APPVERSION_N=0
# This is the patch version of this release
APPVERSION_P=2
APPVERSION_P=3
13 changes: 11 additions & 2 deletions app/src/common/migration.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,18 @@ zxerr_t migrationGetItem(int8_t displayIdx,
return zxerr_ok;
}

void migrationOk() {
view_idle_show(0, NULL);
}

void migrationStartMessage() {
#ifdef MIGRATION_APP
view_review_init(migrationGetItem, migrationGetNumItems, NULL);
view_review_show(REVIEW_MSG);
#ifdef TARGET_STAX
const review_type_e reviewType = REVIEW_UI;
#else
const review_type_e reviewType = REVIEW_MSG;
#endif
view_review_init(migrationGetItem, migrationGetNumItems, migrationOk);
view_review_show(reviewType);
#endif
}
23 changes: 23 additions & 0 deletions app/src/parser_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,29 @@ parser_error_t transaction_parse(parser_tx_t *txObj) {
printItem.itemCount += tmpEra.isMortal ? 3 : 1;
continue;
}

// Extract Mode if present
if (identifierLen == strlen(STR_METADATA_HASH) &&
strncmp((const char *)tmpExtension.identifier.ptr, STR_METADATA_HASH, identifierLen) == 0) {

// The following byte must be 0x01
if(*(blobBuf->buffer + blobBuf->offset)!= 0x01) {
return parser_wrong_metadata_digest;
}

PrintItem_t tmpPrintItem = {0};
tmpPrintItem.printing = true;
tmpPrintItem.target = 1;
tmpPrintItem.itemCount = 0;
const uint16_t tmpBlobOffset = blobBuf->offset;
CHECK_ERROR(parseTypeRef(blobBuf, metadataBuf, &tmpEntry, &tmpExtension.includedInExtrinsic, &tmpPrintItem));

// Check that Mode is enabled
if (tmpPrintItem.item.val.len != strlen(STR_MODE_ENABLED) || strncmp((const char *)tmpPrintItem.item.val.ptr, STR_MODE_ENABLED, tmpPrintItem.item.val.len) != 0) {
return parser_wrong_metadata_digest;
}
blobBuf->offset = tmpBlobOffset;
}
CHECK_ERROR(parseTypeRef(blobBuf, metadataBuf, &tmpEntry, &tmpExtension.includedInExtrinsic, &printItem));

// first case is tip without assetid, second case is tip with assetid
Expand Down
1 change: 1 addition & 0 deletions app/src/parser_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ static const char STR_TIP[] = "ChargeTransactionPayment";
static const char STR_TIP_WITH_ASSETID[] = "ChargeAssetTxPayment";
static const char STR_ERA[] = "CheckMortality";
static const char STR_METADATA_HASH[] = "CheckMetadataHash";
static const char STR_MODE_ENABLED[] = "Enabled";

#ifdef __cplusplus
}
Expand Down
Loading

0 comments on commit 0ad7600

Please sign in to comment.