[clean] Linting pass

This commit is contained in:
Alexandre Paillier
2022-01-14 17:32:17 +01:00
parent 8fd033e32a
commit eb531de5d2
13 changed files with 65 additions and 74 deletions

View File

@@ -133,7 +133,7 @@ eth_plugin_result_t eth_plugin_perform_init(uint8_t *contractAddress,
#ifdef HAVE_NFT_SUPPORT
case ERC1155:
case ERC721:
#endif // HAVE_NFT_SUPPORT
#endif // HAVE_NFT_SUPPORT
case EXTERNAL:
eth_plugin_perform_init_default(contractAddress, init);
contractAddress = NULL;
@@ -277,7 +277,7 @@ eth_plugin_result_t eth_plugin_call(int method, void *parameter) {
erc1155_plugin_call(method, parameter);
break;
}
#endif // HAVE_NFT_SUPPORT
#endif // HAVE_NFT_SUPPORT
case OLD_INTERNAL: {
// Perform the call
for (i = 0;; i++) {

View File

@@ -528,7 +528,7 @@ void handleApdu(unsigned int *flags, unsigned int *tx) {
flags,
tx);
break;
#endif // HAVE_NFT_SUPPORT
#endif // HAVE_NFT_SUPPORT
case INS_SET_EXTERNAL_PLUGIN:
handleSetExternalPlugin(G_io_apdu_buffer[OFFSET_P1],

View File

@@ -204,10 +204,10 @@ extern const internalStorage_t N_storage_real;
extern bool called_from_swap;
typedef enum {
EXTERNAL, // External plugin, set by setExternalPlugin.
ERC721, // Specific ERC721 internal plugin, set by setPlugin.
ERC1155, // Specific ERC1155 internal plugin, set by setPlugin
OLD_INTERNAL // Old internal plugin, not set by any command.
EXTERNAL, // External plugin, set by setExternalPlugin.
ERC721, // Specific ERC721 internal plugin, set by setPlugin.
ERC1155, // Specific ERC1155 internal plugin, set by setPlugin
OLD_INTERNAL // Old internal plugin, not set by any command.
} pluginType_t;
extern pluginType_t pluginType;

View File

@@ -18,8 +18,8 @@
#define MIN_DER_SIG_SIZE 67
#define MAX_DER_SIG_SIZE 72
#define TEST_NFT_METADATA_KEY 0
#define PROD_NFT_METADATA_KEY 1
#define TEST_NFT_METADATA_KEY 0
#define PROD_NFT_METADATA_KEY 1
#define ALGORITHM_ID_1 1
@@ -29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x0f, 0x5a, 0x02, 0xa1, 0x1a, 0x3a, 0xb9, 0x9d, 0x5f, 0x59, 0x5a, 0x3d,
0x50, 0xa0, 0xe1, 0x30, 0x23, 0xfd, 0x0d, 0x95, 0x87, 0x92, 0xd7, 0x97, 0x01
0x04, 0x98, 0x8d, 0xa6, 0xb2, 0x46, 0xf2, 0x8e, 0x77, 0xc1, 0xba, 0xb6, 0x75, 0xcb,
0x2a, 0x27, 0x44, 0xf7, 0xf5, 0xce, 0xc5, 0x6a, 0xe6, 0xe0, 0x32, 0x23, 0x33, 0x7b,
0x57, 0x94, 0xcd, 0x6a, 0xe0, 0x7d, 0x48, 0xb3, 0x0d, 0xb9, 0xcc, 0xb4, 0x0f, 0x5a,
0x02, 0xa1, 0x1a, 0x3a, 0xb9, 0x9d, 0x5f, 0x59, 0x5a, 0x3d, 0x50, 0xa0, 0xe1, 0x30,
0x23, 0xfd, 0x0d, 0x95, 0x87, 0x92, 0xd7, 0x97, 0x01
#endif
};
@@ -176,7 +176,7 @@ void handleProvideNFTInformation(uint8_t p1,
switch (algorithmId) {
case ALGORITHM_ID_1:
curve = CX_CURVE_256K1;
verificationFn = (verificationAlgo*)cx_ecdsa_verify;
verificationFn = (verificationAlgo *) cx_ecdsa_verify;
hashId = CX_SHA256;
break;
default:
@@ -227,4 +227,4 @@ void handleProvideNFTInformation(uint8_t p1,
THROW(0x9000);
}
#endif // HAVE_NFT_SUPPORT
#endif // HAVE_NFT_SUPPORT

View File

@@ -46,17 +46,17 @@ typedef enum AlgorithmID {
// Only used for signing NFT plugins (ERC721 and ERC1155)
static const uint8_t LEDGER_NFT_SELECTOR_PUBLIC_KEY[] = {
#ifdef HAVE_NFT_TESTING_KEY
0x04, 0xf5, 0x70, 0x0c, 0xa1, 0xe8, 0x74, 0x24, 0xc7, 0xc7, 0xd1, 0x19, 0xe7,
0xe3, 0xc1, 0x89, 0xb1, 0x62, 0x50, 0x94, 0xdb, 0x6e, 0xa0, 0x40, 0x87, 0xc8,
0x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9a, 0x1c, 0xda, 0xc4, 0x93, 0x90, 0x08, 0xbc, 0x79, 0x77, 0x33, 0x6d,
0x78, 0x24, 0xee, 0xe3, 0xa2, 0x62, 0x24, 0x1a, 0x62, 0x73, 0x52, 0x3b, 0x09, 0xb8,
0xd0, 0xce, 0x0d, 0x39, 0xe8, 0x60, 0xc9, 0x4d, 0x02, 0x53, 0x58, 0xdb, 0xdc, 0x25,
0x92, 0xc7, 0xc6, 0x48, 0x0d, 0x39, 0xce, 0xbb, 0xa3
#endif
};
@@ -209,7 +209,7 @@ void handleSetPlugin(uint8_t p1,
switch (algorithmId) {
case ECC_SECG_P256K1__ECDSA_SHA_256:
curve = CX_CURVE_256K1;
verificationFn = (verificationAlgo*)cx_ecdsa_verify;
verificationFn = (verificationAlgo *) cx_ecdsa_verify;
hashId = CX_SHA256;
break;
default:

View File

@@ -139,4 +139,4 @@ void erc1155_plugin_call(int message, void *parameters) {
}
}
#endif // HAVE_NFT_SUPPORT
#endif // HAVE_NFT_SUPPORT

View File

@@ -34,9 +34,9 @@ typedef enum {
} erc1155_selector_field;
typedef struct erc1155_context_t {
uint8_t address[ADDRESS_LENGTH];
uint8_t tokenId[INT256_LENGTH];
uint256_t value;
uint8_t address[ADDRESS_LENGTH];
uint8_t tokenId[INT256_LENGTH];
uint256_t value;
uint16_t ids_array_len;
uint32_t ids_offset;
@@ -52,4 +52,4 @@ typedef struct erc1155_context_t {
void handle_provide_parameter_1155(void *parameters);
void handle_query_contract_ui_1155(void *parameters);
#endif // HAVE_NFT_SUPPORT
#endif // HAVE_NFT_SUPPORT

View File

@@ -30,7 +30,7 @@ static void handle_safe_transfer(ethPluginProvideParameter_t *msg, erc1155_conte
}
static void handle_batch_transfer(ethPluginProvideParameter_t *msg, erc1155_context_t *context) {
uint256_t new_value;
uint256_t new_value;
switch (context->next_param) {
case FROM:
@@ -41,23 +41,19 @@ static void handle_batch_transfer(ethPluginProvideParameter_t *msg, erc1155_cont
context->next_param = TOKEN_IDS_OFFSET;
break;
case TOKEN_IDS_OFFSET:
context->ids_offset = \
U4BE(msg->parameter,
PARAMETER_LENGTH - sizeof(context->ids_offset)) + 4;
context->ids_offset =
U4BE(msg->parameter, PARAMETER_LENGTH - sizeof(context->ids_offset)) + 4;
context->next_param = VALUE_OFFSET;
break;
case VALUE_OFFSET:
context->values_offset = \
U4BE(msg->parameter,
PARAMETER_LENGTH - sizeof(context->values_offset)) + 4;
context->values_offset =
U4BE(msg->parameter, PARAMETER_LENGTH - sizeof(context->values_offset)) + 4;
context->next_param = TOKEN_IDS_LENGTH;
break;
case TOKEN_IDS_LENGTH:
if ((msg->parameterOffset + PARAMETER_LENGTH) > context->ids_offset)
{
context->ids_array_len = \
U2BE(msg->parameter,
PARAMETER_LENGTH - sizeof(context->ids_array_len));
if ((msg->parameterOffset + PARAMETER_LENGTH) > context->ids_offset) {
context->ids_array_len =
U2BE(msg->parameter, PARAMETER_LENGTH - sizeof(context->ids_array_len));
context->next_param = TOKEN_ID;
// set to zero for next step
context->array_index = 0;
@@ -65,20 +61,16 @@ static void handle_batch_transfer(ethPluginProvideParameter_t *msg, erc1155_cont
break;
case TOKEN_ID:
// don't copy anything since we won't display it
if (--context->ids_array_len == 0)
{
if (--context->ids_array_len == 0) {
context->next_param = VALUE_LENGTH;
}
context->array_index++;
break;
case VALUE_LENGTH:
if ((msg->parameterOffset + PARAMETER_LENGTH) > context->values_offset)
{
context->values_array_len = \
U2BE(msg->parameter,
PARAMETER_LENGTH - sizeof(context->values_array_len));
if (context->values_array_len != context->array_index)
{
if ((msg->parameterOffset + PARAMETER_LENGTH) > context->values_offset) {
context->values_array_len =
U2BE(msg->parameter, PARAMETER_LENGTH - sizeof(context->values_array_len));
if (context->values_array_len != context->array_index) {
PRINTF("Token ids and values array sizes mismatch!");
}
context->next_param = VALUE;
@@ -92,8 +84,7 @@ static void handle_batch_transfer(ethPluginProvideParameter_t *msg, erc1155_cont
copy_parameter(context->tokenId, msg->parameter, sizeof(context->value));
convertUint256BE(context->tokenId, sizeof(context->tokenId), &new_value);
add256(&context->value, &new_value, &context->value);
if (--context->values_array_len == 0)
{
if (--context->values_array_len == 0) {
context->next_param = NONE;
}
context->array_index++;
@@ -132,10 +123,10 @@ void handle_provide_parameter_1155(void *parameters) {
msg->result = ETH_PLUGIN_RESULT_SUCCESSFUL;
//if (context->targetOffset > SELECTOR_SIZE &&
// context->targetOffset != msg->parameterOffset - SELECTOR_SIZE) {
// return;
//}
// if (context->targetOffset > SELECTOR_SIZE &&
// context->targetOffset != msg->parameterOffset - SELECTOR_SIZE) {
// return;
// }
switch (context->selectorIndex) {
case SAFE_TRANSFER:
handle_safe_transfer(msg, context);
@@ -153,4 +144,4 @@ void handle_provide_parameter_1155(void *parameters) {
}
}
#endif // HAVE_NFT_SUPPORT
#endif // HAVE_NFT_SUPPORT

View File

@@ -59,7 +59,7 @@ static void set_transfer_ui(ethQueryContractUI_t *msg, erc1155_context_t *contex
break;
case 2:
strlcpy(msg->title, "NFT Address", msg->titleLength);
getEthDisplayableAddress((uint8_t *)msg->item1->nft.contractAddress,
getEthDisplayableAddress((uint8_t *) msg->item1->nft.contractAddress,
msg->msg,
msg->msgLength,
&global_sha3,
@@ -84,7 +84,7 @@ static void set_transfer_ui(ethQueryContractUI_t *msg, erc1155_context_t *contex
}
static void set_batch_transfer_ui(ethQueryContractUI_t *msg, erc1155_context_t *context) {
char quantity_str[48];
char quantity_str[48];
switch (msg->screenIndex) {
case 0:
@@ -105,7 +105,7 @@ static void set_batch_transfer_ui(ethQueryContractUI_t *msg, erc1155_context_t *
break;
case 2:
strlcpy(msg->title, "NFT Address", msg->titleLength);
getEthDisplayableAddress((uint8_t *)msg->item1->nft.contractAddress,
getEthDisplayableAddress((uint8_t *) msg->item1->nft.contractAddress,
msg->msg,
msg->msgLength,
&global_sha3,
@@ -149,4 +149,4 @@ void handle_query_contract_ui_1155(void *parameters) {
}
}
#endif // HAVE_NFT_SUPPORT
#endif // HAVE_NFT_SUPPORT

View File

@@ -147,4 +147,4 @@ void erc721_plugin_call(int message, void *parameters) {
}
}
#endif // HAVE_NFT_SUPPORT
#endif // HAVE_NFT_SUPPORT

View File

@@ -43,4 +43,4 @@ typedef struct erc721_context_t {
void handle_provide_parameter_721(void *parameters);
void handle_query_contract_ui_721(void *parameters);
#endif // HAVE_NFT_SUPPORT
#endif // HAVE_NFT_SUPPORT

View File

@@ -94,4 +94,4 @@ void handle_provide_parameter_721(void *parameters) {
}
}
#endif // HAVE_NFT_SUPPORT
#endif // HAVE_NFT_SUPPORT

View File

@@ -115,7 +115,7 @@ static void set_transfer_ui(ethQueryContractUI_t *msg, erc721_context_t *context
break;
case 2:
strlcpy(msg->title, "NFT Address", msg->titleLength);
getEthDisplayableAddress((uint8_t *)msg->item1->nft.contractAddress,
getEthDisplayableAddress((uint8_t *) msg->item1->nft.contractAddress,
msg->msg,
msg->msgLength,
&global_sha3,
@@ -167,4 +167,4 @@ void handle_query_contract_ui_721(void *parameters) {
}
}
#endif // HAVE_NFT_SUPPORT
#endif // HAVE_NFT_SUPPORT