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 Jan 10, 2023
1 parent 0a72945 commit a4badce
Show file tree
Hide file tree
Showing 6 changed files with 189 additions and 373 deletions.
20 changes: 8 additions & 12 deletions cardano-api/gen/Gen/Cardano/Api/Typed.hs
Expand Up @@ -179,27 +179,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
Expand Up @@ -336,18 +336,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 @@ -388,9 +385,6 @@ module Cardano.Api (
-- ** Simple scripts
-- | Making multi-signature and time-lock scripts.
SimpleScript(..),
TimeLocksSupported(..),
timeLocksSupported,
adjustSimpleScriptVersion,

-- ** Plutus scripts
PlutusScript,
Expand Down

0 comments on commit a4badce

Please sign in to comment.