@odatano/core 2.0.0-rc.2 → 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 (132) hide show
  1. package/@cds-models/CardanoAgentService/index.d.ts +251 -0
  2. package/@cds-models/CardanoAgentService/index.js +36 -0
  3. package/@cds-models/CardanoIndexerService/index.d.ts +139 -2
  4. package/@cds-models/CardanoIndexerService/index.js +18 -0
  5. package/@cds-models/CardanoODataService/index.d.ts +224 -0
  6. package/@cds-models/CardanoODataService/index.js +27 -0
  7. package/@cds-models/CardanoSignService/index.d.ts +5 -2
  8. package/@cds-models/CardanoTransactionService/index.d.ts +9 -9
  9. package/@cds-models/odatano/cardano/index.d.ts +316 -0
  10. package/@cds-models/odatano/cardano/index.js +33 -0
  11. package/README.md +195 -136
  12. package/db/schema.cds +2121 -1633
  13. package/package.json +179 -173
  14. package/src/index.d.ts +10 -10
  15. package/src/index.js +24 -14
  16. package/src/plugin.js +39 -52
  17. package/srv/blockchain/backends/blockfrost-backend.d.ts +29 -131
  18. package/srv/blockchain/backends/blockfrost-backend.js +45 -158
  19. package/srv/blockchain/backends/cardano-backend.d.ts +78 -158
  20. package/srv/blockchain/backends/cardano-backend.js +14 -5
  21. package/srv/blockchain/backends/koios-backend.d.ts +126 -60
  22. package/srv/blockchain/backends/koios-backend.js +292 -202
  23. package/srv/blockchain/backends/ogmios-backend.d.ts +59 -96
  24. package/srv/blockchain/backends/ogmios-backend.js +241 -153
  25. package/srv/blockchain/backends/ogmios-frame-guard.d.ts +32 -0
  26. package/srv/blockchain/backends/ogmios-frame-guard.js +142 -0
  27. package/srv/blockchain/cardano-client.d.ts +50 -205
  28. package/srv/blockchain/cardano-client.js +80 -224
  29. package/srv/blockchain/cardano-indexer.d.ts +146 -244
  30. package/srv/blockchain/cardano-indexer.js +442 -285
  31. package/srv/blockchain/cardano-tx-builder.d.ts +19 -84
  32. package/srv/blockchain/cardano-tx-builder.js +21 -107
  33. package/srv/blockchain/crawler/certificate-backfill.d.ts +45 -0
  34. package/srv/blockchain/crawler/certificate-backfill.js +150 -0
  35. package/srv/blockchain/crawler/crawler.d.ts +121 -53
  36. package/srv/blockchain/crawler/crawler.js +402 -82
  37. package/srv/blockchain/crawler/hooks.d.ts +3 -14
  38. package/srv/blockchain/crawler/index.d.ts +5 -0
  39. package/srv/blockchain/crawler/index.js +35 -7
  40. package/srv/blockchain/crawler/sync-state.d.ts +44 -28
  41. package/srv/blockchain/crawler/sync-state.js +115 -43
  42. package/srv/blockchain/crawler/utxo-set-import.d.ts +69 -0
  43. package/srv/blockchain/crawler/utxo-set-import.js +269 -0
  44. package/srv/blockchain/ledger-state.d.ts +80 -0
  45. package/srv/blockchain/ledger-state.js +383 -0
  46. package/srv/blockchain/signing/cose-verifier.d.ts +5 -12
  47. package/srv/blockchain/signing/cose-verifier.js +6 -12
  48. package/srv/blockchain/signing/external-signer.d.ts +16 -113
  49. package/srv/blockchain/signing/external-signer.js +19 -122
  50. package/srv/blockchain/signing/hsm-signer.d.ts +13 -45
  51. package/srv/blockchain/signing/hsm-signer.js +23 -63
  52. package/srv/blockchain/signing/signature-verifier.d.ts +8 -44
  53. package/srv/blockchain/signing/signature-verifier.js +13 -54
  54. package/srv/blockchain/signing/submission-finalizer.d.ts +9 -36
  55. package/srv/blockchain/signing/submission-finalizer.js +16 -48
  56. package/srv/blockchain/transaction-building/buildooor-tx.d.ts +71 -160
  57. package/srv/blockchain/transaction-building/buildooor-tx.js +185 -260
  58. package/srv/blockchain/transaction-building/cardano-tx.d.ts +8 -34
  59. package/srv/blockchain/wallet-worker/build-request.d.ts +4 -17
  60. package/srv/blockchain/wallet-worker/build-request.js +39 -23
  61. package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +25 -17
  62. package/srv/blockchain/wallet-worker/confirmation-tracker.js +87 -41
  63. package/srv/blockchain/wallet-worker/index.js +2 -8
  64. package/srv/blockchain/wallet-worker/job-store.d.ts +36 -103
  65. package/srv/blockchain/wallet-worker/job-store.js +0 -0
  66. package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +4 -20
  67. package/srv/blockchain/wallet-worker/lease-heartbeat.js +4 -20
  68. package/srv/blockchain/wallet-worker/signers.d.ts +6 -19
  69. package/srv/blockchain/wallet-worker/signers.js +3 -8
  70. package/srv/blockchain/wallet-worker/wallet-worker.d.ts +15 -71
  71. package/srv/blockchain/wallet-worker/wallet-worker.js +34 -90
  72. package/srv/cardano-agent-service.cds +146 -0
  73. package/srv/cardano-agent-service.d.ts +2 -0
  74. package/srv/cardano-agent-service.js +12 -0
  75. package/srv/cardano-indexer-service.cds +164 -73
  76. package/srv/cardano-indexer-service.js +156 -11
  77. package/srv/cardano-service.cds +45 -0
  78. package/srv/cardano-service.js +38 -96
  79. package/srv/cardano-sign-service.cds +200 -180
  80. package/srv/cardano-sign-service.js +55 -173
  81. package/srv/cardano-tx-service.cds +32 -26
  82. package/srv/cardano-tx-service.js +133 -195
  83. package/srv/cardano-worker-service.js +7 -15
  84. package/srv/server.d.ts +28 -86
  85. package/srv/server.js +95 -128
  86. package/srv/utils/agent-grants-config.d.ts +37 -0
  87. package/srv/utils/agent-grants-config.js +138 -0
  88. package/srv/utils/agent-grants.d.ts +262 -0
  89. package/srv/utils/agent-grants.js +914 -0
  90. package/srv/utils/agent-token-auth.d.ts +16 -0
  91. package/srv/utils/agent-token-auth.js +78 -0
  92. package/srv/utils/backend-request-handler.d.ts +2 -16
  93. package/srv/utils/backend-request-handler.js +3 -18
  94. package/srv/utils/collections.d.ts +4 -8
  95. package/srv/utils/collections.js +4 -8
  96. package/srv/utils/const.d.ts +19 -68
  97. package/srv/utils/const.js +20 -69
  98. package/srv/utils/crypto.d.ts +3 -12
  99. package/srv/utils/crypto.js +5 -18
  100. package/srv/utils/db-indexes.d.ts +25 -0
  101. package/srv/utils/db-indexes.js +89 -0
  102. package/srv/utils/db-sanitize.d.ts +27 -0
  103. package/srv/utils/db-sanitize.js +85 -0
  104. package/srv/utils/error-codes.d.ts +18 -73
  105. package/srv/utils/error-codes.js +17 -70
  106. package/srv/utils/errors.d.ts +34 -178
  107. package/srv/utils/errors.js +55 -217
  108. package/srv/utils/liveness.d.ts +16 -0
  109. package/srv/utils/liveness.js +41 -0
  110. package/srv/utils/mappers.d.ts +82 -210
  111. package/srv/utils/mappers.js +272 -293
  112. package/srv/utils/network-context.js +2 -11
  113. package/srv/utils/pg-order-nulls.d.ts +14 -0
  114. package/srv/utils/pg-order-nulls.js +57 -0
  115. package/srv/utils/plutus-placeholders.d.ts +6 -18
  116. package/srv/utils/plutus-placeholders.js +6 -20
  117. package/srv/utils/rate-limiter.d.ts +46 -0
  118. package/srv/utils/rate-limiter.js +116 -0
  119. package/srv/utils/service-events.d.ts +2 -22
  120. package/srv/utils/service-events.js +3 -23
  121. package/srv/utils/signing-helper.d.ts +3 -18
  122. package/srv/utils/signing-helper.js +10 -32
  123. package/srv/utils/tx-build-helper.d.ts +18 -92
  124. package/srv/utils/tx-build-helper.js +32 -123
  125. package/srv/utils/tx-request-parsers.d.ts +14 -20
  126. package/srv/utils/tx-request-parsers.js +33 -20
  127. package/srv/utils/tx-utils.d.ts +4 -23
  128. package/srv/utils/tx-utils.js +12 -41
  129. package/srv/utils/types.d.ts +112 -169
  130. package/srv/utils/types.js +2 -6
  131. package/srv/utils/validators.d.ts +19 -89
  132. package/srv/utils/validators.js +31 -138
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Guard for Ogmios chain-sync frames the client's `safeJSON.parse` cannot handle: it recurses per
3
+ * nesting level, so a deeply nested native script overflows the stack inside an un-awaited socket
4
+ * handler and ends the process. On RangeError fall back to iterative `JSON.parse` (big ints as strings).
5
+ */
6
+ import { safeJSON } from '@cardano-ogmios/client';
7
+ /** A frame the guard could not turn into an object at all. */
8
+ export interface UnparseableFrame {
9
+ /** Block height, when it could be read off the raw text; null when even that failed. */
10
+ height: number | null;
11
+ /** Block id (hash), when readable. */
12
+ id: string | null;
13
+ reason: string;
14
+ bytes: number;
15
+ }
16
+ /**
17
+ * Wrap integers outside the safe double range in JSON strings so plain `JSON.parse` cannot
18
+ * round them. One linear pass, no recursion; digits inside strings, floats and exponents
19
+ * are left alone.
20
+ */
21
+ export declare function widenBigIntegers(text: string): string;
22
+ /**
23
+ * Wrap `safeJSON.parse` once per process and register a report callback; returns its
24
+ * unregister function. The parser is shared by every open chain-sync socket and cannot tell
25
+ * which one a frame came from, so an unusable frame goes to every registered callback.
26
+ * After a reported frame the stream stalls (the client drops non-nextBlock responses),
27
+ * so the caller decides what happens next.
28
+ */
29
+ export declare function installOgmiosFrameGuard(onUnparseableFrame: (frame: UnparseableFrame) => void): () => void;
30
+ /** Tests only — drop the wrapper so each case starts from the untouched client. */
31
+ export declare function resetOgmiosFrameGuardForTests(originalParse?: typeof safeJSON.parse): void;
32
+ //# sourceMappingURL=ogmios-frame-guard.d.ts.map
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.widenBigIntegers = widenBigIntegers;
7
+ exports.installOgmiosFrameGuard = installOgmiosFrameGuard;
8
+ exports.resetOgmiosFrameGuardForTests = resetOgmiosFrameGuardForTests;
9
+ /**
10
+ * Guard for Ogmios chain-sync frames the client's `safeJSON.parse` cannot handle: it recurses per
11
+ * nesting level, so a deeply nested native script overflows the stack inside an un-awaited socket
12
+ * handler and ends the process. On RangeError fall back to iterative `JSON.parse` (big ints as strings).
13
+ */
14
+ const client_1 = require("@cardano-ogmios/client");
15
+ const cds_1 = __importDefault(require("@sap/cds"));
16
+ const logger = cds_1.default.log('OgmiosFrameGuard');
17
+ /**
18
+ * Wrap integers outside the safe double range in JSON strings so plain `JSON.parse` cannot
19
+ * round them. One linear pass, no recursion; digits inside strings, floats and exponents
20
+ * are left alone.
21
+ */
22
+ function widenBigIntegers(text) {
23
+ const SAFE_DIGITS = String(Number.MAX_SAFE_INTEGER).length; // 16
24
+ let out = '';
25
+ let last = 0;
26
+ let inString = false;
27
+ let escaped = false;
28
+ for (let i = 0; i < text.length; i++) {
29
+ const c = text[i];
30
+ if (inString) {
31
+ if (escaped)
32
+ escaped = false;
33
+ else if (c === '\\')
34
+ escaped = true;
35
+ else if (c === '"')
36
+ inString = false;
37
+ continue;
38
+ }
39
+ if (c === '"') {
40
+ inString = true;
41
+ continue;
42
+ }
43
+ // a number literal starts here only after a structural character
44
+ if (c !== '-' && (c < '0' || c > '9'))
45
+ continue;
46
+ const prev = text[i - 1];
47
+ if (prev !== ':' && prev !== ',' && prev !== '[' && prev !== ' ' && prev !== '\n' && prev !== '\t' && prev !== '\r')
48
+ continue;
49
+ let j = i;
50
+ if (text[j] === '-')
51
+ j++;
52
+ const digitsFrom = j;
53
+ while (j < text.length && text[j] >= '0' && text[j] <= '9')
54
+ j++;
55
+ const digits = j - digitsFrom;
56
+ if (digits === 0)
57
+ continue;
58
+ // a fraction or exponent means it was never an exact integer — leave it alone
59
+ const after = text[j];
60
+ if (after === '.' || after === 'e' || after === 'E') {
61
+ i = j;
62
+ continue;
63
+ }
64
+ if (digits >= SAFE_DIGITS) {
65
+ const literal = text.slice(i, j);
66
+ if (!Number.isSafeInteger(Number(literal))) {
67
+ out += text.slice(last, i) + '"' + literal + '"';
68
+ last = j;
69
+ }
70
+ }
71
+ i = j - 1;
72
+ }
73
+ return last === 0 ? text : out + text.slice(last);
74
+ }
75
+ /** Block height/id from the front of an unparseable frame, to name the block in logs and `lastError`. */
76
+ function readBlockHeader(text) {
77
+ const head = text.slice(0, 4096);
78
+ const id = /"id"\s*:\s*"([0-9a-fA-F]{64})"/.exec(head);
79
+ const height = /"height"\s*:\s*(\d{1,15})/.exec(head);
80
+ return { height: height ? Number(height[1]) : null, id: id ? id[1] : null };
81
+ }
82
+ let installed = false;
83
+ const reporters = new Set();
84
+ /**
85
+ * Wrap `safeJSON.parse` once per process and register a report callback; returns its
86
+ * unregister function. The parser is shared by every open chain-sync socket and cannot tell
87
+ * which one a frame came from, so an unusable frame goes to every registered callback.
88
+ * After a reported frame the stream stalls (the client drops non-nextBlock responses),
89
+ * so the caller decides what happens next.
90
+ */
91
+ function installOgmiosFrameGuard(onUnparseableFrame) {
92
+ reporters.add(onUnparseableFrame);
93
+ const unregister = () => { reporters.delete(onUnparseableFrame); };
94
+ if (installed)
95
+ return unregister;
96
+ const original = client_1.safeJSON.parse.bind(client_1.safeJSON);
97
+ installed = true; // only once the original is safely in hand
98
+ client_1.safeJSON.parse = (raw) => {
99
+ try {
100
+ return original(raw);
101
+ }
102
+ catch (err) {
103
+ if (!(err instanceof RangeError))
104
+ throw err; // a genuine syntax error stays a syntax error
105
+ const text = String(raw);
106
+ const where = readBlockHeader(text);
107
+ try {
108
+ const parsed = JSON.parse(widenBigIntegers(text));
109
+ logger.warn(`chain-sync frame too deeply nested for the client's parser (block ${where.height ?? '?'} ` +
110
+ `${where.id ?? ''}, ${text.length} bytes) — parsed without it. Integers beyond 2^53 are ` +
111
+ `strings on this path; the chain-sync mapper stringifies them anyway.`);
112
+ return parsed;
113
+ }
114
+ catch (fallbackErr) {
115
+ const reason = fallbackErr instanceof Error ? fallbackErr.message : String(fallbackErr);
116
+ logger.error(`chain-sync frame unparseable (block ${where.height ?? '?'} ${where.id ?? ''}, ` +
117
+ `${text.length} bytes): ${reason}`);
118
+ const frame = { ...where, reason, bytes: text.length };
119
+ for (const r of [...reporters]) {
120
+ try {
121
+ r(frame);
122
+ }
123
+ catch (cbErr) {
124
+ logger.error('frame guard report callback failed:', cbErr);
125
+ }
126
+ }
127
+ // Never throw: this runs in an async socket handler nobody awaits, so a throw
128
+ // becomes an unhandled rejection and ends the process.
129
+ return {};
130
+ }
131
+ }
132
+ };
133
+ return unregister;
134
+ }
135
+ /** Tests only — drop the wrapper so each case starts from the untouched client. */
136
+ function resetOgmiosFrameGuardForTests(originalParse) {
137
+ if (originalParse)
138
+ client_1.safeJSON.parse = originalParse;
139
+ installed = false;
140
+ reporters.clear();
141
+ }
142
+ //# sourceMappingURL=ogmios-frame-guard.js.map
@@ -1,4 +1,4 @@
1
- import { ChainSyncBackend, PaginatingBackend } from './backends/cardano-backend';
1
+ import { ChainSyncBackend, PaginatingBackend, EnumeratingBackend, LedgerStateBackend } from './backends/cardano-backend';
2
2
  import { type CircuitBreakerConfig } from './circuit-breaker';
