1111module Test.Cardano.Ledger.Conway.CDDL (
1212 module Test.Cardano.Ledger.Babbage.CDDL ,
1313 conwayCDDL ,
14- oset ,
1514 potential_languages ,
1615 pool_registration ,
1716 pool_retirement ,
@@ -29,11 +28,9 @@ module Test.Cardano.Ledger.Conway.CDDL (
2928 update_drep_cert ,
3029 block_no ,
3130 slot_no ,
32- set ,
3331 transaction_input ,
3432 withdrawals ,
3533 mint ,
36- nonempty_set ,
3734 voting_procedures ,
3835 anchor ,
3936 hard_fork_initiation_action ,
@@ -45,7 +42,6 @@ module Test.Cardano.Ledger.Conway.CDDL (
4542 gov_action_id ,
4643 policy_hash ,
4744 shelley_transaction_output ,
48- nonempty_oset ,
4945 epoch_interval ,
5046 ex_unit_prices ,
5147 pool_voting_thresholds ,
@@ -62,13 +58,19 @@ module Test.Cardano.Ledger.Conway.CDDL (
6258 metadata ,
6359 shelley_auxiliary_data ,
6460 shelley_ma_auxiliary_data ,
61+
62+ -- * Sets
63+ maybe_tagged_set ,
64+ maybe_tagged_nonempty_set ,
65+ maybe_tagged_oset ,
66+ maybe_tagged_nonempty_oset ,
6567) where
6668
6769import Cardano.Ledger.Conway (ConwayEra )
6870import Codec.CBOR.Cuddle.Comments ((//-) )
6971import Codec.CBOR.Cuddle.Huddle
7072import Data.Function (($) )
71- import Data.Text ( Text )
73+ import Data.Text qualified as T
7274import Data.Word (Word64 )
7375import GHC.Num (Integer )
7476import Test.Cardano.Ledger.Babbage.CDDL hiding (
@@ -81,15 +83,14 @@ import Test.Cardano.Ledger.Babbage.CDDL hiding (
8183 mint ,
8284 multiasset ,
8385 native_script ,
84- nonempty_set ,
8586 redeemers ,
8687 required_signers ,
8788 script_all ,
8889 script_any ,
8990 script_pubkey ,
90- set ,
9191 transaction_input ,
9292 transaction_metadatum_label ,
93+ untagged_set ,
9394 value ,
9495 withdrawals ,
9596 )
@@ -186,7 +187,7 @@ transaction_body :: Rule
186187transaction_body =
187188 " transaction_body"
188189 =:= mp
189- [ idx 0 ==> set transaction_input
190+ [ idx 0 ==> maybe_tagged_set transaction_input
190191 , idx 1 ==> arr [0 <+ a transaction_output]
191192 , idx 2 ==> coin
192193 , opt (idx 3 ==> slot_no)
@@ -196,12 +197,12 @@ transaction_body =
196197 , opt (idx 8 ==> slot_no) -- Validity interval start
197198 , opt (idx 9 ==> mint)
198199 , opt (idx 11 ==> script_data_hash)
199- , opt (idx 13 ==> nonempty_set transaction_input)
200+ , opt (idx 13 ==> maybe_tagged_nonempty_set transaction_input)
200201 , opt (idx 14 ==> required_signers)
201202 , opt (idx 15 ==> network_id)
202203 , opt (idx 16 ==> transaction_output)
203204 , opt (idx 17 ==> coin)
204- , opt (idx 18 ==> nonempty_set transaction_input)
205+ , opt (idx 18 ==> maybe_tagged_nonempty_set transaction_input)
205206 , opt (idx 19 ==> voting_procedures)
206207 , opt (idx 20 ==> proposal_procedures)
207208 , opt (idx 21 ==> coin)
@@ -227,10 +228,10 @@ proposal_procedure =
227228 ]
228229
229230proposal_procedures :: Rule
230- proposal_procedures = " proposal_procedures" =:= nonempty_oset proposal_procedure
231+ proposal_procedures = " proposal_procedures" =:= maybe_tagged_nonempty_oset proposal_procedure
231232
232233certificates :: Rule
233- certificates = " certificates" =:= nonempty_oset certificate
234+ certificates = " certificates" =:= maybe_tagged_nonempty_oset certificate
234235
235236gov_action :: Rule
236237gov_action =
@@ -275,7 +276,7 @@ update_committee =
275276 =:~ grp
276277 [ 4
277278 , a $ gov_action_id / VNil
278- , a (set committee_cold_credential)
279+ , a (maybe_tagged_set committee_cold_credential)
279280 , a (mp [0 <+ asKey committee_cold_credential ==> epoch_no])
280281 , a unit_interval
281282 ]
@@ -325,7 +326,7 @@ gov_action_id =
325326 ]
326327
327328required_signers :: Rule
328- required_signers = " required_signers" =:= nonempty_set addr_keyhash
329+ required_signers = " required_signers" =:= maybe_tagged_nonempty_set addr_keyhash
329330
330331transaction_input :: Rule
331332transaction_input =
@@ -540,7 +541,7 @@ pool_params =
540541 , " cost" ==> coin
541542 , " margin" ==> unit_interval
542543 , " reward_account" ==> reward_account
543- , " pool_owners" ==> set addr_keyhash
544+ , " pool_owners" ==> maybe_tagged_set addr_keyhash
544545 , " relays" ==> arr [0 <+ a relay]
545546 , " pool_metadata" ==> (pool_metadata / VNil )
546547 ]
@@ -646,14 +647,14 @@ transaction_witness_set :: Rule
646647transaction_witness_set =
647648 " transaction_witness_set"
648649 =:= mp
649- [ opt $ idx 0 ==> nonempty_set vkeywitness
650- , opt $ idx 1 ==> nonempty_set native_script
651- , opt $ idx 2 ==> nonempty_set bootstrap_witness
652- , opt $ idx 3 ==> nonempty_set plutus_v1_script
653- , opt $ idx 4 ==> nonempty_set plutus_data
650+ [ opt $ idx 0 ==> maybe_tagged_nonempty_set vkeywitness
651+ , opt $ idx 1 ==> maybe_tagged_nonempty_set native_script
652+ , opt $ idx 2 ==> maybe_tagged_nonempty_set bootstrap_witness
653+ , opt $ idx 3 ==> maybe_tagged_nonempty_set plutus_v1_script
654+ , opt $ idx 4 ==> maybe_tagged_nonempty_set plutus_data
654655 , opt $ idx 5 ==> redeemers conway_redeemer_tag
655- , opt $ idx 6 ==> nonempty_set plutus_v2_script
656- , opt $ idx 7 ==> nonempty_set plutus_v3_script
656+ , opt $ idx 6 ==> maybe_tagged_nonempty_set plutus_v2_script
657+ , opt $ idx 7 ==> maybe_tagged_nonempty_set plutus_v3_script
657658 ]
658659
659660plutus_v1_script :: Rule
@@ -863,27 +864,19 @@ conway_script =
863864 / arr [2 , a plutus_v2_script]
864865 / arr [3 , a plutus_v3_script]
865866
866- -- | Conway era introduces an optional 258 tag for sets, which will
867- -- become mandatory in the second era after Conway. We recommend all the
868- -- tooling to account for this future breaking change sooner rather than
869- -- later, in order to provide a smooth transition for their users.
870- set :: IsType0 t0 => t0 -> GRuleCall
871- set = set_len_spec " set" 0
872-
873- -- | Conway era introduces an optional 258 tag for sets, which will
874- -- become mandatory in the second era after Conway. We recommend all the
875- -- tooling to account for this future breaking change sooner rather than
876- -- later, in order to provide a smooth transition for their users.
877- nonempty_set :: IsType0 t0 => t0 -> GRuleCall
878- nonempty_set = set_len_spec " nonempty_set" 1
879-
880- -- | An OSet is a Set that preserves the order of its elements.
881- oset :: IsType0 t0 => t0 -> GRuleCall
882- oset = set_len_spec " oset" 0
883-
884- -- | An NonEmpty OSet is a NonEmpty Set that preserves the order of its elements.
885- nonempty_oset :: IsType0 t0 => t0 -> GRuleCall
886- nonempty_oset = set_len_spec " nonempty_oset" 1
887-
888- set_len_spec :: IsType0 t0 => Text -> Word64 -> t0 -> GRuleCall
889- set_len_spec label n = binding $ \ x -> label =:= tag 258 (arr [n <+ a x]) / sarr [n <+ a x]
867+ -- | Conway era introduces an optional 258 tag for sets, which will become
868+ -- mandatory in the second era after Conway.
869+ mkMaybeTaggedSet :: IsType0 a => T. Text -> Word64 -> a -> GRuleCall
870+ mkMaybeTaggedSet label n = binding $ \ x -> label =:= tag 258 (arr [n <+ a x]) / sarr [n <+ a x]
871+
872+ maybe_tagged_set :: IsType0 a => a -> GRuleCall
873+ maybe_tagged_set = mkMaybeTaggedSet " set" 0
874+
875+ maybe_tagged_nonempty_set :: IsType0 a => a -> GRuleCall
876+ maybe_tagged_nonempty_set = mkMaybeTaggedSet " nonempty_set" 1
877+
878+ maybe_tagged_oset :: IsType0 a => a -> GRuleCall
879+ maybe_tagged_oset = mkMaybeTaggedSet " oset" 0
880+
881+ maybe_tagged_nonempty_oset :: IsType0 a => a -> GRuleCall
882+ maybe_tagged_nonempty_oset = mkMaybeTaggedSet " nonempty_oset" 1
0 commit comments