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