Skip to content

handle_finalize()

Handle explanation

The Ethereum application will call this handle when the entire smart contract has been fed to the plugin using the provide_parameter handle.

The plugin needs to perform the following actions:

  • Check that nothing is missing from the smart contract if applicable.
  • Report an error to the ethereum application if the smart contract has an issue.
  • Request information about a ERC20 token if needed (2 max).
  • Set the UI layout to SIMPLIFIED (called UI_AMOUNT_ADDRESS) or CUSTOM (called ETH_UI_TYPE_GENERIC)
    • CUSTOM: Inform the Ethereum application of the number of screens needed to display the smart contract.
    • SIMPLIFIED: Inform the Ethereum application of the amount and address to display.

An example of smart contract parsing finalization is already done in the boilerplate plugin. Adapt and expand it for your use case.

Fields descriptions

typedef struct ethPluginFinalize_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;

    // OUTPUT. The plugin can set this value to a 20 bytes array in
    // pluginContext containing the address of an ERC20 token. In this case
    // Ethereum will call the plugin with handle_provide_token() with the
    // requested ERC20 token information. The Ethereum application must be made
    // aware of ERC20 token information first using 'PROVIDE ERC 20 TOKEN
    // INFORMATION' APDU. Leave the value at NULL if not needed
    uint8_t *tokenLookup1;
    // OUTPUT. Same as tokenLookup1.
    uint8_t *tokenLookup2;

    // OUTPUT. The plugin needs to set this pointer to a 256 bits number in
    // pluginContext to display as the amount in UI_AMOUNT_ADDRESS case. IGNORED
    // if uiType is UI_AMOUNT_ADDRESS.
    const uint8_t *amount;
    // OUTPUT. The plugin needs to set this pointer to a 20 bytes address in
    // pluginContext to display as the address in UI_AMOUNT_ADDRESS case.
    // IGNORED if uiType is UI_AMOUNT_ADDRESS.
    const uint8_t *address;

    // OUTPUT. The plugin needs to set this value to either
    // ETH_UI_TYPE_AMOUNT_ADDRESS for an amount/address UI or
    // ETH_UI_TYPE_GENERIC for a generic UI.
    eth_ui_type_t uiType;

    // OUTPUT. The plugin needs to set this value to the number of screens
    // needed to display the smart contract in ETH_UI_TYPE_GENERIC case. IGNORED
    // if uiType is UI_AMOUNT_ADDRESS.
    uint8_t numScreens;

    // 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;

} ethPluginFinalize_t;