Now prevents NFT signatures without NFT metadata
This commit is contained in:
@@ -48,14 +48,14 @@ void eth_plugin_prepare_query_contract_UI(ethQueryContractUI_t *queryContractUI,
|
||||
memset((uint8_t *) queryContractUI, 0, sizeof(ethQueryContractUI_t));
|
||||
|
||||
// If no extra information was found, set the pointer to NULL
|
||||
if (allzeroes(&tmpCtx.transactionContext.extraInfo[1], sizeof(union extraInfo_t))) {
|
||||
if (NO_EXTRA_INFO(tmpCtx, 1)) {
|
||||
queryContractUI->item1 = NULL;
|
||||
} else {
|
||||
queryContractUI->item1 = &tmpCtx.transactionContext.extraInfo[1];
|
||||
}
|
||||
|
||||
// If no extra information was found, set the pointer to NULL
|
||||
if (allzeroes(&tmpCtx.transactionContext.extraInfo[0], sizeof(union extraInfo_t))) {
|
||||
if (NO_EXTRA_INFO(tmpCtx, 0)) {
|
||||
queryContractUI->item2 = NULL;
|
||||
} else {
|
||||
queryContractUI->item2 = &tmpCtx.transactionContext.extraInfo[0];
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
|
||||
#include "eth_plugin_interface.h"
|
||||
|
||||
#define NO_EXTRA_INFO(ctx, idx) \
|
||||
(allzeroes(&(ctx.transactionContext.extraInfo[idx]), sizeof(extraInfo_t)))
|
||||
|
||||
void eth_plugin_prepare_init(ethPluginInitContract_t *init, uint8_t *selector, uint32_t dataSize);
|
||||
void eth_plugin_prepare_provide_parameter(ethPluginProvideParameter_t *provideParameter,
|
||||
uint8_t *parameter,
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
#ifndef _NFT_H_
|
||||
#define _NFT_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define COLLECTION_NAME_MAX_LEN 70
|
||||
#define NO_NFT_METADATA (NO_EXTRA_INFO(tmpCtx, 1))
|
||||
|
||||
typedef struct nftInfo_t {
|
||||
uint8_t contractAddress[ADDRESS_LENGTH]; // must be first item
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "erc1155_plugin.h"
|
||||
#include "eth_plugin_internal.h"
|
||||
#include "ethUtils.h"
|
||||
#include "eth_plugin_handler.h"
|
||||
|
||||
static const uint8_t ERC1155_APPROVE_FOR_ALL_SELECTOR[SELECTOR_SIZE] = {0xa2, 0x2c, 0xb4, 0x65};
|
||||
static const uint8_t ERC1155_SAFE_TRANSFER_SELECTOR[SELECTOR_SIZE] = {0xf2, 0x42, 0x43, 0x2a};
|
||||
@@ -19,6 +20,11 @@ static void handle_init_contract(void *parameters) {
|
||||
ethPluginInitContract_t *msg = (ethPluginInitContract_t *) parameters;
|
||||
erc1155_context_t *context = (erc1155_context_t *) msg->pluginContext;
|
||||
|
||||
if (NO_NFT_METADATA) {
|
||||
PRINTF("No NFT metadata when trying to sign!\n");
|
||||
msg->result = ETH_PLUGIN_RESULT_ERROR;
|
||||
return;
|
||||
}
|
||||
uint8_t i;
|
||||
for (i = 0; i < SELECTORS_COUNT; i++) {
|
||||
if (memcmp((uint8_t *) PIC(ERC1155_SELECTORS[i]), msg->selector, SELECTOR_SIZE) == 0) {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "eth_plugin_internal.h"
|
||||
#include "eth_plugin_interface.h"
|
||||
#include "ethUtils.h"
|
||||
#include "eth_plugin_handler.h"
|
||||
|
||||
static const uint8_t ERC721_APPROVE_SELECTOR[SELECTOR_SIZE] = {0x09, 0x5e, 0xa7, 0xb3};
|
||||
static const uint8_t ERC721_APPROVE_FOR_ALL_SELECTOR[SELECTOR_SIZE] = {0xa2, 0x2c, 0xb4, 0x65};
|
||||
@@ -24,6 +25,11 @@ static void handle_init_contract(void *parameters) {
|
||||
ethPluginInitContract_t *msg = (ethPluginInitContract_t *) parameters;
|
||||
erc721_context_t *context = (erc721_context_t *) msg->pluginContext;
|
||||
|
||||
if (NO_NFT_METADATA) {
|
||||
PRINTF("No NFT metadata when trying to sign!\n");
|
||||
msg->result = ETH_PLUGIN_RESULT_ERROR;
|
||||
return;
|
||||
}
|
||||
uint8_t i;
|
||||
for (i = 0; i < SELECTORS_COUNT; i++) {
|
||||
if (memcmp((uint8_t *) PIC(ERC721_SELECTORS[i]), msg->selector, SELECTOR_SIZE) == 0) {
|
||||
|
||||
Reference in New Issue
Block a user