@@ -266,9 +266,7 @@ STATIC bool solana_handle_initiate_query(const solana_query_t *query) {
266
266
return false;
267
267
}
268
268
269
- snprintf (
270
- msg , sizeof (msg ), UI_TEXT_SIGN_TXN_PROMPT , SOLANA_NAME , wallet_name
271
- );
269
+ snprintf (msg , sizeof (msg ), UI_TEXT_SIGN_TXN_PROMPT , SOLANA_NAME , wallet_name );
272
270
273
271
// Take user consent to sign the transaction for the wallet
274
272
if (!core_confirmation (msg , solana_send_error )) {
@@ -357,7 +355,7 @@ STATIC bool solana_fetch_valid_transaction(solana_query_t *query) {
357
355
return true;
358
356
}
359
357
360
- static bool solana_transfer_sol_transaction () {
358
+ static bool verify_solana_transfer_sol_transaction () {
361
359
char address [45 ] = {0 };
362
360
size_t address_size = sizeof (address );
363
361
@@ -387,7 +385,7 @@ static bool solana_transfer_sol_transaction() {
387
385
while (i -- )
388
386
be_lamports [i ] = solana_txn_context -> transaction_info
389
387
.instruction [transfer_instruction_index ]
390
- .program .transfer .amount >>
388
+ .program .transfer .lamports >>
391
389
8 * (7 - i );
392
390
393
391
byte_array_to_hex_string (
@@ -535,35 +533,59 @@ static bool is_token_whitelisted(const uint8_t *address,
535
533
return status ;
536
534
}
537
535
538
- static bool solana_transfer_token_transaction () {
539
- char address [ 45 ] = { 0 };
540
- size_t address_size = sizeof ( address ) ;
536
+ static bool verify_solana_transfer_token_transaction () {
537
+ const uint8_t transfer_instruction_index =
538
+ solana_txn_context -> transaction_info . transfer_instruction_index ;
541
539
542
- const solana_token_program_t * contract ;
543
- if (!is_token_whitelisted (solana_txn_context -> token_data .mint_address ,
544
- & contract )) {
540
+ const uint8_t * token_mint = solana_txn_context -> transaction_info
541
+ .instruction [transfer_instruction_index ]
542
+ .program .transfer_checked .token_mint ;
543
+ const solana_token_program_t * contract = NULL ;
544
+ if (!is_token_whitelisted (token_mint , & contract )) {
545
545
// Contract Unverifed, Display warning
546
- delay_scr_init (ui_text_unverified_contract , DELAY_TIME );
546
+ delay_scr_init (ui_text_unverified_token , DELAY_TIME );
547
547
548
548
char mint_address [45 ] = {0 };
549
549
size_t mint_address_size = sizeof (mint_address );
550
550
// verify mint address
551
551
if (!b58enc (mint_address ,
552
552
& mint_address_size ,
553
- solana_txn_context -> token_data . mint_address ,
553
+ token_mint ,
554
554
SOLANA_ACCOUNT_ADDRESS_LENGTH )) {
555
555
solana_send_error (ERROR_COMMON_ERROR_UNKNOWN_ERROR_TAG , 2 );
556
556
return false;
557
557
}
558
558
559
- if (!core_scroll_page (ui_text_solana_verify_mint_authority ,
560
- mint_address ,
561
- solana_send_error )) {
559
+ if (!core_scroll_page (
560
+ ui_text_verify_token_address , mint_address , solana_send_error )) {
561
+ return false;
562
+ }
563
+
564
+ const uint8_t token_decimals = solana_txn_context -> transaction_info
565
+ .instruction [transfer_instruction_index ]
566
+ .program .transfer_checked .decimals ;
567
+
568
+ solana_token_program_t empty_contract = {
569
+ .symbol = "" ,
570
+ .decimal = token_decimals ,
571
+ };
572
+
573
+ contract = & empty_contract ;
574
+ } else {
575
+ char msg [100 ] = "" ;
576
+ snprintf (msg ,
577
+ sizeof (msg ),
578
+ UI_TEXT_SEND_TOKEN_PROMPT ,
579
+ contract -> symbol ,
580
+ SOLANA_NAME );
581
+ if (!core_confirmation (msg , solana_send_error )) {
562
582
return false;
563
583
}
564
584
}
565
585
566
586
// verify recipient address;
587
+ char address [45 ] = {0 };
588
+ size_t address_size = sizeof (address );
567
589
if (!b58enc (address ,
568
590
& address_size ,
569
591
solana_txn_context -> token_data .recipient_address ,
@@ -572,32 +594,30 @@ static bool solana_transfer_token_transaction() {
572
594
return false;
573
595
}
574
596
575
- if (!core_scroll_page (ui_text_verify_address , address , solana_send_error )) {
576
- return false;
577
- }
578
-
579
- // Upon recipient address confirmwation, calculate associated token address
580
- // and compare with utxn's value
597
+ // Calculate associated token address and compare with utxn's value
581
598
uint8_t associated_token_address [SOLANA_ACCOUNT_ADDRESS_LENGTH ] = {0 };
582
599
if (!get_associated_token_address (
583
- solana_txn_context -> token_data . mint_address ,
600
+ token_mint ,
584
601
solana_txn_context -> token_data .recipient_address ,
585
602
associated_token_address )) {
586
603
solana_send_error (ERROR_COMMON_ERROR_UNKNOWN_ERROR_TAG , 2 );
587
604
return false;
588
605
}
589
606
590
- const uint8_t transfer_instruction_index =
591
- solana_txn_context -> transaction_info .transfer_instruction_index ;
592
607
if (memcmp (associated_token_address ,
593
608
solana_txn_context -> transaction_info
594
609
.instruction [transfer_instruction_index ]
595
- .program .transfer . recipient_account ,
610
+ .program .transfer_checked . destination ,
596
611
SOLANA_ACCOUNT_ADDRESS_LENGTH ) != 0 ) {
597
612
solana_send_error (ERROR_COMMON_ERROR_CORRUPT_DATA_TAG , 2 );
598
613
return false;
599
614
}
600
615
616
+ // Now take user verification
617
+ if (!core_scroll_page (ui_text_verify_address , address , solana_send_error )) {
618
+ return false;
619
+ }
620
+
601
621
// verify recipient amount
602
622
char amount_string [40 ] = {'\0' }, amount_decimal_string [30 ] = {'\0' };
603
623
char display [100 ] = "" ;
@@ -607,7 +627,7 @@ static bool solana_transfer_token_transaction() {
607
627
while (i -- )
608
628
be_units [i ] = solana_txn_context -> transaction_info
609
629
.instruction [transfer_instruction_index ]
610
- .program .transfer .amount >>
630
+ .program .transfer_checked .amount >>
611
631
8 * (7 - i );
612
632
613
633
byte_array_to_hex_string (be_units , 8 , amount_string , sizeof (amount_string ));
@@ -635,9 +655,9 @@ static bool solana_transfer_token_transaction() {
635
655
636
656
STATIC bool solana_get_user_verification () {
637
657
if (solana_txn_context -> is_token_transfer_transaction == true) {
638
- return solana_transfer_token_transaction ();
658
+ return verify_solana_transfer_token_transaction ();
639
659
} else
640
- return solana_transfer_sol_transaction ();
660
+ return verify_solana_transfer_sol_transaction ();
641
661
}
642
662
643
663
STATIC bool fetch_seed (solana_query_t * query , uint8_t * seed_out ) {
0 commit comments