Align internal plugin handler API with standard plugin handler API

This commit is contained in:
Francois Beutin
2024-08-01 16:50:46 +02:00
parent 4eb5ed3a19
commit 264d1de96e
8 changed files with 30 additions and 42 deletions

View File

@@ -16,8 +16,7 @@ const uint8_t *const ERC1155_SELECTORS[SELECTORS_COUNT] = {
ERC1155_SAFE_BATCH_TRANSFER, ERC1155_SAFE_BATCH_TRANSFER,
}; };
static void handle_init_contract(void *parameters) { void handle_init_contract_1155(ethPluginInitContract_t *msg) {
ethPluginInitContract_t *msg = (ethPluginInitContract_t *) parameters;
erc1155_context_t *context = (erc1155_context_t *) msg->pluginContext; erc1155_context_t *context = (erc1155_context_t *) msg->pluginContext;
if (NO_NFT_METADATA) { if (NO_NFT_METADATA) {
@@ -56,8 +55,7 @@ static void handle_init_contract(void *parameters) {
} }
} }
static void handle_finalize(void *parameters) { void handle_finalize_1155(ethPluginFinalize_t *msg) {
ethPluginFinalize_t *msg = (ethPluginFinalize_t *) parameters;
erc1155_context_t *context = (erc1155_context_t *) msg->pluginContext; erc1155_context_t *context = (erc1155_context_t *) msg->pluginContext;
if (context->selectorIndex != SAFE_BATCH_TRANSFER) { if (context->selectorIndex != SAFE_BATCH_TRANSFER) {
@@ -92,14 +90,11 @@ static void handle_finalize(void *parameters) {
msg->result = ETH_PLUGIN_RESULT_OK; msg->result = ETH_PLUGIN_RESULT_OK;
} }
static void handle_provide_info(void *parameters) { void handle_provide_info_1155(ethPluginProvideInfo_t *msg) {
ethPluginProvideInfo_t *msg = (ethPluginProvideInfo_t *) parameters;
msg->result = ETH_PLUGIN_RESULT_OK; msg->result = ETH_PLUGIN_RESULT_OK;
} }
static void handle_query_contract_id(void *parameters) { void handle_query_contract_id_1155(ethQueryContractID_t *msg) {
ethQueryContractID_t *msg = (ethQueryContractID_t *) parameters;
erc1155_context_t *context = (erc1155_context_t *) msg->pluginContext; erc1155_context_t *context = (erc1155_context_t *) msg->pluginContext;
msg->result = ETH_PLUGIN_RESULT_OK; msg->result = ETH_PLUGIN_RESULT_OK;
@@ -131,22 +126,22 @@ static void handle_query_contract_id(void *parameters) {
void erc1155_plugin_call(int message, void *parameters) { void erc1155_plugin_call(int message, void *parameters) {
switch (message) { switch (message) {
case ETH_PLUGIN_INIT_CONTRACT: { case ETH_PLUGIN_INIT_CONTRACT: {
handle_init_contract(parameters); handle_init_contract_1155((ethPluginInitContract_t *) parameters);
} break; } break;
case ETH_PLUGIN_PROVIDE_PARAMETER: { case ETH_PLUGIN_PROVIDE_PARAMETER: {
handle_provide_parameter_1155(parameters); handle_provide_parameter_1155((ethPluginProvideParameter_t *) parameters);
} break; } break;
case ETH_PLUGIN_FINALIZE: { case ETH_PLUGIN_FINALIZE: {
handle_finalize(parameters); handle_finalize_1155((ethPluginFinalize_t *) parameters);
} break; } break;
case ETH_PLUGIN_PROVIDE_INFO: { case ETH_PLUGIN_PROVIDE_INFO: {
handle_provide_info(parameters); handle_provide_info_1155((ethPluginProvideInfo_t *) parameters);
} break; } break;
case ETH_PLUGIN_QUERY_CONTRACT_ID: { case ETH_PLUGIN_QUERY_CONTRACT_ID: {
handle_query_contract_id(parameters); handle_query_contract_id_1155((ethQueryContractID_t *) parameters);
} break; } break;
case ETH_PLUGIN_QUERY_CONTRACT_UI: { case ETH_PLUGIN_QUERY_CONTRACT_UI: {
handle_query_contract_ui_1155(parameters); handle_query_contract_ui_1155((ethQueryContractUI_t *) parameters);
} break; } break;
default: default:
PRINTF("Unhandled message %d\n", message); PRINTF("Unhandled message %d\n", message);

View File

@@ -8,6 +8,7 @@
#include "ethUstream.h" #include "ethUstream.h"
#include "uint256.h" #include "uint256.h"
#include "asset_info.h" #include "asset_info.h"
#include "eth_plugin_interface.h"
// Internal plugin for EIP 1155: https://eips.ethereum.org/EIPS/eip-1155 // Internal plugin for EIP 1155: https://eips.ethereum.org/EIPS/eip-1155
@@ -48,8 +49,8 @@ typedef struct erc1155_context_t {
uint8_t selectorIndex; uint8_t selectorIndex;
} erc1155_context_t; } erc1155_context_t;
void handle_provide_parameter_1155(void *parameters); void handle_provide_parameter_1155(ethPluginProvideParameter_t *parameters);
void handle_query_contract_ui_1155(void *parameters); void handle_query_contract_ui_1155(ethQueryContractUI_t *parameters);
#endif // HAVE_NFT_SUPPORT #endif // HAVE_NFT_SUPPORT

View File

@@ -115,8 +115,7 @@ static void handle_approval_for_all(ethPluginProvideParameter_t *msg, erc1155_co
} }
} }
void handle_provide_parameter_1155(void *parameters) { void handle_provide_parameter_1155(ethPluginProvideParameter_t *msg) {
ethPluginProvideParameter_t *msg = (ethPluginProvideParameter_t *) parameters;
erc1155_context_t *context = (erc1155_context_t *) msg->pluginContext; erc1155_context_t *context = (erc1155_context_t *) msg->pluginContext;
PRINTF("erc1155 plugin provide parameter %d %.*H\n", PRINTF("erc1155 plugin provide parameter %d %.*H\n",

View File

@@ -132,8 +132,7 @@ static void set_batch_transfer_ui(ethQueryContractUI_t *msg, erc1155_context_t *
} }
} }
void handle_query_contract_ui_1155(void *parameters) { void handle_query_contract_ui_1155(ethQueryContractUI_t *msg) {
ethQueryContractUI_t *msg = (ethQueryContractUI_t *) parameters;
erc1155_context_t *context = (erc1155_context_t *) msg->pluginContext; erc1155_context_t *context = (erc1155_context_t *) msg->pluginContext;
msg->result = ETH_PLUGIN_RESULT_OK; msg->result = ETH_PLUGIN_RESULT_OK;

View File

@@ -21,8 +21,7 @@ const uint8_t *const ERC721_SELECTORS[SELECTORS_COUNT] = {
ERC721_SAFE_TRANSFER_DATA_SELECTOR, ERC721_SAFE_TRANSFER_DATA_SELECTOR,
}; };
static void handle_init_contract(void *parameters) { void handle_init_contract_721(ethPluginInitContract_t *msg) {
ethPluginInitContract_t *msg = (ethPluginInitContract_t *) parameters;
erc721_context_t *context = (erc721_context_t *) msg->pluginContext; erc721_context_t *context = (erc721_context_t *) msg->pluginContext;
if (NO_NFT_METADATA) { if (NO_NFT_METADATA) {
@@ -63,8 +62,7 @@ static void handle_init_contract(void *parameters) {
} }
} }
static void handle_finalize(void *parameters) { void handle_finalize_721(ethPluginFinalize_t *msg) {
ethPluginFinalize_t *msg = (ethPluginFinalize_t *) parameters;
erc721_context_t *context = (erc721_context_t *) msg->pluginContext; erc721_context_t *context = (erc721_context_t *) msg->pluginContext;
msg->tokenLookup1 = msg->pluginSharedRO->txContent->destination; msg->tokenLookup1 = msg->pluginSharedRO->txContent->destination;
@@ -99,14 +97,11 @@ static void handle_finalize(void *parameters) {
msg->result = ETH_PLUGIN_RESULT_OK; msg->result = ETH_PLUGIN_RESULT_OK;
} }
static void handle_provide_info(void *parameters) { void handle_provide_info_721(ethPluginProvideInfo_t *msg) {
ethPluginProvideInfo_t *msg = (ethPluginProvideInfo_t *) parameters;
msg->result = ETH_PLUGIN_RESULT_OK; msg->result = ETH_PLUGIN_RESULT_OK;
} }
static void handle_query_contract_id(void *parameters) { void handle_query_contract_id_721(ethQueryContractID_t *msg) {
ethQueryContractID_t *msg = (ethQueryContractID_t *) parameters;
erc721_context_t *context = (erc721_context_t *) msg->pluginContext; erc721_context_t *context = (erc721_context_t *) msg->pluginContext;
msg->result = ETH_PLUGIN_RESULT_OK; msg->result = ETH_PLUGIN_RESULT_OK;
@@ -138,22 +133,22 @@ static void handle_query_contract_id(void *parameters) {
void erc721_plugin_call(int message, void *parameters) { void erc721_plugin_call(int message, void *parameters) {
switch (message) { switch (message) {
case ETH_PLUGIN_INIT_CONTRACT: { case ETH_PLUGIN_INIT_CONTRACT: {
handle_init_contract(parameters); handle_init_contract_721((ethPluginInitContract_t *) parameters);
} break; } break;
case ETH_PLUGIN_PROVIDE_PARAMETER: { case ETH_PLUGIN_PROVIDE_PARAMETER: {
handle_provide_parameter_721(parameters); handle_provide_parameter_721((ethPluginProvideParameter_t *) parameters);
} break; } break;
case ETH_PLUGIN_FINALIZE: { case ETH_PLUGIN_FINALIZE: {
handle_finalize(parameters); handle_finalize_721((ethPluginFinalize_t *) parameters);
} break; } break;
case ETH_PLUGIN_PROVIDE_INFO: { case ETH_PLUGIN_PROVIDE_INFO: {
handle_provide_info(parameters); handle_provide_info_721((ethPluginProvideInfo_t *) parameters);
} break; } break;
case ETH_PLUGIN_QUERY_CONTRACT_ID: { case ETH_PLUGIN_QUERY_CONTRACT_ID: {
handle_query_contract_id(parameters); handle_query_contract_id_721((ethQueryContractID_t *) parameters);
} break; } break;
case ETH_PLUGIN_QUERY_CONTRACT_UI: { case ETH_PLUGIN_QUERY_CONTRACT_UI: {
handle_query_contract_ui_721(parameters); handle_query_contract_ui_721((ethQueryContractUI_t *) parameters);
} break; } break;
default: default:
PRINTF("Unhandled message %d\n", message); PRINTF("Unhandled message %d\n", message);

View File

@@ -7,6 +7,7 @@
#include <stdint.h> #include <stdint.h>
#include "ethUstream.h" #include "ethUstream.h"
#include "asset_info.h" #include "asset_info.h"
#include "eth_plugin_interface.h"
// Internal plugin for EIP 721: https://eips.ethereum.org/EIPS/eip-721 // Internal plugin for EIP 721: https://eips.ethereum.org/EIPS/eip-721
@@ -39,8 +40,8 @@ typedef struct erc721_context_t {
uint8_t selectorIndex; uint8_t selectorIndex;
} erc721_context_t; } erc721_context_t;
void handle_provide_parameter_721(void *parameters); void handle_provide_parameter_721(ethPluginProvideParameter_t *parameters);
void handle_query_contract_ui_721(void *parameters); void handle_query_contract_ui_721(ethQueryContractUI_t *parameters);
#endif // HAVE_NFT_SUPPORT #endif // HAVE_NFT_SUPPORT

View File

@@ -63,8 +63,7 @@ static void handle_approval_for_all(ethPluginProvideParameter_t *msg, erc721_con
} }
} }
void handle_provide_parameter_721(void *parameters) { void handle_provide_parameter_721(ethPluginProvideParameter_t *msg) {
ethPluginProvideParameter_t *msg = (ethPluginProvideParameter_t *) parameters;
erc721_context_t *context = (erc721_context_t *) msg->pluginContext; erc721_context_t *context = (erc721_context_t *) msg->pluginContext;
PRINTF("erc721 plugin provide parameter %d %.*H\n", PRINTF("erc721 plugin provide parameter %d %.*H\n",

View File

@@ -121,8 +121,7 @@ static void set_transfer_ui(ethQueryContractUI_t *msg, erc721_context_t *context
} }
} }
void handle_query_contract_ui_721(void *parameters) { void handle_query_contract_ui_721(ethQueryContractUI_t *msg) {
ethQueryContractUI_t *msg = (ethQueryContractUI_t *) parameters;
erc721_context_t *context = (erc721_context_t *) msg->pluginContext; erc721_context_t *context = (erc721_context_t *) msg->pluginContext;
msg->result = ETH_PLUGIN_RESULT_OK; msg->result = ETH_PLUGIN_RESULT_OK;