Skip to content

Commit

Permalink
Merge pull request #23 from LedgerHQ/develop
Browse files Browse the repository at this point in the history
Align master with version on P1
  • Loading branch information
fbeutin-ledger authored Jan 25, 2023
2 parents 81eff4c + d936b69 commit d9fa510
Show file tree
Hide file tree
Showing 20 changed files with 50 additions and 30 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ jobs:
run: |
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10
make deps
brew install conan
conan config install https://github.com/conan-io/conanclientcert.git
- run: cmake -DCMAKE_BUILD_TYPE=Debug . && make
- run: GTEST_COLOR=1 ASAN_OPTIONS=detect_leaks=0 ctest -VV

Expand Down
2 changes: 0 additions & 2 deletions app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ all: bin/app.elf
include $(BOLOS_SDK)/Makefile.defines
include $(CURDIR)/Makefile.version

DEFINES += APP_SECRET_MODE_ENABLED

$(info ************ TARGET_NAME = [$(TARGET_NAME)])

ifeq ($(APP_TESTING),1)
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=2
# This is the `spec_version` field of `Runtime`
APPVERSION_N=34
# This is the patch version of this release
APPVERSION_P=6
APPVERSION_P=9
9 changes: 9 additions & 0 deletions app/src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ parser_error_t parser_parse(parser_context_t *ctx,
const uint8_t *data,
size_t dataLen) {
CHECK_PARSER_ERR(tx_display_readTx(ctx, data, dataLen))
extraDepthLevel =false;
return parser_ok;
}

Expand Down Expand Up @@ -92,6 +93,14 @@ __Z_INLINE bool_t parser_isAmount(char *key) {
return bool_true;
}

if (strcmp(key, "msgs/value/inputs/coins") == 0) {
return bool_true;
}

if (strcmp(key, "msgs/value/outputs/coins") == 0) {
return bool_true;
}

