Skip to content

Commit

Permalink
fix: removed unused methods
Browse files Browse the repository at this point in the history
  • Loading branch information
n4l5u0r committed Mar 4, 2022
1 parent 5ac9356 commit 669e837
Show file tree
Hide file tree
Showing 10 changed files with 6 additions and 74 deletions.
7 changes: 0 additions & 7 deletions src/handle_finalize.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,9 @@

void handle_finalize(void *parameters) {
ethPluginFinalize_t *msg = (ethPluginFinalize_t *) parameters;
context_t *context = (context_t *) msg->pluginContext;

msg->uiType = ETH_UI_TYPE_GENERIC;

// 2 additional screens are required to display the `token and `beneficiary` fields
msg->numScreens = 2;
msg->result = ETH_PLUGIN_RESULT_OK;

if (context->selectorIndex == SAFE_TRANSFER) {
// An additional screen is required to display the `token` field for safe_transfer method.
msg->numScreens += 1;
}
}
3 changes: 0 additions & 3 deletions src/handle_init_contract.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ void handle_init_contract(void *parameters) {
case MINT_TOKEN:
context->next_param = EVENT_ID;
break;
case SAFE_TRANSFER:
context->next_param = FROM_ADDRESS;
break;
default:
PRINTF("Missing selectorIndex: %d\n", context->selectorIndex);
msg->result = ETH_PLUGIN_RESULT_ERROR;
Expand Down
32 changes: 0 additions & 32 deletions src/handle_provide_parameter.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ static void handle_beneficiary(const ethPluginProvideParameter_t *msg, context_t
PRINTF("BENEFICIARY: %.*H\n", ADDRESS_LENGTH, context->beneficiary);
}

static void handle_from_address(const ethPluginProvideParameter_t *msg, context_t *context) {
memset(context->from_address, 0, sizeof(context->from_address));
memcpy(context->from_address,
&msg->parameter[PARAMETER_LENGTH - ADDRESS_LENGTH],
sizeof(context->from_address));
PRINTF("FROM_ADDRESS: %.*H\n", ADDRESS_LENGTH, context->from_address);
}
static void handle_mint_token(ethPluginProvideParameter_t *msg, context_t *context) {
switch (context->next_param) {
case EVENT_ID:
Expand All @@ -41,28 +34,6 @@ static void handle_mint_token(ethPluginProvideParameter_t *msg, context_t *conte
break;
}
}
static void handle_safe_transfer(ethPluginProvideParameter_t *msg, context_t *context) {
switch (context->next_param) {
case FROM_ADDRESS: // from_address
handle_from_address(msg, context);
context->next_param = BENEFICIARY;
break;
case BENEFICIARY: // to
handle_beneficiary(msg, context);
context->next_param = TOKEN;
break;
case TOKEN: // id of the token received
handle_token(msg, context);
context->next_param = NONE;
break;
case NONE:
break;
default:
PRINTF("Param not supported\n");
msg->result = ETH_PLUGIN_RESULT_ERROR;
break;
}
}

void handle_provide_parameter(void *parameters) {
ethPluginProvideParameter_t *msg = (ethPluginProvideParameter_t *) parameters;
Expand All @@ -86,9 +57,6 @@ void handle_provide_parameter(void *parameters) {
case MINT_TOKEN:
handle_mint_token(msg, context);
break;
case SAFE_TRANSFER:
handle_safe_transfer(msg, context);
break;
default:
PRINTF("Selector Index not supported: %d\n", context->selectorIndex);
msg->result = ETH_PLUGIN_RESULT_ERROR;
Expand Down
3 changes: 0 additions & 3 deletions src/handle_query_contract_id.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ void handle_query_contract_id(void *parameters) {
strlcpy(msg->name, PLUGIN_NAME, msg->nameLength);

switch (context->selectorIndex) {
case SAFE_TRANSFER:
strlcpy(msg->version, "Safe Transfer", msg->versionLength);
break;
case MINT_TOKEN:
strlcpy(msg->version, "Mint", msg->versionLength);
break;
Expand Down
16 changes: 0 additions & 16 deletions src/handle_query_contract_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,6 @@ static void set_beneficiary_ui(ethQueryContractUI_t *msg, context_t *context) {
getEthAddressStringFromBinary(context->beneficiary, msg->msg + 2, msg->pluginSharedRW->sha3, 0);
}

// Set UI for "From Address" screen.
static void set_from_address_ui(ethQueryContractUI_t *msg, context_t *context) {
strlcpy(msg->title, "From Address", msg->titleLength);

msg->msg[0] = '0';
msg->msg[1] = 'x';

getEthAddressStringFromBinary(context->from_address,
msg->msg + 2,
msg->pluginSharedRW->sha3,
0);
}

// Set UI for "Warning" screen.
static void set_warning_ui(ethQueryContractUI_t *msg,
const context_t *context __attribute__((unused))) {
Expand Down Expand Up @@ -82,9 +69,6 @@ void handle_query_contract_ui(void *parameters) {
screens_t screen = get_screen(msg, context);

switch (screen) {
case FROM_ADDRESS_SCREEN:
set_from_address_ui(msg, context);
break;
case TOKEN_SCREEN:
set_token_ui(msg, context);
break;
Expand Down
10 changes: 5 additions & 5 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@

#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};
static const uint8_t SAFE_TRANSFER_SELECTOR[SELECTOR_SIZE] = {0x42, 0x84, 0x2e, 0x0e};
// Function: mintToken(uint256 eventId, uint256 tokenId, address receiver, uint256 expirationTime,
// bytes signature)
// Selector: 0xaf68b302
static const uint8_t MINT_TOKEN_SELECTOR[SELECTOR_SIZE] = {0xaf, 0x68, 0xb3, 0x02};

// Array of all the different poap selectors.
const uint8_t *const POAP_SELECTORS[NUM_SELECTORS] = {MINT_TOKEN_SELECTOR, SAFE_TRANSFER_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) {
Expand Down
4 changes: 1 addition & 3 deletions src/poap_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "eth_plugin_interface.h"
#include <string.h>

#define NUM_SELECTORS 2
#define NUM_SELECTORS 1
#define PLUGIN_NAME "Poap"
#define TOKEN_FOUND 1 << 1
#define SELECTOR_SIZE 4
Expand All @@ -13,7 +13,6 @@

typedef enum {
MINT_TOKEN,
SAFE_TRANSFER,
} selector_t;

// Enumeration used to parse the smart contract data.
Expand All @@ -39,7 +38,6 @@ extern const uint8_t *const POAP_SELECTORS[NUM_SELECTORS];
typedef struct context_t {
// For display.
uint8_t beneficiary[ADDRESS_LENGTH];
uint8_t from_address[ADDRESS_LENGTH];
uint8_t token_id[PARAMETER_LENGTH]; // not crypto token dedicated poap token value int number
char ticker[MAX_TICKER_LEN];

Expand Down
Binary file modified tests/elfs/poap_nanos.elf
Binary file not shown.
Binary file modified tests/elfs/poap_nanox.elf
Binary file not shown.
5 changes: 0 additions & 5 deletions tests/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5123,11 +5123,6 @@ [email protected]:
resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz"
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==

n@^8.0.2:
version "8.0.2"
resolved "https://registry.npmjs.org/n/-/n-8.0.2.tgz"
integrity sha512-IvKMeWenkEntHnktypexqIi1BCTQc0Po1+zBanui+flF4dwHtsV+B2WNkx6KAMCqlTHyIisSddj1Y7EbnKRgXQ==

nan@^2.12.1:
version "2.15.0"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.15.0.tgz#3f34a473ff18e15c1b5626b62903b5ad6e665fee"
Expand Down

0 comments on commit 669e837

Please sign in to comment.