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

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 (239) 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 +358 -0
  4. package/@cds-models/CardanoBackendService/index.js +41 -0
  5. package/@cds-models/CardanoIndexerService/index.d.ts +594 -11
  6. package/@cds-models/CardanoIndexerService/index.js +74 -0
  7. package/@cds-models/CardanoODataService/index.d.ts +417 -57
  8. package/@cds-models/CardanoODataService/index.js +42 -0
  9. package/@cds-models/CardanoSignService/index.d.ts +45 -19
  10. package/@cds-models/CardanoSignService/index.js +4 -0
  11. package/@cds-models/CardanoTransactionService/index.d.ts +70 -44
  12. package/@cds-models/CardanoTransactionService/index.js +5 -0
  13. package/@cds-models/CardanoWorkerService/index.d.ts +35 -22
  14. package/@cds-models/CardanoWorkerService/index.js +2 -0
  15. package/@cds-models/index.d.ts +114 -4
  16. package/@cds-models/index.js +20 -4
  17. package/@cds-models/odatano/cardano/index.d.ts +451 -32
  18. package/@cds-models/odatano/cardano/index.js +48 -0
  19. package/README.md +103 -167
  20. package/db/schema.cds +2455 -1705
  21. package/db/types.cds +456 -295
  22. package/package.json +41 -53
  23. package/scripts/deploy-schema.mjs +113 -0
  24. package/scripts/migrate-schema.mjs +528 -0
  25. package/scripts/migrate-slot-leader.mjs +96 -0
  26. package/src/index.d.ts +20 -21
  27. package/src/index.js +45 -31
  28. package/src/plugin.js +17 -35
  29. package/srv/blockchain/asset-decimals.d.ts +7 -0
  30. package/srv/blockchain/asset-decimals.js +91 -0
  31. package/srv/blockchain/backends/blockfrost-backend.d.ts +25 -137
  32. package/srv/blockchain/backends/blockfrost-backend.js +125 -215
  33. package/srv/blockchain/backends/call-signal.d.ts +7 -0
  34. package/srv/blockchain/backends/call-signal.js +22 -0
  35. package/srv/blockchain/backends/cardano-backend.d.ts +100 -189
  36. package/srv/blockchain/backends/cardano-backend.js +29 -5
  37. package/srv/blockchain/backends/koios-backend.d.ts +108 -170
  38. package/srv/blockchain/backends/koios-backend.js +488 -482
  39. package/srv/blockchain/backends/odatano-backend.d.ts +55 -0
  40. package/srv/blockchain/backends/odatano-backend.js +211 -0
  41. package/srv/blockchain/backends/ogmios-backend.d.ts +122 -190
  42. package/srv/blockchain/backends/ogmios-backend.js +683 -327
  43. package/srv/blockchain/backends/ogmios-frame-guard.d.ts +14 -0
  44. package/srv/blockchain/backends/ogmios-frame-guard.js +89 -0
  45. package/srv/blockchain/cardano-client.d.ts +71 -241
  46. package/srv/blockchain/cardano-client.js +354 -322
  47. package/srv/blockchain/cardano-indexer.d.ts +295 -283
  48. package/srv/blockchain/cardano-indexer.js +1690 -502
  49. package/srv/blockchain/cardano-tx-builder.d.ts +25 -89
  50. package/srv/blockchain/cardano-tx-builder.js +164 -140
  51. package/srv/blockchain/circuit-breaker.d.ts +2 -13
  52. package/srv/blockchain/circuit-breaker.js +11 -15
  53. package/srv/blockchain/crawler/account-snapshots.d.ts +29 -0
  54. package/srv/blockchain/crawler/account-snapshots.js +173 -0
  55. package/srv/blockchain/crawler/asset-decimals-backfill.d.ts +17 -0
  56. package/srv/blockchain/crawler/asset-decimals-backfill.js +56 -0
  57. package/srv/blockchain/crawler/asset-registry-backfill.d.ts +46 -0
  58. package/srv/blockchain/crawler/asset-registry-backfill.js +157 -0
  59. package/srv/blockchain/crawler/asset-slice-backfill.d.ts +35 -0
  60. package/srv/blockchain/crawler/asset-slice-backfill.js +149 -0
  61. package/srv/blockchain/crawler/certificate-backfill.d.ts +56 -0
  62. package/srv/blockchain/crawler/certificate-backfill.js +174 -0
  63. package/srv/blockchain/crawler/crawler.d.ts +125 -81
  64. package/srv/blockchain/crawler/crawler.js +738 -167
  65. package/srv/blockchain/crawler/credential-backfill.d.ts +30 -0
  66. package/srv/blockchain/crawler/credential-backfill.js +101 -0
  67. package/srv/blockchain/crawler/hooks.d.ts +2 -17
  68. package/srv/blockchain/crawler/index.d.ts +1 -8
  69. package/srv/blockchain/crawler/index.js +31 -17
  70. package/srv/blockchain/crawler/input-asset-copies.d.ts +34 -0
  71. package/srv/blockchain/crawler/input-asset-copies.js +161 -0
  72. package/srv/blockchain/crawler/key-pages.d.ts +12 -0
  73. package/srv/blockchain/crawler/key-pages.js +48 -0
  74. package/srv/blockchain/crawler/metadata-position-backfill.d.ts +22 -0
  75. package/srv/blockchain/crawler/metadata-position-backfill.js +59 -0
  76. package/srv/blockchain/crawler/output-datum-backfill.d.ts +41 -0
  77. package/srv/blockchain/crawler/output-datum-backfill.js +100 -0
  78. package/srv/blockchain/crawler/sync-state.d.ts +31 -47
  79. package/srv/blockchain/crawler/sync-state.js +135 -128
  80. package/srv/blockchain/crawler/transaction-backfill.d.ts +46 -0
  81. package/srv/blockchain/crawler/transaction-backfill.js +271 -0
  82. package/srv/blockchain/crawler/utxo-set-import.d.ts +66 -0
  83. package/srv/blockchain/crawler/utxo-set-import.js +399 -0
  84. package/srv/blockchain/crawler/window-plan.d.ts +31 -0
  85. package/srv/blockchain/crawler/window-plan.js +59 -0
  86. package/srv/blockchain/ledger-state.d.ts +62 -0
  87. package/srv/blockchain/ledger-state.js +521 -0
  88. package/srv/blockchain/pending-spends.d.ts +16 -0
  89. package/srv/blockchain/pending-spends.js +81 -0
  90. package/srv/blockchain/pool-metadata.d.ts +15 -0
  91. package/srv/blockchain/pool-metadata.js +132 -0
  92. package/srv/blockchain/request-coalescer.d.ts +2 -16
  93. package/srv/blockchain/request-coalescer.js +2 -16
  94. package/srv/blockchain/signing/cose-verifier.d.ts +3 -17
  95. package/srv/blockchain/signing/cose-verifier.js +146 -70
  96. package/srv/blockchain/signing/external-signer.d.ts +15 -115
  97. package/srv/blockchain/signing/external-signer.js +22 -131
  98. package/srv/blockchain/signing/failed-recheck.d.ts +17 -0
  99. package/srv/blockchain/signing/failed-recheck.js +135 -0
  100. package/srv/blockchain/signing/hsm-signer.d.ts +10 -54
  101. package/srv/blockchain/signing/hsm-signer.js +28 -79
  102. package/srv/blockchain/signing/landing-proof.d.ts +60 -0
  103. package/srv/blockchain/signing/landing-proof.js +224 -0
  104. package/srv/blockchain/signing/signature-verifier.d.ts +9 -47
  105. package/srv/blockchain/signing/signature-verifier.js +71 -87
  106. package/srv/blockchain/signing/submission-finalizer.d.ts +37 -45
  107. package/srv/blockchain/signing/submission-finalizer.js +280 -86
  108. package/srv/blockchain/stored-chain.d.ts +19 -0
  109. package/srv/blockchain/stored-chain.js +258 -0
  110. package/srv/blockchain/transaction-building/buildooor-tx.d.ts +31 -229
  111. package/srv/blockchain/transaction-building/buildooor-tx.js +663 -421
  112. package/srv/blockchain/transaction-building/cardano-tx.d.ts +9 -37
  113. package/srv/blockchain/transaction-presence.d.ts +12 -0
  114. package/srv/blockchain/transaction-presence.js +29 -0
  115. package/srv/blockchain/transaction-rows.d.ts +12 -0
  116. package/srv/blockchain/transaction-rows.js +44 -0
  117. package/srv/blockchain/wallet-worker/build-request.d.ts +8 -23
  118. package/srv/blockchain/wallet-worker/build-request.js +40 -353
  119. package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +27 -47
  120. package/srv/blockchain/wallet-worker/confirmation-tracker.js +158 -61
  121. package/srv/blockchain/wallet-worker/index.d.ts +1 -1
  122. package/srv/blockchain/wallet-worker/index.js +3 -11
  123. package/srv/blockchain/wallet-worker/invalidation.d.ts +35 -0
  124. package/srv/blockchain/wallet-worker/invalidation.js +128 -0
  125. package/srv/blockchain/wallet-worker/job-store.d.ts +58 -150
  126. package/srv/blockchain/wallet-worker/job-store.js +200 -273
  127. package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +2 -26
  128. package/srv/blockchain/wallet-worker/lease-heartbeat.js +6 -28
  129. package/srv/blockchain/wallet-worker/signers.d.ts +5 -24
  130. package/srv/blockchain/wallet-worker/signers.js +4 -12
  131. package/srv/blockchain/wallet-worker/wallet-worker.d.ts +29 -82
  132. package/srv/blockchain/wallet-worker/wallet-worker.js +334 -198
  133. package/srv/cardano-agent-service.cds +122 -84
  134. package/srv/cardano-agent-service.js +12 -9
  135. package/srv/cardano-backend-service.cds +81 -0
  136. package/srv/cardano-backend-service.d.ts +2 -0
  137. package/srv/cardano-backend-service.js +259 -0
  138. package/srv/cardano-indexer-service.cds +393 -18
  139. package/srv/cardano-indexer-service.d.ts +5 -1
  140. package/srv/cardano-indexer-service.js +477 -16
  141. package/srv/cardano-service.cds +426 -269
  142. package/srv/cardano-service.js +640 -217
  143. package/srv/cardano-sign-service.cds +211 -180
  144. package/srv/cardano-sign-service.js +210 -287
  145. package/srv/cardano-tx-service.cds +462 -370
  146. package/srv/cardano-tx-service.js +283 -800
  147. package/srv/cardano-ui.cds +16 -16
  148. package/srv/cardano-worker-service.cds +141 -125
  149. package/srv/cardano-worker-service.js +104 -61
  150. package/srv/cbor/cip68.d.ts +13 -0
  151. package/srv/cbor/cip68.js +56 -0
  152. package/srv/cbor/index.d.ts +3 -1
  153. package/srv/cbor/index.js +9 -1
  154. package/srv/cbor/parse.d.ts +30 -18
  155. package/srv/cbor/parse.js +44 -9
  156. package/srv/cbor/plutus-data-json.d.ts +20 -0
  157. package/srv/cbor/plutus-data-json.js +32 -0
  158. package/srv/config.d.ts +117 -0
  159. package/srv/config.js +419 -0
  160. package/srv/server.d.ts +15 -110
  161. package/srv/server.js +83 -405
  162. package/srv/utils/agent-access.d.ts +11 -0
  163. package/srv/utils/agent-access.js +86 -0
  164. package/srv/utils/agent-grants-config.d.ts +0 -46
  165. package/srv/utils/agent-grants-config.js +17 -85
  166. package/srv/utils/agent-grants.d.ts +106 -122
  167. package/srv/utils/agent-grants.js +538 -237
  168. package/srv/utils/agent-token-auth.d.ts +4 -99
  169. package/srv/utils/agent-token-auth.js +62 -186
  170. package/srv/utils/backend-request-handler.d.ts +3 -17
  171. package/srv/utils/backend-request-handler.js +3 -18
  172. package/srv/utils/build-request.d.ts +52 -0
  173. package/srv/utils/build-request.js +487 -0
  174. package/srv/utils/collections.d.ts +4 -10
  175. package/srv/utils/collections.js +14 -10
  176. package/srv/utils/const.d.ts +32 -75
  177. package/srv/utils/const.js +40 -80
  178. package/srv/utils/crypto.d.ts +3 -12
  179. package/srv/utils/crypto.js +11 -25
  180. package/srv/utils/db-indexes.d.ts +31 -0
  181. package/srv/utils/db-indexes.js +185 -0
  182. package/srv/utils/db-kind.d.ts +23 -0
  183. package/srv/utils/db-kind.js +42 -0
  184. package/srv/utils/db-sanitize.d.ts +20 -0
  185. package/srv/utils/db-sanitize.js +80 -0
  186. package/srv/utils/deep-json.d.ts +6 -0
  187. package/srv/utils/deep-json.js +240 -0
  188. package/srv/utils/detached-run.d.ts +41 -0
  189. package/srv/utils/detached-run.js +101 -0
  190. package/srv/utils/epoch-slots.d.ts +14 -0
  191. package/srv/utils/epoch-slots.js +45 -0
  192. package/srv/utils/error-codes.d.ts +26 -75
  193. package/srv/utils/error-codes.js +27 -72
  194. package/srv/utils/errors.d.ts +55 -187
  195. package/srv/utils/errors.js +161 -235
  196. package/srv/utils/lease.d.ts +20 -0
  197. package/srv/utils/lease.js +62 -0
  198. package/srv/utils/liveness.d.ts +12 -0
  199. package/srv/utils/liveness.js +35 -0
  200. package/srv/utils/mappers.d.ts +111 -223
  201. package/srv/utils/mappers.js +432 -371
  202. package/srv/utils/navigation.d.ts +17 -0
  203. package/srv/utils/navigation.js +52 -0
  204. package/srv/utils/network-context.d.ts +0 -1
  205. package/srv/utils/network-context.js +9 -15
  206. package/srv/utils/paging.d.ts +31 -0
  207. package/srv/utils/paging.js +43 -0
  208. package/srv/utils/pg-inline-json.d.ts +8 -0
  209. package/srv/utils/pg-inline-json.js +58 -0
  210. package/srv/utils/pg-order-nulls.d.ts +14 -0
  211. package/srv/utils/pg-order-nulls.js +54 -0
  212. package/srv/utils/plutus-placeholders.d.ts +16 -22
  213. package/srv/utils/plutus-placeholders.js +62 -33
  214. package/srv/utils/rate-limiter.d.ts +2 -21
  215. package/srv/utils/rate-limiter.js +5 -17
  216. package/srv/utils/readiness.d.ts +12 -0
  217. package/srv/utils/readiness.js +29 -0
  218. package/srv/utils/reference-script.d.ts +19 -0
  219. package/srv/utils/reference-script.js +84 -0
  220. package/srv/utils/resolution.d.ts +13 -0
  221. package/srv/utils/resolution.js +47 -0
  222. package/srv/utils/result-numbers.d.ts +15 -0
  223. package/srv/utils/result-numbers.js +61 -0
  224. package/srv/utils/row-values.d.ts +7 -0
  225. package/srv/utils/row-values.js +27 -0
  226. package/srv/utils/service-events.d.ts +0 -24
  227. package/srv/utils/service-events.js +3 -25
  228. package/srv/utils/signing-helper.d.ts +3 -20
  229. package/srv/utils/signing-helper.js +35 -64
  230. package/srv/utils/tx-build-helper.d.ts +25 -105
  231. package/srv/utils/tx-build-helper.js +108 -156
  232. package/srv/utils/tx-request-parsers.d.ts +82 -33
  233. package/srv/utils/tx-request-parsers.js +401 -49
  234. package/srv/utils/tx-utils.d.ts +3 -27
  235. package/srv/utils/tx-utils.js +32 -50
  236. package/srv/utils/types.d.ts +294 -232
  237. package/srv/utils/types.js +2 -22
  238. package/srv/utils/validators.d.ts +22 -92
  239. package/srv/utils/validators.js +60 -170
