Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Address in Tezos.
Synopsis
- type ContractHash = Hash 'HashKindContract
- data KindedAddress (kind :: AddressKind) where
- mkKeyAddress :: PublicKey -> ImplicitAddress
- detGenKeyAddress :: ByteString -> ImplicitAddress
- isImplicitAddress :: KindedAddress kind -> Maybe (kind :~: 'AddressKindImplicit)
- type ImplicitAddress = KindedAddress 'AddressKindImplicit
- type ContractAddress = KindedAddress 'AddressKindContract
- type SmartRollupAddress = KindedAddress 'AddressKindSmartRollup
- type L1Address = ConstrainedAddress '['AddressKindImplicit, 'AddressKindContract]
- type L1AddressKind = ConstrainAddressKind '['AddressKindImplicit, 'AddressKindContract]
- class (CheckConstrainAddressKindError k (ConstrainAddressKindHelper ks k), ConstrainAddressKindHelper ks k ~ 'True) => ConstrainAddressKind ks k
- type Address = Constrained NullConstraint KindedAddress
- type ConstrainedAddress (ks :: [AddressKind]) = Constrained (ConstrainAddressKind ks) KindedAddress
- data Constrained c f where
- Constrained :: forall c f a. c a => f a -> Constrained c f
- pattern MkAddress :: KindedAddress kind -> Address
- newtype GlobalCounter = GlobalCounter {}
- mkContractHashHack :: ByteString -> ContractHash
- parseConstrainedAddress :: forall kinds. SingI kinds => Text -> Either ParseAddressError (ConstrainedAddress kinds)
- data ParseAddressError
- data ParseAddressRawError
- formatAddress :: KindedAddress kind -> Text
- mformatAddress :: KindedAddress kind -> MText
- parseAddressRaw :: ByteString -> Either ParseAddressRawError Address
- parseKindedAddress :: forall kind. SingI kind => Text -> Either ParseAddressError (KindedAddress kind)
- parseAddress :: Text -> Either ParseAddressError Address
- ta :: QuasiQuoter
- addressKindSanity :: KindedAddress kind -> Dict (SingI kind)
- usingImplicitOrContractKind :: forall kind a. L1AddressKind kind => a -> a
- unImplicitAddress :: ImplicitAddress -> KeyHash
- addressKindTag :: AddressKind -> Word8
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
.
ImplicitAddress :: KeyHash -> KindedAddress 'AddressKindImplicit |
|
ContractAddress :: ContractHash -> KindedAddress 'AddressKindContract |
|
SmartRollupAddress :: SmartRollupHash -> KindedAddress 'AddressKindSmartRollup |
Instances
mkKeyAddress :: PublicKey -> ImplicitAddress Source #
Smart constructor for ImplicitAddress
.
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 ImplicitAddress = KindedAddress 'AddressKindImplicit Source #
A type only allowing ImplicitAddress
type ContractAddress = KindedAddress 'AddressKindContract Source #
A type only allowing ContractAddress
type SmartRollupAddress = KindedAddress 'AddressKindSmartRollup Source #
A type only allowing SmartRollupAddress
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
(CheckConstrainAddressKindError k (ConstrainAddressKindHelper ks k), ConstrainAddressKindHelper ks k ~ 'True) => ConstrainAddressKind ks k Source # | |
Defined in Morley.Tezos.Address | |
SingI kinds => FromJSON (ConstrainedAddress kinds) Source # | |
Defined in Morley.Tezos.Address parseJSON :: Value -> Parser (ConstrainedAddress kinds) # parseJSONList :: Value -> Parser [ConstrainedAddress kinds] # | |
SingI ks => HasCLReader (ConstrainedAddress ks) Source # | |
Defined in Morley.Tezos.Address getReader :: ReadM (ConstrainedAddress ks) Source # getMetavar :: String Source # |
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 #
Constrained :: forall c f a. c a => f a -> Constrained c f |
pattern MkAddress :: KindedAddress kind -> Address |
|
Instances
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.
Instances
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.
ParseAddressCryptoError CryptoParseError | The address parsers failed with some error. |
ParseAddressWrongKind [AddressKind] Address | The parsed address is of wrong kind |
Instances
data ParseAddressRawError Source #
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
formatAddress :: KindedAddress kind -> Text Source #
mformatAddress :: KindedAddress kind -> MText Source #
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
addressKindTag :: AddressKind -> Word8 Source #