{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}

{-# HLINT ignore "Use camelCase" #-}
{-# HLINT ignore "Evaluate" #-}

module Test.Cardano.Ledger.Conway.CDDL (conway) where

import Codec.CBOR.Cuddle.Huddle
import Data.Function (($))
import Data.Semigroup ((<>))
import Data.String.Here (here)
import Data.Word (Word64)
import GHC.Num (Integer)
import Test.Cardano.Ledger.Core.Binary.CDDL
import Test.Cardano.Ledger.Shelley.CDDL (
  bootstrap_witness,
  port,
  single_host_addr,
  transaction_index,
  transaction_metadatum,
  vkeywitness,
 )

conway :: Huddle
conway :: Huddle
conway =
  [Rule] -> Huddle
collectFrom forall a b. (a -> b) -> a -> b
$
    [Rule
block, Rule
transaction]
      forall a. Semigroup a => a -> a -> a
<> [Rule
kes_signature, Rule
language, Rule
potential_languages, Rule
signkeyKES]

block :: Rule
block :: Rule
block =
  forall a. Text -> Named a -> Named a
comment
    [here|
    Valid blocks must also satisfy the following two constraints:
    1) the length of transaction_bodies and transaction_witness_sets
       must be the same
    2) every transaction_index must be strictly smaller than the
       length of transaction_bodies

  |]
    forall a b. (a -> b) -> a -> b
$ Text
"block"
      forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr
        [ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
header
        , Key
"transaction_bodies" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> ArrayChoice -> ArrayChoice
arr [Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
transaction_body]
        , Key
"transaction_witness_sets"
            forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> ArrayChoice -> ArrayChoice
arr [Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
transaction_witness_set]
        , Key
"auxiliary_data_set"
            forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> MapChoice -> MapChoice
mp [Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall r. IsType0 r => r -> Key
asKey Rule
transaction_index forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
auxiliary_data]
        , Key
"invalid_transactions" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> ArrayChoice -> ArrayChoice
arr [Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
transaction_index]
        ]

transaction :: Rule
transaction :: Rule
transaction =
  Text
"transaction"
    forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr
      [ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
transaction_body
      , forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
transaction_witness_set
      , forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Value Bool
VBool
      , forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a (Rule
auxiliary_data forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Value Void
VNil)
      ]

header :: Rule
header :: Rule
header =
  Text
"header"
    forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr
      [ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
header_body
      , Key
"body_signature" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
kes_signature
      ]

header_body :: Rule
header_body :: Rule
header_body =
  Text
"header_body"
    forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr
      [ Key
"block_number" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
block_no
      , Key
"slot" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
slot_no
      , Key
"prev_hash" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> (Rule
hash32 forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Value Void
VNil)
      , Key
"issuer_vkey" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
vkey
      , Key
"vrf_vkey" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
vrf_vkey
      , Key
"vrf_result" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
vrf_cert
      , Key
"block_body_size" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> (Value Int
VUInt forall a s. (IsSizeable a, IsSize s) => Value a -> s -> Constrained
`sized` (Word64
4 :: Word64))
      , Key
"block_body_hash" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
hash32
      , forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
operational_cert
      , forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
protocol_version
      ]

operational_cert :: Rule
operational_cert :: Rule
operational_cert =
  Text
"operational_cert"
    forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr
      [ Key
"hot_vkey" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
kes_vkey
      , Key
"sequence_number" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> (Value Int
VUInt forall a s. (IsSizeable a, IsSize s) => Value a -> s -> Constrained
`sized` (Word64
8 :: Word64))
      , Key
"kes_period" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Value Int
VUInt
      , Key
"sigma" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
signature
      ]

protocol_version :: Rule
protocol_version :: Rule
protocol_version = Text
"protocol_version" forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
major_protocol_version, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Value Int
VUInt]

-- TODO Replace with the following once
-- https://github.com/input-output-hk/cuddle/issues/29 is addressed in cuddle.
--
-- next_major_protocol_version :: Rule
-- next_major_protocol_version = "next_major_protocol_version" =:= (10 :: Integer)
next_major_protocol_version :: Integer
next_major_protocol_version :: Integer
next_major_protocol_version = Integer
10

major_protocol_version :: Rule
major_protocol_version :: Rule
major_protocol_version = Text
"major_protocol_version" forall a. IsType0 a => Text -> a -> Rule
=:= (Integer
1 :: Integer) Integer -> Integer -> Ranged
... Integer
next_major_protocol_version

transaction_body :: Rule
transaction_body :: Rule
transaction_body =
  Text
"transaction_body"
    forall a. IsType0 a => Text -> a -> Rule
=:= MapChoice -> MapChoice
mp
      [ Word64 -> Key
idx Word64
0 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> forall t0. IsType0 t0 => t0 -> GRuleCall
set Rule
transaction_input
      , Word64 -> Key
idx Word64
1 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> ArrayChoice -> ArrayChoice
arr [Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
transaction_output]
      , Word64 -> Key
idx Word64
2 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
coin
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
3 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
slot_no)
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
4 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
certificates)
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
5 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
withdrawals)
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
7 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
auxiliary_data_hash)
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
8 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
slot_no) -- Validity interval start
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
9 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
mint)
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
11 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
script_data_hash)
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
13 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> forall t0. IsType0 t0 => t0 -> GRuleCall
nonempty_set Rule
transaction_input)
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
14 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
required_signers)
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
15 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
network_id)
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
16 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
transaction_output)
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
17 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
coin)
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
18 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> forall t0. IsType0 t0 => t0 -> GRuleCall
nonempty_set Rule
transaction_input)
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
19 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
voting_procedures)
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
20 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
proposal_procedures)
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
21 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
coin)
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
22 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
positive_coin)
      ]

voting_procedures :: Rule
voting_procedures :: Rule
voting_procedures =
  Text
"voting_procedures"
    forall a. IsType0 a => Text -> a -> Rule
=:= MapChoice -> MapChoice
mp [Word64
1 forall a. CanQuantify a => Word64 -> a -> a
<+ forall r. IsType0 r => r -> Key
asKey Rule
voter forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> MapChoice -> MapChoice
mp [Word64
1 forall a. CanQuantify a => Word64 -> a -> a
<+ forall r. IsType0 r => r -> Key
asKey Rule
gov_action_id forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
voting_procedure]]

voting_procedure :: Rule
voting_procedure :: Rule
voting_procedure = Text
"voting_procedure" forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
vote, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a (Rule
anchor forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Value Void
VNil)]

proposal_procedure :: Rule
proposal_procedure :: Rule
proposal_procedure =
  Text
