@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
package/src/index.js
CHANGED
|
@@ -36,11 +36,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.
|
|
39
|
+
exports.plutusScriptHash = exports.applyScriptParameters = exports.slotToPosixMs = exports.posixToSlot = exports.verifyTxWitnesses = exports.parseTransaction = exports.registerTransportLane = exports.agentGrantableActions = exports.agentAccessOf = exports.AGENT_ROLE = exports.AGENT_TOKEN_PREFIX = exports.AGENT_TOKEN_HEADER = exports.hashAgentToken = exports.resolveUsageWindow = exports.getGrantUsage = exports.revokeAgentGrantById = exports.rotateAgentGrantToken = exports.updateAgentGrant = exports.issueAgentGrant = exports.getHsmSigner = exports.loadAgentGrantsConfig = exports.loadWalletWorkerConfigFromEnv = exports.loadCrawlerConfigFromEnv = exports.loadHsmConfigFromEnv = exports.loadConfigFromEnv = exports.shutdownAppContext = exports.startWalletWorkerIfConfigured = exports.startCrawlerIfConfigured = exports.getCardanoTxBuilder = exports.getCardanoClient = exports.getCardanoIndexer = exports.getAppContext = exports.CardanoTransactionBuilder = exports.CardanoIndexer = exports.CardanoClient = void 0;
|
|
40
40
|
exports.initialize = initialize;
|
|
41
41
|
exports.shutdown = shutdown;
|
|
42
|
+
exports.getTransactionConfirmations = getTransactionConfirmations;
|
|
42
43
|
exports.getStatus = getStatus;
|
|
43
44
|
const cds_1 = __importDefault(require("@sap/cds"));
|
|
45
|
+
const validators_1 = require("../srv/utils/validators");
|
|
46
|
+
const errors_1 = require("../srv/utils/errors");
|
|
47
|
+
const error_codes_1 = require("../srv/utils/error-codes");
|
|
44
48
|
const logger = cds_1.default.log('ODATANO');
|
|
45
49
|
// Re-export key types and classes for programmatic consumers
|
|
46
50
|
var cardano_client_1 = require("../srv/blockchain/cardano-client");
|
|
@@ -55,49 +59,59 @@ Object.defineProperty(exports, "getAppContext", { enumerable: true, get: functio
|
|
|
55
59
|
Object.defineProperty(exports, "getCardanoIndexer", { enumerable: true, get: function () { return server_1.getCardanoIndexer; } });
|
|
56
60
|
Object.defineProperty(exports, "getCardanoClient", { enumerable: true, get: function () { return server_1.getCardanoClient; } });
|
|
57
61
|
Object.defineProperty(exports, "getCardanoTxBuilder", { enumerable: true, get: function () { return server_1.getCardanoTxBuilder; } });
|
|
58
|
-
Object.defineProperty(exports, "loadConfigFromEnv", { enumerable: true, get: function () { return server_1.loadConfigFromEnv; } });
|
|
59
|
-
Object.defineProperty(exports, "loadHsmConfigFromEnv", { enumerable: true, get: function () { return server_1.loadHsmConfigFromEnv; } });
|
|
60
|
-
Object.defineProperty(exports, "loadCrawlerConfigFromEnv", { enumerable: true, get: function () { return server_1.loadCrawlerConfigFromEnv; } });
|
|
61
62
|
Object.defineProperty(exports, "startCrawlerIfConfigured", { enumerable: true, get: function () { return server_1.startCrawlerIfConfigured; } });
|
|
62
|
-
Object.defineProperty(exports, "loadWalletWorkerConfigFromEnv", { enumerable: true, get: function () { return server_1.loadWalletWorkerConfigFromEnv; } });
|
|
63
63
|
Object.defineProperty(exports, "startWalletWorkerIfConfigured", { enumerable: true, get: function () { return server_1.startWalletWorkerIfConfigured; } });
|
|
64
64
|
Object.defineProperty(exports, "shutdownAppContext", { enumerable: true, get: function () { return server_1.shutdownAppContext; } });
|
|
65
|
+
var config_1 = require("../srv/config");
|
|
66
|
+
Object.defineProperty(exports, "loadConfigFromEnv", { enumerable: true, get: function () { return config_1.loadConfigFromEnv; } });
|
|
67
|
+
Object.defineProperty(exports, "loadHsmConfigFromEnv", { enumerable: true, get: function () { return config_1.loadHsmConfigFromEnv; } });
|
|
68
|
+
Object.defineProperty(exports, "loadCrawlerConfigFromEnv", { enumerable: true, get: function () { return config_1.loadCrawlerConfigFromEnv; } });
|
|
69
|
+
Object.defineProperty(exports, "loadWalletWorkerConfigFromEnv", { enumerable: true, get: function () { return config_1.loadWalletWorkerConfigFromEnv; } });
|
|
70
|
+
Object.defineProperty(exports, "loadAgentGrantsConfig", { enumerable: true, get: function () { return config_1.loadAgentGrantsConfig; } });
|
|
65
71
|
// Re-export HSM signer for programmatic access
|
|
66
72
|
var hsm_signer_1 = require("../srv/blockchain/signing/hsm-signer");
|
|
67
73
|
Object.defineProperty(exports, "getHsmSigner", { enumerable: true, get: function () { return hsm_signer_1.getHsmSigner; } });
|
|
68
|
-
// Agent grants
|
|
69
|
-
// packages build on — @odatano/x402 sells grants through issueAgentGrant and
|
|
70
|
-
// adds its payment lane through registerTransportLane.
|
|
74
|
+
// Agent grants: programmatic seams for packages that issue grants or add transport lanes.
|
|
71
75
|
var agent_grants_1 = require("../srv/utils/agent-grants");
|
|
72
76
|
Object.defineProperty(exports, "issueAgentGrant", { enumerable: true, get: function () { return agent_grants_1.issueAgentGrant; } });
|
|
77
|
+
Object.defineProperty(exports, "updateAgentGrant", { enumerable: true, get: function () { return agent_grants_1.updateAgentGrant; } });
|
|
78
|
+
Object.defineProperty(exports, "rotateAgentGrantToken", { enumerable: true, get: function () { return agent_grants_1.rotateAgentGrantToken; } });
|
|
73
79
|
Object.defineProperty(exports, "revokeAgentGrantById", { enumerable: true, get: function () { return agent_grants_1.revokeAgentGrantById; } });
|
|
80
|
+
Object.defineProperty(exports, "getGrantUsage", { enumerable: true, get: function () { return agent_grants_1.getGrantUsage; } });
|
|
81
|
+
Object.defineProperty(exports, "resolveUsageWindow", { enumerable: true, get: function () { return agent_grants_1.resolveUsageWindow; } });
|
|
74
82
|
Object.defineProperty(exports, "hashAgentToken", { enumerable: true, get: function () { return agent_grants_1.hashAgentToken; } });
|
|
75
83
|
Object.defineProperty(exports, "AGENT_TOKEN_HEADER", { enumerable: true, get: function () { return agent_grants_1.AGENT_TOKEN_HEADER; } });
|
|
76
84
|
Object.defineProperty(exports, "AGENT_TOKEN_PREFIX", { enumerable: true, get: function () { return agent_grants_1.AGENT_TOKEN_PREFIX; } });
|
|
77
85
|
Object.defineProperty(exports, "AGENT_ROLE", { enumerable: true, get: function () { return agent_grants_1.AGENT_ROLE; } });
|
|
78
|
-
|
|
79
|
-
Object.defineProperty(exports, "
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
Object.defineProperty(exports, "loadAgentGrantsConfig", { enumerable: true, get: function () { return agent_grants_config_1.loadAgentGrantsConfig; } });
|
|
86
|
+
var agent_access_1 = require("../srv/utils/agent-access");
|
|
87
|
+
Object.defineProperty(exports, "agentAccessOf", { enumerable: true, get: function () { return agent_access_1.agentAccessOf; } });
|
|
88
|
+
Object.defineProperty(exports, "agentGrantableActions", { enumerable: true, get: function () { return agent_access_1.agentGrantableActions; } });
|
|
89
|
+
var cap_auth_1 = require("@odatano/cap-auth");
|
|
90
|
+
Object.defineProperty(exports, "registerTransportLane", { enumerable: true, get: function () { return cap_auth_1.registerTransportLane; } });
|
|
84
91
|
// Re-export pure CBOR utilities (no CAP round-trip needed)
|
|
85
92
|
var cbor_1 = require("../srv/cbor");
|
|
86
93
|
Object.defineProperty(exports, "parseTransaction", { enumerable: true, get: function () { return cbor_1.parseTransaction; } });
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
94
|
+
var signature_verifier_1 = require("../srv/blockchain/signing/signature-verifier");
|
|
95
|
+
Object.defineProperty(exports, "verifyTxWitnesses", { enumerable: true, get: function () { return signature_verifier_1.verifyTxWitnesses; } });
|
|
96
|
+
var epoch_slots_1 = require("../srv/utils/epoch-slots");
|
|
97
|
+
Object.defineProperty(exports, "posixToSlot", { enumerable: true, get: function () { return epoch_slots_1.posixToSlot; } });
|
|
98
|
+
Object.defineProperty(exports, "slotToPosixMs", { enumerable: true, get: function () { return epoch_slots_1.slotToPosixMs; } });
|
|
99
|
+
// Pure script helpers (no initialize() needed)
|
|
100
|
+
var tx_build_helper_1 = require("../srv/utils/tx-build-helper");
|
|
101
|
+
Object.defineProperty(exports, "applyScriptParameters", { enumerable: true, get: function () { return tx_build_helper_1.applyScriptParameters; } });
|
|
102
|
+
Object.defineProperty(exports, "plutusScriptHash", { enumerable: true, get: function () { return tx_build_helper_1.plutusScriptHash; } });
|
|
103
|
+
// Reads config from cds.env.requires["odatano-core"] or env vars.
|
|
104
|
+
// Starts all blockchain components plus the optional crawler and wallet worker.
|
|
92
105
|
async function initialize() {
|
|
93
|
-
const {
|
|
106
|
+
const { initializeFromConfig, getAppContext } = await Promise.resolve().then(() => __importStar(require('../srv/server')));
|
|
107
|
+
const { loadConfigFromEnv, loadHsmConfigFromEnv } = await Promise.resolve().then(() => __importStar(require('../srv/config')));
|
|
94
108
|
let alreadyInitialized = false;
|
|
95
109
|
try {
|
|
96
110
|
getAppContext();
|
|
97
111
|
alreadyInitialized = true;
|
|
98
112
|
}
|
|
99
113
|
catch {
|
|
100
|
-
//
|
|
114
|
+
// Not initialized yet. initializeFromConfig creates the context.
|
|
101
115
|
}
|
|
102
116
|
const config = loadConfigFromEnv();
|
|
103
117
|
const hsmConfig = loadHsmConfigFromEnv();
|
|
@@ -105,26 +119,26 @@ async function initialize() {
|
|
|
105
119
|
if (!alreadyInitialized) {
|
|
106
120
|
logger.info('ODATANO core initialized');
|
|
107
121
|
}
|
|
108
|
-
//
|
|
122
|
+
// Optional subsystems; each is non-fatal.
|
|
109
123
|
const { startCrawlerIfConfigured, startWalletWorkerIfConfigured, redriveInterruptedSubmissionsIfConfigured } = await Promise.resolve().then(() => __importStar(require('../srv/server')));
|
|
110
124
|
await startCrawlerIfConfigured();
|
|
111
|
-
// Start the wallet worker if configured (plugin mode). Non-fatal.
|
|
112
125
|
await startWalletWorkerIfConfigured();
|
|
113
|
-
// Re-drive deferred submissions interrupted by a restart (plugin mode). Non-fatal.
|
|
114
126
|
await redriveInterruptedSubmissionsIfConfigured();
|
|
115
127
|
}
|
|
116
|
-
/**
|
|
117
|
-
* Shutdown the ODATANO plugin.
|
|
118
|
-
* Cleans up all backend connections (especially Ogmios WebSocket).
|
|
119
|
-
*/
|
|
128
|
+
/** Shut down the plugin and close all backend connections. */
|
|
120
129
|
async function shutdown() {
|
|
121
130
|
const { shutdownAppContext } = await Promise.resolve().then(() => __importStar(require('../srv/server')));
|
|
122
131
|
await shutdownAppContext();
|
|
123
132
|
logger.info('ODATANO core shutdown');
|
|
124
133
|
}
|
|
125
|
-
/**
|
|
126
|
-
|
|
127
|
-
|
|
134
|
+
/** Confirmations of a transaction; needs initialize(). See CardanoIndexer.resolveTransactionConfirmations. */
|
|
135
|
+
async function getTransactionConfirmations(txHash) {
|
|
136
|
+
if (!(0, validators_1.isTxHash)(txHash))
|
|
137
|
+
throw new errors_1.TransactionValidationError(`Invalid transaction hash: ${txHash}`, undefined, error_codes_1.ERROR_CODES.INVALID_INPUT);
|
|
138
|
+
const { getCardanoIndexer } = await Promise.resolve().then(() => __importStar(require('../srv/server')));
|
|
139
|
+
return cds_1.default.tx((tx) => getCardanoIndexer().resolveTransactionConfirmations(tx, txHash));
|
|
140
|
+
}
|
|
141
|
+
/** Current plugin status. */
|
|
128
142
|
function getStatus() {
|
|
129
143
|
try {
|
|
130
144
|
const { getAppContext } = require('../srv/server');
|
package/src/plugin.js
CHANGED
|
@@ -41,18 +41,15 @@ const path_1 = __importDefault(require("path"));
|
|
|
41
41
|
const logger = cds_1.default.log('ODATANO');
|
|
42
42
|
const pluginRoot = path_1.default.resolve(__dirname, '..');
|
|
43
43
|
let initialized = false;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
* This is executed when the plugin is loaded via cds-plugin.js
|
|
47
|
-
*/
|
|
48
|
-
// Register service kinds so consumer apps can configure via cds.env.requires
|
|
44
|
+
// CAP plugin registration for @odatano/core; loaded via cds-plugin.js.
|
|
45
|
+
// Register the service kind so consumer apps can configure via cds.env.requires
|
|
49
46
|
if (!cds_1.default.env.requires) {
|
|
50
47
|
cds_1.default.env.requires = {};
|
|
51
48
|
}
|
|
52
49
|
if (!cds_1.default.env.requires.kinds) {
|
|
53
50
|
cds_1.default.env.requires.kinds = {};
|
|
54
51
|
}
|
|
55
|
-
/** The schema and the
|
|
52
|
+
/** The schema and the seven CDS services this package ships, package-qualified. */
|
|
56
53
|
const PLUGIN_MODEL = [
|
|
57
54
|
'@odatano/core/db/schema',
|
|
58
55
|
'@odatano/core/srv/cardano-service',
|
|
@@ -60,7 +57,8 @@ const PLUGIN_MODEL = [
|
|
|
60
57
|
'@odatano/core/srv/cardano-sign-service',
|
|
61
58
|
'@odatano/core/srv/cardano-indexer-service',
|
|
62
59
|
'@odatano/core/srv/cardano-worker-service',
|
|
63
|
-
'@odatano/core/srv/cardano-agent-service'
|
|
60
|
+
'@odatano/core/srv/cardano-agent-service',
|
|
61
|
+
'@odatano/core/srv/cardano-backend-service'
|
|
64
62
|
];
|
|
65
63
|
/** Relative `@impl` values used in the CDS files (rewritten in plugin mode, see below). */
|
|
66
64
|
const IMPL_PATHS = [
|
|
@@ -69,36 +67,26 @@ const IMPL_PATHS = [
|
|
|
69
67
|
'srv/cardano-sign-service',
|
|
70
68
|
'srv/cardano-indexer-service',
|
|
71
69
|
'srv/cardano-worker-service',
|
|
72
|
-
'srv/cardano-agent-service'
|
|
70
|
+
'srv/cardano-agent-service',
|
|
71
|
+
'srv/cardano-backend-service'
|
|
73
72
|
];
|
|
74
73
|
cds_1.default.env.requires.kinds['odatano-core'] = {
|
|
75
74
|
impl: '@odatano/core',
|
|
76
75
|
model: [...PLUGIN_MODEL]
|
|
77
76
|
};
|
|
78
|
-
//
|
|
79
|
-
//
|
|
80
|
-
// so the model array on the kind is never merged. Set it directly.
|
|
77
|
+
// Also set model on the requires entry: CAP merges kind→requires before cds-plugin.js
|
|
78
|
+
// runs, so the model array on the kind alone is never picked up.
|
|
81
79
|
const req = cds_1.default.env.requires['odatano-core'];
|
|
82
80
|
if (req) {
|
|
83
81
|
req.model = [...PLUGIN_MODEL];
|
|
84
82
|
}
|
|
85
83
|
logger.debug('Plugin registered');
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
* cds.requires.odatano-core.agentGrants.enabled / AGENT_GRANTS_ENABLED=true.
|
|
89
|
-
* Has to run at plugin load, before CAP builds its middlewares (the auth impl
|
|
90
|
-
* is swapped here). srv/server.ts makes the same call for standalone mode, where
|
|
91
|
-
* this file is never loaded; the call is idempotent and never throws.
|
|
92
|
-
*/
|
|
84
|
+
// Agent grants swap the auth impl, so this runs at plugin load before CAP builds middlewares.
|
|
85
|
+
// Idempotent. server.ts repeats it for standalone mode.
|
|
93
86
|
require('../srv/utils/agent-grants-config')
|
|
94
87
|
.activateAgentGrants();
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
* CDS files use relative @impl (e.g. 'srv/cardano-service') which resolves from cds.root.
|
|
98
|
-
* In standalone mode cds.root IS the package root, so it works.
|
|
99
|
-
* In plugin mode cds.root is the consumer app — rewrite to package-qualified paths
|
|
100
|
-
* so CAP resolves via Node module resolution (node_modules/@odatano/core/srv/...).
|
|
101
|
-
*/
|
|
88
|
+
// In plugin mode relative @impl paths resolve from the consumer app.
|
|
89
|
+
// Rewrite them to package-qualified paths that Node can resolve.
|
|
102
90
|
cds_1.default.on('loaded', (model) => {
|
|
103
91
|
if (path_1.default.resolve(cds_1.default.root) === pluginRoot)
|
|
104
92
|
return;
|
|
@@ -110,15 +98,12 @@ cds_1.default.on('loaded', (model) => {
|
|
|
110
98
|
}
|
|
111
99
|
}
|
|
112
100
|
});
|
|
113
|
-
|
|
114
|
-
* Initialize blockchain components when services are served
|
|
115
|
-
*/
|
|
101
|
+
// Initialize blockchain components once services are served.
|
|
116
102
|
cds_1.default.on('served', async () => {
|
|
117
103
|
if (initialized)
|
|
118
104
|
return;
|
|
119
|
-
//
|
|
120
|
-
|
|
121
|
-
if (process.env.SKIP_AUTO_INIT === 'true') {
|
|
105
|
+
// SKIP_AUTO_INIT lets consumer test suites mount the plugin without backend connections.
|
|
106
|
+
if (require('../srv/config').autoInitSkipped()) {
|
|
122
107
|
logger.info('Skipping plugin auto-initialization (SKIP_AUTO_INIT=true)');
|
|
123
108
|
return;
|
|
124
109
|
}
|
|
@@ -130,13 +115,10 @@ cds_1.default.on('served', async () => {
|
|
|
130
115
|
initialized = true;
|
|
131
116
|
}
|
|
132
117
|
catch (err) {
|
|
133
|
-
//
|
|
118
|
+
// Never throw: a plugin failure must not crash the host app.
|
|
134
119
|
logger.error('Failed to initialize plugin:', err);
|
|
135
120
|
}
|
|
136
121
|
});
|
|
137
|
-
/**
|
|
138
|
-
* Graceful shutdown handler
|
|
139
|
-
*/
|
|
140
122
|
cds_1.default.on('shutdown', async () => {
|
|
141
123
|
if (!initialized)
|
|
142
124
|
return;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Transaction as CapTransaction } from '@sap/cds';
|
|
2
|
+
import type { Transaction as ProviderTransaction } from '../utils/types';
|
|
3
|
+
export declare function cip68Decimals(tx: CapTransaction, unit: string, mintTxHash?: string | null): Promise<number | null>;
|
|
4
|
+
/** Write `decimals` on every slice of the unit; returns the rows changed. */
|
|
5
|
+
export declare function setAssetDecimals(tx: CapTransaction, unit: string, decimals: number): Promise<number>;
|
|
6
|
+
export declare function applyReferenceDatums(tx: CapTransaction, txs: ProviderTransaction[]): Promise<number>;
|
|
7
|
+
//# sourceMappingURL=asset-decimals.d.ts.map
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.cip68Decimals = cip68Decimals;
|
|
7
|
+
exports.setAssetDecimals = setAssetDecimals;
|
|
8
|
+
exports.applyReferenceDatums = applyReferenceDatums;
|
|
9
|
+
const cds_1 = __importDefault(require("@sap/cds"));
|
|
10
|
+
const cardano_1 = require("#cds-models/odatano/cardano");
|
|
11
|
+
const cip68_1 = require("../cbor/cip68");
|
|
12
|
+
const { SELECT, UPDATE } = cds_1.default.ql;
|
|
13
|
+
/** Spending transactions a reference NFT is followed through before the trail is given up. */
|
|
14
|
+
const MAX_HOPS = 10_000;
|
|
15
|
+
async function storedDatum(tx, dataHash) {
|
|
16
|
+
const row = await tx.run(SELECT.one.from(cardano_1.TransactionDatums).columns('datum').where({ dataHash }));
|
|
17
|
+
return row?.datum ?? null;
|
|
18
|
+
}
|
|
19
|
+
// The transaction that consumed an output. Collateral consumes only in a phase-2 failure,
|
|
20
|
+
// which is stored with collateral and reference inputs alone.
|
|
21
|
+
async function consumingTx(tx, spentTxHash, spentOutputIndex) {
|
|
22
|
+
const inputs = await tx.run(SELECT.from(cardano_1.TransactionInputs).columns('txSeq', 'isCollateral').where({ spentTxHash, spentOutputIndex, isReference: false }));
|
|
23
|
+
const regular = (inputs ?? []).find(i => !i.isCollateral);
|
|
24
|
+
if (regular)
|
|
25
|
+
return regular;
|
|
26
|
+
for (const candidate of inputs ?? []) {
|
|
27
|
+
const spendsRegular = await tx.run(SELECT.one.from(cardano_1.TransactionInputs).columns('txSeq').where({ txSeq: candidate.txSeq, isCollateral: false, isReference: false }));
|
|
28
|
+
if (!spendsRegular)
|
|
29
|
+
return candidate;
|
|
30
|
+
}
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
// Datum of the output holding a reference NFT now, followed from its latest mint through each spend.
|
|
34
|
+
// Hashed datums come from TransactionDatums. Null when the crawled chain has no trail.
|
|
35
|
+
async function currentReferenceDatum(tx, referenceUnit, mintTxHash) {
|
|
36
|
+
const mint = await tx.run(SELECT.one.from(cardano_1.AssetHistory).columns('txHash').where({ unit: referenceUnit, action: 'mint' }).orderBy('blockHeight desc', 'blockTime desc', 'txHash desc'));
|
|
37
|
+
let txHash = mint?.txHash ?? mintTxHash;
|
|
38
|
+
let datum = null;
|
|
39
|
+
for (let hop = 0; txHash && hop < MAX_HOPS; hop++) {
|
|
40
|
+
const head = await tx.run(SELECT.one.from(cardano_1.Transactions).columns('txSeq').where({ hash: txHash }));
|
|
41
|
+
if (head?.txSeq == null)
|
|
42
|
+
break;
|
|
43
|
+
const holder = await tx.run(SELECT.one.from(cardano_1.TransactionOutputAssets).columns('output_outputIndex').where({ output_txSeq: head.txSeq, unit: referenceUnit }));
|
|
44
|
+
if (holder?.output_outputIndex == null)
|
|
45
|
+
break;
|
|
46
|
+
const output = await tx.run(SELECT.one.from(cardano_1.TransactionOutputs).columns('utxo_inlineDatum', 'utxo_dataHash').where({ txSeq: head.txSeq, outputIndex: holder.output_outputIndex }));
|
|
47
|
+
datum = output?.utxo_inlineDatum ?? (output?.utxo_dataHash ? await storedDatum(tx, output.utxo_dataHash) : null) ?? datum;
|
|
48
|
+
const spender = await consumingTx(tx, txHash, holder.output_outputIndex);
|
|
49
|
+
if (spender?.txSeq == null)
|
|
50
|
+
break;
|
|
51
|
+
const next = await tx.run(SELECT.one.from(cardano_1.Transactions).columns('hash').where({ txSeq: spender.txSeq }));
|
|
52
|
+
txHash = next?.hash ?? null;
|
|
53
|
+
}
|
|
54
|
+
return datum;
|
|
55
|
+
}
|
|
56
|
+
// CIP-68 decimals of a label 333 or 444 token. `mintTxHash` is the token's own mint, tried when
|
|
57
|
+
// AssetHistory has no mint of the reference NFT. Null for other units or without data.
|
|
58
|
+
async function cip68Decimals(tx, unit, mintTxHash = null) {
|
|
59
|
+
const referenceUnit = (0, cip68_1.cip68ReferenceUnit)(unit);
|
|
60
|
+
if (!referenceUnit)
|
|
61
|
+
return null;
|
|
62
|
+
const datum = await currentReferenceDatum(tx, referenceUnit, mintTxHash);
|
|
63
|
+
return datum ? (0, cip68_1.cip68DecimalsFromDatum)(datum) : null;
|
|
64
|
+
}
|
|
65
|
+
/** Write `decimals` on every slice of the unit; returns the rows changed. */
|
|
66
|
+
async function setAssetDecimals(tx, unit, decimals) {
|
|
67
|
+
const changed = await tx.run(UPDATE.entity(cardano_1.Assets).set({ decimals }).where({ unit }));
|
|
68
|
+
return Number(changed) || 0;
|
|
69
|
+
}
|
|
70
|
+
// Copy decimals from each reference-NFT datum in a block to the matching user tokens. Returns rows changed.
|
|
71
|
+
async function applyReferenceDatums(tx, txs) {
|
|
72
|
+
let changed = 0;
|
|
73
|
+
for (const t of txs) {
|
|
74
|
+
const witness = new Map((t.datums ?? []).map((d) => [d.hash, d.cbor]));
|
|
75
|
+
for (const o of t.outputs ?? []) {
|
|
76
|
+
for (const a of o.amount ?? []) {
|
|
77
|
+
const users = (0, cip68_1.cip68UserUnits)(a.unit);
|
|
78
|
+
if (!users)
|
|
79
|
+
continue;
|
|
80
|
+
const datum = o.inlineDatum ?? (o.dataHash ? witness.get(o.dataHash) ?? await storedDatum(tx, o.dataHash) : null);
|
|
81
|
+
const decimals = datum ? (0, cip68_1.cip68DecimalsFromDatum)(datum) : null;
|
|
82
|
+
if (decimals == null)
|
|
83
|
+
continue;
|
|
84
|
+
for (const unit of users)
|
|
85
|
+
changed += await setAssetDecimals(tx, unit, decimals);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return changed;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=asset-decimals.js.map
|
|
@@ -1,174 +1,64 @@
|
|
|
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. Transactions come from 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
|
-
/**
|
|
75
|
-
* Get Asset Info (supply, mint history, CIP-25 + CIP-26 metadata).
|
|
76
|
-
* Blockfrost does NOT expose initial-mint timestamp in this endpoint —
|
|
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
|
|
80
|
-
*/
|
|
30
|
+
/** Asset info. Blockfrost has no initial-mint timestamp here, so `initialMintTime` stays null. */
|
|
81
31
|
getAssetInfo(unit: string): Promise<AssetInfo>;
|
|
82
|
-
/**
|
|
83
|
-
* Get latest mint/burn events for an asset, with backfilled block metadata.
|
|
84
|
-
* Blockfrost's `assetsHistory` returns tx_hash + action + amount only; we
|
|
85
|
-
* backfill `blockTime` and `blockHeight` via concurrent `api.txs(...)` calls.
|
|
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)
|
|
91
|
-
*/
|
|
92
32
|
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
|
-
*/
|
|
33
|
+
/** DRep by id (bech32). */
|
|
98
34
|
getDrep(drepId: string): Promise<DrepData>;
|
|
99
|
-
/**
|
|
100
|
-
* Get Account Data
|
|
101
|
-
* @param stakeAddress bech32 stake address
|
|
102
|
-
* @return {Promise<AccountData>} account data
|
|
103
|
-
*/
|
|
35
|
+
/** Account by stake address (bech32), with all its addresses and their UTxOs. */
|
|
104
36
|
getAccount(stakeAddress: string): Promise<AccountData>;
|
|
105
|
-
/**
|
|
106
|
-
* Submit Transaction
|
|
107
|
-
* @param signedTxCbor hex-encoded signed transaction CBOR
|
|
108
|
-
* @returns {Promise<string>} transaction hash
|
|
109
|
-
*/
|
|
37
|
+
/** Submit a signed transaction (CBOR hex); returns the tx hash. */
|
|
110
38
|
submitTransaction(signedTxCbor: string): Promise<string>;
|
|
111
|
-
/**
|
|
112
|
-
* Get Protocol Parameters
|
|
113
|
-
* @returns {Promise<LedgerProtocolParameters>} protocol parameters
|
|
114
|
-
*/
|
|
39
|
+
/** Protocol parameters of the latest epoch. */
|
|
115
40
|
getProtocolParameters(): Promise<LedgerProtocolParameters>;
|
|
116
|
-
/**
|
|
117
|
-
* Get Latest Epoch Data
|
|
118
|
-
* @returns {Promise<EpochData>} latest epoch data
|
|
119
|
-
*/
|
|
41
|
+
/** Latest epoch. */
|
|
120
42
|
getLatestEpoch(): Promise<EpochData>;
|
|
121
|
-
/**
|
|
122
|
-
* Get Latest Block Data
|
|
123
|
-
* @returns {Promise<BlockData>} latest block data
|
|
124
|
-
*/
|
|
43
|
+
/** Latest block. */
|
|
125
44
|
getLatestBlock(): Promise<BlockData>;
|
|
126
|
-
/**
|
|
127
|
-
* Get the latest chain tip slot.
|
|
128
|
-
* @returns {Promise<number>} current chain slot
|
|
129
|
-
*/
|
|
45
|
+
/** Latest chain tip slot; ProviderUnavailableError when the latest block has no slot. */
|
|
130
46
|
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
|
-
*/
|
|
47
|
+
/** Whether a UTxO is unspent, via Blockfrost's `consumed_by_tx`; false for unknown tx or out-of-range index. */
|
|
137
48
|
isUtxoUnspent(txHash: string, outputIndex: number): Promise<boolean>;
|
|
138
49
|
/** Max concurrent Blockfrost API calls (free tier: ~10 req/s) */
|
|
139
50
|
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
|
-
*/
|
|
51
|
+
/** Most recent tx hashes of an address (no details). */
|
|
146
52
|
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
|
-
*/
|
|
53
|
+
/** Transactions by hash (map hash -> Transaction); no batch endpoint, so concurrency-limited parallel calls. */
|
|
153
54
|
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
|
-
*/
|
|
55
|
+
/** Map a Blockfrost block summary (blocks()/blocksNext()) to BlockData. */
|
|
158
56
|
private toBlockData;
|
|
159
|
-
/**
|
|
160
|
-
* Get a block by its height. Blockfrost's `blocks` endpoint accepts a height as
|
|
161
|
-
* well as a hash.
|
|
162
|
-
*/
|
|
57
|
+
/** Block by height; Blockfrost's `blocks` endpoint accepts a height as well as a hash. */
|
|
163
58
|
getBlockByHeight(height: number): Promise<BlockData>;
|
|
164
|
-
/**
|
|
165
|
-
* Get up to `count` blocks immediately following `afterHash`, in ascending chain order.
|
|
166
|
-
*/
|
|
59
|
+
/** Up to `count` blocks immediately following `afterHash`, in ascending chain order. */
|
|
167
60
|
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
|
-
*/
|
|
61
|
+
/** Full transaction list of a block in block order (hashes from blocksTxsAll, details batched). */
|
|
172
62
|
getBlockTransactions(blockHash: string): Promise<Transaction[]>;
|
|
173
63
|
}
|
|
174
64
|
//# sourceMappingURL=blockfrost-backend.d.ts.map
|