2022-03-07 14:21:32 +01:00
|
|
|
#ifndef _ERC1155_PLUGIN_H_
|
|
|
|
|
#define _ERC1155_PLUGIN_H_
|
2021-12-17 12:04:51 +01:00
|
|
|
|
2022-03-07 14:21:32 +01:00
|
|
|
#ifdef HAVE_NFT_SUPPORT
|
2021-11-22 14:39:36 +01:00
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include "eth_plugin_handler.h"
|
|
|
|
|
#include "shared_context.h"
|
|
|
|
|
#include "ethUtils.h"
|
|
|
|
|
#include "utils.h"
|
2021-12-17 12:04:51 +01:00
|
|
|
#include "uint256.h"
|
2021-11-22 14:39:36 +01:00
|
|
|
|
|
|
|
|
// Internal plugin for EIP 1155: https://eips.ethereum.org/EIPS/eip-1155
|
|
|
|
|
|
|
|
|
|
#define NUM_ERC1155_SELECTORS 3
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
|
SET_APPROVAL_FOR_ALL,
|
|
|
|
|
SAFE_TRANSFER,
|
|
|
|
|
SAFE_BATCH_TRANSFER,
|
|
|
|
|
} erc1155_selector_t;
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
|
FROM,
|
|
|
|
|
TO,
|
|
|
|
|
TOKEN_IDS_OFFSET,
|
|
|
|
|
TOKEN_IDS_LENGTH,
|
|
|
|
|
TOKEN_ID,
|
|
|
|
|
VALUE_OFFSET,
|
|
|
|
|
VALUE_LENGTH,
|
|
|
|
|
VALUE,
|
|
|
|
|
OPERATOR,
|
|
|
|
|
APPROVED,
|
|
|
|
|
NONE,
|
|
|
|
|
} erc1155_selector_field;
|
|
|
|
|
|
|
|
|
|
typedef struct erc1155_context_t {
|
2022-01-14 17:32:17 +01:00
|
|
|
uint8_t address[ADDRESS_LENGTH];
|
|
|
|
|
uint8_t tokenId[INT256_LENGTH];
|
|
|
|
|
uint256_t value;
|
2021-11-22 14:39:36 +01:00
|
|
|
|
2021-12-17 12:04:51 +01:00
|
|
|
uint16_t ids_array_len;
|
|
|
|
|
uint32_t ids_offset;
|
|
|
|
|
uint16_t values_array_len;
|
|
|
|
|
uint32_t values_offset;
|
|
|
|
|
uint16_t array_index;
|
2021-11-22 14:39:36 +01:00
|
|
|
|
|
|
|
|
bool approved;
|
|
|
|
|
erc1155_selector_field next_param;
|
|
|
|
|
uint8_t selectorIndex;
|
|
|
|
|
} erc1155_context_t;
|
|
|
|
|
|
|
|
|
|
void handle_provide_parameter_1155(void *parameters);
|
2021-12-17 12:04:51 +01:00
|
|
|
void handle_query_contract_ui_1155(void *parameters);
|
|
|
|
|
|
2022-01-14 17:32:17 +01:00
|
|
|
#endif // HAVE_NFT_SUPPORT
|
2022-03-07 14:21:32 +01:00
|
|
|
|
|
|
|
|
#endif // _ERC1155_PLUGIN_H_
|