Skip to content

Commit 654a2f4

Browse files
committed
fix: replace forEach with awaited for-loop in fetchRelevantAddresses for proper async handling
1 parent 98c8efa commit 654a2f4

1 file changed

Lines changed: 19 additions & 13 deletions

File tree

packages/extension/src/providers/solana/ui/libs/decode-tx.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)