Kit
Type aliases

RpcSubscriptionsTransportFromClusterUrl

RpcSubscriptionsTransportFromClusterUrl<TClusterUrl> = TClusterUrl extends DevnetUrl ? RpcSubscriptionsTransportDevnet : TClusterUrl extends TestnetUrl ? RpcSubscriptionsTransportTestnet : TClusterUrl extends MainnetUrl ? RpcSubscriptionsTransportMainnet : RpcSubscriptionsTransport

Given a ClusterUrl, this utility type will resolve to as specific a RpcSubscriptionsTransport as possible.

Type Parameters

Type Parameter
TClusterUrl extends ClusterUrl

Example

function createCustomSubscriptionsTransport<TClusterUrl extends ClusterUrl>(
    clusterUrl: TClusterUrl,
): RpcSubscriptionsTransportFromClusterUrl<TClusterUrl> {
    /* ... */
}
 
const transport = createCustomSubscriptionsTransport(testnet('ws://api.testnet.solana.com'));
transport satisfies RpcSubscriptionsTransportTestnet; // OK

On this page