@odatano/core 2.0.0-rc.23 → 2.0.0-rc.25
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/CardanoBackendService/index.d.ts +357 -0
- package/@cds-models/CardanoBackendService/index.js +40 -0
- package/@cds-models/CardanoIndexerService/index.d.ts +37 -0
- package/@cds-models/CardanoIndexerService/index.js +4 -0
- package/@cds-models/CardanoODataService/index.d.ts +27 -2
- package/@cds-models/CardanoODataService/index.js +3 -0
- package/@cds-models/CardanoSignService/index.d.ts +23 -1
- package/@cds-models/CardanoSignService/index.js +3 -0
- package/@cds-models/CardanoTransactionService/index.d.ts +34 -1
- package/@cds-models/CardanoTransactionService/index.js +4 -0
- package/@cds-models/index.d.ts +18 -0
- package/@cds-models/index.js +3 -0
- package/@cds-models/odatano/cardano/index.d.ts +49 -2
- package/@cds-models/odatano/cardano/index.js +6 -0
- package/db/schema.cds +74 -3
- package/db/types.cds +27 -0
- package/package.json +182 -181
- package/srv/blockchain/backends/blockfrost-backend.js +4 -2
- package/srv/blockchain/backends/cardano-backend.d.ts +0 -2
- package/srv/blockchain/backends/koios-backend.d.ts +1 -1
- package/srv/blockchain/backends/koios-backend.js +61 -14
- package/srv/blockchain/backends/odatano-backend.d.ts +64 -0
- package/srv/blockchain/backends/odatano-backend.js +166 -0
- package/srv/blockchain/backends/ogmios-backend.d.ts +12 -2
- package/srv/blockchain/backends/ogmios-backend.js +91 -21
- package/srv/blockchain/cardano-client.d.ts +23 -9
- package/srv/blockchain/cardano-client.js +77 -25
- package/srv/blockchain/cardano-indexer.d.ts +61 -15
- package/srv/blockchain/cardano-indexer.js +248 -79
- package/srv/blockchain/cardano-tx-builder.d.ts +11 -1
- package/srv/blockchain/cardano-tx-builder.js +59 -4
- package/srv/blockchain/crawler/certificate-backfill.d.ts +22 -0
- package/srv/blockchain/crawler/certificate-backfill.js +49 -30
- package/srv/blockchain/crawler/crawler.d.ts +3 -1
- package/srv/blockchain/crawler/crawler.js +12 -7
- package/srv/blockchain/crawler/sync-state.d.ts +3 -1
- package/srv/blockchain/crawler/sync-state.js +15 -2
- package/srv/blockchain/crawler/transaction-backfill.d.ts +52 -0
- package/srv/blockchain/crawler/transaction-backfill.js +283 -0
- package/srv/blockchain/crawler/utxo-set-import.d.ts +9 -0
- package/srv/blockchain/crawler/utxo-set-import.js +138 -47
- package/srv/blockchain/ledger-state.d.ts +16 -1
- package/srv/blockchain/ledger-state.js +38 -18
- package/srv/blockchain/pending-spends.d.ts +28 -0
- package/srv/blockchain/pending-spends.js +89 -0
- package/srv/blockchain/stored-chain.d.ts +33 -0
- package/srv/blockchain/stored-chain.js +234 -0
- package/srv/blockchain/transaction-building/buildooor-tx.d.ts +12 -3
- package/srv/blockchain/transaction-building/buildooor-tx.js +203 -21
- package/srv/blockchain/transaction-building/cardano-tx.d.ts +2 -1
- package/srv/blockchain/transaction-rows.d.ts +1 -1
- package/srv/blockchain/transaction-rows.js +2 -1
- package/srv/blockchain/wallet-worker/build-request.js +1 -1
- package/srv/cardano-backend-service.cds +52 -0
- package/srv/cardano-backend-service.d.ts +2 -0
- package/srv/cardano-backend-service.js +244 -0
- package/srv/cardano-indexer-service.cds +201 -176
- package/srv/cardano-indexer-service.js +104 -10
- package/srv/cardano-service.cds +5 -0
- package/srv/cardano-tx-service.cds +39 -0
- package/srv/cardano-tx-service.js +88 -14
- package/srv/server.js +20 -2
- package/srv/utils/agent-grants.js +8 -0
- package/srv/utils/const.d.ts +5 -0
- package/srv/utils/const.js +6 -1
- package/srv/utils/error-codes.d.ts +2 -0
- package/srv/utils/error-codes.js +2 -0
- package/srv/utils/errors.d.ts +7 -0
- package/srv/utils/errors.js +11 -1
- package/srv/utils/mappers.d.ts +24 -2
- package/srv/utils/mappers.js +49 -0
- package/srv/utils/pg-inline-json.d.ts +8 -0
- package/srv/utils/pg-inline-json.js +63 -0
- package/srv/utils/tx-build-helper.d.ts +2 -0
- package/srv/utils/tx-build-helper.js +12 -0
- package/srv/utils/tx-request-parsers.d.ts +46 -5
- package/srv/utils/tx-request-parsers.js +227 -16
- package/srv/utils/types.d.ts +59 -0
- package/srv/utils/validators.d.ts +5 -1
- package/srv/utils/validators.js +19 -9
|
@@ -7,11 +7,13 @@ exports.CardanoClient = void 0;
|
|
|
7
7
|
const cds_1 = __importDefault(require("@sap/cds"));
|
|
8
8
|
const cardano_backend_1 = require("./backends/cardano-backend");
|
|
9
9
|
const errors_1 = require("../utils/errors");
|
|
10
|
+
const pending_spends_1 = require("./pending-spends");
|
|
10
11
|
const circuit_breaker_1 = require("./circuit-breaker");
|
|
11
12
|
const request_coalescer_1 = require("./request-coalescer");
|
|
12
13
|
const ogmios_backend_1 = require("./backends/ogmios-backend");
|
|
13
14
|
const blockfrost_backend_1 = require("./backends/blockfrost-backend");
|
|
14
15
|
const koios_backend_1 = require("./backends/koios-backend");
|
|
16
|
+
const odatano_backend_1 = require("./backends/odatano-backend");
|
|
15
17
|
const logger = cds_1.default.log('CardanoClient');
|
|
16
18
|
/** Which backend type to prefer per method. */
|
|
17
19
|
const METHOD_ROUTING = {
|
|
@@ -35,7 +37,8 @@ const METHOD_ROUTING = {
|
|
|
35
37
|
getAccount: { preferLive: true },
|
|
36
38
|
getAssetInfo: { preferLive: false },
|
|
37
39
|
getProtocolParameters: { preferLive: true },
|
|
38
|
-
|
|
40
|
+
// a node's rejection (4xx) is final: another backend submits to the same ledger
|
|
41
|
+
submitTransaction: { preferLive: true, finalOnClientError: true },
|
|
39
42
|
};
|
|
40
43
|
/**
|
|
41
44
|
* Multi-backend Cardano client: live/state queries prefer Ogmios, historical queries prefer
|
|
@@ -52,8 +55,12 @@ class CardanoClient {
|
|
|
52
55
|
uninitializedBackends = new Set();
|
|
53
56
|
network;
|
|
54
57
|
max_age_ms = 60000; // default 1 minute for temporary caching
|
|
58
|
+
/** Transactions submitted through this client that the ledger view does not show yet. */
|
|
59
|
+
pendingSpends = new pending_spends_1.PendingSpends();
|
|
55
60
|
protocolParamsCache;
|
|
56
61
|
protocolParamsFetchPromise = null;
|
|
62
|
+
/** Last protocol parameters the live backend (node) answered. */
|
|
63
|
+
lastLiveProtocolParams;
|
|
57
64
|
static PROTOCOL_PARAMS_TTL_MS = 5 * 60 * 1000; // 5 minutes
|
|
58
65
|
// Request coalescers — deduplicate concurrent fetches for the same resource
|
|
59
66
|
txCoalescer = new request_coalescer_1.RequestCoalescer();
|
|
@@ -72,6 +79,10 @@ class CardanoClient {
|
|
|
72
79
|
if (backends.includes('koios')) {
|
|
73
80
|
this.historicalBackends.push(new koios_backend_1.KoiosBackend(clientConfig.network, clientConfig.primaryTimeoutMs, clientConfig.koiosApiKey));
|
|
74
81
|
}
|
|
82
|
+
if (backends.includes('odatano')) {
|
|
83
|
+
// A remote ODATANO runs its own failover chain: allow its primary timeout plus the fallback.
|
|
84
|
+
this.historicalBackends.push(new odatano_backend_1.OdatanoBackend(clientConfig.network, clientConfig.fallbackTimeoutMs, clientConfig.odatanoUrl, clientConfig.odatanoApiKey));
|
|
85
|
+
}
|
|
75
86
|
if (!this.liveBackend && this.historicalBackends.length === 0) {
|
|
76
87
|
throw new errors_1.ConfigError('No valid backends configured for CardanoClient');
|
|
77
88
|
}
|
|
@@ -208,9 +219,9 @@ class CardanoClient {
|
|
|
208
219
|
clearTimeout(timeoutId);
|
|
209
220
|
});
|
|
210
221
|
}
|
|
211
|
-
/** Per-backend timeout: Koios
|
|
222
|
+
/** Per-backend timeout: Koios and a remote ODATANO get the fallback timeout, everything else the primary one. */
|
|
212
223
|
getTimeoutForBackend(backend) {
|
|
213
|
-
if (backend.name === 'koios')
|
|
224
|
+
if (backend.name === 'koios' || backend.name === 'odatano')
|
|
214
225
|
return this.config.fallbackTimeoutMs;
|
|
215
226
|
return this.config.primaryTimeoutMs;
|
|
216
227
|
}
|
|
@@ -241,7 +252,7 @@ class CardanoClient {
|
|
|
241
252
|
}
|
|
242
253
|
}
|
|
243
254
|
/** Execute on backends in preference order (live vs historical) with automatic fallback. */
|
|
244
|
-
async executeWithPriority(fn, preferLive, methodName) {
|
|
255
|
+
async executeWithPriority(fn, preferLive, methodName, finalOnClientError = false) {
|
|
245
256
|
await this.ensureInitialized();
|
|
246
257
|
const errors = [];
|
|
247
258
|
const skipped = [];
|
|
@@ -288,6 +299,8 @@ class CardanoClient {
|
|
|
288
299
|
}
|
|
289
300
|
const logLevel = backendError.statusCode === 404 ? 'debug' : 'warn';
|
|
290
301
|
logger[logLevel](`Backend failed${backendError.statusCode === 404 ? ': resource not found' : ''}: ${backend.name} - ${backendError.message}`);
|
|
302
|
+
if (finalOnClientError && isClientError)
|
|
303
|
+
throw backendError;
|
|
291
304
|
}
|
|
292
305
|
}
|
|
293
306
|
throw new errors_1.AllBackendsFailedError(errors, undefined, skipped);
|
|
@@ -295,7 +308,7 @@ class CardanoClient {
|
|
|
295
308
|
/** Route a call by METHOD_ROUTING (default: historical first). */
|
|
296
309
|
route(methodName, fn) {
|
|
297
310
|
const config = METHOD_ROUTING[methodName] ?? { preferLive: false };
|
|
298
|
-
return this.executeWithPriority(fn, config.preferLive, methodName);
|
|
311
|
+
return this.executeWithPriority(fn, config.preferLive, methodName, config.finalOnClientError);
|
|
299
312
|
}
|
|
300
313
|
/** Transaction by hash (coalesced across concurrent callers). */
|
|
301
314
|
getTransaction(txHash) {
|
|
@@ -310,15 +323,16 @@ class CardanoClient {
|
|
|
310
323
|
}
|
|
311
324
|
/**
|
|
312
325
|
* UTxOs by 28-byte payment credential (56-char hex), across all bech32 forms sharing it.
|
|
313
|
-
*
|
|
326
|
+
* Needs a credential-keyed backend (Koios, or another ODATANO); Blockfrost has none.
|
|
314
327
|
*/
|
|
315
328
|
getCredentialUtxos(credHash) {
|
|
316
329
|
const candidates = [this.liveBackend, ...this.historicalBackends];
|
|
317
|
-
const
|
|
318
|
-
|
|
319
|
-
|
|
330
|
+
const capable = candidates.filter((b) => typeof b?.getCredentialUtxos === 'function');
|
|
331
|
+
const backend = capable.find(b => b.name === 'koios') ?? capable[0];
|
|
332
|
+
if (!backend) {
|
|
333
|
+
throw new errors_1.ProviderUnavailableError("getCredentialUtxos requires a Koios or odatano backend. Configure one in cds.requires.odatano-core.backends.", 'koios');
|
|
320
334
|
}
|
|
321
|
-
return this.credCoalescer.get(credHash, () => this.callWithResilience(
|
|
335
|
+
return this.credCoalescer.get(credHash, () => this.callWithResilience(backend, () => backend.getCredentialUtxos(credHash)));
|
|
322
336
|
}
|
|
323
337
|
getAddressTransactions(address, limit) {
|
|
324
338
|
return this.route('getAddressTransactions', b => b.getAddressTransactions(address, limit));
|
|
@@ -446,17 +460,24 @@ class CardanoClient {
|
|
|
446
460
|
return null;
|
|
447
461
|
}
|
|
448
462
|
/**
|
|
449
|
-
* Outputs among `refs` that are unspent at the tip, read from the node's ledger
|
|
450
|
-
*
|
|
463
|
+
* Outputs among `refs` that are unspent at the tip, read from the node's ledger (Ogmios, or a remote
|
|
464
|
+
* ODATANO that asks its node); null when no backend can (the caller then resolves via the producing
|
|
465
|
+
* transaction, which carries no reference-script bytes).
|
|
451
466
|
*/
|
|
452
467
|
async getUnspentOutputs(refs) {
|
|
453
|
-
const backend = this.getLedgerStateBackend();
|
|
468
|
+
const backend = this.getLedgerStateBackend() ?? this.outputLookupBackend();
|
|
454
469
|
return backend ? backend.getUnspentOutputs(refs) : null;
|
|
455
470
|
}
|
|
456
|
-
/**
|
|
457
|
-
|
|
458
|
-
const
|
|
459
|
-
|
|
471
|
+
/** A usable backend answering output-reference lookups without a whole-ledger dump (the odatano backend). */
|
|
472
|
+
outputLookupBackend() {
|
|
473
|
+
const candidates = [this.liveBackend, ...this.historicalBackends];
|
|
474
|
+
for (const b of candidates) {
|
|
475
|
+
const lookup = b;
|
|
476
|
+
if (lookup && !this.uninitializedBackends.has(lookup) && typeof lookup.getUnspentOutputs === 'function') {
|
|
477
|
+
return lookup;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
return null;
|
|
460
481
|
}
|
|
461
482
|
/** True when an initialized backend implements `method` and does not declare it unsupported. */
|
|
462
483
|
hasBackendFor(method) {
|
|
@@ -512,7 +533,16 @@ class CardanoClient {
|
|
|
512
533
|
}
|
|
513
534
|
if (!this.protocolParamsFetchPromise) {
|
|
514
535
|
logger.debug('Fetching fresh protocol parameters');
|
|
515
|
-
this.protocolParamsFetchPromise = this.route('getProtocolParameters', b =>
|
|
536
|
+
this.protocolParamsFetchPromise = this.route('getProtocolParameters', async (b) => {
|
|
537
|
+
const params = await b.getProtocolParameters();
|
|
538
|
+
if (b === this.liveBackend) {
|
|
539
|
+
this.lastLiveProtocolParams = params;
|
|
540
|
+
return params;
|
|
541
|
+
}
|
|
542
|
+
// A fallback answering for the epoch the node last reported: keep the node's values
|
|
543
|
+
const live = this.lastLiveProtocolParams;
|
|
544
|
+
return live && Number(live.epoch) === Number(params.epoch) ? live : params;
|
|
545
|
+
})
|
|
516
546
|
.then(params => {
|
|
517
547
|
this.protocolParamsCache = { data: params, fetchedAt: Date.now() };
|
|
518
548
|
this.protocolParamsFetchPromise = null;
|
|
@@ -569,21 +599,43 @@ class CardanoClient {
|
|
|
569
599
|
* Submit a signed transaction (CBOR hex); returns its hash. On failover after a lost response
|
|
570
600
|
* the next backend may answer 409 "already submitted" — callers treat that as success.
|
|
571
601
|
*/
|
|
572
|
-
submitTransaction(signedTxCbor) {
|
|
573
|
-
|
|
602
|
+
async submitTransaction(signedTxCbor) {
|
|
603
|
+
try {
|
|
604
|
+
const hash = await this.route('submitTransaction', b => b.submitTransaction(signedTxCbor));
|
|
605
|
+
this.pendingSpends.record(signedTxCbor);
|
|
606
|
+
return hash;
|
|
607
|
+
}
|
|
608
|
+
catch (err) {
|
|
609
|
+
// already in the mempool or on chain: its inputs are gone all the same
|
|
610
|
+
if (err instanceof errors_1.TransactionAlreadySubmittedError)
|
|
611
|
+
this.pendingSpends.record(signedTxCbor);
|
|
612
|
+
throw err;
|
|
613
|
+
}
|
|
574
614
|
}
|
|
575
|
-
/** True when Ogmios is the live backend
|
|
615
|
+
/** True when Ogmios is the live backend. */
|
|
576
616
|
hasOgmiosBackend() {
|
|
577
617
|
return this.liveBackend?.name === 'ogmios';
|
|
578
618
|
}
|
|
579
|
-
/**
|
|
619
|
+
/** The backend that evaluates scripts: the live one (Ogmios), else an evaluating historical one (odatano). */
|
|
620
|
+
evaluatingBackend() {
|
|
621
|
+
const candidates = [this.liveBackend, ...this.historicalBackends];
|
|
622
|
+
for (const b of candidates)
|
|
623
|
+
if (b && (0, cardano_backend_1.isEvaluatingBackend)(b))
|
|
624
|
+
return b;
|
|
625
|
+
return null;
|
|
626
|
+
}
|
|
627
|
+
/** True when some backend can evaluate script execution units. */
|
|
628
|
+
hasEvaluatingBackend() {
|
|
629
|
+
return this.evaluatingBackend() != null;
|
|
630
|
+
}
|
|
631
|
+
/** Evaluate script execution units of an unsigned transaction. */
|
|
580
632
|
async evaluateTransaction(unsignedTxCbor) {
|
|
581
633
|
await this.ensureInitialized();
|
|
582
|
-
|
|
583
|
-
|
|
634
|
+
const backend = this.evaluatingBackend();
|
|
635
|
+
if (!backend) {
|
|
636
|
+
throw new errors_1.ProviderUnavailableError('Transaction evaluation requires an evaluating backend (Ogmios or odatano)');
|
|
584
637
|
}
|
|
585
638
|
// timeout + breaker, so a hanging socket cannot block Plutus builds
|
|
586
|
-
const backend = this.liveBackend;
|
|
587
639
|
return this.callWithResilience(backend, () => backend.evaluateTransaction(unsignedTxCbor));
|
|
588
640
|
}
|
|
589
641
|
}
|
|
@@ -3,8 +3,8 @@ import type { CardanoClient } from './cardano-client';
|
|
|
3
3
|
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
|
-
import { TxBuildRequest, Transaction as ProviderTransaction, BlockData } from '../utils/types';
|
|
7
|
-
import { type LedgerAnchor } from './ledger-state';
|
|
6
|
+
import { TxBuildRequest, TxBuildPlutusRequest, AssetInfo, AccountData, PoolData, NetworkInformation as ProviderNetworkInformation, Address as ProviderAddress, Transaction as ProviderTransaction, UTxO as OdatanoUtxo, BlockData, AssetHistoryEntry as AssetHistoryEntryProviderData } from '../utils/types';
|
|
7
|
+
import { type LedgerAnchor, type LedgerLookup } from './ledger-state';
|
|
8
8
|
import type { TxCacheTargets } from '../utils/tx-build-helper';
|
|
9
9
|
/**
|
|
10
10
|
* Indexes Cardano data into the OData entities: fetches via CardanoClient, maps provider data
|
|
@@ -18,11 +18,15 @@ export declare class CardanoIndexer {
|
|
|
18
18
|
private static readonly CRAWL_EPOCH_RETRY_MS;
|
|
19
19
|
/**
|
|
20
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.
|
|
22
|
-
* block transaction
|
|
21
|
+
* next one starts; holds at most the current and previous epoch. A row is UPSERTed until a
|
|
22
|
+
* block transaction that wrote it has committed (`confirmBlockCommit`).
|
|
23
23
|
*/
|
|
24
24
|
private crawlEpochCache;
|
|
25
25
|
private crawlEpochCurrent;
|
|
26
|
+
/** Epoch rows known to be committed; a refresh creates a new row object and is written again. */
|
|
27
|
+
private crawlEpochWritten;
|
|
28
|
+
/** Memo updates of the running block transaction, applied only after its commit. */
|
|
29
|
+
private pendingCommit;
|
|
26
30
|
private crawlEpochPrevious;
|
|
27
31
|
/** Analytics coverage of the crawl path; defaults mirror the crawler config defaults. */
|
|
28
32
|
private crawlAssetHistory;
|
|
@@ -52,6 +56,8 @@ export declare class CardanoIndexer {
|
|
|
52
56
|
private ledgerInvalidation;
|
|
53
57
|
/** Units known to have an `Assets` row, so a repeat sighting costs no DB round-trip. */
|
|
54
58
|
private static readonly ASSET_MEMO_CAP;
|
|
59
|
+
/** Output references per node lookup when checking crawled UTxOs. */
|
|
60
|
+
private static readonly OUTREF_CHUNK;
|
|
55
61
|
private assetMemo;
|
|
56
62
|
/**
|
|
57
63
|
* Background registry enrichment queue (`assetCatalogue: 'enrich'`), drained at a fixed rate
|
|
@@ -86,20 +92,34 @@ export declare class CardanoIndexer {
|
|
|
86
92
|
*/
|
|
87
93
|
private crawlAnswers;
|
|
88
94
|
/** 404 for a lookup the crawled chain answers on its own (the caller already missed in the DB). */
|
|
89
|
-
|
|
95
|
+
refuseOutsideCrawl(tx: CapTransaction, method: string, what: string): Promise<void>;
|
|
90
96
|
/**
|
|
91
97
|
* Asset from crawled mint/burn rows: supply = mints − burns, first mint, CIP-25 payload (label 721)
|
|
92
98
|
* of the latest mint. Registry fields stay null. null = the crawled chain does not answer.
|
|
93
99
|
*/
|
|
94
100
|
private localAssetInfo;
|
|
101
|
+
/** Address from the crawled UTxO set when it answers, else from the backend. */
|
|
102
|
+
resolveAddress(tx: CapTransaction, addr: string): Promise<ProviderAddress>;
|
|
103
|
+
/** UTxOs of an address: the crawled set (checked unspent at the node) when it answers, else the backend. */
|
|
104
|
+
resolveAddressUtxos(tx: CapTransaction, addr: string): Promise<OdatanoUtxo[]>;
|
|
105
|
+
/** Asset from the crawled chain when it answers, else from the backend. */
|
|
106
|
+
resolveAssetInfo(tx: CapTransaction, unit: string): Promise<AssetInfo>;
|
|
107
|
+
/** Mint/burn events, newest first: crawled rows when the crawled chain answers, else the backend. */
|
|
108
|
+
resolveAssetHistory(tx: CapTransaction, unit: string, limit: number): Promise<AssetHistoryEntryProviderData[]>;
|
|
109
|
+
/** UTxOs of a payment credential: the crawled set when it answers, else Koios. */
|
|
110
|
+
resolveCredentialUtxos(tx: CapTransaction, credHash: string): Promise<OdatanoUtxo[]>;
|
|
111
|
+
/** Latest transaction hashes of an address: the crawled set when it has enough, else the backend. */
|
|
112
|
+
resolveAddressTransactionHashes(tx: CapTransaction, addr: string, limit: number): Promise<string[]>;
|
|
95
113
|
/** True while the crawled UTxO set answers address queries (live crawler at the tip, set active). */
|
|
96
114
|
ledgerCoverageActive(tx: CapTransaction): Promise<boolean>;
|
|
97
115
|
/**
|
|
98
|
-
* Address from the crawled UTxO set:
|
|
99
|
-
*
|
|
116
|
+
* Address from the crawled UTxO set: the unspent `LedgerUTxOs` (see openLedgerUtxos), type and
|
|
117
|
+
* stake address decoded from the address. An address the set has never
|
|
100
118
|
* seen is an empty address, not an error. null = the set cannot answer.
|
|
101
119
|
*/
|
|
102
120
|
private localAddress;
|
|
121
|
+
/** Addresses of a stake key from the crawled UTxO set, with their unspent outputs (one read for all). */
|
|
122
|
+
private localAccountAddresses;
|
|
103
123
|
/**
|
|
104
124
|
* Latest transactions of an address from the crawled UTxO set: the outputs it received
|
|
105
125
|
* (`LedgerUTxOs.txHash`) and spent (`spentTxHash`) since the anchor. `complete` = the address was
|
|
@@ -128,6 +148,8 @@ export declare class CardanoIndexer {
|
|
|
128
148
|
private verifyUtxoAnchor;
|
|
129
149
|
/** Null while the mode is off, nothing is imported, or an invalidation awaits its commit. */
|
|
130
150
|
getUtxoAnchor(): LedgerAnchor | null;
|
|
151
|
+
/** Apply the memo updates of the block transaction that just committed. */
|
|
152
|
+
confirmBlockCommit(): void;
|
|
131
153
|
/** Hand out a pending invalidation (dropping the anchor) exactly once after the block commit, or null. */
|
|
132
154
|
takeLedgerInvalidation(): string | null;
|
|
133
155
|
/**
|
|
@@ -151,6 +173,11 @@ export declare class CardanoIndexer {
|
|
|
151
173
|
/** Epoch row with only the slot-derived bounds, for an epoch the backend cannot describe. */
|
|
152
174
|
private bareEpochRow;
|
|
153
175
|
constructor(client: CardanoClient, txBuilder: CardanoTransactionBuilder);
|
|
176
|
+
/**
|
|
177
|
+
* Unspent outputs of an address from the crawled set for the transaction builder; null = the set
|
|
178
|
+
* cannot answer. Runs on `cds.db`, i.e. inside the caller's request transaction when there is one.
|
|
179
|
+
*/
|
|
180
|
+
private localAddressUtxos;
|
|
154
181
|
/**
|
|
155
182
|
* Index a transaction with inputs/outputs/assets/metadata; all UPSERTs run in the caller's
|
|
156
183
|
* transaction, so either everything persists or nothing does.
|
|
@@ -160,21 +187,27 @@ export declare class CardanoIndexer {
|
|
|
160
187
|
private writeTransactionChildren;
|
|
161
188
|
/**
|
|
162
189
|
* Index address data with assets and UTxOs; transactions are loaded separately via
|
|
163
|
-
* indexAddressTransactions().
|
|
190
|
+
* indexAddressTransactions(). `prefetched` = address data the caller already fetched in a batch.
|
|
164
191
|
*/
|
|
165
|
-
indexAddress(tx: CapTransaction, addr: string): Promise<Address>;
|
|
192
|
+
indexAddress(tx: CapTransaction, addr: string, prefetched?: ProviderAddress): Promise<Address>;
|
|
166
193
|
/**
|
|
167
194
|
* Index UTxOs by 28-byte payment credential (56-char hex), always fresh from Koios. Child
|
|
168
195
|
* rows are UPSERTed without a parent Addresses row (same pattern as TransactionInputs).
|
|
169
196
|
*/
|
|
170
197
|
indexCredentialUtxos(tx: CapTransaction, credHash: string): Promise<AddressUTxOs[]>;
|
|
171
198
|
/**
|
|
172
|
-
* UTxOs of a payment credential without a provider: addresses from the crawled
|
|
173
|
-
*
|
|
199
|
+
* UTxOs of a payment credential without a provider: addresses and unspent outputs from the crawled
|
|
200
|
+
* UTxO set (see openLedgerUtxos).
|
|
174
201
|
* null = the crawled set cannot answer (not synced, no set, credential column still filling).
|
|
175
202
|
* An address first used in the last `confirmationDepth` blocks is not in the set yet.
|
|
176
203
|
*/
|
|
177
204
|
private localCredentialUtxos;
|
|
205
|
+
/**
|
|
206
|
+
* Unspent outputs of addresses from the crawled set, checked against the node by output reference
|
|
207
|
+
* (a keyed lookup; the node's address query scans its whole UTxO set): drops what was spent after
|
|
208
|
+
* the cursor. Without a usable node, or when the check fails, the set as of the cursor.
|
|
209
|
+
*/
|
|
210
|
+
private openLedgerUtxos;
|
|
178
211
|
/** Unspent `LedgerUTxOs` (+ assets) of the given addresses in the provider UTxO shape. */
|
|
179
212
|
private ledgerUtxosOf;
|
|
180
213
|
/**
|
|
@@ -205,6 +238,8 @@ export declare class CardanoIndexer {
|
|
|
205
238
|
indexTransactionMetadata(tx: CapTransaction, tx_hash: string): Promise<TransactionMetadata[]>;
|
|
206
239
|
/** Index the network information; circulating supply comes from the crawled UTxO set when it is current. */
|
|
207
240
|
indexNetworkInformation(tx: CapTransaction): Promise<NetworkInformation>;
|
|
241
|
+
/** Network information from the backend; circulating supply from the crawled UTxO set when current. */
|
|
242
|
+
resolveNetworkInformation(tx: CapTransaction): Promise<ProviderNetworkInformation>;
|
|
208
243
|
/** Index a block by hash, with best-effort epoch enrichment. */
|
|
209
244
|
indexBlock(tx: CapTransaction, blockHash: string): Promise<Block>;
|
|
210
245
|
/**
|
|
@@ -229,10 +264,11 @@ export declare class CardanoIndexer {
|
|
|
229
264
|
*/
|
|
230
265
|
private warnIfCertificatesUnreported;
|
|
231
266
|
/**
|
|
232
|
-
* Backfill address
|
|
233
|
-
* then earlier-indexed outputs from the DB. Inputs that
|
|
267
|
+
* Backfill address, amount and datum/script fields of bare chain-sync inputs: from this block's
|
|
268
|
+
* own outputs first, then the UTxO set, then earlier-indexed outputs from the DB. Inputs that
|
|
269
|
+
* already carry an address are skipped.
|
|
234
270
|
*/
|
|
235
|
-
|
|
271
|
+
resolveInputs(tx: CapTransaction, txs: ProviderTransaction[], ledger?: LedgerLookup): Promise<void>;
|
|
236
272
|
/**
|
|
237
273
|
* Settle the fee of phase-2-invalid transactions (collateral inputs minus collateral return)
|
|
238
274
|
* and the block total. The declared fee is kept when the mapper already set it via
|
|
@@ -292,10 +328,14 @@ export declare class CardanoIndexer {
|
|
|
292
328
|
indexEpoch(tx: CapTransaction, epochNumber: number): Promise<Epoch>;
|
|
293
329
|
/** Index an account by stake address, plus its addresses when it has any. */
|
|
294
330
|
indexAccount(tx: CapTransaction, stakeAddress: string): Promise<Account>;
|
|
331
|
+
/** Account from the backend with the crawled overlays (controlled amount, withdrawals). */
|
|
332
|
+
resolveAccount(tx: CapTransaction, stakeAddress: string): Promise<AccountData>;
|
|
295
333
|
/** Index a DRep by bech32 id. */
|
|
296
334
|
indexDrep(tx: CapTransaction, drepId: string): Promise<Drep>;
|
|
297
335
|
/** Index a pool by id. */
|
|
298
336
|
indexPool(tx: CapTransaction, poolId: string): Promise<Pool>;
|
|
337
|
+
/** Pool from the backend with crawled block counts and the snapshot's active stake. */
|
|
338
|
+
resolvePool(tx: CapTransaction, poolId: string): Promise<PoolData>;
|
|
299
339
|
/** Index an asset by unit (policyId + assetNameHex). */
|
|
300
340
|
indexAsset(tx: CapTransaction, unit: string): Promise<Asset>;
|
|
301
341
|
/**
|
|
@@ -310,6 +350,8 @@ export declare class CardanoIndexer {
|
|
|
310
350
|
indexMultiAssetBuildResult(tx: CapTransaction, buildreq: TxBuildRequest): Promise<TransactionBuild>;
|
|
311
351
|
indexMintBuildResult(tx: CapTransaction, buildreq: TxBuildRequest): Promise<TransactionBuild>;
|
|
312
352
|
indexPlutusSpendBuildResult(tx: CapTransaction, buildreq: TxBuildRequest): Promise<TransactionBuild>;
|
|
353
|
+
/** BuildPlutusTransaction: several script inputs; the redeemers are stored with the build. */
|
|
354
|
+
indexPlutusBuildResult(tx: CapTransaction, buildreq: TxBuildPlutusRequest): Promise<TransactionBuild>;
|
|
313
355
|
/** Protocol parameters, served from the DB row within a 5-minute TTL. */
|
|
314
356
|
indexProtocolParameters(tx: CapTransaction): Promise<LedgerProtocolParameter>;
|
|
315
357
|
/** Persist a transaction submission and flag the build as submitted when linked. */
|
|
@@ -406,7 +448,11 @@ export declare class CardanoIndexer {
|
|
|
406
448
|
* @returns provider transactions for the hashes that had to be fetched
|
|
407
449
|
*/
|
|
408
450
|
ensureTransactionsIndexed(tx: CapTransaction, txHashes: string[]): Promise<Map<string, ProviderTransaction>>;
|
|
409
|
-
/**
|
|
451
|
+
/**
|
|
452
|
+
* Index the addresses of an account with bounded concurrency. The address data the account
|
|
453
|
+
* carries (from the backend, or from the crawled set) is used as is, so an account costs no
|
|
454
|
+
* request per address; an entry without UTxOs is fetched.
|
|
455
|
+
*/
|
|
410
456
|
private _ensureAddresses;
|
|
411
457
|
}
|
|
412
458
|
//# sourceMappingURL=cardano-indexer.d.ts.map
|