@odatano/core 2.0.0-rc.5 → 2.0.0-rc.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/@cds-models/CardanoAgentService/index.d.ts +99 -51
  2. package/@cds-models/CardanoAgentService/index.js +15 -0
  3. package/@cds-models/CardanoBackendService/index.d.ts +347 -0
  4. package/@cds-models/CardanoBackendService/index.js +40 -0
  5. package/@cds-models/CardanoIndexerService/index.d.ts +496 -11
  6. package/@cds-models/CardanoIndexerService/index.js +64 -0
  7. package/@cds-models/CardanoODataService/index.d.ts +414 -57
  8. package/@cds-models/CardanoODataService/index.js +42 -0
  9. package/@cds-models/CardanoSignService/index.d.ts +32 -19
  10. package/@cds-models/CardanoSignService/index.js +3 -0
  11. package/@cds-models/CardanoTransactionService/index.d.ts +58 -44
  12. package/@cds-models/CardanoTransactionService/index.js +4 -0
  13. package/@cds-models/CardanoWorkerService/index.d.ts +7 -22
  14. package/@cds-models/index.d.ts +101 -1
  15. package/@cds-models/index.js +16 -1
  16. package/@cds-models/odatano/cardano/index.d.ts +437 -32
  17. package/@cds-models/odatano/cardano/index.js +48 -0
  18. package/README.md +207 -167
  19. package/db/schema.cds +2402 -1705
  20. package/db/types.cds +446 -295
  21. package/package.json +41 -16
  22. package/scripts/migrate-schema.mjs +334 -0
  23. package/scripts/migrate-slot-leader.mjs +96 -0
  24. package/src/index.d.ts +20 -21
  25. package/src/index.js +45 -31
  26. package/src/plugin.js +17 -35
  27. package/srv/blockchain/asset-decimals.d.ts +7 -0
  28. package/srv/blockchain/asset-decimals.js +91 -0
  29. package/srv/blockchain/backends/blockfrost-backend.d.ts +25 -135
  30. package/srv/blockchain/backends/blockfrost-backend.js +66 -172
  31. package/srv/blockchain/backends/cardano-backend.d.ts +94 -186
  32. package/srv/blockchain/backends/cardano-backend.js +29 -5
  33. package/srv/blockchain/backends/koios-backend.d.ts +103 -168
  34. package/srv/blockchain/backends/koios-backend.js +428 -360
  35. package/srv/blockchain/backends/odatano-backend.d.ts +54 -0
  36. package/srv/blockchain/backends/odatano-backend.js +169 -0
  37. package/srv/blockchain/backends/ogmios-backend.d.ts +123 -190
  38. package/srv/blockchain/backends/ogmios-backend.js +637 -315
  39. package/srv/blockchain/backends/ogmios-frame-guard.d.ts +14 -0
  40. package/srv/blockchain/backends/ogmios-frame-guard.js +89 -0
  41. package/srv/blockchain/cardano-client.d.ts +61 -241
  42. package/srv/blockchain/cardano-client.js +253 -293
  43. package/srv/blockchain/cardano-indexer.d.ts +282 -281
  44. package/srv/blockchain/cardano-indexer.js +1551 -484
  45. package/srv/blockchain/cardano-tx-builder.d.ts +25 -89
  46. package/srv/blockchain/cardano-tx-builder.js +164 -140
  47. package/srv/blockchain/circuit-breaker.d.ts +1 -13
  48. package/srv/blockchain/circuit-breaker.js +5 -15
  49. package/srv/blockchain/crawler/account-snapshots.d.ts +29 -0
  50. package/srv/blockchain/crawler/account-snapshots.js +153 -0
  51. package/srv/blockchain/crawler/asset-decimals-backfill.d.ts +15 -0
  52. package/srv/blockchain/crawler/asset-decimals-backfill.js +56 -0
  53. package/srv/blockchain/crawler/asset-registry-backfill.d.ts +43 -0
  54. package/srv/blockchain/crawler/asset-registry-backfill.js +153 -0
  55. package/srv/blockchain/crawler/certificate-backfill.d.ts +52 -0
  56. package/srv/blockchain/crawler/certificate-backfill.js +162 -0
  57. package/srv/blockchain/crawler/crawler.d.ts +104 -81
  58. package/srv/blockchain/crawler/crawler.js +532 -160
  59. package/srv/blockchain/crawler/credential-backfill.d.ts +28 -0
  60. package/srv/blockchain/crawler/credential-backfill.js +124 -0
  61. package/srv/blockchain/crawler/hooks.d.ts +2 -17
  62. package/srv/blockchain/crawler/index.d.ts +1 -8
  63. package/srv/blockchain/crawler/index.js +31 -17
  64. package/srv/blockchain/crawler/input-asset-copies.d.ts +34 -0
  65. package/srv/blockchain/crawler/input-asset-copies.js +171 -0
  66. package/srv/blockchain/crawler/metadata-position-backfill.d.ts +16 -0
  67. package/srv/blockchain/crawler/metadata-position-backfill.js +55 -0
  68. package/srv/blockchain/crawler/output-datum-backfill.d.ts +39 -0
  69. package/srv/blockchain/crawler/output-datum-backfill.js +110 -0
  70. package/srv/blockchain/crawler/sync-state.d.ts +27 -47
  71. package/srv/blockchain/crawler/sync-state.js +113 -63
  72. package/srv/blockchain/crawler/transaction-backfill.d.ts +44 -0
  73. package/srv/blockchain/crawler/transaction-backfill.js +278 -0
  74. package/srv/blockchain/crawler/utxo-set-import.d.ts +66 -0
  75. package/srv/blockchain/crawler/utxo-set-import.js +399 -0
  76. package/srv/blockchain/ledger-state.d.ts +62 -0
  77. package/srv/blockchain/ledger-state.js +419 -0
  78. package/srv/blockchain/pending-spends.d.ts +16 -0
  79. package/srv/blockchain/pending-spends.js +81 -0
  80. package/srv/blockchain/pool-metadata.d.ts +15 -0
  81. package/srv/blockchain/pool-metadata.js +132 -0
  82. package/srv/blockchain/request-coalescer.d.ts +2 -16
  83. package/srv/blockchain/request-coalescer.js +2 -16
  84. package/srv/blockchain/signing/cose-verifier.d.ts +3 -17
  85. package/srv/blockchain/signing/cose-verifier.js +146 -70
  86. package/srv/blockchain/signing/external-signer.d.ts +15 -115
  87. package/srv/blockchain/signing/external-signer.js +17 -126
  88. package/srv/blockchain/signing/hsm-signer.d.ts +10 -54
  89. package/srv/blockchain/signing/hsm-signer.js +28 -79
  90. package/srv/blockchain/signing/signature-verifier.d.ts +9 -47
  91. package/srv/blockchain/signing/signature-verifier.js +70 -83
  92. package/srv/blockchain/signing/submission-finalizer.d.ts +23 -45
  93. package/srv/blockchain/signing/submission-finalizer.js +219 -86
  94. package/srv/blockchain/stored-chain.d.ts +20 -0
  95. package/srv/blockchain/stored-chain.js +237 -0
  96. package/srv/blockchain/transaction-building/buildooor-tx.d.ts +31 -229
  97. package/srv/blockchain/transaction-building/buildooor-tx.js +652 -416
  98. package/srv/blockchain/transaction-building/cardano-tx.d.ts +9 -37
  99. package/srv/blockchain/transaction-presence.d.ts +5 -0
  100. package/srv/blockchain/transaction-presence.js +29 -0
  101. package/srv/blockchain/transaction-rows.d.ts +12 -0
  102. package/srv/blockchain/transaction-rows.js +44 -0
  103. package/srv/blockchain/wallet-worker/build-request.d.ts +5 -20
  104. package/srv/blockchain/wallet-worker/build-request.js +47 -30
  105. package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +5 -46
  106. package/srv/blockchain/wallet-worker/confirmation-tracker.js +25 -45
  107. package/srv/blockchain/wallet-worker/index.d.ts +1 -1
  108. package/srv/blockchain/wallet-worker/index.js +3 -11
  109. package/srv/blockchain/wallet-worker/job-store.d.ts +30 -148
  110. package/srv/blockchain/wallet-worker/job-store.js +101 -201
  111. package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +2 -26
  112. package/srv/blockchain/wallet-worker/lease-heartbeat.js +6 -28
  113. package/srv/blockchain/wallet-worker/signers.d.ts +5 -24
  114. package/srv/blockchain/wallet-worker/signers.js +4 -12
  115. package/srv/blockchain/wallet-worker/wallet-worker.d.ts +8 -80
  116. package/srv/blockchain/wallet-worker/wallet-worker.js +107 -155
  117. package/srv/cardano-agent-service.cds +122 -84
  118. package/srv/cardano-agent-service.js +4 -9
  119. package/srv/cardano-backend-service.cds +78 -0
  120. package/srv/cardano-backend-service.d.ts +2 -0
  121. package/srv/cardano-backend-service.js +242 -0
  122. package/srv/cardano-indexer-service.cds +387 -73
  123. package/srv/cardano-indexer-service.d.ts +5 -1
  124. package/srv/cardano-indexer-service.js +532 -16
  125. package/srv/cardano-service.cds +424 -269
  126. package/srv/cardano-service.js +289 -201
  127. package/srv/cardano-sign-service.cds +201 -180
  128. package/srv/cardano-sign-service.js +71 -201
  129. package/srv/cardano-tx-service.cds +451 -370
  130. package/srv/cardano-tx-service.js +271 -289
  131. package/srv/cardano-ui.cds +16 -16
  132. package/srv/cardano-worker-service.cds +118 -125
  133. package/srv/cardano-worker-service.js +52 -61
  134. package/srv/cbor/cip68.d.ts +13 -0
  135. package/srv/cbor/cip68.js +56 -0
  136. package/srv/cbor/index.d.ts +3 -1
  137. package/srv/cbor/index.js +9 -1
  138. package/srv/cbor/parse.d.ts +30 -18
  139. package/srv/cbor/parse.js +44 -9
  140. package/srv/cbor/plutus-data-json.d.ts +20 -0
  141. package/srv/cbor/plutus-data-json.js +32 -0
  142. package/srv/config.d.ts +113 -0
  143. package/srv/config.js +409 -0
  144. package/srv/server.d.ts +15 -110
  145. package/srv/server.js +84 -404
  146. package/srv/utils/agent-access.d.ts +9 -0
  147. package/srv/utils/agent-access.js +67 -0
  148. package/srv/utils/agent-grants-config.d.ts +0 -46
  149. package/srv/utils/agent-grants-config.js +17 -85
  150. package/srv/utils/agent-grants.d.ts +106 -122
  151. package/srv/utils/agent-grants.js +538 -236
  152. package/srv/utils/agent-token-auth.d.ts +4 -99
  153. package/srv/utils/agent-token-auth.js +18 -182
  154. package/srv/utils/backend-request-handler.d.ts +3 -17
  155. package/srv/utils/backend-request-handler.js +3 -18
  156. package/srv/utils/collections.d.ts +3 -10
  157. package/srv/utils/collections.js +3 -10
  158. package/srv/utils/const.d.ts +23 -74
  159. package/srv/utils/const.js +32 -79
  160. package/srv/utils/crypto.d.ts +3 -12
  161. package/srv/utils/crypto.js +6 -21
  162. package/srv/utils/db-indexes.d.ts +27 -0
  163. package/srv/utils/db-indexes.js +120 -0
  164. package/srv/utils/db-sanitize.d.ts +20 -0
  165. package/srv/utils/db-sanitize.js +80 -0
  166. package/srv/utils/deep-json.d.ts +6 -0
  167. package/srv/utils/deep-json.js +240 -0
  168. package/srv/utils/epoch-slots.d.ts +13 -0
  169. package/srv/utils/epoch-slots.js +38 -0
  170. package/srv/utils/error-codes.d.ts +22 -75
  171. package/srv/utils/error-codes.js +23 -72
  172. package/srv/utils/errors.d.ts +46 -187
  173. package/srv/utils/errors.js +114 -230
  174. package/srv/utils/liveness.d.ts +12 -0
  175. package/srv/utils/liveness.js +35 -0
  176. package/srv/utils/mappers.d.ts +102 -223
  177. package/srv/utils/mappers.js +387 -316
  178. package/srv/utils/network-context.js +2 -13
  179. package/srv/utils/paging.d.ts +31 -0
  180. package/srv/utils/paging.js +43 -0
  181. package/srv/utils/pg-inline-json.d.ts +8 -0
  182. package/srv/utils/pg-inline-json.js +58 -0
  183. package/srv/utils/pg-order-nulls.d.ts +14 -0
  184. package/srv/utils/pg-order-nulls.js +54 -0
  185. package/srv/utils/plutus-placeholders.d.ts +16 -22
  186. package/srv/utils/plutus-placeholders.js +62 -33
  187. package/srv/utils/rate-limiter.d.ts +2 -21
  188. package/srv/utils/rate-limiter.js +5 -17
  189. package/srv/utils/readiness.d.ts +12 -0
  190. package/srv/utils/readiness.js +29 -0
  191. package/srv/utils/reference-script.d.ts +19 -0
  192. package/srv/utils/reference-script.js +84 -0
  193. package/srv/utils/result-numbers.d.ts +15 -0
  194. package/srv/utils/result-numbers.js +61 -0
  195. package/srv/utils/service-events.d.ts +0 -24
  196. package/srv/utils/service-events.js +3 -25
  197. package/srv/utils/signing-helper.d.ts +3 -20
  198. package/srv/utils/signing-helper.js +35 -64
  199. package/srv/utils/tx-build-helper.d.ts +10 -105
  200. package/srv/utils/tx-build-helper.js +81 -144
  201. package/srv/utils/tx-request-parsers.d.ts +82 -33
  202. package/srv/utils/tx-request-parsers.js +401 -49
  203. package/srv/utils/tx-utils.d.ts +3 -27
  204. package/srv/utils/tx-utils.js +32 -50
  205. package/srv/utils/types.d.ts +261 -191
  206. package/srv/utils/types.js +2 -6
  207. package/srv/utils/validators.d.ts +22 -92
  208. package/srv/utils/validators.js +50 -149
