Skip to content

Commit ea46b36

Browse files
author
euonymos
committed
chore: cosmetic changes
1 parent d495eb1 commit ea46b36

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

example/CEM/Example/Auction.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ instance CEMScript SimpleAuction where
124124
( BuyoutSpine
125125
,
126126
[ input (ownUtxo $ inState WinnerSpine) auctionValue
127-
, byFlagError (lift False) "Some err"
128-
, byFlagError (lift False) "Another err"
129127
, -- Example: In constraints redundant for on-chain
130128
offchainOnly
131129
( if'

src/Cardano/CEM/OffChain.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ compileActionConstraints
166166
Map.! getSpine transition
167167
xSpine = transitionInStateSpine uncompiled
168168

169+
-- Check input state
169170
when (fmap getSpine mState /= xSpine) $
170171
throwError CEMScriptTxInResolutionError
171172

@@ -286,8 +287,8 @@ resolveTx spec = runExceptT $ do
286287
SomeCEMAction -> (ExceptT TxResolutionError m) [OffchainTxIR]
287288
resolveSomeAction (MkSomeCEMAction @script action) = do
288289
let MkCEMAction params _ = action
289-
mScript <- lift $ queryScriptState params
290-
cs <- ExceptT $ return $ compileActionConstraints mScript action
290+
mState <- lift $ queryScriptState params
291+
cs <- ExceptT $ return $ compileActionConstraints mState action
291292
mapM (process action) cs
292293

293294
resolveTxAndSubmitRet ::
@@ -368,7 +369,6 @@ compileConstraint datum transition c = case c of
368369
UserAddress dsl -> UserAddress <$> compileDslRecur dsl
369370
SameScript (MkSameScriptArg stateDsl) -> SameScript . MkSameScriptArg <$> compileDslRecur stateDsl
370371

371-
-- TODO: types errors
372372
compileDsl ::
373373
forall script x.
374374
(CEMScript script) =>

src/Cardano/CEM/OnChain.hs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,19 +165,26 @@ genericPlutarchScript spec code =
165165
script # params # state # redm
166166
Nothing -> ptraceInfo "transitionComp is nothing" perror
167167
-- Builds checks for transition (its spine)
168+
-- checks :: Spine (Transition script) -> Term s PUnit
168169
let checks = perTransitionCheck ctx.txInfo ownAddress comp
169170
-- Checks for transition spine from redeemer
170171
compileSpineCaseSwitch spineIndex checks
171172
where
172-
-- We are done
173-
174173
-- Builds 'Spine (Transition script) -> Term s PUnit'
175174
perTransitionCheck txInfo ownAddress comp transitionSpine = P.do
176175
ptraceDebug
177176
(pconstant $ fromString $ "Checking transition " <> Prelude.show transitionSpine)
178177
perTransitionCheck'
179178
where
180179
perTransitionCheck' = P.do
180+
-- Get constraints from the definition
181+
let constrs = case Map.lookup transitionSpine spec of
182+
Just x -> x
183+
Nothing ->
184+
error $
185+
"Compilation error: transition: "
186+
<> (Prelude.show transitionSpine)
187+
<> " lacks spec"
181188
pif
182189
-- Constraints
183190
( foldr
@@ -190,15 +197,6 @@ genericPlutarchScript spec code =
190197
-- Fail
191198
(ptraceInfoError "Constraint check failed")
192199

193-
-- Get constraints from the definition
194-
constrs = case Map.lookup transitionSpine spec of
195-
Just x -> x
196-
Nothing ->
197-
error $
198-
"Compilation error: transition: "
199-
<> (Prelude.show transitionSpine)
200-
<> " lacks spec"
201-
202200
-- Actual constraint compilation
203201
compileConstr :: TxConstraint False script -> Term s PBool
204202
compileConstr c = ptraceInfoIfFalse

0 commit comments

Comments
 (0)