morley-client-0.1.0: Client to interact with the Tezos blockchain
Safe HaskellNone
LanguageHaskell2010

Morley.Client.RPC.AsRPC

Description

This module contains a type family for converting a type to its RPC representation, and TemplateHaskell functions for deriving RPC representations for custom types.

Synopsis

Documentation

type family AsRPC (a :: k) :: k Source #

A type-level function that maps a type to its Tezos RPC representation.

For example, when we retrieve a contract's storage using the Tezos RPC, all its BigMaps will be replaced by BigMapIds.

So if a contract has a storage of type T, when we call the Tezos RPC to retrieve it, we must deserialize the micheline expression to the type AsRPC T.

AsRPC (BigMap Integer MText) ~ BigMapId Integer MText
AsRPC [BigMap Integer MText] ~ [BigMapId Integer MText]
AsRPC (MText, (Address, BigMap Integer MText)) ~ (MText, (Address, BigMapId Integer MText))

The following law holds IFF a type t has an IsoValue instance:

ToT (AsRPC t) ~ AsRPC (ToT t)

Instances

Instances details
type AsRPC 'TNat Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC 'TNat = 'TNat
type AsRPC 'TBytes Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC 'TBytes = 'TBytes
type AsRPC 'TAddress Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC 'TAddress = 'TAddress
type AsRPC 'TBls12381Fr Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC 'TBls12381Fr = 'TBls12381Fr
type AsRPC 'TBls12381G1 Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC 'TBls12381G1 = 'TBls12381G1
type AsRPC 'TBls12381G2 Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC 'TBls12381G2 = 'TBls12381G2
type AsRPC 'TBool Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC 'TBool = 'TBool
type AsRPC 'TChainId Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC 'TChainId = 'TChainId
type AsRPC 'TChest Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC 'TChest = 'TChest
type AsRPC 'TChestKey Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC 'TChestKey = 'TChestKey
type AsRPC 'TInt Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC 'TInt = 'TInt
type AsRPC 'TKey Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC 'TKey = 'TKey
type AsRPC 'TKeyHash Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC 'TKeyHash = 'TKeyHash
type AsRPC 'TMutez Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC 'TMutez = 'TMutez
type AsRPC 'TNever Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC 'TNever = 'TNever
type AsRPC 'TOperation Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC 'TOperation = 'TOperation
type AsRPC 'TSignature Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC 'TSignature = 'TSignature
type AsRPC 'TString Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC 'TString = 'TString
type AsRPC 'TTimestamp Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC 'TTimestamp = 'TTimestamp
type AsRPC 'TUnit Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC 'TUnit = 'TUnit
type AsRPC ('TContract t :: T) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC ('TContract t :: T) = 'TContract t
type AsRPC ('TList t :: T) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC ('TList t :: T) = 'TList (AsRPC t)
type AsRPC ('TOption t :: T) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC ('TOption t :: T) = 'TOption (AsRPC t)
type AsRPC ('TSet t :: T) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC ('TSet t :: T) = 'TSet t
type AsRPC ('TTicket t :: T) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC ('TTicket t :: T) = 'TTicket t
type AsRPC ('TPair t1 t2 :: T) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC ('TPair t1 t2 :: T) = 'TPair (AsRPC t1) (AsRPC t2)
type AsRPC ('TBigMap _1 _2 :: T) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC ('TBigMap _1 _2 :: T) = 'TNat
type AsRPC ('TLambda t1 t2 :: T) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC ('TLambda t1 t2 :: T) = 'TLambda t1 t2
type AsRPC ('TMap k v :: T) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC ('TMap k v :: T) = 'TMap k (AsRPC v)
type AsRPC ('TOr t1 t2 :: T) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC ('TOr t1 t2 :: T) = 'TOr (AsRPC t1) (AsRPC t2)
type AsRPC Bool Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC Bool = Bool
type AsRPC Integer Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC Natural Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC () Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC () = ()
type AsRPC ByteString Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC Empty Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC Empty = Empty
type AsRPC Never Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC Never = Never
type AsRPC OpenChest Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC OpenChest = OpenChest
type AsRPC MText Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC MText = MText
type AsRPC Operation Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC Operation = Operation
type AsRPC EpAddress Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC EpAddress = EpAddress
type AsRPC Address Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC Address = Address
type AsRPC ChainId Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC ChainId = ChainId
type AsRPC Mutez Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC Mutez = Mutez
type AsRPC Timestamp Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC Timestamp = Timestamp
type AsRPC KeyHash Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC KeyHash = KeyHash
type AsRPC PublicKey Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC PublicKey = PublicKey
type AsRPC Signature Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC Signature = Signature
type AsRPC Bls12381Fr Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC Bls12381Fr = Bls12381Fr
type AsRPC Bls12381G1 Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC Bls12381G1 = Bls12381G1
type AsRPC Bls12381G2 Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC Bls12381G2 = Bls12381G2
type AsRPC Chest Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC Chest = Chest
type AsRPC ChestKey Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC ChestKey = ChestKey
type AsRPC ([a] :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC ([a] :: Type) = [AsRPC a]
type AsRPC (Maybe a :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC (Maybe a :: Type) = Maybe (AsRPC a)
type AsRPC (Identity a :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC (Identity a :: Type) = Identity (AsRPC a)
type AsRPC (Set a :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC (Set a :: Type) = Set a
type AsRPC (FutureContract p :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC (FutureContract p :: Type) = FutureContract p
type AsRPC (ChestT a :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC (ChestT a :: Type) = ChestT a
type AsRPC (OpenChestT a :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC (OpenChestT a :: Type) = OpenChestT a
type AsRPC (Packed a :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC (Packed a :: Type) = Packed a
type AsRPC (TSignature a :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC (TSignature a :: Type) = TSignature a
type AsRPC (ShouldHaveEntrypoints a :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC (ShouldHaveEntrypoints a :: Type) = ShouldHaveEntrypoints a
type AsRPC (UParam entries :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC (UParam entries :: Type) = UParam entries
type AsRPC (ContractRef arg :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC (ContractRef arg :: Type) = ContractRef arg
type AsRPC (Either l r :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC (Either l r :: Type) = Either (AsRPC l) (AsRPC r)
type AsRPC ((a, b) :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC ((a, b) :: Type) = (AsRPC a, AsRPC b)
type AsRPC (Map k v :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC (Map k v :: Type) = Map k (AsRPC v)
type AsRPC (TAddress p vd :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC (TAddress p vd :: Type) = TAddress p vd
type AsRPC (inp :-> out :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC (inp :-> out :: Type) = inp :-> out
type AsRPC (Hash alg a :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC (Hash alg a :: Type) = Hash alg a
type AsRPC (ParameterWrapper deriv cp :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC (ParameterWrapper deriv cp :: Type) = ParameterWrapper deriv (AsRPC cp)
type AsRPC (View_ a r :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC (View_ a r :: Type) = View_ a r
type AsRPC (Void_ a r :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC (Void_ a r :: Type) = Void_ a r
type AsRPC (BigMap k v :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC (BigMap k v :: Type) = BigMapId k v
type AsRPC (Extensible x :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC (Extensible x :: Type) = Extensible x
type AsRPC (Value' instr t :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC (Value' instr t :: Type) = Value' instr (AsRPC t)
type AsRPC ((a, b, c) :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC ((a, b, c) :: Type) = (AsRPC a, AsRPC b, AsRPC c)
type AsRPC (NamedF Maybe a name :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC (NamedF Maybe a name :: Type) = NamedF Maybe (AsRPC a) name
type AsRPC (NamedF Identity a name :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC (NamedF Identity a name :: Type) = NamedF Identity (AsRPC a) name
type AsRPC ((a, b, c, d) :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC ((a, b, c, d) :: Type) = (AsRPC a, AsRPC b, AsRPC c, AsRPC d)
type AsRPC ((a, b, c, d, e) :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC ((a, b, c, d, e) :: Type) = (AsRPC a, AsRPC b, AsRPC c, AsRPC d, AsRPC e)
type AsRPC ((a, b, c, d, e, f) :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC ((a, b, c, d, e, f) :: Type) = (AsRPC a, AsRPC b, AsRPC c, AsRPC d, AsRPC e, AsRPC f)
type AsRPC ((a, b, c, d, e, f, g) :: Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC ((a, b, c, d, e, f, g) :: Type) = (AsRPC a, AsRPC b, AsRPC c, AsRPC d, AsRPC e, AsRPC f, AsRPC g)
type AsRPC (TAddress cp :: Type -> Type) Source # 
Instance details

Defined in Morley.Client.RPC.AsRPC

type AsRPC (TAddress cp :: Type -> Type) = TAddress cp

deriveRPC :: String -> Q [Dec] Source #

Derive an RPC representation for a type, as well as instances for Generic, IsoValue and AsRPC.

data ExampleStorage a b = ExampleStorage
  { esField1 :: Integer
  , esField2 :: [BigMap Integer MText]
  , esField3 :: a
  }
  deriving stock Generic
  deriving anyclass IsoValue

deriveRPC "ExampleStorage"

Will generate:

data ExampleStorageRPC a b = ExampleStorageRPC
  { esField1RPC :: AsRPC Integer
  , esField2RPC :: AsRPC [BigMap Integer MText]
  , esField3RPC :: AsRPC a
  }

type instance AsRPC (ExampleStorage a b) = ExampleStorageRPC a b
deriving anyclass instance (IsoValue (AsRPC a), IsoValue (AsRPC b)) => IsoValue (ExampleStorageRPC a b)
instance Generic (ExampleStorageRPC a b) where
  ...

deriveRPCWithStrategy :: String -> GenericStrategy -> Q [Dec] Source #

Same as deriveRPC, but uses a custom strategy for deriving a Generic instance.

deriveManyRPC :: String -> [String] -> Q [Dec] Source #

Recursively enumerate data, newtype and type declarations, and derives an RPC representation for each type that doesn't yet have one.

You can also pass in a list of types for which you _don't_ want an RPC representation to be derived.

In this example, deriveManyRPC will generate an RPC representation for A and B, but not for C (because we explicitly said we don't want one) or D (because it already has one).

data B = B
data C = C
data D = D
deriveRPC "D"

data A = A B C D
deriveManyRPC "A" ["C"]

deriveManyRPCWithStrategy :: String -> [String] -> GenericStrategy -> Q [Dec] Source #

Same as deriveManyRPC, but uses a custom strategy for deriving a Generic instance.

Conversions

valueAsRPC :: HasCallStack => Value t -> Value (AsRPC t) Source #

Replace all big_maps in a value with the respective big_map IDs.

Throws an error if it finds a big_map without an ID.

notesAsRPC :: Notes t -> Notes (AsRPC t) Source #

Replace all big_map annotations in a value with nat annotations.

Entailments

rpcSingIEvi :: forall (t :: T). SingI t :- SingI (AsRPC t) Source #

A proof that if a singleton exists for t, then so it does for AsRPC t.

rpcHasNoOpEvi :: forall (t :: T). (SingI t, HasNoOp t) => HasNoOp t :- HasNoOp (AsRPC t) Source #

A proof that if t does not contain any operations, then neither does AsRPC t.

rpcHasNoBigMapEvi :: forall (t :: T). SingI t => Dict (HasNoBigMap (AsRPC t)) Source #

A proof that AsRPC (Value t) does not contain big_maps.

rpcHasNoNestedBigMapsEvi :: forall (t :: T). SingI t => Dict (HasNoNestedBigMaps (AsRPC t)) Source #

A proof that AsRPC (Value t) does not contain big_maps.

rpcHasNoContractEvi :: forall (t :: T). (SingI t, HasNoContract t) => HasNoContract t :- HasNoContract (AsRPC t) Source #

A proof that if t does not contain any contract values, then neither does AsRPC t.

rpcStorageScopeEvi :: forall (t :: T). StorageScope t :- StorageScope (AsRPC t) Source #

A proof that if t is a valid storage type, then so is AsRPC t.