morley-1.19.0: Developer tools for the Michelson Language
Safe HaskellSafe-Inferred
LanguageHaskell2010

Morley.Tezos.Address

Description

Address in Tezos.

Synopsis

Documentation

type ContractHash = Hash 'HashKindContract Source #

Convenience synonym for a contract hash.

data KindedAddress (kind :: AddressKind) where Source #

A "kinded" address. This type carries AddressKind on the type-level. Useful in the internal API, not as much when we have to interact with the network. See Address for a type that is isomorphic to a Michelson address.

Constructors

ImplicitAddress :: KeyHash -> KindedAddress 'AddressKindImplicit

tz1, tz2 or tz3 address which is a hash of a public key.

ContractAddress :: ContractHash -> KindedAddress 'AddressKindContract

KT1 address which corresponds to a callable contract.

TxRollupAddress :: TxRollupHash -> KindedAddress 'AddressKindTxRollup

txr1 address which corresponds to a transaction rollup.

Instances

Instances details
FromJSON Address Source # 
Instance details

Defined in Morley.Tezos.Address

FromJSONKey Address Source # 
Instance details

Defined in Morley.Tezos.Address

HasRPCRepr Address Source # 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC Address Source #

TypeHasDoc Address Source # 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Doc

IsoValue Address Source # 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Value

Associated Types

type ToT Address :: T Source #

GCompare KindedAddress Source # 
Instance details

Defined in Morley.Tezos.Address

Methods

gcompare :: forall (a :: k) (b :: k). KindedAddress a -> KindedAddress b -> GOrdering a b #

GEq KindedAddress Source # 
Instance details

Defined in Morley.Tezos.Address

Methods

geq :: forall (a :: k) (b :: k). KindedAddress a -> KindedAddress b -> Maybe (a :~: b) #

ArgDict (c :: AddressKind -> Constraint) KindedAddress Source # 
Instance details

Defined in Morley.Tezos.Address

Associated Types

type ConstraintsFor KindedAddress c #

Methods

argDict :: forall (a :: k). ConstraintsFor KindedAddress c => KindedAddress a -> Dict (c a) #

Lift (KindedAddress kind :: Type) Source # 
Instance details

Defined in Morley.Tezos.Address

Methods

lift :: Quote m => KindedAddress kind -> m Exp #

liftTyped :: forall (m :: Type -> Type). Quote m => KindedAddress kind -> Code m (KindedAddress kind) #

SingI kinds => FromJSON (ConstrainedAddress kinds) Source # 
Instance details

Defined in Morley.Tezos.Address

SingI kind => FromJSON (KindedAddress kind) Source # 
Instance details

Defined in Morley.Tezos.Address

SingI kind => FromJSONKey (KindedAddress kind) Source # 
Instance details

Defined in Morley.Tezos.Address

ToJSON (KindedAddress kind) Source # 
Instance details

Defined in Morley.Tezos.Address

ToJSONKey (KindedAddress kind) Source # 
Instance details

Defined in Morley.Tezos.Address

(Bottom, TypeError ('Text "There is no instance defined for (IsString Address)" :$$: 'Text "Consider using QuasiQuotes: `[ta|some text...|]`") :: Constraint) => IsString (KindedAddress kind) Source # 
Instance details

Defined in Morley.Tezos.Address

Methods

fromString :: String -> KindedAddress kind #

Show (KindedAddress kind) Source # 
Instance details

Defined in Morley.Tezos.Address

Methods

showsPrec :: Int -> KindedAddress kind -> ShowS #

show :: KindedAddress kind -> String #

showList :: [KindedAddress kind] -> ShowS #

NFData (KindedAddress kind) Source # 
Instance details

Defined in Morley.Tezos.Address

Methods

rnf :: KindedAddress kind -> () #

Buildable (KindedAddress kind) Source # 
Instance details

Defined in Morley.Tezos.Address

Methods

build :: KindedAddress kind -> Builder #

Eq (KindedAddress kind) Source # 
Instance details

