@odatano/core 2.0.0-rc.5 → 2.0.0-rc.50

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 (208) hide show
  1. package/@cds-models/CardanoAgentService/index.d.ts +99 -51
  2. package/@cds-models/CardanoAgentService/index.js +15 -0
  3. package/@cds-models/CardanoBackendService/index.d.ts +347 -0
  4. package/@cds-models/CardanoBackendService/index.js +40 -0
  5. package/@cds-models/CardanoIndexerService/index.d.ts +496 -11
  6. package/@cds-models/CardanoIndexerService/index.js +64 -0
  7. package/@cds-models/CardanoODataService/index.d.ts +414 -57
  8. package/@cds-models/CardanoODataService/index.js +42 -0
  9. package/@cds-models/CardanoSignService/index.d.ts +32 -19
  10. package/@cds-models/CardanoSignService/index.js +3 -0
  11. package/@cds-models/CardanoTransactionService/index.d.ts +58 -44
  12. package/@cds-models/CardanoTransactionService/index.js +4 -0
  13. package/@cds-models/CardanoWorkerService/index.d.ts +7 -22
  14. package/@cds-models/index.d.ts +101 -1
  15. package/@cds-models/index.js +16 -1
  16. package/@cds-models/odatano/cardano/index.d.ts +437 -32
  17. package/@cds-models/odatano/cardano/index.js +48 -0
  18. package/README.md +207 -167
  19. package/db/schema.cds +2402 -1705
  20. package/db/types.cds +446 -295
  21. package/package.json +41 -16
  22. package/scripts/migrate-schema.mjs +334 -0
  23. package/scripts/migrate-slot-leader.mjs +96 -0
  24. package/src/index.d.ts +20 -21
  25. package/src/index.js +45 -31
  26. package/src/plugin.js +17 -35
  27. package/srv/blockchain/asset-decimals.d.ts +7 -0
  28. package/srv/blockchain/asset-decimals.js +91 -0
  29. package/srv/blockchain/backends/blockfrost-backend.d.ts +25 -135
  30. package/srv/blockchain/backends/blockfrost-backend.js +66 -172
  31. package/srv/blockchain/backends/cardano-backend.d.ts +94 -186
  32. package/srv/blockchain/backends/cardano-backend.js +29 -5
  33. package/srv/blockchain/backends/koios-backend.d.ts +103 -168
  34. package/srv/blockchain/backends/koios-backend.js +428 -360
  35. package/srv/blockchain/backends/odatano-backend.d.ts +54 -0
  36. package/srv/blockchain/backends/odatano-backend.js +169 -0
  37. package/srv/blockchain/backends/ogmios-backend.d.ts +123 -190
  38. package/srv/blockchain/backends/ogmios-backend.js +637 -315
  39. package/srv/blockchain/backends/ogmios-frame-guard.d.ts +14 -0
  40. package/srv/blockchain/backends/ogmios-frame-guard.js +89 -0
  41. package/srv/blockchain/cardano-client.d.ts +61 -241
  42. package/srv/blockchain/cardano-client.js +253 -293
  43. package/srv/blockchain/cardano-indexer.d.ts +282 -281
  44. package/srv/blockchain/cardano-indexer.js +1551 -484
  45. package/srv/blockchain/cardano-tx-builder.d.ts +25 -89
  46. package/srv/blockchain/cardano-tx-builder.js +164 -140
  47. package/srv/blockchain/circuit-breaker.d.ts +1 -13
  48. package/srv/blockchain/circuit-breaker.js +5 -15
  49. package/srv/blockchain/crawler/account-snapshots.d.ts +29 -0
  50. package/srv/blockchain/crawler/account-snapshots.js +153 -0
  51. package/srv/blockchain/crawler/asset-decimals-backfill.d.ts +15 -0
  52. package/srv/blockchain/crawler/asset-decimals-backfill.js +56 -0
  53. package/srv/blockchain/crawler/asset-registry-backfill.d.ts +43 -0
  54. package/srv/blockchain/crawler/asset-registry-backfill.js +153 -0
  55. package/srv/blockchain/crawler/certificate-backfill.d.ts +52 -0
  56. package/srv/blockchain/crawler/certificate-backfill.js +162 -0
  57. package/srv/blockchain/crawler/crawler.d.ts +104 -81
  58. package/srv/blockchain/crawler/crawler.js +532 -160
  59. package/srv/blockchain/crawler/credential-backfill.d.ts +28 -0
  60. package/srv/blockchain/crawler/credential-backfill.js +124 -0
  61. package/srv/blockchain/crawler/hooks.d.ts +2 -17
  62. package/srv/blockchain/crawler/index.d.ts +1 -8
  63. package/srv/blockchain/crawler/index.js +31 -17
  64. package/srv/blockchain/crawler/input-asset-copies.d.ts +34 -0
  65. package/srv/blockchain/crawler/input-asset-copies.js +171 -0
  66. package/srv/blockchain/crawler/metadata-position-backfill.d.ts +16 -0
  67. package/srv/blockchain/crawler/metadata-position-backfill.js +55 -0
  68. package/srv/blockchain/crawler/output-datum-backfill.d.ts +39 -0
  69. package/srv/blockchain/crawler/output-datum-backfill.js +110 -0
  70. package/srv/blockchain/crawler/sync-state.d.ts +27 -47
  71. package/srv/blockchain/crawler/sync-state.js +113 -63
  72. package/srv/blockchain/crawler/transaction-backfill.d.ts +44 -0
  73. package/srv/blockchain/crawler/transaction-backfill.js +278 -0
  74. package/srv/blockchain/crawler/utxo-set-import.d.ts +66 -0
  75. package/srv/blockchain/crawler/utxo-set-import.js +399 -0
  76. package/srv/blockchain/ledger-state.d.ts +62 -0
  77. package/srv/blockchain/ledger-state.js +419 -0
  78. package/srv/blockchain/pending-spends.d.ts +16 -0
  79. package/srv/blockchain/pending-spends.js +81 -0
  80. package/srv/blockchain/pool-metadata.d.ts +15 -0
  81. package/srv/blockchain/pool-metadata.js +132 -0
  82. package/srv/blockchain/request-coalescer.d.ts +2 -16
  83. package/srv/blockchain/request-coalescer.js +2 -16
  84. package/srv/blockchain/signing/cose-verifier.d.ts +3 -17
  85. package/srv/blockchain/signing/cose-verifier.js +146 -70
  86. package/srv/blockchain/signing/external-signer.d.ts +15 -115
  87. package/srv/blockchain/signing/external-signer.js +17 -126
  88. package/srv/blockchain/signing/hsm-signer.d.ts +10 -54
  89. package/srv/blockchain/signing/hsm-signer.js +28 -79
  90. package/srv/blockchain/signing/signature-verifier.d.ts +9 -47
  91. package/srv/blockchain/signing/signature-verifier.js +70 -83
  92. package/srv/blockchain/signing/submission-finalizer.d.ts +23 -45
  93. package/srv/blockchain/signing/submission-finalizer.js +219 -86
  94. package/srv/blockchain/stored-chain.d.ts +20 -0
  95. package/srv/blockchain/stored-chain.js +237 -0
  96. package/srv/blockchain/transaction-building/buildooor-tx.d.ts +31 -229
  97. package/srv/blockchain/transaction-building/buildooor-tx.js +652 -416
  98. package/srv/blockchain/transaction-building/cardano-tx.d.ts +9 -37
  99. package/srv/blockchain/transaction-presence.d.ts +5 -0
  100. package/srv/blockchain/transaction-presence.js +29 -0
  101. package/srv/blockchain/transaction-rows.d.ts +12 -0
  102. package/srv/blockchain/transaction-rows.js +44 -0
  103. package/srv/blockchain/wallet-worker/build-request.d.ts +5 -20
  104. package/srv/blockchain/wallet-worker/build-request.js +47 -30
  105. package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +5 -46
  106. package/srv/blockchain/wallet-worker/confirmation-tracker.js +25 -45
  107. package/srv/blockchain/wallet-worker/index.d.ts +1 -1
  108. package/srv/blockchain/wallet-worker/index.js +3 -11
  109. package/srv/blockchain/wallet-worker/job-store.d.ts +30 -148
  110. package/srv/blockchain/wallet-worker/job-store.js +101 -201
  111. package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +2 -26
  112. package/srv/blockchain/wallet-worker/lease-heartbeat.js +6 -28
  113. package/srv/blockchain/wallet-worker/signers.d.ts +5 -24
  114. package/srv/blockchain/wallet-worker/signers.js +4 -12
  115. package/srv/blockchain/wallet-worker/wallet-worker.d.ts +8 -80
  116. package/srv/blockchain/wallet-worker/wallet-worker.js +107 -155
  117. package/srv/cardano-agent-service.cds +122 -84
  118. package/srv/cardano-agent-service.js +4 -9
  119. package/srv/cardano-backend-service.cds +78 -0
  120. package/srv/cardano-backend-service.d.ts +2 -0
  121. package/srv/cardano-backend-service.js +242 -0
  122. package/srv/cardano-indexer-service.cds +387 -73
  123. package/srv/cardano-indexer-service.d.ts +5 -1
  124. package/srv/cardano-indexer-service.js +532 -16
  125. package/srv/cardano-service.cds +424 -269
  126. package/srv/cardano-service.js +289 -201
  127. package/srv/cardano-sign-service.cds +201 -180
  128. package/srv/cardano-sign-service.js +71 -201
  129. package/srv/cardano-tx-service.cds +451 -370
  130. package/srv/cardano-tx-service.js +271 -289
  131. package/srv/cardano-ui.cds +16 -16
  132. package/srv/cardano-worker-service.cds +118 -125
  133. package/srv/cardano-worker-service.js +52 -61
  134. package/srv/cbor/cip68.d.ts +13 -0
  135. package/srv/cbor/cip68.js +56 -0
  136. package/srv/cbor/index.d.ts +3 -1
  137. package/srv/cbor/index.js +9 -1
  138. package/srv/cbor/parse.d.ts +30 -18
  139. package/srv/cbor/parse.js +44 -9
  140. package/srv/cbor/plutus-data-json.d.ts +20 -0
  141. package/srv/cbor/plutus-data-json.js +32 -0
  142. package/srv/config.d.ts +113 -0
  143. package/srv/config.js +409 -0
  144. package/srv/server.d.ts +15 -110
  145. package/srv/server.js +84 -404
  146. package/srv/utils/agent-access.d.ts +9 -0
  147. package/srv/utils/agent-access.js +67 -0
  148. package/srv/utils/agent-grants-config.d.ts +0 -46
  149. package/srv/utils/agent-grants-config.js +17 -85
  150. package/srv/utils/agent-grants.d.ts +106 -122
  151. package/srv/utils/agent-grants.js +538 -236
  152. package/srv/utils/agent-token-auth.d.ts +4 -99
  153. package/srv/utils/agent-token-auth.js +18 -182
  154. package/srv/utils/backend-request-handler.d.ts +3 -17
  155. package/srv/utils/backend-request-handler.js +3 -18
  156. package/srv/utils/collections.d.ts +3 -10
  157. package/srv/utils/collections.js +3 -10
  158. package/srv/utils/const.d.ts +23 -74
  159. package/srv/utils/const.js +32 -79
  160. package/srv/utils/crypto.d.ts +3 -12
  161. package/srv/utils/crypto.js +6 -21
  162. package/srv/utils/db-indexes.d.ts +27 -0
  163. package/srv/utils/db-indexes.js +120 -0
  164. package/srv/utils/db-sanitize.d.ts +20 -0
  165. package/srv/utils/db-sanitize.js +80 -0
  166. package/srv/utils/deep-json.d.ts +6 -0
  167. package/srv/utils/deep-json.js +240 -0
  168. package/srv/utils/epoch-slots.d.ts +13 -0
  169. package/srv/utils/epoch-slots.js +38 -0
  170. package/srv/utils/error-codes.d.ts +22 -75
  171. package/srv/utils/error-codes.js +23 -72
  172. package/srv/utils/errors.d.ts +46 -187
  173. package/srv/utils/errors.js +114 -230
  174. package/srv/utils/liveness.d.ts +12 -0
  175. package/srv/utils/liveness.js +35 -0
  176. package/srv/utils/mappers.d.ts +102 -223
  177. package/srv/utils/mappers.js +387 -316
  178. package/srv/utils/network-context.js +2 -13
  179. package/srv/utils/paging.d.ts +31 -0
  180. package/srv/utils/paging.js +43 -0
  181. package/srv/utils/pg-inline-json.d.ts +8 -0
  182. package/srv/utils/pg-inline-json.js +58 -0
  183. package/srv/utils/pg-order-nulls.d.ts +14 -0
  184. package/srv/utils/pg-order-nulls.js +54 -0
  185. package/srv/utils/plutus-placeholders.d.ts +16 -22
  186. package/srv/utils/plutus-placeholders.js +62 -33
  187. package/srv/utils/rate-limiter.d.ts +2 -21
  188. package/srv/utils/rate-limiter.js +5 -17
  189. package/srv/utils/readiness.d.ts +12 -0
  190. package/srv/utils/readiness.js +29 -0
  191. package/srv/utils/reference-script.d.ts +19 -0
  192. package/srv/utils/reference-script.js +84 -0
  193. package/srv/utils/result-numbers.d.ts +15 -0
  194. package/srv/utils/result-numbers.js +61 -0
  195. package/srv/utils/service-events.d.ts +0 -24
  196. package/srv/utils/service-events.js +3 -25
  197. package/srv/utils/signing-helper.d.ts +3 -20
  198. package/srv/utils/signing-helper.js +35 -64
  199. package/srv/utils/tx-build-helper.d.ts +10 -105
  200. package/srv/utils/tx-build-helper.js +81 -144
  201. package/srv/utils/tx-request-parsers.d.ts +82 -33
  202. package/srv/utils/tx-request-parsers.js +401 -49
  203. package/srv/utils/tx-utils.d.ts +3 -27
  204. package/srv/utils/tx-utils.js +32 -50
  205. package/srv/utils/types.d.ts +261 -191
  206. package/srv/utils/types.js +2 -6
  207. package/srv/utils/validators.d.ts +22 -92
  208. package/srv/utils/validators.js +50 -149
