@odatano/core 2.0.0-rc.19 → 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 +1 -5
- package/@cds-models/CardanoIndexerService/index.d.ts +51 -2
- package/@cds-models/CardanoIndexerService/index.js +7 -0
- package/package.json +1 -1
- package/src/index.d.ts +4 -10
- package/src/index.js +6 -16
- package/src/plugin.js +11 -27
- package/srv/blockchain/backends/blockfrost-backend.d.ts +29 -131
- package/srv/blockchain/backends/blockfrost-backend.js +39 -150
- package/srv/blockchain/backends/cardano-backend.d.ts +53 -171
- package/srv/blockchain/backends/cardano-backend.js +1 -5
- package/srv/blockchain/backends/koios-backend.d.ts +26 -71
- package/srv/blockchain/backends/koios-backend.js +50 -132
- package/srv/blockchain/backends/ogmios-backend.d.ts +43 -124
- package/srv/blockchain/backends/ogmios-backend.js +71 -179
- package/srv/blockchain/backends/ogmios-frame-guard.d.ts +12 -57
- package/srv/blockchain/backends/ogmios-frame-guard.js +27 -66
- package/srv/blockchain/cardano-client.d.ts +43 -216
- package/srv/blockchain/cardano-client.js +49 -234
- package/srv/blockchain/cardano-indexer.d.ts +79 -357
- package/srv/blockchain/cardano-indexer.js +98 -406
- 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 +41 -145
- package/srv/blockchain/crawler/crawler.js +57 -172
- package/srv/blockchain/crawler/hooks.d.ts +3 -14
- package/srv/blockchain/crawler/index.d.ts +2 -6
- package/srv/blockchain/crawler/index.js +4 -9
- package/srv/blockchain/crawler/sync-state.d.ts +17 -39
- package/srv/blockchain/crawler/sync-state.js +23 -55
- package/srv/blockchain/crawler/utxo-set-import.d.ts +5 -22
- package/srv/blockchain/crawler/utxo-set-import.js +8 -28
- package/srv/blockchain/ledger-state.d.ts +3 -12
- 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 +65 -174
- package/srv/blockchain/transaction-building/buildooor-tx.js +107 -266
- 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 +9 -22
- package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +12 -35
- package/srv/blockchain/wallet-worker/confirmation-tracker.js +16 -32
- package/srv/blockchain/wallet-worker/index.js +2 -8
- package/srv/blockchain/wallet-worker/job-store.d.ts +33 -111
- 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 +1 -5
- package/srv/cardano-agent-service.js +3 -7
- package/srv/cardano-indexer-service.cds +32 -4
- package/srv/cardano-indexer-service.js +83 -15
- package/srv/cardano-service.js +36 -98
- package/srv/cardano-sign-service.cds +1 -1
- package/srv/cardano-sign-service.js +55 -173
- package/srv/cardano-tx-service.cds +1 -1
- package/srv/cardano-tx-service.js +54 -174
- package/srv/cardano-worker-service.js +7 -15
- package/srv/server.d.ts +27 -86
- package/srv/server.js +52 -148
- package/srv/utils/agent-grants-config.d.ts +11 -50
- package/srv/utils/agent-grants-config.js +12 -45
- package/srv/utils/agent-grants.d.ts +34 -123
- package/srv/utils/agent-grants.js +57 -156
- package/srv/utils/agent-token-auth.d.ts +2 -5
- package/srv/utils/agent-token-auth.js +2 -5
- 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 +2 -7
- package/srv/utils/db-indexes.js +7 -34
- package/srv/utils/db-sanitize.d.ts +5 -18
- package/srv/utils/db-sanitize.js +6 -19
- package/srv/utils/error-codes.d.ts +18 -73
- package/srv/utils/error-codes.js +17 -70
- package/srv/utils/errors.d.ts +29 -191
- package/srv/utils/errors.js +44 -229
- package/srv/utils/liveness.d.ts +2 -9
- package/srv/utils/liveness.js +3 -11
- package/srv/utils/mappers.d.ts +50 -298
- package/srv/utils/mappers.js +80 -386
- package/srv/utils/network-context.js +2 -11
- package/srv/utils/pg-order-nulls.js +4 -23
- package/srv/utils/plutus-placeholders.d.ts +6 -18
- package/srv/utils/plutus-placeholders.js +6 -20
- package/srv/utils/rate-limiter.d.ts +6 -17
- package/srv/utils/rate-limiter.js +5 -15
- 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 +7 -26
- package/srv/utils/tx-request-parsers.js +7 -26
- package/srv/utils/tx-utils.d.ts +4 -23
- package/srv/utils/tx-utils.js +12 -41
- package/srv/utils/types.d.ts +67 -206
- package/srv/utils/types.js +2 -6
- package/srv/utils/validators.d.ts +19 -89
- package/srv/utils/validators.js +31 -138
|
@@ -5,7 +5,7 @@ import * as __ from './../_';
|
|
|
5
5
|
* Cardano Agent Service (v2.0)
|
|
6
6
|
*
|
|
7
7
|
* Agent grants: scoped, budgeted bearer capabilities an Admin hands to an agent
|
|
8
|
-
* instead of a full user
|
|
8
|
+
* instead of a full user.
|
|
9
9
|
*
|
|
10
10
|
* - CreateAgentGrant / UpdateAgentGrant / RotateAgentGrantToken / RevokeAgentGrant:
|
|
11
11
|
* Admin-only administration, rate limited per principal per hour
|
|
@@ -19,10 +19,6 @@ import * as __ from './../_';
|
|
|
19
19
|
* - GetGrantUsage: admitted calls per service and action over a window — an Admin
|
|
20
20
|
* for any grant, a token for its own (a partner usage view, ledger reconciliation).
|
|
21
21
|
*
|
|
22
|
-
* Names are this repo's PascalCase; semantics mirror NIGHTGATE's agent grants
|
|
23
|
-
* (createAgentGrant / updateAgentGrant / rotateAgentGrantToken / revokeAgentGrant /
|
|
24
|
-
* getGrantUsage), so a gateway drives both products with one code path.
|
|
25
|
-
*
|
|
26
22
|
* A token request never inherits the operator's roles: `@requires: 'Admin'` on the
|
|
27
23
|
* four actions, on PauseWorker / ResumeWorker / pauseCrawler / resumeCrawler and on
|
|
28
24
|
* every other Admin surface therefore refuses it by construction. The allow list,
|
|
@@ -17,8 +17,7 @@ import * as __ from './../_';
|
|
|
17
17
|
* on every request BEFORE the operation's own annotation, so an operation-level
|
|
18
18
|
* `@requires: 'any'` can never open a single function on an otherwise
|
|
19
19
|
* authenticated service (anonymous callers get the 401 challenge first). The
|
|
20
|
-
* requirement therefore sits on each element, and getLiveness() alone is 'any'
|
|
21
|
-
* the same layout as NIGHTGATE's indexer service.
|
|
20
|
+
* requirement therefore sits on each element, and getLiveness() alone is 'any'.
|
|
22
21
|
*/
|
|
23
22
|
export default class {
|
|
24
23
|
static readonly getStatus: typeof getStatus;
|
|
@@ -26,6 +25,7 @@ export default class {
|
|
|
26
25
|
static readonly pauseCrawler: typeof pauseCrawler;
|
|
27
26
|
static readonly resumeCrawler: typeof resumeCrawler;
|
|
28
27
|
static readonly importUtxoSet: typeof importUtxoSet;
|
|
28
|
+
static readonly backfillCertificates: typeof backfillCertificates;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
// entity 'SyncState'
|
|
@@ -101,6 +101,7 @@ export declare function _CrawlerStatusAspect<TBase extends new (...args: any[])
|
|
|
101
101
|
syncProgress?: string | null
|
|
102
102
|
consecutiveErrors?: number | null
|
|
103
103
|
utxoSet?: UtxoSetStatus | null
|
|
104
|
+
certificateBackfill?: CertificateBackfillStatus | null
|
|
104
105
|
} & InstanceType<TBase>
|
|
105
106
|
readonly kind: 'type';
|
|
106
107
|
readonly keys: __.KeysOf<CrawlerStatus>;
|
|
@@ -110,6 +111,44 @@ export declare function _CrawlerStatusAspect<TBase extends new (...args: any[])
|
|
|
110
111
|
export class CrawlerStatus extends _CrawlerStatusAspect(__.Entity) {
|
|
111
112
|
}
|
|
112
113
|
|
|
114
|
+
// entity 'CertificateBackfillStatus'
|
|
115
|
+
export declare function _CertificateBackfillStatusAspect<TBase extends new (...args: any[]) => object>(Base: TBase): {
|
|
116
|
+
new (...args: any[]): {
|
|
117
|
+
status?: string | null
|
|
118
|
+
fromSlot?: string | null
|
|
119
|
+
toSlot?: string | null
|
|
120
|
+
atSlot?: string | null
|
|
121
|
+
blocks?: number | null
|
|
122
|
+
certificates?: number | null
|
|
123
|
+
withdrawals?: number | null
|
|
124
|
+
startedAt?: __.CdsTimestamp | null
|
|
125
|
+
finishedAt?: __.CdsTimestamp | null
|
|
126
|
+
error?: string | null
|
|
127
|
+
} & InstanceType<TBase>
|
|
128
|
+
readonly kind: 'type';
|
|
129
|
+
readonly keys: __.KeysOf<CertificateBackfillStatus>;
|
|
130
|
+
readonly elements: __.ElementsOf<CertificateBackfillStatus>;
|
|
131
|
+
readonly actions: globalThis.Record<never, never>;
|
|
132
|
+
};
|
|
133
|
+
export class CertificateBackfillStatus extends _CertificateBackfillStatusAspect(__.Entity) {
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// entity 'CertificateBackfillResult'
|
|
137
|
+
export declare function _CertificateBackfillResultAspect<TBase extends new (...args: any[]) => object>(Base: TBase): {
|
|
138
|
+
new (...args: any[]): {
|
|
139
|
+
accepted?: boolean | null
|
|
140
|
+
fromSlot?: string | null
|
|
141
|
+
toSlot?: string | null
|
|
142
|
+
message?: string | null
|
|
143
|
+
} & InstanceType<TBase>
|
|
144
|
+
readonly kind: 'type';
|
|
145
|
+
readonly keys: __.KeysOf<CertificateBackfillResult>;
|
|
146
|
+
readonly elements: __.ElementsOf<CertificateBackfillResult>;
|
|
147
|
+
readonly actions: globalThis.Record<never, never>;
|
|
148
|
+
};
|
|
149
|
+
export class CertificateBackfillResult extends _CertificateBackfillResultAspect(__.Entity) {
|
|
150
|
+
}
|
|
151
|
+
|
|
113
152
|
// entity 'UtxoSetStatus'
|
|
114
153
|
export declare function _UtxoSetStatusAspect<TBase extends new (...args: any[]) => object>(Base: TBase): {
|
|
115
154
|
new (...args: any[]): {
|
|
@@ -227,4 +266,14 @@ export declare const importUtxoSet: {
|
|
|
227
266
|
// metadata (do not use)
|
|
228
267
|
__parameters: {source?: string | null, filePath?: string | null, anchorSlot?: number | null, anchorHash?: string | null}, __returns: globalThis.Promise<UtxoSetImportResult | null> | UtxoSetImportResult | null, __self: never
|
|
229
268
|
kind: 'action'
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export declare const backfillCertificates: {
|
|
272
|
+
// positional
|
|
273
|
+
(fromSlot: number | null, toSlot: number | null): globalThis.Promise<CertificateBackfillResult | null> | CertificateBackfillResult | null
|
|
274
|
+
// named
|
|
275
|
+
({fromSlot, toSlot}: {fromSlot?: number | null, toSlot?: number | null}): globalThis.Promise<CertificateBackfillResult | null> | CertificateBackfillResult | null
|
|
276
|
+
// metadata (do not use)
|
|
277
|
+
__parameters: {fromSlot?: number | null, toSlot?: number | null}, __returns: globalThis.Promise<CertificateBackfillResult | null> | CertificateBackfillResult | null, __self: never
|
|
278
|
+
kind: 'action'
|
|
230
279
|
}
|
|
@@ -13,6 +13,12 @@ module.exports.ReorgLog_ = createEntityProxy(['CardanoIndexerService', 'ReorgLog
|
|
|
13
13
|
// CrawlerStatus
|
|
14
14
|
module.exports.CrawlerStatus = createEntityProxy(['CardanoIndexerService', 'CrawlerStatus'], { target: { is_singular: true } })
|
|
15
15
|
module.exports.__Array_CrawlerStatus_ = createEntityProxy(['CardanoIndexerService', 'CrawlerStatus'], { target: { is_singular: false }})
|
|
16
|
+
// CertificateBackfillStatus
|
|
17
|
+
module.exports.CertificateBackfillStatus = createEntityProxy(['CardanoIndexerService', 'CertificateBackfillStatus'], { target: { is_singular: true } })
|
|
18
|
+
module.exports.__Array_CertificateBackfillStatus_ = createEntityProxy(['CardanoIndexerService', 'CertificateBackfillStatus'], { target: { is_singular: false }})
|
|
19
|
+
// CertificateBackfillResult
|
|
20
|
+
module.exports.CertificateBackfillResult = createEntityProxy(['CardanoIndexerService', 'CertificateBackfillResult'], { target: { is_singular: true } })
|
|
21
|
+
module.exports.__Array_CertificateBackfillResult_ = createEntityProxy(['CardanoIndexerService', 'CertificateBackfillResult'], { target: { is_singular: false }})
|
|
16
22
|
// UtxoSetStatus
|
|
17
23
|
module.exports.UtxoSetStatus = createEntityProxy(['CardanoIndexerService', 'UtxoSetStatus'], { target: { is_singular: true } })
|
|
18
24
|
module.exports.__Array_UtxoSetStatus_ = createEntityProxy(['CardanoIndexerService', 'UtxoSetStatus'], { target: { is_singular: false }})
|
|
@@ -31,4 +37,5 @@ module.exports.getLiveness = 'getLiveness'
|
|
|
31
37
|
module.exports.pauseCrawler = 'pauseCrawler'
|
|
32
38
|
module.exports.resumeCrawler = 'resumeCrawler'
|
|
33
39
|
module.exports.importUtxoSet = 'importUtxoSet'
|
|
40
|
+
module.exports.backfillCertificates = 'backfillCertificates'
|
|
34
41
|
// enums
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -14,19 +14,13 @@ export type { HsmConfig, HsmSignResult } from '../srv/utils/types';
|
|
|
14
14
|
export { parseTransaction } from '../srv/cbor';
|
|
15
15
|
export type { ParsedTransaction, ParsedInput, ParsedOutput, ParsedAsset, ParsedWitnesses, } from '../srv/cbor';
|
|
16
16
|
/**
|
|
17
|
-
* Initialize the
|
|
18
|
-
*
|
|
19
|
-
* then initializes all blockchain components.
|
|
17
|
+
* Initialize the plugin: config from cds.env.requires["odatano-core"] or env vars,
|
|
18
|
+
* then all blockchain components plus the optional crawler and wallet worker.
|
|
20
19
|
*/
|
|
21
20
|
export declare function initialize(): Promise<void>;
|
|
22
|
-
/**
|
|
23
|
-
* Shutdown the ODATANO plugin.
|
|
24
|
-
* Cleans up all backend connections (especially Ogmios WebSocket).
|
|
25
|
-
*/
|
|
21
|
+
/** Shut down the plugin and close all backend connections. */
|
|
26
22
|
export declare function shutdown(): Promise<void>;
|
|
27
|
-
/**
|
|
28
|
-
* Get the current status of the plugin.
|
|
29
|
-
*/
|
|
23
|
+
/** Current plugin status. */
|
|
30
24
|
export declare function getStatus(): {
|
|
31
25
|
initialized: boolean;
|
|
32
26
|
network?: string;
|
package/src/index.js
CHANGED
|
@@ -65,9 +65,7 @@ Object.defineProperty(exports, "shutdownAppContext", { enumerable: true, get: fu
|
|
|
65
65
|
// Re-export HSM signer for programmatic access
|
|
66
66
|
var hsm_signer_1 = require("../srv/blockchain/signing/hsm-signer");
|
|
67
67
|
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.
|
|
68
|
+
// Agent grants: programmatic seams for packages that issue grants or add transport lanes.
|
|
71
69
|
var agent_grants_1 = require("../srv/utils/agent-grants");
|
|
72
70
|
Object.defineProperty(exports, "issueAgentGrant", { enumerable: true, get: function () { return agent_grants_1.issueAgentGrant; } });
|
|
73
71
|
Object.defineProperty(exports, "updateAgentGrant", { enumerable: true, get: function () { return agent_grants_1.updateAgentGrant; } });
|
|
@@ -89,9 +87,8 @@ Object.defineProperty(exports, "loadAgentGrantsConfig", { enumerable: true, get:
|
|
|
89
87
|
var cbor_1 = require("../srv/cbor");
|
|
90
88
|
Object.defineProperty(exports, "parseTransaction", { enumerable: true, get: function () { return cbor_1.parseTransaction; } });
|
|
91
89
|
/**
|
|
92
|
-
* Initialize the
|
|
93
|
-
*
|
|
94
|
-
* then initializes all blockchain components.
|
|
90
|
+
* Initialize the plugin: config from cds.env.requires["odatano-core"] or env vars,
|
|
91
|
+
* then all blockchain components plus the optional crawler and wallet worker.
|
|
95
92
|
*/
|
|
96
93
|
async function initialize() {
|
|
97
94
|
const { loadConfigFromEnv, loadHsmConfigFromEnv, initializeFromConfig, getAppContext } = await Promise.resolve().then(() => __importStar(require('../srv/server')));
|
|
@@ -109,26 +106,19 @@ async function initialize() {
|
|
|
109
106
|
if (!alreadyInitialized) {
|
|
110
107
|
logger.info('ODATANO core initialized');
|
|
111
108
|
}
|
|
112
|
-
//
|
|
109
|
+
// Optional subsystems; each is non-fatal.
|
|
113
110
|
const { startCrawlerIfConfigured, startWalletWorkerIfConfigured, redriveInterruptedSubmissionsIfConfigured } = await Promise.resolve().then(() => __importStar(require('../srv/server')));
|
|
114
111
|
await startCrawlerIfConfigured();
|
|
115
|
-
// Start the wallet worker if configured (plugin mode). Non-fatal.
|
|
116
112
|
await startWalletWorkerIfConfigured();
|
|
117
|
-
// Re-drive deferred submissions interrupted by a restart (plugin mode). Non-fatal.
|
|
118
113
|
await redriveInterruptedSubmissionsIfConfigured();
|
|
119
114
|
}
|
|
120
|
-
/**
|
|
121
|
-
* Shutdown the ODATANO plugin.
|
|
122
|
-
* Cleans up all backend connections (especially Ogmios WebSocket).
|
|
123
|
-
*/
|
|
115
|
+
/** Shut down the plugin and close all backend connections. */
|
|
124
116
|
async function shutdown() {
|
|
125
117
|
const { shutdownAppContext } = await Promise.resolve().then(() => __importStar(require('../srv/server')));
|
|
126
118
|
await shutdownAppContext();
|
|
127
119
|
logger.info('ODATANO core shutdown');
|
|
128
120
|
}
|
|
129
|
-
/**
|
|
130
|
-
* Get the current status of the plugin.
|
|
131
|
-
*/
|
|
121
|
+
/** Current plugin status. */
|
|
132
122
|
function getStatus() {
|
|
133
123
|
try {
|
|
134
124
|
const { getAppContext } = require('../srv/server');
|
package/src/plugin.js
CHANGED
|
@@ -41,11 +41,8 @@ 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
|
}
|
|
@@ -75,29 +72,22 @@ cds_1.default.env.requires.kinds['odatano-core'] = {
|
|
|
75
72
|
impl: '@odatano/core',
|
|
76
73
|
model: [...PLUGIN_MODEL]
|
|
77
74
|
};
|
|
78
|
-
//
|
|
79
|
-
//
|
|
80
|
-
// so the model array on the kind is never merged. Set it directly.
|
|
75
|
+
// Also set model on the requires entry: CAP merges kind→requires before cds-plugin.js
|
|
76
|
+
// runs, so the model array on the kind alone is never picked up.
|
|
81
77
|
const req = cds_1.default.env.requires['odatano-core'];
|
|
82
78
|
if (req) {
|
|
83
79
|
req.model = [...PLUGIN_MODEL];
|
|
84
80
|
}
|
|
85
81
|
logger.debug('Plugin registered');
|
|
86
82
|
/**
|
|
87
|
-
* Agent grants (
|
|
88
|
-
*
|
|
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.
|
|
83
|
+
* Agent grants (off by default). Must run at plugin load, before CAP builds its
|
|
84
|
+
* middlewares, because it swaps the auth impl. Idempotent; server.ts repeats it for standalone.
|
|
92
85
|
*/
|
|
93
86
|
require('../srv/utils/agent-grants-config')
|
|
94
87
|
.activateAgentGrants();
|
|
95
88
|
/**
|
|
96
|
-
*
|
|
97
|
-
*
|
|
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/...).
|
|
89
|
+
* Plugin mode: relative @impl paths resolve from cds.root (the consumer app), so
|
|
90
|
+
* rewrite them to package-qualified paths that Node module resolution can find.
|
|
101
91
|
*/
|
|
102
92
|
cds_1.default.on('loaded', (model) => {
|
|
103
93
|
if (path_1.default.resolve(cds_1.default.root) === pluginRoot)
|
|
@@ -110,14 +100,11 @@ cds_1.default.on('loaded', (model) => {
|
|
|
110
100
|
}
|
|
111
101
|
}
|
|
112
102
|
});
|
|
113
|
-
|
|
114
|
-
* Initialize blockchain components when services are served
|
|
115
|
-
*/
|
|
103
|
+
// Initialize blockchain components once services are served.
|
|
116
104
|
cds_1.default.on('served', async () => {
|
|
117
105
|
if (initialized)
|
|
118
106
|
return;
|
|
119
|
-
//
|
|
120
|
-
// opening real backend connections (matches srv/server.ts's standalone hook).
|
|
107
|
+
// SKIP_AUTO_INIT lets consumer test suites mount the plugin without backend connections.
|
|
121
108
|
if (process.env.SKIP_AUTO_INIT === 'true') {
|
|
122
109
|
logger.info('Skipping plugin auto-initialization (SKIP_AUTO_INIT=true)');
|
|
123
110
|
return;
|
|
@@ -130,13 +117,10 @@ cds_1.default.on('served', async () => {
|
|
|
130
117
|
initialized = true;
|
|
131
118
|
}
|
|
132
119
|
catch (err) {
|
|
133
|
-
//
|
|
120
|
+
// Never throw: a plugin failure must not crash the host app.
|
|
134
121
|
logger.error('Failed to initialize plugin:', err);
|
|
135
122
|
}
|
|
136
123
|
});
|
|
137
|
-
/**
|
|
138
|
-
* Graceful shutdown handler
|
|
139
|
-
*/
|
|
140
124
|
cds_1.default.on('shutdown', async () => {
|
|
141
125
|
if (!initialized)
|
|
142
126
|
return;
|
|
@@ -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
|