@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
|
@@ -1,183 +1,83 @@
|
|
|
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
|
-
*/
|
|
4
|
+
/** Backend name */
|
|
11
5
|
name: string;
|
|
12
6
|
/**
|
|
13
|
-
* Methods this backend declares as NOT supported
|
|
14
|
-
*
|
|
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.
|
|
7
|
+
* Methods this backend declares as NOT supported; the orchestrator skips it for
|
|
8
|
+
* these without counting a circuit-breaker failure.
|
|
18
9
|
*/
|
|
19
10
|
readonly unsupportedMethods?: ReadonlySet<string>;
|
|
20
|
-
/**
|
|
21
|
-
* Initialize the backend
|
|
22
|
-
*/
|
|
11
|
+
/** Initialize the backend */
|
|
23
12
|
init(): Promise<boolean>;
|
|
24
|
-
/**
|
|
25
|
-
* Get Transaction Data
|
|
26
|
-
* @param txHash transaction hash (hex)
|
|
27
|
-
* @returns {Promise<Transaction>} transaction data
|
|
28
|
-
*/
|
|
13
|
+
/** Transaction by hash (hex). */
|
|
29
14
|
getTransaction(txHash: string): Promise<Transaction>;
|
|
30
|
-
/**
|
|
31
|
-
* Get Address Data
|
|
32
|
-
* @param address bech32 address
|
|
33
|
-
* @returns {Promise<Address>} address data
|
|
34
|
-
*/
|
|
15
|
+
/** Address data by bech32 address. */
|
|
35
16
|
getAddress(address: string): Promise<Address>;
|
|
36
|
-
/**
|
|
37
|
-
* Get Address UTxOs
|
|
38
|
-
* @param address bech32 address
|
|
39
|
-
* @returns {Promise<UTxO[]>} list of UTxOs
|
|
40
|
-
*/
|
|
17
|
+
/** UTxOs of a bech32 address. */
|
|
41
18
|
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
|
-
*/
|
|
19
|
+
/** Transactions involving a bech32 address (lightweight — hashes and basic info). */
|
|
47
20
|
getAddressTransactions(address: string, limit: number): Promise<Transaction[]>;
|
|
48
|
-
/**
|
|
49
|
-
* Get Network Information
|
|
50
|
-
* @returns {Promise<NetworkInformation>} network information
|
|
51
|
-
*/
|
|
21
|
+
/** Network information (supply, stake). */
|
|
52
22
|
getNetworkInformation(): Promise<NetworkInformation>;
|
|
53
|
-
/**
|
|
54
|
-
* Get Transaction Metadata
|
|
55
|
-
* @param txHash transaction hash (hex)
|
|
56
|
-
* @returns {Promise<MetadataLabelTx[]>} transaction metadata list
|
|
57
|
-
*/
|
|
23
|
+
/** Metadata labels of a transaction (hash hex). */
|
|
58
24
|
getTransactionMetadata(txHash: string): Promise<MetadataLabelTx[]>;
|
|
59
|
-
/**
|
|
60
|
-
* Get Block Data
|
|
61
|
-
* @param blockHash block hash (hex)
|
|
62
|
-
* @returns {Promise<BlockData>} block data
|
|
63
|
-
*/
|
|
25
|
+
/** Block by hash (hex). */
|
|
64
26
|
getBlock(blockHash: string): Promise<BlockData>;
|
|
65
|
-
/**
|
|
66
|
-
* Get Epoch Data
|
|
67
|
-
* @param epochNumber epoch number
|
|
68
|
-
* @returns {Promise<EpochData>} epoch data
|
|
69
|
-
*/
|
|
27
|
+
/** Epoch by number. */
|
|
70
28
|
getEpoch(epochNumber: number): Promise<EpochData>;
|
|
71
|
-
/**
|
|
72
|
-
* Get Latest Epoch Data
|
|
73
|
-
* @returns {Promise<EpochData>} latest epoch data
|
|
74
|
-
*/
|
|
29
|
+
/** Latest epoch. */
|
|
75
30
|
getLatestEpoch(): Promise<EpochData>;
|
|
76
|
-
/**
|
|
77
|
-
* Get Latest Block Data
|
|
78
|
-
* @returns {Promise<BlockData>} latest block data
|
|
79
|
-
*/
|
|
31
|
+
/** Latest block. */
|
|
80
32
|
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
|
-
*/
|
|
33
|
+
/** Latest chain tip slot; throws ProviderUnavailableError when the latest block has no slot. */
|
|
86
34
|
getCurrentSlot(): Promise<number>;
|
|
87
35
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
36
|
+
* Whether a UTxO is still unspent. `false` for txs that don't exist on chain and
|
|
37
|
+
* for out-of-range output indices.
|
|
90
38
|
* @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
39
|
*/
|
|
94
40
|
isUtxoUnspent(txHash: string, outputIndex: number): Promise<boolean>;
|
|
95
|
-
/**
|
|
96
|
-
* Get Pool Data
|
|
97
|
-
* @param poolId pool id
|
|
98
|
-
* @returns {Promise<PoolData>} pool data
|
|
99
|
-
*/
|
|
41
|
+
/** Stake pool by id. */
|
|
100
42
|
getPool(poolId: string): Promise<PoolData>;
|
|
101
|
-
/**
|
|
102
|
-
* Get Drep Data
|
|
103
|
-
* @param drepId drep id
|
|
104
|
-
* @returns {Promise<DrepData>} drep data
|
|
105
|
-
*/
|
|
43
|
+
/** DRep by id. */
|
|
106
44
|
getDrep(drepId: string): Promise<DrepData>;
|
|
107
|
-
/**
|
|
108
|
-
* Get Account Data
|
|
109
|
-
* @param accountId account id
|
|
110
|
-
* @returns {Promise<AccountData>} account data
|
|
111
|
-
*/
|
|
45
|
+
/** Account by stake address. */
|
|
112
46
|
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
|
-
*/
|
|
47
|
+
/** Asset info (supply, mint history, CIP-25 + CIP-26 metadata); unit = policyId + assetNameHex. */
|
|
118
48
|
getAssetInfo(unit: string): Promise<AssetInfo>;
|
|
119
49
|
/**
|
|
120
|
-
*
|
|
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
|
|
50
|
+
* Latest mint/burn events for an asset (most recent first; limit default 100).
|
|
51
|
+
* Optional — Ogmios doesn't expose this. Blockfrost lacks block timestamps; Koios has block_time per entry.
|
|
126
52
|
*/
|
|
127
53
|
getAssetHistory?(unit: string, limit?: number): Promise<AssetHistoryEntry[]>;
|
|
128
|
-
/**
|
|
129
|
-
* Get Protocol Parameters
|
|
130
|
-
* @returns {Promise<LedgerProtocolParameters>} protocol parameters
|
|
131
|
-
*/
|
|
54
|
+
/** Current protocol parameters. */
|
|
132
55
|
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
|
-
*/
|
|
56
|
+
/** Submit a signed transaction (CBOR hex); returns the tx hash. */
|
|
138
57
|
submitTransaction(signedTxCbor: string): Promise<string>;
|
|
139
58
|
/**
|
|
140
|
-
*
|
|
141
|
-
*
|
|
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)
|
|
59
|
+
* Most recent tx hashes of an address (no details).
|
|
60
|
+
* Optional — falls back to getAddressTransactions() mapped to hashes.
|
|
146
61
|
*/
|
|
147
62
|
getAddressTransactionHashes?(address: string, limit: number): Promise<string[]>;
|
|
148
63
|
/**
|
|
149
|
-
*
|
|
150
|
-
*
|
|
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
|
|
64
|
+
* Transactions by hash, as a map txHash -> Transaction.
|
|
65
|
+
* Optional — falls back to individual getTransaction() calls.
|
|
154
66
|
*/
|
|
155
67
|
getTransactionsBatch?(txHashes: string[]): Promise<Map<string, Transaction>>;
|
|
156
68
|
/**
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
* Optional — only Koios implements this natively (`POST /credential_utxos`).
|
|
69
|
+
* UTxOs across all bech32 addresses sharing a 28-byte payment credential (key or script
|
|
70
|
+
* hash), each with its owning address. Optional — only Koios has this natively.
|
|
160
71
|
* @param credHash 28-byte payment credential as 56-char lowercase hex
|
|
161
|
-
* @returns {Promise<UTxO[]>} list of UTxOs across all bech32 forms
|
|
162
72
|
*/
|
|
163
73
|
getCredentialUtxos?(credHash: string): Promise<UTxO[]>;
|
|
164
74
|
}
|
|
165
|
-
/**
|
|
166
|
-
* Extended backend interface for backends that support transaction evaluation (e.g., Ogmios)
|
|
167
|
-
*/
|
|
75
|
+
/** Backend that can evaluate script execution units (Ogmios). */
|
|
168
76
|
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
|
-
*/
|
|
77
|
+
/** Evaluate the script execution units of an unsigned transaction (CBOR hex). */
|
|
174
78
|
evaluateTransaction(unsignedTxCbor: string): Promise<ScriptEvaluationResult[]>;
|
|
175
79
|
}
|
|
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
|
-
*/
|
|
80
|
+
/** Type guard: does this backend support transaction evaluation? */
|
|
181
81
|
export declare function isEvaluatingBackend(backend: CardanoBackend): backend is EvaluatingBackend;
|
|
182
82
|
/** A chain position the crawler can start from, stream to, or roll back to. */
|
|
183
83
|
export interface ChainPoint {
|
|
@@ -189,16 +89,14 @@ export interface ChainPoint {
|
|
|
189
89
|
export interface ChainSyncCallbacks {
|
|
190
90
|
/**
|
|
191
91
|
* A new block (with its full transaction list) extends the chain.
|
|
192
|
-
* @param tip the node's current chain tip
|
|
193
|
-
* consumer track sync progress / detect being caught up
|
|
92
|
+
* @param tip the node's current chain tip when the protocol supplies it (sync progress)
|
|
194
93
|
*/
|
|
195
94
|
rollForward(block: BlockData, txs: Transaction[], tip?: ChainPoint): Promise<void>;
|
|
196
95
|
/** The chain rolled back to `point` (or to genesis). All blocks after it are abandoned. */
|
|
197
96
|
rollBackward(point: ChainPoint | 'origin'): Promise<void>;
|
|
198
97
|
/**
|
|
199
|
-
* A message-handler error stalled the stream
|
|
200
|
-
*
|
|
201
|
-
* close/restart. Optional — without it such errors are only logged.
|
|
98
|
+
* A message-handler error stalled the stream; no further blocks are requested and the
|
|
99
|
+
* consumer should record the error and close/restart. Optional — otherwise only logged.
|
|
202
100
|
*/
|
|
203
101
|
onError?(err: unknown): Promise<void>;
|
|
204
102
|
}
|
|
@@ -208,44 +106,35 @@ export interface ChainSyncHandle {
|
|
|
208
106
|
close(): Promise<void>;
|
|
209
107
|
}
|
|
210
108
|
/**
|
|
211
|
-
* Backend that
|
|
212
|
-
*
|
|
213
|
-
* chain-synchronization protocol — the crawler's primary, reorg-aware source.
|
|
109
|
+
* Backend that streams the chain forward from a point, emitting ordered rollForward and
|
|
110
|
+
* native rollBackward (reorg) events — Ogmios chain-synchronization, the crawler's primary source.
|
|
214
111
|
*/
|
|
215
112
|
export interface ChainSyncBackend extends CardanoBackend {
|
|
216
113
|
/**
|
|
217
|
-
* Open a chain-sync stream starting just after the first of `from`
|
|
218
|
-
*
|
|
219
|
-
*
|
|
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
|
|
114
|
+
* Open a chain-sync stream starting just after the first of `from` still on the node's chain.
|
|
115
|
+
* @param from intersection candidates NEWEST FIRST (or 'origin'); include ancestors of the
|
|
116
|
+
* last-indexed point so a reorg during a disconnect resolves via rollBackward instead of "No intersection found"
|
|
226
117
|
*/
|
|
227
118
|
openChainSync(from: ChainPoint[] | 'origin', callbacks: ChainSyncCallbacks): Promise<ChainSyncHandle>;
|
|
228
119
|
}
|
|
229
120
|
/** Type guard: does this backend support streamed chain-sync? */
|
|
230
121
|
export declare function isChainSyncBackend(backend: CardanoBackend): backend is ChainSyncBackend;
|
|
231
122
|
/**
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
* crawler.utxoSet snapshot import; the point must lie inside the node's volatile window.
|
|
123
|
+
* Backend that returns the whole UTxO set as of a chain point (Ogmios `queryLedgerState/utxo`
|
|
124
|
+
* after `acquireLedgerState`); the point must lie inside the node's volatile window.
|
|
235
125
|
*/
|
|
236
126
|
export interface LedgerStateBackend extends CardanoBackend {
|
|
237
127
|
queryUtxoSetAt(point: ChainPoint): Promise<UTxO[]>;
|
|
238
128
|
}
|
|
239
129
|
export declare function isLedgerStateBackend(backend: CardanoBackend): backend is LedgerStateBackend;
|
|
240
130
|
/**
|
|
241
|
-
* Backend that
|
|
242
|
-
*
|
|
243
|
-
* detected by the crawler via parent-hash mismatch (not delivered natively).
|
|
131
|
+
* Backend that walks the chain forward by pagination (no live node) — the crawler's fallback
|
|
132
|
+
* source. Reorgs are not delivered natively; the crawler detects them via parent-hash mismatch.
|
|
244
133
|
*/
|
|
245
134
|
export interface PaginatingBackend extends CardanoBackend {
|
|
246
135
|
/**
|
|
247
|
-
* Optional: what the crawl wants per block beyond inputs/outputs
|
|
248
|
-
*
|
|
136
|
+
* Optional: what the crawl wants per block beyond inputs/outputs. A backend that pays per
|
|
137
|
+
* payload (Koios `_certs`/`_withdrawals`) only asks when told to.
|
|
249
138
|
*/
|
|
250
139
|
configureCrawl?(options: {
|
|
251
140
|
certificates: boolean;
|
|
@@ -254,9 +143,7 @@ export interface PaginatingBackend extends CardanoBackend {
|
|
|
254
143
|
getBlockByHeight(height: number): Promise<BlockData>;
|
|
255
144
|
/**
|
|
256
145
|
* Fetch up to `count` blocks immediately following `afterHash`, in chain order.
|
|
257
|
-
* @param afterHeight
|
|
258
|
-
* (the crawler's cursor does) — lets height-listing backends
|
|
259
|
-
* (Koios) skip a hash→height resolution round-trip
|
|
146
|
+
* @param afterHeight height of `afterHash` when known — lets height-listing backends skip a hash→height round-trip
|
|
260
147
|
*/
|
|
261
148
|
getNextBlocks(afterHash: string, count: number, afterHeight?: number): Promise<BlockData[]>;
|
|
262
149
|
/** Fetch the full transaction list of a block, in block order. */
|
|
@@ -265,14 +152,9 @@ export interface PaginatingBackend extends CardanoBackend {
|
|
|
265
152
|
/** Type guard: can this backend be walked forward by pagination? */
|
|
266
153
|
export declare function isPaginatingBackend(backend: CardanoBackend): backend is PaginatingBackend;
|
|
267
154
|
/**
|
|
268
|
-
* Backend that
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
* Koios only, and deliberately so: it lists ids (`/pool_list`, `/drep_list`) and resolves
|
|
272
|
-
* them in batches (`POST /pool_info`, `POST /drep_info`), which turns a mainnet snapshot of
|
|
273
|
-
* ~3 200 pools into a handful of requests. Blockfrost can list ids but has no batch info
|
|
274
|
-
* endpoint, so the same snapshot would be thousands of single requests — the snapshots stay
|
|
275
|
-
* off rather than being served that way (same rule as GetUTxOsByCredential).
|
|
155
|
+
* Backend that enumerates the full stake-pool and DRep set and resolves them in batches
|
|
156
|
+
* (crawler epoch snapshots). Koios only: `/pool_list` + `POST /pool_info` make a mainnet
|
|
157
|
+
* snapshot a handful of requests; Blockfrost has no batch info endpoint (thousands of calls).
|
|
276
158
|
*/
|
|
277
159
|
export interface EnumeratingBackend extends CardanoBackend {
|
|
278
160
|
/** All known stake-pool ids (bech32). */
|
|
@@ -5,11 +5,7 @@ exports.isChainSyncBackend = isChainSyncBackend;
|
|
|
5
5
|
exports.isLedgerStateBackend = isLedgerStateBackend;
|
|
6
6
|
exports.isPaginatingBackend = isPaginatingBackend;
|
|
7
7
|
exports.isEnumeratingBackend = isEnumeratingBackend;
|
|
8
|
-
/**
|
|
9
|
-
* Type guard to check if a backend supports transaction evaluation
|
|
10
|
-
* @param backend - The backend to check
|
|
11
|
-
* @returns true if the backend supports evaluateTransaction
|
|
12
|
-
*/
|
|
8
|
+
/** Type guard: does this backend support transaction evaluation? */
|
|
13
9
|
function isEvaluatingBackend(backend) {
|
|
14
10
|
return typeof backend.evaluateTransaction === 'function';
|
|
15
11
|
}
|
|
@@ -42,9 +42,8 @@ interface KoiosTxInfo {
|
|
|
42
42
|
collateral_output?: KoiosTxIO | KoiosTxIO[] | null;
|
|
43
43
|
reference_inputs?: KoiosTxIO[] | null;
|
|
44
44
|
/**
|
|
45
|
-
* Net mint/burn
|
|
46
|
-
*
|
|
47
|
-
* which is exact here because Koios resolves every input's `asset_list`.
|
|
45
|
+
* Net mint/burn (`_assets: true`), quantity signed — negative is a burn. Absent on older
|
|
46
|
+
* Koios; the indexer then derives the delta from inputs/outputs.
|
|
48
47
|
*/
|
|
49
48
|
assets_minted?: Array<{
|
|
50
49
|
policy_id?: string;
|
|
@@ -58,8 +57,7 @@ interface KoiosTxInfo {
|
|
|
58
57
|
}> | null;
|
|
59
58
|
/**
|
|
60
59
|
* `_certs: true` only (crawler batch path). `type` is Koios' own vocabulary
|
|
61
|
-
* (stake_registration, pool_delegation,
|
|
62
|
-
* `info` carries the certificate fields, named per type.
|
|
60
|
+
* (stake_registration, pool_delegation, …); `info` carries per-type fields.
|
|
63
61
|
*/
|
|
64
62
|
certificates?: Array<{
|
|
65
63
|
index?: number | null;
|
|
@@ -67,37 +65,23 @@ interface KoiosTxInfo {
|
|
|
67
65
|
info?: Record<string, unknown> | null;
|
|
68
66
|
}> | null;
|
|
69
67
|
}
|
|
70
|
-
/**
|
|
71
|
-
* KoiosBackend Implementation for CardanoBackend Interface
|
|
72
|
-
* Implements the CardanoBackend interface using Koios API with Axios
|
|
73
|
-
*/
|
|
68
|
+
/** CardanoBackend implementation on the Koios REST API (Axios). */
|
|
74
69
|
export declare class KoiosBackend implements CardanoBackend, PaginatingBackend, EnumeratingBackend {
|
|
75
70
|
readonly name = "koios";
|
|
76
71
|
private api;
|
|
77
72
|
private network;
|
|
78
|
-
/**
|
|
79
|
-
* Constructor
|
|
80
|
-
*/
|
|
81
73
|
constructor(network: Network, timeoutMs: number, apiKey?: string);
|
|
82
|
-
/**
|
|
83
|
-
* Initialize the backend
|
|
84
|
-
*/
|
|
74
|
+
/** Probe /tip to verify connectivity. */
|
|
85
75
|
init(): Promise<boolean>;
|
|
86
76
|
/**
|
|
87
|
-
* Retry
|
|
88
|
-
*
|
|
89
|
-
* valid queries — a single retry is not always sufficient for historical
|
|
90
|
-
* epoch lookups, so we retry with increasing delays (500 → 1000 → 2000 ms).
|
|
77
|
+
* Retry (500 → 1000 → 2000 ms) when Koios transiently returns [] for a valid query.
|
|
78
|
+
* Element type is `any` on purpose: only non-emptiness is checked; rows are narrowed at use sites.
|
|
91
79
|
*/
|
|
92
80
|
private fetchWithRetryOnEmpty;
|
|
93
81
|
/**
|
|
94
|
-
*
|
|
95
|
-
* version-skewed
|
|
96
|
-
*
|
|
97
|
-
* word128 vs numeric on /epoch_info) while healthy instances serve the
|
|
98
|
-
* IDENTICAL request fine. The same request therefore flips 200/400 between
|
|
99
|
-
* calls. Retrying a few times lands on a healthy instance. Scoped strictly to
|
|
100
|
-
* the 42804 type-skew error so genuine 400s (bad params) still fail fast.
|
|
82
|
+
* Retry on Postgres 42804 ("structure of query does not match function result type"):
|
|
83
|
+
* version-skewed Koios instances behind the load balancer return it for a request that
|
|
84
|
+
* healthy instances serve fine. Other 400s still fail fast.
|
|
101
85
|
*/
|
|
102
86
|
private getWithRetryOn42804;
|
|
103
87
|
/**
|
|
@@ -137,11 +121,8 @@ export declare class KoiosBackend implements CardanoBackend, PaginatingBackend,
|
|
|
137
121
|
*/
|
|
138
122
|
getAddressUtxos(address: string): Promise<UTxO[]>;
|
|
139
123
|
/**
|
|
140
|
-
*
|
|
141
|
-
* sharing the given 28-byte payment credential (key hash or script hash).
|
|
142
|
-
* Native Koios endpoint — single round-trip with inline-datum hydration.
|
|
124
|
+
* UTxOs across all bech32 addresses sharing a payment credential (native Koios endpoint).
|
|
143
125
|
* @param credHash 28-byte payment credential as 56-char lowercase hex
|
|
144
|
-
* @returns {Promise<UTxO[]>} list of UTxOs across all bech32 forms
|
|
145
126
|
*/
|
|
146
127
|
getCredentialUtxos(credHash: string): Promise<UTxO[]>;
|
|
147
128
|
/**
|
|
@@ -164,22 +145,14 @@ export declare class KoiosBackend implements CardanoBackend, PaginatingBackend,
|
|
|
164
145
|
/** Map one Koios /pool_info row to the canonical PoolData. */
|
|
165
146
|
private _mapKoiosPool;
|
|
166
147
|
/**
|
|
167
|
-
*
|
|
168
|
-
* Koios's `asset_info` returns total_supply, mint/burn counts split,
|
|
169
|
-
* minting tx + creation_time, and both on-chain and registry metadata.
|
|
148
|
+
* Asset info from Koios `asset_info`: supply, mint/burn counts, minting tx, CIP-25 + CIP-26 metadata.
|
|
170
149
|
* @param unit policyId + assetNameHex (concatenated hex)
|
|
171
|
-
* @returns {Promise<AssetInfo>} canonical asset info
|
|
172
150
|
*/
|
|
173
151
|
getAssetInfo(unit: string): Promise<AssetInfo>;
|
|
174
152
|
/**
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
* the canonical `quantity` field stores absolute value.
|
|
179
|
-
* @param unit policyId + assetNameHex (concatenated hex)
|
|
180
|
-
* @param limit max number of events (default 100). Note: Koios returns ALL events;
|
|
181
|
-
* limit is applied client-side after sort-by-block_time desc.
|
|
182
|
-
* @returns {Promise<AssetHistoryEntry[]>} list of mint/burn events (most recent first)
|
|
153
|
+
* Latest mint/burn events. Koios `asset_history` returns ALL events with `quantity` SIGNED
|
|
154
|
+
* (negative = burn): action derives from the sign, `quantity` stores the absolute value,
|
|
155
|
+
* `limit` is applied client-side after sorting by block_time desc.
|
|
183
156
|
*/
|
|
184
157
|
getAssetHistory(unit: string, limit?: number): Promise<AssetHistoryEntry[]>;
|
|
185
158
|
/**
|
|
@@ -241,17 +214,9 @@ export declare class KoiosBackend implements CardanoBackend, PaginatingBackend,
|
|
|
241
214
|
configureCrawl(options: {
|
|
242
215
|
certificates: boolean;
|
|
243
216
|
}): void;
|
|
244
|
-
/**
|
|
245
|
-
* Batch fetch multiple transactions by hash using Koios POST /tx_info.
|
|
246
|
-
* Sends all hashes in one request (chunked at 100 per Koios limit).
|
|
247
|
-
* @param txHashes array of transaction hashes
|
|
248
|
-
* @returns {Promise<Map<string, Transaction>>} map of hash -> Transaction
|
|
249
|
-
*/
|
|
217
|
+
/** Batch fetch transactions via POST /tx_info, chunked at 100 hashes (Koios limit). */
|
|
250
218
|
getTransactionsBatch(txHashes: string[]): Promise<Map<string, Transaction>>;
|
|
251
|
-
/**
|
|
252
|
-
* Map a Koios /block_info response object to our BlockData (same shape getBlock
|
|
253
|
-
* maps inline; kept private to avoid touching getBlock).
|
|
254
|
-
*/
|
|
219
|
+
/** Map a Koios /block_info row to BlockData. */
|
|
255
220
|
private mapKoiosBlockInfo;
|
|
256
221
|
/**
|
|
257
222
|
* Get a block by its height via the PostgREST-filtered /blocks list, then resolve
|
|
@@ -259,21 +224,16 @@ export declare class KoiosBackend implements CardanoBackend, PaginatingBackend,
|
|
|
259
224
|
*/
|
|
260
225
|
getBlockByHeight(height: number): Promise<BlockData>;
|
|
261
226
|
/**
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
* knows the anchor height (the crawler's cursor), the hash→height resolution
|
|
266
|
-
* round-trip is skipped entirely.
|
|
227
|
+
* Up to `count` blocks after `afterHash`, ascending. Koios has no "next after hash" endpoint:
|
|
228
|
+
* list blocks above the anchor height (PostgREST gt + order + limit), then batch /block_info.
|
|
229
|
+
* A known `afterHeight` skips the hash→height round-trip.
|
|
267
230
|
*/
|
|
268
231
|
getNextBlocks(afterHash: string, count: number, afterHeight?: number): Promise<BlockData[]>;
|
|
269
232
|
/** Rows per page when listing ids (PostgREST caps a response at 1000 rows). */
|
|
270
233
|
private static readonly LIST_PAGE_SIZE;
|
|
271
234
|
/** Ids resolved per /pool_info / /drep_info request. */
|
|
272
235
|
private static readonly INFO_BATCH_SIZE;
|
|
273
|
-
/**
|
|
274
|
-
* Refuse to page forever if an endpoint keeps returning full pages — 500 pages is
|
|
275
|
-
* 500 000 ids, far beyond any real pool or DRep set.
|
|
276
|
-
*/
|
|
236
|
+
/** Page cap — 500 pages is 500 000 ids, far beyond any real pool or DRep set. */
|
|
277
237
|
private static readonly LIST_MAX_PAGES;
|
|
278
238
|
/**
|
|
279
239
|
* Page through a PostgREST list endpoint and collect one id column. Stops on the first
|
|
@@ -295,21 +255,16 @@ export declare class KoiosBackend implements CardanoBackend, PaginatingBackend,
|
|
|
295
255
|
/** Resolve DRep ids in batches; unknown ids are omitted (see getPools). */
|
|
296
256
|
getDreps(drepIds: string[]): Promise<DrepData[]>;
|
|
297
257
|
/**
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
* {tx_hashes:[...]} shape defensively.
|
|
258
|
+
* Full transaction list of a block in block order via /block_txs → /tx_info batch.
|
|
259
|
+
* Accepts both the flattened ({tx_hash} per row) and the {tx_hashes:[...]} shape.
|
|
301
260
|
*/
|
|
302
261
|
getBlockTransactions(blockHash: string): Promise<Transaction[]>;
|
|
303
|
-
/**
|
|
304
|
-
* Map a Koios /tx_info response object to the normalized Transaction type.
|
|
305
|
-
*/
|
|
262
|
+
/** Map a Koios /tx_info row to the normalized Transaction. */
|
|
306
263
|
private _mapKoiosTx;
|
|
307
264
|
}
|
|
308
265
|
/**
|
|
309
|
-
* Normalize Koios `/tx_info` certificates (`_certs: true`). Field names inside `info`
|
|
310
|
-
*
|
|
311
|
-
* `retiring_epoch` — spelled `retiring epoch` with a space in current Koios), so every
|
|
312
|
-
* alias is read. Exported for the unit tests.
|
|
266
|
+
* Normalize Koios `/tx_info` certificates (`_certs: true`). Field names inside `info` differ
|
|
267
|
+
* per type (`retiring_epoch` is spelled `retiring epoch` in current Koios), so every alias is read.
|
|
313
268
|
*/
|
|
314
269
|
export declare function mapKoiosCertificates(certs: NonNullable<KoiosTxInfo['certificates']>): TxCertificate[];
|
|
315
270
|
export {};
|