Skip to content

Commit

Permalink
Replace SimpleScriptV1 and SimpleScriptV2 type level tags with
Browse files Browse the repository at this point in the history
SimpleScript'
Remove type variable from SimpleScript data declaration
  • Loading branch information
Jimbo4350 committed Feb 27, 2023
1 parent ec57638 commit 0fc287f
Show file tree
Hide file tree
Showing 6 changed files with 195 additions and 378 deletions.
20 changes: 8 additions & 12 deletions cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -182,27 +182,23 @@ genLovelace = Lovelace <$> Gen.integral (Range.linear 0 5000)
--

genScript :: ScriptLanguage lang -> Gen (Script lang)
genScript (SimpleScriptLanguage lang) =
SimpleScript lang <$> genSimpleScript lang
genScript SimpleScriptLanguage =
SimpleScript <$> genSimpleScript
genScript (PlutusScriptLanguage lang) =
PlutusScript lang <$> genPlutusScript lang

genSimpleScript :: SimpleScriptVersion lang -> Gen (SimpleScript lang)
genSimpleScript lang =
genSimpleScript :: Gen SimpleScript
genSimpleScript =
genTerm
where
genTerm = Gen.recursive Gen.choice nonRecursive recursive

-- Non-recursive generators
nonRecursive =
(RequireSignature . verificationKeyHash <$>
genVerificationKey AsPaymentKey)

: [ RequireTimeBefore supported <$> genSlotNo
| supported <- maybeToList (timeLocksSupported lang) ]

++ [ RequireTimeAfter supported <$> genSlotNo
| supported <- maybeToList (timeLocksSupported lang) ]
[ RequireSignature . verificationKeyHash <$> genVerificationKey AsPaymentKey
, RequireTimeBefore <$> genSlotNo
, RequireTimeAfter <$> genSlotNo
]

-- Recursive generators
recursive =
Expand Down
8 changes: 1 addition & 7 deletions cardano-api/src/Cardano/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -337,18 +337,15 @@ module Cardano.Api (
-- | Both 'PaymentCredential's and 'StakeCredential's can use scripts.

-- ** Script languages
SimpleScriptV1,
SimpleScriptV2,
SimpleScript',
PlutusScriptV1,
PlutusScriptV2,
ScriptLanguage(..),
SimpleScriptVersion(..),
PlutusScriptVersion(..),
AnyScriptLanguage(..),
AnyPlutusScriptVersion(..),
IsPlutusScriptLanguage(..),
IsScriptLanguage(..),
IsSimpleScriptLanguage(..),

-- ** Scripts in a specific language
Script(..),
Expand Down Expand Up @@ -389,9 +386,6 @@ module Cardano.Api (
-- ** Simple scripts
-- | Making multi-signature and time-lock scripts.
SimpleScript(..),
TimeLocksSupported(..),
timeLocksSupported,
adjustSimpleScriptVersion,

-- ** Plutus scripts
PlutusScript,
Expand Down
Loading

0 comments on commit 0fc287f

Please sign in to comment.