"proposal_procedure"
    forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr
      [ Key
"deposit" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
coin
      , forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
reward_account
      , forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
gov_action
      , forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
anchor
      ]

proposal_procedures :: Rule
proposal_procedures :: Rule
proposal_procedures = Text
"proposal_procedures" forall a. IsType0 a => Text -> a -> Rule
=:= forall t0. IsType0 t0 => t0 -> GRuleCall
nonempty_set Rule
proposal_procedure

certificates :: Rule
certificates :: Rule
certificates = Text
"certificates" forall a. IsType0 a => Text -> a -> Rule
=:= forall t0. IsType0 t0 => t0 -> GRuleCall
nonempty_set Rule
certificate

gov_action :: Rule
gov_action :: Rule
gov_action =
  Text
"gov_action"
    forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
parameter_change_action]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
hard_fork_initiation_action]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
treasury_withdrawals_action]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
no_confidence]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
update_committee]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
new_constitution]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
info_action]

policy_hash :: Rule
policy_hash :: Rule
policy_hash = Text
"policy_hash" forall a. IsType0 a => Text -> a -> Rule
=:= Rule
scripthash

parameter_change_action :: Named Group
parameter_change_action :: Named Group
parameter_change_action =
  Text
"parameter_change_action"
    Text -> Group -> Named Group
=:~ Group -> Group
grp
      [ Choice Type2
0
      , Rule
gov_action_id forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Value Void
VNil
      , forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
protocol_param_update
      , Rule
policy_hash forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Value Void
VNil
      ]

hard_fork_initiation_action :: Named Group
hard_fork_initiation_action :: Named Group
hard_fork_initiation_action =
  Text
"hard_fork_initiation_action"
    Text -> Group -> Named Group
=:~ Group -> Group
grp [Choice Type2
1, Rule
gov_action_id forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Value Void
VNil, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
protocol_version]

treasury_withdrawals_action :: Named Group
treasury_withdrawals_action :: Named Group
treasury_withdrawals_action =
  Text
"treasury_withdrawals_action"
    Text -> Group -> Named Group
=:~ Group -> Group
grp [Choice Type2
2, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a (MapChoice -> MapChoice
mp [forall r. IsType0 r => r -> Key
asKey Rule
reward_account forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
coin]), Rule
policy_hash forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Value Void
VNil]

no_confidence :: Named Group
no_confidence :: Named Group
no_confidence = Text
"no_confidence" Text -> Group -> Named Group
=:~ Group -> Group
grp [Choice Type2
3, Rule
gov_action_id forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Value Void
VNil]

update_committee :: Named Group
update_committee :: Named Group
update_committee =
  Text
"update_committee"
    Text -> Group -> Named Group
=:~ Group -> Group
grp
      [ Choice Type2
4
      , Rule
gov_action_id forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Value Void
VNil
      , forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a (forall t0. IsType0 t0 => t0 -> GRuleCall
set Rule
committee_cold_credential)
      , forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a (MapChoice -> MapChoice
mp [forall r. IsType0 r => r -> Key
asKey Rule
committee_cold_credential forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
epoch_no])
      , forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
unit_interval
      ]

new_constitution :: Named Group
new_constitution :: Named Group
new_constitution =
  Text
"new_constitution"
    Text -> Group -> Named Group
=:~ Group -> Group
grp [Choice Type2
5, Rule
gov_action_id forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Value Void
VNil, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
constitution]

constitution :: Rule
constitution :: Rule
constitution =
  Text
"constitution"
    forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr
      [ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
anchor
      , forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a (Rule
scripthash forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Value Void
VNil)
      ]

info_action :: Rule
info_action :: Rule
info_action = Text
"info_action" forall a. IsType0 a => Text -> a -> Rule
=:= Integer -> Literal
int Integer
6

voter :: Rule
voter :: Rule
voter =
  forall a. Text -> Named a -> Named a
comment
    [here|
    Constitutional Committee Hot KeyHash: 0
    Constitutional Committee Hot ScriptHash: 1
    DRep KeyHash: 2
    DRep ScriptHash: 3
    StakingPool KeyHash: 4
  |]
    forall a b. (a -> b) -> a -> b
$ Text
"voter"
      forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr [ArrayEntry
0, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
addr_keyhash]
      forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [ArrayEntry
1, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
scripthash]
      forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [ArrayEntry
2, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
addr_keyhash]
      forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [ArrayEntry
3, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
scripthash]
      forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [ArrayEntry
4, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
addr_keyhash]

anchor :: Rule
anchor :: Rule
anchor =
  Text
"anchor"
    forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr
      [ Key
"anchor_url" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
url
      , Key
"anchor_data_hash" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
hash32
      ]

vote :: Rule
vote :: Rule
vote = Text
"vote" forall a. IsType0 a => Text -> a -> Rule
=:= Integer
0 Integer -> Integer -> Ranged
... Integer
2

gov_action_id :: Rule
gov_action_id :: Rule
gov_action_id =
  Text
"gov_action_id"
    forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr
      [ Key
"transaction_id" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
hash32
      , Key
"gov_action_index" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> (Value Int
VUInt forall a s. (IsSizeable a, IsSize s) => Value a -> s -> Constrained
`sized` (Word64
2 :: Word64))
      ]

required_signers :: Rule
required_signers :: Rule
required_signers = Text
"required_signers" forall a. IsType0 a => Text -> a -> Rule
=:= forall t0. IsType0 t0 => t0 -> GRuleCall
nonempty_set Rule
addr_keyhash

transaction_input :: Rule
transaction_input :: Rule
transaction_input =
  Text
"transaction_input"
    forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr
      [ Key
"transaction_id" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
hash32
      , Key
"index" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> (Value Int
VUInt forall a s. (IsSizeable a, IsSize s) => Value a -> s -> Constrained
`sized` (Word64
2 :: Word64))
      ]

transaction_output :: Rule
transaction_output :: Rule
transaction_output =
  forall a. Text -> Named a -> Named a
comment
    [here|
    Both of the Alonzo and Babbage style TxOut formats are equally valid
    and can be used interchangeably
  |]
    forall a b. (a -> b) -> a -> b
$ Text
"transaction_output"
      forall a. IsType0 a => Text -> a -> Rule
=:= Rule
pre_babbage_transaction_output
      forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Rule
post_alonzo_transaction_output

pre_babbage_transaction_output :: Rule
pre_babbage_transaction_output :: Rule
pre_babbage_transaction_output =
  Text
"pre_babbage_transaction_output"
    forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr
      [ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
address
      , Key
"amount" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
value
      , forall a. CanQuantify a => a -> a
opt (Key
"datum_hash" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
datum_hash)
      ]