if (strcmp(key, "msgs/value/amount") == 0) {
return bool_true;
}
Expand Down
7 changes: 6 additions & 1 deletion app/src/tx_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ __Z_INLINE uint8_t get_root_max_level(root_item_e i) {
case root_item_memo:
return 2;
case root_item_msgs:
return 2;
return extraDepthLevel ? 3 : 2;
case root_item_tip:
return 1;
default:
Expand Down Expand Up @@ -471,6 +471,11 @@ static const key_subst_t key_substitutions[] = {
{"msgs/outputs/address", "Dest Address"},
{"msgs/outputs/coins", "Dest Coins"},

{"msgs/value/inputs/address", "Source Address"},
{"msgs/value/inputs/coins", "Source Coins"},
{"msgs/value/outputs/address", "Dest Address"},
{"msgs/value/outputs/coins", "Dest Coins"},

{"msgs/value/from_address", "From"},
{"msgs/value/to_address", "To"},
{"msgs/value/amount", "Amount"},
Expand Down
9 changes: 8 additions & 1 deletion app/src/tx_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "zxformat.h"
#include "parser_impl.h"

bool extraDepthLevel = false;

// strcat but source does not need to be terminated (a chunk from a bigger string is concatenated)
// dst_max is measured in bytes including the space for NULL termination
// src_size does not include NULL termination
Expand Down Expand Up @@ -60,6 +62,8 @@ static const key_subst_t value_substitutions[] = {
{"cosmos-sdk/MsgVote", "Vote"},
{"cosmos-sdk/MsgWithdrawDelegationReward", "Withdraw Reward"},
{"cosmos-sdk/MsgWithdrawValidatorCommission", "Withdraw Val. Commission"},
{"cosmos-sdk/MsgMultiSend", "Multi Send"},

};

parser_error_t tx_getToken(uint16_t token_index,
Expand Down Expand Up @@ -87,8 +91,11 @@ parser_error_t tx_getToken(uint16_t token_index,
if (inLen == substStrLen && !MEMCMP(inValue, substStr, substStrLen)) {
inValue = value_substitutions[i].str2;
inLen = strlen(value_substitutions[i].str2);

//Extra Depth level for Multisend type
extraDepthLevel = (i == MULTISEND_KEY_IDX);
break;
}
}
}

pageStringExt(out_val, out_val_len, inValue, inLen, pageIdx, pageCount);
Expand Down
2 changes: 2 additions & 0 deletions app/src/tx_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ extern "C" {
#endif

#define MAX_RECURSION_DEPTH 6
#define MULTISEND_KEY_IDX 9
extern bool extraDepthLevel;

#define INIT_QUERY_CONTEXT(_KEY, _KEY_LEN, _VAL, _VAL_LEN, _PAGE_IDX, _MAX_LEVEL) \
parser_tx_obj.query._item_index_current = 0; \
Expand Down
2 changes: 1 addition & 1 deletion deps/nanos-secure-sdk
2 changes: 1 addition & 1 deletion deps/nanosplus-secure-sdk
2 changes: 1 addition & 1 deletion deps/nanox-secure-sdk
24 changes: 12 additions & 12 deletions tests/testcases/manual.json
Original file line number Diff line number Diff line change
Expand Up @@ -1826,18 +1826,18 @@
"0 | Chain ID : testing",
"1 | Account : 8",
"2 | Sequence : 0",
"3 | Type : cosmos-sdk/MsgMultiSend",
"4 | msgs/value/inputs [1/3] : [{\"address\":\"cosmos1hr9x0sjvel6z3vt9qny",
"4 | msgs/value/inputs [2/3] : 8sdd5gnnlgk0p69d6cv\",\"coins\":[{\"amount\"",
"4 | msgs/value/inputs [3/3] : :\"101000\",\"denom\":\"uatom\"}]}]",
"5 | msgs/value/outputs [1/6] : [{\"address\":\"cosmos13dr26wdygna3s8fdl5t",
"5 | msgs/value/outputs [2/6] : lc45m2le2ydydgjk8ek\",\"coins\":[{\"amount\"",
"5 | msgs/value/outputs [3/6] : :\"1000\",\"denom\":\"uatom\"}]},{\"address\":\"",
"5 | msgs/value/outputs [4/6] : cosmos1hr9x0sjvel6z3vt9qny8sdd5gnnlgk0p",
"5 | msgs/value/outputs [5/6] : 69d6cv\",\"coins\":[{\"amount\":\"100000\",\"de",
"5 | msgs/value/outputs [6/6] : nom\":\"uatom\"}]}]",
"6 | Fee : 0 uatom",
"7 | Gas : 200000"
"3 | Type : Multi Send",
"4 | Source Address [1/2] : cosmos1hr9x0sjvel6z3vt9qny8sdd5gnnlgk0p",
"4 | Source Address [2/2] : 69d6cv",
"5 | Source Coins : 101000 uatom",
"6 | Dest Address [1/2] : cosmos13dr26wdygna3s8fdl5tlc45m2le2ydyd",
"6 | Dest Address [2/2] : gjk8ek",
"7 | Dest Coins : 1000 uatom",
"8 | Dest Address [1/2] : cosmos1hr9x0sjvel6z3vt9qny8sdd5gnnlgk0p",
"8 | Dest Address [2/2] : 69d6cv",
"9 | Dest Coins : 100000 uatom",
"10 | Fee : 0 uatom",
"11 | Gas : 200000"
],
"expert": true
},
Expand Down
4 changes: 2 additions & 2 deletions tests_zemu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"testSR25519": "jest --detectOpenHandles --runInBand tests/sr25519.test.ts"
},
"dependencies": {
"@zondax/zemu": "^0.32.0",
"ledger-cosmos-js": "^2.1.8"
"@zondax/zemu": "^0.33.1",
"@zondax/ledger-cosmos-js": "^3.0.0"
},
"devDependencies": {
"@types/jest": "^27.4.0",
Expand Down
Binary file modified tests_zemu/snapshots/s-mainmenu/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/s-mainmenu/00010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-mainmenu/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-mainmenu/00010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/x-mainmenu/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/x-mainmenu/00010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 6 additions & 5 deletions tests_zemu/tests/standard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import Zemu from '@zondax/zemu'
// @ts-ignore
import CosmosApp from 'ledger-cosmos-js'
import { CosmosApp } from '@zondax/ledger-cosmos-js'
import { DEFAULT_OPTIONS, DEVICE_MODELS, example_tx_str_basic, example_tx_str_basic2, ibc_denoms } from './common'

// @ts-ignore
Expand Down Expand Up @@ -185,7 +185,7 @@ describe('Standard', function () {
const app = new CosmosApp(sim.getTransport())

const path = [44, 118, 0, 0, 0]
const tx = JSON.stringify(example_tx_str_basic)
const tx = Buffer.from(JSON.stringify(example_tx_str_basic), "utf-8")

// get address / publickey
const respPk = await app.getAddressAndPubKey(path, 'cosmos')
Expand Down Expand Up @@ -230,7 +230,7 @@ describe('Standard', function () {
const app = new CosmosApp(sim.getTransport())

const path = [44, 118, 0, 0, 0]
const tx = JSON.stringify(example_tx_str_basic2)
const tx = Buffer.from(JSON.stringify(example_tx_str_basic2), "utf-8")

// get address / publickey
const respPk = await app.getAddressAndPubKey(path, 'cosmos')
Expand Down Expand Up @@ -274,7 +274,7 @@ describe('Standard', function () {
const app = new CosmosApp(sim.getTransport())

const path = [44, 118, 0, 0, 0]
const tx = JSON.stringify(example_tx_str_basic)
const tx = Buffer.from(JSON.stringify(example_tx_str_basic), "utf-8")

// get address / publickey
const respPk = await app.getAddressAndPubKey(path, 'cosmos')
Expand Down Expand Up @@ -319,7 +319,8 @@ describe('Standard', function () {
const app = new CosmosApp(sim.getTransport())

const path = [44, 118, 0, 0, 0]
const tx = JSON.stringify(ibc_denoms)
const tx = Buffer.from(JSON.stringify(ibc_denoms), "utf-8")


// get address / publickey
const respPk = await app.getAddressAndPubKey(path, 'cosmos')
Expand Down

0 comments on commit d9fa510

Please sign in to comment.