@@ -1,183 +1,63 @@
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[]>;
52
+ /** Whether a stake address is registered, as the backend itself decides; null = it cannot tell. */
53
+ isRewardAccountRegistered?(stakeAddress: string): Promise<boolean | null>;
164
54
  }
165
- /**
166
- * Extended backend interface for backends that support transaction evaluation (e.g., Ogmios)
167
- */
55
+ /** Backend that can evaluate script execution units (Ogmios). */
168
56
  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
- */
57
+ /** Evaluate the script execution units of an unsigned transaction (CBOR hex). */
174
58
  evaluateTransaction(unsignedTxCbor: string): Promise<ScriptEvaluationResult[]>;
175
59
  }
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
- */
60
+ /** Type guard: does this backend support transaction evaluation? */
181
61
  export declare function isEvaluatingBackend(backend: CardanoBackend): backend is EvaluatingBackend;
182
62
  /** A chain position the crawler can start from, stream to, or roll back to. */
183
63
  export interface ChainPoint {
@@ -187,19 +67,11 @@ export interface ChainPoint {
187
67
  }
188
68
  /** Callbacks driven by a streamed chain-sync (Ogmios). */
189
69
  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
- */
70
+ /** A new block with all its transactions extends the chain. `tip` is the node's tip when known. */
195
71
  rollForward(block: BlockData, txs: Transaction[], tip?: ChainPoint): Promise<void>;
196
- /** The chain rolled back to `point` (or to genesis). All blocks after it are abandoned. */
197
- 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
+ /** The chain rolled back to `point` (or to genesis). All blocks after it are abandoned. `tip` is the node's tip when known. */
73
+ rollBackward(point: ChainPoint | 'origin', tip?: ChainPoint): Promise<void>;
74
+ /** A handler error stalled the stream. The consumer should record it and restart the stream. */
203
75
  onError?(err: unknown): Promise<void>;
204
76
  }
