diff --git a/src/index.ts b/src/index.ts index 2c84f42..36d2d82 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,6 +2,7 @@ import "dotenv/config"; import { getKeypairFromEnvironment } from "@solana-developers/helpers"; import axios from "axios"; import { + AddressLookupTableAccount, Connection, PublicKey, VersionedTransaction, @@ -39,6 +40,8 @@ function instructionFormat(instruction) { }; } +let addressLookupTables: { [key: string]: AddressLookupTableAccount[] } = {}; + async function run() { const start = Date.now(); @@ -127,7 +130,14 @@ async function run() { // ALT const addressLookupTableAccounts = await Promise.all( instructions.addressLookupTableAddresses.map(async (address) => { + if (addressLookupTables[address]) { + return addressLookupTables[address]; + } + const result = await connection.getAddressLookupTable(new PublicKey(address)); + if (result.value) { + addressLookupTables[address] = result.value; + } return result.value; }) );