post_alonzo_transaction_output :: Rule
post_alonzo_transaction_output :: Rule
post_alonzo_transaction_output =
  Text
"post_alonzo_transaction_output"
    forall a. IsType0 a => Text -> a -> Rule
=:= MapChoice -> MapChoice
mp
      [ Word64 -> Key
idx Word64
0 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
address
      , Word64 -> Key
idx Word64
1 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
value
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
2 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
datum_option) -- datum option
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
3 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
script_ref) -- script reference
      ]

script_data_hash :: Rule
script_data_hash :: Rule
script_data_hash =
  forall a. Text -> Named a -> Named a
comment
    [here|
    This is a hash of data which may affect evaluation of a script.
    This data consists of:
      - The redeemers from the transaction_witness_set (the value of field 5).
      - The datums from the transaction_witness_set (the value of field 4).
      - The value in the costmdls map corresponding to the script's language
        (in field 18 of protocol_param_update.)
    (In the future it may contain additional protocol parameters.)

    Since this data does not exist in contiguous form inside a transaction, it needs
    to be independently constructed by each recipient.

    The bytestring which is hashed is the concatenation of three things:
      redeemers || datums || language views
    The redeemers are exactly the data present in the transaction witness set.
    Similarly for the datums, if present. If no datums are provided, the middle
    field is omitted (i.e. it is the empty/null bytestring).

    language views CDDL:
    { * language => script_integrity_data }

    This must be encoded canonically, using the same scheme as in
    RFC7049 section 3.9:
     - Maps, strings, and bytestrings must use a definite-length encoding
     - Integers must be as small as possible.
     - The expressions for map length, string length, and bytestring length
       must be as short as possible.
     - The keys in the map must be sorted as follows:
        -  If two keys have different lengths, the shorter one sorts earlier.
        -  If two keys have the same length, the one with the lower value
           in (byte-wise) lexical order sorts earlier.

    For PlutusV1 (language id 0), the language view is the following:
      - the value of costmdls map at key 0 (in other words, the script_integrity_data)
        is encoded as an indefinite length list and the result is encoded as a bytestring.
        (our apologies)
        For example, the script_integrity_data corresponding to the all zero costmodel for V1
        would be encoded as (in hex):
        58a89f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ff
      - the language ID tag is also encoded twice. first as a uint then as
        a bytestring. (our apologies)
        Concretely, this means that the language version for V1 is encoded as
        4100 in hex.
    For PlutusV2 (language id 1), the language view is the following:
      - the value of costmdls map at key 1 is encoded as an definite length list.
        For example, the script_integrity_data corresponding to the all zero costmodel for V2
        would be encoded as (in hex):
        98af0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
      - the language ID tag is encoded as expected.
        Concretely, this means that the language version for V2 is encoded as
        01 in hex.
    For PlutusV3 (language id 2), the language view is the following:
      - the value of costmdls map at key 2 is encoded as a definite length list.

    Note that each Plutus language represented inside a transaction must have
    a cost model in the costmdls protocol parameter in order to execute,
    regardless of what the script integrity data is.

    Finally, note that in the case that a transaction includes datums but does not
    include the redeemers field, the script data format becomes (in hex):
    [ A0 | datums | A0 ]
    corresponding to a CBOR empty map and an empty map for language view.
    This empty redeeemer case has changed from the previous eras, since default
    representation for redeemers has been changed to a map. Also whenever redeemers are
    supplied either as a map or as an array they must contain at least one element,
    therefore there is no way to override this behavior by providing a custom
    representation for empty redeemers.
  |]
    forall a b. (a -> b) -> a -> b
$ Text
"script_data_hash" forall a. IsType0 a => Text -> a -> Rule
=:= Rule
hash32

certificate :: Rule
certificate :: Rule
certificate =
  Text
"certificate"
    forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
stake_registration]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
stake_deregistration]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
stake_delegation]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
pool_registration]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
pool_retirement]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
reg_cert]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
unreg_cert]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
vote_deleg_cert]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
stake_vote_deleg_cert]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
stake_reg_deleg_cert]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
vote_reg_deleg_cert]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
stake_vote_reg_deleg_cert]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
auth_committee_hot_cert]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
resign_committee_cold_cert]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
reg_drep_cert]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
unreg_drep_cert]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
update_drep_cert]

stake_registration :: Named Group
stake_registration :: Named Group
stake_registration =
  forall a. Text -> Named a -> Named a
comment Text
"This will be deprecated in a future era" forall a b. (a -> b) -> a -> b
$
    Text
"stake_registration" Text -> Group -> Named Group
=:~ Group -> Group
grp [Choice Type2
0, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
stake_credential]

stake_deregistration :: Named Group
stake_deregistration :: Named Group
stake_deregistration =
  forall a. Text -> Named a -> Named a
comment Text
"This will be deprecated in a future era" forall a b. (a -> b) -> a -> b
$
    Text
"stake_deregistration" Text -> Group -> Named Group
=:~ Group -> Group
grp [Choice Type2
1, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
stake_credential]

stake_delegation :: Named Group
stake_delegation :: Named Group
stake_delegation =
  Text
"stake_delegation"
    Text -> Group -> Named Group
=:~ Group -> Group
grp [Choice Type2
2, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
stake_credential, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
pool_keyhash]

-- POOL
pool_registration :: Named Group
pool_registration :: Named Group
pool_registration = Text
"pool_registration" Text -> Group -> Named Group
=:~ Group -> Group
grp [Choice Type2
3, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
pool_params]

pool_retirement :: Named Group
pool_retirement :: Named Group
pool_retirement = Text
"pool_retirement" Text -> Group -> Named Group
=:~ Group -> Group
grp [Choice Type2
4, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
pool_keyhash, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
epoch_no]

-- numbers 5 and 6 used to be the Genesis and MIR certificates respectively,
-- which were deprecated in Conway

-- DELEG
reg_cert :: Named Group
reg_cert :: Named Group
reg_cert = Text
"reg_cert" Text -> Group -> Named Group
=:~ Group -> Group
grp [Choice Type2
7, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
stake_credential, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
coin]

unreg_cert :: Named Group
unreg_cert :: Named Group
unreg_cert = Text
"unreg_cert" Text -> Group -> Named Group
=:~ Group -> Group
grp [Choice Type2
8, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
stake_credential, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
coin]

vote_deleg_cert :: Named Group
vote_deleg_cert :: Named Group
vote_deleg_cert = Text
"vote_deleg_cert" Text -> Group -> Named Group
=:~ Group -> Group
grp [Choice Type2
9, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
stake_credential, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
drep]