205
77
  /** Handle to an open chain-sync stream. */
@@ -207,45 +79,84 @@ export interface ChainSyncHandle {
207
79
  /** Stop streaming and release the underlying connection. */
208
80
  close(): Promise<void>;
209
81
  }
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
- */
82
+ /** Backend that streams the chain forward with native rollback events (Ogmios chain-sync). */
215
83
  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
84
  openChainSync(from: ChainPoint[] | 'origin', callbacks: ChainSyncCallbacks): Promise<ChainSyncHandle>;
228
85
  }
229
86
  /** Type guard: does this backend support streamed chain-sync? */
230
87
  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
- */
88
+ export interface LedgerStateBackend extends CardanoBackend {
89
+ queryUtxoSetAt(point: ChainPoint): Promise<UTxO[]>;
90
+ /** Outputs among `refs` that are unspent at the tip; spent or unknown references are absent. */
91
+ getUnspentOutputs(refs: Array<{
92
+ txHash: string;
93
+ outputIndex: number;
94
+ }>): Promise<UTxO[]>;
95
+ }
96
+ export declare function isLedgerStateBackend(backend: CardanoBackend): backend is LedgerStateBackend;
236
97
  export interface PaginatingBackend extends CardanoBackend {
98
+ /** Extra data the crawl wants per block. Payloads that cost extra are only fetched when asked. */
99
+ configureCrawl?(options: {
100
+ certificates: boolean;
101
+ }): void;
237
102
  /** Fetch a block by its height. */
238
103
  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
- */
104
+ /** Up to `count` blocks after `afterHash` in chain order. `afterHeight` saves a height lookup. */
245
105
  getNextBlocks(afterHash: string, count: number, afterHeight?: number): Promise<BlockData[]>;
246
106
  /** Fetch the full transaction list of a block, in block order. */
247
- getBlockTransactions(blockHash: string): Promise<Transaction[]>;
107
+ /** `txCount` from the block header, when known: 0 answers without a request. */
108
+ getBlockTransactions(blockHash: string, txCount?: number): Promise<Transaction[]>;
248
109
  }
