Skip to content

Commit

Permalink
feat(experimental): add blockNotifications websocket method (#1653)
Browse files Browse the repository at this point in the history
* feat(experimental): add `slotsUpdatesNotifications` websocket method

* feat(experimental): add `blockNotifications` websocket method
  • Loading branch information
buffalojoec authored Oct 6, 2023
1 parent 63bb307 commit 867084a
Show file tree
Hide file tree
Showing 6 changed files with 2,351 additions and 1 deletion.
159 changes: 159 additions & 0 deletions packages/rpc-core/src/response-patcher-allowed-numeric-values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,165 @@ export function getAllowedNumericKeypathsForNotification(): AllowedNumericKeypat
if (!memoizedNotificationKeypaths) {
memoizedNotificationKeypaths = {
accountNotifications: jsonParsedAccountsConfigs.map(c => ['value', ...c]),
blockNotifications: [
['value', 'block', 'blockTime'],
[
'value',
'block',
'transactions',
KEYPATH_WILDCARD,
'meta',
'preTokenBalances',
KEYPATH_WILDCARD,
'accountIndex',
],
[
'value',
'block',
'transactions',
KEYPATH_WILDCARD,
'meta',
'preTokenBalances',
KEYPATH_WILDCARD,
'uiTokenAmount',
'decimals',
],
[
'value',
'block',
'transactions',
KEYPATH_WILDCARD,
'meta',
'postTokenBalances',
KEYPATH_WILDCARD,
'accountIndex',
],
[
'value',
'block',
'transactions',
KEYPATH_WILDCARD,
'meta',
'postTokenBalances',
KEYPATH_WILDCARD,
'uiTokenAmount',
'decimals',
],
['value', 'block', 'transactions', KEYPATH_WILDCARD, 'meta', 'rewards', KEYPATH_WILDCARD, 'commission'],
[
'value',
'block',
'transactions',
KEYPATH_WILDCARD,
'meta',
'innerInstructions',
KEYPATH_WILDCARD,
'index',
],
[
'value',
'block',
'transactions',
KEYPATH_WILDCARD,
'meta',
'innerInstructions',
KEYPATH_WILDCARD,
'instructions',
KEYPATH_WILDCARD,
'programIdIndex',
],
[
'value',
'block',
'transactions',
KEYPATH_WILDCARD,
'meta',
'innerInstructions',
KEYPATH_WILDCARD,
'instructions',
KEYPATH_WILDCARD,
'accounts',
KEYPATH_WILDCARD,
],
[
'value',
'block',
'transactions',
KEYPATH_WILDCARD,
'transaction',
'message',
'addressTableLookups',
KEYPATH_WILDCARD,
'writableIndexes',
KEYPATH_WILDCARD,
],
[
'value',
'block',
'transactions',
KEYPATH_WILDCARD,
'transaction',
'message',
'addressTableLookups',
KEYPATH_WILDCARD,
'readonlyIndexes',
KEYPATH_WILDCARD,
],
[
'value',
'block',
'transactions',
KEYPATH_WILDCARD,
'transaction',
'message',
'instructions',
KEYPATH_WILDCARD,
'programIdIndex',
],
[
'value',
'block',
'transactions',
KEYPATH_WILDCARD,
'transaction',
'message',
'instructions',
KEYPATH_WILDCARD,
'accounts',
KEYPATH_WILDCARD,
],
[
'value',
'block',
'transactions',
KEYPATH_WILDCARD,
'transaction',
'message',
'header',
'numReadonlySignedAccounts',
],
[
'value',
'block',
'transactions',
KEYPATH_WILDCARD,
'transaction',
'message',
'header',
'numReadonlyUnsignedAccounts',
],
[
'value',
'block',
'transactions',
KEYPATH_WILDCARD,
'transaction',
'message',
'header',
'numRequiredSignatures',
],
['value', 'block', 'rewards', KEYPATH_WILDCARD, 'commission'],
],
programNotifications: jsonParsedAccountsConfigs.flatMap(c => [
['value', KEYPATH_WILDCARD, 'account', ...c],
[KEYPATH_WILDCARD, 'account', ...c],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
describe('blockNotifications', () => {
(
['all', { mentionsAccountOrProgram: 'Vote111111111111111111111111111111111111111' }] as (
| 'all'
| { mentionsAccountOrProgram: string }
)[]
).forEach(filter => {
describe(`filter: ${JSON.stringify(filter)}`, () => {
describe('when `transactionDetails` is set to `none`', () => {
describe('when called with rewards set to false', () => {
it.todo('returns an empty array for transactions and an empty array for rewards');
});

describe('when called with rewards set to true', () => {
it.todo('returns no transactions and an array of rewards for rewards');
});
});

describe('when `transactionDetails` is set to `signatures`', () => {
describe('returns transactions with only signatures', () => {
it.todo('when maxSupportedTransactionVersion is set');
it.todo('when maxSupportedTransactionVersion is not set');
it.todo('when called without additional config');
});
});

describe('when `transactionDetails` is set to `accounts`', () => {
describe('returns transactions with only signatures and an annotated list of accounts', () => {
it.todo('when maxSupportedTransactionVersion is set');
it.todo('when maxSupportedTransactionVersion is not set');
it.todo('when called without additional config');
});
});

describe('when `transactionDetails` is set to `full`', () => {
describe('returns transactions with the correct shape', () => {
it.todo('when called with json encoding and maxSupportedTransactionVersion is set');
it.todo('when called with jsonParsed encoding and maxSupportedTransactionVersion is set');
it.todo('when called with base58 encoding and maxSupportedTransactionVersion is set');
it.todo('when called with base64 encoding and maxSupportedTransactionVersion is set');
it.todo('when called with json encoding and maxSupportedTransactionVersion is not set');
it.todo('when called with jsonParsed encoding and maxSupportedTransactionVersion is not set');
it.todo('when called with base58 encoding and maxSupportedTransactionVersion is not set');
it.todo('when called with base64 encoding and maxSupportedTransactionVersion is not set');
it.todo('when called without additional config');
});
});
});
});
});
Loading

0 comments on commit 867084a

Please sign in to comment.