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

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 (239) 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 +358 -0
  4. package/@cds-models/CardanoBackendService/index.js +41 -0
  5. package/@cds-models/CardanoIndexerService/index.d.ts +594 -11
  6. package/@cds-models/CardanoIndexerService/index.js +74 -0
  7. package/@cds-models/CardanoODataService/index.d.ts +417 -57
  8. package/@cds-models/CardanoODataService/index.js +42 -0
  9. package/@cds-models/CardanoSignService/index.d.ts +45 -19
  10. package/@cds-models/CardanoSignService/index.js +4 -0
  11. package/@cds-models/CardanoTransactionService/index.d.ts +70 -44
  12. package/@cds-models/CardanoTransactionService/index.js +5 -0
  13. package/@cds-models/CardanoWorkerService/index.d.ts +35 -22
  14. package/@cds-models/CardanoWorkerService/index.js +2 -0
  15. package/@cds-models/index.d.ts +114 -4
  16. package/@cds-models/index.js +20 -4
  17. package/@cds-models/odatano/cardano/index.d.ts +451 -32
  18. package/@cds-models/odatano/cardano/index.js +48 -0
  19. package/README.md +103 -167
  20. package/db/schema.cds +2455 -1705
  21. package/db/types.cds +456 -295
  22. package/package.json +41 -53
  23. package/scripts/deploy-schema.mjs +113 -0
  24. package/scripts/migrate-schema.mjs +528 -0
  25. package/scripts/migrate-slot-leader.mjs +96 -0
  26. package/src/index.d.ts +20 -21
  27. package/src/index.js +45 -31
  28. package/src/plugin.js +17 -35
  29. package/srv/blockchain/asset-decimals.d.ts +7 -0
  30. package/srv/blockchain/asset-decimals.js +91 -0
  31. package/srv/blockchain/backends/blockfrost-backend.d.ts +25 -137
  32. package/srv/blockchain/backends/blockfrost-backend.js +125 -215
  33. package/srv/blockchain/backends/call-signal.d.ts +7 -0
  34. package/srv/blockchain/backends/call-signal.js +22 -0
  35. package/srv/blockchain/backends/cardano-backend.d.ts +100 -189
  36. package/srv/blockchain/backends/cardano-backend.js +29 -5
  37. package/srv/blockchain/backends/koios-backend.d.ts +108 -170
  38. package/srv/blockchain/backends/koios-backend.js +488 -482
  39. package/srv/blockchain/backends/odatano-backend.d.ts +55 -0
  40. package/srv/blockchain/backends/odatano-backend.js +211 -0
  41. package/srv/blockchain/backends/ogmios-backend.d.ts +122 -190
  42. package/srv/blockchain/backends/ogmios-backend.js +683 -327
  43. package/srv/blockchain/backends/ogmios-frame-guard.d.ts +14 -0
  44. package/srv/blockchain/backends/ogmios-frame-guard.js +89 -0
  45. package/srv/blockchain/cardano-client.d.ts +71 -241
  46. package/srv/blockchain/cardano-client.js +354 -322
  47. package/srv/blockchain/cardano-indexer.d.ts +295 -283
  48. package/srv/blockchain/cardano-indexer.js +1690 -502
  49. package/srv/blockchain/cardano-tx-builder.d.ts +25 -89
  50. package/srv/blockchain/cardano-tx-builder.js +164 -140
  51. package/srv/blockchain/circuit-breaker.d.ts +2 -13
  52. package/srv/blockchain/circuit-breaker.js +11 -15
  53. package/srv/blockchain/crawler/account-snapshots.d.ts +29 -0
  54. package/srv/blockchain/crawler/account-snapshots.js +173 -0
  55. package/srv/blockchain/crawler/asset-decimals-backfill.d.ts +17 -0
  56. package/srv/blockchain/crawler/asset-decimals-backfill.js +56 -0
  57. package/srv/blockchain/crawler/asset-registry-backfill.d.ts +46 -0
  58. package/srv/blockchain/crawler/asset-registry-backfill.js +157 -0
  59. package/srv/blockchain/crawler/asset-slice-backfill.d.ts +35 -0
  60. package/srv/blockchain/crawler/asset-slice-backfill.js +149 -0
  61. package/srv/blockchain/crawler/certificate-backfill.d.ts +56 -0
  62. package/srv/blockchain/crawler/certificate-backfill.js +174 -0
  63. package/srv/blockchain/crawler/crawler.d.ts +125 -81
  64. package/srv/blockchain/crawler/crawler.js +738 -167
  65. package/srv/blockchain/crawler/credential-backfill.d.ts +30 -0
  66. package/srv/blockchain/crawler/credential-backfill.js +101 -0
  67. package/srv/blockchain/crawler/hooks.d.ts +2 -17
  68. package/srv/blockchain/crawler/index.d.ts +1 -8
  69. package/srv/blockchain/crawler/index.js +31 -17
  70. package/srv/blockchain/crawler/input-asset-copies.d.ts +34 -0
  71. package/srv/blockchain/crawler/input-asset-copies.js +161 -0
  72. package/srv/blockchain/crawler/key-pages.d.ts +12 -0
  73. package/srv/blockchain/crawler/key-pages.js +48 -0
  74. package/srv/blockchain/crawler/metadata-position-backfill.d.ts +22 -0
  75. package/srv/blockchain/crawler/metadata-position-backfill.js +59 -0
  76. package/srv/blockchain/crawler/output-datum-backfill.d.ts +41 -0
  77. package/srv/blockchain/crawler/output-datum-backfill.js +100 -0
  78. package/srv/blockchain/crawler/sync-state.d.ts +31 -47
  79. package/srv/blockchain/crawler/sync-state.js +135 -128
  80. package/srv/blockchain/crawler/transaction-backfill.d.ts +46 -0
  81. package/srv/blockchain/crawler/transaction-backfill.js +271 -0
  82. package/srv/blockchain/crawler/utxo-set-import.d.ts +66 -0
  83. package/srv/blockchain/crawler/utxo-set-import.js +399 -0
  84. package/srv/blockchain/crawler/window-plan.d.ts +31 -0
  85. package/srv/blockchain/crawler/window-plan.js +59 -0
  86. package/srv/blockchain/ledger-state.d.ts +62 -0
  87. package/srv/blockchain/ledger-state.js +521 -0
  88. package/srv/blockchain/pending-spends.d.ts +16 -0
  89. package/srv/blockchain/pending-spends.js +81 -0
  90. package/srv/blockchain/pool-metadata.d.ts +15 -0
  91. package/srv/blockchain/pool-metadata.js +132 -0
  92. package/srv/blockchain/request-coalescer.d.ts +2 -16
  93. package/srv/blockchain/request-coalescer.js +2 -16
  94. package/srv/blockchain/signing/cose-verifier.d.ts +3 -17
  95. package/srv/blockchain/signing/cose-verifier.js +146 -70
  96. package/srv/blockchain/signing/external-signer.d.ts +15 -115
  97. package/srv/blockchain/signing/external-signer.js +22 -131
  98. package/srv/blockchain/signing/failed-recheck.d.ts +17 -0
  99. package/srv/blockchain/signing/failed-recheck.js +135 -0
  100. package/srv/blockchain/signing/hsm-signer.d.ts +10 -54
  101. package/srv/blockchain/signing/hsm-signer.js +28 -79
  102. package/srv/blockchain/signing/landing-proof.d.ts +60 -0
  103. package/srv/blockchain/signing/landing-proof.js +224 -0
  104. package/srv/blockchain/signing/signature-verifier.d.ts +9 -47
  105. package/srv/blockchain/signing/signature-verifier.js +71 -87
  106. package/srv/blockchain/signing/submission-finalizer.d.ts +37 -45
  107. package/srv/blockchain/signing/submission-finalizer.js +280 -86
  108. package/srv/blockchain/stored-chain.d.ts +19 -0
  109. package/srv/blockchain/stored-chain.js +258 -0
  110. package/srv/blockchain/transaction-building/buildooor-tx.d.ts +31 -229
  111. package/srv/blockchain/transaction-building/buildooor-tx.js +663 -421
  112. package/srv/blockchain/transaction-building/cardano-tx.d.ts +9 -37
  113. package/srv/blockchain/transaction-presence.d.ts +12 -0
  114. package/srv/blockchain/transaction-presence.js +29 -0
  115. package/srv/blockchain/transaction-rows.d.ts +12 -0
  116. package/srv/blockchain/transaction-rows.js +44 -0
  117. package/srv/blockchain/wallet-worker/build-request.d.ts +8 -23
  118. package/srv/blockchain/wallet-worker/build-request.js +40 -353
  119. package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +27 -47
  120. package/srv/blockchain/wallet-worker/confirmation-tracker.js +158 -61
  121. package/srv/blockchain/wallet-worker/index.d.ts +1 -1
  122. package/srv/blockchain/wallet-worker/index.js +3 -11
  123. package/srv/blockchain/wallet-worker/invalidation.d.ts +35 -0
  124. package/srv/blockchain/wallet-worker/invalidation.js +128 -0
  125. package/srv/blockchain/wallet-worker/job-store.d.ts +58 -150
  126. package/srv/blockchain/wallet-worker/job-store.js +200 -273
  127. package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +2 -26
  128. package/srv/blockchain/wallet-worker/lease-heartbeat.js +6 -28
  129. package/srv/blockchain/wallet-worker/signers.d.ts +5 -24
  130. package/srv/blockchain/wallet-worker/signers.js +4 -12
  131. package/srv/blockchain/wallet-worker/wallet-worker.d.ts +29 -82
  132. package/srv/blockchain/wallet-worker/wallet-worker.js +334 -198
  133. package/srv/cardano-agent-service.cds +122 -84
  134. package/srv/cardano-agent-service.js +12 -9
  135. package/srv/cardano-backend-service.cds +81 -0
  136. package/srv/cardano-backend-service.d.ts +2 -0
  137. package/srv/cardano-backend-service.js +259 -0
  138. package/srv/cardano-indexer-service.cds +393 -18
  139. package/srv/cardano-indexer-service.d.ts +5 -1
  140. package/srv/cardano-indexer-service.js +477 -16
  141. package/srv/cardano-service.cds +426 -269
  142. package/srv/cardano-service.js +640 -217
  143. package/srv/cardano-sign-service.cds +211 -180
  144. package/srv/cardano-sign-service.js +210 -287
  145. package/srv/cardano-tx-service.cds +462 -370
  146. package/srv/cardano-tx-service.js +283 -800
  147. package/srv/cardano-ui.cds +16 -16
  148. package/srv/cardano-worker-service.cds +141 -125
  149. package/srv/cardano-worker-service.js +104 -61
  150. package/srv/cbor/cip68.d.ts +13 -0
  151. package/srv/cbor/cip68.js +56 -0
  152. package/srv/cbor/index.d.ts +3 -1
  153. package/srv/cbor/index.js +9 -1
  154. package/srv/cbor/parse.d.ts +30 -18
  155. package/srv/cbor/parse.js +44 -9
  156. package/srv/cbor/plutus-data-json.d.ts +20 -0
  157. package/srv/cbor/plutus-data-json.js +32 -0
  158. package/srv/config.d.ts +117 -0
  159. package/srv/config.js +419 -0
  160. package/srv/server.d.ts +15 -110
  161. package/srv/server.js +83 -405
  162. package/srv/utils/agent-access.d.ts +11 -0
  163. package/srv/utils/agent-access.js +86 -0
  164. package/srv/utils/agent-grants-config.d.ts +0 -46
  165. package/srv/utils/agent-grants-config.js +17 -85
  166. package/srv/utils/agent-grants.d.ts +106 -122
  167. package/srv/utils/agent-grants.js +538 -237
  168. package/srv/utils/agent-token-auth.d.ts +4 -99
  169. package/srv/utils/agent-token-auth.js +62 -186
  170. package/srv/utils/backend-request-handler.d.ts +3 -17
  171. package/srv/utils/backend-request-handler.js +3 -18
  172. package/srv/utils/build-request.d.ts +52 -0
  173. package/srv/utils/build-request.js +487 -0
  174. package/srv/utils/collections.d.ts +4 -10
  175. package/srv/utils/collections.js +14 -10
  176. package/srv/utils/const.d.ts +32 -75
  177. package/srv/utils/const.js +40 -80
  178. package/srv/utils/crypto.d.ts +3 -12
  179. package/srv/utils/crypto.js +11 -25
  180. package/srv/utils/db-indexes.d.ts +31 -0
  181. package/srv/utils/db-indexes.js +185 -0
  182. package/srv/utils/db-kind.d.ts +23 -0
  183. package/srv/utils/db-kind.js +42 -0
  184. package/srv/utils/db-sanitize.d.ts +20 -0
  185. package/srv/utils/db-sanitize.js +80 -0
  186. package/srv/utils/deep-json.d.ts +6 -0
  187. package/srv/utils/deep-json.js +240 -0
  188. package/srv/utils/detached-run.d.ts +41 -0
  189. package/srv/utils/detached-run.js +101 -0
  190. package/srv/utils/epoch-slots.d.ts +14 -0
  191. package/srv/utils/epoch-slots.js +45 -0
  192. package/srv/utils/error-codes.d.ts +26 -75
  193. package/srv/utils/error-codes.js +27 -72
  194. package/srv/utils/errors.d.ts +55 -187
  195. package/srv/utils/errors.js +161 -235
  196. package/srv/utils/lease.d.ts +20 -0
  197. package/srv/utils/lease.js +62 -0
  198. package/srv/utils/liveness.d.ts +12 -0
  199. package/srv/utils/liveness.js +35 -0
  200. package/srv/utils/mappers.d.ts +111 -223
  201. package/srv/utils/mappers.js +432 -371
  202. package/srv/utils/navigation.d.ts +17 -0
  203. package/srv/utils/navigation.js +52 -0
  204. package/srv/utils/network-context.d.ts +0 -1
  205. package/srv/utils/network-context.js +9 -15
  206. package/srv/utils/paging.d.ts +31 -0
  207. package/srv/utils/paging.js +43 -0
  208. package/srv/utils/pg-inline-json.d.ts +8 -0
  209. package/srv/utils/pg-inline-json.js +58 -0
  210. package/srv/utils/pg-order-nulls.d.ts +14 -0
  211. package/srv/utils/pg-order-nulls.js +54 -0
  212. package/srv/utils/plutus-placeholders.d.ts +16 -22
  213. package/srv/utils/plutus-placeholders.js +62 -33
  214. package/srv/utils/rate-limiter.d.ts +2 -21
  215. package/srv/utils/rate-limiter.js +5 -17
  216. package/srv/utils/readiness.d.ts +12 -0
  217. package/srv/utils/readiness.js +29 -0
  218. package/srv/utils/reference-script.d.ts +19 -0
  219. package/srv/utils/reference-script.js +84 -0
  220. package/srv/utils/resolution.d.ts +13 -0
  221. package/srv/utils/resolution.js +47 -0
  222. package/srv/utils/result-numbers.d.ts +15 -0
  223. package/srv/utils/result-numbers.js +61 -0
  224. package/srv/utils/row-values.d.ts +7 -0
  225. package/srv/utils/row-values.js +27 -0
  226. package/srv/utils/service-events.d.ts +0 -24
  227. package/srv/utils/service-events.js +3 -25
  228. package/srv/utils/signing-helper.d.ts +3 -20
  229. package/srv/utils/signing-helper.js +35 -64
  230. package/srv/utils/tx-build-helper.d.ts +25 -105
  231. package/srv/utils/tx-build-helper.js +108 -156
  232. package/srv/utils/tx-request-parsers.d.ts +82 -33
  233. package/srv/utils/tx-request-parsers.js +401 -49
  234. package/srv/utils/tx-utils.d.ts +3 -27
  235. package/srv/utils/tx-utils.js +32 -50
  236. package/srv/utils/types.d.ts +294 -232
  237. package/srv/utils/types.js +2 -22
  238. package/srv/utils/validators.d.ts +22 -92
  239. package/srv/utils/validators.js +60 -170