@@ -0,0 +1,240 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stringifyJson = stringifyJson;
4
+ exports.parseJson = parseJson;
5
+ const native = JSON;
6
+ /** The Ogmios client's rule: an integer literal longer than 15 characters is read as bigint. */
7
+ const isBigLiteral = (src) => src.length > 15 && /^-?\d+$/.test(src);
8
+ /** Scalar text of a value, or undefined for what JSON leaves out (undefined, functions, symbols). */
9
+ function scalar(v) {
10
+ if (v === null)
11
+ return 'null';
12
+ switch (typeof v) {
13
+ case 'string': return JSON.stringify(v);
14
+ case 'number': return Number.isFinite(v) ? String(v) : 'null';
15
+ case 'bigint': return v.toString();
16
+ case 'boolean': return v ? 'true' : 'false';
17
+ default: return undefined;
18
+ }
19
+ }
20
+ // only objects are asked for toJSON; a bigint keeps its digits even with a toJSON polyfill
21
+ function withToJson(v, key) {
22
+ if (typeof v !== 'object' || v === null)
23
+ return v;
24
+ const toJSON = v.toJSON;
25
+ const r = typeof toJSON === 'function' ? toJSON.call(v, key) : v;
26
+ // a boxed primitive is written as the primitive, as JSON.stringify does
27
+ return r instanceof Number || r instanceof String || r instanceof Boolean || r instanceof BigInt ? r.valueOf() : r;
28
+ }
29
+ // a boxed BigInt is unboxed here, before the writer rejects it as a bigint
30
+ function replaceBigInt(_key, value) {
31
+ const v = value instanceof BigInt ? value.valueOf() : value;
32
+ return typeof v === 'bigint' ? native.rawJSON(v.toString()) : v;
33
+ }
34
+ /** JSON.stringify without a replacer. Big integers are written as plain digits. */
35
+ function stringifyJson(root) {
36
+ // a toJSON on BigInt.prototype (a common polyfill) would quote the digits before the replacer sees them
37
+ if (!('toJSON' in BigInt.prototype)) {
38
+ try {
39
+ const text = JSON.stringify(root, replaceBigInt);
40
+ if (text === undefined)
41
+ throw new TypeError('undefined has no JSON text');
42
+ return text;
43
+ }
44
+ catch (err) {
45
+ if (!(err instanceof RangeError))
46
+ throw err;
47
+ }
48
+ }
49
+ return stringifyJsonLoop(root);
50
+ }
51
+ function stringifyJsonLoop(root) {
52
+ let out = '';
53
+ const stack = [];
54
+ const open = new Set(); // containers on the current path, to refuse cycles like JSON.stringify
55
+ // writes a value; containers are pushed and written by the loop
56
+ const emit = (v, inArray) => {
57
+ if (typeof v === 'object' && v !== null) {
58
+ if (open.has(v))
59
+ throw new TypeError('Converting circular structure to JSON');
60
+ open.add(v);
61
+ if (Array.isArray(v)) {
62
+ out += '[';
63
+ stack.push({ kind: 'array', value: v, i: 0 });
64
+ }
65
+ else {
66
+ out += '{';
67
+ stack.push({ kind: 'object', value: v, keys: Object.keys(v), i: 0, wrote: false });
68
+ }
69
+ return true;
70
+ }
71
+ const s = scalar(v);
72
+ if (s === undefined) {
73
+ if (!inArray)
74
+ return false;
75
+ out += 'null';
76
+ return true;
77
+ }
78
+ out += s;
79
+ return true;
80
+ };
81
+ if (!emit(withToJson(root, ''), false))
82
+ throw new TypeError('undefined has no JSON text');
83
+ while (stack.length > 0) {
84
+ const top = stack[stack.length - 1];
85
+ if (top.kind === 'array') {
86
+ if (top.i >= top.value.length) {
87
+ out += ']';
88
+ open.delete(top.value);
89
+ stack.pop();
90
+ continue;
91
+ }
92
+ if (top.i > 0)
93
+ out += ',';
94
+ const i = top.i++;
95
+ emit(withToJson(top.value[i], String(i)), true);
96
+ }
97
+ else {
98
+ if (top.i >= top.keys.length) {
99
+ out += '}';
100
+ open.delete(top.value);
101
+ stack.pop();
102
+ continue;
103
+ }
104
+ const key = top.keys[top.i++];
105
+ const v = withToJson(top.value[key], key);
106
+ if ((typeof v !== 'object' || v === null) && scalar(v) === undefined)
107
+ continue;
108
+ out += (top.wrote ? ',' : '') + JSON.stringify(key) + ':';
109
+ top.wrote = true;
110
+ emit(v, false);
111
+ }
112
+ }
113
+ return out;
114
+ }
115
+ function reviveBigInt(_key, value, context) {
116
+ return typeof value === 'number' && context?.source !== undefined && isBigLiteral(context.source)
117
+ ? BigInt(context.source)
118
+ : value;
119
+ }
120
+ /** JSON.parse with long integer literals as bigint. No key rewrite and no field-specific rule. */
121
+ function parseJson(text) {
122
+ try {
123
+ return native.parse(text, reviveBigInt);
124
+ }
125
+ catch (err) {
126
+ if (!(err instanceof RangeError))
127
+ throw err;
128
+ return parseJsonLoop(text);
129
+ }
130
+ }
131
+ const NUMBER = /-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/y;
132
+ // JSON.parse checks the string body, including raw control characters
133
+ const STRING = /"(?:[^"\\]|\\.)*"/y;
134
+ const SPACE = /[ \t\n\r]*/y;
135
+ function parseJsonLoop(text) {
136
+ let pos = 0;
137
+ const fail = (what) => { throw new SyntaxError(`${what} in JSON at position ${pos}`); };
138
+ const skip = () => { SPACE.lastIndex = pos; SPACE.exec(text); pos = SPACE.lastIndex; };
139
+ const match = (re) => {
140
+ re.lastIndex = pos;
141
+ const m = re.exec(text);
142
+ if (!m)
143
+ return null;
144
+ pos = re.lastIndex;
145
+ return m[0];
146
+ };
147
+ const stack = [];
148
+ let result;
149
+ let done = false;
150
+ const put = (v) => {
151
+ const top = stack[stack.length - 1];
152
+ if (!top) {
153
+ result = v;
154
+ done = true;
155
+ return;
156
+ }
157
+ if (top.kind === 'array')
158
+ top.value.push(v);
159
+ else {
160
+ // an own property, as JSON.parse makes it, even for the key "__proto__"
161
+ if (top.key === '__proto__')
162
+ Object.defineProperty(top.value, top.key, { value: v, writable: true, enumerable: true, configurable: true });
163
+ else
164
+ top.value[top.key] = v;
165
+ top.key = null;
166
+ }
167
+ };
168
+ // after a value inside a container: a comma or the closing bracket
169
+ const close = () => {
170
+ while (stack.length > 0) {
171
+ skip();
172
+ const top = stack[stack.length - 1];
173
+ const c = text[pos];
174
+ if (c === ',') {
175
+ pos++;
176
+ return;
177
+ }
178
+ if ((top.kind === 'array' && c === ']') || (top.kind === 'object' && c === '}')) {
179
+ pos++;
180
+ stack.pop();
181
+ put(top.value);
182
+ continue;
183
+ }
184
+ fail(`Unexpected ${c === undefined ? 'end' : `token ${c}`}`);
185
+ }
186
+ };
187
+ while (!done) {
188
+ skip();
189
+ const top = stack[stack.length - 1];
190
+ if (top?.kind === 'object' && top.key === null) {
191
+ const k = match(STRING) ?? fail('Expected property name');
192
+ skip();
193
+ if (text[pos] !== ':')
194
+ fail('Expected colon');
195
+ pos++;
196
+ top.key = JSON.parse(k);
197
+ continue;
198
+ }
199
+ const c = text[pos];
200
+ if (c === '[' || c === '{') {
201
+ pos++;
202
+ skip();
203
+ const empty = text[pos] === (c === '[' ? ']' : '}');
204
+ if (empty) {
205
+ pos++;
206
+ put(c === '[' ? [] : {});
207
+ }
208
+ else {
209
+ stack.push(c === '[' ? { kind: 'array', value: [] } : { kind: 'object', value: {}, key: null });
210
+ continue;
211
+ }
212
+ }
213
+ else if (c === '"') {
214
+ put(JSON.parse(match(STRING) ?? fail('Bad string')));
215
+ }
216
+ else if (text.startsWith('true', pos)) {
217
+ pos += 4;
218
+ put(true);
219
+ }
220
+ else if (text.startsWith('false', pos)) {
221
+ pos += 5;
222
+ put(false);
223
+ }
224
+ else if (text.startsWith('null', pos)) {
225
+ pos += 4;
226
+ put(null);
227
+ }
228
+ else {
229
+ const n = match(NUMBER) ?? fail(`Unexpected ${c === undefined ? 'end' : `token ${c}`}`);
230
+ put(isBigLiteral(n) ? BigInt(n) : Number(n));
231
+ }
232
+ if (!done)
233
+ close();
234
+ }
235
+ skip();
236
+ if (pos < text.length)
237
+ fail(`Unexpected token ${text[pos]}`);
238
+ return result;
239
+ }
240
+ //# sourceMappingURL=deep-json.js.map
@@ -0,0 +1,13 @@
1
+ import { EPOCH_CONFIG_BY_NETWORK } from './const';
2
+ type EpochNetwork = keyof typeof EPOCH_CONFIG_BY_NETWORK;
3
+ /** Epoch a slot belongs to, from the network's Shelley anchor. */
4
+ export declare function epochOfSlot(network: EpochNetwork, slot: number): number;
5
+ /** First absolute slot of an epoch, from the network's Shelley anchor. */
6
+ export declare function epochStartSlot(network: EpochNetwork, epoch: number): number;
7
+ export declare function slotToPosixMs(network: EpochNetwork, slot: number): number;
8
+ /** Absolute POSIX seconds for a slot, rounded down. */
9
+ export declare function slotToPosixSeconds(network: EpochNetwork, slot: number): number;
10
+ /** Slot that contains a POSIX time. Throws RangeError before Shelley, where slots were 20 s long. */
11
+ export declare function posixToSlot(network: EpochNetwork, posixMs: number): number;
12
+ export {};
13
+ //# sourceMappingURL=epoch-slots.d.ts.map
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.epochOfSlot = epochOfSlot;
4
+ exports.epochStartSlot = epochStartSlot;
5
+ exports.slotToPosixMs = slotToPosixMs;
6
+ exports.slotToPosixSeconds = slotToPosixSeconds;
7
+ exports.posixToSlot = posixToSlot;
8
+ const const_1 = require("./const");
9
+ /** Epoch a slot belongs to, from the network's Shelley anchor. */
10
+ function epochOfSlot(network, slot) {
11
+ const cfg = const_1.EPOCH_CONFIG_BY_NETWORK[network];
12
+ return cfg.shelleyStartEpoch + Math.floor((slot - cfg.shelleyStartSlot) / cfg.slotsPerEpoch);
13
+ }
14
+ /** First absolute slot of an epoch, from the network's Shelley anchor. */
15
+ function epochStartSlot(network, epoch) {
16
+ const cfg = const_1.EPOCH_CONFIG_BY_NETWORK[network];
17
+ return cfg.shelleyStartSlot + (epoch - cfg.shelleyStartEpoch) * cfg.slotsPerEpoch;
18
+ }
19
+ // POSIX milliseconds for a slot, exact for Shelley-era slots.
20
+ // Ogmios eraStart.time is relative to system start, not a Unix timestamp.
21
+ function slotToPosixMs(network, slot) {
22
+ const genesis = const_1.GENESIS_INFOS_BY_NETWORK[network];
23
+ return genesis.systemStartPosixMs + (slot - genesis.startSlotNo) * genesis.slotLengthMs;
24
+ }
25
+ /** Absolute POSIX seconds for a slot, rounded down. */
26
+ function slotToPosixSeconds(network, slot) {
27
+ return Math.floor(slotToPosixMs(network, slot) / 1000);
28
+ }
29
+ /** Slot that contains a POSIX time. Throws RangeError before Shelley, where slots were 20 s long. */
30
+ function posixToSlot(network, posixMs) {
31
+ const genesis = const_1.GENESIS_INFOS_BY_NETWORK[network];
32
+ const shelleyStartMs = slotToPosixMs(network, const_1.EPOCH_CONFIG_BY_NETWORK[network].shelleyStartSlot);
33
+ if (!Number.isFinite(posixMs) || posixMs < shelleyStartMs) {
34
+ throw new RangeError(`posixToSlot: ${posixMs} is not a time from the ${network} Shelley start on`);
35
+ }
36
+ return genesis.startSlotNo + Math.floor((posixMs - genesis.systemStartPosixMs) / genesis.slotLengthMs);
37
+ }
38
+ //# sourceMappingURL=epoch-slots.js.map
@@ -1,94 +1,41 @@
1
- /**
2
- * Error codes used throughout the ODATANO backend
3
- */
1
+ /** Error codes used throughout the backend. */
4
2
  export declare const ERROR_CODES: {
5
- /**
6
- * 400 – Invalid input
7
- * Indicates that the input provided by the client is invalid (malformed address, invalid transaction hash, etc.)
8
- */
3
+ /** 400: malformed client input (address, tx hash, ...). */
9
4
  readonly INVALID_INPUT: "ODATANO_INVALID_INPUT";
10
- /**
11
- * 403 – Caller lacks the required role
12
- * Indicates the caller is authenticated but not authorized for the operation
13
- * (e.g. HSM-backed signing without the configured hsm.requiresRole)
14
- */
5
+ /** 403: authenticated but lacking the required role (e.g. hsm.requiresRole). */
15
6
  readonly FORBIDDEN: "ODATANO_FORBIDDEN";
16
- /**
17
- * 404 – Data not found
18
- * Indicates that the requested resource could not be found (Empty result set Address with no UTxOs, Transaction hash not found, etc.)
19
- */
7
+ /** 404: requested resource not found (unknown tx hash, address without UTxOs, ...). */
20
8
  readonly NOT_FOUND: "ODATANO_NOT_FOUND";
21
- /**
22
- * 400 – Insufficient funds/assets
23
- * Indicates that the address does not have enough funds or assets to complete the transaction
24
- */
9
+ /** 400: address lacks the funds or assets for the transaction. */
25
10
  readonly INSUFFICIENT_FUNDS: "ODATANO_INSUFFICIENT_FUNDS";
26
- /**
27
- * 400 – Transaction validation failed
28
- * Indicates that the transaction failed validation (wrong signature, tampered CBOR, etc.)
29
- */
11
+ /** 400: decoded transaction failed validation (wrong signature, tampered CBOR, ...). */
30
12
  readonly TX_VALIDATION_FAILED: "ODATANO_TX_VALIDATION_FAILED";
31
- /**
32
- * 400 – Transaction CBOR parse failed
33
- * Indicates that the provided transaction CBOR could not be decoded
34
- * (malformed bytes, truncated, not a Cardano Conway tx). Distinct from
35
- * TX_VALIDATION_FAILED which applies to decoded-but-invalid transactions.
36
- */
13
+ /** 400: transaction CBOR could not be decoded (malformed, truncated, not a Conway tx). */
37
14
  readonly TX_PARSE_FAILED: "ODATANO_TX_PARSE_FAILED";
38
- /**
39
- * 400 – Plutus script validation failed
40
- * Indicates that the ledger cleanly rejected the transaction due to script
41
- * evaluation — e.g. PlutusFailure, CekError, overspent budget, script hash
42
- * mismatch. Distinct from provider outages (503) and generic tx validation.
43
- */
15
+ /** 400: ledger rejected the tx on script evaluation (PlutusFailure, CekError, budget, hash mismatch). */
44
16
  readonly SCRIPT_VALIDATION_FAILURE: "ODATANO_SCRIPT_VALIDATION_FAILURE";
45
- /**
46
- * 409 – Transaction already submitted
47
- * Indicates that the transaction has already been submitted (duplicate/replay)
48
- */
17
+ /** 409: a crawler cursor block is not on this instance's chain (orphaned by a reorg). */
18
+ readonly CHAIN_POINT_MISMATCH: "ODATANO_CHAIN_POINT_MISMATCH";
19
+ /** 409: transaction already submitted (duplicate / replay). */
49
20
  readonly TX_ALREADY_SUBMITTED: "ODATANO_TX_ALREADY_SUBMITTED";
50
- /**
51
- * 429 – Rate limiting
52
- * indicates temporary unavailability
53
- */
21
+ /** 409: the idempotency key belongs to a job with another request. */
22
+ readonly IDEMPOTENCY_KEY_CONFLICT: "ODATANO_IDEMPOTENCY_KEY_CONFLICT";
23
+ /** 429: provider rate limit hit. */
54
24
  readonly PROVIDER_RATE_LIMITED: "ODATANO_PROVIDER_RATE_LIMITED";
55
- /**
56
- * 503 – Upstream / connectivity
57
- * Indicates that the Cardano data provider is currently unavailable
58
- */
25
+ /** 503: Cardano data provider unavailable. */
59
26
  readonly PROVIDER_UNAVAILABLE: "ODATANO_PROVIDER_UNAVAILABLE";
60
- /**
61
- * 500 – Internal fallback
62
- * Indicates an unexpected internal error
63
- */
27
+ /** 503: a submit failed without a verdict; the transaction may still reach the chain. */
28
+ readonly SUBMIT_OUTCOME_UNKNOWN: "ODATANO_SUBMIT_OUTCOME_UNKNOWN";
29
+ /** 500: unexpected internal error. */
64
30
  readonly INTERNAL_ERROR: "ODATANO_INTERNAL_ERROR";
65
- /**
66
- * 503 – HSM unavailable
67
- * Indicates the HSM device or session is not available
68
- */
31
+ /** 503: HSM device or session not available. */
69
32
  readonly HSM_UNAVAILABLE: "ODATANO_HSM_UNAVAILABLE";
70
- /**
71
- * 500 – HSM signing failed
72
- * Indicates the HSM signing operation failed
73
- */
33
+ /** 500: HSM signing operation failed. */
74
34
  readonly HSM_SIGNING_FAILED: "ODATANO_HSM_SIGNING_FAILED";
75
- /**
76
- * 400 – HSM not configured
77
- * Indicates HSM signing was requested but HSM is not configured
78
- */
35
+ /** 400: HSM signing requested but HSM not configured. */
79
36
  readonly HSM_NOT_CONFIGURED: "ODATANO_HSM_NOT_CONFIGURED";
80
- /**
81
- * 503 – Detached transaction could not begin in time
82
- * The sign-service could not acquire a pooled DB connection for one of its
83
- * detached bookkeeping transactions. Most common cause: an in-process
84
- * consumer awaits SubmitVerifiedTransaction/SignAndSubmitWithHsm while its
85
- * own request transaction holds the (single) pooled sqlite connection —
86
- * see docs/KNOWN_ISSUES.md issue 11.
87
- */
88
37
  readonly NESTED_TX_TIMEOUT: "ODATANO_NESTED_TX_TIMEOUT";
89
38
  };
