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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/@cds-models/CardanoAgentService/index.d.ts +99 -51
  2. package/@cds-models/CardanoAgentService/index.js +15 -0
  3. package/@cds-models/CardanoBackendService/index.d.ts +347 -0
  4. package/@cds-models/CardanoBackendService/index.js +40 -0
  5. package/@cds-models/CardanoIndexerService/index.d.ts +496 -11
  6. package/@cds-models/CardanoIndexerService/index.js +64 -0
  7. package/@cds-models/CardanoODataService/index.d.ts +414 -57
  8. package/@cds-models/CardanoODataService/index.js +42 -0
  9. package/@cds-models/CardanoSignService/index.d.ts +32 -19
  10. package/@cds-models/CardanoSignService/index.js +3 -0
  11. package/@cds-models/CardanoTransactionService/index.d.ts +58 -44
  12. package/@cds-models/CardanoTransactionService/index.js +4 -0
  13. package/@cds-models/CardanoWorkerService/index.d.ts +7 -22
  14. package/@cds-models/index.d.ts +101 -1
  15. package/@cds-models/index.js +16 -1
  16. package/@cds-models/odatano/cardano/index.d.ts +437 -32
  17. package/@cds-models/odatano/cardano/index.js +48 -0
  18. package/README.md +207 -167
  19. package/db/schema.cds +2402 -1705
  20. package/db/types.cds +446 -295
  21. package/package.json +41 -16
  22. package/scripts/migrate-schema.mjs +334 -0
  23. package/scripts/migrate-slot-leader.mjs +96 -0
  24. package/src/index.d.ts +20 -21
  25. package/src/index.js +45 -31
  26. package/src/plugin.js +17 -35
  27. package/srv/blockchain/asset-decimals.d.ts +7 -0
  28. package/srv/blockchain/asset-decimals.js +91 -0
  29. package/srv/blockchain/backends/blockfrost-backend.d.ts +25 -135
  30. package/srv/blockchain/backends/blockfrost-backend.js +66 -172
  31. package/srv/blockchain/backends/cardano-backend.d.ts +94 -186
  32. package/srv/blockchain/backends/cardano-backend.js +29 -5
  33. package/srv/blockchain/backends/koios-backend.d.ts +103 -168
  34. package/srv/blockchain/backends/koios-backend.js +428 -360
  35. package/srv/blockchain/backends/odatano-backend.d.ts +54 -0
  36. package/srv/blockchain/backends/odatano-backend.js +169 -0
  37. package/srv/blockchain/backends/ogmios-backend.d.ts +123 -190
  38. package/srv/blockchain/backends/ogmios-backend.js +637 -315
  39. package/srv/blockchain/backends/ogmios-frame-guard.d.ts +14 -0
  40. package/srv/blockchain/backends/ogmios-frame-guard.js +89 -0
  41. package/srv/blockchain/cardano-client.d.ts +61 -241
  42. package/srv/blockchain/cardano-client.js +253 -293
  43. package/srv/blockchain/cardano-indexer.d.ts +282 -281
  44. package/srv/blockchain/cardano-indexer.js +1551 -484
  45. package/srv/blockchain/cardano-tx-builder.d.ts +25 -89
  46. package/srv/blockchain/cardano-tx-builder.js +164 -140
  47. package/srv/blockchain/circuit-breaker.d.ts +1 -13
  48. package/srv/blockchain/circuit-breaker.js +5 -15
  49. package/srv/blockchain/crawler/account-snapshots.d.ts +29 -0
  50. package/srv/blockchain/crawler/account-snapshots.js +153 -0
  51. package/srv/blockchain/crawler/asset-decimals-backfill.d.ts +15 -0
  52. package/srv/blockchain/crawler/asset-decimals-backfill.js +56 -0
  53. package/srv/blockchain/crawler/asset-registry-backfill.d.ts +43 -0
  54. package/srv/blockchain/crawler/asset-registry-backfill.js +153 -0
  55. package/srv/blockchain/crawler/certificate-backfill.d.ts +52 -0
  56. package/srv/blockchain/crawler/certificate-backfill.js +162 -0
  57. package/srv/blockchain/crawler/crawler.d.ts +104 -81
  58. package/srv/blockchain/crawler/crawler.js +532 -160
  59. package/srv/blockchain/crawler/credential-backfill.d.ts +28 -0
  60. package/srv/blockchain/crawler/credential-backfill.js +124 -0
  61. package/srv/blockchain/crawler/hooks.d.ts +2 -17
  62. package/srv/blockchain/crawler/index.d.ts +1 -8
  63. package/srv/blockchain/crawler/index.js +31 -17
  64. package/srv/blockchain/crawler/input-asset-copies.d.ts +34 -0
  65. package/srv/blockchain/crawler/input-asset-copies.js +171 -0
  66. package/srv/blockchain/crawler/metadata-position-backfill.d.ts +16 -0
  67. package/srv/blockchain/crawler/metadata-position-backfill.js +55 -0
  68. package/srv/blockchain/crawler/output-datum-backfill.d.ts +39 -0
  69. package/srv/blockchain/crawler/output-datum-backfill.js +110 -0
  70. package/srv/blockchain/crawler/sync-state.d.ts +27 -47
  71. package/srv/blockchain/crawler/sync-state.js +113 -63
  72. package/srv/blockchain/crawler/transaction-backfill.d.ts +44 -0
  73. package/srv/blockchain/crawler/transaction-backfill.js +278 -0
  74. package/srv/blockchain/crawler/utxo-set-import.d.ts +66 -0
  75. package/srv/blockchain/crawler/utxo-set-import.js +399 -0
  76. package/srv/blockchain/ledger-state.d.ts +62 -0
  77. package/srv/blockchain/ledger-state.js +419 -0
  78. package/srv/blockchain/pending-spends.d.ts +16 -0
  79. package/srv/blockchain/pending-spends.js +81 -0
  80. package/srv/blockchain/pool-metadata.d.ts +15 -0
  81. package/srv/blockchain/pool-metadata.js +132 -0
  82. package/srv/blockchain/request-coalescer.d.ts +2 -16
  83. package/srv/blockchain/request-coalescer.js +2 -16
  84. package/srv/blockchain/signing/cose-verifier.d.ts +3 -17
  85. package/srv/blockchain/signing/cose-verifier.js +146 -70
  86. package/srv/blockchain/signing/external-signer.d.ts +15 -115
  87. package/srv/blockchain/signing/external-signer.js +17 -126
  88. package/srv/blockchain/signing/hsm-signer.d.ts +10 -54
  89. package/srv/blockchain/signing/hsm-signer.js +28 -79
  90. package/srv/blockchain/signing/signature-verifier.d.ts +9 -47
  91. package/srv/blockchain/signing/signature-verifier.js +70 -83
  92. package/srv/blockchain/signing/submission-finalizer.d.ts +23 -45
  93. package/srv/blockchain/signing/submission-finalizer.js +219 -86
  94. package/srv/blockchain/stored-chain.d.ts +20 -0
  95. package/srv/blockchain/stored-chain.js +237 -0
  96. package/srv/blockchain/transaction-building/buildooor-tx.d.ts +31 -229
  97. package/srv/blockchain/transaction-building/buildooor-tx.js +652 -416
  98. package/srv/blockchain/transaction-building/cardano-tx.d.ts +9 -37
  99. package/srv/blockchain/transaction-presence.d.ts +5 -0
  100. package/srv/blockchain/transaction-presence.js +29 -0
  101. package/srv/blockchain/transaction-rows.d.ts +12 -0
  102. package/srv/blockchain/transaction-rows.js +44 -0
  103. package/srv/blockchain/wallet-worker/build-request.d.ts +5 -20
  104. package/srv/blockchain/wallet-worker/build-request.js +47 -30
  105. package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +5 -46
  106. package/srv/blockchain/wallet-worker/confirmation-tracker.js +25 -45
  107. package/srv/blockchain/wallet-worker/index.d.ts +1 -1
  108. package/srv/blockchain/wallet-worker/index.js +3 -11
  109. package/srv/blockchain/wallet-worker/job-store.d.ts +30 -148
  110. package/srv/blockchain/wallet-worker/job-store.js +101 -201
  111. package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +2 -26
  112. package/srv/blockchain/wallet-worker/lease-heartbeat.js +6 -28
  113. package/srv/blockchain/wallet-worker/signers.d.ts +5 -24
  114. package/srv/blockchain/wallet-worker/signers.js +4 -12
  115. package/srv/blockchain/wallet-worker/wallet-worker.d.ts +8 -80
  116. package/srv/blockchain/wallet-worker/wallet-worker.js +107 -155
  117. package/srv/cardano-agent-service.cds +122 -84
  118. package/srv/cardano-agent-service.js +4 -9
  119. package/srv/cardano-backend-service.cds +78 -0
  120. package/srv/cardano-backend-service.d.ts +2 -0
  121. package/srv/cardano-backend-service.js +242 -0
  122. package/srv/cardano-indexer-service.cds +387 -73
  123. package/srv/cardano-indexer-service.d.ts +5 -1
  124. package/srv/cardano-indexer-service.js +532 -16
  125. package/srv/cardano-service.cds +424 -269
  126. package/srv/cardano-service.js +289 -201
  127. package/srv/cardano-sign-service.cds +201 -180
  128. package/srv/cardano-sign-service.js +71 -201
  129. package/srv/cardano-tx-service.cds +451 -370
  130. package/srv/cardano-tx-service.js +271 -289
  131. package/srv/cardano-ui.cds +16 -16
  132. package/srv/cardano-worker-service.cds +118 -125
  133. package/srv/cardano-worker-service.js +52 -61
  134. package/srv/cbor/cip68.d.ts +13 -0
  135. package/srv/cbor/cip68.js +56 -0
  136. package/srv/cbor/index.d.ts +3 -1
  137. package/srv/cbor/index.js +9 -1
  138. package/srv/cbor/parse.d.ts +30 -18
  139. package/srv/cbor/parse.js +44 -9
  140. package/srv/cbor/plutus-data-json.d.ts +20 -0
  141. package/srv/cbor/plutus-data-json.js +32 -0
  142. package/srv/config.d.ts +113 -0
  143. package/srv/config.js +409 -0
  144. package/srv/server.d.ts +15 -110
  145. package/srv/server.js +84 -404
  146. package/srv/utils/agent-access.d.ts +9 -0
  147. package/srv/utils/agent-access.js +67 -0
  148. package/srv/utils/agent-grants-config.d.ts +0 -46
  149. package/srv/utils/agent-grants-config.js +17 -85
  150. package/srv/utils/agent-grants.d.ts +106 -122
  151. package/srv/utils/agent-grants.js +538 -236
  152. package/srv/utils/agent-token-auth.d.ts +4 -99
  153. package/srv/utils/agent-token-auth.js +18 -182
  154. package/srv/utils/backend-request-handler.d.ts +3 -17
  155. package/srv/utils/backend-request-handler.js +3 -18
  156. package/srv/utils/collections.d.ts +3 -10
  157. package/srv/utils/collections.js +3 -10
  158. package/srv/utils/const.d.ts +23 -74
  159. package/srv/utils/const.js +32 -79
  160. package/srv/utils/crypto.d.ts +3 -12
  161. package/srv/utils/crypto.js +6 -21
  162. package/srv/utils/db-indexes.d.ts +27 -0
  163. package/srv/utils/db-indexes.js +120 -0
  164. package/srv/utils/db-sanitize.d.ts +20 -0
  165. package/srv/utils/db-sanitize.js +80 -0
  166. package/srv/utils/deep-json.d.ts +6 -0
  167. package/srv/utils/deep-json.js +240 -0
  168. package/srv/utils/epoch-slots.d.ts +13 -0
  169. package/srv/utils/epoch-slots.js +38 -0
  170. package/srv/utils/error-codes.d.ts +22 -75
  171. package/srv/utils/error-codes.js +23 -72
  172. package/srv/utils/errors.d.ts +46 -187
  173. package/srv/utils/errors.js +114 -230
  174. package/srv/utils/liveness.d.ts +12 -0
  175. package/srv/utils/liveness.js +35 -0
  176. package/srv/utils/mappers.d.ts +102 -223
  177. package/srv/utils/mappers.js +387 -316
  178. package/srv/utils/network-context.js +2 -13
  179. package/srv/utils/paging.d.ts +31 -0
  180. package/srv/utils/paging.js +43 -0
  181. package/srv/utils/pg-inline-json.d.ts +8 -0
  182. package/srv/utils/pg-inline-json.js +58 -0
  183. package/srv/utils/pg-order-nulls.d.ts +14 -0
  184. package/srv/utils/pg-order-nulls.js +54 -0
  185. package/srv/utils/plutus-placeholders.d.ts +16 -22
  186. package/srv/utils/plutus-placeholders.js +62 -33
  187. package/srv/utils/rate-limiter.d.ts +2 -21
  188. package/srv/utils/rate-limiter.js +5 -17
  189. package/srv/utils/readiness.d.ts +12 -0
  190. package/srv/utils/readiness.js +29 -0
  191. package/srv/utils/reference-script.d.ts +19 -0
  192. package/srv/utils/reference-script.js +84 -0
  193. package/srv/utils/result-numbers.d.ts +15 -0
  194. package/srv/utils/result-numbers.js +61 -0
  195. package/srv/utils/service-events.d.ts +0 -24
  196. package/srv/utils/service-events.js +3 -25
  197. package/srv/utils/signing-helper.d.ts +3 -20
  198. package/srv/utils/signing-helper.js +35 -64
  199. package/srv/utils/tx-build-helper.d.ts +10 -105
  200. package/srv/utils/tx-build-helper.js +81 -144
  201. package/srv/utils/tx-request-parsers.d.ts +82 -33
  202. package/srv/utils/tx-request-parsers.js +401 -49
  203. package/srv/utils/tx-utils.d.ts +3 -27
  204. package/srv/utils/tx-utils.js +32 -50
  205. package/srv/utils/types.d.ts +261 -191
  206. package/srv/utils/types.js +2 -6
  207. package/srv/utils/validators.d.ts +22 -92
  208. package/srv/utils/validators.js +50 -149
