Skip to content

Commit 40ed24a

Browse files
authored
Merge pull request #296 from Zondax/feat/intent
Feat/intent
2 parents 27cfbc7 + 6f8fc88 commit 40ed24a

File tree

29 files changed

+70
-23
lines changed

29 files changed

+70
-23
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ jobs:
156156
submodules: true
157157

158158
- name: Install node
159-
uses: actions/setup-node@v3
159+
uses: actions/setup-node@v4
160+
with:
161+
node-version: '22'
160162

161163
- name: Install yarn
162164
run: npm install -g yarn
@@ -194,7 +196,9 @@ jobs:
194196
submodules: recursive
195197
- run: sudo apt-get update -y && sudo apt-get install -y libusb-1.0.0 libudev-dev
196198
- name: Install node
197-
uses: actions/setup-node@v3
199+
uses: actions/setup-node@v4
200+
with:
201+
node-version: '22'
198202
- name: Install yarn
199203
run: |
200204
npm install -g yarn

app/Makefile.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ APPVERSION_M=4
33
# This is the minor version of this release
44
APPVERSION_N=0
55
# This is the patch version of this release
6-
APPVERSION_P=6
6+
APPVERSION_P=7

app/rust/src/constants.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pub const MAX_TABLE_FIELDS: usize = 15;
6666

6767
// Maximum fields per type entry
6868
// Analysis of ICRC-21 test vectors shows max 4 fields per type
69-
pub const MAX_FIELDS_PER_TYPE: usize = 10;
69+
pub const MAX_FIELDS_PER_TYPE: usize = 8;
7070
// the max number of candid arguments in memory
7171
pub const MAX_ARGS: usize = 5;
7272

app/rust/src/parser/certificate/cert.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,12 +423,13 @@ mod test_certificate {
423423
let msg = &ui.message;
424424

425425
// Test number of items (should be 4 fields)
426-
assert_eq!(msg.num_items().unwrap(), 4);
426+
assert_eq!(msg.num_items().unwrap(), 5);
427427

428428
// Expected field pairs from the encoded data
429429
let expected_fields = [
430+
("Transaction Type", "Greet user"),
430431
("User", "Hello, world!"),
431-
("created_at", "2025-07-11 15:26:31"),
432+
("created_at", "2025-07-11 07:27:44"),
432433
("active_for", "10 minutes"),
433434
("amount", "2 ICP"),
434435
];

app/rust/src/parser/consent_message/msg.rs

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ impl<'a> FromCandidHeader<'a> for Msg<'a> {
111111
let m = consent_msg.assume_init_ref();
112112
match m {
113113
ConsentMessage::FieldsDisplayMessage { field_count, .. } => {
114-
addr_of_mut!((*out).num_items).write(*field_count);
114+
// Add 1 to field_count to include intent as item 0
115+
addr_of_mut!((*out).num_items).write(*field_count + 1);
115116
}
116117
ConsentMessage::GenericDisplayMessage(_) => {
117118
// Do not accept generic messages
@@ -350,7 +351,7 @@ impl DisplayableItem for ConsentMessage<'_> {
350351
fn num_items(&self) -> Result<u8, ViewError> {
351352
check_canary();
352353
match self {
353-
ConsentMessage::FieldsDisplayMessage { field_count, .. } => Ok(*field_count),
354+
ConsentMessage::FieldsDisplayMessage { field_count, .. } => Ok(*field_count + 1), // +1 for intent
354355
ConsentMessage::GenericDisplayMessage(_) => Ok(1),
355356
}
356357
}
@@ -369,16 +370,30 @@ impl DisplayableItem for ConsentMessage<'_> {
369370
ConsentMessage::FieldsDisplayMessage {
370371
fields,
371372
field_count,
372-
..
373+
intent,
373374
} => {
374-
if item_n >= *field_count {
375+
// Item 0 is the intent
376+
if item_n == 0 {
377+
let title_text = b"Transaction Type";
378+
let title_len = title_text.len().min(title.len() - 1);
379+
title[..title_len].copy_from_slice(&title_text[..title_len]);
380+
title[title_len] = 0;
381+
382+
// Set message to the intent text
383+
return handle_ui_message(intent.as_bytes(), message, page);
384+
}
385+
386+
// Adjust item_n for field access (subtract 1 since intent is item 0)
387+
let field_index = item_n - 1;
388+
389+
if field_index >= *field_count {
375390
return Err(ViewError::NoData);
376391
}
377392

378393
let mut current = *fields;
379394

380395
// Skip to the desired field
381-
for _ in 0..item_n {
396+
for _ in 0..field_index {
382397
// Skip key
383398
let (rem, _) = parse_text(current).map_err(|_| ViewError::NoData)?;
384399
// Skip value - need to properly skip the variant
@@ -450,9 +465,8 @@ impl DisplayableItem for ConsentMessage<'_> {
450465
}
451466

452467
// Use a portion of the message buffer for formatting
453-
let format_len =
454-
crate::utils::format_timestamp(timestamp, message)
455-
.map_err(|_| ViewError::NoData)?;
468+
let format_len = crate::utils::format_timestamp(timestamp, message)
469+
.map_err(|_| ViewError::NoData)?;
456470

457471
// Null terminate
458472
message[format_len] = 0;
@@ -474,9 +488,8 @@ impl DisplayableItem for ConsentMessage<'_> {
474488
}
475489

476490
// Use a portion of the message buffer for formatting
477-
let format_len =
478-
crate::utils::format_duration(duration, message)
479-
.map_err(|_| ViewError::NoData)?;
491+
let format_len = crate::utils::format_duration(duration, message)
492+
.map_err(|_| ViewError::NoData)?;
480493

481494
// Null terminate
482495
message[format_len] = 0;

app/rust/src/parser/consent_message/snapshots/rslib__parser__consent_message__msg_response__msg_response_test__ui.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ input_file: src/parser/consent_message/testvectors/ui_data.json
66
snapshot_kind: text
77
---
88
[
9+
"Transaction Type": "Greet user",
910
"User": "Hello, world!",
1011
"created_at": "2025-07-11 07:27:44",
1112
"active_for": "10 minutes",

tests_zemu/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"@ledgerhq/hw-transport-node-hid": "^6.29.7",
3030
"@ledgerhq/logs": "^6.13.0",
3131
"@zondax/ledger-icp": "^3.2.8",
32-
"@zondax/zemu": "^0.55.3"
32+
"@zondax/zemu": "^0.61.1"
3333
},
3434
"devDependencies": {
3535
"@matteoh2o1999/github-actions-jest-reporter": "^3.0.0",
-92 Bytes
Loading
1.24 KB
Loading

0 commit comments

Comments
 (0)