Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ethPluginSharedRW_t and rename ethPluginSharedRO_t #603

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions src/eth_plugin_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,9 @@ eth_plugin_result_t eth_plugin_perform_init(uint8_t *contractAddress,
}

eth_plugin_result_t eth_plugin_call(int method, void *parameter) {
ethPluginSharedRW_t pluginRW;
ethPluginSharedRO_t pluginRO;
char *alias;
uint8_t i;

pluginRW.sha3 = &global_sha3;
pluginRO.txContent = &tmpContent.txContent;

if (dataContext.tokenContext.pluginStatus <= ETH_PLUGIN_RESULT_UNSUCCESSFUL) {
PRINTF("Cached plugin call but no plugin available\n");
return dataContext.tokenContext.pluginStatus;
Expand All @@ -201,8 +196,7 @@ eth_plugin_result_t eth_plugin_call(int method, void *parameter) {
((ethPluginInitContract_t *) parameter)->interfaceVersion =
ETH_PLUGIN_INTERFACE_VERSION_LATEST;
((ethPluginInitContract_t *) parameter)->result = ETH_PLUGIN_RESULT_UNAVAILABLE;
((ethPluginInitContract_t *) parameter)->pluginSharedRW = &pluginRW;
((ethPluginInitContract_t *) parameter)->pluginSharedRO = &pluginRO;
((ethPluginInitContract_t *) parameter)->txContent = &tmpContent.txContent;
((ethPluginInitContract_t *) parameter)->pluginContext =
(uint8_t *) &dataContext.tokenContext.pluginContext;
((ethPluginInitContract_t *) parameter)->pluginContextLength =
Expand All @@ -211,39 +205,34 @@ eth_plugin_result_t eth_plugin_call(int method, void *parameter) {
case ETH_PLUGIN_PROVIDE_PARAMETER:
PRINTF("-- PLUGIN PROVIDE PARAMETER --\n");
((ethPluginProvideParameter_t *) parameter)->result = ETH_PLUGIN_RESULT_UNAVAILABLE;
((ethPluginProvideParameter_t *) parameter)->pluginSharedRW = &pluginRW;
((ethPluginProvideParameter_t *) parameter)->pluginSharedRO = &pluginRO;
((ethPluginProvideParameter_t *) parameter)->txContent = &tmpContent.txContent;
((ethPluginProvideParameter_t *) parameter)->pluginContext =
(uint8_t *) &dataContext.tokenContext.pluginContext;
break;
case ETH_PLUGIN_FINALIZE:
PRINTF("-- PLUGIN FINALIZE --\n");
((ethPluginFinalize_t *) parameter)->result = ETH_PLUGIN_RESULT_UNAVAILABLE;
((ethPluginFinalize_t *) parameter)->pluginSharedRW = &pluginRW;
((ethPluginFinalize_t *) parameter)->pluginSharedRO = &pluginRO;
((ethPluginFinalize_t *) parameter)->txContent = &tmpContent.txContent;
((ethPluginFinalize_t *) parameter)->pluginContext =
(uint8_t *) &dataContext.tokenContext.pluginContext;
break;
case ETH_PLUGIN_PROVIDE_INFO:
PRINTF("-- PLUGIN PROVIDE INFO --\n");
((ethPluginProvideInfo_t *) parameter)->result = ETH_PLUGIN_RESULT_UNAVAILABLE;
((ethPluginProvideInfo_t *) parameter)->pluginSharedRW = &pluginRW;
((ethPluginProvideInfo_t *) parameter)->pluginSharedRO = &pluginRO;
((ethPluginProvideInfo_t *) parameter)->txContent = &tmpContent.txContent;
((ethPluginProvideInfo_t *) parameter)->pluginContext =
(uint8_t *) &dataContext.tokenContext.pluginContext;
break;
case ETH_PLUGIN_QUERY_CONTRACT_ID:
PRINTF("-- PLUGIN QUERY CONTRACT ID --\n");
((ethQueryContractID_t *) parameter)->result = ETH_PLUGIN_RESULT_UNAVAILABLE;
((ethQueryContractID_t *) parameter)->pluginSharedRW = &pluginRW;
((ethQueryContractID_t *) parameter)->pluginSharedRO = &pluginRO;
((ethQueryContractID_t *) parameter)->txContent = &tmpContent.txContent;
((ethQueryContractID_t *) parameter)->pluginContext =
(uint8_t *) &dataContext.tokenContext.pluginContext;
break;
case ETH_PLUGIN_QUERY_CONTRACT_UI:
PRINTF("-- PLUGIN QUERY CONTRACT UI --\n");
((ethQueryContractUI_t *) parameter)->pluginSharedRW = &pluginRW;
((ethQueryContractUI_t *) parameter)->pluginSharedRO = &pluginRO;
((ethQueryContractUI_t *) parameter)->txContent = &tmpContent.txContent;
((ethQueryContractUI_t *) parameter)->pluginContext =
(uint8_t *) &dataContext.tokenContext.pluginContext;
break;
Expand Down
5 changes: 2 additions & 3 deletions src_plugins/erc1155/erc1155_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static void handle_finalize(void *parameters) {
erc1155_context_t *context = (erc1155_context_t *) msg->pluginContext;

if (context->selectorIndex != SAFE_BATCH_TRANSFER) {
msg->tokenLookup1 = msg->pluginSharedRO->txContent->destination;
msg->tokenLookup1 = msg->txContent->destination;
} else {
msg->tokenLookup1 = NULL;
}
Expand All @@ -82,8 +82,7 @@ static void handle_finalize(void *parameters) {
return;
}
// Check if some ETH is attached to this tx
if (!allzeroes((void *) &msg->pluginSharedRO->txContent->value,
sizeof(msg->pluginSharedRO->txContent->value))) {
if (!allzeroes((void *) &msg->txContent->value, sizeof(msg->txContent->value))) {
// Those functions are not payable so return an error.
msg->result = ETH_PLUGIN_RESULT_ERROR;
return;
Expand Down
6 changes: 3 additions & 3 deletions src_plugins/erc20/erc20_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void erc20_plugin_call(int message, void *parameters) {
ethPluginInitContract_t *msg = (ethPluginInitContract_t *) parameters;
erc20_parameters_t *context = (erc20_parameters_t *) msg->pluginContext;
// enforce that ETH amount should be 0
if (!allzeroes(msg->pluginSharedRO->txContent->value.value, 32)) {
if (!allzeroes(msg->txContent->value.value, 32)) {
PRINTF("Err: Transaction amount is not 0\n");
msg->result = ETH_PLUGIN_RESULT_ERROR;
} else {
Expand Down Expand Up @@ -129,13 +129,13 @@ void erc20_plugin_call(int message, void *parameters) {
erc20_parameters_t *context = (erc20_parameters_t *) msg->pluginContext;
PRINTF("erc20 plugin finalize\n");
if (context->selectorIndex == ERC20_TRANSFER) {
msg->tokenLookup1 = msg->pluginSharedRO->txContent->destination;
msg->tokenLookup1 = msg->txContent->destination;
msg->amount = context->amount;
msg->address = context->destinationAddress;
msg->uiType = ETH_UI_TYPE_AMOUNT_ADDRESS;
msg->result = ETH_PLUGIN_RESULT_OK;
} else if (context->selectorIndex == ERC20_APPROVE) {
msg->tokenLookup1 = msg->pluginSharedRO->txContent->destination;
msg->tokenLookup1 = msg->txContent->destination;
msg->numScreens = 2;
msg->uiType = ETH_UI_TYPE_GENERIC;
msg->result = ETH_PLUGIN_RESULT_OK;
Expand Down
5 changes: 2 additions & 3 deletions src_plugins/erc721/erc721_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static void handle_finalize(void *parameters) {
ethPluginFinalize_t *msg = (ethPluginFinalize_t *) parameters;
erc721_context_t *context = (erc721_context_t *) msg->pluginContext;

msg->tokenLookup1 = msg->pluginSharedRO->txContent->destination;
msg->tokenLookup1 = msg->txContent->destination;
msg->tokenLookup2 = NULL;
switch (context->selectorIndex) {
case TRANSFER:
Expand All @@ -84,8 +84,7 @@ static void handle_finalize(void *parameters) {
return;
}
// Check if some ETH is attached to this tx
if (!allzeroes((void *) &msg->pluginSharedRO->txContent->value,
sizeof(msg->pluginSharedRO->txContent->value))) {
if (!allzeroes((void *) &msg->txContent->value, sizeof(msg->txContent->value))) {
// Set Approval for All is not payable
if (context->selectorIndex == SET_APPROVAL_FOR_ALL) {
msg->result = ETH_PLUGIN_RESULT_ERROR;
Expand Down
2 changes: 1 addition & 1 deletion src_plugins/eth2/eth2_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void eth2_plugin_call(int message, void *parameters) {
ethPluginInitContract_t *msg = (ethPluginInitContract_t *) parameters;
eth2_deposit_parameters_t *context = (eth2_deposit_parameters_t *) msg->pluginContext;
if (memcmp(deposit_contract_address,
msg->pluginSharedRO->txContent->destination,
msg->txContent->destination,
sizeof(deposit_contract_address)) != 0) {
PRINTF("eth2plugin: failed to check deposit contract\n");
context->valid = 0;
Expand Down
Loading