Skip to content

Instantly share code, notes, and snippets.

@mgild
Last active July 10, 2024 20:35
Show Gist options
  • Save mgild/01e1293943953d787364fc34a4c471cb to your computer and use it in GitHub Desktop.
Save mgild/01e1293943953d787364fc34a4c471cb to your computer and use it in GitHub Desktop.
export async function fetchAllLutKeys(
queue: Queue,
feeds: PullFeed[]
): Promise<PublicKey[]> {
const oracles = await queue.fetchOracleKeys();
const lutOwners: any[] = [];
lutOwners.push(queue);
for (const feed of feeds) {
lutOwners.push(feed);
}
for (const oracle of oracles) {
lutOwners.push(new Oracle(queue.program, oracle));
}
const lutPromises = lutOwners.map((lutOwner) => {
return lutOwner.loadLookupTable();
});
const luts = await Promise.all(lutPromises);
const keyset = new Set<PublicKey>();
for (const lut of luts) {
for (const key of lut.state.addresses) {
keyset.add(key.toString());
}
}
return Array.from(keyset).map((key) => new PublicKey(key));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment