{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Test.Cardano.Ledger.Core.Binary.CDDL (
hash28,
hash32,
positive_int,
max_word32,
positive_word32,
unit_interval,
nonnegative_interval,
distinct,
untagged_set,
untagged_nonempty_set,
nonce,
epoch,
epoch_interval,
slot,
block_number,
credential,
stake_credential,
port,
ipv4,
ipv6,
dns_name64,
url64,
single_host_addr,
mkPoolRules,
addr_keyhash,
pool_keyhash,
vrf_keyhash,
vkey,
vrf_vkey,
vrf_cert,
kes_vkey,
kes_signature,
signkey_kes,
signature,
sequence_number,
kes_period,
coin,
positive_coin,
address,
reward_account,
transaction_index,
metadatum_label,
metadatum,
metadata,
auxiliary_data_hash,
script_hash,
mkScriptPubkey,
mkScriptAll,
mkScriptAny,
mkScriptNOfK,
mkScriptInvalidBefore,
mkScriptInvalidHereafter,
) where
import Codec.CBOR.Cuddle.Huddle
import Data.Function (($))
import Data.Semigroup ((<>))
import qualified Data.Text as T
import Data.Word (Word64)
import GHC.Base (error)
import GHC.Show (Show (show))
import Text.Heredoc
import Prelude (Integer)
coin :: Rule
coin :: Rule
coin = Text
"coin" Text -> Value Int -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= Value Int
VUInt
positive_coin :: Rule
positive_coin :: Rule
positive_coin = Text
"positive_coin" Text -> Ranged -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= (Integer
1 :: Integer) Integer -> Rule -> Ranged
forall a b. (IsRangeBound a, IsRangeBound b) => a -> b -> Ranged
... Rule
max_word64
address :: Rule
address :: Rule
address =
Text -> Rule -> Rule
forall a. HasField' "description" a (Maybe Text) => Text -> a -> a
comment
Text
[str|address = bytes
|
|address format:
| [ 8 bit header | payload ];
|
|shelley payment addresses:
| bit 7: 0
| bit 6: base/other
| bit 5: pointer/enterprise [for base: stake cred is keyhash/scripthash]
| bit 4: payment cred is keyhash/scripthash
| bits 3-0: network id
|
|reward addresses:
| bits 7-5: 111
| bit 4: credential is keyhash/scripthash
| bits 3-0: network id
|
|byron addresses:
| bits 7-4: 1000
|
| 0000: base address: keyhash28,keyhash28
| 0001: base address: scripthash28,keyhash28
| 0010: base address: keyhash28,scripthash28
| 0011: base address: scripthash28,scripthash28
| 0100: pointer address: keyhash28, 3 variable length uint
| 0101: pointer address: scripthash28, 3 variable length uint
| 0110: enterprise address: keyhash28
| 0111: enterprise address: scripthash28
| 1000: byron address
| 1110: reward account: keyhash28
| 1111: reward account: scripthash28
|1001-1101: future formats
|]
(Rule -> Rule) -> Rule -> Rule
forall a b. (a -> b) -> a -> b
$ Text
"address"
Text -> Choice Type2 -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= ByteString -> Literal
bstr
ByteString
"001000000000000000000000000000000000000000000000000000000011000000000000000000000000000000000000000000000000000000"
Literal -> Literal -> Choice Type2
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ByteString -> Literal
bstr
ByteString
"102000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000"
Choice Type2 -> Literal -> Choice Type2
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ByteString -> Literal
bstr
ByteString
"203000000000000000000000000000000000000000000000000000000033000000000000000000000000000000000000000000000000000000"
Choice Type2 -> Literal -> Choice Type2
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ByteString -> Literal
bstr
ByteString
"304000000000000000000000000000000000000000000000000000000044000000000000000000000000000000000000000000000000000000"
Choice Type2 -> Literal -> Choice Type2
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ByteString -> Literal
bstr ByteString
"405000000000000000000000000000000000000000000000000000000087680203"
Choice Type2 -> Literal -> Choice Type2
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ByteString -> Literal
bstr ByteString
"506000000000000000000000000000000000000000000000000000000087680203"
Choice Type2 -> Literal -> Choice Type2
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ByteString -> Literal
bstr ByteString
"6070000000000000000000000000000000000000000000000000000000"
Choice Type2 -> Literal -> Choice Type2
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ByteString -> Literal
bstr ByteString
"7080000000000000000000000000000000000000000000000000000000"
reward_account :: Rule
reward_account :: Rule
reward_account =
Text -> Rule -> Rule
forall a. HasField' "description" a (Maybe Text) => Text -> a -> a
comment
Text
[str|reward_account = bytes
|]
(Rule -> Rule) -> Rule -> Rule
forall a b. (a -> b) -> a -> b
$ Text
"reward_account"
Text -> Choice Type2 -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= ByteString -> Literal
bstr ByteString
"E090000000000000000000000000000000000000000000000000000000"
Literal -> Literal -> Choice Type2
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ByteString -> Literal
bstr ByteString
"F0A0000000000000000000000000000000000000000000000000000000"
addr_keyhash :: Rule
addr_keyhash :: Rule
addr_keyhash = Text
"addr_keyhash" Text -> Rule -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= Rule
hash28
pool_keyhash :: Rule
pool_keyhash :: Rule
pool_keyhash = Text
"pool_keyhash" Text -> Rule -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= Rule
hash28
vrf_keyhash :: Rule
vrf_keyhash :: Rule
vrf_keyhash = Text
"vrf_keyhash" Text -> Rule -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= Rule
hash32
mkHashSized :: Word64 -> Rule
mkHashSized :: Word64 -> Rule
mkHashSized Word64
size = Text
"hash" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack (Word64 -> String
forall a. Show a => a -> String
show Word64
size) Text -> Constrained -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= Value ByteString
VBytes Value ByteString -> Word64 -> Constrained
forall c a s.
(IsSizeable a, IsSize s, IsConstrainable c a) =>
c -> s -> Constrained
`sized` Word64
size
hash28 :: Rule
hash28 :: Rule
hash28 = Word64 -> Rule
mkHashSized Word64
28
hash32 :: Rule
hash32 :: Rule
hash32 = Word64 -> Rule
mkHashSized Word64
32
vkey :: Rule
vkey :: Rule
vkey = Text
"vkey" Text -> Constrained -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= Value ByteString
VBytes Value ByteString -> Word64 -> Constrained
forall c a s.
(IsSizeable a, IsSize s, IsConstrainable c a) =>
c -> s -> Constrained
`sized` (Word64
32 :: Word64)
vrf_vkey :: Rule
vrf_vkey :: Rule
vrf_vkey = Text
"vrf_vkey" Text -> Constrained -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= Value ByteString
VBytes Value ByteString -> Word64 -> Constrained
forall c a s.
(IsSizeable a, IsSize s, IsConstrainable c a) =>
c -> s -> Constrained
`sized` (Word64
32 :: Word64)
vrf_cert :: Rule
vrf_cert :: Rule
vrf_cert = Text
"vrf_cert" Text -> ArrayChoice -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr [Value ByteString -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Value ByteString
VBytes, Constrained -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a (Value ByteString
VBytes Value ByteString -> Word64 -> Constrained
forall c a s.
(IsSizeable a, IsSize s, IsConstrainable c a) =>
c -> s -> Constrained
`sized` (Word64
80 :: Word64))]
kes_vkey :: Rule
kes_vkey :: Rule
kes_vkey = Text
"kes_vkey" Text -> Constrained -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= Value ByteString
VBytes Value ByteString -> Word64 -> Constrained
forall c a s.
(IsSizeable a, IsSize s, IsConstrainable c a) =>
c -> s -> Constrained
`sized` (Word64
32 :: Word64)
kes_signature :: Rule
kes_signature :: Rule
kes_signature = Text
"kes_signature" Text -> Constrained -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= Value ByteString
VBytes Value ByteString -> Word64 -> Constrained
forall c a s.
(IsSizeable a, IsSize s, IsConstrainable c a) =>
c -> s -> Constrained
`sized` (Word64
448 :: Word64)
signkey_kes :: Rule
signkey_kes :: Rule
signkey_kes = Text
"signkey_kes" Text -> Constrained -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= Value ByteString
VBytes Value ByteString -> Word64 -> Constrained
forall c a s.
(IsSizeable a, IsSize s, IsConstrainable c a) =>
c -> s -> Constrained
`sized` (Word64
64 :: Word64)
signature :: Rule
signature :: Rule
signature = Text
"signature" Text -> Constrained -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= Value ByteString
VBytes Value ByteString -> Word64 -> Constrained
forall c a s.
(IsSizeable a, IsSize s, IsConstrainable c a) =>
c -> s -> Constrained
`sized` (Word64
64 :: Word64)
sequence_number :: Rule
sequence_number :: Rule
sequence_number = Text
"sequence_number" Text -> Constrained -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= Value Int
VUInt Value Int -> Word64 -> Constrained
forall c a s.
(IsSizeable a, IsSize s, IsConstrainable c a) =>
c -> s -> Constrained
`sized` (Word64
8 :: Word64)
kes_period :: Rule
kes_period :: Rule
kes_period = Text
"kes_period" Text -> Constrained -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= Value Int
VUInt Value Int -> Word64 -> Constrained
forall c a s.
(IsSizeable a, IsSize s, IsConstrainable c a) =>
c -> s -> Constrained
`sized` (Word64
8 :: Word64)
max_word64 :: Rule
max_word64 :: Rule
max_word64 = Text
"max_word64" Text -> Integer -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= (Integer
18446744073709551615 :: Integer)
positive_int :: Rule
positive_int :: Rule
positive_int = Text
"positive_int" Text -> Ranged -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= (Integer
1 :: Integer) Integer -> Rule -> Ranged
forall a b. (IsRangeBound a, IsRangeBound b) => a -> b -> Ranged
... Rule
max_word64
max_word32 :: Rule
max_word32 :: Rule
max_word32 = Text
"max_word32" Text -> Integer -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= (Integer
4294967295 :: Integer)
positive_word32 :: Rule
positive_word32 :: Rule
positive_word32 = Text
"positive_word32" Text -> Ranged -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= (Integer
1 :: Integer) Integer -> Rule -> Ranged
forall a b. (IsRangeBound a, IsRangeBound b) => a -> b -> Ranged
... Rule
max_word32
unit_interval :: Rule
unit_interval :: Rule
unit_interval =
Text -> Rule -> Rule
forall a. HasField' "description" a (Maybe Text) => Text -> a -> a
comment
Text
[str|The real unit_interval is: #6.30([uint, uint])
|
|A unit interval is a number in the range between 0 and 1, which
|means there are two extra constraints:
| 1. numerator <= denominator
| 2. denominator > 0
|
|The relation between numerator and denominator can be
|expressed in CDDL, but we have a limitation currently
|(see: https://github.com/input-output-hk/cuddle/issues/30)
|which poses a problem for testing. We need to be able to
|generate random valid data for testing implementation of
|our encoders/decoders. Which means we cannot use the actual
|definition here and we hard code the value to 1/2
|]
(Rule -> Rule) -> Rule -> Rule
forall a b. (a -> b) -> a -> b
$ Text
"unit_interval" Text -> Tagged ArrayChoice -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= Word64 -> ArrayChoice -> Tagged ArrayChoice
forall a. Word64 -> a -> Tagged a
tag Word64
30 (ArrayChoice -> ArrayChoice
arr [Item ArrayChoice
ArrayEntry
1, Item ArrayChoice
ArrayEntry
2])
nonnegative_interval :: Rule
nonnegative_interval :: Rule
nonnegative_interval = Text
"nonnegative_interval" Text -> Tagged ArrayChoice -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= Word64 -> ArrayChoice -> Tagged ArrayChoice
forall a. Word64 -> a -> Tagged a
tag Word64
30 (ArrayChoice -> ArrayChoice
arr [Value Int -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Value Int
VUInt, Rule -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
positive_int])
distinct :: IsSizeable s => Value s -> Rule
distinct :: forall s. IsSizeable s => Value s -> Rule
distinct Value s
x =
Text -> Rule -> Rule
forall a. HasField' "description" a (Maybe Text) => Text -> a -> a
comment
Text
[str|A type for distinct values.
|The type parameter must support .size, for example: bytes or uint
|]
(Rule -> Rule) -> Rule -> Rule
forall a b. (a -> b) -> a -> b
$ Text
"distinct_"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Value s -> Text
forall s. Value s -> Text
show' Value s
x
Text -> Choice Type2 -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= (Value s
x Value s -> Word64 -> Constrained
forall c a s.
(IsSizeable a, IsSize s, IsConstrainable c a) =>
c -> s -> Constrained
`sized` (Word64
8 :: Word64))
Constrained -> Constrained -> Choice Type2
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ (Value s
x Value s -> Word64 -> Constrained
forall c a s.
(IsSizeable a, IsSize s, IsConstrainable c a) =>
c -> s -> Constrained
`sized` (Word64
16 :: Word64))
Choice Type2 -> Constrained -> Choice Type2
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ (Value s
x Value s -> Word64 -> Constrained
forall c a s.
(IsSizeable a, IsSize s, IsConstrainable c a) =>
c -> s -> Constrained
`sized` (Word64
20 :: Word64))
Choice Type2 -> Constrained -> Choice Type2
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ (Value s
x Value s -> Word64 -> Constrained
forall c a s.
(IsSizeable a, IsSize s, IsConstrainable c a) =>
c -> s -> Constrained
`sized` (Word64
24 :: Word64))
Choice Type2 -> Constrained -> Choice Type2
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ (Value s
x Value s -> Word64 -> Constrained
forall c a s.
(IsSizeable a, IsSize s, IsConstrainable c a) =>
c -> s -> Constrained
`sized` (Word64
30 :: Word64))
Choice Type2 -> Constrained -> Choice Type2
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ (Value s
x Value s -> Word64 -> Constrained
forall c a s.
(IsSizeable a, IsSize s, IsConstrainable c a) =>
c -> s -> Constrained
`sized` (Word64
32 :: Word64))
where
show' :: Value s -> T.Text
show' :: forall s. Value s -> Text
show' = \case
Value s
VBytes -> String -> Text
T.pack String
"bytes"
Value s
VUInt -> String -> Text
T.pack String
"uint"
Value s
_ -> String -> Text
forall a. HasCallStack => String -> a
error String
"Unsupported Value for `distinct`"
untagged_set :: IsType0 a => a -> GRuleCall
untagged_set :: forall a. IsType0 a => a -> GRuleCall
untagged_set = (GRef -> Rule) -> a -> GRuleCall
forall t0. IsType0 t0 => (GRef -> Rule) -> t0 -> GRuleCall
binding ((GRef -> Rule) -> a -> GRuleCall)
-> (GRef -> Rule) -> a -> GRuleCall
forall a b. (a -> b) -> a -> b
$ \GRef
x -> Text
"set" Text -> ArrayChoice -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr [Word64
0 Word64 -> ArrayEntry -> ArrayEntry
forall a. CanQuantify a => Word64 -> a -> a
<+ GRef -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a GRef
x]
untagged_nonempty_set :: IsType0 a => a -> GRuleCall
untagged_nonempty_set :: forall a. IsType0 a => a -> GRuleCall
untagged_nonempty_set = (GRef -> Rule) -> a -> GRuleCall
forall t0. IsType0 t0 => (GRef -> Rule) -> t0 -> GRuleCall
binding ((GRef -> Rule) -> a -> GRuleCall)
-> (GRef -> Rule) -> a -> GRuleCall
forall a b. (a -> b) -> a -> b
$ \GRef
x -> Text
"nonempty_set" Text -> ArrayChoice -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr [Word64
1 Word64 -> ArrayEntry -> ArrayEntry
forall a. CanQuantify a => Word64 -> a -> a
<+ GRef -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a GRef
x]
mkTaggedSet :: IsType0 a => T.Text -> Word64 -> a -> GRuleCall
mkTaggedSet :: forall a. IsType0 a => Text -> Word64 -> a -> GRuleCall
mkTaggedSet Text
label Word64
n = (GRef -> Rule) -> a -> GRuleCall
forall t0. IsType0 t0 => (GRef -> Rule) -> t0 -> GRuleCall
binding ((GRef -> Rule) -> a -> GRuleCall)
-> (GRef -> Rule) -> a -> GRuleCall
forall a b. (a -> b) -> a -> b
$ \GRef
x -> Text
label Text -> Tagged ArrayChoice -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= Word64 -> ArrayChoice -> Tagged ArrayChoice
forall a. Word64 -> a -> Tagged a
tag Word64
258 (ArrayChoice -> ArrayChoice
arr [Word64
n Word64 -> ArrayEntry -> ArrayEntry
forall a. CanQuantify a => Word64 -> a -> a
<+ GRef -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a GRef
x])
_tagged_set :: IsType0 a => a -> GRuleCall
_tagged_set :: forall a. IsType0 a => a -> GRuleCall
_tagged_set = Text -> Word64 -> a -> GRuleCall
forall a. IsType0 a => Text -> Word64 -> a -> GRuleCall
mkTaggedSet Text
"set" Word64
0
_tagged_nonempty_set :: IsType0 a => a -> GRuleCall
_tagged_nonempty_set :: forall a. IsType0 a => a -> GRuleCall
_tagged_nonempty_set = Text -> Word64 -> a -> GRuleCall
forall a. IsType0 a => Text -> Word64 -> a -> GRuleCall
mkTaggedSet Text
"nonempty_set" Word64
1
_tagged_oset :: IsType0 a => a -> GRuleCall
_tagged_oset :: forall a. IsType0 a => a -> GRuleCall
_tagged_oset = Text -> Word64 -> a -> GRuleCall
forall a. IsType0 a => Text -> Word64 -> a -> GRuleCall
mkTaggedSet Text
"oset" Word64
0
_tagged_nonempty_oset :: IsType0 a => a -> GRuleCall
_tagged_nonempty_oset :: forall a. IsType0 a => a -> GRuleCall
_tagged_nonempty_oset = Text -> Word64 -> a -> GRuleCall
forall a. IsType0 a => Text -> Word64 -> a -> GRuleCall
mkTaggedSet Text
"nonempty_oset" Word64
1
nonce :: Rule
nonce :: Rule
nonce = Text
"nonce" Text -> Array -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr [Item ArrayChoice
ArrayEntry
0] ArrayChoice -> ArrayChoice -> Array
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [Item ArrayChoice
ArrayEntry
1, Rule -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
hash32]
epoch :: Rule
epoch :: Rule
epoch = Text
"epoch" Text -> Constrained -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= Value Int
VUInt Value Int -> Word64 -> Constrained
forall c a s.
(IsSizeable a, IsSize s, IsConstrainable c a) =>
c -> s -> Constrained
`sized` (Word64
8 :: Word64)
epoch_interval :: Rule
epoch_interval :: Rule
epoch_interval = Text
"epoch_interval" Text -> Constrained -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= Value Int
VUInt Value Int -> Word64 -> Constrained
forall c a s.
(IsSizeable a, IsSize s, IsConstrainable c a) =>
c -> s -> Constrained
`sized` (Word64
4 :: Word64)
slot :: Rule
slot :: Rule
slot = Text
"slot" Text -> Constrained -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= Value Int
VUInt Value Int -> Word64 -> Constrained
forall c a s.
(IsSizeable a, IsSize s, IsConstrainable c a) =>
c -> s -> Constrained
`sized` (Word64
8 :: Word64)
block_number :: Rule
block_number :: Rule
block_number = Text
"block_number" Text -> Constrained -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= Value Int
VUInt Value Int -> Word64 -> Constrained
forall c a s.
(IsSizeable a, IsSize s, IsConstrainable c a) =>
c -> s -> Constrained
`sized` (Word64
8 :: Word64)
transaction_index :: Rule
transaction_index :: Rule
transaction_index = Text
"transaction_index" Text -> Constrained -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= Value Int
VUInt Value Int -> Word64 -> Constrained
forall c a s.
(IsSizeable a, IsSize s, IsConstrainable c a) =>
c -> s -> Constrained
`sized` (Word64
2 :: Word64)
metadatum_label :: Rule
metadatum_label :: Rule
metadatum_label = Text
"metadatum_label" Text -> Constrained -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= Value Int
VUInt Value Int -> Word64 -> Constrained
forall c a s.
(IsSizeable a, IsSize s, IsConstrainable c a) =>
c -> s -> Constrained
`sized` (Word64
8 :: Word64)
metadatum :: Rule
metadatum :: Rule
metadatum =
Text
"metadatum"
Text -> Choice Type2 -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= MapChoice -> Seal Map
smp [Word64
0 Word64 -> MapEntry -> MapEntry
forall a. CanQuantify a => Word64 -> a -> a
<+ Rule -> Key
forall r. IsType0 r => r -> Key
asKey Rule
metadatum Key -> Rule -> MapEntry
forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
metadatum]
Seal Map -> Seal Array -> Choice Type2
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> Seal Array
sarr [Word64
0 Word64 -> ArrayEntry -> ArrayEntry
forall a. CanQuantify a => Word64 -> a -> a
<+ Rule -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
metadatum]
Choice Type2 -> Value Int -> Choice Type2
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Value Int
VInt
Choice Type2 -> Constrained -> Choice Type2
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ (Value ByteString
VBytes Value ByteString -> (Word64, Word64) -> Constrained
forall c a s.
(IsSizeable a, IsSize s, IsConstrainable c a) =>
c -> s -> Constrained
`sized` (Word64
0 :: Word64, Word64
64 :: Word64))
Choice Type2 -> Constrained -> Choice Type2
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ (Value Text
VText Value Text -> (Word64, Word64) -> Constrained
forall c a s.
(IsSizeable a, IsSize s, IsConstrainable c a) =>
c -> s -> Constrained
`sized` (Word64
0 :: Word64, Word64
64 :: Word64))
metadata :: Rule
metadata :: Rule
metadata = Text
"metadata" Text -> MapChoice -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= MapChoice -> MapChoice
mp [Word64
0 Word64 -> MapEntry -> MapEntry
forall a. CanQuantify a => Word64 -> a -> a
<+ Rule -> Key
forall r. IsType0 r => r -> Key
asKey Rule
metadatum_label Key -> Rule -> MapEntry
forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
metadatum]
auxiliary_data_hash :: Rule
auxiliary_data_hash :: Rule
auxiliary_data_hash = Text
"auxiliary_data_hash" Text -> Rule -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= Rule
hash32
script_hash :: Rule
script_hash :: Rule
script_hash =
Text -> Rule -> Rule
forall a. HasField' "description" a (Maybe Text) => Text -> a -> a
comment
Text
[str|To compute a script hash, note that you must prepend
|a tag to the bytes of the script before hashing.
|The tag is determined by the language.
|The tags are:
| "\x00" for multisig/native scripts
| "\x01" for Plutus V1 scripts
| "\x02" for Plutus V2 scripts
| "\x03" for Plutus V3 scripts
| "\x04" for Plutus V4 scripts
|]
(Rule -> Rule) -> Rule -> Rule
forall a b. (a -> b) -> a -> b
$ Text
"script_hash" Text -> Rule -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= Rule
hash28
mkScriptPubkey :: Named Group
mkScriptPubkey :: Named Group
mkScriptPubkey = Text
"script_pubkey" Text -> Group -> Named Group
=:~ Group -> Group
grp [Item Group
ArrayEntry
0, Rule -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
addr_keyhash]
mkScriptAll :: IsType0 script => script -> Named Group
mkScriptAll :: forall script. IsType0 script => script -> Named Group
mkScriptAll script
s = Text
"script_all" Text -> Group -> Named Group
=:~ Group -> Group
grp [Item Group
ArrayEntry
1, ArrayChoice -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a (ArrayChoice -> ArrayChoice
arr [Word64
0 Word64 -> ArrayEntry -> ArrayEntry
forall a. CanQuantify a => Word64 -> a -> a
<+ script -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a script
s])]
mkScriptAny :: IsType0 script => script -> Named Group
mkScriptAny :: forall script. IsType0 script => script -> Named Group
mkScriptAny script
s = Text
"script_any" Text -> Group -> Named Group
=:~ Group -> Group
grp [Item Group
ArrayEntry
2, ArrayChoice -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a (ArrayChoice -> ArrayChoice
arr [Word64
0 Word64 -> ArrayEntry -> ArrayEntry
forall a. CanQuantify a => Word64 -> a -> a
<+ script -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a script
s])]
mkScriptNOfK :: (IsType0 threshold, IsType0 script) => threshold -> script -> Named Group
mkScriptNOfK :: forall threshold script.
(IsType0 threshold, IsType0 script) =>
threshold -> script -> Named Group
mkScriptNOfK threshold
threshold script
s =
Text
"script_n_of_k" Text -> Group -> Named Group
=:~ Group -> Group
grp [Item Group
ArrayEntry
3, Key
"n" Key -> threshold -> ArrayEntry
forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> threshold
threshold, ArrayChoice -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a (ArrayChoice -> ArrayChoice
arr [Word64
0 Word64 -> ArrayEntry -> ArrayEntry
forall a. CanQuantify a => Word64 -> a -> a
<+ script -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a script
s])]
mkScriptInvalidBefore :: Named Group
mkScriptInvalidBefore :: Named Group
mkScriptInvalidBefore =
Text -> Named Group -> Named Group
forall a. HasField' "description" a (Maybe Text) => Text -> a -> a
comment
Text
[str|Timelock validity intervals are half-open intervals [a, b).
|This field specifies the left (included) endpoint a.
|]
(Named Group -> Named Group) -> Named Group -> Named Group
forall a b. (a -> b) -> a -> b
$ Text
"script_invalid_before" Text -> Group -> Named Group
=:~ Group -> Group
grp [Item Group
ArrayEntry
4, Rule -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
slot]
mkScriptInvalidHereafter :: Named Group
mkScriptInvalidHereafter :: Named Group
mkScriptInvalidHereafter =
Text -> Named Group -> Named Group
forall a. HasField' "description" a (Maybe Text) => Text -> a -> a
comment
Text
[str|Timelock validity intervals are half-open intervals [a, b).
|This field specifies the right (excluded) endpoint b.
|]
(Named Group -> Named Group) -> Named Group -> Named Group
forall a b. (a -> b) -> a -> b
$ Text
"script_invalid_hereafter" Text -> Group -> Named Group
=:~ Group -> Group
grp [Item Group
ArrayEntry
5, Rule -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
slot]
stake_credential :: Rule
stake_credential :: Rule
stake_credential = Text
"stake_credential" Text -> Rule -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= Rule
credential
credential :: Rule
credential :: Rule
credential = Text
"credential" Text -> Array -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr [Item ArrayChoice
ArrayEntry
0, Rule -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
addr_keyhash] ArrayChoice -> ArrayChoice -> Array
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [Item ArrayChoice
ArrayEntry
1, Rule -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
script_hash]
port :: Rule
port :: Rule
port = Text
"port" Text -> Constrained -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= Value Int
VUInt Value Int -> Word64 -> Constrained
forall a c.
(IsComparable a, IsConstrainable c a) =>
c -> Word64 -> Constrained
`le` Word64
65535
ipv4 :: Rule
ipv4 :: Rule
ipv4 = Text
"ipv4" Text -> Constrained -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= Value ByteString
VBytes Value ByteString -> Word64 -> Constrained
forall c a s.
(IsSizeable a, IsSize s, IsConstrainable c a) =>
c -> s -> Constrained
`sized` (Word64
4 :: Word64)
ipv6 :: Rule
ipv6 :: Rule
ipv6 = Text
"ipv6" Text -> Constrained -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= Value ByteString
VBytes Value ByteString -> Word64 -> Constrained
forall c a s.
(IsSizeable a, IsSize s, IsConstrainable c a) =>
c -> s -> Constrained
`sized` (Word64
16 :: Word64)
dns_name64 :: Rule
dns_name64 :: Rule
dns_name64 = Text
"dns_name" Text -> Constrained -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= Value Text
VText Value Text -> (Word64, Word64) -> Constrained
forall c a s.
(IsSizeable a, IsSize s, IsConstrainable c a) =>
c -> s -> Constrained
`sized` (Word64
0 :: Word64, Word64
64 :: Word64)
url64 :: Rule
url64 :: Rule
url64 = Text
"url" Text -> Constrained -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= Value Text
VText Value Text -> (Word64, Word64) -> Constrained
forall c a s.
(IsSizeable a, IsSize s, IsConstrainable c a) =>
c -> s -> Constrained
`sized` (Word64
0 :: Word64, Word64
64 :: Word64)
single_host_addr :: Named Group
single_host_addr :: Named Group
single_host_addr =
Text
"single_host_addr"
Text -> Group -> Named Group
=:~ Group -> Group
grp
[ Item Group
ArrayEntry
0
, Choice Type2 -> Item Group
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a (Choice Type2 -> Item Group) -> Choice Type2 -> Item Group
forall a b. (a -> b) -> a -> b
$ Rule
port Rule -> Value Void -> Choice Type2
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Value Void
VNil
, Choice Type2 -> Item Group
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a (Choice Type2 -> Item Group) -> Choice Type2 -> Item Group
forall a b. (a -> b) -> a -> b
$ Rule
ipv4 Rule -> Value Void -> Choice Type2
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Value Void
VNil
, Choice Type2 -> Item Group
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a (Choice Type2 -> Item Group) -> Choice Type2 -> Item Group
forall a b. (a -> b) -> a -> b
$ Rule
ipv6 Rule -> Value Void -> Choice Type2
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Value Void
VNil
]
mkPoolRules :: Rule -> Rule -> (Named Group, Named Group, [HuddleItem])
mkPoolRules :: Rule -> Rule -> (Named Group, Named Group, [HuddleItem])
mkPoolRules Rule
dns_name Rule
url = (Named Group
pool_registration_cert, Named Group
pool_retirement_cert, [HuddleItem]
subFields)
where
subFields :: [HuddleItem]
subFields =
[ Named Group -> HuddleItem
HIGroup Named Group
single_host_name
, Named Group -> HuddleItem
HIGroup Named Group
multi_host_name
, Rule -> HuddleItem
HIRule Rule
pool_metadata
, Rule -> HuddleItem
HIRule Rule
relay
, Named Group -> HuddleItem
HIGroup Named Group
pool_params
]
single_host_name :: Named Group
single_host_name :: Named Group
single_host_name =
Text -> Named Group -> Named Group
forall a. HasField' "description" a (Maybe Text) => Text -> a -> a
comment
Text
[str|dns_name: An A or AAAA DNS record
|]
(Named Group -> Named Group) -> Named Group -> Named Group
forall a b. (a -> b) -> a -> b
$ Text
"single_host_name" Text -> Group -> Named Group
=:~ Group -> Group
grp [Item Group
ArrayEntry
1, Choice Type2 -> Item Group
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a (Choice Type2 -> Item Group) -> Choice Type2 -> Item Group
forall a b. (a -> b) -> a -> b
$ Rule
port Rule -> Value Void -> Choice Type2
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Value Void
VNil, Rule -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
dns_name]
multi_host_name :: Named Group
multi_host_name :: Named Group
multi_host_name =
Text -> Named Group -> Named Group
forall a. HasField' "description" a (Maybe Text) => Text -> a -> a
comment
Text
[str|dns_name: An SRV DNS record
|]
(Named Group -> Named Group) -> Named Group -> Named Group
forall a b. (a -> b) -> a -> b
$ Text
"multi_host_name"
Text -> Group -> Named Group
=:~ Group -> Group
grp [Item Group
ArrayEntry
2, Rule -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
dns_name]
pool_metadata :: Rule
pool_metadata :: Rule
pool_metadata = Text
"pool_metadata" Text -> ArrayChoice -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr [Rule -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
url, Value ByteString -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Value ByteString
VBytes]
relay :: Rule
relay :: Rule
relay =
Text
"relay"
Text -> Array -> Rule
forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr [Named Group -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
single_host_addr]
ArrayChoice -> ArrayChoice -> Array
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [Named Group -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
single_host_name]
Array -> ArrayChoice -> Array
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [Named Group -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
multi_host_name]
pool_params :: Named Group
pool_params :: Named Group
pool_params =
Text
"pool_params"
Text -> Group -> Named Group
=:~ Group -> Group
grp
[ Key
"operator" Key -> Rule -> ArrayEntry
forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
pool_keyhash
, Key
"vrf_keyhash" Key -> Rule -> ArrayEntry
forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
vrf_keyhash
, Key
"pledge" Key -> Rule -> ArrayEntry
forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
coin
, Key
"cost" Key -> Rule -> ArrayEntry
forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
coin
, Key
"margin" Key -> Rule -> ArrayEntry
forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
unit_interval
, Key
"reward_account" Key -> Rule -> ArrayEntry
forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
reward_account
, Key
"pool_owners" Key -> GRuleCall -> ArrayEntry
forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule -> GRuleCall
forall a. IsType0 a => a -> GRuleCall
untagged_set Rule
addr_keyhash
, Key
"relays" Key -> ArrayChoice -> ArrayEntry
forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> ArrayChoice -> ArrayChoice
arr [Word64
0 Word64 -> ArrayEntry -> ArrayEntry
forall a. CanQuantify a => Word64 -> a -> a
<+ Rule -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
relay]
, Key
"pool_metadata" Key -> Choice Type2 -> ArrayEntry
forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
pool_metadata Rule -> Value Void -> Choice Type2
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Value Void
VNil
]
pool_registration_cert :: Named Group
pool_registration_cert :: Named Group
pool_registration_cert = Text
"pool_registration_cert" Text -> Group -> Named Group
=:~ Group -> Group
grp [Item Group
ArrayEntry
3, Named Group -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
pool_params]
pool_retirement_cert :: Named Group
pool_retirement_cert :: Named Group
pool_retirement_cert = Text
"pool_retirement_cert" Text -> Group -> Named Group
=:~ Group -> Group
grp [Item Group
ArrayEntry
4, Rule -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
pool_keyhash, Rule -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
epoch]