handle_provide_token()
Handle explanation
The Ethereum application will call this handle when the plugin has requested
ERC20 token information in handle_finalize
The plugin needs to perform the following actions:
- Check that provided token matches the one requested.
- Increase the number of screens needed for the display if needed.
- Report an error to the ethereum application if the display must be aborted.
Warning
The Ethereum application can only provide to the plugin information about
ERC20 token it knows about.
You need to provide the ERC20 token information to the Ethereum application
using PROVIDE ERC 20 TOKEN INFORMATION
APDU.
An example of token info providing is already done in the boilerplate plugin. Adapt and expand it for your use case.
Fields descriptions
typedef struct ethPluginProvideInfo_s {
// DEPRECATED, will be removed soon. Do not use.
ethPluginSharedRW_t *pluginSharedRW;
// INPUT. Transaction data available to the plugin. READ-ONLY.
ethPluginSharedRO_t *pluginSharedRO;
// RW INPUT. Contains the semi-persistent RAM space that can be used by the
// plugin in each handle call.
uint8_t *pluginContext;
// INPUT. ERC20 token information as requested by tokenLookup1 in
// handle_finalize. NULL if not found.
union extraInfo_t *item1;
// INPUT. Same as item1 but for tokenLookup2.
union extraInfo_t *item2;
// OUTPUT. Set by the plugin if it needs to display additional screens based
// on the information received from the token definitions.
uint8_t additionalScreens;
// OUTPUT. Used by the plugin to inform the Ethereum application of the
// result of this handle The following return codes are expected, any other
// will abort the signing process:
// - ETH_PLUGIN_RESULT_OK
// - ETH_PLUGIN_RESULT_FALLBACK : if the signing logic should fallback to
// the generic one
eth_plugin_result_t result;
} ethPluginProvideInfo_t;
Provided token structure
This is the structure given by the Ethereum application to the plugin.
// NFT
#define COLLECTION_NAME_MAX_LEN 70
typedef struct nftInfo_t {
uint8_t contractAddress[ADDRESS_LENGTH]; // must be first item
char collectionName[COLLECTION_NAME_MAX_LEN + 1];
} nftInfo_t;
// TOKENS
#define MAX_TICKER_LEN 11 // 10 characters + '\0'
typedef struct tokenDefinition_t {
uint8_t address[ADDRESS_LENGTH]; // must be first item
char ticker[MAX_TICKER_LEN];
uint8_t decimals;
} tokenDefinition_t;
// UNION
typedef union extraInfo_t {
tokenDefinition_t token;
// Would have used HAVE_NFT_SUPPORT but it is only declared for the Ethereum app
// and not plugins
#ifndef TARGET_NANOS
nftInfo_t nft;
#endif
} extraInfo_t;