Module

Ctl.Internal.QueryM.JsonRpc2

Provides basics types and operations for working with JSON RPC protocol used by Ogmios

#JsonRpc2Call

newtype JsonRpc2Call (i :: Type) (o :: Type)

A wrapper for tying arguments and response types to request building.

#JsonRpc2Request

type JsonRpc2Request (a :: Type) = { id :: ListenerId, jsonrpc :: String, method :: String, params :: a }

Structure of all json rpc2.0 websocket requests

#buildRequest

buildRequest :: forall (i :: Type) (o :: Type). JsonRpc2Call i o -> i -> Effect { body :: Aeson, id :: String }

Create a JsonRpc2 request body and id

#mkCallType

mkCallType :: forall (a :: Type) (i :: Type) (o :: Type). EncodeAeson (JsonRpc2Request a) => { jsonrpc :: String } -> { method :: String, params :: i -> a } -> JsonRpc2Call i o

Creates a "jsonrpc call" which ties together request input and response output types along with a way to create a request object.

#JsonRpc2Response

type JsonRpc2Response = { error :: Maybe Aeson, id :: ListenerId, jsonrpc :: String, method :: Maybe String, result :: Maybe Aeson }

Structure of all json rpc websocket responses

#decodeResult

decodeResult :: forall o. (Aeson -> Either JsonDecodeError o) -> Aeson -> Either OgmiosDecodeError o

Decode "result" field of ogmios response.

#ogmiosDecodeErrorToError

#OgmiosError

#DecodeOgmios

class DecodeOgmios o  where

Variation of DecodeAeson for ogmios response, defines how to parse full ogmios reponse.

Members

#decodeErrorOrResult

decodeErrorOrResult :: forall o. { parseError :: Aeson -> Either JsonDecodeError o } -> { parseResult :: Aeson -> Either JsonDecodeError o } -> Aeson -> Either OgmiosDecodeError o

Decode "result" field or if absent the error field of ogmios response.

#parseJsonRpc2ResponseId

parseJsonRpc2ResponseId :: Aeson -> Either JsonDecodeError ListenerId

Parse just ID from the response

#pprintOgmiosDecodeError

#pprintOgmiosError

Modules