stake_vote_deleg_cert :: Named Group
stake_vote_deleg_cert :: Named Group
stake_vote_deleg_cert =
  Text
"stake_vote_deleg_cert"
    Text -> Group -> Named Group
=:~ Group -> Group
grp [Choice Type2
10, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
stake_credential, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
pool_keyhash, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
drep]

stake_reg_deleg_cert :: Named Group
stake_reg_deleg_cert :: Named Group
stake_reg_deleg_cert =
  Text
"stake_reg_deleg_cert"
    Text -> Group -> Named Group
=:~ Group -> Group
grp [Choice Type2
11, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
stake_credential, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
pool_keyhash, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
coin]

vote_reg_deleg_cert :: Named Group
vote_reg_deleg_cert :: Named Group
vote_reg_deleg_cert =
  Text
"vote_reg_deleg_cert"
    Text -> Group -> Named Group
=:~ Group -> Group
grp [Choice Type2
12, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
stake_credential, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
drep, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
coin]

stake_vote_reg_deleg_cert :: Named Group
stake_vote_reg_deleg_cert :: Named Group
stake_vote_reg_deleg_cert =
  Text
"stake_vote_reg_deleg_cert"
    Text -> Group -> Named Group
=:~ Group -> Group
grp [Choice Type2
13, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
stake_credential, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
pool_keyhash, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
drep, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
coin]

-- GOVCERT
auth_committee_hot_cert :: Named Group
auth_committee_hot_cert :: Named Group
auth_committee_hot_cert =
  Text
"auth_committee_hot_cert"
    Text -> Group -> Named Group
=:~ Group -> Group
grp [Choice Type2
14, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
committee_cold_credential, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
committee_hot_credential]

resign_committee_cold_cert :: Named Group
resign_committee_cold_cert :: Named Group
resign_committee_cold_cert =
  Text
"resign_committee_cold_cert"
    Text -> Group -> Named Group
=:~ Group -> Group
grp [Choice Type2
15, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
committee_cold_credential, Rule
anchor forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Value Void
VNil]

reg_drep_cert :: Named Group
reg_drep_cert :: Named Group
reg_drep_cert = Text
"reg_drep_cert" Text -> Group -> Named Group
=:~ Group -> Group
grp [Choice Type2
16, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
drep_credential, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
coin, Rule
anchor forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Value Void
VNil]

unreg_drep_cert :: Named Group
unreg_drep_cert :: Named Group
unreg_drep_cert = Text
"unreg_drep_cert" Text -> Group -> Named Group
=:~ Group -> Group
grp [Choice Type2
17, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
drep_credential, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
coin]

update_drep_cert :: Named Group
update_drep_cert :: Named Group
update_drep_cert = Text
"update_drep_cert" Text -> Group -> Named Group
=:~ Group -> Group
grp [Choice Type2
18, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
drep_credential, Rule
anchor forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Value Void
VNil]

credential :: Rule
credential :: Rule
credential =
  Text
"credential"
    forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr
      [ArrayEntry
0, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
addr_keyhash]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [ArrayEntry
1, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
scripthash]

drep :: Rule
drep :: Rule
drep =
  Text
"drep"
    forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr [ArrayEntry
0, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
addr_keyhash]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [ArrayEntry
1, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
scripthash]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [ArrayEntry
2] -- always abstain
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [ArrayEntry
3] -- always no confidence

stake_credential :: Rule
stake_credential :: Rule
stake_credential = Text
"stake_credential" forall a. IsType0 a => Text -> a -> Rule
=:= Rule
credential

drep_credential :: Rule
drep_credential :: Rule
drep_credential = Text
"drep_credential" forall a. IsType0 a => Text -> a -> Rule
=:= Rule
credential

committee_cold_credential :: Rule
committee_cold_credential :: Rule
committee_cold_credential = Text
"committee_cold_credential" forall a. IsType0 a => Text -> a -> Rule
=:= Rule
credential

committee_hot_credential :: Rule
committee_hot_credential :: Rule
committee_hot_credential = Text
"committee_hot_credential" forall a. IsType0 a => Text -> a -> Rule
=:= Rule
credential

pool_params :: Named Group
pool_params :: Named Group
pool_params =
  Text
"pool_params"
    Text -> Group -> Named Group
=:~ Group -> Group
grp
      [ Key
"operator" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
pool_keyhash
      , Key
"vrf_keyhash" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
vrf_keyhash
      , Key
"pledge" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
coin
      , Key
"cost" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
coin
      , Key
"margin" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
unit_interval
      , Key
"reward_account" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
reward_account
      , Key
"pool_owners" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> forall t0. IsType0 t0 => t0 -> GRuleCall
set Rule
addr_keyhash
      , Key
"relays" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> ArrayChoice -> ArrayChoice
arr [Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
relay]
      , Key
"pool_metadata" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> (Rule
pool_metadata forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Value Void
VNil)
      ]

dns_name :: Rule
dns_name :: Rule
dns_name = Text
"dns_name" forall a. IsType0 a => Text -> a -> Rule
=:= Value Text
VText forall a s. (IsSizeable a, IsSize s) => Value a -> s -> Constrained
`sized` (Word64
0 :: Word64, Word64
128 :: Word64)

single_host_name :: Named Group
single_host_name :: Named Group
single_host_name =
  Text
"single_host_name"
    Text -> Group -> Named Group
=:~ Group -> Group
grp
      [ Choice Type2
1
      , Rule
port forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Value Void
VNil
      , forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
dns_name -- An A or AAAA DNS record
      ]

multi_host_name :: Named Group
multi_host_name :: Named Group
multi_host_name =
  Text
"multi_host_name"
    Text -> Group -> Named Group
=:~ Group -> Group
grp
      [ Choice Type2
2
      , forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
dns_name -- A SRV DNS record
      ]

relay :: Rule
relay :: Rule
relay =
  Text
"relay"
    forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
single_host_addr]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
single_host_name]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
multi_host_name]

pool_metadata :: Rule
pool_metadata :: Rule
pool_metadata = Text
"pool_metadata" forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
url, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
pool_metadata_hash]

url :: Rule
url :: Rule
url = Text
"url" forall a. IsType0 a => Text -> a -> Rule
=:= Value Text
VText forall a s. (IsSizeable a, IsSize s) => Value a -> s -> Constrained
`sized` (Word64
0 :: Word64, Word64
128 :: Word64)

withdrawals :: Rule
withdrawals :: Rule
withdrawals = Text
"withdrawals" forall a. IsType0 a => Text -> a -> Rule
=:= MapChoice -> MapChoice
mp [Word64
1 forall a. CanQuantify a => Word64 -> a -> a
<+ forall r. IsType0 r => r -> Key
asKey Rule
reward_account forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
coin]

