@odatano/core 2.0.0-rc.19 → 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.
- package/@cds-models/CardanoAgentService/index.d.ts +1 -5
- package/@cds-models/CardanoIndexerService/index.d.ts +51 -2
- package/@cds-models/CardanoIndexerService/index.js +7 -0
- package/package.json +1 -1
- package/src/index.d.ts +4 -10
- package/src/index.js +6 -16
- package/src/plugin.js +11 -27
- package/srv/blockchain/backends/blockfrost-backend.d.ts +29 -131
- package/srv/blockchain/backends/blockfrost-backend.js +39 -150
- package/srv/blockchain/backends/cardano-backend.d.ts +53 -171
- package/srv/blockchain/backends/cardano-backend.js +1 -5
- package/srv/blockchain/backends/koios-backend.d.ts +26 -71
- package/srv/blockchain/backends/koios-backend.js +50 -132
- package/srv/blockchain/backends/ogmios-backend.d.ts +43 -124
- package/srv/blockchain/backends/ogmios-backend.js +71 -179
- package/srv/blockchain/backends/ogmios-frame-guard.d.ts +12 -57
- package/srv/blockchain/backends/ogmios-frame-guard.js +27 -66
- package/srv/blockchain/cardano-client.d.ts +43 -216
- package/srv/blockchain/cardano-client.js +49 -234
- package/srv/blockchain/cardano-indexer.d.ts +79 -357
- package/srv/blockchain/cardano-indexer.js +98 -406
- package/srv/blockchain/cardano-tx-builder.d.ts +19 -84
- package/srv/blockchain/cardano-tx-builder.js +21 -107
- package/srv/blockchain/crawler/certificate-backfill.d.ts +45 -0
- package/srv/blockchain/crawler/certificate-backfill.js +150 -0
- package/srv/blockchain/crawler/crawler.d.ts +41 -145
- package/srv/blockchain/crawler/crawler.js +57 -172
- package/srv/blockchain/crawler/hooks.d.ts +3 -14
- package/srv/blockchain/crawler/index.d.ts +2 -6
- package/srv/blockchain/crawler/index.js +4 -9
- package/srv/blockchain/crawler/sync-state.d.ts +17 -39
- package/srv/blockchain/crawler/sync-state.js +23 -55
- package/srv/blockchain/crawler/utxo-set-import.d.ts +5 -22
- package/srv/blockchain/crawler/utxo-set-import.js +8 -28
- package/srv/blockchain/ledger-state.d.ts +3 -12
- package/srv/blockchain/signing/cose-verifier.d.ts +5 -12
- package/srv/blockchain/signing/cose-verifier.js +6 -12
- package/srv/blockchain/signing/external-signer.d.ts +16 -113
- package/srv/blockchain/signing/external-signer.js +19 -122
- package/srv/blockchain/signing/hsm-signer.d.ts +13 -45
- package/srv/blockchain/signing/hsm-signer.js +23 -63
- package/srv/blockchain/signing/signature-verifier.d.ts +8 -44
- package/srv/blockchain/signing/signature-verifier.js +13 -54
- package/srv/blockchain/signing/submission-finalizer.d.ts +9 -36
- package/srv/blockchain/signing/submission-finalizer.js +16 -48
- package/srv/blockchain/transaction-building/buildooor-tx.d.ts +65 -174
- package/srv/blockchain/transaction-building/buildooor-tx.js +107 -266
- package/srv/blockchain/transaction-building/cardano-tx.d.ts +8 -34
- package/srv/blockchain/wallet-worker/build-request.d.ts +4 -17
- package/srv/blockchain/wallet-worker/build-request.js +9 -22
- package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +12 -35
- package/srv/blockchain/wallet-worker/confirmation-tracker.js +16 -32
- package/srv/blockchain/wallet-worker/index.js +2 -8
- package/srv/blockchain/wallet-worker/job-store.d.ts +33 -111
- package/srv/blockchain/wallet-worker/job-store.js +0 -0
- package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +4 -20
- package/srv/blockchain/wallet-worker/lease-heartbeat.js +4 -20
- package/srv/blockchain/wallet-worker/signers.d.ts +6 -19
- package/srv/blockchain/wallet-worker/signers.js +3 -8
- package/srv/blockchain/wallet-worker/wallet-worker.d.ts +15 -71
- package/srv/blockchain/wallet-worker/wallet-worker.js +34 -90
- package/srv/cardano-agent-service.cds +1 -5
- package/srv/cardano-agent-service.js +3 -7
- package/srv/cardano-indexer-service.cds +32 -4
- package/srv/cardano-indexer-service.js +83 -15
- package/srv/cardano-service.js +36 -98
- package/srv/cardano-sign-service.cds +1 -1
- package/srv/cardano-sign-service.js +55 -173
- package/srv/cardano-tx-service.cds +1 -1
- package/srv/cardano-tx-service.js +54 -174
- package/srv/cardano-worker-service.js +7 -15
- package/srv/server.d.ts +27 -86
- package/srv/server.js +52 -148
- package/srv/utils/agent-grants-config.d.ts +11 -50
- package/srv/utils/agent-grants-config.js +12 -45
- package/srv/utils/agent-grants.d.ts +34 -123
- package/srv/utils/agent-grants.js +57 -156
- package/srv/utils/agent-token-auth.d.ts +2 -5
- package/srv/utils/agent-token-auth.js +2 -5
- package/srv/utils/backend-request-handler.d.ts +2 -16
- package/srv/utils/backend-request-handler.js +3 -18
- package/srv/utils/collections.d.ts +4 -8
- package/srv/utils/collections.js +4 -8
- package/srv/utils/const.d.ts +19 -68
- package/srv/utils/const.js +20 -69
- package/srv/utils/crypto.d.ts +3 -12
- package/srv/utils/crypto.js +5 -18
- package/srv/utils/db-indexes.d.ts +2 -7
- package/srv/utils/db-indexes.js +7 -34
- package/srv/utils/db-sanitize.d.ts +5 -18
- package/srv/utils/db-sanitize.js +6 -19
- package/srv/utils/error-codes.d.ts +18 -73
- package/srv/utils/error-codes.js +17 -70
- package/srv/utils/errors.d.ts +29 -191
- package/srv/utils/errors.js +44 -229
- package/srv/utils/liveness.d.ts +2 -9
- package/srv/utils/liveness.js +3 -11
- package/srv/utils/mappers.d.ts +50 -298
- package/srv/utils/mappers.js +80 -386
- package/srv/utils/network-context.js +2 -11
- package/srv/utils/pg-order-nulls.js +4 -23
- package/srv/utils/plutus-placeholders.d.ts +6 -18
- package/srv/utils/plutus-placeholders.js +6 -20
- package/srv/utils/rate-limiter.d.ts +6 -17
- package/srv/utils/rate-limiter.js +5 -15
- package/srv/utils/service-events.d.ts +2 -22
- package/srv/utils/service-events.js +3 -23
- package/srv/utils/signing-helper.d.ts +3 -18
- package/srv/utils/signing-helper.js +10 -32
- package/srv/utils/tx-build-helper.d.ts +18 -92
- package/srv/utils/tx-build-helper.js +32 -123
- package/srv/utils/tx-request-parsers.d.ts +7 -26
- package/srv/utils/tx-request-parsers.js +7 -26
- package/srv/utils/tx-utils.d.ts +4 -23
- package/srv/utils/tx-utils.js +12 -41
- package/srv/utils/types.d.ts +67 -206
- package/srv/utils/types.js +2 -6
- package/srv/utils/validators.d.ts +19 -89
- package/srv/utils/validators.js +31 -138
|
@@ -7,17 +7,8 @@ import { TxBuildRequest, Transaction as ProviderTransaction, BlockData } from '.
|
|
|
7
7
|
import { type LedgerAnchor } from './ledger-state';
|
|
8
8
|
import type { TxCacheTargets } from '../utils/tx-build-helper';
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* Provides methods to index & manage db consistency for various Cardano blockchain data (transactions, addresses, blocks, epochs, accounts, pools, dreps)
|
|
13
|
-
* 1. Fetches data from the configured Cardano data provider via the CardanoClient
|
|
14
|
-
* 2. Maps the provider data into corresponding OData entity rows
|
|
15
|
-
* 3. Upserts the data rows into the database via CAP transactions
|
|
16
|
-
* 4. Ensures referential integrity and consistency across related entities (e.g., addresses in transactions, UTxOs in addresses)
|
|
17
|
-
* 5. Returns the indexed entity data for further processing
|
|
18
|
-
*
|
|
19
|
-
* Each method corresponds to a specific Cardano Entity type and handles the necessary mapping and persistence
|
|
20
|
-
* 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.
|
|
21
12
|
*/
|
|
22
13
|
export declare class CardanoIndexer {
|
|
23
14
|
private client;
|
|
@@ -26,23 +17,14 @@ export declare class CardanoIndexer {
|
|
|
26
17
|
private static readonly CRAWL_EPOCH_REFRESH_MS;
|
|
27
18
|
private static readonly CRAWL_EPOCH_RETRY_MS;
|
|
28
19
|
/**
|
|
29
|
-
* Crawler epoch memo
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* At most the current and immediately previous epoch are retained. The rows are
|
|
34
|
-
* intentionally UPSERTed in every block transaction: the caller owns that
|
|
35
|
-
* transaction, so an in-memory "persisted" bit cannot know whether its commit later
|
|
36
|
-
* 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.
|
|
37
23
|
*/
|
|
38
24
|
private crawlEpochCache;
|
|
39
25
|
private crawlEpochCurrent;
|
|
40
26
|
private crawlEpochPrevious;
|
|
41
|
-
/**
|
|
42
|
-
* Analytics coverage of the crawl path (v2.0). The
|
|
43
|
-
* defaults mirror the crawler config defaults, so an indexer the crawler never configured
|
|
44
|
-
* (unit tests, the lazy-only path) behaves exactly like a configured one.
|
|
45
|
-
*/
|
|
27
|
+
/** Analytics coverage of the crawl path; defaults mirror the crawler config defaults. */
|
|
46
28
|
private crawlAssetHistory;
|
|
47
29
|
private crawlAssetCatalogue;
|
|
48
30
|
/** Certificates + withdrawals per block (ledger-state coverage). Opt-in. */
|
|
@@ -50,37 +32,30 @@ export declare class CardanoIndexer {
|
|
|
50
32
|
/** Logged once per process: the active source reports no certificates (Blockfrost). */
|
|
51
33
|
private certificatesUnreportedWarned;
|
|
52
34
|
/**
|
|
53
|
-
* Crawler-fed ledger state (`crawler.utxoSet`)
|
|
54
|
-
*
|
|
55
|
-
* past it) means the mode is configured but inactive.
|
|
35
|
+
* Crawler-fed ledger state (`crawler.utxoSet`): blocks after `utxoAnchor` are applied to the
|
|
36
|
+
* Ledger* tables; no anchor means configured but inactive.
|
|
56
37
|
*/
|
|
57
38
|
private crawlUtxoSet;
|
|
58
39
|
private utxoAnchor;
|
|
59
40
|
/** The anchor block was found in the crawled chain (checked once, before the first apply). */
|
|
60
41
|
private utxoAnchorVerified;
|
|
61
42
|
/**
|
|
62
|
-
* Invalidation decided inside a block transaction
|
|
63
|
-
*
|
|
64
|
-
* loses the anchor nor leaves the DB saying `active` while this process stopped applying.
|
|
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.
|
|
65
45
|
*/
|
|
66
46
|
private ledgerInvalidation;
|
|
67
47
|
/** Units known to have an `Assets` row, so a repeat sighting costs no DB round-trip. */
|
|
68
48
|
private static readonly ASSET_MEMO_CAP;
|
|
69
49
|
private assetMemo;
|
|
70
50
|
/**
|
|
71
|
-
* Background registry enrichment (`assetCatalogue: 'enrich'`)
|
|
72
|
-
*
|
|
73
|
-
* but never the crawl. Above the cap the oldest entries are dropped: the unit keeps its bare
|
|
74
|
-
* row and is still enriched by the lazy path on its first API read.
|
|
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).
|
|
75
53
|
*/
|
|
76
54
|
private static readonly ENRICH_QUEUE_CAP;
|
|
77
55
|
private enrichQueue;
|
|
78
56
|
private enrichTimer;
|
|
79
57
|
private enrichRate;
|
|
80
|
-
/**
|
|
81
|
-
* Adopt the crawler's coverage settings. Called once from the crawler's start path; the
|
|
82
|
-
* lazy request path never touches these.
|
|
83
|
-
*/
|
|
58
|
+
/** Adopt the crawler's coverage settings; the lazy request path never touches these. */
|
|
84
59
|
configureCrawlCoverage(coverage: {
|
|
85
60
|
assetHistory: boolean;
|
|
86
61
|
assetCatalogue: 'off' | 'bare' | 'enrich';
|
|
@@ -91,272 +66,111 @@ export declare class CardanoIndexer {
|
|
|
91
66
|
/** The anchor the imported UTxO set describes (null = ledger mode inactive). */
|
|
92
67
|
setUtxoAnchor(anchor: LedgerAnchor | null): void;
|
|
93
68
|
/**
|
|
94
|
-
* The imported set describes the chain AT the anchor block
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* never in its cursor) would otherwise seed the set with the wrong balances.
|
|
98
|
-
*
|
|
99
|
-
* The check is against the cursor, not the Blocks table: when the first block past the
|
|
100
|
-
* anchor arrives, the cursor (not yet advanced in this transaction) IS the block the
|
|
101
|
-
* crawler followed last, so it must equal the anchor exactly. That also covers the
|
|
102
|
-
* bootstrap case — the configured start block sits in the cursor without a Blocks row of
|
|
103
|
-
* its own. Once a block has been applied (`utxoAppliedSlot` set, same transaction), the
|
|
104
|
-
* anchor was verified and a restart skips the check.
|
|
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.
|
|
105
72
|
*/
|
|
106
73
|
private verifyUtxoAnchor;
|
|
107
74
|
/** Null while the mode is off, nothing is imported, or an invalidation awaits its commit. */
|
|
108
75
|
getUtxoAnchor(): LedgerAnchor | null;
|
|
109
|
-
/**
|
|
110
|
-
* Called by the crawler right after a block transaction committed: hands out a pending
|
|
111
|
-
* invalidation (and drops the anchor) exactly once, or null.
|
|
112
|
-
*/
|
|
76
|
+
/** Hand out a pending invalidation (dropping the anchor) exactly once after the block commit, or null. */
|
|
113
77
|
takeLedgerInvalidation(): string | null;
|
|
114
78
|
/**
|
|
115
79
|
* Drain the enrichment queue at `enrichRate` units per second, one `indexAsset()` per tick in
|
|
116
|
-
* its own transaction.
|
|
117
|
-
* unit (404 from every backend, provider outage) is dropped rather than retried — its bare row
|
|
118
|
-
* stays and the lazy path can still enrich it later.
|
|
80
|
+
* its own transaction. A failing unit is dropped; its bare row stays for the lazy path.
|
|
119
81
|
*/
|
|
120
82
|
private startAssetEnrichment;
|
|
121
83
|
/** Stop the enrichment loop and forget what is still queued (shutdown, crawler halt, mode change). */
|
|
122
84
|
stopAssetEnrichment(): void;
|
|
123
85
|
/**
|
|
124
|
-
* Network-only epoch prefetch for the crawler. Call BEFORE opening the per-block
|
|
125
|
-
*
|
|
126
|
-
* lock is held (indexBlockFull then serves the epoch from this memo). Never throws.
|
|
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.
|
|
127
88
|
*/
|
|
128
89
|
prefetchCrawlEpoch(epochNumber: number): Promise<void>;
|
|
129
90
|
private refreshCrawlEpoch;
|
|
130
|
-
/**
|
|
131
|
-
* Create a new CardanoIndexer instance
|
|
132
|
-
* @param client - The CardanoClient instance for blockchain queries
|
|
133
|
-
* @param txBuilder - The CardanoTransactionBuilder instance for transaction building
|
|
134
|
-
*/
|
|
135
91
|
constructor(client: CardanoClient, txBuilder: CardanoTransactionBuilder);
|
|
136
92
|
/**
|
|
137
|
-
* Index
|
|
138
|
-
*
|
|
139
|
-
* atomicity: either all entities are persisted or none are (automatic rollback on error).
|
|
140
|
-
* @param tx CAP transaction (cds.tx(req))
|
|
141
|
-
* @param txHash Cardano transaction hash (hex)
|
|
142
|
-
* @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.
|
|
143
95
|
*/
|
|
144
96
|
indexTransaction(tx: CapTransaction, txHash: string): Promise<CardanoTransaction>;
|
|
145
97
|
/**
|
|
146
|
-
* Index
|
|
147
|
-
*
|
|
148
|
-
* @param tx CAP transaction
|
|
149
|
-
* @param addr bech32 address
|
|
150
|
-
* @return {Promise<Address>} address entity data
|
|
98
|
+
* Index address data with assets and UTxOs; transactions are loaded separately via
|
|
99
|
+
* indexAddressTransactions().
|
|
151
100
|
*/
|
|
152
101
|
indexAddress(tx: CapTransaction, addr: string): Promise<Address>;
|
|
153
102
|
/**
|
|
154
|
-
* Index UTxOs by 28-byte payment credential
|
|
155
|
-
*
|
|
156
|
-
* current data. Underlying AddressUTxOs/UTxOAssets rows are UPSERTed and stay
|
|
157
|
-
* available for follow-up address-keyed queries within the TTL.
|
|
158
|
-
*
|
|
159
|
-
* Does NOT upsert parent Addresses rows; child rows reference bech32 addresses
|
|
160
|
-
* that may not yet have a parent stub. Same pattern as TransactionInputs.
|
|
161
|
-
*
|
|
162
|
-
* @param tx CAP transaction
|
|
163
|
-
* @param credHash 28-byte payment credential as 56-char lowercase hex
|
|
164
|
-
* @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).
|
|
165
105
|
*/
|
|
166
106
|
indexCredentialUtxos(tx: CapTransaction, credHash: string): Promise<AddressUTxOs[]>;
|
|
167
107
|
/**
|
|
168
|
-
* Index
|
|
169
|
-
*
|
|
170
|
-
* the live UTxO set but not address aggregation (e.g. Ogmios). Used as the
|
|
171
|
-
* GetUTxOsByAddress fallback when no configured backend supports getAddress.
|
|
172
|
-
*
|
|
173
|
-
* Does NOT upsert a parent Addresses row (same pattern as indexCredentialUtxos);
|
|
174
|
-
* AddressUTxOs/UTxOAssets reference the bech32 address directly.
|
|
175
|
-
*
|
|
176
|
-
* @param tx CAP transaction
|
|
177
|
-
* @param addr bech32 address
|
|
178
|
-
* @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.
|
|
179
110
|
*/
|
|
180
111
|
indexAddressUtxos(tx: CapTransaction, addr: string): Promise<AddressUTxOs[]>;
|
|
181
112
|
/**
|
|
182
|
-
* Evict cached rows a submitted transaction made stale
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
* - all address-level rows of the output addresses (their UTxO set gained
|
|
186
|
-
* the new outputs — sender change included) and of `extraAddresses`
|
|
187
|
-
* (e.g. the build's sender when the CBOR could not be parsed).
|
|
188
|
-
*
|
|
189
|
-
* Only the read cache is touched; submissions/builds stay untouched. Note the
|
|
190
|
-
* next refetch may STILL see pre-submit state on lagging backends
|
|
191
|
-
* (Blockfrost/Koios propagation) — that matches cache-less behaviour and is
|
|
192
|
-
* not recoverable server-side.
|
|
193
|
-
*
|
|
194
|
-
* @param tx CAP transaction
|
|
195
|
-
* @param targets input refs + output addresses from extractTxCacheTargets
|
|
196
|
-
* @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.
|
|
197
116
|
*/
|
|
198
117
|
invalidateUtxoCacheForTx(tx: CapTransaction, targets: TxCacheTargets, extraAddresses?: string[]): Promise<void>;
|
|
199
|
-
/**
|
|
200
|
-
* Index & return address transactions (separate from indexAddress for lazy loading)
|
|
201
|
-
* @param tx CAP transaction
|
|
202
|
-
* @param addr bech32 address
|
|
203
|
-
* @param limit maximum number of transactions to fetch
|
|
204
|
-
* @return {Promise<AddressTransactions[]>} address transaction entities
|
|
205
|
-
*/
|
|
118
|
+
/** Index address transactions (separate from indexAddress for lazy loading). */
|
|
206
119
|
indexAddressTransactions(tx: CapTransaction, addr: string, limit: number): Promise<AddressTransactions[]>;
|
|
207
|
-
/**
|
|
208
|
-
* Index & return address signing request association
|
|
209
|
-
* Links an address to a signing request for address-based queries
|
|
210
|
-
* @param tx CAP transaction
|
|
211
|
-
* @param addr bech32 address
|
|
212
|
-
* @param signingRequestId signing request UUID
|
|
213
|
-
* @return {Promise<void>}
|
|
214
|
-
*/
|
|
120
|
+
/** Link an address to a signing request for address-based queries. */
|
|
215
121
|
indexAddressSigningRequests(tx: CapTransaction, addr: string, signingRequestId: string): Promise<void>;
|
|
216
|
-
/**
|
|
217
|
-
* Index & return address transaction build association
|
|
218
|
-
* Links an address to a transaction build for address-based queries
|
|
219
|
-
* @param tx CAP transaction
|
|
220
|
-
* @param addr bech32 address
|
|
221
|
-
* @param buildId transaction build UUID
|
|
222
|
-
* @return {Promise<void>}
|
|
223
|
-
*/
|
|
122
|
+
/** Link an address to a transaction build for address-based queries. */
|
|
224
123
|
indexAddressTransactionBuilds(tx: CapTransaction, addr: string, buildId: string): Promise<void>;
|
|
225
|
-
/**
|
|
226
|
-
* Index & return metadata for a single transaction (Metadata)
|
|
227
|
-
* @param tx CAP transaction
|
|
228
|
-
* @param txHash transaction hash
|
|
229
|
-
* @param metadata raw metadata object (label -> JSONValue)
|
|
230
|
-
* @return {Promise<TransactionMetadata[]>} array of transaction metadata rows
|
|
231
|
-
*/
|
|
124
|
+
/** Index the metadata rows of a transaction. */
|
|
232
125
|
indexTransactionMetadata(tx: CapTransaction, tx_hash: string): Promise<TransactionMetadata[]>;
|
|
233
|
-
/**
|
|
234
|
-
* Index & return the network information data
|
|
235
|
-
* @param tx CAP transaction object
|
|
236
|
-
* @returns {Promise<NetworkInformation>} network information entity data
|
|
237
|
-
*/
|
|
126
|
+
/** Index the network information. */
|
|
238
127
|
indexNetworkInformation(tx: CapTransaction): Promise<NetworkInformation>;
|
|
239
|
-
/**
|
|
240
|
-
* Index & return the block information data
|
|
241
|
-
* @param tx CAP transaction object
|
|
242
|
-
* @param blockHash block hash (hex)
|
|
243
|
-
* @returns {Promise<Block>} block entity data
|
|
244
|
-
*/
|
|
128
|
+
/** Index a block by hash, with best-effort epoch enrichment. */
|
|
245
129
|
indexBlock(tx: CapTransaction, blockHash: string): Promise<Block>;
|
|
246
130
|
/**
|
|
247
|
-
* Bulk-index a whole block and
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
* accumulated across the block's txs and UPSERTed once per table (few statements).
|
|
251
|
-
*
|
|
252
|
-
* All writes run inside the caller's CAP transaction (`tx`), so a block is persisted
|
|
253
|
-
* atomically — a failure mid-block rolls the whole block back, keeping the cursor and
|
|
254
|
-
* the data consistent.
|
|
255
|
-
*
|
|
256
|
-
* Inputs from the Ogmios chain-sync path arrive as bare references (no address/amount);
|
|
257
|
-
* resolveInputs() backfills them from this block's own outputs and previously-indexed
|
|
258
|
-
* outputs before mapping. Blockfrost/Koios inputs already carry address/amount and are
|
|
259
|
-
* left untouched.
|
|
260
|
-
*
|
|
261
|
-
* @param tx CAP transaction (one per block, committed by the crawler)
|
|
262
|
-
* @param blockData block header/summary from the crawler source
|
|
263
|
-
* @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.
|
|
264
134
|
*/
|
|
265
135
|
indexBlockFull(tx: CapTransaction, blockData: BlockData, txs: ProviderTransaction[]): Promise<void>;
|
|
266
136
|
/**
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
* tx's output in the same block), then batch-reads previously-indexed outputs from the
|
|
270
|
-
* 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.
|
|
271
139
|
*/
|
|
140
|
+
private warnIfCertificatesUnreported;
|
|
272
141
|
/**
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
* calls per transaction). `[]` means "none", undefined means "unreported"; only the latter is
|
|
276
|
-
* worth a warning, and only once — the crawl itself is unaffected.
|
|
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.
|
|
277
144
|
*/
|
|
278
|
-
private warnIfCertificatesUnreported;
|
|
279
145
|
private resolveInputs;
|
|
280
146
|
/**
|
|
281
|
-
* Settle the fee of phase-2-invalid transactions
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
* collateral instead, i.e. the collateral inputs minus the collateral return. The Ogmios
|
|
285
|
-
* mapper already uses the body's `total_collateral` when it declares one; what is left are
|
|
286
|
-
* the transactions without it, and those need the collateral inputs that resolveInputs()
|
|
287
|
-
* has just filled in.
|
|
288
|
-
*
|
|
289
|
-
* A collateral input the crawler cannot resolve — spent from an output produced before the
|
|
290
|
-
* crawl start, so no row exists locally — would make the sum silently too small. The
|
|
291
|
-
* declared fee is kept in that case and the transaction is logged: a value that is wrong in
|
|
292
|
-
* a known, named way beats one that looks derived but is short by an unknown amount.
|
|
293
|
-
*
|
|
294
|
-
* Applies to every backend that reports phase-2 validity — the chain-sync path (`spends`)
|
|
295
|
-
* and Blockfrost (`valid_contract`), whose declared `fees` are likewise never collected on a
|
|
296
|
-
* failed script phase, and Koios (`valid_contract` + collateral inputs/output on `/tx_info`).
|
|
297
|
-
* A source without the field carries `spendsCollaterals` as undefined and passes through
|
|
298
|
-
* untouched.
|
|
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).
|
|
299
150
|
*/
|
|
300
151
|
private applyCollateralFees;
|
|
301
152
|
/**
|
|
302
|
-
* Mint/burn rows for a
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
* Two sources, in this order:
|
|
306
|
-
* 1. `t.mint` — the ledger's own mint field, reported natively by Ogmios (`mint`) and
|
|
307
|
-
* Koios (`assets_minted`). Authoritative: it needs no resolved inputs and states the
|
|
308
|
-
* net per unit directly.
|
|
309
|
-
* 2. Σ outputs − Σ inputs per unit, for backends without that field (Blockfrost), whose
|
|
310
|
-
* inputs all carry their full `amount` so the delta is exact.
|
|
311
|
-
*
|
|
312
|
-
* The delta path excludes what the ledger does not consume or produce: reference inputs are
|
|
313
|
-
* read, never spent, and collateral only moves when the script phase failed — which applies
|
|
314
|
-
* no mint at all, so those transactions are skipped outright. Both exclusions rest on
|
|
315
|
-
* `isReference` / `isCollateral` / `spendsCollaterals`, which every backend that can reach
|
|
316
|
-
* this branch has to set — Blockfrost does since rc.12. A transaction with even one
|
|
317
|
-
* unresolvable consumed input (an output created before the crawl start, so no local row) is
|
|
318
|
-
* skipped and logged rather than reported with a delta that is short by an unknown amount —
|
|
319
|
-
* the same discipline as applyCollateralFees() above.
|
|
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.
|
|
320
156
|
*/
|
|
321
157
|
private buildAssetHistoryRows;
|
|
322
158
|
/**
|
|
323
|
-
* Keep the `Assets` catalogue complete for every unit the crawl meets,
|
|
324
|
-
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
* therefore carries the fixed epoch-zero stamp (`BARE_ASSET_STAMP`), which no wall-clock slice
|
|
328
|
-
* from mapAsset() can ever alias: the write cannot overwrite enriched registry data, and it
|
|
329
|
-
* stays a single idempotent row per unit. That makes UPSERT safe — and safe is what it has to
|
|
330
|
-
* be, because this runs inside the crawler's block transaction, where a unique-key violation
|
|
331
|
-
* from a lazy-path write racing us would take the whole block down with it (and on PostgreSQL
|
|
332
|
-
* poison the transaction beyond any catch).
|
|
333
|
-
*
|
|
334
|
-
* The existence check is then only an optimization — it keeps a settled catalogue from
|
|
335
|
-
* rewriting every unit of every block. It runs against the DB-LEVEL entity on purpose: the
|
|
336
|
-
* service projection carries the temporal filter (`validFrom < $valid.to AND validTo >
|
|
337
|
-
* $valid.from`), which hides precisely the born-expired rows this check is looking for.
|
|
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.
|
|
338
163
|
*/
|
|
339
164
|
private ensureAssetRows;
|
|
340
165
|
/**
|
|
341
|
-
* Remember a unit as present in the catalogue. Insertion-ordered
|
|
342
|
-
*
|
|
343
|
-
* hot policies stay memoized. Losing an entry costs one SELECT, never a wrong write.
|
|
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.
|
|
344
168
|
*/
|
|
345
169
|
private noteAssetSeen;
|
|
346
170
|
/**
|
|
347
|
-
* Snapshot every
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
* block's write transaction: a few thousand rows would inflate an otherwise small atomic
|
|
351
|
-
* write, and a snapshot failure would fail the block and burn its persist retries.
|
|
352
|
-
*
|
|
353
|
-
* Writes two things per entity: the dated snapshot row (authoritative, never expires) and a
|
|
354
|
-
* refresh of the live temporal row, so `Pools` / `Dreps` also stop being empty on a crawled
|
|
355
|
-
* instance. Needs an enumerating backend (Koios); without one it is a logged no-op.
|
|
356
|
-
*
|
|
357
|
-
* @param epoch the epoch the snapshot is taken for
|
|
358
|
-
* @param at slot and block time of the block that triggered the boundary
|
|
359
|
-
* @returns counts actually written, for the caller's log
|
|
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
|
|
360
174
|
*/
|
|
361
175
|
snapshotEpoch(epoch: number, at: {
|
|
362
176
|
slot: number;
|
|
@@ -367,99 +181,39 @@ export declare class CardanoIndexer {
|
|
|
367
181
|
}>;
|
|
368
182
|
/** Every native-asset unit a block touches: outputs, consumed inputs and mint/burn rows. */
|
|
369
183
|
private collectBlockUnits;
|
|
370
|
-
/**
|
|
371
|
-
* Index & return the epoch information data
|
|
372
|
-
* @param tx CAP transaction object
|
|
373
|
-
* @param epochNumber epoch number
|
|
374
|
-
* @returns {Promise<Epoch>} epoch entity data
|
|
375
|
-
*/
|
|
184
|
+
/** Index an epoch by number. */
|
|
376
185
|
indexEpoch(tx: CapTransaction, epochNumber: number): Promise<Epoch>;
|
|
377
|
-
/**
|
|
378
|
-
* Index & return the account information data
|
|
379
|
-
* @param tx CAP transaction object
|
|
380
|
-
* @param stakeAddress stake address (bech32)
|
|
381
|
-
* @returns {Promise<Account>} account entity data
|
|
382
|
-
*/
|
|
186
|
+
/** Index an account by stake address, plus its addresses when it has any. */
|
|
383
187
|
indexAccount(tx: CapTransaction, stakeAddress: string): Promise<Account>;
|
|
384
|
-
/**
|
|
385
|
-
* Index & return the drep information data
|
|
386
|
-
* @param tx CAP transaction object
|
|
387
|
-
* @param drepId drep id (bech32)
|
|
388
|
-
* @returns {Promise<Drep>} drep entity data
|
|
389
|
-
*/
|
|
188
|
+
/** Index a DRep by bech32 id. */
|
|
390
189
|
indexDrep(tx: CapTransaction, drepId: string): Promise<Drep>;
|
|
391
|
-
/**
|
|
392
|
-
* Index & return the pool information data
|
|
393
|
-
* @param tx CAP transaction object
|
|
394
|
-
* @param poolId pool id (hex)
|
|
395
|
-
* @returns {Promise<Pool>} pool entity data
|
|
396
|
-
*/
|
|
190
|
+
/** Index a pool by id. */
|
|
397
191
|
indexPool(tx: CapTransaction, poolId: string): Promise<Pool>;
|
|
398
|
-
/**
|
|
399
|
-
* Index & return the asset information data
|
|
400
|
-
* @param tx CAP transaction object
|
|
401
|
-
* @param unit asset unit (policyId + assetNameHex)
|
|
402
|
-
* @returns {Promise<Asset>} asset entity data
|
|
403
|
-
*/
|
|
192
|
+
/** Index an asset by unit (policyId + assetNameHex). */
|
|
404
193
|
indexAsset(tx: CapTransaction, unit: string): Promise<Asset>;
|
|
405
194
|
/**
|
|
406
|
-
* Index
|
|
407
|
-
*
|
|
408
|
-
* UPSERTs entries by (unit, txHash) — events are immutable, so re-fetching
|
|
409
|
-
* just refreshes the cap of recent entries; older cached entries persist.
|
|
410
|
-
* @param tx CAP transaction object
|
|
411
|
-
* @param unit asset unit (policyId + assetNameHex)
|
|
412
|
-
* @param limit max number of recent events to fetch (default 100)
|
|
413
|
-
* @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.
|
|
414
197
|
*/
|
|
415
198
|
indexAssetHistory(tx: CapTransaction, unit: string, limit?: number): Promise<AssetHistory[]>;
|
|
416
|
-
/**
|
|
417
|
-
* Common method: build a transaction, persist build result with inputs/outputs/address associations.
|
|
418
|
-
* All four public indexBuild*Result methods delegate to this to eliminate duplication.
|
|
419
|
-
* @param tx CAP transaction object
|
|
420
|
-
* @param buildreq transaction build request data
|
|
421
|
-
* @param buildFn the specific builder method to call
|
|
422
|
-
* @returns {Promise<TransactionBuild>} transaction build entity data
|
|
423
|
-
*/
|
|
199
|
+
/** Build a transaction and persist the build result with inputs/outputs/address association. */
|
|
424
200
|
private _indexBuildResult;
|
|
425
201
|
indexSimpleBuildResult(tx: CapTransaction, buildreq: TxBuildRequest): Promise<TransactionBuild>;
|
|
426
202
|
indexMetadataBuildResult(tx: CapTransaction, buildreq: TxBuildRequest): Promise<TransactionBuild>;
|
|
427
203
|
indexMultiAssetBuildResult(tx: CapTransaction, buildreq: TxBuildRequest): Promise<TransactionBuild>;
|
|
428
204
|
indexMintBuildResult(tx: CapTransaction, buildreq: TxBuildRequest): Promise<TransactionBuild>;
|
|
429
205
|
indexPlutusSpendBuildResult(tx: CapTransaction, buildreq: TxBuildRequest): Promise<TransactionBuild>;
|
|
430
|
-
/**
|
|
431
|
-
* Index & return the protocol parameters data
|
|
432
|
-
* @param tx CAP transaction object
|
|
433
|
-
* @returns {Promise<LedgerProtocolParameter>} protocol parameters entity data
|
|
434
|
-
*/
|
|
206
|
+
/** Protocol parameters, served from the DB row within a 5-minute TTL. */
|
|
435
207
|
indexProtocolParameters(tx: CapTransaction): Promise<LedgerProtocolParameter>;
|
|
436
|
-
/**
|
|
437
|
-
* Persist a transaction submission with optional build association
|
|
438
|
-
* Handles: TransactionSubmission insert, optional Build status update
|
|
439
|
-
* @param tx CAP transaction object
|
|
440
|
-
* @param params submission parameters
|
|
441
|
-
* @returns {Promise<TransactionSubmission>} persisted transaction submission entity
|
|
442
|
-
*/
|
|
208
|
+
/** Persist a transaction submission and flag the build as submitted when linked. */
|
|
443
209
|
persistTransactionSubmission(tx: CapTransaction, params: {
|
|
444
210
|
signedTxCbor: string;
|
|
445
211
|
txHash: string;
|
|
446
212
|
buildId?: string | null;
|
|
447
213
|
}): Promise<TransactionSubmission>;
|
|
448
|
-
/**
|
|
449
|
-
* Update the status of a transaction submission
|
|
450
|
-
* Used for the two-phase submit flow: pending → submitted (or failed)
|
|
451
|
-
* @param tx CAP transaction object
|
|
452
|
-
* @param submissionId the submission to update
|
|
453
|
-
* @param status new status value
|
|
454
|
-
* @param errorMessage optional error message for failed status
|
|
455
|
-
*/
|
|
214
|
+
/** Update a submission's status (two-phase submit: pending → submitted or failed). */
|
|
456
215
|
updateSubmissionStatus(tx: CapTransaction, submissionId: string, status: string, errorMessage?: string): Promise<void>;
|
|
457
|
-
/**
|
|
458
|
-
* Persist a new signing request
|
|
459
|
-
* @param tx CAP transaction object
|
|
460
|
-
* @param params signing request parameters from external signer module
|
|
461
|
-
* @returns persisted signing request record
|
|
462
|
-
*/
|
|
216
|
+
/** Persist a new signing request and link it to the build's sender address. */
|
|
463
217
|
persistSigningRequest(tx: CapTransaction, params: {
|
|
464
218
|
buildId: string;
|
|
465
219
|
signingPayload: {
|
|
@@ -488,13 +242,7 @@ export declare class CardanoIndexer {
|
|
|
488
242
|
cardanoCliCommand: string | undefined;
|
|
489
243
|
cip30TxCbor: string | undefined;
|
|
490
244
|
}>;
|
|
491
|
-
/**
|
|
492
|
-
* Persist a signature verification with signing request status update
|
|
493
|
-
* Handles: SignatureVerification insert, SigningRequest status update
|
|
494
|
-
* @param tx CAP transaction object
|
|
495
|
-
* @param params verification parameters
|
|
496
|
-
* @returns persisted signature verification record
|
|
497
|
-
*/
|
|
245
|
+
/** Persist a signature verification and update the signing request status. */
|
|
498
246
|
persistSignatureVerification(tx: CapTransaction, params: {
|
|
499
247
|
signingRequestId: string;
|
|
500
248
|
signedTxCbor: string;
|
|
@@ -520,13 +268,7 @@ export declare class CardanoIndexer {
|
|
|
520
268
|
warnings: string;
|
|
521
269
|
verifiedAt: string;
|
|
522
270
|
}>;
|
|
523
|
-
/**
|
|
524
|
-
* Index a verified transaction submission with all related records
|
|
525
|
-
* Handles persistence of: SignatureVerification, TransactionSubmission, SigningRequest update, Build update
|
|
526
|
-
* @param tx CAP transaction object
|
|
527
|
-
* @param params submission parameters
|
|
528
|
-
* @returns {Promise<TransactionSubmission>} transaction submission entity data
|
|
529
|
-
*/
|
|
271
|
+
/** Persist a verified submission: verification, submission, signing request and build updates. */
|
|
530
272
|
indexVerifiedTransactionSubmission(tx: CapTransaction, params: {
|
|
531
273
|
signingRequestId: string;
|
|
532
274
|
buildId: string;
|
|
@@ -541,38 +283,18 @@ export declare class CardanoIndexer {
|
|
|
541
283
|
signerType?: string;
|
|
542
284
|
signerInfo?: string;
|
|
543
285
|
}): Promise<TransactionSubmission>;
|
|
544
|
-
/**
|
|
545
|
-
* Index & return the latest epoch information data
|
|
546
|
-
* @param tx CAP transaction object
|
|
547
|
-
* @returns {Promise<Epoch>} epoch entity data
|
|
548
|
-
*/
|
|
286
|
+
/** Index the latest epoch. */
|
|
549
287
|
indexLatestEpoch(tx: CapTransaction): Promise<Epoch>;
|
|
550
|
-
/**
|
|
551
|
-
* Index & return the latest block information data
|
|
552
|
-
* @param tx CAP transaction object
|
|
553
|
-
* @returns {Promise<Block>} block entity data
|
|
554
|
-
*/
|
|
288
|
+
/** Index the latest block, with best-effort epoch enrichment. */
|
|
555
289
|
indexLatestBlock(tx: CapTransaction): Promise<Block>;
|
|
556
290
|
/** Max addresses to index concurrently (avoid overloading backends) */
|
|
557
291
|
private static readonly ADDR_CONCURRENCY;
|
|
558
292
|
/**
|
|
559
|
-
* Ensure a set of transactions
|
|
560
|
-
*
|
|
561
|
-
* 2. Check which hashes already exist in DB
|
|
562
|
-
* 3. Batch-fetch missing transactions from backend
|
|
563
|
-
* 4. UPSERT all entities (Transactions, Inputs, Outputs, Assets, Metadata)
|
|
564
|
-
*
|
|
565
|
-
* @param tx CAP transaction (cds.tx)
|
|
566
|
-
* @param txHashes array of transaction hashes to ensure
|
|
567
|
-
* @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
|
|
568
295
|
*/
|
|
569
296
|
ensureTransactionsIndexed(tx: CapTransaction, txHashes: string[]): Promise<Map<string, ProviderTransaction>>;
|
|
570
|
-
/**
|
|
571
|
-
* Index multiple addresses with concurrency-limited parallelism.
|
|
572
|
-
* Processes addresses in chunks to avoid overwhelming backends.
|
|
573
|
-
* @param tx CAP transaction object
|
|
574
|
-
* @param bech32List array of bech32 addresses
|
|
575
|
-
*/
|
|
297
|
+
/** Index addresses with bounded concurrency. */
|
|
576
298
|
private _ensureAddresses;
|
|
577
299
|
}
|
|
578
300
|
//# sourceMappingURL=cardano-indexer.d.ts.map
|