From 1b75b072aa06dcdf267f90ea641105d74fbbd330 Mon Sep 17 00:00:00 2001 From: lisaoulmi <88668098+lisaoulmi@users.noreply.github.com> Date: Mon, 22 Nov 2021 15:16:33 +0100 Subject: [PATCH 1/4] feat(poap ledger plugin): added mintToken method to poap plugin --- src/handle_finalize.c | 5 -- src/handle_init_contract.c | 20 +----- src/handle_provide_parameter.c | 101 +++++++++++------------------ src/handle_provide_token.c | 27 +++----- src/handle_query_contract_id.c | 10 +-- src/handle_query_contract_ui.c | 113 +++++++++++++++++---------------- src/main.c | 18 +++--- src/poap_plugin.h | 56 +++++++++------- 8 files changed, 148 insertions(+), 202 deletions(-) diff --git a/src/handle_finalize.c b/src/handle_finalize.c index 02de734..c2ccaf5 100644 --- a/src/handle_finalize.c +++ b/src/handle_finalize.c @@ -6,16 +6,11 @@ void handle_finalize(void *parameters) { msg->uiType = ETH_UI_TYPE_GENERIC; - // EDIT THIS: Set the total number of screen you will need. msg->numScreens = 2; - // EDIT THIS: Handle this case like you wish to (i.e. maybe no additional screen needed?). - // If the beneficiary is NOT the sender, we will need an additional screen to display it. if (memcmp(msg->address, context->beneficiary, ADDRESS_LENGTH) != 0) { msg->numScreens += 1; } - // EDIT THIS: set `tokenLookup1` (and maybe `tokenLookup2`) to point to - // token addresses you will info for (such as decimals, ticker...). msg->tokenLookup1 = context->token_received; msg->result = ETH_PLUGIN_RESULT_OK; diff --git a/src/handle_init_contract.c b/src/handle_init_contract.c index d35c507..49946ec 100644 --- a/src/handle_init_contract.c +++ b/src/handle_init_contract.c @@ -1,19 +1,13 @@ #include "poap_plugin.h" -// Called once to init. void handle_init_contract(void *parameters) { - // Cast the msg to the type of structure we expect (here, ethPluginInitContract_t). ethPluginInitContract_t *msg = (ethPluginInitContract_t *) parameters; - // Make sure we are running a compatible version. if (msg->interfaceVersion != ETH_PLUGIN_INTERFACE_VERSION_LATEST) { - // If not the case, return the `UNAVAILABLE` status. msg->result = ETH_PLUGIN_RESULT_UNAVAILABLE; return; } - // Double check that the `context_t` struct is not bigger than the maximum size (defined by - // `msg->pluginContextLength`). if (msg->pluginContextLength < sizeof(context_t)) { PRINTF("Plugin parameters structure is bigger than allowed size\n"); msg->result = ETH_PLUGIN_RESULT_ERROR; @@ -22,10 +16,8 @@ void handle_init_contract(void *parameters) { context_t *context = (context_t *) msg->pluginContext; - // Initialize the context (to 0). memset(context, 0, sizeof(*context)); - // Look for the index of the selectorIndex passed in by `msg`. uint8_t i; for (i = 0; i < NUM_SELECTORS; i++) { if (memcmp((uint8_t *) PIC(POAP_SELECTORS[i]), msg->selector, SELECTOR_SIZE) == 0) { @@ -33,28 +25,20 @@ void handle_init_contract(void *parameters) { break; } } - - // If `i == NUM_SELECTORS` it means we haven't found the selector. Return an error. if (i == NUM_SELECTORS) { msg->result = ETH_PLUGIN_RESULT_UNAVAILABLE; } // Set `next_param` to be the first field we expect to parse. - // EDIT THIS: Adapt the `cases`, and set the `next_param` to be the first parameter you expect - // to parse. switch (context->selectorIndex) { - case SWAP_EXACT_ETH_FOR_TOKENS: - context->next_param = MIN_AMOUNT_RECEIVED; + case MINT_TOKEN: + context->next_param = EVENT_ID; break; - case POAP_DUMMY_2: - context->next_param = TOKEN_RECEIVED; - // Keep this default: PRINTF("Missing selectorIndex: %d\n", context->selectorIndex); msg->result = ETH_PLUGIN_RESULT_ERROR; return; } - // Return valid status. msg->result = ETH_PLUGIN_RESULT_OK; } diff --git a/src/handle_provide_parameter.c b/src/handle_provide_parameter.c index 35ba855..e55ff2a 100644 --- a/src/handle_provide_parameter.c +++ b/src/handle_provide_parameter.c @@ -1,82 +1,53 @@ #include "poap_plugin.h" -// Copies the whole parameter (32 bytes long) from `src` to `dst`. -// Useful for numbers, data... -static void copy_parameter(uint8_t *dst, size_t dst_len, uint8_t *src) { - // Take the minimum between dst_len and parameter_length to make sure we don't overwrite memory. - size_t len = MIN(dst_len, PARAMETER_LENGTH); - memcpy(dst, src, len); +static void handle_beneficiary(const ethPluginProvideParameter_t *msg, + context_t *context) { + memset(context->beneficiary, 0, sizeof(context->beneficiary)); + memcpy(context->beneficiary, + &msg->parameter[PARAMETER_LENGTH - ADDRESS_LENGTH], + sizeof(context->beneficiary)); + PRINTF("BENEFICIARY: %.*H\n", ADDRESS_LENGTH, context->beneficiary); } -// Copies a 20 byte address (located in a 32 bytes parameter) `from `src` to `dst`. -// Useful for token addresses, user addresses... -static void copy_address(uint8_t *dst, size_t dst_len, uint8_t *src) { - // An address is 20 bytes long: so we need to make sure we skip the first 12 bytes! - size_t offset = PARAMETER_LENGTH - ADDRESS_LENGTH; - size_t len = MIN(dst_len, ADDRESS_LENGTH); - memcpy(dst, &src[offset], len); -} - -// EDIT THIS: Remove this function and write your own handlers! -static void handle_swap_exact_eth_for_tokens(ethPluginProvideParameter_t *msg, context_t *context) { - if (context->go_to_offset) { - if (msg->parameterOffset != context->offset + SELECTOR_SIZE) { - return; - } - context->go_to_offset = false; - } - switch (context->next_param) { - case MIN_AMOUNT_RECEIVED: // amountOutMin - copy_parameter(context->amount_received, - sizeof(context->amount_received), - msg->parameter); - context->next_param = PATH_OFFSET; - break; - case PATH_OFFSET: // path - context->offset = U2BE(msg->parameter, PARAMETER_LENGTH - 2); - context->next_param = BENEFICIARY; - break; - case BENEFICIARY: // to - copy_address(context->beneficiary, sizeof(context->beneficiary), msg->parameter); - context->next_param = PATH_LENGTH; - context->go_to_offset = true; - break; - case PATH_LENGTH: - context->offset = msg->parameterOffset - SELECTOR_SIZE + PARAMETER_LENGTH * 2; - context->go_to_offset = true; - context->next_param = TOKEN_RECEIVED; - break; - case TOKEN_RECEIVED: // path[1] -> contract address of token received - copy_address(context->token_received, sizeof(context->token_received), msg->parameter); - context->next_param = UNEXPECTED_PARAMETER; - break; - // Keep this - default: - PRINTF("Param not supported: %d\n", context->next_param); - msg->result = ETH_PLUGIN_RESULT_ERROR; - break; - } +static void handle_token_received(const ethPluginProvideParameter_t *msg, + context_t *context) { + memset(context->token_received, 0, sizeof(context->token_received)); + memcpy(context->token_received, + &msg->parameter[PARAMETER_LENGTH - ADDRESS_LENGTH], + sizeof(context->token_received)); + PRINTF("TOKEN RECEIVED: %.*H\n", ADDRESS_LENGTH, context->token_received); } void handle_provide_parameter(void *parameters) { ethPluginProvideParameter_t *msg = (ethPluginProvideParameter_t *) parameters; context_t *context = (context_t *) msg->pluginContext; - // We use `%.*H`: it's a utility function to print bytes. You first give - // the number of bytes you wish to print (in this case, `PARAMETER_LENGTH`) and then - // the address (here `msg->parameter`). - PRINTF("plugin provide parameter: offset %d\nBytes: %.*H\n", - msg->parameterOffset, - PARAMETER_LENGTH, - msg->parameter); msg->result = ETH_PLUGIN_RESULT_OK; - // EDIT THIS: adapt the cases and the names of the functions. + if (context->skip) { + // Skip this step, and don't forget to decrease skipping counter. + context->skip--; + } else if ((context->offset) && msg->parameterOffset != context->checkpoint + context->offset) { + PRINTF("offset: %d, checkpoint: %d, parameterOffset: %d\n", + context->offset, + context->checkpoint, + msg->parameterOffset); + return; + } + context->offset = 0; switch (context->selectorIndex) { - case SWAP_EXACT_ETH_FOR_TOKENS: - handle_swap_exact_eth_for_tokens(msg, context); + case EVENT_ID: + context->next_param = TOKEN_RECEIVED; + break; + case TOKEN_RECEIVED: // path[1] -> id of the token received + handle_token_received(msg, context); + context->next_param = BENEFICIARY; + break; + case BENEFICIARY: // to + handle_beneficiary(msg, context); + context->next_param = NONE; break; - case POAP_DUMMY_2: + case NONE: break; default: PRINTF("Selector Index not supported: %d\n", context->selectorIndex); diff --git a/src/handle_provide_token.c b/src/handle_provide_token.c index e5e5e31..ed4e074 100644 --- a/src/handle_provide_token.c +++ b/src/handle_provide_token.c @@ -1,29 +1,20 @@ #include "poap_plugin.h" -// EDIT THIS: Adapt this function to your needs! Remember, the information for tokens are held in -// `msg->token1` and `msg->token2`. If those pointers are `NULL`, this means the ethereum app didn't -// find any info regarding the requested tokens! void handle_provide_token(void *parameters) { ethPluginProvideToken_t *msg = (ethPluginProvideToken_t *) parameters; context_t *context = (context_t *) msg->pluginContext; - if (msg->token1) { - // The Ethereum App found the information for the requested token! - // Store its decimals. - context->decimals = msg->token1->decimals; - // Store its ticker. - strlcpy(context->ticker, (char *) msg->token1->ticker, sizeof(context->ticker)); + PRINTF("POAP plugin provide token: 0x%p\n", msg->token1); - // Keep track that we found the token. - context->token_found = true; + if (msg->token1 != NULL) { + context->decimals = msg->token1->decimals; + strlcpy(context->ticker, + (char *) msg->token1->ticker, + sizeof(context->ticker)); + context->tokens_found |= TOKEN_RECEIVED_FOUND; } else { - // The Ethereum App did not manage to find the info for the requested token. - context->token_found = false; - - // If we wanted to add a screen, say a warning screen for example, we could instruct the - // ethereum app to add an additional screen by setting `msg->additionalScreens` here, just - // like so: - // msg->additionalScreens = 1; + context->decimals = DEFAULT_DECIMAL; + msg->additionalScreens++; } msg->result = ETH_PLUGIN_RESULT_OK; } \ No newline at end of file diff --git a/src/handle_query_contract_id.c b/src/handle_query_contract_id.c index 76d27a8..5ef6d05 100644 --- a/src/handle_query_contract_id.c +++ b/src/handle_query_contract_id.c @@ -1,21 +1,15 @@ #include "poap_plugin.h" -// Sets the first screen to display. void handle_query_contract_id(void *parameters) { ethQueryContractID_t *msg = (ethQueryContractID_t *) parameters; context_t *context = (context_t *) msg->pluginContext; - // msg->name will be the upper sentence displayed on the screen. - // msg->version will be the lower sentence displayed on the screen. - // For the first screen, display the plugin name. strlcpy(msg->name, PLUGIN_NAME, msg->nameLength); - // EDIT THIS: Adapt the cases by modifying the strings you pass to `strlcpy`. switch (context->selectorIndex) { - case SWAP_EXACT_ETH_FOR_TOKENS: - strlcpy(msg->version, "Swap", msg->versionLength); + case MINT_TOKEN: + strlcpy(msg->version, "Mint", msg->versionLength); break; - // Keep this default: PRINTF("Selector index: %d not supported\n", context->selectorIndex); msg->result = ETH_PLUGIN_RESULT_ERROR; diff --git a/src/handle_query_contract_ui.c b/src/handle_query_contract_ui.c index 18160b4..f0b06ee 100644 --- a/src/handle_query_contract_ui.c +++ b/src/handle_query_contract_ui.c @@ -1,90 +1,95 @@ #include "poap_plugin.h" -// EDIT THIS: You need to adapt / remove the static functions (set_send_ui, set_receive_ui ...) to -// match what you wish to display. - -// Set UI for the "Send" screen. -// EDIT THIS: Adapt / remove this function to your needs. -static void set_send_ui(ethQueryContractUI_t *msg) { - strlcpy(msg->title, "Send", msg->titleLength); - - uint8_t *eth_amount = msg->pluginSharedRO->txContent->value.value; - uint8_t eth_amount_size = msg->pluginSharedRO->txContent->value.length; - - // Converts the uint256 number located in `eth_amount` to its string representation and - // copies this to `msg->msg`. - amountToString(eth_amount, eth_amount_size, WEI_TO_ETHER, "ETH ", msg->msg, msg->msgLength); +// Set UI for "Mint" screen. +static void set_mint_ui(ethQueryContractUI_t *msg, context_t *context) { + strlcpy(msg->title, "Mint", msg->titleLength); + strlcpy(msg->msg, "POAP", msg->msgLength); } -// Set UI for "Receive" screen. -// EDIT THIS: Adapt / remove this function to your needs. -static void set_receive_ui(ethQueryContractUI_t *msg, context_t *context) { - strlcpy(msg->title, "Receive Min.", msg->titleLength); - - uint8_t decimals = context->decimals; - char *ticker = context->ticker; +// Set UI for "Token" screen. +static void set_token_ui(ethQueryContractUI_t *msg, context_t *context) { + strlcpy(msg->title, "Token", msg->titleLength); - // If the token look up failed, use the default network ticker along with the default decimals. - if (!context->token_found) { - decimals = WEI_TO_ETHER; - ticker = msg->network_ticker; - } - - amountToString(context->amount_received, - sizeof(context->amount_received), - decimals, - ticker, + amountToString(context->token_received, + sizeof(context->token_received), + context->decimals, + context->ticker, msg->msg, msg->msgLength); } + // Set UI for "Beneficiary" screen. -// EDIT THIS: Adapt / remove this function to your needs. static void set_beneficiary_ui(ethQueryContractUI_t *msg, context_t *context) { strlcpy(msg->title, "Beneficiary", msg->titleLength); - // Prefix the address with `0x`. msg->msg[0] = '0'; msg->msg[1] = 'x'; - // We need a random chainID for legacy reasons with `getEthAddressStringFromBinary`. - // Setting it to `0` will make it work with every chainID :) - uint64_t chainid = 0; - - // Get the string representation of the address stored in `context->beneficiary`. Put it in - // `msg->msg`. getEthAddressStringFromBinary( context->beneficiary, - msg->msg + 2, // +2 here because we've already prefixed with '0x'. + msg->msg + 2, msg->pluginSharedRW->sha3, - chainid); + 0); +} + +// Set UI for "Warning" screen. +static void set_warning_ui(ethQueryContractUI_t *msg, + const context_t *context __attribute__((unused))) { + strlcpy(msg->title, "WARNING", msg->titleLength); + strlcpy(msg->msg, "Unknown token", msg->msgLength); +} + +// Helper function that returns the enum corresponding to the screen that should be displayed. +static screens_t get_screen(const ethQueryContractUI_t *msg, const context_t *context) { + uint8_t index = msg->screenIndex; + + bool token_received_found = context->tokens_found & TOKEN_RECEIVED_FOUND; + bool token_received_not_found = !token_received_found; + switch (index) { + case 0: + if (token_received_found) { + return TOKEN_SCREEN; + } else if (token_received_not_found) { + return WARN_SCREEN; + } + break; + case 1: + if (token_received_found) { + return BENEFICIARY_SCREEN; + } else if (token_received_not_found) { + return WARN_SCREEN; + } + break; + default: + return ERROR; + break; + } } void handle_query_contract_ui(void *parameters) { ethQueryContractUI_t *msg = (ethQueryContractUI_t *) parameters; context_t *context = (context_t *) msg->pluginContext; - // msg->title is the upper line displayed on the device. - // msg->msg is the lower line displayed on the device. - - // Clean the display fields. memset(msg->title, 0, msg->titleLength); memset(msg->msg, 0, msg->msgLength); - msg->result = ETH_PLUGIN_RESULT_OK; - // EDIT THIS: Adapt the cases for the screens you'd like to display. - switch (msg->screenIndex) { - case 0: - set_send_ui(msg); + screens_t screen = get_screen(msg, context); + + switch (screen) { + case MINT_SCREEN: + set_mint_ui(msg, context); break; - case 1: - set_receive_ui(msg, context); + case TOKEN_SCREEN: + set_token_ui(msg, context); break; - case 2: + case BENEFICIARY_SCREEN: set_beneficiary_ui(msg, context); break; - // Keep this + case WARN_SCREEN: + set_warning_ui(msg, context); + break; default: PRINTF("Received an invalid screenIndex\n"); msg->result = ETH_PLUGIN_RESULT_ERROR; diff --git a/src/main.c b/src/main.c index ed16520..98a74c1 100644 --- a/src/main.c +++ b/src/main.c @@ -24,17 +24,15 @@ #include "poap_plugin.h" -// List of selectors supported by this plugin. -// EDIT THIS: Adapt the variable names and change the `0x` values to match your selectors. -static const uint8_t SWAP_EXACT_ETH_FOR_TOKENS_SELECTOR[SELECTOR_SIZE] = {0x7f, 0xf3, 0x6a, 0xb5}; -static const uint8_t POAP_DUMMY_SELECTOR_2[SELECTOR_SIZE] = {0x13, 0x37, 0x42, 0x42}; - -// Array of all the different poap selectors. Make sure this follows the same order as the -// enum defined in `poap_plugin.h` -// EDIT THIS: Use the names of the array declared above. + +// Function: mintToken(uint256 eventId, uint256 tokenId, address receiver, bytes signedMessage) +// Selector: 0x3da5b8f0 +static const uint8_t MINT_TOKEN_SELECTOR[SELECTOR_SIZE] = {0x3d, 0xa5, 0xb8, 0xf0}; + + +// Array of all the different poap selectors. const uint8_t *const POAP_SELECTORS[NUM_SELECTORS] = { - SWAP_EXACT_ETH_FOR_TOKENS_SELECTOR, - POAP_DUMMY_SELECTOR_2, + MINT_TOKEN_SELECTOR }; // Function to dispatch calls from the ethereum app. diff --git a/src/poap_plugin.h b/src/poap_plugin.h index 8480c86..79ca060 100644 --- a/src/poap_plugin.h +++ b/src/poap_plugin.h @@ -4,53 +4,61 @@ #include "eth_plugin_interface.h" #include -// Number of selectors defined in this plugin. Should match the enum `selector_t`. -// EDIT THIS: Put in the number of selectors your plugin is going to support. -#define NUM_SELECTORS 2 -// Name of the plugin. -// EDIT THIS: Replace with your plugin name. +#define NUM_SELECTORS 1 + #define PLUGIN_NAME "Poap" -// Enumeration of the different selectors possible. -// Should follow the exact same order as the array declared in main.c -// EDIT THIS: Change the naming (`selector_t`), and add your selector names. +#define TOKEN_RECEIVED_FOUND 1 << 1 + +#define SELECTOR_SIZE 4 + +#define PARAMETER_LENGTH 32 + +#define RUN_APPLICATION 1 + typedef enum { - SWAP_EXACT_ETH_FOR_TOKENS = 0, - POAP_DUMMY_2, + MINT_TOKEN, } selector_t; // Enumeration used to parse the smart contract data. -// EDIT THIS: Adapt the parameter names here. typedef enum { - MIN_AMOUNT_RECEIVED = 0, + EVENT_ID, TOKEN_RECEIVED, BENEFICIARY, - PATH_OFFSET, - PATH_LENGTH, - UNEXPECTED_PARAMETER, + NONE, } parameter; -// EDIT THIS: Rename `POAP` to be the same as the one initialized in `main.c`. +typedef enum { + MINT_SCREEN, + TOKEN_SCREEN, + WARN_SCREEN, + BENEFICIARY_SCREEN, + ERROR, +} screens_t; + extern const uint8_t *const POAP_SELECTORS[NUM_SELECTORS]; +// Number of decimals used when the token wasn't found in the CAL. +#define DEFAULT_DECIMAL WEI_TO_ETHER + +// Ticker used when the token wasn't found in the CAL. +#define DEFAULT_TICKER "" + // Shared global memory with Ethereum app. Must be at most 5 * 32 bytes. -// EDIT THIS: This struct is used by your plugin to save the parameters you parse. You -// will need to adapt this struct to your plugin. typedef struct context_t { // For display. - uint8_t amount_received[INT256_LENGTH]; uint8_t beneficiary[ADDRESS_LENGTH]; uint8_t token_received[ADDRESS_LENGTH]; char ticker[MAX_TICKER_LEN]; uint8_t decimals; - uint8_t token_found; // For parsing data. - uint8_t next_param; // Set to be the next param we expect to parse. - uint16_t offset; // Offset at which the array or struct starts. - bool go_to_offset; // If set, will force the parsing to iterate through parameters until - // `offset` is reached. + uint16_t offset; + uint16_t checkpoint; + uint8_t skip; + uint8_t next_param; + uint8_t tokens_found; // For both parsing and display. selector_t selectorIndex; From 2f2b0badeb202e0a060036b24865d19dc7fd359d Mon Sep 17 00:00:00 2001 From: lisaoulmi <88668098+lisaoulmi@users.noreply.github.com> Date: Mon, 22 Nov 2021 15:28:04 +0100 Subject: [PATCH 2/4] feat(mint token): lint bug fix --- src/handle_provide_parameter.c | 18 ++++++++---------- src/handle_provide_token.c | 4 +--- src/handle_query_contract_ui.c | 7 +------ src/main.c | 6 +----- 4 files changed, 11 insertions(+), 24 deletions(-) diff --git a/src/handle_provide_parameter.c b/src/handle_provide_parameter.c index e55ff2a..a97afac 100644 --- a/src/handle_provide_parameter.c +++ b/src/handle_provide_parameter.c @@ -1,7 +1,6 @@ #include "poap_plugin.h" -static void handle_beneficiary(const ethPluginProvideParameter_t *msg, - context_t *context) { +static void handle_beneficiary(const ethPluginProvideParameter_t *msg, context_t *context) { memset(context->beneficiary, 0, sizeof(context->beneficiary)); memcpy(context->beneficiary, &msg->parameter[PARAMETER_LENGTH - ADDRESS_LENGTH], @@ -9,8 +8,7 @@ static void handle_beneficiary(const ethPluginProvideParameter_t *msg, PRINTF("BENEFICIARY: %.*H\n", ADDRESS_LENGTH, context->beneficiary); } -static void handle_token_received(const ethPluginProvideParameter_t *msg, - context_t *context) { +static void handle_token_received(const ethPluginProvideParameter_t *msg, context_t *context) { memset(context->token_received, 0, sizeof(context->token_received)); memcpy(context->token_received, &msg->parameter[PARAMETER_LENGTH - ADDRESS_LENGTH], @@ -25,13 +23,13 @@ void handle_provide_parameter(void *parameters) { msg->result = ETH_PLUGIN_RESULT_OK; if (context->skip) { - // Skip this step, and don't forget to decrease skipping counter. - context->skip--; - } else if ((context->offset) && msg->parameterOffset != context->checkpoint + context->offset) { + // Skip this step, and don't forget to decrease skipping counter. + context->skip--; + } else if ((context->offset) && msg->parameterOffset != context->checkpoint + context->offset) { PRINTF("offset: %d, checkpoint: %d, parameterOffset: %d\n", - context->offset, - context->checkpoint, - msg->parameterOffset); + context->offset, + context->checkpoint, + msg->parameterOffset); return; } context->offset = 0; diff --git a/src/handle_provide_token.c b/src/handle_provide_token.c index ed4e074..845246f 100644 --- a/src/handle_provide_token.c +++ b/src/handle_provide_token.c @@ -8,9 +8,7 @@ void handle_provide_token(void *parameters) { if (msg->token1 != NULL) { context->decimals = msg->token1->decimals; - strlcpy(context->ticker, - (char *) msg->token1->ticker, - sizeof(context->ticker)); + strlcpy(context->ticker, (char *) msg->token1->ticker, sizeof(context->ticker)); context->tokens_found |= TOKEN_RECEIVED_FOUND; } else { context->decimals = DEFAULT_DECIMAL; diff --git a/src/handle_query_contract_ui.c b/src/handle_query_contract_ui.c index f0b06ee..086938b 100644 --- a/src/handle_query_contract_ui.c +++ b/src/handle_query_contract_ui.c @@ -18,7 +18,6 @@ static void set_token_ui(ethQueryContractUI_t *msg, context_t *context) { msg->msgLength); } - // Set UI for "Beneficiary" screen. static void set_beneficiary_ui(ethQueryContractUI_t *msg, context_t *context) { strlcpy(msg->title, "Beneficiary", msg->titleLength); @@ -26,11 +25,7 @@ static void set_beneficiary_ui(ethQueryContractUI_t *msg, context_t *context) { msg->msg[0] = '0'; msg->msg[1] = 'x'; - getEthAddressStringFromBinary( - context->beneficiary, - msg->msg + 2, - msg->pluginSharedRW->sha3, - 0); + getEthAddressStringFromBinary(context->beneficiary, msg->msg + 2, msg->pluginSharedRW->sha3, 0); } // Set UI for "Warning" screen. diff --git a/src/main.c b/src/main.c index 98a74c1..00015b2 100644 --- a/src/main.c +++ b/src/main.c @@ -24,16 +24,12 @@ #include "poap_plugin.h" - // Function: mintToken(uint256 eventId, uint256 tokenId, address receiver, bytes signedMessage) // Selector: 0x3da5b8f0 static const uint8_t MINT_TOKEN_SELECTOR[SELECTOR_SIZE] = {0x3d, 0xa5, 0xb8, 0xf0}; - // Array of all the different poap selectors. -const uint8_t *const POAP_SELECTORS[NUM_SELECTORS] = { - MINT_TOKEN_SELECTOR -}; +const uint8_t *const POAP_SELECTORS[NUM_SELECTORS] = {MINT_TOKEN_SELECTOR}; // Function to dispatch calls from the ethereum app. void dispatch_plugin_calls(int message, void *parameters) { From 1bbfa9e66afafef8bba9a9b3e064655ed7cd25c5 Mon Sep 17 00:00:00 2001 From: lisaoulmi <88668098+lisaoulmi@users.noreply.github.com> Date: Mon, 22 Nov 2021 15:32:07 +0100 Subject: [PATCH 3/4] feat(mint token): bug fixe lint --- src/poap_plugin.h | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/poap_plugin.h b/src/poap_plugin.h index 79ca060..93776ed 100644 --- a/src/poap_plugin.h +++ b/src/poap_plugin.h @@ -6,17 +6,17 @@ #define NUM_SELECTORS 1 - #define PLUGIN_NAME "Poap" - #define TOKEN_RECEIVED_FOUND 1 << 1 - #define SELECTOR_SIZE 4 - #define PARAMETER_LENGTH 32 - #define RUN_APPLICATION 1 +// Number of decimals used when the token wasn't found in the CAL. +#define DEFAULT_DECIMAL WEI_TO_ETHER + +// Ticker used when the token wasn't found in the CAL. +#define DEFAULT_TICKER "" typedef enum { MINT_TOKEN, } selector_t; @@ -39,12 +39,6 @@ typedef enum { extern const uint8_t *const POAP_SELECTORS[NUM_SELECTORS]; -// Number of decimals used when the token wasn't found in the CAL. -#define DEFAULT_DECIMAL WEI_TO_ETHER - -// Ticker used when the token wasn't found in the CAL. -#define DEFAULT_TICKER "" - // Shared global memory with Ethereum app. Must be at most 5 * 32 bytes. typedef struct context_t { // For display. From 996311cef1d1fce7e987c771f67122eed09795c3 Mon Sep 17 00:00:00 2001 From: lisaoulmi <88668098+lisaoulmi@users.noreply.github.com> Date: Mon, 22 Nov 2021 15:35:00 +0100 Subject: [PATCH 4/4] feat(mint token): bug fixe lint --- src/poap_plugin.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/poap_plugin.h b/src/poap_plugin.h index 93776ed..ace82b8 100644 --- a/src/poap_plugin.h +++ b/src/poap_plugin.h @@ -4,13 +4,12 @@ #include "eth_plugin_interface.h" #include - -#define NUM_SELECTORS 1 -#define PLUGIN_NAME "Poap" +#define NUM_SELECTORS 1 +#define PLUGIN_NAME "Poap" #define TOKEN_RECEIVED_FOUND 1 << 1 -#define SELECTOR_SIZE 4 -#define PARAMETER_LENGTH 32 -#define RUN_APPLICATION 1 +#define SELECTOR_SIZE 4 +#define PARAMETER_LENGTH 32 +#define RUN_APPLICATION 1 // Number of decimals used when the token wasn't found in the CAL. #define DEFAULT_DECIMAL WEI_TO_ETHER