@statechannels/client-api-schema

client-api-schema package

Defines and validates the data types communicated between an app and a wallet

Remarks

Also exposes functions that can validate messages (Requests, Responses, Notifications and Error Responses), as well as to cast them as the correct Type.

Example request:

{
"jsonrpc": "2.0",
"method": "PushMessage",
"id": 1,
"params": {
"recipient": "user123",
"sender": "user456",
"data": "0x123.."
}
}

Example response:

{
"jsonrpc": "2.0",
"id": 1,
"result": {"success": true}
}

Functions

FunctionDescription
isJsonRpcErrorResponse(message)(BETA) Type guard for JsonRpcErrorResponse
isJsonRpcNotification(message)(BETA) Type guard for JsonRpcNotification
isJsonRpcRequest(message)(BETA) Type guard for JsonRpcRequest
isJsonRpcResponse(message)(BETA) Type guard for JsonRpcResponse
isStateChannelsErrorResponse(message)
isStateChannelsNotification(message)
isStateChannelsRequest(message)
isStateChannelsResponse(message)
parseErrorResponse(jsonBlob)Validates an error response against the API schema & returns the input cast to the correctly narrowed type.
parseNotification(jsonBlob)Validates a notification against the API schema & returns the input cast to the correctly narrowed type.
parseRequest(jsonBlob)Validates a request against the API schema & returns the input cast to the correctly narrowed type.
parseResponse(jsonBlob)Validates a response against the API schema & returns the input cast to the correctly narrowed type.

Interfaces

InterfaceDescription
AllocationArray of destination-amount pairings for a given token
AllocationItemAssigns some amount of an unspecified asset to a destination
ApproveBudgetAndFundParams
ChallengeChannelParams
ChannelBudget
ChannelResult
CloseAndWithdrawParams
CloseChannelParams
CreateChannelParams
DomainBudget
Funds
GetBudgetParams
GetChannelsParams
GetStateParams
JoinChannelParams
JsonRpcError(BETA) Specifies error object as per JSON-RPC 2.0 Specification
JsonRpcErrorResponse(BETA) Specifies response headers as per JSON-RPC 2.0 Specification
JsonRpcNotification(BETA) Specifies notification headers as per JSON-RPC 2.0 Specification
JsonRpcRequest(BETA) Specifies request headers as per JSON-RPC 2.0 Specification
JsonRpcResponse(BETA) Specifies response headers as per JSON-RPC 2.0 Specification
MessageFormat of message sent from the wallet to the app
ParticipantContainer for data specific to a single state channel participant
SyncChannelParams
TokenBudget
UpdateChannelParams

Type Aliases

Type AliasDescription
AddressEthereum Address ^0x([a-fA-F0-9]{40})|0$
AllocationsIncluded for backwards compatibility
ApproveBudgetAndFundRequest
ApproveBudgetAndFundResponse
BudgetUpdatedNotification
Bytes32Bytes32 ^0x([a-fA-F0-9]{64})$
ChallengeChannelError
ChallengeChannelRequest
ChallengeChannelResponse
ChannelClosed
ChannelClosingNotification
ChannelIdNitro ChannelId ^0x([a-fA-F0-9]{64})$
ChannelNotFound
ChannelProposedNotification
ChannelStatus
ChannelUpdatedNotification
CloseAndWithdrawError
CloseAndWithdrawRequest
CloseAndWithdrawResponse
CloseChannelError
CloseChannelRequest
CloseChannelResponse
CreateChannelError
CreateChannelRequest
CreateChannelResponse
EnableEthereumError
EnableEthereumRequest
EnableEthereumResponse
ErrorCodesError codes that might be returned by the wallet
ExternalDestinationNitro ChannelId ^0x(0{24})([a-fA-F0-9]{40})$
FundingStrategy
GetBudgetRequest
GetBudgetResponse
GetChannelsRequest
GetChannelsResponse
GetStateError
GetStateRequest
GetStateResponse
GetWalletInformationRequest
GetWalletInformationResponse
InvalidAppData
InvalidTransition
JoinChannelError
JoinChannelRequest
JoinChannelResponse
MessageQueuedNotification
NotYourTurn
PushMessageError
PushMessageParams
PushMessageRequest
PushMessageResponse
PushMessageResult
StateChannelsError
StateChannelsErrorResponse
StateChannelsJsonRpcMessage
StateChannelsNotification
StateChannelsNotificationType
StateChannelsRequest
StateChannelsResponse
SyncChannelError
SyncChannelRequest
SyncChannelResponse
UiNotification
Uint256Uint256 ^0x([a-fA-F0-9]{64})$
Uint48
UpdateChannelError
UpdateChannelRequest
UpdateChannelResponse
WalletReady
Last updated on by geoknee