Skip to content

Commit 3e889e4

Browse files
committed
Introduce gov/committee/v0 namespace
1 parent 20921c1 commit 3e889e4

File tree

6 files changed

+55
-17
lines changed

6 files changed

+55
-17
lines changed

scls-cddl/cddl-src/Cardano/SCLS/CDDL.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module Cardano.SCLS.CDDL (
66
) where
77

88
import Cardano.SCLS.Namespace.Blocks qualified as Blocks
9+
import Cardano.SCLS.Namespace.GovCommittee qualified as GovCommittee
910
import Cardano.SCLS.Namespace.GovConstitution qualified as GovConstitution
1011
import Cardano.SCLS.Namespace.GovPParams qualified as GovPParams
1112
import Cardano.SCLS.Namespace.PoolStake qualified as PoolStake
@@ -34,6 +35,7 @@ namespaces =
3435
, ("pots/v0", NamespaceInfo (collectFromInit [HIRule Pots.record_entry]) 8) -- Key is epoch number
3536
, ("pool_stake/v0", NamespaceInfo (collectFromInit [HIRule PoolStake.record_entry]) 28) -- 28 bytes for key
3637
, ("snapshots/v0", NamespaceInfo (collectFromInit [HIRule Snapshots.record_entry]) 30)
38+
, ("gov/committee/v0", NamespaceInfo (collectFromInit [HIRule GovCommittee.record_entry]) 8)
3739
, ("gov/constitution/v0", NamespaceInfo (collectFromInit [HIRule GovConstitution.record_entry]) 8)
3840
, ("gov/pparams/v0", NamespaceInfo (collectFromInit [HIRule GovPParams.record_entry]) 4)
3941
]

scls-cddl/cddl-src/Cardano/SCLS/Common.hs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,15 @@ positive_int = "positive_int" =:= (1 :: Integer) ... maxWord64
188188
maxWord64 :: Integer
189189
maxWord64 = 18446744073709551615
190190

191+
credential :: Rule
192+
credential =
193+
"credential"
194+
=:= arr [0, a addr_keyhash]
195+
/ arr [1, a script_hash]
196+
197+
addr_keyhash :: Rule
198+
addr_keyhash = "addr_keyhash" =:= hash28
199+
191200
script_hash :: Rule
192201
script_hash =
193202
comment
@@ -201,3 +210,14 @@ script_hash =
201210
| - "\x03" for Plutus V3 scripts
202211
|]
203212
$ "script_hash" =:= hash28
213+
214+
anchor :: Rule
215+
anchor =
216+
"anchor"
217+
=:= arr
218+
[ "anchor_url" ==> url
219+
, "anchor_data_hash" ==> hash32
220+
]
221+
222+
epoch_no :: Rule
223+
epoch_no = "epoch_no" =:= VUInt `sized` (8 :: Word64)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{-# LANGUAGE ImportQualifiedPost #-}
2+
{-# LANGUAGE OverloadedLists #-}
3+
{-# LANGUAGE OverloadedStrings #-}
4+
{-# LANGUAGE QuasiQuotes #-}
5+
{-# LANGUAGE TypeApplications #-}
6+
{-# LANGUAGE NoImplicitPrelude #-}
7+
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
8+
9+
{-# HLINT ignore "Use camelCase" #-}
10+
module Cardano.SCLS.Namespace.GovCommittee where
11+
12+
import Cardano.SCLS.Common
13+
import Codec.CBOR.Cuddle.Huddle
14+
import Data.Function (($))
15+
import Text.Heredoc (str)
16+
17+
record_entry :: Rule
18+
record_entry =
19+
comment
20+
[str| The key for the entry is epoch number (8 bytes) |]
21+
$ "record_entry" =:= committee
22+
23+
committee :: Rule
24+
committee =
25+
"committee"
26+
=:= (mp [0 <+ asKey credential ==> committee_authorization])
27+
28+
committee_authorization :: Rule
29+
committee_authorization =
30+
"committee_authorization"
31+
=:= arr [0, a credential]
32+
/ arr [1, a (anchor / VNil)]

scls-cddl/cddl-src/Cardano/SCLS/Namespace/GovConstitution.hs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,6 @@ record_entry =
2121
|]
2222
$ "record_entry" =:= constitution
2323

24-
anchor :: Rule
25-
anchor =
26-
"anchor"
27-
=:= arr
28-
[ "anchor_url" ==> url
29-
, "anchor_data_hash" ==> hash32
30-
]
31-
3224
constitution :: Rule
3325
constitution =
3426
"constitution"

scls-cddl/cddl-src/Cardano/SCLS/Namespace/Snapshots.hs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,6 @@ record_key =
3838
pool_keyhash :: Rule
3939
pool_keyhash = "pool_keyhash" =:= hash28
4040

41-
addr_keyhash :: Rule
42-
addr_keyhash = "addr_keyhash" =:= hash28
43-
44-
credential :: Rule
45-
credential =
46-
"credential"
47-
=:= arr [0, a addr_keyhash]
48-
/ arr [1, a script_hash]
49-
5041
snapshot_out :: Rule
5142
snapshot_out =
5243
comment

scls-cddl/scls-cddl.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ library
2929
other-modules:
3030
Cardano.SCLS.Common
3131
Cardano.SCLS.Namespace.Blocks
32+
Cardano.SCLS.Namespace.GovCommittee
3233
Cardano.SCLS.Namespace.GovConstitution
3334
Cardano.SCLS.Namespace.GovPParams
3435
Cardano.SCLS.Namespace.PoolStake

0 commit comments

Comments
 (0)