Skip to content

Commit

Permalink
Merge pull request #44 from blooo-io/feat/LDG-615--nano-app-implement…
Browse files Browse the repository at this point in the history
…-deploy-stax-and-flex-display

Feat/LDG-615--nano-app-implement-deploy-stax-and-flex-display
  • Loading branch information
n4l5u0r authored Dec 12, 2024
2 parents 476bb73 + fec02eb commit 133bafe
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 58 deletions.
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 @@ static void review_choice(bool confirm) {
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);
} else {
sendUserRejection();
// nbgl_useCaseReviewStatus(STATUS_TYPE_TRANSACTION_REJECTED, ui_menu_main);
}
}

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

// 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++;

// // 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);
}

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

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

void uiSignScheduledTransferPairFlowDisplay(void) {
Expand All @@ -232,4 +245,35 @@ void startInitialScheduledTransferDisplay(bool displayMemo) {
// 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

0 comments on commit 133bafe

Please sign in to comment.