Defined in Morley.Tezos.Address

Methods

(==) :: KindedAddress kind -> KindedAddress kind -> Bool #

(/=) :: KindedAddress kind -> KindedAddress kind -> Bool #

Ord (KindedAddress kind) Source # 
Instance details

Defined in Morley.Tezos.Address

Methods

compare :: KindedAddress kind -> KindedAddress kind -> Ordering #

(<) :: KindedAddress kind -> KindedAddress kind -> Bool #

(<=) :: KindedAddress kind -> KindedAddress kind -> Bool #

(>) :: KindedAddress kind -> KindedAddress kind -> Bool #

(>=) :: KindedAddress kind -> KindedAddress kind -> Bool #

max :: KindedAddress kind -> KindedAddress kind -> KindedAddress kind #

min :: KindedAddress kind -> KindedAddress kind -> KindedAddress kind #

SingI kind => HasCLReader (KindedAddress kind) Source # 
Instance details

Defined in Morley.Tezos.Address

ToJSON (Constrained c KindedAddress) Source # 
Instance details

Defined in Morley.Tezos.Address

ToJSONKey (Constrained c KindedAddress) Source # 
Instance details

Defined in Morley.Tezos.Address

type AsRPC Address Source # 
Instance details

Defined in Morley.AsRPC

type TypeDocFieldDescriptions Address Source # 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Doc

type ToT Address Source # 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Value

type ConstraintsFor KindedAddress (c :: AddressKind -> Constraint) Source # 
Instance details

Defined in Morley.Tezos.Address

newtype TxRollupL2Address Source #

tz4 level-2 public key hash address, used with transaction rollups, corresponds to tx_rollup_l2_address Michelson type.

Instances

Instances details
Generic TxRollupL2Address Source # 
Instance details

Defined in Morley.Tezos.Address

Associated Types

type Rep TxRollupL2Address :: Type -> Type #

Show TxRollupL2Address Source # 
Instance details

Defined in Morley.Tezos.Address

NFData TxRollupL2Address Source # 
Instance details

Defined in Morley.Tezos.Address

Methods

rnf :: TxRollupL2Address -> () #

Buildable TxRollupL2Address Source # 
Instance details

Defined in Morley.Tezos.Address

Eq TxRollupL2Address Source # 
Instance details

Defined in Morley.Tezos.Address

Ord TxRollupL2Address Source # 
Instance details

Defined in Morley.Tezos.Address

HasRPCRepr TxRollupL2Address Source # 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC TxRollupL2Address Source #

IsoValue TxRollupL2Address Source # 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Value

Associated Types

type ToT TxRollupL2Address :: T Source #

Lift TxRollupL2Address Source # 
Instance details

Defined in Morley.Tezos.Address

Methods

lift :: Quote m => TxRollupL2Address -> m Exp #

liftTyped :: forall (m :: Type -> Type). Quote m => TxRollupL2Address -> Code m TxRollupL2Address #

type Rep TxRollupL2Address Source # 
Instance details

Defined in Morley.Tezos.Address

