@odatano/core 2.0.0-rc.44 → 2.0.0-rc.46

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 (168) hide show
  1. package/@cds-models/CardanoAgentService/index.d.ts +0 -46
  2. package/@cds-models/CardanoBackendService/index.d.ts +0 -10
  3. package/@cds-models/CardanoIndexerService/index.d.ts +5 -20
  4. package/@cds-models/CardanoODataService/index.d.ts +18 -47
  5. package/@cds-models/CardanoSignService/index.d.ts +3 -18
  6. package/@cds-models/CardanoTransactionService/index.d.ts +9 -31
  7. package/@cds-models/CardanoWorkerService/index.d.ts +3 -19
  8. package/@cds-models/index.d.ts +17 -0
  9. package/@cds-models/index.js +2 -0
  10. package/@cds-models/odatano/cardano/index.d.ts +0 -34
  11. package/README.md +20 -20
  12. package/db/schema.cds +25 -44
  13. package/db/types.cds +22 -5
  14. package/package.json +3 -1
  15. package/scripts/migrate-slot-leader.mjs +3 -11
  16. package/scripts/migrate-txseq.mjs +3 -12
  17. package/src/index.d.ts +0 -4
  18. package/src/index.js +3 -5
  19. package/src/plugin.js +4 -8
  20. package/srv/blockchain/asset-decimals.d.ts +0 -9
  21. package/srv/blockchain/asset-decimals.js +21 -16
  22. package/srv/blockchain/backends/blockfrost-backend.d.ts +2 -10
  23. package/srv/blockchain/backends/blockfrost-backend.js +15 -21
  24. package/srv/blockchain/backends/cardano-backend.d.ts +12 -71
  25. package/srv/blockchain/backends/koios-backend.d.ts +14 -147
  26. package/srv/blockchain/backends/koios-backend.js +43 -166
  27. package/srv/blockchain/backends/odatano-backend.d.ts +1 -11
  28. package/srv/blockchain/backends/odatano-backend.js +11 -12
  29. package/srv/blockchain/backends/ogmios-backend.d.ts +19 -160
  30. package/srv/blockchain/backends/ogmios-backend.js +96 -175
  31. package/srv/blockchain/backends/ogmios-frame-guard.d.ts +2 -18
  32. package/srv/blockchain/backends/ogmios-frame-guard.js +8 -20
  33. package/srv/blockchain/cardano-client.d.ts +12 -80
  34. package/srv/blockchain/cardano-client.js +36 -88
  35. package/srv/blockchain/cardano-indexer.d.ts +14 -192
  36. package/srv/blockchain/cardano-indexer.js +136 -222
  37. package/srv/blockchain/cardano-tx-builder.d.ts +1 -28
  38. package/srv/blockchain/cardano-tx-builder.js +17 -34
  39. package/srv/blockchain/circuit-breaker.d.ts +1 -13
  40. package/srv/blockchain/circuit-breaker.js +5 -15
  41. package/srv/blockchain/crawler/asset-decimals-backfill.d.ts +0 -5
  42. package/srv/blockchain/crawler/asset-decimals-backfill.js +2 -5
  43. package/srv/blockchain/crawler/certificate-backfill.d.ts +0 -17
  44. package/srv/blockchain/crawler/certificate-backfill.js +8 -22
  45. package/srv/blockchain/crawler/crawler.d.ts +16 -93
  46. package/srv/blockchain/crawler/crawler.js +85 -160
  47. package/srv/blockchain/crawler/credential-backfill.d.ts +0 -10
  48. package/srv/blockchain/crawler/credential-backfill.js +2 -4
  49. package/srv/blockchain/crawler/hooks.d.ts +1 -5
  50. package/srv/blockchain/crawler/index.d.ts +0 -12
  51. package/srv/blockchain/crawler/index.js +6 -20
  52. package/srv/blockchain/crawler/sync-state.d.ts +6 -44
  53. package/srv/blockchain/crawler/sync-state.js +18 -53
  54. package/srv/blockchain/crawler/transaction-backfill.d.ts +0 -11
  55. package/srv/blockchain/crawler/transaction-backfill.js +11 -30
  56. package/srv/blockchain/crawler/utxo-set-import.d.ts +1 -30
  57. package/srv/blockchain/crawler/utxo-set-import.js +27 -53
  58. package/srv/blockchain/ledger-state.d.ts +10 -54
  59. package/srv/blockchain/ledger-state.js +11 -27
  60. package/srv/blockchain/pending-spends.d.ts +0 -12
  61. package/srv/blockchain/pending-spends.js +4 -12
  62. package/srv/blockchain/request-coalescer.d.ts +2 -16
  63. package/srv/blockchain/request-coalescer.js +2 -16
  64. package/srv/blockchain/signing/cose-verifier.d.ts +0 -9
  65. package/srv/blockchain/signing/cose-verifier.js +4 -10
  66. package/srv/blockchain/signing/external-signer.d.ts +1 -4
  67. package/srv/blockchain/signing/external-signer.js +2 -8
  68. package/srv/blockchain/signing/hsm-signer.d.ts +6 -18
  69. package/srv/blockchain/signing/hsm-signer.js +16 -28
  70. package/srv/blockchain/signing/signature-verifier.d.ts +1 -8
  71. package/srv/blockchain/signing/signature-verifier.js +9 -19
  72. package/srv/blockchain/signing/submission-finalizer.d.ts +10 -16
  73. package/srv/blockchain/signing/submission-finalizer.js +53 -19
  74. package/srv/blockchain/stored-chain.d.ts +1 -14
  75. package/srv/blockchain/stored-chain.js +3 -8
  76. package/srv/blockchain/transaction-building/buildooor-fee-patch.d.ts +0 -4
  77. package/srv/blockchain/transaction-building/buildooor-fee-patch.js +4 -9
  78. package/srv/blockchain/transaction-building/buildooor-tx.d.ts +7 -150
  79. package/srv/blockchain/transaction-building/buildooor-tx.js +91 -196
  80. package/srv/blockchain/transaction-building/caller-datums.d.ts +0 -14
  81. package/srv/blockchain/transaction-building/caller-datums.js +3 -9
  82. package/srv/blockchain/transaction-building/cardano-tx.d.ts +1 -4
  83. package/srv/blockchain/wallet-worker/build-request.d.ts +0 -5
  84. package/srv/blockchain/wallet-worker/build-request.js +6 -9
  85. package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +5 -23
  86. package/srv/blockchain/wallet-worker/confirmation-tracker.js +16 -20
  87. package/srv/blockchain/wallet-worker/index.d.ts +1 -1
  88. package/srv/blockchain/wallet-worker/index.js +3 -5
  89. package/srv/blockchain/wallet-worker/job-store.d.ts +15 -65
  90. package/srv/blockchain/wallet-worker/job-store.js +0 -0
  91. package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +2 -10
  92. package/srv/blockchain/wallet-worker/lease-heartbeat.js +6 -12
  93. package/srv/blockchain/wallet-worker/signers.d.ts +3 -11
  94. package/srv/blockchain/wallet-worker/signers.js +3 -6
  95. package/srv/blockchain/wallet-worker/wallet-worker.d.ts +3 -21
  96. package/srv/blockchain/wallet-worker/wallet-worker.js +47 -54
  97. package/srv/cardano-agent-service.cds +123 -146
  98. package/srv/cardano-agent-service.js +2 -5
  99. package/srv/cardano-backend-service.cds +10 -17
  100. package/srv/cardano-backend-service.js +7 -12
  101. package/srv/cardano-indexer-service.cds +16 -37
  102. package/srv/cardano-indexer-service.d.ts +5 -1
  103. package/srv/cardano-indexer-service.js +44 -35
  104. package/srv/cardano-service.cds +56 -40
  105. package/srv/cardano-service.js +42 -69
  106. package/srv/cardano-sign-service.cds +14 -23
  107. package/srv/cardano-sign-service.js +18 -24
  108. package/srv/cardano-tx-service.cds +27 -29
  109. package/srv/cardano-tx-service.js +60 -122
  110. package/srv/cardano-worker-service.cds +109 -125
  111. package/srv/cardano-worker-service.js +21 -31
  112. package/srv/cbor/cip68.d.ts +0 -4
  113. package/srv/cbor/cip68.js +2 -4
  114. package/srv/cbor/parse.d.ts +3 -18
  115. package/srv/cbor/parse.js +2 -7
  116. package/srv/cbor/plutus-data-json.d.ts +0 -4
  117. package/srv/server.d.ts +5 -36
  118. package/srv/server.js +30 -51
  119. package/srv/utils/agent-grants-config.d.ts +0 -18
  120. package/srv/utils/agent-grants-config.js +6 -13
  121. package/srv/utils/agent-grants.d.ts +14 -68
  122. package/srv/utils/agent-grants.js +42 -60
  123. package/srv/utils/agent-token-auth.d.ts +0 -5
  124. package/srv/utils/agent-token-auth.js +2 -5
  125. package/srv/utils/backend-request-handler.d.ts +1 -1
  126. package/srv/utils/collections.d.ts +1 -4
  127. package/srv/utils/collections.js +1 -4
  128. package/srv/utils/const.d.ts +0 -18
  129. package/srv/utils/const.js +7 -18
  130. package/srv/utils/crypto.js +3 -5
  131. package/srv/utils/db-indexes.d.ts +2 -0
  132. package/srv/utils/db-indexes.js +22 -9
  133. package/srv/utils/db-sanitize.d.ts +1 -8
  134. package/srv/utils/db-sanitize.js +3 -8
  135. package/srv/utils/epoch-slots.d.ts +1 -8
  136. package/srv/utils/epoch-slots.js +3 -8
  137. package/srv/utils/error-codes.d.ts +0 -4
  138. package/srv/utils/error-codes.js +2 -4
  139. package/srv/utils/errors.d.ts +2 -22
  140. package/srv/utils/errors.js +13 -27
  141. package/srv/utils/liveness.d.ts +0 -4
  142. package/srv/utils/liveness.js +2 -4
  143. package/srv/utils/mappers.d.ts +0 -37
  144. package/srv/utils/mappers.js +19 -39
  145. package/srv/utils/network-context.js +2 -4
  146. package/srv/utils/paging.d.ts +31 -0
  147. package/srv/utils/paging.js +43 -0
  148. package/srv/utils/pg-inline-json.js +3 -7
  149. package/srv/utils/pg-order-nulls.js +2 -5
  150. package/srv/utils/plutus-placeholders.d.ts +0 -13
  151. package/srv/utils/plutus-placeholders.js +6 -13
  152. package/srv/utils/rate-limiter.d.ts +0 -8
  153. package/srv/utils/rate-limiter.js +2 -4
  154. package/srv/utils/reference-script.d.ts +0 -18
  155. package/srv/utils/reference-script.js +8 -19
  156. package/srv/utils/service-events.d.ts +0 -4
  157. package/srv/utils/service-events.js +2 -4
  158. package/srv/utils/signing-helper.d.ts +1 -8
  159. package/srv/utils/signing-helper.js +3 -8
  160. package/srv/utils/tx-build-helper.d.ts +2 -32
  161. package/srv/utils/tx-build-helper.js +26 -40
  162. package/srv/utils/tx-request-parsers.d.ts +1 -25
  163. package/srv/utils/tx-request-parsers.js +10 -25
  164. package/srv/utils/tx-utils.d.ts +0 -8
  165. package/srv/utils/tx-utils.js +10 -13
  166. package/srv/utils/types.d.ts +2 -37
  167. package/srv/utils/validators.d.ts +0 -4
  168. package/srv/utils/validators.js +2 -4
