Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Interface to the octez-client
executable expressed in Haskell types.
Synopsis
- data TezosClientError
- = UnexpectedClientFailure Int Text Text
- | AlreadyRevealed ImplicitAlias
- | InvalidOperationHash OperationHash
- | CounterIsAlreadyUsed Text Text
- | EConnreset
- | ConfigParseError String
- | TezosClientCryptoParseError Text CryptoParseError
- | TezosClientParseAddressError Text ParseAddressError
- | TezosClientParseFeeError Text Text
- | TezosClientUnexpectedOutputFormat Text
- | CantRevealContract ImplicitAlias
- | ContractSender ContractAddress Text
- | EmptyImplicitContract ImplicitAlias
- | TezosClientUnexpectedSignatureOutput Text
- | TezosClientParseEncryptionTypeError Text Text
- | DuplicateAlias Text
- | ResolveError ResolveError
- signBytes :: ImplicitAlias -> Maybe ScrubbedBytes -> ByteString -> MorleyClientM Signature
- rememberContract :: AliasBehavior -> ContractAddress -> ContractAlias -> MorleyClientM ()
- importKey :: Bool -> ImplicitAlias -> SecretKey -> MorleyClientM ImplicitAddressWithAlias
- genKey :: ImplicitAlias -> MorleyClientM ImplicitAddress
- genFreshKey :: ImplicitAlias -> MorleyClientM ImplicitAddress
- revealKey :: ImplicitAlias -> Maybe ScrubbedBytes -> MorleyClientM ()
- revealKeyUnlessRevealed :: ImplicitAddressWithAlias -> Maybe ScrubbedBytes -> MorleyClientM ()
- data ResolveError where
- REAliasNotFound :: Text -> ResolveError
- REWrongKind :: Alias expectedKind -> Address -> ResolveError
- REAddressNotFound :: KindedAddress kind -> ResolveError
- REAmbiguousAlias :: Text -> [L1Address] -> ResolveError
- class Resolve addressOrAlias where
- type ResolvedAddress addressOrAlias :: Type
- type ResolvedAlias addressOrAlias :: Type
- type ResolvedAddressAndAlias addressOrAlias :: Type
- resolveAddressEither :: HasTezosClient m => addressOrAlias -> m (Either ResolveError (ResolvedAddress addressOrAlias))
- getAliasEither :: HasTezosClient m => addressOrAlias -> m (Either ResolveError (ResolvedAlias addressOrAlias))
- resolveAddressWithAliasEither :: HasTezosClient m => addressOrAlias -> m (Either ResolveError (ResolvedAddressAndAlias addressOrAlias))
- resolveAddress :: forall addressOrAlias m. (HasTezosClient m, MonadThrow m, Resolve addressOrAlias) => addressOrAlias -> m (ResolvedAddress addressOrAlias)
- resolveAddressMaybe :: forall addressOrAlias m. (HasTezosClient m, MonadThrow m, Resolve addressOrAlias) => addressOrAlias -> m (Maybe (ResolvedAddress addressOrAlias))
- getAlias :: forall addressOrAlias m. (HasTezosClient m, MonadThrow m, Resolve addressOrAlias) => addressOrAlias -> m (ResolvedAlias addressOrAlias)
- getAliasMaybe :: forall addressOrAlias m. (HasTezosClient m, MonadThrow m, Resolve addressOrAlias) => addressOrAlias -> m (Maybe (ResolvedAlias addressOrAlias))
- getPublicKey :: ImplicitAlias -> MorleyClientM PublicKey
- getSecretKey :: ImplicitAlias -> MorleyClientM SecretKey
- getTezosClientConfig :: FilePath -> Maybe FilePath -> IO TezosClientConfig
- calcTransferFee :: AddressOrAlias kind -> Maybe ScrubbedBytes -> TezosInt64 -> [CalcTransferFeeData] -> MorleyClientM [TezosMutez]
- calcOriginationFee :: UntypedValScope st => CalcOriginationFeeData cp st -> MorleyClientM TezosMutez
- calcRevealFee :: ImplicitAlias -> Maybe ScrubbedBytes -> TezosInt64 -> MorleyClientM TezosMutez
- getKeyPassword :: ImplicitAlias -> MorleyClientM (Maybe ScrubbedBytes)
- registerDelegate :: ImplicitAlias -> Maybe ScrubbedBytes -> MorleyClientM ()
- getAliasesAndAddresses :: MorleyClientM AliasesAndAddresses
- resolveAddressWithAlias :: forall addressOrAlias m. (HasTezosClient m, MonadThrow m, Resolve addressOrAlias) => addressOrAlias -> m (ResolvedAddressAndAlias addressOrAlias)
- resolveAddressWithAliasMaybe :: forall addressOrAlias m. (HasTezosClient m, Resolve addressOrAlias) => addressOrAlias -> m (Maybe (ResolvedAddressAndAlias addressOrAlias))
- lookupAliasCache :: Alias kind -> MorleyClientM (Maybe (KindedAddress kind))
Documentation
data TezosClientError Source #
A data type for all predicatable errors that can happen during
octez-client
usage.
UnexpectedClientFailure |
|
AlreadyRevealed | Public key of the given address is already revealed. |
| |
InvalidOperationHash OperationHash | Can't wait for inclusion of operation with given hash because the hash is invalid. |
CounterIsAlreadyUsed | Error that indicates when given counter is already used for given contract. |
EConnreset | Network error with which |
ConfigParseError String | A parse error occurred during config parsing. |
TezosClientCryptoParseError Text CryptoParseError |
|
TezosClientParseAddressError Text ParseAddressError |
|
TezosClientParseFeeError Text Text |
|
TezosClientUnexpectedOutputFormat Text |
|
CantRevealContract | Given alias is a contract and cannot be revealed. |
| |
ContractSender ContractAddress Text | Given contract is a source of a transfer or origination operation. |
EmptyImplicitContract | Given alias is an empty implicit contract. |
| |
TezosClientUnexpectedSignatureOutput Text |
|
TezosClientParseEncryptionTypeError Text Text |
|
DuplicateAlias Text | Tried to save alias, but such alias already exists. |
ResolveError ResolveError |
Instances
Exception TezosClientError Source # | |
Show TezosClientError Source # | |
Defined in Morley.Client.TezosClient.Types.Errors showsPrec :: Int -> TezosClientError -> ShowS # show :: TezosClientError -> String # showList :: [TezosClientError] -> ShowS # | |
Buildable TezosClientError Source # | |
Defined in Morley.Client.TezosClient.Types.Errors build :: TezosClientError -> Doc buildList :: [TezosClientError] -> Doc |
octez-client
api
signBytes :: ImplicitAlias -> Maybe ScrubbedBytes -> ByteString -> MorleyClientM Signature Source #
Sign an arbtrary bytestring using octez-client
.
Secret key of the address corresponding to give AddressOrAlias
must be known.
rememberContract :: AliasBehavior -> ContractAddress -> ContractAlias -> MorleyClientM () Source #
Save a contract with given address and alias.
If replaceExisting
is False
and a contract with given alias
already exists, this function does nothing.
importKey :: Bool -> ImplicitAlias -> SecretKey -> MorleyClientM ImplicitAddressWithAlias Source #
genKey :: ImplicitAlias -> MorleyClientM ImplicitAddress Source #
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.
genFreshKey :: ImplicitAlias -> MorleyClientM ImplicitAddress Source #
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.
revealKey :: ImplicitAlias -> Maybe ScrubbedBytes -> MorleyClientM () Source #
Reveal public key corresponding to the given alias. Fails if it's already revealed.
revealKeyUnlessRevealed :: ImplicitAddressWithAlias -> Maybe ScrubbedBytes -> MorleyClientM () Source #
Reveal key for implicit address if necessary.
data ResolveError where Source #
REAliasNotFound | |
| |
REWrongKind | |
| |
REAddressNotFound | |
| |
REAmbiguousAlias | |
|
Instances
Show ResolveError Source # | |
Defined in Morley.Client.TezosClient.Types.Errors showsPrec :: Int -> ResolveError -> ShowS # show :: ResolveError -> String # showList :: [ResolveError] -> ShowS # | |
Buildable ResolveError Source # | |
Defined in Morley.Client.TezosClient.Types.Errors build :: ResolveError -> Doc buildList :: [ResolveError] -> Doc |
class Resolve addressOrAlias where Source #
type ResolvedAddress addressOrAlias :: Type Source #
type ResolvedAlias addressOrAlias :: Type Source #
type ResolvedAddressAndAlias addressOrAlias :: Type Source #
resolveAddressEither :: HasTezosClient m => addressOrAlias -> m (Either ResolveError (ResolvedAddress addressOrAlias)) Source #
Looks up the address associated with the given addressOrAlias
.
When the alias is associated with both an implicit and a contract address:
- The
SomeAddressOrAlias
instance will returnREAmbiguousAlias
, unless the alias is prefixed withimplicit:
orcontract:
to disambiguate. - The
AddressOrAlias
instance will return the address with the requested kind.
getAliasEither :: HasTezosClient m => addressOrAlias -> m (Either ResolveError (ResolvedAlias addressOrAlias)) Source #
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 returnREAmbiguousAlias
, unless the alias is prefixed withimplicit:
orcontract:
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.
resolveAddressWithAliasEither :: HasTezosClient m => addressOrAlias -> m (Either ResolveError (ResolvedAddressAndAlias addressOrAlias)) Source #
Resolve both address and alias at the same time
Instances
resolveAddress :: forall addressOrAlias m. (HasTezosClient m, MonadThrow m, Resolve addressOrAlias) => addressOrAlias -> m (ResolvedAddress addressOrAlias) Source #
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:
- The
SomeAddressOrAlias
instance will throw aTezosClientError
, unless the alias is prefixed withimplicit:
orcontract:
to disambiguate. - The
AddressOrAlias
instance will return the address with the requested kind.
resolveAddressMaybe :: forall addressOrAlias m. (HasTezosClient m, MonadThrow m, Resolve addressOrAlias) => addressOrAlias -> m (Maybe (ResolvedAddress addressOrAlias)) Source #
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:
- The
SomeAddressOrAlias
instance will throw aTezosClientError
, unless the alias is prefixed withimplicit:
orcontract:
to disambiguate. - The
AddressOrAlias
instance will return the address with the requested kind.
getAlias :: forall addressOrAlias m. (HasTezosClient m, MonadThrow m, Resolve addressOrAlias) => addressOrAlias -> m (ResolvedAlias addressOrAlias) Source #
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:
- The
SomeAddressOrAlias
instance will throw aTezosClientError
, unless the alias is prefixed withimplicit:
orcontract:
to disambiguate. - The
AddressOrAlias
instance will return the alias.
getAliasMaybe :: forall addressOrAlias m. (HasTezosClient m, MonadThrow m, Resolve addressOrAlias) => addressOrAlias -> m (Maybe (ResolvedAlias addressOrAlias)) Source #
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:
- The
SomeAddressOrAlias
instance will throw aTezosClientError
, unless the alias is prefixed withimplicit:
orcontract:
to disambiguate. - The
AddressOrAlias
instance will return the alias.
getPublicKey :: ImplicitAlias -> MorleyClientM PublicKey Source #
Return PublicKey
corresponding to given AddressOrAlias
.
getSecretKey :: ImplicitAlias -> MorleyClientM SecretKey Source #
Return SecretKey
corresponding to given AddressOrAlias
.
getTezosClientConfig :: FilePath -> Maybe FilePath -> IO TezosClientConfig Source #
Read octez-client
configuration.
calcTransferFee :: AddressOrAlias kind -> Maybe ScrubbedBytes -> TezosInt64 -> [CalcTransferFeeData] -> MorleyClientM [TezosMutez] Source #
Calc baker fee for transfer using octez-client
.
calcOriginationFee :: UntypedValScope st => CalcOriginationFeeData cp st -> MorleyClientM TezosMutez Source #
Calc baker fee for origination using octez-client
.
calcRevealFee :: ImplicitAlias -> Maybe ScrubbedBytes -> TezosInt64 -> MorleyClientM TezosMutez Source #
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.
getKeyPassword :: ImplicitAlias -> MorleyClientM (Maybe ScrubbedBytes) Source #
Get password for secret key associated with given address in case this key is password-protected
registerDelegate :: ImplicitAlias -> Maybe ScrubbedBytes -> MorleyClientM () Source #
Register alias as delegate
getAliasesAndAddresses :: MorleyClientM AliasesAndAddresses Source #
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...")
resolveAddressWithAlias :: forall addressOrAlias m. (HasTezosClient m, MonadThrow m, Resolve addressOrAlias) => addressOrAlias -> m (ResolvedAddressAndAlias addressOrAlias) Source #
Looks up the address and alias with the given addressOrAlias
.
resolveAddressWithAliasMaybe :: forall addressOrAlias m. (HasTezosClient m, Resolve addressOrAlias) => addressOrAlias -> m (Maybe (ResolvedAddressAndAlias addressOrAlias)) Source #
Looks up the address and alias with the given addressOrAlias
.
For tests
lookupAliasCache :: Alias kind -> MorleyClientM (Maybe (KindedAddress kind)) Source #
Orphan instances
HasTezosClient MorleyClientM Source # | |
signBytes :: ImplicitAddressWithAlias -> Maybe ScrubbedBytes -> ByteString -> MorleyClientM Signature Source # genKey :: ImplicitAlias -> MorleyClientM ImplicitAddressWithAlias Source # genFreshKey :: ImplicitAlias -> MorleyClientM ImplicitAddressWithAlias Source # rememberContract :: AliasBehavior -> ContractAddress -> ContractAlias -> MorleyClientM () Source # getAliasesAndAddresses :: MorleyClientM AliasesAndAddresses Source # getKeyPassword :: ImplicitAddressWithAlias -> MorleyClientM (Maybe ScrubbedBytes) Source # getPublicKey :: ImplicitAddressWithAlias -> MorleyClientM PublicKey Source # |