@solana/rpc-subscriptions-spec
Advanced tools
Comparing version 2.0.0-canary-20241004181514 to 2.0.0-canary-20241004181751
export * from './rpc-subscriptions-request'; | ||
export * from './rpc-subscriptions'; | ||
export * from './rpc-subscriptions-api'; | ||
export * from './rpc-subscriptions-channel'; | ||
export * from './rpc-subscriptions-transport'; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@solana/rpc-subscriptions-spec", | ||
"version": "2.0.0-canary-20241004181514", | ||
"version": "2.0.0-canary-20241004181751", | ||
"description": "A generic implementation of JSON RPC Subscriptions using proxies", | ||
@@ -57,4 +57,5 @@ "exports": { | ||
"dependencies": { | ||
"@solana/errors": "2.0.0-canary-20241004181514", | ||
"@solana/rpc-spec-types": "2.0.0-canary-20241004181514" | ||
"@solana/errors": "2.0.0-canary-20241004181751", | ||
"@solana/rpc-spec-types": "2.0.0-canary-20241004181751", | ||
"@solana/subscribable": "2.0.0-canary-20241004181751" | ||
}, | ||
@@ -61,0 +62,0 @@ "peerDependencies": { |
@@ -17,2 +17,42 @@ [![npm][npm-image]][npm-url] | ||
TODO | ||
This package contains types that describe the implementation of the JSON RPC Subscriptions API, as well as methods to create one. It can be used standalone, but it is also exported as part of the Solana JavaScript SDK [`@solana/web3.js@rc`](https://github.com/solana-labs/solana-web3.js/tree/master/packages/library). | ||
This API is designed to be used as follows: | ||
```ts | ||
const rpcSubscriptions = | ||
// Step 1 - Create an `RpcSubscriptions` instance. This may be stateful. | ||
createSolanaRpcSubscriptions(mainnet('wss://api.mainnet-beta.solana.com')); | ||
const response = await rpcSubscriptions | ||
// Step 2 - Call supported methods on it to produce `PendingRpcSubscriptionsRequest` objects. | ||
.slotNotifications({ commitment: 'confirmed' }) | ||
// Step 3 - Call the `subscribe()` method on those pending requests to trigger them. | ||
.subscribe({ abortSignal: AbortSignal.timeout(10_000) }); | ||
// Step 4 - Iterate over the result. | ||
try { | ||
for await (const slotNotification of slotNotifications) { | ||
console.log('Got a slot notification', slotNotification); | ||
} | ||
} catch (e) { | ||
console.error('The subscription closed unexpectedly', e); | ||
} finally { | ||
console.log('We have stopped listening for notifications'); | ||
} | ||
``` | ||
## Types | ||
### `RpcSubscriptionsChannel<TOutboundMessage, TInboundMessage>` | ||
A channel is a `DataPublisher` that you can subscribe to events of type `RpcSubscriptionChannelEvents<TInboundMessage>`. Additionally, you can use it to send messages of type `TOutboundMessage` back to the remote end by calling the `send(message)` method. | ||
### `RpcSubscriptionsChannelCreator<TOutboundMessage, TInboundMessage>` | ||
A channel creator is a function that accepts an `AbortSignal`, returns a new `RpcSubscriptionsChannel`, and tears down the channel when the abort signal fires. | ||
### `RpcSubscriptionChannelEvents<TInboundMessage>` | ||
Subscription channels publish events on two channel names: | ||
- `error`: Fires when the channel closes unexpectedly | ||
- `message`: Fires on every message received from the remote end |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
119451
25
707
58
4
+ Added@solana/errors@2.0.0-canary-20241004181751(transitive)
+ Added@solana/rpc-spec-types@2.0.0-canary-20241004181751(transitive)
+ Added@solana/subscribable@2.0.0-canary-20241004181751(transitive)
- Removed@solana/errors@2.0.0-canary-20241004181514(transitive)
- Removed@solana/rpc-spec-types@2.0.0-canary-20241004181514(transitive)