@@ -891,13 +891,13 @@ annotate srv.Addresses with @(
891
891
  $Type : 'UI.ReferenceFacet',
892
892
  Label : 'Assets',
893
893
  Target : 'assets/@UI.LineItem',
894
- ![@UI.Hidden]: (not hasAssets)
894
+ @UI.Hidden: (not hasAssets)
895
895
  },
896
896
  {
897
897
  $Type : 'UI.ReferenceFacet',
898
898
  Label : 'UTxOs',
899
899
  Target : 'utxos/@UI.LineItem',
900
- ![@UI.Hidden]: (not hasUTxOs)
900
+ @UI.Hidden: (not hasUTxOs)
901
901
  }
902
902
  ],
903
903
 
@@ -1075,7 +1075,7 @@ annotate srv.AddressUTxOs with @(
1075
1075
  $Type : 'UI.ReferenceFacet',
1076
1076
  Label : 'Assets',
1077
1077
  Target : 'assets/@UI.LineItem',
1078
- ![@UI.Hidden]: (not hasAssets)
1078
+ @UI.Hidden: (not hasAssets)
1079
1079
  },
1080
1080
  {
1081
1081
  $Type : 'UI.ReferenceFacet',
@@ -1305,19 +1305,19 @@ annotate srv.Transactions with @(
1305
1305
  $Type : 'UI.ReferenceFacet',
1306
1306
  Label : 'Metadata',
1307
1307
  Target : 'metadata/@UI.LineItem',
1308
- ![@UI.Hidden]: (not hasMetadata)
1308
+ @UI.Hidden: (not hasMetadata)
1309
1309
  },
1310
1310
  {
1311
1311
  $Type : 'UI.ReferenceFacet',
1312
1312
  Label : 'Inputs',
1313
1313
  Target : 'inputs/@UI.LineItem',
1314
- ![@UI.Hidden]: (not hasInputs)
1314
+ @UI.Hidden: (not hasInputs)
1315
1315
  },
1316
1316
  {
1317
1317
  $Type : 'UI.ReferenceFacet',
1318
1318
  Label : 'Outputs',
1319
1319
  Target : 'outputs/@UI.LineItem',
1320
- ![@UI.Hidden]: (not hasOutputs)
1320
+ @UI.Hidden: (not hasOutputs)
1321
1321
  }
1322
1322
  ],
