@odatano/core 2.0.0-rc.2 → 2.0.0-rc.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@cds-models/CardanoAgentService/index.d.ts +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 +224 -0
- 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 +316 -0
- package/@cds-models/odatano/cardano/index.js +33 -0
- package/README.md +195 -136
- package/db/schema.cds +2121 -1633
- package/package.json +179 -173
- 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 +78 -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 +292 -202
- package/srv/blockchain/backends/ogmios-backend.d.ts +59 -96
- package/srv/blockchain/backends/ogmios-backend.js +241 -153
- 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 +50 -205
- package/srv/blockchain/cardano-client.js +80 -224
- package/srv/blockchain/cardano-indexer.d.ts +146 -244
- package/srv/blockchain/cardano-indexer.js +442 -285
- package/srv/blockchain/cardano-tx-builder.d.ts +19 -84
- package/srv/blockchain/cardano-tx-builder.js +21 -107
- package/srv/blockchain/crawler/certificate-backfill.d.ts +45 -0
- package/srv/blockchain/crawler/certificate-backfill.js +150 -0
- package/srv/blockchain/crawler/crawler.d.ts +121 -53
- package/srv/blockchain/crawler/crawler.js +402 -82
- 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/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 +34 -90
- 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 +133 -195
- 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 +89 -0
- package/srv/utils/db-sanitize.d.ts +27 -0
- package/srv/utils/db-sanitize.js +85 -0
- package/srv/utils/error-codes.d.ts +18 -73
- package/srv/utils/error-codes.js +17 -70
- package/srv/utils/errors.d.ts +34 -178
- package/srv/utils/errors.js +55 -217
- package/srv/utils/liveness.d.ts +16 -0
- package/srv/utils/liveness.js +41 -0
- package/srv/utils/mappers.d.ts +82 -210
- package/srv/utils/mappers.js +272 -293
- 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 +112 -169
- package/srv/utils/types.js +2 -6
- package/srv/utils/validators.d.ts +19 -89
- package/srv/utils/validators.js +31 -138
|
@@ -1,174 +1,72 @@
|
|
|
1
1
|
import { CardanoBackend, PaginatingBackend } from './cardano-backend';
|
|
2
2
|
import { Transaction, BlockData, Address, UTxO, NetworkInformation, EpochData, MetadataLabelTx, PoolData, AccountData, DrepData, AssetInfo, AssetHistoryEntry, LedgerProtocolParameters } from '../../utils/types';
|
|
3
3
|
import { Network } from '../cardano-client';
|
|
4
|
-
/**
|
|
5
|
-
* BlockfrostBackend Implementation for CardanoBackend Interface
|
|
6
|
-
* Implements the CardanoBackend interface using Blockfrost API SDK
|
|
7
|
-
*/
|
|
4
|
+
/** CardanoBackend + PaginatingBackend implementation on the Blockfrost API SDK. */
|
|
8
5
|
export declare class BlockfrostBackend implements CardanoBackend, PaginatingBackend {
|
|
9
6
|
readonly name = "blockfrost";
|
|
10
7
|
private api;
|
|
11
8
|
private network;
|
|
12
9
|
private timeoutMs;
|
|
13
|
-
/**
|
|
14
|
-
* Constructor
|
|
15
|
-
*/
|
|
16
10
|
constructor(network: Network, timeoutMs: number, projectId: string, customBackend?: string);
|
|
17
|
-
/**
|
|
18
|
-
* Initialize the backend
|
|
19
|
-
*/
|
|
20
11
|
init(): Promise<boolean>;
|
|
21
|
-
/**
|
|
22
|
-
* Get Network Information
|
|
23
|
-
* @returns {Promise<NetworkInformation>} network information
|
|
24
|
-
*/
|
|
12
|
+
/** Network information (supply, stake). */
|
|
25
13
|
getNetworkInformation(): Promise<NetworkInformation>;
|
|
26
|
-
/**
|
|
27
|
-
* Get Block Data
|
|
28
|
-
* @param blockHash block hash (hex)
|
|
29
|
-
* @returns {Promise<BlockData>} block data
|
|
30
|
-
*/
|
|
14
|
+
/** Block by hash (hex). */
|
|
31
15
|
getBlock(blockHash: string): Promise<BlockData>;
|
|
32
|
-
/**
|
|
33
|
-
* Get Epoch Data
|
|
34
|
-
* @param epochNumber epoch number
|
|
35
|
-
* @returns {Promise<EpochData>} epoch data
|
|
36
|
-
*/
|
|
16
|
+
/** Epoch by number. */
|
|
37
17
|
getEpoch(epochNumber: number): Promise<EpochData>;
|
|
38
|
-
/**
|
|
39
|
-
* Get Transaction Data
|
|
40
|
-
* @param hash transaction hash (hex)
|
|
41
|
-
* @returns {Promise<Transaction>} transaction data
|
|
42
|
-
*/
|
|
18
|
+
/** Transaction by hash (hex), with UTxOs and metadata. */
|
|
43
19
|
getTransaction(hash: string): Promise<Transaction>;
|
|
44
|
-
/**
|
|
45
|
-
* Get Transaction Metadata
|
|
46
|
-
* @param tx_hash transaction hash (hex)
|
|
47
|
-
* @returns {Promise<MetadataLabelTx[]>} transaction metadata list
|
|
48
|
-
*/
|
|
20
|
+
/** Metadata labels of a transaction (hash hex); NotFoundError when it has none. */
|
|
49
21
|
getTransactionMetadata(tx_hash: string): Promise<MetadataLabelTx[]>;
|
|
50
|
-
/**
|
|
51
|
-
* Get Address Data (without transactions - use getAddressTransactions() separately)
|
|
52
|
-
* @param address bech32 address string
|
|
53
|
-
* @returns {Promise<Address>} address data
|
|
54
|
-
*/
|
|
22
|
+
/** Address data with UTxOs (no transactions — see getAddressTransactions()). */
|
|
55
23
|
getAddress(address: string): Promise<Address>;
|
|
56
|
-
/**
|
|
57
|
-
* Get Address Transactions
|
|
58
|
-
* @param address bech32 address string
|
|
59
|
-
* @returns {Promise<Transaction[]>} list of transactions for this address
|
|
60
|
-
*/
|
|
24
|
+
/** Transactions of an address, most recent first, with full details (batched). */
|
|
61
25
|
getAddressTransactions(address: string, limit?: number): Promise<Transaction[]>;
|
|
62
|
-
/**
|
|
63
|
-
* Get Address UTxOs
|
|
64
|
-
* @param address bech32 address string
|
|
65
|
-
* @returns {Promise<UTxO[]>} list of UTxOs
|
|
66
|
-
*/
|
|
26
|
+
/** UTxOs of an address. */
|
|
67
27
|
getAddressUtxos(address: string): Promise<UTxO[]>;
|
|
68
|
-
/**
|
|
69
|
-
* Get Pool Data
|
|
70
|
-
* @param poolId stake pool id (hex)
|
|
71
|
-
* @return {Promise<PoolData>} pool data
|
|
72
|
-
*/
|
|
28
|
+
/** Stake pool by id. */
|
|
73
29
|
getPool(poolId: string): Promise<PoolData>;
|
|
74
30
|
/**
|
|
75
|
-
*
|
|
76
|
-
* Blockfrost does
|
|
77
|
-
* `initialMintTime` is left null. Filling it would cost an extra tx fetch.
|
|
78
|
-
* @param unit policyId + assetNameHex (concatenated hex)
|
|
79
|
-
* @return {Promise<AssetInfo>} canonical asset info
|
|
31
|
+
* Asset info (supply, mint history, CIP-25 + CIP-26 metadata); unit = policyId + assetNameHex.
|
|
32
|
+
* Blockfrost does not expose the initial-mint timestamp here, so `initialMintTime` stays null.
|
|
80
33
|
*/
|
|
81
34
|
getAssetInfo(unit: string): Promise<AssetInfo>;
|
|
82
35
|
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* Cost: 1 extra API call per history entry. Failed tx fetches leave the
|
|
87
|
-
* timestamp fields null instead of failing the whole call (best-effort).
|
|
88
|
-
* @param unit policyId + assetNameHex (concatenated hex)
|
|
89
|
-
* @param limit max number of events (default 100, max 100 per Blockfrost page)
|
|
90
|
-
* @return {Promise<AssetHistoryEntry[]>} list of mint/burn events (most recent first)
|
|
36
|
+
* Mint/burn events of an asset, most recent first (max 100 per Blockfrost page).
|
|
37
|
+
* `assetsHistory` carries no block metadata; blockTime/blockHeight are backfilled with one
|
|
38
|
+
* best-effort `txs()` call per entry (a failed fetch leaves them null).
|
|
91
39
|
*/
|
|
92
40
|
getAssetHistory(unit: string, limit?: number): Promise<AssetHistoryEntry[]>;
|
|
93
|
-
/**
|
|
94
|
-
* Get Drep Data
|
|
95
|
-
* @param drepId drep id (bech32)
|
|
96
|
-
* @return {Promise<DrepData>} drep data
|
|
97
|
-
*/
|
|
41
|
+
/** DRep by id (bech32). */
|
|
98
42
|
getDrep(drepId: string): Promise<DrepData>;
|
|
99
|
-
/**
|
|
100
|
-
* Get Account Data
|
|
101
|
-
* @param stakeAddress bech32 stake address
|
|
102
|
-
* @return {Promise<AccountData>} account data
|
|
103
|
-
*/
|
|
43
|
+
/** Account by stake address (bech32), with all its addresses and their UTxOs. */
|
|
104
44
|
getAccount(stakeAddress: string): Promise<AccountData>;
|
|
105
|
-
/**
|
|
106
|
-
* Submit Transaction
|
|
107
|
-
* @param signedTxCbor hex-encoded signed transaction CBOR
|
|
108
|
-
* @returns {Promise<string>} transaction hash
|
|
109
|
-
*/
|
|
45
|
+
/** Submit a signed transaction (CBOR hex); returns the tx hash. */
|
|
110
46
|
submitTransaction(signedTxCbor: string): Promise<string>;
|
|
111
|
-
/**
|
|
112
|
-
* Get Protocol Parameters
|
|
113
|
-
* @returns {Promise<LedgerProtocolParameters>} protocol parameters
|
|
114
|
-
*/
|
|
47
|
+
/** Protocol parameters of the latest epoch. */
|
|
115
48
|
getProtocolParameters(): Promise<LedgerProtocolParameters>;
|
|
116
|
-
/**
|
|
117
|
-
* Get Latest Epoch Data
|
|
118
|
-
* @returns {Promise<EpochData>} latest epoch data
|
|
119
|
-
*/
|
|
49
|
+
/** Latest epoch. */
|
|
120
50
|
getLatestEpoch(): Promise<EpochData>;
|
|
121
|
-
/**
|
|
122
|
-
* Get Latest Block Data
|
|
123
|
-
* @returns {Promise<BlockData>} latest block data
|
|
124
|
-
*/
|
|
51
|
+
/** Latest block. */
|
|
125
52
|
getLatestBlock(): Promise<BlockData>;
|
|
126
|
-
/**
|
|
127
|
-
* Get the latest chain tip slot.
|
|
128
|
-
* @returns {Promise<number>} current chain slot
|
|
129
|
-
*/
|
|
53
|
+
/** Latest chain tip slot; ProviderUnavailableError when the latest block has no slot. */
|
|
130
54
|
getCurrentSlot(): Promise<number>;
|
|
131
|
-
/**
|
|
132
|
-
* Check whether a UTxO is still unspent via Blockfrost's `consumed_by_tx` field.
|
|
133
|
-
* @param txHash 64-char lowercase hex
|
|
134
|
-
* @param outputIndex non-negative integer
|
|
135
|
-
* @returns {Promise<boolean>} true iff the UTxO exists and is unspent
|
|
136
|
-
*/
|
|
55
|
+
/** Whether a UTxO is unspent, via Blockfrost's `consumed_by_tx`; false for unknown tx or out-of-range index. */
|
|
137
56
|
isUtxoUnspent(txHash: string, outputIndex: number): Promise<boolean>;
|
|
138
57
|
/** Max concurrent Blockfrost API calls (free tier: ~10 req/s) */
|
|
139
58
|
private static readonly MAX_CONCURRENT;
|
|
140
|
-
/**
|
|
141
|
-
* Get transaction hashes for an address (lightweight — no full tx details).
|
|
142
|
-
* @param address bech32 address
|
|
143
|
-
* @param limit maximum number of hashes
|
|
144
|
-
* @returns {Promise<string[]>} most recent tx hashes
|
|
145
|
-
*/
|
|
59
|
+
/** Most recent tx hashes of an address (no details). */
|
|
146
60
|
getAddressTransactionHashes(address: string, limit: number): Promise<string[]>;
|
|
147
|
-
/**
|
|
148
|
-
* Batch fetch multiple transactions by hash.
|
|
149
|
-
* Blockfrost has no batch endpoint — uses concurrency-limited parallel calls.
|
|
150
|
-
* @param txHashes array of transaction hashes
|
|
151
|
-
* @returns {Promise<Map<string, Transaction>>} map of hash -> Transaction
|
|
152
|
-
*/
|
|
61
|
+
/** Transactions by hash (map hash -> Transaction); no batch endpoint, so concurrency-limited parallel calls. */
|
|
153
62
|
getTransactionsBatch(txHashes: string[]): Promise<Map<string, Transaction>>;
|
|
154
|
-
/**
|
|
155
|
-
* Map a Blockfrost block summary (from blocks()/blocksNext()) to our BlockData.
|
|
156
|
-
* Same shape getBlock() maps inline — kept private to avoid touching getBlock().
|
|
157
|
-
*/
|
|
63
|
+
/** Map a Blockfrost block summary (blocks()/blocksNext()) to BlockData. */
|
|
158
64
|
private toBlockData;
|
|
159
|
-
/**
|
|
160
|
-
* Get a block by its height. Blockfrost's `blocks` endpoint accepts a height as
|
|
161
|
-
* well as a hash.
|
|
162
|
-
*/
|
|
65
|
+
/** Block by height; Blockfrost's `blocks` endpoint accepts a height as well as a hash. */
|
|
163
66
|
getBlockByHeight(height: number): Promise<BlockData>;
|
|
164
|
-
/**
|
|
165
|
-
* Get up to `count` blocks immediately following `afterHash`, in ascending chain order.
|
|
166
|
-
*/
|
|
67
|
+
/** Up to `count` blocks immediately following `afterHash`, in ascending chain order. */
|
|
167
68
|
getNextBlocks(afterHash: string, count: number): Promise<BlockData[]>;
|
|
168
|
-
/**
|
|
169
|
-
* Get the full transaction list of a block in block order. Blockfrost returns tx
|
|
170
|
-
* hashes; details are batched via getTransactionsBatch. Order is preserved.
|
|
171
|
-
*/
|
|
69
|
+
/** Full transaction list of a block in block order (hashes from blocksTxsAll, details batched). */
|
|
172
70
|
getBlockTransactions(blockHash: string): Promise<Transaction[]>;
|
|
173
71
|
}
|
|
174
72
|
//# sourceMappingURL=blockfrost-backend.d.ts.map
|
|
@@ -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
|
|
@@ -120,6 +94,9 @@ class BlockfrostBackend {
|
|
|
120
94
|
fee: tx.fees,
|
|
121
95
|
deposit: tx.deposit,
|
|
122
96
|
size: tx.size,
|
|
97
|
+
// `spends === 'collaterals'` in Ogmios terms: the script phase failed, so the
|
|
98
|
+
// ledger applied neither the declared inputs/outputs nor the declared mint.
|
|
99
|
+
spendsCollaterals: tx.valid_contract === false,
|
|
123
100
|
inputs: txUtxos.inputs.map(input => ({
|
|
124
101
|
address: input.address,
|
|
125
102
|
txHash: input.tx_hash,
|
|
@@ -128,8 +105,8 @@ class BlockfrostBackend {
|
|
|
128
105
|
dataHash: input.data_hash,
|
|
129
106
|
inlineDatum: (0, tx_build_helper_1.inlineDatumToHex)(input.inline_datum),
|
|
130
107
|
referenceScriptHash: input.reference_script_hash,
|
|
131
|
-
|
|
132
|
-
|
|
108
|
+
isCollateral: input.collateral === true,
|
|
109
|
+
isReference: input.reference === true,
|
|
133
110
|
})),
|
|
134
111
|
outputs: txUtxos.outputs.map(output => ({
|
|
135
112
|
address: output.address,
|
|
@@ -145,11 +122,7 @@ class BlockfrostBackend {
|
|
|
145
122
|
};
|
|
146
123
|
}, this.name);
|
|
147
124
|
}
|
|
148
|
-
/**
|
|
149
|
-
* Get Transaction Metadata
|
|
150
|
-
* @param tx_hash transaction hash (hex)
|
|
151
|
-
* @returns {Promise<MetadataLabelTx[]>} transaction metadata list
|
|
152
|
-
*/
|
|
125
|
+
/** Metadata labels of a transaction (hash hex); NotFoundError when it has none. */
|
|
153
126
|
async getTransactionMetadata(tx_hash) {
|
|
154
127
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
155
128
|
const txMetadata = await this.api.txsMetadata(tx_hash);
|
|
@@ -163,16 +136,11 @@ class BlockfrostBackend {
|
|
|
163
136
|
}));
|
|
164
137
|
}, this.name);
|
|
165
138
|
}
|
|
166
|
-
/**
|
|
167
|
-
* Get Address Data (without transactions - use getAddressTransactions() separately)
|
|
168
|
-
* @param address bech32 address string
|
|
169
|
-
* @returns {Promise<Address>} address data
|
|
170
|
-
*/
|
|
139
|
+
/** Address data with UTxOs (no transactions — see getAddressTransactions()). */
|
|
171
140
|
async getAddress(address) {
|
|
172
141
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
173
142
|
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)
|
|
143
|
+
// *All variant paginates internally — plain addressesUtxos caps at 100 entries and silently truncates
|
|
176
144
|
const address_utxos = await this.api.addressesUtxosAll(address);
|
|
177
145
|
return {
|
|
178
146
|
address: address_data.address,
|
|
@@ -193,11 +161,7 @@ class BlockfrostBackend {
|
|
|
193
161
|
};
|
|
194
162
|
}, this.name);
|
|
195
163
|
}
|
|
196
|
-
/**
|
|
197
|
-
* Get Address Transactions
|
|
198
|
-
* @param address bech32 address string
|
|
199
|
-
* @returns {Promise<Transaction[]>} list of transactions for this address
|
|
200
|
-
*/
|
|
164
|
+
/** Transactions of an address, most recent first, with full details (batched). */
|
|
201
165
|
async getAddressTransactions(address, limit) {
|
|
202
166
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
203
167
|
// Blockfrost rejects count > 100 with a 400 — clamp instead
|
|
@@ -216,11 +180,7 @@ class BlockfrostBackend {
|
|
|
216
180
|
return transactions;
|
|
217
181
|
}, this.name);
|
|
218
182
|
}
|
|
219
|
-
/**
|
|
220
|
-
* Get Address UTxOs
|
|
221
|
-
* @param address bech32 address string
|
|
222
|
-
* @returns {Promise<UTxO[]>} list of UTxOs
|
|
223
|
-
*/
|
|
183
|
+
/** UTxOs of an address. */
|
|
224
184
|
async getAddressUtxos(address) {
|
|
225
185
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
226
186
|
// *All variant paginates internally (plain addressesUtxos caps at 100 entries)
|
|
@@ -237,11 +197,7 @@ class BlockfrostBackend {
|
|
|
237
197
|
}));
|
|
238
198
|
}, this.name);
|
|
239
199
|
}
|
|
240
|
-
/**
|
|
241
|
-
* Get Pool Data
|
|
242
|
-
* @param poolId stake pool id (hex)
|
|
243
|
-
* @return {Promise<PoolData>} pool data
|
|
244
|
-
*/
|
|
200
|
+
/** Stake pool by id. */
|
|
245
201
|
async getPool(poolId) {
|
|
246
202
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
247
203
|
const poolData = await this.api.poolsById(poolId);
|
|
@@ -253,6 +209,7 @@ class BlockfrostBackend {
|
|
|
253
209
|
liveStake: poolData.live_stake || '0',
|
|
254
210
|
liveSize: poolData.live_size,
|
|
255
211
|
liveDelegators: poolData.live_delegators,
|
|
212
|
+
// Blockfrost reports saturation as a fraction (0.7542 = 75.42 %), the canonical unit
|
|
256
213
|
liveSaturation: poolData.live_saturation,
|
|
257
214
|
activeStake: poolData.active_stake || '0',
|
|
258
215
|
activeSize: poolData.active_size,
|
|
@@ -264,26 +221,14 @@ class BlockfrostBackend {
|
|
|
264
221
|
}, this.name);
|
|
265
222
|
}
|
|
266
223
|
/**
|
|
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
|
|
224
|
+
* Asset info (supply, mint history, CIP-25 + CIP-26 metadata); unit = policyId + assetNameHex.
|
|
225
|
+
* Blockfrost does not expose the initial-mint timestamp here, so `initialMintTime` stays null.
|
|
272
226
|
*/
|
|
273
227
|
async getAssetInfo(unit) {
|
|
274
228
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
275
229
|
const a = await this.api.assetsById(unit);
|
|
276
230
|
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
|
-
};
|
|
231
|
+
const decodeUtf8 = (hex) => (hex ? (0, mappers_1.decodeAssetName)(hex) : null);
|
|
287
232
|
return {
|
|
288
233
|
unit: a.asset,
|
|
289
234
|
policyId: a.policy_id,
|
|
@@ -305,14 +250,9 @@ class BlockfrostBackend {
|
|
|
305
250
|
}, this.name);
|
|
306
251
|
}
|
|
307
252
|
/**
|
|
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)
|
|
253
|
+
* Mint/burn events of an asset, most recent first (max 100 per Blockfrost page).
|
|
254
|
+
* `assetsHistory` carries no block metadata; blockTime/blockHeight are backfilled with one
|
|
255
|
+
* best-effort `txs()` call per entry (a failed fetch leaves them null).
|
|
316
256
|
*/
|
|
317
257
|
async getAssetHistory(unit, limit = 100) {
|
|
318
258
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
@@ -350,11 +290,7 @@ class BlockfrostBackend {
|
|
|
350
290
|
});
|
|
351
291
|
}, this.name);
|
|
352
292
|
}
|
|
353
|
-
/**
|
|
354
|
-
* Get Drep Data
|
|
355
|
-
* @param drepId drep id (bech32)
|
|
356
|
-
* @return {Promise<DrepData>} drep data
|
|
357
|
-
*/
|
|
293
|
+
/** DRep by id (bech32). */
|
|
358
294
|
async getDrep(drepId) {
|
|
359
295
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
360
296
|
const drepData = await this.api.governance.drepsById(drepId);
|
|
@@ -369,11 +305,7 @@ class BlockfrostBackend {
|
|
|
369
305
|
};
|
|
370
306
|
}, this.name);
|
|
371
307
|
}
|
|
372
|
-
/**
|
|
373
|
-
* Get Account Data
|
|
374
|
-
* @param stakeAddress bech32 stake address
|
|
375
|
-
* @return {Promise<AccountData>} account data
|
|
376
|
-
*/
|
|
308
|
+
/** Account by stake address (bech32), with all its addresses and their UTxOs. */
|
|
377
309
|
async getAccount(stakeAddress) {
|
|
378
310
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
379
311
|
const accountData = await this.api.accounts(stakeAddress);
|
|
@@ -402,11 +334,7 @@ class BlockfrostBackend {
|
|
|
402
334
|
};
|
|
403
335
|
}, this.name);
|
|
404
336
|
}
|
|
405
|
-
/**
|
|
406
|
-
* Submit Transaction
|
|
407
|
-
* @param signedTxCbor hex-encoded signed transaction CBOR
|
|
408
|
-
* @returns {Promise<string>} transaction hash
|
|
409
|
-
*/
|
|
337
|
+
/** Submit a signed transaction (CBOR hex); returns the tx hash. */
|
|
410
338
|
async submitTransaction(signedTxCbor) {
|
|
411
339
|
const txBytes = Buffer.from(signedTxCbor, "hex");
|
|
412
340
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
@@ -414,10 +342,7 @@ class BlockfrostBackend {
|
|
|
414
342
|
return txHash;
|
|
415
343
|
}, this.name);
|
|
416
344
|
}
|
|
417
|
-
/**
|
|
418
|
-
* Get Protocol Parameters
|
|
419
|
-
* @returns {Promise<LedgerProtocolParameters>} protocol parameters
|
|
420
|
-
*/
|
|
345
|
+
/** Protocol parameters of the latest epoch. */
|
|
421
346
|
async getProtocolParameters() {
|
|
422
347
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
423
348
|
const protocolParams = await this.api.epochsLatestParameters();
|
|
@@ -459,10 +384,7 @@ class BlockfrostBackend {
|
|
|
459
384
|
};
|
|
460
385
|
}, this.name);
|
|
461
386
|
}
|
|
462
|
-
/**
|
|
463
|
-
* Get Latest Epoch Data
|
|
464
|
-
* @returns {Promise<EpochData>} latest epoch data
|
|
465
|
-
*/
|
|
387
|
+
/** Latest epoch. */
|
|
466
388
|
async getLatestEpoch() {
|
|
467
389
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
468
390
|
const epochData = await this.api.epochsLatest();
|
|
@@ -480,10 +402,7 @@ class BlockfrostBackend {
|
|
|
480
402
|
};
|
|
481
403
|
}, this.name);
|
|
482
404
|
}
|
|
483
|
-
/**
|
|
484
|
-
* Get Latest Block Data
|
|
485
|
-
* @returns {Promise<BlockData>} latest block data
|
|
486
|
-
*/
|
|
405
|
+
/** Latest block. */
|
|
487
406
|
async getLatestBlock() {
|
|
488
407
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
489
408
|
const blockdata = await this.api.blocksLatest();
|
|
@@ -501,10 +420,7 @@ class BlockfrostBackend {
|
|
|
501
420
|
};
|
|
502
421
|
}, this.name);
|
|
503
422
|
}
|
|
504
|
-
/**
|
|
505
|
-
* Get the latest chain tip slot.
|
|
506
|
-
* @returns {Promise<number>} current chain slot
|
|
507
|
-
*/
|
|
423
|
+
/** Latest chain tip slot; ProviderUnavailableError when the latest block has no slot. */
|
|
508
424
|
async getCurrentSlot() {
|
|
509
425
|
const block = await this.getLatestBlock();
|
|
510
426
|
if (block.slot == null) {
|
|
@@ -512,12 +428,7 @@ class BlockfrostBackend {
|
|
|
512
428
|
}
|
|
513
429
|
return block.slot;
|
|
514
430
|
}
|
|
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
|
-
*/
|
|
431
|
+
/** Whether a UTxO is unspent, via Blockfrost's `consumed_by_tx`; false for unknown tx or out-of-range index. */
|
|
521
432
|
async isUtxoUnspent(txHash, outputIndex) {
|
|
522
433
|
if (!Number.isInteger(outputIndex) || outputIndex < 0)
|
|
523
434
|
return false;
|
|
@@ -527,9 +438,8 @@ class BlockfrostBackend {
|
|
|
527
438
|
const out = utxos?.outputs?.find(o => o.output_index === outputIndex);
|
|
528
439
|
if (!out)
|
|
529
440
|
return false;
|
|
530
|
-
// consumed_by_tx is optional on the openapi type (
|
|
531
|
-
//
|
|
532
|
-
// router falls through to another backend rather than silently lying.
|
|
441
|
+
// consumed_by_tx is optional on the openapi type (Blockfrost server >= 0.1.59); without it
|
|
442
|
+
// unspent cannot be proven — escalate so the router falls through to another backend.
|
|
533
443
|
const consumed = out.consumed_by_tx;
|
|
534
444
|
if (consumed === undefined) {
|
|
535
445
|
throw new errors_1.ProviderUnavailableError(`${this.name}: server does not expose consumed_by_tx — cannot determine UTxO status`, this.name);
|
|
@@ -548,12 +458,7 @@ class BlockfrostBackend {
|
|
|
548
458
|
//-----------------------------------------------------------------------------
|
|
549
459
|
/** Max concurrent Blockfrost API calls (free tier: ~10 req/s) */
|
|
550
460
|
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
|
-
*/
|
|
461
|
+
/** Most recent tx hashes of an address (no details). */
|
|
557
462
|
async getAddressTransactionHashes(address, limit) {
|
|
558
463
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
559
464
|
// Blockfrost rejects count > 100 with a 400 — clamp instead
|
|
@@ -562,12 +467,7 @@ class BlockfrostBackend {
|
|
|
562
467
|
return txs.map(tx => tx.tx_hash);
|
|
563
468
|
}, this.name);
|
|
564
469
|
}
|
|
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
|
-
*/
|
|
470
|
+
/** Transactions by hash (map hash -> Transaction); no batch endpoint, so concurrency-limited parallel calls. */
|
|
571
471
|
async getTransactionsBatch(txHashes) {
|
|
572
472
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
573
473
|
const result = new Map();
|
|
@@ -583,12 +483,9 @@ class BlockfrostBackend {
|
|
|
583
483
|
}, this.name);
|
|
584
484
|
}
|
|
585
485
|
// ---------------------------------------------------------------------------
|
|
586
|
-
// PaginatingBackend — forward iteration for the chain crawler
|
|
486
|
+
// PaginatingBackend — forward iteration for the chain crawler
|
|
587
487
|
// ---------------------------------------------------------------------------
|
|
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
|
-
*/
|
|
488
|
+
/** Map a Blockfrost block summary (blocks()/blocksNext()) to BlockData. */
|
|
592
489
|
toBlockData(b) {
|
|
593
490
|
return {
|
|
594
491
|
time: b.time,
|
|
@@ -603,16 +500,11 @@ class BlockfrostBackend {
|
|
|
603
500
|
fees: b.fees,
|
|
604
501
|
};
|
|
605
502
|
}
|
|
606
|
-
/**
|
|
607
|
-
* Get a block by its height. Blockfrost's `blocks` endpoint accepts a height as
|
|
608
|
-
* well as a hash.
|
|
609
|
-
*/
|
|
503
|
+
/** Block by height; Blockfrost's `blocks` endpoint accepts a height as well as a hash. */
|
|
610
504
|
async getBlockByHeight(height) {
|
|
611
505
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => this.toBlockData(await this.api.blocks(height)), this.name);
|
|
612
506
|
}
|
|
613
|
-
/**
|
|
614
|
-
* Get up to `count` blocks immediately following `afterHash`, in ascending chain order.
|
|
615
|
-
*/
|
|
507
|
+
/** Up to `count` blocks immediately following `afterHash`, in ascending chain order. */
|
|
616
508
|
async getNextBlocks(afterHash, count) {
|
|
617
509
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
618
510
|
let blocks;
|
|
@@ -620,11 +512,9 @@ class BlockfrostBackend {
|
|
|
620
512
|
blocks = await this.api.blocksNext(afterHash, { count });
|
|
621
513
|
}
|
|
622
514
|
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.
|
|
515
|
+
// Blockfrost only knows canonical blocks: a 404 on the anchor means the cursor block was
|
|
516
|
+
// orphaned by a reorg. Signal CHAIN_POINT_MISMATCH so the crawler enters reorg recovery;
|
|
517
|
+
// a plain NotFoundError would count as transient and halt it with an error streak.
|
|
628
518
|
const normalized = (0, errors_1.normalizeBackendError)(err, this.name);
|
|
629
519
|
if (normalized.statusCode === 404) {
|
|
630
520
|
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 +524,7 @@ class BlockfrostBackend {
|
|
|
634
524
|
return blocks.map(b => this.toBlockData(b));
|
|
635
525
|
}, this.name);
|
|
636
526
|
}
|
|
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
|
-
*/
|
|
527
|
+
/** Full transaction list of a block in block order (hashes from blocksTxsAll, details batched). */
|
|
641
528
|
async getBlockTransactions(blockHash) {
|
|
642
529
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
643
530
|
const hashes = await this.api.blocksTxsAll(blockHash);
|