@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.
Files changed (119) hide show
  1. package/@cds-models/CardanoAgentService/index.d.ts +1 -5
  2. package/@cds-models/CardanoIndexerService/index.d.ts +51 -2
  3. package/@cds-models/CardanoIndexerService/index.js +7 -0
  4. package/package.json +1 -1
  5. package/src/index.d.ts +4 -10
  6. package/src/index.js +6 -16
  7. package/src/plugin.js +11 -27
  8. package/srv/blockchain/backends/blockfrost-backend.d.ts +29 -131
  9. package/srv/blockchain/backends/blockfrost-backend.js +39 -150
  10. package/srv/blockchain/backends/cardano-backend.d.ts +53 -171
  11. package/srv/blockchain/backends/cardano-backend.js +1 -5
  12. package/srv/blockchain/backends/koios-backend.d.ts +26 -71
  13. package/srv/blockchain/backends/koios-backend.js +50 -132
  14. package/srv/blockchain/backends/ogmios-backend.d.ts +43 -124
  15. package/srv/blockchain/backends/ogmios-backend.js +71 -179
  16. package/srv/blockchain/backends/ogmios-frame-guard.d.ts +12 -57
  17. package/srv/blockchain/backends/ogmios-frame-guard.js +27 -66
  18. package/srv/blockchain/cardano-client.d.ts +43 -216
  19. package/srv/blockchain/cardano-client.js +49 -234
  20. package/srv/blockchain/cardano-indexer.d.ts +79 -357
  21. package/srv/blockchain/cardano-indexer.js +98 -406
  22. package/srv/blockchain/cardano-tx-builder.d.ts +19 -84
  23. package/srv/blockchain/cardano-tx-builder.js +21 -107
  24. package/srv/blockchain/crawler/certificate-backfill.d.ts +45 -0
  25. package/srv/blockchain/crawler/certificate-backfill.js +150 -0
  26. package/srv/blockchain/crawler/crawler.d.ts +41 -145
  27. package/srv/blockchain/crawler/crawler.js +57 -172
  28. package/srv/blockchain/crawler/hooks.d.ts +3 -14
  29. package/srv/blockchain/crawler/index.d.ts +2 -6
  30. package/srv/blockchain/crawler/index.js +4 -9
  31. package/srv/blockchain/crawler/sync-state.d.ts +17 -39
  32. package/srv/blockchain/crawler/sync-state.js +23 -55
  33. package/srv/blockchain/crawler/utxo-set-import.d.ts +5 -22
  34. package/srv/blockchain/crawler/utxo-set-import.js +8 -28
  35. package/srv/blockchain/ledger-state.d.ts +3 -12
  36. package/srv/blockchain/signing/cose-verifier.d.ts +5 -12
  37. package/srv/blockchain/signing/cose-verifier.js +6 -12
  38. package/srv/blockchain/signing/external-signer.d.ts +16 -113
  39. package/srv/blockchain/signing/external-signer.js +19 -122
  40. package/srv/blockchain/signing/hsm-signer.d.ts +13 -45
  41. package/srv/blockchain/signing/hsm-signer.js +23 -63
  42. package/srv/blockchain/signing/signature-verifier.d.ts +8 -44
  43. package/srv/blockchain/signing/signature-verifier.js +13 -54
  44. package/srv/blockchain/signing/submission-finalizer.d.ts +9 -36
  45. package/srv/blockchain/signing/submission-finalizer.js +16 -48
  46. package/srv/blockchain/transaction-building/buildooor-tx.d.ts +65 -174
  47. package/srv/blockchain/transaction-building/buildooor-tx.js +107 -266
  48. package/srv/blockchain/transaction-building/cardano-tx.d.ts +8 -34
  49. package/srv/blockchain/wallet-worker/build-request.d.ts +4 -17
  50. package/srv/blockchain/wallet-worker/build-request.js +9 -22
  51. package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +12 -35
  52. package/srv/blockchain/wallet-worker/confirmation-tracker.js +16 -32
  53. package/srv/blockchain/wallet-worker/index.js +2 -8
  54. package/srv/blockchain/wallet-worker/job-store.d.ts +33 -111
  55. package/srv/blockchain/wallet-worker/job-store.js +0 -0
  56. package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +4 -20
  57. package/srv/blockchain/wallet-worker/lease-heartbeat.js +4 -20
  58. package/srv/blockchain/wallet-worker/signers.d.ts +6 -19
  59. package/srv/blockchain/wallet-worker/signers.js +3 -8
  60. package/srv/blockchain/wallet-worker/wallet-worker.d.ts +15 -71
  61. package/srv/blockchain/wallet-worker/wallet-worker.js +34 -90
  62. package/srv/cardano-agent-service.cds +1 -5
  63. package/srv/cardano-agent-service.js +3 -7
  64. package/srv/cardano-indexer-service.cds +32 -4
  65. package/srv/cardano-indexer-service.js +83 -15
  66. package/srv/cardano-service.js +36 -98
  67. package/srv/cardano-sign-service.cds +1 -1
  68. package/srv/cardano-sign-service.js +55 -173
  69. package/srv/cardano-tx-service.cds +1 -1
  70. package/srv/cardano-tx-service.js +54 -174
  71. package/srv/cardano-worker-service.js +7 -15
  72. package/srv/server.d.ts +27 -86
  73. package/srv/server.js +52 -148
  74. package/srv/utils/agent-grants-config.d.ts +11 -50
  75. package/srv/utils/agent-grants-config.js +12 -45
  76. package/srv/utils/agent-grants.d.ts +34 -123
  77. package/srv/utils/agent-grants.js +57 -156
  78. package/srv/utils/agent-token-auth.d.ts +2 -5
  79. package/srv/utils/agent-token-auth.js +2 -5
  80. package/srv/utils/backend-request-handler.d.ts +2 -16
  81. package/srv/utils/backend-request-handler.js +3 -18
  82. package/srv/utils/collections.d.ts +4 -8
  83. package/srv/utils/collections.js +4 -8
  84. package/srv/utils/const.d.ts +19 -68
  85. package/srv/utils/const.js +20 -69
  86. package/srv/utils/crypto.d.ts +3 -12
  87. package/srv/utils/crypto.js +5 -18
  88. package/srv/utils/db-indexes.d.ts +2 -7
  89. package/srv/utils/db-indexes.js +7 -34
  90. package/srv/utils/db-sanitize.d.ts +5 -18
  91. package/srv/utils/db-sanitize.js +6 -19
  92. package/srv/utils/error-codes.d.ts +18 -73
  93. package/srv/utils/error-codes.js +17 -70
  94. package/srv/utils/errors.d.ts +29 -191
  95. package/srv/utils/errors.js +44 -229
  96. package/srv/utils/liveness.d.ts +2 -9
  97. package/srv/utils/liveness.js +3 -11
  98. package/srv/utils/mappers.d.ts +50 -298
  99. package/srv/utils/mappers.js +80 -386
  100. package/srv/utils/network-context.js +2 -11
  101. package/srv/utils/pg-order-nulls.js +4 -23
  102. package/srv/utils/plutus-placeholders.d.ts +6 -18
  103. package/srv/utils/plutus-placeholders.js +6 -20
  104. package/srv/utils/rate-limiter.d.ts +6 -17
  105. package/srv/utils/rate-limiter.js +5 -15
  106. package/srv/utils/service-events.d.ts +2 -22
  107. package/srv/utils/service-events.js +3 -23
  108. package/srv/utils/signing-helper.d.ts +3 -18
  109. package/srv/utils/signing-helper.js +10 -32
  110. package/srv/utils/tx-build-helper.d.ts +18 -92
  111. package/srv/utils/tx-build-helper.js +32 -123
  112. package/srv/utils/tx-request-parsers.d.ts +7 -26
  113. package/srv/utils/tx-request-parsers.js +7 -26
  114. package/srv/utils/tx-utils.d.ts +4 -23
  115. package/srv/utils/tx-utils.js +12 -41
  116. package/srv/utils/types.d.ts +67 -206
  117. package/srv/utils/types.js +2 -6
  118. package/srv/utils/validators.d.ts +19 -89
  119. package/srv/utils/validators.js +31 -138
