@odatano/core 2.0.0-rc.2 → 2.0.0-rc.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/@cds-models/CardanoAgentService/index.d.ts +251 -0
  2. package/@cds-models/CardanoAgentService/index.js +36 -0
  3. package/@cds-models/CardanoIndexerService/index.d.ts +139 -2
  4. package/@cds-models/CardanoIndexerService/index.js +18 -0
  5. package/@cds-models/CardanoODataService/index.d.ts +224 -0
  6. package/@cds-models/CardanoODataService/index.js +27 -0
  7. package/@cds-models/CardanoSignService/index.d.ts +5 -2
  8. package/@cds-models/CardanoTransactionService/index.d.ts +9 -9
  9. package/@cds-models/odatano/cardano/index.d.ts +316 -0
  10. package/@cds-models/odatano/cardano/index.js +33 -0
  11. package/README.md +195 -136
  12. package/db/schema.cds +2121 -1633
  13. package/package.json +179 -173
  14. package/src/index.d.ts +10 -10
  15. package/src/index.js +24 -14
  16. package/src/plugin.js +39 -52
  17. package/srv/blockchain/backends/blockfrost-backend.d.ts +29 -131
  18. package/srv/blockchain/backends/blockfrost-backend.js +45 -158
  19. package/srv/blockchain/backends/cardano-backend.d.ts +78 -158
  20. package/srv/blockchain/backends/cardano-backend.js +14 -5
  21. package/srv/blockchain/backends/koios-backend.d.ts +126 -60
  22. package/srv/blockchain/backends/koios-backend.js +292 -202
  23. package/srv/blockchain/backends/ogmios-backend.d.ts +59 -96
  24. package/srv/blockchain/backends/ogmios-backend.js +241 -153
  25. package/srv/blockchain/backends/ogmios-frame-guard.d.ts +32 -0
  26. package/srv/blockchain/backends/ogmios-frame-guard.js +142 -0
  27. package/srv/blockchain/cardano-client.d.ts +50 -205
  28. package/srv/blockchain/cardano-client.js +80 -224
  29. package/srv/blockchain/cardano-indexer.d.ts +146 -244
  30. package/srv/blockchain/cardano-indexer.js +442 -285
  31. package/srv/blockchain/cardano-tx-builder.d.ts +19 -84
  32. package/srv/blockchain/cardano-tx-builder.js +21 -107
  33. package/srv/blockchain/crawler/certificate-backfill.d.ts +45 -0
  34. package/srv/blockchain/crawler/certificate-backfill.js +150 -0
  35. package/srv/blockchain/crawler/crawler.d.ts +121 -53
  36. package/srv/blockchain/crawler/crawler.js +402 -82
  37. package/srv/blockchain/crawler/hooks.d.ts +3 -14
  38. package/srv/blockchain/crawler/index.d.ts +5 -0
  39. package/srv/blockchain/crawler/index.js +35 -7
  40. package/srv/blockchain/crawler/sync-state.d.ts +44 -28
  41. package/srv/blockchain/crawler/sync-state.js +115 -43
  42. package/srv/blockchain/crawler/utxo-set-import.d.ts +69 -0
  43. package/srv/blockchain/crawler/utxo-set-import.js +269 -0
  44. package/srv/blockchain/ledger-state.d.ts +80 -0
  45. package/srv/blockchain/ledger-state.js +383 -0
  46. package/srv/blockchain/signing/cose-verifier.d.ts +5 -12
  47. package/srv/blockchain/signing/cose-verifier.js +6 -12
  48. package/srv/blockchain/signing/external-signer.d.ts +16 -113
  49. package/srv/blockchain/signing/external-signer.js +19 -122
  50. package/srv/blockchain/signing/hsm-signer.d.ts +13 -45
  51. package/srv/blockchain/signing/hsm-signer.js +23 -63
  52. package/srv/blockchain/signing/signature-verifier.d.ts +8 -44
  53. package/srv/blockchain/signing/signature-verifier.js +13 -54
  54. package/srv/blockchain/signing/submission-finalizer.d.ts +9 -36
  55. package/srv/blockchain/signing/submission-finalizer.js +16 -48
  56. package/srv/blockchain/transaction-building/buildooor-tx.d.ts +71 -160
  57. package/srv/blockchain/transaction-building/buildooor-tx.js +185 -260
  58. package/srv/blockchain/transaction-building/cardano-tx.d.ts +8 -34
  59. package/srv/blockchain/wallet-worker/build-request.d.ts +4 -17
  60. package/srv/blockchain/wallet-worker/build-request.js +39 -23
  61. package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +25 -17
  62. package/srv/blockchain/wallet-worker/confirmation-tracker.js +87 -41
  63. package/srv/blockchain/wallet-worker/index.js +2 -8
  64. package/srv/blockchain/wallet-worker/job-store.d.ts +36 -103
  65. package/srv/blockchain/wallet-worker/job-store.js +0 -0
  66. package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +4 -20
  67. package/srv/blockchain/wallet-worker/lease-heartbeat.js +4 -20
  68. package/srv/blockchain/wallet-worker/signers.d.ts +6 -19
  69. package/srv/blockchain/wallet-worker/signers.js +3 -8
  70. package/srv/blockchain/wallet-worker/wallet-worker.d.ts +15 -71
  71. package/srv/blockchain/wallet-worker/wallet-worker.js +34 -90
  72. package/srv/cardano-agent-service.cds +146 -0
  73. package/srv/cardano-agent-service.d.ts +2 -0
  74. package/srv/cardano-agent-service.js +12 -0
  75. package/srv/cardano-indexer-service.cds +164 -73
  76. package/srv/cardano-indexer-service.js +156 -11
  77. package/srv/cardano-service.cds +45 -0
  78. package/srv/cardano-service.js +38 -96
  79. package/srv/cardano-sign-service.cds +200 -180
  80. package/srv/cardano-sign-service.js +55 -173
  81. package/srv/cardano-tx-service.cds +32 -26
  82. package/srv/cardano-tx-service.js +133 -195
  83. package/srv/cardano-worker-service.js +7 -15
  84. package/srv/server.d.ts +28 -86
  85. package/srv/server.js +95 -128
  86. package/srv/utils/agent-grants-config.d.ts +37 -0
  87. package/srv/utils/agent-grants-config.js +138 -0
  88. package/srv/utils/agent-grants.d.ts +262 -0
  89. package/srv/utils/agent-grants.js +914 -0
  90. package/srv/utils/agent-token-auth.d.ts +16 -0
  91. package/srv/utils/agent-token-auth.js +78 -0
  92. package/srv/utils/backend-request-handler.d.ts +2 -16
  93. package/srv/utils/backend-request-handler.js +3 -18
  94. package/srv/utils/collections.d.ts +4 -8
  95. package/srv/utils/collections.js +4 -8
  96. package/srv/utils/const.d.ts +19 -68
  97. package/srv/utils/const.js +20 -69
  98. package/srv/utils/crypto.d.ts +3 -12
  99. package/srv/utils/crypto.js +5 -18
  100. package/srv/utils/db-indexes.d.ts +25 -0
  101. package/srv/utils/db-indexes.js +89 -0
  102. package/srv/utils/db-sanitize.d.ts +27 -0
  103. package/srv/utils/db-sanitize.js +85 -0
  104. package/srv/utils/error-codes.d.ts +18 -73
  105. package/srv/utils/error-codes.js +17 -70
  106. package/srv/utils/errors.d.ts +34 -178
  107. package/srv/utils/errors.js +55 -217
  108. package/srv/utils/liveness.d.ts +16 -0
  109. package/srv/utils/liveness.js +41 -0
  110. package/srv/utils/mappers.d.ts +82 -210
  111. package/srv/utils/mappers.js +272 -293
  112. package/srv/utils/network-context.js +2 -11
  113. package/srv/utils/pg-order-nulls.d.ts +14 -0
  114. package/srv/utils/pg-order-nulls.js +57 -0
  115. package/srv/utils/plutus-placeholders.d.ts +6 -18
  116. package/srv/utils/plutus-placeholders.js +6 -20
  117. package/srv/utils/rate-limiter.d.ts +46 -0
  118. package/srv/utils/rate-limiter.js +116 -0
  119. package/srv/utils/service-events.d.ts +2 -22
  120. package/srv/utils/service-events.js +3 -23
  121. package/srv/utils/signing-helper.d.ts +3 -18
  122. package/srv/utils/signing-helper.js +10 -32
  123. package/srv/utils/tx-build-helper.d.ts +18 -92
  124. package/srv/utils/tx-build-helper.js +32 -123
  125. package/srv/utils/tx-request-parsers.d.ts +14 -20
  126. package/srv/utils/tx-request-parsers.js +33 -20
  127. package/srv/utils/tx-utils.d.ts +4 -23
  128. package/srv/utils/tx-utils.js +12 -41
  129. package/srv/utils/types.d.ts +112 -169
  130. package/srv/utils/types.js +2 -6
  131. package/srv/utils/validators.d.ts +19 -89
  132. package/srv/utils/validators.js +31 -138
