2929module LinearVesting.Validator where
3030
3131import PlutusTx
32+ import PlutusTx.Builtins.Internal qualified as BI
3233import PlutusTx.Prelude
3334import Prelude qualified as Haskell
3435
@@ -38,6 +39,8 @@ import PlutusLedgerApi.V3.Data.Contexts (txSignedBy)
3839import PlutusTx.Data.List (List )
3940import PlutusTx.Data.List qualified as List
4041
42+ {-# ANN module ("onchain-contract " :: Haskell.String) #-}
43+
4144data VestingDatum = VestingDatum
4245 { beneficiary :: Address
4346 , vestingAsset :: AssetClass
@@ -139,20 +142,37 @@ validateVestingFullUnlock ctx =
139142 vestingDatum :: VestingDatum = unsafeFromBuiltinData datum
140143 PubKeyCredential beneficiaryKey = addressCredential (beneficiary vestingDatum)
141144 in
142- if
143- | not (txSignedBy txInfo beneficiaryKey) ->
144- traceError " Missing beneficiary signature"
145- | vestingPeriodEnd vestingDatum >= currentTimeApproximation ->
146- traceError " Unlock not permitted until vestingPeriodEnd time"
147- | otherwise ->
148- True
145+ BI. ifThenElse
146+ (not (txSignedBy txInfo beneficiaryKey))
147+ (\ _ -> traceError " Missing beneficiary signature" )
148+ ( \ _ ->
149+ BI. ifThenElse
150+ (vestingPeriodEnd vestingDatum >= currentTimeApproximation)
151+ (\ _ -> traceError " Unlock not permitted until vestingPeriodEnd time" )
152+ (\ _ -> True )
153+ BI. unitval
154+ )
155+ BI. unitval
149156
150157getLowerInclusiveTimeRange :: POSIXTimeRange -> POSIXTime
151158getLowerInclusiveTimeRange = \ case
152159 Interval (LowerBound (Finite posixTime) inclusive) _upperBound ->
153160 if inclusive then posixTime else posixTime + 1
154161 _ -> traceError " Time range not Finite"
155162
163+ -- Evaluation was SUCCESSFUL, result is:
164+ -- ()
165+
166+ -- Execution budget spent:
167+ -- CPU 30,837,131
168+ -- MEM 131,619
169+
170+ -- Evaluation traces:
171+ -- 1. Parsing ScriptContext...
172+ -- 2. Parsed ScriptContext
173+ -- 3. Parsed Redeemer
174+ -- 4. Full unlock requested
175+ -- 5. Validation completed
156176{-# INLINEABLE typedValidator #-}
157177typedValidator :: ScriptContext -> Bool
158178typedValidator context =
0 commit comments