@odatano/core 2.0.0-rc.19 → 2.0.0-rc.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@cds-models/CardanoAgentService/index.d.ts +1 -5
- package/@cds-models/CardanoIndexerService/index.d.ts +51 -2
- package/@cds-models/CardanoIndexerService/index.js +7 -0
- package/package.json +1 -1
- package/src/index.d.ts +4 -10
- package/src/index.js +6 -16
- package/src/plugin.js +11 -27
- package/srv/blockchain/backends/blockfrost-backend.d.ts +29 -131
- package/srv/blockchain/backends/blockfrost-backend.js +39 -150
- package/srv/blockchain/backends/cardano-backend.d.ts +53 -171
- package/srv/blockchain/backends/cardano-backend.js +1 -5
- package/srv/blockchain/backends/koios-backend.d.ts +26 -71
- package/srv/blockchain/backends/koios-backend.js +50 -132
- package/srv/blockchain/backends/ogmios-backend.d.ts +43 -124
- package/srv/blockchain/backends/ogmios-backend.js +71 -179
- package/srv/blockchain/backends/ogmios-frame-guard.d.ts +12 -57
- package/srv/blockchain/backends/ogmios-frame-guard.js +27 -66
- package/srv/blockchain/cardano-client.d.ts +43 -216
- package/srv/blockchain/cardano-client.js +49 -234
- package/srv/blockchain/cardano-indexer.d.ts +79 -357
- package/srv/blockchain/cardano-indexer.js +98 -406
- package/srv/blockchain/cardano-tx-builder.d.ts +19 -84
- package/srv/blockchain/cardano-tx-builder.js +21 -107
- package/srv/blockchain/crawler/certificate-backfill.d.ts +45 -0
- package/srv/blockchain/crawler/certificate-backfill.js +150 -0
- package/srv/blockchain/crawler/crawler.d.ts +41 -145
- package/srv/blockchain/crawler/crawler.js +57 -172
- package/srv/blockchain/crawler/hooks.d.ts +3 -14
- package/srv/blockchain/crawler/index.d.ts +2 -6
- package/srv/blockchain/crawler/index.js +4 -9
- package/srv/blockchain/crawler/sync-state.d.ts +17 -39
- package/srv/blockchain/crawler/sync-state.js +23 -55
- package/srv/blockchain/crawler/utxo-set-import.d.ts +5 -22
- package/srv/blockchain/crawler/utxo-set-import.js +8 -28
- package/srv/blockchain/ledger-state.d.ts +3 -12
- package/srv/blockchain/signing/cose-verifier.d.ts +5 -12
- package/srv/blockchain/signing/cose-verifier.js +6 -12
- package/srv/blockchain/signing/external-signer.d.ts +16 -113
- package/srv/blockchain/signing/external-signer.js +19 -122
- package/srv/blockchain/signing/hsm-signer.d.ts +13 -45
- package/srv/blockchain/signing/hsm-signer.js +23 -63
- package/srv/blockchain/signing/signature-verifier.d.ts +8 -44
- package/srv/blockchain/signing/signature-verifier.js +13 -54
- package/srv/blockchain/signing/submission-finalizer.d.ts +9 -36
- package/srv/blockchain/signing/submission-finalizer.js +16 -48
- package/srv/blockchain/transaction-building/buildooor-tx.d.ts +65 -174
- package/srv/blockchain/transaction-building/buildooor-tx.js +107 -266
- package/srv/blockchain/transaction-building/cardano-tx.d.ts +8 -34
- package/srv/blockchain/wallet-worker/build-request.d.ts +4 -17
- package/srv/blockchain/wallet-worker/build-request.js +9 -22
- package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +12 -35
- package/srv/blockchain/wallet-worker/confirmation-tracker.js +16 -32
- package/srv/blockchain/wallet-worker/index.js +2 -8
- package/srv/blockchain/wallet-worker/job-store.d.ts +33 -111
- package/srv/blockchain/wallet-worker/job-store.js +0 -0
- package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +4 -20
- package/srv/blockchain/wallet-worker/lease-heartbeat.js +4 -20
- package/srv/blockchain/wallet-worker/signers.d.ts +6 -19
- package/srv/blockchain/wallet-worker/signers.js +3 -8
- package/srv/blockchain/wallet-worker/wallet-worker.d.ts +15 -71
- package/srv/blockchain/wallet-worker/wallet-worker.js +34 -90
- package/srv/cardano-agent-service.cds +1 -5
- package/srv/cardano-agent-service.js +3 -7
- package/srv/cardano-indexer-service.cds +32 -4
- package/srv/cardano-indexer-service.js +83 -15
- package/srv/cardano-service.js +36 -98
- package/srv/cardano-sign-service.cds +1 -1
- package/srv/cardano-sign-service.js +55 -173
- package/srv/cardano-tx-service.cds +1 -1
- package/srv/cardano-tx-service.js +54 -174
- package/srv/cardano-worker-service.js +7 -15
- package/srv/server.d.ts +27 -86
- package/srv/server.js +52 -148
- package/srv/utils/agent-grants-config.d.ts +11 -50
- package/srv/utils/agent-grants-config.js +12 -45
- package/srv/utils/agent-grants.d.ts +34 -123
- package/srv/utils/agent-grants.js +57 -156
- package/srv/utils/agent-token-auth.d.ts +2 -5
- package/srv/utils/agent-token-auth.js +2 -5
- package/srv/utils/backend-request-handler.d.ts +2 -16
- package/srv/utils/backend-request-handler.js +3 -18
- package/srv/utils/collections.d.ts +4 -8
- package/srv/utils/collections.js +4 -8
- package/srv/utils/const.d.ts +19 -68
- package/srv/utils/const.js +20 -69
- package/srv/utils/crypto.d.ts +3 -12
- package/srv/utils/crypto.js +5 -18
- package/srv/utils/db-indexes.d.ts +2 -7
- package/srv/utils/db-indexes.js +7 -34
- package/srv/utils/db-sanitize.d.ts +5 -18
- package/srv/utils/db-sanitize.js +6 -19
- package/srv/utils/error-codes.d.ts +18 -73
- package/srv/utils/error-codes.js +17 -70
- package/srv/utils/errors.d.ts +29 -191
- package/srv/utils/errors.js +44 -229
- package/srv/utils/liveness.d.ts +2 -9
- package/srv/utils/liveness.js +3 -11
- package/srv/utils/mappers.d.ts +50 -298
- package/srv/utils/mappers.js +80 -386
- package/srv/utils/network-context.js +2 -11
- package/srv/utils/pg-order-nulls.js +4 -23
- package/srv/utils/plutus-placeholders.d.ts +6 -18
- package/srv/utils/plutus-placeholders.js +6 -20
- package/srv/utils/rate-limiter.d.ts +6 -17
- package/srv/utils/rate-limiter.js +5 -15
- package/srv/utils/service-events.d.ts +2 -22
- package/srv/utils/service-events.js +3 -23
- package/srv/utils/signing-helper.d.ts +3 -18
- package/srv/utils/signing-helper.js +10 -32
- package/srv/utils/tx-build-helper.d.ts +18 -92
- package/srv/utils/tx-build-helper.js +32 -123
- package/srv/utils/tx-request-parsers.d.ts +7 -26
- package/srv/utils/tx-request-parsers.js +7 -26
- package/srv/utils/tx-utils.d.ts +4 -23
- package/srv/utils/tx-utils.js +12 -41
- package/srv/utils/types.d.ts +67 -206
- package/srv/utils/types.js +2 -6
- package/srv/utils/validators.d.ts +19 -89
- package/srv/utils/validators.js +31 -138
|
@@ -7,61 +7,17 @@ exports.widenBigIntegers = widenBigIntegers;
|
|
|
7
7
|
exports.installOgmiosFrameGuard = installOgmiosFrameGuard;
|
|
8
8
|
exports.resetOgmiosFrameGuardForTests = resetOgmiosFrameGuardForTests;
|
|
9
9
|
/**
|
|
10
|
-
* Guard
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* `sanitize(JSONBig.parse(raw))`. Both halves recurse once per nesting level: the
|
|
14
|
-
* `@cardanosolutions/json-bigint` parser is Crockford's recursive descent, and `sanitize`
|
|
15
|
-
* walks the parsed tree recursively. A native script nests one JSON object per clause, and
|
|
16
|
-
* nested clauses cost only a few bytes each in CBOR — so an ordinary-looking block can
|
|
17
|
-
* expand into JSON that is ten thousand levels deep and exhaust the V8 stack.
|
|
18
|
-
*
|
|
19
|
-
* That is not a theoretical shape. Preprod block 5183974 carries a native script nested
|
|
20
|
-
* 10 774 levels deep (`{"clause":"all","from":[ … ]}` down to a single signature clause).
|
|
21
|
-
* The block is 43 kB on chain and 205 kB as a chain-sync frame.
|
|
22
|
-
*
|
|
23
|
-
* The crash is fatal rather than merely annoying, because of where the parse happens
|
|
24
|
-
* (`ChainSynchronization/Client.js`):
|
|
25
|
-
*
|
|
26
|
-
* socket.on('message', async (message) => {
|
|
27
|
-
* await responseHandler(util_1.safeJSON.parse(message));
|
|
28
|
-
* });
|
|
29
|
-
*
|
|
30
|
-
* `safeJSON.parse` throws synchronously inside an `async` handler that nobody awaits, so
|
|
31
|
-
* the `RangeError` surfaces as an unhandled rejection and Node takes the process down. The
|
|
32
|
-
* crawler's poison-block latch cannot help: it guards the persist path, and the server is
|
|
33
|
-
* gone long before a block reaches it. Docker restarts, the crawler resumes at the same
|
|
34
|
-
* block, and the loop repeats — 53 restarts in seven minutes on the hosted box.
|
|
35
|
-
*
|
|
36
|
-
* This guard wraps `safeJSON.parse` (a public export of the client package) so that the
|
|
37
|
-
* fast path is untouched and only an overflowing frame takes the recovery route:
|
|
38
|
-
*
|
|
39
|
-
* 1. the original parser, so every ordinary frame keeps its exact BigInt handling;
|
|
40
|
-
* 2. on `RangeError`, `widenBigIntegers()` rewrites integer literals that a double cannot
|
|
41
|
-
* hold into JSON strings, then plain `JSON.parse` — V8's parser is iterative, so depth
|
|
42
|
-
* is no longer a limit. `sanitize` is skipped, because it would overflow on the very
|
|
43
|
-
* same structure;
|
|
44
|
-
* 3. if even that fails, the frame is reported to the caller and a sentinel is returned.
|
|
45
|
-
* The guard never throws, because throwing here is what kills the process.
|
|
46
|
-
*
|
|
47
|
-
* Measured against the real frame (node 22, 205 728 bytes, depth 10 774): json-bigint and
|
|
48
|
-
* `JSON.parse` with a reviver both overflow — a reviver walk is recursive too — while plain
|
|
49
|
-
* `JSON.parse` completes in 17 ms.
|
|
50
|
-
*
|
|
51
|
-
* Upstream: a recursive parser on untrusted chain data is a denial-of-service against every
|
|
52
|
-
* consumer of the client, mainnet included. This guard is a local mitigation, not the cure.
|
|
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).
|
|
53
13
|
*/
|
|
54
14
|
const client_1 = require("@cardano-ogmios/client");
|
|
55
15
|
const cds_1 = __importDefault(require("@sap/cds"));
|
|
56
16
|
const logger = cds_1.default.log('OgmiosFrameGuard');
|
|
57
17
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* Only numbers in value position are touched: digits inside strings (hashes, CBOR, asset
|
|
63
|
-
* names) are skipped, and so are floats and exponents, which are doubles by nature and have
|
|
64
|
-
* no exact integer to preserve.
|
|
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.
|
|
65
21
|
*/
|
|
66
22
|
function widenBigIntegers(text) {
|
|
67
23
|
const SAFE_DIGITS = String(Number.MAX_SAFE_INTEGER).length; // 16
|
|
@@ -116,11 +72,7 @@ function widenBigIntegers(text) {
|
|
|
116
72
|
}
|
|
117
73
|
return last === 0 ? text : out + text.slice(last);
|
|
118
74
|
}
|
|
119
|
-
/**
|
|
120
|
-
* Block header fields out of a frame we could not parse. They sit near the front of a
|
|
121
|
-
* chain-sync response and at shallow depth, so a narrow match finds them even when the
|
|
122
|
-
* body is unusable — enough to name the offending block in a log line and in `lastError`.
|
|
123
|
-
*/
|
|
75
|
+
/** Block height/id from the front of an unparseable frame, to name the block in logs and `lastError`. */
|
|
124
76
|
function readBlockHeader(text) {
|
|
125
77
|
const head = text.slice(0, 4096);
|
|
126
78
|
const id = /"id"\s*:\s*"([0-9a-fA-F]{64})"/.exec(head);
|
|
@@ -128,18 +80,19 @@ function readBlockHeader(text) {
|
|
|
128
80
|
return { height: height ? Number(height[1]) : null, id: id ? id[1] : null };
|
|
129
81
|
}
|
|
130
82
|
let installed = false;
|
|
83
|
+
const reporters = new Set();
|
|
131
84
|
/**
|
|
132
|
-
* Wrap `safeJSON.parse` once per process
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
* itself stalls, because the client drops anything that is not a nextBlock response.
|
|
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.
|
|
138
90
|
*/
|
|
139
91
|
function installOgmiosFrameGuard(onUnparseableFrame) {
|
|
140
|
-
|
|
92
|
+
reporters.add(onUnparseableFrame);
|
|
93
|
+
const unregister = () => { reporters.delete(onUnparseableFrame); };
|
|
141
94
|
if (installed)
|
|
142
|
-
return;
|
|
95
|
+
return unregister;
|
|
143
96
|
const original = client_1.safeJSON.parse.bind(client_1.safeJSON);
|
|
144
97
|
installed = true; // only once the original is safely in hand
|
|
145
98
|
client_1.safeJSON.parse = (raw) => {
|
|
@@ -162,20 +115,28 @@ function installOgmiosFrameGuard(onUnparseableFrame) {
|
|
|
162
115
|
const reason = fallbackErr instanceof Error ? fallbackErr.message : String(fallbackErr);
|
|
163
116
|
logger.error(`chain-sync frame unparseable (block ${where.height ?? '?'} ${where.id ?? ''}, ` +
|
|
164
117
|
`${text.length} bytes): ${reason}`);
|
|
165
|
-
|
|
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
|
+
}
|
|
166
127
|
// Never throw: this runs in an async socket handler nobody awaits, so a throw
|
|
167
128
|
// becomes an unhandled rejection and ends the process.
|
|
168
129
|
return {};
|
|
169
130
|
}
|
|
170
131
|
}
|
|
171
132
|
};
|
|
133
|
+
return unregister;
|
|
172
134
|
}
|
|
173
|
-
let report = () => { };
|
|
174
135
|
/** Tests only — drop the wrapper so each case starts from the untouched client. */
|
|
175
136
|
function resetOgmiosFrameGuardForTests(originalParse) {
|
|
176
137
|
if (originalParse)
|
|
177
138
|
client_1.safeJSON.parse = originalParse;
|
|
178
139
|
installed = false;
|
|
179
|
-
|
|
140
|
+
reporters.clear();
|
|
180
141
|
}
|
|
181
142
|
//# sourceMappingURL=ogmios-frame-guard.js.map
|
|
@@ -18,12 +18,8 @@ export type CardanoClientConfig = {
|
|
|
18
18
|
circuitBreaker?: Partial<CircuitBreakerConfig>;
|
|
19
19
|
};
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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.
|
|
70
|
-
*
|
|
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
|
|
79
|
-
*
|
|
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,244 +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
|
-
*
|
|
108
|
-
*
|
|
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
|
-
*
|
|
148
|
-
*
|
|
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
|
-
*
|
|
210
|
-
*
|
|
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
|
-
*
|
|
219
|
-
*
|
|
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
|
-
*
|
|
242
|
-
*
|
|
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
|
-
* getChainSyncBackend(),
|
|
250
|
-
*
|
|
251
|
-
* chain-sync source was usable when it started: on a box where the node and ODATANO
|
|
252
|
-
* restart together, the node's chunk validation and ledger replay routinely outlast
|
|
253
|
-
* ODATANO's startup, so Ogmios refuses the init once and is healthy minutes later.
|
|
254
|
-
* Without this the crawler would stay on pagination for the rest of the process.
|
|
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.
|
|
255
126
|
*/
|
|
256
127
|
recoverChainSyncBackend(): Promise<ChainSyncBackend | null>;
|
|
257
128
|
/** The first usable backend that can dump the UTxO set at a point (Ogmios) — crawler.utxoSet import. */
|
|
258
129
|
getLedgerStateBackend(): LedgerStateBackend | null;
|
|
259
130
|
/**
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
* thousands of single requests (see EnumeratingBackend).
|
|
263
|
-
* Skips backends whose init() failed (see getChainSyncBackend).
|
|
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.
|
|
264
133
|
*/
|
|
265
134
|
getEnumeratingBackend(): EnumeratingBackend | null;
|
|
266
135
|
/**
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
* Skips backends whose init() failed (see getChainSyncBackend).
|
|
270
|
-
*
|
|
271
|
-
* Koios is preferred over Blockfrost for bulk block-crawling: Koios batches 100 txs
|
|
272
|
-
* per POST /tx_info, while Blockfrost has no batch endpoint (~3 HTTP calls per tx) —
|
|
273
|
-
* roughly a 40x difference in request volume per crawled block.
|
|
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.
|
|
274
138
|
*/
|
|
275
139
|
getPaginatingBackend(): PaginatingBackend | null;
|
|
276
|
-
/**
|
|
277
|
-
* Get protocol parameters with caching (5 minute TTL)
|
|
278
|
-
* Protocol parameters rarely change (once per epoch at most), so caching improves performance
|
|
279
|
-
* @returns {Promise<LedgerProtocolParameters>} protocol parameters
|
|
280
|
-
*/
|
|
140
|
+
/** Protocol parameters with a 5-minute in-memory cache and coalesced refresh. */
|
|
281
141
|
getProtocolParameters(): Promise<LedgerProtocolParameters>;
|
|
282
|
-
/**
|
|
283
|
-
* Shutdown all backends (for cleanup in tests)
|
|
284
|
-
*/
|
|
142
|
+
/** Shut down all backends. */
|
|
285
143
|
shutdown(): Promise<void>;
|
|
286
|
-
/**
|
|
287
|
-
* Get latest block data with fallback between backends
|
|
288
|
-
* @returns {Promise<BlockData>} latest block data
|
|
289
|
-
*/
|
|
290
144
|
getLatestBlock(): Promise<BlockData>;
|
|
291
|
-
/**
|
|
292
|
-
* Get latest epoch data with fallback between backends
|
|
293
|
-
* @returns {Promise<EpochData>} latest epoch data
|
|
294
|
-
*/
|
|
295
145
|
getLatestEpoch(): Promise<EpochData>;
|
|
296
|
-
/**
|
|
297
|
-
* Get the current chain slot with fallback between backends.
|
|
298
|
-
* @returns {Promise<number>} current chain slot
|
|
299
|
-
*/
|
|
300
146
|
getCurrentSlot(): Promise<number>;
|
|
301
|
-
/**
|
|
302
|
-
* Check whether a UTxO is still unspent with fallback between backends.
|
|
303
|
-
* @param txHash 64-char lowercase hex transaction hash
|
|
304
|
-
* @param outputIndex non-negative integer output index
|
|
305
|
-
* @returns {Promise<boolean>} true iff the UTxO exists and is unspent
|
|
306
|
-
*/
|
|
147
|
+
/** True iff the UTxO exists and is unspent. */
|
|
307
148
|
isUtxoUnspent(txHash: string, outputIndex: number): Promise<boolean>;
|
|
308
149
|
/**
|
|
309
|
-
* Submit transaction
|
|
310
|
-
*
|
|
311
|
-
* @returns {Promise<string>} transaction hash
|
|
312
|
-
*
|
|
313
|
-
* NOTE on failover semantics: when the preferred backend ACCEPTS the tx but
|
|
314
|
-
* its response is lost (timeout), the failover resubmits on the next backend,
|
|
315
|
-
* which may answer 409 "already submitted". Callers should treat a
|
|
316
|
-
* TransactionAlreadySubmittedError after a submit attempt as success — the
|
|
317
|
-
* 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.
|
|
318
152
|
*/
|
|
319
153
|
submitTransaction(signedTxCbor: string): Promise<string>;
|
|
320
|
-
/**
|
|
321
|
-
* Check if Ogmios backend is available for transaction evaluation
|
|
322
|
-
* @returns {boolean} true if Ogmios is the live backend
|
|
323
|
-
*/
|
|
154
|
+
/** True when Ogmios is the live backend (script evaluation available). */
|
|
324
155
|
hasOgmiosBackend(): boolean;
|
|
325
|
-
/**
|
|
326
|
-
* Evaluate transaction script execution units (Ogmios only)
|
|
327
|
-
* @param unsignedTxCbor unsigned transaction in CBOR hex format
|
|
328
|
-
* @returns {Promise<ScriptEvaluationResult[]>} evaluation results
|
|
329
|
-
*/
|
|
156
|
+
/** Evaluate script execution units of an unsigned transaction (Ogmios only). */
|
|
330
157
|
evaluateTransaction(unsignedTxCbor: string): Promise<ScriptEvaluationResult[]>;
|
|
331
158
|
}
|
|
332
159
|
//# sourceMappingURL=cardano-client.d.ts.map
|