protocol_param_update :: Rule
protocol_param_update :: Rule
protocol_param_update =
  Text
"protocol_param_update"
    forall a. IsType0 a => Text -> a -> Rule
=:= MapChoice -> MapChoice
mp
      [ forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
0 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
coin) -- minfee A
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
1 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
coin) -- minfee B
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
2 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> (Value Int
VUInt forall a s. (IsSizeable a, IsSize s) => Value a -> s -> Constrained
`sized` (Word64
4 :: Word64))) -- max block body size
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
3 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> (Value Int
VUInt forall a s. (IsSizeable a, IsSize s) => Value a -> s -> Constrained
`sized` (Word64
4 :: Word64))) -- max transaction size
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
4 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> (Value Int
VUInt forall a s. (IsSizeable a, IsSize s) => Value a -> s -> Constrained
`sized` (Word64
2 :: Word64))) -- max block header size
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
5 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
coin) -- key deposit
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
6 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
coin) -- pool deposit
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
7 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
epoch_interval) -- maximum epoch
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
8 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> (Value Int
VUInt forall a s. (IsSizeable a, IsSize s) => Value a -> s -> Constrained
`sized` (Word64
2 :: Word64))) -- n_opt: desired number of stake pools
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
9 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
nonnegative_interval) -- pool pledge influence
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
10 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
unit_interval) -- expansion rate
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
11 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
unit_interval) -- treasury growth rate
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
16 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
coin) -- min pool cost
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
17 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
coin) -- ada per utxo byte
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
18 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
costmdls) -- cost models for script languages
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
19 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
ex_unit_prices) -- execution costs
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
20 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
ex_units) -- max tx ex units
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
21 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
ex_units) -- max block ex units
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
22 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> (Value Int
VUInt forall a s. (IsSizeable a, IsSize s) => Value a -> s -> Constrained
`sized` (Word64
4 :: Word64))) -- max value size
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
23 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> (Value Int
VUInt forall a s. (IsSizeable a, IsSize s) => Value a -> s -> Constrained
`sized` (Word64
2 :: Word64))) -- collateral percentage
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
24 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> (Value Int
VUInt forall a s. (IsSizeable a, IsSize s) => Value a -> s -> Constrained
`sized` (Word64
2 :: Word64))) -- max collateral inputs
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
25 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
pool_voting_thresholds) -- pool voting thresholds
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
26 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
drep_voting_thresholds) -- DRep voting thresholds
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
27 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> (Value Int
VUInt forall a s. (IsSizeable a, IsSize s) => Value a -> s -> Constrained
`sized` (Word64
2 :: Word64))) -- min committee size
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
28 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
epoch_interval) -- committee term limit
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
29 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
epoch_interval) -- governance action validity period
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
30 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
coin) -- governance action deposit
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
31 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
coin) -- DRep deposit
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
32 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
epoch_interval) -- DRep inactivity period
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
33 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
nonnegative_interval) -- MinFee RefScriptCoinsPerByte
      ]

pool_voting_thresholds :: Rule
pool_voting_thresholds :: Rule
pool_voting_thresholds =
  Text
"pool_voting_thresholds"
    forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr
      [ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
unit_interval -- motion no confidence
      , forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
unit_interval -- committee normal
      , forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
unit_interval -- committee no confidence
      , forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
unit_interval -- hard fork initiation
      , forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
unit_interval -- security relevant parameter voting threshold
      ]

drep_voting_thresholds :: Rule
drep_voting_thresholds :: Rule
drep_voting_thresholds =
  Text
"drep_voting_thresholds"
    forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr
      [ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
unit_interval -- motion no confidence
      , forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
unit_interval -- committee normal
      , forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
unit_interval -- committee no confidence
      , forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
unit_interval -- update constitution
      , forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
unit_interval -- hard fork initiation
      , forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
unit_interval -- PP network group
      , forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
unit_interval -- PP economic group
      , forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
unit_interval -- PP technical group
      , forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
unit_interval -- PP governance group
      , forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
unit_interval -- treasury withdrawal
      ]

transaction_witness_set :: Rule
transaction_witness_set :: Rule
transaction_witness_set =
  Text
"transaction_witness_set"
    forall a. IsType0 a => Text -> a -> Rule
=:= MapChoice -> MapChoice
mp
      [ forall a. CanQuantify a => a -> a
opt forall a b. (a -> b) -> a -> b
$ Word64 -> Key
idx Word64
0 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> forall t0. IsType0 t0 => t0 -> GRuleCall
nonempty_set Rule
vkeywitness
      , forall a. CanQuantify a => a -> a
opt forall a b. (a -> b) -> a -> b
$ Word64 -> Key
idx Word64
1 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> forall t0. IsType0 t0 => t0 -> GRuleCall
nonempty_set Rule
native_script
      , forall a. CanQuantify a => a -> a
opt forall a b. (a -> b) -> a -> b
$ Word64 -> Key
idx Word64
2 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> forall t0. IsType0 t0 => t0 -> GRuleCall
nonempty_set Rule
bootstrap_witness
      , forall a. CanQuantify a => a -> a
opt forall a b. (a -> b) -> a -> b
$ Word64 -> Key
idx Word64
3 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> forall t0. IsType0 t0 => t0 -> GRuleCall
nonempty_set Rule
plutus_v1_script
      , forall a. CanQuantify a => a -> a
opt forall a b. (a -> b) -> a -> b
$ Word64 -> Key
idx Word64
4 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> forall t0. IsType0 t0 => t0 -> GRuleCall
nonempty_set Rule
plutus_data
      , forall a. CanQuantify a => a -> a
opt forall a b. (a -> b) -> a -> b
$ Word64 -> Key
idx Word64
5 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
redeemers
      , forall a. CanQuantify a => a -> a
opt forall a b. (a -> b) -> a -> b
$ Word64 -> Key
idx Word64
6 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> forall t0. IsType0 t0 => t0 -> GRuleCall
nonempty_set Rule
plutus_v2_script
      , forall a. CanQuantify a => a -> a
opt forall a b. (a -> b) -> a -> b
$ Word64 -> Key
idx Word64
7 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> forall t0. IsType0 t0 => t0 -> GRuleCall
nonempty_set Rule
plutus_v3_script
      ]

plutus_v1_script :: Rule
plutus_v1_script :: Rule
plutus_v1_script =
  forall a. Text -> Named a -> Named a