type Rep TxRollupL2Address = D1 ('MetaData "TxRollupL2Address" "Morley.Tezos.Address" "morley-1.19.0-inplace" 'True) (C1 ('MetaCons "TxRollupL2Address" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 KeyHashL2)))
type AsRPC TxRollupL2Address Source # 
Instance details

Defined in Morley.AsRPC

type ToT TxRollupL2Address Source # 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Value

detGenKeyAddress :: ByteString -> ImplicitAddress Source #

Deterministically generate a random ImplicitAddress and discard its secret key.

isImplicitAddress :: KindedAddress kind -> Maybe (kind :~: 'AddressKindImplicit) Source #

Checks if the provided KindedAddress is an implicit address and returns proof of the fact if it is.

type L1Address = ConstrainedAddress '['AddressKindImplicit, 'AddressKindContract] Source #

A convenience synonym for ConstrainedAddress allowing only implicit and contract addresses.

L1Address is named as such because in addition to implicit and contract addresses, Michelson's address type can contain txr1 addresses, identifying transaction rollups. While txr1 are technically also level-1 (level-2 being tx_rollup_l2_address, i.e. tz4), in practice it's a level-1 identifier for a bundle of level-2 operations. Hence, to keep type names concise, we use L1Address.

type L1AddressKind kind = ConstrainAddressKind '['AddressKindImplicit, 'AddressKindContract] kind Source #

Convenience synonym for ConstrainAddressKind allowing only implicit and contract addresses.

For a note on the naming convention, refer to L1Address.

class (CheckConstrainAddressKindError k (ConstrainAddressKindHelper ks k), ConstrainAddressKindHelper ks k ~ 'True) => ConstrainAddressKind ks k Source #

Constrain address kind to be one of the kinds in the list.

Instances

Instances details
(CheckConstrainAddressKindError k (ConstrainAddressKindHelper ks k), ConstrainAddressKindHelper ks k ~ 'True) => ConstrainAddressKind ks k Source # 
Instance details

Defined in Morley.Tezos.Address

SingI kinds => FromJSON (ConstrainedAddress kinds) Source # 
Instance details

Defined in Morley.Tezos.Address

type Address = Constrained NullConstraint KindedAddress Source #

Data type corresponding to address structure in Tezos.

type ConstrainedAddress (ks :: [AddressKind]) = Constrained (ConstrainAddressKind ks) KindedAddress Source #

An existential of KindedAddress constrained by its type argument.

data AnyParsableAddress Source #

A sum type for any known parsable address (tz1 - tz4, KT1, txr1)

data Constrained c f where Source #

Constructors

Constrained :: forall c f a. c a => f a -> Constrained c f 

Bundled Patterns

pattern MkConstrainedAddress :: forall ks. () => forall kind. ConstrainAddressKind ks kind => KindedAddress kind -> ConstrainedAddress ks

Deprecated: Use Constrained instead

pattern MkAddress :: KindedAddress kind -> Address

Constrained specialized to Address

Instances

Instances details
FromJSON Address Source # 
Instance details

Defined in Morley.Tezos.Address

FromJSONKey Address Source # 
Instance details

Defined in Morley.Tezos.Address

HasRPCRepr Address Source # 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC Address Source #

TypeHasDoc Address Source # 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Doc

IsoValue Address Source # 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Value

Associated Types

type ToT Address :: T Source #

(forall (a :: k). c a => Lift (f a)) => Lift (Constrained c f :: Type) Source # 
Instance details

Defined in Morley.Util.Constrained

Methods

lift :: Quote m => Constrained c f -> m Exp #

liftTyped :: forall (m :: Type -> Type). Quote m => Constrained c f -> Code m (Constrained c f) #

SingI kinds => FromJSON (ConstrainedAddress kinds) Source # 
Instance details

Defined in Morley.Tezos.Address

(forall (t :: T). cs t => HasNoOp t) => RenderDoc (SomeConstrainedValue cs) Source # 
Instance details

Defined in Morley.Michelson.Typed.Existential

ToJSON (Constrained c KindedAddress) Source # 
Instance details

Defined in Morley.Tezos.Address

ToJSONKey (Constrained c KindedAddress) Source # 
Instance details

Defined in Morley.Tezos.Address

(forall (a :: k). c a => Show (f a)) => Show (Constrained c f) Source # 
Instance details

Defined in Morley.Util.Constrained

Methods

showsPrec :: Int -> Constrained c f -> ShowS #

show :: Constrained c f -> String #

showList :: [Constrained c f] -> ShowS #

(forall (a :: k). c a => NFData (f a)) => NFData (Constrained c f) Source # 
Instance details

Defined in Morley.Util.Constrained

Methods

rnf :: Constrained c f -> () #

(forall (a :: k). c a => Buildable (f a)) => Buildable (Constrained c f) Source # 
Instance details

Defined in Morley.Util.Constrained

Methods

build :: Constrained c f -> Builder #

GEq f => Eq (Constrained c f) Source # 
Instance details

Defined in Morley.Util.Constrained

Methods

(==) :: Constrained c f -> Constrained c f -> Bool #

(/=) :: Constrained c f -> Constrained c f -> Bool #

GCompare f => Ord (Constrained c f) Source # 
Instance details

Defined in Morley.Util.Constrained

Methods

compare :: Constrained c f -> Constrained c f -> Ordering #

(<) :: Constrained c f -> Constrained c f -> Bool #

(<=) :: Constrained c f -> Constrained c f -> Bool #

(>) :: Constrained c f -> Constrained c f -> Bool #

(>=) :: Constrained c f -> Constrained c f -> Bool #

max :: Constrained c f -> Constrained c f -> Constrained c f #

min :: Constrained c f -> Constrained c f -> Constrained c f #

type AsRPC Address Source # 
Instance details

Defined in Morley.AsRPC

type TypeDocFieldDescriptions Address Source # 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Doc

type ToT Address Source # 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Value

newtype GlobalCounter Source #

Represents the network's global counter.

We store the current value of this counter in the operation at the time of its creation for the following reasons: * to guarantee the uniqueness of contract addresses upon origination (see 'Morley.Michelson.Typed.Operation.mkContractAddress) * to prevent replay attacks by checking that an operation with the same counter value con't be performed twice.

The counter is incremented after every operation execution and interpretation of instructions CREATE_CONTRACT and TRANSFER_TOKENS, and thus ensures that these addresses are unique (i.e. origination of identical contracts with identical metadata will result in different addresses.)

Our counter is represented as Word64, while in Tezos it is unbounded. We believe that for our interpreter it should not matter.

Constructors

GlobalCounter 

Instances

Instances details
FromJSON GlobalCounter Source # 
Instance details

Defined in Morley.Tezos.Address

ToJSON GlobalCounter Source # 
Instance details

Defined in Morley.Tezos.Address

Generic GlobalCounter Source # 
Instance details

Defined in Morley.Tezos.Address

Associated Types

type Rep GlobalCounter :: Type -> Type #

Num GlobalCounter Source # 
Instance details

Defined in Morley.Tezos.Address

Show GlobalCounter Source # 
Instance details

Defined in Morley.Tezos.Address

NFData GlobalCounter Source # 
Instance details

Defined in Morley.Tezos.Address

Methods

rnf :: GlobalCounter -> () #

Buildable GlobalCounter Source # 
Instance details

Defined in Morley.Tezos.Address

Eq GlobalCounter Source # 
Instance details

Defined in Morley.Tezos.Address

Hashable GlobalCounter Source # 
Instance details

Defined in Morley.Tezos.Address

type Rep GlobalCounter Source # 
Instance details

Defined in Morley.Tezos.Address

type Rep GlobalCounter = D1 ('MetaData "GlobalCounter" "Morley.Tezos.Address" "morley-1.19.0-inplace" 'True) (C1 ('MetaCons "GlobalCounter" 'PrefixI 'True) (S1 ('MetaSel ('Just "unGlobalCounter") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64)))

mkContractHashHack :: ByteString -> ContractHash Source #

Create a dummy ContractHash value by hashing given ByteString.

Use in tests **only**.

parseConstrainedAddress :: forall kinds. SingI kinds => Text -> Either ParseAddressError (ConstrainedAddress kinds) Source #

Parse an ConstrainedAddress of the given kinds from its human-readable textual representation. Maybe fail with a ParseAddressWrongKind in case the address parsed is of wrong kind.

parseAnyAddress :: Text -> Either ParseAddressError AnyParsableAddress Source #

Parse any kind of known address from it's human-readable textual representation, or fail if it's invalid.

Formatting

data ParseAddressError Source #

Errors that can happen during address parsing.

Constructors

ParseAddressCryptoError CryptoParseError

The address parsers failed with some error.

ParseAddressWrongKind [AddressKind] AnyParsableAddress

The parsed address is of wrong kind

Instances

Instances details
Generic ParseAddressError Source # 
Instance details

Defined in Morley.Tezos.Address

Associated Types

type Rep ParseAddressError :: Type -> Type #

Show ParseAddressError Source # 
Instance details

Defined in Morley.Tezos.Address

NFData ParseAddressError Source # 
Instance details

Defined in Morley.Tezos.Address

Methods

rnf :: ParseAddressError -> () #

Buildable ParseAddressError Source # 
Instance details

Defined in Morley.Tezos.Address

Eq ParseAddressError Source # 
Instance details

Defined in Morley.Tezos.Address

RenderDoc ParseAddressError Source # 
Instance details

Defined in Morley.Tezos.Address

type Rep ParseAddressError Source # 
Instance details

Defined in Morley.Tezos.Address

data ParseAddressRawError Source #

Constructors

ParseAddressRawWrongSize ByteString

Raw bytes representation of an address has invalid length.

ParseAddressRawInvalidPrefix Word8

Raw bytes representation of an address has incorrect prefix.

ParseAddressRawMalformedSeparator Word8

Raw bytes representation of an address does not end with "00".

ParseAddressRawBinaryError Text

General binary decoding error.

ParseAddressRawCryptoError CryptoParseError

Crypto error in parsing key hash.

Instances

Instances details
Generic ParseAddressRawError Source # 
Instance details

Defined in Morley.Tezos.Address

Associated Types

type Rep ParseAddressRawError :: Type -> Type #

Show ParseAddressRawError Source # 
Instance details

Defined in Morley.Tezos.Address

NFData ParseAddressRawError Source # 
Instance details

Defined in Morley.Tezos.Address

Methods

rnf :: ParseAddressRawError -> () #

Buildable ParseAddressRawError Source # 
Instance details

Defined in Morley.Tezos.Address

Eq ParseAddressRawError Source # 
Instance details

Defined in Morley.Tezos.Address

RenderDoc ParseAddressRawError Source # 
Instance details

Defined in Morley.Tezos.Address

type Rep ParseAddressRawError Source # 
Instance details

Defined in Morley.Tezos.Address

type Rep ParseAddressRawError = D1 ('MetaData "ParseAddressRawError" "Morley.Tezos.Address" "morley-1.19.0-inplace" 'False) ((C1 ('MetaCons "ParseAddressRawWrongSize" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ByteString)) :+: C1 ('MetaCons "ParseAddressRawInvalidPrefix" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Word8))) :+: (C1 ('MetaCons "ParseAddressRawMalformedSeparator" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Word8)) :+: (C1 ('MetaCons "ParseAddressRawBinaryError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text)) :+: C1 ('MetaCons "ParseAddressRawCryptoError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 CryptoParseError)))))

parseAddressRaw :: ByteString -> Either ParseAddressRawError Address Source #

Parse the given address in its raw byte form used by Tezos (e.g "01521139f84791537d54575df0c74a8084cc68861c00")) . Or fail otherwise if it's invalid.

parseKindedAddress :: forall kind. SingI kind => Text -> Either ParseAddressError (KindedAddress kind) Source #

Parse an address of a particular kind from its human-readable textual representation used by Tezos (e. g. "tz1faswCTDciRzE4oJ9jn2Vm2dvjeyA9fUzU"). Or fail if it's invalid.

parseAddress :: Text -> Either ParseAddressError Address Source #

Parse an address of arbitrary kind from its human-readable textual representation, or fail if it's invalid.

ta :: QuasiQuoter Source #

QuasiQuoter for constructing Tezos addresses.

Validity of result will be checked at compile time.

Utilities

addressKindSanity :: KindedAddress kind -> Dict (SingI kind) Source #

Given any (non-bottom) KindedAddress, prove that kind is well-defined (i.e. has a SingI instance)

usingImplicitOrContractKind :: forall kind a. L1AddressKind kind => a -> a Source #

A trick to avoid bogus redundant constraint warnings