@odatano/core 2.0.0-rc.27 → 2.0.0-rc.28
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/package.json +1 -1
- package/srv/blockchain/backends/koios-backend.d.ts +1 -1
- package/srv/blockchain/backends/koios-backend.js +8 -6
- package/srv/blockchain/cardano-indexer.d.ts +1 -1
- package/srv/blockchain/signing/submission-finalizer.js +0 -1
- package/srv/cardano-service.js +13 -17
- package/srv/cardano-ui.cds +16 -16
- package/srv/server.js +11 -6
- package/srv/utils/liveness.js +0 -1
- package/srv/utils/pg-inline-json.js +0 -1
- package/srv/utils/pg-order-nulls.js +0 -1
package/package.json
CHANGED
|
@@ -75,7 +75,7 @@ export declare class KoiosBackend implements CardanoBackend, PaginatingBackend,
|
|
|
75
75
|
init(): Promise<boolean>;
|
|
76
76
|
/**
|
|
77
77
|
* Retry (500 → 1000 → 2000 ms) when Koios transiently returns [] for a valid query.
|
|
78
|
-
*
|
|
78
|
+
* Only non-emptiness is checked here; rows keep the caller's element type.
|
|
79
79
|
*/
|
|
80
80
|
private fetchWithRetryOnEmpty;
|
|
81
81
|
/**
|
|
@@ -114,10 +114,9 @@ class KoiosBackend {
|
|
|
114
114
|
}
|
|
115
115
|
/**
|
|
116
116
|
* Retry (500 → 1000 → 2000 ms) when Koios transiently returns [] for a valid query.
|
|
117
|
-
*
|
|
117
|
+
* Only non-emptiness is checked here; rows keep the caller's element type.
|
|
118
118
|
*/
|
|
119
|
-
async fetchWithRetryOnEmpty(fn,
|
|
120
|
-
label) {
|
|
119
|
+
async fetchWithRetryOnEmpty(fn, label) {
|
|
121
120
|
const maxRetries = 3;
|
|
122
121
|
const baseDelayMs = 500;
|
|
123
122
|
const result = await fn();
|
|
@@ -445,8 +444,8 @@ class KoiosBackend {
|
|
|
445
444
|
_mapKoiosPool(poolData, fallbackId) {
|
|
446
445
|
return {
|
|
447
446
|
poolId: poolData.pool_id_bech32 || poolData.pool_id_hex || fallbackId,
|
|
448
|
-
vrfKeyHash: poolData.vrf_key_hash,
|
|
449
|
-
blocksMinted: poolData.block_count,
|
|
447
|
+
vrfKeyHash: poolData.vrf_key_hash || '',
|
|
448
|
+
blocksMinted: poolData.block_count || 0,
|
|
450
449
|
// Koios pool_info has no blocks-in-current-epoch figure. null = not available;
|
|
451
450
|
// a 0 would be indistinguishable from a real zero downstream.
|
|
452
451
|
blocksEpoch: null,
|
|
@@ -461,7 +460,7 @@ class KoiosBackend {
|
|
|
461
460
|
pledge: poolData.pledge || '0',
|
|
462
461
|
margin: poolData.margin || 0,
|
|
463
462
|
fixedCost: poolData.fixed_cost || '0',
|
|
464
|
-
rewardAccount: poolData.reward_addr,
|
|
463
|
+
rewardAccount: poolData.reward_addr || '',
|
|
465
464
|
};
|
|
466
465
|
}
|
|
467
466
|
/**
|
|
@@ -911,6 +910,9 @@ class KoiosBackend {
|
|
|
911
910
|
const info = await this.fetchWithRetryOnEmpty(() => this.api.post('/block_info', { _block_hashes: [afterHash] }), `getNextBlocks/height(${afterHash})`);
|
|
912
911
|
if (!info.length)
|
|
913
912
|
throw new errors_1.NotFoundError('Block', this.name);
|
|
913
|
+
if (info[0].block_height == null) {
|
|
914
|
+
throw new errors_1.ProviderUnavailableError(`Block ${afterHash} has no height on Koios and cannot anchor pagination`, this.name);
|
|
915
|
+
}
|
|
914
916
|
anchorHeight = info[0].block_height;
|
|
915
917
|
}
|
|
916
918
|
const rows = await this.fetchWithRetryOnEmpty(() => this.api.get(`/blocks?block_height=gt.${anchorHeight}&order=block_height.asc&limit=${count}`), `getNextBlocks(${afterHash})`);
|
|
@@ -361,7 +361,7 @@ export declare class CardanoIndexer {
|
|
|
361
361
|
buildId?: string | null;
|
|
362
362
|
}): Promise<TransactionSubmission>;
|
|
363
363
|
/** Update a submission's status (two-phase submit: pending → submitted or failed). */
|
|
364
|
-
updateSubmissionStatus(tx: CapTransaction, submissionId: string, status:
|
|
364
|
+
updateSubmissionStatus(tx: CapTransaction, submissionId: string, status: TransactionSubmission['status'], errorMessage?: string): Promise<void>;
|
|
365
365
|
/** Persist a new signing request and link it to the build's sender address. */
|
|
366
366
|
persistSigningRequest(tx: CapTransaction, params: {
|
|
367
367
|
buildId: string;
|
|
@@ -16,7 +16,6 @@ const logger = cds_1.default.log('SubmissionFinalizer');
|
|
|
16
16
|
// Lazy require avoids the srv/server.ts <-> this-module import cycle; the app-context
|
|
17
17
|
// getters are only needed at runtime.
|
|
18
18
|
function server() {
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
20
19
|
return require('../../server');
|
|
21
20
|
}
|
|
22
21
|
/**
|
package/srv/cardano-service.js
CHANGED
|
@@ -9,6 +9,17 @@ const validators_1 = require("./utils/validators");
|
|
|
9
9
|
const errors_1 = require("./utils/errors");
|
|
10
10
|
const backend_request_handler_1 = require("./utils/backend-request-handler");
|
|
11
11
|
const cbor_1 = require("./cbor");
|
|
12
|
+
/** Newest temporal slice per key; child tables keep one row per validFrom. */
|
|
13
|
+
function latestSlices(rows, keyOf) {
|
|
14
|
+
const seen = new Map();
|
|
15
|
+
for (const row of rows) {
|
|
16
|
+
const key = keyOf(row);
|
|
17
|
+
const prev = seen.get(key);
|
|
18
|
+
if (!prev || (row.validFrom ?? '') > (prev.validFrom ?? ''))
|
|
19
|
+
seen.set(key, row);
|
|
20
|
+
}
|
|
21
|
+
return Array.from(seen.values());
|
|
22
|
+
}
|
|
12
23
|
const { SELECT } = cds_1.default.ql;
|
|
13
24
|
const logger = cds_1.default.log(`CardanoService`);
|
|
14
25
|
/** Upper bound of the temporal window; must outlast the slowest index-on-miss of one request. */
|
|
@@ -194,14 +205,7 @@ module.exports = (srv) => {
|
|
|
194
205
|
if (!existing)
|
|
195
206
|
await indexer().indexAddress(db, address);
|
|
196
207
|
const assets = await db.run(SELECT.from(AddressAssets).where({ address_address: address }));
|
|
197
|
-
|
|
198
|
-
const seen = new Map();
|
|
199
|
-
for (const asset of assets) {
|
|
200
|
-
if (!seen.has(asset.unit) || asset.validFrom > seen.get(asset.unit).validFrom) {
|
|
201
|
-
seen.set(asset.unit, asset);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
return Array.from(seen.values());
|
|
208
|
+
return latestSlices(assets, (asset) => asset.unit ?? '');
|
|
205
209
|
});
|
|
206
210
|
});
|
|
207
211
|
// GetUTxOsByAddress — indexes the parent address if needed, then queries child UTxOs.
|
|
@@ -232,15 +236,7 @@ module.exports = (srv) => {
|
|
|
232
236
|
const fresh = await db.run(SELECT.from(AddressUTxOs).where({ address_address: address }));
|
|
233
237
|
return fresh;
|
|
234
238
|
}
|
|
235
|
-
|
|
236
|
-
const seen = new Map();
|
|
237
|
-
for (const utxo of existing) {
|
|
238
|
-
const key = `${utxo.hash}#${utxo.index}`;
|
|
239
|
-
if (!seen.has(key) || utxo.validFrom > seen.get(key).validFrom) {
|
|
240
|
-
seen.set(key, utxo);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
return Array.from(seen.values());
|
|
239
|
+
return latestSlices(existing, (utxo) => `${utxo.hash}#${utxo.index}`);
|
|
244
240
|
});
|
|
245
241
|
});
|
|
246
242
|
// GetUTxOsByCredential — always-fresh credential-keyed UTxO query (dApp state reads need current
|
package/srv/cardano-ui.cds
CHANGED
|
@@ -891,13 +891,13 @@ annotate srv.Addresses with @(
|
|
|
891
891
|
$Type : 'UI.ReferenceFacet',
|
|
892
892
|
Label : 'Assets',
|
|
893
893
|
Target : 'assets/@UI.LineItem',
|
|
894
|
-
|
|
894
|
+
@UI.Hidden: (not hasAssets)
|
|
895
895
|
},
|
|
896
896
|
{
|
|
897
897
|
$Type : 'UI.ReferenceFacet',
|
|
898
898
|
Label : 'UTxOs',
|
|
899
899
|
Target : 'utxos/@UI.LineItem',
|
|
900
|
-
|
|
900
|
+
@UI.Hidden: (not hasUTxOs)
|
|
901
901
|
}
|
|
902
902
|
],
|
|
903
903
|
|
|
@@ -1075,7 +1075,7 @@ annotate srv.AddressUTxOs with @(
|
|
|
1075
1075
|
$Type : 'UI.ReferenceFacet',
|
|
1076
1076
|
Label : 'Assets',
|
|
1077
1077
|
Target : 'assets/@UI.LineItem',
|
|
1078
|
-
|
|
1078
|
+
@UI.Hidden: (not hasAssets)
|
|
1079
1079
|
},
|
|
1080
1080
|
{
|
|
1081
1081
|
$Type : 'UI.ReferenceFacet',
|
|
@@ -1305,19 +1305,19 @@ annotate srv.Transactions with @(
|
|
|
1305
1305
|
$Type : 'UI.ReferenceFacet',
|
|
1306
1306
|
Label : 'Metadata',
|
|
1307
1307
|
Target : 'metadata/@UI.LineItem',
|
|
1308
|
-
|
|
1308
|
+
@UI.Hidden: (not hasMetadata)
|
|
1309
1309
|
},
|
|
1310
1310
|
{
|
|
1311
1311
|
$Type : 'UI.ReferenceFacet',
|
|
1312
1312
|
Label : 'Inputs',
|
|
1313
1313
|
Target : 'inputs/@UI.LineItem',
|
|
1314
|
-
|
|
1314
|
+
@UI.Hidden: (not hasInputs)
|
|
1315
1315
|
},
|
|
1316
1316
|
{
|
|
1317
1317
|
$Type : 'UI.ReferenceFacet',
|
|
1318
1318
|
Label : 'Outputs',
|
|
1319
1319
|
Target : 'outputs/@UI.LineItem',
|
|
1320
|
-
|
|
1320
|
+
@UI.Hidden: (not hasOutputs)
|
|
1321
1321
|
}
|
|
1322
1322
|
],
|
|
1323
1323
|
|
|
@@ -1451,7 +1451,7 @@ annotate srv.TransactionInputs with @(
|
|
|
1451
1451
|
$Type : 'UI.ReferenceFacet',
|
|
1452
1452
|
Label : 'Assets',
|
|
1453
1453
|
Target : 'assets/@UI.LineItem',
|
|
1454
|
-
|
|
1454
|
+
@UI.Hidden: (not hasAssets)
|
|
1455
1455
|
},
|
|
1456
1456
|
{
|
|
1457
1457
|
$Type : 'UI.ReferenceFacet',
|
|
@@ -1625,7 +1625,7 @@ annotate srv.TransactionOutputs with @(
|
|
|
1625
1625
|
$Type : 'UI.ReferenceFacet',
|
|
1626
1626
|
Label : 'Assets',
|
|
1627
1627
|
Target : 'assets/@UI.LineItem',
|
|
1628
|
-
|
|
1628
|
+
@UI.Hidden: (not hasAssets)
|
|
1629
1629
|
},
|
|
1630
1630
|
{
|
|
1631
1631
|
$Type : 'UI.ReferenceFacet',
|
|
@@ -1860,7 +1860,7 @@ annotate srv.Accounts with @(
|
|
|
1860
1860
|
$Type : 'UI.ReferenceFacet',
|
|
1861
1861
|
Label : 'Addresses',
|
|
1862
1862
|
Target : 'Address/@UI.LineItem',
|
|
1863
|
-
|
|
1863
|
+
@UI.Hidden: (not hasAddresses)
|
|
1864
1864
|
}
|
|
1865
1865
|
],
|
|
1866
1866
|
|
|
@@ -2301,19 +2301,19 @@ annotate txsrv.TransactionBuilds with @(
|
|
|
2301
2301
|
$Type : 'UI.ReferenceFacet',
|
|
2302
2302
|
Label : 'Inputs',
|
|
2303
2303
|
Target : 'inputs/@UI.LineItem',
|
|
2304
|
-
|
|
2304
|
+
@UI.Hidden: (not hasInputs)
|
|
2305
2305
|
},
|
|
2306
2306
|
{
|
|
2307
2307
|
$Type : 'UI.ReferenceFacet',
|
|
2308
2308
|
Label : 'Outputs',
|
|
2309
2309
|
Target : 'outputs/@UI.LineItem',
|
|
2310
|
-
|
|
2310
|
+
@UI.Hidden: (not hasOutputs)
|
|
2311
2311
|
},
|
|
2312
2312
|
{
|
|
2313
2313
|
$Type : 'UI.ReferenceFacet',
|
|
2314
2314
|
Label : 'Submission',
|
|
2315
2315
|
Target : 'submission/@UI.FieldGroup#SubmissionDetails',
|
|
2316
|
-
|
|
2316
|
+
@UI.Hidden: (not wasSubmitted)
|
|
2317
2317
|
}
|
|
2318
2318
|
],
|
|
2319
2319
|
|
|
@@ -2439,7 +2439,7 @@ annotate txsrv.TransactionBuildInputs with @(
|
|
|
2439
2439
|
$Type : 'UI.ReferenceFacet',
|
|
2440
2440
|
Label : 'Assets',
|
|
2441
2441
|
Target : 'assets/@UI.LineItem',
|
|
2442
|
-
|
|
2442
|
+
@UI.Hidden: (not hasAssets)
|
|
2443
2443
|
},
|
|
2444
2444
|
{
|
|
2445
2445
|
$Type : 'UI.ReferenceFacet',
|
|
@@ -2611,7 +2611,7 @@ annotate txsrv.TransactionBuildOutputs with @(
|
|
|
2611
2611
|
$Type : 'UI.ReferenceFacet',
|
|
2612
2612
|
Label : 'Assets',
|
|
2613
2613
|
Target : 'assets/@UI.LineItem',
|
|
2614
|
-
|
|
2614
|
+
@UI.Hidden: (not hasAssets)
|
|
2615
2615
|
},
|
|
2616
2616
|
{
|
|
2617
2617
|
$Type : 'UI.ReferenceFacet',
|
|
@@ -2796,13 +2796,13 @@ annotate txsrv.TransactionSubmissions with @(
|
|
|
2796
2796
|
$Type : 'UI.ReferenceFacet',
|
|
2797
2797
|
Label : 'Error Details',
|
|
2798
2798
|
Target : '@UI.FieldGroup#ErrorDetails',
|
|
2799
|
-
|
|
2799
|
+
@UI.Hidden: (not hasErrors)
|
|
2800
2800
|
},
|
|
2801
2801
|
{
|
|
2802
2802
|
$Type : 'UI.ReferenceFacet',
|
|
2803
2803
|
Label : 'Errors',
|
|
2804
2804
|
Target : 'errors/@UI.LineItem',
|
|
2805
|
-
|
|
2805
|
+
@UI.Hidden: (not hasErrors)
|
|
2806
2806
|
}
|
|
2807
2807
|
],
|
|
2808
2808
|
|
package/srv/server.js
CHANGED
|
@@ -37,6 +37,10 @@ const agent_grants_config_1 = require("./utils/agent-grants-config");
|
|
|
37
37
|
const process_1 = require("process");
|
|
38
38
|
const logger = cds_1.default.log('ODATANO');
|
|
39
39
|
const VALID_NETWORKS = ['mainnet', 'preview', 'preprod'];
|
|
40
|
+
function coreCdsConfig() {
|
|
41
|
+
const requires = cds_1.default.env?.requires;
|
|
42
|
+
return requires?.['odatano-core'] ?? {};
|
|
43
|
+
}
|
|
40
44
|
const VALID_BACKENDS = ['blockfrost', 'koios', 'ogmios', 'odatano'];
|
|
41
45
|
const CRAWLER_LIMITS = {
|
|
42
46
|
batchSize: { min: 1, max: 100 },
|
|
@@ -238,13 +242,14 @@ async function shutdownAppContext() {
|
|
|
238
242
|
* @throws {ConfigError} if any value is invalid
|
|
239
243
|
*/
|
|
240
244
|
function loadConfigFromEnv() {
|
|
241
|
-
const cdsConfig =
|
|
245
|
+
const cdsConfig = coreCdsConfig();
|
|
242
246
|
const network = (cdsConfig.network || process_1.env.NETWORK || 'preview');
|
|
243
247
|
if (!VALID_NETWORKS.includes(network)) {
|
|
244
248
|
throw new errors_1.ConfigError(`Invalid NETWORK "${cdsConfig.network || process_1.env.NETWORK}". Must be one of: ${VALID_NETWORKS.join(', ')}`);
|
|
245
249
|
}
|
|
246
|
-
const
|
|
247
|
-
|
|
250
|
+
const backendsRaw = cdsConfig.backends ?? process_1.env.BACKENDS;
|
|
251
|
+
const backendStrings = Array.isArray(backendsRaw) ? backendsRaw
|
|
252
|
+
: backendsRaw ? String(backendsRaw).split(',').map(b => b.trim()) : ['koios'];
|
|
248
253
|
const invalidBackends = backendStrings.filter(b => !VALID_BACKENDS.includes(b));
|
|
249
254
|
if (invalidBackends.length > 0) {
|
|
250
255
|
throw new errors_1.ConfigError(`Invalid BACKENDS: "${invalidBackends.join(', ')}". Must be one of: ${VALID_BACKENDS.join(', ')}`);
|
|
@@ -315,7 +320,7 @@ function loadConfigFromEnv() {
|
|
|
315
320
|
* Returns undefined when HSM is not enabled.
|
|
316
321
|
*/
|
|
317
322
|
function loadHsmConfigFromEnv() {
|
|
318
|
-
const cdsConfig =
|
|
323
|
+
const cdsConfig = coreCdsConfig();
|
|
319
324
|
const hsmCds = cdsConfig.hsm ?? {};
|
|
320
325
|
const hsmEnabled = hsmCds.enabled === true || process_1.env.HSM_ENABLED === 'true';
|
|
321
326
|
if (!hsmEnabled)
|
|
@@ -352,7 +357,7 @@ function loadHsmConfigFromEnv() {
|
|
|
352
357
|
* Returns { enabled: false } when the crawler is off (the default).
|
|
353
358
|
*/
|
|
354
359
|
function loadCrawlerConfigFromEnv() {
|
|
355
|
-
const cdsConfig =
|
|
360
|
+
const cdsConfig = coreCdsConfig();
|
|
356
361
|
const c = cdsConfig.crawler ?? {};
|
|
357
362
|
// A CDS value, including an explicit `false`, wins over the environment.
|
|
358
363
|
const enabledRaw = c.enabled !== undefined ? c.enabled : process_1.env.CRAWLER_ENABLED;
|
|
@@ -440,7 +445,7 @@ const WALLET_WORKER_LIMITS = {
|
|
|
440
445
|
* Returns { enabled: false } when the worker is off (the default).
|
|
441
446
|
*/
|
|
442
447
|
function loadWalletWorkerConfigFromEnv() {
|
|
443
|
-
const cdsConfig =
|
|
448
|
+
const cdsConfig = coreCdsConfig();
|
|
444
449
|
const w = cdsConfig.walletWorker ?? {};
|
|
445
450
|
const enabledRaw = w.enabled !== undefined ? w.enabled : process_1.env.WALLET_WORKER_ENABLED;
|
|
446
451
|
let enabled = false;
|
package/srv/utils/liveness.js
CHANGED
|
@@ -17,7 +17,6 @@ function packageVersion() {
|
|
|
17
17
|
return cachedVersion;
|
|
18
18
|
try {
|
|
19
19
|
// srv/utils → package root; the in-place build keeps this path in plugin mode too.
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
21
20
|
const pkg = require(path_1.default.resolve(__dirname, '..', '..', 'package.json'));
|
|
22
21
|
cachedVersion = String(pkg.version ?? '');
|
|
23
22
|
}
|
|
@@ -31,7 +31,6 @@ async function drain(stream) {
|
|
|
31
31
|
function installPostgresInlineJson() {
|
|
32
32
|
let PostgresService;
|
|
33
33
|
try {
|
|
34
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
35
34
|
PostgresService = require('@cap-js/postgres/lib/PostgresService');
|
|
36
35
|
}
|
|
37
36
|
catch (err) {
|
|
@@ -29,7 +29,6 @@ function stripNullsForNotNull(orderBy, rendered) {
|
|
|
29
29
|
function installPostgresOrderNulls() {
|
|
30
30
|
let PostgresService;
|
|
31
31
|
try {
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
33
32
|
PostgresService = require('@cap-js/postgres/lib/PostgresService');
|
|
34
33
|
}
|
|
35
34
|
catch (err) {
|