@odatano/core 2.0.0-rc.5 → 2.0.0-rc.50
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 +99 -51
- package/@cds-models/CardanoAgentService/index.js +15 -0
- package/@cds-models/CardanoBackendService/index.d.ts +347 -0
- package/@cds-models/CardanoBackendService/index.js +40 -0
- package/@cds-models/CardanoIndexerService/index.d.ts +496 -11
- package/@cds-models/CardanoIndexerService/index.js +64 -0
- package/@cds-models/CardanoODataService/index.d.ts +414 -57
- package/@cds-models/CardanoODataService/index.js +42 -0
- package/@cds-models/CardanoSignService/index.d.ts +32 -19
- package/@cds-models/CardanoSignService/index.js +3 -0
- package/@cds-models/CardanoTransactionService/index.d.ts +58 -44
- package/@cds-models/CardanoTransactionService/index.js +4 -0
- package/@cds-models/CardanoWorkerService/index.d.ts +7 -22
- package/@cds-models/index.d.ts +101 -1
- package/@cds-models/index.js +16 -1
- package/@cds-models/odatano/cardano/index.d.ts +437 -32
- package/@cds-models/odatano/cardano/index.js +48 -0
- package/README.md +207 -167
- package/db/schema.cds +2402 -1705
- package/db/types.cds +446 -295
- package/package.json +41 -16
- package/scripts/migrate-schema.mjs +334 -0
- package/scripts/migrate-slot-leader.mjs +96 -0
- package/src/index.d.ts +20 -21
- package/src/index.js +45 -31
- package/src/plugin.js +17 -35
- package/srv/blockchain/asset-decimals.d.ts +7 -0
- package/srv/blockchain/asset-decimals.js +91 -0
- package/srv/blockchain/backends/blockfrost-backend.d.ts +25 -135
- package/srv/blockchain/backends/blockfrost-backend.js +66 -172
- package/srv/blockchain/backends/cardano-backend.d.ts +94 -186
- package/srv/blockchain/backends/cardano-backend.js +29 -5
- package/srv/blockchain/backends/koios-backend.d.ts +103 -168
- package/srv/blockchain/backends/koios-backend.js +428 -360
- package/srv/blockchain/backends/odatano-backend.d.ts +54 -0
- package/srv/blockchain/backends/odatano-backend.js +169 -0
- package/srv/blockchain/backends/ogmios-backend.d.ts +123 -190
- package/srv/blockchain/backends/ogmios-backend.js +637 -315
- package/srv/blockchain/backends/ogmios-frame-guard.d.ts +14 -0
- package/srv/blockchain/backends/ogmios-frame-guard.js +89 -0
- package/srv/blockchain/cardano-client.d.ts +61 -241
- package/srv/blockchain/cardano-client.js +253 -293
- package/srv/blockchain/cardano-indexer.d.ts +282 -281
- package/srv/blockchain/cardano-indexer.js +1551 -484
- package/srv/blockchain/cardano-tx-builder.d.ts +25 -89
- package/srv/blockchain/cardano-tx-builder.js +164 -140
- package/srv/blockchain/circuit-breaker.d.ts +1 -13
- package/srv/blockchain/circuit-breaker.js +5 -15
- package/srv/blockchain/crawler/account-snapshots.d.ts +29 -0
- package/srv/blockchain/crawler/account-snapshots.js +153 -0
- package/srv/blockchain/crawler/asset-decimals-backfill.d.ts +15 -0
- package/srv/blockchain/crawler/asset-decimals-backfill.js +56 -0
- package/srv/blockchain/crawler/asset-registry-backfill.d.ts +43 -0
- package/srv/blockchain/crawler/asset-registry-backfill.js +153 -0
- package/srv/blockchain/crawler/certificate-backfill.d.ts +52 -0
- package/srv/blockchain/crawler/certificate-backfill.js +162 -0
- package/srv/blockchain/crawler/crawler.d.ts +104 -81
- package/srv/blockchain/crawler/crawler.js +532 -160
- package/srv/blockchain/crawler/credential-backfill.d.ts +28 -0
- package/srv/blockchain/crawler/credential-backfill.js +124 -0
- package/srv/blockchain/crawler/hooks.d.ts +2 -17
- package/srv/blockchain/crawler/index.d.ts +1 -8
- package/srv/blockchain/crawler/index.js +31 -17
- package/srv/blockchain/crawler/input-asset-copies.d.ts +34 -0
- package/srv/blockchain/crawler/input-asset-copies.js +171 -0
- package/srv/blockchain/crawler/metadata-position-backfill.d.ts +16 -0
- package/srv/blockchain/crawler/metadata-position-backfill.js +55 -0
- package/srv/blockchain/crawler/output-datum-backfill.d.ts +39 -0
- package/srv/blockchain/crawler/output-datum-backfill.js +110 -0
- package/srv/blockchain/crawler/sync-state.d.ts +27 -47
- package/srv/blockchain/crawler/sync-state.js +113 -63
- package/srv/blockchain/crawler/transaction-backfill.d.ts +44 -0
- package/srv/blockchain/crawler/transaction-backfill.js +278 -0
- package/srv/blockchain/crawler/utxo-set-import.d.ts +66 -0
- package/srv/blockchain/crawler/utxo-set-import.js +399 -0
- package/srv/blockchain/ledger-state.d.ts +62 -0
- package/srv/blockchain/ledger-state.js +419 -0
- package/srv/blockchain/pending-spends.d.ts +16 -0
- package/srv/blockchain/pending-spends.js +81 -0
- package/srv/blockchain/pool-metadata.d.ts +15 -0
- package/srv/blockchain/pool-metadata.js +132 -0
- package/srv/blockchain/request-coalescer.d.ts +2 -16
- package/srv/blockchain/request-coalescer.js +2 -16
- package/srv/blockchain/signing/cose-verifier.d.ts +3 -17
- package/srv/blockchain/signing/cose-verifier.js +146 -70
- package/srv/blockchain/signing/external-signer.d.ts +15 -115
- package/srv/blockchain/signing/external-signer.js +17 -126
- package/srv/blockchain/signing/hsm-signer.d.ts +10 -54
- package/srv/blockchain/signing/hsm-signer.js +28 -79
- package/srv/blockchain/signing/signature-verifier.d.ts +9 -47
- package/srv/blockchain/signing/signature-verifier.js +70 -83
- package/srv/blockchain/signing/submission-finalizer.d.ts +23 -45
- package/srv/blockchain/signing/submission-finalizer.js +219 -86
- package/srv/blockchain/stored-chain.d.ts +20 -0
- package/srv/blockchain/stored-chain.js +237 -0
- package/srv/blockchain/transaction-building/buildooor-tx.d.ts +31 -229
- package/srv/blockchain/transaction-building/buildooor-tx.js +652 -416
- package/srv/blockchain/transaction-building/cardano-tx.d.ts +9 -37
- package/srv/blockchain/transaction-presence.d.ts +5 -0
- package/srv/blockchain/transaction-presence.js +29 -0
- package/srv/blockchain/transaction-rows.d.ts +12 -0
- package/srv/blockchain/transaction-rows.js +44 -0
- package/srv/blockchain/wallet-worker/build-request.d.ts +5 -20
- package/srv/blockchain/wallet-worker/build-request.js +47 -30
- package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +5 -46
- package/srv/blockchain/wallet-worker/confirmation-tracker.js +25 -45
- package/srv/blockchain/wallet-worker/index.d.ts +1 -1
- package/srv/blockchain/wallet-worker/index.js +3 -11
- package/srv/blockchain/wallet-worker/job-store.d.ts +30 -148
- package/srv/blockchain/wallet-worker/job-store.js +101 -201
- package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +2 -26
- package/srv/blockchain/wallet-worker/lease-heartbeat.js +6 -28
- package/srv/blockchain/wallet-worker/signers.d.ts +5 -24
- package/srv/blockchain/wallet-worker/signers.js +4 -12
- package/srv/blockchain/wallet-worker/wallet-worker.d.ts +8 -80
- package/srv/blockchain/wallet-worker/wallet-worker.js +107 -155
- package/srv/cardano-agent-service.cds +122 -84
- package/srv/cardano-agent-service.js +4 -9
- package/srv/cardano-backend-service.cds +78 -0
- package/srv/cardano-backend-service.d.ts +2 -0
- package/srv/cardano-backend-service.js +242 -0
- package/srv/cardano-indexer-service.cds +387 -73
- package/srv/cardano-indexer-service.d.ts +5 -1
- package/srv/cardano-indexer-service.js +532 -16
- package/srv/cardano-service.cds +424 -269
- package/srv/cardano-service.js +289 -201
- package/srv/cardano-sign-service.cds +201 -180
- package/srv/cardano-sign-service.js +71 -201
- package/srv/cardano-tx-service.cds +451 -370
- package/srv/cardano-tx-service.js +271 -289
- package/srv/cardano-ui.cds +16 -16
- package/srv/cardano-worker-service.cds +118 -125
- package/srv/cardano-worker-service.js +52 -61
- package/srv/cbor/cip68.d.ts +13 -0
- package/srv/cbor/cip68.js +56 -0
- package/srv/cbor/index.d.ts +3 -1
- package/srv/cbor/index.js +9 -1
- package/srv/cbor/parse.d.ts +30 -18
- package/srv/cbor/parse.js +44 -9
- package/srv/cbor/plutus-data-json.d.ts +20 -0
- package/srv/cbor/plutus-data-json.js +32 -0
- package/srv/config.d.ts +113 -0
- package/srv/config.js +409 -0
- package/srv/server.d.ts +15 -110
- package/srv/server.js +84 -404
- package/srv/utils/agent-access.d.ts +9 -0
- package/srv/utils/agent-access.js +67 -0
- package/srv/utils/agent-grants-config.d.ts +0 -46
- package/srv/utils/agent-grants-config.js +17 -85
- package/srv/utils/agent-grants.d.ts +106 -122
- package/srv/utils/agent-grants.js +538 -236
- package/srv/utils/agent-token-auth.d.ts +4 -99
- package/srv/utils/agent-token-auth.js +18 -182
- package/srv/utils/backend-request-handler.d.ts +3 -17
- package/srv/utils/backend-request-handler.js +3 -18
- package/srv/utils/collections.d.ts +3 -10
- package/srv/utils/collections.js +3 -10
- package/srv/utils/const.d.ts +23 -74
- package/srv/utils/const.js +32 -79
- package/srv/utils/crypto.d.ts +3 -12
- package/srv/utils/crypto.js +6 -21
- package/srv/utils/db-indexes.d.ts +27 -0
- package/srv/utils/db-indexes.js +120 -0
- package/srv/utils/db-sanitize.d.ts +20 -0
- package/srv/utils/db-sanitize.js +80 -0
- package/srv/utils/deep-json.d.ts +6 -0
- package/srv/utils/deep-json.js +240 -0
- package/srv/utils/epoch-slots.d.ts +13 -0
- package/srv/utils/epoch-slots.js +38 -0
- package/srv/utils/error-codes.d.ts +22 -75
- package/srv/utils/error-codes.js +23 -72
- package/srv/utils/errors.d.ts +46 -187
- package/srv/utils/errors.js +114 -230
- package/srv/utils/liveness.d.ts +12 -0
- package/srv/utils/liveness.js +35 -0
- package/srv/utils/mappers.d.ts +102 -223
- package/srv/utils/mappers.js +387 -316
- package/srv/utils/network-context.js +2 -13
- package/srv/utils/paging.d.ts +31 -0
- package/srv/utils/paging.js +43 -0
- package/srv/utils/pg-inline-json.d.ts +8 -0
- package/srv/utils/pg-inline-json.js +58 -0
- package/srv/utils/pg-order-nulls.d.ts +14 -0
- package/srv/utils/pg-order-nulls.js +54 -0
- package/srv/utils/plutus-placeholders.d.ts +16 -22
- package/srv/utils/plutus-placeholders.js +62 -33
- package/srv/utils/rate-limiter.d.ts +2 -21
- package/srv/utils/rate-limiter.js +5 -17
- package/srv/utils/readiness.d.ts +12 -0
- package/srv/utils/readiness.js +29 -0
- package/srv/utils/reference-script.d.ts +19 -0
- package/srv/utils/reference-script.js +84 -0
- package/srv/utils/result-numbers.d.ts +15 -0
- package/srv/utils/result-numbers.js +61 -0
- package/srv/utils/service-events.d.ts +0 -24
- package/srv/utils/service-events.js +3 -25
- package/srv/utils/signing-helper.d.ts +3 -20
- package/srv/utils/signing-helper.js +35 -64
- package/srv/utils/tx-build-helper.d.ts +10 -105
- package/srv/utils/tx-build-helper.js +81 -144
- package/srv/utils/tx-request-parsers.d.ts +82 -33
- package/srv/utils/tx-request-parsers.js +401 -49
- package/srv/utils/tx-utils.d.ts +3 -27
- package/srv/utils/tx-utils.js +32 -50
- package/srv/utils/types.d.ts +261 -191
- package/srv/utils/types.js +2 -6
- package/srv/utils/validators.d.ts +22 -92
- package/srv/utils/validators.js +50 -149
|
@@ -5,27 +5,20 @@ const blockfrost_js_1 = require("@blockfrost/blockfrost-js");
|
|
|
5
5
|
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
|
+
const pool_metadata_1 = require("../pool-metadata");
|
|
8
9
|
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
|
-
*/
|
|
10
|
+
/** CardanoBackend + PaginatingBackend implementation on the Blockfrost API SDK. */
|
|
13
11
|
class BlockfrostBackend {
|
|
14
12
|
name = 'blockfrost';
|
|
15
13
|
api;
|
|
16
14
|
network;
|
|
17
15
|
timeoutMs;
|
|
18
|
-
/**
|
|
19
|
-
* Constructor
|
|
20
|
-
*/
|
|
21
16
|
constructor(network, timeoutMs, projectId, customBackend) {
|
|
22
17
|
if (!projectId && !customBackend) {
|
|
23
18
|
throw new errors_1.BackendInitError('blockfrost', new Error('Either projectId (BLOCKFROST_API_KEY) or customBackend (BLOCKFROST_CUSTOM_BACKEND) is required'));
|
|
24
19
|
}
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
// SDK validator accepts customBackend OR projectId — this substitution is purely
|
|
28
|
-
// for the runtime HTTP header.
|
|
20
|
+
// Self-hosted Blockfrost-compatible servers reject an empty project_id header,
|
|
21
|
+
// even without authentication, so a placeholder is sent.
|
|
29
22
|
const effectiveProjectId = projectId || 'self-hosted';
|
|
30
23
|
this.api = new blockfrost_js_1.BlockFrostAPI({
|
|
31
24
|
projectId: effectiveProjectId,
|
|
@@ -35,9 +28,6 @@ class BlockfrostBackend {
|
|
|
35
28
|
this.network = network;
|
|
36
29
|
this.timeoutMs = timeoutMs;
|
|
37
30
|
}
|
|
38
|
-
/**
|
|
39
|
-
* Initialize the backend
|
|
40
|
-
*/
|
|
41
31
|
async init() {
|
|
42
32
|
this.api.options.requestTimeout = this.timeoutMs;
|
|
43
33
|
// Test connection by fetching latest block
|
|
@@ -49,10 +39,7 @@ class BlockfrostBackend {
|
|
|
49
39
|
}
|
|
50
40
|
return true;
|
|
51
41
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Get Network Information
|
|
54
|
-
* @returns {Promise<NetworkInformation>} network information
|
|
55
|
-
*/
|
|
42
|
+
/** Network information (supply, stake). */
|
|
56
43
|
async getNetworkInformation() {
|
|
57
44
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
58
45
|
const networkInfo = await this.api.network();
|
|
@@ -62,19 +49,11 @@ class BlockfrostBackend {
|
|
|
62
49
|
};
|
|
63
50
|
}, this.name);
|
|
64
51
|
}
|
|
65
|
-
/**
|
|
66
|
-
* Get Block Data
|
|
67
|
-
* @param blockHash block hash (hex)
|
|
68
|
-
* @returns {Promise<BlockData>} block data
|
|
69
|
-
*/
|
|
52
|
+
/** Block by hash (hex). */
|
|
70
53
|
async getBlock(blockHash) {
|
|
71
54
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => this.toBlockData(await this.api.blocks(blockHash)), this.name);
|
|
72
55
|
}
|
|
73
|
-
/**
|
|
74
|
-
* Get Epoch Data
|
|
75
|
-
* @param epochNumber epoch number
|
|
76
|
-
* @returns {Promise<EpochData>} epoch data
|
|
77
|
-
*/
|
|
56
|
+
/** Epoch by number. */
|
|
78
57
|
async getEpoch(epochNumber) {
|
|
79
58
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
80
59
|
const epochData = await this.api.epochs(epochNumber);
|
|
@@ -92,14 +71,10 @@ class BlockfrostBackend {
|
|
|
92
71
|
};
|
|
93
72
|
}, this.name);
|
|
94
73
|
}
|
|
95
|
-
/**
|
|
96
|
-
* Get Transaction Data
|
|
97
|
-
* @param hash transaction hash (hex)
|
|
98
|
-
* @returns {Promise<Transaction>} transaction data
|
|
99
|
-
*/
|
|
74
|
+
/** Transaction by hash (hex), with UTxOs and metadata. */
|
|
100
75
|
async getTransaction(hash) {
|
|
101
76
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
102
|
-
// independent endpoints
|
|
77
|
+
// independent endpoints, fetched in parallel
|
|
103
78
|
const [tx, txUtxos, txMetadata] = await Promise.all([
|
|
104
79
|
this.api.txs(hash),
|
|
105
80
|
this.api.txsUtxos(hash),
|
|
@@ -110,7 +85,8 @@ class BlockfrostBackend {
|
|
|
110
85
|
label: md.label,
|
|
111
86
|
json: md.json_metadata,
|
|
112
87
|
})) : undefined;
|
|
113
|
-
|
|
88
|
+
// ledger view: inputs in ledger order, only what the ledger applied (see ledgerView)
|
|
89
|
+
return (0, mappers_1.ledgerView)({
|
|
114
90
|
hash: tx.hash,
|
|
115
91
|
blockHash: tx.block,
|
|
116
92
|
blockHeight: tx.block_height,
|
|
@@ -120,6 +96,10 @@ class BlockfrostBackend {
|
|
|
120
96
|
fee: tx.fees,
|
|
121
97
|
deposit: tx.deposit,
|
|
122
98
|
size: tx.size,
|
|
99
|
+
// `spends === 'collaterals'` in Ogmios terms: the script phase failed, so the
|
|
100
|
+
// ledger applied neither the declared inputs/outputs nor the declared mint.
|
|
101
|
+
spendsCollaterals: tx.valid_contract === false,
|
|
102
|
+
// one mixed list in Blockfrost's order; ledgerView groups and sorts it
|
|
123
103
|
inputs: txUtxos.inputs.map(input => ({
|
|
124
104
|
address: input.address,
|
|
125
105
|
txHash: input.tx_hash,
|
|
@@ -128,8 +108,8 @@ class BlockfrostBackend {
|
|
|
128
108
|
dataHash: input.data_hash,
|
|
129
109
|
inlineDatum: (0, tx_build_helper_1.inlineDatumToHex)(input.inline_datum),
|
|
130
110
|
referenceScriptHash: input.reference_script_hash,
|
|
131
|
-
|
|
132
|
-
|
|
111
|
+
isCollateral: input.collateral === true,
|
|
112
|
+
isReference: input.reference === true,
|
|
133
113
|
})),
|
|
134
114
|
outputs: txUtxos.outputs.map(output => ({
|
|
135
115
|
address: output.address,
|
|
@@ -142,14 +122,10 @@ class BlockfrostBackend {
|
|
|
142
122
|
referenceScriptHash: output.reference_script_hash,
|
|
143
123
|
})),
|
|
144
124
|
metadata: metadata,
|
|
145
|
-
};
|
|
125
|
+
});
|
|
146
126
|
}, this.name);
|
|
147
127
|
}
|
|
148
|
-
/**
|
|
149
|
-
* Get Transaction Metadata
|
|
150
|
-
* @param tx_hash transaction hash (hex)
|
|
151
|
-
* @returns {Promise<MetadataLabelTx[]>} transaction metadata list
|
|
152
|
-
*/
|
|
128
|
+
/** Metadata labels of a transaction (hash hex); NotFoundError when it has none. */
|
|
153
129
|
async getTransactionMetadata(tx_hash) {
|
|
154
130
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
155
131
|
const txMetadata = await this.api.txsMetadata(tx_hash);
|
|
@@ -163,21 +139,17 @@ class BlockfrostBackend {
|
|
|
163
139
|
}));
|
|
164
140
|
}, this.name);
|
|
165
141
|
}
|
|
166
|
-
/**
|
|
167
|
-
* Get Address Data (without transactions - use getAddressTransactions() separately)
|
|
168
|
-
* @param address bech32 address string
|
|
169
|
-
* @returns {Promise<Address>} address data
|
|
170
|
-
*/
|
|
142
|
+
/** Address data with UTxOs. Transactions come from getAddressTransactions(). */
|
|
171
143
|
async getAddress(address) {
|
|
172
144
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
173
145
|
const address_data = await this.api.addresses(address);
|
|
174
|
-
// *All variant
|
|
175
|
-
// silently truncating larger wallets (wrong balances / spurious InsufficientFunds)
|
|
146
|
+
// plain addressesUtxos silently stops at 100 entries; the *All variant pages through all of them
|
|
176
147
|
const address_utxos = await this.api.addressesUtxosAll(address);
|
|
177
148
|
return {
|
|
178
149
|
address: address_data.address,
|
|
179
150
|
stakeAddress: address_data.stake_address,
|
|
180
|
-
|
|
151
|
+
// Blockfrost says shelley | byron; the other sources and the model use the CIP-19 kind
|
|
152
|
+
type: (0, mappers_1.decodeShelleyAddress)(address_data.address).type,
|
|
181
153
|
isScript: address_data.script,
|
|
182
154
|
amount: address_data.amount,
|
|
183
155
|
utxos: address_utxos.map(utxo => ({
|
|
@@ -193,14 +165,10 @@ class BlockfrostBackend {
|
|
|
193
165
|
};
|
|
194
166
|
}, this.name);
|
|
195
167
|
}
|
|
196
|
-
/**
|
|
197
|
-
* Get Address Transactions
|
|
198
|
-
* @param address bech32 address string
|
|
199
|
-
* @returns {Promise<Transaction[]>} list of transactions for this address
|
|
200
|
-
*/
|
|
168
|
+
/** Transactions of an address, most recent first, with full details (batched). */
|
|
201
169
|
async getAddressTransactions(address, limit) {
|
|
202
170
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
203
|
-
// Blockfrost rejects count > 100 with a 400
|
|
171
|
+
// Blockfrost rejects count > 100 with a 400
|
|
204
172
|
const count = limit === undefined ? undefined : Math.min(Math.max(limit, 1), 100);
|
|
205
173
|
const address_txs = await this.api.addressesTransactions(address, { order: 'desc', count });
|
|
206
174
|
const txHashes = address_txs.map(tx => tx.tx_hash);
|
|
@@ -216,11 +184,7 @@ class BlockfrostBackend {
|
|
|
216
184
|
return transactions;
|
|
217
185
|
}, this.name);
|
|
218
186
|
}
|
|
219
|
-
/**
|
|
220
|
-
* Get Address UTxOs
|
|
221
|
-
* @param address bech32 address string
|
|
222
|
-
* @returns {Promise<UTxO[]>} list of UTxOs
|
|
223
|
-
*/
|
|
187
|
+
/** UTxOs of an address. */
|
|
224
188
|
async getAddressUtxos(address) {
|
|
225
189
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
226
190
|
// *All variant paginates internally (plain addressesUtxos caps at 100 entries)
|
|
@@ -237,14 +201,11 @@ class BlockfrostBackend {
|
|
|
237
201
|
}));
|
|
238
202
|
}, this.name);
|
|
239
203
|
}
|
|
240
|
-
/**
|
|
241
|
-
* Get Pool Data
|
|
242
|
-
* @param poolId stake pool id (hex)
|
|
243
|
-
* @return {Promise<PoolData>} pool data
|
|
244
|
-
*/
|
|
204
|
+
/** Stake pool by id. */
|
|
245
205
|
async getPool(poolId) {
|
|
246
206
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
247
|
-
const poolData = await this.api.poolsById(poolId);
|
|
207
|
+
const [poolData, registered] = await Promise.all([this.api.poolsById(poolId), this.api.poolMetadata(poolId)]);
|
|
208
|
+
const metadata = (0, pool_metadata_1.validPoolMetadata)(registered);
|
|
248
209
|
return {
|
|
249
210
|
poolId: poolData.pool_id,
|
|
250
211
|
vrfKeyHash: poolData.vrf_key,
|
|
@@ -253,6 +214,7 @@ class BlockfrostBackend {
|
|
|
253
214
|
liveStake: poolData.live_stake || '0',
|
|
254
215
|
liveSize: poolData.live_size,
|
|
255
216
|
liveDelegators: poolData.live_delegators,
|
|
217
|
+
// Blockfrost reports saturation as a fraction (0.7542 = 75.42 %), the canonical unit
|
|
256
218
|
liveSaturation: poolData.live_saturation,
|
|
257
219
|
activeStake: poolData.active_stake || '0',
|
|
258
220
|
activeSize: poolData.active_size,
|
|
@@ -260,30 +222,21 @@ class BlockfrostBackend {
|
|
|
260
222
|
margin: poolData.margin_cost,
|
|
261
223
|
fixedCost: poolData.fixed_cost || '0',
|
|
262
224
|
rewardAccount: poolData.reward_account,
|
|
225
|
+
metadataUrl: registered.url ?? null,
|
|
226
|
+
metadataHash: registered.hash ?? null,
|
|
227
|
+
name: metadata?.name ?? null,
|
|
228
|
+
ticker: metadata?.ticker ?? null,
|
|
229
|
+
homepage: metadata?.homepage ?? null,
|
|
230
|
+
description: metadata?.description ?? null,
|
|
263
231
|
};
|
|
264
232
|
}, this.name);
|
|
265
233
|
}
|
|
266
|
-
/**
|
|
267
|
-
* Get Asset Info (supply, mint history, CIP-25 + CIP-26 metadata).
|
|
268
|
-
* Blockfrost does NOT expose initial-mint timestamp in this endpoint —
|
|
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
|
|
272
|
-
*/
|
|
234
|
+
/** Asset info. Blockfrost has no initial-mint timestamp here, so `initialMintTime` stays null. */
|
|
273
235
|
async getAssetInfo(unit) {
|
|
274
236
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
275
237
|
const a = await this.api.assetsById(unit);
|
|
276
238
|
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
|
-
};
|
|
239
|
+
const decodeUtf8 = (hex) => (hex ? (0, mappers_1.decodeAssetName)(hex) : null);
|
|
287
240
|
return {
|
|
288
241
|
unit: a.asset,
|
|
289
242
|
policyId: a.policy_id,
|
|
@@ -304,16 +257,8 @@ class BlockfrostBackend {
|
|
|
304
257
|
};
|
|
305
258
|
}, this.name);
|
|
306
259
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
* Blockfrost's `assetsHistory` returns tx_hash + action + amount only; we
|
|
310
|
-
* backfill `blockTime` and `blockHeight` via concurrent `api.txs(...)` calls.
|
|
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)
|
|
316
|
-
*/
|
|
260
|
+
// Mint and burn events, newest first, at most 100 per page. `assetsHistory` has no block data,
|
|
261
|
+
// so one `txs()` call per entry fills blockTime and blockHeight. A failed call leaves them null.
|
|
317
262
|
async getAssetHistory(unit, limit = 100) {
|
|
318
263
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
319
264
|
const count = Math.min(Math.max(1, limit), 100);
|
|
@@ -350,11 +295,7 @@ class BlockfrostBackend {
|
|
|
350
295
|
});
|
|
351
296
|
}, this.name);
|
|
352
297
|
}
|
|
353
|
-
/**
|
|
354
|
-
* Get Drep Data
|
|
355
|
-
* @param drepId drep id (bech32)
|
|
356
|
-
* @return {Promise<DrepData>} drep data
|
|
357
|
-
*/
|
|
298
|
+
/** DRep by id (bech32). */
|
|
358
299
|
async getDrep(drepId) {
|
|
359
300
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
360
301
|
const drepData = await this.api.governance.drepsById(drepId);
|
|
@@ -369,11 +310,7 @@ class BlockfrostBackend {
|
|
|
369
310
|
};
|
|
370
311
|
}, this.name);
|
|
371
312
|
}
|
|
372
|
-
/**
|
|
373
|
-
* Get Account Data
|
|
374
|
-
* @param stakeAddress bech32 stake address
|
|
375
|
-
* @return {Promise<AccountData>} account data
|
|
376
|
-
*/
|
|
313
|
+
/** Account by stake address (bech32), with all its addresses and their UTxOs. */
|
|
377
314
|
async getAccount(stakeAddress) {
|
|
378
315
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
379
316
|
const accountData = await this.api.accounts(stakeAddress);
|
|
@@ -388,7 +325,8 @@ class BlockfrostBackend {
|
|
|
388
325
|
}
|
|
389
326
|
return {
|
|
390
327
|
stakeaddress: accountData.stake_address,
|
|
391
|
-
active
|
|
328
|
+
// `active` is the delegation state; registration lives in `registered`
|
|
329
|
+
active: accountData.registered,
|
|
392
330
|
activeEpoch: accountData.active_epoch ?? 0,
|
|
393
331
|
controlledAmount: accountData.controlled_amount,
|
|
394
332
|
rewardsSum: accountData.rewards_sum,
|
|
@@ -402,11 +340,7 @@ class BlockfrostBackend {
|
|
|
402
340
|
};
|
|
403
341
|
}, this.name);
|
|
404
342
|
}
|
|
405
|
-
/**
|
|
406
|
-
* Submit Transaction
|
|
407
|
-
* @param signedTxCbor hex-encoded signed transaction CBOR
|
|
408
|
-
* @returns {Promise<string>} transaction hash
|
|
409
|
-
*/
|
|
343
|
+
/** Submit a signed transaction (CBOR hex); returns the tx hash. */
|
|
410
344
|
async submitTransaction(signedTxCbor) {
|
|
411
345
|
const txBytes = Buffer.from(signedTxCbor, "hex");
|
|
412
346
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
@@ -414,10 +348,7 @@ class BlockfrostBackend {
|
|
|
414
348
|
return txHash;
|
|
415
349
|
}, this.name);
|
|
416
350
|
}
|
|
417
|
-
/**
|
|
418
|
-
* Get Protocol Parameters
|
|
419
|
-
* @returns {Promise<LedgerProtocolParameters>} protocol parameters
|
|
420
|
-
*/
|
|
351
|
+
/** Protocol parameters of the latest epoch. */
|
|
421
352
|
async getProtocolParameters() {
|
|
422
353
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
423
354
|
const protocolParams = await this.api.epochsLatestParameters();
|
|
@@ -440,6 +371,7 @@ class BlockfrostBackend {
|
|
|
440
371
|
collateralPercent: protocolParams.collateral_percent,
|
|
441
372
|
maxCollateralInputs: protocolParams.max_collateral_inputs,
|
|
442
373
|
coinsPerUtxoSize: protocolParams.coins_per_utxo_size,
|
|
374
|
+
minFeeRefScriptCostPerByte: protocolParams.min_fee_ref_script_cost_per_byte ?? null,
|
|
443
375
|
maxBlockHeaderSize: protocolParams.max_block_header_size,
|
|
444
376
|
maxTxSize: protocolParams.max_tx_size,
|
|
445
377
|
keyDeposit: protocolParams.key_deposit,
|
|
@@ -459,10 +391,7 @@ class BlockfrostBackend {
|
|
|
459
391
|
};
|
|
460
392
|
}, this.name);
|
|
461
393
|
}
|
|
462
|
-
/**
|
|
463
|
-
* Get Latest Epoch Data
|
|
464
|
-
* @returns {Promise<EpochData>} latest epoch data
|
|
465
|
-
*/
|
|
394
|
+
/** Latest epoch. */
|
|
466
395
|
async getLatestEpoch() {
|
|
467
396
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
468
397
|
const epochData = await this.api.epochsLatest();
|
|
@@ -480,10 +409,7 @@ class BlockfrostBackend {
|
|
|
480
409
|
};
|
|
481
410
|
}, this.name);
|
|
482
411
|
}
|
|
483
|
-
/**
|
|
484
|
-
* Get Latest Block Data
|
|
485
|
-
* @returns {Promise<BlockData>} latest block data
|
|
486
|
-
*/
|
|
412
|
+
/** Latest block. */
|
|
487
413
|
async getLatestBlock() {
|
|
488
414
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
489
415
|
const blockdata = await this.api.blocksLatest();
|
|
@@ -501,10 +427,7 @@ class BlockfrostBackend {
|
|
|
501
427
|
};
|
|
502
428
|
}, this.name);
|
|
503
429
|
}
|
|
504
|
-
/**
|
|
505
|
-
* Get the latest chain tip slot.
|
|
506
|
-
* @returns {Promise<number>} current chain slot
|
|
507
|
-
*/
|
|
430
|
+
/** Latest chain tip slot; ProviderUnavailableError when the latest block has no slot. */
|
|
508
431
|
async getCurrentSlot() {
|
|
509
432
|
const block = await this.getLatestBlock();
|
|
510
433
|
if (block.slot == null) {
|
|
@@ -512,12 +435,7 @@ class BlockfrostBackend {
|
|
|
512
435
|
}
|
|
513
436
|
return block.slot;
|
|
514
437
|
}
|
|
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
|
-
*/
|
|
438
|
+
/** Whether a UTxO is unspent, via Blockfrost's `consumed_by_tx`; false for unknown tx or out-of-range index. */
|
|
521
439
|
async isUtxoUnspent(txHash, outputIndex) {
|
|
522
440
|
if (!Number.isInteger(outputIndex) || outputIndex < 0)
|
|
523
441
|
return false;
|
|
@@ -527,12 +445,11 @@ class BlockfrostBackend {
|
|
|
527
445
|
const out = utxos?.outputs?.find(o => o.output_index === outputIndex);
|
|
528
446
|
if (!out)
|
|
529
447
|
return false;
|
|
530
|
-
//
|
|
531
|
-
//
|
|
532
|
-
// router falls through to another backend rather than silently lying.
|
|
448
|
+
// Blockfrost servers before 0.1.59 omit consumed_by_tx. Without it unspent cannot be
|
|
449
|
+
// proven, so the router must fall through to another backend.
|
|
533
450
|
const consumed = out.consumed_by_tx;
|
|
534
451
|
if (consumed === undefined) {
|
|
535
|
-
throw new errors_1.ProviderUnavailableError(`${this.name}: server does not expose consumed_by_tx
|
|
452
|
+
throw new errors_1.ProviderUnavailableError(`${this.name}: server does not expose consumed_by_tx, cannot determine UTxO status`, this.name);
|
|
536
453
|
}
|
|
537
454
|
return consumed === null;
|
|
538
455
|
}, this.name);
|
|
@@ -548,26 +465,16 @@ class BlockfrostBackend {
|
|
|
548
465
|
//-----------------------------------------------------------------------------
|
|
549
466
|
/** Max concurrent Blockfrost API calls (free tier: ~10 req/s) */
|
|
550
467
|
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
|
-
*/
|
|
468
|
+
/** Most recent tx hashes of an address (no details). */
|
|
557
469
|
async getAddressTransactionHashes(address, limit) {
|
|
558
470
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
559
|
-
// Blockfrost rejects count > 100 with a 400
|
|
471
|
+
// Blockfrost rejects count > 100 with a 400
|
|
560
472
|
const count = Math.min(Math.max(limit, 1), 100);
|
|
561
473
|
const txs = await this.api.addressesTransactions(address, { order: 'desc', count });
|
|
562
474
|
return txs.map(tx => tx.tx_hash);
|
|
563
475
|
}, this.name);
|
|
564
476
|
}
|
|
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
|
-
*/
|
|
477
|
+
/** Transactions by hash (map hash -> Transaction); no batch endpoint, so concurrency-limited parallel calls. */
|
|
571
478
|
async getTransactionsBatch(txHashes) {
|
|
572
479
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
573
480
|
const result = new Map();
|
|
@@ -583,12 +490,9 @@ class BlockfrostBackend {
|
|
|
583
490
|
}, this.name);
|
|
584
491
|
}
|
|
585
492
|
// ---------------------------------------------------------------------------
|
|
586
|
-
// PaginatingBackend
|
|
493
|
+
// PaginatingBackend: forward iteration for the chain crawler
|
|
587
494
|
// ---------------------------------------------------------------------------
|
|
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
|
-
*/
|
|
495
|
+
/** Map a Blockfrost block summary (blocks()/blocksNext()) to BlockData. */
|
|
592
496
|
toBlockData(b) {
|
|
593
497
|
return {
|
|
594
498
|
time: b.time,
|
|
@@ -603,16 +507,11 @@ class BlockfrostBackend {
|
|
|
603
507
|
fees: b.fees,
|
|
604
508
|
};
|
|
605
509
|
}
|
|
606
|
-
/**
|
|
607
|
-
* Get a block by its height. Blockfrost's `blocks` endpoint accepts a height as
|
|
608
|
-
* well as a hash.
|
|
609
|
-
*/
|
|
510
|
+
/** Block by height; Blockfrost's `blocks` endpoint accepts a height as well as a hash. */
|
|
610
511
|
async getBlockByHeight(height) {
|
|
611
512
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => this.toBlockData(await this.api.blocks(height)), this.name);
|
|
612
513
|
}
|
|
613
|
-
/**
|
|
614
|
-
* Get up to `count` blocks immediately following `afterHash`, in ascending chain order.
|
|
615
|
-
*/
|
|
514
|
+
/** Up to `count` blocks immediately following `afterHash`, in ascending chain order. */
|
|
616
515
|
async getNextBlocks(afterHash, count) {
|
|
617
516
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
618
517
|
let blocks;
|
|
@@ -620,24 +519,19 @@ class BlockfrostBackend {
|
|
|
620
519
|
blocks = await this.api.blocksNext(afterHash, { count });
|
|
621
520
|
}
|
|
622
521
|
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.
|
|
522
|
+
// Blockfrost only knows canonical blocks: a 404 on the anchor means the cursor block was
|
|
523
|
+
// orphaned by a reorg. Signal CHAIN_POINT_MISMATCH so the crawler enters reorg recovery;
|
|
524
|
+
// a plain NotFoundError would count as transient and halt it with an error streak.
|
|
628
525
|
const normalized = (0, errors_1.normalizeBackendError)(err, this.name);
|
|
629
526
|
if (normalized.statusCode === 404) {
|
|
630
|
-
throw new errors_1.ProviderUnavailableError(`CHAIN_POINT_MISMATCH: cursor block ${afterHash} is unknown to ${this.name}
|
|
527
|
+
throw new errors_1.ProviderUnavailableError(`CHAIN_POINT_MISMATCH: cursor block ${afterHash} is unknown to ${this.name}, likely orphaned by a reorg`, this.name);
|
|
631
528
|
}
|
|
632
529
|
throw err;
|
|
633
530
|
}
|
|
634
531
|
return blocks.map(b => this.toBlockData(b));
|
|
635
532
|
}, this.name);
|
|
636
533
|
}
|
|
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
|
-
*/
|
|
534
|
+
/** Full transaction list of a block in block order (hashes from blocksTxsAll, details batched). */
|
|
641
535
|
async getBlockTransactions(blockHash) {
|
|
642
536
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
643
537
|
const hashes = await this.api.blocksTxsAll(blockHash);
|