Update some prototypes to use chainId value instead of chainConfig structure
This commit is contained in:
@@ -61,7 +61,7 @@ int handle_check_address(check_address_parameters_t* params, chain_config_t* cha
|
||||
getEthAddressStringFromKey(&locals_union2.publicKey,
|
||||
locals_union1.address,
|
||||
&local_sha3,
|
||||
chain_config);
|
||||
chain_config->chainId);
|
||||
ZERO(locals_union2);
|
||||
|
||||
uint8_t offset_0x = 0;
|
||||
|
||||
@@ -126,11 +126,11 @@ void getEthAddressFromKey(cx_ecfp_public_key_t *publicKey, uint8_t *out, cx_sha3
|
||||
void getEthAddressStringFromKey(cx_ecfp_public_key_t *publicKey,
|
||||
char *out,
|
||||
cx_sha3_t *sha3Context,
|
||||
chain_config_t *chain_config) {
|
||||
uint64_t chainId) {
|
||||
uint8_t hashAddress[INT256_LENGTH];
|
||||
cx_keccak_init(sha3Context, 256);
|
||||
cx_hash((cx_hash_t *) sha3Context, CX_LAST, publicKey->W + 1, 64, hashAddress, 32);
|
||||
getEthAddressStringFromBinary(hashAddress + 12, out, sha3Context, chain_config);
|
||||
getEthAddressStringFromBinary(hashAddress + 12, out, sha3Context, chainId);
|
||||
}
|
||||
|
||||
void u64_to_string(uint64_t src, char *dst, uint8_t dst_size) {
|
||||
@@ -164,7 +164,7 @@ void u64_to_string(uint64_t src, char *dst, uint8_t dst_size) {
|
||||
void getEthAddressStringFromBinary(uint8_t *address,
|
||||
char *out,
|
||||
cx_sha3_t *sha3Context,
|
||||
chain_config_t *chain_config) {
|
||||
uint64_t chainId) {
|
||||
// save some precious stack space
|
||||
union locals_union {
|
||||
uint8_t hashChecksum[INT256_LENGTH];
|
||||
@@ -174,14 +174,14 @@ void getEthAddressStringFromBinary(uint8_t *address,
|
||||
uint8_t i;
|
||||
bool eip1191 = false;
|
||||
uint32_t offset = 0;
|
||||
switch (chain_config->chainId) {
|
||||
switch (chainId) {
|
||||
case 30:
|
||||
case 31:
|
||||
eip1191 = true;
|
||||
break;
|
||||
}
|
||||
if (eip1191) {
|
||||
u64_to_string(chain_config->chainId, (char *) locals_union.tmp, sizeof(locals_union.tmp));
|
||||
u64_to_string(chainId, (char *) locals_union.tmp, sizeof(locals_union.tmp));
|
||||
offset = strnlen((char *) locals_union.tmp, sizeof(locals_union.tmp));
|
||||
strlcat((char *) locals_union.tmp + offset, "0x", sizeof(locals_union.tmp) - offset);
|
||||
offset = strnlen((char *) locals_union.tmp, sizeof(locals_union.tmp));
|
||||
@@ -219,22 +219,22 @@ void getEthAddressStringFromBinary(uint8_t *address,
|
||||
out[40] = '\0';
|
||||
}
|
||||
|
||||
// Fills the `out` buffer with the lowercase string representation of the pubkey passed in as binary
|
||||
// format by `in`. (eg: uint8_t*:0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB ->
|
||||
// char*:"0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB\0" ) `sha3` context doesn't have have to be
|
||||
// initialized prior to call. `chain_config` must be initialized.
|
||||
/* Fills the `out` buffer with the lowercase string representation of the pubkey passed in as binary
|
||||
format by `in`. (eg: uint8_t*:0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB ->
|
||||
char*:"0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB\0" )
|
||||
`sha3` context doesn't have have to be initialized prior to call.*/
|
||||
void getEthDisplayableAddress(uint8_t *in,
|
||||
char *out,
|
||||
size_t out_len,
|
||||
cx_sha3_t *sha3,
|
||||
chain_config_t *chain_config) {
|
||||
uint64_t chainId) {
|
||||
if (out_len < 43) {
|
||||
strlcpy(out, "ERROR", out_len);
|
||||
return;
|
||||
}
|
||||
out[0] = '0';
|
||||
out[1] = 'x';
|
||||
getEthAddressStringFromBinary(in, out + 2, sha3, chain_config);
|
||||
getEthAddressStringFromBinary(in, out + 2, sha3, chainId);
|
||||
}
|
||||
|
||||
bool adjustDecimals(char *src,
|
||||
|
||||
@@ -42,20 +42,20 @@ void getEthAddressFromKey(cx_ecfp_public_key_t *publicKey, uint8_t *out, cx_sha3
|
||||
void getEthAddressStringFromKey(cx_ecfp_public_key_t *publicKey,
|
||||
char *out,
|
||||
cx_sha3_t *sha3Context,
|
||||
chain_config_t *chain_config);
|
||||
uint64_t chainId);
|
||||
|
||||
void u64_to_string(uint64_t src, char *dst, uint8_t dst_size);
|
||||
|
||||
void getEthAddressStringFromBinary(uint8_t *address,
|
||||
char *out,
|
||||
cx_sha3_t *sha3Context,
|
||||
chain_config_t *chain_config);
|
||||
uint64_t chainId);
|
||||
|
||||
void getEthDisplayableAddress(uint8_t *in,
|
||||
char *out,
|
||||
size_t out_len,
|
||||
cx_sha3_t *sha3,
|
||||
chain_config_t *chain_config);
|
||||
uint64_t chainId);
|
||||
|
||||
bool adjustDecimals(char *src,
|
||||
uint32_t srcLength,
|
||||
|
||||
@@ -50,7 +50,7 @@ void handleGetPublicKey(uint8_t p1,
|
||||
getEthAddressStringFromKey(&tmpCtx.publicKeyContext.publicKey,
|
||||
tmpCtx.publicKeyContext.address,
|
||||
&global_sha3,
|
||||
chainConfig);
|
||||
chainConfig->chainId);
|
||||
#ifndef NO_CONSENT
|
||||
if (p1 == P1_NON_CONFIRM)
|
||||
#endif // NO_CONSENT
|
||||
|
||||
@@ -419,7 +419,7 @@ void finalizeParsing(bool direct) {
|
||||
displayBuffer,
|
||||
sizeof(displayBuffer),
|
||||
&global_sha3,
|
||||
chainConfig);
|
||||
chainConfig->chainId);
|
||||
compareOrCopy(strings.common.fullAddress,
|
||||
sizeof(strings.common.fullAddress),
|
||||
displayBuffer,
|
||||
|
||||
@@ -183,7 +183,7 @@ UX_STEP_NOCB_INIT(
|
||||
strings.tmp.tmp,
|
||||
sizeof(strings.tmp.tmp),
|
||||
&global_sha3,
|
||||
chainConfig),
|
||||
chainConfig->chainId),
|
||||
{
|
||||
.title = "Cond. Address",
|
||||
.text = strings.tmp.tmp
|
||||
|
||||
@@ -216,7 +216,7 @@ void erc20_plugin_call(int message, void *parameters) {
|
||||
msg->msg,
|
||||
msg->msgLength,
|
||||
msg->pluginSharedRW->sha3,
|
||||
chainConfig);
|
||||
chainConfig->chainId);
|
||||
}
|
||||
|
||||
msg->result = ETH_PLUGIN_RESULT_OK;
|
||||
|
||||
@@ -5,12 +5,6 @@
|
||||
#include "ethUtils.h"
|
||||
#include "utils.h"
|
||||
|
||||
void getEthDisplayableAddress(uint8_t *in,
|
||||
char *out,
|
||||
size_t out_len,
|
||||
cx_sha3_t *sha3,
|
||||
chain_config_t *chain_config);
|
||||
|
||||
typedef struct erc721_parameters_t {
|
||||
uint8_t selectorIndex;
|
||||
uint8_t address[ADDRESS_LENGTH];
|
||||
@@ -126,7 +120,7 @@ void erc721_plugin_call(int message, void *parameters) {
|
||||
msg->msg,
|
||||
msg->msgLength,
|
||||
&global_sha3,
|
||||
chainConfig);
|
||||
chainConfig->chainId);
|
||||
msg->result = ETH_PLUGIN_RESULT_OK;
|
||||
break;
|
||||
|
||||
@@ -136,7 +130,7 @@ void erc721_plugin_call(int message, void *parameters) {
|
||||
msg->msg,
|
||||
msg->msgLength,
|
||||
&global_sha3,
|
||||
chainConfig);
|
||||
chainConfig->chainId);
|
||||
msg->result = ETH_PLUGIN_RESULT_OK;
|
||||
break;
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ void eth2_plugin_call(int message, void *parameters) {
|
||||
tmp,
|
||||
sizeof(tmp),
|
||||
msg->pluginSharedRW->sha3,
|
||||
chainConfig);
|
||||
chainConfig->chainId);
|
||||
|
||||
// Copy back the string to the global variable.
|
||||
strlcpy(context->deposit_address, tmp, ETH2_DEPOSIT_PUBKEY_LENGTH);
|
||||
|
||||
@@ -340,7 +340,7 @@ void starkware_print_asset_contract(char *destination, size_t destinationLength)
|
||||
destination,
|
||||
destinationLength,
|
||||
&global_sha3,
|
||||
chainConfig);
|
||||
chainConfig->chainId);
|
||||
} else {
|
||||
strlcpy(destination, "UNKNOWN", destinationLength);
|
||||
}
|
||||
@@ -364,7 +364,7 @@ void starkware_get_source_address(char *destination) {
|
||||
io_seproxyhal_io_heartbeat();
|
||||
destination[0] = '0';
|
||||
destination[1] = 'x';
|
||||
getEthAddressStringFromKey(&publicKey, destination + 2, &global_sha3, chainConfig);
|
||||
getEthAddressStringFromKey(&publicKey, destination + 2, &global_sha3, chainConfig->chainId);
|
||||
destination[42] = '\0';
|
||||
}
|
||||
|
||||
@@ -704,7 +704,7 @@ void starkware_plugin_call(int message, void *parameters) {
|
||||
msg->msg,
|
||||
msg->msgLength,
|
||||
&global_sha3,
|
||||
chainConfig);
|
||||
chainConfig->chainId);
|
||||
}
|
||||
msg->result = ETH_PLUGIN_RESULT_OK;
|
||||
break;
|
||||
@@ -718,7 +718,7 @@ void starkware_plugin_call(int message, void *parameters) {
|
||||
msg->msg,
|
||||
msg->msgLength,
|
||||
&global_sha3,
|
||||
chainConfig);
|
||||
chainConfig->chainId);
|
||||
break;
|
||||
case STARKWARE_ESCAPE:
|
||||
strlcpy(msg->title, "Amount", msg->titleLength);
|
||||
@@ -786,7 +786,7 @@ void starkware_plugin_call(int message, void *parameters) {
|
||||
msg->msg,
|
||||
msg->msgLength,
|
||||
&global_sha3,
|
||||
chainConfig);
|
||||
chainConfig->chainId);
|
||||
break;
|
||||
case STARKWARE_WITHDRAW_AND_MINT:
|
||||
strlcpy(msg->title, "Asset Contract", msg->titleLength);
|
||||
|
||||
Reference in New Issue
Block a user