1323
1323
 
@@ -1451,7 +1451,7 @@ annotate srv.TransactionInputs with @(
1451
1451
  $Type : 'UI.ReferenceFacet',
1452
1452
  Label : 'Assets',
1453
1453
  Target : 'assets/@UI.LineItem',
1454
- ![@UI.Hidden]: (not hasAssets)
1454
+ @UI.Hidden: (not hasAssets)
1455
1455
  },
1456
1456
  {
1457
1457
  $Type : 'UI.ReferenceFacet',
@@ -1625,7 +1625,7 @@ annotate srv.TransactionOutputs with @(
1625
1625
  $Type : 'UI.ReferenceFacet',
1626
1626
  Label : 'Assets',
1627
1627
  Target : 'assets/@UI.LineItem',
1628
- ![@UI.Hidden]: (not hasAssets)
1628
+ @UI.Hidden: (not hasAssets)
1629
1629
  },
1630
1630
  {
1631
1631
  $Type : 'UI.ReferenceFacet',
@@ -1860,7 +1860,7 @@ annotate srv.Accounts with @(
1860
1860
  $Type : 'UI.ReferenceFacet',
1861
1861
  Label : 'Addresses',
1862
1862
  Target : 'Address/@UI.LineItem',
1863
- ![@UI.Hidden]: (not hasAddresses)
1863
+ @UI.Hidden: (not hasAddresses)
1864
1864
  }
1865
1865
  ],
1866
1866
 
@@ -2301,19 +2301,19 @@ annotate txsrv.TransactionBuilds with @(
2301
2301
  $Type : 'UI.ReferenceFacet',
2302
2302
  Label : 'Inputs',
2303
2303
  Target : 'inputs/@UI.LineItem',
2304
- ![@UI.Hidden]: (not hasInputs)
2304
+ @UI.Hidden: (not hasInputs)
2305
2305
  },
2306
2306
  {
2307
2307
  $Type : 'UI.ReferenceFacet',
2308
2308
  Label : 'Outputs',
2309
2309
  Target : 'outputs/@UI.LineItem',
2310
- ![@UI.Hidden]: (not hasOutputs)
2310
+ @UI.Hidden: (not hasOutputs)
2311
2311
  },
2312
2312
  {
2313
2313
  $Type : 'UI.ReferenceFacet',
2314
2314
  Label : 'Submission',
2315
2315
  Target : 'submission/@UI.FieldGroup#SubmissionDetails',
2316
- ![@UI.Hidden]: (not wasSubmitted)
2316
+ @UI.Hidden: (not wasSubmitted)
2317
2317
  }
2318
2318
  ],
2319
2319
 
@@ -2439,7 +2439,7 @@ annotate txsrv.TransactionBuildInputs with @(
2439
2439
  $Type : 'UI.ReferenceFacet',
2440
2440
  Label : 'Assets',
2441
2441
  Target : 'assets/@UI.LineItem',
2442
- ![@UI.Hidden]: (not hasAssets)
2442
+ @UI.Hidden: (not hasAssets)
2443
2443
  },
2444
2444
  {
2445
2445
  $Type : 'UI.ReferenceFacet',
@@ -2611,7 +2611,7 @@ annotate txsrv.TransactionBuildOutputs with @(
2611
2611
  $Type : 'UI.ReferenceFacet',
2612
2612
  Label : 'Assets',
2613
2613
  Target : 'assets/@UI.LineItem',
2614
- ![@UI.Hidden]: (not hasAssets)
2614
+ @UI.Hidden: (not hasAssets)
2615
2615
  },
2616
2616
  {
2617
2617
  $Type : 'UI.ReferenceFacet',
@@ -2796,13 +2796,13 @@ annotate txsrv.TransactionSubmissions with @(
2796
2796
  $Type : 'UI.ReferenceFacet',
2797
2797
  Label : 'Error Details',
2798
2798
  Target : '@UI.FieldGroup#ErrorDetails',
2799
- ![@UI.Hidden]: (not hasErrors)
2799
+ @UI.Hidden: (not hasErrors)
2800
2800
  },
2801
2801
  {
2802
2802
  $Type : 'UI.ReferenceFacet',
2803
2803
  Label : 'Errors',
2804
2804
  Target : 'errors/@UI.LineItem',
2805
- ![@UI.Hidden]: (not hasErrors)
2805
+ @UI.Hidden: (not hasErrors)
2806
2806
  }
2807
2807
  ],
2808
2808
 
@@ -1,125 +1,141 @@
1
- using {odatano.cardano as db} from '../db/schema';
2
-
3
- /**
4
- * Cardano Wallet Worker Service (v2.0)
5
- *
6
- * Control + observability surface for the wallet worker / job engine:
7
- * - job submission (async build → sign → submit → confirm from server-side wallets)
8
- * - job status polling + cancellation
9
- * - read-only projections of jobs and registered worker wallets
10
- * - pause/resume of the local worker instance (admin)
11
- *
12
- * Security note: SubmitWalletJob executes value transfers with server-held keys —
13
- * the service requires authentication throughout; control actions and foreign-job
14
- * visibility are gated behind the Admin role. Jobs on HSM-backed wallets addition-
15
- * ally require the configured hsm.requiresRole (HSM_REQUIRES_ROLE), the same gate
16
- * the synchronous SignWithHsm path enforces. Keys are NEVER accepted or exposed
17
- * through this surface.
18
- */
19
- @requires: 'authenticated-user'
20
- service CardanoWorkerService @(impl: './cardano-worker-service') {
21
-
22
- @readonly
23
- @title : 'Wallet Jobs'
24
- @description: 'Asynchronous wallet-worker jobs. Non-admin callers see their own jobs only.'
25
- @restrict : [
26
- { grant: 'READ', to: 'Admin' },
27
- { grant: 'READ', where: 'createdBy = $user' }
28
- ]
29
- // dedupKey is the internal backing column of the idempotency constraint.
30
- entity WalletJobs as projection on db.CardanoWalletJobs excluding { dedupKey };
31
-
32
- @readonly
33
- @title : 'Worker Wallets'
34
- @description: 'Registered server-side worker wallets (addresses and stats only — no key material, no lease internals)'
35
- entity WorkerWallets as projection on db.CardanoWorkerWallets excluding { leaseOwner, leaseUntil };
36
-
37
- @title : 'Wallet Job Submission Result'
38
- type JobSubmissionResult {
39
- jobId : UUID;
40
- status : String(12);
41
- deduplicated : Boolean;
42
- }
43
-
44
- @title : 'Wallet Job Status'
45
- type JobStatus {
46
- jobId : UUID;
47
- walletId : String(50);
48
- kind : String(12);
49
- status : String(12);
50
- attempt : Integer;
51
- txHash : String(64);
52
- fee : String;
53
- errorCode : String(50);
54
- errorMessage : String(500);
55
- submittedAt : Timestamp;
56
- confirmedAt : Timestamp;
57
- finishedAt : Timestamp;
58
- }
59
-
60
- @title : 'Worker Status'
61
- type WorkerStatus {
62
- running : Boolean;
63
- wallets : many String;
64
- executing : many String;
65
- awaitingConfirmation : Integer;
66
- pendingJobs : Integer;
67
- }
68
-
69
- /**
70
- * Terminal job outcomes. Subscribing removes the need for a GetJobStatus poll loop:
71
- * (await cds.connect.to('CardanoWorkerService')).on('jobConfirmed', ({ data }) => …)
72
- */
73
- event jobConfirmed {
74
- jobId : UUID;
75
- walletId : String(50);
76
- kind : String(12);
77
- txHash : String(64);
78
- }
79
-
80
- event jobFailed {
81
- jobId : UUID;
82
- walletId : String(50);
83
- kind : String(12);
84
- txHash : String(64); // null when the job never reached the chain
85
- errorCode : String(50);
86
- errorMessage : String(500);
87
- }
88
-
89
- @title : 'Submit Wallet Job'
90
- @description: 'Queue an asynchronous transaction job for a worker wallet. Returns immediately with a jobId; poll GetJobStatus for the outcome. The request JSON is the same payload shape as the corresponding Build* action; senderAddress is always overridden with the wallet address.'
91
- action SubmitWalletJob(
92
- @title: 'Wallet Id' walletId : String(50),
93
- @title: 'Job Kind' kind : String(12),
94
- @title: 'Request JSON' requestJson : LargeString,
95
- @title: 'Idempotency Key' idempotencyKey : String(100),
96
- @title: 'Priority' priority : Integer,
97
- @title: 'Not Before' notBefore : Timestamp
98
- ) returns JobSubmissionResult;
99
-
100
- @title : 'Cancel Job'
101
- @description: 'Cancel a still-pending job. Jobs that started building may already reach the chain and cannot be cancelled.'
102
- action CancelJob(
103
- @title: 'Job Id' jobId : UUID
104
- ) returns Boolean;
105
-
106
- @title : 'Get Job Status'
107
- @description: 'Current lifecycle state of a wallet job (non-admins: own jobs only)'
108
- function GetJobStatus(
109
- @title: 'Job Id' jobId : UUID
110
- ) returns JobStatus;
111
-
112
- @title : 'Get Worker Status'
113
- @description: 'Live worker summary: running state, wallets, in-flight executions, confirmation backlog, queue depth'
114
- function GetWorkerStatus() returns WorkerStatus;
115
-
116
- @title : 'Pause Worker'
117
- @description: 'Stop the local worker instance (finishes in-flight steps; queued jobs stay pending).'
118
- @requires : 'Admin'
119
- action PauseWorker() returns Boolean;
120
-
121
- @title : 'Resume Worker'
122
- @description: 'Start/restart the local worker instance using the configured wallets.'
123
- @requires : 'Admin'
124
- action ResumeWorker() returns Boolean;
125
- }
1
+ using { WalletJobKind, ResolvedOutcome } from '../db/types';
2
+ using {odatano.cardano as db} from '../db/schema';
3
+
4
+ // Async wallet jobs signed with server-held keys, which are never accepted or returned here.
5
+ // Control actions and foreign jobs need Admin. A job needs the wallet's requiresRole and, on an
6
+ // HSM wallet, hsm.requiresRole. An agent token gets a 403 on every event of this service.
7
+ @requires: 'Transact'
8
+ @odatano.agent: 'closed'
9
+ service CardanoWorkerService @(impl: './cardano-worker-service') {
10
+
11
+ @readonly
12
+ @title : 'Wallet Jobs'
13
+ @description: 'Asynchronous wallet-worker jobs. Non-admin callers see their own jobs only.'
14
+ @restrict : [
15
+ { grant: 'READ', to: 'Admin' },
16
+ { grant: 'READ', where: 'createdBy = $user' }
17
+ ]
18
+ // dedupKey is the internal backing column of the idempotency constraint.
19
+ entity WalletJobs as projection on db.CardanoWalletJobs excluding { dedupKey };
20
+
21
+ @readonly
22
+ @title : 'Worker Wallets'
23
+ @description: 'Registered server-side worker wallets (addresses and stats only; no key material, no lease internals)'
24
+ entity WorkerWallets as projection on db.CardanoWorkerWallets excluding { leaseOwner, leaseUntil };
25
+
26
+ @title : 'Wallet Job Submission Result'
27
+ type JobSubmissionResult {
28
+ jobId : UUID;
29
+ status : String(12);
30
+ deduplicated : Boolean;
31
+ }
32
+
33
+ @title : 'Wallet Job Status'
34
+ type JobStatus {
35
+ jobId : UUID;
36
+ walletId : String(50);
37
+ kind : String(12);
38
+ status : String(12);
39
+ attempt : Integer;
40
+ txHash : String(64);
41
+ fee : String;
42
+ errorCode : String(50);
43
+ errorMessage : String(500);
44
+ submittedAt : Timestamp;
45
+ confirmedAt : Timestamp;
46
+ finishedAt : Timestamp;
47
+ resolution : String(500);
48
+ invalidationTxHash : String(64);
49
+ }
50
+
51
+ @title : 'Worker Status'
52
+ type WorkerStatus {
53
+ running : Boolean;
54
+ wallets : many String;
55
+ executing : many String;
56
+ awaitingConfirmation : Integer;
57
+ pendingJobs : Integer;
58
+ unresolvedJobs : Integer; // jobs an operator has to resolve (ResolveJob)
59
+ }
60
+
61
+ /** Terminal job outcome. Subscribe in process, or wait over HTTP with GetJobStatus(waitMs). */
62
+ event jobConfirmed {
63
+ jobId : UUID;
64
+ walletId : String(50);
65
+ kind : String(12);
66
+ txHash : String(64);
67
+ }
68
+
69
+ event jobFailed {
70
+ jobId : UUID;
71
+ walletId : String(50);
72
+ kind : String(12);
73
+ txHash : String(64); // null when the job never reached the chain
74
+ errorCode : String(50);
75
+ errorMessage : String(500);
76
+ }
77
+
78
+ /** The transaction can no longer land and nothing shows whether it did; ResolveJob settles it. */
79
+ event jobUnresolved {
80
+ jobId : UUID;
81
+ walletId : String(50);
82
+ kind : String(12);
83
+ txHash : String(64);
84
+ errorMessage : String(500);
85
+ }
86
+
87
+ @title : 'Submit Wallet Job'
88
+ @description: 'Queue an asynchronous transaction job for a worker wallet. Returns immediately with a jobId; poll GetJobStatus for the outcome. The request JSON is the same payload shape as the corresponding Build* action; senderAddress is always overridden with the wallet address. A retry with the same idempotencyKey and request returns the job that holds the key; another request under that key is a 409.'
89
+ @odatano.agent: 'operator'
90
+ action SubmitWalletJob(
91
+ @title: 'Wallet Id' walletId : String(50),
92
+ @title: 'Job Kind' @assert.range kind : WalletJobKind,
93
+ @title: 'Request JSON' requestJson : LargeString,
94
+ @title: 'Idempotency Key' idempotencyKey : String(100),
95
+ @title: 'Priority' @assert.range: [0, 10000] priority : Integer,
96
+ @title: 'Not Before' notBefore : Timestamp
97
+ ) returns JobSubmissionResult;
98
+
99
+ @title : 'Cancel Job'
100
+ @description: 'Cancel a still-pending job. Jobs that started building may already reach the chain and cannot be cancelled.'
101
+ @odatano.agent: 'operator'
102
+ action CancelJob(
103
+ @title: 'Job Id' jobId : UUID
104
+ ) returns Boolean;
105
+
106
+ @title : 'Get Job Status'
107
+ @description: 'Current lifecycle state of a wallet job (non-admins: own jobs only). With waitMs the call answers as soon as the job is confirmed, failed, cancelled or unresolved, or after that time with the state it has then. Keep waitMs below the timeout of the proxies in front of the service.'
108
+ @odatano.agent: 'operator'
109
+ function GetJobStatus(
110
+ @title: 'Job Id' jobId : UUID,
111
+ @title: 'Wait (ms)' @assert.range: [0, 30000] waitMs : Integer
112
+ ) returns JobStatus;
113
+
114
+ @title : 'Get Worker Status'
115
+ @description: 'Live worker summary: running state, wallets, in-flight executions, confirmation backlog, queue depth'
116
+ @odatano.agent: 'operator'
117
+ function GetWorkerStatus() returns WorkerStatus;
118
+
119
+ @title : 'Resolve Job'
120
+ @description: 'Settle an unresolved job after reading the chain: confirmed when its transaction is on chain with passing scripts, failed when it is not and can no longer land. failed is refused with 409 while the transaction is not expired and an input of it is unspent. txHash, when given, must be the job transaction. The job and its submission record follow the outcome; the job keeps its idempotency key either way.'
121
+ @requires : 'Admin'
122
+ @odatano.agent: 'operator'
123
+ action ResolveJob(
124
+ @title: 'Job Id' jobId : UUID not null,
125
+ @title: 'Outcome' @assert.range outcome : ResolvedOutcome not null,
126
+ @title: 'Transaction Hash' txHash : String(64),
127
+ @title: 'Note' note : String(300)
128
+ ) returns JobStatus;
129
+
130
+ @title : 'Pause Worker'
131
+ @description: 'Stop the local worker instance (finishes in-flight steps; queued jobs stay pending).'
132
+ @requires : 'Admin'
133
+ @odatano.agent: 'operator'
134
+ action PauseWorker() returns Boolean;
135
+
136
+ @title : 'Resume Worker'
137
+ @description: 'Start/restart the local worker instance using the configured wallets.'
138
+ @requires : 'Admin'
139
+ @odatano.agent: 'operator'
140
+ action ResumeWorker() returns Boolean;
141
+ }