@@ -56,6 +56,7 @@ export async function fetchRelevantAddresses(
5656 relevantIndexes : Set < number > ,
5757) : Promise < PublicKey [ ] > {
5858 const relevantAddresses : PublicKey [ ] = [ ] ;
59+
5960 for ( const key of lookupTableKeys ) {
6061 const accountInfo = await solAPI . web3 . getAccountInfo ( key ) ;
6162 if (
@@ -67,20 +68,25 @@ export async function fetchRelevantAddresses(
6768 accountInfo . data ,
6869 ) ;
6970 if ( lookupTableAccount && lookupTableAccount . addresses ) {
70- lookupTableAccount . addresses . forEach ( async ( address , index ) => {
71- if ( relevantIndexes . has ( index ) ) {
72- const addressInfo = await solAPI . web3 . getAccountInfo ( address ) ;
73- if (
74- ( addressInfo ?. owner . toBase58 ( ) ===
75- TOKEN_PROGRAM_ID . toBase58 ( ) ||
76- addressInfo ?. owner . toBase58 ( ) ===
77- TOKEN_2022_PROGRAM_ID . toBase58 ( ) ) &&
78- addressInfo . data . length >= ACCOUNT_SIZE
79- ) {
80- relevantAddresses . push ( address ) ;
81- }
71+ // FIX: awaited for-loop instead of forEach(async …)
72+ for (
73+ let index = 0 ;
74+ index < lookupTableAccount . addresses . length ;
75+ index ++
76+ ) {
77+ const address = lookupTableAccount . addresses [ index ] ;
78+ if ( ! relevantIndexes . has ( index ) ) continue ;
79+
80+ const addressInfo = await solAPI . web3 . getAccountInfo ( address ) ;
81+ if (
82+ ( addressInfo ?. owner . toBase58 ( ) === TOKEN_PROGRAM_ID . toBase58 ( ) ||
83+ addressInfo ?. owner . toBase58 ( ) ===
84+ TOKEN_2022_PROGRAM_ID . toBase58 ( ) ) &&
85+ addressInfo . data . length >= ACCOUNT_SIZE
86+ ) {
87+ relevantAddresses . push ( address ) ;
8288 }
83- } ) ;
89+ }
8490 }
8591 } catch {
8692 console . error ( 'Failed to deserialize address lookup table account' ) ;
0 commit comments