@@ -1,183 +1,61 @@
1
1
  import { Transaction, Address, UTxO, NetworkInformation, BlockData, EpochData, MetadataLabelTx, PoolData, DrepData, AccountData, AssetInfo, AssetHistoryEntry, LedgerProtocolParameters, ScriptEvaluationResult } from '../../utils/types';
2
- /**
3
- * CardanoBackend - Interface Definition for multiple backends (Blockfrost, Koios, Ogmios, etc.)
4
- *
5
- * Defines the standard methods that any Cardano backend must implement to be used interchangeably.
6
- */
2
+ /** Common interface every Cardano backend (Blockfrost, Koios, Ogmios, ...) implements. */
7
3
  export interface CardanoBackend {
8
- /**
9
- * Backend name
10
- */
11
4
  name: string;
12
- /**
13
- * Methods this backend declares as NOT supported. The orchestrator skips the
14
- * backend for these without counting a circuit-breaker failure — previously
15
- * Ogmios either fabricated placeholder data for them (which preferLive routing
16
- * then preferred over correct historical data) or its thrown errors poisoned
17
- * the breaker.
18
- */
5
+ /** Methods this backend does not support. The orchestrator skips them without a circuit-breaker failure. */
19
6
  readonly unsupportedMethods?: ReadonlySet<string>;
20
- /**
21
- * Initialize the backend
22
- */
23
7
  init(): Promise<boolean>;
24
- /**
25
- * Get Transaction Data
26
- * @param txHash transaction hash (hex)
27
- * @returns {Promise<Transaction>} transaction data
28
- */
8
+ /** Transaction by hash (hex). */
29
9
  getTransaction(txHash: string): Promise<Transaction>;
30
- /**
31
- * Get Address Data
32
- * @param address bech32 address
33
- * @returns {Promise<Address>} address data
34
- */
10
+ /** Address data by bech32 address. */
35
11
  getAddress(address: string): Promise<Address>;
36
- /**
37
- * Get Address UTxOs
38
- * @param address bech32 address
39
- * @returns {Promise<UTxO[]>} list of UTxOs
40
- */
12
+ /** UTxOs of a bech32 address. */
41
13
  getAddressUtxos(address: string): Promise<UTxO[]>;
42
- /**
43
- * Get Address Transactions (lightweight - only tx hashes and basic info)
44
- * @param address bech32 address
45
- * @returns {Promise<Transaction[]>} list of transactions involving this address
46
- */
14
+ /** Transactions involving a bech32 address (hashes and basic info only). */
47
15
  getAddressTransactions(address: string, limit: number): Promise<Transaction[]>;
48
- /**
49
- * Get Network Information
50
- * @returns {Promise<NetworkInformation>} network information
51
- */
16
+ /** Network information (supply, stake). */
52
17
  getNetworkInformation(): Promise<NetworkInformation>;
53
- /**
54
- * Get Transaction Metadata
55
- * @param txHash transaction hash (hex)
56
- * @returns {Promise<MetadataLabelTx[]>} transaction metadata list
57
- */
18
+ /** Metadata labels of a transaction (hash hex). */
58
19
  getTransactionMetadata(txHash: string): Promise<MetadataLabelTx[]>;
59
- /**
60
- * Get Block Data
61
- * @param blockHash block hash (hex)
62
- * @returns {Promise<BlockData>} block data
63
- */
20
+ /** Block by hash (hex). */
64
21
  getBlock(blockHash: string): Promise<BlockData>;
65
- /**
66
- * Get Epoch Data
67
- * @param epochNumber epoch number
68
- * @returns {Promise<EpochData>} epoch data
69
- */
22
+ /** Epoch by number. */
70
23
  getEpoch(epochNumber: number): Promise<EpochData>;
71
- /**
72
- * Get Latest Epoch Data
73
- * @returns {Promise<EpochData>} latest epoch data
74
- */
24
+ /** Latest epoch. */
75
25
  getLatestEpoch(): Promise<EpochData>;
76
- /**
77
- * Get Latest Block Data
78
- * @returns {Promise<BlockData>} latest block data
79
- */
26
+ /** Latest block. */
80
27
  getLatestBlock(): Promise<BlockData>;
81
- /**
82
- * Get the latest chain tip slot.
83
- * Throws ProviderUnavailableError when the backend's latest block has no slot.
84
- * @returns {Promise<number>} current chain slot
85
- */
28
+ /** Latest chain tip slot; throws ProviderUnavailableError when the latest block has no slot. */
86
29
  getCurrentSlot(): Promise<number>;
87
- /**
88
- * Check whether a UTxO is still unspent. Returns `false` for txs that don't
89
- * exist on chain and for out-of-range output indices.
90
- * @param txHash 64-char lowercase hex
91
- * @param outputIndex non-negative integer
92
- * @returns {Promise<boolean>} true iff the UTxO exists and is unspent
93
- */
30
+ /** Whether a UTxO is still unspent. `false` for unknown txs and out-of-range output indices. */
94
31
  isUtxoUnspent(txHash: string, outputIndex: number): Promise<boolean>;
95
- /**
96
- * Get Pool Data
97
- * @param poolId pool id
98
- * @returns {Promise<PoolData>} pool data
99
- */
32
+ /** Stake pool by id. */
100
33
  getPool(poolId: string): Promise<PoolData>;
101
- /**
102
- * Get Drep Data
103
- * @param drepId drep id
104
- * @returns {Promise<DrepData>} drep data
105
- */
34
+ /** DRep by id. */
106
35
  getDrep(drepId: string): Promise<DrepData>;
107
- /**
108
- * Get Account Data
109
- * @param accountId account id
110
- * @returns {Promise<AccountData>} account data
111
- */
36
+ /** Account by stake address. */
112
37
  getAccount(accountId: string): Promise<AccountData>;
113
- /**
114
- * Get Asset Info (supply, mint history, CIP-25 + CIP-26 metadata)
115
- * @param unit policyId + assetNameHex (concatenated hex)
116
- * @returns {Promise<AssetInfo>} canonical asset info
117
- */
38
+ /** Asset info (supply, mint history, CIP-25 + CIP-26 metadata); unit = policyId + assetNameHex. */
118
39
  getAssetInfo(unit: string): Promise<AssetInfo>;
119
- /**
120
- * Get latest mint/burn events for an asset (most recent first).
121
- * Optional — Ogmios doesn't expose this. Blockfrost lacks block timestamps;
122
- * Koios includes block_time per entry.
123
- * @param unit policyId + assetNameHex (concatenated hex)
124
- * @param limit max number of events (default 100)
125
- * @returns {Promise<AssetHistoryEntry[]>} list of mint/burn events
126
- */
40
+ /** Latest mint and burn events of an asset, newest first. Blockfrost has no block timestamps here. */
127
41
  getAssetHistory?(unit: string, limit?: number): Promise<AssetHistoryEntry[]>;
128
- /**
129
- * Get Protocol Parameters
130
- * @returns {Promise<LedgerProtocolParameters>} protocol parameters
131
- */
42
+ /** Current protocol parameters. */
132
43
  getProtocolParameters(): Promise<LedgerProtocolParameters>;
133
- /**
134
- * Submit a signed transaction to the network
135
- * @param signedTxCbor signed transaction in CBOR hex format
136
- * @returns {Promise<string>} transaction hash
137
- */
44
+ /** Submit a signed transaction (CBOR hex); returns the tx hash. */
138
45
  submitTransaction(signedTxCbor: string): Promise<string>;
139
- /**
140
- * Get transaction hashes for an address (lightweight — no full tx details).
141
- * Used by the indexer to separate hash listing from detail fetching.
142
- * Optional: falls back to getAddressTransactions() + map to hashes if not implemented.
143
- * @param address bech32 address
144
- * @param limit maximum number of transaction hashes to return
145
- * @returns {Promise<string[]>} list of transaction hashes (most recent first)
146
- */
46
+ /** Most recent tx hashes of an address. Callers fall back to getAddressTransactions(). */
147
47
  getAddressTransactionHashes?(address: string, limit: number): Promise<string[]>;
148
- /**
149
- * Batch fetch multiple transactions by hash.
150
- * Koios implements natively via POST /tx_info; Blockfrost uses concurrency-limited parallel calls.
151
- * Optional: falls back to individual getTransaction() calls if not implemented.
152
- * @param txHashes array of transaction hashes (hex)
153
- * @returns {Promise<Map<string, Transaction>>} map of txHash -> Transaction
154
- */
48
+ /** Transactions by hash. Callers fall back to single getTransaction() calls. */
155
49
  getTransactionsBatch?(txHashes: string[]): Promise<Map<string, Transaction>>;
156
- /**
157
- * Get UTxOs across all bech32 addresses sharing a 28-byte payment credential
158
- * (key hash or script hash). Returns UTxOs with their owning bech32 address.
159
- * Optional — only Koios implements this natively (`POST /credential_utxos`).
160
- * @param credHash 28-byte payment credential as 56-char lowercase hex
161
- * @returns {Promise<UTxO[]>} list of UTxOs across all bech32 forms
162
- */
50
+ /** UTxOs of every address with this payment credential (56 hex chars), each with its address. */
163
51
  getCredentialUtxos?(credHash: string): Promise<UTxO[]>;
164
52
  }