3
3
  import { Transaction, Address, UTxO, NetworkInformation, BlockData, EpochData, MetadataLabelTx, PoolData, DrepData, AccountData, AssetInfo, AssetHistoryEntry, LedgerProtocolParameters, ScriptEvaluationResult } from '../utils/types';
4
4
  export type Network = 'mainnet' | 'preview' | 'preprod';
@@ -18,12 +18,8 @@ export type CardanoClientConfig = {
18
18
  circuitBreaker?: Partial<CircuitBreakerConfig>;
19
19
  };
20
20
  /**
21
- * CardanoClient - Smart Multi-backend Cardano Client
22
- *
23
- * Routes requests to appropriate backends:
24
- * - Live/State queries → Ogmios (if available)
25
- * - Historical queries → Blockfrost/Koios (if available)
26
- * - Automatic fallback between backends
21
+ * Multi-backend Cardano client: live/state queries prefer Ogmios, historical queries prefer
22
+ * Blockfrost/Koios, with automatic fallback between them.
27
23
  */
28
24
  export declare class CardanoClient {
29
25
  private config;
@@ -42,45 +38,28 @@ export declare class CardanoClient {
42
38
  private txCoalescer;
43
39
  private addrCoalescer;
44
40
  private credCoalescer;
45
- /**
46
- * Constructor for CardanoClient
47
- * @param liveBackend - Optional backend for live/state queries (typically Ogmios)
48
- * @param historicalBackends - Optional backends for historical queries (typically Blockfrost/Koios)
49
- */
41
+ /** Builds the configured backends; throws ConfigError when none is configured. */
50
42
  constructor(clientConfig: CardanoClientConfig);
51
43
  /** Names of the configured backends (live + historical), for status reporting. */
52
44
  listBackends(): string[];
53
45
  /**
54
- * Ensure backends are initialized.
55
- * A REJECTED init promise is cleared so the next request retries — previously
56
- * a transient startup failure (e.g. Ogmios briefly down) left the client
57
- * permanently broken until process restart.
58
- * @returns {Promise<void>}
46
+ * Ensure backends are initialized. A rejected init promise is cleared so the next request
47
+ * retries instead of leaving the client permanently broken.
59
48
  */
60
49
  private ensureInitialized;
61
50
  /**
62
- * Transient (retryable) init failures: a backend momentarily unreachable at
63
- * startup — e.g. Ogmios's /health response cut short while the node processes
64
- * a freshly-arrived block ("Premature close"), or the socket still coming up
65
- * (ECONNREFUSED). Config/validation errors are NOT transient.
51
+ * Transient (retryable) init failures: a backend momentarily unreachable at startup
52
+ * (connection refused/reset, a cut-short health response). Config/validation errors are not.
66
53
  */
67
54
  private static isTransientInitError;
68
55
  /**
69
- * Init a backend, retrying brief transient failures. Deliberately SMALL: the
70
- * integration suites bootstrap under a 20s cds.test() hook, so total retry
71
- * time must stay well under it (≤3 attempts × 4s init-timeout + 1s backoff
72
- * ≈ 14s worst case; in practice "Premature close" returns sub-second). With
73
- * the node at tip these failures are momentary block-processing blips, so a
74
- * couple of quick retries ride over them; a sustained outage still fails fast.
56
+ * Init a backend, retrying brief transient failures. Kept small (3 attempts, 1 s backoff) so
57
+ * a sustained outage still fails fast and the total stays under the test bootstrap hook.
75
58
  */
76
59
  private initBackendWithRetry;
77
60
  /**
78
- * Initialize all backends from configuration.
79
- * Backends that fail to initialize are KEPT (previously removed permanently)
80
- * and tracked in `uninitializedBackends` — the request loops retry their
81
- * init lazily, so a backend that comes back online recovers without a
82
- * process restart. The circuit breaker bounds the retry cost.
83
- * @returns {Promise<void>}
61
+ * Initialize all backends. Backends whose init fails stay in rotation, tracked in
62
+ * `uninitializedBackends`, and are retried lazily per request (bounded by the circuit breaker).
84
63
  */
85
64
  private initBackends;
86
65
  /**
@@ -89,226 +68,92 @@ export declare class CardanoClient {
89
68
  * retry failed.
90
69
  */
91
70
  private ensureBackendInitialized;
92
- /**
93
- * Wrap a promise with a timeout
94
- * @param promise - the promise to wrap
95
- * @param ms - timeout in milliseconds
96
- * @param backendName - name of the backend (for error context)
97
- * @returns {Promise<T>} the result of the promise or a timeout error
98
- */
71
+ /** Wrap a promise with a timeout that rejects with ProviderUnavailableError. */
99
72
  private withTimeout;
100
- /**
101
- * Get timeout for specific backend
102
- * @param backend CardanoBackend instance
103
- * @returns {number} timeout in milliseconds
104
- */
73
+ /** Per-backend timeout: Koios gets the fallback timeout, everything else the primary one. */
105
74
  private getTimeoutForBackend;
106
75
  /**
107
- * Run a single-backend call with the same resilience contract as
108
- * executeWithPriority: circuit-breaker gate, timeout, success/failure
109
- * recording (4xx exempt). For the paths that cannot fail over (Koios-only,
110
- * Ogmios-only, batch-capable loops) — these previously bypassed timeout AND
111
- * breaker entirely, so a hanging socket blocked the caller indefinitely.
76
+ * Single-backend call with the executeWithPriority resilience contract (breaker gate, timeout,
77
+ * success/failure recording, 4xx exempt) for paths that cannot fail over.
112
78
  */
113
79
  private callWithResilience;
114
- /**
115
- * Execute with priority-based backend selection and automatic fallback
116
- * @param fn function to execute on backend
117
- * @param preferLive whether to prefer live backend over historical
118
- * @returns {Promise<T>} result from backend
119
- */
80
+ /** Execute on backends in preference order (live vs historical) with automatic fallback. */
120
81
  private executeWithPriority;
121
- /**
122
- * Route method call to appropriate backend based on method routing configuration
123
- * @param methodName name of the method being called
124
- * @param fn function to execute on backend
125
- * @returns {Promise<T>} result from backend
126
- */
82
+ /** Route a call by METHOD_ROUTING (default: historical first). */
127
83
  private route;
128
- /**
129
- * Get transaction by hash with fallback between backends
130
- * @param txHash transaction hash (hex)
131
- * @returns {Promise<Transaction>} transaction data
132
- */
84
+ /** Transaction by hash (coalesced across concurrent callers). */
133
85
  getTransaction(txHash: string): Promise<Transaction>;
134
- /**
135
- * Get address by bech32 address with fallback between backends
136
- * @param address bech32 address
137
- * @returns {Promise<Address>} address data
138
- */
86
+ /** Address data (coalesced across concurrent callers). */
139
87
  getAddress(address: string): Promise<Address>;
140
- /**
141
- * Get address UTxOs with fallback between backends
142
- * @param address bech32 address
143
- * @returns {Promise<UTxO[]>} list of UTxOs
144
- */
145
88
  getAddressUtxos(address: string): Promise<UTxO[]>;
146
89
  /**
147
- * Get UTxOs by 28-byte payment credential. Koios-only — bypasses generic
148
- * failover because no other backend exposes a credential-keyed UTxO endpoint.
149
- * Throws ProviderUnavailableError if Koios is not configured.
150
- * @param credHash 28-byte payment credential as 56-char lowercase hex
151
- * @returns {Promise<UTxO[]>} list of UTxOs across all bech32 forms sharing the credential
90
+ * UTxOs by 28-byte payment credential (56-char hex), across all bech32 forms sharing it.
91
+ * Koios-only: no other backend has a credential-keyed endpoint, so this throws without Koios.
152
92
  */
153
93
  getCredentialUtxos(credHash: string): Promise<UTxO[]>;
154
- /**
155
- * Get address transactions with fallback between backends
156
- * @param address bech32 address
157
- * @returns {Promise<Transaction[]>} list of transactions for this address
158
- */
159
94
  getAddressTransactions(address: string, limit: number): Promise<Transaction[]>;
160
- /**
161
- * Get network information with fallback between backends
162
- * @returns {Promise<Network>} network information
163
- */
164
95
  getNetworkInformation(): Promise<NetworkInformation>;
165
- /**
166
- * Get transaction metadata with fallback between backends
167
- * @param tx_hash transaction hash (hex)
168
- * @returns {Promise<MetadataLabelTx[]>} transaction metadata
169
- */
170
96
  getTransactionMetadata(tx_hash: string): Promise<MetadataLabelTx[]>;
171
- /**
172
- * Get block data with fallback between backends
173
- * @param block_hash block hash (hex)
174
- * @returns {Promise<BlockData>} block data
175
- */
176
97
  getBlock(block_hash: string): Promise<BlockData>;
177
- /**
178
- * Get epoch data with fallback between backends
179
- * @param epochNumber epoch number
180
- * @returns {Promise<EpochData>} epoch data
181
- */
182
98
  getEpoch(epochNumber: number): Promise<EpochData>;
183
- /**
184
- * Get Pool data with fallback between backends
185
- * @param poolId pool id
186
- * @returns {Promise<PoolData>} pool data
187
- */
188
99
  getPool(poolId: string): Promise<PoolData>;
189
- /**
190
- * Get drep data with fallback between backends
191
- * @param drepId drep id
192
- * @returns {Promise<DrepData>} drep data
193
- */
194
100
  getDrep(drepId: string): Promise<DrepData>;
195
- /**
196
- * Get account data with fallback between backends
197
- * @param stakeAddress stake address
198
- * @returns {Promise<AccountData>} account data
199
- */
200
101
  getAccount(stakeAddress: string): Promise<AccountData>;
201
- /**
202
- * Get asset info (supply, mint history, CIP-25 + CIP-26 metadata) with fallback.
203
- * Both Blockfrost and Koios implement; Ogmios throws "not supported".
204
- * @param unit policyId + assetNameHex (concatenated hex)
205
- * @returns {Promise<AssetInfo>} canonical asset info
206
- */
102
+ /** Asset info (supply, mint history, CIP-25/CIP-26 metadata); Blockfrost and Koios only. */
207
103
  getAssetInfo(unit: string): Promise<AssetInfo>;
208
104
  /**
209
- * Get latest mint/burn events for an asset. Prefers Koios because it provides
210
- * block timestamps; Blockfrost is the fallback (timestamps left null).
211
- * Ogmios doesn't implement — fallback skips it via the optional method check.
212
- * @param unit policyId + assetNameHex (concatenated hex)
213
- * @param limit max number of events (default 100)
214
- * @returns {Promise<AssetHistoryEntry[]>} list of mint/burn events (most recent first)
105
+ * Latest mint/burn events for an asset, most recent first. Prefers Koios (block timestamps);
106
+ * Blockfrost is the fallback with timestamps left null.
215
107
  */
216
108
  getAssetHistory(unit: string, limit?: number): Promise<AssetHistoryEntry[]>;
217
109
  /**
218
- * Get transaction hashes for an address (lightweight — no full tx details).
219
- * Uses getAddressTransactionHashes() if backend supports it, otherwise
220
- * falls back to getAddressTransactions() and extracts hashes.
221
- * @param address bech32 address
222
- * @param limit maximum number of hashes
223
- * @returns {Promise<string[]>} list of transaction hashes
110
+ * Transaction hashes for an address; falls back to a full getAddressTransactions when no
111
+ * backend supports the lightweight listing.
224
112
  */
225
113
  getAddressTransactionHashes(address: string, limit: number): Promise<string[]>;
226
- /**
227
- * Batch fetch multiple transactions by hash.
228
- * Uses getTransactionsBatch() if backend supports it, otherwise
229
- * falls back to individual getTransaction() calls (still coalesced).
230
- * @param txHashes array of transaction hashes
231
- * @returns {Promise<Map<string, Transaction>>} map of hash -> Transaction
232
- */
114
+ /** Batch fetch transactions by hash; falls back to individual coalesced getTransaction calls. */
233
115
  getTransactionsBatch(txHashes: string[]): Promise<Map<string, Transaction>>;
234
- /**
235
- * Backends in historical-first order. Used by the batch methods — both
236
- * always prefer historical data, so the former preferLive parameter was a
237
- * dead branch.
238
- */
116
+ /** Backends in historical-first order, for the batch methods. */
239
117
  private getOrderedBackends;
240
118
  /**
241
- * Get a backend that supports streamed chain-synchronization (Ogmios), or null.
242
- * The crawler's primary, reorg-aware source. Checks the live backend first.
243
- * Backends whose init() failed are skipped — the crawler uses these instances
244
- * DIRECTLY (outside executeWithPriority's lazy-retry/breaker), so handing out an
245
- * uninitialized backend would wedge it.
119
+ * A backend that supports streamed chain-sync (Ogmios), or null. Backends whose init failed
120
+ * are skipped: the crawler uses these instances directly, outside the lazy-retry/breaker path.
246
121
  */
247
122
  getChainSyncBackend(): ChainSyncBackend | null;
248
123
  /**
249
- * Get a backend that can be walked forward by pagination (Blockfrost/Koios), or null.
250
- * The crawler's fallback source when no Ogmios chain-sync is available.
251
- * Skips backends whose init() failed (see getChainSyncBackend).
252
- *
253
- * Koios is preferred over Blockfrost for bulk block-crawling: Koios batches 100 txs
254
- * per POST /tx_info, while Blockfrost has no batch endpoint (~3 HTTP calls per tx) —
255
- * roughly a 40x difference in request volume per crawled block.
124
+ * getChainSyncBackend(), retrying a failed startup init. Polled by the crawler while it runs
125
+ * on pagination because no chain-sync source was usable when it started.
256
126
  */
257
- getPaginatingBackend(): PaginatingBackend | null;
127
+ recoverChainSyncBackend(): Promise<ChainSyncBackend | null>;
128
+ /** The first usable backend that can dump the UTxO set at a point (Ogmios) — crawler.utxoSet import. */
129
+ getLedgerStateBackend(): LedgerStateBackend | null;
258
130
  /**
259
- * Get protocol parameters with caching (5 minute TTL)
260
- * Protocol parameters rarely change (once per epoch at most), so caching improves performance
261
- * @returns {Promise<LedgerProtocolParameters>} protocol parameters
131
+ * A backend that can enumerate the full pool/DRep set (Koios), or null; without one the epoch
132
+ * snapshots stay off instead of degrading into thousands of single requests.
262
133
  */
263
- getProtocolParameters(): Promise<LedgerProtocolParameters>;
134
+ getEnumeratingBackend(): EnumeratingBackend | null;
264
135
  /**
265
- * Shutdown all backends (for cleanup in tests)
136
+ * A backend that can be walked forward by pagination (Blockfrost/Koios), or null. Koios is
137
+ * preferred: it batches 100 txs per call, Blockfrost needs ~3 calls per tx.
266
138
  */
139
+ getPaginatingBackend(): PaginatingBackend | null;
140
+ /** Protocol parameters with a 5-minute in-memory cache and coalesced refresh. */
141
+ getProtocolParameters(): Promise<LedgerProtocolParameters>;
142
+ /** Shut down all backends. */
267
143
  shutdown(): Promise<void>;
268
- /**
269
- * Get latest block data with fallback between backends
270
- * @returns {Promise<BlockData>} latest block data
271
- */
272
144
  getLatestBlock(): Promise<BlockData>;
273
- /**
274
- * Get latest epoch data with fallback between backends
275
- * @returns {Promise<EpochData>} latest epoch data
276
- */
277
145
  getLatestEpoch(): Promise<EpochData>;
278
- /**
279
- * Get the current chain slot with fallback between backends.
280
- * @returns {Promise<number>} current chain slot
281
- */
282
146
  getCurrentSlot(): Promise<number>;
283
- /**
284
- * Check whether a UTxO is still unspent with fallback between backends.
285
- * @param txHash 64-char lowercase hex transaction hash
286
- * @param outputIndex non-negative integer output index
287
- * @returns {Promise<boolean>} true iff the UTxO exists and is unspent
288
- */
147
+ /** True iff the UTxO exists and is unspent. */
289
148
  isUtxoUnspent(txHash: string, outputIndex: number): Promise<boolean>;
290
149
  /**
291
- * Submit transaction with fallback between backends
292
- * @param signedTxCbor signed transaction in CBOR hex format
293
- * @returns {Promise<string>} transaction hash
294
- *
295
- * NOTE on failover semantics: when the preferred backend ACCEPTS the tx but
296
- * its response is lost (timeout), the failover resubmits on the next backend,
297
- * which may answer 409 "already submitted". Callers should treat a
298
- * TransactionAlreadySubmittedError after a submit attempt as success — the
299
- * transaction IS in the mempool.
150
+ * Submit a signed transaction (CBOR hex); returns its hash. On failover after a lost response
151
+ * the next backend may answer 409 "already submitted" — callers treat that as success.
300
152
  */
301
153
  submitTransaction(signedTxCbor: string): Promise<string>;
302
- /**
303
- * Check if Ogmios backend is available for transaction evaluation
304
- * @returns {boolean} true if Ogmios is the live backend
305
- */
154
+ /** True when Ogmios is the live backend (script evaluation available). */
306
155
  hasOgmiosBackend(): boolean;
307
- /**
308
- * Evaluate transaction script execution units (Ogmios only)
309
- * @param unsignedTxCbor unsigned transaction in CBOR hex format
310
- * @returns {Promise<ScriptEvaluationResult[]>} evaluation results
311
- */
156
+ /** Evaluate script execution units of an unsigned transaction (Ogmios only). */
312
157
  evaluateTransaction(unsignedTxCbor: string): Promise<ScriptEvaluationResult[]>;
313
158
  }
314
159
  //# sourceMappingURL=cardano-client.d.ts.map