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

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

module Test.Cardano.Ledger.Mary.CDDL (
  module Test.Cardano.Ledger.Allegra.CDDL,
  module Test.Cardano.Ledger.Mary.CDDL,
) where

import Codec.CBOR.Cuddle.Huddle
import Data.Function (($))
import Data.Word (Word64)
import Test.Cardano.Ledger.Allegra.CDDL hiding (
  block,
  transaction,
  transaction_body,
  transaction_output,
 )

maryCDDL :: Huddle
maryCDDL :: Huddle
maryCDDL = [Rule] -> Huddle
collectFrom [Rule
block, Rule
transaction]

multiasset :: IsType0 a => a -> GRuleCall
multiasset :: forall a. IsType0 a => a -> 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
script_hash

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 a. IsType0 a => a -> GRuleCall
multiasset Value Int
VUInt)]

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

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 a. IsType0 a => a -> 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
      , Word64 -> Key
idx Word64
3 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Value Int
VUInt
      , 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
certificate])
      , 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
6 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
update)
      , forall a. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
7 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
metadata_hash)
      , 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. CanQuantify a => a -> a
opt (Word64 -> Key
idx Word64
9 forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
mint)
      ]

transaction_output :: Rule
transaction_output :: Rule
transaction_output = Text
"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]

block :: Rule
block :: Rule
block =
  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]
      ]

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 (Rule
auxiliary_data forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Value Void
VNil)
      ]