Socket
Socket
Sign inDemoInstall

@solana/rpc-subscriptions-spec

Package Overview
Dependencies
Maintainers
14
Versions
796
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solana/rpc-subscriptions-spec - npm Package Compare versions

Comparing version 2.0.0-canary-20241004181514 to 2.0.0-canary-20241004181751

dist/types/rpc-subscriptions-channel.d.ts

1

dist/types/index.d.ts
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

7

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc