@@ -4,6 +4,8 @@ import type {
44 TxnCountReq ,
55 TxnFT ,
66 TxnFTsReq ,
7+ TxnMT ,
8+ TxnMTsReq ,
79 TxnNFT ,
810 TxnNFTsReq ,
911 TxnReceipt ,
@@ -340,4 +342,67 @@ const nfts = responseHandler(
340342 } ,
341343) ;
342344
343- export default { count, fts, latest, nfts, receipts, txn, txns } ;
345+ const mts = responseHandler (
346+ response . mts ,
347+ async ( req : RequestValidator < TxnMTsReq > ) => {
348+ const hash = req . validator . hash ;
349+
350+ if ( hash . startsWith ( '0x' ) ) {
351+ const receipts = await rollingWindow <
352+ Pick < TxnMT , 'block_timestamp' | 'receipt_id' > [ ]
353+ > (
354+ async ( start , end ) => {
355+ const receipts = await dbBase . any < TxnMT > ( sql . eventsRlp , {
356+ end,
357+ hash,
358+ start,
359+ } ) ;
360+
361+ return receipts . length ? receipts : null ;
362+ } ,
363+ { start : config . baseStart } ,
364+ ) ;
365+
366+ if ( ! receipts || ! receipts . length ) {
367+ return { data : [ ] } ;
368+ }
369+
370+ const queries = receipts . map ( ( receipt ) => {
371+ return pgp . as . format ( sql . mt , receipt ) ;
372+ } ) ;
373+ const unionQuery = queries . join ( '\nUNION ALL\n' ) ;
374+ const mts = await dbEvents . manyOrNone < TxnMT > ( unionQuery ) ;
375+
376+ return { data : mts } ;
377+ }
378+
379+ const receipts = await rollingWindow <
380+ Pick < TxnMT , 'block_timestamp' | 'receipt_id' > [ ]
381+ > (
382+ async ( start , end ) => {
383+ const receipts = await dbBase . any < TxnMT > ( sql . events , {
384+ end,
385+ hash,
386+ start,
387+ } ) ;
388+
389+ return receipts . length ? receipts : null ;
390+ } ,
391+ { start : config . baseStart } ,
392+ ) ;
393+
394+ if ( ! receipts || ! receipts . length ) {
395+ return { data : [ ] } ;
396+ }
397+
398+ const queries = receipts . map ( ( receipt ) => {
399+ return pgp . as . format ( sql . mt , receipt ) ;
400+ } ) ;
401+ const unionQuery = queries . join ( '\nUNION ALL\n' ) ;
402+ const mts = await dbEvents . manyOrNone < TxnMT > ( unionQuery ) ;
403+
404+ return { data : mts } ;
405+ } ,
406+ ) ;
407+
408+ export default { count, fts, latest, mts, nfts, receipts, txn, txns } ;
0 commit comments