Skip to content

Commit

Permalink
use reduce > find+map
Browse files Browse the repository at this point in the history
  • Loading branch information
joeymeere committed Nov 7, 2024
1 parent 08144c3 commit 425f30f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/transaction/getAccountsForSimulation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ export async function getAccountsForSimulation(
const { staticAccountKeys, accountKeysFromLookups } =
tx.message.getAccountKeys({ addressLookupTableAccounts });

const staticAddresses = staticAccountKeys
.filter((k) => !k.equals(SystemProgram.programId))
.map((k) => k.toString());
const staticAddresses = staticAccountKeys.reduce((acc, k) => {
if (!k.equals(SystemProgram.programId)) {
acc.push(k.toString());
}
return acc;
}, [] as string[]);

const addressesFromLookups = accountKeysFromLookups
? accountKeysFromLookups.writable.map((k) => k.toString())
Expand Down

0 comments on commit 425f30f

Please sign in to comment.