@odatano/core 2.0.0-rc.4 → 2.0.0-rc.40
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/CardanoBackendService/index.d.ts +357 -0
- package/@cds-models/CardanoBackendService/index.js +40 -0
- package/@cds-models/CardanoIndexerService/index.d.ts +194 -2
- package/@cds-models/CardanoIndexerService/index.js +25 -0
- package/@cds-models/CardanoODataService/index.d.ts +305 -7
- package/@cds-models/CardanoODataService/index.js +34 -0
- package/@cds-models/CardanoSignService/index.d.ts +28 -3
- package/@cds-models/CardanoSignService/index.js +3 -0
- package/@cds-models/CardanoTransactionService/index.d.ts +46 -13
- package/@cds-models/CardanoTransactionService/index.js +4 -0
- package/@cds-models/index.d.ts +72 -0
- package/@cds-models/index.js +12 -0
- package/@cds-models/odatano/cardano/index.d.ts +408 -7
- package/@cds-models/odatano/cardano/index.js +42 -0
- package/README.md +64 -5
- package/db/schema.cds +2297 -1633
- package/db/types.cds +114 -0
- package/package.json +27 -6
- package/scripts/migrate-slot-leader.mjs +104 -0
- package/scripts/migrate-txseq.mjs +147 -0
- package/src/index.d.ts +18 -11
- package/src/index.js +44 -14
- package/src/plugin.js +42 -52
- package/srv/blockchain/backends/blockfrost-backend.d.ts +29 -131
- package/srv/blockchain/backends/blockfrost-backend.js +53 -162
- package/srv/blockchain/backends/cardano-backend.d.ts +104 -158
- package/srv/blockchain/backends/cardano-backend.js +19 -5
- package/srv/blockchain/backends/koios-backend.d.ts +126 -60
- package/srv/blockchain/backends/koios-backend.js +376 -235
- package/srv/blockchain/backends/odatano-backend.d.ts +64 -0
- package/srv/blockchain/backends/odatano-backend.js +170 -0
- package/srv/blockchain/backends/ogmios-backend.d.ts +162 -94
- package/srv/blockchain/backends/ogmios-backend.js +556 -201
- 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 +87 -202
- package/srv/blockchain/cardano-client.js +210 -240
- package/srv/blockchain/cardano-indexer.d.ts +311 -242
- package/srv/blockchain/cardano-indexer.js +1238 -362
- package/srv/blockchain/cardano-tx-builder.d.ts +44 -81
- package/srv/blockchain/cardano-tx-builder.js +173 -132
- package/srv/blockchain/crawler/certificate-backfill.d.ts +67 -0
- package/srv/blockchain/crawler/certificate-backfill.js +169 -0
- package/srv/blockchain/crawler/crawler.d.ts +139 -54
- package/srv/blockchain/crawler/crawler.js +478 -96
- 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 +46 -28
- package/srv/blockchain/crawler/sync-state.js +128 -43
- package/srv/blockchain/crawler/transaction-backfill.d.ts +52 -0
- package/srv/blockchain/crawler/transaction-backfill.js +283 -0
- package/srv/blockchain/crawler/utxo-set-import.d.ts +78 -0
- package/srv/blockchain/crawler/utxo-set-import.js +363 -0
- package/srv/blockchain/ledger-state.d.ts +101 -0
- package/srv/blockchain/ledger-state.js +432 -0
- package/srv/blockchain/pending-spends.d.ts +28 -0
- package/srv/blockchain/pending-spends.js +89 -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 +14 -45
- package/srv/blockchain/signing/signature-verifier.js +73 -76
- package/srv/blockchain/signing/submission-finalizer.d.ts +9 -36
- package/srv/blockchain/signing/submission-finalizer.js +16 -49
- package/srv/blockchain/stored-chain.d.ts +33 -0
- package/srv/blockchain/stored-chain.js +234 -0
- package/srv/blockchain/transaction-building/buildooor-tx.d.ts +111 -173
- package/srv/blockchain/transaction-building/buildooor-tx.js +649 -326
- package/srv/blockchain/transaction-building/caller-datums.d.ts +29 -0
- package/srv/blockchain/transaction-building/caller-datums.js +139 -0
- package/srv/blockchain/transaction-building/cardano-tx.d.ts +10 -35
- package/srv/blockchain/transaction-rows.d.ts +12 -0
- package/srv/blockchain/transaction-rows.js +43 -0
- package/srv/blockchain/wallet-worker/build-request.d.ts +4 -17
- package/srv/blockchain/wallet-worker/build-request.js +18 -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-backend-service.cds +52 -0
- package/srv/cardano-backend-service.d.ts +2 -0
- package/srv/cardano-backend-service.js +244 -0
- package/srv/cardano-indexer-service.cds +201 -73
- package/srv/cardano-indexer-service.js +280 -11
- package/srv/cardano-service.cds +65 -2
- package/srv/cardano-service.js +170 -129
- package/srv/cardano-sign-service.cds +200 -180
- package/srv/cardano-sign-service.js +57 -184
- package/srv/cardano-tx-service.cds +439 -370
- package/srv/cardano-tx-service.js +231 -190
- package/srv/cardano-ui.cds +16 -16
- package/srv/cardano-worker-service.js +7 -15
- package/srv/cbor/index.d.ts +1 -1
- package/srv/cbor/parse.d.ts +27 -0
- package/srv/cbor/parse.js +63 -2
- package/srv/server.d.ts +28 -86
- package/srv/server.js +132 -135
- 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 +922 -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 +30 -67
- package/srv/utils/const.js +32 -72
- 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 +94 -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 +20 -0
- package/srv/utils/epoch-slots.js +43 -0
- package/srv/utils/error-codes.d.ts +20 -73
- package/srv/utils/error-codes.js +19 -70
- package/srv/utils/errors.d.ts +50 -177
- package/srv/utils/errors.js +94 -218
- package/srv/utils/legacy-service-paths.d.ts +11 -0
- package/srv/utils/legacy-service-paths.js +58 -0
- package/srv/utils/liveness.d.ts +16 -0
- package/srv/utils/liveness.js +40 -0
- package/srv/utils/mappers.d.ts +128 -214
- package/srv/utils/mappers.js +354 -299
- package/srv/utils/network-context.js +2 -11
- package/srv/utils/pg-inline-json.d.ts +8 -0
- package/srv/utils/pg-inline-json.js +62 -0
- package/srv/utils/pg-order-nulls.d.ts +14 -0
- package/srv/utils/pg-order-nulls.js +56 -0
- package/srv/utils/plutus-placeholders.d.ts +23 -16
- package/srv/utils/plutus-placeholders.js +63 -27
- 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 +6 -16
- package/srv/utils/signing-helper.js +36 -60
- package/srv/utils/tx-build-helper.d.ts +28 -93
- package/srv/utils/tx-build-helper.js +75 -124
- package/srv/utils/tx-request-parsers.d.ts +101 -28
- package/srv/utils/tx-request-parsers.js +410 -43
- package/srv/utils/tx-utils.d.ts +4 -23
- package/srv/utils/tx-utils.js +12 -41
- package/srv/utils/types.d.ts +252 -179
- package/srv/utils/types.js +2 -6
- package/srv/utils/validators.d.ts +24 -90
- package/srv/utils/validators.js +50 -147
|
@@ -6,26 +6,18 @@ const backend_request_handler_1 = require("../../utils/backend-request-handler")
|
|
|
6
6
|
const errors_1 = require("../../utils/errors");
|
|
7
7
|
const mappers_1 = require("../../utils/mappers");
|
|
8
8
|
const tx_build_helper_1 = require("../../utils/tx-build-helper");
|
|
9
|
-
/**
|
|
10
|
-
* BlockfrostBackend Implementation for CardanoBackend Interface
|
|
11
|
-
* Implements the CardanoBackend interface using Blockfrost API SDK
|
|
12
|
-
*/
|
|
9
|
+
/** CardanoBackend + PaginatingBackend implementation on the Blockfrost API SDK. */
|
|
13
10
|
class BlockfrostBackend {
|
|
14
11
|
name = 'blockfrost';
|
|
15
12
|
api;
|
|
16
13
|
network;
|
|
17
14
|
timeoutMs;
|
|
18
|
-
/**
|
|
19
|
-
* Constructor
|
|
20
|
-
*/
|
|
21
15
|
constructor(network, timeoutMs, projectId, customBackend) {
|
|
22
16
|
if (!projectId && !customBackend) {
|
|
23
17
|
throw new errors_1.BackendInitError('blockfrost', new Error('Either projectId (BLOCKFROST_API_KEY) or customBackend (BLOCKFROST_CUSTOM_BACKEND) is required'));
|
|
24
18
|
}
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
// SDK validator accepts customBackend OR projectId — this substitution is purely
|
|
28
|
-
// for the runtime HTTP header.
|
|
19
|
+
// Self-hosted Blockfrost-compatible nodes reject an empty project_id header
|
|
20
|
+
// even without authentication — placeholder for the runtime HTTP header only.
|
|
29
21
|
const effectiveProjectId = projectId || 'self-hosted';
|
|
30
22
|
this.api = new blockfrost_js_1.BlockFrostAPI({
|
|
31
23
|
projectId: effectiveProjectId,
|
|
@@ -35,9 +27,6 @@ class BlockfrostBackend {
|
|
|
35
27
|
this.network = network;
|
|
36
28
|
this.timeoutMs = timeoutMs;
|
|
37
29
|
}
|
|
38
|
-
/**
|
|
39
|
-
* Initialize the backend
|
|
40
|
-
*/
|
|
41
30
|
async init() {
|
|
42
31
|
this.api.options.requestTimeout = this.timeoutMs;
|
|
43
32
|
// Test connection by fetching latest block
|
|
@@ -49,10 +38,7 @@ class BlockfrostBackend {
|
|
|
49
38
|
}
|
|
50
39
|
return true;
|
|
51
40
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Get Network Information
|
|
54
|
-
* @returns {Promise<NetworkInformation>} network information
|
|
55
|
-
*/
|
|
41
|
+
/** Network information (supply, stake). */
|
|
56
42
|
async getNetworkInformation() {
|
|
57
43
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
58
44
|
const networkInfo = await this.api.network();
|
|
@@ -62,19 +48,11 @@ class BlockfrostBackend {
|
|
|
62
48
|
};
|
|
63
49
|
}, this.name);
|
|
64
50
|
}
|
|
65
|
-
/**
|
|
66
|
-
* Get Block Data
|
|
67
|
-
* @param blockHash block hash (hex)
|
|
68
|
-
* @returns {Promise<BlockData>} block data
|
|
69
|
-
*/
|
|
51
|
+
/** Block by hash (hex). */
|
|
70
52
|
async getBlock(blockHash) {
|
|
71
53
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => this.toBlockData(await this.api.blocks(blockHash)), this.name);
|
|
72
54
|
}
|
|
73
|
-
/**
|
|
74
|
-
* Get Epoch Data
|
|
75
|
-
* @param epochNumber epoch number
|
|
76
|
-
* @returns {Promise<EpochData>} epoch data
|
|
77
|
-
*/
|
|
55
|
+
/** Epoch by number. */
|
|
78
56
|
async getEpoch(epochNumber) {
|
|
79
57
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
80
58
|
const epochData = await this.api.epochs(epochNumber);
|
|
@@ -92,11 +70,7 @@ class BlockfrostBackend {
|
|
|
92
70
|
};
|
|
93
71
|
}, this.name);
|
|
94
72
|
}
|
|
95
|
-
/**
|
|
96
|
-
* Get Transaction Data
|
|
97
|
-
* @param hash transaction hash (hex)
|
|
98
|
-
* @returns {Promise<Transaction>} transaction data
|
|
99
|
-
*/
|
|
73
|
+
/** Transaction by hash (hex), with UTxOs and metadata. */
|
|
100
74
|
async getTransaction(hash) {
|
|
101
75
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
102
76
|
// independent endpoints — fetch in parallel instead of 3 sequential roundtrips
|
|
@@ -110,7 +84,8 @@ class BlockfrostBackend {
|
|
|
110
84
|
label: md.label,
|
|
111
85
|
json: md.json_metadata,
|
|
112
86
|
})) : undefined;
|
|
113
|
-
|
|
87
|
+
// ledger view: inputs in ledger order, only what the ledger applied (see ledgerView)
|
|
88
|
+
return (0, mappers_1.ledgerView)({
|
|
114
89
|
hash: tx.hash,
|
|
115
90
|
blockHash: tx.block,
|
|
116
91
|
blockHeight: tx.block_height,
|
|
@@ -120,6 +95,10 @@ class BlockfrostBackend {
|
|
|
120
95
|
fee: tx.fees,
|
|
121
96
|
deposit: tx.deposit,
|
|
122
97
|
size: tx.size,
|
|
98
|
+
// `spends === 'collaterals'` in Ogmios terms: the script phase failed, so the
|
|
99
|
+
// ledger applied neither the declared inputs/outputs nor the declared mint.
|
|
100
|
+
spendsCollaterals: tx.valid_contract === false,
|
|
101
|
+
// one mixed list in Blockfrost's order; ledgerView groups and sorts it
|
|
123
102
|
inputs: txUtxos.inputs.map(input => ({
|
|
124
103
|
address: input.address,
|
|
125
104
|
txHash: input.tx_hash,
|
|
@@ -128,8 +107,8 @@ class BlockfrostBackend {
|
|
|
128
107
|
dataHash: input.data_hash,
|
|
129
108
|
inlineDatum: (0, tx_build_helper_1.inlineDatumToHex)(input.inline_datum),
|
|
130
109
|
referenceScriptHash: input.reference_script_hash,
|
|
131
|
-
|
|
132
|
-
|
|
110
|
+
isCollateral: input.collateral === true,
|
|
111
|
+
isReference: input.reference === true,
|
|
133
112
|
})),
|
|
134
113
|
outputs: txUtxos.outputs.map(output => ({
|
|
135
114
|
address: output.address,
|
|
@@ -142,14 +121,10 @@ class BlockfrostBackend {
|
|
|
142
121
|
referenceScriptHash: output.reference_script_hash,
|
|
143
122
|
})),
|
|
144
123
|
metadata: metadata,
|
|
145
|
-
};
|
|
124
|
+
});
|
|
146
125
|
}, this.name);
|
|
147
126
|
}
|
|
148
|
-
/**
|
|
149
|
-
* Get Transaction Metadata
|
|
150
|
-
* @param tx_hash transaction hash (hex)
|
|
151
|
-
* @returns {Promise<MetadataLabelTx[]>} transaction metadata list
|
|
152
|
-
*/
|
|
127
|
+
/** Metadata labels of a transaction (hash hex); NotFoundError when it has none. */
|
|
153
128
|
async getTransactionMetadata(tx_hash) {
|
|
154
129
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
155
130
|
const txMetadata = await this.api.txsMetadata(tx_hash);
|
|
@@ -163,21 +138,17 @@ class BlockfrostBackend {
|
|
|
163
138
|
}));
|
|
164
139
|
}, this.name);
|
|
165
140
|
}
|
|
166
|
-
/**
|
|
167
|
-
* Get Address Data (without transactions - use getAddressTransactions() separately)
|
|
168
|
-
* @param address bech32 address string
|
|
169
|
-
* @returns {Promise<Address>} address data
|
|
170
|
-
*/
|
|
141
|
+
/** Address data with UTxOs (no transactions — see getAddressTransactions()). */
|
|
171
142
|
async getAddress(address) {
|
|
172
143
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
173
144
|
const address_data = await this.api.addresses(address);
|
|
174
|
-
// *All variant paginates internally — addressesUtxos caps at 100 entries
|
|
175
|
-
// silently truncating larger wallets (wrong balances / spurious InsufficientFunds)
|
|
145
|
+
// *All variant paginates internally — plain addressesUtxos caps at 100 entries and silently truncates
|
|
176
146
|
const address_utxos = await this.api.addressesUtxosAll(address);
|
|
177
147
|
return {
|
|
178
148
|
address: address_data.address,
|
|
179
149
|
stakeAddress: address_data.stake_address,
|
|
180
|
-
|
|
150
|
+
// Blockfrost says shelley | byron; the other sources and the model use the CIP-19 kind
|
|
151
|
+
type: (0, mappers_1.decodeShelleyAddress)(address_data.address).type,
|
|
181
152
|
isScript: address_data.script,
|
|
182
153
|
amount: address_data.amount,
|
|
183
154
|
utxos: address_utxos.map(utxo => ({
|
|
@@ -193,11 +164,7 @@ class BlockfrostBackend {
|
|
|
193
164
|
};
|
|
194
165
|
}, this.name);
|
|
195
166
|
}
|
|
196
|
-
/**
|
|
197
|
-
* Get Address Transactions
|
|
198
|
-
* @param address bech32 address string
|
|
199
|
-
* @returns {Promise<Transaction[]>} list of transactions for this address
|
|
200
|
-
*/
|
|
167
|
+
/** Transactions of an address, most recent first, with full details (batched). */
|
|
201
168
|
async getAddressTransactions(address, limit) {
|
|
202
169
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
203
170
|
// Blockfrost rejects count > 100 with a 400 — clamp instead
|
|
@@ -216,11 +183,7 @@ class BlockfrostBackend {
|
|
|
216
183
|
return transactions;
|
|
217
184
|
}, this.name);
|
|
218
185
|
}
|
|
219
|
-
/**
|
|
220
|
-
* Get Address UTxOs
|
|
221
|
-
* @param address bech32 address string
|
|
222
|
-
* @returns {Promise<UTxO[]>} list of UTxOs
|
|
223
|
-
*/
|
|
186
|
+
/** UTxOs of an address. */
|
|
224
187
|
async getAddressUtxos(address) {
|
|
225
188
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
226
189
|
// *All variant paginates internally (plain addressesUtxos caps at 100 entries)
|
|
@@ -237,11 +200,7 @@ class BlockfrostBackend {
|
|
|
237
200
|
}));
|
|
238
201
|
}, this.name);
|
|
239
202
|
}
|
|
240
|
-
/**
|
|
241
|
-
* Get Pool Data
|
|
242
|
-
* @param poolId stake pool id (hex)
|
|
243
|
-
* @return {Promise<PoolData>} pool data
|
|
244
|
-
*/
|
|
203
|
+
/** Stake pool by id. */
|
|
245
204
|
async getPool(poolId) {
|
|
246
205
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
247
206
|
const poolData = await this.api.poolsById(poolId);
|
|
@@ -253,6 +212,7 @@ class BlockfrostBackend {
|
|
|
253
212
|
liveStake: poolData.live_stake || '0',
|
|
254
213
|
liveSize: poolData.live_size,
|
|
255
214
|
liveDelegators: poolData.live_delegators,
|
|
215
|
+
// Blockfrost reports saturation as a fraction (0.7542 = 75.42 %), the canonical unit
|
|
256
216
|
liveSaturation: poolData.live_saturation,
|
|
257
217
|
activeStake: poolData.active_stake || '0',
|
|
258
218
|
activeSize: poolData.active_size,
|
|
@@ -264,26 +224,14 @@ class BlockfrostBackend {
|
|
|
264
224
|
}, this.name);
|
|
265
225
|
}
|
|
266
226
|
/**
|
|
267
|
-
*
|
|
268
|
-
* Blockfrost does
|
|
269
|
-
* `initialMintTime` is left null. Filling it would cost an extra tx fetch.
|
|
270
|
-
* @param unit policyId + assetNameHex (concatenated hex)
|
|
271
|
-
* @return {Promise<AssetInfo>} canonical asset info
|
|
227
|
+
* Asset info (supply, mint history, CIP-25 + CIP-26 metadata); unit = policyId + assetNameHex.
|
|
228
|
+
* Blockfrost does not expose the initial-mint timestamp here, so `initialMintTime` stays null.
|
|
272
229
|
*/
|
|
273
230
|
async getAssetInfo(unit) {
|
|
274
231
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
275
232
|
const a = await this.api.assetsById(unit);
|
|
276
233
|
const reg = a.metadata ?? null;
|
|
277
|
-
const decodeUtf8 = (hex) =>
|
|
278
|
-
if (!hex)
|
|
279
|
-
return null;
|
|
280
|
-
try {
|
|
281
|
-
return Buffer.from(hex, 'hex').toString('utf8');
|
|
282
|
-
}
|
|
283
|
-
catch {
|
|
284
|
-
return null;
|
|
285
|
-
}
|
|
286
|
-
};
|
|
234
|
+
const decodeUtf8 = (hex) => (hex ? (0, mappers_1.decodeAssetName)(hex) : null);
|
|
287
235
|
return {
|
|
288
236
|
unit: a.asset,
|
|
289
237
|
policyId: a.policy_id,
|
|
@@ -305,14 +253,9 @@ class BlockfrostBackend {
|
|
|
305
253
|
}, this.name);
|
|
306
254
|
}
|
|
307
255
|
/**
|
|
308
|
-
*
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
* Cost: 1 extra API call per history entry. Failed tx fetches leave the
|
|
312
|
-
* timestamp fields null instead of failing the whole call (best-effort).
|
|
313
|
-
* @param unit policyId + assetNameHex (concatenated hex)
|
|
314
|
-
* @param limit max number of events (default 100, max 100 per Blockfrost page)
|
|
315
|
-
* @return {Promise<AssetHistoryEntry[]>} list of mint/burn events (most recent first)
|
|
256
|
+
* Mint/burn events of an asset, most recent first (max 100 per Blockfrost page).
|
|
257
|
+
* `assetsHistory` carries no block metadata; blockTime/blockHeight are backfilled with one
|
|
258
|
+
* best-effort `txs()` call per entry (a failed fetch leaves them null).
|
|
316
259
|
*/
|
|
317
260
|
async getAssetHistory(unit, limit = 100) {
|
|
318
261
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
@@ -350,11 +293,7 @@ class BlockfrostBackend {
|
|
|
350
293
|
});
|
|
351
294
|
}, this.name);
|
|
352
295
|
}
|
|
353
|
-
/**
|
|
354
|
-
* Get Drep Data
|
|
355
|
-
* @param drepId drep id (bech32)
|
|
356
|
-
* @return {Promise<DrepData>} drep data
|
|
357
|
-
*/
|
|
296
|
+
/** DRep by id (bech32). */
|
|
358
297
|
async getDrep(drepId) {
|
|
359
298
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
360
299
|
const drepData = await this.api.governance.drepsById(drepId);
|
|
@@ -369,11 +308,7 @@ class BlockfrostBackend {
|
|
|
369
308
|
};
|
|
370
309
|
}, this.name);
|
|
371
310
|
}
|
|
372
|
-
/**
|
|
373
|
-
* Get Account Data
|
|
374
|
-
* @param stakeAddress bech32 stake address
|
|
375
|
-
* @return {Promise<AccountData>} account data
|
|
376
|
-
*/
|
|
311
|
+
/** Account by stake address (bech32), with all its addresses and their UTxOs. */
|
|
377
312
|
async getAccount(stakeAddress) {
|
|
378
313
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
379
314
|
const accountData = await this.api.accounts(stakeAddress);
|
|
@@ -388,7 +323,8 @@ class BlockfrostBackend {
|
|
|
388
323
|
}
|
|
389
324
|
return {
|
|
390
325
|
stakeaddress: accountData.stake_address,
|
|
391
|
-
active
|
|
326
|
+
// `active` is the delegation state; registration lives in `registered`
|
|
327
|
+
active: accountData.registered,
|
|
392
328
|
activeEpoch: accountData.active_epoch ?? 0,
|
|
393
329
|
controlledAmount: accountData.controlled_amount,
|
|
394
330
|
rewardsSum: accountData.rewards_sum,
|
|
@@ -402,11 +338,7 @@ class BlockfrostBackend {
|
|
|
402
338
|
};
|
|
403
339
|
}, this.name);
|
|
404
340
|
}
|
|
405
|
-
/**
|
|
406
|
-
* Submit Transaction
|
|
407
|
-
* @param signedTxCbor hex-encoded signed transaction CBOR
|
|
408
|
-
* @returns {Promise<string>} transaction hash
|
|
409
|
-
*/
|
|
341
|
+
/** Submit a signed transaction (CBOR hex); returns the tx hash. */
|
|
410
342
|
async submitTransaction(signedTxCbor) {
|
|
411
343
|
const txBytes = Buffer.from(signedTxCbor, "hex");
|
|
412
344
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
@@ -414,10 +346,7 @@ class BlockfrostBackend {
|
|
|
414
346
|
return txHash;
|
|
415
347
|
}, this.name);
|
|
416
348
|
}
|
|
417
|
-
/**
|
|
418
|
-
* Get Protocol Parameters
|
|
419
|
-
* @returns {Promise<LedgerProtocolParameters>} protocol parameters
|
|
420
|
-
*/
|
|
349
|
+
/** Protocol parameters of the latest epoch. */
|
|
421
350
|
async getProtocolParameters() {
|
|
422
351
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
423
352
|
const protocolParams = await this.api.epochsLatestParameters();
|
|
@@ -459,10 +388,7 @@ class BlockfrostBackend {
|
|
|
459
388
|
};
|
|
460
389
|
}, this.name);
|
|
461
390
|
}
|
|
462
|
-
/**
|
|
463
|
-
* Get Latest Epoch Data
|
|
464
|
-
* @returns {Promise<EpochData>} latest epoch data
|
|
465
|
-
*/
|
|
391
|
+
/** Latest epoch. */
|
|
466
392
|
async getLatestEpoch() {
|
|
467
393
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
468
394
|
const epochData = await this.api.epochsLatest();
|
|
@@ -480,10 +406,7 @@ class BlockfrostBackend {
|
|
|
480
406
|
};
|
|
481
407
|
}, this.name);
|
|
482
408
|
}
|
|
483
|
-
/**
|
|
484
|
-
* Get Latest Block Data
|
|
485
|
-
* @returns {Promise<BlockData>} latest block data
|
|
486
|
-
*/
|
|
409
|
+
/** Latest block. */
|
|
487
410
|
async getLatestBlock() {
|
|
488
411
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
489
412
|
const blockdata = await this.api.blocksLatest();
|
|
@@ -501,10 +424,7 @@ class BlockfrostBackend {
|
|
|
501
424
|
};
|
|
502
425
|
}, this.name);
|
|
503
426
|
}
|
|
504
|
-
/**
|
|
505
|
-
* Get the latest chain tip slot.
|
|
506
|
-
* @returns {Promise<number>} current chain slot
|
|
507
|
-
*/
|
|
427
|
+
/** Latest chain tip slot; ProviderUnavailableError when the latest block has no slot. */
|
|
508
428
|
async getCurrentSlot() {
|
|
509
429
|
const block = await this.getLatestBlock();
|
|
510
430
|
if (block.slot == null) {
|
|
@@ -512,12 +432,7 @@ class BlockfrostBackend {
|
|
|
512
432
|
}
|
|
513
433
|
return block.slot;
|
|
514
434
|
}
|
|
515
|
-
/**
|
|
516
|
-
* Check whether a UTxO is still unspent via Blockfrost's `consumed_by_tx` field.
|
|
517
|
-
* @param txHash 64-char lowercase hex
|
|
518
|
-
* @param outputIndex non-negative integer
|
|
519
|
-
* @returns {Promise<boolean>} true iff the UTxO exists and is unspent
|
|
520
|
-
*/
|
|
435
|
+
/** Whether a UTxO is unspent, via Blockfrost's `consumed_by_tx`; false for unknown tx or out-of-range index. */
|
|
521
436
|
async isUtxoUnspent(txHash, outputIndex) {
|
|
522
437
|
if (!Number.isInteger(outputIndex) || outputIndex < 0)
|
|
523
438
|
return false;
|
|
@@ -527,9 +442,8 @@ class BlockfrostBackend {
|
|
|
527
442
|
const out = utxos?.outputs?.find(o => o.output_index === outputIndex);
|
|
528
443
|
if (!out)
|
|
529
444
|
return false;
|
|
530
|
-
// consumed_by_tx is optional on the openapi type (
|
|
531
|
-
//
|
|
532
|
-
// router falls through to another backend rather than silently lying.
|
|
445
|
+
// consumed_by_tx is optional on the openapi type (Blockfrost server >= 0.1.59); without it
|
|
446
|
+
// unspent cannot be proven — escalate so the router falls through to another backend.
|
|
533
447
|
const consumed = out.consumed_by_tx;
|
|
534
448
|
if (consumed === undefined) {
|
|
535
449
|
throw new errors_1.ProviderUnavailableError(`${this.name}: server does not expose consumed_by_tx — cannot determine UTxO status`, this.name);
|
|
@@ -548,12 +462,7 @@ class BlockfrostBackend {
|
|
|
548
462
|
//-----------------------------------------------------------------------------
|
|
549
463
|
/** Max concurrent Blockfrost API calls (free tier: ~10 req/s) */
|
|
550
464
|
static MAX_CONCURRENT = 10;
|
|
551
|
-
/**
|
|
552
|
-
* Get transaction hashes for an address (lightweight — no full tx details).
|
|
553
|
-
* @param address bech32 address
|
|
554
|
-
* @param limit maximum number of hashes
|
|
555
|
-
* @returns {Promise<string[]>} most recent tx hashes
|
|
556
|
-
*/
|
|
465
|
+
/** Most recent tx hashes of an address (no details). */
|
|
557
466
|
async getAddressTransactionHashes(address, limit) {
|
|
558
467
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
559
468
|
// Blockfrost rejects count > 100 with a 400 — clamp instead
|
|
@@ -562,12 +471,7 @@ class BlockfrostBackend {
|
|
|
562
471
|
return txs.map(tx => tx.tx_hash);
|
|
563
472
|
}, this.name);
|
|
564
473
|
}
|
|
565
|
-
/**
|
|
566
|
-
* Batch fetch multiple transactions by hash.
|
|
567
|
-
* Blockfrost has no batch endpoint — uses concurrency-limited parallel calls.
|
|
568
|
-
* @param txHashes array of transaction hashes
|
|
569
|
-
* @returns {Promise<Map<string, Transaction>>} map of hash -> Transaction
|
|
570
|
-
*/
|
|
474
|
+
/** Transactions by hash (map hash -> Transaction); no batch endpoint, so concurrency-limited parallel calls. */
|
|
571
475
|
async getTransactionsBatch(txHashes) {
|
|
572
476
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
573
477
|
const result = new Map();
|
|
@@ -583,12 +487,9 @@ class BlockfrostBackend {
|
|
|
583
487
|
}, this.name);
|
|
584
488
|
}
|
|
585
489
|
// ---------------------------------------------------------------------------
|
|
586
|
-
// PaginatingBackend — forward iteration for the chain crawler
|
|
490
|
+
// PaginatingBackend — forward iteration for the chain crawler
|
|
587
491
|
// ---------------------------------------------------------------------------
|
|
588
|
-
/**
|
|
589
|
-
* Map a Blockfrost block summary (from blocks()/blocksNext()) to our BlockData.
|
|
590
|
-
* Same shape getBlock() maps inline — kept private to avoid touching getBlock().
|
|
591
|
-
*/
|
|
492
|
+
/** Map a Blockfrost block summary (blocks()/blocksNext()) to BlockData. */
|
|
592
493
|
toBlockData(b) {
|
|
593
494
|
return {
|
|
594
495
|
time: b.time,
|
|
@@ -603,16 +504,11 @@ class BlockfrostBackend {
|
|
|
603
504
|
fees: b.fees,
|
|
604
505
|
};
|
|
605
506
|
}
|
|
606
|
-
/**
|
|
607
|
-
* Get a block by its height. Blockfrost's `blocks` endpoint accepts a height as
|
|
608
|
-
* well as a hash.
|
|
609
|
-
*/
|
|
507
|
+
/** Block by height; Blockfrost's `blocks` endpoint accepts a height as well as a hash. */
|
|
610
508
|
async getBlockByHeight(height) {
|
|
611
509
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => this.toBlockData(await this.api.blocks(height)), this.name);
|
|
612
510
|
}
|
|
613
|
-
/**
|
|
614
|
-
* Get up to `count` blocks immediately following `afterHash`, in ascending chain order.
|
|
615
|
-
*/
|
|
511
|
+
/** Up to `count` blocks immediately following `afterHash`, in ascending chain order. */
|
|
616
512
|
async getNextBlocks(afterHash, count) {
|
|
617
513
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
618
514
|
let blocks;
|
|
@@ -620,11 +516,9 @@ class BlockfrostBackend {
|
|
|
620
516
|
blocks = await this.api.blocksNext(afterHash, { count });
|
|
621
517
|
}
|
|
622
518
|
catch (err) {
|
|
623
|
-
// Blockfrost only knows canonical blocks
|
|
624
|
-
//
|
|
625
|
-
//
|
|
626
|
-
// NotFoundError would be treated as transient and the crawler would halt
|
|
627
|
-
// with an error streak instead of entering reorg recovery.
|
|
519
|
+
// Blockfrost only knows canonical blocks: a 404 on the anchor means the cursor block was
|
|
520
|
+
// orphaned by a reorg. Signal CHAIN_POINT_MISMATCH so the crawler enters reorg recovery;
|
|
521
|
+
// a plain NotFoundError would count as transient and halt it with an error streak.
|
|
628
522
|
const normalized = (0, errors_1.normalizeBackendError)(err, this.name);
|
|
629
523
|
if (normalized.statusCode === 404) {
|
|
630
524
|
throw new errors_1.ProviderUnavailableError(`CHAIN_POINT_MISMATCH: cursor block ${afterHash} is unknown to ${this.name} — likely orphaned by a reorg`, this.name);
|
|
@@ -634,10 +528,7 @@ class BlockfrostBackend {
|
|
|
634
528
|
return blocks.map(b => this.toBlockData(b));
|
|
635
529
|
}, this.name);
|
|
636
530
|
}
|
|
637
|
-
/**
|
|
638
|
-
* Get the full transaction list of a block in block order. Blockfrost returns tx
|
|
639
|
-
* hashes; details are batched via getTransactionsBatch. Order is preserved.
|
|
640
|
-
*/
|
|
531
|
+
/** Full transaction list of a block in block order (hashes from blocksTxsAll, details batched). */
|
|
641
532
|
async getBlockTransactions(blockHash) {
|
|
642
533
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
643
534
|
const hashes = await this.api.blocksTxsAll(blockHash);
|