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

Morley.Client.App

Description

Functions useful for implementing instances of type classes from this package. Monads and actual instances are defined in separate modules.

Synopsis

RunClient

HasTezosRpc

getCounterImpl :: (RunClient m, MonadUnliftIO m, MonadCatch m) => BlockId -> Address -> m TezosInt64 Source #

getBalanceImpl :: (RunClient m, MonadUnliftIO m, MonadCatch m) => BlockId -> Address -> m Mutez Source #

getManagerKeyImpl :: (RunClient m, MonadUnliftIO m, MonadCatch m) => BlockId -> Address -> m (Maybe PublicKey) Source #

Similar to getManagerKey, but retries once on timeout.

getChainIdImpl :: (RunClient m, MonadCatch m) => m ChainId Source #

getDelegateImpl :: (RunClient m, MonadUnliftIO m, MonadCatch m) => BlockId -> Address -> m (Maybe KeyHash) Source #

Timeouts and retries

retryOnTimeout :: (MonadUnliftIO m, MonadThrow m) => Bool -> m a -> m a Source #

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.

failOnTimeout :: (MonadUnliftIO m, MonadThrow m) => m a -> m a Source #

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.

retryOnceOnTimeout :: (MonadUnliftIO m, MonadThrow m) => m a -> m a Source #

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 tezos-client config/environment.

waitBeforeRetry :: (MonadIO m, HasTezosRpc m, WithClientLog env m) => m () Source #

Wait for a reasonable amount of time before retrying an action that failed due to invalid counter. The waiting time depends on protocol parameters.

handleInvalidCounterRpc :: MonadThrow m => m a -> ClientRpcError -> m a Source #

Retry action if it failed due to invalid counter (already used one).