comment
    ( Text
"The real type of  plutus_v1_script, plutus_v2_script and plutus_v3_script is bytes.\n"
        forall a. Semigroup a => a -> a -> a
<> Text
"However, because we enforce uniqueness when many scripts are supplied,\n"
        forall a. Semigroup a => a -> a -> a
<> Text
"we need to hack around for tests in order to avoid generating duplicates,\n"
        forall a. Semigroup a => a -> a -> a
<> Text
"since the cddl tool we use for roundtrip testing doesn't generate distinct collections.\n"
    )
    forall a b. (a -> b) -> a -> b
$ Text
"plutus_v1_script" forall a. IsType0 a => Text -> a -> Rule
=:= forall s. IsSizeable s => Value s -> Rule
distinct Value ByteString
VBytes

plutus_v2_script :: Rule
plutus_v2_script :: Rule
plutus_v2_script = Text
"plutus_v2_script" forall a. IsType0 a => Text -> a -> Rule
=:= forall s. IsSizeable s => Value s -> Rule
distinct Value ByteString
VBytes

plutus_v3_script :: Rule
plutus_v3_script :: Rule
plutus_v3_script = Text
"plutus_v3_script" forall a. IsType0 a => Text -> a -> Rule
=:= forall s. IsSizeable s => Value s -> Rule
distinct Value ByteString
VBytes

plutus_data :: Rule
plutus_data :: Rule
plutus_data =
  Text
"plutus_data"
    forall a. IsType0 a => Text -> a -> Rule
=:= forall t0. IsType0 t0 => t0 -> GRuleCall
constr Rule
plutus_data
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ MapChoice -> Seal Map
smp [Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall r. IsType0 r => r -> Key
asKey Rule
plutus_data forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
plutus_data]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> Seal Array
sarr [Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
plutus_data]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Rule
big_int
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Rule
bounded_bytes

constr :: IsType0 x => x -> GRuleCall
constr :: forall t0. IsType0 t0 => t0 -> GRuleCall
constr = forall t0. IsType0 t0 => (GRef -> Rule) -> t0 -> GRuleCall
binding forall a b. (a -> b) -> a -> b
$ \GRef
x ->
  Text
"constr"
    forall a. IsType0 a => Text -> a -> Rule
=:= forall a. Word64 -> a -> Tagged a
tag Word64
121 (ArrayChoice -> ArrayChoice
arr [Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a GRef
x])
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ forall a. Word64 -> a -> Tagged a
tag Word64
122 (ArrayChoice -> ArrayChoice
arr [Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a GRef
x])
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ forall a. Word64 -> a -> Tagged a
tag Word64
123 (ArrayChoice -> ArrayChoice
arr [Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a GRef
x])
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ forall a. Word64 -> a -> Tagged a
tag Word64
124 (ArrayChoice -> ArrayChoice
arr [Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a GRef
x])
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ forall a. Word64 -> a -> Tagged a
tag Word64
125 (ArrayChoice -> ArrayChoice
arr [Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a GRef
x])
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ forall a. Word64 -> a -> Tagged a
tag Word64
126 (ArrayChoice -> ArrayChoice
arr [Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a GRef
x])
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ forall a. Word64 -> a -> Tagged a
tag Word64
127 (ArrayChoice -> ArrayChoice
arr [Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a GRef
x])
    -- similarly for tag range: 6.1280 .. 6.1400 inclusive
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ forall a. Word64 -> a -> Tagged a
tag Word64
102 (ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Value Int
VUInt, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a forall a b. (a -> b) -> a -> b
$ ArrayChoice -> ArrayChoice
arr [Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a GRef
x]])

redeemers :: Rule
redeemers :: Rule
redeemers =
  forall a. Text -> Named a -> Named a
comment
    ( Text
"Flat Array support is included for backwards compatibility and will be removed in the next era.\n"
        forall a. Semigroup a => a -> a -> a
<> Text
"It is recommended for tools to adopt using a Map instead of Array going forward."
    )
    forall a b. (a -> b) -> a -> b
$ Text
"redeemers"
      forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> Seal Array
sarr
        [ Word64
1
            forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a
              ( ArrayChoice -> ArrayChoice
arr
                  [ Key
"tag" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
redeemer_tag
                  , Key
"index" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> (Value Int
VUInt forall a s. (IsSizeable a, IsSize s) => Value a -> s -> Constrained
`sized` (Word64
4 :: Word64))
                  , Key
"data" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
plutus_data
                  , Key
"ex_units" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
ex_units
                  ]
              )
        ]
      forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ MapChoice -> Seal Map
smp
        [ Word64
1
            forall a. CanQuantify a => Word64 -> a -> a
<+ forall r. IsType0 r => r -> Key
asKey
              ( ArrayChoice -> ArrayChoice
arr
                  [ Key
"tag" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
redeemer_tag
                  , Key
"index" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> (Value Int
VUInt forall a s. (IsSizeable a, IsSize s) => Value a -> s -> Constrained
`sized` (Word64
4 :: Word64))
                  ]
              )
            forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> ArrayChoice -> ArrayChoice
arr [Key
"data" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
plutus_data, Key
"ex_units" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
ex_units]
        ]

redeemer_tag :: Rule
redeemer_tag :: Rule
redeemer_tag =
  Text
"redeemer_tag"
    forall a. IsType0 a => Text -> a -> Rule
=:= Integer -> Literal
int Integer
0 -- Spending
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Integer -> Literal
int Integer
1 -- Minting
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Integer -> Literal
int Integer
2 -- Certifying
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Integer -> Literal
int Integer
3 -- Rewarding
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Integer -> Literal
int Integer
4 -- Voting
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Integer -> Literal
int Integer
5 -- Proposing

ex_units :: Rule
ex_units :: Rule
ex_units = Text
"ex_units" forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr [Key
"mem" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Value Int
VUInt, Key
"steps" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Value Int
VUInt]

ex_unit_prices :: Rule
ex_unit_prices :: Rule
ex_unit_prices =
  Text
"ex_unit_prices"
    forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr
      [ Key
"mem_price" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
nonnegative_interval
      , Key
"step_price" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
nonnegative_interval
      ]

language :: Rule
language :: Rule
language =
  Text
"language"
    forall a. IsType0 a => Text -> a -> Rule
=:= Integer -> Literal
int Integer
0 -- Plutus v1
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Integer -> Literal
int Integer
1 -- Plutus v2
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Integer -> Literal
int Integer
2 -- Plutus v3

potential_languages :: Rule
potential_languages :: Rule
potential_languages = Text
"potential_languages" forall a. IsType0 a => Text -> a -> Rule
=:= Integer
0 Integer -> Integer -> Ranged
... Integer
255

-- The format for costmdls is flexible enough to allow adding Plutus built-ins and language
-- versions in the future.
--
costmdls :: Rule
costmdls :: Rule
costmdls =
  forall a. Text -> Named a -> Named a
