forked from LedgerHQ/app-plugin-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from adrienlacombe-ledger/develop
clang format and fix tests
- Loading branch information
Showing
9 changed files
with
1,124 additions
and
1,166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,49 @@ | ||
#include "plugin.h" | ||
|
||
void handle_finalize(ethPluginFinalize_t *msg) { | ||
context_t *context = (context_t *)msg->pluginContext; | ||
context_t *context = (context_t *) msg->pluginContext; | ||
|
||
msg->uiType = ETH_UI_TYPE_GENERIC; | ||
msg->uiType = ETH_UI_TYPE_GENERIC; | ||
|
||
// Number of screens needed | ||
msg->numScreens = 2; | ||
// Number of screens needed | ||
msg->numScreens = 2; | ||
|
||
bool sender_is_beneficiary = | ||
memcmp(msg->address, context->beneficiary, ADDRESS_LENGTH) == 0; | ||
bool sender_is_beneficiary = memcmp(msg->address, context->beneficiary, ADDRESS_LENGTH) == 0; | ||
|
||
if (sender_is_beneficiary) { | ||
// No need to show beneficary screen when signer is same as `beneficiary` | ||
bool wrap_tx = | ||
(context->selectorIndex == WRAP || context->selectorIndex == UNWRAP); | ||
bool uniswap_tx = | ||
(context->selectorIndex == UNISWAP_V3_ROUTER_EXACT_INPUT || | ||
context->selectorIndex == UNISWAP_ROUTER_EXACT_INPUT_SINGLE); | ||
if (sender_is_beneficiary) { | ||
// No need to show beneficary screen when signer is same as `beneficiary` | ||
bool wrap_tx = (context->selectorIndex == WRAP || context->selectorIndex == UNWRAP); | ||
bool uniswap_tx = (context->selectorIndex == UNISWAP_V3_ROUTER_EXACT_INPUT || | ||
context->selectorIndex == UNISWAP_ROUTER_EXACT_INPUT_SINGLE); | ||
|
||
if (wrap_tx) { | ||
msg->numScreens -= 1; | ||
} else if (uniswap_tx) { | ||
msg->numScreens += 1; | ||
if (wrap_tx) { | ||
msg->numScreens -= 1; | ||
} else if (uniswap_tx) { | ||
msg->numScreens += 1; | ||
} | ||
} | ||
if (!ADDRESS_IS_NETWORK_TOKEN(context->contract_address_sent)) { | ||
// Address is not network token (0xeee...) so we will need to look up the | ||
// token in the CAL. | ||
printf_hex_array("Setting address sent to: ", | ||
ADDRESS_LENGTH, | ||
context->contract_address_sent); | ||
msg->tokenLookup1 = context->contract_address_sent; | ||
} else { | ||
sent_network_token(context); | ||
msg->tokenLookup1 = NULL; | ||
} | ||
if (!ADDRESS_IS_NETWORK_TOKEN(context->contract_address_received)) { | ||
// Address is not network token (0xeee...) so we will need to look up the | ||
// token in the CAL. | ||
printf_hex_array("Setting address received to: ", | ||
ADDRESS_LENGTH, | ||
context->contract_address_received); | ||
msg->tokenLookup2 = context->contract_address_received; | ||
} else { | ||
received_network_token(context); | ||
msg->tokenLookup2 = NULL; | ||
} | ||
} | ||
if (!ADDRESS_IS_NETWORK_TOKEN(context->contract_address_sent)) { | ||
// Address is not network token (0xeee...) so we will need to look up the | ||
// token in the CAL. | ||
printf_hex_array("Setting address sent to: ", ADDRESS_LENGTH, | ||
context->contract_address_sent); | ||
msg->tokenLookup1 = context->contract_address_sent; | ||
} else { | ||
sent_network_token(context); | ||
msg->tokenLookup1 = NULL; | ||
} | ||
if (!ADDRESS_IS_NETWORK_TOKEN(context->contract_address_received)) { | ||
// Address is not network token (0xeee...) so we will need to look up the | ||
// token in the CAL. | ||
printf_hex_array("Setting address received to: ", ADDRESS_LENGTH, | ||
context->contract_address_received); | ||
msg->tokenLookup2 = context->contract_address_received; | ||
} else { | ||
received_network_token(context); | ||
msg->tokenLookup2 = NULL; | ||
} | ||
|
||
msg->result = ETH_PLUGIN_RESULT_OK; | ||
msg->result = ETH_PLUGIN_RESULT_OK; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.