@@ -2,10 +2,8 @@ import { Transaction, BlockData, Address, UTxO, NetworkInformation, EpochData, M
2
2
  import { EvaluatingBackend, ChainSyncBackend, ChainSyncCallbacks, ChainSyncHandle, ChainPoint, LedgerStateBackend } from './cardano-backend';
3
3
  import { Network } from '../cardano-client';
4
4
  /**
5
- * Decode a CIP-129 DRep ID (`drep1…`, 29 bytes) into its credential hash and
6
- * type. Header byte: high nibble 0x2 = DRep, low nibble 0x2 = key hash /
7
- * 0x3 = script hash. The validators already enforce HRP + length before the
8
- * request reaches a backend, so this only has to split the payload.
5
+ * Decode a CIP-129 DRep ID (`drep1…`, 29 bytes) into credential hash and type. Header byte:
6
+ * high nibble 0x2 = DRep, low nibble 0x2 = key hash / 0x3 = script hash.
9
7
  */
10
8
  export declare function decodeDrepId(drepId: string): {
11
9
  hashHex: string;
@@ -21,15 +19,13 @@ export declare function resolveOgmiosTip(tip: 'origin' | {
21
19
  };
22
20
  /** Resolve Ogmios block height which may be 'origin' (genesis block) or a number */
23
21
  export declare function resolveOgmiosHeight(height: 'origin' | number): number;
22
+ /** CardanoBackend implementation over an Ogmios WebSocket (local node). */
24
23
  export declare class OgmiosBackend implements EvaluatingBackend, ChainSyncBackend, LedgerStateBackend {
25
24
  readonly name = "ogmios";
26
25
  /**
27
- * Capability declaration — the orchestrator skips Ogmios for these without
28
- * counting circuit failures. Historic queries are out of protocol scope;
29
- * getAddress/getNetworkInformation previously FABRICATED placeholder data
30
- * (type:'base'/isScript:false/stakeAddress:null resp. maxSupply as
31
- * total/circulating) which preferLive routing then preferred over correct
32
- * Blockfrost/Koios data.
26
+ * Capability declaration — the orchestrator skips Ogmios for these without counting
27
+ * circuit failures. Historic queries are out of protocol scope, and address/network
28
+ * aggregates cannot be derived from state queries.
33
29
  */
34
30
  readonly unsupportedMethods: ReadonlySet<string>;
35
31
  private stateQueryClient;
@@ -40,56 +36,32 @@ export declare class OgmiosBackend implements EvaluatingBackend, ChainSyncBacken
40
36
  private network;
41
37
  private timeoutMs;
42
38
  private ogmiosUrl;
43
- /**
44
- * Constructor
45
- */
46
39
  constructor(network: Network, timeoutMs: number, ogmiosUrl: string);
47
40
  /**
48
- * Force fresh (non-keep-alive) HTTP connections for the Ogmios `/health` probe.
49
- *
50
- * createInteractionContext() opens the WebSocket, but FIRST probes
51
- * `GET http://<ogmios>/health` via the library's `cross-fetch` → node-fetch v2
52
- * → Node-core `http`. Since Node 19, `http.globalAgent` defaults to
53
- * keepAlive:true, so node-fetch reuses pooled sockets. Against Ogmios' Warp
54
- * server on Node 22/24 a reused socket the server has already half-closed
55
- * yields "Invalid response body … Premature close" the instant the body is
56
- * read — deterministically (Node 20's older http client tolerated it; `curl`
57
- * does too, so the /health response itself is well-formed and the node is
58
- * healthy). The lib pins cross-fetch even in 7.0 and exposes no way to inject
59
- * an agent into that internal fetch, so we neutralise keep-alive process-wide
60
- * for `http://`. Blast radius is tiny: the only `http://` consumer is the local
61
- * Ogmios probe — Blockfrost/Koios run over `https` with their own axios agents
62
- * and are unaffected. Runs once, lazily, only when Ogmios is actually used.
41
+ * Force non-keep-alive HTTP for the Ogmios `/health` probe: node-fetch v2 uses `http.globalAgent`,
42
+ * whose pooled sockets (kept alive since Node 19) fail with "Premature close" once Ogmios' Warp server
43
+ * half-closes them. No agent hook exists, so keep-alive is disabled process-wide for `http://` only.
63
44
  */
64
45
  private static keepAliveDisabled;
65
46
  private static disableHttpKeepAlive;
66
47
  /** Validate Ogmios URL scheme and reject dangerous protocols */
67
48
  private static validateOgmiosUrl;
68
49
  /**
69
- * Bound an init step in time. A hung WebSocket connect/handshake (e.g. the
70
- * node is alive but too busy catching up to answer) would otherwise block
71
- * forever — there is no built-in connect timeout — hanging the whole
72
- * app-context bootstrap (seen as a 6h CI job timeout). On timeout we reject
73
- * with a message containing "timeout" so the orchestrator's transient-error
74
- * retry picks it up instead of dying.
50
+ * Bound an init step in time: the WebSocket connect/handshake has no built-in timeout and
51
+ * can hang when the node is busy. The rejection message contains "timeout" so the
52
+ * orchestrator's transient-error retry picks it up.
75
53
  */
76
54
  private withInitTimeout;
77
55
  /**
78
- * Force-release an Ogmios interaction socket after a failed/expired open or
79
- * close step. The runtime uses `ws` (and therefore supports `terminate`), but
80
- * the close fallback keeps the helper compatible with the public structural
81
- * InteractionContext type and lightweight test doubles.
56
+ * Force-release an interaction socket after a failed/expired open or close. The runtime
57
+ * socket is `ws` (has `terminate`); the `close` fallback keeps test doubles working.
82
58
  */
83
59
  private forceCloseContext;
84
- /**
85
- * Initialize the Ogmios backend connection
86
- */
60
+ /** Open the interaction context and the query/submission clients. */
87
61
  init(): Promise<boolean>;
88
62
  /**
89
- * Reconnect when the WebSocket has died since the last successful init.
90
- * No-op when never initialized (test-injected clients) — startup-init
91
- * recovery is the orchestrator's job (lazy init retry in CardanoClient).
92
- * Concurrent callers share one reconnect attempt.
63
+ * Reconnect when the WebSocket died since the last init. No-op when never initialized
64
+ * (test-injected clients); concurrent callers share one reconnect attempt.
93
65
  */
94
66
  private ensureConnected;
95
67
  /**
@@ -117,19 +89,10 @@ export declare class OgmiosBackend implements EvaluatingBackend, ChainSyncBacken
117
89
  */
118
90
  getTransactionMetadata(_tx_hash: string): Promise<MetadataLabelTx[]>;
119
91
  /**
120
- * Get DRep data from the live ledger state (`queryLedgerState/delegateRepresentatives`).
121
- *
122
- * The client package (6.14) ships the schema types but no wrapper for this query,
123
- * so it goes through the exported `Method()` primitive on our interaction context —
124
- * the same building block the client uses for `stakePools` & co.
125
- *
126
- * Semantics vs. Blockfrost/Koios: Ogmios only lists REGISTERED DReps, so a retired
127
- * or unknown DRep is a NotFoundError here (never `retired: true`), and there is no
128
- * last-activity epoch — `expired` is derived from the mandate epoch instead.
129
- * Routing keeps `getDrep` historical-preferred; this is the Ogmios-only fallback.
130
- *
92
+ * DRep data from the live ledger state (`queryLedgerState/delegateRepresentatives`) via the
93
+ * raw `Method()` primitive, since the client ships no wrapper. Ogmios lists only REGISTERED
94
+ * DReps: retired/unknown → NotFoundError; `expired` is derived from the mandate epoch.
131
95
  * @param drepId CIP-129 bech32 DRep ID (`drep1…`)
132
- * @returns {Promise<DrepData>} drep data
133
96
  */
134
97
  getDrep(drepId: string): Promise<DrepData>;
135
98
  /**
@@ -138,18 +101,11 @@ export declare class OgmiosBackend implements EvaluatingBackend, ChainSyncBacken
138
101
  * @returns {Promise<AssetInfo>} asset info
139
102
  */
140
103
  getAssetInfo(_unit: string): Promise<AssetInfo>;
141
- /**
142
- * Get specific Network Information (not supported — Ogmios state queries
143
- * expose no supply/stake aggregates; the previous implementation fabricated
144
- * maxSupply as total/circulating, which preferLive routing then preferred
145
- * over correct Blockfrost/Koios data)
146
- */
104
+ /** Not supported — Ogmios state queries expose no supply/stake aggregates. */
147
105
  getNetworkInformation(): Promise<NetworkInformation>;
148
106
  /**
149
- * Get current specific Address Data (not supported — address type, script
150
- * flag and stake address are not derivable from Ogmios state queries; the
151
- * previous implementation fabricated type:'base'/isScript:false/
152
- * stakeAddress:null. UTxOs remain available via getAddressUtxos.)
107
+ * Not supported — address type, script flag and stake address are not derivable from
108
+ * state queries. UTxOs remain available via getAddressUtxos.
153
109
  */
154
110
  getAddress(_address: string): Promise<Address>;
155
111
  /** get current specific Address UTxOs
@@ -160,20 +116,12 @@ export declare class OgmiosBackend implements EvaluatingBackend, ChainSyncBacken
160
116
  /** Ogmios `Utxo` entry → normalized UTxO line (shared by the address query and the set import). */
161
117
  private mapOgmiosUtxo;
162
118
  /**
163
- * The whole UTxO set as of `point` (LedgerStateBackend — crawler.utxoSet snapshot import).
164
- * Opens a SEPARATE WebSocket connection for it: the local-state-query protocol keeps one
165
- * acquired point per connection, so a client on the shared socket would move every live
166
- * query to the historical anchor for the duration. The point must be inside the node's
167
- * volatile window (the last 2160 blocks) or the node refuses the acquisition. Whole-set
168
- * queries are fine on preview/preprod; on mainnet prefer a cardano-cli file.
119
+ * Whole UTxO set as of `point` (crawler snapshot import) on a SEPARATE WebSocket: local-state-query
120
+ * holds one acquired point per connection, so the shared socket would pin live queries to the past.
121
+ * The point must be inside the node's volatile window (last 2160 blocks) or acquisition is refused.
169
122
  */
170
123
  queryUtxoSetAt(point: ChainPoint): Promise<UTxO[]>;
171
- /**
172
- * Get Address Transactions (not supported by Ogmios - use historical backend)
173
- * Ogmios is a live state query backend and does not provide historical transaction data
174
- * @param _address bech32 address
175
- * @returns {Promise<Transaction[]>} always throws - use historical backend instead
176
- */
124
+ /** Not supported — Ogmios is a live state-query backend; use Blockfrost/Koios. */
177
125
  getAddressTransactions(_address: string): Promise<Transaction[]>;
178
126
  /**
179
127
  * Get current specific Pool Data
@@ -220,71 +168,42 @@ export declare class OgmiosBackend implements EvaluatingBackend, ChainSyncBacken
220
168
  */
221
169
  getCurrentSlot(): Promise<number>;
222
170
  /**
223
- * Check whether a UTxO is still unspent via Ogmios `queryLedgerState/utxo`
224
- * with an outputReferences filter. Empty result means spent or nonexistent.
171
+ * Unspent check via `queryLedgerState/utxo` with an outputReferences filter; empty = spent or nonexistent.
225
172
  * @param txHash 64-char lowercase hex
226
173
  * @param outputIndex non-negative integer
227
- * @returns {Promise<boolean>} true iff the UTxO exists and is unspent
228
174
  */
229
175
  isUtxoUnspent(txHash: string, outputIndex: number): Promise<boolean>;
230
- /**
231
- * Shutdown the Ogmios Backend
232
- * Closes all connections and marks as shutdown
233
- */
176
+ /** Close the WebSocket and mark the backend as shut down. */
234
177
  shutdown(): Promise<void>;
235
- /**
236
- * Check if backend is connected
237
- */
238
178
  isConnected(): boolean;
239
- /**
240
- * Ensure the client is not shutdown before operations
241
- */
242
179
  private ensureNotShutdown;
243
180
  /**
244
- * Convert Ogmios value format to odatano amount array
245
- * Ogmios: { ada: { lovelace: 1000000 }, policyId: { assetName: quantity } }
246
- * Standard: [{ unit: 'lovelace', quantity: '1000000' }, { unit: 'policyId.assetName', quantity: 'N' }]
181
+ * Ogmios value `{ ada: { lovelace }, policyId: { assetName: qty } }` →
182
+ * `[{ unit: 'lovelace', quantity }, { unit: policyId+assetName, quantity }]`.
247
183
  */
248
184
  private convertOgmiosValue;
249
185
  /**
250
- * Open a dedicated chain-synchronization stream. Uses its own InteractionContext
251
- * (a separate WebSocket) from the query/submission clients, because it is a
252
- * long-lived stream. `sequential: true` + `inFlight: 1` deliver blocks one at a
253
- * time in order, which the crawler needs for reorg detection and serial persist.
254
- *
255
- * KNOWN LIMITATIONS (documented, to harden against a live node — see CRAWLER_DESIGN.md):
256
- * - Input address/amount are left empty: Ogmios chain-sync inputs are bare
257
- * references ({txId,index}); the indexer resolves them from already-indexed
258
- * outputs (indexBlockFull, C3).
259
- * - Per-tx `size` and `deposit` are not surfaced by chain-sync (set 0).
260
- * - Output `referenceScriptHash` is not derived from the inline script yet.
186
+ * Open a long-lived chain-sync stream on its own WebSocket. `sequential: true` + `inFlight: 1`
187
+ * deliver blocks strictly in order (required by reorg detection and serial persist). Inputs arrive
188
+ * as bare references (resolved by the indexer from indexed outputs); per-tx size/deposit are not surfaced.
261
189
  */
262
190
  openChainSync(from: ChainPoint[] | 'origin', callbacks: ChainSyncCallbacks): Promise<ChainSyncHandle>;
263
191
  /**
264
- * Map an Ogmios Praos block into our BlockData + its transactions. Block-level
265
- * fees are the sum of per-tx fees; epoch/epochSlot are derived from the slot via
266
- * the network's Shelley anchor (same config the tx-builder uses).
267
- *
268
- * A phase-2 failure whose body declares no `total_collateral` still carries its
269
- * declared fee here, because the collateral inputs are not resolved yet. The indexer
270
- * corrects both the transaction and this sum in applyCollateralFees().
192
+ * Map an Ogmios Praos block to BlockData + transactions. Block fees are the sum of per-tx
193
+ * fees; epoch/epochSlot derive from the slot via the Shelley anchor. A phase-2 failure without
194
+ * `total_collateral` still carries its declared fee here; applyCollateralFees() corrects it.
271
195
  */
272
196
  private mapOgmiosBlock;
273
197
  /**
274
- * Map a single Ogmios chain-sync transaction into our Transaction. Outputs, fee
275
- * and metadata are mapped fully; inputs are kept as bare references (address/amount
276
- * resolved downstream by the indexer). `spends` selects the ledger-applied
277
- * partition: a phase-2-invalid transaction consumes collaterals and creates only
278
- * its collateral-return output, never its declared regular inputs/outputs. The fee
279
- * follows that partition too — see the `spendsCollaterals` branch below.
198
+ * Map one chain-sync transaction. Inputs stay bare references (resolved by the indexer).
199
+ * `spends` selects the ledger-applied partition: a phase-2-invalid tx consumes collaterals
200
+ * and creates only its collateral-return output; the fee follows that partition too.
280
201
  */
281
202
  private mapOgmiosTx;
282
203
  /**
283
- * Normalize Ogmios certificates onto the shared `CertificateKind` vocabulary.
284
- * A `stakeDelegation` carrying both a pool and a DRep target is split into two entries
285
- * with the same index, matching what Koios (db-sync) reports for the Conway combined
286
- * certificate. Ogmios credentials are bare hashes; they are re-encoded as bech32 here so
287
- * the rows carry the same identifiers as every other table.
204
+ * Normalize Ogmios certificates onto the shared `CertificateKind` vocabulary. A `stakeDelegation`
205
+ * with both pool and DRep target is split into two entries with the same index (as db-sync
206
+ * reports it); bare credential hashes are re-encoded as bech32 to match the other tables.
288
207
  */
289
208
  private mapOgmiosCertificates;
290
209
  }