Improve transaction wording
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
|
#include <ctype.h>
|
||||||
#include <nbgl_page.h>
|
#include <nbgl_page.h>
|
||||||
#include "shared_context.h"
|
#include "shared_context.h"
|
||||||
#include "ui_callbacks.h"
|
#include "ui_callbacks.h"
|
||||||
@@ -219,19 +219,55 @@ static void reviewContinueCommon(void) {
|
|||||||
reviewChoice);
|
reviewChoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Replace "Review" by "Sign" and add questionmark
|
||||||
|
static void prepare_sign_text(void) {
|
||||||
|
uint8_t sign_length = strlen("Sign");
|
||||||
|
uint8_t review_length = strlen("Review");
|
||||||
|
|
||||||
|
memmove(staxSharedBuffer, "Sign", sign_length);
|
||||||
|
memmove(staxSharedBuffer + sign_length,
|
||||||
|
staxSharedBuffer + review_length,
|
||||||
|
strlen(staxSharedBuffer) - review_length + 1);
|
||||||
|
strlcat(staxSharedBuffer, "?", sizeof(staxSharedBuffer));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Force operation to be lowercase
|
||||||
|
static void get_lowercase_operation(char *dst, size_t dst_len) {
|
||||||
|
const char *src = strings.common.fullAmount;
|
||||||
|
size_t idx;
|
||||||
|
|
||||||
|
for (idx = 0; (idx < dst_len - 1) && (src[idx] != '\0'); ++idx) {
|
||||||
|
dst[idx] = (char) tolower((int) src[idx]);
|
||||||
|
}
|
||||||
|
dst[idx] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
static void buildFirstPage(void) {
|
static void buildFirstPage(void) {
|
||||||
if (tx_approval_context.fromPlugin) {
|
if (tx_approval_context.fromPlugin) {
|
||||||
|
char op_name[sizeof(strings.common.fullAmount)];
|
||||||
plugin_ui_get_id();
|
plugin_ui_get_id();
|
||||||
SPRINTF(staxSharedBuffer,
|
|
||||||
"Review %s\ntransaction:\n%s",
|
get_lowercase_operation(op_name, sizeof(op_name));
|
||||||
strings.common.fullAddress,
|
if (pluginType == EXTERNAL) {
|
||||||
strings.common.fullAmount);
|
snprintf(staxSharedBuffer,
|
||||||
|
sizeof(staxSharedBuffer),
|
||||||
|
"Review transaction\nto %s\non %s",
|
||||||
|
op_name,
|
||||||
|
strings.common.fullAddress);
|
||||||
|
} else {
|
||||||
|
snprintf(staxSharedBuffer,
|
||||||
|
sizeof(staxSharedBuffer),
|
||||||
|
"Review transaction\nto %s\n%s",
|
||||||
|
op_name,
|
||||||
|
strings.common.fullAddress);
|
||||||
|
}
|
||||||
nbgl_useCaseReviewStart(get_app_icon(true),
|
nbgl_useCaseReviewStart(get_app_icon(true),
|
||||||
staxSharedBuffer,
|
staxSharedBuffer,
|
||||||
NULL,
|
NULL,
|
||||||
"Reject transaction",
|
"Reject transaction",
|
||||||
reviewContinue,
|
reviewContinue,
|
||||||
rejectTransactionQuestion);
|
rejectTransactionQuestion);
|
||||||
|
prepare_sign_text();
|
||||||
} else {
|
} else {
|
||||||
nbgl_useCaseReviewStart(get_app_icon(true),
|
nbgl_useCaseReviewStart(get_app_icon(true),
|
||||||
"Review transaction",
|
"Review transaction",
|
||||||
|
|||||||
@@ -182,7 +182,11 @@ void erc20_plugin_call(int message, void *parameters) {
|
|||||||
|
|
||||||
case ETH_PLUGIN_QUERY_CONTRACT_ID: {
|
case ETH_PLUGIN_QUERY_CONTRACT_ID: {
|
||||||
ethQueryContractID_t *msg = (ethQueryContractID_t *) parameters;
|
ethQueryContractID_t *msg = (ethQueryContractID_t *) parameters;
|
||||||
|
#ifdef HAVE_NBGL
|
||||||
|
strlcpy(msg->name, "ERC20 token", msg->nameLength);
|
||||||
|
#else
|
||||||
strlcpy(msg->name, "Type", msg->nameLength);
|
strlcpy(msg->name, "Type", msg->nameLength);
|
||||||
|
#endif
|
||||||
strlcpy(msg->version, "Approve", msg->versionLength);
|
strlcpy(msg->version, "Approve", msg->versionLength);
|
||||||
msg->result = ETH_PLUGIN_RESULT_OK;
|
msg->result = ETH_PLUGIN_RESULT_OK;
|
||||||
} break;
|
} break;
|
||||||
|
|||||||
Reference in New Issue
Block a user