@@ -43,7 +43,7 @@ import Cardano.DbSync.Cache (
43
43
import Cardano.DbSync.Cache.Epoch (writeEpochBlockDiffToCache )
44
44
import Cardano.DbSync.Cache.Types (Cache (.. ), CacheNew (.. ), EpochBlockDiff (.. ))
45
45
46
- import Cardano.DbSync.Config (plutusWhitelistCheckTxOut )
46
+ import Cardano.DbSync.Config (plutusMultiAssetWhitelistCheck )
47
47
import Cardano.DbSync.Config.Types (MetadataConfig (.. ), MultiAssetConfig (.. ), PlutusConfig (.. ), isMetadataEnableOrWhiteList , isPlutusEnableOrWhitelist )
48
48
import qualified Cardano.DbSync.Era.Shelley.Generic as Generic
49
49
import Cardano.DbSync.Era.Shelley.Generic.Metadata (
@@ -324,8 +324,7 @@ insertTx syncEnv isMember blkId epochNo slotNo applyResult blockIndex tx grouped
324
324
then do
325
325
! txOutsGrouped <- do
326
326
let txOuts = Generic. txOutputs tx
327
- -- we do a plutus whitelist check
328
- if plutusWhitelistCheckTxOut syncEnv txOuts
327
+ if plutusMultiAssetWhitelistCheck syncEnv txOuts
329
328
then mapM (prepareTxOut tracer iopts cache (txId, txHash)) txOuts
330
329
else pure mempty
331
330
@@ -339,7 +338,7 @@ insertTx syncEnv isMember blkId epochNo slotNo applyResult blockIndex tx grouped
339
338
! txOutsGrouped <- do
340
339
let txOuts = Generic. txOutputs tx
341
340
-- we do a plutus whitelist check
342
- if plutusWhitelistCheckTxOut syncEnv txOuts
341
+ if plutusMultiAssetWhitelistCheck syncEnv txOuts
343
342
then mapM (prepareTxOut tracer iopts cache (txId, txHash)) txOuts
344
343
else pure mempty
345
344
@@ -380,7 +379,7 @@ insertTx syncEnv isMember blkId epochNo slotNo applyResult blockIndex tx grouped
380
379
MetadataDisable -> pure mempty
381
380
MetadataEnable -> prepareMaTxMint tracer cache Nothing txId $ Generic. txMint tx
382
381
MetadataWhitelistKeys whitelist -> prepareMaTxMint tracer cache (Just whitelist) txId $ Generic. txMint tx
383
- -- TODO: cmdv do whitelist check here maybe?
382
+
384
383
when (isPlutusEnableOrWhitelist $ ioPlutusExtra iopts) $
385
384
mapM_ (lift . insertScript tracer txId) $
386
385
Generic. txScripts tx
@@ -408,7 +407,7 @@ prepareTxOut ::
408
407
(DB. TxId , ByteString ) ->
409
408
Generic. TxOut ->
410
409
ExceptT SyncNodeError (ReaderT SqlBackend m ) (ExtendedTxOut , [MissingMaTxOut ])
411
- prepareTxOut tracer iopts cache (txId, txHash) (Generic. TxOut index addr addrRaw value maMap mScript dt) = do
410
+ prepareTxOut tracer iopts cache (txId, txHash) (Generic. TxOut index addr value maMap mScript dt) = do
412
411
case ioPlutusExtra iopts of
413
412
-- can skip to part2 as mDatumId & mScriptId aren't needed
414
413
PlutusDisable -> buildExtendedTxOutPart2 Nothing Nothing
@@ -419,8 +418,8 @@ prepareTxOut tracer iopts cache (txId, txHash) (Generic.TxOut index addr addrRaw
419
418
(MonadBaseControl IO m , MonadIO m ) =>
420
419
ExceptT SyncNodeError (ReaderT SqlBackend m ) (ExtendedTxOut , [MissingMaTxOut ])
421
420
buildExtendedTxOutPart1 = do
422
- mDatumId <- whenFalseEmpty (ioPlutusExtra iopts) Nothing $ Generic. whenInlineDatum dt $ insertDatum tracer cache txId
423
- mScriptId <- whenFalseEmpty (ioPlutusExtra iopts) Nothing $ whenMaybe mScript $ lift . insertScript tracer txId
421
+ mDatumId <- Generic. whenInlineDatum dt $ insertDatum tracer cache txId
422
+ mScriptId <- whenMaybe mScript $ lift . insertScript tracer txId
424
423
buildExtendedTxOutPart2 mDatumId mScriptId
425
424
426
425
buildExtendedTxOutPart2 ::
@@ -435,7 +434,6 @@ prepareTxOut tracer iopts cache (txId, txHash) (Generic.TxOut index addr addrRaw
435
434
{ DB. txOutTxId = txId
436
435
, DB. txOutIndex = index
437
436
, DB. txOutAddress = Generic. renderAddress addr
438
- , DB. txOutAddressRaw = addrRaw
439
437
, DB. txOutAddressHasScript = hasScript
440
438
, DB. txOutPaymentCred = Generic. maybePaymentCred addr
441
439
, DB. txOutStakeAddressId = mSaId
@@ -447,14 +445,9 @@ prepareTxOut tracer iopts cache (txId, txHash) (Generic.TxOut index addr addrRaw
447
445
let ! eutxo = ExtendedTxOut txHash txOut
448
446
case ioMultiAssets iopts of
449
447
MultiAssetDisable -> pure (eutxo, mempty )
450
- -- prepareMaTxOuts with NO multi asset whitelist check
451
- MultiAssetEnable -> do
448
+ _ -> do
452
449
! maTxOuts <- prepareMaTxOuts tracer cache Nothing maMap
453
450
pure (eutxo, maTxOuts)
454
- -- prepareMaTxOuts with a multiasset whitelist check
455
- MultiAssetWhitelistPolicies whitelist -> do
456
- ! maTxOuts <- prepareMaTxOuts tracer cache (Just whitelist) maMap
457
- pure (eutxo, maTxOuts)
458
451
459
452
hasScript :: Bool
460
453
hasScript = maybe False Generic. hasCredScript (Generic. getPaymentCred addr)
@@ -467,7 +460,7 @@ insertCollateralTxOut ::
467
460
(DB. TxId , ByteString ) ->
468
461
Generic. TxOut ->
469
462
ExceptT SyncNodeError (ReaderT SqlBackend m ) ()
470
- insertCollateralTxOut tracer cache inOpts (txId, _txHash) (Generic. TxOut index addr addrRaw value maMap mScript dt) = do
463
+ insertCollateralTxOut tracer cache inOpts (txId, _txHash) (Generic. TxOut index addr value maMap mScript dt) = do
471
464
case ioPlutusExtra inOpts of
472
465
PlutusDisable -> do
473
466
_ <- insertColTxOutPart2 Nothing Nothing
@@ -487,8 +480,8 @@ insertCollateralTxOut tracer cache inOpts (txId, _txHash) (Generic.TxOut index a
487
480
(Nothing , Nothing ) -> void $ insertColTxOutPart2 Nothing Nothing
488
481
where
489
482
insertColTxOutPart1 = do
490
- mDatumId <- whenFalseEmpty (isPlutusEnableOrWhitelist iopts) Nothing $ Generic. whenInlineDatum dt $ insertDatum tracer cache txId
491
- mScriptId <- whenFalseEmpty (isPlutusEnableOrWhitelist iopts) Nothing $ whenMaybe mScript $ lift . insertScript tracer txId
483
+ mDatumId <- Generic. whenInlineDatum dt $ insertDatum tracer cache txId
484
+ mScriptId <- whenMaybe mScript $ lift . insertScript tracer txId
492
485
insertColTxOutPart2 mDatumId mScriptId
493
486
pure ()
494
487
@@ -501,7 +494,6 @@ insertCollateralTxOut tracer cache inOpts (txId, _txHash) (Generic.TxOut index a
501
494
{ DB. collateralTxOutTxId = txId
502
495
, DB. collateralTxOutIndex = index
503
496
, DB. collateralTxOutAddress = Generic. renderAddress addr
504
- , DB. collateralTxOutAddressRaw = addrRaw
505
497
, DB. collateralTxOutAddressHasScript = hasScript
506
498
, DB. collateralTxOutPaymentCred = Generic. maybePaymentCred addr
507
499
, DB. collateralTxOutStakeAddressId = mSaId
@@ -1465,8 +1457,8 @@ insertMultiAsset cache mWhitelist policy aName = do
1465
1457
Right maId -> pure $ Just maId
1466
1458
Left (policyBs, assetNameBs) ->
1467
1459
case mWhitelist of
1460
+ -- we want to check the whitelist at the begining
1468
1461
Just whitelist ->
1469
- --
1470
1462
if policyBs `elem` whitelist
1471
1463
then Just <$> insertAssettIntoDB policyBs assetNameBs
1472
1464
else pure Nothing
0 commit comments