-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Client to interact with the Tezos blockchain
--
-- A client to interact with the Tezos blockchain, by use of the
-- octez-node RPC and/or of the octez-client binary.
@package morley-client
@version 0.3.2
-- | A tiny abstraction layer over logging capability we use in
-- morley-client.
--
-- We use the co-log package and this module reduces direct
-- dependencies on co-log making our code more resistant to
-- logging changes.
module Morley.Client.Logging
-- | LogAction with fixed message parameter.
type ClientLogAction m = LogAction m Message
-- | A specialization of WithLog constraint to the Message
-- type. If we want to use another message type we can change this
-- constraint and exported functions, presumably without breaking other
-- code significantly.
type WithClientLog env m = WithLog env Message m
-- | Logs the message with the Debug severity.
logDebug :: WithLog env Message m => Text -> m ()
-- | Logs the message with the Info severity.
logInfo :: WithLog env Message m => Text -> m ()
-- | Logs the message with the Warning severity.
logWarning :: WithLog env Message m => Text -> m ()
-- | Logs the message with the Error severity.
logError :: WithLog env Message m => Text -> m ()
-- | Logs Exception message with the Error severity.
logException :: forall e m env. (WithLog env Message m, Exception e) => e -> m ()
-- | This action can be used in combination with other actions to flush a
-- handle every time you log anything.
logFlush :: forall (m :: Type -> Type) a. MonadIO m => Handle -> LogAction m a
-- | Morley client initialization.
module Morley.Client.Init
-- | Data necessary for morley client initialization.
data MorleyClientConfig
MorleyClientConfig :: Maybe BaseUrl -> FilePath -> Maybe FilePath -> Word -> Maybe SecretKey -> MorleyClientConfig
-- | URL of tezos endpoint on which operations are performed
[mccEndpointUrl] :: MorleyClientConfig -> Maybe BaseUrl
-- | Path to octez-client binary through which operations are
-- performed
[mccTezosClientPath] :: MorleyClientConfig -> FilePath
-- | Path to octez-client data directory.
[mccMbTezosClientDataDir] :: MorleyClientConfig -> Maybe FilePath
-- | Verbosity level. 0 means that only important messages will be
-- printed. The greater this value is, the more messages will be printed
-- during execution. After some small unspecified limit increasing this
-- value does not change anything.
[mccVerbosity] :: MorleyClientConfig -> Word
-- | Custom secret key to use for signing.
[mccSecretKey] :: MorleyClientConfig -> Maybe SecretKey
-- | Make appropriate ClientLogAction based on verbosity specified
-- by the user.
mkLogAction :: MonadIO m => Word -> ClientLogAction m
mccEndpointUrlL :: Lens' MorleyClientConfig (Maybe BaseUrl)
mccTezosClientPathL :: Lens' MorleyClientConfig FilePath
mccMbTezosClientDataDirL :: Lens' MorleyClientConfig (Maybe FilePath)
mccVerbosityL :: Lens' MorleyClientConfig Word
mccSecretKeyL :: Lens' MorleyClientConfig (Maybe SecretKey)
instance GHC.Show.Show Morley.Client.Init.MorleyClientConfig
-- | Helpers for the aeson package.
--
-- Currently we need this module due to "GHC stage restriction".
module Morley.Client.RPC.Aeson
-- | We use these Options to produce JSON encoding in the format
-- that RPC expects. We are not using defaults from morley
-- because we need a specific format.
morleyClientAesonOptions :: Options
newtype ClientJSON a
ClientJSON :: a -> ClientJSON a
[unClientJSON] :: ClientJSON a -> a
instance (GHC.Generics.Generic a, Data.Aeson.Types.Class.GToJSON Data.Aeson.Types.Generic.Zero (GHC.Generics.Rep a), Data.Aeson.Types.Class.GToEncoding Data.Aeson.Types.Generic.Zero (GHC.Generics.Rep a)) => Data.Aeson.Types.ToJSON.ToJSON (Morley.Client.RPC.Aeson.ClientJSON a)
instance (GHC.Generics.Generic a, Data.Aeson.Types.FromJSON.GFromJSON Data.Aeson.Types.Generic.Zero (GHC.Generics.Rep a)) => Data.Aeson.Types.FromJSON.FromJSON (Morley.Client.RPC.Aeson.ClientJSON a)
module Morley.Client.RPC.HttpClient
-- | Make servant client environment from morley client config.
--
-- Note: Creating a new servant manager is a relatively expensive
-- operation, so this function is not supposed to be called often.
newClientEnv :: BaseUrl -> IO ClientEnv
module Morley.Client.RPC.QueryFixedParam
-- | Like servant's QueryParam, but the value is fixed as a
-- type-level string.
data QueryFixedParam (name :: Symbol) (value :: Symbol)
instance (GHC.TypeLits.KnownSymbol sym, GHC.TypeLits.KnownSymbol val, Servant.Client.Core.HasClient.HasClient m api) => Servant.Client.Core.HasClient.HasClient m (Morley.Client.RPC.QueryFixedParam.QueryFixedParam sym val Servant.API.Sub.:> api)
module Morley.Client.Types
-- | Designates types whose ToJSON instance produces only
-- Objects.
class ToJSON a => ToJSONObject a
class OperationInfoDescriptor (i :: Type) where {
type family TransferInfo i :: Type;
type family TransferTicketInfo i :: Type;
type family OriginationInfo i :: Type;
type family RevealInfo i :: Type;
type family DelegationInfo i :: Type;
}
data OperationInfo i
OpTransfer :: TransferInfo i -> OperationInfo i
OpTransferTicket :: TransferTicketInfo i -> OperationInfo i
OpOriginate :: OriginationInfo i -> OperationInfo i
OpReveal :: RevealInfo i -> OperationInfo i
OpDelegation :: DelegationInfo i -> OperationInfo i
-- | A kinded address together with the corresponding alias. Due to the
-- quirks of octez-client we usually need both in
-- morley-client, hence the need for this type. Historically, we
-- asked octez-client for the missing part, but that resulted in
-- a lot of inefficiencies.
--
-- Note that the Ord instance is rather arbitrary, and doesn't
-- necessarily correspond to anything in Michelson. It's added for
-- convenience, e.g. so that AddressWithAlias is usable as a
-- Map key.
data AddressWithAlias kind
AddressWithAlias :: KindedAddress kind -> Alias kind -> AddressWithAlias kind
[awaAddress] :: AddressWithAlias kind -> KindedAddress kind
[awaAlias] :: AddressWithAlias kind -> Alias kind
type ImplicitAddressWithAlias = AddressWithAlias 'AddressKindImplicit
type ContractAddressWithAlias = AddressWithAlias 'AddressKindContract
_OpTransfer :: forall i_aHRV. Prism' (OperationInfo i_aHRV) (TransferInfo i_aHRV)
_OpOriginate :: forall i_aHRV. Prism' (OperationInfo i_aHRV) (OriginationInfo i_aHRV)
_OpReveal :: forall i_aHRV. Prism' (OperationInfo i_aHRV) (RevealInfo i_aHRV)
_OpDelegation :: forall i_aHRV. Prism' (OperationInfo i_aHRV) (DelegationInfo i_aHRV)
_OpTransferTicket :: forall i_aHRV. Prism' (OperationInfo i_aHRV) (TransferTicketInfo i_aHRV)
instance GHC.Classes.Ord (Morley.Client.Types.AddressWithAlias kind)
instance GHC.Classes.Eq (Morley.Client.Types.AddressWithAlias kind)
instance GHC.Show.Show (Morley.Client.Types.AddressWithAlias kind)
instance Lorentz.Address.ToAddress (Morley.Client.Types.AddressWithAlias kind)
instance Lorentz.Address.ToTAddress cp vd (Morley.Tezos.Address.KindedAddress kind) => Lorentz.Address.ToTAddress cp vd (Morley.Client.Types.AddressWithAlias kind)
instance Fmt.Buildable.Buildable (Morley.Client.Types.AddressWithAlias kind)
instance Universum.TypeOps.Each '[Morley.Client.Types.ToJSONObject] '[Morley.Client.Types.TransferInfo i, Morley.Client.Types.TransferTicketInfo i, Morley.Client.Types.OriginationInfo i, Morley.Client.Types.RevealInfo i, Morley.Client.Types.DelegationInfo i] => Data.Aeson.Types.ToJSON.ToJSON (Morley.Client.Types.OperationInfo i)
instance Data.Aeson.Types.ToJSON.ToJSON (Morley.Client.Types.OperationInfo i) => Morley.Client.Types.ToJSONObject (Morley.Client.Types.OperationInfo i)
-- | This module contains various types which are used in
-- octez-node RPC API.
--
-- Documentation for RPC API can be found e. g. here (010 is the
-- protocol, change to the desired one).
--
-- Note that errors are reported a bit inconsistently by RPC. For more
-- information see this question and this issue.
module Morley.Client.RPC.Types
data AppliedResult
AppliedResult :: TezosInt64 -> TezosInt64 -> TezosInt64 -> [ContractAddress] -> TezosInt64 -> AppliedResult
[arConsumedMilliGas] :: AppliedResult -> TezosInt64
[arStorageSize] :: AppliedResult -> TezosInt64
[arPaidStorageDiff] :: AppliedResult -> TezosInt64
[arOriginatedContracts] :: AppliedResult -> [ContractAddress]
-- | We need to count number of destination contracts that are new to the
-- chain in order to calculate proper storage_limit
[arAllocatedDestinationContracts] :: AppliedResult -> TezosInt64
data BlockConstants
BlockConstants :: Text -> Text -> BlockHeaderNoHash -> BlockHash -> BlockConstants
[bcProtocol] :: BlockConstants -> Text
[bcChainId] :: BlockConstants -> Text
[bcHeader] :: BlockConstants -> BlockHeaderNoHash
[bcHash] :: BlockConstants -> BlockHash
newtype BlockHash
BlockHash :: Text -> BlockHash
[unBlockHash] :: BlockHash -> Text
data BlockHeaderNoHash
BlockHeaderNoHash :: UTCTime -> Int64 -> BlockHash -> BlockHeaderNoHash
[bhnhTimestamp] :: BlockHeaderNoHash -> UTCTime
[bhnhLevel] :: BlockHeaderNoHash -> Int64
[bhnhPredecessor] :: BlockHeaderNoHash -> BlockHash
-- | The whole block header.
data BlockHeader
BlockHeader :: UTCTime -> Int64 -> BlockHash -> BlockHash -> BlockHeader
[bhTimestamp] :: BlockHeader -> UTCTime
[bhLevel] :: BlockHeader -> Int64
[bhPredecessor] :: BlockHeader -> BlockHash
[bhHash] :: BlockHeader -> BlockHash
data FeeConstants
FeeConstants :: Mutez -> Milli -> Milli -> FeeConstants
[fcBase] :: FeeConstants -> Mutez
[fcMutezPerGas] :: FeeConstants -> Milli
[fcMutezPerOpByte] :: FeeConstants -> Milli
-- | A block identifier as submitted to RPC.
--
-- A block can be referenced by head, genesis, level or
-- block hash
data BlockId
-- | Identifier referring to the head block.
HeadId :: BlockId
-- | Identifier of the most recent block guaranteed to have been finalized.
-- See:
-- https://web.archive.org/web/20220305165609/https://tezos.gitlab.io/protocols/tenderbake.html#operations
FinalHeadId :: BlockId
-- | Identifier referring to the genesis block.
GenesisId :: BlockId
-- | Identifier referring to a block by its level.
LevelId :: Natural -> BlockId
-- | Idenfitier referring to a block by its hash in Base58Check notation.
BlockHashId :: BlockHash -> BlockId
-- | Identifier of a block at specific depth relative to head.
AtDepthId :: Natural -> BlockId
-- | $operation in Tezos docs.
data BlockOperation
BlockOperation :: Text -> [OperationRespWithMeta] -> BlockOperation
[boHash] :: BlockOperation -> Text
[boContents] :: BlockOperation -> [OperationRespWithMeta]
-- | Data that is common for transaction and origination operations.
data CommonOperationData
CommonOperationData :: ImplicitAddress -> TezosMutez -> TezosInt64 -> TezosInt64 -> TezosInt64 -> CommonOperationData
[codSource] :: CommonOperationData -> ImplicitAddress
[codFee] :: CommonOperationData -> TezosMutez
[codCounter] :: CommonOperationData -> TezosInt64
[codGasLimit] :: CommonOperationData -> TezosInt64
[codStorageLimit] :: CommonOperationData -> TezosInt64
data DelegationOperation
DelegationOperation :: Maybe KeyHash -> DelegationOperation
-- | Nothing removes delegate, Just sets it
[doDelegate] :: DelegationOperation -> Maybe KeyHash
data ForgeOperation
ForgeOperation :: BlockHash -> NonEmpty OperationInput -> ForgeOperation
[foBranch] :: ForgeOperation -> BlockHash
[foContents] :: ForgeOperation -> NonEmpty OperationInput
data GetBigMap
GetBigMap :: Expression -> Expression -> GetBigMap
[bmKey] :: GetBigMap -> Expression
[bmType] :: GetBigMap -> Expression
data CalcSize
CalcSize :: Expression -> Expression -> TezosInt64 -> Bool -> CalcSize
[csProgram] :: CalcSize -> Expression
[csStorage] :: CalcSize -> Expression
[csGas] :: CalcSize -> TezosInt64
[csLegacy] :: CalcSize -> Bool
newtype ScriptSize
ScriptSize :: Natural -> ScriptSize
[ssScriptSize] :: ScriptSize -> Natural
data GetBigMapResult
GetBigMapResult :: Expression -> GetBigMapResult
GetBigMapNotFound :: GetBigMapResult
data InternalOperation
InternalOperation :: OperationResp WithSource -> OperationResult -> InternalOperation
[ioData] :: InternalOperation -> OperationResp WithSource
[ioResult] :: InternalOperation -> OperationResult
data WithSource a
WithSource :: Address -> a -> WithSource a
[wsSource] :: WithSource a -> Address
[wsOtherData] :: WithSource a -> a
data OperationContent
OperationContent :: OperationResp WithSource -> RunMetadata -> OperationContent
[ocOperation] :: OperationContent -> OperationResp WithSource
[ocMetadata] :: OperationContent -> RunMetadata
newtype OperationHash
OperationHash :: Text -> OperationHash
[unOperationHash] :: OperationHash -> Text
type OperationInput = WithCommonOperationData (OperationInfo RPCInput)
-- | Contents of an operation that can appear in RPC responses.
data OperationResp f
-- | Operation with kind transaction.
TransactionOpResp :: f TransactionOperation -> OperationResp f
-- | Operation with kind transfer_ticket.
TransferTicketOpResp :: f TransferTicketOperation -> OperationResp f
-- | Operation with kind origination.
OriginationOpResp :: f OriginationOperation -> OperationResp f
-- | Operation with kind delegation.
DelegationOpResp :: f DelegationOperation -> OperationResp f
-- | Operation with kind reveal.
RevealOpResp :: f RevealOperation -> OperationResp f
-- | Operation with kind event.
EventOpResp :: f EventOperation -> OperationResp f
-- | Response we don't handle yet.
OtherOpResp :: Text -> OperationResp f
data OperationRespWithMeta
OperationRespWithMeta :: OperationResp WithCommonOperationData -> Maybe OperationMetadata -> OperationRespWithMeta
[orwmResponse] :: OperationRespWithMeta -> OperationResp WithCommonOperationData
[orwmMetadata] :: OperationRespWithMeta -> Maybe OperationMetadata
newtype OperationMetadata
OperationMetadata :: Maybe OperationResult -> OperationMetadata
[unOperationMetadata] :: OperationMetadata -> Maybe OperationResult
data OperationResult
OperationApplied :: AppliedResult -> OperationResult
OperationFailed :: [RunError] -> OperationResult
-- | All the data needed to perform contract origination through Tezos RPC
-- interface
data OriginationOperation
OriginationOperation :: TezosMutez -> Maybe KeyHash -> OriginationScript -> OriginationOperation
[ooBalance] :: OriginationOperation -> TezosMutez
[ooDelegate] :: OriginationOperation -> Maybe KeyHash
[ooScript] :: OriginationOperation -> OriginationScript
data OriginationScript
OriginationScript :: Expression -> Expression -> OriginationScript
[osCode] :: OriginationScript -> Expression
[osStorage] :: OriginationScript -> Expression
data ParametersInternal
ParametersInternal :: Text -> Expression -> ParametersInternal
[piEntrypoint] :: ParametersInternal -> Text
[piValue] :: ParametersInternal -> Expression
data PreApplyOperation
PreApplyOperation :: Text -> BlockHash -> NonEmpty OperationInput -> Signature -> PreApplyOperation
[paoProtocol] :: PreApplyOperation -> Text
[paoBranch] :: PreApplyOperation -> BlockHash
[paoContents] :: PreApplyOperation -> NonEmpty OperationInput
[paoSignature] :: PreApplyOperation -> Signature
-- | Protocol-wide constants.
--
-- There are more constants, but currently, we are using only these in
-- our code.
data ProtocolParameters
ProtocolParameters :: Int -> TezosInt64 -> TezosInt64 -> TezosNat -> TezosMutez -> TezosInt64 -> ProtocolParameters
-- | Byte size cost for originating new contract.
[ppOriginationSize] :: ProtocolParameters -> Int
-- | Gas limit for a single operation.
[ppHardGasLimitPerOperation] :: ProtocolParameters -> TezosInt64
-- | Storage limit for a single operation.
[ppHardStorageLimitPerOperation] :: ProtocolParameters -> TezosInt64
-- | Minimal delay between two blocks, this constant is new in V010.
[ppMinimalBlockDelay] :: ProtocolParameters -> TezosNat
-- | Burn cost per storage byte
[ppCostPerByte] :: ProtocolParameters -> TezosMutez
-- | Gas limit for a single block.
[ppHardGasLimitPerBlock] :: ProtocolParameters -> TezosInt64
-- | All the data needed to perform key revealing through Tezos RPC
-- interface
data RevealOperation
RevealOperation :: PublicKey -> RevealOperation
[roPublicKey] :: RevealOperation -> PublicKey
-- | Data required for calling run_code RPC endpoint.
data RunCode
RunCode :: Expression -> Expression -> Expression -> TezosMutez -> TezosMutez -> Text -> Maybe TezosNat -> Maybe TezosNat -> Maybe ImplicitAddress -> Maybe ImplicitAddress -> RunCode
[rcScript] :: RunCode -> Expression
[rcStorage] :: RunCode -> Expression
[rcInput] :: RunCode -> Expression
[rcAmount] :: RunCode -> TezosMutez
[rcBalance] :: RunCode -> TezosMutez
[rcChainId] :: RunCode -> Text
[rcNow] :: RunCode -> Maybe TezosNat
[rcLevel] :: RunCode -> Maybe TezosNat
[rcSource] :: RunCode -> Maybe ImplicitAddress
[rcPayer] :: RunCode -> Maybe ImplicitAddress
-- | Result storage of run_code RPC endpoint call.
--
-- Actual resulting JSON has more contents, but currently we're
-- interested only in resulting storage.
data RunCodeResult
RunCodeResult :: Expression -> RunCodeResult
[rcrStorage] :: RunCodeResult -> Expression
data RunMetadata
RunMetadata :: OperationResult -> [InternalOperation] -> RunMetadata
[rmOperationResult] :: RunMetadata -> OperationResult
[rmInternalOperationResults] :: RunMetadata -> [InternalOperation]
data RunOperation
RunOperation :: RunOperationInternal -> Text -> RunOperation
[roOperation] :: RunOperation -> RunOperationInternal
[roChainId] :: RunOperation -> Text
data RunOperationInternal
RunOperationInternal :: BlockHash -> NonEmpty OperationInput -> Signature -> RunOperationInternal
[roiBranch] :: RunOperationInternal -> BlockHash
[roiContents] :: RunOperationInternal -> NonEmpty OperationInput
[roiSignature] :: RunOperationInternal -> Signature
data RunOperationResult
RunOperationResult :: NonEmpty OperationContent -> RunOperationResult
[rrOperationContents] :: RunOperationResult -> NonEmpty OperationContent
-- | Designates an input RPC data that we supply to perform an operation.
data RPCInput
-- | All the data needed to perform a transaction through Tezos RPC
-- interface. For additional information, please refer to RPC
-- documentation http://tezos.gitlab.io/api/rpc.html
data TransactionOperation
TransactionOperation :: TezosMutez -> Address -> ParametersInternal -> TransactionOperation
[toAmount] :: TransactionOperation -> TezosMutez
[toDestination] :: TransactionOperation -> Address
[toParameters] :: TransactionOperation -> ParametersInternal
data TransferTicketOperation
TransferTicketOperation :: Expression -> Expression -> Address -> TezosNat -> Address -> Text -> TransferTicketOperation
[ttoTicketContents] :: TransferTicketOperation -> Expression
[ttoTicketTy] :: TransferTicketOperation -> Expression
[ttoTicketTicketer] :: TransferTicketOperation -> Address
[ttoTicketAmount] :: TransferTicketOperation -> TezosNat
[ttoDestination] :: TransferTicketOperation -> Address
[ttoEntrypoint] :: TransferTicketOperation -> Text
-- | Some operation data accompanied with common data.
data WithCommonOperationData a
WithCommonOperationData :: CommonOperationData -> a -> WithCommonOperationData a
[wcoCommon] :: WithCommonOperationData a -> CommonOperationData
[wcoCustom] :: WithCommonOperationData a -> a
data EventOperation
EventOperation :: Expression -> Maybe MText -> Maybe Expression -> EventOperation
[eoType] :: EventOperation -> Expression
[eoTag] :: EventOperation -> Maybe MText
[eoPayload] :: EventOperation -> Maybe Expression
data MonitorHeadsStep a
MonitorHeadsStop :: a -> MonitorHeadsStep a
MonitorHeadsContinue :: MonitorHeadsStep a
data GetTicketBalance
GetTicketBalance :: ContractAddress -> Expression -> Expression -> GetTicketBalance
[gtbTicketer] :: GetTicketBalance -> ContractAddress
[gtbContentType] :: GetTicketBalance -> Expression
[gtbContent] :: GetTicketBalance -> Expression
data GetAllTicketBalancesResponse
GetAllTicketBalancesResponse :: ContractAddress -> Expression -> Expression -> TezosNat -> GetAllTicketBalancesResponse
[gatbrTicketer] :: GetAllTicketBalancesResponse -> ContractAddress
[gatbrContentType] :: GetAllTicketBalancesResponse -> Expression
[gatbrContent] :: GetAllTicketBalancesResponse -> Expression
[gatbrAmount] :: GetAllTicketBalancesResponse -> TezosNat
data PackData
PackData :: Expression -> Expression -> Maybe TezosBigNum -> PackData
[pdData] :: PackData -> Expression
[pdType] :: PackData -> Expression
[pdGas] :: PackData -> Maybe TezosBigNum
data PackDataResult
PackDataResult :: Text -> PackDataResultGas -> PackDataResult
[pdrPacked] :: PackDataResult -> Text
[pdrGas] :: PackDataResult -> PackDataResultGas
-- | Create CommonOperationData based on current blockchain protocol
-- parameters and sender info. This data is used for operation
-- simulation.
--
-- num_operations parameter can be used for smarter gas limit
-- estimation. If Nothing, the gas limit is set to
-- ppHardGasLimitPerOperation, but that puts a hard low limit on
-- the number of operations that will fit into one batch. If
-- num_operations is set, then gas limit is estimated as
--
-- <math>
--
-- This works well enough for the case of many small operations, but will
-- break when there is one big one and a lot of small ones. That said,
-- specifying num_operations will work in all cases where not
-- specifying it would, and then some, so it's recommended to specify it
-- whenever possible.
--
-- num_operations is assumed to be greater than 0,
-- otherwise it'll be silently ignored.
--
-- Fee isn't accounted during operation simulation, so it's safe to use
-- zero amount. Real operation fee is calculated later using
-- octez-client.
mkCommonOperationData :: ProtocolParameters -> ("sender" :! ImplicitAddress) -> ("counter" :! TezosInt64) -> ("num_operations" :? Int64) -> CommonOperationData
-- | 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.
data RunError
RuntimeError :: ContractAddress -> RunError
ScriptRejected :: Expression -> RunError
BadContractParameter :: Address -> RunError
InvalidConstant :: Expression -> Expression -> RunError
InvalidContract :: Address -> RunError
InconsistentTypes :: Expression -> Expression -> RunError
InvalidPrimitive :: [Text] -> Text -> RunError
InvalidSyntacticConstantError :: Expression -> Expression -> RunError
InvalidExpressionKind :: [Text] -> Text -> RunError
InvalidContractNotation :: Text -> RunError
UnexpectedContract :: RunError
IllFormedType :: Expression -> RunError
UnexpectedOperation :: RunError
-- | Transfer of 0 to an implicit account.
REEmptyTransaction :: ImplicitAddress -> RunError
-- | 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).
ScriptOverflow :: RunError
GasExhaustedOperation :: RunError
MutezAdditionOverflow :: [TezosInt64] -> RunError
MutezSubtractionUnderflow :: [TezosInt64] -> RunError
MutezMultiplicationOverflow :: TezosInt64 -> TezosInt64 -> RunError
CantPayStorageFee :: RunError
BalanceTooLow :: ("balance" :! Mutez) -> ("required" :! Mutez) -> RunError
PreviouslyRevealedKey :: ImplicitAddress -> RunError
NonExistingContract :: Address -> RunError
InvalidB58Check :: Text -> RunError
UnregisteredDelegate :: ImplicitAddress -> RunError
FailedUnDelegation :: ImplicitAddress -> RunError
DelegateAlreadyActive :: RunError
IllTypedContract :: Expression -> RunError
IllTypedData :: Expression -> Expression -> RunError
BadStack :: BadStackInformation -> RunError
ForbiddenZeroAmountTicket :: RunError
REEmptyImplicitContract :: ImplicitAddress -> RunError
-- | Errors that are sent as part of an "Internal Server Error" response
-- (HTTP code 500).
--
-- We call them internal because of the HTTP code, but we shouldn't treat
-- them as internal. They can be easily triggered by making a failing
-- operation.
data InternalError
-- | An operation assumed a contract counter in the past.
CounterInThePast :: ImplicitAddress -> ("expected" :! Word) -> ("found" :! Word) -> InternalError
-- | One tried to apply a manager operation without revealing the manager
-- public key.
UnrevealedKey :: ImplicitAddress -> InternalError
-- | Failure reported without specific id
Failure :: Text -> InternalError
_RuntimeError :: Prism' RunError ContractAddress
_ScriptRejected :: Prism' RunError Expression
_BadContractParameter :: Prism' RunError Address
_InvalidConstant :: Prism' RunError (Expression, Expression)
_InconsistentTypes :: Prism' RunError (Expression, Expression)
_InvalidPrimitive :: Prism' RunError ([Text], Text)
_InvalidSyntacticConstantError :: Prism' RunError (Expression, Expression)
_InvalidExpressionKind :: Prism' RunError ([Text], Text)
_InvalidContractNotation :: Prism' RunError Text
_UnexpectedContract :: Prism' RunError ()
_IllFormedType :: Prism' RunError Expression
_UnexpectedOperation :: Prism' RunError ()
_REEmptyTransaction :: Prism' RunError ImplicitAddress
_ScriptOverflow :: Prism' RunError ()
_PreviouslyRevealedKey :: Prism' RunError ImplicitAddress
_GasExhaustedOperation :: Prism' RunError ()
_UnregisteredDelegate :: Prism' RunError ImplicitAddress
wcoCommonDataL :: Lens' (WithCommonOperationData a) CommonOperationData
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.PackDataResult
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.GetBigMapResult
instance Data.Aeson.Types.ToJSON.ToJSON Morley.Client.RPC.Types.PackData
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.RunCodeResult
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.BlockOperation
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.ProtocolParameters
instance Data.Aeson.Types.ToJSON.ToJSON Morley.Client.RPC.Types.BlockHeader
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.BlockHeader
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.BlockConstants
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.ScriptSize
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.BlockHeaderNoHash
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.GetAllTicketBalancesResponse
instance Data.Aeson.Types.ToJSON.ToJSON Morley.Client.RPC.Types.RunCode
instance Data.Aeson.Types.ToJSON.ToJSON Morley.Client.RPC.Types.CalcSize
instance Data.Aeson.Types.ToJSON.ToJSON Morley.Client.RPC.Types.GetTicketBalance
instance Data.Aeson.Types.ToJSON.ToJSON Morley.Client.RPC.Types.GetBigMap
instance Data.Aeson.Types.ToJSON.ToJSON Morley.Client.RPC.Types.RunOperation
instance Fmt.Buildable.Buildable Morley.Client.RPC.Types.OperationHash
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.OperationHash
instance GHC.Show.Show Morley.Client.RPC.Types.OperationHash
instance GHC.Classes.Eq Morley.Client.RPC.Types.OperationHash
instance Web.Internal.HttpApiData.ToHttpApiData Morley.Client.RPC.Types.BlockHash
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.BlockHash
instance Data.Aeson.Types.ToJSON.ToJSON Morley.Client.RPC.Types.BlockHash
instance Fmt.Buildable.Buildable Morley.Client.RPC.Types.BlockHash
instance GHC.Show.Show Morley.Client.RPC.Types.BlockHash
instance GHC.Classes.Ord Morley.Client.RPC.Types.BlockHash
instance GHC.Classes.Eq Morley.Client.RPC.Types.BlockHash
instance GHC.Classes.Eq Morley.Client.RPC.Types.BlockId
instance GHC.Show.Show Morley.Client.RPC.Types.BlockId
instance GHC.Show.Show Morley.Client.RPC.Types.BadStackInformation
instance GHC.Classes.Eq Morley.Client.RPC.Types.BadStackInformation
instance GHC.Show.Show Morley.Client.RPC.Types.RunError
instance GHC.Show.Show Morley.Client.RPC.Types.InternalError
instance GHC.Show.Show Morley.Client.RPC.Types.AppliedResult
instance Data.Aeson.Types.ToJSON.ToJSON Morley.Client.RPC.Types.ParametersInternal
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.ParametersInternal
instance GHC.Show.Show Morley.Client.RPC.Types.ParametersInternal
instance GHC.Generics.Generic Morley.Client.RPC.Types.ParametersInternal
instance GHC.Base.Functor Morley.Client.RPC.Types.WithSource
instance GHC.Show.Show a => GHC.Show.Show (Morley.Client.RPC.Types.WithSource a)
instance GHC.Show.Show Morley.Client.RPC.Types.TransactionOperation
instance GHC.Show.Show Morley.Client.RPC.Types.TransferTicketOperation
instance Data.Aeson.Types.ToJSON.ToJSON Morley.Client.RPC.Types.OriginationScript
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.OriginationScript
instance GHC.Show.Show Morley.Client.RPC.Types.OriginationScript
instance GHC.Generics.Generic Morley.Client.RPC.Types.OriginationScript
instance Morley.Client.Types.ToJSONObject Morley.Client.RPC.Types.OriginationOperation
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.OriginationOperation
instance GHC.Show.Show Morley.Client.RPC.Types.OriginationOperation
instance GHC.Generics.Generic Morley.Client.RPC.Types.OriginationOperation
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.RevealOperation
instance Morley.Client.Types.ToJSONObject Morley.Client.RPC.Types.RevealOperation
instance GHC.Show.Show Morley.Client.RPC.Types.RevealOperation
instance GHC.Generics.Generic Morley.Client.RPC.Types.RevealOperation
instance Morley.Client.Types.ToJSONObject Morley.Client.RPC.Types.DelegationOperation
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.DelegationOperation
instance GHC.Show.Show Morley.Client.RPC.Types.DelegationOperation
instance GHC.Generics.Generic Morley.Client.RPC.Types.DelegationOperation
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.EventOperation
instance Data.Aeson.Types.ToJSON.ToJSON Morley.Client.RPC.Types.EventOperation
instance Morley.Client.Types.ToJSONObject Morley.Client.RPC.Types.EventOperation
instance GHC.Show.Show Morley.Client.RPC.Types.EventOperation
instance GHC.Generics.Generic Morley.Client.RPC.Types.EventOperation
instance (forall a. GHC.Show.Show a => GHC.Show.Show (f a)) => GHC.Show.Show (Morley.Client.RPC.Types.OperationResp f)
instance Fmt.Buildable.Buildable Morley.Client.RPC.Types.PackDataResult
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.PackDataResultGas
instance Fmt.Buildable.Buildable Morley.Client.RPC.Types.PackDataResultGas
instance Fmt.Buildable.Buildable Morley.Client.RPC.Types.PackData
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.OperationRespWithMeta
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.OperationMetadata
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.RunOperationResult
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.OperationContent
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.RunMetadata
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.InternalOperation
instance (forall a. Fmt.Buildable.Buildable a => Fmt.Buildable.Buildable (f a)) => Fmt.Buildable.Buildable (Morley.Client.RPC.Types.OperationResp f)
instance (forall a. Data.Aeson.Types.FromJSON.FromJSON a => Data.Aeson.Types.FromJSON.FromJSON (f a)) => Data.Aeson.Types.FromJSON.FromJSON (Morley.Client.RPC.Types.OperationResp f)
instance Fmt.Buildable.Buildable Morley.Client.RPC.Types.EventOperation
instance Morley.Client.Types.OperationInfoDescriptor Morley.Client.RPC.Types.RPCInput
instance Data.Aeson.Types.ToJSON.ToJSON Morley.Client.RPC.Types.DelegationOperation
instance Fmt.Buildable.Buildable Morley.Client.RPC.Types.DelegationOperation
instance Data.Aeson.Types.ToJSON.ToJSON Morley.Client.RPC.Types.RevealOperation
instance Fmt.Buildable.Buildable Morley.Client.RPC.Types.RevealOperation
instance Fmt.Buildable.Buildable Morley.Client.RPC.Types.OriginationOperation
instance Data.Aeson.Types.ToJSON.ToJSON Morley.Client.RPC.Types.OriginationOperation
instance Fmt.Buildable.Buildable Morley.Client.RPC.Types.TransferTicketOperation
instance Data.Aeson.Types.ToJSON.ToJSON Morley.Client.RPC.Types.TransferTicketOperation
instance Morley.Client.Types.ToJSONObject Morley.Client.RPC.Types.TransferTicketOperation
instance Fmt.Buildable.Buildable Morley.Client.RPC.Types.TransactionOperation
instance Data.Aeson.Types.ToJSON.ToJSON Morley.Client.RPC.Types.TransactionOperation
instance Morley.Client.Types.ToJSONObject Morley.Client.RPC.Types.TransactionOperation
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.TransactionOperation
instance Data.Aeson.Types.FromJSON.FromJSON a => Data.Aeson.Types.FromJSON.FromJSON (Morley.Client.RPC.Types.WithSource a)
instance Fmt.Buildable.Buildable a => Fmt.Buildable.Buildable (Morley.Client.RPC.Types.WithSource a)
instance Data.Aeson.Types.ToJSON.ToJSON Morley.Client.RPC.Types.ForgeOperation
instance Data.Aeson.Types.ToJSON.ToJSON Morley.Client.RPC.Types.RunOperationInternal
instance Data.Aeson.Types.ToJSON.ToJSON Morley.Client.RPC.Types.PreApplyOperation
instance Morley.Client.Types.ToJSONObject a => Data.Aeson.Types.ToJSON.ToJSON (Morley.Client.RPC.Types.WithCommonOperationData a)
instance Data.Aeson.Types.FromJSON.FromJSON a => Data.Aeson.Types.FromJSON.FromJSON (Morley.Client.RPC.Types.WithCommonOperationData a)
instance Data.Aeson.Types.ToJSON.ToJSON Morley.Client.RPC.Types.CommonOperationData
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.CommonOperationData
instance Fmt.Buildable.Buildable Morley.Client.RPC.Types.ParametersInternal
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.OperationResult
instance GHC.Base.Semigroup Morley.Client.RPC.Types.AppliedResult
instance GHC.Base.Monoid Morley.Client.RPC.Types.AppliedResult
instance Fmt.Buildable.Buildable Morley.Client.RPC.Types.InternalError
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.InternalError
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.RunError
instance Fmt.Buildable.Buildable Morley.Client.RPC.Types.RunError
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.RPC.Types.BadStackInformation
instance Fmt.Buildable.Buildable Morley.Client.RPC.Types.BadStackInformation
instance Web.Internal.HttpApiData.ToHttpApiData Morley.Client.RPC.Types.BlockId
instance Fmt.Buildable.Buildable Morley.Client.RPC.Types.BlockId
instance Morley.Util.CLI.HasCLReader Morley.Client.RPC.Types.BlockId
instance Data.Default.Class.Default Morley.Client.RPC.Types.FeeConstants
-- | Various error types.
module Morley.Client.TezosClient.Types.Errors
-- | A data type for all predicatable errors that can happen during
-- octez-client usage.
data TezosClientError
-- | octez-client call unexpectedly failed (returned non-zero exit
-- code). The error contains the error code, stdout and stderr contents.
UnexpectedClientFailure :: Int -> Text -> Text -> TezosClientError
-- | Public key of the given address is already revealed.
AlreadyRevealed :: ImplicitAlias -> TezosClientError
-- | Can't wait for inclusion of operation with given hash because the hash
-- is invalid.
InvalidOperationHash :: OperationHash -> TezosClientError
-- | Error that indicates when given counter is already used for given
-- contract.
CounterIsAlreadyUsed :: Text -> Text -> TezosClientError
-- | Network error with which octez-client fails from time to
-- time.
EConnreset :: TezosClientError
-- | A parse error occurred during config parsing.
ConfigParseError :: String -> TezosClientError
-- | octez-client produced a cryptographic primitive that we can't
-- parse.
TezosClientCryptoParseError :: Text -> CryptoParseError -> TezosClientError
-- | octez-client produced an address that we can't parse.
TezosClientParseAddressError :: Text -> ParseAddressError -> TezosClientError
-- | octez-client produced invalid output for parsing baker fee
TezosClientParseFeeError :: Text -> Text -> TezosClientError
-- | octez-client printed a string that doesn't match the format
-- we expect.
TezosClientUnexpectedOutputFormat :: Text -> TezosClientError
-- | Given alias is a contract and cannot be revealed.
CantRevealContract :: ImplicitAlias -> TezosClientError
-- | Given contract is a source of a transfer or origination operation.
ContractSender :: ContractAddress -> Text -> TezosClientError
-- | Given alias is an empty implicit contract.
EmptyImplicitContract :: ImplicitAlias -> TezosClientError
-- | octez-client sign bytes produced unexpected output format
TezosClientUnexpectedSignatureOutput :: Text -> TezosClientError
-- | octez-client produced invalid output for parsing secret key
-- encryption type.
TezosClientParseEncryptionTypeError :: Text -> Text -> TezosClientError
-- | Tried to save alias, but such alias already exists.
DuplicateAlias :: Text -> TezosClientError
-- | Expected an alias to be associated with either an implicit address or
-- a contract address, but it was associated with both.
AmbiguousAlias :: Text -> ContractAddress -> ImplicitAddress -> TezosClientError
ResolveError :: ResolveError -> TezosClientError
data ResolveError
[REAliasNotFound] :: Text -> ResolveError
[REWrongKind] :: Alias expectedKind -> Address -> ResolveError
[REAddressNotFound] :: KindedAddress kind -> ResolveError
instance GHC.Show.Show Morley.Client.TezosClient.Types.Errors.TezosClientError
instance GHC.Show.Show Morley.Client.TezosClient.Types.Errors.ResolveError
instance GHC.Exception.Type.Exception Morley.Client.TezosClient.Types.Errors.TezosClientError
instance Fmt.Buildable.Buildable Morley.Client.TezosClient.Types.Errors.TezosClientError
instance Fmt.Buildable.Buildable Morley.Client.TezosClient.Types.Errors.ResolveError
-- | Various errors that can happen in the RPC part of
-- morley-client.
module Morley.Client.RPC.Error
-- | Errors that can happen in the RPC part when a user tries to make
-- failing actions.
data ClientRpcError
-- | Smart contract execution has failed.
ContractFailed :: ContractAddress -> Expression -> ClientRpcError
-- | Parameter passed to a contract does not match its type.
BadParameter :: Address -> Expression -> ClientRpcError
-- | Transfer of 0 to an implicit account.
EmptyTransaction :: ImplicitAddress -> ClientRpcError
-- | A smart contract execution failed due to a shift overflow.
ShiftOverflow :: ContractAddress -> ClientRpcError
-- | A smart contract execution failed due gas exhaustion.
GasExhaustion :: ContractAddress -> ClientRpcError
-- | A key has already been revealed.
KeyAlreadyRevealed :: ImplicitAddress -> ClientRpcError
-- | Address not registered as delegate
DelegateNotRegistered :: ImplicitAddress -> ClientRpcError
-- | 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
-- InternalError here as is, because it's easy for a user of
-- morley-client to work with this type. In #284 we will
-- consider more errors and maybe some of them will need to be mapped
-- into something more user-friendly, then we will reconsider this
-- approach.
ClientInternalError :: InternalError -> ClientRpcError
data ClientRpcErrorWithStack a
ClientRpcErrorWithStack :: NonEmpty (OperationResp WithSource) -> a -> ClientRpcErrorWithStack a
[crewsStack] :: ClientRpcErrorWithStack a -> NonEmpty (OperationResp WithSource)
[crewsError] :: ClientRpcErrorWithStack a -> a
-- | Errors that can happen during run_code endpoint call. These
-- errors returned along with 500 code, so we have to handle them a bit
-- differently in comparison to other run errors that are returned as a
-- part of successful JSON response.
data RunCodeErrors
RunCodeErrors :: [RunError] -> RunCodeErrors
-- | Errors that we don't expect to happen, but they can be reported by the
-- server.
data UnexpectedErrors
UnexpectedRunErrors :: [RunError] -> UnexpectedErrors
UnexpectedInternalErrors :: [InternalError] -> UnexpectedErrors
-- | 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.
data IncorrectRpcResponse
RpcUnexpectedSize :: Int -> Int -> IncorrectRpcResponse
RpcOriginatedNoContracts :: IncorrectRpcResponse
RpcOriginatedMoreContracts :: [ContractAddress] -> IncorrectRpcResponse
data WaitForOperationError
WaitForOperationBlockout :: Word -> WaitForOperationError
WaitForOperationStreamingError :: Text -> WaitForOperationError
instance GHC.Show.Show a => GHC.Show.Show (Morley.Client.RPC.Error.ClientRpcErrorWithStack a)
instance GHC.Show.Show Morley.Client.RPC.Error.ClientRpcError
instance GHC.Show.Show Morley.Client.RPC.Error.RunCodeErrors
instance GHC.Show.Show Morley.Client.RPC.Error.UnexpectedErrors
instance GHC.Show.Show Morley.Client.RPC.Error.IncorrectRpcResponse
instance GHC.Show.Show Morley.Client.RPC.Error.WaitForOperationError
instance Fmt.Buildable.Buildable Morley.Client.RPC.Error.WaitForOperationError
instance GHC.Exception.Type.Exception Morley.Client.RPC.Error.WaitForOperationError
instance Fmt.Buildable.Buildable Morley.Client.RPC.Error.IncorrectRpcResponse
instance GHC.Exception.Type.Exception Morley.Client.RPC.Error.IncorrectRpcResponse
instance Fmt.Buildable.Buildable Morley.Client.RPC.Error.UnexpectedErrors
instance GHC.Exception.Type.Exception Morley.Client.RPC.Error.UnexpectedErrors
instance Fmt.Buildable.Buildable Morley.Client.RPC.Error.RunCodeErrors
instance GHC.Exception.Type.Exception Morley.Client.RPC.Error.RunCodeErrors
instance Fmt.Buildable.Buildable Morley.Client.RPC.Error.ClientRpcError
instance GHC.Exception.Type.Exception Morley.Client.RPC.Error.ClientRpcError
instance Fmt.Buildable.Buildable a => Fmt.Buildable.Buildable (Morley.Client.RPC.Error.ClientRpcErrorWithStack a)
instance (GHC.Show.Show a, Data.Typeable.Internal.Typeable a, Fmt.Buildable.Buildable a) => GHC.Exception.Type.Exception (Morley.Client.RPC.Error.ClientRpcErrorWithStack a)
-- | An abstraction layer over RPC implementation. The primary reason it
-- exists is to make it possible to fake RPC in tests.
module Morley.Client.RPC.Class
-- | Type class that provides interaction with tezos node via RPC
class (Monad m, MonadCatch m) => HasTezosRpc m
-- | Get hash of the given BlockId, mostly used to get hash of
-- HeadId
getBlockHash :: HasTezosRpc m => BlockId -> m BlockHash
-- | Get address counter, which is required for both transaction sending
-- and contract origination.
getCounterAtBlock :: HasTezosRpc m => BlockId -> ImplicitAddress -> m TezosInt64
-- | Get the whole header of a block.
getBlockHeader :: HasTezosRpc m => BlockId -> m BlockHeader
-- | Get the script size at block.
getScriptSizeAtBlock :: HasTezosRpc m => BlockId -> CalcSize -> m ScriptSize
-- | Get block constants that are required by other RPC calls.
getBlockConstants :: HasTezosRpc m => BlockId -> m BlockConstants
-- | Get all operations from the block with specified ID.
getBlockOperations :: HasTezosRpc m => BlockId -> m [[BlockOperation]]
-- | Get all operation hashes from the block with specified ID.
getBlockOperationHashes :: HasTezosRpc m => BlockId -> m [[OperationHash]]
-- | Get protocol parameters that are for limits calculations.
getProtocolParametersAtBlock :: HasTezosRpc m => BlockId -> m ProtocolParameters
-- | 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.
runOperationAtBlock :: HasTezosRpc m => BlockId -> RunOperation -> m RunOperationResult
-- | 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.
preApplyOperationsAtBlock :: HasTezosRpc m => BlockId -> [PreApplyOperation] -> m [RunOperationResult]
-- | Forge operation in order to receive its hexadecimal representation.
forgeOperationAtBlock :: HasTezosRpc m => BlockId -> ForgeOperation -> m HexJSONByteString
-- | Inject operation, note that this operation has to be signed before
-- injection. As a result it returns operation hash.
injectOperation :: HasTezosRpc m => HexJSONByteString -> m OperationHash
-- | 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.
getContractScriptAtBlock :: HasTezosRpc m => BlockId -> ContractAddress -> m OriginationScript
-- | 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.
getContractStorageAtBlock :: HasTezosRpc m => BlockId -> ContractAddress -> m Expression
-- | Get big map value by contract address.
getContractBigMapAtBlock :: HasTezosRpc m => BlockId -> ContractAddress -> GetBigMap -> m GetBigMapResult
-- | Get big map value at some block by the big map's ID and the hashed
-- entry key.
getBigMapValueAtBlock :: HasTezosRpc m => BlockId -> Natural -> Text -> m Expression
-- | Get all big map values at some block by the big map's ID and the
-- optional offset and length.
getBigMapValuesAtBlock :: HasTezosRpc m => BlockId -> Natural -> Maybe Natural -> Maybe Natural -> m Expression
-- | Get balance for given address.
getBalanceAtBlock :: HasTezosRpc m => BlockId -> Address -> m Mutez
-- | Get delegate for given address.
getDelegateAtBlock :: HasTezosRpc m => BlockId -> L1Address -> m (Maybe KeyHash)
-- | Emulate contract call. This RPC endpoint does the same as
-- octez-client run script command does.
runCodeAtBlock :: HasTezosRpc m => BlockId -> RunCode -> m RunCodeResult
-- | Get current ChainId
getChainId :: HasTezosRpc m => m ChainId
-- | Get manager key for given address. Returns Nothing if this
-- key wasn't revealed.
getManagerKeyAtBlock :: HasTezosRpc m => BlockId -> ImplicitAddress -> m (Maybe PublicKey)
-- | Blocks until an operation with the given hash is included into the
-- chain. The first argument is the action that puts the operation on the
-- chain. Returns the hash of the included operation.
waitForOperation :: HasTezosRpc m => m OperationHash -> m OperationHash
-- | Access the contract's or implicit account's balance of ticket with
-- specified ticketer, content type, and content.
getTicketBalanceAtBlock :: HasTezosRpc m => BlockId -> Address -> GetTicketBalance -> m Natural
-- | Access the complete list of tickets owned by the given contract by
-- scanning the contract's storage.
getAllTicketBalancesAtBlock :: HasTezosRpc m => BlockId -> ContractAddress -> m [GetAllTicketBalancesResponse]
-- | Pack typed value into hexadecimal text representation.
packData :: (HasTezosRpc m, ForbidOp t) => BlockId -> Value t -> Notes t -> m Text
-- | Some read-only actions (wrappers over RPC calls).
module Morley.Client.RPC.Getters
-- | Failed to decode received value to the given type.
data ValueDecodeFailure
ValueDecodeFailure :: Text -> T -> ValueDecodeFailure
data ValueNotFound
ValueNotFound :: ValueNotFound
-- | Read all big_map values, given it's ID. If the values are not of the
-- expected type, a ValueDecodeFailure will be thrown.
readAllBigMapValues :: forall v k m. (NiceUnpackedValue v, HasTezosRpc m) => BigMapId k v -> m [v]
-- | 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.
readAllBigMapValuesMaybe :: forall v k m. (NiceUnpackedValue v, HasTezosRpc m) => BigMapId k v -> m (Maybe [v])
-- | Read big_map value of given contract by key.
--
-- If the contract contains several big_maps with given key
-- type, only one of them will be considered.
readContractBigMapValue :: forall k v m. (PackedValScope k, HasTezosRpc m, SingI v) => ContractAddress -> Value k -> m (Value v)
-- | 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.
readBigMapValueMaybe :: forall v k m. (NicePackedValue k, NiceUnpackedValue v, HasTezosRpc m) => BigMapId k v -> k -> m (Maybe v)
-- | 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.
readBigMapValue :: forall v k m. (NicePackedValue k, NiceUnpackedValue v, HasTezosRpc m) => BigMapId k v -> k -> m v
-- | Get originated Contract for some address.
getContract :: HasTezosRpc m => ContractAddress -> m Contract
-- | Get counter value for given implicit address.
getImplicitContractCounter :: HasTezosRpc m => ImplicitAddress -> m TezosInt64
-- | Extract parameter types for all smart contracts' addresses and return
-- mapping from their hashes to their parameter types
getContractsParameterTypes :: HasTezosRpc m => [ContractAddress] -> m TcOriginatedContracts
-- | getContractStorageAtBlock applied to the head block.
getContractStorage :: HasTezosRpc m => ContractAddress -> m Expression
-- | getScriptSizeAtBlock applied to the head block.
getScriptSize :: HasTezosRpc m => CalcSize -> m ScriptSize
-- | getBigMapValueAtBlock applied to the head block.
getBigMapValue :: HasTezosRpc m => Natural -> Text -> m Expression
-- | getBigMapValuesAtBlock applied to the head block.
getBigMapValues :: HasTezosRpc m => Natural -> Maybe Natural -> Maybe Natural -> m Expression
-- | Get hash of the current head block, this head hash is used in other
-- RPC calls.
getHeadBlock :: HasTezosRpc m => m BlockHash
-- | getCounterAtBlock applied to the head block.
getCounter :: HasTezosRpc m => ImplicitAddress -> m TezosInt64
-- | getProtocolParametersAtBlock applied to the head block.
getProtocolParameters :: HasTezosRpc m => m ProtocolParameters
-- | runOperationAtBlock applied to the head block.
runOperation :: HasTezosRpc m => RunOperation -> m RunOperationResult
-- | preApplyOperationsAtBlock applied to the head block.
preApplyOperations :: HasTezosRpc m => [PreApplyOperation] -> m [RunOperationResult]
-- | forgeOperationAtBlock applied to the head block.
forgeOperation :: HasTezosRpc m => ForgeOperation -> m HexJSONByteString
-- | getContractScriptAtBlock applied to the head block.
getContractScript :: HasTezosRpc m => ContractAddress -> m OriginationScript
-- | getContractBigMapAtBlock applied to the head block.
getContractBigMap :: HasTezosRpc m => ContractAddress -> GetBigMap -> m GetBigMapResult
-- | getBalanceAtBlock applied to the head block.
getBalance :: forall kind m. (HasTezosRpc m, L1AddressKind kind) => KindedAddress kind -> m Mutez
-- | getDelegateAtBlock applied to the head block.
getDelegate :: HasTezosRpc m => L1Address -> m (Maybe KeyHash)
-- | runCodeAtBlock applied to the head block.
runCode :: HasTezosRpc m => RunCode -> m RunCodeResult
getManagerKey :: HasTezosRpc m => ImplicitAddress -> m (Maybe PublicKey)
-- | Get ContractState for a given ContractAddress at a given
-- BlockId. Can be used with the morley interpreter to add some
-- network interoperability.
contractStateResolver :: HasTezosRpc m => BlockId -> ContractAddress -> m (Maybe ContractState)
getTicketBalance :: HasTezosRpc m => L1Address -> GetTicketBalance -> m Natural
getAllTicketBalances :: HasTezosRpc m => ContractAddress -> m [GetAllTicketBalancesResponse]
instance GHC.Show.Show Morley.Client.RPC.Getters.ContractGetCounterAttempt
instance GHC.Show.Show Morley.Client.RPC.Getters.ValueDecodeFailure
instance GHC.Show.Show Morley.Client.RPC.Getters.ValueNotFound
instance GHC.Show.Show Morley.Client.RPC.Getters.ContractNotFound
instance Fmt.Buildable.Buildable Morley.Client.RPC.Getters.ContractNotFound
instance GHC.Exception.Type.Exception Morley.Client.RPC.Getters.ContractNotFound
instance GHC.Exception.Type.Exception Morley.Client.RPC.Getters.ValueNotFound
instance Fmt.Buildable.Buildable Morley.Client.RPC.Getters.ValueNotFound
instance GHC.Exception.Type.Exception Morley.Client.RPC.Getters.ValueDecodeFailure
instance Fmt.Buildable.Buildable Morley.Client.RPC.Getters.ValueDecodeFailure
instance GHC.Exception.Type.Exception Morley.Client.RPC.Getters.ContractGetCounterAttempt
instance Fmt.Buildable.Buildable Morley.Client.RPC.Getters.ContractGetCounterAttempt
-- | This module contains servant types for octez-node RPC API.
module Morley.Client.RPC.API
data NodeMethods m
NodeMethods :: (BlockId -> m Text) -> (BlockId -> ImplicitAddress -> m TezosInt64) -> (BlockId -> ContractAddress -> m OriginationScript) -> (BlockId -> ContractAddress -> m Expression) -> (BlockId -> Address -> GetTicketBalance -> m TezosNat) -> (BlockId -> ContractAddress -> m [GetAllTicketBalancesResponse]) -> (BlockId -> m BlockConstants) -> (BlockId -> m BlockHeader) -> (BlockId -> m ProtocolParameters) -> (BlockId -> m [[BlockOperation]]) -> (BlockId -> m [[OperationHash]]) -> (BlockId -> ContractAddress -> GetBigMap -> m GetBigMapResult) -> (BlockId -> Natural -> Text -> m Expression) -> (BlockId -> Natural -> Maybe Natural -> Maybe Natural -> m Expression) -> (BlockId -> Address -> m TezosMutez) -> (BlockId -> L1Address -> m (Maybe KeyHash)) -> (BlockId -> CalcSize -> m ScriptSize) -> (BlockId -> ForgeOperation -> m HexJSONByteString) -> (BlockId -> RunOperation -> m RunOperationResult) -> (BlockId -> [PreApplyOperation] -> m [RunOperationResult]) -> (BlockId -> RunCode -> m RunCodeResult) -> (BlockId -> ImplicitAddress -> m (Maybe PublicKey)) -> m Text -> (HexJSONByteString -> m OperationHash) -> (BlockId -> PackData -> m PackDataResult) -> NodeMethods m
[getBlockHash] :: NodeMethods m -> BlockId -> m Text
[getCounter] :: NodeMethods m -> BlockId -> ImplicitAddress -> m TezosInt64
[getScript] :: NodeMethods m -> BlockId -> ContractAddress -> m OriginationScript
[getStorageAtBlock] :: NodeMethods m -> BlockId -> ContractAddress -> m Expression
[getTicketBalanceAtBlock] :: NodeMethods m -> BlockId -> Address -> GetTicketBalance -> m TezosNat
[getAllTicketBalancesAtBlock] :: NodeMethods m -> BlockId -> ContractAddress -> m [GetAllTicketBalancesResponse]
[getBlockConstants] :: NodeMethods m -> BlockId -> m BlockConstants
[getBlockHeader] :: NodeMethods m -> BlockId -> m BlockHeader
[getProtocolParameters] :: NodeMethods m -> BlockId -> m ProtocolParameters
[getBlockOperations] :: NodeMethods m -> BlockId -> m [[BlockOperation]]
[getBlockOperationHashes] :: NodeMethods m -> BlockId -> m [[OperationHash]]
[getBigMap] :: NodeMethods m -> BlockId -> ContractAddress -> GetBigMap -> m GetBigMapResult
[getBigMapValueAtBlock] :: NodeMethods m -> BlockId -> Natural -> Text -> m Expression
[getBigMapValuesAtBlock] :: NodeMethods m -> BlockId -> Natural -> Maybe Natural -> Maybe Natural -> m Expression
[getBalance] :: NodeMethods m -> BlockId -> Address -> m TezosMutez
[getDelegate] :: NodeMethods m -> BlockId -> L1Address -> m (Maybe KeyHash)
[getScriptSizeAtBlock] :: NodeMethods m -> BlockId -> CalcSize -> m ScriptSize
[forgeOperation] :: NodeMethods m -> BlockId -> ForgeOperation -> m HexJSONByteString
[runOperation] :: NodeMethods m -> BlockId -> RunOperation -> m RunOperationResult
[preApplyOperations] :: NodeMethods m -> BlockId -> [PreApplyOperation] -> m [RunOperationResult]
[runCode] :: NodeMethods m -> BlockId -> RunCode -> m RunCodeResult
[getManagerKey] :: NodeMethods m -> BlockId -> ImplicitAddress -> m (Maybe PublicKey)
[getChainId] :: NodeMethods m -> m Text
[injectOperation] :: NodeMethods m -> HexJSONByteString -> m OperationHash
[packData] :: NodeMethods m -> BlockId -> PackData -> m PackDataResult
nodeMethods :: forall m. (MonadCatch m, RunClient m) => NodeMethods m
monitorHeads :: forall m. RunStreamingClient m => m (SourceIO BlockHeader)
instance Web.Internal.HttpApiData.ToHttpApiData Morley.Client.RPC.API.Address'
instance Web.Internal.HttpApiData.ToHttpApiData (Morley.Client.RPC.API.KindedAddress' kind)
-- | Interface to node RPC (and its implementation).
module Morley.Client.RPC
-- | Functions useful for implementing instances of type classes from this
-- package. Monads and actual instances are defined in separate modules.
module Morley.Client.App
runRequestAcceptStatusImpl :: forall env m. (WithClientLog env m, MonadIO m, MonadThrow m) => ClientEnv -> Maybe [Status] -> Request -> m Response
throwClientErrorImpl :: forall m a. MonadThrow m => ClientError -> m a
getBlockHashImpl :: (RunClient m, MonadUnliftIO m, MonadCatch m) => BlockId -> m BlockHash
getCounterImpl :: (RunClient m, MonadUnliftIO m, MonadCatch m) => BlockId -> ImplicitAddress -> m TezosInt64
getBlockHeaderImpl :: (RunClient m, MonadUnliftIO m, MonadCatch m) => BlockId -> m BlockHeader
getBlockConstantsImpl :: (RunClient m, MonadUnliftIO m, MonadCatch m) => BlockId -> m BlockConstants
getScriptSizeAtBlockImpl :: (RunClient m, MonadUnliftIO m, MonadCatch m) => BlockId -> CalcSize -> m ScriptSize
getBlockOperationsImpl :: (RunClient m, MonadUnliftIO m, MonadCatch m) => BlockId -> m [[BlockOperation]]
getBlockOperationHashesImpl :: (RunClient m, MonadUnliftIO m, MonadCatch m) => BlockId -> m [[OperationHash]]
getProtocolParametersImpl :: (RunClient m, MonadUnliftIO m, MonadCatch m) => BlockId -> m ProtocolParameters
runOperationImpl :: (RunClient m, MonadUnliftIO m, MonadCatch m) => BlockId -> RunOperation -> m RunOperationResult
preApplyOperationsImpl :: (RunClient m, MonadUnliftIO m, MonadCatch m) => BlockId -> [PreApplyOperation] -> m [RunOperationResult]
forgeOperationImpl :: (RunClient m, MonadUnliftIO m, MonadCatch m) => BlockId -> ForgeOperation -> m HexJSONByteString
injectOperationImpl :: (RunClient m, MonadUnliftIO m, MonadCatch m) => HexJSONByteString -> m OperationHash
getContractScriptImpl :: (RunClient m, MonadUnliftIO m, MonadCatch m) => BlockId -> ContractAddress -> m OriginationScript
getContractStorageAtBlockImpl :: (RunClient m, MonadUnliftIO m, MonadCatch m) => BlockId -> ContractAddress -> m Expression
getContractBigMapImpl :: (RunClient m, MonadUnliftIO m, MonadCatch m) => BlockId -> ContractAddress -> GetBigMap -> m GetBigMapResult
getBigMapValueAtBlockImpl :: (RunClient m, MonadUnliftIO m, MonadCatch m) => BlockId -> Natural -> Text -> m Expression
getBigMapValuesAtBlockImpl :: (RunClient m, MonadUnliftIO m, MonadCatch m) => BlockId -> Natural -> Maybe Natural -> Maybe Natural -> m Expression
getBalanceImpl :: (RunClient m, MonadUnliftIO m, MonadCatch m) => BlockId -> Address -> m Mutez
-- | Similar to getManagerKey, but retries once on timeout.
getManagerKeyImpl :: (RunClient m, MonadUnliftIO m, MonadCatch m) => BlockId -> ImplicitAddress -> m (Maybe PublicKey)
runCodeImpl :: (RunClient m, MonadCatch m) => BlockId -> RunCode -> m RunCodeResult
getChainIdImpl :: (RunClient m, MonadCatch m) => m ChainId
getDelegateImpl :: (RunClient m, MonadUnliftIO m, MonadCatch m) => BlockId -> L1Address -> m (Maybe KeyHash)
waitForOperationImpl :: forall m. (MonadUnliftIO m, HasTezosRpc m) => m OperationHash -> ClientEnv -> m OperationHash
getTicketBalanceAtBlockImpl :: (RunClient m, MonadUnliftIO m, MonadCatch m) => BlockId -> Address -> GetTicketBalance -> m Natural
getAllTicketBalancesAtBlockImpl :: (RunClient m, MonadUnliftIO m, MonadCatch m) => BlockId -> ContractAddress -> m [GetAllTicketBalancesResponse]
packDataImpl :: (ForbidOp t, RunClient m, MonadCatch m, MonadUnliftIO m) => BlockId -> Value t -> Notes t -> m Text
-- | Helper function that retries a monadic action in case action hasn't
-- succeed in timeoutInterval. In case retry didn't help, error
-- that indicates timeout is thrown.
retryOnTimeout :: (MonadUnliftIO m, MonadThrow m) => Bool -> m a -> m a
-- | Helper function that consider action failed in case of timeout,
-- because it's unsafe to perform some of the actions twice. E.g.
-- performing two injectOperation action can lead to a situation
-- when operation is injected twice.
failOnTimeout :: (MonadUnliftIO m, MonadThrow m) => m a -> m a
-- | Helper function that retries action once in case of timeout. If retry
-- ended up with timeout as well, action is considered failed. It's safe
-- to retry read-only actions that don't update chain state or
-- octez-client config/environment.
retryOnceOnTimeout :: (MonadUnliftIO m, MonadThrow m) => m a -> m a
-- | Wait for a reasonable amount of time before retrying an action that
-- failed due to invalid counter. The waiting time depends on protocol
-- parameters.
waitBeforeRetry :: (MonadIO m, HasTezosRpc m, WithClientLog env m) => m ()
-- | Retry action if it failed due to invalid counter (already used one).
handleInvalidCounterRpc :: MonadThrow m => m a -> ClientRpcError -> m a
instance GHC.Show.Show Morley.Client.App.TimeoutError
instance Fmt.Buildable.Buildable Morley.Client.App.TimeoutError
instance GHC.Exception.Type.Exception Morley.Client.App.TimeoutError
module Morley.Client.Action.SizeCalculation
computeUntypedContractSize :: HasTezosRpc m => Contract -> Value -> m Natural
computeContractSize :: forall m cp st. (HasTezosRpc m, StorageScope st) => Contract cp st -> Value st -> m Natural
-- | Container for address-to-alias and vice versa translation.
module Morley.Client.Types.AliasesAndAddresses
data AliasesAndAddresses
lookupAddr :: Alias kind -> AliasesAndAddresses -> Maybe (KindedAddress kind)
lookupAlias :: KindedAddress kind -> AliasesAndAddresses -> Maybe (Alias kind)
mkAliasesAndAddresses :: [Constrained NullConstraint AddressWithAlias] -> AliasesAndAddresses
insertAliasAndAddress :: Alias kind -> KindedAddress kind -> AliasesAndAddresses -> AliasesAndAddresses
emptyAliasesAndAddresses :: AliasesAndAddresses
module Morley.Client.Util
-- | Convert EpName to the textual representation used by RPC and
-- octez-client.
epNameToTezosEp :: EpName -> Text
-- | Extract all addresses value from given untyped Value.
--
-- Note that it returns all values that can be used as an address.
-- However, some of fetched values can never be used as an address.
extractAddressesFromValue :: Value -> [Address]
-- | Sets the environment variable for disabling octez-client's
-- "not a mainnet" warning
disableAlphanetWarning :: IO ()
-- | Run contract with given parameter and storage and get new storage
-- without injecting anything to the chain.
runContract :: forall cp st m. (HasTezosRpc m, StorageScope st) => RunContractParameters cp st -> m (AsRPC (Value st))
-- | A structure with all the parameters for runContract
data RunContractParameters cp st
RunContractParameters :: Contract cp st -> Value -> Value -> Mutez -> Maybe Timestamp -> Maybe Natural -> Mutez -> Maybe ImplicitAddress -> Maybe ImplicitAddress -> RunContractParameters cp st
[rcpContract] :: RunContractParameters cp st -> Contract cp st
-- | The parameter value should have the same "structure" as cp,
-- except it _may_ also have big_map IDs. E.g. if the contract's
-- parameter is pair (big_map string string) (big_map string
-- string), then rcpParameter may be one of:
--
--
-- pair (big_map string string) (big_map string
-- string)
-- pair nat (big_map string string)
-- pair (big_map string string) nat
-- pair nat nat
--
--
-- ... where nat represents a big_map ID.
[rcpParameter] :: RunContractParameters cp st -> Value
-- | The storage value should have the same "structure" as st,
-- except it _may_ also have big_map IDs. See the documentation of
-- rcpParameter.
[rcpStorage] :: RunContractParameters cp st -> Value
[rcpBalance] :: RunContractParameters cp st -> Mutez
[rcpNow] :: RunContractParameters cp st -> Maybe Timestamp
[rcpLevel] :: RunContractParameters cp st -> Maybe Natural
[rcpAmount] :: RunContractParameters cp st -> Mutez
[rcpSender] :: RunContractParameters cp st -> Maybe ImplicitAddress
[rcpSource] :: RunContractParameters cp st -> Maybe ImplicitAddress
-- | Initializes the parameters for runContract with sensible
-- defaults.
--
-- Use the with* lenses to set any optional parameters.
runContractParameters :: (ForbidOp cp, ForbidOp st) => Contract cp st -> Value cp -> Value st -> RunContractParameters cp st
withBalance :: forall cp_a23qb st_a23qc. Lens' (RunContractParameters cp_a23qb st_a23qc) Mutez
withAmount :: forall cp_a23qb st_a23qc. Lens' (RunContractParameters cp_a23qb st_a23qc) Mutez
withSender :: forall cp_a23qb st_a23qc. Lens' (RunContractParameters cp_a23qb st_a23qc) (Maybe ImplicitAddress)
withSource :: forall cp_a23qb st_a23qc. Lens' (RunContractParameters cp_a23qb st_a23qc) (Maybe ImplicitAddress)
withLevel :: forall cp_a23qb st_a23qc. Lens' (RunContractParameters cp_a23qb st_a23qc) (Maybe Natural)
withNow :: forall cp_a23qb st_a23qc. Lens' (RunContractParameters cp_a23qb st_a23qc) (Maybe Timestamp)
-- | Convert ScrubbedBytes to String, so that it can be
-- passed to octez-client as a stdin
scrubbedBytesToString :: ScrubbedBytes -> String
-- | Function for relatively safe getting password from stdin. After
-- reading bytes are converted to ScrubbedBytes, thus it's
-- harder to accidentally leak them.
readScrubbedBytes :: MonadIO m => m ScrubbedBytes
-- | Types used for interaction with octez-client.
module Morley.Client.TezosClient.Types
-- | An object that can be put as argument to a octez-client
-- command-line call.
class CmdArg a
-- | Render an object as a command-line argument.
toCmdArg :: CmdArg a => a -> String
-- | Render an object as a command-line argument.
toCmdArg :: (CmdArg a, Buildable a) => a -> String
-- | Data required for calculating fee for origination operation.
data CalcOriginationFeeData cp st
CalcOriginationFeeData :: AddressOrAlias kind -> TezosMutez -> Maybe ScrubbedBytes -> Contract cp st -> Value st -> TezosInt64 -> CalcOriginationFeeData cp st
[cofdFrom] :: CalcOriginationFeeData cp st -> AddressOrAlias kind
[cofdBalance] :: CalcOriginationFeeData cp st -> TezosMutez
[cofdMbFromPassword] :: CalcOriginationFeeData cp st -> Maybe ScrubbedBytes
[cofdContract] :: CalcOriginationFeeData cp st -> Contract cp st
[cofdStorage] :: CalcOriginationFeeData cp st -> Value st
[cofdBurnCap] :: CalcOriginationFeeData cp st -> TezosInt64
-- | Data required for calculating fee for transfer operation.
data CalcTransferFeeData
CalcTransferFeeData :: AddressOrAlias kind -> Value t -> EpName -> TezosMutez -> CalcTransferFeeData
[ctfdTo] :: CalcTransferFeeData -> AddressOrAlias kind
[ctfdParam] :: CalcTransferFeeData -> Value t
[ctfdEp] :: CalcTransferFeeData -> EpName
[ctfdAmount] :: CalcTransferFeeData -> TezosMutez
-- | Runtime environment for octez-client bindings.
data TezosClientEnv
TezosClientEnv :: BaseUrl -> FilePath -> Maybe FilePath -> MVar (Maybe AliasesAndAddresses) -> TezosClientEnv
-- | URL of tezos node on which operations are performed.
[tceEndpointUrl] :: TezosClientEnv -> BaseUrl
-- | Path to tezos client binary through which operations are performed.
[tceTezosClientPath] :: TezosClientEnv -> FilePath
-- | Path to tezos client data directory.
[tceMbTezosClientDataDir] :: TezosClientEnv -> Maybe FilePath
-- | Lazy cache for the mapping between addresses and aliases. The
-- Nothing value signifies the cache is either yet unpopulated or
-- was recently invalidated. The Just value is the cached result
-- of octez-client list known contracts. MVar itself
-- being empty/full is used for thread synchronization, as is usual.
[tceAliasMap] :: TezosClientEnv -> MVar (Maybe AliasesAndAddresses)
-- | Using this type class one can require MonadReader constraint
-- that holds any type with TezosClientEnv inside.
class HasTezosClientEnv env
tezosClientEnvL :: HasTezosClientEnv env => Lens' env TezosClientEnv
-- | Representation of address secret key encryption type
data SecretKeyEncryption
UnencryptedKey :: SecretKeyEncryption
EncryptedKey :: SecretKeyEncryption
LedgerKey :: SecretKeyEncryption
-- | How to save the originated contract address.
data AliasBehavior
-- | Don't save the newly originated contract address.
DontSaveAlias :: AliasBehavior
-- | If an alias already exists, keep it, don't save the newly originated
-- contract address.
KeepDuplicateAlias :: AliasBehavior
-- | If an alias already exists, replace it with the address of the newly
-- originated contract.
OverwriteDuplicateAlias :: AliasBehavior
-- | If an alias already exists, throw an exception without doing the
-- origination
ForbidDuplicateAlias :: AliasBehavior
tceEndpointUrlL :: Lens' TezosClientEnv BaseUrl
tceTezosClientPathL :: Lens' TezosClientEnv FilePath
tceMbTezosClientDataDirL :: Lens' TezosClientEnv (Maybe FilePath)
tceAliasMapL :: Lens' TezosClientEnv (MVar (Maybe AliasesAndAddresses))
instance GHC.Enum.Enum Morley.Client.TezosClient.Types.AliasBehavior
instance GHC.Classes.Ord Morley.Client.TezosClient.Types.AliasBehavior
instance GHC.Classes.Eq Morley.Client.TezosClient.Types.AliasBehavior
instance Data.Aeson.Types.ToJSON.ToJSON Morley.Client.TezosClient.Types.CalcTransferFeeData
instance GHC.Show.Show Morley.Client.TezosClient.Types.SecretKeyEncryption
instance GHC.Classes.Eq Morley.Client.TezosClient.Types.SecretKeyEncryption
instance Morley.Client.TezosClient.Types.CmdArg Data.Text.Internal.Text
instance Morley.Client.TezosClient.Types.CmdArg Universum.String.Conversion.LText
instance Morley.Client.TezosClient.Types.CmdArg GHC.Word.Word16
instance Morley.Client.TezosClient.Types.CmdArg Morley.Tezos.Crypto.SecretKey
instance Morley.Client.TezosClient.Types.CmdArg (Morley.Tezos.Address.KindedAddress kind)
instance Morley.Client.TezosClient.Types.CmdArg Morley.Tezos.Address.Address
instance Morley.Client.TezosClient.Types.CmdArg Data.ByteString.Internal.ByteString
instance Morley.Client.TezosClient.Types.CmdArg Morley.Michelson.Untyped.Entrypoints.EpName
instance Morley.Client.TezosClient.Types.CmdArg Morley.Tezos.Core.Mutez
instance Morley.Michelson.Typed.Scope.Internal.Scopes.UntypedValScope t => Morley.Client.TezosClient.Types.CmdArg (Morley.Michelson.Typed.Aliases.Value t)
instance Morley.Client.TezosClient.Types.CmdArg (Morley.Michelson.Typed.Aliases.Contract cp st)
instance Morley.Client.TezosClient.Types.CmdArg Servant.Client.Core.BaseUrl.BaseUrl
instance Morley.Client.TezosClient.Types.CmdArg Morley.Client.RPC.Types.OperationHash
instance Morley.Client.TezosClient.Types.CmdArg (Morley.Tezos.Address.Alias.Alias kind)
instance Morley.Client.TezosClient.Types.CmdArg (Morley.Tezos.Address.Alias.AddressOrAlias kind)
-- | Parsers that are used in Morley.Client.TezosClient.Impl
module Morley.Client.TezosClient.Parser
-- | Function to parse baker fee from given octez-client output.
parseBakerFeeFromOutput :: forall n. SingIPeano n => Text -> Either FeeParserException (SizedList n TezosMutez)
parseSecretKeyEncryption :: Text -> Either SecretKeyEncryptionParserException SecretKeyEncryption
instance GHC.Show.Show Morley.Client.TezosClient.Parser.FeeParserException
instance GHC.Classes.Eq Morley.Client.TezosClient.Parser.FeeParserException
instance GHC.Show.Show Morley.Client.TezosClient.Parser.UnexpectedEncryptionType
instance GHC.Classes.Ord Morley.Client.TezosClient.Parser.UnexpectedEncryptionType
instance GHC.Classes.Eq Morley.Client.TezosClient.Parser.UnexpectedEncryptionType
instance GHC.Show.Show Morley.Client.TezosClient.Parser.SecretKeyEncryptionParserException
instance GHC.Classes.Eq Morley.Client.TezosClient.Parser.SecretKeyEncryptionParserException
instance Fmt.Buildable.Buildable Morley.Client.TezosClient.Parser.SecretKeyEncryptionParserException
instance Text.Megaparsec.Error.ShowErrorComponent Morley.Client.TezosClient.Parser.UnexpectedEncryptionType
instance GHC.Exception.Type.Exception Morley.Client.TezosClient.Parser.FeeParserException
instance Fmt.Buildable.Buildable Morley.Client.TezosClient.Parser.FeeParserException
-- | Abstraction layer for octez-client functionality. We use it
-- to fake octez-client in tests.
module Morley.Client.TezosClient.Class
-- | Type class that provides interaction with octez-client binary
class (Monad m) => HasTezosClient m
-- | Sign an operation with octez-client.
signBytes :: HasTezosClient m => ImplicitAddressWithAlias -> Maybe ScrubbedBytes -> ByteString -> m Signature
-- | 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.
genKey :: HasTezosClient m => ImplicitAlias -> m ImplicitAddressWithAlias
-- | Generate a secret key and store it with given alias. Unlike
-- genKey this function overwrites the existing key when given
-- alias is already stored.
genFreshKey :: HasTezosClient m => ImplicitAlias -> m ImplicitAddressWithAlias
-- | Associate the given contract with alias. The Bool variable
-- indicates whether or not we should replace already existing contract
-- alias or not.
rememberContract :: HasTezosClient m => AliasBehavior -> ContractAddress -> ContractAlias -> m ()
-- | Retrieves a list with all known aliases and respective addresses.
--
-- Note that an alias can be ambiguous: it can refer to BOTH a contract
-- and an implicit account. In that case, the map will contain entries
-- for both.
getAliasesAndAddresses :: HasTezosClient m => m AliasesAndAddresses
-- | 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.
getKeyPassword :: HasTezosClient m => ImplicitAddressWithAlias -> m (Maybe ScrubbedBytes)
-- | Get a public key for an implicit address or alias.
getPublicKey :: HasTezosClient m => ImplicitAddressWithAlias -> m PublicKey
-- | How to save the originated contract address.
data AliasBehavior
-- | Don't save the newly originated contract address.
DontSaveAlias :: AliasBehavior
-- | If an alias already exists, keep it, don't save the newly originated
-- contract address.
KeepDuplicateAlias :: AliasBehavior
-- | If an alias already exists, replace it with the address of the newly
-- originated contract.
OverwriteDuplicateAlias :: AliasBehavior
-- | If an alias already exists, throw an exception without doing the
-- origination
ForbidDuplicateAlias :: AliasBehavior
-- | An alternative implementation of morley-client that does not
-- require octez-client and has some limitations because of that
-- (not all methods are implemented).
module Morley.Client.OnlyRPC
-- | Environment used by MorleyOnlyRpcM.
data MorleyOnlyRpcEnv
MorleyOnlyRpcEnv :: ClientLogAction MorleyOnlyRpcM -> ClientEnv -> Map ImplicitAddress SecretKey -> MorleyOnlyRpcEnv
-- | Action used to log messages.
[moreLogAction] :: MorleyOnlyRpcEnv -> ClientLogAction MorleyOnlyRpcM
-- | Environment necessary to make HTTP calls.
[moreClientEnv] :: MorleyOnlyRpcEnv -> ClientEnv
-- | In-memory secret keys that can be used for signing.
[moreSecretKeys] :: MorleyOnlyRpcEnv -> Map ImplicitAddress SecretKey
-- | 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.
--
mkMorleyOnlyRpcEnv :: [SecretKey] -> BaseUrl -> Word -> IO MorleyOnlyRpcEnv
-- | Monad that implements HasTezosClient and HasTezosRpc
-- classes and can be used for high-level actions as an alternative to
-- MorleyClientM.
newtype MorleyOnlyRpcM a
MorleyOnlyRpcM :: ReaderT MorleyOnlyRpcEnv IO a -> MorleyOnlyRpcM a
[unMorleyOnlyRpcM] :: MorleyOnlyRpcM a -> ReaderT MorleyOnlyRpcEnv IO a
-- | Run MorleyOnlyRpcM action within given MorleyOnlyRpcEnv.
-- Retry action in case of invalid counter error.
runMorleyOnlyRpcM :: MorleyOnlyRpcEnv -> MorleyOnlyRpcM a -> IO a
instance Control.Monad.IO.Unlift.MonadUnliftIO Morley.Client.OnlyRPC.MorleyOnlyRpcM
instance Control.Monad.Catch.MonadMask Morley.Client.OnlyRPC.MorleyOnlyRpcM
instance Control.Monad.Catch.MonadCatch Morley.Client.OnlyRPC.MorleyOnlyRpcM
instance Control.Monad.Catch.MonadThrow Morley.Client.OnlyRPC.MorleyOnlyRpcM
instance Control.Monad.IO.Class.MonadIO Morley.Client.OnlyRPC.MorleyOnlyRpcM
instance Control.Monad.Reader.Class.MonadReader Morley.Client.OnlyRPC.MorleyOnlyRpcEnv Morley.Client.OnlyRPC.MorleyOnlyRpcM
instance GHC.Base.Monad Morley.Client.OnlyRPC.MorleyOnlyRpcM
instance GHC.Base.Applicative Morley.Client.OnlyRPC.MorleyOnlyRpcM
instance GHC.Base.Functor Morley.Client.OnlyRPC.MorleyOnlyRpcM
instance GHC.Classes.Eq Morley.Client.OnlyRPC.UnsupportedByOnlyRPC
instance GHC.Show.Show Morley.Client.OnlyRPC.UnsupportedByOnlyRPC
instance GHC.Classes.Eq Morley.Client.OnlyRPC.MorleyOnlyRpcException
instance GHC.Show.Show Morley.Client.OnlyRPC.MorleyOnlyRpcException
instance GHC.Exception.Type.Exception Morley.Client.OnlyRPC.MorleyOnlyRpcException
instance Morley.Client.TezosClient.Class.HasTezosClient Morley.Client.OnlyRPC.MorleyOnlyRpcM
instance GHC.Exception.Type.Exception Morley.Client.OnlyRPC.UnsupportedByOnlyRPC
instance Colog.Core.Class.HasLog Morley.Client.OnlyRPC.MorleyOnlyRpcEnv Colog.Message.Message Morley.Client.OnlyRPC.MorleyOnlyRpcM
instance Servant.Client.Core.RunClient.RunClient Morley.Client.OnlyRPC.MorleyOnlyRpcM
instance Morley.Client.RPC.Class.HasTezosRpc Morley.Client.OnlyRPC.MorleyOnlyRpcM
-- | Helpers used to call octez-client.
module Morley.Client.TezosClient.Helpers
-- | Datatype that represents modes for calling node from
-- octez-client.
data CallMode
-- | Mode in which octez-client doesn't perform any actual RPC
-- calls to the node and use mock instead.
MockupMode :: CallMode
-- | Normal mode in which octez-client performs all necessary RPC
-- calls to the node.
ClientMode :: CallMode
-- | Call octez-client with given arguments. Arguments defined by
-- config are added automatically. The second argument specifies what
-- should be done in failure case. It takes stdout and stderr output.
-- Possible handling:
--
--
-- - Parse a specific error and throw it.
-- - Parse an expected error that shouldn't cause a failure. Return
-- True in this case.
-- - Detect an unexpected error, return False. In this case
-- UnexpectedClientFailure will be throw.
--
callTezosClient :: forall env m. (WithClientLog env m, HasTezosClientEnv env, MonadIO m, MonadCatch m) => (Text -> Text -> IO Bool) -> [String] -> CallMode -> Maybe ScrubbedBytes -> m Text
-- | Call octez-client and expect success.
callTezosClientStrict :: (WithClientLog env m, HasTezosClientEnv env, MonadIO m, MonadCatch m) => [String] -> CallMode -> Maybe ScrubbedBytes -> m Text
-- | Variant of readProcessWithExitCode that prints a better error
-- in case of an exception in the inner readProcessWithExitCode
-- call.
readProcessWithExitCode' :: FilePath -> [String] -> String -> IO (ExitCode, String, String)
-- | octez-client config.
module Morley.Client.TezosClient.Config
-- | Configuration maintained by octez-client, see its
-- config subcommands (e. g. octez-client config show).
-- Only the field we are interested in is present here.
newtype TezosClientConfig
TezosClientConfig :: BaseUrl -> TezosClientConfig
[tcEndpointUrl] :: TezosClientConfig -> BaseUrl
-- | Read octez-client configuration.
getTezosClientConfig :: FilePath -> Maybe FilePath -> IO TezosClientConfig
instance GHC.Show.Show Morley.Client.TezosClient.Config.TezosClientConfig
instance Data.Aeson.Types.FromJSON.FromJSON Morley.Client.TezosClient.Config.TezosClientConfig
-- | Full-featured Morley client, backed by octez-client.
module Morley.Client.TezosClient.Types.MorleyClientM
-- | Runtime environment for morley client.
data MorleyClientEnv
MorleyClientEnv :: TezosClientEnv -> ClientLogAction MorleyClientM -> Maybe SecretKey -> ClientEnv -> MorleyClientEnv
-- | Environment for octez-client.
[mceTezosClient] :: MorleyClientEnv -> TezosClientEnv
-- | Action used to log messages.
[mceLogAction] :: MorleyClientEnv -> ClientLogAction MorleyClientM
-- | Pass if you want to sign operations manually or leave it to
-- octez-client.
[mceSecretKey] :: MorleyClientEnv -> Maybe SecretKey
-- | Environment necessary to make HTTP calls.
[mceClientEnv] :: MorleyClientEnv -> ClientEnv
-- | Data necessary for morley client initialization.
data MorleyClientConfig
MorleyClientConfig :: Maybe BaseUrl -> FilePath -> Maybe FilePath -> Word -> Maybe SecretKey -> MorleyClientConfig
-- | URL of tezos endpoint on which operations are performed
[mccEndpointUrl] :: MorleyClientConfig -> Maybe BaseUrl
-- | Path to octez-client binary through which operations are
-- performed
[mccTezosClientPath] :: MorleyClientConfig -> FilePath
-- | Path to octez-client data directory.
[mccMbTezosClientDataDir] :: MorleyClientConfig -> Maybe FilePath
-- | Verbosity level. 0 means that only important messages will be
-- printed. The greater this value is, the more messages will be printed
-- during execution. After some small unspecified limit increasing this
-- value does not change anything.
[mccVerbosity] :: MorleyClientConfig -> Word
-- | Custom secret key to use for signing.
[mccSecretKey] :: MorleyClientConfig -> Maybe SecretKey
data MorleyClientM a
-- | Run MorleyClientM action within given MorleyClientEnv.
-- Retry action in case of invalid counter error.
runMorleyClientM :: MorleyClientEnv -> MorleyClientM a -> IO a
-- | Construct MorleyClientEnv.
--
--
-- - octez-client path is taken from
-- MorleyClientConfig, but can be overridden using
-- MORLEY_TEZOS_CLIENT environment variable.
-- - Node data is taken from octez-client config and can be
-- overridden by MorleyClientConfig.
-- - The rest is taken from MorleyClientConfig as is.
--
mkMorleyClientEnv :: MorleyClientConfig -> IO MorleyClientEnv
-- | Make appropriate ClientLogAction based on verbosity specified
-- by the user.
mkLogAction :: MonadIO m => Word -> ClientLogAction m
mceTezosClientL :: Lens' MorleyClientEnv TezosClientEnv
mceLogActionL :: Lens' MorleyClientEnv (ClientLogAction MorleyClientM)
mceSecretKeyL :: Lens' MorleyClientEnv (Maybe SecretKey)
mceClientEnvL :: Lens' MorleyClientEnv ClientEnv
mccEndpointUrlL :: Lens' MorleyClientConfig (Maybe BaseUrl)
mccTezosClientPathL :: Lens' MorleyClientConfig FilePath
mccMbTezosClientDataDirL :: Lens' MorleyClientConfig (Maybe FilePath)
mccVerbosityL :: Lens' MorleyClientConfig Word
mccSecretKeyL :: Lens' MorleyClientConfig (Maybe SecretKey)
instance Morley.Client.TezosClient.Types.HasTezosClientEnv Morley.Client.TezosClient.Types.MorleyClientM.MorleyClientEnv
instance Colog.Core.Class.HasLog Morley.Client.TezosClient.Types.MorleyClientM.MorleyClientEnv Colog.Message.Message Morley.Client.TezosClient.Types.MorleyClientM.MorleyClientM
instance Servant.Client.Core.RunClient.RunClient Morley.Client.TezosClient.Types.MorleyClientM.MorleyClientM
instance Morley.Client.RPC.Class.HasTezosRpc Morley.Client.TezosClient.Types.MorleyClientM.MorleyClientM
instance Control.Monad.IO.Unlift.MonadUnliftIO Morley.Client.TezosClient.Types.MorleyClientM.MorleyClientM
instance Control.Monad.Catch.MonadMask Morley.Client.TezosClient.Types.MorleyClientM.MorleyClientM
instance Control.Monad.Catch.MonadCatch Morley.Client.TezosClient.Types.MorleyClientM.MorleyClientM
instance Control.Monad.Catch.MonadThrow Morley.Client.TezosClient.Types.MorleyClientM.MorleyClientM
instance Control.Monad.IO.Class.MonadIO Morley.Client.TezosClient.Types.MorleyClientM.MorleyClientM
instance Control.Monad.Reader.Class.MonadReader Morley.Client.TezosClient.Types.MorleyClientM.MorleyClientEnv Morley.Client.TezosClient.Types.MorleyClientM.MorleyClientM
instance GHC.Base.Monad Morley.Client.TezosClient.Types.MorleyClientM.MorleyClientM
instance GHC.Base.Applicative Morley.Client.TezosClient.Types.MorleyClientM.MorleyClientM
instance GHC.Base.Functor Morley.Client.TezosClient.Types.MorleyClientM.MorleyClientM
-- | Implementation of full-featured Morley client.
module Morley.Client.Full
-- | Runtime environment for morley client.
data MorleyClientEnv
MorleyClientEnv :: TezosClientEnv -> ClientLogAction MorleyClientM -> Maybe SecretKey -> ClientEnv -> MorleyClientEnv
-- | Environment for octez-client.
[mceTezosClient] :: MorleyClientEnv -> TezosClientEnv
-- | Action used to log messages.
[mceLogAction] :: MorleyClientEnv -> ClientLogAction MorleyClientM
-- | Pass if you want to sign operations manually or leave it to
-- octez-client.
[mceSecretKey] :: MorleyClientEnv -> Maybe SecretKey
-- | Environment necessary to make HTTP calls.
[mceClientEnv] :: MorleyClientEnv -> ClientEnv
-- | Data necessary for morley client initialization.
data MorleyClientConfig
MorleyClientConfig :: Maybe BaseUrl -> FilePath -> Maybe FilePath -> Word -> Maybe SecretKey -> MorleyClientConfig
-- | URL of tezos endpoint on which operations are performed
[mccEndpointUrl] :: MorleyClientConfig -> Maybe BaseUrl
-- | Path to octez-client binary through which operations are
-- performed
[mccTezosClientPath] :: MorleyClientConfig -> FilePath
-- | Path to octez-client data directory.
[mccMbTezosClientDataDir] :: MorleyClientConfig -> Maybe FilePath
-- | Verbosity level. 0 means that only important messages will be
-- printed. The greater this value is, the more messages will be printed
-- during execution. After some small unspecified limit increasing this
-- value does not change anything.
[mccVerbosity] :: MorleyClientConfig -> Word
-- | Custom secret key to use for signing.
[mccSecretKey] :: MorleyClientConfig -> Maybe SecretKey
data MorleyClientM a
-- | Run MorleyClientM action within given MorleyClientEnv.
-- Retry action in case of invalid counter error.
runMorleyClientM :: MorleyClientEnv -> MorleyClientM a -> IO a
-- | Construct MorleyClientEnv.
--
--
-- - octez-client path is taken from
-- MorleyClientConfig, but can be overridden using
-- MORLEY_TEZOS_CLIENT environment variable.
-- - Node data is taken from octez-client config and can be
-- overridden by MorleyClientConfig.
-- - The rest is taken from MorleyClientConfig as is.
--
mkMorleyClientEnv :: MorleyClientConfig -> IO MorleyClientEnv
-- | Make appropriate ClientLogAction based on verbosity specified
-- by the user.
mkLogAction :: MonadIO m => Word -> ClientLogAction m
mceTezosClientL :: Lens' MorleyClientEnv TezosClientEnv
mceLogActionL :: Lens' MorleyClientEnv (ClientLogAction MorleyClientM)
mceSecretKeyL :: Lens' MorleyClientEnv (Maybe SecretKey)
mceClientEnvL :: Lens' MorleyClientEnv ClientEnv
mccEndpointUrlL :: Lens' MorleyClientConfig (Maybe BaseUrl)
mccTezosClientPathL :: Lens' MorleyClientConfig FilePath
mccMbTezosClientDataDirL :: Lens' MorleyClientConfig (Maybe FilePath)
mccVerbosityL :: Lens' MorleyClientConfig Word
mccSecretKeyL :: Lens' MorleyClientConfig (Maybe SecretKey)
-- | Utilities for resolving addresses and aliases.
module Morley.Client.TezosClient.Resolve
data ResolveError
[REAliasNotFound] :: Text -> ResolveError
[REWrongKind] :: Alias expectedKind -> Address -> ResolveError
[REAddressNotFound] :: KindedAddress kind -> ResolveError
class Resolve addressOrAlias where {
type family ResolvedAddress addressOrAlias :: Type;
type family ResolvedAlias addressOrAlias :: Type;
type family ResolvedAddressAndAlias addressOrAlias :: Type;
}
-- | Looks up the address associated with the given
-- addressOrAlias.
--
-- When the alias is associated with both an implicit and a
-- contract address:
--
--
resolveAddressEither :: forall m env. (Resolve addressOrAlias, HasTezosClient m, MonadThrow m, WithClientLog env m) => addressOrAlias -> m (Either ResolveError (ResolvedAddress addressOrAlias))
-- | Looks up the alias associated with the given addressOrAlias.
--
-- When the alias is associated with both an implicit and a
-- contract address:
--
--
-- - The SomeAddressOrAlias instance will throw a
-- TezosClientError, unless the alias is prefixed with
-- implicit: or contract: to disambiguate.
-- - The AddressOrAlias instance will return the alias of the
-- address with the requested kind.
--
--
-- The primary (and probably only) reason this function exists is that
-- octez-client sign command only works with aliases. It was
-- reported upstream: https://gitlab.com/tezos/tezos/-/issues/836.
getAliasEither :: forall m env. (Resolve addressOrAlias, HasTezosClient m, MonadThrow m, WithClientLog env m) => addressOrAlias -> m (Either ResolveError (ResolvedAlias addressOrAlias))
-- | Resolve both address and alias at the same time
resolveAddressWithAliasEither :: forall m env. (Resolve addressOrAlias, HasTezosClient m, MonadThrow m, WithClientLog env m) => addressOrAlias -> m (Either ResolveError (ResolvedAddressAndAlias addressOrAlias))
-- | Looks up the address associated with the given
-- addressOrAlias.
--
-- Will throw a TezosClientError if addressOrAlias is an
-- alias and:
--
--
-- - the alias does not exist.
-- - the alias exists but its address is of the wrong kind.
--
--
-- When the alias is associated with both an implicit and a
-- contract address:
--
--
resolveAddress :: forall addressOrAlias m env. (HasTezosClient m, MonadThrow m, WithClientLog env m, Resolve addressOrAlias) => addressOrAlias -> m (ResolvedAddress addressOrAlias)
-- | Looks up the address associated with the given
-- addressOrAlias.
--
-- Will return Nothing if addressOrAlias is an alias and:
--
--
-- - the alias does not exist.
-- - the alias exists but its address is of the wrong kind.
--
--
-- When the alias is associated with both an implicit and a
-- contract address:
--
--
resolveAddressMaybe :: forall addressOrAlias m env. (HasTezosClient m, MonadThrow m, WithClientLog env m, Resolve addressOrAlias) => addressOrAlias -> m (Maybe (ResolvedAddress addressOrAlias))
-- | Looks up the alias associated with the given addressOrAlias.
--
-- Will throw a TezosClientError if addressOrAlias:
--
--
-- - is an address that is not associated with any alias.
-- - is an alias that does not exist.
-- - is an alias that exists but its address is of the wrong kind.
--
--
-- When the alias is associated with both an implicit and a
-- contract address:
--
--
getAlias :: forall addressOrAlias m env. (HasTezosClient m, WithClientLog env m, MonadThrow m, Resolve addressOrAlias) => addressOrAlias -> m (ResolvedAlias addressOrAlias)
-- | Looks up the alias associated with the given addressOrAlias.
--
-- Will return Nothing if addressOrAlias:
--
--
-- - is an address that is not associated with any alias.
-- - is an alias that does not exist.
-- - is an alias that exists but its address is of the wrong kind.
--
--
-- When the alias is associated with both an implicit and a
-- contract address:
--
--
getAliasMaybe :: forall addressOrAlias m env. (HasTezosClient m, WithClientLog env m, MonadThrow m, Resolve addressOrAlias) => addressOrAlias -> m (Maybe (ResolvedAlias addressOrAlias))
-- | Read octez-client configuration.
getTezosClientConfig :: FilePath -> Maybe FilePath -> IO TezosClientConfig
-- | Looks up the address and alias with the given addressOrAlias.
resolveAddressWithAlias :: forall addressOrAlias m env. (HasTezosClient m, MonadThrow m, WithClientLog env m, Resolve addressOrAlias) => addressOrAlias -> m (ResolvedAddressAndAlias addressOrAlias)
-- | Looks up the address and alias with the given addressOrAlias.
resolveAddressWithAliasMaybe :: forall addressOrAlias m env. (HasTezosClient m, MonadThrow m, WithClientLog env m, Resolve addressOrAlias) => addressOrAlias -> m (Maybe (ResolvedAddressAndAlias addressOrAlias))
instance Morley.Client.TezosClient.Resolve.Resolve (Morley.Tezos.Address.Alias.AddressOrAlias kind)
instance Morley.Client.TezosClient.Resolve.Resolve Morley.Tezos.Address.Alias.SomeAddressOrAlias
-- | Interface to the octez-client executable expressed in Haskell
-- types.
module Morley.Client.TezosClient.Impl
-- | A data type for all predicatable errors that can happen during
-- octez-client usage.
data TezosClientError
-- | octez-client call unexpectedly failed (returned non-zero exit
-- code). The error contains the error code, stdout and stderr contents.
UnexpectedClientFailure :: Int -> Text -> Text -> TezosClientError
-- | Public key of the given address is already revealed.
AlreadyRevealed :: ImplicitAlias -> TezosClientError
-- | Can't wait for inclusion of operation with given hash because the hash
-- is invalid.
InvalidOperationHash :: OperationHash -> TezosClientError
-- | Error that indicates when given counter is already used for given
-- contract.
CounterIsAlreadyUsed :: Text -> Text -> TezosClientError
-- | Network error with which octez-client fails from time to
-- time.
EConnreset :: TezosClientError
-- | A parse error occurred during config parsing.
ConfigParseError :: String -> TezosClientError
-- | octez-client produced a cryptographic primitive that we can't
-- parse.
TezosClientCryptoParseError :: Text -> CryptoParseError -> TezosClientError
-- | octez-client produced an address that we can't parse.
TezosClientParseAddressError :: Text -> ParseAddressError -> TezosClientError
-- | octez-client produced invalid output for parsing baker fee
TezosClientParseFeeError :: Text -> Text -> TezosClientError
-- | octez-client printed a string that doesn't match the format
-- we expect.
TezosClientUnexpectedOutputFormat :: Text -> TezosClientError
-- | Given alias is a contract and cannot be revealed.
CantRevealContract :: ImplicitAlias -> TezosClientError
-- | Given contract is a source of a transfer or origination operation.
ContractSender :: ContractAddress -> Text -> TezosClientError
-- | Given alias is an empty implicit contract.
EmptyImplicitContract :: ImplicitAlias -> TezosClientError
-- | octez-client sign bytes produced unexpected output format
TezosClientUnexpectedSignatureOutput :: Text -> TezosClientError
-- | octez-client produced invalid output for parsing secret key
-- encryption type.
TezosClientParseEncryptionTypeError :: Text -> Text -> TezosClientError
-- | Tried to save alias, but such alias already exists.
DuplicateAlias :: Text -> TezosClientError
-- | Expected an alias to be associated with either an implicit address or
-- a contract address, but it was associated with both.
AmbiguousAlias :: Text -> ContractAddress -> ImplicitAddress -> TezosClientError
ResolveError :: ResolveError -> TezosClientError
-- | Sign an arbtrary bytestring using octez-client. Secret key of
-- the address corresponding to give AddressOrAlias must be known.
signBytes :: ImplicitAlias -> Maybe ScrubbedBytes -> ByteString -> MorleyClientM Signature
-- | Save a contract with given address and alias. If
-- replaceExisting is False and a contract with given
-- alias already exists, this function does nothing.
rememberContract :: AliasBehavior -> ContractAddress -> ContractAlias -> MorleyClientM ()
importKey :: Bool -> ImplicitAlias -> SecretKey -> MorleyClientM ImplicitAddressWithAlias
-- | Generate a new secret key and save it with given alias. If an address
-- with given alias already exists, it will be returned and no state will
-- be changed.
genKey :: ImplicitAlias -> MorleyClientM ImplicitAddress
-- | Generate a new secret key and save it with given alias. If an address
-- with given alias already exists, it will be removed and replaced with
-- a fresh one.
genFreshKey :: ImplicitAlias -> MorleyClientM ImplicitAddress
-- | Reveal public key corresponding to the given alias. Fails if it's
-- already revealed.
revealKey :: ImplicitAlias -> Maybe ScrubbedBytes -> MorleyClientM ()
-- | Reveal key for implicit address if necessary.
revealKeyUnlessRevealed :: ImplicitAddressWithAlias -> Maybe ScrubbedBytes -> MorleyClientM ()
data ResolveError
[REAliasNotFound] :: Text -> ResolveError
[REWrongKind] :: Alias expectedKind -> Address -> ResolveError
[REAddressNotFound] :: KindedAddress kind -> ResolveError
class Resolve addressOrAlias where {
type family ResolvedAddress addressOrAlias :: Type;
type family ResolvedAlias addressOrAlias :: Type;
type family ResolvedAddressAndAlias addressOrAlias :: Type;
}
-- | Looks up the address associated with the given
-- addressOrAlias.
--
-- When the alias is associated with both an implicit and a
-- contract address:
--
--
resolveAddressEither :: forall m env. (Resolve addressOrAlias, HasTezosClient m, MonadThrow m, WithClientLog env m) => addressOrAlias -> m (Either ResolveError (ResolvedAddress addressOrAlias))
-- | Looks up the alias associated with the given addressOrAlias.
--
-- When the alias is associated with both an implicit and a
-- contract address:
--
--
-- - The SomeAddressOrAlias instance will throw a
-- TezosClientError, unless the alias is prefixed with
-- implicit: or contract: to disambiguate.
-- - The AddressOrAlias instance will return the alias of the
-- address with the requested kind.
--
--
-- The primary (and probably only) reason this function exists is that
-- octez-client sign command only works with aliases. It was
-- reported upstream: https://gitlab.com/tezos/tezos/-/issues/836.
getAliasEither :: forall m env. (Resolve addressOrAlias, HasTezosClient m, MonadThrow m, WithClientLog env m) => addressOrAlias -> m (Either ResolveError (ResolvedAlias addressOrAlias))
-- | Resolve both address and alias at the same time
resolveAddressWithAliasEither :: forall m env. (Resolve addressOrAlias, HasTezosClient m, MonadThrow m, WithClientLog env m) => addressOrAlias -> m (Either ResolveError (ResolvedAddressAndAlias addressOrAlias))
-- | Looks up the address associated with the given
-- addressOrAlias.
--
-- Will throw a TezosClientError if addressOrAlias is an
-- alias and:
--
--
-- - the alias does not exist.
-- - the alias exists but its address is of the wrong kind.
--
--
-- When the alias is associated with both an implicit and a
-- contract address:
--
--
resolveAddress :: forall addressOrAlias m env. (HasTezosClient m, MonadThrow m, WithClientLog env m, Resolve addressOrAlias) => addressOrAlias -> m (ResolvedAddress addressOrAlias)
-- | Looks up the address associated with the given
-- addressOrAlias.
--
-- Will return Nothing if addressOrAlias is an alias and:
--
--
-- - the alias does not exist.
-- - the alias exists but its address is of the wrong kind.
--
--
-- When the alias is associated with both an implicit and a
-- contract address:
--
--
resolveAddressMaybe :: forall addressOrAlias m env. (HasTezosClient m, MonadThrow m, WithClientLog env m, Resolve addressOrAlias) => addressOrAlias -> m (Maybe (ResolvedAddress addressOrAlias))
-- | Looks up the alias associated with the given addressOrAlias.
--
-- Will throw a TezosClientError if addressOrAlias:
--
--
-- - is an address that is not associated with any alias.
-- - is an alias that does not exist.
-- - is an alias that exists but its address is of the wrong kind.
--
--
-- When the alias is associated with both an implicit and a
-- contract address:
--
--
getAlias :: forall addressOrAlias m env. (HasTezosClient m, WithClientLog env m, MonadThrow m, Resolve addressOrAlias) => addressOrAlias -> m (ResolvedAlias addressOrAlias)
-- | Looks up the alias associated with the given addressOrAlias.
--
-- Will return Nothing if addressOrAlias:
--
--
-- - is an address that is not associated with any alias.
-- - is an alias that does not exist.
-- - is an alias that exists but its address is of the wrong kind.
--
--
-- When the alias is associated with both an implicit and a
-- contract address:
--
--
getAliasMaybe :: forall addressOrAlias m env. (HasTezosClient m, WithClientLog env m, MonadThrow m, Resolve addressOrAlias) => addressOrAlias -> m (Maybe (ResolvedAlias addressOrAlias))
-- | Return PublicKey corresponding to given AddressOrAlias.
getPublicKey :: ImplicitAlias -> MorleyClientM PublicKey
-- | Return SecretKey corresponding to given AddressOrAlias.
getSecretKey :: ImplicitAlias -> MorleyClientM SecretKey
-- | Read octez-client configuration.
getTezosClientConfig :: FilePath -> Maybe FilePath -> IO TezosClientConfig
-- | Calc baker fee for transfer using octez-client.
calcTransferFee :: AddressOrAlias kind -> Maybe ScrubbedBytes -> TezosInt64 -> [CalcTransferFeeData] -> MorleyClientM [TezosMutez]
-- | Calc baker fee for origination using octez-client.
calcOriginationFee :: UntypedValScope st => CalcOriginationFeeData cp st -> MorleyClientM TezosMutez
-- | Calc baker fee for revealing using octez-client.
--
-- Note that octez-client does not support passing an address
-- here, at least at the moment of writing.
calcRevealFee :: ImplicitAlias -> Maybe ScrubbedBytes -> TezosInt64 -> MorleyClientM TezosMutez
-- | Get password for secret key associated with given address in case this
-- key is password-protected
getKeyPassword :: ImplicitAlias -> MorleyClientM (Maybe ScrubbedBytes)
-- | Register alias as delegate
registerDelegate :: ImplicitAlias -> Maybe ScrubbedBytes -> MorleyClientM ()
-- | Calls octez-client list known contracts and returns a list of
-- (alias, address) pairs.
--
-- Note that an alias can be ambiguous: it can refer to both a
-- contract and an implicit account. When an alias "abc" is ambiguous,
-- the list will contain two entries:
--
--
-- ("abc", "KT1...")
-- ("key:abc", "tz1...")
--
getAliasesAndAddresses :: MorleyClientM AliasesAndAddresses
-- | Looks up the address and alias with the given addressOrAlias.
resolveAddressWithAlias :: forall addressOrAlias m env. (HasTezosClient m, MonadThrow m, WithClientLog env m, Resolve addressOrAlias) => addressOrAlias -> m (ResolvedAddressAndAlias addressOrAlias)
-- | Looks up the address and alias with the given addressOrAlias.
resolveAddressWithAliasMaybe :: forall addressOrAlias m env. (HasTezosClient m, MonadThrow m, WithClientLog env m, Resolve addressOrAlias) => addressOrAlias -> m (Maybe (ResolvedAddressAndAlias addressOrAlias))
lookupAliasCache :: Alias kind -> MorleyClientM (Maybe (KindedAddress kind))
instance Morley.Client.TezosClient.Class.HasTezosClient Morley.Client.TezosClient.Types.MorleyClientM.MorleyClientM
-- | Interface to octez-client (and its implementation).
module Morley.Client.TezosClient
-- | A data type for all predicatable errors that can happen during
-- octez-client usage.
data TezosClientError
-- | octez-client call unexpectedly failed (returned non-zero exit
-- code). The error contains the error code, stdout and stderr contents.
UnexpectedClientFailure :: Int -> Text -> Text -> TezosClientError
-- | Public key of the given address is already revealed.
AlreadyRevealed :: ImplicitAlias -> TezosClientError
-- | Can't wait for inclusion of operation with given hash because the hash
-- is invalid.
InvalidOperationHash :: OperationHash -> TezosClientError
-- | Error that indicates when given counter is already used for given
-- contract.
CounterIsAlreadyUsed :: Text -> Text -> TezosClientError
-- | Network error with which octez-client fails from time to
-- time.
EConnreset :: TezosClientError
-- | A parse error occurred during config parsing.
ConfigParseError :: String -> TezosClientError
-- | octez-client produced a cryptographic primitive that we can't
-- parse.
TezosClientCryptoParseError :: Text -> CryptoParseError -> TezosClientError
-- | octez-client produced an address that we can't parse.
TezosClientParseAddressError :: Text -> ParseAddressError -> TezosClientError
-- | octez-client produced invalid output for parsing baker fee
TezosClientParseFeeError :: Text -> Text -> TezosClientError
-- | octez-client printed a string that doesn't match the format
-- we expect.
TezosClientUnexpectedOutputFormat :: Text -> TezosClientError
-- | Given alias is a contract and cannot be revealed.
CantRevealContract :: ImplicitAlias -> TezosClientError
-- | Given contract is a source of a transfer or origination operation.
ContractSender :: ContractAddress -> Text -> TezosClientError
-- | Given alias is an empty implicit contract.
EmptyImplicitContract :: ImplicitAlias -> TezosClientError
-- | octez-client sign bytes produced unexpected output format
TezosClientUnexpectedSignatureOutput :: Text -> TezosClientError
-- | octez-client produced invalid output for parsing secret key
-- encryption type.
TezosClientParseEncryptionTypeError :: Text -> Text -> TezosClientError
-- | Tried to save alias, but such alias already exists.
DuplicateAlias :: Text -> TezosClientError
-- | Expected an alias to be associated with either an implicit address or
-- a contract address, but it was associated with both.
AmbiguousAlias :: Text -> ContractAddress -> ImplicitAddress -> TezosClientError
ResolveError :: ResolveError -> TezosClientError
-- | How to save the originated contract address.
data AliasBehavior
-- | Don't save the newly originated contract address.
DontSaveAlias :: AliasBehavior
-- | If an alias already exists, keep it, don't save the newly originated
-- contract address.
KeepDuplicateAlias :: AliasBehavior
-- | If an alias already exists, replace it with the address of the newly
-- originated contract.
OverwriteDuplicateAlias :: AliasBehavior
-- | If an alias already exists, throw an exception without doing the
-- origination
ForbidDuplicateAlias :: AliasBehavior
class Resolve addressOrAlias where {
type family ResolvedAddress addressOrAlias :: Type;
type family ResolvedAlias addressOrAlias :: Type;
}
data ResolveError
[REAliasNotFound] :: Text -> ResolveError
[REWrongKind] :: Alias expectedKind -> Address -> ResolveError
[REAddressNotFound] :: KindedAddress kind -> ResolveError
-- | Looks up the address associated with the given
-- addressOrAlias.
--
-- Will throw a TezosClientError if addressOrAlias is an
-- alias and:
--
--
-- - the alias does not exist.
-- - the alias exists but its address is of the wrong kind.
--
--
-- When the alias is associated with both an implicit and a
-- contract address:
--
--
resolveAddress :: forall addressOrAlias m env. (HasTezosClient m, MonadThrow m, WithClientLog env m, Resolve addressOrAlias) => addressOrAlias -> m (ResolvedAddress addressOrAlias)
-- | Looks up the address associated with the given
-- addressOrAlias.
--
-- Will return Nothing if addressOrAlias is an alias and:
--
--
-- - the alias does not exist.
-- - the alias exists but its address is of the wrong kind.
--
--
-- When the alias is associated with both an implicit and a
-- contract address:
--
--
resolveAddressMaybe :: forall addressOrAlias m env. (HasTezosClient m, MonadThrow m, WithClientLog env m, Resolve addressOrAlias) => addressOrAlias -> m (Maybe (ResolvedAddress addressOrAlias))
-- | Looks up the address and alias with the given addressOrAlias.
resolveAddressWithAlias :: forall addressOrAlias m env. (HasTezosClient m, MonadThrow m, WithClientLog env m, Resolve addressOrAlias) => addressOrAlias -> m (ResolvedAddressAndAlias addressOrAlias)
-- | Looks up the address and alias with the given addressOrAlias.
resolveAddressWithAliasMaybe :: forall addressOrAlias m env. (HasTezosClient m, MonadThrow m, WithClientLog env m, Resolve addressOrAlias) => addressOrAlias -> m (Maybe (ResolvedAddressAndAlias addressOrAlias))
-- | Looks up the alias associated with the given addressOrAlias.
--
-- Will throw a TezosClientError if addressOrAlias:
--
--
-- - is an address that is not associated with any alias.
-- - is an alias that does not exist.
-- - is an alias that exists but its address is of the wrong kind.
--
--
-- When the alias is associated with both an implicit and a
-- contract address:
--
--
getAlias :: forall addressOrAlias m env. (HasTezosClient m, WithClientLog env m, MonadThrow m, Resolve addressOrAlias) => addressOrAlias -> m (ResolvedAlias addressOrAlias)
-- | Looks up the alias associated with the given addressOrAlias.
--
-- Will return Nothing if addressOrAlias:
--
--
-- - is an address that is not associated with any alias.
-- - is an alias that does not exist.
-- - is an alias that exists but its address is of the wrong kind.
--
--
-- When the alias is associated with both an implicit and a
-- contract address:
--
--
getAliasMaybe :: forall addressOrAlias m env. (HasTezosClient m, WithClientLog env m, MonadThrow m, Resolve addressOrAlias) => addressOrAlias -> m (Maybe (ResolvedAlias addressOrAlias))
-- | Module with functions that used in both transaction sending and
-- contract origination.
module Morley.Client.Action.Common
-- | Datatype that contains various values required for chain operations.
data OperationConstants
OperationConstants :: BlockHash -> BlockConstants -> FeeConstants -> TezosInt64 -> OperationConstants
-- | Block in which operations is going to be injected
[ocLastBlockHash] :: OperationConstants -> BlockHash
-- | Information about block: chain_id and protocol
[ocBlockConstants] :: OperationConstants -> BlockConstants
-- | Information about fees
[ocFeeConstants] :: OperationConstants -> FeeConstants
-- | Sender counter
[ocCounter] :: OperationConstants -> TezosInt64
-- | Helper for TransactionData and LTransactionData.
data TD (t :: Type)
TD :: L1Address -> Mutez -> EpName -> t -> Maybe Mutez -> TD (t :: Type)
[tdReceiver] :: TD (t :: Type) -> L1Address
[tdAmount] :: TD (t :: Type) -> Mutez
[tdEpName] :: TD (t :: Type) -> EpName
[tdParam] :: TD (t :: Type) -> t
[tdMbFee] :: TD (t :: Type) -> Maybe Mutez
-- | Data for a single transaction in a batch.
data TransactionData
[TransactionData] :: forall (t :: T). ParameterScope t => TD (Value t) -> TransactionData
-- | Data for a single origination in a batch
data OriginationData
OriginationData :: AliasBehavior -> ContractAlias -> Mutez -> Contract cp st -> Value st -> Maybe KeyHash -> Maybe Mutez -> OriginationData
[odAliasBehavior] :: OriginationData -> AliasBehavior
[odName] :: OriginationData -> ContractAlias
[odBalance] :: OriginationData -> Mutez
[odContract] :: OriginationData -> Contract cp st
[odStorage] :: OriginationData -> Value st
[odDelegate] :: OriginationData -> Maybe KeyHash
[odMbFee] :: OriginationData -> Maybe Mutez
data TransferTicketData
TransferTicketData :: Value t -> Address -> Natural -> Address -> EpName -> Maybe Mutez -> TransferTicketData
[ttdTicketContents] :: TransferTicketData -> Value t
[ttdTicketTicketer] :: TransferTicketData -> Address
[ttdTicketAmount] :: TransferTicketData -> Natural
[ttdDestination] :: TransferTicketData -> Address
[ttdEntrypoint] :: TransferTicketData -> EpName
[ttdMbFee] :: TransferTicketData -> Maybe Mutez
data RevealData
RevealData :: PublicKey -> Maybe Mutez -> RevealData
[rdPublicKey] :: RevealData -> PublicKey
[rdMbFee] :: RevealData -> Maybe Mutez
data DelegationData
DelegationData :: Maybe KeyHash -> Maybe Mutez -> DelegationData
[ddDelegate] :: DelegationData -> Maybe KeyHash
[ddMbFee] :: DelegationData -> Maybe Mutez
-- | Standard operation input in morley-client interface.
data ClientInput
addOperationPrefix :: ByteString -> ByteString
-- | Builds TransactionData with additional info about receiver's
-- alias, if present.
buildTxDataWithAlias :: Maybe SomeAlias -> TransactionData -> Doc
-- | Builds TransactionData with additional info about receiver's
-- alias, if present.
buildTxTicketDataWithAlias :: Maybe SomeAlias -> TransferTicketData -> Doc
-- | Perform runOperation or preApplyOperations and combine the results.
--
-- If an error occurs, this function tries to turn errors returned by RPC
-- into ClientRpcError. If it can't do the conversion,
-- UnexpectedErrors will be thrown.
getAppliedResults :: HasTezosRpc m => Either RunOperation PreApplyOperation -> m (NonEmpty AppliedResult, [OperationResp WithSource])
-- | Compute fee for operation.
computeFee :: FeeConstants -> Int -> TezosInt64 -> Mutez
-- | Compute storage limit based on the results of the operations
-- application and given ProtocolParameters.
computeStorageLimit :: [AppliedResult] -> ProtocolParameters -> TezosInt64
-- | convergingFee mkOperation countFee tries to find the most
-- minimal fee F and the respective operation Op so
-- that mkOperation F = Op and countFee Op <= F.
convergingFee :: forall op extra m. Monad m => (Mutez -> m op) -> (op -> m (Mutez, extra)) -> m (Mutez, op, extra)
-- | Preprocess chain operation in order to get required constants.
preProcessOperation :: HasTezosRpc m => ImplicitAddress -> m OperationConstants
stubSignature :: Signature
prepareOpForInjection :: ByteString -> Signature -> ByteString
-- | Update common operation data based on preliminary run which estimates
-- storage and gas limits and fee.
--
-- Reference implementation adds 100 gas and 20 bytes to the limits for
-- safety.
updateCommonData :: TezosInt64 -> TezosInt64 -> TezosMutez -> CommonOperationData -> CommonOperationData
toParametersInternals :: ParameterScope t => EpName -> Value t -> ParametersInternal
mkOriginationScript :: Contract cp st -> Value st -> OriginationScript
-- | Handle a result of an operation: throw errors if there was an error,
-- return a nonempty list of applied results if there weren't.
handleOperationResult :: MonadThrow m => RunOperationResult -> Int -> m (NonEmpty AppliedResult, [OperationResp WithSource])
-- | When an error happens, we will get a list of RunError in
-- response. This list often contains more than one item. We tested which
-- errors are returned in certain scenarios and added handling of such
-- scenarios here. We don't rely on any specific order of errors and on
-- the number of errors. For example, in case of bad parameter this
-- number can be different.
runErrorsToClientError :: [RunError] -> Maybe ClientRpcError
instance Morley.Client.Types.OperationInfoDescriptor Morley.Client.Action.Common.ClientInput
instance Fmt.Buildable.Buildable Morley.Client.Action.Common.TransactionData
-- | Functions to originate large smart contracts via octez-client
-- and node RPC.
--
-- This is based on a workaround leveraging the lack of gas cost limits
-- on internal transactions produced by CREATE_CONTRACT.
--
-- So, in brief, we cannot directly originate a contract that's too
-- large, but we can originate a small "originator" contract,
-- progressively load a packed lambda into it in chunks and finally
-- unpack and execute it, which will run the actual large contract
-- origination.
module Morley.Client.Action.Origination.Large
-- | Just a utility type to hold SomeLargeContractOriginator and its
-- large contract OriginationData.
data LargeOriginationData
LargeOriginationData :: SomeLargeContractOriginator -> OriginationData -> LargeOriginationData
[largeOriginator] :: LargeOriginationData -> SomeLargeContractOriginator
[largeContractData] :: LargeOriginationData -> OriginationData
-- | Contains the 'Value heavy' with all the large contract
-- big_maps and tickets, the
-- largeContractOriginator for it as well as the lambda to use
-- there.
data SomeLargeContractOriginator
[SomeLargeContractOriginator] :: forall heavy. StorageScope heavy => Value heavy -> Contract LargeOriginatorParam (LargeOriginatorStore heavy) -> Value (ToT (Lambda (Value heavy) (Address, [Operation]))) -> SomeLargeContractOriginator
mkLargeOriginationData :: OriginationData -> LargeOriginationData
mkSomeLargeContractOriginator :: (ParameterScope param, StorageScope store) => Value store -> Contract param store -> Mutez -> SomeLargeContractOriginator
-- | Parameter of the originator contract.
type LargeOriginatorParam = 'TOr 'TBytes 'TUnit
-- | Storage of the originator contract.
type LargeOriginatorStore heavy = 'TPair 'TAddress ('TOr 'TAddress ('TPair 'TBytes heavy))
-- | Large Originator contract.
--
-- Only keeps track of the "owner" address and either - the heavy entries
-- and packed lambda to do the generation (if still loading), or - the
-- resulting address of the originated large contract.
--
-- If the large contract was originated any call will result in a failure
-- containing its address. Any call from an address that's not the
-- "owner" will result in a failure.
largeContractOriginator :: StorageScope heavy => Contract LargeOriginatorParam (LargeOriginatorStore heavy)
-- | Returns bytes that fit into transaction limits from
-- mkOriginationLambda.
--
-- Note: these have the original order, meaning they should be given to
-- the originator contract from last to first.
divideValueInChunks :: ConstantScope val => Value val -> [ByteString]
-- | Generates the lambda to originate a large contract.
mkOriginationLambda :: (ParameterScope param, StorageScope store, StorageScope heavy) => Instr '[heavy] '[store] -> Contract param store -> Mutez -> Value (ToT (Lambda (Value heavy) (Address, [Operation])))
-- | Helper to create a LargeOriginatorStore Value.
mkLargeOriginatorStore :: StorageScope heavy => Value heavy -> ImplicitAddress -> Value (LargeOriginatorStore heavy)
-- | Makes OriginationData of the largeContractOriginator
-- that will generate the large contract of the given
-- OriginationData for the sender ImplicitAddress.
mkLargeOriginatorData :: ImplicitAddress -> LargeOriginationData -> OriginationData
-- | Makes all the TransactionData to feed the origination lambda
-- into a largeContractOriginator from the ContractAddress
-- of the latter.
mkLargeOriginatorTransactions :: ContractAddress -> LargeOriginationData -> [TransactionData]
-- | Fetches back the ContractAddress of the large contract
-- generated by a completed largeContractOriginator process.
--
-- It also uses the large contract OriginationData to associate it
-- to the expected alias.
retrieveLargeContracts :: (HasTezosRpc m, HasTezosClient m) => ContractAddress -> OriginationData -> m ContractAddress
-- | Implementation of generic operations submission.
module Morley.Client.Action.Operation
-- | Designates output of an operation.
data Result
-- | Perform sequence of operations.
--
-- Returns operation hash (or Nothing in case empty list was
-- provided) and result of each operation (nothing for transactions and
-- an address for originated contracts
runOperations :: forall m env. (HasTezosRpc m, HasTezosClient m, WithClientLog env m) => ImplicitAddressWithAlias -> [OperationInfo ClientInput] -> m (Maybe OperationHash, [OperationInfo Result])
-- | Perform non-empty sequence of operations.
--
-- Returns operation hash and result of each operation (nothing for
-- transactions and an address for originated contracts).
runOperationsNonEmpty :: forall m env. (HasTezosRpc m, HasTezosClient m, WithClientLog env m) => ImplicitAddressWithAlias -> NonEmpty (OperationInfo ClientInput) -> m (OperationHash, NonEmpty (OperationInfo Result))
-- | Perform dry-run for sequence of operations.
--
-- Returned AppliedResult contains information about estimated
-- limits, storage changes, etc. Additionally, estimated fees are
-- returned.
dryRunOperationsNonEmpty :: forall m env. (HasTezosRpc m, HasTezosClient m, WithClientLog env m) => ImplicitAddressWithAlias -> NonEmpty (OperationInfo ClientInput) -> m (NonEmpty (AppliedResult, TezosMutez))
instance Data.Singletons.SingI 'Morley.Client.Action.Operation.DryRun
instance Data.Singletons.SingI 'Morley.Client.Action.Operation.RealRun
instance Morley.Client.Types.OperationInfoDescriptor Morley.Client.Action.Operation.Result
-- | Functions to submit transactions via octez-client and node
-- RPC.
module Morley.Client.Action.Transaction
-- | Perform sequence of transactions to the contract. Returns operation
-- hash and a list of RPC responses, or Nothing in case an empty
-- list was provided.
runTransactions :: forall m env. (HasTezosRpc m, HasTezosClient m, WithClientLog env m) => ImplicitAddressWithAlias -> [TransactionData] -> m (Maybe (OperationHash, [OperationInfo Result]))
-- | Lorentz version of runTransactions
lRunTransactions :: forall m env. (HasTezosRpc m, HasTezosClient m, WithClientLog env m) => ImplicitAddressWithAlias -> [LTransactionData] -> m (Maybe (OperationHash, [OperationInfo Result]))
transfer :: forall m t env kind. (HasTezosRpc m, HasTezosClient m, WithClientLog env m, ParameterScope t, L1AddressKind kind) => ImplicitAddressWithAlias -> KindedAddress kind -> Mutez -> EpName -> Value t -> Maybe Mutez -> m (OperationHash, [WithSource EventOperation])
lTransfer :: forall m t env kind. (HasTezosRpc m, HasTezosClient m, WithClientLog env m, NiceParameter t, L1AddressKind kind) => ImplicitAddressWithAlias -> KindedAddress kind -> Mutez -> EpName -> t -> Maybe Mutez -> m (OperationHash, [WithSource EventOperation])
transferTicket :: forall m t env kind. (HasTezosRpc m, HasTezosClient m, WithClientLog env m, ParameterScope t, Comparable t) => ImplicitAddressWithAlias -> KindedAddress kind -> ContractAddress -> Value t -> Natural -> EpName -> Maybe Mutez -> m (OperationHash, [WithSource EventOperation])
-- | Helper for TransactionData and LTransactionData.
data TD (t :: Type)
TD :: L1Address -> Mutez -> EpName -> t -> Maybe Mutez -> TD (t :: Type)
[tdReceiver] :: TD (t :: Type) -> L1Address
[tdAmount] :: TD (t :: Type) -> Mutez
[tdEpName] :: TD (t :: Type) -> EpName
[tdParam] :: TD (t :: Type) -> t
[tdMbFee] :: TD (t :: Type) -> Maybe Mutez
-- | Lorentz version of TransactionData.
data LTransactionData
[LTransactionData] :: forall (t :: Type). NiceParameter t => TD t -> LTransactionData
-- | Data for a single transaction in a batch.
data TransactionData
[TransactionData] :: forall (t :: T). ParameterScope t => TD (Value t) -> TransactionData
data TransferTicketData
TransferTicketData :: Value t -> Address -> Natural -> Address -> EpName -> Maybe Mutez -> TransferTicketData
[ttdTicketContents] :: TransferTicketData -> Value t
[ttdTicketTicketer] :: TransferTicketData -> Address
[ttdTicketAmount] :: TransferTicketData -> Natural
[ttdDestination] :: TransferTicketData -> Address
[ttdEntrypoint] :: TransferTicketData -> EpName
[ttdMbFee] :: TransferTicketData -> Maybe Mutez
-- | Functions to reveal keys via node RPC.
module Morley.Client.Action.Reveal
data RevealData
RevealData :: PublicKey -> Maybe Mutez -> RevealData
[rdPublicKey] :: RevealData -> PublicKey
[rdMbFee] :: RevealData -> Maybe Mutez
-- | Resolve the public key of an implicit address and reveal it.
revealKey :: (HasTezosRpc m, HasTezosClient m, WithClientLog env m) => ImplicitAddressWithAlias -> m OperationHash
-- | Version of revealKey with explicit fee.
revealKeyWithFee :: (HasTezosRpc m, HasTezosClient m, WithClientLog env m) => ImplicitAddressWithAlias -> Maybe Mutez -> m OperationHash
-- | Resolve the public key of an implicit address and reveal it, unless
-- already revealed.
revealKeyUnlessRevealed :: (HasTezosRpc m, HasTezosClient m, WithClientLog env m) => ImplicitAddressWithAlias -> m ()
-- | Version of revealKeyUnlessRevealed with explicit fee.
revealKeyUnlessRevealedWithFee :: (HasTezosRpc m, HasTezosClient m, WithClientLog env m) => ImplicitAddressWithAlias -> Maybe Mutez -> m ()
-- | Functions to originate smart contracts via octez-client and
-- node RPC.
module Morley.Client.Action.Origination
-- | Originate single contract
originateContract :: forall m cp st env. (HasTezosRpc m, HasTezosClient m, WithClientLog env m, StorageScope st, ParameterScope cp) => AliasBehavior -> ContractAlias -> ImplicitAddressWithAlias -> Mutez -> Contract cp st -> Value st -> Maybe Mutez -> Maybe KeyHash -> m (OperationHash, ContractAddress)
-- | Originate given contracts with given initial storages. Returns
-- operation hash (or Nothing in case empty list was provided)
-- and originated contracts' addresses.
originateContracts :: forall m env. (HasTezosRpc m, HasTezosClient m, WithClientLog env m) => ImplicitAddressWithAlias -> [OriginationData] -> m (Maybe OperationHash, [ContractAddress])
-- | Originate a single untyped contract
originateUntypedContract :: forall m env. (HasTezosRpc m, HasTezosClient m, WithClientLog env m) => AliasBehavior -> ContractAlias -> ImplicitAddressWithAlias -> Mutez -> Contract -> Value -> Maybe Mutez -> Maybe KeyHash -> m (OperationHash, ContractAddress)
-- | Originate single Lorentz contract
lOriginateContract :: forall m cp st vd env. (HasTezosRpc m, HasTezosClient m, WithClientLog env m, NiceStorage st, NiceParameterFull cp) => AliasBehavior -> ContractAlias -> ImplicitAddressWithAlias -> Mutez -> Contract cp st vd -> st -> Maybe Mutez -> Maybe KeyHash -> m (OperationHash, ContractAddress)
-- | Lorentz version of originateContracts
lOriginateContracts :: forall m env. (HasTezosRpc m, HasTezosClient m, WithClientLog env m) => ImplicitAddressWithAlias -> [LOriginationData] -> m (Maybe OperationHash, [ContractAddress])
-- | Automated multi-step origination process for contracts that don't fit
-- into the origination limit. See
-- Morley.Client.Action.Origination.Large.
originateLargeContracts :: forall m env. (HasTezosRpc m, HasTezosClient m, WithClientLog env m) => ImplicitAddressWithAlias -> [OriginationData] -> m (Maybe OperationHash, [ContractAddress])
-- | Originate a single large contract
originateLargeContract :: forall m cp st env. (HasTezosRpc m, HasTezosClient m, WithClientLog env m, StorageScope st, ParameterScope cp) => AliasBehavior -> ContractAlias -> ImplicitAddressWithAlias -> Mutez -> Contract cp st -> Value st -> Maybe Mutez -> Maybe KeyHash -> m (OperationHash, ContractAddress)
-- | Originate a single untyped large contract
originateLargeUntypedContract :: forall m env. (HasTezosRpc m, HasTezosClient m, WithClientLog env m) => AliasBehavior -> ContractAlias -> ImplicitAddressWithAlias -> Mutez -> Contract -> Value -> Maybe Mutez -> Maybe KeyHash -> m (OperationHash, ContractAddress)
-- | Lorentz version of originateLargeContracts
lOriginateLargeContracts :: forall m env. (HasTezosRpc m, HasTezosClient m, WithClientLog env m) => ImplicitAddressWithAlias -> [LOriginationData] -> m (Maybe OperationHash, [ContractAddress])
-- | Originate a single large Lorentz contract
lOriginateLargeContract :: forall m cp st vd env. (HasTezosRpc m, HasTezosClient m, WithClientLog env m, NiceStorage st, NiceParameter cp) => AliasBehavior -> ContractAlias -> ImplicitAddressWithAlias -> Mutez -> Contract cp st vd -> st -> Maybe Mutez -> Maybe KeyHash -> m (OperationHash, ContractAddress)
-- | Lorentz version of OriginationData
data LOriginationData
LOriginationData :: AliasBehavior -> ContractAlias -> Mutez -> Contract cp st vd -> st -> Maybe KeyHash -> Maybe Mutez -> LOriginationData
[lodAliasBehavior] :: LOriginationData -> AliasBehavior
[lodName] :: LOriginationData -> ContractAlias
[lodBalance] :: LOriginationData -> Mutez
[lodContract] :: LOriginationData -> Contract cp st vd
[lodStorage] :: LOriginationData -> st
[lodDelegate] :: LOriginationData -> Maybe KeyHash
[lodMbFee] :: LOriginationData -> Maybe Mutez
-- | Data for a single origination in a batch
data OriginationData
OriginationData :: AliasBehavior -> ContractAlias -> Mutez -> Contract cp st -> Value st -> Maybe KeyHash -> Maybe Mutez -> OriginationData
[odAliasBehavior] :: OriginationData -> AliasBehavior
[odName] :: OriginationData -> ContractAlias
[odBalance] :: OriginationData -> Mutez
[odContract] :: OriginationData -> Contract cp st
[odStorage] :: OriginationData -> Value st
[odDelegate] :: OriginationData -> Maybe KeyHash
[odMbFee] :: OriginationData -> Maybe Mutez
module Morley.Client.Action.Delegation
-- | Set or revoke a delegate for the sender. To set a supply Just
-- delegate as the second argument. To withdraw a delegate supply
-- Nothing as the second argument.
--
-- Some notes on delegations:
--
-- Implicit Accounts can either be registered delegates, have no
-- delegate, or have a delegate set without being registered
-- delegates themselves.
--
-- For example imagine two implicit addresses Alice and Bob: * Alice
-- registers as delegate using registerDelegateOp. This means that
-- Alice delegates to Alice. * Bob sets Alice as his delegate. This
-- delegates Bob's staking rights to Alice.
--
-- Now, Alice can't change their delegate, because that would revoke
-- Alice as delegate and make Bob's delegation void. So setDelegateOp
-- alice Nothing would throw a FailedUnDelegation alice
-- exception.
--
-- However, Bob, not beeing a registered delegate can: * Revoke
-- the delegation to alice setDelegateOp bob Nothing * Delegate
-- to another "registered delegate": registerDelegateOp charly
-- >> setDelegateOp bob charly * Become a registered delegate
-- himself: registerDelegateOp bob
--
-- Smart Contracts can also delegate to registered delegates, but
-- can't be registered delegates themselves.
setDelegateOp :: (HasTezosRpc m, HasTezosClient m, MonadReader env m, HasLog env Message m) => ImplicitAddressWithAlias -> Maybe KeyHash -> m OperationHash
-- | Register the sender as its delegate and become a "registered delegate"
-- Alias for setDelegateOp sender (Just sender)
registerDelegateOp :: (HasTezosRpc m, HasTezosClient m, MonadReader env m, HasLog env Message m) => ImplicitAddressWithAlias -> m OperationHash
-- | High-level actions implemented in abstract monads that require both
-- RPC and octez-client functionality.
module Morley.Client.Action
-- | Standard operation input in morley-client interface.
data ClientInput
module Morley.Client.Parser
-- | Parser for the morley-client executable.
clientParser :: Parser (IO ())
clientConfigParser :: Parser MorleyClientConfig
argsRawParser :: Parser (MorleyClientM ())
mbContractFileOption :: Parser (Maybe FilePath)
contractNameOption :: Parser ContractAlias
feeOption :: Parser (Maybe Mutez)
-- | Utility reader to use in parsing BaseUrl.
baseUrlReader :: ReadM BaseUrl
data OriginateArgs
OriginateArgs :: Maybe FilePath -> ContractAlias -> Mutez -> Value -> ImplicitAddressOrAlias -> Maybe Mutez -> Maybe KeyHash -> OriginateArgs
[oaMbContractFile] :: OriginateArgs -> Maybe FilePath
[oaContractName] :: OriginateArgs -> ContractAlias
[oaInitialBalance] :: OriginateArgs -> Mutez
[oaInitialStorage] :: OriginateArgs -> Value
[oaOriginateFrom] :: OriginateArgs -> ImplicitAddressOrAlias
[oaMbFee] :: OriginateArgs -> Maybe Mutez
[oaDelegate] :: OriginateArgs -> Maybe KeyHash
originateArgsOption :: Parser OriginateArgs
parserInfo :: ("usage" :! Doc) -> ("description" :! String) -> ("header" :! String) -> ("parser" :! Parser s) -> ParserInfo s
-- | Morley client that connects with real Tezos network through RPC and
-- the octez-client binary. For more information please refer to
-- README.
module Morley.Client
parserInfo :: ("usage" :! Doc) -> ("description" :! String) -> ("header" :! String) -> ("parser" :! Parser s) -> ParserInfo s
clientConfigParser :: Parser MorleyClientConfig
data MorleyClientM a
-- | Data necessary for morley client initialization.
data MorleyClientConfig
MorleyClientConfig :: Maybe BaseUrl -> FilePath -> Maybe FilePath -> Word -> Maybe SecretKey -> MorleyClientConfig
-- | URL of tezos endpoint on which operations are performed
[mccEndpointUrl] :: MorleyClientConfig -> Maybe BaseUrl
-- | Path to octez-client binary through which operations are
-- performed
[mccTezosClientPath] :: MorleyClientConfig -> FilePath
-- | Path to octez-client data directory.
[mccMbTezosClientDataDir] :: MorleyClientConfig -> Maybe FilePath
-- | Verbosity level. 0 means that only important messages will be
-- printed. The greater this value is, the more messages will be printed
-- during execution. After some small unspecified limit increasing this
-- value does not change anything.
[mccVerbosity] :: MorleyClientConfig -> Word
-- | Custom secret key to use for signing.
[mccSecretKey] :: MorleyClientConfig -> Maybe SecretKey
-- | Runtime environment for morley client.
data MorleyClientEnv
MorleyClientEnv :: TezosClientEnv -> ClientLogAction MorleyClientM -> Maybe SecretKey -> ClientEnv -> MorleyClientEnv
-- | Environment for octez-client.
[mceTezosClient] :: MorleyClientEnv -> TezosClientEnv
-- | Action used to log messages.
[mceLogAction] :: MorleyClientEnv -> ClientLogAction MorleyClientM
-- | Pass if you want to sign operations manually or leave it to
-- octez-client.
[mceSecretKey] :: MorleyClientEnv -> Maybe SecretKey
-- | Environment necessary to make HTTP calls.
[mceClientEnv] :: MorleyClientEnv -> ClientEnv
-- | Run MorleyClientM action within given MorleyClientEnv.
-- Retry action in case of invalid counter error.
runMorleyClientM :: MorleyClientEnv -> MorleyClientM a -> IO a
-- | Construct MorleyClientEnv.
--
--
-- - octez-client path is taken from
-- MorleyClientConfig, but can be overridden using
-- MORLEY_TEZOS_CLIENT environment variable.
-- - Node data is taken from octez-client config and can be
-- overridden by MorleyClientConfig.
-- - The rest is taken from MorleyClientConfig as is.
--
mkMorleyClientEnv :: MorleyClientConfig -> IO MorleyClientEnv
mceTezosClientL :: Lens' MorleyClientEnv TezosClientEnv
mceLogActionL :: Lens' MorleyClientEnv (ClientLogAction MorleyClientM)
mceSecretKeyL :: Lens' MorleyClientEnv (Maybe SecretKey)
mceClientEnvL :: Lens' MorleyClientEnv ClientEnv
-- | Monad that implements HasTezosClient and HasTezosRpc
-- classes and can be used for high-level actions as an alternative to
-- MorleyClientM.
newtype MorleyOnlyRpcM a
MorleyOnlyRpcM :: ReaderT MorleyOnlyRpcEnv IO a -> MorleyOnlyRpcM a
[unMorleyOnlyRpcM] :: MorleyOnlyRpcM a -> ReaderT MorleyOnlyRpcEnv IO a
-- | Environment used by MorleyOnlyRpcM.
data MorleyOnlyRpcEnv
MorleyOnlyRpcEnv :: ClientLogAction MorleyOnlyRpcM -> ClientEnv -> Map ImplicitAddress SecretKey -> MorleyOnlyRpcEnv
-- | Action used to log messages.
[moreLogAction] :: MorleyOnlyRpcEnv -> ClientLogAction MorleyOnlyRpcM
-- | Environment necessary to make HTTP calls.
[moreClientEnv] :: MorleyOnlyRpcEnv -> ClientEnv
-- | In-memory secret keys that can be used for signing.
[moreSecretKeys] :: MorleyOnlyRpcEnv -> Map ImplicitAddress SecretKey
-- | 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.
--
mkMorleyOnlyRpcEnv :: [SecretKey] -> BaseUrl -> Word -> IO MorleyOnlyRpcEnv
-- | Run MorleyOnlyRpcM action within given MorleyOnlyRpcEnv.
-- Retry action in case of invalid counter error.
runMorleyOnlyRpcM :: MorleyOnlyRpcEnv -> MorleyOnlyRpcM a -> IO a
-- | A block identifier as submitted to RPC.
--
-- A block can be referenced by head, genesis, level or
-- block hash
data BlockId
-- | Identifier referring to the head block.
HeadId :: BlockId
-- | Identifier of the most recent block guaranteed to have been finalized.
-- See:
-- https://web.archive.org/web/20220305165609/https://tezos.gitlab.io/protocols/tenderbake.html#operations
FinalHeadId :: BlockId
-- | Identifier referring to the genesis block.
GenesisId :: BlockId
-- | Identifier referring to a block by its level.
LevelId :: Natural -> BlockId
-- | Idenfitier referring to a block by its hash in Base58Check notation.
BlockHashId :: BlockHash -> BlockId
-- | Identifier of a block at specific depth relative to head.
AtDepthId :: Natural -> BlockId
-- | Type class that provides interaction with tezos node via RPC
class (Monad m, MonadCatch m) => HasTezosRpc m
-- | Get hash of the given BlockId, mostly used to get hash of
-- HeadId
getBlockHash :: HasTezosRpc m => BlockId -> m BlockHash
-- | Get address counter, which is required for both transaction sending
-- and contract origination.
getCounterAtBlock :: HasTezosRpc m => BlockId -> ImplicitAddress -> m TezosInt64
-- | Get the whole header of a block.
getBlockHeader :: HasTezosRpc m => BlockId -> m BlockHeader
-- | Get the script size at block.
getScriptSizeAtBlock :: HasTezosRpc m => BlockId -> CalcSize -> m ScriptSize
-- | Get block constants that are required by other RPC calls.
getBlockConstants :: HasTezosRpc m => BlockId -> m BlockConstants
-- | Get all operations from the block with specified ID.
getBlockOperations :: HasTezosRpc m => BlockId -> m [[BlockOperation]]
-- | Get all operation hashes from the block with specified ID.
getBlockOperationHashes :: HasTezosRpc m => BlockId -> m [[OperationHash]]
-- | Get protocol parameters that are for limits calculations.
getProtocolParametersAtBlock :: HasTezosRpc m => BlockId -> m ProtocolParameters
-- | 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.
runOperationAtBlock :: HasTezosRpc m => BlockId -> RunOperation -> m RunOperationResult
-- | 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.
preApplyOperationsAtBlock :: HasTezosRpc m => BlockId -> [PreApplyOperation] -> m [RunOperationResult]
-- | Forge operation in order to receive its hexadecimal representation.
forgeOperationAtBlock :: HasTezosRpc m => BlockId -> ForgeOperation -> m HexJSONByteString
-- | Inject operation, note that this operation has to be signed before
-- injection. As a result it returns operation hash.
injectOperation :: HasTezosRpc m => HexJSONByteString -> m OperationHash
-- | 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.
getContractScriptAtBlock :: HasTezosRpc m => BlockId -> ContractAddress -> m OriginationScript
-- | 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.
getContractStorageAtBlock :: HasTezosRpc m => BlockId -> ContractAddress -> m Expression
-- | Get big map value by contract address.
getContractBigMapAtBlock :: HasTezosRpc m => BlockId -> ContractAddress -> GetBigMap -> m GetBigMapResult
-- | Get big map value at some block by the big map's ID and the hashed
-- entry key.
getBigMapValueAtBlock :: HasTezosRpc m => BlockId -> Natural -> Text -> m Expression
-- | Get all big map values at some block by the big map's ID and the
-- optional offset and length.
getBigMapValuesAtBlock :: HasTezosRpc m => BlockId -> Natural -> Maybe Natural -> Maybe Natural -> m Expression
-- | Get balance for given address.
getBalanceAtBlock :: HasTezosRpc m => BlockId -> Address -> m Mutez
-- | Get delegate for given address.
getDelegateAtBlock :: HasTezosRpc m => BlockId -> L1Address -> m (Maybe KeyHash)
-- | Emulate contract call. This RPC endpoint does the same as
-- octez-client run script command does.
runCodeAtBlock :: HasTezosRpc m => BlockId -> RunCode -> m RunCodeResult
-- | Get current ChainId
getChainId :: HasTezosRpc m => m ChainId
-- | Get manager key for given address. Returns Nothing if this
-- key wasn't revealed.
getManagerKeyAtBlock :: HasTezosRpc m => BlockId -> ImplicitAddress -> m (Maybe PublicKey)
-- | Blocks until an operation with the given hash is included into the
-- chain. The first argument is the action that puts the operation on the
-- chain. Returns the hash of the included operation.
waitForOperation :: HasTezosRpc m => m OperationHash -> m OperationHash
-- | Access the contract's or implicit account's balance of ticket with
-- specified ticketer, content type, and content.
getTicketBalanceAtBlock :: HasTezosRpc m => BlockId -> Address -> GetTicketBalance -> m Natural
-- | Access the complete list of tickets owned by the given contract by
-- scanning the contract's storage.
getAllTicketBalancesAtBlock :: HasTezosRpc m => BlockId -> ContractAddress -> m [GetAllTicketBalancesResponse]
-- | Pack typed value into hexadecimal text representation.
packData :: (HasTezosRpc m, ForbidOp t) => BlockId -> Value t -> Notes t -> m Text
data OperationInfo i
OpTransfer :: TransferInfo i -> OperationInfo i
OpTransferTicket :: TransferTicketInfo i -> OperationInfo i
OpOriginate :: OriginationInfo i -> OperationInfo i
OpReveal :: RevealInfo i -> OperationInfo i
OpDelegation :: DelegationInfo i -> OperationInfo i
class OperationInfoDescriptor (i :: Type) where {
type family TransferInfo i :: Type;
type family TransferTicketInfo i :: Type;
type family OriginationInfo i :: Type;
type family RevealInfo i :: Type;
type family DelegationInfo i :: Type;
}
-- | Designates an input RPC data that we supply to perform an operation.
data RPCInput
-- | Get originated Contract for some address.
getContract :: HasTezosRpc m => ContractAddress -> m Contract
-- | Get counter value for given implicit address.
getImplicitContractCounter :: HasTezosRpc m => ImplicitAddress -> m TezosInt64
-- | getContractStorageAtBlock applied to the head block.
getContractStorage :: HasTezosRpc m => ContractAddress -> m Expression
-- | getBigMapValueAtBlock applied to the head block.
getBigMapValue :: HasTezosRpc m => Natural -> Text -> m Expression
-- | Get hash of the current head block, this head hash is used in other
-- RPC calls.
getHeadBlock :: HasTezosRpc m => m BlockHash
-- | getCounterAtBlock applied to the head block.
getCounter :: HasTezosRpc m => ImplicitAddress -> m TezosInt64
-- | getProtocolParametersAtBlock applied to the head block.
getProtocolParameters :: HasTezosRpc m => m ProtocolParameters
-- | runOperationAtBlock applied to the head block.
runOperation :: HasTezosRpc m => RunOperation -> m RunOperationResult
-- | preApplyOperationsAtBlock applied to the head block.
preApplyOperations :: HasTezosRpc m => [PreApplyOperation] -> m [RunOperationResult]
-- | forgeOperationAtBlock applied to the head block.
forgeOperation :: HasTezosRpc m => ForgeOperation -> m HexJSONByteString
-- | getContractScriptAtBlock applied to the head block.
getContractScript :: HasTezosRpc m => ContractAddress -> m OriginationScript
-- | getContractBigMapAtBlock applied to the head block.
getContractBigMap :: HasTezosRpc m => ContractAddress -> GetBigMap -> m GetBigMapResult
-- | getBalanceAtBlock applied to the head block.
getBalance :: forall kind m. (HasTezosRpc m, L1AddressKind kind) => KindedAddress kind -> m Mutez
-- | getDelegateAtBlock applied to the head block.
getDelegate :: HasTezosRpc m => L1Address -> m (Maybe KeyHash)
-- | runCodeAtBlock applied to the head block.
runCode :: HasTezosRpc m => RunCode -> m RunCodeResult
getManagerKey :: HasTezosRpc m => ImplicitAddress -> m (Maybe PublicKey)
getTicketBalance :: HasTezosRpc m => L1Address -> GetTicketBalance -> m Natural
getAllTicketBalances :: HasTezosRpc m => ContractAddress -> m [GetAllTicketBalancesResponse]
data GetTicketBalance
GetTicketBalance :: ContractAddress -> Expression -> Expression -> GetTicketBalance
[gtbTicketer] :: GetTicketBalance -> ContractAddress
[gtbContentType] :: GetTicketBalance -> Expression
[gtbContent] :: GetTicketBalance -> Expression
data GetAllTicketBalancesResponse
GetAllTicketBalancesResponse :: ContractAddress -> Expression -> Expression -> TezosNat -> GetAllTicketBalancesResponse
[gatbrTicketer] :: GetAllTicketBalancesResponse -> ContractAddress
[gatbrContentType] :: GetAllTicketBalancesResponse -> Expression
[gatbrContent] :: GetAllTicketBalancesResponse -> Expression
[gatbrAmount] :: GetAllTicketBalancesResponse -> TezosNat
-- | Errors that can happen in the RPC part when a user tries to make
-- failing actions.
data ClientRpcError
-- | Smart contract execution has failed.
ContractFailed :: ContractAddress -> Expression -> ClientRpcError
-- | Parameter passed to a contract does not match its type.
BadParameter :: Address -> Expression -> ClientRpcError
-- | Transfer of 0 to an implicit account.
EmptyTransaction :: ImplicitAddress -> ClientRpcError
-- | A smart contract execution failed due to a shift overflow.
ShiftOverflow :: ContractAddress -> ClientRpcError
-- | A smart contract execution failed due gas exhaustion.
GasExhaustion :: ContractAddress -> ClientRpcError
-- | A key has already been revealed.
KeyAlreadyRevealed :: ImplicitAddress -> ClientRpcError
-- | Address not registered as delegate
DelegateNotRegistered :: ImplicitAddress -> ClientRpcError
-- | 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
-- InternalError here as is, because it's easy for a user of
-- morley-client to work with this type. In #284 we will
-- consider more errors and maybe some of them will need to be mapped
-- into something more user-friendly, then we will reconsider this
-- approach.
ClientInternalError :: InternalError -> ClientRpcError
data ClientRpcErrorWithStack a
ClientRpcErrorWithStack :: NonEmpty (OperationResp WithSource) -> a -> ClientRpcErrorWithStack a
[crewsStack] :: ClientRpcErrorWithStack a -> NonEmpty (OperationResp WithSource)
[crewsError] :: ClientRpcErrorWithStack a -> a
-- | Errors that we don't expect to happen, but they can be reported by the
-- server.
data UnexpectedErrors
UnexpectedRunErrors :: [RunError] -> UnexpectedErrors
UnexpectedInternalErrors :: [InternalError] -> UnexpectedErrors
-- | 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.
data IncorrectRpcResponse
RpcUnexpectedSize :: Int -> Int -> IncorrectRpcResponse
RpcOriginatedNoContracts :: IncorrectRpcResponse
RpcOriginatedMoreContracts :: [ContractAddress] -> IncorrectRpcResponse
-- | 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.
data RunError
RuntimeError :: ContractAddress -> RunError
ScriptRejected :: Expression -> RunError
BadContractParameter :: Address -> RunError
InvalidConstant :: Expression -> Expression -> RunError
InvalidContract :: Address -> RunError
InconsistentTypes :: Expression -> Expression -> RunError
InvalidPrimitive :: [Text] -> Text -> RunError
InvalidSyntacticConstantError :: Expression -> Expression -> RunError
InvalidExpressionKind :: [Text] -> Text -> RunError
InvalidContractNotation :: Text -> RunError
UnexpectedContract :: RunError
IllFormedType :: Expression -> RunError
UnexpectedOperation :: RunError
-- | Transfer of 0 to an implicit account.
REEmptyTransaction :: ImplicitAddress -> RunError
-- | 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).
ScriptOverflow :: RunError
GasExhaustedOperation :: RunError
MutezAdditionOverflow :: [TezosInt64] -> RunError
MutezSubtractionUnderflow :: [TezosInt64] -> RunError
MutezMultiplicationOverflow :: TezosInt64 -> TezosInt64 -> RunError
CantPayStorageFee :: RunError
BalanceTooLow :: ("balance" :! Mutez) -> ("required" :! Mutez) -> RunError
PreviouslyRevealedKey :: ImplicitAddress -> RunError
NonExistingContract :: Address -> RunError
InvalidB58Check :: Text -> RunError
UnregisteredDelegate :: ImplicitAddress -> RunError
FailedUnDelegation :: ImplicitAddress -> RunError
DelegateAlreadyActive :: RunError
IllTypedContract :: Expression -> RunError
IllTypedData :: Expression -> Expression -> RunError
BadStack :: BadStackInformation -> RunError
ForbiddenZeroAmountTicket :: RunError
REEmptyImplicitContract :: ImplicitAddress -> RunError
-- | Failed to decode received value to the given type.
data ValueDecodeFailure
ValueDecodeFailure :: Text -> T -> ValueDecodeFailure
data ValueNotFound
ValueNotFound :: ValueNotFound
-- | Read all big_map values, given it's ID. If the values are not of the
-- expected type, a ValueDecodeFailure will be thrown.
readAllBigMapValues :: forall v k m. (NiceUnpackedValue v, HasTezosRpc m) => BigMapId k v -> m [v]
-- | 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.
readAllBigMapValuesMaybe :: forall v k m. (NiceUnpackedValue v, HasTezosRpc m) => BigMapId k v -> m (Maybe [v])
-- | Read big_map value of given contract by key.
--
-- If the contract contains several big_maps with given key
-- type, only one of them will be considered.
readContractBigMapValue :: forall k v m. (PackedValScope k, HasTezosRpc m, SingI v) => ContractAddress -> Value k -> m (Value v)
-- | 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.
readBigMapValueMaybe :: forall v k m. (NicePackedValue k, NiceUnpackedValue v, HasTezosRpc m) => BigMapId k v -> k -> m (Maybe v)
-- | 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.
readBigMapValue :: forall v k m. (NicePackedValue k, NiceUnpackedValue v, HasTezosRpc m) => BigMapId k v -> k -> m v
-- | Type class that provides interaction with octez-client binary
class (Monad m) => HasTezosClient m
-- | Sign an operation with octez-client.
signBytes :: HasTezosClient m => ImplicitAddressWithAlias -> Maybe ScrubbedBytes -> ByteString -> m Signature
-- | 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.
genKey :: HasTezosClient m => ImplicitAlias -> m ImplicitAddressWithAlias
-- | Generate a secret key and store it with given alias. Unlike
-- genKey this function overwrites the existing key when given
-- alias is already stored.
genFreshKey :: HasTezosClient m => ImplicitAlias -> m ImplicitAddressWithAlias
-- | Associate the given contract with alias. The Bool variable
-- indicates whether or not we should replace already existing contract
-- alias or not.
rememberContract :: HasTezosClient m => AliasBehavior -> ContractAddress -> ContractAlias -> m ()
-- | Retrieves a list with all known aliases and respective addresses.
--
-- Note that an alias can be ambiguous: it can refer to BOTH a contract
-- and an implicit account. In that case, the map will contain entries
-- for both.
getAliasesAndAddresses :: HasTezosClient m => m AliasesAndAddresses
-- | 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.
getKeyPassword :: HasTezosClient m => ImplicitAddressWithAlias -> m (Maybe ScrubbedBytes)
-- | Get a public key for an implicit address or alias.
getPublicKey :: HasTezosClient m => ImplicitAddressWithAlias -> m PublicKey
class Resolve addressOrAlias where {
type family ResolvedAddress addressOrAlias :: Type;
type family ResolvedAlias addressOrAlias :: Type;
}
data ResolveError
[REAliasNotFound] :: Text -> ResolveError
[REWrongKind] :: Alias expectedKind -> Address -> ResolveError
[REAddressNotFound] :: KindedAddress kind -> ResolveError
-- | Looks up the alias associated with the given addressOrAlias.
--
-- Will throw a TezosClientError if addressOrAlias:
--
--
-- - is an address that is not associated with any alias.
-- - is an alias that does not exist.
-- - is an alias that exists but its address is of the wrong kind.
--
--
-- When the alias is associated with both an implicit and a
-- contract address:
--
--
getAlias :: forall addressOrAlias m env. (HasTezosClient m, WithClientLog env m, MonadThrow m, Resolve addressOrAlias) => addressOrAlias -> m (ResolvedAlias addressOrAlias)
-- | Looks up the alias associated with the given addressOrAlias.
--
-- Will return Nothing if addressOrAlias:
--
--
-- - is an address that is not associated with any alias.
-- - is an alias that does not exist.
-- - is an alias that exists but its address is of the wrong kind.
--
--
-- When the alias is associated with both an implicit and a
-- contract address:
--
--
getAliasMaybe :: forall addressOrAlias m env. (HasTezosClient m, WithClientLog env m, MonadThrow m, Resolve addressOrAlias) => addressOrAlias -> m (Maybe (ResolvedAlias addressOrAlias))
-- | Looks up the address associated with the given
-- addressOrAlias.
--
-- Will throw a TezosClientError if addressOrAlias is an
-- alias and:
--
--
-- - the alias does not exist.
-- - the alias exists but its address is of the wrong kind.
--
--
-- When the alias is associated with both an implicit and a
-- contract address:
--
--
resolveAddress :: forall addressOrAlias m env. (HasTezosClient m, MonadThrow m, WithClientLog env m, Resolve addressOrAlias) => addressOrAlias -> m (ResolvedAddress addressOrAlias)
-- | Looks up the address associated with the given
-- addressOrAlias.
--
-- Will return Nothing if addressOrAlias is an alias and:
--
--
-- - the alias does not exist.
-- - the alias exists but its address is of the wrong kind.
--
--
-- When the alias is associated with both an implicit and a
-- contract address:
--
--
resolveAddressMaybe :: forall addressOrAlias m env. (HasTezosClient m, MonadThrow m, WithClientLog env m, Resolve addressOrAlias) => addressOrAlias -> m (Maybe (ResolvedAddress addressOrAlias))
-- | Looks up the address and alias with the given addressOrAlias.
resolveAddressWithAlias :: forall addressOrAlias m env. (HasTezosClient m, MonadThrow m, WithClientLog env m, Resolve addressOrAlias) => addressOrAlias -> m (ResolvedAddressAndAlias addressOrAlias)
-- | Looks up the address and alias with the given addressOrAlias.
resolveAddressWithAliasMaybe :: forall addressOrAlias m env. (HasTezosClient m, MonadThrow m, WithClientLog env m, Resolve addressOrAlias) => addressOrAlias -> m (Maybe (ResolvedAddressAndAlias addressOrAlias))
-- | A data type for all predicatable errors that can happen during
-- octez-client usage.
data TezosClientError
-- | octez-client call unexpectedly failed (returned non-zero exit
-- code). The error contains the error code, stdout and stderr contents.
UnexpectedClientFailure :: Int -> Text -> Text -> TezosClientError
-- | Public key of the given address is already revealed.
AlreadyRevealed :: ImplicitAlias -> TezosClientError
-- | Can't wait for inclusion of operation with given hash because the hash
-- is invalid.
InvalidOperationHash :: OperationHash -> TezosClientError
-- | Error that indicates when given counter is already used for given
-- contract.
CounterIsAlreadyUsed :: Text -> Text -> TezosClientError
-- | Network error with which octez-client fails from time to
-- time.
EConnreset :: TezosClientError
-- | A parse error occurred during config parsing.
ConfigParseError :: String -> TezosClientError
-- | octez-client produced a cryptographic primitive that we can't
-- parse.
TezosClientCryptoParseError :: Text -> CryptoParseError -> TezosClientError
-- | octez-client produced an address that we can't parse.
TezosClientParseAddressError :: Text -> ParseAddressError -> TezosClientError
-- | octez-client produced invalid output for parsing baker fee
TezosClientParseFeeError :: Text -> Text -> TezosClientError
-- | octez-client printed a string that doesn't match the format
-- we expect.
TezosClientUnexpectedOutputFormat :: Text -> TezosClientError
-- | Given alias is a contract and cannot be revealed.
CantRevealContract :: ImplicitAlias -> TezosClientError
-- | Given contract is a source of a transfer or origination operation.
ContractSender :: ContractAddress -> Text -> TezosClientError
-- | Given alias is an empty implicit contract.
EmptyImplicitContract :: ImplicitAlias -> TezosClientError
-- | octez-client sign bytes produced unexpected output format
TezosClientUnexpectedSignatureOutput :: Text -> TezosClientError
-- | octez-client produced invalid output for parsing secret key
-- encryption type.
TezosClientParseEncryptionTypeError :: Text -> Text -> TezosClientError
-- | Tried to save alias, but such alias already exists.
DuplicateAlias :: Text -> TezosClientError
-- | Expected an alias to be associated with either an implicit address or
-- a contract address, but it was associated with both.
AmbiguousAlias :: Text -> ContractAddress -> ImplicitAddress -> TezosClientError
ResolveError :: ResolveError -> TezosClientError
-- | How to save the originated contract address.
data AliasBehavior
-- | Don't save the newly originated contract address.
DontSaveAlias :: AliasBehavior
-- | If an alias already exists, keep it, don't save the newly originated
-- contract address.
KeepDuplicateAlias :: AliasBehavior
-- | If an alias already exists, replace it with the address of the newly
-- originated contract.
OverwriteDuplicateAlias :: AliasBehavior
-- | If an alias already exists, throw an exception without doing the
-- origination
ForbidDuplicateAlias :: AliasBehavior
-- | Sets the environment variable for disabling octez-client's
-- "not a mainnet" warning
disableAlphanetWarning :: IO ()
-- | A kinded address together with the corresponding alias. Due to the
-- quirks of octez-client we usually need both in
-- morley-client, hence the need for this type. Historically, we
-- asked octez-client for the missing part, but that resulted in
-- a lot of inefficiencies.
--
-- Note that the Ord instance is rather arbitrary, and doesn't
-- necessarily correspond to anything in Michelson. It's added for
-- convenience, e.g. so that AddressWithAlias is usable as a
-- Map key.
data AddressWithAlias kind
AddressWithAlias :: KindedAddress kind -> Alias kind -> AddressWithAlias kind
[awaAddress] :: AddressWithAlias kind -> KindedAddress kind
[awaAlias] :: AddressWithAlias kind -> Alias kind
type ImplicitAddressWithAlias = AddressWithAlias 'AddressKindImplicit
type ContractAddressWithAlias = AddressWithAlias 'AddressKindContract
-- | A full description for a runnable Parser for a program.
data ParserInfo a
module Morley.Util.Batching
-- | Records operations to be executed in batch.
--
-- Chronologically, this works in 3 steps:
--
--
-- - Form the list of input items i;
-- - Perform the batch operation;
-- - Parse output items o into result a, maybe
-- producing error e.
--
--
-- However in code we usually want steps 1 and 3 to be grouped and step 2
-- to be delayed - BatchingM facilitates this separation.
--
-- Note that BatchingM is fundamentally not a monad, rather just
-- an applicative, because within a batch you cannot use result of one
-- operation in another operation.
data BatchingM i o e a
-- | Run recorded operations sequence using the given batch executor.
runBatching :: Functor m => ([i] -> m (r, [o])) -> BatchingM i o e a -> m (r, Either (BatchingError e) a)
-- | Similar to runBatching, for cases when the given batch executor
-- is guaranteed to return the output respective to the provided input.
unsafeRunBatching :: (Functor m, Buildable e) => ([i] -> m (r, [o])) -> BatchingM i o e a -> m (r, a)
-- | This is the basic primitive for all actions in BatchingM.
--
-- It records that given input item should be put to batch, and once
-- operation is actually performed, the result should be parsed with
-- given method.
submitThenParse :: i -> (o -> Either e a) -> BatchingM i o e a
infix 1 `submitThenParse`
-- | Errors that can occur during batching, usually because the underlying
-- function that performs batch operation returns output that does not
-- match the provided input.
data BatchingError e
-- | The function that executes the batch returned less elements in output
-- than were provided at input.
InsufficientOutput :: BatchingError e
-- | The function that executes the batch returned more elements in output
-- than were provided at input.
ExtraOutput :: BatchingError e
-- | User-provided parsing method failed. Usually this means that output
-- does not correspond to provided input.
UnexpectedElement :: e -> BatchingError e
instance GHC.Base.Functor (Morley.Util.Batching.BatchingM i o e)
instance GHC.Base.Applicative (Morley.Util.Batching.BatchingM i o e)
instance Fmt.Buildable.Buildable e => Fmt.Buildable.Buildable (Morley.Util.Batching.BatchingError e)
-- | Primitives for running batched operations with a neat interface.
module Morley.Client.Action.Batched
-- | Where the batched operations occur.
--
-- Example:
--
--
-- runOperationsBatch mySender $ do
-- addr <- originateContractM ...
-- runTransactionM ...
-- return addr
--
--
-- Note that this is not a Monad, rather an Applicative -
-- use -XApplicativeDo extension for nicer experience.
newtype OperationsBatch a
OperationsBatch :: BatchingM (OperationInfo ClientInput) (OperationInfo Result) BatchedOperationError a -> OperationsBatch a
[unOperationsBatch] :: OperationsBatch a -> BatchingM (OperationInfo ClientInput) (OperationInfo Result) BatchedOperationError a
-- | Perform origination within a batch.
originateContractM :: OriginationData -> OperationsBatch ContractAddress
-- | Perform transaction within a batch.
runTransactionM :: TransactionData -> OperationsBatch [WithSource EventOperation]
-- | Perform key revealing within a batch.
revealKeyM :: RevealData -> OperationsBatch ()
-- | Perform delegation within a batch.
delegateM :: DelegationData -> OperationsBatch ()
-- | Execute a batch.
runOperationsBatch :: (HasTezosRpc m, HasTezosClient m, WithClientLog env m) => ImplicitAddressWithAlias -> OperationsBatch a -> m (Maybe OperationHash, a)
instance GHC.Base.Applicative Morley.Client.Action.Batched.OperationsBatch
instance GHC.Base.Functor Morley.Client.Action.Batched.OperationsBatch
instance Fmt.Buildable.Buildable Morley.Client.Action.Batched.BatchedOperationError