Skip to content

chore: rework IDL card and simplify IDL resolution#1115

Open
askov wants to merge 3 commits into
solana-foundation:masterfrom
hoodieshq:chore/idl-cleanup
Open

chore: rework IDL card and simplify IDL resolution#1115
askov wants to merge 3 commits into
solana-foundation:masterfrom
hoodieshq:chore/idl-cleanup

Conversation

@askov

@askov askov commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Description

Reworks the program IDL card to a single, source-agnostic view, adds an at-a-glance metadata block under the badge, and removes the PMP feature flags.

  • The card no longer renders one tab per IDL source. It shows the latest Program Metadata (PMP) IDL, falling back to the program's on-chain Anchor IDL — flagged with a warning badge + tooltip — only when no PMP IDL exists.
  • The badge shows the IDL standard and its format (encoding) version — Codama's root version or Anchor's metadata.spec: Codama (version 1.5.1), Anchor 0.30.1 (version 0.1.0), or Anchor (legacy).
  • A metadata block under the badge surfaces, for the displayed IDL:
    • Address — the on-chain account it was read from (PMP metadata account / Anchor IDL PDA), linked + copyable via the shared AddressLink.
    • SourcePMP or Anchor.
    • Program Version — the program's own semver (program.version for Codama, metadata.version / legacy top-level version for Anchor), kept distinct from the format version shown in the badge.
  • Adds an IDL history link in the card header to the standalone IDL explorer (idl.solana.com) for the full history across all sources.
  • Removes the NEXT_PUBLIC_PMP_IDL_ENABLED and NEXT_PUBLIC_PMP_SECURITY_TXT_ENABLED feature flags — PMP IDL and security.txt resolution are now always on (the security.txt path keeps its Neodyme ELF fallback).
  • Simplifies the IDL resolution layer: drops the includeAnchor/includePmp options and the preferredVariant field, merges the duplicate result types into one ProgramIdlPair (now also carrying each source's storage-account address, threaded from @solana/idl — which already returns it — through the resolver, the /api/idl-latest route, and useProgramIdls), moves useProgramIdls into the idl entity so the card, the Anchor tx-decoder, and the program-name label share one cached resolution, and removes the now-redundant useIdlFromAnchorProgramSeed hook plus dead exports.

Net ~250 fewer lines; the tx-inspector routes drop ~10 kB First Load JS (one fewer IDL hook on the decoder path — see bench/BUILD.md).

Type of change

  • New feature
  • Other: UI rework + refactor — removes feature flags and simplifies IDL resolution (no new protocol)

Screenshots

localhost_3000_address_BUYuxRfhCMWavaUWxhGtPP3ksKEDZxCD5gzknk3JfAya_idl localhost_3000_address_JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4_idl localhost_3000_address_AXcxp15oz1L4YYtqZo6Qt6EkUj1jtLR6wXYqaJvn4oye_idl_cluster=devnet

Testing

Automated: pnpm lint, pnpm typecheck, pnpm build, and pnpm test pass locally; IDL card / resolver / hook specs added or updated — including the badge label, the program-version accessor, and the storage-address threading through the resolver and the /api/idl-latest route.

Manual (Vercel preview):

Related Issues

Closes HOO-711

Checklist

  • My code follows the project's style guidelines
  • I have added tests that prove my fix/feature works
  • All checks pass locally (pnpm test, pnpm lint, pnpm typecheck)
  • I have run build:info script to update build information

@vercel

vercel Bot commented Jun 26, 2026

Copy link
Copy Markdown

@askov is attempting to deploy a commit to the Solana Foundation Team on Vercel.

A member of the Team first needs to authorize it.

@askov askov changed the title chore: rework IDL card and simplify IDL resolution (HOO-711) chore: rework IDL card and simplify IDL resolution Jun 26, 2026
@greptile-apps

greptile-apps Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR reworks the program IDL experience and simplifies IDL resolution. The main changes are:

  • Shows one PMP-first IDL card with Anchor fallback.
  • Adds IDL source, storage address, and program version metadata.
  • Threads IDL storage addresses through the resolver, API route, and shared hook.
  • Removes PMP feature flags for IDL and security.txt resolution.
  • Moves IDL fetching into a shared entity hook used by the card, decoder, and program label.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
app/entities/idl/api/resolve-program-idls.ts Simplifies IDL resolution to return both sources and their storage accounts.
app/entities/idl/model/use-program-idls.ts Centralizes shared IDL fetching for known and custom clusters.
app/features/idl/ui/IdlCard.tsx Replaces source tabs with a single PMP-first card and metadata block.
app/api/security-txt/route.ts Always resolves security.txt through the shared PMP-to-ELF path.

Reviews (4): Last reviewed commit: "refactor: address IDL PR review feedback..." | Re-trigger Greptile

@vercel

vercel Bot commented Jun 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
explorer Ready Ready Preview, Comment Jun 29, 2026 10:45pm

Request Review

@@ -1,49 +0,0 @@
'use client';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you, please, check that by deleting the hook, we do not have leftover excludes in the eslint.config?

@@ -0,0 +1,8 @@
import { AnchorProvider } from '@coral-xyz/anchor';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it is worth moving the logic regarding the Anchor's IDL into the shared entity, which will provide functionality via @x/idl?
I think we could combine this rework and localise all the parts of the standard according to the FSD

@@ -1,105 +0,0 @@
import { renderHook, waitFor } from '@testing-library/react';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may have leftover excludes in the eslint.config, please check them, if any

const { data: customIdls, isLoading: customLoading } = useSWRImmutable(
isCustom && (['program-idls-custom', programId, url] as const),
() => resolveProgramIdlsClient({ includePmp: PMP_IDL_ENABLED, programId, url }),
() => resolveProgramIdlsClient({ programId, url }),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const isCustom = shouldUseDirectRpc(cluster, url); may return true for MainnetBeta + http://localhost:8899 combination.
We need at least a test case to ensure the IDL is loaded from the correct network.

}));

