@odatano/core 2.0.0-rc.2 → 2.0.0-rc.21
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 +251 -0
- package/@cds-models/CardanoAgentService/index.js +36 -0
- package/@cds-models/CardanoIndexerService/index.d.ts +139 -2
- package/@cds-models/CardanoIndexerService/index.js +18 -0
- package/@cds-models/CardanoODataService/index.d.ts +231 -6
- package/@cds-models/CardanoODataService/index.js +27 -0
- package/@cds-models/CardanoSignService/index.d.ts +5 -2
- package/@cds-models/CardanoTransactionService/index.d.ts +9 -9
- package/@cds-models/odatano/cardano/index.d.ts +323 -6
- package/@cds-models/odatano/cardano/index.js +33 -0
- package/README.md +195 -136
- package/db/schema.cds +2133 -1633
- package/package.json +181 -173
- package/scripts/migrate-slot-leader.mjs +104 -0
- package/scripts/migrate-txseq.mjs +147 -0
- package/src/index.d.ts +10 -10
- package/src/index.js +24 -14
- package/src/plugin.js +39 -52
- package/srv/blockchain/backends/blockfrost-backend.d.ts +29 -131
- package/srv/blockchain/backends/blockfrost-backend.js +45 -158
- package/srv/blockchain/backends/cardano-backend.d.ts +83 -158
- package/srv/blockchain/backends/cardano-backend.js +14 -5
- package/srv/blockchain/backends/koios-backend.d.ts +126 -60
- package/srv/blockchain/backends/koios-backend.js +293 -203
- package/srv/blockchain/backends/ogmios-backend.d.ts +69 -94
- package/srv/blockchain/backends/ogmios-backend.js +319 -185
- package/srv/blockchain/backends/ogmios-frame-guard.d.ts +32 -0
- package/srv/blockchain/backends/ogmios-frame-guard.js +142 -0
- package/srv/blockchain/cardano-client.d.ts +57 -204
- package/srv/blockchain/cardano-client.js +94 -226
- package/srv/blockchain/cardano-indexer.d.ts +176 -240
- package/srv/blockchain/cardano-indexer.js +615 -338
- package/srv/blockchain/cardano-tx-builder.d.ts +29 -82
- package/srv/blockchain/cardano-tx-builder.js +88 -128
- 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 +121 -53
- package/srv/blockchain/crawler/crawler.js +403 -89
- package/srv/blockchain/crawler/hooks.d.ts +3 -14
- package/srv/blockchain/crawler/index.d.ts +5 -0
- package/srv/blockchain/crawler/index.js +35 -7
- package/srv/blockchain/crawler/sync-state.d.ts +44 -28
- package/srv/blockchain/crawler/sync-state.js +115 -43
- package/srv/blockchain/crawler/utxo-set-import.d.ts +69 -0
- package/srv/blockchain/crawler/utxo-set-import.js +269 -0
- package/srv/blockchain/ledger-state.d.ts +80 -0
- package/srv/blockchain/ledger-state.js +383 -0
- 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 +71 -160
- package/srv/blockchain/transaction-building/buildooor-tx.js +185 -260
- package/srv/blockchain/transaction-building/cardano-tx.d.ts +8 -34
- package/srv/blockchain/transaction-rows.d.ts +12 -0
- package/srv/blockchain/transaction-rows.js +42 -0
- package/srv/blockchain/wallet-worker/build-request.d.ts +4 -17
- package/srv/blockchain/wallet-worker/build-request.js +39 -23
- package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +25 -17
- package/srv/blockchain/wallet-worker/confirmation-tracker.js +87 -41
- package/srv/blockchain/wallet-worker/index.js +2 -8
- package/srv/blockchain/wallet-worker/job-store.d.ts +36 -103
- 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 +40 -91
- package/srv/cardano-agent-service.cds +146 -0
- package/srv/cardano-agent-service.d.ts +2 -0
- package/srv/cardano-agent-service.js +12 -0
- package/srv/cardano-indexer-service.cds +164 -73
- package/srv/cardano-indexer-service.js +156 -11
- package/srv/cardano-service.cds +45 -0
- package/srv/cardano-service.js +38 -96
- package/srv/cardano-sign-service.cds +200 -180
- package/srv/cardano-sign-service.js +55 -173
- package/srv/cardano-tx-service.cds +32 -26
- package/srv/cardano-tx-service.js +136 -196
- package/srv/cardano-worker-service.js +7 -15
- package/srv/server.d.ts +28 -86
- package/srv/server.js +95 -128
- package/srv/utils/agent-grants-config.d.ts +37 -0
- package/srv/utils/agent-grants-config.js +138 -0
- package/srv/utils/agent-grants.d.ts +262 -0
- package/srv/utils/agent-grants.js +914 -0
- package/srv/utils/agent-token-auth.d.ts +16 -0
- package/srv/utils/agent-token-auth.js +78 -0
- 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 +25 -0
- package/srv/utils/db-indexes.js +93 -0
- package/srv/utils/db-sanitize.d.ts +27 -0
- package/srv/utils/db-sanitize.js +85 -0
- package/srv/utils/epoch-slots.d.ts +13 -0
- package/srv/utils/epoch-slots.js +25 -0
- package/srv/utils/error-codes.d.ts +18 -73
- package/srv/utils/error-codes.js +17 -70
- package/srv/utils/errors.d.ts +36 -179
- package/srv/utils/errors.js +62 -220
- package/srv/utils/liveness.d.ts +16 -0
- package/srv/utils/liveness.js +41 -0
- package/srv/utils/mappers.d.ts +89 -214
- package/srv/utils/mappers.js +289 -301
- package/srv/utils/network-context.js +2 -11
- package/srv/utils/pg-order-nulls.d.ts +14 -0
- package/srv/utils/pg-order-nulls.js +57 -0
- package/srv/utils/plutus-placeholders.d.ts +6 -18
- package/srv/utils/plutus-placeholders.js +6 -20
- package/srv/utils/rate-limiter.d.ts +46 -0
- package/srv/utils/rate-limiter.js +116 -0
- 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 +14 -20
- package/srv/utils/tx-request-parsers.js +33 -20
- package/srv/utils/tx-utils.d.ts +4 -23
- package/srv/utils/tx-utils.js +12 -41
- package/srv/utils/types.d.ts +114 -169
- 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,39 +106,49 @@ 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
|
-
* Backend that
|
|
233
|
-
*
|
|
234
|
-
|
|
123
|
+
* Backend that reads UTxOs straight from the node's ledger (Ogmios `queryLedgerState/utxo`):
|
|
124
|
+
* the whole set as of a chain point inside the volatile window, or selected outputs at the tip.
|
|
125
|
+
*/
|
|
126
|
+
export interface LedgerStateBackend extends CardanoBackend {
|
|
127
|
+
queryUtxoSetAt(point: ChainPoint): Promise<UTxO[]>;
|
|
128
|
+
/** Outputs among `refs` that are unspent at the tip; spent or unknown references are absent. */
|
|
129
|
+
getUnspentOutputs(refs: Array<{
|
|
130
|
+
txHash: string;
|
|
131
|
+
outputIndex: number;
|
|
132
|
+
}>): Promise<UTxO[]>;
|
|
133
|
+
}
|
|
134
|
+
export declare function isLedgerStateBackend(backend: CardanoBackend): backend is LedgerStateBackend;
|
|
135
|
+
/**
|
|
136
|
+
* Backend that walks the chain forward by pagination (no live node) — the crawler's fallback
|
|
137
|
+
* source. Reorgs are not delivered natively; the crawler detects them via parent-hash mismatch.
|
|
235
138
|
*/
|
|
236
139
|
export interface PaginatingBackend extends CardanoBackend {
|
|
140
|
+
/**
|
|
141
|
+
* Optional: what the crawl wants per block beyond inputs/outputs. A backend that pays per
|
|
142
|
+
* payload (Koios `_certs`/`_withdrawals`) only asks when told to.
|
|
143
|
+
*/
|
|
144
|
+
configureCrawl?(options: {
|
|
145
|
+
certificates: boolean;
|
|
146
|
+
}): void;
|
|
237
147
|
/** Fetch a block by its height. */
|
|
238
148
|
getBlockByHeight(height: number): Promise<BlockData>;
|
|
239
149
|
/**
|
|
240
150
|
* Fetch up to `count` blocks immediately following `afterHash`, in chain order.
|
|
241
|
-
* @param afterHeight
|
|
242
|
-
* (the crawler's cursor does) — lets height-listing backends
|
|
243
|
-
* (Koios) skip a hash→height resolution round-trip
|
|
151
|
+
* @param afterHeight height of `afterHash` when known — lets height-listing backends skip a hash→height round-trip
|
|
244
152
|
*/
|
|
245
153
|
getNextBlocks(afterHash: string, count: number, afterHeight?: number): Promise<BlockData[]>;
|
|
246
154
|
/** Fetch the full transaction list of a block, in block order. */
|
|
@@ -248,4 +156,21 @@ export interface PaginatingBackend extends CardanoBackend {
|
|
|
248
156
|
}
|
|
249
157
|
/** Type guard: can this backend be walked forward by pagination? */
|
|
250
158
|
export declare function isPaginatingBackend(backend: CardanoBackend): backend is PaginatingBackend;
|
|
159
|
+
/**
|
|
160
|
+
* Backend that enumerates the full stake-pool and DRep set and resolves them in batches
|
|
161
|
+
* (crawler epoch snapshots). Koios only: `/pool_list` + `POST /pool_info` make a mainnet
|
|
162
|
+
* snapshot a handful of requests; Blockfrost has no batch info endpoint (thousands of calls).
|
|
163
|
+
*/
|
|
164
|
+
export interface EnumeratingBackend extends CardanoBackend {
|
|
165
|
+
/** All known stake-pool ids (bech32). */
|
|
166
|
+
getPoolIds(): Promise<string[]>;
|
|
167
|
+
/** Resolve a batch of pool ids. Ids the backend does not know are omitted, not faked. */
|
|
168
|
+
getPools(poolIds: string[]): Promise<PoolData[]>;
|
|
169
|
+
/** All known DRep ids (bech32). */
|
|
170
|
+
getDrepIds(): Promise<string[]>;
|
|
171
|
+
/** Resolve a batch of DRep ids. Ids the backend does not know are omitted. */
|
|
172
|
+
getDreps(drepIds: string[]): Promise<DrepData[]>;
|
|
173
|
+
}
|
|
174
|
+
/** Type guard: can this backend enumerate pools and DReps? */
|
|
175
|
+
export declare function isEnumeratingBackend(backend: CardanoBackend): backend is EnumeratingBackend;
|
|
251
176
|
//# sourceMappingURL=cardano-backend.d.ts.map
|
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isEvaluatingBackend = isEvaluatingBackend;
|
|
4
4
|
exports.isChainSyncBackend = isChainSyncBackend;
|
|
5
|
+
exports.isLedgerStateBackend = isLedgerStateBackend;
|
|
5
6
|
exports.isPaginatingBackend = isPaginatingBackend;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* @param backend - The backend to check
|
|
9
|
-
* @returns true if the backend supports evaluateTransaction
|
|
10
|
-
*/
|
|
7
|
+
exports.isEnumeratingBackend = isEnumeratingBackend;
|
|
8
|
+
/** Type guard: does this backend support transaction evaluation? */
|
|
11
9
|
function isEvaluatingBackend(backend) {
|
|
12
10
|
return typeof backend.evaluateTransaction === 'function';
|
|
13
11
|
}
|
|
@@ -15,6 +13,9 @@ function isEvaluatingBackend(backend) {
|
|
|
15
13
|
function isChainSyncBackend(backend) {
|
|
16
14
|
return typeof backend.openChainSync === 'function';
|
|
17
15
|
}
|
|
16
|
+
function isLedgerStateBackend(backend) {
|
|
17
|
+
return typeof backend.queryUtxoSetAt === 'function';
|
|
18
|
+
}
|
|
18
19
|
/** Type guard: can this backend be walked forward by pagination? */
|
|
19
20
|
function isPaginatingBackend(backend) {
|
|
20
21
|
const b = backend;
|
|
@@ -22,4 +23,12 @@ function isPaginatingBackend(backend) {
|
|
|
22
23
|
&& typeof b.getNextBlocks === 'function'
|
|
23
24
|
&& typeof b.getBlockTransactions === 'function';
|
|
24
25
|
}
|
|
26
|
+
/** Type guard: can this backend enumerate pools and DReps? */
|
|
27
|
+
function isEnumeratingBackend(backend) {
|
|
28
|
+
const b = backend;
|
|
29
|
+
return typeof b.getPoolIds === 'function'
|
|
30
|
+
&& typeof b.getPools === 'function'
|
|
31
|
+
&& typeof b.getDrepIds === 'function'
|
|
32
|
+
&& typeof b.getDreps === 'function';
|
|
33
|
+
}
|
|
25
34
|
//# sourceMappingURL=cardano-backend.js.map
|
|
@@ -1,37 +1,87 @@
|
|
|
1
|
-
import { CardanoBackend, PaginatingBackend } from './cardano-backend';
|
|
2
|
-
import { Transaction, BlockData, Address, UTxO, NetworkInformation, EpochData, MetadataLabelTx, PoolData, DrepData, AccountData, AssetInfo, AssetHistoryEntry, LedgerProtocolParameters } from '../../utils/types';
|
|
1
|
+
import { CardanoBackend, PaginatingBackend, EnumeratingBackend } from './cardano-backend';
|
|
2
|
+
import { Transaction, BlockData, Address, UTxO, NetworkInformation, EpochData, MetadataLabelTx, PoolData, DrepData, AccountData, AssetInfo, AssetHistoryEntry, LedgerProtocolParameters, TxCertificate } from '../../utils/types';
|
|
3
3
|
import { Network } from '../cardano-client';
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
/** Shape of a Koios tx-in/tx-out row from /tx_info */
|
|
5
|
+
interface KoiosTxIO {
|
|
6
|
+
address?: string;
|
|
7
|
+
payment_addr?: {
|
|
8
|
+
bech32?: string;
|
|
9
|
+
};
|
|
10
|
+
tx_hash: string;
|
|
11
|
+
tx_index: number;
|
|
12
|
+
value: string;
|
|
13
|
+
datum_hash?: string | null;
|
|
14
|
+
inline_datum?: unknown;
|
|
15
|
+
reference_script?: unknown;
|
|
16
|
+
asset_list?: Array<{
|
|
17
|
+
policy_id: string;
|
|
18
|
+
asset_name: string;
|
|
19
|
+
quantity: string;
|
|
20
|
+
}>;
|
|
21
|
+
}
|
|
22
|
+
/** Shape of a Koios /tx_info response row */
|
|
23
|
+
interface KoiosTxInfo {
|
|
24
|
+
tx_hash: string;
|
|
25
|
+
block_hash: string;
|
|
26
|
+
block_height: number | string;
|
|
27
|
+
tx_timestamp?: number;
|
|
28
|
+
block_time?: number;
|
|
29
|
+
absolute_slot?: number;
|
|
30
|
+
slot_no?: number;
|
|
31
|
+
tx_block_index?: number;
|
|
32
|
+
fee?: string;
|
|
33
|
+
deposit?: string;
|
|
34
|
+
tx_size: number;
|
|
35
|
+
metadata?: Record<string, unknown> | null;
|
|
36
|
+
inputs: KoiosTxIO[];
|
|
37
|
+
outputs: KoiosTxIO[];
|
|
38
|
+
/** False when the script phase failed (collateral consumed, regular ins/outs not applied). Absent on older Koios. */
|
|
39
|
+
valid_contract?: boolean | null;
|
|
40
|
+
collateral_inputs?: KoiosTxIO[] | null;
|
|
41
|
+
/** Live Koios returns ONE object here (the spec says array); both shapes are accepted. */
|
|
42
|
+
collateral_output?: KoiosTxIO | KoiosTxIO[] | null;
|
|
43
|
+
reference_inputs?: KoiosTxIO[] | null;
|
|
12
44
|
/**
|
|
13
|
-
*
|
|
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.
|
|
14
47
|
*/
|
|
15
|
-
|
|
48
|
+
assets_minted?: Array<{
|
|
49
|
+
policy_id?: string;
|
|
50
|
+
asset_name?: string | null;
|
|
51
|
+
quantity?: string | number;
|
|
52
|
+
}> | null;
|
|
53
|
+
/** `_withdrawals: true` only (crawler batch path); null/absent otherwise. */
|
|
54
|
+
withdrawals?: Array<{
|
|
55
|
+
amount?: string | number;
|
|
56
|
+
stake_addr?: string;
|
|
57
|
+
}> | null;
|
|
16
58
|
/**
|
|
17
|
-
*
|
|
59
|
+
* `_certs: true` only (crawler batch path). `type` is Koios' own vocabulary
|
|
60
|
+
* (stake_registration, pool_delegation, …); `info` carries per-type fields.
|
|
18
61
|
*/
|
|
62
|
+
certificates?: Array<{
|
|
63
|
+
index?: number | null;
|
|
64
|
+
type?: string;
|
|
65
|
+
info?: Record<string, unknown> | null;
|
|
66
|
+
}> | null;
|
|
67
|
+
}
|
|
68
|
+
/** CardanoBackend implementation on the Koios REST API (Axios). */
|
|
69
|
+
export declare class KoiosBackend implements CardanoBackend, PaginatingBackend, EnumeratingBackend {
|
|
70
|
+
readonly name = "koios";
|
|
71
|
+
private api;
|
|
72
|
+
private network;
|
|
73
|
+
constructor(network: Network, timeoutMs: number, apiKey?: string);
|
|
74
|
+
/** Probe /tip to verify connectivity. */
|
|
19
75
|
init(): Promise<boolean>;
|
|
20
76
|
/**
|
|
21
|
-
* Retry
|
|
22
|
-
*
|
|
23
|
-
* valid queries — a single retry is not always sufficient for historical
|
|
24
|
-
* 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.
|
|
25
79
|
*/
|
|
26
80
|
private fetchWithRetryOnEmpty;
|
|
27
81
|
/**
|
|
28
|
-
*
|
|
29
|
-
* version-skewed
|
|
30
|
-
*
|
|
31
|
-
* word128 vs numeric on /epoch_info) while healthy instances serve the
|
|
32
|
-
* IDENTICAL request fine. The same request therefore flips 200/400 between
|
|
33
|
-
* calls. Retrying a few times lands on a healthy instance. Scoped strictly to
|
|
34
|
-
* 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.
|
|
35
85
|
*/
|
|
36
86
|
private getWithRetryOn42804;
|
|
37
87
|
/**
|
|
@@ -71,11 +121,8 @@ export declare class KoiosBackend implements CardanoBackend, PaginatingBackend {
|
|
|
71
121
|
*/
|
|
72
122
|
getAddressUtxos(address: string): Promise<UTxO[]>;
|
|
73
123
|
/**
|
|
74
|
-
*
|
|
75
|
-
* sharing the given 28-byte payment credential (key hash or script hash).
|
|
76
|
-
* Native Koios endpoint — single round-trip with inline-datum hydration.
|
|
124
|
+
* UTxOs across all bech32 addresses sharing a payment credential (native Koios endpoint).
|
|
77
125
|
* @param credHash 28-byte payment credential as 56-char lowercase hex
|
|
78
|
-
* @returns {Promise<UTxO[]>} list of UTxOs across all bech32 forms
|
|
79
126
|
*/
|
|
80
127
|
getCredentialUtxos(credHash: string): Promise<UTxO[]>;
|
|
81
128
|
/**
|
|
@@ -95,23 +142,17 @@ export declare class KoiosBackend implements CardanoBackend, PaginatingBackend {
|
|
|
95
142
|
* @returns {Promise<PoolData>} pool data
|
|
96
143
|
*/
|
|
97
144
|
getPool(poolId: string): Promise<PoolData>;
|
|
145
|
+
/** Map one Koios /pool_info row to the canonical PoolData. */
|
|
146
|
+
private _mapKoiosPool;
|
|
98
147
|
/**
|
|
99
|
-
*
|
|
100
|
-
* Koios's `asset_info` returns total_supply, mint/burn counts split,
|
|
101
|
-
* 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.
|
|
102
149
|
* @param unit policyId + assetNameHex (concatenated hex)
|
|
103
|
-
* @returns {Promise<AssetInfo>} canonical asset info
|
|
104
150
|
*/
|
|
105
151
|
getAssetInfo(unit: string): Promise<AssetInfo>;
|
|
106
152
|
/**
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
* the canonical `quantity` field stores absolute value.
|
|
111
|
-
* @param unit policyId + assetNameHex (concatenated hex)
|
|
112
|
-
* @param limit max number of events (default 100). Note: Koios returns ALL events;
|
|
113
|
-
* limit is applied client-side after sort-by-block_time desc.
|
|
114
|
-
* @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.
|
|
115
156
|
*/
|
|
116
157
|
getAssetHistory(unit: string, limit?: number): Promise<AssetHistoryEntry[]>;
|
|
117
158
|
/**
|
|
@@ -120,6 +161,8 @@ export declare class KoiosBackend implements CardanoBackend, PaginatingBackend {
|
|
|
120
161
|
* @returns {Promise<DrepData>} drep data
|
|
121
162
|
*/
|
|
122
163
|
getDrep(drepId: string): Promise<DrepData>;
|
|
164
|
+
/** Map one Koios /drep_info row to the canonical DrepData. */
|
|
165
|
+
private _mapKoiosDrep;
|
|
123
166
|
/**
|
|
124
167
|
* Get Account Data for specified stake address
|
|
125
168
|
* @param accountId account id
|
|
@@ -166,17 +209,14 @@ export declare class KoiosBackend implements CardanoBackend, PaginatingBackend {
|
|
|
166
209
|
* @returns {Promise<string[]>} most recent tx hashes
|
|
167
210
|
*/
|
|
168
211
|
getAddressTransactionHashes(address: string, limit: number): Promise<string[]>;
|
|
169
|
-
/**
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
212
|
+
/** crawler.certificates: ask /tx_info for certificates + withdrawals on the crawl's batch call. */
|
|
213
|
+
private crawlCertificates;
|
|
214
|
+
configureCrawl(options: {
|
|
215
|
+
certificates: boolean;
|
|
216
|
+
}): void;
|
|
217
|
+
/** Batch fetch transactions via POST /tx_info, chunked at 100 hashes (Koios limit). */
|
|
175
218
|
getTransactionsBatch(txHashes: string[]): Promise<Map<string, Transaction>>;
|
|
176
|
-
/**
|
|
177
|
-
* Map a Koios /block_info response object to our BlockData (same shape getBlock
|
|
178
|
-
* maps inline; kept private to avoid touching getBlock).
|
|
179
|
-
*/
|
|
219
|
+
/** Map a Koios /block_info row to BlockData. */
|
|
180
220
|
private mapKoiosBlockInfo;
|
|
181
221
|
/**
|
|
182
222
|
* Get a block by its height via the PostgREST-filtered /blocks list, then resolve
|
|
@@ -184,22 +224,48 @@ export declare class KoiosBackend implements CardanoBackend, PaginatingBackend {
|
|
|
184
224
|
*/
|
|
185
225
|
getBlockByHeight(height: number): Promise<BlockData>;
|
|
186
226
|
/**
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
* knows the anchor height (the crawler's cursor), the hash→height resolution
|
|
191
|
-
* 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.
|
|
192
230
|
*/
|
|
193
231
|
getNextBlocks(afterHash: string, count: number, afterHeight?: number): Promise<BlockData[]>;
|
|
232
|
+
/** Rows per page when listing ids (PostgREST caps a response at 1000 rows). */
|
|
233
|
+
private static readonly LIST_PAGE_SIZE;
|
|
234
|
+
/** Ids resolved per /pool_info / /drep_info request. */
|
|
235
|
+
private static readonly INFO_BATCH_SIZE;
|
|
236
|
+
/** Page cap — 500 pages is 500 000 ids, far beyond any real pool or DRep set. */
|
|
237
|
+
private static readonly LIST_MAX_PAGES;
|
|
194
238
|
/**
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
* {tx_hashes:[...]} shape defensively.
|
|
239
|
+
* Page through a PostgREST list endpoint and collect one id column. Stops on the first
|
|
240
|
+
* short page, so a complete set costs exactly ceil(n / 1000) + 1 requests.
|
|
198
241
|
*/
|
|
199
|
-
|
|
242
|
+
private listAllIds;
|
|
243
|
+
/**
|
|
244
|
+
* All stake-pool ids known to Koios (bech32), including retired ones — a snapshot that
|
|
245
|
+
* silently dropped retiring pools would misreport the epoch's pool set.
|
|
246
|
+
*/
|
|
247
|
+
getPoolIds(): Promise<string[]>;
|
|
248
|
+
/**
|
|
249
|
+
* Resolve pool ids in batches. Ids Koios does not return are omitted rather than
|
|
250
|
+
* substituted with empty rows — a missing pool is better than an invented one.
|
|
251
|
+
*/
|
|
252
|
+
getPools(poolIds: string[]): Promise<PoolData[]>;
|
|
253
|
+
/** All DRep ids known to Koios (bech32). */
|
|
254
|
+
getDrepIds(): Promise<string[]>;
|
|
255
|
+
/** Resolve DRep ids in batches; unknown ids are omitted (see getPools). */
|
|
256
|
+
getDreps(drepIds: string[]): Promise<DrepData[]>;
|
|
200
257
|
/**
|
|
201
|
-
*
|
|
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.
|
|
202
260
|
*/
|
|
261
|
+
getBlockTransactions(blockHash: string): Promise<Transaction[]>;
|
|
262
|
+
/** Map a Koios /tx_info row to the normalized Transaction. */
|
|
203
263
|
private _mapKoiosTx;
|
|
204
264
|
}
|
|
265
|
+
/**
|
|
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.
|
|
268
|
+
*/
|
|
269
|
+
export declare function mapKoiosCertificates(certs: NonNullable<KoiosTxInfo['certificates']>): TxCertificate[];
|
|
270
|
+
export {};
|
|
205
271
|
//# sourceMappingURL=koios-backend.d.ts.map
|