chore: rework IDL card and simplify IDL resolution#1115
Conversation
|
@askov is attempting to deploy a commit to the Solana Foundation Team on Vercel. A member of the Team first needs to authorize it. |
Greptile SummaryThis PR reworks the program IDL experience and simplifies IDL resolution. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (4): Last reviewed commit: "refactor: address IDL PR review feedback..." | Re-trigger Greptile |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| @@ -1,49 +0,0 @@ | |||
| 'use client'; | |||
There was a problem hiding this comment.
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'; | |||
There was a problem hiding this comment.
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'; | |||
There was a problem hiding this comment.
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 }), |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
Let's add to @fixtures/gen a vanity address helper to create similar addresses.
| includePmp: boolean; | ||
| }; | ||
|
|
||
| export type ResolvedProgramIdls = { |
There was a problem hiding this comment.
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>;- 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.
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.
metadata.spec:Codama (version 1.5.1),Anchor 0.30.1 (version 0.1.0), orAnchor (legacy).AddressLink.PMPorAnchor.program.versionfor Codama,metadata.version/ legacy top-levelversionfor Anchor), kept distinct from the format version shown in the badge.idl.solana.com) for the full history across all sources.NEXT_PUBLIC_PMP_IDL_ENABLEDandNEXT_PUBLIC_PMP_SECURITY_TXT_ENABLEDfeature flags — PMP IDL and security.txt resolution are now always on (the security.txt path keeps its Neodyme ELF fallback).includeAnchor/includePmpoptions and thepreferredVariantfield, merges the duplicate result types into oneProgramIdlPair(now also carrying each source's storage-account address, threaded from@solana/idl— which already returns it — through the resolver, the/api/idl-latestroute, anduseProgramIdls), movesuseProgramIdlsinto theidlentity so the card, the Anchor tx-decoder, and the program-name label share one cached resolution, and removes the now-redundantuseIdlFromAnchorProgramSeedhook 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
Screenshots
Testing
Automated:
pnpm lint,pnpm typecheck,pnpm build, andpnpm testpass 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-latestroute.Manual (Vercel preview):
Related Issues
Closes HOO-711
Checklist
pnpm test,pnpm lint,pnpm typecheck)build:infoscript to update build information