@@ -285,8 +285,6 @@ __attribute__((noinline)) static uint16_t finalize_parsing_helper(const txContex
285285
286286 // Verify the chain
287287 if (g_chain_config -> chain_id != ETHEREUM_MAINNET_CHAINID ) {
288- chain_id = get_tx_chain_id ();
289-
290288 if (g_chain_config -> chain_id != chain_id ) {
291289 PRINTF ("Invalid chainID %llu expected %llu\n" , chain_id , g_chain_config -> chain_id );
292290 report_finalize_error ();
@@ -333,24 +331,28 @@ __attribute__((noinline)) static uint16_t finalize_parsing_helper(const txContex
333331 error = APDU_NO_RESPONSE ;
334332 goto end ;
335333 }
334+
335+ // store the lookup addresses
336+ // not needed to set them for PLUGIN_PROVIDE_INFO since it is done within this function,
337+ // but required for PLUGIN_QUERY_CONTRACT_UI
338+ dataContext .tokenContext .token_lookup1 = pluginFinalize .tokenLookup1 ;
339+ dataContext .tokenContext .token_lookup2 = pluginFinalize .tokenLookup2 ;
340+
336341 // Lookup tokens if requested
337342 ethPluginProvideInfo_t pluginProvideInfo ;
338343 eth_plugin_prepare_provide_info (& pluginProvideInfo );
339- if ((pluginFinalize .tokenLookup1 != NULL ) || (pluginFinalize .tokenLookup2 != NULL )) {
340- if (pluginFinalize .tokenLookup1 != NULL ) {
341- PRINTF ("Lookup1: %.*H\n" , ADDRESS_LENGTH , pluginFinalize .tokenLookup1 );
342- pluginProvideInfo .item1 = get_asset_info_by_addr (pluginFinalize .tokenLookup1 );
343- if (pluginProvideInfo .item1 != NULL ) {
344- PRINTF ("Token1 ticker: %s\n" , pluginProvideInfo .item1 -> token .ticker );
345- }
346- }
347- if (pluginFinalize .tokenLookup2 != NULL ) {
348- PRINTF ("Lookup2: %.*H\n" , ADDRESS_LENGTH , pluginFinalize .tokenLookup2 );
349- pluginProvideInfo .item2 = get_asset_info_by_addr (pluginFinalize .tokenLookup2 );
350- if (pluginProvideInfo .item2 != NULL ) {
351- PRINTF ("Token2 ticker: %s\n" , pluginProvideInfo .item2 -> token .ticker );
352- }
353- }
344+ pluginProvideInfo .item1 =
345+ get_matching_asset_info (& chain_id , dataContext .tokenContext .token_lookup1 );
346+ if (pluginProvideInfo .item1 != NULL ) {
347+ PRINTF ("Asset1 ticker: %s\n" , pluginProvideInfo .item1 -> token .ticker );
348+ }
349+ pluginProvideInfo .item2 =
350+ get_matching_asset_info (& chain_id , dataContext .tokenContext .token_lookup2 );
351+ if (pluginProvideInfo .item2 != NULL ) {
352+ PRINTF ("Asset2 ticker: %s\n" , pluginProvideInfo .item2 -> token .ticker );
353+ }
354+ if ((dataContext .tokenContext .token_lookup1 != NULL ) ||
355+ (dataContext .tokenContext .token_lookup2 != NULL )) {
354356 if (eth_plugin_call (ETH_PLUGIN_PROVIDE_INFO , (void * ) & pluginProvideInfo ) <=
355357 ETH_PLUGIN_RESULT_UNSUCCESSFUL ) {
356358 PRINTF ("Plugin provide token call failed\n" );
0 commit comments