| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Morley.Client.RPC.AsRPC
Contents
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
- type family AsRPC (a :: k) :: k
- deriveRPC :: String -> Q [Dec]
- deriveRPCWithStrategy :: String -> GenericStrategy -> Q [Dec]
- deriveManyRPC :: String -> [String] -> Q [Dec]
- deriveManyRPCWithStrategy :: String -> [String] -> GenericStrategy -> Q [Dec]
- valueAsRPC :: HasCallStack => Value t -> Value (AsRPC t)
- notesAsRPC :: Notes t -> Notes (AsRPC t)
- rpcSingIEvi :: forall (t :: T). SingI t :- SingI (AsRPC t)
- rpcHasNoOpEvi :: forall (t :: T). (SingI t, HasNoOp t) => HasNoOp t :- HasNoOp (AsRPC t)
- rpcHasNoBigMapEvi :: forall (t :: T). SingI t => Dict (HasNoBigMap (AsRPC t))
- rpcHasNoNestedBigMapsEvi :: forall (t :: T). SingI t => Dict (HasNoNestedBigMaps (AsRPC t))
- rpcHasNoContractEvi :: forall (t :: T). (SingI t, HasNoContract t) => HasNoContract t :- HasNoContract (AsRPC t)
- rpcStorageScopeEvi :: forall (t :: T). StorageScope t :- StorageScope (AsRPC t)
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
| type AsRPC 'TNat Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC 'TNat = 'TNat | |
| type AsRPC 'TBytes Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC 'TBytes = 'TBytes | |
| type AsRPC 'TAddress Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC 'TAddress = 'TAddress | |
| type AsRPC 'TBls12381Fr Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC 'TBls12381Fr = 'TBls12381Fr | |
| type AsRPC 'TBls12381G1 Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC 'TBls12381G1 = 'TBls12381G1 | |
| type AsRPC 'TBls12381G2 Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC 'TBls12381G2 = 'TBls12381G2 | |
| type AsRPC 'TBool Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC 'TBool = 'TBool | |
| type AsRPC 'TChainId Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC 'TChainId = 'TChainId | |
| type AsRPC 'TChest Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC 'TChest = 'TChest | |
| type AsRPC 'TChestKey Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC 'TChestKey = 'TChestKey | |
| type AsRPC 'TInt Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC 'TInt = 'TInt | |
| type AsRPC 'TKey Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC 'TKey = 'TKey | |
| type AsRPC 'TKeyHash Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC 'TKeyHash = 'TKeyHash | |
| type AsRPC 'TMutez Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC 'TMutez = 'TMutez | |
| type AsRPC 'TNever Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC 'TNever = 'TNever | |
| type AsRPC 'TOperation Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC 'TOperation = 'TOperation | |
| type AsRPC 'TSignature Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC 'TSignature = 'TSignature | |
| type AsRPC 'TString Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC 'TString = 'TString | |
| type AsRPC 'TTimestamp Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC 'TTimestamp = 'TTimestamp | |
| type AsRPC 'TUnit Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC 'TUnit = 'TUnit | |
| type AsRPC ('TContract t :: T) Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC ('TContract t :: T) = 'TContract t | |
| type AsRPC ('TList t :: T) Source # | |
Defined in Morley.Client.RPC.AsRPC | |
| type AsRPC ('TOption t :: T) Source # | |
Defined in Morley.Client.RPC.AsRPC | |
| type AsRPC ('TSet t :: T) Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC ('TSet t :: T) = 'TSet t | |
| type AsRPC ('TTicket t :: T) Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC ('TTicket t :: T) = 'TTicket t | |
| type AsRPC ('TPair t1 t2 :: T) Source # | |
Defined in Morley.Client.RPC.AsRPC | |
| type AsRPC ('TBigMap _1 _2 :: T) Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC ('TBigMap _1 _2 :: T) = 'TNat | |
| type AsRPC ('TLambda t1 t2 :: T) Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC ('TLambda t1 t2 :: T) = 'TLambda t1 t2 | |
| type AsRPC ('TMap k v :: T) Source # | |
Defined in Morley.Client.RPC.AsRPC | |
| type AsRPC ('TOr t1 t2 :: T) Source # | |
Defined in Morley.Client.RPC.AsRPC | |
| type AsRPC Bool Source # | |
Defined in Morley.Client.RPC.AsRPC | |
| type AsRPC Integer Source # | |
Defined in Morley.Client.RPC.AsRPC | |
| type AsRPC Natural Source # | |
Defined in Morley.Client.RPC.AsRPC | |
| type AsRPC () Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC () = () | |
| type AsRPC ByteString Source # | |
Defined in Morley.Client.RPC.AsRPC | |
| type AsRPC Empty Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC Empty = Empty | |
| type AsRPC Never Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC Never = Never | |
| type AsRPC OpenChest Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC OpenChest = OpenChest | |
| type AsRPC MText Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC MText = MText | |
| type AsRPC Operation Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC Operation = Operation | |
| type AsRPC EpAddress Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC EpAddress = EpAddress | |
| type AsRPC Address Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC Address = Address | |
| type AsRPC ChainId Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC ChainId = ChainId | |
| type AsRPC Mutez Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC Mutez = Mutez | |
| type AsRPC Timestamp Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC Timestamp = Timestamp | |
| type AsRPC KeyHash Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC KeyHash = KeyHash | |
| type AsRPC PublicKey Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC PublicKey = PublicKey | |
| type AsRPC Signature Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC Signature = Signature | |
| type AsRPC Bls12381Fr Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC Bls12381Fr = Bls12381Fr | |
| type AsRPC Bls12381G1 Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC Bls12381G1 = Bls12381G1 | |
| type AsRPC Bls12381G2 Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC Bls12381G2 = Bls12381G2 | |
| type AsRPC Chest Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC Chest = Chest | |
| type AsRPC ChestKey Source # | |
Defined in Morley.Client.RPC.AsRPC type AsRPC ChestKey = ChestKey | |
| type AsRPC ([a] :: Type) Source # | |
Defined in Morley.Client.RPC.AsRPC | |
| type AsRPC (Maybe a :: Type) Source # | |
| type AsRPC (Identity a :: Type) Source # | |
| type AsRPC (Set a :: Type) Source # | |
Defined in Morley.Client.RPC.AsRPC | |
| type AsRPC (FutureContract p :: Type) Source # | |
Defined in Morley.Client.RPC.AsRPC | |
| type AsRPC (ChestT a :: Type) Source # | |
Defined in Morley.Client.RPC.AsRPC | |
| type AsRPC (OpenChestT a :: Type) Source # | |
Defined in Morley.Client.RPC.AsRPC | |
| type AsRPC (Packed a :: Type) Source # | |
Defined in Morley.Client.RPC.AsRPC | |
| type AsRPC (TSignature a :: Type) Source # | |
Defined in Morley.Client.RPC.AsRPC | |
| type AsRPC (ShouldHaveEntrypoints a :: Type) Source # | |
Defined in Morley.Client.RPC.AsRPC | |
| type AsRPC (UParam entries :: Type) Source # | |
Defined in Morley.Client.RPC.AsRPC | |
| type AsRPC (ContractRef arg :: Type) Source # | |
Defined in Morley.Client.RPC.AsRPC | |
| type AsRPC (Either l r :: Type) Source # | |
| type AsRPC ((a, b) :: Type) Source # | |
Defined in Morley.Client.RPC.AsRPC | |
| type AsRPC (Map k v :: Type) Source # | |
| type AsRPC (TAddress p vd :: Type) Source # | |
Defined in Morley.Client.RPC.AsRPC | |
| type AsRPC (inp :-> out :: Type) Source # | |
Defined in Morley.Client.RPC.AsRPC | |
| type AsRPC (Hash alg a :: Type) Source # | |
Defined in Morley.Client.RPC.AsRPC | |
| type AsRPC (ParameterWrapper deriv cp :: Type) Source # | |
Defined in Morley.Client.RPC.AsRPC | |
| type AsRPC (View_ a r :: Type) Source # | |
Defined in Morley.Client.RPC.AsRPC | |
| type AsRPC (Void_ a r :: Type) Source # | |
Defined in Morley.Client.RPC.AsRPC | |
| type AsRPC (BigMap k v :: Type) Source # | |
Defined in Morley.Client.RPC.AsRPC | |
| type AsRPC (Extensible x :: Type) Source # | |
Defined in Morley.Client.RPC.AsRPC | |
| type AsRPC (Value' instr t :: Type) Source # | |
Defined in Morley.Client.RPC.AsRPC | |
| type AsRPC ((a, b, c) :: Type) Source # | |
| type AsRPC (NamedF Maybe a name :: Type) Source # | |
| type AsRPC (NamedF Identity a name :: Type) Source # | |
| type AsRPC ((a, b, c, d) :: Type) Source # | |
| type AsRPC ((a, b, c, d, e) :: Type) Source # | |
| type AsRPC ((a, b, c, d, e, f) :: Type) Source # | |
| type AsRPC ((a, b, c, d, e, f, g) :: Type) Source # | |
| type AsRPC (TAddress cp :: Type -> Type) Source # | |
Defined in Morley.Client.RPC.AsRPC | |
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
...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.