-
Notifications
You must be signed in to change notification settings - Fork 800
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(experimental): add function to create Solana RPC Subscriptio…
…ns using only an URL (#2239) This PR changes the `createSolanaRpcSubscriptions` and `createSolanaRpcSubscriptions_UNSTABLE` functions so that they accepts a `ClusterUrl` as a first parameter and an optional config object as a second parameter. This makes it much easier for 95% of RPC Subscription use-cases to get started with the library: ```ts const rpcSubscriptions = createSolanaRpcSubscriptions("ws://localhost:8899"); // Cluster-aware RPC Subscriptions: const rpcSubscriptions = createSolanaRpcSubscriptions(devnet("ws://api.devnet.solana.com")); const rpcSubscriptions = createSolanaRpcSubscriptions(testnet("ws://api.testnet.solana.com")); const rpcSubscriptions = createSolanaRpcSubscriptions(mainnet("ws://api.mainnet-beta.solana.com")); // With configs: const rpcSubscriptions = createSolanaRpcSubscriptions("ws://localhost:8899", { intervalMs: 500, sendBufferHighWatermark: 0, }); ``` Additionally, this PR adds the `createSolanaRpcSubscriptionsFromTransport` and `createSolanaRpcSubscriptionsFromTransport_UNSTABLE` function allowing the remaining 5% of use-cases to customize their own transport just as easily: ```ts const rpcSubscriptions = createSolanaRpcSubscriptionsFromTransport(myCustomTransport); ``` Note that these functions are cluster aware so, if `myCustomTransport` is of type `RpcSubscriptionsTransportMainnet`, then `rpcSubscriptions` will automatically be of type `RpcSubscriptionsMainnet<SolanaRpcSubscriptionsApi>`. Finally, this PR refactors the cluster typetests to make it clearer what we are trying to tests. --- Fixes #2119
- Loading branch information
1 parent
cd0b6c6
commit fc11993
Showing
3 changed files
with
267 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.