@@ -20,7 +20,7 @@ import Cardano.DbSync.Api
20
20
import Cardano.DbSync.Api.Types (InsertOptions (.. ), SyncEnv (.. ))
21
21
import Cardano.DbSync.Cache.Types (Cache (.. ))
22
22
23
- import Cardano.DbSync.Config.Types (MetadataConfig (.. ), MultiAssetConfig (.. ), PlutusConfig (.. ), ShelleyInsertConfig ( .. ), isPlutusModeActive , isShelleyModeActive )
23
+ import Cardano.DbSync.Config.Types (MetadataConfig (.. ), MultiAssetConfig (.. ), PlutusConfig (.. ), isPlutusModeActive , isShelleyModeActive )
24
24
import qualified Cardano.DbSync.Era.Shelley.Generic as Generic
25
25
import Cardano.DbSync.Era.Shelley.Generic.Metadata (TxMetadataValue (.. ), metadataValueToJsonNoSchema )
26
26
import Cardano.DbSync.Era.Universal.Insert.Certificate (insertCertificate )
@@ -83,7 +83,7 @@ insertTx syncEnv isMember blkId epochNo slotNo applyResult blockIndex tx grouped
83
83
disInOut <- liftIO $ getDisableInOutState syncEnv
84
84
-- In some txs and with specific configuration we may be able to find necessary data within the tx body.
85
85
-- In these cases we can avoid expensive queries.
86
- (resolvedInputs, fees ', deposits ) <- case (disInOut, mdeposits, unCoin <$> Generic. txFees tx) of
86
+ (resolvedInputs, resolvedFees ', resolvedDeposits ) <- case (disInOut, mdeposits, unCoin <$> Generic. txFees tx) of
87
87
(True , _, _) -> pure ([] , 0 , unCoin <$> mdeposits)
88
88
(_, Just deposits, Just fees) -> do
89
89
(resolvedInputs, _) <- splitLast <$> mapM (resolveTxInputs syncEnv hasConsumed False (fst <$> groupedTxOut grouped)) (Generic. txInputs tx)
@@ -95,14 +95,14 @@ insertTx syncEnv isMember blkId epochNo slotNo applyResult blockIndex tx grouped
95
95
else
96
96
let ! inSum = sum $ map unDbLovelace $ catMaybes amounts
97
97
in pure (resolvedInputs, fees, Just $ fromIntegral (inSum + withdrawalSum) - fromIntegral outSum - fromIntegral fees)
98
+ -- Nothing in fees means a phase 2 failure
98
99
(_, _, Nothing ) -> do
99
- -- Nothing in fees means a phase 2 failure
100
100
(resolvedInsFull, amounts) <- splitLast <$> mapM (resolveTxInputs syncEnv hasConsumed True (fst <$> groupedTxOut grouped)) (Generic. txInputs tx)
101
101
let ! inSum = sum $ map unDbLovelace $ catMaybes amounts
102
102
! diffSum = if inSum >= outSum then inSum - outSum else 0
103
103
! fees = maybe diffSum (fromIntegral . unCoin) (Generic. txFees tx)
104
104
pure (resolvedInsFull, fromIntegral fees, Just 0 )
105
- let fees = fromIntegral fees '
105
+ let resolvedFees = fromIntegral resolvedFees '
106
106
-- Insert transaction and get txId from the DB.
107
107
! txId <-
108
108
lift
@@ -112,8 +112,8 @@ insertTx syncEnv isMember blkId epochNo slotNo applyResult blockIndex tx grouped
112
112
, DB. txBlockId = blkId
113
113
, DB. txBlockIndex = blockIndex
114
114
, DB. txOutSum = DB. DbLovelace outSum
115
- , DB. txFee = DB. DbLovelace fees
116
- , DB. txDeposit = fromIntegral <$> deposits
115
+ , DB. txFee = DB. DbLovelace resolvedFees
116
+ , DB. txDeposit = fromIntegral <$> resolvedDeposits
117
117
, DB. txSize = Generic. txSize tx
118
118
, DB. txInvalidBefore = DbWord64 . unSlotNo <$> Generic. txInvalidBefore tx
119
119
, DB. txInvalidHereafter = DbWord64 . unSlotNo <$> Generic. txInvalidHereafter tx
@@ -132,7 +132,7 @@ insertTx syncEnv isMember blkId epochNo slotNo applyResult blockIndex tx grouped
132
132
let ! txIns = map (prepareTxIn txId Map. empty) resolvedInputs
133
133
-- There is a custom semigroup instance for BlockGroupedData which uses addition for the values `fees` and `outSum`.
134
134
-- Same happens bellow on last line of this function.
135
- pure (grouped <> BlockGroupedData txIns txOutsGrouped [] [] fees outSum)
135
+ pure (grouped <> BlockGroupedData txIns txOutsGrouped [] [] resolvedFees outSum)
136
136
else do
137
137
-- The following operations only happen if the script passes stage 2 validation (or the tx has
138
138
-- no script).
@@ -168,7 +168,6 @@ insertTx syncEnv isMember blkId epochNo slotNo applyResult blockIndex tx grouped
168
168
169
169
when (isShelleyModeActive $ ioShelley iopts) $ do
170
170
mapM_ (insertWithdrawals syncEnv cache txId redeemers) $ Generic. txWithdrawals tx
171
- -- TODO: cmdv SHELLEY
172
171
mapM_ (lift . insertParamProposal blkId txId) $ Generic. txParamProposal tx
173
172
174
173
maTxMint <-
@@ -179,11 +178,10 @@ insertTx syncEnv isMember blkId epochNo slotNo applyResult blockIndex tx grouped
179
178
180
179
when (ioGov iopts) $ do
181
180
mapM_ (insertGovActionProposal syncEnv blkId txId (getGovExpiresAt applyResult epochNo) (apCommittee applyResult)) $ zip [0 .. ] (Generic. txProposalProcedure tx)
182
- -- TODO: cmdv SHELLEY
183
181
mapM_ (insertVotingProcedures syncEnv txId (Generic. txProposalProcedure tx)) (Generic. txVotingProcedure tx)
184
182
185
183
let ! txIns = map (prepareTxIn txId redeemers) resolvedInputs
186
- pure (grouped <> BlockGroupedData txIns txOutsGrouped txMetadata maTxMint fees outSum)
184
+ pure (grouped <> BlockGroupedData txIns txOutsGrouped txMetadata maTxMint resolvedFees outSum)
187
185
where
188
186
tracer = getTrace syncEnv
189
187
cache = envCache syncEnv
@@ -202,18 +200,10 @@ insertTxOut ::
202
200
Generic. TxOut ->
203
201
ExceptT SyncNodeError (ReaderT SqlBackend m ) (Maybe (ExtendedTxOut , [MissingMaTxOut ]))
204
202
insertTxOut syncEnv cache iopts (txId, txHash) (Generic. TxOut index addr value maMap mScript dt) =
205
- case ioShelley iopts of
206
- ShelleyStakeAddrs _ ->
207
- if shelleyStkAddrWhitelistCheckWithAddr syncEnv addr
208
- then plutusCheck
209
- else pure Nothing
210
- _other -> plutusCheck
203
+ case ioPlutus iopts of
204
+ PlutusDisable -> buildExtendedTxOutPart2 Nothing Nothing
205
+ _other -> buildExtendedTxOutPart1
211
206
where
212
- plutusCheck =
213
- case ioPlutus iopts of
214
- PlutusDisable -> buildExtendedTxOutPart2 Nothing Nothing
215
- _other -> buildExtendedTxOutPart1
216
-
217
207
buildExtendedTxOutPart1 ::
218
208
(MonadBaseControl IO m , MonadIO m ) =>
219
209
ExceptT SyncNodeError (ReaderT SqlBackend m ) (Maybe (ExtendedTxOut , [MissingMaTxOut ]))
@@ -420,7 +410,6 @@ insertCollateralTxOut syncEnv cache (txId, _txHash) txout@(Generic.TxOut index a
420
410
, DB. collateralTxOutReferenceScriptId = mScriptId
421
411
}
422
412
pure ()
423
- -- TODO: Is there any reason to add new tables for collateral multi-assets/multi-asset-outputs
424
413
hasScript :: Bool
425
414
hasScript = maybe False Generic. hasCredScript (Generic. getPaymentCred addr)
426
415
0 commit comments