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

Feat/LDG-615--nano-app-implement-deploy-stax-and-flex-display #44

Merged
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 101 additions & 57 deletions src/common/ui/display_nbgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "nbgl_use_case.h"
accountSender_t global_account_sender;

static nbgl_contentTagValue_t pairs[10];

static void review_choice(bool confirm) {
// Answer, display a status page and go back to main
if (confirm) {
Expand All @@ -22,6 +24,18 @@
nbgl_useCaseReviewStatus(STATUS_TYPE_ADDRESS_REJECTED, ui_menu_main);
}
}
static void review_choice_sign(bool confirm) {
// Answer, display a status page and go back to main
// validate_transaction(confirm);
if (confirm) {
buildAndSignTransactionHash();
// nbgl_useCaseReviewStatus(STATUS_TYPE_TRANSACTION_SIGNED, ui_menu_main);

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
} else {
sendUserRejection();
// nbgl_useCaseReviewStatus(STATUS_TYPE_TRANSACTION_REJECTED, ui_menu_main);

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
}
}

void uiComparePubkey(void) {
// TODO: Implement this
nbgl_useCaseAddressReview(global.exportPublicKeyContext.publicKey,
Expand Down Expand Up @@ -64,62 +78,62 @@

// TODO: To fix
void startConfigureDelegationDisplay(void) {
// Get context from global state
signConfigureDelegationContext_t *ctx = &global.signConfigureDelegation;

// Create tag-value pairs for the content
nbgl_layoutTagValue_t pairs[4]; // Maximum possible pairs
uint8_t pairIndex = 0;

// Add sender address
pairs[pairIndex].item = "Sender";
pairs[pairIndex].value = (char *) global_account_sender.sender;
pairIndex++;

// Add capital amount if present
if (ctx->hasCapital) {
if (ctx->stopDelegation) {
pairs[pairIndex].item = "Action";
pairs[pairIndex].value = "Stop delegation";
} else {
pairs[pairIndex].item = "Amount to delegate";
pairs[pairIndex].value = (char *) ctx->displayCapital;
}
pairIndex++;
}

// Add restake earnings if present
if (ctx->hasRestakeEarnings) {
pairs[pairIndex].item = "Restake earnings";
pairs[pairIndex].value = (char *) ctx->displayRestake;
pairIndex++;
}

// Add delegation target if present
if (ctx->hasDelegationTarget) {
pairs[pairIndex].item = "Delegation target";
pairs[pairIndex].value = (char *) ctx->displayDelegationTarget;
pairIndex++;
}

// Create the page content
nbgl_pageContent_t content;
content.type = TAG_VALUE_LIST;
content.title = "Review Transaction";
content.isTouchableTitle = true;
content.topRightIcon = NULL;
content.tagValueList.nbPairs = pairIndex;
content.tagValueList.pairs = pairs;
content.tagValueList.smallCaseForValue = false;
content.tagValueList.nbMaxLinesForValue = 0;

// Setup the review screen
nbgl_useCaseReviewStart(&C_app_concordium_64px,
"Review Transaction",
NULL, // No subtitle
"Reject transaction",
buildAndSignTransactionHash,
sendUserRejection);
// // Get context from global state
// signConfigureDelegationContext_t *ctx = &global.signConfigureDelegation;

// // Create tag-value pairs for the content
// nbgl_layoutTagValue_t pairs[4]; // Maximum possible pairs
// uint8_t pairIndex = 0;

// // Add sender address
// pairs[pairIndex].item = "Sender";
// pairs[pairIndex].value = (char *) global_account_sender.sender;
// pairIndex++;
Comment on lines +88 to +91

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.

// // Add capital amount if present
// if (ctx->hasCapital) {
// if (ctx->stopDelegation) {
// pairs[pairIndex].item = "Action";
// pairs[pairIndex].value = "Stop delegation";
// } else {
// pairs[pairIndex].item = "Amount to delegate";
// pairs[pairIndex].value = (char *) ctx->displayCapital;
// }
// pairIndex++;
// }
Comment on lines +93 to +103

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.

// // Add restake earnings if present
// if (ctx->hasRestakeEarnings) {
// pairs[pairIndex].item = "Restake earnings";
// pairs[pairIndex].value = (char *) ctx->displayRestake;
// pairIndex++;
// }
Comment on lines +105 to +110

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.

// // Add delegation target if present
// if (ctx->hasDelegationTarget) {
// pairs[pairIndex].item = "Delegation target";
// pairs[pairIndex].value = (char *) ctx->displayDelegationTarget;
// pairIndex++;
// }
Comment on lines +112 to +117

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.

// // Create the page content
// nbgl_pageContent_t content;
// content.type = TAG_VALUE_LIST;
// content.title = "Review Transaction";
// content.isTouchableTitle = true;
// content.topRightIcon = NULL;
// content.tagValueList.nbPairs = pairIndex;
// content.tagValueList.pairs = pairs;
// content.tagValueList.smallCaseForValue = false;
// content.tagValueList.nbMaxLinesForValue = 0;
Comment on lines +119 to +128

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.

// // Setup the review screen
// nbgl_useCaseReviewStart(&C_app_concordium_64px,
// "Review Transaction",
// NULL, // No subtitle
// "Reject transaction",
// buildAndSignTransactionHash,
// sendUserRejection);
}

void uiSignUpdateCredentialThresholdDisplay(volatile unsigned int *flags) {
Expand Down Expand Up @@ -207,7 +221,6 @@

void uiSignTransferToPublicDisplay(volatile unsigned int *flags) {
*flags |= IO_ASYNCH_REPLY;
// TODO: Implement this
}

void uiSignScheduledTransferPairFlowDisplay(void) {
Expand All @@ -232,4 +245,35 @@
// TODO: Implement this
}

void uiDeployModuleDisplay(void) {
pairs[0].item = "Sender";
pairs[0].value = (char *) global_account_sender.sender;
pairs[1].item = "Version";
pairs[1].value = (char *) global.deployModule.versionDisplay;

// Create the page content
nbgl_contentTagValueList_t content;
content.nbPairs = 2;
content.pairs = pairs;
content.smallCaseForValue = false;
content.nbMaxLinesForValue = 0;
content.startIndex = 0;
// Setup the review screen
nbgl_useCaseReview(TYPE_TRANSACTION,
&content,
&C_app_concordium_64px,
"Review Transaction \nto deploy module",
NULL, // No subtitle
"Sign transaction\nto deploy module",
review_choice_sign);
}

void uiUpdateContractDisplay(void) {
// TODO: Implement this
}

void uiInitContractDisplay(void) {
// TODO: Implement this
}

#endif
Binary file added tests/snapshots/flex/test_deploy_module/00000.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 added tests/snapshots/flex/test_deploy_module/00001.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 added tests/snapshots/flex/test_deploy_module/00002.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 added tests/snapshots/flex/test_deploy_module/00003.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 added tests/snapshots/stax/test_deploy_module/00000.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 added tests/snapshots/stax/test_deploy_module/00001.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 added tests/snapshots/stax/test_deploy_module/00002.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 added tests/snapshots/stax/test_deploy_module/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions tests/test_deploy_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,10 @@ def test_deploy_module(
navigate_until_text_and_compare(
firmware, navigator, "Sign", default_screenshot_path, test_name
)

response = client.get_async_response()
print(response.data.hex())
assert response.status == 0x9000
assert response.data == bytes.fromhex(
"dbf31688385e1dcf05520acb4dada4a139dd18c17a77645a0ffee5b3d3a1c5ad581286c0e6c82584c245cc9f21281b7244994e9ea5a07e4ac8fe8957144c2e0a"
)
2 changes: 1 addition & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def navigate_until_text_and_compare(
"""
if firmware.device.startswith(("stax", "flex")):
go_right_instruction = NavInsID.SWIPE_CENTER_TO_LEFT
confirm_instructions = [NavInsID.USE_CASE_ADDRESS_CONFIRMATION_CONFIRM]
confirm_instructions = [NavInsID.USE_CASE_REVIEW_CONFIRM]
else:
go_right_instruction = NavInsID.RIGHT_CLICK
confirm_instructions = [NavInsID.BOTH_CLICK]
Expand Down
Loading