@odatano/core 2.0.0-rc.21 → 2.0.0-rc.24
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 +18 -0
- package/@cds-models/CardanoIndexerService/index.js +3 -0
- package/@cds-models/CardanoODataService/index.d.ts +37 -0
- package/@cds-models/CardanoODataService/index.js +3 -0
- package/@cds-models/odatano/cardano/index.d.ts +37 -0
- package/@cds-models/odatano/cardano/index.js +3 -0
- package/db/schema.cds +2226 -2133
- package/package.json +182 -181
- package/srv/blockchain/backends/cardano-backend.d.ts +23 -0
- package/srv/blockchain/backends/cardano-backend.js +5 -0
- package/srv/blockchain/backends/odatano-backend.d.ts +59 -0
- package/srv/blockchain/backends/odatano-backend.js +154 -0
- package/srv/blockchain/backends/ogmios-backend.d.ts +92 -9
- package/srv/blockchain/backends/ogmios-backend.js +164 -32
- package/srv/blockchain/cardano-client.d.ts +19 -5
- package/srv/blockchain/cardano-client.js +53 -12
- package/srv/blockchain/cardano-indexer.d.ts +100 -4
- package/srv/blockchain/cardano-indexer.js +466 -23
- package/srv/blockchain/cardano-tx-builder.js +2 -2
- package/srv/blockchain/crawler/crawler.d.ts +20 -5
- package/srv/blockchain/crawler/crawler.js +78 -15
- package/srv/blockchain/crawler/utxo-set-import.js +3 -0
- package/srv/blockchain/ledger-state.d.ts +6 -0
- package/srv/blockchain/ledger-state.js +29 -0
- package/srv/blockchain/stored-chain.d.ts +30 -0
- package/srv/blockchain/stored-chain.js +208 -0
- package/srv/cardano-backend-service.cds +52 -0
- package/srv/cardano-backend-service.d.ts +2 -0
- package/srv/cardano-backend-service.js +217 -0
- package/srv/cardano-indexer-service.cds +176 -164
- package/srv/cardano-indexer-service.js +30 -0
- package/srv/cardano-service.cds +6 -1
- package/srv/cardano-service.js +5 -2
- package/srv/server.js +19 -2
- package/srv/utils/agent-grants.js +7 -0
- package/srv/utils/const.d.ts +4 -0
- package/srv/utils/const.js +4 -3
- package/srv/utils/db-indexes.js +1 -0
- package/srv/utils/errors.d.ts +8 -0
- package/srv/utils/errors.js +14 -1
- package/srv/utils/mappers.d.ts +19 -2
- package/srv/utils/mappers.js +25 -7
- package/srv/utils/types.d.ts +8 -1
|
@@ -3,7 +3,7 @@ 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';
|
|
6
|
+
import { TxBuildRequest, AssetInfo, AccountData, PoolData, NetworkInformation as ProviderNetworkInformation, Address as ProviderAddress, Transaction as ProviderTransaction, UTxO as OdatanoUtxo, BlockData, AssetHistoryEntry as AssetHistoryEntryProviderData } from '../utils/types';
|
|
7
7
|
import { type LedgerAnchor } from './ledger-state';
|
|
8
8
|
import type { TxCacheTargets } from '../utils/tx-build-helper';
|
|
9
9
|
/**
|
|
@@ -36,7 +36,13 @@ export declare class CardanoIndexer {
|
|
|
36
36
|
* Ledger* tables; no anchor means configured but inactive.
|
|
37
37
|
*/
|
|
38
38
|
private crawlUtxoSet;
|
|
39
|
+
/** crawler.authoritative: misses in the crawled chain are 404, no provider call. */
|
|
40
|
+
private crawlAuthoritative;
|
|
39
41
|
private utxoAnchor;
|
|
42
|
+
/** `LedgerAddresses.paymentCredential` is complete; the running fill and its table generation. */
|
|
43
|
+
private credentialsReady;
|
|
44
|
+
private credentialFill;
|
|
45
|
+
private credentialGeneration;
|
|
40
46
|
/** The anchor block was found in the crawled chain (checked once, before the first apply). */
|
|
41
47
|
private utxoAnchorVerified;
|
|
42
48
|
/**
|
|
@@ -62,6 +68,7 @@ export declare class CardanoIndexer {
|
|
|
62
68
|
assetEnrichRate?: number;
|
|
63
69
|
certificates?: boolean;
|
|
64
70
|
utxoSet?: boolean;
|
|
71
|
+
authoritative?: boolean;
|
|
65
72
|
}): void;
|
|
66
73
|
/**
|
|
67
74
|
* What the crawled data answers authoritatively: only while a live crawler is at the tip.
|
|
@@ -73,6 +80,56 @@ export declare class CardanoIndexer {
|
|
|
73
80
|
* crawl covers it from its first slot, the lifetime total when it covers the chain since Shelley.
|
|
74
81
|
*/
|
|
75
82
|
private localPoolBlocks;
|
|
83
|
+
/**
|
|
84
|
+
* The crawled chain answers `method` on its own: live crawler at the tip, crawl from the Shelley
|
|
85
|
+
* start, and either crawler.authoritative or no configured backend can serve the method.
|
|
86
|
+
*/
|
|
87
|
+
private crawlAnswers;
|
|
88
|
+
/** 404 for a lookup the crawled chain answers on its own (the caller already missed in the DB). */
|
|
89
|
+
refuseOutsideCrawl(tx: CapTransaction, method: string, what: string): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Asset from crawled mint/burn rows: supply = mints − burns, first mint, CIP-25 payload (label 721)
|
|
92
|
+
* of the latest mint. Registry fields stay null. null = the crawled chain does not answer.
|
|
93
|
+
*/
|
|
94
|
+
private localAssetInfo;
|
|
95
|
+
/** Address from the crawled UTxO set when it answers, else from the backend. */
|
|
96
|
+
resolveAddress(tx: CapTransaction, addr: string): Promise<ProviderAddress>;
|
|
97
|
+
/** UTxOs of an address: the crawled set (outputs from the node at the tip) when it answers, else the backend. */
|
|
98
|
+
resolveAddressUtxos(tx: CapTransaction, addr: string): Promise<OdatanoUtxo[]>;
|
|
99
|
+
/** Asset from the crawled chain when it answers, else from the backend. */
|
|
100
|
+
resolveAssetInfo(tx: CapTransaction, unit: string): Promise<AssetInfo>;
|
|
101
|
+
/** Mint/burn events, newest first: crawled rows when the crawled chain answers, else the backend. */
|
|
102
|
+
resolveAssetHistory(tx: CapTransaction, unit: string, limit: number): Promise<AssetHistoryEntryProviderData[]>;
|
|
103
|
+
/** UTxOs of a payment credential: the crawled set when it answers, else Koios. */
|
|
104
|
+
resolveCredentialUtxos(tx: CapTransaction, credHash: string): Promise<OdatanoUtxo[]>;
|
|
105
|
+
/** Latest transaction hashes of an address: the crawled set when it has enough, else the backend. */
|
|
106
|
+
resolveAddressTransactionHashes(tx: CapTransaction, addr: string, limit: number): Promise<string[]>;
|
|
107
|
+
/** True while the crawled UTxO set answers address queries (live crawler at the tip, set active). */
|
|
108
|
+
ledgerCoverageActive(tx: CapTransaction): Promise<boolean>;
|
|
109
|
+
/**
|
|
110
|
+
* Address from the crawled UTxO set: outputs from the node at the tip (Ogmios) or the unspent
|
|
111
|
+
* `LedgerUTxOs`, type and stake address decoded from the address. An address the set has never
|
|
112
|
+
* seen is an empty address, not an error. null = the set cannot answer.
|
|
113
|
+
*/
|
|
114
|
+
private localAddress;
|
|
115
|
+
/**
|
|
116
|
+
* Latest transactions of an address from the crawled UTxO set: the outputs it received
|
|
117
|
+
* (`LedgerUTxOs.txHash`) and spent (`spentTxHash`) since the anchor. `complete` = the address was
|
|
118
|
+
* first seen after the anchor, so nothing older exists. null = the set cannot answer.
|
|
119
|
+
*/
|
|
120
|
+
private localAddressTransactions;
|
|
121
|
+
/** Amount lists (lovelace + assets) of `LedgerUTxOs` rows, keyed `txHash#outputIndex`. */
|
|
122
|
+
private ledgerAmounts;
|
|
123
|
+
/**
|
|
124
|
+
* Active stake of a pool from the Ogmios epoch snapshot of the running epoch (constant within
|
|
125
|
+
* an epoch). Empty when the crawler is not at the tip or the epoch has no such snapshot.
|
|
126
|
+
*/
|
|
127
|
+
private snapshotActiveStake;
|
|
128
|
+
/**
|
|
129
|
+
* Lifetime withdrawals of a stake key from crawled withdrawals — only when certificates are
|
|
130
|
+
* crawled and the crawl covers the chain since Shelley; null otherwise.
|
|
131
|
+
*/
|
|
132
|
+
private localWithdrawalsSum;
|
|
76
133
|
/** The anchor the imported UTxO set describes (null = ledger mode inactive). */
|
|
77
134
|
setUtxoAnchor(anchor: LedgerAnchor | null): void;
|
|
78
135
|
/**
|
|
@@ -123,6 +180,22 @@ export declare class CardanoIndexer {
|
|
|
123
180
|
* rows are UPSERTed without a parent Addresses row (same pattern as TransactionInputs).
|
|
124
181
|
*/
|
|
125
182
|
indexCredentialUtxos(tx: CapTransaction, credHash: string): Promise<AddressUTxOs[]>;
|
|
183
|
+
/**
|
|
184
|
+
* UTxOs of a payment credential without a provider: addresses from the crawled UTxO set, outputs
|
|
185
|
+
* from the node at the tip (Ogmios) or, without one, the unspent `LedgerUTxOs` as of the cursor.
|
|
186
|
+
* null = the crawled set cannot answer (not synced, no set, credential column still filling).
|
|
187
|
+
* An address first used in the last `confirmationDepth` blocks is not in the set yet.
|
|
188
|
+
*/
|
|
189
|
+
private localCredentialUtxos;
|
|
190
|
+
/** Unspent `LedgerUTxOs` (+ assets) of the given addresses in the provider UTxO shape. */
|
|
191
|
+
private ledgerUtxosOf;
|
|
192
|
+
/**
|
|
193
|
+
* True once every Shelley-type `LedgerAddresses` row carries its payment credential. Until then
|
|
194
|
+
* the fill runs in the background (started once per process) and callers use the provider.
|
|
195
|
+
*/
|
|
196
|
+
paymentCredentialsReady(): Promise<boolean>;
|
|
197
|
+
/** The ledger tables were replaced (re-import): the credential column has to be filled again. */
|
|
198
|
+
resetPaymentCredentials(): void;
|
|
126
199
|
/**
|
|
127
200
|
* Index only the UTxOs of an address via getAddressUtxos (no getAddress call), so it works on
|
|
128
201
|
* backends without address aggregation such as Ogmios. Writes no parent Addresses row.
|
|
@@ -144,6 +217,8 @@ export declare class CardanoIndexer {
|
|
|
144
217
|
indexTransactionMetadata(tx: CapTransaction, tx_hash: string): Promise<TransactionMetadata[]>;
|
|
145
218
|
/** Index the network information; circulating supply comes from the crawled UTxO set when it is current. */
|
|
146
219
|
indexNetworkInformation(tx: CapTransaction): Promise<NetworkInformation>;
|
|
220
|
+
/** Network information from the backend; circulating supply from the crawled UTxO set when current. */
|
|
221
|
+
resolveNetworkInformation(tx: CapTransaction): Promise<ProviderNetworkInformation>;
|
|
147
222
|
/** Index a block by hash, with best-effort epoch enrichment. */
|
|
148
223
|
indexBlock(tx: CapTransaction, blockHash: string): Promise<Block>;
|
|
149
224
|
/**
|
|
@@ -197,27 +272,48 @@ export declare class CardanoIndexer {
|
|
|
197
272
|
*/
|
|
198
273
|
private noteAssetSeen;
|
|
199
274
|
/**
|
|
200
|
-
* Snapshot every pool and DRep for an epoch in its OWN transaction (after the block commit)
|
|
201
|
-
*
|
|
202
|
-
*
|
|
275
|
+
* Snapshot every pool and DRep for an epoch in its OWN transaction (after the block commit), plus
|
|
276
|
+
* one EpochLedgerSnapshots row that marks the epoch as observed. With a block hash and an Ogmios
|
|
277
|
+
* backend the node's ledger state AT that block is read; otherwise Koios reports current state
|
|
278
|
+
* (and the live `Pools` / `Dreps` rows are refreshed). Neither available: no-op.
|
|
279
|
+
* @returns counts written and the source used (null = skipped)
|
|
203
280
|
*/
|
|
204
281
|
snapshotEpoch(epoch: number, at: {
|
|
205
282
|
slot: number;
|
|
206
283
|
time: number;
|
|
284
|
+
hash?: string | null;
|
|
207
285
|
}): Promise<{
|
|
208
286
|
pools: number;
|
|
209
287
|
dreps: number;
|
|
288
|
+
source: 'ogmios' | 'koios' | null;
|
|
210
289
|
}>;
|
|
290
|
+
/**
|
|
291
|
+
* Epoch snapshot from the node's ledger state at block `at`. The live `Pools` / `Dreps` rows are
|
|
292
|
+
* NOT refreshed: the acquired state may be hours old. `blocksMinted` counts crawled blocks up to
|
|
293
|
+
* `at`, only when the crawl covers the chain since Shelley.
|
|
294
|
+
*/
|
|
295
|
+
private snapshotEpochFromLedger;
|
|
296
|
+
/**
|
|
297
|
+
* Active stake of epoch E = the stake distribution taken at the E-1 boundary, which is the live
|
|
298
|
+
* stake the Ogmios snapshot of E-1 recorded at its first block. null without that snapshot.
|
|
299
|
+
*/
|
|
300
|
+
private previousLiveStake;
|
|
301
|
+
/** Crawled blocks per pool up to `slot`; null unless the crawl started at or before Shelley. */
|
|
302
|
+
private crawledBlocksByPool;
|
|
211
303
|
/** Every native-asset unit a block touches: outputs, consumed inputs and mint/burn rows. */
|
|
212
304
|
private collectBlockUnits;
|
|
213
305
|
/** Index an epoch by number. */
|
|
214
306
|
indexEpoch(tx: CapTransaction, epochNumber: number): Promise<Epoch>;
|
|
215
307
|
/** Index an account by stake address, plus its addresses when it has any. */
|
|
216
308
|
indexAccount(tx: CapTransaction, stakeAddress: string): Promise<Account>;
|
|
309
|
+
/** Account from the backend with the crawled overlays (controlled amount, withdrawals). */
|
|
310
|
+
resolveAccount(tx: CapTransaction, stakeAddress: string): Promise<AccountData>;
|
|
217
311
|
/** Index a DRep by bech32 id. */
|
|
218
312
|
indexDrep(tx: CapTransaction, drepId: string): Promise<Drep>;
|
|
219
313
|
/** Index a pool by id. */
|
|
220
314
|
indexPool(tx: CapTransaction, poolId: string): Promise<Pool>;
|
|
315
|
+
/** Pool from the backend with crawled block counts and the snapshot's active stake. */
|
|
316
|
+
resolvePool(tx: CapTransaction, poolId: string): Promise<PoolData>;
|
|
221
317
|
/** Index an asset by unit (policyId + assetNameHex). */
|
|
222
318
|
indexAsset(tx: CapTransaction, unit: string): Promise<Asset>;
|
|
223
319
|
/**
|