singular-registry
Safe HaskellNone
LanguageGHC2021

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

Documentation

data WireData Source #

Untyped PlutusData-shaped wire value: exactly the four shapes the contract's serialiseWireData accepts.

Constructors

Constr Int [WireData] 
WBytes ByteString 
WInt Integer 
WList [WireData] 

Instances

Instances details
Show WireData Source # 
Instance details

Defined in Naming.Wire

Methods

showsPrec :: Int -> WireData -> ShowS Source #

show :: WireData -> String Source #

showList :: [WireData] -> ShowS Source #

Eq WireData Source # 
Instance details

Defined in Naming.Wire

Methods

(==) :: WireData -> WireData -> Bool Source #

(/=) :: WireData -> WireData -> Bool Source #

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.

Instances

Instances details
Show PaymentCredential Source # 
Instance details

Defined in Naming.Wire

Methods

showsPrec :: Int -> PaymentCredential -> ShowS Source #

show :: PaymentCredential -> String Source #

showList :: [PaymentCredential] -> ShowS Source #

Eq PaymentCredential Source # 
Instance details

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

Instances details
Show AddressForm Source # 
Instance details

Defined in Naming.Wire

Methods

showsPrec :: Int -> AddressForm -> ShowS Source #

show :: AddressForm -> String Source #

showList :: [AddressForm] -> ShowS Source #

Eq AddressForm Source # 
Instance details

Defined in Naming.Wire

Methods

(==) :: AddressForm -> AddressForm -> Bool Source #

(/=) :: AddressForm -> AddressForm -> Bool Source #

data Address Source #

A decoded Shelley-style address: the bytes plus the fields the contract's decodeAddress recovers from the header byte.

Instances

Instances details
Show Address Source # 
Instance details

Defined in Naming.Wire

Methods

showsPrec :: Int -> Address -> ShowS Source #

show :: Address -> String Source #

showList :: [Address] -> ShowS Source #

Eq Address Source # 
Instance details

Defined in Naming.Wire

Methods

(==) :: Address -> Address -> Bool Source #

(/=) :: Address -> Address -> Bool Source #

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.

guardWire :: Bool -> Maybe () Source #

Maybe-flavoured guard, the analogue of the reference's repeated === null refusals.