@@ -4,19 +4,11 @@ import type { CardanoTransactionBuilder } from './cardano-tx-builder';
4
4
  import { Transaction as CardanoTransaction, AddressUTxOs, TransactionMetadata, NetworkInformation, Block, Epoch, AssetHistory, Account, Drep, Pool, Asset, Address, LedgerProtocolParameter, AddressTransactions } from '#cds-models/CardanoODataService';
5
5
  import { TransactionBuild, TransactionSubmission } from '#cds-models/CardanoTransactionService';
6
6
  import { TxBuildRequest, Transaction as ProviderTransaction, BlockData } from '../utils/types';
7
+ import { type LedgerAnchor } from './ledger-state';
7
8
  import type { TxCacheTargets } from '../utils/tx-build-helper';
8
9
  /**
9
- * CardanoIndexer - Indexer for Cardano blockchain data into OData entities
10
- *
11
- * Provides methods to index & manage db consistency for various Cardano blockchain data (transactions, addresses, blocks, epochs, accounts, pools, dreps)
12
- * 1. Fetches data from the configured Cardano data provider via the CardanoClient
13
- * 2. Maps the provider data into corresponding OData entity rows
14
- * 3. Upserts the data rows into the database via CAP transactions
15
- * 4. Ensures referential integrity and consistency across related entities (e.g., addresses in transactions, UTxOs in addresses)
16
- * 5. Returns the indexed entity data for further processing
17
- *
18
- * Each method corresponds to a specific Cardano Entity type and handles the necessary mapping and persistence
19
- * into the corresponding OData entities defined in the CardanoODataService(M1) and CardanoTransactionService(M2) models.
10
+ * Indexes Cardano data into the OData entities: fetches via CardanoClient, maps provider data
11
+ * to entity rows and UPSERTs them inside the caller's CAP transaction.
20
12
  */
