@odatano/core 2.0.0-rc.3 → 2.0.0-rc.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@cds-models/CardanoAgentService/index.d.ts +251 -0
- package/@cds-models/CardanoAgentService/index.js +36 -0
- package/@cds-models/CardanoBackendService/index.d.ts +357 -0
- package/@cds-models/CardanoBackendService/index.js +40 -0
- package/@cds-models/CardanoIndexerService/index.d.ts +194 -2
- package/@cds-models/CardanoIndexerService/index.js +25 -0
- package/@cds-models/CardanoODataService/index.d.ts +294 -7
- package/@cds-models/CardanoODataService/index.js +33 -0
- package/@cds-models/CardanoSignService/index.d.ts +28 -3
- package/@cds-models/CardanoSignService/index.js +3 -0
- package/@cds-models/CardanoTransactionService/index.d.ts +52 -19
- package/@cds-models/CardanoTransactionService/index.js +4 -0
- package/@cds-models/index.d.ts +18 -0
- package/@cds-models/index.js +3 -0
- package/@cds-models/odatano/cardano/index.d.ts +408 -7
- package/@cds-models/odatano/cardano/index.js +42 -0
- package/README.md +64 -5
- package/db/schema.cds +677 -13
- package/db/types.cds +27 -0
- package/package.json +182 -173
- package/scripts/migrate-slot-leader.mjs +104 -0
- package/scripts/migrate-txseq.mjs +147 -0
- package/src/index.d.ts +11 -10
- package/src/index.js +28 -14
- package/src/plugin.js +39 -52
- package/srv/blockchain/backends/blockfrost-backend.d.ts +29 -131
- package/srv/blockchain/backends/blockfrost-backend.js +49 -160
- package/srv/blockchain/backends/cardano-backend.d.ts +104 -158
- package/srv/blockchain/backends/cardano-backend.js +19 -5
- package/srv/blockchain/backends/koios-backend.d.ts +126 -60
- package/srv/blockchain/backends/koios-backend.js +356 -217
- package/srv/blockchain/backends/odatano-backend.d.ts +64 -0
- package/srv/blockchain/backends/odatano-backend.js +170 -0
- package/srv/blockchain/backends/ogmios-backend.d.ts +162 -94
- package/srv/blockchain/backends/ogmios-backend.js +548 -197
- 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 +78 -205
- package/srv/blockchain/cardano-client.js +186 -242
- package/srv/blockchain/cardano-indexer.d.ts +302 -242
- package/srv/blockchain/cardano-indexer.js +1193 -362
- package/srv/blockchain/cardano-tx-builder.d.ts +43 -81
- package/srv/blockchain/cardano-tx-builder.js +177 -132
- package/srv/blockchain/crawler/certificate-backfill.d.ts +67 -0
- package/srv/blockchain/crawler/certificate-backfill.js +169 -0
- package/srv/blockchain/crawler/crawler.d.ts +139 -54
- package/srv/blockchain/crawler/crawler.js +478 -96
- package/srv/blockchain/crawler/hooks.d.ts +3 -14
- package/srv/blockchain/crawler/index.d.ts +5 -0
- package/srv/blockchain/crawler/index.js +35 -7
- package/srv/blockchain/crawler/sync-state.d.ts +46 -28
- package/srv/blockchain/crawler/sync-state.js +128 -43
- package/srv/blockchain/crawler/transaction-backfill.d.ts +52 -0
- package/srv/blockchain/crawler/transaction-backfill.js +283 -0
- package/srv/blockchain/crawler/utxo-set-import.d.ts +78 -0
- package/srv/blockchain/crawler/utxo-set-import.js +363 -0
- package/srv/blockchain/ledger-state.d.ts +101 -0
- package/srv/blockchain/ledger-state.js +432 -0
- package/srv/blockchain/pending-spends.d.ts +28 -0
- package/srv/blockchain/pending-spends.js +89 -0
- package/srv/blockchain/signing/cose-verifier.d.ts +5 -12
- package/srv/blockchain/signing/cose-verifier.js +6 -12
- package/srv/blockchain/signing/external-signer.d.ts +16 -113
- package/srv/blockchain/signing/external-signer.js +19 -122
- package/srv/blockchain/signing/hsm-signer.d.ts +13 -45
- package/srv/blockchain/signing/hsm-signer.js +23 -63
- package/srv/blockchain/signing/signature-verifier.d.ts +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 -49
- package/srv/blockchain/stored-chain.d.ts +33 -0
- package/srv/blockchain/stored-chain.js +234 -0
- package/srv/blockchain/transaction-building/buildooor-tx.d.ts +115 -160
- package/srv/blockchain/transaction-building/buildooor-tx.js +651 -287
- package/srv/blockchain/transaction-building/caller-datums.d.ts +29 -0
- package/srv/blockchain/transaction-building/caller-datums.js +139 -0
- package/srv/blockchain/transaction-building/cardano-tx.d.ts +10 -35
- package/srv/blockchain/transaction-rows.d.ts +12 -0
- package/srv/blockchain/transaction-rows.js +43 -0
- package/srv/blockchain/wallet-worker/build-request.d.ts +4 -17
- package/srv/blockchain/wallet-worker/build-request.js +48 -24
- package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +25 -17
- package/srv/blockchain/wallet-worker/confirmation-tracker.js +87 -41
- package/srv/blockchain/wallet-worker/index.js +2 -8
- package/srv/blockchain/wallet-worker/job-store.d.ts +36 -103
- package/srv/blockchain/wallet-worker/job-store.js +0 -0
- package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +4 -20
- package/srv/blockchain/wallet-worker/lease-heartbeat.js +4 -20
- package/srv/blockchain/wallet-worker/signers.d.ts +6 -19
- package/srv/blockchain/wallet-worker/signers.js +3 -8
- package/srv/blockchain/wallet-worker/wallet-worker.d.ts +15 -71
- package/srv/blockchain/wallet-worker/wallet-worker.js +40 -91
- package/srv/cardano-agent-service.cds +146 -0
- package/srv/cardano-agent-service.d.ts +2 -0
- package/srv/cardano-agent-service.js +12 -0
- package/srv/cardano-backend-service.cds +52 -0
- package/srv/cardano-backend-service.d.ts +2 -0
- package/srv/cardano-backend-service.js +244 -0
- package/srv/cardano-indexer-service.cds +201 -73
- package/srv/cardano-indexer-service.js +280 -11
- package/srv/cardano-service.cds +56 -1
- package/srv/cardano-service.js +52 -113
- package/srv/cardano-sign-service.cds +200 -180
- package/srv/cardano-sign-service.js +55 -173
- package/srv/cardano-tx-service.cds +439 -364
- package/srv/cardano-tx-service.js +305 -209
- package/srv/cardano-ui.cds +16 -16
- package/srv/cardano-worker-service.js +7 -15
- package/srv/cbor/parse.js +13 -1
- package/srv/server.d.ts +28 -86
- package/srv/server.js +130 -135
- package/srv/utils/agent-grants-config.d.ts +37 -0
- package/srv/utils/agent-grants-config.js +138 -0
- package/srv/utils/agent-grants.d.ts +262 -0
- package/srv/utils/agent-grants.js +922 -0
- package/srv/utils/agent-token-auth.d.ts +16 -0
- package/srv/utils/agent-token-auth.js +78 -0
- package/srv/utils/backend-request-handler.d.ts +2 -16
- package/srv/utils/backend-request-handler.js +3 -18
- package/srv/utils/collections.d.ts +4 -8
- package/srv/utils/collections.js +4 -8
- package/srv/utils/const.d.ts +30 -67
- package/srv/utils/const.js +32 -72
- package/srv/utils/crypto.d.ts +3 -12
- package/srv/utils/crypto.js +5 -18
- package/srv/utils/db-indexes.d.ts +25 -0
- package/srv/utils/db-indexes.js +94 -0
- package/srv/utils/db-sanitize.d.ts +27 -0
- package/srv/utils/db-sanitize.js +85 -0
- package/srv/utils/epoch-slots.d.ts +13 -0
- package/srv/utils/epoch-slots.js +25 -0
- package/srv/utils/error-codes.d.ts +20 -73
- package/srv/utils/error-codes.js +19 -70
- package/srv/utils/errors.d.ts +50 -177
- package/srv/utils/errors.js +94 -218
- package/srv/utils/liveness.d.ts +16 -0
- package/srv/utils/liveness.js +40 -0
- package/srv/utils/mappers.d.ts +128 -214
- package/srv/utils/mappers.js +354 -299
- package/srv/utils/network-context.js +2 -11
- package/srv/utils/pg-inline-json.d.ts +8 -0
- package/srv/utils/pg-inline-json.js +62 -0
- package/srv/utils/pg-order-nulls.d.ts +14 -0
- package/srv/utils/pg-order-nulls.js +56 -0
- package/srv/utils/plutus-placeholders.d.ts +23 -16
- package/srv/utils/plutus-placeholders.js +63 -27
- package/srv/utils/rate-limiter.d.ts +46 -0
- package/srv/utils/rate-limiter.js +116 -0
- package/srv/utils/service-events.d.ts +2 -22
- package/srv/utils/service-events.js +3 -23
- package/srv/utils/signing-helper.d.ts +3 -18
- package/srv/utils/signing-helper.js +10 -32
- package/srv/utils/tx-build-helper.d.ts +26 -92
- package/srv/utils/tx-build-helper.js +68 -123
- package/srv/utils/tx-request-parsers.d.ts +107 -21
- package/srv/utils/tx-request-parsers.js +433 -34
- package/srv/utils/tx-utils.d.ts +4 -23
- package/srv/utils/tx-utils.js +12 -41
- package/srv/utils/types.d.ts +238 -169
- package/srv/utils/types.js +2 -6
- package/srv/utils/validators.d.ts +24 -90
- package/srv/utils/validators.js +50 -147
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Move a database written before the txSeq schema onto it: TransactionInputs / TransactionOutputs
|
|
3
|
+
// and their asset tables are keyed by Transactions.txSeq (slot * 65536 + txIndex) instead of the
|
|
4
|
+
// transaction hash. Runs against the configured `db` (PostgreSQL or SQLite) with ODATANO stopped:
|
|
5
|
+
//
|
|
6
|
+
// node scripts/migrate-txseq.mjs # image: docker compose run --rm --no-deps odatano migrate-txseq
|
|
7
|
+
// node scripts/migrate-txseq.mjs --dry-run # report what would change, touch nothing
|
|
8
|
+
//
|
|
9
|
+
// One transaction: fill Transactions.txSeq, rebuild the four tables in the new layout (rows copied
|
|
10
|
+
// in key order, row counts checked), recreate the service views, refresh the planner statistics
|
|
11
|
+
// and store the new model in `cds_model` so the next schema deployment sees no difference. A
|
|
12
|
+
// database already on the new layout is left alone. The table indexes are recreated by the server
|
|
13
|
+
// on its next start.
|
|
14
|
+
import cds from '@sap/cds';
|
|
15
|
+
|
|
16
|
+
const DRY = process.argv.includes('--dry-run');
|
|
17
|
+
const T = (name) => `odatano_cardano_${name}`;
|
|
18
|
+
const TX_SEQ_SLOT_FACTOR = 65536;
|
|
19
|
+
|
|
20
|
+
/** Old key column -> new key column, and the column the copy is ordered by after the key. */
|
|
21
|
+
const TABLES = [
|
|
22
|
+
{ name: 'TransactionInputs', hashKey: 'tx_hash', seqKey: 'txSeq', order: 'inputIndex' },
|
|
23
|
+
{ name: 'TransactionOutputs', hashKey: 'tx_hash', seqKey: 'txSeq', order: 'outputIndex' },
|
|
24
|
+
{ name: 'TransactionInputAssets', hashKey: 'input_tx_hash', seqKey: 'input_txSeq', order: 'input_inputIndex, unit' },
|
|
25
|
+
{ name: 'TransactionOutputAssets', hashKey: 'output_tx_hash', seqKey: 'output_txSeq', order: 'output_outputIndex, unit' },
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
/** Column names of a table, lower-cased (PostgreSQL folds unquoted identifiers). */
|
|
29
|
+
export async function tableColumns(db, table) {
|
|
30
|
+
const rows = db.kind === 'postgres'
|
|
31
|
+
? await db.run(`SELECT column_name AS name FROM information_schema.columns WHERE table_schema = current_schema() AND table_name = '${table.toLowerCase()}'`)
|
|
32
|
+
: await db.run(`SELECT name FROM pragma_table_info('${table}')`);
|
|
33
|
+
return rows.map(r => String(r.name).toLowerCase());
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** CREATE statements of the compiled model for one table (renamed) and for every view. */
|
|
37
|
+
export function modelStatements(model, options) {
|
|
38
|
+
const sql = cds.compile.to.sql(model, options);
|
|
39
|
+
const views = sql.filter(s => /^CREATE VIEW/i.test(s.trim()));
|
|
40
|
+
const tableDdl = (name) => {
|
|
41
|
+
const stmt = sql.find(s => new RegExp(`^CREATE TABLE ${T(name)} \\(`, 'i').test(s.trim()));
|
|
42
|
+
if (!stmt) throw new Error(`model has no table ${T(name)}`);
|
|
43
|
+
return stmt;
|
|
44
|
+
};
|
|
45
|
+
return { views, tableDdl };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const viewName = (stmt) => stmt.trim().match(/^CREATE VIEW\s+("?[\w.]+"?)/i)[1];
|
|
49
|
+
|
|
50
|
+
/** Copy statement: every column of the old table except the hash key, the new key from Transactions. */
|
|
51
|
+
export function copySql(spec, oldColumns) {
|
|
52
|
+
const others = oldColumns.filter(c => c !== spec.hashKey.toLowerCase());
|
|
53
|
+
const target = [spec.seqKey, ...others].join(', ');
|
|
54
|
+
const source = ['t.txSeq', ...others.map(c => `x.${c}`)].join(', ');
|
|
55
|
+
const order = ['t.txSeq', ...spec.order.split(',').map(c => `x.${c.trim()}`)].join(', ');
|
|
56
|
+
return `INSERT INTO ${T(spec.name)}_txseq_new (${target}) SELECT ${source} FROM ${T(spec.name)} x `
|
|
57
|
+
+ `JOIN ${T('Transactions')} t ON t.hash = x.${spec.hashKey} ORDER BY ${order}`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function count(tx, table) {
|
|
61
|
+
const [row] = await tx.run(`SELECT count(*) AS n FROM ${table}`);
|
|
62
|
+
return Number(row.n);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function main() {
|
|
66
|
+
const db = await cds.connect.to('db');
|
|
67
|
+
if (db.kind !== 'postgres' && db.kind !== 'sqlite') throw new Error(`unsupported database kind ${db.kind}: re-crawl instead`);
|
|
68
|
+
|
|
69
|
+
const inputColumns = await tableColumns(db, T('TransactionInputs'));
|
|
70
|
+
if (!inputColumns.includes('tx_hash')) {
|
|
71
|
+
console.log('Already on the txSeq layout; nothing to do.');
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const [lease] = await db.run(`SELECT leaseUntil FROM ${T('CardanoSyncState')}`).catch(() => []);
|
|
76
|
+
const leaseUntil = lease?.leaseUntil ?? lease?.leaseuntil;
|
|
77
|
+
if (leaseUntil && Date.parse(leaseUntil) > Date.now()) {
|
|
78
|
+
throw new Error(`the crawler lease is held until ${leaseUntil}: stop ODATANO first`);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// the model exactly as `cds deploy` compiles it
|
|
82
|
+
const model = await cds.load('*').then(cds.minify);
|
|
83
|
+
cds.deploy.exclude_external_entities_in(model);
|
|
84
|
+
const options = { ...db.options };
|
|
85
|
+
const { views, tableDdl } = modelStatements(model, options);
|
|
86
|
+
const [hasModelTable] = await db.run(db.kind === 'postgres'
|
|
87
|
+
? `SELECT 1 AS x FROM pg_tables WHERE tablename = 'cds_model' AND schemaname = current_schema()`
|
|
88
|
+
: `SELECT 1 AS x FROM sqlite_schema WHERE name = 'cds_model'`);
|
|
89
|
+
|
|
90
|
+
const txNull = Number((await db.run(`SELECT count(*) AS n FROM ${T('Transactions')} WHERE slot IS NULL OR txIndex IS NULL`))[0].n);
|
|
91
|
+
if (txNull > 0) throw new Error(`${txNull} transactions have no slot or txIndex; their txSeq cannot be derived`);
|
|
92
|
+
|
|
93
|
+
const plan = [];
|
|
94
|
+
for (const spec of TABLES) plan.push({ spec, columns: await tableColumns(db, T(spec.name)), rows: await count(db, T(spec.name)) });
|
|
95
|
+
for (const p of plan) console.log(`${T(p.spec.name)}: ${p.rows} rows, key ${p.spec.hashKey} -> ${p.spec.seqKey}`);
|
|
96
|
+
console.log(`${views.length} views recreated${hasModelTable ? ', cds_model updated' : ''}`);
|
|
97
|
+
if (DRY) { console.log('dry run: nothing changed'); return; }
|
|
98
|
+
|
|
99
|
+
await db.tx(async (tx) => {
|
|
100
|
+
const started = Date.now();
|
|
101
|
+
const step = (msg) => console.log(`[${Math.round((Date.now() - started) / 1000)}s] ${msg}`);
|
|
102
|
+
|
|
103
|
+
for (const stmt of [...views].reverse()) {
|
|
104
|
+
await tx.run(`DROP VIEW IF EXISTS ${viewName(stmt)}${db.kind === 'postgres' ? ' CASCADE' : ''}`);
|
|
105
|
+
}
|
|
106
|
+
step('views dropped');
|
|
107
|
+
|
|
108
|
+
const txColumns = await tableColumns(tx, T('Transactions'));
|
|
109
|
+
if (!txColumns.includes('txseq')) await tx.run(`ALTER TABLE ${T('Transactions')} ADD COLUMN txSeq BIGINT`);
|
|
110
|
+
await tx.run(`UPDATE ${T('Transactions')} SET txSeq = slot * ${TX_SEQ_SLOT_FACTOR} + txIndex`);
|
|
111
|
+
await tx.run(`CREATE INDEX IF NOT EXISTS odatano_cardano_transactions_txseq ON ${T('Transactions')} (txSeq)`);
|
|
112
|
+
step('Transactions.txSeq filled');
|
|
113
|
+
|
|
114
|
+
for (const { spec, columns, rows } of plan) {
|
|
115
|
+
const table = T(spec.name);
|
|
116
|
+
const newTable = `${table}_txseq_new`;
|
|
117
|
+
await tx.run(tableDdl(spec.name).replace(new RegExp(`^(\\s*CREATE TABLE )${table}\\b`, 'i'), `$1${newTable}`));
|
|
118
|
+
await tx.run(copySql(spec, columns));
|
|
119
|
+
const copied = await count(tx, newTable);
|
|
120
|
+
if (copied !== rows) throw new Error(`${table}: ${rows} rows, ${copied} copied (rows without a Transactions row?)`);
|
|
121
|
+
await tx.run(`DROP TABLE ${table}`);
|
|
122
|
+
await tx.run(`ALTER TABLE ${newTable} RENAME TO ${table}`);
|
|
123
|
+
if (db.kind === 'postgres') {
|
|
124
|
+
await tx.run(`ALTER TABLE ${table} RENAME CONSTRAINT ${newTable.toLowerCase()}_pkey TO ${table.toLowerCase()}_pkey`);
|
|
125
|
+
}
|
|
126
|
+
step(`${table}: ${copied} rows`);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
for (const stmt of views) await tx.run(stmt);
|
|
130
|
+
step('views recreated');
|
|
131
|
+
|
|
132
|
+
// fresh planner statistics: without them the rebuilt tables are read by sequential scans
|
|
133
|
+
for (const name of ['Transactions', ...TABLES.map(t => t.name)]) await tx.run(`ANALYZE ${T(name)}`);
|
|
134
|
+
step('statistics updated');
|
|
135
|
+
|
|
136
|
+
if (hasModelTable) {
|
|
137
|
+
const { afterImage } = cds.compile.to.sql.delta(model, options);
|
|
138
|
+
await tx.run(db.kind === 'postgres' ? 'UPDATE cds_model SET csn = $1' : 'UPDATE cds_model SET csn = ?', [JSON.stringify(afterImage)]);
|
|
139
|
+
step('cds_model updated');
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
console.log('Migration to the txSeq layout done. Start ODATANO; it recreates the table indexes.');
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (process.argv[1] && import.meta.url === (await import('node:url')).pathToFileURL(process.argv[1]).href) {
|
|
146
|
+
main().then(() => process.exit(0), (err) => { console.error(`FAILED: ${err.message}`); process.exit(1); });
|
|
147
|
+
}
|
package/src/index.d.ts
CHANGED
|
@@ -4,23 +4,24 @@ export { CardanoIndexer } from '../srv/blockchain/cardano-indexer';
|
|
|
4
4
|
export { CardanoTransactionBuilder } from '../srv/blockchain/cardano-tx-builder';
|
|
5
5
|
export { getAppContext, getCardanoIndexer, getCardanoClient, getCardanoTxBuilder, loadConfigFromEnv, loadHsmConfigFromEnv, loadCrawlerConfigFromEnv, startCrawlerIfConfigured, loadWalletWorkerConfigFromEnv, startWalletWorkerIfConfigured, shutdownAppContext, } from '../srv/server';
|
|
6
6
|
export { getHsmSigner } from '../srv/blockchain/signing/hsm-signer';
|
|
7
|
+
export { issueAgentGrant, updateAgentGrant, rotateAgentGrantToken, revokeAgentGrantById, getGrantUsage, resolveUsageWindow, hashAgentToken, AGENT_TOKEN_HEADER, AGENT_TOKEN_PREFIX, AGENT_ROLE, AGENT_ALLOWLISTABLE_ACTIONS, AGENT_ALWAYS_ALLOWED_EVENTS, } from '../srv/utils/agent-grants';
|
|
8
|
+
export type { IssueAgentGrantInput, IssuedAgentGrant, AgentGrantStatus, UpdateAgentGrantInput, UpdateAgentGrantResult, RotatedAgentGrant, AgentGrantUsage, GrantUsageCall, UsageWindow, } from '../srv/utils/agent-grants';
|
|
9
|
+
export { registerTransportLane } from '@odatano/cap-auth';
|
|
10
|
+
export type { TransportLane, LaneOutcome } from '@odatano/cap-auth';
|
|
11
|
+
export { loadAgentGrantsConfig } from '../srv/utils/agent-grants-config';
|
|
12
|
+
export type { AgentGrantsConfig } from '../srv/utils/agent-grants-config';
|
|
7
13
|
export type { HsmConfig, HsmSignResult } from '../srv/utils/types';
|
|
8
14
|
export { parseTransaction } from '../srv/cbor';
|
|
9
15
|
export type { ParsedTransaction, ParsedInput, ParsedOutput, ParsedAsset, ParsedWitnesses, } from '../srv/cbor';
|
|
16
|
+
export { applyScriptParameters, plutusScriptHash } from '../srv/utils/tx-build-helper';
|
|
10
17
|
/**
|
|
11
|
-
* Initialize the
|
|
12
|
-
*
|
|
13
|
-
* then initializes all blockchain components.
|
|
18
|
+
* Initialize the plugin: config from cds.env.requires["odatano-core"] or env vars,
|
|
19
|
+
* then all blockchain components plus the optional crawler and wallet worker.
|
|
14
20
|
*/
|
|
15
21
|
export declare function initialize(): Promise<void>;
|
|
16
|
-
/**
|
|
17
|
-
* Shutdown the ODATANO plugin.
|
|
18
|
-
* Cleans up all backend connections (especially Ogmios WebSocket).
|
|
19
|
-
*/
|
|
22
|
+
/** Shut down the plugin and close all backend connections. */
|
|
20
23
|
export declare function shutdown(): Promise<void>;
|
|
21
|
-
/**
|
|
22
|
-
* Get the current status of the plugin.
|
|
23
|
-
*/
|
|
24
|
+
/** Current plugin status. */
|
|
24
25
|
export declare function getStatus(): {
|
|
25
26
|
initialized: boolean;
|
|
26
27
|
network?: string;
|
package/src/index.js
CHANGED
|
@@ -36,7 +36,7 @@ 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.parseTransaction = exports.getHsmSigner = exports.shutdownAppContext = exports.startWalletWorkerIfConfigured = exports.loadWalletWorkerConfigFromEnv = exports.startCrawlerIfConfigured = exports.loadCrawlerConfigFromEnv = exports.loadHsmConfigFromEnv = exports.loadConfigFromEnv = exports.getCardanoTxBuilder = exports.getCardanoClient = exports.getCardanoIndexer = exports.getAppContext = exports.CardanoTransactionBuilder = exports.CardanoIndexer = exports.CardanoClient = void 0;
|
|
39
|
+
exports.plutusScriptHash = exports.applyScriptParameters = exports.parseTransaction = exports.loadAgentGrantsConfig = exports.registerTransportLane = exports.AGENT_ALWAYS_ALLOWED_EVENTS = exports.AGENT_ALLOWLISTABLE_ACTIONS = 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.shutdownAppContext = exports.startWalletWorkerIfConfigured = exports.loadWalletWorkerConfigFromEnv = exports.startCrawlerIfConfigured = exports.loadCrawlerConfigFromEnv = exports.loadHsmConfigFromEnv = exports.loadConfigFromEnv = 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
42
|
exports.getStatus = getStatus;
|
|
@@ -65,13 +65,34 @@ 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: programmatic seams for packages that issue grants or add transport lanes.
|
|
69
|
+
var agent_grants_1 = require("../srv/utils/agent-grants");
|
|
70
|
+
Object.defineProperty(exports, "issueAgentGrant", { enumerable: true, get: function () { return agent_grants_1.issueAgentGrant; } });
|
|
71
|
+
Object.defineProperty(exports, "updateAgentGrant", { enumerable: true, get: function () { return agent_grants_1.updateAgentGrant; } });
|
|
72
|
+
Object.defineProperty(exports, "rotateAgentGrantToken", { enumerable: true, get: function () { return agent_grants_1.rotateAgentGrantToken; } });
|
|
73
|
+
Object.defineProperty(exports, "revokeAgentGrantById", { enumerable: true, get: function () { return agent_grants_1.revokeAgentGrantById; } });
|
|
74
|
+
Object.defineProperty(exports, "getGrantUsage", { enumerable: true, get: function () { return agent_grants_1.getGrantUsage; } });
|
|
75
|
+
Object.defineProperty(exports, "resolveUsageWindow", { enumerable: true, get: function () { return agent_grants_1.resolveUsageWindow; } });
|
|
76
|
+
Object.defineProperty(exports, "hashAgentToken", { enumerable: true, get: function () { return agent_grants_1.hashAgentToken; } });
|
|
77
|
+
Object.defineProperty(exports, "AGENT_TOKEN_HEADER", { enumerable: true, get: function () { return agent_grants_1.AGENT_TOKEN_HEADER; } });
|
|
78
|
+
Object.defineProperty(exports, "AGENT_TOKEN_PREFIX", { enumerable: true, get: function () { return agent_grants_1.AGENT_TOKEN_PREFIX; } });
|
|
79
|
+
Object.defineProperty(exports, "AGENT_ROLE", { enumerable: true, get: function () { return agent_grants_1.AGENT_ROLE; } });
|
|
80
|
+
Object.defineProperty(exports, "AGENT_ALLOWLISTABLE_ACTIONS", { enumerable: true, get: function () { return agent_grants_1.AGENT_ALLOWLISTABLE_ACTIONS; } });
|
|
81
|
+
Object.defineProperty(exports, "AGENT_ALWAYS_ALLOWED_EVENTS", { enumerable: true, get: function () { return agent_grants_1.AGENT_ALWAYS_ALLOWED_EVENTS; } });
|
|
82
|
+
var cap_auth_1 = require("@odatano/cap-auth");
|
|
83
|
+
Object.defineProperty(exports, "registerTransportLane", { enumerable: true, get: function () { return cap_auth_1.registerTransportLane; } });
|
|
84
|
+
var agent_grants_config_1 = require("../srv/utils/agent-grants-config");
|
|
85
|
+
Object.defineProperty(exports, "loadAgentGrantsConfig", { enumerable: true, get: function () { return agent_grants_config_1.loadAgentGrantsConfig; } });
|
|
68
86
|
// Re-export pure CBOR utilities (no CAP round-trip needed)
|
|
69
87
|
var cbor_1 = require("../srv/cbor");
|
|
70
88
|
Object.defineProperty(exports, "parseTransaction", { enumerable: true, get: function () { return cbor_1.parseTransaction; } });
|
|
89
|
+
// Pure script helpers (no initialize() needed)
|
|
90
|
+
var tx_build_helper_1 = require("../srv/utils/tx-build-helper");
|
|
91
|
+
Object.defineProperty(exports, "applyScriptParameters", { enumerable: true, get: function () { return tx_build_helper_1.applyScriptParameters; } });
|
|
92
|
+
Object.defineProperty(exports, "plutusScriptHash", { enumerable: true, get: function () { return tx_build_helper_1.plutusScriptHash; } });
|
|
71
93
|
/**
|
|
72
|
-
* Initialize the
|
|
73
|
-
*
|
|
74
|
-
* then initializes all blockchain components.
|
|
94
|
+
* Initialize the plugin: config from cds.env.requires["odatano-core"] or env vars,
|
|
95
|
+
* then all blockchain components plus the optional crawler and wallet worker.
|
|
75
96
|
*/
|
|
76
97
|
async function initialize() {
|
|
77
98
|
const { loadConfigFromEnv, loadHsmConfigFromEnv, initializeFromConfig, getAppContext } = await Promise.resolve().then(() => __importStar(require('../srv/server')));
|
|
@@ -89,26 +110,19 @@ async function initialize() {
|
|
|
89
110
|
if (!alreadyInitialized) {
|
|
90
111
|
logger.info('ODATANO core initialized');
|
|
91
112
|
}
|
|
92
|
-
//
|
|
113
|
+
// Optional subsystems; each is non-fatal.
|
|
93
114
|
const { startCrawlerIfConfigured, startWalletWorkerIfConfigured, redriveInterruptedSubmissionsIfConfigured } = await Promise.resolve().then(() => __importStar(require('../srv/server')));
|
|
94
115
|
await startCrawlerIfConfigured();
|
|
95
|
-
// Start the wallet worker if configured (plugin mode). Non-fatal.
|
|
96
116
|
await startWalletWorkerIfConfigured();
|
|
97
|
-
// Re-drive deferred submissions interrupted by a restart (plugin mode). Non-fatal.
|
|
98
117
|
await redriveInterruptedSubmissionsIfConfigured();
|
|
99
118
|
}
|
|
100
|
-
/**
|
|
101
|
-
* Shutdown the ODATANO plugin.
|
|
102
|
-
* Cleans up all backend connections (especially Ogmios WebSocket).
|
|
103
|
-
*/
|
|
119
|
+
/** Shut down the plugin and close all backend connections. */
|
|
104
120
|
async function shutdown() {
|
|
105
121
|
const { shutdownAppContext } = await Promise.resolve().then(() => __importStar(require('../srv/server')));
|
|
106
122
|
await shutdownAppContext();
|
|
107
123
|
logger.info('ODATANO core shutdown');
|
|
108
124
|
}
|
|
109
|
-
/**
|
|
110
|
-
* Get the current status of the plugin.
|
|
111
|
-
*/
|
|
125
|
+
/** Current plugin status. */
|
|
112
126
|
function getStatus() {
|
|
113
127
|
try {
|
|
114
128
|
const { getAppContext } = require('../srv/server');
|
package/src/plugin.js
CHANGED
|
@@ -41,80 +41,70 @@ 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
|
}
|
|
52
|
+
/** The schema and the six CDS services this package ships, package-qualified. */
|
|
53
|
+
const PLUGIN_MODEL = [
|
|
54
|
+
'@odatano/core/db/schema',
|
|
55
|
+
'@odatano/core/srv/cardano-service',
|
|
56
|
+
'@odatano/core/srv/cardano-tx-service',
|
|
57
|
+
'@odatano/core/srv/cardano-sign-service',
|
|
58
|
+
'@odatano/core/srv/cardano-indexer-service',
|
|
59
|
+
'@odatano/core/srv/cardano-worker-service',
|
|
60
|
+
'@odatano/core/srv/cardano-agent-service'
|
|
61
|
+
];
|
|
62
|
+
/** Relative `@impl` values used in the CDS files (rewritten in plugin mode, see below). */
|
|
63
|
+
const IMPL_PATHS = [
|
|
64
|
+
'srv/cardano-service',
|
|
65
|
+
'srv/cardano-tx-service',
|
|
66
|
+
'srv/cardano-sign-service',
|
|
67
|
+
'srv/cardano-indexer-service',
|
|
68
|
+
'srv/cardano-worker-service',
|
|
69
|
+
'srv/cardano-agent-service'
|
|
70
|
+
];
|
|
55
71
|
cds_1.default.env.requires.kinds['odatano-core'] = {
|
|
56
72
|
impl: '@odatano/core',
|
|
57
|
-
model: [
|
|
58
|
-
'@odatano/core/db/schema',
|
|
59
|
-
'@odatano/core/srv/cardano-service',
|
|
60
|
-
'@odatano/core/srv/cardano-tx-service',
|
|
61
|
-
'@odatano/core/srv/cardano-sign-service',
|
|
62
|
-
'@odatano/core/srv/cardano-indexer-service',
|
|
63
|
-
'@odatano/core/srv/cardano-worker-service'
|
|
64
|
-
]
|
|
73
|
+
model: [...PLUGIN_MODEL]
|
|
65
74
|
};
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
// 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.
|
|
69
77
|
const req = cds_1.default.env.requires['odatano-core'];
|
|
70
78
|
if (req) {
|
|
71
|
-
req.model = [
|
|
72
|
-
'@odatano/core/db/schema',
|
|
73
|
-
'@odatano/core/srv/cardano-service',
|
|
74
|
-
'@odatano/core/srv/cardano-tx-service',
|
|
75
|
-
'@odatano/core/srv/cardano-sign-service',
|
|
76
|
-
'@odatano/core/srv/cardano-indexer-service',
|
|
77
|
-
'@odatano/core/srv/cardano-worker-service'
|
|
78
|
-
];
|
|
79
|
+
req.model = [...PLUGIN_MODEL];
|
|
79
80
|
}
|
|
80
81
|
logger.debug('Plugin registered');
|
|
81
82
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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.
|
|
85
|
+
*/
|
|
86
|
+
require('../srv/utils/agent-grants-config')
|
|
87
|
+
.activateAgentGrants();
|
|
88
|
+
/**
|
|
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.
|
|
87
91
|
*/
|
|
88
92
|
cds_1.default.on('loaded', (model) => {
|
|
89
93
|
if (path_1.default.resolve(cds_1.default.root) === pluginRoot)
|
|
90
94
|
return;
|
|
91
95
|
const defs = model.definitions ?? {};
|
|
92
96
|
for (const def of Object.values(defs)) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
else if (def['@impl'] === 'srv/cardano-tx-service') {
|
|
97
|
-
def['@impl'] = '@odatano/core/srv/cardano-tx-service';
|
|
98
|
-
}
|
|
99
|
-
else if (def['@impl'] === 'srv/cardano-sign-service') {
|
|
100
|
-
def['@impl'] = '@odatano/core/srv/cardano-sign-service';
|
|
101
|
-
}
|
|
102
|
-
else if (def['@impl'] === 'srv/cardano-indexer-service') {
|
|
103
|
-
def['@impl'] = '@odatano/core/srv/cardano-indexer-service';
|
|
104
|
-
}
|
|
105
|
-
else if (def['@impl'] === 'srv/cardano-worker-service') {
|
|
106
|
-
def['@impl'] = '@odatano/core/srv/cardano-worker-service';
|
|
97
|
+
const impl = def['@impl'];
|
|
98
|
+
if (impl && IMPL_PATHS.includes(impl)) {
|
|
99
|
+
def['@impl'] = `@odatano/core/${impl}`;
|
|
107
100
|
}
|
|
108
101
|
}
|
|
109
102
|
});
|
|
110
|
-
|
|
111
|
-
* Initialize blockchain components when services are served
|
|
112
|
-
*/
|
|
103
|
+
// Initialize blockchain components once services are served.
|
|
113
104
|
cds_1.default.on('served', async () => {
|
|
114
105
|
if (initialized)
|
|
115
106
|
return;
|
|
116
|
-
//
|
|
117
|
-
// 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.
|
|
118
108
|
if (process.env.SKIP_AUTO_INIT === 'true') {
|
|
119
109
|
logger.info('Skipping plugin auto-initialization (SKIP_AUTO_INIT=true)');
|
|
120
110
|
return;
|
|
@@ -127,13 +117,10 @@ cds_1.default.on('served', async () => {
|
|
|
127
117
|
initialized = true;
|
|
128
118
|
}
|
|
129
119
|
catch (err) {
|
|
130
|
-
//
|
|
120
|
+
// Never throw: a plugin failure must not crash the host app.
|
|
131
121
|
logger.error('Failed to initialize plugin:', err);
|
|
132
122
|
}
|
|
133
123
|
});
|
|
134
|
-
/**
|
|
135
|
-
* Graceful shutdown handler
|
|
136
|
-
*/
|
|
137
124
|
cds_1.default.on('shutdown', async () => {
|
|
138
125
|
if (!initialized)
|
|
139
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
|