@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
@@ -1,13 +1,5 @@
1
- /**
2
- * Cardano Backend Service
3
- *
4
- * The data a CardanoBackend needs, for another ODATANO instance that uses this one as its
5
- * backend (`backends: ["odatano"]`). Every operation answers the provider shape as a JSON
6
- * string (`value`), so the caller maps it exactly like a Koios or Blockfrost answer.
7
- * Stored blocks and transactions come from this instance's index; everything else goes
8
- * through its own backends and crawled data, as the read service does. Nothing is persisted
9
- * for the caller.
10
- */
1
+ // Backend data for another ODATANO instance that uses this one with `backends: ["odatano"]`.
2
+ // Every operation returns the provider shape as a JSON string, mapped like a Koios answer.
11
3
  @requires: 'authenticated-user'
12
4
  service CardanoBackendService @(impl: './cardano-backend-service') {
13
5
 
@@ -16,21 +8,22 @@ service CardanoBackendService @(impl: './cardano-backend-service') {
16
8
  action GetTransactionsBatch(hashes: LargeString) returns LargeString;
17
9
  action GetTransactionMetadata(hash: String) returns LargeString;
18
10
  action GetBlock(hash: String) returns LargeString;
19
- action GetBlockByHeight(height: Integer64) returns LargeString;
20
- action GetNextBlocks(afterHash: String, count: Integer, afterHeight: Integer64) returns LargeString;
11
+ action GetBlockByHeight(@assert.range: [0, _] height: Integer64) returns LargeString;
12
+ action GetNextBlocks(afterHash: String, @assert.range: [1, 500] count: Integer,
13
+ @assert.range: [0, _] afterHeight: Integer64) returns LargeString;
21
14
  action GetBlockTransactions(blockHash: String) returns LargeString;
22
15
  action GetLatestBlock() returns LargeString;
23
16
  action GetCurrentSlot() returns LargeString;
24
- action GetEpoch(epoch: Integer) returns LargeString;
17
+ action GetEpoch(@assert.range: [0, _] epoch: Integer) returns LargeString;
25
18
  action GetLatestEpoch() returns LargeString;
26
19
 
27
20
  // --- addresses and UTxOs ------------------------------------------------------------------
28
21
  action GetAddress(address: String) returns LargeString;
29
22
  action GetAddressUtxos(address: String) returns LargeString;
30
- action GetAddressTransactions(address: String, limit: Integer) returns LargeString;
31
- action GetAddressTransactionHashes(address: String, limit: Integer) returns LargeString;
23
+ action GetAddressTransactions(address: String, @assert.range: [1, 100] limit: Integer) returns LargeString;
24
+ action GetAddressTransactionHashes(address: String, @assert.range: [1, 100] limit: Integer) returns LargeString;
32
25
  action GetCredentialUtxos(credential: String) returns LargeString;
33
- action IsUtxoUnspent(txHash: String, outputIndex: Integer) returns LargeString;
26
+ action IsUtxoUnspent(txHash: String, @assert.range: [0, _] outputIndex: Integer) returns LargeString;
34
27
  action GetUnspentOutputs(refs: LargeString) returns LargeString;
35
28
 
36
29
  // --- stake, governance, assets, network ------------------------------------------------
@@ -42,7 +35,7 @@ service CardanoBackendService @(impl: './cardano-backend-service') {
42
35
  action GetDrepIds() returns LargeString;
43
36
  action GetDreps(ids: LargeString) returns LargeString;
44
37
  action GetAssetInfo(unit: String) returns LargeString;
45
- action GetAssetHistory(unit: String, limit: Integer) returns LargeString;
38
+ action GetAssetHistory(unit: String, @assert.range: [1, 100] limit: Integer) returns LargeString;
46
39
  action GetNetworkInformation() returns LargeString;
47
40
  action GetProtocolParameters() returns LargeString;
48
41
 
@@ -13,12 +13,8 @@ const stored_chain_1 = require("./blockchain/stored-chain");
13
13
  const logger = cds_1.default.log('CardanoBackendService');
14
14
  /** Largest list one call may ask for (hashes, refs, ids, blocks). */
15
15
  const MAX_LIST = 500;
16
- const MAX_LIMIT = 1000;
17
- /**
18
- * CardanoBackendService: the provider shape for another ODATANO instance. Stored blocks and
19
- * transactions come from the index; the rest goes through the indexer's resolvers (crawled data
20
- * first, then this instance's backends). Answers are JSON strings (safeJSON keeps big integers).
21
- */
16
+ // Provider-shaped answers for another ODATANO instance. Stored blocks and txs come from the index.
17
+ // The rest goes through the indexer's resolvers. Answers are JSON strings so big integers survive.
22
18
  module.exports = (srv) => {
23
19
  const client = () => (0, server_1.getCardanoClient)();
24
20
  const indexer = () => (0, server_1.getCardanoIndexer)();
@@ -38,7 +34,8 @@ module.exports = (srv) => {
38
34
  (0, errors_1.rejectInvalid)(req, req.event, `Invalid ${what}`, field);
39
35
  };
40
36
  const both = (...checks) => (req, data) => checks.forEach(c => c(req, data));
41
- const limitOf = (data, fallback) => Math.min(Math.max(Number(data.limit) || fallback, 1), MAX_LIMIT);
37
+ // the model range-checks limit and count, so only the default is set here
38
+ const limitOf = (data, fallback) => (data.limit == null ? fallback : Number(data.limit));
42
39
  const jsonList = (field, check, what) => (req, data) => {
43
40
  if (data[field] == null)
44
41
  (0, errors_1.rejectMissing)(req, req.event, field);
@@ -117,7 +114,7 @@ module.exports = (srv) => {
117
114
  return paging.getBlockByHeight(Number(height));
118
115
  }, need(v => Number.isInteger(Number(v)) && Number(v) >= 0, 'height', 'height'));
119
116
  op('GetNextBlocks', async ({ afterHash, count, afterHeight }, db) => {
120
- const n = Math.min(Math.max(Number(count) || 1, 1), MAX_LIST);
117
+ const n = count == null ? 1 : Number(count);
121
118
  const anchor = await (0, stored_chain_1.readBlock)(db, String(afterHash));
122
119
  if (anchor?.height != null) {
123
120
  const next = await (0, stored_chain_1.readNextBlocks)(db, anchor.height, n);
@@ -211,10 +208,8 @@ module.exports = (srv) => {
211
208
  logger.info(`submitted ${hash} for a remote instance`);
212
209
  return hash;
213
210
  }, cbor);
214
- /**
215
- * The full pool and DRep set: an enumerating backend (Koios) when configured, else the node's
216
- * ledger at the latest block (Ogmios). Cached for a minute; callers page through it by id.
217
- */
211
+ // The full pool and DRep set, from Koios when configured, else from the Ogmios ledger.
212
+ // Cached for a minute. Details are read in batches of ids.
218
213
  let enumerated = null;
219
214
  async function enumeration() {
220
215
  if (enumerated && Date.now() - enumerated.at < 60_000)
@@ -1,33 +1,15 @@
1
+ using { UtxoSetImportSource } from '../db/types';
1
2
  using {odatano.cardano as db} from '../db/schema';
2
3
 
3
- /**
4
- * Cardano Indexer Service (v2.0)
5
- *
6
- * Control + observability surface for the chain crawler / pre-sync engine:
7
- * - read-only projections of the sync cursor and reorg audit log
8
- * - status function + pause/resume actions delegating to the crawler singleton
9
- *
10
- * Security note: see CardanoODataService (cardano-service.cds) for the rationale on
11
- * auth. pause/resume are operational actions — gate behind a dedicated Admin scope.
12
- * Read-only status and audit data remain available to authenticated users.
13
- *
14
- * Deliberately NO service-level @requires: CAP checks a service-level requirement
15
- * on every request BEFORE the operation's own annotation, so an operation-level
16
- * `@requires: 'any'` can never open a single function on an otherwise
17
- * authenticated service (anonymous callers get the 401 challenge first). The
18
- * requirement therefore sits on each element, and getLiveness() alone is 'any'.
19
- */
20
- // Service-level 'any' on purpose: CAP authorizes the service BEFORE the operation and
21
- // treats a service without a service-level @requires as authenticated-user under
22
- // NODE_ENV=production, which would 401 the anonymous operation below despite its own
23
- // 'any'. Every element carries its requirement; the service itself refuses nothing.
4
+ // Crawler control and status. The service itself is 'any': CAP checks the service before the
5
+ // operation, so anything stricter would 401 the anonymous getLiveness. Each element carries its own requirement.
24
6
  @requires: 'any'
25
7
  service CardanoIndexerService @(impl: './cardano-indexer-service') {
26
8
 
27
9
  @readonly
28
10
  @requires : 'authenticated-user'
29
11
  @title : 'Sync State'
30
- @description: 'Singleton crawl cursor — pre-sync progress, tip lag, status, errors'
12
+ @description: 'Singleton crawl cursor: pre-sync progress, tip lag, status, errors'
31
13
  entity SyncState as projection on db.CardanoSyncState;
32
14
 
33
15
  @readonly
@@ -41,15 +23,17 @@ service CardanoIndexerService @(impl: './cardano-indexer-service') {
41
23
  type CrawlerStatus {
42
24
  running : Boolean;
43
25
  syncStatus : String;
44
- // 'chain-sync' | 'pagination' for the crawler in this process; null when this
45
- // instance is not the one crawling. Pagination is ~50x slower, and a crawl that
46
- // degraded to it still advances the cursor — this is how an operator tells.
26
+ // chain-sync or pagination for the crawler in this process, null when another instance crawls.
27
+ // Pagination is about 50x slower but still advances the cursor, so only this field shows it.
47
28
  source : String;
48
29
  lastSlot : String;
49
30
  lastHeight : String;
50
31
  tipHeight : String;
51
32
  syncProgress : String;
52
33
  consecutiveErrors : Integer;
34
+ lastIndexedAt : Timestamp; // when the last block was committed
35
+ // true: the crawler holds its lease but committed no block for 10 minutes
36
+ stalled : Boolean;
53
37
  // crawler-fed ledger state (crawler.utxoSet): snapshot anchor + validity
54
38
  utxoSet : UtxoSetStatus;
55
39
  // one-off certificate/withdrawal backfill over already crawled blocks (this process)
@@ -168,11 +152,7 @@ service CardanoIndexerService @(impl: './cardano-indexer-service') {
168
152
 
169
153
  @title : 'Get Crawler Status'
170
154
  @description: 'Return the current crawler run state and sync progress'
171
- /**
172
- * Emitted AFTER each block is committed. Subscribe instead of polling:
173
- * (await cds.connect.to('CardanoIndexerService')).on('blockIndexed', ({ data }) => …)
174
- * In-process (plugin mode) this needs no messaging service.
175
- */
155
+ /** Emitted after each block is committed. In plugin mode subscribing needs no messaging service. */
176
156
  event blockIndexed {
177
157
  hash : String(64);
178
158
  slot : Integer64;
@@ -201,10 +181,8 @@ service CardanoIndexerService @(impl: './cardano-indexer-service') {
201
181
  network : String; // configured network
202
182
  }
203
183
 
204
- // Anonymous on purpose: a liveness probe carries no credentials. 200 as long
205
- // as the process answers — no backend or DB probe, no secrets, no backend
206
- // names, no API key state. Readiness stays with getStatus and the worker
207
- // status, which remain authenticated.
184
+ // Anonymous on purpose, since a liveness probe carries no credentials.
185
+ // It probes no backend or DB and reveals no secrets. Readiness stays with the authenticated getStatus.
208
186
  @title : 'Get Liveness'
209
187
  @description: 'Unauthenticated liveness probe: 200 while the process answers. Docker HEALTHCHECK and upstream probes use this instead of the service document.'
210
188
  @requires : 'any'
@@ -223,17 +201,18 @@ service CardanoIndexerService @(impl: './cardano-indexer-service') {
223
201
  @title : 'Import UTxO Set'
224
202
  @description: 'One-off import of the UTxO set that anchors crawler.utxoSet. Pause the crawler first. source=ogmios acquires the set at the crawler cursor (crawl must be at the tip); source=file loads a cardano-cli query utxo --whole-utxo dump (.json, or .ndjson from jq -c to_entries[]) taken at anchorSlot/anchorHash. source=aggregates rebuilds only the sums (LedgerAddresses, LedgerAddressAssets, LedgerAccounts) from the rows an earlier import left, e.g. after its aggregate phase failed; a cursor past the anchor is set back to it. source=scripts fills the reference-script columns (utxo_referenceScriptHash, utxo_referenceScriptSize, utxo_referenceScriptType) of rows an earlier import left empty: from the same dump (filePath), or without filePath from Ogmios for the unspent rows that hold a hash but no size; the set stays active. Runs in the background; progress via getStatus().utxoSet and the log.'
225
203
  @requires : 'Admin'
226
- action importUtxoSet(source: String, filePath: String, anchorSlot: Integer64, anchorHash: String) returns UtxoSetImportResult;
204
+ action importUtxoSet(@assert.range source: UtxoSetImportSource, filePath: String,
205
+ @assert.range: [0, _] anchorSlot: Integer64, anchorHash: String) returns UtxoSetImportResult;
227
206
 
228
207
  @title : 'Backfill Certificates'
229
208
  @description: 'Fill TransactionCertificates and TransactionWithdrawals for blocks the crawl already holds, from a second chain-sync stream (Ogmios). fromSlot defaults to the crawl start, toSlot to the cursor. Writes only those two tables; the crawler may keep running. Runs in the background; progress via getStatus().certificateBackfill.'
230
209
  @requires : 'Admin'
231
- action backfillCertificates(fromSlot: Integer64, toSlot: Integer64) returns CertificateBackfillResult;
210
+ action backfillCertificates(@assert.range: [0, _] fromSlot: Integer64, @assert.range: [0, _] toSlot: Integer64) returns CertificateBackfillResult;
232
211
 
233
212
  @title : 'Backfill Transactions'
234
213
  @description: 'Complete transactions the crawl already holds from a second chain-sync stream (Ogmios): input outpoints, the spent output datum and reference-script hash, missing input addresses, TransactionRedeemers and TransactionDatums. Fills empty fields only; a transaction whose stored inputs differ from the stream is skipped. fromSlot defaults to the crawl start, toSlot to the cursor; the crawler may keep running. Runs in the background; progress via getStatus().transactionBackfill.'
235
214
  @requires : 'Admin'
236
- action backfillTransactions(fromSlot: Integer64, toSlot: Integer64) returns CertificateBackfillResult;
215
+ action backfillTransactions(@assert.range: [0, _] fromSlot: Integer64, @assert.range: [0, _] toSlot: Integer64) returns CertificateBackfillResult;
237
216
 
238
217
  @title : 'Backfill Payment Credentials'
239
218
  @description: 'Fill utxo.paymentCredential on TransactionOutputs, TransactionInputs and LedgerUTxOs rows written before the column existed, decoded from the stored address. Walks each table once in key order; rows that carry a credential are left alone, so a second run is a no-op. No backend call; the crawler may keep running. Runs in the background; progress via getStatus().credentialBackfill.'
@@ -1,2 +1,6 @@
1
- export {};
1
+ import { type SyncCursor } from './blockchain/crawler/sync-state';
2
+ /** No block committed for this long while the crawler holds its lease: it is stuck. */
3
+ export declare const CRAWLER_STALL_MS: number;
4
+ /** A crawler that holds the lease but has committed no block within CRAWLER_STALL_MS. */
5
+ export declare function isCrawlerStalled(cursor: SyncCursor | null, now?: number): boolean;
2
6
  //# sourceMappingURL=cardano-indexer-service.d.ts.map
@@ -3,6 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CRAWLER_STALL_MS = void 0;
7
+ exports.isCrawlerStalled = isCrawlerStalled;
6
8
  const cds_1 = __importDefault(require("@sap/cds"));
7
9
  const backend_request_handler_1 = require("./utils/backend-request-handler");
8
10
  const errors_1 = require("./utils/errors");
@@ -42,13 +44,13 @@ let decimalsBackfill = {
42
44
  async function backfillRange(db, data) {
43
45
  const cursor = await (0, sync_state_1.readCursor)(db);
44
46
  if (!cursor)
45
- throw new errors_1.TransactionValidationError('No crawler cursor yet — the backfill covers crawled blocks only.');
47
+ throw new errors_1.TransactionValidationError('No crawler cursor yet. The backfill covers crawled blocks only.');
46
48
  const fromSlot = data.fromSlot != null ? Number(data.fromSlot) : (cursor.startSlot ?? 0);
47
49
  const toSlot = data.toSlot != null ? Number(data.toSlot) : cursor.lastSlot;
48
50
  if (toSlot < fromSlot)
49
51
  throw new errors_1.TransactionValidationError(`toSlot ${toSlot} lies before fromSlot ${fromSlot}.`);
50
52
  if (toSlot > cursor.lastSlot)
51
- throw new errors_1.TransactionValidationError(`toSlot ${toSlot} is past the crawler cursor (slot ${cursor.lastSlot}) — only crawled blocks can be backfilled.`);
53
+ throw new errors_1.TransactionValidationError(`toSlot ${toSlot} is past the crawler cursor (slot ${cursor.lastSlot}). Only crawled blocks can be backfilled.`);
52
54
  return { fromSlot, toSlot };
53
55
  }
54
56
  function utxoSetConfigured() {
@@ -79,14 +81,19 @@ function epochSnapshotSource() {
79
81
  return null;
80
82
  }
81
83
  }
82
- /**
83
- * CardanoIndexerService handlers: control/observability surface over the crawler
84
- * singleton (srv/blockchain/crawler). Reads the cursor and starts/stops the crawler.
85
- */
84
+ /** No block committed for this long while the crawler holds its lease: it is stuck. */
85
+ exports.CRAWLER_STALL_MS = 10 * 60 * 1000;
86
+ /** A crawler that holds the lease but has committed no block within CRAWLER_STALL_MS. */
87
+ function isCrawlerStalled(cursor, now = Date.now()) {
88
+ if (!cursor || !(0, sync_state_1.isCrawlerLeaseActive)(cursor) || !cursor.lastIndexedAt)
89
+ return false;
90
+ return now - Date.parse(cursor.lastIndexedAt) > exports.CRAWLER_STALL_MS;
91
+ }
92
+ /** CardanoIndexerService handlers. They read the crawler cursor and start or stop the crawler. */
86
93
  module.exports = (srv) => {
87
- // getLiveness — unauthenticated probe (@requires: 'any'); no handleRequest, no app context.
94
+ // getLiveness: unauthenticated probe. No handleRequest and no app context.
88
95
  srv.on('getLiveness', async () => (0, liveness_1.buildLiveness)());
89
- // getStatus — live run state + sync progress (numeric fields as strings, CAP 10 convention)
96
+ // getStatus: run state and sync progress. Numeric fields are strings, as CAP 10 serializes them.
90
97
  srv.on('getStatus', async (req) => {
91
98
  return (0, backend_request_handler_1.handleRequest)(req, async (db) => {
92
99
  const cursor = await (0, sync_state_1.readCursor)(db);
@@ -104,6 +111,8 @@ module.exports = (srv) => {
104
111
  tipHeight: String(tipHeight),
105
112
  syncProgress: progress.toFixed(2),
106
113
  consecutiveErrors: cursor?.consecutiveErrors ?? 0,
114
+ lastIndexedAt: cursor?.lastIndexedAt ?? null,
115
+ stalled: isCrawlerStalled(cursor),
107
116
  utxoSet: {
108
117
  enabled: utxoSetConfigured(),
109
118
  status: utxoSetImportInFlight ? 'importing' : (cursor?.utxoSet?.status ?? 'none'),
@@ -152,8 +161,8 @@ module.exports = (srv) => {
152
161
  };
153
162
  });
154
163
  });
155
- // backfillCertificates — second chain-sync stream over already crawled blocks; writes the
156
- // certificate and withdrawal tables only. Validates, then runs detached.
164
+ // backfillCertificates: a second chain-sync stream over crawled blocks.
165
+ // Writes only the certificate and withdrawal tables and runs detached.
157
166
  srv.on('backfillCertificates', async (req) => {
158
167
  const data = (req.data ?? {});
159
168
  if (data.fromSlot != null && !Number.isInteger(Number(data.fromSlot)))
@@ -198,8 +207,8 @@ module.exports = (srv) => {
198
207
  certificateBackfillStarting = false;
199
208
  }
200
209
  });
201
- // backfillTransactions — second chain-sync stream over already crawled blocks; fills empty
202
- // input fields (outpoint, datum, address) and the redeemers. Validates, then runs detached.
210
+ // backfillTransactions: a second chain-sync stream over crawled blocks.
211
+ // Fills empty input fields and the redeemers and runs detached.
203
212
  srv.on('backfillTransactions', async (req) => {
204
213
  const data = (req.data ?? {});
205
214
  if (data.fromSlot != null && !Number.isInteger(Number(data.fromSlot)))
@@ -244,8 +253,8 @@ module.exports = (srv) => {
244
253
  transactionBackfillStarting = false;
245
254
  }
246
255
  });
247
- // backfillPaymentCredentials — walks the UTxO-shaped tables once and fills the credential
248
- // from the stored address. No backend; runs detached, progress via getStatus().credentialBackfill.
256
+ // backfillPaymentCredentials: fills the credential from the stored address in every UTxO table.
257
+ // Needs no backend and runs detached. Progress is in getStatus().credentialBackfill.
249
258
  srv.on('backfillPaymentCredentials', async (req) => {
250
259
  if (credentialBackfill.status === 'running')
251
260
  return (0, errors_1.rejectInvalid)(req, 'backfillPaymentCredentials', 'A payment-credential backfill is already running');
@@ -261,8 +270,8 @@ module.exports = (srv) => {
261
270
  });
262
271
  return { accepted: true, message: 'Payment-credential backfill started; poll getStatus().credentialBackfill.' };
263
272
  });
264
- // backfillAssetDecimals — resolves the CIP-68 reference datum of every label-333/444 catalogue
265
- // unit from the crawled chain. No backend; runs detached, progress via getStatus().decimalsBackfill.
273
+ // backfillAssetDecimals: reads the CIP-68 reference datum of every label 333 and 444 unit.
274
+ // Needs no backend and runs detached. Progress is in getStatus().decimalsBackfill.
266
275
  srv.on('backfillAssetDecimals', async (req) => {
267
276
  if (decimalsBackfill.status === 'running')
268
277
  return (0, errors_1.rejectInvalid)(req, 'backfillAssetDecimals', 'An asset-decimals backfill is already running');
@@ -278,20 +287,20 @@ module.exports = (srv) => {
278
287
  });
279
288
  return { accepted: true, message: 'Asset-decimals backfill started; poll getStatus().decimalsBackfill.' };
280
289
  });
281
- // importUtxoSet — one-off snapshot import that anchors crawler.utxoSet. Validates, then
282
- // runs detached; progress via getStatus().utxoSet.
290
+ // importUtxoSet: one-off snapshot import that anchors crawler.utxoSet.
291
+ // Runs detached. Progress is in getStatus().utxoSet.
283
292
  srv.on('importUtxoSet', async (req) => {
284
293
  const data = (req.data ?? {});
285
294
  if (data.source === 'aggregates') {
286
295
  if ((0, crawler_1.isCrawlerRunning)())
287
- return (0, errors_1.rejectInvalid)(req, 'importUtxoSet', 'Crawler is running in this process — pauseCrawler first');
296
+ return (0, errors_1.rejectInvalid)(req, 'importUtxoSet', 'Crawler is running in this process. Run pauseCrawler first');
288
297
  if (utxoSetImportInFlight)
289
298
  return (0, errors_1.rejectInvalid)(req, 'importUtxoSet', 'A UTxO set import is already running');
290
299
  return (0, backend_request_handler_1.handleRequest)(req, async (db) => {
291
300
  const cursor = await (0, sync_state_1.readCursor)(db);
292
301
  const { anchorSlot, anchorHash } = cursor?.utxoSet ?? {};
293
302
  if (anchorSlot == null || !anchorHash)
294
- throw new errors_1.TransactionValidationError('No imported UTxO set to rebuild the sums from — run importUtxoSet first.');
303
+ throw new errors_1.TransactionValidationError('No imported UTxO set to rebuild the sums from. Run importUtxoSet first.');
295
304
  utxoSetImportInFlight = (0, utxo_set_import_1.rebuildUtxoSetAggregates)({ indexer: (0, server_1.getCardanoIndexer)() })
296
305
  .then((r) => logger.info(`UTxO set sums rebuilt: ${r.utxos} rows at ${r.anchor.slot}/${r.anchor.hash}`))
297
306
  .catch((err) => logger.error(`UTxO set aggregate rebuild failed: ${err instanceof Error ? err.message : String(err)}`))
@@ -306,14 +315,14 @@ module.exports = (srv) => {
306
315
  }
307
316
  if (data.source === 'scripts') {
308
317
  if ((0, crawler_1.isCrawlerRunning)())
309
- return (0, errors_1.rejectInvalid)(req, 'importUtxoSet', 'Crawler is running in this process — pauseCrawler first');
318
+ return (0, errors_1.rejectInvalid)(req, 'importUtxoSet', 'Crawler is running in this process. Run pauseCrawler first');
310
319
  if (utxoSetImportInFlight)
311
320
  return (0, errors_1.rejectInvalid)(req, 'importUtxoSet', 'A UTxO set import is already running');
312
321
  return (0, backend_request_handler_1.handleRequest)(req, async (db) => {
313
322
  const cursor = await (0, sync_state_1.readCursor)(db);
314
323
  const { anchorSlot, anchorHash } = cursor?.utxoSet ?? {};
315
324
  if (anchorSlot == null || !anchorHash)
316
- throw new errors_1.TransactionValidationError('No imported UTxO set to fill — run importUtxoSet first.');
325
+ throw new errors_1.TransactionValidationError('No imported UTxO set to fill. Run importUtxoSet first.');
317
326
  utxoSetImportInFlight = (0, utxo_set_import_1.refreshUtxoSetReferenceScripts)({ filePath: data.filePath, client: (0, server_1.getCardanoClient)() })
318
327
  .then((r) => logger.info(`UTxO set reference scripts filled: ${r.updated} of ${r.candidates} rows`))
319
328
  .catch((err) => logger.error(`UTxO set reference-script fill failed: ${err instanceof Error ? err.message : String(err)}`))
@@ -326,9 +335,10 @@ module.exports = (srv) => {
326
335
  };
327
336
  });
328
337
  }
329
- const source = data.source === 'file' || data.source === 'ogmios' ? data.source : null;
330
- if (!source)
331
- return (0, errors_1.rejectInvalid)(req, 'importUtxoSet', 'source must be "ogmios", "file", "aggregates" or "scripts"', 'source');
338
+ // the model rejects an unknown source and a negative anchorSlot
339
+ const source = data.source;
340
+ if (source !== 'file' && source !== 'ogmios')
341
+ return (0, errors_1.rejectMissing)(req, 'importUtxoSet', 'source');
332
342
  if (source === 'file' && !data.filePath)
333
343
  return (0, errors_1.rejectMissing)(req, 'importUtxoSet', 'filePath');
334
344
  const anchorGiven = data.anchorSlot != null || !!data.anchorHash;
@@ -339,22 +349,22 @@ module.exports = (srv) => {
339
349
  return (0, errors_1.rejectInvalid)(req, 'importUtxoSet', 'anchorSlot must be an integer and anchorHash a 64-hex block hash', 'anchorHash');
340
350
  }
341
351
  if ((0, crawler_1.isCrawlerRunning)())
342
- return (0, errors_1.rejectInvalid)(req, 'importUtxoSet', 'Crawler is running in this process — pauseCrawler first');
352
+ return (0, errors_1.rejectInvalid)(req, 'importUtxoSet', 'Crawler is running in this process. Run pauseCrawler first');
343
353
  if (utxoSetImportInFlight)
344
354
  return (0, errors_1.rejectInvalid)(req, 'importUtxoSet', 'A UTxO set import is already running');
345
355
  return (0, backend_request_handler_1.handleRequest)(req, async (db) => {
346
356
  const cursor = await (0, sync_state_1.readCursor)(db);
347
357
  if (!cursor)
348
- throw new errors_1.TransactionValidationError('No crawler cursor yet — start the crawler once before importing.');
358
+ throw new errors_1.TransactionValidationError('No crawler cursor yet. Start the crawler once before importing.');
349
359
  if ((0, sync_state_1.isCrawlerLeaseActive)(cursor))
350
- throw new errors_1.TransactionValidationError('Crawler is running (active lease) — pauseCrawler first.');
360
+ throw new errors_1.TransactionValidationError('Crawler is running (active lease). Run pauseCrawler first.');
351
361
  const anchor = anchorGiven
352
362
  ? { slot: Number(data.anchorSlot), hash: String(data.anchorHash).toLowerCase() }
353
363
  : { slot: cursor.lastSlot, hash: cursor.lastBlockHash ?? '' };
354
364
  if (!anchor.hash)
355
- throw new errors_1.TransactionValidationError('Cursor has no block hash yet — pass anchorSlot + anchorHash.');
365
+ throw new errors_1.TransactionValidationError('Cursor has no block hash yet. Pass anchorSlot + anchorHash.');
356
366
  if (cursor.lastSlot > anchor.slot) {
357
- throw new errors_1.TransactionValidationError(`Crawler cursor (slot ${cursor.lastSlot}) is past the anchor (slot ${anchor.slot}) — dump the set at or after the cursor.`);
367
+ throw new errors_1.TransactionValidationError(`Crawler cursor (slot ${cursor.lastSlot}) is past the anchor (slot ${anchor.slot}). Dump the set at or after the cursor.`);
358
368
  }
359
369
  utxoSetImportInFlight = (0, utxo_set_import_1.importUtxoSet)({
360
370
  source, filePath: data.filePath, anchor,
@@ -373,7 +383,7 @@ module.exports = (srv) => {
373
383
  };
374
384
  });
375
385
  });
376
- // pauseCrawler — stop the stream; the cursor is preserved so resume continues.
386
+ // pauseCrawler: stops the stream. The cursor is kept, so resume continues from it.
377
387
  srv.on('pauseCrawler', async (req) => {
378
388
  return (0, backend_request_handler_1.handleRequest)(req, async () => {
379
389
  await (0, crawler_1.stopCrawler)(true);
@@ -381,9 +391,8 @@ module.exports = (srv) => {
381
391
  return true;
382
392
  });
383
393
  });
384
- // resumeCrawler — (re)start from the persisted cursor. Gated on config.enabled so an
385
- // unconfigured crawler is never started (it would sync from genesis). Resume on a running
386
- // crawler is a no-op; pauseCrawler first to apply changed config.
394
+ // resumeCrawler: starts from the stored cursor, only when enabled, since otherwise it would sync from genesis.
395
+ // A no-op on a running crawler. Pause first to apply changed config.
387
396
  srv.on('resumeCrawler', async (req) => {
388
397
  let config;
389
398
  try {
@@ -394,7 +403,7 @@ module.exports = (srv) => {
394
403
  return (0, errors_1.rejectInvalid)(req, 'resumeCrawler', err instanceof Error ? err.message : String(err));
395
404
  }
396
405
  if (!config.enabled) {
397
- return (0, errors_1.rejectInvalid)(req, 'resumeCrawler', 'Crawler is not enabled — set cds.requires.odatano-core.crawler.enabled (or CRAWLER_ENABLED=true) with a start block before resuming.');
406
+ return (0, errors_1.rejectInvalid)(req, 'resumeCrawler', 'Crawler is not enabled. Set cds.requires.odatano-core.crawler.enabled (or CRAWLER_ENABLED=true) with a start block before resuming.');
398
407
  }
399
408
  return (0, backend_request_handler_1.handleRequest)(req, async () => {
400
409
  const client = (0, server_1.getCardanoClient)();
@@ -1,35 +1,8 @@
1
1
  using {odatano.cardano as db} from '../db/schema';
2
2
  using { Blake2b256, Bech32, AssetUnit, ParsedTransaction, TransactionConfirmations } from '../db/types';
3
3
 
4
- /**
5
- * Cardano OData Service
6
- *
7
- * Handles external read-only queries for Cardano blockchain data, including:
8
- * - Retrieving network information, blocks, epochs, pools, dreps, transactions, accounts, addresses, UTxOs, assets, and metadata
9
- * - Providing actions for fetching specific data by identifiers (hashes, addresses, etc.) and for retrieving the latest blockchain state (latest block, epoch, protocol parameters)
10
- *
11
- * ## Security: Authentication & Authorization
12
- *
13
- * All services use `@requires: 'authenticated-user'` (service-level gate).
14
- * The XSUAA scopes defined in xs-security.json (Read, Transact, Sign) are available
15
- * for consumer-level role assignment but are NOT enforced per-action in ODATANO itself.
16
- *
17
- * This is intentional — ODATANO is a blockchain bridge, not a multi-tenant application.
18
- * Per-resource ownership checks (IDOR prevention) are deliberately omitted because:
19
- *
20
- * 1. **Blockchain security model**: Unsigned transaction CBOR is not exploitable without
21
- * the corresponding private key. Viewing a build/signing request does not enable
22
- * fund theft — only the key holder can sign and submit.
23
- *
24
- * 2. **Cross-address operations are legitimate**: Smart contract interactions routinely
25
- * require building transactions for addresses the caller does not own — e.g. script
26
- * redemptions, multi-party Plutus workflows, or DApp backends building on behalf of users.
27
- * Enforcing sender == authenticated user would break these use cases.
28
- *
29
- * 3. **Consumer responsibility**: Consumers deploying ODATANO in multi-user environments
30
- * should add their own authorization layer (e.g. `@restrict` annotations, custom
31
- * middleware) that maps JWT claims to allowed wallet addresses if needed.
32
- */
4
+ // Read queries for Cardano chain data. Every operation needs an authenticated user;
5
+ // per-address ownership is not checked (docs/guides/SECURITY_GUIDE.md).
33
6
  @requires: 'authenticated-user'
34
7
  @path: '/odata/v4/cardano'
35
8
  service CardanoODataService @(impl: './cardano-service') {
@@ -217,6 +190,7 @@ service CardanoODataService @(impl: './cardano-service') {
217
190
  action GetEpochByNumber(
218
191
  @title: 'Epoch Number'
219
192
  @description: 'The sequential number of the epoch'
193
+ @assert.range: [0, _]
220
194
  epochNumber: Integer) returns Epochs;
221
195
 
222
196
  @title : 'Get Pools by Pool Id'
@@ -234,21 +208,26 @@ service CardanoODataService @(impl: './cardano-service') {
234
208
  drepId: String) returns Dreps;
235
209
 
236
210
  @title : 'Get Asset Info'
237
- @description: 'Retrieve native-asset information (supply, mint history, CIP-25 + CIP-26 metadata) by unit. Multi-backend (Blockfrost, Koios). Field availability differs slightly per backend — see entity description.'
211
+ @description: 'Retrieve native-asset information (supply, mint history, CIP-25 + CIP-26 metadata) by unit. Multi-backend (Blockfrost, Koios). Field availability differs slightly per backend; see entity description.'
238
212
  action GetAssetInfo(
239
213
  @title: 'Asset Unit'
240
214
  @description: 'Concatenation of policyId (56 hex) and assetNameHex (0-64 hex; ledger caps asset names at 32 bytes)'
241
215
  unit: AssetUnit) returns Assets;
242
216
 
243
217
  @title : 'Get Asset Mint/Burn History'
244
- @description: 'Retrieve recent mint/burn events for a native asset (most recent first). Koios is preferred (provides block timestamps); Blockfrost is the fallback (timestamps null). Always-fresh fetch — UPSERTs entries by (unit, txHash). For full pagination, query the AssetHistory entity directly with $top/$skip after seeding.'
218
+ @description: 'Retrieve recent mint/burn events for a native asset, newest first. Koios is preferred (provides block timestamps); Blockfrost is the fallback (timestamps null). Always-fresh fetch, UPSERTs entries by (unit, txHash). skip + limit covers at most the newest 100 events; older events are read from the AssetHistory entity with $top/$skip.'
245
219
  action GetAssetHistory(
246
220
  @title: 'Asset Unit'
247
221
  @description: 'Concatenation of policyId (56 hex) and assetNameHex (0-64 hex; ledger caps asset names at 32 bytes)'
248
222
  unit: AssetUnit,
249
223
  @title: 'Limit'
250
- @description: 'Maximum number of recent events to fetch (default 100, clamped to 1-100)'
251
- limit: Integer) returns many AssetHistory;
224
+ @description: 'Maximum number of rows (default 100, at most 100)'
225
+ @assert.range: [1, 100]
226
+ limit: Integer,
227
+ @title: 'Skip'
228
+ @description: 'Number of rows to skip (default 0)'
229
+ @assert.range: [0, 99]
230
+ skip: Integer) returns many AssetHistory;
252
231
 
253
232
  @title : 'Get Accounts by Stake Address'
254
233
  @description: 'Retrieve account information using the Bech32 Stake Address'
@@ -276,7 +255,15 @@ service CardanoODataService @(impl: './cardano-service') {
276
255
  action GetMetadataByTxHash(
277
256
  @title: 'Transaction Hash'
278
257
  @description: 'The unique identifier of the transaction'
279
- txHash: Blake2b256) returns many TransactionMetadata;
258
+ txHash: Blake2b256,
259
+ @title: 'Limit'
260
+ @description: 'Maximum number of rows (default 1000, at most 5000)'
261
+ @assert.range: [1, 5000]
262
+ limit: Integer,
263
+ @title: 'Skip'
264
+ @description: 'Number of rows to skip (default 0)'
265
+ @assert.range: [0, _]
266
+ skip: Integer) returns many TransactionMetadata;
280
267
 
281
268
  @title : 'Get Addresses by Bech32 Address'
282
269
  @description: 'Retrieve address information using the Bech32 Address'
@@ -290,31 +277,60 @@ service CardanoODataService @(impl: './cardano-service') {
290
277
  action GetUTxOsByAddress(
291
278
  @title: 'Bech32 Address'
292
279
  @description: 'The Bech32 encoded address'
293
- address: Bech32) returns many AddressUTxOs;
280
+ address: Bech32,
281
+ @title: 'Limit'
282
+ @description: 'Maximum number of rows (default 1000, at most 5000)'
283
+ @assert.range: [1, 5000]
284
+ limit: Integer,
285
+ @title: 'Skip'
286
+ @description: 'Number of rows to skip (default 0)'
287
+ @assert.range: [0, _]
288
+ skip: Integer) returns many AddressUTxOs;
294
289
 
295
290
  @title : 'Get UTxOs by Payment Credential'
296
291
  @description: 'Retrieve UTxOs across all bech32 addresses sharing the given 28-byte payment credential (key hash or script hash). Useful for protocols that write to multiple bech32 forms of the same script (e.g. Indigo CDPs, Liqwid positions). Served from the crawled UTxO set (crawler.utxoSet active and synced) with outputs read from the node at the tip, else from Koios; throws ProviderUnavailableError when neither is available. Always fresh, no cache check.'
297
292
  action GetUTxOsByCredential(
298
293
  @title: 'Payment Credential'
299
294
  @description: '28-byte payment credential hash as 56-char lowercase hex string'
300
- credential: String) returns many AddressUTxOs;
295
+ credential: String,
296
+ @title: 'Limit'
297
+ @description: 'Maximum number of rows (default 1000, at most 5000)'
298
+ @assert.range: [1, 5000]
299
+ limit: Integer,
300
+ @title: 'Skip'
301
+ @description: 'Number of rows to skip (default 0)'
302
+ @assert.range: [0, _]
303
+ skip: Integer) returns many AddressUTxOs;
301
304
 
302
305
  @title : 'Get Assets by Bech32 Address'
303
306
  @description: 'Retrieve asset information using the Bech32 Address'
304
307
  action GetAssetsByAddress(
305
308
  @title: 'Bech32 Address'
306
309
  @description: 'The Bech32 encoded address'
307
- address: Bech32) returns many AddressAssets;
310
+ address: Bech32,
311
+ @title: 'Limit'
312
+ @description: 'Maximum number of rows (default 1000, at most 5000)'
313
+ @assert.range: [1, 5000]
314
+ limit: Integer,
315
+ @title: 'Skip'
316
+ @description: 'Number of rows to skip (default 0)'
317
+ @assert.range: [0, _]
318
+ skip: Integer) returns many AddressAssets;
308
319
 
309
320
  @title : 'Get latest Transactions by Bech32 Address'
310
- @description: 'Retrieve the latest transactions from the Bech32 Address'
321
+ @description: 'Retrieve the latest transactions of the Bech32 Address, newest first. skip + limit covers at most the newest 100 transactions.'
311
322
  action GetLatestTransactionsByAddress(
312
323
  @title: 'Bech32 Address'
313
324
  @description: 'The Bech32 encoded address'
314
325
  address: Bech32,
315
326
  @title: 'Limit'
316
- @description: 'The maximum number of transactions to retrieve'
317
- limit: Integer) returns many AddressTransactions;
327
+ @description: 'Maximum number of rows (default 10, at most 100)'
328
+ @assert.range: [1, 100]
329
+ limit: Integer,
330
+ @title: 'Skip'
331
+ @description: 'Number of rows to skip (default 0)'
332
+ @assert.range: [0, 99]
333
+ skip: Integer) returns many AddressTransactions;
318
334
 
319
335
  @title : 'Get Latest Block'
320
336
  @description: 'Retrieve the latest block information'