| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Naming.Wire
Description
Wire-level data model and byte serialisation for the Singular naming
contract, transcribed exactly from the accepted epic-15 contract's
simulator/naming-wire.mjs and simulator/naming.mjs (v0.2.0, commit
13231f58833b8feb57f4b0f9b1117bfcfba0c07d, asset sha256
acbabdf54a271251bd73bf9d84ab2c901107045a7dd77d28a391f22cdd53b0e5).
The serialiser and parser mirror the reference function for function: same canonical heads, same refusals, same requirement to consume the whole input. Where this module and the reference disagree, the reference is right and this module is wrong.
Synopsis
- data WireData
- serialiseWireData :: WireData -> Maybe ByteString
- deserialiseWireData :: ByteString -> Maybe WireData
- data PaymentCredential
- data AddressForm
- data Address = Address {
- addressBytes :: ByteString
- addressForm :: AddressForm
- addressNetwork :: Int
- addressPaymentCredential :: PaymentCredential
- addressPaymentHash :: ByteString
- addressStakeCredential :: Maybe PaymentCredential
- addressStakeHash :: ByteString
- decodeAddress :: ByteString -> Maybe Address
- encodeAddress :: Address -> Maybe ByteString
- canonicalAddress :: Address -> Bool
- guardWire :: Bool -> Maybe ()
Documentation
Untyped PlutusData-shaped wire value: exactly the four shapes the
contract's serialiseWireData accepts.
Instances
| Show WireData Source # | |
Defined in Naming.Wire | |
| Eq WireData Source # | |
Defined in Naming.Wire | |
serialiseWireData :: WireData -> Maybe ByteString Source #
Serialise to the contract's byte form. constr(i, fields) becomes
D8 (79+i) 9F … FF with i < 7; byte strings are at most 64 bytes
with the canonical head (direct length below 24, otherwise 58 plus
one length byte); unsigned integers use the canonical unsigned head
(direct below 24, 18 below 256, 19 plus two bytes below 65536);
lists are indefinite (9F … FF). Nothing else serialises.
deserialiseWireData :: ByteString -> Maybe WireData Source #
Parse the contract's byte form back, refusing exactly what the
reference parser refuses: non-canonical heads (a 58 byte-string head
must carry 24..64 bytes, 18/19 integer heads must be the shortest
form), unsupported heads, and truncated input — the whole input must
be consumed.
data PaymentCredential Source #
Payment credential kind, as in the contract's naming.mjs.
Constructors
| PaymentKey | |
| ScriptCredential |
Instances
| Show PaymentCredential Source # | |
Defined in Naming.Wire Methods showsPrec :: Int -> PaymentCredential -> ShowS Source # show :: PaymentCredential -> String Source # showList :: [PaymentCredential] -> ShowS Source # | |
| Eq PaymentCredential Source # | |
Defined in Naming.Wire Methods (==) :: PaymentCredential -> PaymentCredential -> Bool Source # (/=) :: PaymentCredential -> PaymentCredential -> Bool Source # | |
data AddressForm Source #
Address form, as in the contract's naming.mjs.
Constructors
| EnterpriseForm | |
| BaseForm |
Instances
| Show AddressForm Source # | |
Defined in Naming.Wire Methods showsPrec :: Int -> AddressForm -> ShowS Source # show :: AddressForm -> String Source # showList :: [AddressForm] -> ShowS Source # | |
| Eq AddressForm Source # | |
Defined in Naming.Wire Methods (==) :: AddressForm -> AddressForm -> Bool Source # (/=) :: AddressForm -> AddressForm -> Bool Source # | |
A decoded Shelley-style address: the bytes plus the fields the
contract's decodeAddress recovers from the header byte.
Constructors
| Address | |
Fields
| |
Instances
| Show Address Source # | |
Defined in Naming.Wire | |
| Eq Address Source # | |
Defined in Naming.Wire | |
decodeAddress :: ByteString -> Maybe Address Source #
Exact mirror of the contract's decodeAddress: header byte kinds
6–7 are enterprise addresses (29 bytes), kinds 0–3 are base addresses
(57 bytes), everything else is refused.
encodeAddress :: Address -> Maybe ByteString Source #
Exact mirror of the contract's encodeAddress.
canonicalAddress :: Address -> Bool Source #
The contract's canonicalAddress: the bytes decode to the address
and the address encodes back to the same bytes.