Add granular RPC connection plugins and deprecate rpc/localhostRpc#184
Conversation
🦋 Changeset detectedLatest commit: 6ffdfe5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
trevor-cortex
left a comment
There was a problem hiding this comment.
Summary
This PR introduces four new granular plugins — rpcConnection, rpcSubscriptionsConnection, solanaRpcConnection, and solanaRpcSubscriptionsConnection — that let users set up RPC and RPC Subscriptions connections independently. The existing rpc and localhostRpc plugins are deprecated (with migration snippets in their docblocks) and moved to the new solana-rpc.ts file alongside the Solana-specific convenience plugins. All docs, examples, and tests are updated to use the new API.
Clean separation of concerns: rpc.ts now holds the generic plugins (accept any Rpc/RpcSubscriptions instance), while solana-rpc.ts holds the Solana-specific URL-based helpers and the deprecated functions. Nice layering with the solana* variants delegating to the generic ones.
LGTM — this is a well-structured change. One minor nit inline.
Things to watch out for
-
Unused import —
extendClientis imported insolana-rpc.tsbut never used there (the deprecated functions use it, but they could also delegate to the generic plugins like the new functions do). Not a big deal since the deprecated code is a direct move, but it's a minor cleanup opportunity. -
Re-export collision — Both
rpc.tsandsolana-rpc.tsare re-exported viaindex.ts. Sincerpc.tsno longer exportsrpcorlocalhostRpc, and those now live insolana-rpc.ts, there's no name collision. Just worth verifying this stays clean. -
Tests for deprecated functions removed — The old
rpcandlocalhostRpctests were replaced with tests for the new plugins. There are no remaining tests for the deprecated functions themselves. This is probably fine since they're just moved code, but a reviewer might want to consider whether a smoke test for backwards compat is worth keeping.
Notes for subsequent reviewers
- The deprecated
rpc()function insolana-rpc.tsstill does its owncreateSolanaRpc+createSolanaRpcSubscriptions+extendClientinline rather than delegating tosolanaRpcConnection/solanaRpcSubscriptionsConnection. This is intentional to preserve exact behavior (single.use()call installing both), but worth noting. - Docs and examples are comprehensive and consistently updated across all packages.
- The changeset correctly marks this as a
minorfor@solana/kit-plugin-rpc.
There was a problem hiding this comment.
The new plugins look correct, but I'm a bit unclear why we're changing this as part of the current changes. Bundling RPC and subscriptions with a default transform from one URL to the other that works for most cases seemed reasonable to me.
Edit: I see the upstack PR adds a plugin that combines them and that logic moves there, works for me!
Merge activity
|
This PR introduces four new granular plugins for setting up RPC and RPC Subscriptions connections independently: `rpcConnection`, `rpcSubscriptionsConnection`, `solanaRpcConnection`, and `solanaRpcSubscriptionsConnection`. The existing `rpc` and `localhostRpc` plugins, which inject both RPC and RPC Subscriptions in one go, are deprecated in favor of the new alternatives. Docblocks with migration snippets are included on the deprecated functions.
6a41ad4 to
6ffdfe5
Compare

This PR introduces four new granular plugins for setting up RPC and RPC Subscriptions connections independently:
rpcConnection,rpcSubscriptionsConnection,solanaRpcConnection, andsolanaRpcSubscriptionsConnection. The existingrpcandlocalhostRpcplugins, which inject both RPC and RPC Subscriptions in one go, are deprecated in favor of the new alternatives. Docblocks with migration snippets are included on the deprecated functions.