249
110
  /** Type guard: can this backend be walked forward by pagination? */
250
111
  export declare function isPaginatingBackend(backend: CardanoBackend): backend is PaginatingBackend;
112
+ export interface EnumeratingBackend extends CardanoBackend {
113
+ /** All known stake-pool ids (bech32). */
114
+ getPoolIds(): Promise<string[]>;
115
+ /** Resolve a batch of pool ids. Ids the backend does not know are omitted, not faked. */
116
+ getPools(poolIds: string[]): Promise<PoolData[]>;
117
+ /** All known DRep ids (bech32). */
118
+ getDrepIds(): Promise<string[]>;
119
+ /** Resolve a batch of DRep ids. Ids the backend does not know are omitted. */
120
+ getDreps(drepIds: string[]): Promise<DrepData[]>;
121
+ }
122
+ /** Network-wide ledger state read at one block for an epoch snapshot; unreported figures are null. */
123
+ export interface EpochLedgerState {
124
+ /** Epoch the ledger was in at the acquired block. */
125
+ epoch: number;
126
+ pools: PoolData[];
127
+ /** Registered DReps only; the two predefined DReps are summed into the stake fields below. */
128
+ dreps: DrepData[];
129
+ treasury: string | null;
130
+ reserves: string | null;
131
+ drepAbstainStake: string | null;
132
+ drepNoConfidenceStake: string | null;
133
+ }
134
+ export interface EpochStateBackend extends CardanoBackend {
135
+ epochStateAt(point: ChainPoint): Promise<EpochLedgerState>;
136
+ }
137
+ /** Type guard: can this backend read epoch state at a block? */
138
+ export declare function isEpochStateBackend(backend: CardanoBackend): backend is EpochStateBackend;
139
+ /** A reward account as the node's ledger holds it at one block. */
140
+ export interface RewardAccountState {
141
+ stakeAddress: string;
142
+ withdrawableAmount: string | null;
143
+ deposit: string | null;
144
+ poolId: string | null;
145
+ drepId: string | null;
146
+ }
147
+ /** Answers the accounts among `stakeAddresses` that the ledger reports. */
148
+ export type AskRewardAccounts = (stakeAddresses: string[]) => Promise<RewardAccountState[]>;
149
+ export interface RewardAccountStateBackend extends CardanoBackend {
150
+ rewardAccountsAt<T>(point: ChainPoint, read: (ask: AskRewardAccounts) => Promise<T>): Promise<T>;
151
+ }
152
+ /** Type guard: can this backend read reward accounts at a block? */
153
+ export declare function isRewardAccountStateBackend(backend: CardanoBackend): backend is RewardAccountStateBackend;
154
+ export interface TokenRegistryBackend extends CardanoBackend {
155
+ /** Units (policyId + assetNameHex) that have a registry entry. */
156
+ getTokenRegistryUnits(): Promise<string[]>;
157
+ }
158
+ /** Type guard: can this backend list the token registry? */
159
+ export declare function isTokenRegistryBackend(backend: CardanoBackend): backend is TokenRegistryBackend;
160
+ /** Type guard: can this backend enumerate pools and DReps? */
161
+ export declare function isEnumeratingBackend(backend: CardanoBackend): backend is EnumeratingBackend;
251
162
  //# 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