comment
    Text
"The format for costmdls is flexible enough to allow adding Plutus\n built-ins and language versions in the future."
    forall a b. (a -> b) -> a -> b
$ Text
"costmdls"
      forall a. IsType0 a => Text -> a -> Rule
=:= MapChoice -> MapChoice
mp
        [ forall a. CanQuantify a => a -> a
opt forall a b. (a -> b) -> a -> b
$ Word64 -> Key
idx Word64
0 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> ArrayChoice -> ArrayChoice
arr [Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
int64] -- Plutus v1, only 166 integers are used, but more are accepted (and ignored)
        , forall a. CanQuantify a => a -> a
opt forall a b. (a -> b) -> a -> b
$ Word64 -> Key
idx Word64
1 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> ArrayChoice -> ArrayChoice
arr [Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
int64] -- Plutus v2, only 175 integers are used, but more are accepted (and ignored)
        , forall a. CanQuantify a => a -> a
opt forall a b. (a -> b) -> a -> b
$ Word64 -> Key
idx Word64
2 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> ArrayChoice -> ArrayChoice
arr [Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
int64] -- Plutus v3, only 223 integers are used, but more are accepted (and ignored)
        , Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall r. IsType0 r => r -> Key
asKey (Integer
3 Integer -> Integer -> Ranged
... Integer
255) forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> ArrayChoice -> ArrayChoice
arr [Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
int64] -- Any 8-bit unsigned number can be used as a key.
        ]

transaction_metadatum_label :: Rule
transaction_metadatum_label :: Rule
transaction_metadatum_label = Text
"transaction_metadatum_label" forall a. IsType0 a => Text -> a -> Rule
=:= (Value Int
VUInt forall a s. (IsSizeable a, IsSize s) => Value a -> s -> Constrained
`sized` (Word64
8 :: Word64))

metadata :: Rule
metadata :: Rule
metadata =
  Text
"metadata"
    forall a. IsType0 a => Text -> a -> Rule
=:= MapChoice -> MapChoice
mp
      [ Word64
0
          forall a. CanQuantify a => Word64 -> a -> a
<+ forall r. IsType0 r => r -> Key
asKey Rule
transaction_metadatum_label
          forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
transaction_metadatum
      ]

auxiliary_data :: Rule
auxiliary_data :: Rule
auxiliary_data =
  Text
"auxiliary_data"
    forall a. IsType0 a => Text -> a -> Rule
=:= Rule
metadata -- Shelley
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> Seal Array
sarr
      [ Key
"transaction_metadata" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
metadata -- Shelley-ma
      , Key
"auxiliary_scripts" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> ArrayChoice -> ArrayChoice
arr [Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
native_script]
      ]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ forall a. Word64 -> a -> Tagged a
tag
      Word64
259
      ( MapChoice -> MapChoice
mp
          [ forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
0 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
metadata) -- Alonzo and beyond
          , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
1 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> ArrayChoice -> ArrayChoice
arr [Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
native_script])
          , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
2 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> ArrayChoice -> ArrayChoice
arr [Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
plutus_v1_script])
          , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
3 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> ArrayChoice -> ArrayChoice
arr [Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
plutus_v2_script])
          , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
4 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> ArrayChoice -> ArrayChoice
arr [Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
plutus_v3_script])
          ]
      )

native_script :: Rule
native_script :: Rule
native_script =
  Text
"native_script"
    forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
script_pubkey]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
script_all]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
script_any]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
script_n_of_k]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
invalid_before]
    -- Timelock validity intervals are half-open intervals [a, b).
    -- This field specifies the left (included) endpoint a.
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Named Group
invalid_hereafter]

-- Timelock validity intervals are half-open intervals [a, b).
-- This field specifies the right (excluded) endpoint b.

script_pubkey :: Named Group
script_pubkey :: Named Group
script_pubkey = Text
"script_pubkey" Text -> Group -> Named Group
=:~ Group -> Group
grp [Choice Type2
0, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
addr_keyhash]

script_all :: Named Group
script_all :: Named Group
script_all = Text
"script_all" Text -> Group -> Named Group
=:~ Group -> Group
grp [Choice Type2
1, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a (ArrayChoice -> ArrayChoice
arr [Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
native_script])]

script_any :: Named Group
script_any :: Named Group
script_any = Text
"script_any" Text -> Group -> Named Group
=:~ Group -> Group
grp [Choice Type2
2, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a (ArrayChoice -> ArrayChoice
arr [Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
native_script])]

script_n_of_k :: Named Group
script_n_of_k :: Named Group
script_n_of_k =
  Text
"script_n_of_k"
    Text -> Group -> Named Group
=:~ Group -> Group
grp [Choice Type2
3, Key
"n" forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
int64, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a (ArrayChoice -> ArrayChoice
arr [Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
native_script])]

invalid_before :: Named Group
invalid_before :: Named Group
invalid_before = Text
"invalid_before" Text -> Group -> Named Group
=:~ Group -> Group
grp [Choice Type2
4, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
slot_no]

invalid_hereafter :: Named Group
invalid_hereafter :: Named Group
invalid_hereafter = Text
"invalid_hereafter" Text -> Group -> Named Group
=:~ Group -> Group
grp [Choice Type2
5, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
slot_no]

multiasset :: IsType0 a => a -> GRuleCall
multiasset :: forall t0. IsType0 t0 => t0 -> GRuleCall
multiasset = forall t0. IsType0 t0 => (GRef -> Rule) -> t0 -> GRuleCall
binding forall a b. (a -> b) -> a -> b
$ \GRef
x ->
  Text
"multiasset"
    forall a. IsType0 a => Text -> a -> Rule
=:= MapChoice -> MapChoice
mp [Word64
1 forall a. CanQuantify a => Word64 -> a -> a
<+ forall r. IsType0 r => r -> Key
asKey Rule
policy_id forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> MapChoice -> MapChoice
mp [Word64
1 forall a. CanQuantify a => Word64 -> a -> a
<+ forall r. IsType0 r => r -> Key
asKey Rule
asset_name forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> GRef
x]]

policy_id :: Rule
policy_id :: Rule
policy_id = Text
"policy_id" forall a. IsType0 a => Text -> a -> Rule
=:= Rule
scripthash

asset_name :: Rule
asset_name :: Rule
asset_name = Text
"asset_name" forall a. IsType0 a => Text -> a -> Rule
=:= Value ByteString
VBytes forall a s. (IsSizeable a, IsSize s) => Value a -> s -> Constrained
`sized` (Word64
0 :: Word64, Word64
32 :: Word64)

