splitSolanaRpcResponse

Call Signature

function splitSolanaRpcResponse<T>(notification): object;

Decomposes a notification that may or may not be wrapped in a SolanaRpcResponse envelope into its value and slot halves. Runtime-detects the envelope shape via duck-type ('context' in x && 'value' in x); raw notifications without the envelope pass through with slot: undefined.

Accepts T | undefined so callers can pipe straight from store.getUnifiedState().data without an external null-check.

Type Parameters

Type ParameterDescription
TThe raw notification shape.

Parameters

ParameterTypeDescription
notificationSolanaRpcResponse<T>The value to decompose, or undefined while the store hasn't yet produced one.

Returns

object

{ value, slot } where value is the unwrapped inner value (or the original notification when it doesn't match the envelope shape) and slot is lifted from context.slot (or undefined for raw notifications).

NameType
slotbigint
valueT

Example

splitSolanaRpcResponse({ context: { slot: 99n }, value: { lamports: 5n } });
// → { value: { lamports: 5n }, slot: 99n }
 
splitSolanaRpcResponse({ slot: 10n, parent: 9n, root: 8n });
// → { value: { slot: 10n, parent: 9n, root: 8n }, slot: undefined }
 
splitSolanaRpcResponse(undefined);
// → { value: undefined, slot: undefined }

Call Signature

function splitSolanaRpcResponse(notification): object;

Decomposes a notification that may or may not be wrapped in a SolanaRpcResponse envelope into its value and slot halves. Runtime-detects the envelope shape via duck-type ('context' in x && 'value' in x); raw notifications without the envelope pass through with slot: undefined.

Accepts T | undefined so callers can pipe straight from store.getUnifiedState().data without an external null-check.

Parameters

ParameterTypeDescription
notificationundefinedThe value to decompose, or undefined while the store hasn't yet produced one.

Returns

object

{ value, slot } where value is the unwrapped inner value (or the original notification when it doesn't match the envelope shape) and slot is lifted from context.slot (or undefined for raw notifications).

NameType
slotundefined
valueundefined

Example

splitSolanaRpcResponse({ context: { slot: 99n }, value: { lamports: 5n } });
// → { value: { lamports: 5n }, slot: 99n }
 
splitSolanaRpcResponse({ slot: 10n, parent: 9n, root: 8n });
// → { value: { slot: 10n, parent: 9n, root: 8n }, slot: undefined }
 
splitSolanaRpcResponse(undefined);
// → { value: undefined, slot: undefined }

Call Signature

function splitSolanaRpcResponse<T>(notification): object;

Decomposes a notification that may or may not be wrapped in a SolanaRpcResponse envelope into its value and slot halves. Runtime-detects the envelope shape via duck-type ('context' in x && 'value' in x); raw notifications without the envelope pass through with slot: undefined.

Accepts T | undefined so callers can pipe straight from store.getUnifiedState().data without an external null-check.

Type Parameters

Type ParameterDescription
TThe raw notification shape.

Parameters

ParameterTypeDescription
notification| Readonly<{ context: Readonly<{ slot: Slot; }>; value: T; }> | undefinedThe value to decompose, or undefined while the store hasn't yet produced one.

Returns

object

{ value, slot } where value is the unwrapped inner value (or the original notification when it doesn't match the envelope shape) and slot is lifted from context.slot (or undefined for raw notifications).

NameType
slotbigint | undefined
valueT | undefined

Example

splitSolanaRpcResponse({ context: { slot: 99n }, value: { lamports: 5n } });
// → { value: { lamports: 5n }, slot: 99n }
 
splitSolanaRpcResponse({ slot: 10n, parent: 9n, root: 8n });
// → { value: { slot: 10n, parent: 9n, root: 8n }, slot: undefined }
 
splitSolanaRpcResponse(undefined);
// → { value: undefined, slot: undefined }

Call Signature

function splitSolanaRpcResponse<T>(notification): object;

Decomposes a notification that may or may not be wrapped in a SolanaRpcResponse envelope into its value and slot halves. Runtime-detects the envelope shape via duck-type ('context' in x && 'value' in x); raw notifications without the envelope pass through with slot: undefined.

Accepts T | undefined so callers can pipe straight from store.getUnifiedState().data without an external null-check.

Type Parameters

Type ParameterDescription
TThe raw notification shape.

Parameters

ParameterTypeDescription
notificationTThe value to decompose, or undefined while the store hasn't yet produced one.

Returns

object

{ value, slot } where value is the unwrapped inner value (or the original notification when it doesn't match the envelope shape) and slot is lifted from context.slot (or undefined for raw notifications).

NameType
slotundefined
valueT

Example

splitSolanaRpcResponse({ context: { slot: 99n }, value: { lamports: 5n } });
// → { value: { lamports: 5n }, slot: 99n }
 
splitSolanaRpcResponse({ slot: 10n, parent: 9n, root: 8n });
// → { value: { slot: 10n, parent: 9n, root: 8n }, slot: undefined }
 
splitSolanaRpcResponse(undefined);
// → { value: undefined, slot: undefined }

On this page