Safe Haskell | None |
---|---|
Language | Haskell2010 |
Address in Tezos.
Synopsis
- newtype ContractHash = ContractHash ByteString
- data Address
- mkKeyAddress :: PublicKey -> Address
- detGenKeyAddress :: ByteString -> Address
- newtype OperationHash = OperationHash {}
- newtype OriginationIndex = OriginationIndex {}
- mkContractAddress :: OperationHash -> OriginationIndex -> Address
- mkContractHashHack :: ByteString -> ContractHash
- genAddress :: MonadGen m => m Address
- data ParseAddressError
- data ParseContractAddressError
- formatAddress :: Address -> Text
- mformatAddress :: Address -> MText
- parseAddress :: Text -> Either ParseAddressError 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 OperationHash Source #
Instances
newtype OriginationIndex Source #
Instances
mkContractAddress :: OperationHash -> OriginationIndex -> Address Source #
Compute address of a contract from its origination operation and origination index.
However, in real Tezos encoding of the operation is more than just OriginationOperation
.
There an Operation has several more meta-fields plus a big sum-type of all possible operations.
What is important is that one (big) Operation may lead to origination of multiple contracts. That is why contract address is constructed from hash of the operation that originated and of index of the contract's origination in the execution of that operation.
In other words, contract hash is calculated as the blake2b160 (20-byte) hash of origination operation hash + int32 origination index.
In Morley we do not yet support full encoding of Tezos Operations, therefore we choose to generate contract addresses in a simplified manner.
Namely, we encode OriginationOperation
as we can and concat it with the origination index.
Then we take blake2b160
hash of the resulting bytes and consider it to be the contract's
address.
mkContractHashHack :: ByteString -> ContractHash Source #
Create a dummy ContractHash
value by hashing given ByteString
.
Use in tests **only**.
genAddress :: MonadGen m => m Address Source #
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 ParseContractAddressError Source #
Instances
formatAddress :: Address -> Text Source #
mformatAddress :: Address -> MText Source #
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.
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 TK
contract address, fail if address does not match
the expected format.