Add Compound support as an internal plugin

This commit is contained in:
TamtamHero
2020-10-05 18:22:42 +02:00
parent 6a754b5189
commit 4f2cef2e20
7 changed files with 254 additions and 10 deletions

View File

@@ -12,6 +12,7 @@ void eth_plugin_prepare_query_contract_UI(ethQueryContractUI_t *queryContractUI,
int eth_plugin_perform_init(uint8_t *contractAddress, ethPluginInitContract_t *init);
// NULL for cached address, or base contract address
int eth_plugin_call(uint8_t *contractAddress, int method, void *parameter);
int compound_plugin_call(uint8_t *contractAddress, int method, void *parameter);
void plugin_ui_start(void);

View File

@@ -1,6 +1,7 @@
#include "eth_plugin_internal.h"
void erc20_plugin_call(int message, void *parameters);
void compound_plugin_call(int message, void *parameters);
void starkware_plugin_call(int message, void *parameters);
static const uint8_t const ERC20_TRANSFER_SELECTOR[SELECTOR_SIZE] = { 0xa9, 0x05, 0x9c, 0xbb };
@@ -10,6 +11,16 @@ const uint8_t* const ERC20_SELECTORS[NUM_ERC20_SELECTORS] = {
ERC20_TRANSFER_SELECTOR, ERC20_APPROVE_SELECTOR
};
static const uint8_t const COMPOUND_REDEEM_UNDERLYING_SELECTOR[SELECTOR_SIZE] = { 0x85, 0x2a, 0x12, 0xe3 };
static const uint8_t const COMPOUND_REDEEM_SELECTOR[SELECTOR_SIZE] = { 0xdb, 0x00, 0x6a, 0x75 };
static const uint8_t const COMPOUND_MINT_SELECTOR[SELECTOR_SIZE] = { 0xa0, 0x71, 0x2d, 0x68 };
static const uint8_t const CETH_MINT_SELECTOR[SELECTOR_SIZE] = { 0x12, 0x49, 0xc5, 0x8b };
const uint8_t* const COMPOUND_SELECTORS[NUM_COMPOUND_SELECTORS] = {
COMPOUND_REDEEM_UNDERLYING_SELECTOR, COMPOUND_REDEEM_SELECTOR,
COMPOUND_MINT_SELECTOR, CETH_MINT_SELECTOR
};
#ifdef HAVE_STARKWARE
static const uint8_t const STARKWARE_REGISTER_ID[SELECTOR_SIZE] = { 0x76, 0x57, 0x18, 0xd7 };
@@ -42,6 +53,13 @@ const internalEthPlugin_t const INTERNAL_ETH_PLUGINS[NUM_INTERNAL_PLUGINS] = {
erc20_plugin_call
},
{
COMPOUND_SELECTORS,
4,
"-cmpd",
compound_plugin_call
},
#ifdef HAVE_STARKWARE
{

View File

@@ -12,20 +12,22 @@ typedef struct internalEthPlugin_t {
} internalEthPlugin_t;
#define NUM_ERC20_SELECTORS 2
extern const uint8_t* const ERC20_SELECTORS[NUM_ERC20_SELECTORS];
#define NUM_COMPOUND_SELECTORS 4
extern const uint8_t* const COMPOUND_SELECTORS[NUM_COMPOUND_SELECTORS];
#ifdef HAVE_STARKWARE
#define NUM_INTERNAL_PLUGINS 2
#define NUM_INTERNAL_PLUGINS 3
#define NUM_STARKWARE_SELECTORS 10
extern const uint8_t* const STARKWARE_SELECTORS[NUM_STARKWARE_SELECTORS];
#else
#define NUM_INTERNAL_PLUGINS 1
#define NUM_INTERNAL_PLUGINS 2
#endif

View File

@@ -134,7 +134,7 @@ UX_STEP_NOCB_INIT(
bnnn_paging,
plugin_ui_compute_fees(),
{
.title = "Max fees",
.title = "Max Fees",
.text = strings.common.maxFee
});