Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions marconi-chain-index/marconi-chain-index.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ test-suite marconi-chain-index-test-compare-cardano-db-sync
, cardano-api:{cardano-api, gen} ^>=8.0
, cardano-binary
, cardano-crypto-class
, cardano-ledger-api
, cardano-ledger-core
, cardano-ledger-shelley
, cardano-testnet
Expand Down Expand Up @@ -432,6 +433,8 @@ test-suite marconi-chain-index-test-compare-cardano-db-sync
, optparse-applicative
, postgresql-simple
, prettyprinter
, raw-strings-qq
, scientific
, serialise
, sqlite-simple
, stm
Expand Down
25 changes: 23 additions & 2 deletions marconi-chain-index/src/Marconi/ChainIndex/Indexers/MintBurn.hs
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ fromRows :: [TxMintRow] -> [TxMintEvent]
fromRows rows = do
rs@(r :| _) <- NE.groupBy ((==) `on` slotNo) rows -- group by SlotNo
pure $ TxMintEvent (slotNo r) (hash r) (blockNo r) $ do
rs' <- NE.groupBy ((==) `on` assetKey) rs
pure $ TxMintInfo (txId r) (txIx r) (rowToMintAsset <$> rs')
rs'@(r' :| _) <- NE.groupBy ((==) `on` assetKey) rs
pure $ TxMintInfo (txId r') (txIx r') (rowToMintAsset <$> rs')
where
assetKey row = (txId row, txIx row)
txId = view txMintRowTxId
Expand Down Expand Up @@ -498,6 +498,27 @@ instance RI.Queryable MintBurnHandle where
Nothing -> ([], [])
Just s -> (["slotNo <= :slotNo"], [":slotNo" := s])

-- | Query TxMintRow's at specific slot
queryDbTxMintRowsAtSlot :: SQL.Connection -> C.SlotNo -> IO [TxMintRow]
queryDbTxMintRowsAtSlot sqlCon slotNo = do
storedEvents <- queryStoredTxMintEvents sqlCon (["slotNo = :slotNo"], [":slotNo" := slotNo])
pure $ do
TxMintEvent _slotNo blockHeaderHash blockNo txAssets <- storedEvents
-- ^ _slotNo is same as slotNo
TxMintInfo txId txIx mintAssets <- txAssets
MintAsset policyId assetName quantity redeemer <- NE.toList mintAssets
pure $
TxMintRow
slotNo
blockHeaderHash
blockNo
txIx
txId
policyId
assetName
quantity
redeemer

instance RI.HasPoint (RI.StorableEvent MintBurnHandle) C.ChainPoint where
getPoint (MintBurnEvent e) = C.ChainPoint (txMintEventSlotNo e) (txMintEventBlockHeaderHash e)

Expand Down
Loading