Safe Haskell | None |
---|---|
Language | Haskell2010 |
Morley client that connects with real Tezos network through RPC and tezos-client binary. For more information please refer to README.
Synopsis
- parserInfo :: ("usage" :! Doc) -> ("description" :! String) -> ("header" :! String) -> ("parser" :! Parser s) -> ParserInfo s
- clientConfigParser :: Parser (Maybe Text) -> Parser MorleyClientConfig
- data MorleyClientM a
- data MorleyClientConfig = MorleyClientConfig {
- mccAliasPrefix :: Maybe Text
- mccEndpointUrl :: Maybe BaseUrl
- mccTezosClientPath :: FilePath
- mccMbTezosClientDataDir :: Maybe FilePath
- mccVerbosity :: Word
- mccSecretKey :: Maybe SecretKey
- data MorleyClientEnv' m = MorleyClientEnv {
- mceTezosClient :: TezosClientEnv
- mceLogAction :: ClientLogAction m
- mceSecretKey :: Maybe SecretKey
- mceClientEnv :: ClientEnv
- type MorleyClientEnv = MorleyClientEnv' MorleyClientM
- runMorleyClientM :: MorleyClientEnv -> MorleyClientM a -> IO a
- mkMorleyClientEnv :: MonadIO m => MorleyClientConfig -> IO (MorleyClientEnv' m)
- mceTezosClientL :: forall m. Lens' (MorleyClientEnv' m) TezosClientEnv
- mceLogActionL :: forall m m. Lens (MorleyClientEnv' m) (MorleyClientEnv' m) (ClientLogAction m) (ClientLogAction m)
- mceSecretKeyL :: forall m. Lens' (MorleyClientEnv' m) (Maybe SecretKey)
- mceClientEnvL :: forall m. Lens' (MorleyClientEnv' m) ClientEnv
- newtype MorleyOnlyRpcM a = MorleyOnlyRpcM {}
- data MorleyOnlyRpcEnv = MorleyOnlyRpcEnv {
- moreLogAction :: ClientLogAction MorleyOnlyRpcM
- moreClientEnv :: ClientEnv
- moreSecretKeys :: Map Address SecretKey
- mkMorleyOnlyRpcEnv :: [SecretKey] -> BaseUrl -> Word -> IO MorleyOnlyRpcEnv
- runMorleyOnlyRpcM :: MorleyOnlyRpcEnv -> MorleyOnlyRpcM a -> IO a
- module Morley.Client.Action
- data BlockId
- class (Monad m, MonadCatch m) => HasTezosRpc m where
- getBlockHash :: BlockId -> m Text
- getCounterAtBlock :: BlockId -> Address -> m TezosInt64
- getBlockHeader :: BlockId -> m BlockHeader
- getBlockConstants :: BlockId -> m BlockConstants
- getBlockOperations :: BlockId -> m [[BlockOperation]]
- getProtocolParametersAtBlock :: BlockId -> m ProtocolParameters
- runOperationAtBlock :: BlockId -> RunOperation -> m RunOperationResult
- preApplyOperationsAtBlock :: BlockId -> [PreApplyOperation] -> m [RunOperationResult]
- forgeOperationAtBlock :: BlockId -> ForgeOperation -> m HexJSONByteString
- injectOperation :: HexJSONByteString -> m OperationHash
- getContractScriptAtBlock :: BlockId -> Address -> m OriginationScript
- getContractStorageAtBlock :: BlockId -> Address -> m Expression
- getContractBigMapAtBlock :: BlockId -> Address -> GetBigMap -> m GetBigMapResult
- getBigMapValueAtBlock :: BlockId -> Natural -> Text -> m Expression
- getBigMapValuesAtBlock :: BlockId -> Natural -> Maybe Natural -> Maybe Natural -> m Expression
- getBalanceAtBlock :: BlockId -> Address -> m Mutez
- getDelegateAtBlock :: BlockId -> Address -> m (Maybe KeyHash)
- runCodeAtBlock :: BlockId -> RunCode -> m RunCodeResult
- getChainId :: m ChainId
- getManagerKeyAtBlock :: BlockId -> Address -> m (Maybe PublicKey)
- getContract :: HasTezosRpc m => Address -> m Contract
- getImplicitContractCounter :: HasTezosRpc m => Address -> m TezosInt64
- getContractStorage :: HasTezosRpc m => Address -> m Expression
- getBigMapValue :: HasTezosRpc m => Natural -> Text -> m Expression
- getHeadBlock :: HasTezosRpc m => m Text
- getCounter :: HasTezosRpc m => Address -> m TezosInt64
- getProtocolParameters :: HasTezosRpc m => m ProtocolParameters
- runOperation :: HasTezosRpc m => RunOperation -> m RunOperationResult
- preApplyOperations :: HasTezosRpc m => [PreApplyOperation] -> m [RunOperationResult]
- forgeOperation :: HasTezosRpc m => ForgeOperation -> m HexJSONByteString
- getContractScript :: HasTezosRpc m => Address -> m OriginationScript
- getContractBigMap :: HasTezosRpc m => Address -> GetBigMap -> m GetBigMapResult
- getBalance :: HasTezosRpc m => Address -> m Mutez
- getDelegate :: HasTezosRpc m => Address -> m (Maybe KeyHash)
- runCode :: HasTezosRpc m => RunCode -> m RunCodeResult
- getManagerKey :: HasTezosRpc m => Address -> m (Maybe PublicKey)
- data ClientRpcError
- = ContractFailed Address Expression
- | BadParameter Address Expression
- | EmptyTransaction Address
- | ShiftOverflow Address
- | GasExhaustion Address
- | ClientInternalError InternalError
- data UnexpectedErrors
- data IncorrectRpcResponse
- data RunError
- = RuntimeError Address
- | ScriptRejected Expression
- | BadContractParameter Address
- | InvalidConstant Expression Expression
- | InvalidContract Address
- | InconsistentTypes Expression Expression
- | InvalidPrimitive [Text] Text
- | InvalidSyntacticConstantError Expression Expression
- | InvalidExpressionKind [Text] Text
- | InvalidContractNotation Text
- | UnexpectedContract
- | IllFormedType Expression
- | UnexpectedOperation
- | REEmptyTransaction Address
- | ScriptOverflow
- | GasExhaustedOperation
- | MutezAdditionOverflow [TezosInt64]
- | MutezSubtractionUnderflow [TezosInt64]
- | MutezMultiplicationOverflow TezosInt64 TezosInt64
- | CantPayStorageFee
- | BalanceTooLow ("balance" :! Mutez) ("required" :! Mutez)
- | NonExistingContract Address
- data ValueDecodeFailure = ValueDecodeFailure Text T
- data ValueNotFound = ValueNotFound
- readAllBigMapValues :: forall v k m. (NiceUnpackedValue v, HasTezosRpc m) => BigMapId k v -> m [v]
- readAllBigMapValuesMaybe :: forall v k m. (NiceUnpackedValue v, HasTezosRpc m) => BigMapId k v -> m (Maybe [v])
- readContractBigMapValue :: forall k v m. (PackedValScope k, HasTezosRpc m, SingI v) => Address -> Value k -> m (Value v)
- readBigMapValueMaybe :: forall v k m. (NicePackedValue k, NiceUnpackedValue v, HasTezosRpc m) => BigMapId k v -> k -> m (Maybe v)
- readBigMapValue :: forall v k m. (NicePackedValue k, NiceUnpackedValue v, HasTezosRpc m) => BigMapId k v -> k -> m v
- 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]
- data Alias
- mkAlias :: Text -> Alias
- data AliasHint
- mkAliasHint :: Text -> AliasHint
- data AliasOrAliasHint
- data AddressOrAlias
- = AddressResolved Address
- | AddressAlias Alias
- addressResolved :: ToAddress addr => addr -> AddressOrAlias
- class Monad m => HasTezosClient m where
- signBytes :: AddressOrAlias -> Maybe ScrubbedBytes -> ByteString -> m Signature
- genKey :: AliasOrAliasHint -> m Address
- genFreshKey :: AliasOrAliasHint -> m Address
- revealKey :: Alias -> Maybe ScrubbedBytes -> m ()
- waitForOperation :: OperationHash -> m ()
- rememberContract :: Bool -> Address -> AliasOrAliasHint -> m ()
- importKey :: Bool -> AliasOrAliasHint -> SecretKey -> m ()
- resolveAddressMaybe :: AddressOrAlias -> m (Maybe Address)
- getAlias :: AddressOrAlias -> m Alias
- getPublicKey :: AddressOrAlias -> m PublicKey
- registerDelegate :: AliasOrAliasHint -> Maybe ScrubbedBytes -> m ()
- getTezosClientConfig :: m TezosClientConfig
- calcTransferFee :: AddressOrAlias -> Maybe ScrubbedBytes -> TezosInt64 -> [CalcTransferFeeData] -> m [TezosMutez]
- calcOriginationFee :: UntypedValScope st => CalcOriginationFeeData cp st -> m TezosMutez
- getKeyPassword :: Address -> m (Maybe ScrubbedBytes)
- resolveAddress :: (MonadThrow m, HasTezosClient m) => AddressOrAlias -> m Address
- data TezosClientError
- = UnexpectedClientFailure Int Text Text
- | UnknownAddressAlias Alias
- | UnknownAddress Address
- | AlreadyRevealed Alias
- | InvalidOperationHash OperationHash
- | CounterIsAlreadyUsed Text Text
- | EConnreset
- | ConfigParseError String
- | TezosClientCryptoParseError Text CryptoParseError
- | TezosClientParseAddressError Text ParseAddressError
- | TezosClientParseFeeError Text Text
- | TezosClientUnexpectedOutputFormat Text
- | CantRevealContract Alias
- | ContractSender Address Text
- | EmptyImplicitContract Alias
- | TezosClientUnexpectedSignatureOutput Text
- | TezosClientParseEncryptionTypeError Text Text
- disableAlphanetWarning :: IO ()
- data ParserInfo a
Command line parser
parserInfo :: ("usage" :! Doc) -> ("description" :! String) -> ("header" :! String) -> ("parser" :! Parser s) -> ParserInfo s #
Full client monad and environment
data MorleyClientM a Source #
Instances
data MorleyClientConfig Source #
Data necessary for morley client initialization.
MorleyClientConfig | |
|
Instances
Show MorleyClientConfig Source # | |
Defined in Morley.Client.Init showsPrec :: Int -> MorleyClientConfig -> ShowS # show :: MorleyClientConfig -> String # showList :: [MorleyClientConfig] -> ShowS # |
data MorleyClientEnv' m Source #
Runtime environment for morley client.
MorleyClientEnv | |
|
Instances
MonadReader MorleyClientEnv MorleyClientM Source # | |
Defined in Morley.Client.Full ask :: MorleyClientM MorleyClientEnv # local :: (MorleyClientEnv -> MorleyClientEnv) -> MorleyClientM a -> MorleyClientM a # reader :: (MorleyClientEnv -> a) -> MorleyClientM a # | |
HasLog MorleyClientEnv Message MorleyClientM Source # | |
Defined in Morley.Client.Full getLogAction :: MorleyClientEnv -> LogAction MorleyClientM Message # setLogAction :: LogAction MorleyClientM Message -> MorleyClientEnv -> MorleyClientEnv # overLogAction :: (LogAction MorleyClientM Message -> LogAction MorleyClientM Message) -> MorleyClientEnv -> MorleyClientEnv # logActionL :: Lens' MorleyClientEnv (LogAction MorleyClientM Message) # | |
HasTezosClientEnv (MorleyClientEnv' m) Source # | |
Defined in Morley.Client.Env |
runMorleyClientM :: MorleyClientEnv -> MorleyClientM a -> IO a Source #
Run MorleyClientM
action within given MorleyClientEnv
. Retry action
in case of invalid counter error.
mkMorleyClientEnv :: MonadIO m => MorleyClientConfig -> IO (MorleyClientEnv' m) Source #
Construct MorleyClientEnv
.
tezos-client
path is taken fromMorleyClientConfig
, but can be overridden usingMORLEY_TEZOS_CLIENT
environment variable.- Node data is taken from
tezos-client
config and can be overridden byMorleyClientConfig
. - The rest is taken from
MorleyClientConfig
as is.
Lens
mceTezosClientL :: forall m. Lens' (MorleyClientEnv' m) TezosClientEnv Source #
mceLogActionL :: forall m m. Lens (MorleyClientEnv' m) (MorleyClientEnv' m) (ClientLogAction m) (ClientLogAction m) Source #
mceSecretKeyL :: forall m. Lens' (MorleyClientEnv' m) (Maybe SecretKey) Source #
mceClientEnvL :: forall m. Lens' (MorleyClientEnv' m) ClientEnv Source #
Only-RPC client monad and environment
newtype MorleyOnlyRpcM a Source #
Monad that implements HasTezosClient
and HasTezosRpc
classes and
can be used for high-level actions as an alternative to MorleyClientM
.
Instances
data MorleyOnlyRpcEnv Source #
Environment used by MorleyOnlyRpcM
.
MorleyOnlyRpcEnv | |
|
Instances
mkMorleyOnlyRpcEnv :: [SecretKey] -> BaseUrl -> Word -> IO MorleyOnlyRpcEnv Source #
Construct MorleyOnlyRpcEnv
.
- Full
MorleyClientConfig
is not passed because we need just 2 things from it. - Log action is built the same way as for
MorleyClientEnv
. - All secret keys are passed as an argument.
runMorleyOnlyRpcM :: MorleyOnlyRpcEnv -> MorleyOnlyRpcM a -> IO a Source #
Run MorleyOnlyRpcM
action within given MorleyOnlyRpcEnv
. Retry action
in case of invalid counter error.
High-level actions
module Morley.Client.Action
RPC
A block identifier as submitted to RPC.
A block can be referenced by head
, genesis
, level or block hash
HeadId | Identifier referring to the head block. |
GenesisId | Identifier referring to the genesis block. |
LevelId Natural | Identifier referring to a block by its level. |
BlockHashId Text | Idenfitier referring to a block by its hash in Base58Check notation. |
AtDepthId Natural | Identifier of a block at specific depth relative to |
Instances
Eq BlockId Source # | |
Show BlockId Source # | |
Buildable BlockId Source # | |
Defined in Morley.Client.RPC.Types | |
ToHttpApiData BlockId Source # | |
Defined in Morley.Client.RPC.Types toUrlPiece :: BlockId -> Text # toEncodedUrlPiece :: BlockId -> Builder # toHeader :: BlockId -> ByteString # toQueryParam :: BlockId -> Text # | |
HasCLReader BlockId Source # | |
Defined in Morley.Client.RPC.Types |
class (Monad m, MonadCatch m) => HasTezosRpc m where Source #
Type class that provides interaction with tezos node via RPC
getBlockHash :: BlockId -> m Text Source #
getCounterAtBlock :: BlockId -> Address -> m TezosInt64 Source #
Get address counter, which is required for both transaction sending and contract origination.
getBlockHeader :: BlockId -> m BlockHeader Source #
Get the whole header of a block.
getBlockConstants :: BlockId -> m BlockConstants Source #
Get block constants that are required by other RPC calls.
getBlockOperations :: BlockId -> m [[BlockOperation]] Source #
Get all operations from the block with specified ID.
getProtocolParametersAtBlock :: BlockId -> m ProtocolParameters Source #
Get protocol parameters that are for limits calculations.
runOperationAtBlock :: BlockId -> RunOperation -> m RunOperationResult Source #
Perform operation run, this operation doesn't require proper signing. As a result it returns burned gas and storage diff (also list of originated contracts but their addresses are incorrect due to the fact that operation could be not signed properly) or indicates about operation failure.
preApplyOperationsAtBlock :: BlockId -> [PreApplyOperation] -> m [RunOperationResult] Source #
Preapply list of operations, each operation has to be signed with sender secret key. As a result it returns list of results each of which has information about burned gas, storage diff size and originated contracts.
forgeOperationAtBlock :: BlockId -> ForgeOperation -> m HexJSONByteString Source #
Forge operation in order to receive its hexadecimal representation.
injectOperation :: HexJSONByteString -> m OperationHash Source #
Inject operation, note that this operation has to be signed before injection. As a result it returns operation hash.
getContractScriptAtBlock :: BlockId -> Address -> m OriginationScript Source #
Get code and storage of the desired contract. Note that both code and storage
are presented in low-level Micheline representation.
If the storage contains a big_map
, then the expression will contain the big_map
's ID,
not its contents.
getContractStorageAtBlock :: BlockId -> Address -> m Expression Source #
Get storage of the desired contract at some block. Note that storage
is presented in low-level Micheline representation.
If the storage contains a big_map
, then the expression will contain the big_map
's ID,
not its contents.
getContractBigMapAtBlock :: BlockId -> Address -> GetBigMap -> m GetBigMapResult Source #
Get big map value by contract address.
getBigMapValueAtBlock :: BlockId -> Natural -> Text -> m Expression Source #
Get big map value at some block by the big map's ID and the hashed entry key.
getBigMapValuesAtBlock :: BlockId -> Natural -> Maybe Natural -> Maybe Natural -> m Expression Source #
Get all big map values at some block by the big map's ID and the optional offset and length.
getBalanceAtBlock :: BlockId -> Address -> m Mutez Source #
Get balance for given address.
getDelegateAtBlock :: BlockId -> Address -> m (Maybe KeyHash) Source #
Get delegate for given address.
runCodeAtBlock :: BlockId -> RunCode -> m RunCodeResult Source #
Emulate contract call. This RPC endpoint does the same as
tezos-client run script
command does.
getChainId :: m ChainId Source #
Get current ChainId
getManagerKeyAtBlock :: BlockId -> Address -> m (Maybe PublicKey) Source #
Get manager key for given address.
Returns Nothing
if this key wasn't revealed.
Instances
getContract :: HasTezosRpc m => Address -> m Contract Source #
Get originated Contract
for some address.
getImplicitContractCounter :: HasTezosRpc m => Address -> m TezosInt64 Source #
Get counter value for given address.
Throws an error if given address is a contract address.
getContractStorage :: HasTezosRpc m => Address -> m Expression Source #
getContractStorageAtBlock
applied to the head block.
getBigMapValue :: HasTezosRpc m => Natural -> Text -> m Expression Source #
getBigMapValueAtBlock
applied to the head block.
getHeadBlock :: HasTezosRpc m => m Text Source #
Get hash of the current head block, this head hash is used in other RPC calls.
getCounter :: HasTezosRpc m => Address -> m TezosInt64 Source #
getCounterAtBlock
applied to the head block.
getProtocolParameters :: HasTezosRpc m => m ProtocolParameters Source #
getProtocolParametersAtBlock
applied to the head block.
runOperation :: HasTezosRpc m => RunOperation -> m RunOperationResult Source #
runOperationAtBlock
applied to the head block.
preApplyOperations :: HasTezosRpc m => [PreApplyOperation] -> m [RunOperationResult] Source #
preApplyOperationsAtBlock
applied to the head block.
forgeOperation :: HasTezosRpc m => ForgeOperation -> m HexJSONByteString Source #
forgeOperationAtBlock
applied to the head block.
getContractScript :: HasTezosRpc m => Address -> m OriginationScript Source #
getContractScriptAtBlock
applied to the head block.
getContractBigMap :: HasTezosRpc m => Address -> GetBigMap -> m GetBigMapResult Source #
getContractBigMapAtBlock
applied to the head block.
getBalance :: HasTezosRpc m => Address -> m Mutez Source #
getBalanceAtBlock
applied to the head block.
getDelegate :: HasTezosRpc m => Address -> m (Maybe KeyHash) Source #
getDelegateAtBlock
applied to the head block.
runCode :: HasTezosRpc m => RunCode -> m RunCodeResult Source #
runCodeAtBlock
applied to the head block.
getManagerKey :: HasTezosRpc m => Address -> m (Maybe PublicKey) Source #
Errors
data ClientRpcError Source #
Errors that can happen in the RPC part when a user tries to make failing actions.
ContractFailed | Smart contract execution has failed. |
| |
BadParameter | Parameter passed to a contract does not match its type. |
| |
EmptyTransaction | Transfer of 0 to an implicit account. |
| |
ShiftOverflow | A smart contract execution failed due to a shift overflow. |
| |
GasExhaustion | A smart contract execution failed due gas exhaustion. |
| |
ClientInternalError InternalError | An error that RPC considers internal occurred. These errors
are considered internal by mistake, they are actually quite
realistic and normally indicate bad user action. Currently we
put |
Instances
Show ClientRpcError Source # | |
Defined in Morley.Client.RPC.Error showsPrec :: Int -> ClientRpcError -> ShowS # show :: ClientRpcError -> String # showList :: [ClientRpcError] -> ShowS # | |
Exception ClientRpcError Source # | |
Defined in Morley.Client.RPC.Error | |
Buildable ClientRpcError Source # | |
Defined in Morley.Client.RPC.Error build :: ClientRpcError -> Builder # |
data UnexpectedErrors Source #
Errors that we don't expect to happen, but they can be reported by the server.
Instances
Show UnexpectedErrors Source # | |
Defined in Morley.Client.RPC.Error showsPrec :: Int -> UnexpectedErrors -> ShowS # show :: UnexpectedErrors -> String # showList :: [UnexpectedErrors] -> ShowS # | |
Exception UnexpectedErrors Source # | |
Defined in Morley.Client.RPC.Error | |
Buildable UnexpectedErrors Source # | |
Defined in Morley.Client.RPC.Error build :: UnexpectedErrors -> Builder # |
data IncorrectRpcResponse Source #
Errors that we can throw when we get a response from a node that doesn't match our expectations. It means that either the node we are talking to misbehaves or our code is incorrect.
RpcUnexpectedSize Int Int | |
RpcOriginatedNoContracts | |
RpcNoOperationsRun | |
RpcOriginatedMoreContracts [Address] |
Instances
Show IncorrectRpcResponse Source # | |
Defined in Morley.Client.RPC.Error showsPrec :: Int -> IncorrectRpcResponse -> ShowS # show :: IncorrectRpcResponse -> String # showList :: [IncorrectRpcResponse] -> ShowS # | |
Exception IncorrectRpcResponse Source # | |
Buildable IncorrectRpcResponse Source # | |
Defined in Morley.Client.RPC.Error build :: IncorrectRpcResponse -> Builder # |
Errors that are sent as part of operation result in an OK response (status 200). They are semi-formally defined as errors that can happen when a contract is executed and something goes wrong.
RuntimeError Address | |
ScriptRejected Expression | |
BadContractParameter Address | |
InvalidConstant Expression Expression | |
InvalidContract Address | |
InconsistentTypes Expression Expression | |
InvalidPrimitive [Text] Text | |
InvalidSyntacticConstantError Expression Expression | |
InvalidExpressionKind [Text] Text | |
InvalidContractNotation Text | |
UnexpectedContract | |
IllFormedType Expression | |
UnexpectedOperation | |
REEmptyTransaction | Transfer of 0 to an implicit account. |
| |
ScriptOverflow | A contract failed due to the detection of an overflow. It seems to happen if a too big value is passed to shift instructions (as second argument). |
GasExhaustedOperation | |
MutezAdditionOverflow [TezosInt64] | |
MutezSubtractionUnderflow [TezosInt64] | |
MutezMultiplicationOverflow TezosInt64 TezosInt64 | |
CantPayStorageFee | |
BalanceTooLow ("balance" :! Mutez) ("required" :! Mutez) | |
NonExistingContract Address |
Getters
data ValueDecodeFailure Source #
Failed to decode received value to the given type.
Instances
Show ValueDecodeFailure Source # | |
Defined in Morley.Client.RPC.Getters showsPrec :: Int -> ValueDecodeFailure -> ShowS # show :: ValueDecodeFailure -> String # showList :: [ValueDecodeFailure] -> ShowS # | |
Exception ValueDecodeFailure Source # | |
Defined in Morley.Client.RPC.Getters | |
Buildable ValueDecodeFailure Source # | |
Defined in Morley.Client.RPC.Getters build :: ValueDecodeFailure -> Builder # |
data ValueNotFound Source #
Instances
Show ValueNotFound Source # | |
Defined in Morley.Client.RPC.Getters showsPrec :: Int -> ValueNotFound -> ShowS # show :: ValueNotFound -> String # showList :: [ValueNotFound] -> ShowS # | |
Exception ValueNotFound Source # | |
Defined in Morley.Client.RPC.Getters | |
Buildable ValueNotFound Source # | |
Defined in Morley.Client.RPC.Getters build :: ValueNotFound -> Builder # |
readAllBigMapValues :: forall v k m. (NiceUnpackedValue v, HasTezosRpc m) => BigMapId k v -> m [v] Source #
Read all big_map values, given it's ID.
If the values are not of the expected type, a ValueDecodeFailure
will be thrown.
readAllBigMapValuesMaybe :: forall v k m. (NiceUnpackedValue v, HasTezosRpc m) => BigMapId k v -> m (Maybe [v]) Source #
Read all big_map values, given it's ID.
If the values are not of the expected type, a ValueDecodeFailure
will be thrown.
Returns Nothing
if a big_map with the given ID does not exist.
readContractBigMapValue :: forall k v m. (PackedValScope k, HasTezosRpc m, SingI v) => Address -> Value k -> m (Value v) Source #
Read big_map value of given contract by key.
If the contract contains several big_map
s with given key type, only one
of them will be considered.
readBigMapValueMaybe :: forall v k m. (NicePackedValue k, NiceUnpackedValue v, HasTezosRpc m) => BigMapId k v -> k -> m (Maybe v) Source #
Read big_map value, given it's ID and a key.
If the value is not of the expected type, a ValueDecodeFailure
will be thrown.
Returns Nothing
if a big_map with the given ID does not exist,
or it does exist but does not contain the given key.
readBigMapValue :: forall v k m. (NicePackedValue k, NiceUnpackedValue v, HasTezosRpc m) => BigMapId k v -> k -> m v Source #
Read big_map value, given it's ID and a key.
If the value is not of the expected type, a ValueDecodeFailure
will be thrown.
AsRPC
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 BigMap
s will be replaced
by BigMapId
s.
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.
tezos-client
tezos-client
can associate addresses with textual aliases.
This type denotes such an alias.
A hint for constructing an alias when generating an address or remembering a contract.
Resulting Alias
most likely will differ from this as we tend to prefix
aliases, but a user should be able to recognize your alias visually.
For instance, passing "alice"
as a hint may result into "myTest.alice"
alias being created.
data AliasOrAliasHint Source #
Either an Alias
, or an AliasHint
. The difference is that AliasHint
needs to be
prefixed (if alias prefix is non-empty), while Alias
doesn't.
Instances
Show AliasOrAliasHint Source # | |
Defined in Morley.Client.TezosClient.Types showsPrec :: Int -> AliasOrAliasHint -> ShowS # show :: AliasOrAliasHint -> String # showList :: [AliasOrAliasHint] -> ShowS # |
data AddressOrAlias Source #
Representation of an address that tezos-client
uses. It can be
an address itself or a textual alias.
AddressResolved Address | Address itself, can be used as is. |
AddressAlias Alias | Address alias, should be resolved by |
Instances
addressResolved :: ToAddress addr => addr -> AddressOrAlias Source #
Creates an AddressOrAlias
with the given address.
class Monad m => HasTezosClient m where Source #
Type class that provides interaction with tezos-client
binary
signBytes :: AddressOrAlias -> Maybe ScrubbedBytes -> ByteString -> m Signature Source #
Sign an operation with tezos-client
.
genKey :: AliasOrAliasHint -> m Address Source #
Generate a secret key and store it with given alias. If a key with this alias already exists, the corresponding address will be returned and no state will be changed.
genFreshKey :: AliasOrAliasHint -> m Address Source #
Generate a secret key and store it with given alias.
Unlike genKey
this function overwrites
the existing key when given alias is already stored.
revealKey :: Alias -> Maybe ScrubbedBytes -> m () Source #
Reveal public key associated with given implicit account.
waitForOperation :: OperationHash -> m () Source #
Wait until operation known by some hash is included into the chain.
rememberContract :: Bool -> Address -> AliasOrAliasHint -> m () Source #
Associate the given contract with alias.
The Bool
variable indicates whether or not we should replace already
existing contract alias or not.
importKey :: Bool -> AliasOrAliasHint -> SecretKey -> m () Source #
Saves SecretKey
via tezos-client
with given alias associated.
The Bool
variable indicates whether or not we should replace already
existing alias key or not.
resolveAddressMaybe :: AddressOrAlias -> m (Maybe Address) Source #
Retrieve an address from given address or alias. If address or alias does not exist
returns Nothing
getAlias :: AddressOrAlias -> m Alias Source #
Retrieve an alias from given address using tezos-client
. The
primary (and probably only) reason this function exists is that
tezos-client sign
command only works with aliases. It was
reported upstream: https://gitlab.com/tezos/tezos/-/issues/836.
getPublicKey :: AddressOrAlias -> m PublicKey Source #
Get public key for given address. Public keys are often used when interacting with the multising contracts
registerDelegate :: AliasOrAliasHint -> Maybe ScrubbedBytes -> m () Source #
Register a given address as delegate
getTezosClientConfig :: m TezosClientConfig Source #
Retrieve the current tezos-client
config.
calcTransferFee :: AddressOrAlias -> Maybe ScrubbedBytes -> TezosInt64 -> [CalcTransferFeeData] -> m [TezosMutez] Source #
Calculate fee for transfer using `--dry-run` flag.
calcOriginationFee :: UntypedValScope st => CalcOriginationFeeData cp st -> m TezosMutez Source #
Calculate fee for origination using `--dry-run` flag.
getKeyPassword :: Address -> m (Maybe ScrubbedBytes) Source #
Get password for secret key associated with given address
in case this key is password-protected. Obtained password is used
in two places:
* 1) In signBytes
call.
* 2) in revealKey
call.
Instances
resolveAddress :: (MonadThrow m, HasTezosClient m) => AddressOrAlias -> m Address Source #
Return Address
corresponding to given AddressOrAlias
.
data TezosClientError Source #
A data type for all predicatable errors that can happen during
tezos-client
usage.
UnexpectedClientFailure |
|
UnknownAddressAlias | Could not find an address with given name. |
| |
UnknownAddress | Could not find an address. |
| |
AlreadyRevealed | Public key of the given address is already revealed. |
| |
InvalidOperationHash OperationHash | Can't wait for inclusion of operation with given hash because the hash is invalid. |
CounterIsAlreadyUsed | Error that indicates when given counter is already used for given contract. |
EConnreset | Network error with which |
ConfigParseError String | A parse error occurred during config parsing. |
TezosClientCryptoParseError Text CryptoParseError |
|
TezosClientParseAddressError Text ParseAddressError |
|
TezosClientParseFeeError Text Text |
|
TezosClientUnexpectedOutputFormat Text |
|
CantRevealContract | Given alias is a contract and cannot be revealed. |
| |
ContractSender Address Text | Given contract is a source of a transfer or origination operation. |
EmptyImplicitContract | Given alias is an empty implicit contract. |
| |
TezosClientUnexpectedSignatureOutput Text |
|
TezosClientParseEncryptionTypeError Text Text |
|
Instances
Eq TezosClientError Source # | |
Defined in Morley.Client.TezosClient.Impl (==) :: TezosClientError -> TezosClientError -> Bool # (/=) :: TezosClientError -> TezosClientError -> Bool # | |
Show TezosClientError Source # | |
Defined in Morley.Client.TezosClient.Impl showsPrec :: Int -> TezosClientError -> ShowS # show :: TezosClientError -> String # showList :: [TezosClientError] -> ShowS # | |
Exception TezosClientError Source # | |
Defined in Morley.Client.TezosClient.Impl | |
Buildable TezosClientError Source # | |
Defined in Morley.Client.TezosClient.Impl build :: TezosClientError -> Builder # |
Util
disableAlphanetWarning :: IO () Source #
Sets the environment variable for disabling tezos-client "not a mainnet" warning
Reexports
data ParserInfo a #
A full description for a runnable Parser
for a program.
Instances
Functor ParserInfo | |
Defined in Options.Applicative.Types fmap :: (a -> b) -> ParserInfo a -> ParserInfo b # (<$) :: a -> ParserInfo b -> ParserInfo a # |