isSolanaRpcResponse

function isSolanaRpcResponse<T>(
    notification,
): notification is Readonly<{
    context: Readonly<{ slot: Slot }>;
    value: UnwrapRpcResponse;
}>;

Type-guards a notification as a SolanaRpcResponse envelope. Validates the shape by duck-typing for context.slot: bigint and the presence of value.

The narrowed type is SolanaRpcResponse<UnwrapRpcResponse<T>>. In the false branch, notification retains its original type.

Type Parameters

Type ParameterDescription
TThe notification shape, which may be a raw value, an envelope, or a union of the two.

Parameters

ParameterTypeDescription
notification| T | Readonly<{ context: Readonly<{ slot: Slot; }>; value: UnwrapRpcResponse; }>The value to test.

Returns

notification is Readonly<{ context: Readonly<{ slot: Slot }>; value: UnwrapRpcResponse }>

true when notification is a SolanaRpcResponse envelope, narrowing accordingly.

Example

if (isSolanaRpcResponse(notification)) {
    return { slot: notification.context.slot, value: notification.value };
}

On this page