Merge pull request #449 from LedgerHQ/tdj/eth_plugin_sdk_update
Update plugins SDK framework
This commit is contained in:
@@ -53,10 +53,12 @@ int handle_check_address(check_address_parameters_t* params, chain_config_t* cha
|
||||
ZERO(locals_union2);
|
||||
cx_ecfp_generate_pair(CX_CURVE_256K1, &locals_union2.publicKey, &locals_union1.privateKey, 1);
|
||||
ZERO(locals_union1);
|
||||
getEthAddressStringFromKey(&locals_union2.publicKey,
|
||||
locals_union1.address,
|
||||
&local_sha3,
|
||||
chain_config->chainId);
|
||||
if (!getEthAddressStringFromKey(&locals_union2.publicKey,
|
||||
locals_union1.address,
|
||||
&local_sha3,
|
||||
chain_config->chainId)) {
|
||||
THROW(CX_INVALID_PARAMETER);
|
||||
}
|
||||
ZERO(locals_union2);
|
||||
|
||||
uint8_t offset_0x = 0;
|
||||
|
||||
@@ -33,11 +33,13 @@ int handle_get_printable_amount(get_printable_amount_parameters_t* params, chain
|
||||
}
|
||||
}
|
||||
|
||||
amountToString(params->amount,
|
||||
params->amount_length,
|
||||
decimals,
|
||||
ticker,
|
||||
params->printable_amount,
|
||||
sizeof(params->printable_amount));
|
||||
if (!amountToString(params->amount,
|
||||
params->amount_length,
|
||||
decimals,
|
||||
ticker,
|
||||
params->printable_amount,
|
||||
sizeof(params->printable_amount))) {
|
||||
THROW(EXCEPTION_OVERFLOW);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -35,22 +35,26 @@ bool copy_transaction_parameters(create_transaction_parameters_t* sign_transacti
|
||||
PRINTF("Error while parsing config\n");
|
||||
return false;
|
||||
}
|
||||
amountToString(sign_transaction_params->amount,
|
||||
sign_transaction_params->amount_length,
|
||||
decimals,
|
||||
ticker,
|
||||
stack_data.fullAmount,
|
||||
sizeof(stack_data.fullAmount));
|
||||
if (!amountToString(sign_transaction_params->amount,
|
||||
sign_transaction_params->amount_length,
|
||||
decimals,
|
||||
ticker,
|
||||
stack_data.fullAmount,
|
||||
sizeof(stack_data.fullAmount))) {
|
||||
THROW(EXCEPTION_OVERFLOW);
|
||||
}
|
||||
|
||||
// If the amount is a fee, its value is nominated in ETH even if we're doing an ERC20 swap
|
||||
strlcpy(ticker, config->coinName, MAX_TICKER_LEN);
|
||||
decimals = WEI_TO_ETHER;
|
||||
amountToString(sign_transaction_params->fee_amount,
|
||||
sign_transaction_params->fee_amount_length,
|
||||
decimals,
|
||||
ticker,
|
||||
stack_data.maxFee,
|
||||
sizeof(stack_data.maxFee));
|
||||
if (!amountToString(sign_transaction_params->fee_amount,
|
||||
sign_transaction_params->fee_amount_length,
|
||||
decimals,
|
||||
ticker,
|
||||
stack_data.maxFee,
|
||||
sizeof(stack_data.maxFee))) {
|
||||
THROW(EXCEPTION_OVERFLOW);
|
||||
}
|
||||
|
||||
// Full reset the global variables
|
||||
os_explicit_zero_BSS_segment();
|
||||
|
||||
@@ -116,7 +116,7 @@ bool uint256_to_decimal(const uint8_t *value, size_t value_len, char *out, size_
|
||||
return true;
|
||||
}
|
||||
|
||||
void amountToString(const uint8_t *amount,
|
||||
bool amountToString(const uint8_t *amount,
|
||||
uint8_t amount_size,
|
||||
uint8_t decimals,
|
||||
const char *ticker,
|
||||
@@ -125,7 +125,7 @@ void amountToString(const uint8_t *amount,
|
||||
char tmp_buffer[100] = {0};
|
||||
|
||||
if (uint256_to_decimal(amount, amount_size, tmp_buffer, sizeof(tmp_buffer)) == false) {
|
||||
THROW(EXCEPTION_OVERFLOW);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t amount_len = strnlen(tmp_buffer, sizeof(tmp_buffer));
|
||||
@@ -141,10 +141,11 @@ void amountToString(const uint8_t *amount,
|
||||
out_buffer + ticker_len,
|
||||
out_buffer_size - ticker_len - 1,
|
||||
decimals) == false) {
|
||||
THROW(EXCEPTION_OVERFLOW);
|
||||
return false;
|
||||
}
|
||||
|
||||
out_buffer[out_buffer_size - 1] = '\0';
|
||||
return true;
|
||||
}
|
||||
|
||||
bool parse_swap_config(const uint8_t *config, uint8_t config_len, char *ticker, uint8_t *decimals) {
|
||||
|
||||
@@ -34,7 +34,7 @@ uint64_t u64_from_BE(const uint8_t* in, uint8_t size);
|
||||
|
||||
bool uint256_to_decimal(const uint8_t* value, size_t value_len, char* out, size_t out_len);
|
||||
|
||||
void amountToString(const uint8_t* amount,
|
||||
bool amountToString(const uint8_t* amount,
|
||||
uint8_t amount_len,
|
||||
uint8_t decimals,
|
||||
const char* ticker,
|
||||
|
||||
Reference in New Issue
Block a user