Skip to content

refactor: use explicit named RPC types instead of derived types - #265

Merged
macalinao merged 4 commits into
masterfrom
explicit-rpc-types
Oct 19, 2026
Merged

macalinao merged 4 commits into
masterfrom
explicit-rpc-types

Conversation

@macalinao

@macalinao macalinao commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

Replaces derived types (Parameters<typeof ...>, ReturnType<typeof ...>, inline literal unions) with the named types the granular @solana/* packages and our own packages already export.

Changed

  • solana-batch-accounts-loader RpcWithGetMultipleAccounts: Parameters<typeof import("@solana/accounts").fetchEncodedAccounts>[0] → Rpc<GetMultipleAccountsApi>. The shape is the same; @solana/accounts just doesn't export its GetMultipleAccountsApi. Adds @solana/rpc-api and @solana/rpc-spec as peer and dev deps, which is why this is a minor bump. Type-checked against a full kit rpc (grill-headless-provider) and against fetchEncodedAccounts (gill-extra/fetch-token-info-for-mint).
  • grill internal prepare-transaction-message, create-sign-tx, create-send-tx and their tests: ReturnType<typeof simulateTransactionFactory> → SimulateTransactionFunction (already exported by gill-extra).
  • grill create-send-tx.test.ts: Partial<Parameters<typeof createSendTX>[0]> → Partial<CreateSendTXParams>.
  • gill-extra confirm-transaction.test.ts: "processed" | "confirmed" | "finalized" | null → Commitment | null.
  • example-dapp token-balances.tsx: ReturnType<typeof address> → Address.

Left alone

  • BatchAccountsLoaderConfig.commitment: "confirmed" | "finalized": Commitment would also allow "processed", which widens the public type.
  • gill-extra SimulateTransactionConfig / SimulateTransactionFunction, which index into SimulateTransactionApi["simulateTransaction"]: rpc-api doesn't export the config or response types.
  • das-api createDasRpc config, Parameters<typeof createDefaultRpcTransport<TClusterUrl>>[0]: DefaultRpcTransportConfig isn't exported from @solana/rpc.
  • das-api test Parameters<RpcTransport>[0]: the transport request config type isn't exported from @solana/rpc-spec.
  • gill-extra ConfirmedTransaction: derived from our own getConfirmedTransaction, and rpc-api has no named jsonParsed transaction response type.
  • grill GillUseQueryDefaultOptions, Parameters<typeof useQuery>[0]: this is TanStack, not Solana, and switching to UseQueryOptions could change how generic defaults resolve.

Summary by Sourcery

Adopt explicit exported types across RPC-related APIs and examples to improve type clarity and maintainability without changing runtime behavior.

Enhancements:

  • Replace derived RPC and domain types with explicit named types from the granular Solana and project packages while preserving existing behavior.
  • Align transaction simulation, send-transaction parameters, commitment values, and example address types with their exported named definitions.

Build:

  • Add @solana/rpc-api and @solana/rpc-spec as peer dependencies for the batch accounts loader.

@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Repository: macalinao/grill/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ee30ee1f-066f-40a4-a5f7-e32ea8d88714
📥 Commits

Reviewing files that changed from the base of the PR and between 6f7ec92 and 3461ae8.

⛔ Files ignored due to path filters: 1
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing: 11
  • .changeset/explicit-rpc-types.md
  • apps/example-dapp/src/routes/examples/token-balances.tsx
  • packages/gill-extra/src/confirm-transaction.test.ts
  • packages/grill/src/utils/internal/create-send-tx.test.ts
  • packages/grill/src/utils/internal/create-send-tx.ts
  • packages/grill/src/utils/internal/create-sign-tx.test.ts
  • packages/grill/src/utils/internal/create-sign-tx.ts
  • packages/grill/src/utils/internal/prepare-transaction-message.test.ts
  • packages/grill/src/utils/internal/prepare-transaction-message.ts
  • packages/solana-batch-accounts-loader/package.json
  • packages/solana-batch-accounts-loader/src/types.ts
+------------------------------------------------+
| Love the optimism of `// should never happen`. |
+------------------------------------------------+
  \
   \     /)/)
        ( '')
        /  |
      o(___)
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai

sourcery-ai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

This refactor standardizes RPC, transaction, commitment, and address annotations on named exports from the Solana and project packages, including a new explicit RPC API type for the batch accounts loader and its associated peer dependencies. The changes are type-only and should not alter runtime behavior; review primarily for type compatibility, dependency correctness, and preservation of intentionally narrower types.

File-Level Changes

Change Details Files
Replace derived RPC and transaction-related types with explicit exported types while preserving runtime behavior and existing shapes.
  • Declare the batch accounts loader RPC as Rpc.
  • Use SimulateTransactionFunction for injected simulation callbacks in transaction preparation, signing, sending, and tests.
  • Use CreateSendTXParams, Commitment, and Address instead of locally derived or inline types.
  • Add @solana/rpc-api and @solana/rpc-spec as peer dependencies for the batch accounts loader.
packages/solana-batch-accounts-loader/src/types.ts
packages/solana-batch-accounts-loader/package.json
packages/grill/src/utils/internal/prepare-transaction-message.ts
packages/grill/src/utils/internal/prepare-transaction-message.test.ts
packages/grill/src/utils/internal/create-sign-tx.ts
packages/grill/src/utils/internal/create-sign-tx.test.ts
packages/grill/src/utils/internal/create-send-tx.ts
packages/grill/src/utils/internal/create-send-tx.test.ts
packages/gill-extra/src/confirm-transaction.test.ts
apps/example-dapp/src/routes/examples/token-balances.tsx
Update package metadata and lockfile to publish the dependency and versioning changes.
  • Record a minor release for the batch accounts loader and a patch release for grill.
  • Update resolved dependency data for the new peer dependencies.
.changeset/explicit-rpc-types.md
bun.lock

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
grill-example-dapp 3461ae8 Commit Preview URL

Branch Preview URL
Oct 12 2026, 11:12 AM

@macalinao
macalinao marked this pull request as ready for review October 19, 2026 00:10
@macalinao
macalinao merged commit 753c448 into master Oct 19, 2026
9 checks passed
@macalinao
macalinao deleted the explicit-rpc-types branch October 19, 2026 00:10

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

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.

1 participant