@odatano/core 1.8.0 → 1.9.1
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/CardanoODataService/index.d.ts +66 -42
- package/@cds-models/CardanoODataService/index.d.ts.map +1 -1
- package/@cds-models/CardanoODataService/index.js.map +1 -1
- package/@cds-models/CardanoODataService/index.ts +11 -7
- package/@cds-models/CardanoSignService/index.d.ts +49 -0
- package/@cds-models/CardanoSignService/index.d.ts.map +1 -1
- package/@cds-models/CardanoSignService/index.js.map +1 -1
- package/@cds-models/CardanoSignService/index.ts +41 -0
- package/@cds-models/odatano/cardano/index.d.ts +70 -46
- package/@cds-models/odatano/cardano/index.d.ts.map +1 -1
- package/@cds-models/odatano/cardano/index.js +2 -2
- package/@cds-models/odatano/cardano/index.js.map +1 -1
- package/@cds-models/odatano/cardano/index.ts +13 -13
- package/db/schema.cds +18 -18
- package/db/types.cds +3 -3
- package/package.json +16 -2
- package/src/index.d.ts +29 -0
- package/src/index.js +1 -0
- package/src/plugin.d.ts +2 -0
- package/src/plugin.js +6 -0
- package/srv/blockchain/backends/blockfrost-backend.d.ts +155 -0
- package/srv/blockchain/backends/blockfrost-backend.js +19 -8
- package/srv/blockchain/backends/cardano-backend.d.ts +182 -0
- package/srv/blockchain/backends/koios-backend.d.ts +171 -0
- package/srv/blockchain/backends/koios-backend.js +69 -27
- package/srv/blockchain/backends/ogmios-backend.d.ts +188 -0
- package/srv/blockchain/backends/ogmios-backend.js +175 -108
- package/srv/blockchain/cardano-client.d.ts +279 -0
- package/srv/blockchain/cardano-client.js +134 -33
- package/srv/blockchain/cardano-indexer.d.ts +330 -0
- package/srv/blockchain/cardano-indexer.js +51 -8
- package/srv/blockchain/cardano-tx-builder.d.ts +113 -0
- package/srv/blockchain/cardano-tx-builder.js +61 -54
- package/srv/blockchain/circuit-breaker.d.ts +37 -0
- package/srv/blockchain/circuit-breaker.js +11 -2
- package/srv/blockchain/request-coalescer.d.ts +23 -0
- package/srv/blockchain/signing/cose-verifier.d.ts +34 -0
- package/srv/blockchain/signing/cose-verifier.js +128 -0
- package/srv/blockchain/signing/external-signer.d.ts +146 -0
- package/srv/blockchain/signing/external-signer.js +23 -0
- package/srv/blockchain/signing/hsm-signer.d.ts +74 -0
- package/srv/blockchain/signing/hsm-signer.js +20 -5
- package/srv/blockchain/signing/signature-verifier.d.ts +56 -0
- package/srv/blockchain/signing/signature-verifier.js +11 -2
- package/srv/blockchain/transaction-building/buildooor-tx.d.ts +236 -0
- package/srv/blockchain/transaction-building/buildooor-tx.js +626 -187
- package/srv/blockchain/transaction-building/cardano-tx.d.ts +47 -0
- package/srv/cardano-service.cds +23 -3
- package/srv/cardano-service.d.ts +2 -0
- package/srv/cardano-service.js +25 -5
- package/srv/cardano-sign-service.cds +25 -0
- package/srv/cardano-sign-service.d.ts +2 -0
- package/srv/cardano-sign-service.js +243 -131
- package/srv/cardano-tx-service.d.ts +12 -0
- package/srv/cardano-tx-service.js +152 -110
- package/srv/cbor/index.d.ts +2 -0
- package/srv/cbor/parse.d.ts +64 -0
- package/srv/server.d.ts +90 -0
- package/srv/server.js +34 -9
- package/srv/utils/backend-request-handler.d.ts +20 -0
- package/srv/utils/const.d.ts +183 -0
- package/srv/utils/const.js +13 -6
- package/srv/utils/error-codes.d.ts +79 -0
- package/srv/utils/errors.d.ts +259 -0
- package/srv/utils/errors.js +22 -7
- package/srv/utils/mappers.d.ts +260 -0
- package/srv/utils/mappers.js +52 -17
- package/srv/utils/network-context.d.ts +6 -0
- package/srv/utils/network-context.js +27 -0
- package/srv/utils/plutus-placeholders.d.ts +35 -0
- package/srv/utils/plutus-placeholders.js +5 -15
- package/srv/utils/signing-helper.d.ts +23 -0
- package/srv/utils/signing-helper.js +5 -2
- package/srv/utils/tx-build-helper.d.ts +76 -0
- package/srv/utils/tx-build-helper.js +10 -37
- package/srv/utils/types.d.ts +653 -0
- package/srv/utils/validators.d.ts +145 -0
- package/srv/utils/validators.js +41 -19
- package/@cds-models/CardanoWatcherAdminService/index.js +0 -109
- package/@cds-models/CardanoWatcherAdminService/index.js.map +0 -1
- package/@cds-models/CardanoWatcherAdminService/index.ts +0 -263
- package/@cds-models/cds/outbox/index.js.map +0 -1
- package/@cds-models/cds/xt/MTXServices/index.js +0 -8
- package/@cds-models/cds/xt/MTXServices/index.js.map +0 -1
- package/@cds-models/cds/xt/MTXServices/index.ts +0 -4
- package/@cds-models/odatano/reeve/index.js +0 -77
- package/@cds-models/odatano/reeve/index.js.map +0 -1
- package/@cds-models/odatano/reeve/index.ts +0 -57
- package/@cds-models/odatano/transactions/index.js +0 -55
- package/@cds-models/odatano/transactions/index.js.map +0 -1
- package/@cds-models/odatano/transactions/index.ts +0 -18
- package/@cds-models/odatano/watch/index.js +0 -114
- package/@cds-models/odatano/watch/index.js.map +0 -1
- package/@cds-models/odatano/watch/index.ts +0 -110
- package/config/preview/cardano-node/alonzo-genesis.json +0 -196
- package/config/preview/cardano-node/byron-genesis.json +0 -117
- package/config/preview/cardano-node/config.json +0 -117
- package/config/preview/cardano-node/conway-genesis.json +0 -297
- package/config/preview/cardano-node/peer-snapshot.json +0 -890
- package/config/preview/cardano-node/shelley-genesis.json +0 -68
- package/config/preview/cardano-node/topology.json +0 -24
- package/output/sora/iter0_base.json +0 -32
- package/output/sora/iter0_base.mp4 +0 -0
- package/output/sora/logo_ref_1280x720.png +0 -0
- package/output/sora/odatano_full_logo_sky_ref_1280x720.png +0 -0
- package/output/sora/odatano_full_logo_transparent.png +0 -0
- package/output/sora/odatano_full_logo_transparent_dark.png +0 -0
- package/output/sora/odatano_full_logo_v4_8s.json +0 -32
- package/output/sora/odatano_full_logo_v4_8s.mp4 +0 -0
- package/output/sora/odatano_full_logo_v5_create.json +0 -15
- package/output/sora/odatano_full_logo_v5_fixes.json +0 -15
- package/output/sora/odatano_full_logo_v5_fixes.mp4 +0 -0
- package/output/sora/odatano_logo_v1.json +0 -32
- package/output/sora/odatano_logo_v1.mp4 +0 -0
- package/output/sora/odatano_o_only_clean.png +0 -0
- package/output/sora/odatano_o_sky_ref_1280x720.png +0 -0
- package/output/sora/odatano_o_sky_v2_8s.json +0 -32
- package/output/sora/odatano_o_sky_v2_8s.mp4 +0 -0
- package/output/sora/odatano_o_sky_v3_create.json +0 -15
- package/output/sora/odatano_o_sky_v3_splash_text.json +0 -15
- package/output/sora/odatano_o_sky_v3_splash_text.mp4 +0 -0
- package/output/sora/odatano_v6_composite_exact_logo.mp4 +0 -0
- package/output/sora/odatano_v6_composite_exact_logo_clean.mp4 +0 -0
- package/output/sora/odatano_v6_composite_exact_logo_final.mp4 +0 -0
- package/output/sora/odatano_v6_endframe.jpg +0 -0
- package/output/sora/odatano_v6_endframe_clean.jpg +0 -0
- package/output/sora/odatano_v6_endframe_final.jpg +0 -0
- package/output/sora/odatano_v7_1_earlylogo_fadeoldtext.mp4 +0 -0
- package/output/sora/odatano_v7_1_end.jpg +0 -0
- package/output/sora/odatano_v7_1_transition.jpg +0 -0
- package/output/sora/odatano_v7_2_original2d_keep_sky.mp4 +0 -0
- package/output/sora/odatano_v7_endframe_nobg.jpg +0 -0
- package/output/sora/odatano_v7_endframe_nobg_cleanend.jpg +0 -0
- package/output/sora/odatano_v7_spin_splash_logo_nobg.mp4 +0 -0
- package/output/sora/odatano_v7_spin_splash_logo_nobg_cleanend.mp4 +0 -0
- package/prod.mtaext +0 -17
- package/prod.mtaext.example +0 -27
- package/review.md +0 -42
- package/src/index.d.ts.map +0 -1
- package/src/index.js.map +0 -1
- package/src/plugin.d.ts.map +0 -1
- package/src/plugin.js.map +0 -1
- package/srv/blockchain/backends/blockfrost-backend.d.ts.map +0 -1
- package/srv/blockchain/backends/blockfrost-backend.js.map +0 -1
- package/srv/blockchain/backends/cardano-backend.d.ts.map +0 -1
- package/srv/blockchain/backends/cardano-backend.js.map +0 -1
- package/srv/blockchain/backends/koios-backend.d.ts.map +0 -1
- package/srv/blockchain/backends/koios-backend.js.map +0 -1
- package/srv/blockchain/backends/ogmios-backend.d.ts.map +0 -1
- package/srv/blockchain/backends/ogmios-backend.js.map +0 -1
- package/srv/blockchain/cardano-client.d.ts.map +0 -1
- package/srv/blockchain/cardano-client.js.map +0 -1
- package/srv/blockchain/cardano-indexer.d.ts.map +0 -1
- package/srv/blockchain/cardano-indexer.js.map +0 -1
- package/srv/blockchain/cardano-tx-builder.d.ts.map +0 -1
- package/srv/blockchain/cardano-tx-builder.js.map +0 -1
- package/srv/blockchain/circuit-breaker.d.ts.map +0 -1
- package/srv/blockchain/circuit-breaker.js.map +0 -1
- package/srv/blockchain/request-coalescer.d.ts.map +0 -1
- package/srv/blockchain/request-coalescer.js.map +0 -1
- package/srv/blockchain/signing/external-signer.d.ts.map +0 -1
- package/srv/blockchain/signing/external-signer.js.map +0 -1
- package/srv/blockchain/signing/hsm-signer.d.ts.map +0 -1
- package/srv/blockchain/signing/hsm-signer.js.map +0 -1
- package/srv/blockchain/signing/signature-verifier.d.ts.map +0 -1
- package/srv/blockchain/signing/signature-verifier.js.map +0 -1
- package/srv/blockchain/transaction-building/buildooor-tx.d.ts.map +0 -1
- package/srv/blockchain/transaction-building/buildooor-tx.js.map +0 -1
- package/srv/blockchain/transaction-building/cardano-tx.d.ts.map +0 -1
- package/srv/blockchain/transaction-building/cardano-tx.js.map +0 -1
- package/srv/cardano-service.d.ts.map +0 -1
- package/srv/cardano-service.js.map +0 -1
- package/srv/cardano-sign-service.d.ts.map +0 -1
- package/srv/cardano-sign-service.js.map +0 -1
- package/srv/cardano-tx-service.d.ts.map +0 -1
- package/srv/cardano-tx-service.js.map +0 -1
- package/srv/cbor/index.d.ts.map +0 -1
- package/srv/cbor/index.js.map +0 -1
- package/srv/cbor/parse.d.ts.map +0 -1
- package/srv/cbor/parse.js.map +0 -1
- package/srv/server.d.ts.map +0 -1
- package/srv/server.js.map +0 -1
- package/srv/utils/backend-request-handler.d.ts.map +0 -1
- package/srv/utils/backend-request-handler.js.map +0 -1
- package/srv/utils/const.d.ts.map +0 -1
- package/srv/utils/const.js.map +0 -1
- package/srv/utils/error-codes.d.ts.map +0 -1
- package/srv/utils/error-codes.js.map +0 -1
- package/srv/utils/errors.d.ts.map +0 -1
- package/srv/utils/errors.js.map +0 -1
- package/srv/utils/mappers.d.ts.map +0 -1
- package/srv/utils/mappers.js.map +0 -1
- package/srv/utils/plutus-placeholders.d.ts.map +0 -1
- package/srv/utils/plutus-placeholders.js.map +0 -1
- package/srv/utils/signing-helper.d.ts.map +0 -1
- package/srv/utils/signing-helper.js.map +0 -1
- package/srv/utils/tx-build-helper.d.ts.map +0 -1
- package/srv/utils/tx-build-helper.js.map +0 -1
- package/srv/utils/types.d.ts.map +0 -1
- package/srv/utils/types.js.map +0 -1
- package/srv/utils/validators.d.ts.map +0 -1
- package/srv/utils/validators.js.map +0 -1
|
@@ -13,6 +13,55 @@ const errors_1 = require("../../utils/errors");
|
|
|
13
13
|
const mappers_1 = require("../../utils/mappers");
|
|
14
14
|
const const_1 = require("../../utils/const");
|
|
15
15
|
const logger = cds_1.default.log('OgmiosBackend');
|
|
16
|
+
/**
|
|
17
|
+
* First absolute slot of the given epoch, from the network's Shelley anchor.
|
|
18
|
+
* Replaces the old `epoch * 432000` math, which was wrong on preview (86 400
|
|
19
|
+
* slots per epoch) and on mainnet/preprod (Byron offset).
|
|
20
|
+
*/
|
|
21
|
+
function epochStartSlot(network, epoch) {
|
|
22
|
+
const cfg = const_1.EPOCH_CONFIG_BY_NETWORK[network];
|
|
23
|
+
return cfg.shelleyStartSlot + (epoch - cfg.shelleyStartEpoch) * cfg.slotsPerEpoch;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Absolute POSIX seconds for a slot, via the same Shelley-anchored genesis infos
|
|
27
|
+
* the transaction builder uses for validity windows. The previous code treated
|
|
28
|
+
* Ogmios' `eraStart.time` (RelativeTime since SYSTEM start) as a Unix timestamp.
|
|
29
|
+
*/
|
|
30
|
+
function slotToPosixSeconds(network, slot) {
|
|
31
|
+
const genesis = const_1.GENESIS_INFOS_BY_NETWORK[network];
|
|
32
|
+
return Math.floor((genesis.systemStartPosixMs + (slot - genesis.startSlotNo) * genesis.slotLengthMs) / 1000);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Parse an Ogmios `Ratio` ("num/den" string, e.g. "3/1000") into a number.
|
|
36
|
+
* `Number("3/1000")` is NaN — previously every ratio-typed protocol parameter
|
|
37
|
+
* (priceMem, priceStep, a0, rho, tau) came out as NaN.
|
|
38
|
+
*/
|
|
39
|
+
function parseOgmiosRatio(ratio) {
|
|
40
|
+
if (ratio === null || ratio === undefined)
|
|
41
|
+
return 0;
|
|
42
|
+
if (typeof ratio === 'number')
|
|
43
|
+
return ratio;
|
|
44
|
+
const m = /^(-?\d+)\s*\/\s*(\d+)$/.exec(ratio);
|
|
45
|
+
if (m) {
|
|
46
|
+
const den = Number(m[2]);
|
|
47
|
+
return den === 0 ? 0 : Number(m[1]) / den;
|
|
48
|
+
}
|
|
49
|
+
const n = Number(ratio);
|
|
50
|
+
return Number.isFinite(n) ? n : 0;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Extract a lovelace amount from Ogmios' value shapes. Ogmios v6 returns
|
|
54
|
+
* `{ ada: { lovelace } }` objects — calling `.toString()` on those yields
|
|
55
|
+
* "[object Object]", which previously ended up in the AccountData fields.
|
|
56
|
+
*/
|
|
57
|
+
function ogmiosValueToLovelaceString(value) {
|
|
58
|
+
if (value === null || value === undefined)
|
|
59
|
+
return '0';
|
|
60
|
+
if (typeof value === 'bigint' || typeof value === 'number')
|
|
61
|
+
return String(value);
|
|
62
|
+
const lovelace = value.ada?.lovelace;
|
|
63
|
+
return lovelace === undefined ? '0' : String(lovelace);
|
|
64
|
+
}
|
|
16
65
|
/** Resolve Ogmios ledger tip which may be 'origin' (genesis block) or a point */
|
|
17
66
|
function resolveOgmiosTip(tip) {
|
|
18
67
|
return tip === 'origin' ? { slot: 0, hash: '' } : { slot: tip.slot, hash: tip.id };
|
|
@@ -27,10 +76,31 @@ function resolveOgmiosHeight(height) {
|
|
|
27
76
|
*/
|
|
28
77
|
class OgmiosBackend {
|
|
29
78
|
name = 'ogmios';
|
|
79
|
+
/**
|
|
80
|
+
* Capability declaration — the orchestrator skips Ogmios for these without
|
|
81
|
+
* counting circuit failures. Historic queries are out of protocol scope;
|
|
82
|
+
* getAddress/getNetworkInformation previously FABRICATED placeholder data
|
|
83
|
+
* (type:'base'/isScript:false/stakeAddress:null resp. maxSupply as
|
|
84
|
+
* total/circulating) which preferLive routing then preferred over correct
|
|
85
|
+
* Blockfrost/Koios data.
|
|
86
|
+
*/
|
|
87
|
+
unsupportedMethods = new Set([
|
|
88
|
+
// getEpoch is NOT listed: Ogmios can serve the CURRENT epoch and only
|
|
89
|
+
// rejects historic ones — routing prefers historical backends anyway.
|
|
90
|
+
'getBlock',
|
|
91
|
+
'getTransaction',
|
|
92
|
+
'getTransactionMetadata',
|
|
93
|
+
'getAddressTransactions',
|
|
94
|
+
'getDrep',
|
|
95
|
+
'getAssetInfo',
|
|
96
|
+
'getAddress',
|
|
97
|
+
'getNetworkInformation',
|
|
98
|
+
]);
|
|
30
99
|
stateQueryClient = null;
|
|
31
100
|
txSubmissionClient = null;
|
|
32
101
|
context = null;
|
|
33
102
|
isShutdown = false;
|
|
103
|
+
reconnectPromise = null;
|
|
34
104
|
network;
|
|
35
105
|
timeoutMs;
|
|
36
106
|
ogmiosUrl;
|
|
@@ -74,13 +144,56 @@ class OgmiosBackend {
|
|
|
74
144
|
port: Number(url.port) || (url.protocol === 'wss:' ? 443 : 80),
|
|
75
145
|
tls: url.protocol === 'wss:'
|
|
76
146
|
};
|
|
77
|
-
|
|
147
|
+
const context = await (0, client_1.createInteractionContext)(
|
|
78
148
|
/* c8 ignore next */
|
|
79
|
-
(err) => logger.error(`[OgmiosBackend] Interaction context error: ${err.message}`), (
|
|
80
|
-
|
|
81
|
-
|
|
149
|
+
(err) => logger.error(`[OgmiosBackend] Interaction context error: ${err.message}`), () => {
|
|
150
|
+
// Socket closed: clear the clients so the next request reconnects via
|
|
151
|
+
// ensureConnected — previously this handler only logged and the backend
|
|
152
|
+
// stayed dead until process restart.
|
|
153
|
+
if (this.isShutdown)
|
|
154
|
+
return;
|
|
155
|
+
logger.warn('[OgmiosBackend] WebSocket closed — will reconnect on next request');
|
|
156
|
+
this.stateQueryClient = null;
|
|
157
|
+
this.txSubmissionClient = null;
|
|
158
|
+
}, { connection });
|
|
159
|
+
try {
|
|
160
|
+
this.stateQueryClient = await (0, client_1.createLedgerStateQueryClient)(context);
|
|
161
|
+
this.txSubmissionClient = await (0, client_1.createTransactionSubmissionClient)(context);
|
|
162
|
+
}
|
|
163
|
+
catch (err) {
|
|
164
|
+
// don't leak the WebSocket when client creation fails mid-init
|
|
165
|
+
// (runtime socket is node `ws`, which exposes terminate())
|
|
166
|
+
try {
|
|
167
|
+
context.socket.terminate();
|
|
168
|
+
}
|
|
169
|
+
catch { /* best effort */ }
|
|
170
|
+
throw err;
|
|
171
|
+
}
|
|
172
|
+
this.context = context;
|
|
82
173
|
return true;
|
|
83
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* Reconnect when the WebSocket has died since the last successful init.
|
|
177
|
+
* No-op when never initialized (test-injected clients) — startup-init
|
|
178
|
+
* recovery is the orchestrator's job (lazy init retry in CardanoClient).
|
|
179
|
+
* Concurrent callers share one reconnect attempt.
|
|
180
|
+
*/
|
|
181
|
+
async ensureConnected() {
|
|
182
|
+
this.ensureNotShutdown();
|
|
183
|
+
if (!this.context)
|
|
184
|
+
return;
|
|
185
|
+
const socket = this.context.socket;
|
|
186
|
+
const socketOpen = !socket || socket.readyState === (socket.OPEN ?? 1);
|
|
187
|
+
if (this.stateQueryClient && socketOpen)
|
|
188
|
+
return;
|
|
189
|
+
if (!this.reconnectPromise) {
|
|
190
|
+
logger.warn('[OgmiosBackend] WebSocket not connected — reconnecting');
|
|
191
|
+
this.reconnectPromise = this.init()
|
|
192
|
+
.then(() => undefined)
|
|
193
|
+
.finally(() => { this.reconnectPromise = null; });
|
|
194
|
+
}
|
|
195
|
+
await this.reconnectPromise;
|
|
196
|
+
}
|
|
84
197
|
/**
|
|
85
198
|
* Get specific Block Data (not supported)
|
|
86
199
|
* @param _hash block hash (hex)
|
|
@@ -98,7 +211,7 @@ class OgmiosBackend {
|
|
|
98
211
|
*/
|
|
99
212
|
async getEpoch(epochNumber) {
|
|
100
213
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
101
|
-
this.
|
|
214
|
+
await this.ensureConnected();
|
|
102
215
|
// Get current epoch directly via epoch() query
|
|
103
216
|
const currentEpoch = await this.stateQueryClient.epoch();
|
|
104
217
|
// Ogmios only supports current epoch queries
|
|
@@ -150,65 +263,25 @@ class OgmiosBackend {
|
|
|
150
263
|
}, this.name);
|
|
151
264
|
}
|
|
152
265
|
/**
|
|
153
|
-
* Get specific Network Information
|
|
154
|
-
*
|
|
266
|
+
* Get specific Network Information (not supported — Ogmios state queries
|
|
267
|
+
* expose no supply/stake aggregates; the previous implementation fabricated
|
|
268
|
+
* maxSupply as total/circulating, which preferLive routing then preferred
|
|
269
|
+
* over correct Blockfrost/Koios data)
|
|
155
270
|
*/
|
|
156
271
|
async getNetworkInformation() {
|
|
157
272
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
158
|
-
|
|
159
|
-
return {
|
|
160
|
-
supply: {
|
|
161
|
-
max: maxSupply.toString(),
|
|
162
|
-
total: maxSupply.toString(),
|
|
163
|
-
circulating: maxSupply.toString(),
|
|
164
|
-
locked: '0',
|
|
165
|
-
treasury: '0',
|
|
166
|
-
reserves: '0'
|
|
167
|
-
},
|
|
168
|
-
stake: {
|
|
169
|
-
active: '0',
|
|
170
|
-
live: '0',
|
|
171
|
-
}
|
|
172
|
-
};
|
|
273
|
+
throw new errors_1.ProviderUnavailableError('Network information not supported by Ogmios backend — use Blockfrost/Koios', this.name);
|
|
173
274
|
}, this.name);
|
|
174
275
|
}
|
|
175
276
|
/**
|
|
176
|
-
* Get current specific Address Data
|
|
177
|
-
*
|
|
178
|
-
*
|
|
277
|
+
* Get current specific Address Data (not supported — address type, script
|
|
278
|
+
* flag and stake address are not derivable from Ogmios state queries; the
|
|
279
|
+
* previous implementation fabricated type:'base'/isScript:false/
|
|
280
|
+
* stakeAddress:null. UTxOs remain available via getAddressUtxos.)
|
|
179
281
|
*/
|
|
180
|
-
async getAddress(
|
|
282
|
+
async getAddress(_address) {
|
|
181
283
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
182
|
-
this.
|
|
183
|
-
// Query UTxOs from tip (no acquire needed - queries from tip by default)
|
|
184
|
-
const utxos = await this.stateQueryClient.utxo({ addresses: [address] });
|
|
185
|
-
const totalLovelace = utxos.reduce((sum, u) => {
|
|
186
|
-
const lovelace = u.value?.ada?.lovelace;
|
|
187
|
-
return sum + BigInt(lovelace);
|
|
188
|
-
}, 0n);
|
|
189
|
-
return {
|
|
190
|
-
address,
|
|
191
|
-
stakeAddress: null,
|
|
192
|
-
type: 'base',
|
|
193
|
-
isScript: false,
|
|
194
|
-
amount: [{
|
|
195
|
-
unit: 'lovelace',
|
|
196
|
-
quantity: totalLovelace.toString()
|
|
197
|
-
}],
|
|
198
|
-
utxos: utxos.map((u) => {
|
|
199
|
-
const amount = this.convertOgmiosValue(u.value);
|
|
200
|
-
return {
|
|
201
|
-
txHash: u.transaction?.id || '',
|
|
202
|
-
outputIndex: u.index || 0,
|
|
203
|
-
address: u.address || address,
|
|
204
|
-
amount: amount,
|
|
205
|
-
blockHash: '',
|
|
206
|
-
datumHash: u.datumHash,
|
|
207
|
-
scriptRef: u.script?.hash
|
|
208
|
-
};
|
|
209
|
-
}),
|
|
210
|
-
transactions: [] // Historic transaction queries not supported
|
|
211
|
-
};
|
|
284
|
+
throw new errors_1.ProviderUnavailableError('Address detail queries not supported by Ogmios backend — use Blockfrost/Koios', this.name);
|
|
212
285
|
}, this.name);
|
|
213
286
|
}
|
|
214
287
|
/** get current specific Address UTxOs
|
|
@@ -217,7 +290,7 @@ class OgmiosBackend {
|
|
|
217
290
|
*/
|
|
218
291
|
async getAddressUtxos(address) {
|
|
219
292
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
220
|
-
this.
|
|
293
|
+
await this.ensureConnected();
|
|
221
294
|
const utxos = await this.stateQueryClient.utxo({ addresses: [address] });
|
|
222
295
|
return utxos.map((u) => {
|
|
223
296
|
// convert Ogmios value format to standard amount array
|
|
@@ -229,6 +302,9 @@ class OgmiosBackend {
|
|
|
229
302
|
amount: amount,
|
|
230
303
|
blockHash: '',
|
|
231
304
|
datumHash: u.datumHash,
|
|
305
|
+
// Ogmios delivers the inline datum as CBOR hex in `datum` — it was
|
|
306
|
+
// dropped before, breaking inline-datum spends when Ogmios serves UTxOs
|
|
307
|
+
inlineDatum: typeof u.datum === 'string' ? u.datum : null,
|
|
232
308
|
scriptRef: u.script?.hash
|
|
233
309
|
};
|
|
234
310
|
});
|
|
@@ -250,7 +326,7 @@ class OgmiosBackend {
|
|
|
250
326
|
*/
|
|
251
327
|
async getPool(poolId) {
|
|
252
328
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
253
|
-
this.
|
|
329
|
+
await this.ensureConnected();
|
|
254
330
|
// Query from tip (no acquire needed) with stake included
|
|
255
331
|
const pools = await this.stateQueryClient.stakePools([{ id: poolId }], true);
|
|
256
332
|
// Extract pool from response - stakePools returns object keyed by poolId
|
|
@@ -266,11 +342,15 @@ class OgmiosBackend {
|
|
|
266
342
|
liveSize: 0,
|
|
267
343
|
liveDelegators: 0,
|
|
268
344
|
liveSaturation: 0,
|
|
269
|
-
activeStake
|
|
345
|
+
// activeStake is not available from Ogmios pool params — report 0 instead
|
|
346
|
+
// of fabricating it from the pledge
|
|
347
|
+
activeStake: '0',
|
|
270
348
|
activeSize: 0,
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
349
|
+
// pledge/cost are ValueAdaOnly objects in Ogmios v6 — String() on those
|
|
350
|
+
// yielded "[object Object]"; margin is a Ratio string ("1/10")
|
|
351
|
+
pledge: ogmiosValueToLovelaceString(pool.pledge),
|
|
352
|
+
margin: parseOgmiosRatio(pool.margin),
|
|
353
|
+
fixedCost: ogmiosValueToLovelaceString(pool.cost),
|
|
274
354
|
rewardAccount: pool.rewardAccount || ''
|
|
275
355
|
};
|
|
276
356
|
}, this.name);
|
|
@@ -282,7 +362,7 @@ class OgmiosBackend {
|
|
|
282
362
|
*/
|
|
283
363
|
async getAccount(stakeAddress) {
|
|
284
364
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
285
|
-
this.
|
|
365
|
+
await this.ensureConnected();
|
|
286
366
|
const rawResult = await this.stateQueryClient.rewardAccountSummaries({ keys: [stakeAddress] });
|
|
287
367
|
// Ogmios returns a record keyed by stake address; normalize to array
|
|
288
368
|
const summaries = Array.isArray(rawResult)
|
|
@@ -295,14 +375,16 @@ class OgmiosBackend {
|
|
|
295
375
|
}
|
|
296
376
|
return {
|
|
297
377
|
stakeaddress: stakeAddress,
|
|
378
|
+
// Ogmios only returns reward-account summaries for REGISTERED stake keys —
|
|
379
|
+
// reaching this point (summary found) therefore implies the account is active.
|
|
298
380
|
active: true,
|
|
299
381
|
activeEpoch: 0,
|
|
300
|
-
controlledAmount: account.controlledAmount
|
|
301
|
-
rewardsSum: account.rewards
|
|
302
|
-
withdrawalsSum: account.withdrawals
|
|
382
|
+
controlledAmount: ogmiosValueToLovelaceString(account.controlledAmount),
|
|
383
|
+
rewardsSum: ogmiosValueToLovelaceString(account.rewards),
|
|
384
|
+
withdrawalsSum: ogmiosValueToLovelaceString(account.withdrawals),
|
|
303
385
|
reservesSum: '0',
|
|
304
386
|
treasurySum: '0',
|
|
305
|
-
withdrawableAmount: account.rewards
|
|
387
|
+
withdrawableAmount: ogmiosValueToLovelaceString(account.rewards),
|
|
306
388
|
poolId: account.delegate?.id || account.delegation?.poolId || null,
|
|
307
389
|
drepId: account.vote?.id || account.drep?.id || null,
|
|
308
390
|
addresses: []
|
|
@@ -316,7 +398,7 @@ class OgmiosBackend {
|
|
|
316
398
|
*/
|
|
317
399
|
async submitTransaction(signedTxCbor) {
|
|
318
400
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
319
|
-
this.
|
|
401
|
+
await this.ensureConnected();
|
|
320
402
|
const txHash = await this.txSubmissionClient.submitTransaction(signedTxCbor);
|
|
321
403
|
return txHash;
|
|
322
404
|
}, this.name);
|
|
@@ -328,7 +410,7 @@ class OgmiosBackend {
|
|
|
328
410
|
*/
|
|
329
411
|
async evaluateTransaction(unsignedTxCbor) {
|
|
330
412
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
331
|
-
this.
|
|
413
|
+
await this.ensureConnected();
|
|
332
414
|
const results = await this.txSubmissionClient.evaluateTransaction(unsignedTxCbor);
|
|
333
415
|
return results;
|
|
334
416
|
}, this.name);
|
|
@@ -339,7 +421,7 @@ class OgmiosBackend {
|
|
|
339
421
|
*/
|
|
340
422
|
async getProtocolParameters() {
|
|
341
423
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
342
|
-
this.
|
|
424
|
+
await this.ensureConnected();
|
|
343
425
|
// Query protocol parameters and epoch in parallel
|
|
344
426
|
const [params, currentEpoch] = await Promise.all([
|
|
345
427
|
this.stateQueryClient.protocolParameters(),
|
|
@@ -354,8 +436,8 @@ class OgmiosBackend {
|
|
|
354
436
|
minFeeA: params.minFeeCoefficient || 0,
|
|
355
437
|
minFeeB: Number(params.minFeeConstant?.ada?.lovelace || 0),
|
|
356
438
|
maxBlockSize: params.maxBlockBodySize?.bytes || 0,
|
|
357
|
-
priceMem:
|
|
358
|
-
priceStep:
|
|
439
|
+
priceMem: parseOgmiosRatio(params.scriptExecutionPrices?.memory),
|
|
440
|
+
priceStep: parseOgmiosRatio(params.scriptExecutionPrices?.cpu),
|
|
359
441
|
maxTxExMem: (params.maxExecutionUnitsPerTransaction?.memory || 0).toString(),
|
|
360
442
|
maxTxExSteps: (params.maxExecutionUnitsPerTransaction?.cpu || 0).toString(),
|
|
361
443
|
maxBlockExMem: (params.maxExecutionUnitsPerBlock?.memory || 0).toString(),
|
|
@@ -371,9 +453,10 @@ class OgmiosBackend {
|
|
|
371
453
|
poolDeposit: params.stakePoolDeposit?.ada?.lovelace?.toString() || '0',
|
|
372
454
|
eMax: params.stakePoolRetirementEpochBound || 0,
|
|
373
455
|
nOpt: params.desiredNumberOfStakePools || 0,
|
|
374
|
-
a0:
|
|
375
|
-
|
|
376
|
-
|
|
456
|
+
a0: parseOgmiosRatio(params.stakePoolPledgeInfluence),
|
|
457
|
+
// ρ = monetaryExpansion, τ = treasuryExpansion (was swapped; Koios maps it correctly)
|
|
458
|
+
rho: parseOgmiosRatio(params.monetaryExpansion),
|
|
459
|
+
tau: parseOgmiosRatio(params.treasuryExpansion),
|
|
377
460
|
decentralisationParam: 0,
|
|
378
461
|
extraEntropy: null,
|
|
379
462
|
protocolMajorVer: params.version?.major || 0,
|
|
@@ -389,32 +472,21 @@ class OgmiosBackend {
|
|
|
389
472
|
*/
|
|
390
473
|
async getLatestEpoch() {
|
|
391
474
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
392
|
-
this.
|
|
393
|
-
|
|
394
|
-
const [currentEpoch, eraStart, tip] = await Promise.all([
|
|
475
|
+
await this.ensureConnected();
|
|
476
|
+
const [currentEpoch, tip] = await Promise.all([
|
|
395
477
|
this.stateQueryClient.epoch(),
|
|
396
|
-
this.stateQueryClient.eraStart(),
|
|
397
478
|
this.stateQueryClient.ledgerTip()
|
|
398
479
|
]);
|
|
399
480
|
const { slot } = resolveOgmiosTip(tip);
|
|
400
|
-
//
|
|
401
|
-
const
|
|
402
|
-
const
|
|
403
|
-
const epochEndSlot = (currentEpoch + 1) * SLOTS_PER_EPOCH;
|
|
404
|
-
// eraStart.time is RelativeTime { seconds: bigint }
|
|
405
|
-
const eraStartTime = Number(eraStart.time.seconds) * 1000;
|
|
406
|
-
const slotsSinceEraStart = slot - eraStart.slot;
|
|
407
|
-
const currentTime = eraStartTime + (slotsSinceEraStart * 1000);
|
|
408
|
-
const slotsSinceEpochStart = slot - epochStartSlot;
|
|
409
|
-
const epochStartTime = currentTime - (slotsSinceEpochStart * 1000);
|
|
410
|
-
const slotsUntilEpochEnd = epochEndSlot - slot;
|
|
411
|
-
const epochEndTime = currentTime + (slotsUntilEpochEnd * 1000);
|
|
481
|
+
// Network-aware epoch geometry + Shelley-anchored slot→time conversion
|
|
482
|
+
const startSlot = epochStartSlot(this.network, currentEpoch);
|
|
483
|
+
const endSlot = startSlot + const_1.EPOCH_CONFIG_BY_NETWORK[this.network].slotsPerEpoch;
|
|
412
484
|
return {
|
|
413
485
|
epoch: currentEpoch,
|
|
414
|
-
start_time:
|
|
415
|
-
end_time:
|
|
416
|
-
first_block_time:
|
|
417
|
-
last_block_time:
|
|
486
|
+
start_time: slotToPosixSeconds(this.network, startSlot),
|
|
487
|
+
end_time: slotToPosixSeconds(this.network, endSlot),
|
|
488
|
+
first_block_time: slotToPosixSeconds(this.network, startSlot),
|
|
489
|
+
last_block_time: slotToPosixSeconds(this.network, slot),
|
|
418
490
|
block_count: 0, // Not available from Ogmios state queries
|
|
419
491
|
tx_count: 0, // Not available from Ogmios state queries
|
|
420
492
|
output: '0',
|
|
@@ -429,24 +501,19 @@ class OgmiosBackend {
|
|
|
429
501
|
*/
|
|
430
502
|
async getLatestBlock() {
|
|
431
503
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
432
|
-
this.
|
|
433
|
-
// Fetch ledger tip, block height
|
|
434
|
-
const [tip, blockHeight, epoch
|
|
504
|
+
await this.ensureConnected();
|
|
505
|
+
// Fetch ledger tip, block height and epoch in parallel
|
|
506
|
+
const [tip, blockHeight, epoch] = await Promise.all([
|
|
435
507
|
this.stateQueryClient.ledgerTip(),
|
|
436
508
|
this.stateQueryClient.networkBlockHeight(),
|
|
437
|
-
this.stateQueryClient.epoch()
|
|
438
|
-
this.stateQueryClient.eraStart()
|
|
509
|
+
this.stateQueryClient.epoch()
|
|
439
510
|
]);
|
|
440
511
|
const { slot, hash } = resolveOgmiosTip(tip);
|
|
441
512
|
const height = resolveOgmiosHeight(blockHeight);
|
|
442
|
-
//
|
|
443
|
-
const
|
|
444
|
-
const slotsSinceEraStart = slot - eraStart.slot;
|
|
445
|
-
const blockTime = eraStartTime + (slotsSinceEraStart * 1000); // Each slot = 1 second
|
|
446
|
-
// Calculate slot within epoch
|
|
447
|
-
const epochSlot = slot % const_1.CARDANO_DEFAULTS.SLOTS_PER_EPOCH;
|
|
513
|
+
// network-aware slot-in-epoch (the old `slot % 432000` was wrong on every network)
|
|
514
|
+
const epochSlot = Math.max(0, slot - epochStartSlot(this.network, epoch));
|
|
448
515
|
return {
|
|
449
|
-
time:
|
|
516
|
+
time: slotToPosixSeconds(this.network, slot), // seconds (mapBlock expects seconds)
|
|
450
517
|
height,
|
|
451
518
|
hash,
|
|
452
519
|
slot,
|
|
@@ -481,7 +548,7 @@ class OgmiosBackend {
|
|
|
481
548
|
if (!Number.isInteger(outputIndex) || outputIndex < 0)
|
|
482
549
|
return false;
|
|
483
550
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
484
|
-
this.
|
|
551
|
+
await this.ensureConnected();
|
|
485
552
|
const result = await this.stateQueryClient.utxo({
|
|
486
553
|
outputReferences: [{ transaction: { id: txHash }, index: outputIndex }],
|
|
487
554
|
});
|