const DEFAULT_ADDRESS = PublicKey.default.toBase58();
const PMP_PDA = 'PMP1111111111111111111111111111111111111111';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add to @fixtures/gen a vanity address helper to create similar addresses.

includePmp: boolean;
};

export type ResolvedProgramIdls = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: just was wondering if ResolvedProgramIdls and ProgramIdlPair could extend each other or use generic as they are nearly identical, something like:

type ResolvedProgramIdls<TSupportedIdl = unknown> {
    anchorIdl: TSupportedIdl
    programMetadataIdl: TSupportedIdl
}
type ProgramIdlPair = ResolvedProgramIdls<SupportedIdl | undefined>;

askov added 2 commits June 29, 2026 20:03
- Replace per-source IDL tabs with a single view: the latest PMP IDL,
  falling back to the on-chain Anchor IDL (flagged via a tooltip) only
  when no PMP IDL exists.
- Remove the NEXT_PUBLIC_PMP_IDL_ENABLED and NEXT_PUBLIC_PMP_SECURITY_TXT_ENABLED
  feature flags (PMP resolution is always on).
- Add an "IDL history" link to idl.solana.com in the card header.
- Simplify resolution: drop the includeAnchor/includePmp args and the
  preferredVariant field, and merge the duplicate result types into ProgramIdlPair.
- Move useProgramIdls into the idl entity and share it across the card,
  the Anchor tx decoder (useAnchorProgram), and the program-name label;
  delete the now-redundant useIdlFromAnchorProgramSeed hook.
- Trim dead barrel/server exports and the unused cluster @x/program-metadata slice.
- Add a metadata block under the badge: the IDL storage account
  (linked + copyable via the shared AddressLink), the source
  (PMP / Anchor), and the program's own version.
- Surface the IDL storage-account address — already returned by
  @solana/idl but previously discarded — through the resolver, the
  /api/idl-latest route, the fetch/client resolvers, and useProgramIdls.
- Rework the badge to show the IDL standard + format (encoding) version:
  "Codama (version 1.5.1)", "Anchor 0.30.1 (version 0.1.0)", or
  "Anchor (legacy)". Add getIdlBadgeLabel + getIdlProgramVersion (the
  program semver, distinct from the spec/era label getIdlVersion returns).
- Add an `info` slot to IdlSection for the metadata block.
- Unify ResolvedProgramIdls/ProgramIdlPair via a ProgramIdlSources<IdlContent>
  generic; relocate resolution shapes to api/types.ts and the foundational IDL
  aliases to lib/types.ts, giving a clean model -> api -> lib dependency flow.
- Group the entity's Anchor-standard modules under model/anchor/.
- Add a useProgramIdls test for the MainnetBeta + localhost direct-RPC path.
- Add a gen.vanityAddress() fixture helper and use it in IdlCard.spec.
- Drop a stale unicorn/no-null exclude for the deleted seed hook.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants