Skip to content

Commit

Permalink
chore (app): Remove unreliable details from txn meta
Browse files Browse the repository at this point in the history
  • Loading branch information
Ujjwal0501 committed Sep 22, 2023
1 parent decb0cb commit 83a44e8
Show file tree
Hide file tree
Showing 21 changed files with 715 additions and 539 deletions.
25 changes: 23 additions & 2 deletions apps/evm_family/arbitrum/arbitrum_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,20 @@ extern const erc20_contracts_t arbitrum_contracts[];
* STATIC FUNCTION PROTOTYPES
*****************************************************************************/

/**
* @brief Checks if the provided token address is whitelisted and return the
* matching contract instance.
*
* @param address Reference to the buffer containing the token address
* @param contract Pointer to store the matched contract address instance
*
* @return bool Indicating if the provided token address is whitelisted
* @return true If the address matches to an entry in the whitelist
* @return false If the address does not match to an entry in the whitelist
*/
static bool is_token_whitelisted(const uint8_t *address,
const erc20_contracts_t **contract);

/*****************************************************************************
* STATIC VARIABLES
*****************************************************************************/
Expand All @@ -102,8 +116,7 @@ static const evm_config_t arbitrum_app_config = {
.chain_id = 42161,

// whitelisted contracts
.whitelisted_contracts = NULL,
.whitelist_count = ARBITRUM_WHITELISTED_CONTRACTS_COUNT,
.is_token_whitelisted = is_token_whitelisted,
};

static const cy_app_desc_t arbitrum_app_desc = {
Expand All @@ -124,6 +137,14 @@ static const cy_app_desc_t arbitrum_app_desc = {
* STATIC FUNCTIONS
*****************************************************************************/

static bool is_token_whitelisted(const uint8_t *address,
const erc20_contracts_t **contract) {
if (NULL != contract) {
*contract = NULL;
}
return false;
}

/*****************************************************************************
* GLOBAL FUNCTIONS
*****************************************************************************/
Expand Down
25 changes: 23 additions & 2 deletions apps/evm_family/avalanche/avalanche_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,20 @@ extern const erc20_contracts_t avalanche_contracts[];
* STATIC FUNCTION PROTOTYPES
*****************************************************************************/

/**
* @brief Checks if the provided token address is whitelisted and return the
* matching contract instance.
*
* @param address Reference to the buffer containing the token address
* @param contract Pointer to store the matched contract address instance
*
* @return bool Indicating if the provided token address is whitelisted
* @return true If the address matches to an entry in the whitelist
* @return false If the address does not match to an entry in the whitelist
*/
static bool is_token_whitelisted(const uint8_t *address,
const erc20_contracts_t **contract);

/*****************************************************************************
* STATIC VARIABLES
*****************************************************************************/
Expand All @@ -102,8 +116,7 @@ static const evm_config_t avalanche_app_config = {
.chain_id = 43114,

// whitelisted contracts
.whitelisted_contracts = NULL,
.whitelist_count = AVALANCHE_WHITELISTED_CONTRACTS_COUNT,
.is_token_whitelisted = is_token_whitelisted,
};

static const cy_app_desc_t avalanche_app_desc = {
Expand All @@ -125,6 +138,14 @@ static const cy_app_desc_t avalanche_app_desc = {
* STATIC FUNCTIONS
*****************************************************************************/

static bool is_token_whitelisted(const uint8_t *address,
const erc20_contracts_t **contract) {
if (NULL != contract) {
*contract = NULL;
}
return false;
}

/*****************************************************************************
* GLOBAL FUNCTIONS
*****************************************************************************/
Expand Down
25 changes: 23 additions & 2 deletions apps/evm_family/bsc/bsc_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,20 @@ extern const erc20_contracts_t bsc_contracts[];
* STATIC FUNCTION PROTOTYPES
*****************************************************************************/

/**
* @brief Checks if the provided token address is whitelisted and return the
* matching contract instance.
*
* @param address Reference to the buffer containing the token address
* @param contract Pointer to store the matched contract address instance
*
* @return bool Indicating if the provided token address is whitelisted
* @return true If the address matches to an entry in the whitelist
* @return false If the address does not match to an entry in the whitelist
*/
static bool is_token_whitelisted(const uint8_t *address,
const erc20_contracts_t **contract);

/*****************************************************************************
* STATIC VARIABLES
*****************************************************************************/
Expand All @@ -102,8 +116,7 @@ static const evm_config_t bsc_app_config = {
.chain_id = 56,

// whitelisted contracts
.whitelisted_contracts = NULL,
.whitelist_count = BSC_WHITELISTED_CONTRACTS_COUNT,
.is_token_whitelisted = is_token_whitelisted,
};

static const cy_app_desc_t bsc_app_desc = {.id = 11,
Expand All @@ -124,6 +137,14 @@ static const cy_app_desc_t bsc_app_desc = {.id = 11,
* STATIC FUNCTIONS
*****************************************************************************/

static bool is_token_whitelisted(const uint8_t *address,
const erc20_contracts_t **contract) {
if (NULL != contract) {
*contract = NULL;
}
return false;
}

/*****************************************************************************
* GLOBAL FUNCTIONS
*****************************************************************************/
Expand Down
36 changes: 33 additions & 3 deletions apps/evm_family/eth/eth_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,20 @@ extern const erc20_contracts_t eth_contracts[];
* STATIC FUNCTION PROTOTYPES
*****************************************************************************/

/**
* @brief Checks if the provided token address is whitelisted and return the
* matching contract instance.
*
* @param address Reference to the buffer containing the token address
* @param contract Pointer to store the matched contract address instance
*
* @return bool Indicating if the provided token address is whitelisted
* @return true If the address matches to an entry in the whitelist
* @return false If the address does not match to an entry in the whitelist
*/
static bool is_token_whitelisted(const uint8_t *address,
const erc20_contracts_t **contract);

/*****************************************************************************
* STATIC VARIABLES
*****************************************************************************/
Expand All @@ -99,9 +113,7 @@ static const evm_config_t eth_app_config = {
.name = "Ethereum",
.chain_id = 1,

// whitelisted contracts
.whitelisted_contracts = eth_contracts,
.whitelist_count = ETH_WHITELISTED_CONTRACTS_COUNT,
.is_token_whitelisted = is_token_whitelisted,
};

static const cy_app_desc_t eth_app_desc = {.id = 7,
Expand All @@ -122,6 +134,24 @@ static const cy_app_desc_t eth_app_desc = {.id = 7,
* STATIC FUNCTIONS
*****************************************************************************/

static bool is_token_whitelisted(const uint8_t *address,
const erc20_contracts_t **contract) {
const erc20_contracts_t *match = NULL;
bool status = false;
for (int16_t i = 0; i < ETH_WHITELISTED_CONTRACTS_COUNT; i++) {
if (memcmp(address, eth_contracts[i].address, EVM_ADDRESS_LENGTH) == 0) {
match = &eth_contracts[i];
status = true;
break;
}
}

if (NULL != contract) {
*contract = match;
}
return status;
}

/*****************************************************************************
* GLOBAL FUNCTIONS
*****************************************************************************/
Expand Down
4 changes: 2 additions & 2 deletions apps/evm_family/evm_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ typedef struct {
* https://github.com/ethereum/EIPs/blob/830708a049fc982fd595cb0c4dca703aebefd003/EIPS/eip-2294.md
*/
const uint64_t chain_id;
const erc20_contracts_t *whitelisted_contracts;
const uint16_t whitelist_count;
bool (*is_token_whitelisted)(const uint8_t *address,
const erc20_contracts_t **contract);
} evm_config_t;

/*****************************************************************************
Expand Down
Loading

0 comments on commit 83a44e8

Please sign in to comment.