@@ -1,269 +1,424 @@
1
- using {odatano.cardano as db} from '../db/schema';
2
- using { Blake2b256, Bech32, AssetUnit, ParsedTransaction } from '../db/types';
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
- */
33
- @requires: 'authenticated-user'
34
- service CardanoODataService @(impl: './cardano-service') {
35
-
36
- // ---------------------------------------------------------------------------
37
- // Entity Projections
38
- // ---------------------------------------------------------------------------
39
-
40
- @readonly
41
- @title : 'Network Information'
42
- @description: 'Projection for Network Information'
43
- entity NetworkInformation as projection on db.NetworkInformation;
44
-
45
- @readonly
46
- @title : 'Blocks'
47
- @description: 'Projection for Blocks'
48
- entity Blocks as projection on db.Blocks;
49
-
50
- @readonly
51
- @title : 'Epochs'
52
- @description: 'Projection for Epochs'
53
- entity Epochs as projection on db.Epochs;
54
-
55
- @readonly
56
- @title : 'Pools'
57
- @description: 'Projection for Pools'
58
- entity Pools as projection on db.Pools;
59
-
60
- @readonly
61
- @title : 'Dreps'
62
- @description: 'Projection for Dreps'
63
- entity Dreps as projection on db.Dreps;
64
-
65
- @readonly
66
- @title : 'Assets'
67
- @description: 'Projection for Native-Asset Information'
68
- entity Assets as projection on db.Assets;
69
-
70
- @readonly
71
- @title : 'Asset History'
72
- @description: 'Projection for Native-Asset Mint/Burn History'
73
- entity AssetHistory as projection on db.AssetHistory;
74
-
75
- @readonly
76
- @title : 'Transactions'
77
- @description: 'Projection for Transactions'
78
- entity Transactions as projection on db.Transactions;
79
-
80
- @readonly
81
- @title : 'Transaction Inputs'
82
- @description: 'Projection for Transaction Inputs'
83
- entity TransactionInputs as projection on db.TransactionInputs;
84
-
85
- @readonly
86
- @title : 'Transaction Outputs'
87
- @description: 'Projection for Transaction Outputs'
88
- entity TransactionOutputs as projection on db.TransactionOutputs;
89
-
90
- @readonly
91
- @title : 'Transaction Input Assets'
92
- @description: 'Projection for Transaction Input Assets'
93
- entity TransactionInputAssets as projection on db.TransactionInputAssets;
94
-
95
- @readonly
96
- @title : 'Transaction Output Assets'
97
- @description: 'Projection for Transaction Output Assets'
98
- entity TransactionOutputAssets as projection on db.TransactionOutputAssets;
99
-
100
- @readonly
101
- @title : 'Accounts'
102
- @description: 'Projection for Accounts'
103
- entity Accounts as projection on db.Accounts;
104
-
105
- @readonly
106
- @title : 'Addresses'
107
- @description: 'Projection for Addresses'
108
- entity Addresses as projection on db.Addresses;
109
-
110
- @readonly
111
- @title : 'Address Assets'
112
- @description: 'Projection for Address Assets'
113
- entity AddressAssets as projection on db.AddressAssets;
114
-
115
- @readonly
116
- @title : 'Address UTxOs'
117
- @description: 'Projection for Address UTxOs'
118
- entity AddressUTxOs as projection on db.AddressUTxOs;
119
-
120
- @readonly
121
- @title : 'Address Transactions'
122
- @description: 'Projection for Address Transactions'
123
- entity AddressTransactions as projection on db.AddressTransactions;
124
-
125
- @readonly
126
- @title : 'UTxO Assets'
127
- @description: 'Projection for UTxO Assets'
128
- entity UTxOAssets as projection on db.UTxOAssets;
129
-
130
- @readonly
131
- @title : 'Transaction Metadata'
132
- @description: 'Projection for Transaction Metadata'
133
- entity TransactionMetadata as projection on db.TransactionMetadata;
134
-
135
- @readonly
136
- @title : 'Ledger Protocol Parameters'
137
- @description: 'Projection for Ledger Protocol Parameters'
138
- entity LedgerProtocolParameters as projection on db.LedgerProtocolParameters;
139
-
140
- // ---------------------------------------------------------------------------
141
- // Actions
142
- // ---------------------------------------------------------------------------
143
- @title : 'Get Network Information'
144
- @description: 'Retrieve current network information including network type and genesis hash'
145
- action GetNetworkInformation() returns NetworkInformation;
146
-
147
- @title : 'Get Blocks by Block Hash'
148
- @description: 'Retrieve block information using the Block Hash'
149
- action GetBlockByHash(
150
- @title: 'Block Hash'
151
- @description: 'The unique identifier of the block'
152
- hash: Blake2b256) returns Blocks;
153
-
154
- @title : 'Get Epochs by Epoch Number'
155
- @description: 'Retrieve epoch information using the Epoch Number'
156
- action GetEpochByNumber(
157
- @title: 'Epoch Number'
158
- @description: 'The sequential number of the epoch'
159
- epochNumber: Integer) returns Epochs;
160
-
161
- @title : 'Get Pools by Pool Id'
162
- @description: 'Retrieve pool information using the Pool Id'
163
- action GetPoolById(
164
- @title: 'Pool Id'
165
- @description: 'The unique identifier of the stake pool'
166
- poolId: String) returns Pools;
167
-
168
- @title : 'Get Dreps by Drep Id'
169
- @description: 'Retrieve drep information using the Drep Id'
170
- action GetDrepById(
171
- @title: 'Drep Id'
172
- @description: 'The unique identifier of the drep'
173
- drepId: String) returns Dreps;
174
-
175
- @title : 'Get Asset Info'
176
- @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.'
177
- action GetAssetInfo(
178
- @title: 'Asset Unit'
179
- @description: 'Concatenation of policyId (56 hex) and assetNameHex (0-64 hex; ledger caps asset names at 32 bytes)'
180
- unit: AssetUnit) returns Assets;
181
-
182
- @title : 'Get Asset Mint/Burn History'
183
- @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.'
184
- action GetAssetHistory(
185
- @title: 'Asset Unit'
186
- @description: 'Concatenation of policyId (56 hex) and assetNameHex (0-64 hex; ledger caps asset names at 32 bytes)'
187
- unit: AssetUnit,
188
- @title: 'Limit'
189
- @description: 'Maximum number of recent events to fetch (default 100, clamped to 1-100)'
190
- limit: Integer) returns many AssetHistory;
191
-
192
- @title : 'Get Accounts by Stake Address'
193
- @description: 'Retrieve account information using the Bech32 Stake Address'
194
- action GetAccountByStakeAddress(
195
- @title: 'Stake Address'
196
- @description: 'The Bech32 encoded stake address'
197
- stakeAddress: Bech32) returns Accounts;
198
-
199
- @title : 'Get Transactions by Tx Hash'
200
- @description: 'Retrieve transaction information using the Transaction Hash'
201
- action GetTransactionByHash(
202
- @title: 'Transaction Hash'
203
- @description: 'The unique identifier of the transaction'
204
- hash: Blake2b256) returns Transactions;
205
-
206
- @title : 'Get Transaction Metadata by Tx Hash'
207
- @description: 'Retrieve transaction metadata using the Transaction Hash'
208
- action GetMetadataByTxHash(
209
- @title: 'Transaction Hash'
210
- @description: 'The unique identifier of the transaction'
211
- txHash: Blake2b256) returns many TransactionMetadata;
212
-
213
- @title : 'Get Addresses by Bech32 Address'
214
- @description: 'Retrieve address information using the Bech32 Address'
215
- action GetAddressByBech32(
216
- @title: 'Bech32 Address'
217
- @description: 'The Bech32 encoded address'
218
- address: Bech32) returns Addresses;
219
-
220
- @title : 'Get UTxOs by Bech32 Address'
221
- @description: 'Retrieve UTxO information using the Bech32 Address'
222
- action GetUTxOsByAddress(
223
- @title: 'Bech32 Address'
224
- @description: 'The Bech32 encoded address'
225
- address: Bech32) returns many AddressUTxOs;
226
-
227
- @title : 'Get UTxOs by Payment Credential'
228
- @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). Koios-only — throws ProviderUnavailableError on deployments without Koios. Always fresh, no cache check.'
229
- action GetUTxOsByCredential(
230
- @title: 'Payment Credential'
231
- @description: '28-byte payment credential hash as 56-char lowercase hex string'
232
- credential: String) returns many AddressUTxOs;
233
-
234
- @title : 'Get Assets by Bech32 Address'
235
- @description: 'Retrieve asset information using the Bech32 Address'
236
- action GetAssetsByAddress(
237
- @title: 'Bech32 Address'
238
- @description: 'The Bech32 encoded address'
239
- address: Bech32) returns many AddressAssets;
240
-
241
- @title : 'Get latest Transactions by Bech32 Address'
242
- @description: 'Retrieve the latest transactions from the Bech32 Address'
243
- action GetLatestTransactionsByAddress(
244
- @title: 'Bech32 Address'
245
- @description: 'The Bech32 encoded address'
246
- address: Bech32,
247
- @title: 'Limit'
248
- @description: 'The maximum number of transactions to retrieve'
249
- limit: Integer) returns many AddressTransactions;
250
-
251
- @title : 'Get Latest Block'
252
- @description: 'Retrieve the latest block information'
253
- action GetLatestBlock() returns Blocks;
254
-
255
- @title : 'Get Latest Epoch'
256
- @description: 'Retrieve the latest epoch information'
257
- action GetLatestEpoch() returns Epochs;
258
-
259
- @title : 'Get Ledger Protocol Parameters'
260
- @description: 'Retrieve the current ledger protocol parameters'
261
- action GetLedgerProtocolParameters() returns LedgerProtocolParameters;
262
-
263
- @title : 'Parse Transaction CBOR'
264
- @description: 'Parse hex-encoded transaction CBOR (signed or unsigned) into structured fields. Pure function, no network call, no DB write.'
265
- action ParseTransactionCbor(
266
- @title: 'Transaction CBOR'
267
- @description: 'Hex-encoded transaction CBOR; signed or unsigned. Capped at 128 KiB of hex.'
268
- cbor: LargeString) returns ParsedTransaction;
269
- }
1
+ using {odatano.cardano as db} from '../db/schema';
2
+ using { Blake2b256, Bech32, AssetUnit, ParsedTransaction, TransactionConfirmations } from '../db/types';
3
+
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).
6
+ @requires: 'Read'
7
+ @path: '/odata/v4/cardano'
8
+ service CardanoODataService @(impl: './cardano-service') {
9
+
10
+ // ---------------------------------------------------------------------------
11
+ // Entity Projections
12
+ // ---------------------------------------------------------------------------
13
+
14
+ @readonly
15
+ @title : 'Network Information'
16
+ @description: 'Projection for Network Information'
17
+ entity NetworkInformation as projection on db.NetworkInformation;
18
+
19
+ @readonly
20
+ @title : 'Blocks'
21
+ @description: 'Projection for Blocks'
22
+ entity Blocks as projection on db.Blocks;
23
+
24
+ @readonly
25
+ @title : 'Epochs'
26
+ @description: 'Projection for Epochs'
27
+ entity Epochs as projection on db.Epochs;
28
+
29
+ @readonly
30
+ @title : 'Pools'
31
+ @description: 'Projection for Pools'
32
+ entity Pools as projection on db.Pools;
33
+
34
+ @readonly
35
+ @title : 'Dreps'
36
+ @description: 'Projection for Dreps'
37
+ entity Dreps as projection on db.Dreps;
38
+
39
+ @readonly
40
+ @title : 'Pool Epoch Snapshots'
41
+ @description: 'Projection for per-epoch stake-pool snapshots written by the chain crawler'
42
+ entity PoolEpochSnapshots as projection on db.PoolEpochSnapshots;
43
+
44
+ @readonly
45
+ @title : 'DRep Epoch Snapshots'
46
+ @description: 'Projection for per-epoch DRep snapshots written by the chain crawler'
47
+ entity DrepEpochSnapshots as projection on db.DrepEpochSnapshots;
48
+
49
+ @readonly
50
+ @title : 'Epoch Ledger Snapshots'
51
+ @description: 'Projection for per-epoch network ledger figures written by the chain crawler'
52
+ entity EpochLedgerSnapshots as projection on db.EpochLedgerSnapshots;
53
+
54
+ @readonly
55
+ @title : 'Account Epoch Snapshots'
56
+ @description: 'Projection for per-epoch reward account snapshots written by the chain crawler'
57
+ entity AccountEpochSnapshots as projection on db.AccountEpochSnapshots;
58
+
59
+ @readonly
60
+ @title : 'Assets'
61
+ @description: 'Projection for Native-Asset Information'
62
+ entity Assets as projection on db.Assets;
63
+
64
+ @readonly
65
+ @title : 'Asset History'
66
+ @description: 'Projection for Native-Asset Mint/Burn History'
67
+ entity AssetHistory as projection on db.AssetHistory;
68
+
69
+ @readonly
70
+ @title : 'Transactions'
71
+ @description: 'Projection for Transactions'
72
+ entity Transactions as projection on db.Transactions;
73
+
74
+ @readonly
75
+ @title : 'Transaction Inputs'
76
+ @description: 'Projection for Transaction Inputs'
77
+ entity TransactionInputs as projection on db.TransactionInputs;
78
+
79
+ @readonly
80
+ @title : 'Transaction Outputs'
81
+ @description: 'Projection for Transaction Outputs'
82
+ entity TransactionOutputs as projection on db.TransactionOutputs;
83
+
84
+ @readonly
85
+ @title : 'Transaction Input Assets'
86
+ @description: 'Projection for Transaction Input Assets'
87
+ entity TransactionInputAssets as
88
+ select from db.TransactionInputAssets
89
+ mixin {
90
+ input : Association to TransactionInputs
91
+ on input.txSeq = $projection.input_txSeq
92
+ and input.inputIndex = $projection.input_inputIndex;
93
+ }
94
+ into {
95
+ *,
96
+ input
97
+ };
98
+
99
+ @readonly
100
+ @title : 'Transaction Output Assets'
101
+ @description: 'Projection for Transaction Output Assets'
102
+ entity TransactionOutputAssets as projection on db.TransactionOutputAssets;
103
+
104
+ @readonly
105
+ @title : 'Transaction Certificates'
106
+ @description: 'Projection for Transaction Certificates (crawler-fed, crawler.certificates)'
107
+ entity TransactionCertificates as projection on db.TransactionCertificates;
108
+
109
+ @readonly
110
+ @title : 'Transaction Withdrawals'
111
+ @description: 'Projection for Transaction Withdrawals (crawler-fed, crawler.certificates)'
112
+ entity TransactionWithdrawals as projection on db.TransactionWithdrawals;
113
+
114
+ @readonly
115
+ @title : 'Transaction Redeemers'
116
+ @description: 'Projection for Transaction Redeemers (crawler-fed, Ogmios chain-sync)'
117
+ entity TransactionRedeemers as projection on db.TransactionRedeemers;
118
+
119
+ @readonly
120
+ @title : 'Transaction Datums'
121
+ @description: 'Projection for Transaction Datums (crawler-fed, Ogmios chain-sync): witness-set datums byte for byte'
122
+ entity TransactionDatums as projection on db.TransactionDatums;
123
+
124
+ @readonly
125
+ @title : 'Ledger UTxOs'
126
+ @description: 'Crawler-maintained UTxO set (crawler.utxoSet); unspent while spentTxHash is null'
127
+ entity LedgerUTxOs as projection on db.LedgerUTxOs;
128
+
129
+ @readonly
130
+ @title : 'Ledger UTxO Assets'
131
+ @description: 'Native assets of a LedgerUTxOs row'
132
+ entity LedgerUTxOAssets as projection on db.LedgerUTxOAssets;
133
+
134
+ @readonly
135
+ @title : 'Ledger Addresses'
136
+ @description: 'Per-address balances from the crawler-maintained UTxO set (crawler.utxoSet)'
137
+ entity LedgerAddresses as projection on db.LedgerAddresses;
138
+
139
+ @readonly
140
+ @title : 'Ledger Address Assets'
141
+ @description: 'Native-asset balances per address (crawler.utxoSet)'
142
+ entity LedgerAddressAssets as projection on db.LedgerAddressAssets;
143
+
144
+ @readonly
145
+ @title : 'Ledger Accounts'
146
+ @description: 'Per-stake-key balances from the crawler-maintained UTxO set (crawler.utxoSet)'
147
+ entity LedgerAccounts as projection on db.LedgerAccounts;
148
+
149
+ @readonly
150
+ @title : 'Accounts'
151
+ @description: 'Projection for Accounts'
152
+ entity Accounts as projection on db.Accounts;
153
+
154
+ @readonly
155
+ @title : 'Addresses'
156
+ @description: 'Projection for Addresses'
157
+ entity Addresses as projection on db.Addresses;
158
+
159
+ @readonly
160
+ @title : 'Address Assets'
161
+ @description: 'Projection for Address Assets'
162
+ entity AddressAssets as projection on db.AddressAssets;
163
+
164
+ @readonly
165
+ @title : 'Address UTxOs'
166
+ @description: 'Projection for Address UTxOs'
167
+ entity AddressUTxOs as projection on db.AddressUTxOs;
168
+
169
+ @readonly
170
+ @title : 'Address Transactions'
171
+ @description: 'Projection for Address Transactions'
172
+ entity AddressTransactions as projection on db.AddressTransactions;
173
+
174
+ @readonly
175
+ @title : 'UTxO Assets'
176
+ @description: 'Projection for UTxO Assets'
177
+ entity UTxOAssets as projection on db.UTxOAssets;
178
+
179
+ @readonly
180
+ @title : 'Transaction Metadata'
181
+ @description: 'Projection for Transaction Metadata'
182
+ entity TransactionMetadata as projection on db.TransactionMetadata;
183
+
184
+ @readonly
185
+ @title : 'Ledger Protocol Parameters'
186
+ @description: 'Projection for Ledger Protocol Parameters'
187
+ entity LedgerProtocolParameters as projection on db.LedgerProtocolParameters;
188
+
189
+ // ---------------------------------------------------------------------------
190
+ // Actions
191
+ // ---------------------------------------------------------------------------
192
+ @title : 'Get Network Information'
193
+ @description: 'Retrieve current network information including network type and genesis hash'
194
+ @odatano.agent: 'read'
195
+ action GetNetworkInformation() returns NetworkInformation;
196
+
197
+ @title : 'Get Blocks by Block Hash'
198
+ @description: 'Retrieve block information using the Block Hash'
199
+ @odatano.agent: 'read'
200
+ action GetBlockByHash(
201
+ @title: 'Block Hash'
202
+ @description: 'The unique identifier of the block'
203
+ hash: Blake2b256) returns Blocks;
204
+
205
+ @title : 'Get Epochs by Epoch Number'
206
+ @description: 'Retrieve epoch information using the Epoch Number'
207
+ @odatano.agent: 'read'
208
+ action GetEpochByNumber(
209
+ @title: 'Epoch Number'
210
+ @description: 'The sequential number of the epoch'
211
+ @assert.range: [0, _]
212
+ epochNumber: Integer) returns Epochs;
213
+
214
+ @title : 'Get Pools by Pool Id'
215
+ @description: 'Retrieve pool information using the Pool Id'
216
+ @odatano.agent: 'read'
217
+ action GetPoolById(
218
+ @title: 'Pool Id'
219
+ @description: 'The unique identifier of the stake pool'
220
+ poolId: String) returns Pools;
221
+
222
+ @title : 'Get Dreps by Drep Id'
223
+ @description: 'Retrieve drep information using the Drep Id'
224
+ @odatano.agent: 'read'
225
+ action GetDrepById(
226
+ @title: 'Drep Id'
227
+ @description: 'The unique identifier of the drep'
228
+ drepId: String) returns Dreps;
229
+
230
+ @title : 'Get Asset Info'
231
+ @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.'
232
+ @odatano.agent: 'read'
233
+ action GetAssetInfo(
234
+ @title: 'Asset Unit'
235
+ @description: 'Concatenation of policyId (56 hex) and assetNameHex (0-64 hex; ledger caps asset names at 32 bytes)'
236
+ unit: AssetUnit) returns Assets;
237
+
238
+ @title : 'Get Asset Mint/Burn History'
239
+ @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.'
240
+ @odatano.agent: 'read'
241
+ action GetAssetHistory(
242
+ @title: 'Asset Unit'
243
+ @description: 'Concatenation of policyId (56 hex) and assetNameHex (0-64 hex; ledger caps asset names at 32 bytes)'
244
+ unit: AssetUnit,
245
+ @title: 'Limit'
246
+ @description: 'Maximum number of rows (default 100, at most 100)'
247
+ @assert.range: [1, 100]
248
+ limit: Integer,
249
+ @title: 'Skip'
250
+ @description: 'Number of rows to skip (default 0)'
251
+ @assert.range: [0, 99]
252
+ skip: Integer) returns many AssetHistory;
253
+
254
+ @title : 'Get Accounts by Stake Address'
255
+ @description: 'Retrieve account information using the Bech32 Stake Address'
256
+ @odatano.agent: 'read'
257
+ action GetAccountByStakeAddress(
258
+ @title: 'Stake Address'
259
+ @description: 'The Bech32 encoded stake address'
260
+ stakeAddress: Bech32) returns Accounts;
261
+
262
+ @title : 'Get Transactions by Tx Hash'
263
+ @description: 'Retrieve transaction information using the Transaction Hash'
264
+ @odatano.agent: 'read'
265
+ action GetTransactionByHash(
266
+ @title: 'Transaction Hash'
267
+ @description: 'The unique identifier of the transaction'
268
+ hash: Blake2b256) returns Transactions;
269
+
270
+ @title : 'Get Transaction Confirmations'
271
+ @description: 'Number of blocks on top of a transaction, its own block included; 0 while it is not on chain. Uses the crawled chain when the crawler is synced, else the backends.'
272
+ @odatano.agent: 'read'
273
+ action GetTransactionConfirmations(
274
+ @title: 'Transaction Hash'
275
+ @description: 'The unique identifier of the transaction'
276
+ txHash: Blake2b256) returns TransactionConfirmations;
277
+
278
+ @title : 'Get Transaction Metadata by Tx Hash'
279
+ @description: 'Retrieve transaction metadata using the Transaction Hash'
280
+ @odatano.agent: 'read'
281
+ action GetMetadataByTxHash(
282
+ @title: 'Transaction Hash'
283
+ @description: 'The unique identifier of the transaction'
284
+ txHash: Blake2b256,
285
+ @title: 'Limit'
286
+ @description: 'Maximum number of rows (default 1000, at most 5000)'
287
+ @assert.range: [1, 5000]
288
+ limit: Integer,
289
+ @title: 'Skip'
290
+ @description: 'Number of rows to skip (default 0)'
291
+ @assert.range: [0, _]
292
+ skip: Integer) returns many TransactionMetadata;
293
+
294
+ @title : 'Get Transaction Metadata by Label'
295
+ @description: 'Stored transaction metadata of one label in chain order, oldest first: the metadata of crawled transactions and of transactions read earlier. No backend is asked. Each row carries txSeq (slot * 65536 + txIndex); read on from a slot with fromSlot, or page with skip.'
296
+ @odatano.agent: 'read'
297
+ action GetMetadataByLabel(
298
+ @title: 'Label'
299
+ @description: 'The metadata label, an unsigned 64-bit integer as string'
300
+ label: String(20),
301
+ @title: 'From Slot'
302
+ @description: 'Only transactions in this slot or later (default 0)'
303
+ @assert.range: [0, _]
304
+ fromSlot: Integer64,
305
+ @title: 'Limit'
306
+ @description: 'Maximum number of rows (default 100, at most 1000)'
307
+ @assert.range: [1, 1000]
308
+ limit: Integer,
309
+ @title: 'Skip'
310
+ @description: 'Number of rows to skip (default 0)'
311
+ @assert.range: [0, _]
312
+ skip: Integer) returns many TransactionMetadata;
313
+
314
+ @title : 'Get Addresses by Bech32 Address'
315
+ @description: 'Retrieve address information using the Bech32 Address'
316
+ @odatano.agent: 'read'
317
+ action GetAddressByBech32(
318
+ @title: 'Bech32 Address'
319
+ @description: 'The Bech32 encoded address'
320
+ address: Bech32) returns Addresses;
321
+
322
+ @title : 'Get UTxOs by Bech32 Address'
323
+ @description: 'Retrieve UTxO information using the Bech32 Address'
324
+ @odatano.agent: 'read'
325
+ action GetUTxOsByAddress(
326
+ @title: 'Bech32 Address'
327
+ @description: 'The Bech32 encoded address'
328
+ address: Bech32,
329
+ @title: 'Limit'
330
+ @description: 'Maximum number of rows (default 1000, at most 5000)'
331
+ @assert.range: [1, 5000]
332
+ limit: Integer,
333
+ @title: 'Skip'
334
+ @description: 'Number of rows to skip (default 0)'
335
+ @assert.range: [0, _]
336
+ skip: Integer) returns many AddressUTxOs;
337
+
338
+ @title : 'Get UTxOs by Payment Credential'
339
+ @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.'
340
+ @odatano.agent: 'read'
341
+ action GetUTxOsByCredential(
342
+ @title: 'Payment Credential'
343
+ @description: '28-byte payment credential hash as 56-char lowercase hex string'
344
+ credential: String,
345
+ @title: 'Limit'
346
+ @description: 'Maximum number of rows (default 1000, at most 5000)'
347
+ @assert.range: [1, 5000]
348
+ limit: Integer,
349
+ @title: 'Skip'
350
+ @description: 'Number of rows to skip (default 0)'
351
+ @assert.range: [0, _]
352
+ skip: Integer) returns many AddressUTxOs;
353
+
354
+ @title : 'Get Assets by Bech32 Address'
355
+ @description: 'Retrieve asset information using the Bech32 Address'
356
+ @odatano.agent: 'read'
357
+ action GetAssetsByAddress(
358
+ @title: 'Bech32 Address'
359
+ @description: 'The Bech32 encoded address'
360
+ address: Bech32,
361
+ @title: 'Limit'
362
+ @description: 'Maximum number of rows (default 1000, at most 5000)'
363
+ @assert.range: [1, 5000]
364
+ limit: Integer,
365
+ @title: 'Skip'
366
+ @description: 'Number of rows to skip (default 0)'
367
+ @assert.range: [0, _]
368
+ skip: Integer) returns many AddressAssets;
369
+
370
+ @title : 'Get latest Transactions by Bech32 Address'
371
+ @description: 'Retrieve the latest transactions of the Bech32 Address, newest first. skip + limit covers at most the newest 100 transactions.'
372
+ @odatano.agent: 'read'
373
+ action GetLatestTransactionsByAddress(
374
+ @title: 'Bech32 Address'
375
+ @description: 'The Bech32 encoded address'
376
+ address: Bech32,
377
+ @title: 'Limit'
378
+ @description: 'Maximum number of rows (default 10, at most 100)'
379
+ @assert.range: [1, 100]
380
+ limit: Integer,
381
+ @title: 'Skip'
382
+ @description: 'Number of rows to skip (default 0)'
383
+ @assert.range: [0, 99]
384
+ skip: Integer,
385
+ @title: 'Since Time'
386
+ @description: 'Only transactions with a block time after this unix time in seconds'
387
+ @assert.range: [0, _]
388
+ sinceTime: Integer64,
389
+ @title: 'Wait (ms)'
390
+ @description: 'With sinceTime: when no newer transaction is known, read again every 5 seconds until one appears or this time is up (at most 30000)'
391
+ @assert.range: [0, 30000]
392
+ waitMs: Integer) returns many AddressTransactions;
393
+
394
+ @title : 'Get Latest Block'
395
+ @description: 'Retrieve the latest block information'
396
+ @odatano.agent: 'read'
397
+ action GetLatestBlock() returns Blocks;
398
+
399
+ @title : 'Get Latest Epoch'
400
+ @description: 'Retrieve the latest epoch information'
401
+ @odatano.agent: 'read'
402
+ action GetLatestEpoch() returns Epochs;
403
+
404
+ @title : 'Get Ledger Protocol Parameters'
405
+ @description: 'Retrieve the current ledger protocol parameters'
406
+ @odatano.agent: 'read'
407
+ action GetLedgerProtocolParameters() returns LedgerProtocolParameters;
408
+
409
+ @title : 'Parse Transaction CBOR'
410
+ @description: 'Parse hex-encoded transaction CBOR (signed or unsigned) into structured fields. Pure function, no network call, no DB write.'
411
+ @odatano.agent: 'read'
412
+ action ParseTransactionCbor(
413
+ @title: 'Transaction CBOR'
414
+ @description: 'Hex-encoded transaction CBOR; signed or unsigned. Capped at 128 KiB of hex.'
415
+ cbor: LargeString) returns ParsedTransaction;
416
+
417
+ @title : 'Decode Plutus Data'
418
+ @description: 'Decode PlutusData CBOR hex (an inline datum, a witness datum, a redeemer) into the JSON the build actions accept as outputDatumJson (DetailedSchema: constructor/fields, int, bytes, list, map). Integers beyond 2^53 are decimal strings. Pure function, no network call, no DB write.'
419
+ @odatano.agent: 'read'
420
+ action DecodePlutusData(
421
+ @title: 'PlutusData CBOR'
422
+ @description: 'Hex-encoded PlutusData CBOR. Capped at 128 KiB of hex.'
423
+ cbor: LargeString) returns LargeString;
424
+ }