-
Notifications
You must be signed in to change notification settings - Fork 785
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(experimental): add
rootNotifications
websocket method (#1646)
* fix: broken timestamp test * refactor(experimental): change u64 types to slot in slot notifications * feat(experimental): add `slotsUpdatesNotifications` websocket method * feat(experimental): add `slotsUpdatesNotifications` websocket method * feat(experimental): add `rootNotifications` websocket method
- Loading branch information
1 parent
5789147
commit 064cdc3
Showing
4 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
packages/rpc-core/src/rpc-subscriptions/__tests__/root-notifications-test.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
describe('rootNotifications', () => { | ||
// TODO: A change in root takes too long to occur in order for our tests to pass. | ||
it.todo('produces root notifications'); | ||
}); |
19 changes: 19 additions & 0 deletions
19
packages/rpc-core/src/rpc-subscriptions/__typetests__/root-notifications-type-test.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* eslint-disable @typescript-eslint/ban-ts-comment */ | ||
|
||
import { PendingRpcSubscription, RpcSubscriptions } from '@solana/rpc-transport/dist/types/json-rpc-types'; | ||
|
||
import { Slot } from '../../rpc-methods/common'; | ||
import { RootNotificationsApi } from '../root-notifications'; | ||
|
||
async () => { | ||
const rpcSubscriptions = null as unknown as RpcSubscriptions<RootNotificationsApi>; | ||
|
||
type TNotification = Slot; | ||
rpcSubscriptions.rootNotifications() satisfies PendingRpcSubscription<TNotification>; | ||
rpcSubscriptions.rootNotifications().subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< | ||
AsyncIterable<TNotification> | ||
>; | ||
|
||
// @ts-expect-error Takes no params. | ||
rpcSubscriptions.rootNotifications({ commitment: 'finalized' }); | ||
}; |
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
13 changes: 13 additions & 0 deletions
13
packages/rpc-core/src/rpc-subscriptions/root-notifications.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Slot } from '../rpc-methods/common'; | ||
|
||
type RootNotificationsApiNotification = Slot; | ||
|
||
export interface RootNotificationsApi { | ||
/** | ||
* Subscribe to receive notification anytime a new root is set by the validator | ||
*/ | ||
rootNotifications( | ||
// FIXME: https://github.com/solana-labs/solana-web3.js/issues/1389 | ||
NO_CONFIG?: Record<string, never> | ||
): RootNotificationsApiNotification; | ||
} |