morley-1.20.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.

SmartRollupAddress :: SmartRollupHash -> KindedAddress 'AddressKindSmartRollup 

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 #

HasCLReader Address Source # 
Instance details

Defined in Morley.Tezos.Address

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) #

(c 'AddressKindImplicit, c 'AddressKindContract, c 'AddressKindSmartRollup) => Has (c :: AddressKind -> Constraint) KindedAddress Source # 
Instance details

Defined in Morley.Tezos.Address

Methods

has :: forall (a :: k) r. KindedAddress a -> (c a => r) -> r #

argDict :: forall (a :: k). 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 -> () #

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 ks => HasCLReader (ConstrainedAddress ks) Source # 
Instance details

Defined in Morley.Tezos.Address

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

Defined in Morley.Tezos.Address

Buildable (KindedAddress kind) Source # 
Instance details

Defined in Morley.Tezos.Address

Methods

build :: KindedAddress kind -> Doc

buildList :: [KindedAddress kind] -> Doc

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

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 or sr1 addresses, identifying respectively transaction rollups and smart rollups. While they are technically also level-1 (level-2 being tx_rollup_l2_address), in practice It's level-1 identifiers for bundles of level-2 operations. Hence, to keep type names concise, we use L1Address.

type L1AddressKind = ConstrainAddressKind '['AddressKindImplicit, 'AddressKindContract] 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

SingI ks => HasCLReader (ConstrainedAddress ks) 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 Constrained c f where Source #

Constructors

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

Bundled Patterns

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 #

HasCLReader Address Source # 
Instance details

Defined in Morley.Tezos.Address

(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 => ForbidOp t) => RenderDoc (SomeConstrainedValue cs) Source # 
Instance details

Defined in Morley.Michelson.Typed.Existential

SingI ks => HasCLReader (ConstrainedAddress ks) 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

(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 -> () #

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 #

(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 -> Doc

buildList :: [Constrained c f] -> Doc

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 -> () #

Eq GlobalCounter Source # 
Instance details

Defined in Morley.Tezos.Address

Hashable GlobalCounter Source # 
Instance details

Defined in Morley.Tezos.Address

Buildable GlobalCounter Source # 
Instance details

Defined in Morley.Tezos.Address

Methods

build :: GlobalCounter -> Doc

buildList :: [GlobalCounter] -> Doc

type Rep GlobalCounter Source # 
Instance details

Defined in Morley.Tezos.Address

type Rep GlobalCounter = D1 ('MetaData "GlobalCounter" "Morley.Tezos.Address" "morley-1.20.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.

Formatting

data ParseAddressError Source #

Errors that can happen during address parsing.

Constructors

ParseAddressCryptoError CryptoParseError

The address parsers failed with some error.

ParseAddressWrongKind [AddressKind] Address

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 -> () #

Eq ParseAddressError Source # 
Instance details

Defined in Morley.Tezos.Address

Buildable 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.

ParseAddressRawUnsupportedPrefix Text Word8

Unsupported address type.

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 -> () #

Eq ParseAddressRawError Source # 
Instance details

Defined in Morley.Tezos.Address

Buildable ParseAddressRawError Source # 
Instance details

Defined in Morley.Tezos.Address

type Rep ParseAddressRawError Source # 
Instance details

Defined in Morley.Tezos.Address

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