Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x | import * as Queries from './queries'; import { Cardano } from '@cardano-sdk/core'; import { Logger } from 'ts-log'; import { Pool, QueryResult } from 'pg'; import { bufferToHexString } from '@cardano-sdk/util'; export class MetadataFixtureBuilder { #db: Pool; #logger: Logger; constructor(db: Pool, logger: Logger) { this.#db = db; this.#logger = logger; } public async getTxIds(desiredQty: number) { this.#logger.debug('About to query tx with metadata'); const result: QueryResult<{ tx_id: Buffer }> = await this.#db.query(Queries.findTxWithMetadata, [desiredQty]); const resultsQty = result.rows.length; Iif (result.rows.length === 0) { throw new Error('No transactions found'); } else Iif (resultsQty < desiredQty) { this.#logger.warn(`${desiredQty} transactions desired, only ${resultsQty} results found`); } return result.rows.map(({ tx_id }) => bufferToHexString(tx_id) as unknown as Cardano.TransactionId); } } |