Skip to content

feat(idl): add castaway link with idl source context#909

Merged
Woody4618 merged 1 commit intosolana-foundation:masterfrom
dev-jodee:feat/HOO-382-add-castaway-link-to-idl-tab
Mar 26, 2026
Merged

feat(idl): add castaway link with idl source context#909
Woody4618 merged 1 commit intosolana-foundation:masterfrom
dev-jodee:feat/HOO-382-add-castaway-link-to-idl-tab

Conversation

@dev-jodee
Copy link
Contributor

@dev-jodee dev-jodee commented Mar 25, 2026

Summary

  • add a Castaway CTA to the Program IDL controls in Explorer
  • prefill Castaway with the current program via program query param
  • pass active Explorer IDL source via idlSource (program-metadata or anchor) to preserve selection context

Changes

  • update IDL section controls to include external Castaway link
  • thread active IDL variant from IdlCard into the Castaway URL builder
  • extend IdlCard tests to assert Castaway URL params and external-link behavior

Testing

  • pnpm exec vitest --project specs run app/features/idl/ui/tests/IdlCard.spec.tsx

Screenshot

Screenshot 2026-03-26 at 11 50 13 AM
Screenshot 2026-03-26 at 11 50 10 AM
Screenshot 2026-03-26 at 11 50 05 AM

castaway

Closes HOO-382

@dev-jodee dev-jodee marked this pull request as draft March 25, 2026 16:35
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 25, 2026

Greptile Summary

This PR adds a Generate SDK entry to the IDL section's Download dropdown, which opens a "Leaving Solana Explorer" confirmation dialog before redirecting the user to Castaway with the current program address, active IDL source (anchor or program-metadata), and network pre-filled as query params.\n\nKey changes:\n- IdlCard.tsx: Derives network via clusterSlug(cluster) and threads idlSource (the active IdlVariant) into IdlSection — minimal, low-risk change.\n- IdlSection.tsx: Promotes the plain Download button to a Bootstrap JS-powered dropdown; lazily initialises the Bootstrap Dropdown instance with a fixed Popper strategy; builds the Castaway URL with useMemo; wires up a controlled Radix UI Dialog for the navigation-warning flow.\n- IdlCard.spec.tsx: Extends existing tests with full Castaway URL param assertions (program, idlSource, network) and window.open call verification for both PMP and Anchor IDL variants.\n\nConcerns found:\n- When connected to a custom RPC endpoint, clusterSlug returns 'custom', so network=custom is forwarded to Castaway — Castaway is unlikely to recognize this value.\n- The new "Leaving Solana Explorer" dialog duplicates the pattern already established in the existing ExternalLinkWarning component; ExternalLinkWarning could be extended with controlled-mode props to eliminate the duplication.

Confidence Score: 4/5

Safe to merge after addressing the custom-cluster network value edge case; remaining concern is a minor code-reuse suggestion.

Prior review concern (typing idlSource as IdlVariant instead of string) has been fully resolved. Tests are thorough, covering both IDL variants with full URL param assertions. The only concrete actionable issue is that network=custom is forwarded unchecked to Castaway, which could silently break the flow for custom-cluster users. The dialog duplication is a style suggestion that doesn't affect correctness. Both remaining items are non-critical P2s.

app/features/idl/ui/IdlSection.tsx — custom network guard and dialog deduplication opportunity

Important Files Changed

Filename Overview
app/features/idl/ui/IdlCard.tsx Derives network string from clusterSlug(cluster) and threads it alongside idlSource (the active tab's IdlVariant) down to IdlSection — straightforward, low-risk change.
app/features/idl/ui/IdlSection.tsx Converts the plain Download button into a Bootstrap JS dropdown with "Download IDL" and "Generate SDK" options; adds a controlled "Leaving Explorer" confirmation dialog; minor duplication of the existing ExternalLinkWarning pattern, and network=custom is passed unchecked to Castaway.
app/features/idl/ui/tests/IdlCard.spec.tsx Extends existing tests with Castaway URL assertions (origin, pathname, all three query params) and window.open target/features verification for both PMP and Anchor IDL variants.

Sequence Diagram

sequenceDiagram
    actor User
    participant IdlCard
    participant IdlSection
    participant BootstrapDropdown
    participant ConfirmDialog
    participant Castaway

    IdlCard->>IdlSection: idl, idlSource (IdlVariant), network, programId
    User->>IdlSection: clicks "Download" button
    IdlSection->>BootstrapDropdown: show dropdown menu
    User->>BootstrapDropdown: clicks "Generate SDK"
    BootstrapDropdown->>IdlSection: handleOpenCastawayDialog()
    IdlSection->>ConfirmDialog: open (isCastawayDialogOpen=true)
    ConfirmDialog-->>User: shows castawayUrl preview
    alt User clicks Continue
        User->>ConfirmDialog: click Continue
        ConfirmDialog->>IdlSection: handleCastawayContinue()
        IdlSection->>Castaway: window.open(castawayUrl, _blank, noopener,noreferrer)
        IdlSection->>ConfirmDialog: close (isCastawayDialogOpen=false)
    else User clicks Cancel / Escape
        User->>ConfirmDialog: dismiss
        ConfirmDialog->>IdlSection: onOpenChange(false)
    end
Loading

Reviews (2): Last reviewed commit: "feat(idl): add castaway sdk action in id..." | Re-trigger Greptile

@vercel
Copy link

vercel bot commented Mar 25, 2026

@dev-jodee is attempting to deploy a commit to the Solana Foundation Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Mar 26, 2026

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

Project Deployment Actions Updated (UTC)
explorer Ready Ready Preview, Comment Mar 26, 2026 4:09pm

Request Review

@Woody4618
Copy link
Collaborator

Maybe we make the Button say "Generate SDK" and popup that tells users "You are now leaving Explorer and going to castaway".

@dev-jodee
Copy link
Contributor Author

Maybe we make the Button say "Generate SDK" and popup that tells users "You are now leaving Explorer and going to castaway".

yes makes total sense

@rogaldh
Copy link
Contributor

rogaldh commented Mar 26, 2026

Maybe we make the Button say "Generate SDK" and popup that tells users "You are now leaving Explorer and going to castaway".

yes makes total sense

You can reuse the same dropdown used within the Download button from here, and there is an example for the popup at the Interactive IDL feature (when working with the mainnet)

@dev-jodee dev-jodee force-pushed the feat/HOO-382-add-castaway-link-to-idl-tab branch 5 times, most recently from 023be61 to 741f225 Compare March 26, 2026 15:18
add a castaway generate-sdk action that carries program and idlSource context, and gate external navigation behind a confirmation dialog.\n\nreuse the existing download dropdown interaction pattern for idl actions and update idl card tests for both program-metadata and anchor flows.

Refs: HOO-382
@dev-jodee dev-jodee force-pushed the feat/HOO-382-add-castaway-link-to-idl-tab branch from 741f225 to 3713104 Compare March 26, 2026 15:35
@dev-jodee dev-jodee requested a review from Woody4618 March 26, 2026 15:49
@dev-jodee dev-jodee marked this pull request as ready for review March 26, 2026 15:49
@Woody4618 Woody4618 merged commit b452c2f into solana-foundation:master Mar 26, 2026
8 checks passed
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