Skip to content

Commit

Permalink
handle whitelist resolvetxinput
Browse files Browse the repository at this point in the history
  • Loading branch information
Cmdv committed May 8, 2024
1 parent 5bb86ac commit 787a3d0
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions cardano-db-sync/src/Cardano/DbSync/Era/Universal/Insert/Tx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Cardano.DbSync.Api
import Cardano.DbSync.Api.Types (InsertOptions (..), SyncEnv (..))
import Cardano.DbSync.Cache.Types (Cache (..))

import Cardano.DbSync.Config.Types (MetadataConfig (..), MultiAssetConfig (..), PlutusConfig (..), ShelleyInsertConfig (..), isPlutusModeActive, isShelleyModeActive)
import Cardano.DbSync.Config.Types (MetadataConfig (..), MultiAssetConfig (..), PlutusConfig (..), ShelleyInsertConfig (..), isPlutusModeActive, isShelleyModeActive, isShelleyWhitelistModeActive)
import qualified Cardano.DbSync.Era.Shelley.Generic as Generic
import Cardano.DbSync.Era.Shelley.Generic.Metadata (TxMetadataValue (..), metadataValueToJsonNoSchema)
import Cardano.DbSync.Era.Universal.Insert.Certificate (insertCertificate)
Expand Down Expand Up @@ -95,13 +95,18 @@ insertTx syncEnv isMember blkId epochNo slotNo applyResult blockIndex tx grouped
else
let !inSum = sum $ map unDbLovelace $ catMaybes amounts
in pure (resolvedInputs, fees, Just $ fromIntegral (inSum + withdrawalSum) - fromIntegral outSum - fromIntegral fees)
-- Nothing in fees means a phase 2 failure
(_, _, Nothing) -> do
-- Nothing in fees means a phase 2 failure
(resolvedInsFull, amounts) <- splitLast <$> mapM (resolveTxInputs syncEnv hasConsumed True (fst <$> groupedTxOut grouped)) (Generic.txInputs tx)
let !inSum = sum $ map unDbLovelace $ catMaybes amounts
!diffSum = if inSum >= outSum then inSum - outSum else 0
!fees = maybe diffSum (fromIntegral . unCoin) (Generic.txFees tx)
pure (resolvedInsFull, fromIntegral fees, Just 0)
-- If we are in shelley whitelist mode, we don't need to resolve the tx inputs for this case.
if isShelleyWhitelistModeActive $ ioShelley $ getInsertOptions syncEnv
then -- TODO: cmdv -- would this be the right values to return?
pure ([], 0, Just 0)
else do
(resolvedInsFull, amounts) <- splitLast <$> mapM (resolveTxInputs syncEnv hasConsumed True (fst <$> groupedTxOut grouped)) (Generic.txInputs tx)
let !inSum = sum $ map unDbLovelace $ catMaybes amounts
!diffSum = if inSum >= outSum then inSum - outSum else 0
!fees = maybe diffSum (fromIntegral . unCoin) (Generic.txFees tx)
pure (resolvedInsFull, fromIntegral fees, Just 0)
let fees = fromIntegral fees'
-- Insert transaction and get txId from the DB.
!txId <-
Expand Down

0 comments on commit 787a3d0

Please sign in to comment.