@solana/rpc-subscriptions-api 6.3.1 → 6.3.2-canary-20260313112147

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/index.ts ADDED
@@ -0,0 +1,261 @@
1
+ import {
2
+ createRpcSubscriptionsApi,
3
+ executeRpcPubSubSubscriptionPlan,
4
+ RpcSubscriptionsApi,
5
+ RpcSubscriptionsApiMethods,
6
+ } from '@solana/rpc-subscriptions-spec';
7
+ import {
8
+ AllowedNumericKeypaths,
9
+ getDefaultRequestTransformerForSolanaRpc,
10
+ getDefaultResponseTransformerForSolanaRpcSubscriptions,
11
+ jsonParsedAccountsConfigs,
12
+ KEYPATH_WILDCARD,
13
+ RequestTransformerConfig,
14
+ } from '@solana/rpc-transformers';
15
+
16
+ import { AccountNotificationsApi } from './account-notifications';
17
+ import { BlockNotificationsApi } from './block-notifications';
18
+ import { LogsNotificationsApi } from './logs-notifications';
19
+ import { ProgramNotificationsApi } from './program-notifications';
20
+ import { RootNotificationsApi } from './root-notifications';
21
+ import { SignatureNotificationsApi } from './signature-notifications';
22
+ import { SlotNotificationsApi } from './slot-notifications';
23
+ import { SlotsUpdatesNotificationsApi } from './slots-updates-notifications';
24
+ import { VoteNotificationsApi } from './vote-notifications';
25
+
26
+ export type SolanaRpcSubscriptionsApi = AccountNotificationsApi &
27
+ LogsNotificationsApi &
28
+ ProgramNotificationsApi &
29
+ RootNotificationsApi &
30
+ SignatureNotificationsApi &
31
+ SlotNotificationsApi;
32
+ export type SolanaRpcSubscriptionsApiUnstable = BlockNotificationsApi &
33
+ SlotsUpdatesNotificationsApi &
34
+ VoteNotificationsApi;
35
+
36
+ export type {
37
+ AccountNotificationsApi,
38
+ BlockNotificationsApi,
39
+ LogsNotificationsApi,
40
+ ProgramNotificationsApi,
41
+ RootNotificationsApi,
42
+ SignatureNotificationsApi,
43
+ SlotNotificationsApi,
44
+ SlotsUpdatesNotificationsApi,
45
+ VoteNotificationsApi,
46
+ };
47
+
48
+ type Config = RequestTransformerConfig;
49
+
50
+ function createSolanaRpcSubscriptionsApi_INTERNAL<TApi extends RpcSubscriptionsApiMethods>(
51
+ config?: Config,
52
+ ): RpcSubscriptionsApi<TApi> {
53
+ const requestTransformer = getDefaultRequestTransformerForSolanaRpc(config);
54
+ const responseTransformer = getDefaultResponseTransformerForSolanaRpcSubscriptions({
55
+ allowedNumericKeyPaths: getAllowedNumericKeypaths(),
56
+ });
57
+ return createRpcSubscriptionsApi<TApi>({
58
+ planExecutor({ request, ...rest }) {
59
+ return executeRpcPubSubSubscriptionPlan({
60
+ ...rest,
61
+ responseTransformer,
62
+ subscribeRequest: { ...request, methodName: request.methodName.replace(/Notifications$/, 'Subscribe') },
63
+ unsubscribeMethodName: request.methodName.replace(/Notifications$/, 'Unsubscribe'),
64
+ });
65
+ },
66
+ requestTransformer,
67
+ });
68
+ }
69
+
70
+ export function createSolanaRpcSubscriptionsApi<TApi extends RpcSubscriptionsApiMethods = SolanaRpcSubscriptionsApi>(
71
+ config?: Config,
72
+ ): RpcSubscriptionsApi<TApi> {
73
+ return createSolanaRpcSubscriptionsApi_INTERNAL<TApi>(config);
74
+ }
75
+
76
+ export function createSolanaRpcSubscriptionsApi_UNSTABLE(config?: Config) {
77
+ return createSolanaRpcSubscriptionsApi_INTERNAL<SolanaRpcSubscriptionsApi & SolanaRpcSubscriptionsApiUnstable>(
78
+ config,
79
+ );
80
+ }
81
+
82
+ let memoizedKeypaths: AllowedNumericKeypaths<
83
+ RpcSubscriptionsApi<SolanaRpcSubscriptionsApi & SolanaRpcSubscriptionsApiUnstable>
84
+ >;
85
+
86
+ /**
87
+ * These are keypaths at the end of which you will find a numeric value that should *not* be upcast
88
+ * to a `bigint`. These are values that are legitimately defined as `u8` or `usize` on the backend.
89
+ */
90
+ function getAllowedNumericKeypaths(): AllowedNumericKeypaths<
91
+ RpcSubscriptionsApi<SolanaRpcSubscriptionsApi & SolanaRpcSubscriptionsApiUnstable>
92
+ > {
93
+ if (!memoizedKeypaths) {
94
+ memoizedKeypaths = {
95
+ accountNotifications: jsonParsedAccountsConfigs.map(c => ['value', ...c]),
96
+ blockNotifications: [
97
+ [
98
+ 'value',
99
+ 'block',
100
+ 'transactions',
101
+ KEYPATH_WILDCARD,
102
+ 'meta',
103
+ 'preTokenBalances',
104
+ KEYPATH_WILDCARD,
105
+ 'accountIndex',
106
+ ],
107
+ [
108
+ 'value',
109
+ 'block',
110
+ 'transactions',
111
+ KEYPATH_WILDCARD,
112
+ 'meta',
113
+ 'preTokenBalances',
114
+ KEYPATH_WILDCARD,
115
+ 'uiTokenAmount',
116
+ 'decimals',
117
+ ],
118
+ [
119
+ 'value',
120
+ 'block',
121
+ 'transactions',
122
+ KEYPATH_WILDCARD,
123
+ 'meta',
124
+ 'postTokenBalances',
125
+ KEYPATH_WILDCARD,
126
+ 'accountIndex',
127
+ ],
128
+ [
129
+ 'value',
130
+ 'block',
131
+ 'transactions',
132
+ KEYPATH_WILDCARD,
133
+ 'meta',
134
+ 'postTokenBalances',
135
+ KEYPATH_WILDCARD,
136
+ 'uiTokenAmount',
137
+ 'decimals',
138
+ ],
139
+ ['value', 'block', 'transactions', KEYPATH_WILDCARD, 'meta', 'rewards', KEYPATH_WILDCARD, 'commission'],
140
+ [
141
+ 'value',
142
+ 'block',
143
+ 'transactions',
144
+ KEYPATH_WILDCARD,
145
+ 'meta',
146
+ 'innerInstructions',
147
+ KEYPATH_WILDCARD,
148
+ 'index',
149
+ ],
150
+ [
151
+ 'value',
152
+ 'block',
153
+ 'transactions',
154
+ KEYPATH_WILDCARD,
155
+ 'meta',
156
+ 'innerInstructions',
157
+ KEYPATH_WILDCARD,
158
+ 'instructions',
159
+ KEYPATH_WILDCARD,
160
+ 'programIdIndex',
161
+ ],
162
+ [
163
+ 'value',
164
+ 'block',
165
+ 'transactions',
166
+ KEYPATH_WILDCARD,
167
+ 'meta',
168
+ 'innerInstructions',
169
+ KEYPATH_WILDCARD,
170
+ 'instructions',
171
+ KEYPATH_WILDCARD,
172
+ 'accounts',
173
+ KEYPATH_WILDCARD,
174
+ ],
175
+ [
176
+ 'value',
177
+ 'block',
178
+ 'transactions',
179
+ KEYPATH_WILDCARD,
180
+ 'transaction',
181
+ 'message',
182
+ 'addressTableLookups',
183
+ KEYPATH_WILDCARD,
184
+ 'writableIndexes',
185
+ KEYPATH_WILDCARD,
186
+ ],
187
+ [
188
+ 'value',
189
+ 'block',
190
+ 'transactions',
191
+ KEYPATH_WILDCARD,
192
+ 'transaction',
193
+ 'message',
194
+ 'addressTableLookups',
195
+ KEYPATH_WILDCARD,
196
+ 'readonlyIndexes',
197
+ KEYPATH_WILDCARD,
198
+ ],
199
+ [
200
+ 'value',
201
+ 'block',
202
+ 'transactions',
203
+ KEYPATH_WILDCARD,
204
+ 'transaction',
205
+ 'message',
206
+ 'instructions',
207
+ KEYPATH_WILDCARD,
208
+ 'programIdIndex',
209
+ ],
210
+ [
211
+ 'value',
212
+ 'block',
213
+ 'transactions',
214
+ KEYPATH_WILDCARD,
215
+ 'transaction',
216
+ 'message',
217
+ 'instructions',
218
+ KEYPATH_WILDCARD,
219
+ 'accounts',
220
+ KEYPATH_WILDCARD,
221
+ ],
222
+ [
223
+ 'value',
224
+ 'block',
225
+ 'transactions',
226
+ KEYPATH_WILDCARD,
227
+ 'transaction',
228
+ 'message',
229
+ 'header',
230
+ 'numReadonlySignedAccounts',
231
+ ],
232
+ [
233
+ 'value',
234
+ 'block',
235
+ 'transactions',
236
+ KEYPATH_WILDCARD,
237
+ 'transaction',
238
+ 'message',
239
+ 'header',
240
+ 'numReadonlyUnsignedAccounts',
241
+ ],
242
+ [
243
+ 'value',
244
+ 'block',
245
+ 'transactions',
246
+ KEYPATH_WILDCARD,
247
+ 'transaction',
248
+ 'message',
249
+ 'header',
250
+ 'numRequiredSignatures',
251
+ ],
252
+ ['value', 'block', 'rewards', KEYPATH_WILDCARD, 'commission'],
253
+ ],
254
+ programNotifications: jsonParsedAccountsConfigs.flatMap(c => [
255
+ ['value', KEYPATH_WILDCARD, 'account', ...c],
256
+ [KEYPATH_WILDCARD, 'account', ...c],
257
+ ]),
258
+ };
259
+ }
260
+ return memoizedKeypaths;
261
+ }
@@ -0,0 +1,62 @@
1
+ import type { Address } from '@solana/addresses';
2
+ import type { Signature } from '@solana/keys';
3
+ import type { Commitment, SolanaRpcResponse, TransactionError } from '@solana/rpc-types';
4
+
5
+ type LogsNotificationsApiNotification = SolanaRpcResponse<
6
+ Readonly<{
7
+ /** Error if transaction failed, null if transaction succeeded. */
8
+ err: TransactionError | null;
9
+ /** Array of log messages the transaction instructions output during execution. */
10
+ logs: readonly string[];
11
+ /** Transaction signature as base-58 encoded string */
12
+ signature: Signature;
13
+ }>
14
+ >;
15
+
16
+ type LogsNotificationsApiConfig = Readonly<{
17
+ /**
18
+ * Get notified on logs from new transactions that have reached this level of commitment.
19
+ *
20
+ * @defaultValue Whichever default is applied by the underlying {@link RpcSubscriptionsApi} in
21
+ * use. For example, when using an API created by a `createSolanaRpcSubscriptions*()` helper,
22
+ * the default commitment is `"confirmed"` unless configured otherwise. Unmitigated by an API
23
+ * layer on the client, the default commitment applied by the server is `"finalized"`.
24
+ */
25
+ commitment?: Commitment;
26
+ }>;
27
+
28
+ export type LogsNotificationsApi = {
29
+ /**
30
+ * Subscribe to receive notifications containing the logs of all non-vote transactions.
31
+ *
32
+ * {@label non-vote}
33
+ * @see https://solana.com/docs/rpc/websocket/logssubscribe
34
+ */
35
+ logsNotifications(filter: 'all', config?: LogsNotificationsApiConfig): LogsNotificationsApiNotification;
36
+ /**
37
+ * Subscribe to receive notifications containing the logs of all transactions.
38
+ *
39
+ * {@label all}
40
+ * @see https://solana.com/docs/rpc/websocket/logssubscribe
41
+ */
42
+ logsNotifications(filter: 'allWithVotes', config?: LogsNotificationsApiConfig): LogsNotificationsApiNotification;
43
+ /**
44
+ * Subscribe to receive notifications containing the logs of transactions that mention the
45
+ * supplied program or account.
46
+
47
+ * {@label all-that-mention}
48
+ * @see https://solana.com/docs/rpc/websocket/logssubscribe
49
+ */
50
+ logsNotifications(
51
+ filter: {
52
+ /**
53
+ * This filter matches when a transaction mentions the single address provided.
54
+ *
55
+ * This filter currently only supports one address per method call. Listing additional
56
+ * addresses will result in an error.
57
+ */
58
+ mentions: [Address];
59
+ },
60
+ config?: LogsNotificationsApiConfig,
61
+ ): LogsNotificationsApiNotification;
62
+ };
@@ -0,0 +1,145 @@
1
+ import type { Address } from '@solana/addresses';
2
+ import type {
3
+ AccountInfoBase,
4
+ AccountInfoWithBase58Bytes,
5
+ AccountInfoWithBase58EncodedData,
6
+ AccountInfoWithBase64EncodedData,
7
+ AccountInfoWithBase64EncodedZStdCompressedData,
8
+ AccountInfoWithJsonData,
9
+ AccountInfoWithPubkey,
10
+ Commitment,
11
+ GetProgramAccountsDatasizeFilter,
12
+ GetProgramAccountsMemcmpFilter,
13
+ SolanaRpcResponse,
14
+ } from '@solana/rpc-types';
15
+
16
+ type ProgramNotificationsApiNotificationBase<TData> = SolanaRpcResponse<AccountInfoWithPubkey<AccountInfoBase & TData>>;
17
+
18
+ type ProgramNotificationsApiCommonConfig = Readonly<{
19
+ /**
20
+ * Get notified when a modification to an account has reached this level of commitment.
21
+ *
22
+ * @defaultValue Whichever default is applied by the underlying {@link RpcSubscriptionsApi} in
23
+ * use. For example, when using an API created by a `createSolanaRpcSubscriptions*()` helper,
24
+ * the default commitment is `"confirmed"` unless configured otherwise. Unmitigated by an API
25
+ * layer on the client, the default commitment applied by the server is `"finalized"`.
26
+ */
27
+ commitment?: Commitment;
28
+ /**
29
+ * Limits results to those that match all of these filters.
30
+ *
31
+ * This is useful when your aim is to find program accounts whose purpose is uniquely determined
32
+ * by having a data buffer of a known size, or whose data contains a known series of bytes (eg.
33
+ * a discriminator).
34
+ *
35
+ * You can specify up to 4 filters.
36
+ *
37
+ * @defaultValue When omitted, no filters are applied.
38
+ */
39
+ filters?: readonly Readonly<GetProgramAccountsDatasizeFilter | GetProgramAccountsMemcmpFilter>[];
40
+ }>;
41
+
42
+ export type ProgramNotificationsApi = {
43
+ /**
44
+ * Subscribe for notifications when there is a change in the {@link Lamports} or data of any
45
+ * account owned by the program at the given address changes.
46
+ *
47
+ * The notification format is the same as seen in the
48
+ * {@link GetProgramAccountsApi.getProgramAccounts} RPC HTTP method.
49
+ *
50
+ * If the account has data, it will be returned in the response as a tuple whose first element
51
+ * is a base64-encoded string.
52
+ *
53
+ * {@label base64}
54
+ * @see https://solana.com/docs/rpc/websocket/programsubscribe
55
+ */
56
+ programNotifications(
57
+ programId: Address,
58
+ config: ProgramNotificationsApiCommonConfig &
59
+ Readonly<{
60
+ encoding: 'base64';
61
+ }>,
62
+ ): ProgramNotificationsApiNotificationBase<AccountInfoWithBase64EncodedData>;
63
+ /**
64
+ * Subscribe for notifications when there is a change in the {@link Lamports} or data of any
65
+ * account owned by the program at the given address changes.
66
+ *
67
+ * The notification format is the same as seen in the
68
+ * {@link GetProgramAccountsApi.getProgramAccounts} RPC HTTP method.
69
+ *
70
+ * If the account has data, it will first be compressed using
71
+ * [ZStandard](https://facebook.github.io/zstd/) and the result will be returned in the response
72
+ * as a tuple whose first element is a base64-encoded string.
73
+ *
74
+ * {@label base64-zstd-compressed}
75
+ * @see https://solana.com/docs/rpc/websocket/programsubscribe
76
+ */
77
+ programNotifications(
78
+ programId: Address,
79
+ config: ProgramNotificationsApiCommonConfig &
80
+ Readonly<{
81
+ encoding: 'base64+zstd';
82
+ }>,
83
+ ): ProgramNotificationsApiNotificationBase<AccountInfoWithBase64EncodedZStdCompressedData>;
84
+ /**
85
+ * Subscribe for notifications when there is a change in the {@link Lamports} or data of any
86
+ * account owned by the program at the given address changes.
87
+ *
88
+ * The notification format is the same as seen in the
89
+ * {@link GetProgramAccountsApi.getProgramAccounts} RPC HTTP method.
90
+ *
91
+ * If the account has data, the server will attempt to process it using a parser specific to the
92
+ * account's owning program. If successful, the parsed data will be returned in the response as
93
+ * JSON. Otherwise, the raw account data will be returned in the response as a tuple whose first
94
+ * element is a base64-encoded string.
95
+ *
96
+ * {@label parsed}
97
+ * @see https://solana.com/docs/rpc/websocket/programsubscribe
98
+ */
99
+ programNotifications(
100
+ programId: Address,
101
+ config: ProgramNotificationsApiCommonConfig &
102
+ Readonly<{
103
+ encoding: 'jsonParsed';
104
+ }>,
105
+ ): ProgramNotificationsApiNotificationBase<AccountInfoWithJsonData>;
106
+ /**
107
+ * Subscribe for notifications when there is a change in the {@link Lamports} or data of any
108
+ * account owned by the program at the given address changes.
109
+ *
110
+ * The notification format is the same as seen in the
111
+ * {@link GetProgramAccountsApi.getProgramAccounts} RPC HTTP method.
112
+ *
113
+ * If the account has data, it will be returned in the response as a tuple whose first element
114
+ * is a base58-encoded string. If the account contains more than 129 bytes of data, the `data`
115
+ * field will materialize as the string `"error: data too large for bs58 encoding"`.
116
+ *
117
+ * {@label base58}
118
+ * @see https://solana.com/docs/rpc/websocket/programsubscribe
119
+ */
120
+ programNotifications(
121
+ programId: Address,
122
+ config: ProgramNotificationsApiCommonConfig &
123
+ Readonly<{
124
+ encoding: 'base58';
125
+ }>,
126
+ ): ProgramNotificationsApiNotificationBase<AccountInfoWithBase58EncodedData>;
127
+ /**
128
+ * Subscribe for notifications when there is a change in the {@link Lamports} or data of any
129
+ * account owned by the program at the given address changes.
130
+ *
131
+ * The notification format is the same as seen in the
132
+ * {@link GetProgramAccountsApi.getProgramAccounts} RPC HTTP method.
133
+ *
134
+ * If the account has data, it will be returned in the response as a base58-encoded string. If
135
+ * the account contains more than 129 bytes of data, the `data` field will materialize as the
136
+ * string `"error: data too large for bs58 encoding"`.
137
+ *
138
+ * {@label base58-legacy}
139
+ * @see https://solana.com/docs/rpc/websocket/programsubscribe
140
+ */
141
+ programNotifications(
142
+ programId: Address,
143
+ config?: ProgramNotificationsApiCommonConfig,
144
+ ): ProgramNotificationsApiNotificationBase<AccountInfoWithBase58Bytes>;
145
+ };
@@ -0,0 +1,13 @@
1
+ import type { Slot } from '@solana/rpc-types';
2
+
3
+ type RootNotificationsApiNotification = Slot;
4
+
5
+ export type RootNotificationsApi = {
6
+ /**
7
+ * Subscribe to receive notifications anytime a new root is set by the validator.
8
+ *
9
+ * @returns The number of the rooted slot
10
+ * @see https://solana.com/docs/rpc/websocket/rootsubscribe
11
+ */
12
+ rootNotifications(): RootNotificationsApiNotification;
13
+ };
@@ -0,0 +1,74 @@
1
+ import type { Signature } from '@solana/keys';
2
+ import type { Commitment, SolanaRpcResponse, TransactionError } from '@solana/rpc-types';
3
+
4
+ type SignatureNotificationsApiNotificationReceived = SolanaRpcResponse<Readonly<'receivedSignature'>>;
5
+
6
+ type SignatureNotificationsApiNotificationProcessed = SolanaRpcResponse<
7
+ Readonly<{
8
+ /** Error if transaction failed, null if transaction succeeded. */
9
+ err: TransactionError | null;
10
+ }>
11
+ >;
12
+
13
+ type SignatureNotificationsApiConfigBase = Readonly<{
14
+ /**
15
+ * Get notified when the transaction with the specified signature has reached this level of
16
+ * commitment.
17
+ *
18
+ * @defaultValue Whichever default is applied by the underlying {@link RpcSubscriptionsApi} in
19
+ * use. For example, when using an API created by a `createSolanaRpcSubscriptions*()` helper,
20
+ * the default commitment is `"confirmed"` unless configured otherwise. Unmitigated by an API
21
+ * layer on the client, the default commitment applied by the server is `"finalized"`.
22
+ */
23
+ commitment?: Commitment;
24
+ /**
25
+ * Whether or not to subscribe for notifications when signatures are received by the RPC, in
26
+ * addition to when they are processed.
27
+ *
28
+ * @defaultValue false
29
+ */
30
+ enableReceivedNotification?: boolean;
31
+ }>;
32
+
33
+ export type SignatureNotificationsApi = {
34
+ /**
35
+ * Subscribe to a receive a notification when the transaction identified by the given signature
36
+ * is received by the cluster, then again when it reaches the specified level of commitment.
37
+ *
38
+ * This subscription will not issue notifications for events that have already happened. To
39
+ * fetch the commitment status of any transaction at a point in time use the
40
+ * {@link GetSignatureStatusesApi.getSignatureStatuses | getSignatureStatuses} method of the RPC
41
+ * API.
42
+ *
43
+ * @param signature Transaction signature as base-58 encoded string
44
+ *
45
+ * @see https://solana.com/docs/rpc/websocket/signaturesubscribe
46
+ */
47
+ signatureNotifications(
48
+ signature: Signature,
49
+ config: Readonly<{
50
+ enableReceivedNotification: true;
51
+ }> &
52
+ SignatureNotificationsApiConfigBase,
53
+ ): SignatureNotificationsApiNotificationProcessed | SignatureNotificationsApiNotificationReceived;
54
+ /**
55
+ * Subscribe to a receive a notification when the transaction identified by the given signature
56
+ * reaches the specified level of commitment.
57
+ *
58
+ * This subscription will not issue notifications for events that have already happened. To
59
+ * fetch the commitment status of any transaction at a point in time use the
60
+ * {@link GetSignatureStatusesApi.getSignatureStatuses | getSignatureStatuses} method of the RPC
61
+ * API.
62
+ *
63
+ * @param signature Transaction signature as base-58 encoded string
64
+ *
65
+ * @see https://solana.com/docs/rpc/websocket/signaturesubscribe
66
+ */
67
+ signatureNotifications(
68
+ signature: Signature,
69
+ config?: Readonly<{
70
+ enableReceivedNotification?: false;
71
+ }> &
72
+ SignatureNotificationsApiConfigBase,
73
+ ): SignatureNotificationsApiNotificationProcessed;
74
+ };
@@ -0,0 +1,19 @@
1
+ import type { Slot } from '@solana/rpc-types';
2
+
3
+ type SlotNotificationsApiNotification = Readonly<{
4
+ /** The parent slot */
5
+ parent: Slot;
6
+ /** The current root slot */
7
+ root: Slot;
8
+ /** The newly set slot value */
9
+ slot: Slot;
10
+ }>;
11
+
12
+ export type SlotNotificationsApi = {
13
+ /**
14
+ * Subscribe to receive notifications anytime a slot is processed by the validator.
15
+ *
16
+ * @see https://solana.com/docs/rpc/websocket/slotsubscribe
17
+ */
18
+ slotNotifications(): SlotNotificationsApiNotification;
19
+ };
@@ -0,0 +1,51 @@
1
+ import type { Slot } from '@solana/rpc-types';
2
+
3
+ type SlotsUpdatesNotificationsApiNotificationBase = Readonly<{
4
+ /** The newly updated slot */
5
+ slot: Slot;
6
+ /** The Unix timestamp of the update in milliseconds */
7
+ timestamp: bigint;
8
+ type: 'completed' | 'firstShredReceived' | 'optimisticConfirmation' | 'root';
9
+ }>;
10
+
11
+ type SlotsUpdatesNotificationsApiNotificationCreatedBank = Readonly<{
12
+ /** The parent slot */
13
+ parent: Slot;
14
+ type: 'createdBank';
15
+ }> &
16
+ SlotsUpdatesNotificationsApiNotificationBase;
17
+
18
+ type SlotsUpdatesNotificationsApiNotificationDead = Readonly<{
19
+ err: string;
20
+ type: 'dead';
21
+ }> &
22
+ SlotsUpdatesNotificationsApiNotificationBase;
23
+
24
+ type SlotsUpdatesNotificationsApiNotificationFrozen = Readonly<{
25
+ stats: Readonly<{
26
+ maxTransactionsPerEntry: bigint;
27
+ numFailedTransactions: bigint;
28
+ numSuccessfulTransactions: bigint;
29
+ numTransactionEntries: bigint;
30
+ }>;
31
+ type: 'frozen';
32
+ }> &
33
+ SlotsUpdatesNotificationsApiNotificationBase;
34
+
35
+ type SlotsUpdatesNotificationsApiNotification =
36
+ | SlotsUpdatesNotificationsApiNotificationBase
37
+ | SlotsUpdatesNotificationsApiNotificationCreatedBank
38
+ | SlotsUpdatesNotificationsApiNotificationDead
39
+ | SlotsUpdatesNotificationsApiNotificationFrozen;
40
+
41
+ export type SlotsUpdatesNotificationsApi = {
42
+ /**
43
+ * Subscribe to receive a notification from the validator on a variety of updates on every slot.
44
+ *
45
+ * This subscription is unstable. The format of this subscription may change in the future, and
46
+ * may not be supported by every node.
47
+ *
48
+ * @see https://solana.com/docs/rpc/websocket/slotsupdatessubscribe
49
+ */
50
+ slotsUpdatesNotifications(): SlotsUpdatesNotificationsApiNotification;
51
+ };
@@ -0,0 +1,32 @@
1
+ import type { Address } from '@solana/addresses';
2
+ import type { Signature } from '@solana/keys';
3
+ import type { Blockhash, Slot, UnixTimestamp } from '@solana/rpc-types';
4
+
5
+ type VoteNotificationsApiNotification = Readonly<{
6
+ /** The vote hash */
7
+ hash: Blockhash;
8
+ /** The signature of the transaction that contained this vote */
9
+ signature: Signature;
10
+ /** The slots covered by the vote */
11
+ slots: readonly Slot[];
12
+ /** The timestamp of the vote */
13
+ timestamp: UnixTimestamp | null;
14
+ /** The address of the vote account */
15
+ votePubkey: Address;
16
+ }>;
17
+
18
+ export type VoteNotificationsApi = {
19
+ /**
20
+ * Subscribe to receive notifications anytime a new vote is observed in gossip.
21
+ *
22
+ * These votes are pre-consensus therefore there is no guarantee these votes will enter the
23
+ * ledger.
24
+ *
25
+ * This subscription is unstable and only available if the validator was started with the
26
+ * `--rpc-pubsub-enable-vote-subscription` flag. The format of this subscription may change in
27
+ * the future.
28
+ *
29
+ * @see https://solana.com/docs/rpc/websocket/votesubscribe
30
+ */
31
+ voteNotifications(): VoteNotificationsApiNotification;
32
+ };