90
- /**
91
- * EnumType representing all possible error codes
92
- */
39
+ /** Union of all error code values. */
93
40
  export type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
94
41
  //# sourceMappingURL=error-codes.d.ts.map
@@ -1,93 +1,44 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ERROR_CODES = void 0;
4
- /**
5
- * Error codes used throughout the ODATANO backend
6
- */
4
+ /** Error codes used throughout the backend. */
7
5
  exports.ERROR_CODES = {
8
- /**
9
- * 400 – Invalid input
10
- * Indicates that the input provided by the client is invalid (malformed address, invalid transaction hash, etc.)
11
- */
6
+ /** 400: malformed client input (address, tx hash, ...). */
12
7
  INVALID_INPUT: 'ODATANO_INVALID_INPUT',
13
- /**
14
- * 403 – Caller lacks the required role
15
- * Indicates the caller is authenticated but not authorized for the operation
16
- * (e.g. HSM-backed signing without the configured hsm.requiresRole)
17
- */
8
+ /** 403: authenticated but lacking the required role (e.g. hsm.requiresRole). */
18
9
  FORBIDDEN: 'ODATANO_FORBIDDEN',
19
- /**
20
- * 404 – Data not found
21
- * Indicates that the requested resource could not be found (Empty result set Address with no UTxOs, Transaction hash not found, etc.)
22
- */
10
+ /** 404: requested resource not found (unknown tx hash, address without UTxOs, ...). */
23
11
  NOT_FOUND: 'ODATANO_NOT_FOUND',
24
- /**
25
- * 400 – Insufficient funds/assets
26
- * Indicates that the address does not have enough funds or assets to complete the transaction
27
- */
12
+ /** 400: address lacks the funds or assets for the transaction. */
28
13
  INSUFFICIENT_FUNDS: 'ODATANO_INSUFFICIENT_FUNDS',
29
- /**
30
- * 400 – Transaction validation failed
31
- * Indicates that the transaction failed validation (wrong signature, tampered CBOR, etc.)
32
- */
14
+ /** 400: decoded transaction failed validation (wrong signature, tampered CBOR, ...). */
33
15
  TX_VALIDATION_FAILED: 'ODATANO_TX_VALIDATION_FAILED',
34
- /**
35
- * 400 – Transaction CBOR parse failed
36
- * Indicates that the provided transaction CBOR could not be decoded
37
- * (malformed bytes, truncated, not a Cardano Conway tx). Distinct from
38
- * TX_VALIDATION_FAILED which applies to decoded-but-invalid transactions.
39
- */
16
+ /** 400: transaction CBOR could not be decoded (malformed, truncated, not a Conway tx). */
40
17
  TX_PARSE_FAILED: 'ODATANO_TX_PARSE_FAILED',
41
- /**
42
- * 400 – Plutus script validation failed
43
- * Indicates that the ledger cleanly rejected the transaction due to script
44
- * evaluation — e.g. PlutusFailure, CekError, overspent budget, script hash
45
- * mismatch. Distinct from provider outages (503) and generic tx validation.
46
- */
18
+ /** 400: ledger rejected the tx on script evaluation (PlutusFailure, CekError, budget, hash mismatch). */
47
19
  SCRIPT_VALIDATION_FAILURE: 'ODATANO_SCRIPT_VALIDATION_FAILURE',
48
- /**
49
- * 409 – Transaction already submitted
50
- * Indicates that the transaction has already been submitted (duplicate/replay)
51
- */
20
+ /** 409: a crawler cursor block is not on this instance's chain (orphaned by a reorg). */
21
+ CHAIN_POINT_MISMATCH: 'ODATANO_CHAIN_POINT_MISMATCH',
22
+ /** 409: transaction already submitted (duplicate / replay). */
52
23
  TX_ALREADY_SUBMITTED: 'ODATANO_TX_ALREADY_SUBMITTED',
53
- /**
54
- * 429 – Rate limiting
55
- * indicates temporary unavailability
56
- */
24
+ /** 409: the idempotency key belongs to a job with another request. */
25
+ IDEMPOTENCY_KEY_CONFLICT: 'ODATANO_IDEMPOTENCY_KEY_CONFLICT',
26
+ /** 429: provider rate limit hit. */
57
27
  PROVIDER_RATE_LIMITED: 'ODATANO_PROVIDER_RATE_LIMITED',
58
- /**
59
- * 503 – Upstream / connectivity
60
- * Indicates that the Cardano data provider is currently unavailable
61
- */
28
+ /** 503: Cardano data provider unavailable. */
62
29
  PROVIDER_UNAVAILABLE: 'ODATANO_PROVIDER_UNAVAILABLE',
63
- /**
64
- * 500 – Internal fallback
65
- * Indicates an unexpected internal error
66
- */
30
+ /** 503: a submit failed without a verdict; the transaction may still reach the chain. */
31
+ SUBMIT_OUTCOME_UNKNOWN: 'ODATANO_SUBMIT_OUTCOME_UNKNOWN',
32
+ /** 500: unexpected internal error. */
67
33
  INTERNAL_ERROR: 'ODATANO_INTERNAL_ERROR',
68
- /**
69
- * 503 – HSM unavailable
70
- * Indicates the HSM device or session is not available
71
- */
34
+ /** 503: HSM device or session not available. */
72
35
  HSM_UNAVAILABLE: 'ODATANO_HSM_UNAVAILABLE',
73
- /**
74
- * 500 – HSM signing failed
75
- * Indicates the HSM signing operation failed
76
- */
36
+ /** 500: HSM signing operation failed. */
77
37
  HSM_SIGNING_FAILED: 'ODATANO_HSM_SIGNING_FAILED',
78
- /**
79
- * 400 – HSM not configured
80
- * Indicates HSM signing was requested but HSM is not configured
81
- */
38
+ /** 400: HSM signing requested but HSM not configured. */
82
39
  HSM_NOT_CONFIGURED: 'ODATANO_HSM_NOT_CONFIGURED',
83
- /**
84
- * 503 – Detached transaction could not begin in time
85
- * The sign-service could not acquire a pooled DB connection for one of its
86
- * detached bookkeeping transactions. Most common cause: an in-process
87
- * consumer awaits SubmitVerifiedTransaction/SignAndSubmitWithHsm while its
88
- * own request transaction holds the (single) pooled sqlite connection —
89
- * see docs/KNOWN_ISSUES.md issue 11.
90
- */
40
+ // 503: a detached transaction got no DB connection in time. Typical cause is an in-process caller
41
+ // whose own request transaction holds the single SQLite connection.
91
42
  NESTED_TX_TIMEOUT: 'ODATANO_NESTED_TX_TIMEOUT',
92
43
  };
93
44
  //# sourceMappingURL=error-codes.js.map