Skip to content

Commit

Permalink
Stop parsing idls from program binaries when loading anchor programs (#…
Browse files Browse the repository at this point in the history
…390)

This has been causing rate limiting issues when loading transactions
that have a lot of program interactions because each instruction
required fetching the entire program binary.

Also need a key flagship program to use this feature on mainnet to be
useful.
  • Loading branch information
ngundotra authored Oct 16, 2024
1 parent 8e4589e commit 7a1ba29
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/providers/anchor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const cachedAnchorProgramPromises: Record<
void | { __type: 'promise'; promise: Promise<void> } | { __type: 'result'; result: Idl | null }
> = {};

// eslint-disable-next-line @typescript-eslint/no-unused-vars
function useIdlFromSolanaProgramBinary(programAddress: string): Idl | null {
const fetchAccountInfo = useFetchAccountInfo();
const programInfo = useAccountInfo(programAddress);
Expand Down Expand Up @@ -112,9 +113,10 @@ function useIdlFromAnchorProgramSeed(programAddress: string, url: string): Idl |
}

export function useAnchorProgram(programAddress: string, url: string): { program: Program | null; idl: Idl | null } {
const idlFromBinary = useIdlFromSolanaProgramBinary(programAddress);
// TODO(ngundotra): Rewrite this to be more efficient
// const idlFromBinary = useIdlFromSolanaProgramBinary(programAddress);
const idlFromAnchorProgram = useIdlFromAnchorProgramSeed(programAddress, url);
const idl = idlFromBinary ?? idlFromAnchorProgram;
const idl = idlFromAnchorProgram;
const program: Program<Idl> | null = useMemo(() => {
if (!idl) return null;
try {
Expand Down

0 comments on commit 7a1ba29

Please sign in to comment.