Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Address in Tezos.
Synopsis
- type ContractHash = Hash 'HashKindContract
- data KindedAddress (kind :: AddressKind) where
- newtype TxRollupL2Address = TxRollupL2Address KeyHashL2
- mkKeyAddress :: PublicKey -> ImplicitAddress
- detGenKeyAddress :: ByteString -> ImplicitAddress
- isImplicitAddress :: KindedAddress kind -> Maybe (kind :~: 'AddressKindImplicit)
- type ImplicitAddress = KindedAddress 'AddressKindImplicit
- type ContractAddress = KindedAddress 'AddressKindContract
- type TxRollupAddress = KindedAddress 'AddressKindTxRollup
- type L1Address = ConstrainedAddress '['AddressKindImplicit, 'AddressKindContract]
- type L1AddressKind kind = ConstrainAddressKind '['AddressKindImplicit, 'AddressKindContract] kind
- 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 AnyParsableAddress
- data Constrained c f where
- Constrained :: forall c f a. c a => f a -> Constrained c f
- pattern MkConstrainedAddress :: forall ks. () => forall kind. ConstrainAddressKind ks kind => KindedAddress kind -> ConstrainedAddress ks
- pattern MkAddress :: KindedAddress kind -> Address
- newtype GlobalCounter = GlobalCounter {}
- mkContractHashHack :: ByteString -> ContractHash
- parseConstrainedAddress :: forall kinds. SingI kinds => Text -> Either ParseAddressError (ConstrainedAddress kinds)
- parseAnyAddress :: Text -> Either ParseAddressError AnyParsableAddress
- 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
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 |
|
TxRollupAddress :: TxRollupHash -> KindedAddress 'AddressKindTxRollup |
|
Instances
newtype TxRollupL2Address Source #
tz4
level-2 public key hash address, used with transaction rollups, corresponds
to tx_rollup_l2_address
Michelson type.
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 TxRollupAddress = KindedAddress 'AddressKindTxRollup Source #
A type only allowing TxRollupAddress
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
(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] # |
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
)
Instances
data Constrained c f where Source #
Constrained :: forall c f a. c a => f a -> Constrained c f |
pattern MkConstrainedAddress :: forall ks. () => forall kind. ConstrainAddressKind ks kind => KindedAddress kind -> ConstrainedAddress ks | Deprecated: Use Constrained instead |
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.
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.
ParseAddressCryptoError CryptoParseError | The address parsers failed with some error. |
ParseAddressWrongKind [AddressKind] AnyParsableAddress | 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. |
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