@@ -4,34 +4,31 @@ module Cardano.Plutus.ApplyArgs
4
4
5
5
import Prelude
6
6
7
- import Cardano.Data.Lite as CSL
7
+ import Cardano.Data.Lite as CDL
8
8
import Cardano.Types (PlutusScript (PlutusScript))
9
9
import Cardano.Types.PlutusData (PlutusData (List))
10
10
import Cardano.Types.PlutusData as PlutusData
11
11
import Cardano.Types.PlutusScript (PlutusScript )
12
12
import Cardano.Types.PlutusScript as PlutusScript
13
- import Data.Bifunctor (rmap )
14
13
import Data.Either (Either (Left, Right))
15
- import Data.Newtype (unwrap , wrap )
16
14
import Data.Tuple.Nested ((/\))
17
15
18
16
foreign import apply_params_to_script
19
17
:: (forall a b . a -> Either a b )
20
18
-> (forall a b . b -> Either a b )
21
- -> CSL .PlutusData
22
- -> CSL .PlutusScript
23
- -> Either String CSL .PlutusScript
19
+ -> CDL .PlutusData
20
+ -> CDL .PlutusScript
21
+ -> Either String CDL .PlutusScript
24
22
25
23
apply_params_to_script_either
26
- :: CSL.PlutusData -> CSL.PlutusScript -> Either String CSL.PlutusScript
27
- apply_params_to_script_either = apply_params_to_script Left Right
24
+ :: CDL.PlutusData
25
+ -> CDL.PlutusScript
26
+ -> Either String CDL.PlutusScript
27
+ apply_params_to_script_either =
28
+ apply_params_to_script Left Right
28
29
29
- applyArgs
30
- :: PlutusScript -> Array PlutusData -> Either String PlutusScript
31
- applyArgs script@(PlutusScript (_ /\ langVersion)) paramsList = do
32
- let params = PlutusData .toCsl (List paramsList)
33
- appliedScript <- apply_params_to_script_either params
34
- (PlutusScript .toCsl script)
35
- -- We manually set PlutusScript.Language again since there's no roundtrip
36
- -- guarantee for this type.
37
- Right $ wrap $ rmap (const langVersion) $ unwrap $ PlutusScript .fromCsl appliedScript
30
+ applyArgs :: PlutusScript -> Array PlutusData -> Either String PlutusScript
31
+ applyArgs script@(PlutusScript (_ /\ lang)) paramsList = do
32
+ let params = PlutusData .toCdl (List paramsList)
33
+ appliedScript <- apply_params_to_script_either params $ PlutusScript .toCdl script
34
+ Right $ PlutusScript .fromCdl appliedScript lang
0 commit comments