Put externalPluginIsSet as its own global; initialize it at launch

This commit is contained in:
pscott
2021-05-11 19:08:04 +02:00
parent 0de6e1011a
commit b651f530be
4 changed files with 6 additions and 3 deletions

View File

@@ -62,7 +62,7 @@ eth_plugin_result_t eth_plugin_perform_init(uint8_t *contractAddress,
dataContext.tokenContext.pluginStatus = ETH_PLUGIN_RESULT_UNAVAILABLE;
PRINTF("Selector %.*H\n", 4, init->selector);
if (tmpCtx.transactionContext.externalPluginIsSet) {
if (externalPluginIsSet) {
// check if the registered external plugin matches the TX contract address / method selector
if (memcmp(contractAddress,
dataContext.tokenContext.contract_address,

View File

@@ -51,6 +51,7 @@ cx_sha3_t global_sha3;
uint8_t appState;
bool dataPresent;
bool called_from_swap;
bool externalPluginIsSet;
#ifdef HAVE_STARKWARE
bool quantumSet;
#endif
@@ -72,6 +73,7 @@ void reset_app_context() {
// PRINTF("!!RESET_APP_CONTEXT\n");
appState = APP_STATE_IDLE;
called_from_swap = false;
externalPluginIsSet = false;
#ifdef HAVE_STARKWARE
quantumSet = false;
#endif

View File

@@ -91,7 +91,6 @@ typedef struct transactionContext_t {
tokenDefinition_t tokens[MAX_TOKEN];
uint8_t tokenSet[MAX_TOKEN];
uint8_t currentTokenIndex;
bool externalPluginIsSet;
} transactionContext_t;
typedef struct messageSigningContext_t {
@@ -197,6 +196,7 @@ extern const internalStorage_t N_storage_real;
extern bool called_from_swap;
extern bool dataPresent;
extern bool externalPluginIsSet;
extern uint8_t appState;
#ifdef HAVE_STARKWARE
extern bool quantumSet;

View File

@@ -15,6 +15,7 @@ void handleSetExternalPlugin(uint8_t p1,
UNUSED(p1);
UNUSED(p2);
UNUSED(flags);
PRINTF("Handling set External Plugin\n");
uint8_t hash[32];
cx_ecfp_public_key_t tokenKey;
uint8_t pluginNameLength = *workBuffer;
@@ -78,7 +79,7 @@ void handleSetExternalPlugin(uint8_t p1,
memmove(dataContext.tokenContext.contract_address, workBuffer, CONTRACT_ADDR_SIZE);
workBuffer += 20;
memmove(dataContext.tokenContext.method_selector, workBuffer, SELECTOR_SIZE);
tmpCtx.transactionContext.externalPluginIsSet = true;
externalPluginIsSet = true;
G_io_apdu_buffer[(*tx)++] = 0x90;
G_io_apdu_buffer[(*tx)++] = 0x00;