Skip to content

Commit aa8169e

Browse files
committed
Do not query datums by hash in processConstraints
1 parent 44fd4a0 commit aa8169e

File tree

3 files changed

+2
-18
lines changed

3 files changed

+2
-18
lines changed

src/Contract/UnbalancedTx.purs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import Ctl.Internal.ProcessConstraints.Error
1818
import Ctl.Internal.ProcessConstraints.Error
1919
( MkUnbalancedTxError
2020
( CannotFindDatum
21-
, CannotQueryDatum
2221
, CannotConvertPOSIXTimeRange
2322
, CannotSolveTimeConstraints
2423
, CannotGetMintingPolicyScriptIndex

src/Internal/ProcessConstraints.purs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ import Ctl.Internal.ProcessConstraints.Error
8181
, CannotMintZero
8282
, ExpectedPlutusScriptGotNativeScript
8383
, CannotFindDatum
84-
, CannotQueryDatum
8584
, CannotGetValidatorHashFromAddress
8685
, TxOutRefWrongType
8786
, CannotConvertPOSIXTimeRange
@@ -173,7 +172,7 @@ import Ctl.Internal.Types.Val as Val
173172
import Data.Array (cons, partition, toUnfoldable, zip)
174173
import Data.Array (mapMaybe, singleton, (:)) as Array
175174
import Data.Bifunctor (lmap)
176-
import Data.Either (Either(Left, Right), either, hush, isRight, note)
175+
import Data.Either (Either(Left, Right), either, note)
177176
import Data.Foldable (foldM)
178177
import Data.Lens ((%=), (%~), (.=), (.~), (<>=))
179178
import Data.Lens.Getter (to, use)
@@ -192,7 +191,6 @@ import Effect.Aff.Class (liftAff)
192191
import Effect.Class (liftEffect)
193192
import Effect.Exception (throw)
194193
import Partial.Unsafe (unsafePartial)
195-
import Prelude (join) as Bind
196194

197195
-- The constraints don't precisely match those of Plutus:
198196
-- `forall v. (FromData (DatumType v), ToData (DatumType v), ToData (RedeemerType v))`
@@ -548,15 +546,7 @@ processConstraint
548546
-- Use the datum hash inside the lookup
549547
case datum' of
550548
Just (OutputDatumHash dHash) -> do
551-
dat <- ExceptT do
552-
mDatumLookup <- lookupDatum dHash
553-
if isRight mDatumLookup then
554-
pure mDatumLookup
555-
else
556-
liftAff $ queryHandle.getDatumByHash dHash <#> hush
557-
>>> Bind.join
558-
>>> note
559-
(CannotQueryDatum dHash)
549+
dat <- ExceptT $ lookupDatum dHash
560550
lift $ addDatum dat
561551
Just (OutputDatum _) -> pure unit
562552
Nothing -> throwError CannotFindDatum

src/Internal/ProcessConstraints/Error.purs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import Data.UInt as UInt
3737

3838
data MkUnbalancedTxError
3939
= CannotFindDatum
40-
| CannotQueryDatum DataHash
4140
| CannotConvertPOSIXTimeRange POSIXTimeRange PosixTimeToSlotError
4241
| CannotSolveTimeConstraints POSIXTimeRange POSIXTimeRange
4342
| CannotGetMintingPolicyScriptIndex -- Should be impossible
@@ -70,10 +69,6 @@ instance Show MkUnbalancedTxError where
7069
explainMkUnbalancedTxError :: MkUnbalancedTxError -> String
7170
explainMkUnbalancedTxError = case _ of
7271
CannotFindDatum -> "Cannot find datum"
73-
CannotQueryDatum dh ->
74-
"Querying for datum by datum hash ("
75-
<> byteArrayToHex (unwrap $ encodeCbor dh)
76-
<> ") failed: no datum found"
7772
CannotConvertPOSIXTimeRange tr ttsErr ->
7873
"Cannot convert POSIX time range to slot time range.\nRange: "
7974
<> show tr

0 commit comments

Comments
 (0)