@@ -9,6 +9,8 @@ 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
+ const paging_1 = require("./utils/paging");
13
+ const CardanoODataService_1 = require("#cds-models/CardanoODataService");
12
14
  /** Newest temporal slice per key; child tables keep one row per validFrom. */
13
15
  function latestSlices(rows, keyOf) {
14
16
  const seen = new Map();
@@ -24,13 +26,9 @@ const { SELECT } = cds_1.default.ql;
24
26
  const logger = cds_1.default.log(`CardanoService`);
25
27
  /** Upper bound of the temporal window; must outlast the slowest index-on-miss of one request. */
26
28
  const TEMPORAL_WINDOW_SLACK_MS = 60 * 60 * 1000;
27
- /**
28
- * Let this request see the temporal slices it writes during index-on-miss: CAP's temporal
29
- * filter (`validFrom < $valid.to`) defaults to a `now`..`now+1ms` window fixed at transaction
30
- * start, so a slice stamped after the backend fetch would be invisible to the handler's
31
- * re-read. Only the upper bound moves; explicit `sap-valid-*` options are left alone.
32
- * Must run before the handler's first DB statement.
33
- */
29
+ // CAP's temporal window is fixed at transaction start, so a slice written by index-on-miss would be
30
+ // invisible to the re-read. This widens the upper bound unless the client set `sap-valid-*`.
31
+ // Must run before the handler's first DB statement.
34
32
  function widenTemporalWindow(req) {
35
33
  const q = req.http?.req?.query;
36
34
  if (q && (q['sap-valid-at'] || q['sap-valid-from'] || q['sap-valid-to']))
@@ -47,10 +45,7 @@ function widenTemporalWindow(req) {
47
45
  bag['VALID-TO'] = to;
48
46
  }
49
47
  }
50
- /**
51
- * Factory: READ handler with index-on-miss. With a key, indexes on a cache miss and then
52
- * runs the client's own query so `$expand` / `$select` apply; without a key, passes through.
53
- */
48
+ /** READ handler that indexes a missing key first, then runs the client's own query (keeps `$expand`, `$select`). */
54
49
  function indexOnMissRead(entity, reqKeyField, validate, indexFn, options) {
55
50
  const dbKey = options?.entityKeyField || reqKeyField;
56
51
  const errMsg = options?.errorMessage || `Invalid ${reqKeyField} format`;
@@ -106,11 +101,7 @@ function isAddressRef(t) {
106
101
  return (path.length === 1 && path[0] === 'address_address') || (path.length === 2 && path[0] === 'address' && path[1] === 'address');
107
102
  }
108
103
  const stringVal = (t) => t !== undefined && isVal(t) && typeof t.val === 'string' ? t.val : undefined;
109
- /**
110
- * Addresses a read of an address child set names: the parent of a navigation
111
- * (`Addresses('…')/utxos`) or the `$filter` terms `address_address eq '…'` (either operand
112
- * order) and `address_address in ('…', …)`.
113
- */
104
+ /** Addresses a child-set read names: the navigation parent, or `address_address` in an `eq` or `in` filter. */
114
105
  function addressesInReadQuery(req) {
115
106
  const found = new Set();
116
107
  const parent = req.data?.address_address;
@@ -150,11 +141,7 @@ function addressesInReadQuery(req) {
150
141
  walk(('SELECT' in query && query.SELECT?.where) || []);
151
142
  return Array.from(found);
152
143
  }
153
- /**
154
- * Factory: READ handler for a child set of Addresses with index-on-miss. The address is taken
155
- * from the navigation parent or the `$filter`; without one the read passes through.
156
- * `isIndexed` says whether the address needs no fetch, `indexFn` fetches it.
157
- */
144
+ /** READ handler for a child set of Addresses: indexes the named address on a miss, then runs the query. */
158
145
  function addressChildRead(isIndexed, indexFn) {
159
146
  return async (req) => {
160
147
  const addresses = addressesInReadQuery(req);
@@ -194,7 +181,7 @@ module.exports = (srv) => {
194
181
  LedgerProtocolParameters, AddressTransactions,
195
182
  })) {
196
183
  if (entity?.is_singular) {
197
- throw new Error(`CardanoODataService: '${name}' resolves to the SINGULAR cds-typer class — ` +
184
+ throw new Error(`CardanoODataService: '${name}' resolves to the SINGULAR cds-typer class: ` +
198
185
  `READ handlers registered with it never match under cds 10. Destructure the ` +
199
186
  `plural entity-set class instead (e.g. '${name}_ as ${name}').`);
200
187
  }
@@ -251,25 +238,22 @@ module.exports = (srv) => {
251
238
  // ---------------------------------------------------------------------------
252
239
  srv.on('READ', Assets, indexOnMissRead(Assets, 'unit', validators_1.isAssetUnit, (db, u) => indexer().indexAsset(db, u), { errorMessage: 'Invalid asset unit format' }));
253
240
  srv.on('GetAssetInfo', indexOnMissAction('GetAssetInfo', Assets, 'unit', validators_1.isAssetUnit, (db, u) => indexer().indexAsset(db, u), { errorMessage: 'Invalid asset unit format' }));
254
- // ---------------------------------------------------------------------------
255
- // Asset History
256
- // ---------------------------------------------------------------------------
257
- // Generic READ is served from the DB only; GetAssetHistory(unit) seeds the rows.
241
+ // Asset history: READ serves stored rows only; GetAssetHistory fetches and stores them.
258
242
  srv.on('READ', AssetHistory, async (req) => {
259
243
  return (0, backend_request_handler_1.handleRequest)(req, async (db) => db.run(req.query));
260
244
  });
261
- // GetAssetHistory — always-fresh fetch of recent mint/burn events.
262
- srv.on('GetAssetHistory', async (req) => {
263
- const { unit, limit } = req.data;
245
+ // GetAssetHistory: always-fresh fetch of recent mint/burn events.
246
+ srv.on(CardanoODataService_1.GetAssetHistory, async (req) => {
247
+ const { unit } = req.data;
264
248
  if (!unit)
265
249
  return (0, errors_1.rejectMissing)(req, 'GetAssetHistory', 'unit');
266
250
  if (!(0, validators_1.isAssetUnit)(unit)) {
267
251
  return (0, errors_1.rejectInvalid)(req, 'GetAssetHistory', 'Invalid asset unit format', 'unit');
268
252
  }
269
- // Clamp: an unbounded limit would page the upstream backend indefinitely.
270
- const effectiveLimit = Math.min(Math.max(typeof limit === 'number' ? limit : 100, 1), 100);
253
+ const page = (0, paging_1.latestWindowPage)(req, 'GetAssetHistory', 100);
271
254
  return (0, backend_request_handler_1.handleRequest)(req, async (db) => {
272
- return await indexer().indexAssetHistory(db, unit, effectiveLimit);
255
+ const events = await indexer().indexAssetHistory(db, unit, page.skip + page.limit);
256
+ return (0, paging_1.pageRows)((0, paging_1.sortAssetHistory)(events), page);
273
257
  });
274
258
  });
275
259
  // ---------------------------------------------------------------------------
@@ -277,20 +261,21 @@ module.exports = (srv) => {
277
261
  // ---------------------------------------------------------------------------
278
262
  srv.on('READ', Addresses, indexOnMissRead(Addresses, 'address', validators_1.isValidBech32Address, (db, a) => indexer().indexAddress(db, a), { errorMessage: 'Invalid bech32 address format' }));
279
263
  srv.on('GetAddressByBech32', indexOnMissAction('GetAddressByBech32', Addresses, 'address', validators_1.isValidBech32Address, (db, a) => indexer().indexAddress(db, a), { errorMessage: 'Invalid bech32 address format' }));
280
- // GetAssetsByAddress — indexes the parent address if needed, then queries child assets.
281
- srv.on('GetAssetsByAddress', async (req) => {
264
+ // GetAssetsByAddress: indexes the parent address if needed, then queries child assets.
265
+ srv.on(CardanoODataService_1.GetAssetsByAddress, async (req) => {
282
266
  const { address } = req.data;
283
267
  if (!address)
284
268
  (0, errors_1.rejectMissing)(req, 'GetAssetsByAddress', 'address');
285
269
  if (!(0, validators_1.isValidBech32Address)(address))
286
270
  (0, errors_1.rejectInvalid)(req, 'GetAssetsByAddress', 'Invalid bech32 address format', 'address');
271
+ const page = (0, paging_1.pageOf)(req.data, 1000);
287
272
  return (0, backend_request_handler_1.handleRequest)(req, async (db) => {
288
273
  widenTemporalWindow(req); // before the first DB statement
289
274
  const existing = await db.run(SELECT.one.from(Addresses).where({ address }));
290
275
  if (!existing)
291
276
  await indexer().indexAddress(db, address);
292
277
  const assets = await db.run(SELECT.from(AddressAssets).where({ address_address: address }));
293
- return latestSlices(assets, (asset) => asset.unit ?? '');
278
+ return (0, paging_1.pageRows)((0, paging_1.byKey)(latestSlices(assets, (asset) => asset.unit ?? ''), (a) => a.unit ?? ''), page);
294
279
  });
295
280
  });
296
281
  // Prefer the full address index; when no configured backend supports getAddress
@@ -314,44 +299,44 @@ module.exports = (srv) => {
314
299
  const addressIndexed = async (db, address) => !!(await db.run(SELECT.one.from(Addresses).where({ address })));
315
300
  const addressUtxosIndexed = async (db, address) => (await addressIndexed(db, address))
316
301
  || !!(await db.run(SELECT.one.from(AddressUTxOs).where({ address_address: address })));
317
- // GetUTxOsByAddress — indexes the address if needed, then queries child UTxOs.
318
- srv.on('GetUTxOsByAddress', async (req) => {
302
+ // GetUTxOsByAddress: indexes the address if needed, then queries child UTxOs.
303
+ srv.on(CardanoODataService_1.GetUTxOsByAddress, async (req) => {
319
304
  const { address } = req.data;
320
305
  if (!address)
321
306
  (0, errors_1.rejectMissing)(req, 'GetUTxOsByAddress', 'address');
322
307
  if (!(0, validators_1.isValidBech32Address)(address))
323
308
  (0, errors_1.rejectInvalid)(req, 'GetUTxOsByAddress', 'Invalid bech32 address format', 'address');
309
+ const page = (0, paging_1.pageOf)(req.data, 1000);
324
310
  return (0, backend_request_handler_1.handleRequest)(req, async (db) => {
325
311
  widenTemporalWindow(req); // before the first DB statement
326
312
  if (!(await addressUtxosIndexed(db, address)))
327
313
  await indexAddressOrUtxos(db, address);
328
314
  const utxos = await db.run(SELECT.from(AddressUTxOs).where({ address_address: address }));
329
- return latestSlices(utxos, (utxo) => `${utxo.hash}#${utxo.index}`);
315
+ return (0, paging_1.pageRows)((0, paging_1.byOutRef)(latestSlices(utxos, (utxo) => `${utxo.hash}#${utxo.index}`)), page);
330
316
  });
331
317
  });
332
318
  // Collection reads of the address child sets fill like the parent: an address named in the
333
319
  // navigation or the $filter is indexed on a miss, then the client's own query runs.
334
320
  srv.on('READ', AddressUTxOs, addressChildRead(addressUtxosIndexed, indexAddressOrUtxos));
335
321
  srv.on('READ', AddressAssets, addressChildRead(addressIndexed, (db, address) => indexer().indexAddress(db, address)));
336
- // GetUTxOsByCredential — always-fresh credential-keyed UTxO query (dApp state reads need current
322
+ // GetUTxOsByCredential: always-fresh credential-keyed UTxO query (dApp state reads need current
337
323
  // data). Crawled UTxO set + node first, else Koios; ProviderUnavailableError without either.
338
- srv.on('GetUTxOsByCredential', async (req) => {
324
+ srv.on(CardanoODataService_1.GetUTxOsByCredential, async (req) => {
339
325
  const { credential } = req.data;
340
326
  if (!credential)
341
327
  return (0, errors_1.rejectMissing)(req, 'GetUTxOsByCredential', 'credential');
342
328
  if (!(0, validators_1.isValidCredential)(credential)) {
343
- return (0, errors_1.rejectInvalid)(req, 'GetUTxOsByCredential', 'Invalid payment credential — expected 56-char lowercase hex (28 bytes)', 'credential');
329
+ return (0, errors_1.rejectInvalid)(req, 'GetUTxOsByCredential', 'Invalid payment credential: expected 56-char lowercase hex (28 bytes)', 'credential');
344
330
  }
345
- return (0, backend_request_handler_1.handleRequest)(req, async (db) => {
346
- return await indexer().indexCredentialUtxos(db, credential);
347
- });
331
+ const page = (0, paging_1.pageOf)(req.data, 1000);
332
+ return (0, backend_request_handler_1.handleRequest)(req, async (db) => (0, paging_1.pageRows)((0, paging_1.byOutRef)(await indexer().indexCredentialUtxos(db, credential)), page));
348
333
  });
349
334
  // ---------------------------------------------------------------------------
350
335
  // Transactions
351
336
  // ---------------------------------------------------------------------------
352
337
  srv.on('READ', Transactions, indexOnMissRead(Transactions, 'hash', validators_1.isTxHash, (db, h) => indexer().indexTransaction(db, h), { errorMessage: 'Invalid transaction hash format' }));
353
338
  srv.on('GetTransactionByHash', indexOnMissAction('GetTransactionByHash', Transactions, 'hash', validators_1.isTxHash, (db, h) => indexer().indexTransaction(db, h), { errorMessage: 'Invalid transaction hash format' }));
354
- srv.on('GetTransactionConfirmations', async (req) => {
339
+ srv.on(CardanoODataService_1.GetTransactionConfirmations, async (req) => {
355
340
  const { txHash } = req.data;
356
341
  if (!txHash)
357
342
  (0, errors_1.rejectMissing)(req, 'GetTransactionConfirmations', 'txHash');
@@ -363,19 +348,18 @@ module.exports = (srv) => {
363
348
  // Transaction Metadata
364
349
  // ---------------------------------------------------------------------------
365
350
  srv.on('READ', TransactionMetadata, indexOnMissRead(TransactionMetadata, 'tx_hash', validators_1.isTxHash, (db, h) => indexer().indexTransactionMetadata(db, h), { errorMessage: 'Invalid transaction hash format' }));
366
- // GetMetadataByTxHash — returns all metadata rows of a transaction.
367
- srv.on('GetMetadataByTxHash', async (req) => {
351
+ // GetMetadataByTxHash: returns all metadata rows of a transaction.
352
+ srv.on(CardanoODataService_1.GetMetadataByTxHash, async (req) => {
368
353
  const { txHash } = req.data;
369
354
  if (!txHash)
370
355
  (0, errors_1.rejectMissing)(req, 'GetMetadataByTxHash', 'txHash');
371
356
  if (!(0, validators_1.isTxHash)(txHash))
372
357
  (0, errors_1.rejectInvalid)(req, 'GetMetadataByTxHash', 'Invalid transaction hash format', 'txHash');
358
+ const page = (0, paging_1.pageOf)(req.data, 1000);
373
359
  return (0, backend_request_handler_1.handleRequest)(req, async (db) => {
374
360
  const existing = await db.run(SELECT.from(TransactionMetadata).where({ tx_hash: txHash }));
375
- if (!existing || existing.length === 0) {
376
- return await indexer().indexTransactionMetadata(db, txHash);
377
- }
378
- return existing;
361
+ const rows = existing?.length ? existing : await indexer().indexTransactionMetadata(db, txHash);
362
+ return (0, paging_1.pageRows)((0, paging_1.byKey)(rows, (m) => String(m.label ?? '').padStart(20, '0')), page);
379
363
  });
380
364
  });
381
365
  // ---------------------------------------------------------------------------
@@ -395,7 +379,7 @@ module.exports = (srv) => {
395
379
  // ---------------------------------------------------------------------------
396
380
  // Transaction CBOR parsing (pure; no backend or DB access)
397
381
  // ---------------------------------------------------------------------------
398
- srv.on('ParseTransactionCbor', async (req) => {
382
+ srv.on(CardanoODataService_1.ParseTransactionCbor, async (req) => {
399
383
  const { cbor } = req.data;
400
384
  if (cbor == null || cbor === '')
401
385
  (0, errors_1.rejectMissing)(req, 'ParseTransactionCbor', 'cbor');
@@ -404,7 +388,7 @@ module.exports = (srv) => {
404
388
  }
405
389
  return (0, backend_request_handler_1.handleRequest)(req, async () => (0, cbor_1.parseTransaction)(cbor));
406
390
  });
407
- srv.on('DecodePlutusData', async (req) => {
391
+ srv.on(CardanoODataService_1.DecodePlutusData, async (req) => {
408
392
  const { cbor } = req.data;
409
393
  if (cbor == null || cbor === '')
410
394
  (0, errors_1.rejectMissing)(req, 'DecodePlutusData', 'cbor');
@@ -416,26 +400,15 @@ module.exports = (srv) => {
416
400
  // ---------------------------------------------------------------------------
417
401
  // Address Transactions
418
402
  // ---------------------------------------------------------------------------
419
- srv.on('GetLatestTransactionsByAddress', async (req) => {
420
- const { address, limit } = req.data;
403
+ srv.on(CardanoODataService_1.GetLatestTransactionsByAddress, async (req) => {
404
+ const { address } = req.data;
421
405
  if (!address)
422
406
  (0, errors_1.rejectMissing)(req, 'GetLatestTransactionsByAddress', 'address');
423
407
  if (!(0, validators_1.isValidBech32Address)(address))
424
408
  (0, errors_1.rejectInvalid)(req, 'GetLatestTransactionsByAddress', 'Invalid bech32 address format', 'address');
425
- const txLimit = Math.min(Math.max(limit || 10, 1), 100);
426
- return (0, backend_request_handler_1.handleRequest)(req, async (db) => {
427
- // The crawled UTxO set is current; the cached rows may miss the newest transactions.
428
- if (await indexer().ledgerCoverageActive(db))
429
- return indexer().indexAddressTransactions(db, address, txLimit);
430
- const existing = await db.run(SELECT.from(AddressTransactions)
431
- .where({ address_address: address })
432
- .orderBy('blockTime desc')
433
- .limit(txLimit));
434
- if (!existing || existing.length < txLimit) {
435
- return indexer().indexAddressTransactions(db, address, txLimit);
436
- }
437
- return existing;
438
- });
409
+ const page = (0, paging_1.latestWindowPage)(req, 'GetLatestTransactionsByAddress', 10);
410
+ // Every call lists the newest hashes; stored rows are reused, only new ones are fetched.
411
+ return (0, backend_request_handler_1.handleRequest)(req, async (db) => (0, paging_1.pageRows)(await indexer().indexAddressTransactions(db, address, page.skip + page.limit), page));
439
412
  });
440
413
  logger.debug('All handlers registered');
441
414
  };
@@ -1,25 +1,9 @@
1
1
  using {odatano.cardano as db} from '../db/schema';
2
2
  using {Bech32} from '../db/types';
3
3
 
4
- /**
5
- * Cardano Sign Service
6
- *
7
- * Handles the external signing workflow for Cardano transactions, including:
8
- * - Creating signing requests with transaction details and signing instructions
9
- * - Verifying signatures of signed transactions and storing verification results
10
- * - Submitting verified transactions to the blockchain and tracking submission status
11
- * - Providing actions for signing with a Hardware Security Module (HSM) and retrieving HSM status
12
- *
13
- * Security note: see CardanoODataService (cardano-service.cds) for the rationale on auth
14
- * without per-resource ownership enforcement. Deliberately NO service-level @requires:
15
- * CAP checks it on every request BEFORE the operation annotation, which silenced the
16
- * `any` on VerifyDataSignature (anonymous callers got the 401 challenge first). The
17
- * requirement therefore sits on each element; VerifyDataSignature alone is public.
18
- */
19
- // Service-level 'any' on purpose: CAP authorizes the service BEFORE the operation and
20
- // treats a service without a service-level @requires as authenticated-user under
21
- // NODE_ENV=production, which would 401 the anonymous operation below despite its own
22
- // 'any'. Every element carries its requirement; the service itself refuses nothing.
4
+ // External signing: signing requests, signature checks, submission and HSM signing.
5
+ // The service itself is 'any': CAP checks the service before the operation, so anything stricter
6
+ // would 401 the anonymous VerifyDataSignature. Each element carries its own requirement.
23
7
  @requires: 'any'
24
8
  service CardanoSignService @(impl: './cardano-sign-service') {
25
9
 
@@ -34,7 +18,7 @@ service CardanoSignService @(impl: './cardano-sign-service') {
34
18
 
35
19
  @readonly
36
20
  @title : 'Address Signing Requests'
37
- @description: 'Projection for retrieving signing requests by address'
21
+ @description: 'Signing requests of an address, ordered by request id'
38
22
  @requires : 'authenticated-user'
39
23
  entity AddressSigningRequests as projection on db.AddressSigningRequests;
40
24
 
@@ -106,8 +90,7 @@ service CardanoSignService @(impl: './cardano-sign-service') {
106
90
  // ---------------------------------------------------------------------------
107
91
 
108
92
  // Public override: this action is the crypto check behind wallet-based LOGIN,
109
- // so the caller is not yet authenticated. It is a stateless verification —
110
- // no DB write, no key access, no state — so exposing it leaks nothing.
93
+ // so the caller is not yet authenticated. It writes nothing and touches no key, so it leaks nothing.
111
94
  @requires : 'any'
112
95
  @title : 'Verify Data Signature (CIP-30 signData)'
113
96
  @description: 'Verify a COSE_Sign1 message signature against a bech32 address. Confirms the Ed25519 signature, that the signer key hashes to the address payment credential, and (optionally) that the signed payload matches an expected value.'
@@ -155,7 +138,15 @@ service CardanoSignService @(impl: './cardano-sign-service') {
155
138
  action GetSigningRequestsByAddress(
156
139
  @title: 'Bech32 Address'
157
140
  @description: 'The Bech32 encoded address to retrieve signing requests for'
158
- address: Bech32) returns array of AddressSigningRequests;
141
+ address: Bech32,
142
+ @title: 'Limit'
143
+ @description: 'Maximum number of rows (default 1000, at most 5000)'
144
+ @assert.range: [1, 5000]
145
+ limit: Integer,
146
+ @title: 'Skip'
147
+ @description: 'Number of rows to skip (default 0)'
148
+ @assert.range: [0, _]
149
+ skip: Integer) returns array of AddressSigningRequests;
159
150
 
160
151
  // ---------------------------------------------------------------------------
161
152
  // HSM (Hardware Security Module) Signing Actions
@@ -15,6 +15,7 @@ const hsm_signer_1 = require("./blockchain/signing/hsm-signer");
15
15
  const cose_verifier_1 = require("./blockchain/signing/cose-verifier");
16
16
  const signing_helper_1 = require("./utils/signing-helper");
17
17
  const tx_utils_1 = require("./utils/tx-utils");
18
+ const paging_1 = require("./utils/paging");
18
19
  const submission_finalizer_1 = require("./blockchain/signing/submission-finalizer");
19
20
  const { SELECT, UPDATE } = cds_1.default.ql;
20
21
  const logger = cds_1.default.log('CardanoSignService');
@@ -28,10 +29,7 @@ async function verifyBuildOwnership(req, db, buildId, address, TransactionBuilds
28
29
  }
29
30
  return build;
30
31
  }
31
- /**
32
- * Expire a pending signing request past its TTL.
33
- * @returns true if expired, false otherwise
34
- */
32
+ /** Expires a pending signing request past its TTL. Returns true if it expired. */
35
33
  async function checkAndExpireSigningRequest(db, signingRequest, SigningRequests) {
36
34
  const now = new Date().toISOString();
37
35
  const result = await db.run(UPDATE.entity(SigningRequests)
@@ -45,11 +43,8 @@ async function checkAndExpireSigningRequest(db, signingRequest, SigningRequests)
45
43
  // A later req.reject rolls this update back; the next touch re-applies it.
46
44
  return false;
47
45
  }
48
- /**
49
- * Key hashes that must witness a signing request: the body's `required_signers` plus the
50
- * payment key hash of the build's senderAddress (script credentials skipped).
51
- * Returns undefined when nothing is derivable.
52
- */
46
+ // Key hashes that must sign: the body's required_signers plus the sender's payment key hash.
47
+ // Script credentials are skipped. Returns undefined when nothing can be derived.
53
48
  async function resolveRequiredSigners(db, signingRequest, TransactionBuilds) {
54
49
  const signers = new Set();
55
50
  try {
@@ -94,7 +89,7 @@ module.exports = (srv) => {
94
89
  .set({ status: 'expired' })
95
90
  .where({ status: 'pending', expiresAt: { '<=': new Date().toISOString() } }));
96
91
  });
97
- // CreateSigningRequest — persist a signing request for a build (idempotent per pending build).
92
+ // CreateSigningRequest: persist a signing request for a build (idempotent per pending build).
98
93
  srv.on('CreateSigningRequest', async (req) => {
99
94
  logger.debug('CreateSigningRequest Action handler called');
100
95
  const { buildId, message } = req.data;
@@ -119,7 +114,7 @@ module.exports = (srv) => {
119
114
  return signingRequestRecord;
120
115
  });
121
116
  });
122
- // GetSigningRequest — by id; expires a pending request past its TTL on read.
117
+ // GetSigningRequest: by id; expires a pending request past its TTL on read.
123
118
  srv.on('GetSigningRequest', async (req) => {
124
119
  logger.debug('GetSigningRequest Action handler called');
125
120
  const { signingRequestId } = req.data;
@@ -135,7 +130,7 @@ module.exports = (srv) => {
135
130
  return signingRequest;
136
131
  });
137
132
  });
138
- // VerifySignature — verify a signed tx / witness set against the request; persists the result.
133
+ // VerifySignature: verify a signed tx or witness set against the request; persists the result.
139
134
  srv.on('VerifySignature', async (req) => {
140
135
  logger.debug('VerifySignature Action handler called');
141
136
  const { signingRequestId, signedTxCbor, signerType, signerInfo, address } = req.data;
@@ -189,7 +184,7 @@ module.exports = (srv) => {
189
184
  return verificationRecord;
190
185
  });
191
186
  });
192
- // SubmitVerifiedTransaction — verify and submit in one step.
187
+ // SubmitVerifiedTransaction: verify and submit in one step.
193
188
  srv.on('SubmitVerifiedTransaction', async (req) => {
194
189
  logger.debug('SubmitVerifiedTransaction Action handler called');
195
190
  const { signingRequestId, signedTxCbor, signerType, signerInfo, address } = req.data;
@@ -256,7 +251,7 @@ module.exports = (srv) => {
256
251
  // Phase 1 on the caller's transaction; validation errors stay synchronous.
257
252
  const prep = await phase1(cds_1.default.tx(req));
258
253
  (0, submission_finalizer_1.scheduleDeferredSubmit)(req, SigningRequests, finalizeParams(prep));
259
- logger.info({ signingRequestId, txHash: prep.txHash }, 'Verified and claimed — submit deferred until after the caller commits');
254
+ logger.info({ signingRequestId, txHash: prep.txHash }, 'Verified and claimed, submit deferred until after the caller commits');
260
255
  return {
261
256
  id: null,
262
257
  build_id: prep.buildId,
@@ -278,7 +273,7 @@ module.exports = (srv) => {
278
273
  return (0, mappers_1.mapError)(req, e, 'SubmitVerifiedTransaction');
279
274
  }
280
275
  });
281
- // VerifyDataSignature — stateless CIP-30 signData (COSE_Sign1) check for wallet login.
276
+ // VerifyDataSignature: stateless CIP-30 signData (COSE_Sign1) check for wallet login.
282
277
  // Public (@requires:'any') because the caller is not yet authenticated.
283
278
  srv.on('VerifyDataSignature', async (req) => {
284
279
  logger.debug('VerifyDataSignature Action handler called');
@@ -294,7 +289,7 @@ module.exports = (srv) => {
294
289
  // Never throws: a bad signature is a 200 with valid:false + reason.
295
290
  return (0, cose_verifier_1.verifyDataSignature)({ address, coseSignature, coseKey, expectedPayload });
296
291
  });
297
- // GetSigningRequestsByAddress — address ↔ signing request associations.
292
+ // GetSigningRequestsByAddress: signing requests linked to an address.
298
293
  srv.on('GetSigningRequestsByAddress', async (req) => {
299
294
  logger.debug('GetSigningRequestsByAddress Action handler called');
300
295
  const { address } = req.data;
@@ -302,14 +297,13 @@ module.exports = (srv) => {
302
297
  (0, errors_1.rejectMissing)(req, 'GetSigningRequestsByAddress', 'address');
303
298
  if (!(0, validators_1.isValidBech32Address)(address))
304
299
  (0, errors_1.rejectInvalid)(req, 'GetSigningRequestsByAddress', 'Invalid bech32 address format', 'address');
305
- return (0, backend_request_handler_1.handleRequest)(req, async (db) => {
306
- return db.run(SELECT.from(AddressSigningRequests).where({ address_address: address }));
307
- });
300
+ const { limit, skip } = (0, paging_1.pageOf)(req.data, 1000);
301
+ return (0, backend_request_handler_1.handleRequest)(req, (db) => db.run(SELECT.from(AddressSigningRequests).where({ address_address: address }).orderBy('signingRequest_id').limit(limit, skip)));
308
302
  });
309
303
  // ---------------------------------------------------------------------------
310
304
  // HSM signing actions
311
305
  // ---------------------------------------------------------------------------
312
- // SignWithHsm — create a signing request, sign with the HSM, verify; returns the request.
306
+ // SignWithHsm: create a signing request, sign with the HSM, verify; returns the request.
313
307
  srv.on('SignWithHsm', async (req) => {
314
308
  logger.debug('SignWithHsm Action handler called');
315
309
  enforceHsmRole(req, 'SignWithHsm');
@@ -365,7 +359,7 @@ module.exports = (srv) => {
365
359
  return db.run(SELECT.one.from(SigningRequests).where({ id: signingRequestRecord.id }));
366
360
  });
367
361
  });
368
- // SignAndSubmitWithHsm — create a signing request, sign, verify and submit in one call.
362
+ // SignAndSubmitWithHsm: create a signing request, sign, verify and submit in one call.
369
363
  srv.on('SignAndSubmitWithHsm', async (req) => {
370
364
  logger.debug('SignAndSubmitWithHsm Action handler called');
371
365
  enforceHsmRole(req, 'SignAndSubmitWithHsm');
@@ -398,7 +392,7 @@ module.exports = (srv) => {
398
392
  const hsmStatus = hsmSigner.getStatus();
399
393
  const hsmKeyIdentifier = hsmStatus.keyLabel || hsmStatus.keyId || 'unknown';
400
394
  if (!verificationResult.isValid) {
401
- logger.error({ signingRequestId: signingRequestRecord.id, hsmKey: hsmKeyIdentifier }, 'HSM signature verification failed — aborting submission');
395
+ logger.error({ signingRequestId: signingRequestRecord.id, hsmKey: hsmKeyIdentifier }, 'HSM signature verification failed, aborting submission');
402
396
  (0, errors_1.rejectInvalid)(req, 'SignAndSubmitWithHsm', 'HSM signature verification failed', 'signedTxCbor');
403
397
  }
404
398
  // Claim as 'submitting'; deferred path also persists signed CBOR + signer metadata
@@ -423,7 +417,7 @@ module.exports = (srv) => {
423
417
  // Phase 1 on the caller's transaction; submit runs after its commit.
424
418
  const prep = await phase1(cds_1.default.tx(req));
425
419
  (0, submission_finalizer_1.scheduleDeferredSubmit)(req, SigningRequests, finalizeParams(prep));
426
- logger.info({ signingRequestId: prep.signingRequestId, txHash: prep.txHash }, 'HSM-signed and claimed — submit deferred until after the caller commits');
420
+ logger.info({ signingRequestId: prep.signingRequestId, txHash: prep.txHash }, 'HSM-signed and claimed, submit deferred until after the caller commits');
427
421
  return {
428
422
  id: null,
429
423
  build_id: buildId,
@@ -446,7 +440,7 @@ module.exports = (srv) => {
446
440
  return (0, mappers_1.mapError)(req, e, 'SignAndSubmitWithHsm');
447
441
  }
448
442
  });
449
- // GetHsmStatus — connection status and key info; null fields when no HSM is configured.
443
+ // GetHsmStatus: connection status and key info; null fields when no HSM is configured.
450
444
  srv.on('GetHsmStatus', async (_req) => {
451
445
  enforceHsmRole(_req, 'GetHsmStatus');
452
446
  const hsmSigner = (0, hsm_signer_1.getHsmSigner)();
@@ -1,3 +1,4 @@
1
+ using { CardanoNetwork } from '../db/types';
1
2
  using {odatano.cardano as db} from '../db/schema';
2
3
  using {
3
4
  Bech32,
@@ -5,16 +6,7 @@ using {
5
6
  } from '../db/types';
6
7
 
7
8
 
8
- /**
9
- * Cardano Transaction Service
10
- *
11
- * Handles transaction building and submission operations.
12
- * Separate from the read-only CardanoODataService to provide
13
- * clear separation between general query and command operations.
14
- *
15
- * Security note: see CardanoODataService (cardano-service.cds) for the rationale
16
- * on service-level auth without per-resource ownership enforcement.
17
- */
9
+ // Transaction building and submission, separate from the read service.
18
10
  @requires: 'authenticated-user'
19
11
  service CardanoTransactionService @(impl: './cardano-tx-service') {
20
12
  // ---------------------------------------------------------------------------
@@ -57,16 +49,12 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
57
49
  entity TransactionSubmissions as projection on db.TransactionSubmissions
58
50
  actions {
59
51
  @title : 'Check Submission Status'
60
- @description: 'Check the status of a submitted transaction by querying the blockchain for confirmation'
52
+ @description: 'Mark a submitted transaction confirmed once it is 3 blocks deep (its own block included); otherwise it stays submitted'
61
53
  action CheckSubmissionStatus() returns TransactionSubmissions;
62
54
  };
63
55
 
64
- /**
65
- * TransactionSubmissions status flow:
66
- * pending -> [submit to chain] -> submitted (internal, in SubmitTransaction handler)
67
- * submitted -> [CheckSubmissionStatus] confirmed | stays submitted (conditional)
68
- * pending | submitted -> failed (blockchain error)
69
- */
56
+ // Status flow: pending, then submitted by SubmitTransaction, then confirmed by CheckSubmissionStatus at 3 blocks deep.
57
+ // A blockchain error moves pending or submitted to failed.
70
58
  annotate CardanoTransactionService.TransactionSubmissions with @flow.status: status actions {
71
59
  CheckSubmissionStatus @from : [ #submitted];
72
60
  };
@@ -78,7 +66,7 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
78
66
 
79
67
  @readonly
80
68
  @title : 'Address Transaction Builds'
81
- @description: 'Projection for retrieving transaction builds by address'
69
+ @description: 'Transaction builds of an address, ordered by build id'
82
70
  entity AddressTransactionBuilds as projection on db.AddressTransactionBuilds;
83
71
 
84
72
  // ---------------------------------------------------------------------------
@@ -119,7 +107,7 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
119
107
  @description: 'Optional JSON array of {txHash, outputIndex} UTxOs of the sender that must never be spent: left out of coin selection and collateral.'
120
108
  protectInputsJson: String,
121
109
  @title: 'Validator Script'
122
- @description: 'Optional Plutus validator CBOR hex. Required when lockOnScript=true. Used only to derive the target script address — the script itself is not attached to the transaction.'
110
+ @description: 'Optional Plutus validator CBOR hex. Required when lockOnScript=true. Used only to derive the target script address; the script itself is not attached to the transaction.'
123
111
  validatorScript: String,
124
112
  @title: 'Script Parameters JSON'
125
113
  @description: 'Optional JSON array of PlutusData parameters to apply to validatorScript before deriving the script address. For parameterized validators.'
@@ -128,7 +116,7 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
128
116
  @description: 'When true, validatorScript is required. Derives the enterprise script address from the (optionally param-applied) script and routes the output there instead of recipientAddress. Returns scriptAddress and scriptHash in the response.'
129
117
  lockOnScript: Boolean,
130
118
  @title: 'Reference Script Hex'
131
- @description: 'Optional Plutus V3 validator CBOR hex to attach as referenceScript on the primary recipient output (CIP-33 reference script deploy). Significantly increases the output min-ADA — lovelaceAmount must cover the inflated requirement.'
119
+ @description: 'Optional Plutus V3 validator CBOR hex to attach as referenceScript on the primary recipient output (CIP-33 reference script deploy). Significantly increases the output min-ADA; lovelaceAmount must cover the inflated requirement.'
132
120
  referenceScriptHex: String,
133
121
  @title: 'Validity Start (Posix ms)'
134
122
  @description: 'Optional. Validity-interval start in Posix milliseconds. Passed through to the builder only; for non-script transfers the builder leaves bounds unset unless provided.'
@@ -184,7 +172,7 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
184
172
  @description: 'Optional. When true, a lovelaceAmount below the recipient output min-ADA is raised to it; otherwise such a request is rejected with the required amount.'
185
173
  ensureMinAda: Boolean,
186
174
  @title: 'Reference Script Hex'
187
- @description: 'Optional Plutus V3 validator CBOR hex to attach as referenceScript on the primary recipient output (CIP-33 reference script deploy). Significantly increases the output min-ADA — lovelaceAmount must cover the inflated requirement.'
175
+ @description: 'Optional Plutus V3 validator CBOR hex to attach as referenceScript on the primary recipient output (CIP-33 reference script deploy). Significantly increases the output min-ADA; lovelaceAmount must cover the inflated requirement.'
188
176
  referenceScriptHex: String,
189
177
  @title: 'Validity Start (Posix ms)'
190
178
  @description: 'Optional. Validity-interval start in Posix milliseconds. Passed through to the builder only; for non-script transfers the builder leaves bounds unset unless provided.'
@@ -239,13 +227,13 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
239
227
  @description: 'Optional JSON array of {txHash, outputIndex} UTxOs to include as CIP-31 reference inputs (read-only, not consumed). Use for oracle feeds, shared config UTxOs, or script reference UTxOs. Buildooor builder only.'
240
228
  referenceInputsJson: String,
241
229
  @title: 'Extra Outputs JSON'
242
- @description: 'Optional JSON array of additional outputs [{address, lovelaceAmount, assets?, inlineDatumJson?, referenceScriptHex?}] appended after the primary recipient output. When present, the extra outputs carry the minted assets (declare each minted unit in an entry''s assets) and the primary output stays ADA-only — to place each minted token on its own output with its own inline datum (e.g. datum-bound predicate tokens). Each entry is independently min-ADA checked.'
230
+ @description: 'Optional JSON array of additional outputs [{address, lovelaceAmount, assets?, inlineDatumJson?, referenceScriptHex?}] appended after the primary recipient output. When present, the extra outputs carry the minted assets (declare each minted unit in an entry''s assets) and the primary output stays ADA-only. This places each minted token on its own output with its own inline datum (e.g. datum-bound predicate tokens). Each entry is independently min-ADA checked.'
243
231
  extraOutputsJson: String,
244
232
  @title: 'Metadata JSON'
245
233
  @description: 'Optional transaction metadata as JSON (CIP-20 / label-674 etc.). Object keyed by numeric label string. Attached as auxiliary_data to the mint tx so chain-watchers can correlate off-chain context (receipt IDs, free-form notes).'
246
234
  metadataJson: String,
247
235
  @title: 'Reference Script Hex'
248
- @description: 'Optional Plutus V3 validator CBOR hex to attach as referenceScript on the primary recipient output (CIP-33 reference script deploy). Significantly increases the output min-ADA — lovelaceAmount must cover the inflated requirement.'
236
+ @description: 'Optional Plutus V3 validator CBOR hex to attach as referenceScript on the primary recipient output (CIP-33 reference script deploy). Significantly increases the output min-ADA; lovelaceAmount must cover the inflated requirement.'
249
237
  referenceScriptHex: String,
250
238
  @title: 'Validity Start (Posix ms)'
251
239
  @description: 'Optional. Sets the transaction validity-interval start in Posix milliseconds. Required finite value for Plutus validators that call expect Finite(lower) on tx.validity_range.lower_bound. Defaults to now − 120 000 ms when omitted.'
@@ -278,8 +266,9 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
278
266
  @description: 'The CBOR of the signed transaction'
279
267
  signedTxCbor: String,
280
268
  @title: 'Network'
281
- @description: 'The Cardano network to submit the transaction to (e.g., mainnet, testnet)'
282
- network: String(10)) returns TransactionSubmissions;
269
+ @description: 'Optional network check (mainnet, preview, preprod); must match the configured network'
270
+ @assert.range
271
+ network: CardanoNetwork) returns TransactionSubmissions;
283
272
 
284
273
  @title : 'Build Plutus Spend Transaction'
285
274
  @description: 'Build a transaction to spend a UTxO locked at a Plutus script address'
@@ -345,7 +334,7 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
345
334
  @description: 'Optional JSON array of {txHash, outputIndex} UTxOs to include as CIP-31 reference inputs (read-only, not consumed). Use for oracle feeds, shared config UTxOs, or script reference UTxOs. Buildooor builder only.'
346
335
  referenceInputsJson: String,
347
336
  @title: 'Reference Script Hex'
348
- @description: 'Optional Plutus V3 validator CBOR hex to attach as referenceScript on the primary recipient output (CIP-33 reference script deploy). Combines with the spend in one atomic tx. Significantly increases the output min-ADA — lovelaceAmount must cover the inflated requirement.'
337
+ @description: 'Optional Plutus V3 validator CBOR hex to attach as referenceScript on the primary recipient output (CIP-33 reference script deploy). Combines with the spend in one atomic tx. Significantly increases the output min-ADA; lovelaceAmount must cover the inflated requirement.'
349
338
  referenceScriptHex: String,
350
339
  @title: 'Validity Start (Posix ms)'
351
340
  @description: 'Optional. Sets the transaction validity-interval start in Posix milliseconds. Required finite value for Plutus validators that call expect Finite(lower) on tx.validity_range.lower_bound. Defaults to now − 120 000 ms when omitted.'
@@ -409,7 +398,15 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
409
398
  action GetTransactionBuildsByAddress(
410
399
  @title: 'Bech32 Address'
411
400
  @description: 'The Bech32 encoded address to retrieve transaction builds for'
412
- address: Bech32) returns array of AddressTransactionBuilds;
401
+ address: Bech32,
402
+ @title: 'Limit'
403
+ @description: 'Maximum number of rows (default 1000, at most 5000)'
404
+ @assert.range: [1, 5000]
405
+ limit: Integer,
406
+ @title: 'Skip'
407
+ @description: 'Number of rows to skip (default 0)'
408
+ @assert.range: [0, _]
409
+ skip: Integer) returns array of AddressTransactionBuilds;
413
410
 
414
411
  @title : 'Derive Script Address'
415
412
  @description: 'Utility: Apply optional PlutusData parameters to a validator script and return its enterprise script address (bech32) and script hash (28-byte hex). Pure derivation, no transaction built, no blockchain call.'
@@ -422,13 +419,14 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
422
419
  scriptParamsJson: String,
423
420
  @title: 'Network'
424
421
  @description: 'Optional network override (mainnet, preview, preprod). Defaults to the configured network.'
425
- network: String(10)) returns {
422
+ @assert.range
423
+ network: CardanoNetwork) returns {
426
424
  scriptAddress : String(120);
427
425
  scriptHash : String(56);
428
426
  };
429
427
 
430
428
  @title : 'Extract Payment Key Hash'
431
- @description: 'Utility: Decode a Bech32 Cardano address and return its 28-byte payment credential hash (hex). Pure bech32 decoding — no blockchain call. Use to obtain the key hash for requiredSignersJson on Plutus actions.'
429
+ @description: 'Utility: Decode a Bech32 Cardano address and return its 28-byte payment credential hash (hex). Pure bech32 decoding, no blockchain call. Use to obtain the key hash for requiredSignersJson on Plutus actions.'
432
430
  action ExtractPaymentKeyHash(
433
431
  @title: 'Address'
434
432
  @description: 'The Bech32 encoded Cardano address (addr / addr_test)'