Safe Haskell | None |
---|---|
Language | Haskell2010 |
Address in Tezos.
Synopsis
- newtype ContractHash = ContractHash ByteString
- data Address
- mkKeyAddress :: PublicKey -> Address
- detGenKeyAddress :: ByteString -> Address
- newtype OriginationIndex = OriginationIndex {}
- newtype GlobalCounter = GlobalCounter {}
- mkContractHashHack :: ByteString -> ContractHash
- data ParseAddressError
- data ParseAddressRawError
- data ParseContractAddressError
- formatAddress :: Address -> Text
- mformatAddress :: Address -> MText
- parseAddressRaw :: ByteString -> Either ParseAddressRawError Address
- parseContractHash :: Text -> Either ParseContractAddressError ContractHash
- parseAddress :: Text -> Either ParseAddressError Address
- ta :: QuasiQuoter
- unsafeParseAddressRaw :: ByteString -> Address
- unsafeParseAddress :: HasCallStack => Text -> Address
- unsafeParseContractHash :: HasCallStack => Text -> ContractHash
Documentation
newtype ContractHash Source #
Hash of origination command for some contract.
Instances
Data type corresponding to address structure in Tezos.
KeyAddress KeyHash |
|
ContractAddress ContractHash |
|
Instances
mkKeyAddress :: PublicKey -> Address Source #
Smart constructor for KeyAddress
.
detGenKeyAddress :: ByteString -> Address Source #
Deterministically generate a random KeyAddress
and discard its
secret key.
newtype OriginationIndex Source #
When a transfer operation triggers multiple CREATE_CONTRACT
instructions, using GlobalCounter
to compute those contracts' addresses
is not enough to ensure their uniqueness.
For that reason, we also keep track of an OriginationIndex
that starts out as 0
when a transfer is initiated, and is incremented every time a CREATE_CONTRACT
instruction is interpreted.
See mkContractAddress
.
Instances
newtype GlobalCounter Source #
Represents the network's global counter.
When a new contract is created (either via a "global" origination operation or
via a CREATE_CONTRACT
instruction), this counter is used to create a new address for it
(see mkContractAddress
).
The counter is incremented after every operation, and thus ensures that these addresses are unique (i.e. origination of identical contracts with identical metadata will result in different addresses.)
In Tezos each operation has a special field called counter
, see here:
https://gitlab.com/tezos/tezos/-/blob/397dd233a10cc6df0df959e2a624c7947997dd0c/src/proto_006_PsCARTHA/lib_protocol/operation_repr.ml#L113-120
This counter seems to be a part of global state of Tezos network. In fact, it may be observed in raw JSON representation of the operation in the network explorer.
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**.
Formatting
data ParseAddressError Source #
Errors that can happen during address parsing.
ParseAddressWrongBase58Check | Address is not in Base58Check format. |
ParseAddressBothFailed CryptoParseError ParseContractAddressError | Both address parsers failed with some error. |
Instances
data ParseAddressRawError Source #
ParseAddressRawWrongSize ByteString | Raw bytes representation of an address has invalid length. |
ParseAddressRawInvalidPrefix ByteString | Raw bytes representation of an address has incorrect prefix. |
ParseAddressRawMalformedSeparator ByteString | Raw bytes representation of an address does not end with "00". |
Instances
data ParseContractAddressError Source #
ParseContractAddressWrongBase58Check | |
ParseContractAddressWrongSize ByteString | |
ParseContractAddressWrongPrefix ByteString |
Instances
formatAddress :: Address -> Text Source #
mformatAddress :: Address -> 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.
parseAddress :: Text -> Either ParseAddressError Address Source #
Parse an address from its human-readable textual representation used by Tezos (e. g. "tz1faswCTDciRzE4oJ9jn2Vm2dvjeyA9fUzU"). Or fail if it's invalid.
ta :: QuasiQuoter Source #
QuasyQuoter for constructing Tezos addresses.
Validity of result will be checked at compile time.
unsafeParseAddressRaw :: ByteString -> Address Source #
Partially parse raw bytes representation of an address and assume that it is correct from the beginning. Can be used in tests.
unsafeParseAddress :: HasCallStack => Text -> Address Source #
Partial version of parseAddress
which assumes that the address
is correct. Can be used in tests.
unsafeParseContractHash :: HasCallStack => Text -> ContractHash Source #
Parse a KT1
contract address, fail if address does not match
the expected format.