value :: Rule
value :: Rule
value = Text
"value" forall a. IsType0 a => Text -> a -> Rule
=:= Rule
coin forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> Seal Array
sarr [forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
coin, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a (forall t0. IsType0 t0 => t0 -> GRuleCall
multiasset Rule
positive_coin)]

mint :: Rule
mint :: Rule
mint = Text
"mint" forall a. IsType0 a => Text -> a -> Rule
=:= forall t0. IsType0 t0 => t0 -> GRuleCall
multiasset Rule
nonZeroInt64

network_id :: Rule
network_id :: Rule
network_id = Text
"network_id" forall a. IsType0 a => Text -> a -> Rule
=:= Integer -> Literal
int Integer
0 forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Integer -> Literal
int Integer
1

epoch_no :: Rule
epoch_no :: Rule
epoch_no = Text
"epoch_no" forall a. IsType0 a => Text -> a -> Rule
=:= Value Int
VUInt forall a s. (IsSizeable a, IsSize s) => Value a -> s -> Constrained
`sized` (Word64
8 :: Word64)

epoch_interval :: Rule
epoch_interval :: Rule
epoch_interval = Text
"epoch_interval" forall a. IsType0 a => Text -> a -> Rule
=:= Value Int
VUInt forall a s. (IsSizeable a, IsSize s) => Value a -> s -> Constrained
`sized` (Word64
4 :: Word64)

slot_no :: Rule
slot_no :: Rule
slot_no = Text
"slot_no" forall a. IsType0 a => Text -> a -> Rule
=:= Value Int
VUInt forall a s. (IsSizeable a, IsSize s) => Value a -> s -> Constrained
`sized` (Word64
8 :: Word64)

block_no :: Rule
block_no :: Rule
block_no = Text
"block_no" forall a. IsType0 a => Text -> a -> Rule
=:= Value Int
VUInt forall a s. (IsSizeable a, IsSize s) => Value a -> s -> Constrained
`sized` (Word64
8 :: Word64)

auxiliary_data_hash :: Rule
auxiliary_data_hash :: Rule
auxiliary_data_hash = Text
"auxiliary_data_hash" forall a. IsType0 a => Text -> a -> Rule
=:= Rule
hash32

pool_metadata_hash :: Rule
pool_metadata_hash :: Rule
pool_metadata_hash = Text
"pool_metadata_hash" forall a. IsType0 a => Text -> a -> Rule
=:= Rule
hash32

-- 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 in the Conway era are:
--   "\x00" for multisig scripts
--   "\x01" for Plutus V1 scripts
--   "\x02" for Plutus V2 scripts
--   "\x03" for Plutus V3 scripts
scripthash :: Rule
scripthash :: Rule
scripthash =
  forall a. Text -> Named a -> Named a
comment
    ( Text
"To compute a script hash, note that you must prepend\n"
        forall a. Semigroup a => a -> a -> a
<> Text
"a tag to the bytes of the script before hashing.\n"
        forall a. Semigroup a => a -> a -> a
<> Text
"The tag is determined by the language.\n"
        forall a. Semigroup a => a -> a -> a
<> Text
"The tags in the Conway era are:\n"
        forall a. Semigroup a => a -> a -> a
<> Text
"\"\\x00\" for multisig scripts\n"
        forall a. Semigroup a => a -> a -> a
<> Text
"\"\\x01\" for Plutus V1 scripts\n"
        forall a. Semigroup a => a -> a -> a
<> Text
"\"\\x02\" for Plutus V2 scripts\n"
        forall a. Semigroup a => a -> a -> a
<> Text
"\"\\x03\" for Plutus V3 scripts\n"
    )
    forall a b. (a -> b) -> a -> b
$ Text
"scripthash" forall a. IsType0 a => Text -> a -> Rule
=:= Rule
hash28

datum_hash :: Rule
datum_hash :: Rule
datum_hash = Text
"datum_hash" forall a. IsType0 a => Text -> a -> Rule
=:= Rule
hash32

data_a :: Rule
data_a :: Rule
data_a = Text
"data" forall a. IsType0 a => Text -> a -> Rule
=:= forall a. Word64 -> a -> Tagged a
tag Word64
24 (Value ByteString
VBytes Value ByteString -> Rule -> Constrained
`cbor` Rule
plutus_data)

datum_option :: Rule
datum_option :: Rule
datum_option = Text
"datum_option" forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr [ArrayEntry
0, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
hash32] forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [ArrayEntry
1, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
data_a]

script_ref :: Rule
script_ref :: Rule
script_ref = Text
"script_ref" forall a. IsType0 a => Text -> a -> Rule
=:= forall a. Word64 -> a -> Tagged a
tag Word64
24 (Value ByteString
VBytes Value ByteString -> Rule -> Constrained
`cbor` Rule
script)

script :: Rule
script :: Rule
script =
  Text
"script"
    forall a. IsType0 a => Text -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr [ArrayEntry
0, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
native_script]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [ArrayEntry
1, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
plutus_v1_script]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [ArrayEntry
2, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
plutus_v2_script]
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [ArrayEntry
3, forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
plutus_v3_script]

-- Conway era introduces an optional 258 tag for sets, which will become mandatory in the
-- second era after Conway. We recommend all the tooling to account for this future breaking
-- change sooner rather than later, in order to provide a smooth transition for their users.

set :: IsType0 t0 => t0 -> GRuleCall
set :: forall t0. IsType0 t0 => t0 -> GRuleCall
set = forall t0. IsType0 t0 => (GRef -> Rule) -> t0 -> GRuleCall
binding forall a b. (a -> b) -> a -> b
$ \GRef
x -> Text
"set" forall a. IsType0 a => Text -> a -> Rule
=:= forall a. Word64 -> a -> Tagged a
tag Word64
258 (ArrayChoice -> ArrayChoice
arr [Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a GRef
x]) forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> Seal Array
sarr [Word64
0 forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a GRef
x]

nonempty_set :: IsType0 t0 => t0 -> GRuleCall
nonempty_set :: forall t0. IsType0 t0 => t0 -> GRuleCall
nonempty_set = forall t0. IsType0 t0 => (GRef -> Rule) -> t0 -> GRuleCall
binding forall a b. (a -> b) -> a -> b
$ \GRef
x ->
  Text
"nonempty_set"
    forall a. IsType0 a => Text -> a -> Rule
=:= forall a. Word64 -> a -> Tagged a
tag Word64
258 (ArrayChoice -> ArrayChoice
arr [Word64
1 forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a GRef
x])
    forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> Seal Array
sarr [Word64
1 forall a. CanQuantify a => Word64 -> a -> a
<+ forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a GRef
x]