21
13
  export declare class CardanoIndexer {
22
14
  private client;
@@ -25,261 +17,203 @@ export declare class CardanoIndexer {
25
17
  private static readonly CRAWL_EPOCH_REFRESH_MS;
26
18
  private static readonly CRAWL_EPOCH_RETRY_MS;
27
19
  /**
28
- * Crawler epoch memo. Network reads are refreshed periodically while an epoch is
29
- * live and once more when the next epoch starts, so counters such as block_count,
30
- * fees and lastBlockTime do not remain frozen at their first observed value.
31
- *
32
- * At most the current and immediately previous epoch are retained. The rows are
33
- * intentionally UPSERTed in every block transaction: the caller owns that
34
- * transaction, so an in-memory "persisted" bit cannot know whether its commit later
35
- * succeeded. Repeating one local UPSERT is cheap and remains correct after rollback.
20
+ * Crawler epoch memo: refreshed periodically while an epoch is live and once more when the
21
+ * next one starts; holds at most the current and previous epoch. Rows are UPSERTed in every
22
+ * block transaction because the caller owns the commit.
36
23
  */
37
24
  private crawlEpochCache;
38
25
  private crawlEpochCurrent;
39
26
  private crawlEpochPrevious;
40
- /**
41
- * Network-only epoch prefetch for the crawler. Call BEFORE opening the per-block
42
- * write transaction — the backend round-trip must never run while the DB write
43
- * lock is held (indexBlockFull then serves the epoch from this memo). Never throws.
27
+ /** Analytics coverage of the crawl path; defaults mirror the crawler config defaults. */
28
+ private crawlAssetHistory;
29
+ private crawlAssetCatalogue;
30
+ /** Certificates + withdrawals per block (ledger-state coverage). Opt-in. */
31
+ private crawlCertificates;
32
+ /** Logged once per process: the active source reports no certificates (Blockfrost). */
33
+ private certificatesUnreportedWarned;
34
+ /**
35
+ * Crawler-fed ledger state (`crawler.utxoSet`): blocks after `utxoAnchor` are applied to the
36
+ * Ledger* tables; no anchor means configured but inactive.
37
+ */
38
+ private crawlUtxoSet;
39
+ private utxoAnchor;
40
+ /** The anchor block was found in the crawled chain (checked once, before the first apply). */
41
+ private utxoAnchorVerified;
42
+ /**
43
+ * Invalidation decided inside a block transaction; the anchor stays until the crawler confirms
44
+ * the commit (`takeLedgerInvalidation`), so a rolled-back attempt changes nothing.
45
+ */
46
+ private ledgerInvalidation;
47
+ /** Units known to have an `Assets` row, so a repeat sighting costs no DB round-trip. */
48
+ private static readonly ASSET_MEMO_CAP;
49
+ private assetMemo;
50
+ /**
51
+ * Background registry enrichment queue (`assetCatalogue: 'enrich'`), drained at a fixed rate
52
+ * outside the block transaction. Above the cap the oldest units are dropped (bare row stays).
53
+ */
54
+ private static readonly ENRICH_QUEUE_CAP;
55
+ private enrichQueue;
56
+ private enrichTimer;
57
+ private enrichRate;
58
+ /** Adopt the crawler's coverage settings; the lazy request path never touches these. */
59
+ configureCrawlCoverage(coverage: {
60
+ assetHistory: boolean;
61
+ assetCatalogue: 'off' | 'bare' | 'enrich';
62
+ assetEnrichRate?: number;
63
+ certificates?: boolean;
64
+ utxoSet?: boolean;
65
+ }): void;
66
+ /** The anchor the imported UTxO set describes (null = ledger mode inactive). */
67
+ setUtxoAnchor(anchor: LedgerAnchor | null): void;
68
+ /**
69
+ * The imported set describes the chain AT the anchor block, so before the first block past it
70
+ * is applied the cursor (not yet advanced in this transaction) must equal the anchor exactly;
71
+ * otherwise the snapshot was taken on a fork. Skipped once `utxoAppliedSlot` is set.
72
+ */
73
+ private verifyUtxoAnchor;
74
+ /** Null while the mode is off, nothing is imported, or an invalidation awaits its commit. */
75
+ getUtxoAnchor(): LedgerAnchor | null;
76
+ /** Hand out a pending invalidation (dropping the anchor) exactly once after the block commit, or null. */
77
+ takeLedgerInvalidation(): string | null;
78
+ /**
79
+ * Drain the enrichment queue at `enrichRate` units per second, one `indexAsset()` per tick in
80
+ * its own transaction. A failing unit is dropped; its bare row stays for the lazy path.
81
+ */
82
+ private startAssetEnrichment;
83
+ /** Stop the enrichment loop and forget what is still queued (shutdown, crawler halt, mode change). */
84
+ stopAssetEnrichment(): void;
85
+ /**
86
+ * Network-only epoch prefetch for the crawler. Call BEFORE opening the per-block write
87
+ * transaction so no backend round-trip runs under the DB write lock. Never throws.
44
88
  */
45
89
  prefetchCrawlEpoch(epochNumber: number): Promise<void>;
46
90
  private refreshCrawlEpoch;
47
- /**
48
- * Create a new CardanoIndexer instance
49
- * @param client - The CardanoClient instance for blockchain queries
50
- * @param txBuilder - The CardanoTransactionBuilder instance for transaction building
51
- */
52
91
  constructor(client: CardanoClient, txBuilder: CardanoTransactionBuilder);
53
92
  /**
54
- * Index & return a single transaction with inputs/outputs/assets/UTxOs/addresses
55
- * All UPSERTs execute within the same CAP transaction (cds.tx), which ensures
56
- * atomicity: either all entities are persisted or none are (automatic rollback on error).
57
- * @param tx CAP transaction (cds.tx(req))
58
- * @param txHash Cardano transaction hash (hex)
59
- * @returns {Promise<CardanoTransaction>} transaction entity data
93
+ * Index a transaction with inputs/outputs/assets/metadata; all UPSERTs run in the caller's
94
+ * transaction, so either everything persists or nothing does.
60
95
  */
61
96
  indexTransaction(tx: CapTransaction, txHash: string): Promise<CardanoTransaction>;
62
97
  /**
63
- * Index & return address data with assets and UTxOs (without transactions)
64
- * Transactions are loaded separately via indexAddressTransactions() for better performance
65
- * @param tx CAP transaction
66
- * @param addr bech32 address
67
- * @return {Promise<Address>} address entity data
98
+ * Index address data with assets and UTxOs; transactions are loaded separately via
99
+ * indexAddressTransactions().
68
100
  */
69
101
  indexAddress(tx: CapTransaction, addr: string): Promise<Address>;
70
102
  /**
71
- * Index UTxOs by 28-byte payment credential. Always-fresh fetch from Koios
72
- * (bypasses cache) — credential queries serve dApp-state use cases that require
73
- * current data. Underlying AddressUTxOs/UTxOAssets rows are UPSERTed and stay
74
- * available for follow-up address-keyed queries within the TTL.
75
- *
76
- * Does NOT upsert parent Addresses rows; child rows reference bech32 addresses
77
- * that may not yet have a parent stub. Same pattern as TransactionInputs.
78
- *
79
- * @param tx CAP transaction
80
- * @param credHash 28-byte payment credential as 56-char lowercase hex
81
- * @return UTxO entity rows across all bech32 addresses sharing the credential
103
+ * Index UTxOs by 28-byte payment credential (56-char hex), always fresh from Koios. Child
104
+ * rows are UPSERTed without a parent Addresses row (same pattern as TransactionInputs).
82
105
  */
83
106
  indexCredentialUtxos(tx: CapTransaction, credHash: string): Promise<AddressUTxOs[]>;
84
107
  /**
85
- * Index ONLY the UTxOs at a bech32 address via getAddressUtxos — deliberately
86
- * WITHOUT a getAddress (address-detail) call, so it works on backends that serve
87
- * the live UTxO set but not address aggregation (e.g. Ogmios). Used as the
88
- * GetUTxOsByAddress fallback when no configured backend supports getAddress.
89
- *
90
- * Does NOT upsert a parent Addresses row (same pattern as indexCredentialUtxos);
91
- * AddressUTxOs/UTxOAssets reference the bech32 address directly.
92
- *
93
- * @param tx CAP transaction
94
- * @param addr bech32 address
95
- * @return UTxO entity rows for the address (empty when the address holds none)
108
+ * Index only the UTxOs of an address via getAddressUtxos (no getAddress call), so it works on
109
+ * backends without address aggregation such as Ogmios. Writes no parent Addresses row.
96
110
  */
97
111
  indexAddressUtxos(tx: CapTransaction, addr: string): Promise<AddressUTxOs[]>;
98
112
  /**
99
- * Evict cached rows a submitted transaction made stale, so the next read
100
- * refetches instead of serving spent UTxOs for up to indexTtlMs:
101
- * - every consumed input ref (spent under WHATEVER address cached it),
102
- * - all address-level rows of the output addresses (their UTxO set gained
103
- * the new outputs — sender change included) and of `extraAddresses`
104
- * (e.g. the build's sender when the CBOR could not be parsed).
105
- *
106
- * Only the read cache is touched; submissions/builds stay untouched. Note the
107
- * next refetch may STILL see pre-submit state on lagging backends
108
- * (Blockfrost/Koios propagation) — that matches cache-less behaviour and is
109
- * not recoverable server-side.
110
- *
111
- * @param tx CAP transaction
112
- * @param targets input refs + output addresses from extractTxCacheTargets
113
- * @param extraAddresses additional bech32 addresses to evict
113
+ * Evict cached rows a submitted transaction made stale: every consumed input ref (under any
114
+ * address) and all address-level rows of the output addresses plus `extraAddresses`. Only the
115
+ * read cache is touched; lagging backends may still serve pre-submit state on refetch.
114
116
  */
115
117
  invalidateUtxoCacheForTx(tx: CapTransaction, targets: TxCacheTargets, extraAddresses?: string[]): Promise<void>;
116
- /**
117
- * Index & return address transactions (separate from indexAddress for lazy loading)
118
- * @param tx CAP transaction
119
- * @param addr bech32 address
120
- * @param limit maximum number of transactions to fetch
121
- * @return {Promise<AddressTransactions[]>} address transaction entities
122
- */
118
+ /** Index address transactions (separate from indexAddress for lazy loading). */
123
119
  indexAddressTransactions(tx: CapTransaction, addr: string, limit: number): Promise<AddressTransactions[]>;
124
- /**
125
- * Index & return address signing request association
126
- * Links an address to a signing request for address-based queries
127
- * @param tx CAP transaction
128
- * @param addr bech32 address
129
- * @param signingRequestId signing request UUID
130
- * @return {Promise<void>}
131
- */
120
+ /** Link an address to a signing request for address-based queries. */
132
121
  indexAddressSigningRequests(tx: CapTransaction, addr: string, signingRequestId: string): Promise<void>;
133
- /**
134
- * Index & return address transaction build association
135
- * Links an address to a transaction build for address-based queries
136
- * @param tx CAP transaction
137
- * @param addr bech32 address
138
- * @param buildId transaction build UUID
139
- * @return {Promise<void>}
140
- */
122
+ /** Link an address to a transaction build for address-based queries. */
141
123
  indexAddressTransactionBuilds(tx: CapTransaction, addr: string, buildId: string): Promise<void>;
142
- /**
143
- * Index & return metadata for a single transaction (Metadata)
144
- * @param tx CAP transaction
145
- * @param txHash transaction hash
146
- * @param metadata raw metadata object (label -> JSONValue)
147
- * @return {Promise<TransactionMetadata[]>} array of transaction metadata rows
148
- */
124
+ /** Index the metadata rows of a transaction. */
149
125
  indexTransactionMetadata(tx: CapTransaction, tx_hash: string): Promise<TransactionMetadata[]>;
150
- /**
151
- * Index & return the network information data
152
- * @param tx CAP transaction object
153
- * @returns {Promise<NetworkInformation>} network information entity data
154
- */
126
+ /** Index the network information. */
155
127
  indexNetworkInformation(tx: CapTransaction): Promise<NetworkInformation>;
156
- /**
157
- * Index & return the block information data
158
- * @param tx CAP transaction object
159
- * @param blockHash block hash (hex)
160
- * @returns {Promise<Block>} block entity data
161
- */
128
+ /** Index a block by hash, with best-effort epoch enrichment. */
162
129
  indexBlock(tx: CapTransaction, blockHash: string): Promise<Block>;
163
130
  /**
164
- * Bulk-index a whole block and all of its transactions in ONE pass (chain crawler,
165
- * v2.0). Unlike indexTransaction()/indexBlock() this does NOT re-fetch per hash — the
166
- * crawler already carries the block + full tx list from the stream/page. Rows are
167
- * accumulated across the block's txs and UPSERTed once per table (few statements).
168
- *
169
- * All writes run inside the caller's CAP transaction (`tx`), so a block is persisted
170
- * atomically — a failure mid-block rolls the whole block back, keeping the cursor and
171
- * the data consistent.
172
- *
173
- * Inputs from the Ogmios chain-sync path arrive as bare references (no address/amount);
174
- * resolveInputs() backfills them from this block's own outputs and previously-indexed
175
- * outputs before mapping. Blockfrost/Koios inputs already carry address/amount and are
176
- * left untouched.
177
- *
178
- * @param tx CAP transaction (one per block, committed by the crawler)
179
- * @param blockData block header/summary from the crawler source
180
- * @param txs the block's full transaction list (in block order)
131
+ * Bulk-index a whole block and its transactions in one pass for the crawler: no per-hash
132
+ * re-fetch, one UPSERT per table, all inside the caller's transaction so the block persists
133
+ * atomically. Bare chain-sync inputs are backfilled by resolveInputs() first.
181
134
  */
182
135
  indexBlockFull(tx: CapTransaction, blockData: BlockData, txs: ProviderTransaction[]): Promise<void>;
183
136
  /**
184
- * Backfill input address/amount for chain-sync transactions whose inputs are bare
185
- * references. Resolves first from this block's own outputs (a tx may spend an earlier
186
- * tx's output in the same block), then batch-reads previously-indexed outputs from the
187
- * DB. Inputs that already carry an address (Blockfrost/Koios) are skipped.
137
+ * Warn once when `crawler.certificates` is on but the source reports none (`certificates`
138
+ * undefined, as with Blockfrost). `[]` means "none" and is not a warning.
139
+ */
140
+ private warnIfCertificatesUnreported;
141
+ /**
142
+ * Backfill address/amount of bare chain-sync inputs: from this block's own outputs first,
143
+ * then earlier-indexed outputs from the DB. Inputs that already carry an address are skipped.
188
144
  */
189
145
  private resolveInputs;
190
146
  /**
191
- * Index & return the epoch information data
192
- * @param tx CAP transaction object
193
- * @param epochNumber epoch number
194
- * @returns {Promise<Epoch>} epoch entity data
147
+ * Settle the fee of phase-2-invalid transactions (collateral inputs minus collateral return)
148
+ * and the block total. The declared fee is kept when the mapper already set it via
149
+ * `total_collateral` or a collateral input is not indexed locally (the sum would be short).
195
150
  */
196
- indexEpoch(tx: CapTransaction, epochNumber: number): Promise<Epoch>;
151
+ private applyCollateralFees;
197
152
  /**
198
- * Index & return the account information data
199
- * @param tx CAP transaction object
200
- * @param stakeAddress stake address (bech32)
201
- * @returns {Promise<Account>} account entity data
202
- */
203
- indexAccount(tx: CapTransaction, stakeAddress: string): Promise<Account>;
153
+ * Mint/burn rows for a block from data in hand: the ledger's mint field when the source
154
+ * reports it (Ogmios, Koios), else Σ outputs − Σ inputs per unit, excluding reference and
155
+ * collateral inputs. A tx with an unresolvable consumed input is skipped and logged.
156
+ */
157
+ private buildAssetHistoryRows;
204
158
  /**
205
- * Index & return the drep information data
206
- * @param tx CAP transaction object
207
- * @param drepId drep id (bech32)
208
- * @returns {Promise<Drep>} drep entity data
159
+ * Keep the `Assets` catalogue complete for every unit the crawl meets, without provider calls.
160
+ * `Assets` is temporal, key `(validFrom, unit)`: the bare row's fixed epoch-zero stamp never
161
+ * aliases an enriched slice, so the UPSERT is safe inside the block transaction. The existence
162
+ * check uses the DB-level entity: the service projection's temporal filter hides such rows.
209
163
  */
210
- indexDrep(tx: CapTransaction, drepId: string): Promise<Drep>;
164
+ private ensureAssetRows;
211
165
  /**
212
- * Index & return the pool information data
213
- * @param tx CAP transaction object
214
- * @param poolId pool id (hex)
215
- * @returns {Promise<Pool>} pool entity data
166
+ * Remember a unit as present in the catalogue. Insertion-ordered eviction keeps a long
167
+ * backfill's memory flat; losing an entry costs one SELECT, never a wrong write.
216
168
  */
217
- indexPool(tx: CapTransaction, poolId: string): Promise<Pool>;
169
+ private noteAssetSeen;
218
170
  /**
219
- * Index & return the asset information data
220
- * @param tx CAP transaction object
221
- * @param unit asset unit (policyId + assetNameHex)
222
- * @returns {Promise<Asset>} asset entity data
171
+ * Snapshot every pool and DRep for an epoch in its OWN transaction (after the block commit):
172
+ * dated snapshot rows plus a refresh of the live `Pools` / `Dreps` rows. Needs Koios, else a no-op.
173
+ * @returns counts written
223
174
  */
175
+ snapshotEpoch(epoch: number, at: {
176
+ slot: number;
177
+ time: number;
178
+ }): Promise<{
179
+ pools: number;
180
+ dreps: number;
181
+ }>;
182
+ /** Every native-asset unit a block touches: outputs, consumed inputs and mint/burn rows. */
183
+ private collectBlockUnits;
184
+ /** Index an epoch by number. */
185
+ indexEpoch(tx: CapTransaction, epochNumber: number): Promise<Epoch>;
186
+ /** Index an account by stake address, plus its addresses when it has any. */
187
+ indexAccount(tx: CapTransaction, stakeAddress: string): Promise<Account>;
188
+ /** Index a DRep by bech32 id. */
189
+ indexDrep(tx: CapTransaction, drepId: string): Promise<Drep>;
190
+ /** Index a pool by id. */
191
+ indexPool(tx: CapTransaction, poolId: string): Promise<Pool>;
192
+ /** Index an asset by unit (policyId + assetNameHex). */
224
193
  indexAsset(tx: CapTransaction, unit: string): Promise<Asset>;
225
194
  /**
226
- * Index & return mint/burn history for an asset. Always-fresh from the
227
- * preferred backend (Koios for block timestamps, Blockfrost as fallback).
228
- * UPSERTs entries by (unit, txHash) — events are immutable, so re-fetching
229
- * just refreshes the cap of recent entries; older cached entries persist.
230
- * @param tx CAP transaction object
231
- * @param unit asset unit (policyId + assetNameHex)
232
- * @param limit max number of recent events to fetch (default 100)
233
- * @returns {Promise<AssetHistory[]>} list of mint/burn event entity rows
195
+ * Index mint/burn history for an asset, always fresh. Rows are keyed (unit, txHash), so a
196
+ * refetch refreshes the recent cap and older cached entries persist.
234
197
  */
235
198
  indexAssetHistory(tx: CapTransaction, unit: string, limit?: number): Promise<AssetHistory[]>;
236
- /**
237
- * Common method: build a transaction, persist build result with inputs/outputs/address associations.
238
- * All four public indexBuild*Result methods delegate to this to eliminate duplication.
239
- * @param tx CAP transaction object
240
- * @param buildreq transaction build request data
241
- * @param buildFn the specific builder method to call
242
- * @returns {Promise<TransactionBuild>} transaction build entity data
243
- */
199
+ /** Build a transaction and persist the build result with inputs/outputs/address association. */
244
200
  private _indexBuildResult;
245
201
  indexSimpleBuildResult(tx: CapTransaction, buildreq: TxBuildRequest): Promise<TransactionBuild>;
246
202
  indexMetadataBuildResult(tx: CapTransaction, buildreq: TxBuildRequest): Promise<TransactionBuild>;
247
203
  indexMultiAssetBuildResult(tx: CapTransaction, buildreq: TxBuildRequest): Promise<TransactionBuild>;
248
204
  indexMintBuildResult(tx: CapTransaction, buildreq: TxBuildRequest): Promise<TransactionBuild>;
249
205
  indexPlutusSpendBuildResult(tx: CapTransaction, buildreq: TxBuildRequest): Promise<TransactionBuild>;
250
- /**
251
- * Index & return the protocol parameters data
252
- * @param tx CAP transaction object
253
- * @returns {Promise<LedgerProtocolParameter>} protocol parameters entity data
254
- */
206
+ /** Protocol parameters, served from the DB row within a 5-minute TTL. */
255
207
  indexProtocolParameters(tx: CapTransaction): Promise<LedgerProtocolParameter>;
256
- /**
257
- * Persist a transaction submission with optional build association
258
- * Handles: TransactionSubmission insert, optional Build status update
259
- * @param tx CAP transaction object
260
- * @param params submission parameters
261
- * @returns {Promise<TransactionSubmission>} persisted transaction submission entity
262
- */
208
+ /** Persist a transaction submission and flag the build as submitted when linked. */
263
209
  persistTransactionSubmission(tx: CapTransaction, params: {
264
210
  signedTxCbor: string;
265
211
  txHash: string;
266
212
  buildId?: string | null;
267
213
  }): Promise<TransactionSubmission>;
268
- /**
269
- * Update the status of a transaction submission
270
- * Used for the two-phase submit flow: pending → submitted (or failed)
271
- * @param tx CAP transaction object
272
- * @param submissionId the submission to update
273
- * @param status new status value
274
- * @param errorMessage optional error message for failed status
275
- */
214
+ /** Update a submission's status (two-phase submit: pending → submitted or failed). */
276
215
  updateSubmissionStatus(tx: CapTransaction, submissionId: string, status: string, errorMessage?: string): Promise<void>;
277
- /**
278
- * Persist a new signing request
279
- * @param tx CAP transaction object
280
- * @param params signing request parameters from external signer module
281
- * @returns persisted signing request record
282
- */
216
+ /** Persist a new signing request and link it to the build's sender address. */
283
217
  persistSigningRequest(tx: CapTransaction, params: {
284
218
  buildId: string;
285
219
  signingPayload: {
@@ -308,13 +242,7 @@ export declare class CardanoIndexer {
308
242
  cardanoCliCommand: string | undefined;
309
243
  cip30TxCbor: string | undefined;
310
244
  }>;
311
- /**
312
- * Persist a signature verification with signing request status update
313
- * Handles: SignatureVerification insert, SigningRequest status update
314
- * @param tx CAP transaction object
315
- * @param params verification parameters
316
- * @returns persisted signature verification record
317
- */
245
+ /** Persist a signature verification and update the signing request status. */
318
246
  persistSignatureVerification(tx: CapTransaction, params: {
319
247
  signingRequestId: string;
320
248
  signedTxCbor: string;
@@ -340,13 +268,7 @@ export declare class CardanoIndexer {
340
268
  warnings: string;
341
269
  verifiedAt: string;
342
270
  }>;
343
- /**
344
- * Index a verified transaction submission with all related records
345
- * Handles persistence of: SignatureVerification, TransactionSubmission, SigningRequest update, Build update
346
- * @param tx CAP transaction object
347
- * @param params submission parameters
348
- * @returns {Promise<TransactionSubmission>} transaction submission entity data
349
- */
271
+ /** Persist a verified submission: verification, submission, signing request and build updates. */
350
272
  indexVerifiedTransactionSubmission(tx: CapTransaction, params: {
351
273
  signingRequestId: string;
352
274
  buildId: string;
@@ -361,38 +283,18 @@ export declare class CardanoIndexer {
361
283
  signerType?: string;
362
284
  signerInfo?: string;
363
285
  }): Promise<TransactionSubmission>;
364
- /**
365
- * Index & return the latest epoch information data
366
- * @param tx CAP transaction object
367
- * @returns {Promise<Epoch>} epoch entity data
368
- */
286
+ /** Index the latest epoch. */
369
287
  indexLatestEpoch(tx: CapTransaction): Promise<Epoch>;
370
- /**
371
- * Index & return the latest block information data
372
- * @param tx CAP transaction object
373
- * @returns {Promise<Block>} block entity data
374
- */
288
+ /** Index the latest block, with best-effort epoch enrichment. */
375
289
  indexLatestBlock(tx: CapTransaction): Promise<Block>;
376
290
  /** Max addresses to index concurrently (avoid overloading backends) */
377
291
  private static readonly ADDR_CONCURRENCY;
378
292
  /**
379
- * Ensure a set of transactions are indexed — batch DB-check + batch fetch.
380
- * 1. Deduplicate hashes
381
- * 2. Check which hashes already exist in DB
382
- * 3. Batch-fetch missing transactions from backend
383
- * 4. UPSERT all entities (Transactions, Inputs, Outputs, Assets, Metadata)
384
- *
385
- * @param tx CAP transaction (cds.tx)
386
- * @param txHashes array of transaction hashes to ensure
387
- * @returns Map of txHash → provider Transaction (all requested, from DB fetch or backend)
293
+ * Ensure a set of transactions is indexed: DB check, batch fetch of the missing ones, UPSERT.
294
+ * @returns provider transactions for the hashes that had to be fetched
388
295
  */
389
296
  ensureTransactionsIndexed(tx: CapTransaction, txHashes: string[]): Promise<Map<string, ProviderTransaction>>;
390
- /**
391
- * Index multiple addresses with concurrency-limited parallelism.
392
- * Processes addresses in chunks to avoid overwhelming backends.
393
- * @param tx CAP transaction object
394
- * @param bech32List array of bech32 addresses
395
- */
297
+ /** Index addresses with bounded concurrency. */
396
298
  private _ensureAddresses;
397
299
  }
398
300
  //# sourceMappingURL=cardano-indexer.d.ts.map