{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
{-# HLINT ignore "Use camelCase" #-}
module Cardano.Ledger.CanonicalState.Namespace.UTxO.V0.CDDL where
import Cardano.Ledger.CanonicalState.Namespace.CDDL.Common
import Codec.CBOR.Cuddle.Comments ((//-))
import Codec.CBOR.Cuddle.Huddle
import Data.Function (($))
import Text.Heredoc (str)
import Prelude (foldr, (++))
record_entry :: Rule
record_entry :: Rule
record_entry =
Comment -> Rule -> Rule
forall a. HasComment a => Comment -> a -> a
comment
Comment
[str| The key for the entry is one of the following:
|
| ```
| meta:
| endian: be
|
| seq:
| - id: key
| type: utxo_key
|
| types:
| utxo_key:
| seq:
| - id: tx_addr
| doc: transaction
| type: bytes
| size: 28
| - id: tx_idx
| doc: index inside transaction
| type: u4
| ```
|
|]
(Rule -> Rule) -> Rule -> Rule
forall a b. (a -> b) -> a -> b
$ Name
"record_entry" Name -> Rule -> Rule
forall a. IsType0 a => Name -> a -> Rule
=:= Rule
tx_out
tx_out :: Rule
tx_out :: Rule
tx_out = Name
"tx_out" Name -> Constrained -> Rule
forall a. IsType0 a => Name -> a -> Rule
=:= Value ByteString
VBytes Value ByteString -> Rule -> Constrained
forall b c.
(IsCborable b, IsConstrainable c b) =>
c -> Rule -> Constrained
`cbor` Rule
tx_rule
tx_rule :: Rule
tx_rule :: Rule
tx_rule = Name
"rule" Name -> Choice Type2 -> Rule
forall a. IsType0 a => Name -> a -> Rule
=:= Rule
shelley_tx_out Rule -> Rule -> Choice Type2
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Rule
babbage_tx_out
shelley_tx_out :: Rule
shelley_tx_out :: Rule
shelley_tx_out =
Name
"shelley_tx_out"
Name -> ArrayChoice -> Rule
forall a. IsType0 a => Name -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr [Rule -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
address, Key
"amount" Key -> Rule -> ArrayEntry
forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
value, ArrayEntry -> ArrayEntry
forall a. CanQuantify a => a -> a
opt (Key
"datum_hash" Key -> Rule -> ArrayEntry
forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
hash32)]
babbage_tx_out :: Rule
babbage_tx_out :: Rule
babbage_tx_out =
Comment -> Rule -> Rule
forall a. HasComment a => Comment -> a -> a
comment
Comment
[str|NEW starting with babbage
| datum_option
| script_ref
|]
(Rule -> Rule) -> Rule -> Rule
forall a b. (a -> b) -> a -> b
$ Name
"babbage_tx_out"
Name -> MapChoice -> Rule
forall a. IsType0 a => Name -> a -> Rule
=:= MapChoice -> MapChoice
mp
[ Word64 -> Key
idx Word64
0 Key -> Rule -> MapEntry
forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
address
, Word64 -> Key
idx Word64
1 Key -> Rule -> MapEntry
forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
value
, Item MapChoice -> Item MapChoice
forall a. CanQuantify a => a -> a
opt (Item MapChoice -> Item MapChoice)
-> Item MapChoice -> Item MapChoice
forall a b. (a -> b) -> a -> b
$ Word64 -> Key
idx Word64
2 Key -> Rule -> MapEntry
forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
datum_option
, Item MapChoice -> Item MapChoice
forall a. CanQuantify a => a -> a
opt (Item MapChoice -> Item MapChoice)
-> Item MapChoice -> Item MapChoice
forall a b. (a -> b) -> a -> b
$ Word64 -> Key
idx Word64
3 Key -> Rule -> MapEntry
forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
script_ref
]
plutus_data :: Rule
plutus_data :: Rule
plutus_data =
Name
"plutus_data"
Name -> Choice Type2 -> Rule
forall a. IsType0 a => Name -> a -> Rule
=:= Rule -> GRuleCall
forall x. IsType0 x => x -> GRuleCall
constr Rule
plutus_data
GRuleCall -> Seal Map -> Choice Type2
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ 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
plutus_data Key -> Rule -> MapEntry
forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
plutus_data]
Choice Type2 -> Seal (Choice ArrayChoice) -> Choice Type2
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> Seal (Choice ArrayChoice)
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
plutus_data]
Choice Type2 -> Rule -> Choice Type2
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Rule
big_int
Choice Type2 -> Value ByteString -> Choice Type2
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Value ByteString
VBytes
data' :: Rule
data' :: Rule
data' = Name
"data" Name -> Tagged Constrained -> Rule
forall a. IsType0 a => Name -> a -> Rule
=:= Word64 -> Constrained -> Tagged Constrained
forall a. Word64 -> a -> Tagged a
tag Word64
24 (Value ByteString
VBytes Value ByteString -> Rule -> Constrained
forall b c.
(IsCborable b, IsConstrainable c b) =>
c -> Rule -> Constrained
`cbor` Rule
plutus_data)
datum_option :: Rule
datum_option :: Rule
datum_option = Name
"datum_option" Name -> Choice ArrayChoice -> Rule
forall a. IsType0 a => Name -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr [Item ArrayChoice
ArrayEntry
0, Rule -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
hash32] ArrayChoice -> ArrayChoice -> Choice ArrayChoice
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
data']
constr :: IsType0 x => x -> GRuleCall
constr :: forall x. IsType0 x => x -> GRuleCall
constr = (GRef -> Rule) -> x -> GRuleCall
forall t0. IsType0 t0 => (GRef -> Rule) -> t0 -> GRuleCall
binding ((GRef -> Rule) -> x -> GRuleCall)
-> (GRef -> Rule) -> x -> GRuleCall
forall a b. (a -> b) -> a -> b
$ \GRef
x ->
Comment -> Rule -> Rule
forall a. HasComment a => Comment -> a -> a
comment
Comment
[str|NEW
| #6.102([uint, [* a]]): For tag range 6.1280 .. 6.1400 inclusive
|]
(Rule -> Rule) -> Rule -> Rule
forall a b. (a -> b) -> a -> b
$ Name
"constr"
Name -> Choice Type2 -> Rule
forall a. IsType0 a => Name -> a -> Rule
=:= (Tagged ArrayChoice -> Choice Type2 -> Choice Type2)
-> Choice Type2 -> [Tagged ArrayChoice] -> Choice Type2
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr
Tagged ArrayChoice -> Choice Type2 -> Choice Type2
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
(/)
( Word64 -> ArrayChoice -> Tagged ArrayChoice
forall a. Word64 -> a -> Tagged a
tag Word64
121 (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])
Tagged ArrayChoice -> Tagged ArrayChoice -> Choice Type2
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Word64 -> ArrayChoice -> Tagged ArrayChoice
forall a. Word64 -> a -> Tagged a
tag Word64
102 (ArrayChoice -> ArrayChoice
arr [Value Int -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Value Int
VUInt, ArrayChoice -> Item ArrayChoice
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a (ArrayChoice -> Item ArrayChoice)
-> ArrayChoice -> Item ArrayChoice
forall a b. (a -> b) -> a -> b
$ 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]])
)
( [Word64 -> ArrayChoice -> Tagged ArrayChoice
forall a. Word64 -> a -> Tagged a
tag Word64
i (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]) | Word64
i <- [Word64
Item [Word64]
122 .. Word64
Item [Word64]
127]]
[Tagged ArrayChoice]
-> [Tagged ArrayChoice] -> [Tagged ArrayChoice]
forall a. [a] -> [a] -> [a]
++ [Word64 -> ArrayChoice -> Tagged ArrayChoice
forall a. Word64 -> a -> Tagged a
tag Word64
i (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]) | Word64
i <- [Word64
Item [Word64]
1280 .. Word64
Item [Word64]
1400]]
)
script_ref :: Rule
script_ref :: Rule
script_ref = Name
"script_ref" Name -> Tagged Constrained -> Rule
forall a. IsType0 a => Name -> a -> Rule
=:= Word64 -> Constrained -> Tagged Constrained
forall a. Word64 -> a -> Tagged a
tag Word64
24 (Value ByteString
VBytes Value ByteString -> Rule -> Constrained
forall b c.
(IsCborable b, IsConstrainable c b) =>
c -> Rule -> Constrained
`cbor` Rule
script)
script :: Rule
script :: Rule
script =
Name
"script"
Name -> Choice ArrayChoice -> Rule
forall a. IsType0 a => Name -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr [Item ArrayChoice
ArrayEntry
0, Rule -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
native_script]
ArrayChoice -> ArrayChoice -> Choice ArrayChoice
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ (ArrayChoice -> ArrayChoice
arr [Item ArrayChoice
ArrayEntry
1, Value ByteString -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Value ByteString
VBytes] ArrayChoice -> Comment -> ArrayChoice
forall a. HasComment a => a -> Comment -> a
//- Comment
"Plutus V1")
Choice ArrayChoice -> ArrayChoice -> Choice ArrayChoice
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ (ArrayChoice -> ArrayChoice
arr [Item ArrayChoice
ArrayEntry
2, Value ByteString -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Value ByteString
VBytes] ArrayChoice -> Comment -> ArrayChoice
forall a. HasComment a => a -> Comment -> a
//- Comment
"Plutus V2")
Choice ArrayChoice -> ArrayChoice -> Choice ArrayChoice
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ (ArrayChoice -> ArrayChoice
arr [Item ArrayChoice
ArrayEntry
3, Value ByteString -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Value ByteString
VBytes] ArrayChoice -> Comment -> ArrayChoice
forall a. HasComment a => a -> Comment -> a
//- Comment
"Plutus V3")
native_script :: Rule
native_script :: Rule
native_script =
Name
"native_script"
Name -> Choice ArrayChoice -> Rule
forall a. IsType0 a => Name -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr [GroupDef -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a GroupDef
script_pubkey]
ArrayChoice -> ArrayChoice -> Choice ArrayChoice
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [GroupDef -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a GroupDef
script_all]
Choice ArrayChoice -> ArrayChoice -> Choice ArrayChoice
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [GroupDef -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a GroupDef
script_any]
Choice ArrayChoice -> ArrayChoice -> Choice ArrayChoice
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [GroupDef -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a GroupDef
script_n_of_k]
Choice ArrayChoice -> ArrayChoice -> Choice ArrayChoice
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [GroupDef -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a GroupDef
invalid_before]
Choice ArrayChoice -> ArrayChoice -> Choice ArrayChoice
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ ArrayChoice -> ArrayChoice
arr [GroupDef -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a GroupDef
invalid_hereafter]
script_pubkey :: GroupDef
script_pubkey :: GroupDef
script_pubkey = Name
"script_pubkey" Name -> Group -> GroupDef
=:~ Group -> Group
grp [Item Group
ArrayEntry
0, Rule -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
hash28]
script_all :: GroupDef
script_all :: GroupDef
script_all = Name
"script_all" Name -> Group -> GroupDef
=:~ 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
<+ Rule -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
native_script])]
script_any :: GroupDef
script_any :: GroupDef
script_any = Name
"script_any" Name -> Group -> GroupDef
=:~ 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
<+ Rule -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
native_script])]
script_n_of_k :: GroupDef
script_n_of_k :: GroupDef
script_n_of_k =
Name
"script_n_of_k"
Name -> Group -> GroupDef
=:~ Group -> Group
grp [Item Group
ArrayEntry
3, Key
"n" Key -> Rule -> ArrayEntry
forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
int64, 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
<+ Rule -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
native_script])]
invalid_before :: GroupDef
invalid_before :: GroupDef
invalid_before = Name
"invalid_before" Name -> Group -> GroupDef
=:~ Group -> Group
grp [Item Group
ArrayEntry
4, Rule -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
slot_no]
invalid_hereafter :: GroupDef
invalid_hereafter :: GroupDef
invalid_hereafter = Name
"invalid_hereafter" Name -> Group -> GroupDef
=:~ Group -> Group
grp [Item Group
ArrayEntry
5, Rule -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
slot_no]