165
- /**
166
- * Extended backend interface for backends that support transaction evaluation (e.g., Ogmios)
167
- */
53
+ /** Backend that can evaluate script execution units (Ogmios). */
168
54
  export interface EvaluatingBackend extends CardanoBackend {
169
- /**
170
- * Evaluate transaction script execution units
171
- * @param unsignedTxCbor unsigned transaction in CBOR hex format
172
- * @returns evaluation results with validator and budget
173
- */
55
+ /** Evaluate the script execution units of an unsigned transaction (CBOR hex). */
174
56
  evaluateTransaction(unsignedTxCbor: string): Promise<ScriptEvaluationResult[]>;
175
57
  }
176
- /**
177
- * Type guard to check if a backend supports transaction evaluation
178
- * @param backend - The backend to check
179
- * @returns true if the backend supports evaluateTransaction
180
- */
58
+ /** Type guard: does this backend support transaction evaluation? */
181
59
  export declare function isEvaluatingBackend(backend: CardanoBackend): backend is EvaluatingBackend;
182
60
  /** A chain position the crawler can start from, stream to, or roll back to. */
183
61
  export interface ChainPoint {
@@ -187,19 +65,11 @@ export interface ChainPoint {
187
65
  }
188
66
  /** Callbacks driven by a streamed chain-sync (Ogmios). */
189
67
  export interface ChainSyncCallbacks {
190
- /**
191
- * A new block (with its full transaction list) extends the chain.
192
- * @param tip the node's current chain tip, when the protocol supplies it — lets the
193
- * consumer track sync progress / detect being caught up
194
- */
68
+ /** A new block with all its transactions extends the chain. `tip` is the node's tip when known. */
195
69
  rollForward(block: BlockData, txs: Transaction[], tip?: ChainPoint): Promise<void>;
196
70
  /** The chain rolled back to `point` (or to genesis). All blocks after it are abandoned. */
197
71
  rollBackward(point: ChainPoint | 'origin'): Promise<void>;
198
- /**
199
- * A message-handler error stalled the stream (mapping failure, callback throw). The
200
- * stream stops requesting further blocks; the consumer should record the error and
201
- * close/restart. Optional — without it such errors are only logged.
202
- */
72
+ /** A handler error stalled the stream. The consumer should record it and restart the stream. */
203
73
  onError?(err: unknown): Promise<void>;
204
74
  }
205
75
  /** Handle to an open chain-sync stream. */
@@ -207,45 +77,83 @@ export interface ChainSyncHandle {
207
77
  /** Stop streaming and release the underlying connection. */
208
78
  close(): Promise<void>;
209
79
  }
210
- /**
211
- * Backend that can stream the chain forward from a point, emitting ordered
212
- * rollForward + native rollBackward (reorg) events. Implemented by Ogmios via the
213
- * chain-synchronization protocol — the crawler's primary, reorg-aware source.
214
- */
80
+ /** Backend that streams the chain forward with native rollback events (Ogmios chain-sync). */
215
81
  export interface ChainSyncBackend extends CardanoBackend {
216
- /**
217
- * Open a chain-sync stream starting just after the first of `from` that is still
218
- * on the node's chain (or from genesis).
219
- * @param from candidate intersection points, NEWEST FIRST, or 'origin' for a
220
- * fresh sync. Passing ancestors as well as the last-indexed point is what makes
221
- * a reorg that happened while we were disconnected resolvable: the node
222
- * intersects at the last common block and reports it via rollBackward, instead
223
- * of failing the whole stream with "No intersection found".
224
- * @param callbacks rollForward / rollBackward handlers
225
- * @returns a handle to close the stream
226
- */
227
82
  openChainSync(from: ChainPoint[] | 'origin', callbacks: ChainSyncCallbacks): Promise<ChainSyncHandle>;
228
83
  }
229
84
  /** Type guard: does this backend support streamed chain-sync? */
230
85
  export declare function isChainSyncBackend(backend: CardanoBackend): backend is ChainSyncBackend;
231
- /**
232
- * Backend that can walk the chain forward by pagination (no live node). The
233
- * crawler's fallback source when no Ogmios chain-sync is available. Reorgs are
234
- * detected by the crawler via parent-hash mismatch (not delivered natively).
235
- */
86
+ export interface LedgerStateBackend extends CardanoBackend {
87
+ queryUtxoSetAt(point: ChainPoint): Promise<UTxO[]>;
88
+ /** Outputs among `refs` that are unspent at the tip; spent or unknown references are absent. */
89
+ getUnspentOutputs(refs: Array<{
90
+ txHash: string;
91
+ outputIndex: number;
92
+ }>): Promise<UTxO[]>;
93
+ }
94
+ export declare function isLedgerStateBackend(backend: CardanoBackend): backend is LedgerStateBackend;
236
95
  export interface PaginatingBackend extends CardanoBackend {
96
+ /** Extra data the crawl wants per block. Payloads that cost extra are only fetched when asked. */
97
+ configureCrawl?(options: {
98
+ certificates: boolean;
99
+ }): void;
237
100
  /** Fetch a block by its height. */
238
101
  getBlockByHeight(height: number): Promise<BlockData>;
239
- /**
240
- * Fetch up to `count` blocks immediately following `afterHash`, in chain order.
241
- * @param afterHeight optional height of `afterHash` when the caller already knows it
242
- * (the crawler's cursor does) — lets height-listing backends
243
- * (Koios) skip a hash→height resolution round-trip
244
- */
102
+ /** Up to `count` blocks after `afterHash` in chain order. `afterHeight` saves a height lookup. */
245
103
  getNextBlocks(afterHash: string, count: number, afterHeight?: number): Promise<BlockData[]>;
246
104
  /** Fetch the full transaction list of a block, in block order. */
247
105
  getBlockTransactions(blockHash: string): Promise<Transaction[]>;
248
106
  }
249
107
  /** Type guard: can this backend be walked forward by pagination? */
250
108
  export declare function isPaginatingBackend(backend: CardanoBackend): backend is PaginatingBackend;
109
+ export interface EnumeratingBackend extends CardanoBackend {
110
+ /** All known stake-pool ids (bech32). */
111
+ getPoolIds(): Promise<string[]>;
112
+ /** Resolve a batch of pool ids. Ids the backend does not know are omitted, not faked. */
113
+ getPools(poolIds: string[]): Promise<PoolData[]>;
114
+ /** All known DRep ids (bech32). */
115
+ getDrepIds(): Promise<string[]>;
116
+ /** Resolve a batch of DRep ids. Ids the backend does not know are omitted. */
117
+ getDreps(drepIds: string[]): Promise<DrepData[]>;
118
+ }
119
+ /** Network-wide ledger state read at one block for an epoch snapshot; unreported figures are null. */
120
+ export interface EpochLedgerState {
121
+ /** Epoch the ledger was in at the acquired block. */
122
+ epoch: number;
123
+ pools: PoolData[];
124
+ /** Registered DReps only; the two predefined DReps are summed into the stake fields below. */
125
+ dreps: DrepData[];
126
+ treasury: string | null;
127
+ reserves: string | null;
128
+ drepAbstainStake: string | null;
129
+ drepNoConfidenceStake: string | null;
130
+ }
131
+ export interface EpochStateBackend extends CardanoBackend {
132
+ epochStateAt(point: ChainPoint): Promise<EpochLedgerState>;
133
+ }
134
+ /** Type guard: can this backend read epoch state at a block? */
135
+ export declare function isEpochStateBackend(backend: CardanoBackend): backend is EpochStateBackend;
136
+ /** A reward account as the node's ledger holds it at one block. */
137
+ export interface RewardAccountState {
138
+ stakeAddress: string;
139
+ withdrawableAmount: string | null;
140
+ deposit: string | null;
141
+ poolId: string | null;
142
+ drepId: string | null;
143
+ }
144
+ /** Answers the accounts among `stakeAddresses` that the ledger reports. */
145
+ export type AskRewardAccounts = (stakeAddresses: string[]) => Promise<RewardAccountState[]>;
146
+ export interface RewardAccountStateBackend extends CardanoBackend {
147
+ rewardAccountsAt<T>(point: ChainPoint, read: (ask: AskRewardAccounts) => Promise<T>): Promise<T>;
148
+ }
149
+ /** Type guard: can this backend read reward accounts at a block? */
150
+ export declare function isRewardAccountStateBackend(backend: CardanoBackend): backend is RewardAccountStateBackend;
151
+ export interface TokenRegistryBackend extends CardanoBackend {
152
+ /** Units (policyId + assetNameHex) that have a registry entry. */
153
+ getTokenRegistryUnits(): Promise<string[]>;
154
+ }
155
+ /** Type guard: can this backend list the token registry? */
156
+ export declare function isTokenRegistryBackend(backend: CardanoBackend): backend is TokenRegistryBackend;
157
+ /** Type guard: can this backend enumerate pools and DReps? */
158
+ export declare function isEnumeratingBackend(backend: CardanoBackend): backend is EnumeratingBackend;
251
159
  //# sourceMappingURL=cardano-backend.d.ts.map
@@ -2,12 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isEvaluatingBackend = isEvaluatingBackend;
4
4
  exports.isChainSyncBackend = isChainSyncBackend;
5
+ exports.isLedgerStateBackend = isLedgerStateBackend;
5
6
  exports.isPaginatingBackend = isPaginatingBackend;
6
- /**
7
- * Type guard to check if a backend supports transaction evaluation
8
- * @param backend - The backend to check
9
- * @returns true if the backend supports evaluateTransaction
10
- */
7
+ exports.isEpochStateBackend = isEpochStateBackend;
8
+ exports.isRewardAccountStateBackend = isRewardAccountStateBackend;
9
+ exports.isTokenRegistryBackend = isTokenRegistryBackend;
10
+ exports.isEnumeratingBackend = isEnumeratingBackend;
11
+ /** Type guard: does this backend support transaction evaluation? */
11
12
  function isEvaluatingBackend(backend) {
12
13
  return typeof backend.evaluateTransaction === 'function';
13
14
  }
@@ -15,6 +16,9 @@ function isEvaluatingBackend(backend) {
15
16
  function isChainSyncBackend(backend) {
16
17
  return typeof backend.openChainSync === 'function';
17
18
  }
19
+ function isLedgerStateBackend(backend) {
20
+ return typeof backend.queryUtxoSetAt === 'function';
21
+ }
18
22
  /** Type guard: can this backend be walked forward by pagination? */
19
23
  function isPaginatingBackend(backend) {
20
24
  const b = backend;
@@ -22,4 +26,24 @@ function isPaginatingBackend(backend) {
22
26
  && typeof b.getNextBlocks === 'function'
23
27
  && typeof b.getBlockTransactions === 'function';
24
28
  }
29
+ /** Type guard: can this backend read epoch state at a block? */
30
+ function isEpochStateBackend(backend) {
31
+ return typeof backend.epochStateAt === 'function';
32
+ }
33
+ /** Type guard: can this backend read reward accounts at a block? */
34
+ function isRewardAccountStateBackend(backend) {
35
+ return typeof backend.rewardAccountsAt === 'function';
36
+ }
37
+ /** Type guard: can this backend list the token registry? */
38
+ function isTokenRegistryBackend(backend) {
39
+ return typeof backend.getTokenRegistryUnits === 'function';
40
+ }
41
+ /** Type guard: can this backend enumerate pools and DReps? */
42
+ function isEnumeratingBackend(backend) {
43
+ const b = backend;
44
+ return typeof b.getPoolIds === 'function'
45
+ && typeof b.getPools === 'function'
46
+ && typeof b.getDrepIds === 'function'
47
+ && typeof b.getDreps === 'function';
48
+ }
25
49
  //# sourceMappingURL=cardano-backend.js.map