@odatano/core 1.11.0 → 2.0.0-rc.10

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 (133) hide show
  1. package/@cds-models/CardanoAgentService/index.d.ts +255 -0
  2. package/@cds-models/CardanoAgentService/index.js +36 -0
  3. package/@cds-models/CardanoIndexerService/index.d.ts +177 -0
  4. package/@cds-models/CardanoIndexerService/index.js +27 -0
  5. package/@cds-models/CardanoODataService/index.d.ts +693 -2172
  6. package/@cds-models/CardanoODataService/index.js +88 -390
  7. package/@cds-models/CardanoSignService/index.d.ts +448 -1576
  8. package/@cds-models/CardanoSignService/index.js +62 -293
  9. package/@cds-models/CardanoTransactionService/index.d.ts +437 -1494
  10. package/@cds-models/CardanoTransactionService/index.js +60 -271
  11. package/@cds-models/CardanoWorkerService/index.d.ts +224 -0
  12. package/@cds-models/CardanoWorkerService/index.js +32 -0
  13. package/@cds-models/_/index.d.ts +70 -40
  14. package/@cds-models/_/index.js +17 -32
  15. package/@cds-models/cds/outbox/index.d.ts +28 -0
  16. package/@cds-models/index.d.ts +225 -522
  17. package/@cds-models/index.js +35 -218
  18. package/@cds-models/odatano/cardano/index.d.ts +919 -2884
  19. package/@cds-models/odatano/cardano/index.js +115 -536
  20. package/@cds-models/sap/common/index.d.ts +196 -600
  21. package/@cds-models/sap/common/index.js +28 -269
  22. package/README.md +194 -102
  23. package/db/schema.cds +388 -1
  24. package/db/types.cds +48 -0
  25. package/package.json +48 -33
  26. package/src/index.d.ts +7 -1
  27. package/src/index.js +30 -2
  28. package/src/plugin.js +33 -20
  29. package/srv/blockchain/backends/blockfrost-backend.d.ts +21 -2
  30. package/srv/blockchain/backends/blockfrost-backend.js +69 -25
  31. package/srv/blockchain/backends/cardano-backend.d.ts +69 -0
  32. package/srv/blockchain/backends/cardano-backend.js +13 -0
  33. package/srv/blockchain/backends/koios-backend.d.ts +26 -2
  34. package/srv/blockchain/backends/koios-backend.js +148 -25
  35. package/srv/blockchain/backends/ogmios-backend.d.ts +60 -9
  36. package/srv/blockchain/backends/ogmios-backend.js +326 -10
  37. package/srv/blockchain/cardano-client.d.ts +19 -0
  38. package/srv/blockchain/cardano-client.js +36 -0
  39. package/srv/blockchain/cardano-indexer.d.ts +50 -1
  40. package/srv/blockchain/cardano-indexer.js +193 -0
  41. package/srv/blockchain/crawler/crawler.d.ts +176 -0
  42. package/srv/blockchain/crawler/crawler.js +744 -0
  43. package/srv/blockchain/crawler/hooks.d.ts +43 -0
  44. package/srv/blockchain/crawler/hooks.js +62 -0
  45. package/srv/blockchain/crawler/index.d.ts +35 -0
  46. package/srv/blockchain/crawler/index.js +168 -0
  47. package/srv/blockchain/crawler/sync-state.d.ts +106 -0
  48. package/srv/blockchain/crawler/sync-state.js +287 -0
  49. package/srv/blockchain/signing/hsm-signer.d.ts +45 -0
  50. package/srv/blockchain/signing/hsm-signer.js +8 -1
  51. package/srv/blockchain/transaction-building/buildooor-tx.d.ts +20 -0
  52. package/srv/blockchain/transaction-building/buildooor-tx.js +104 -20
  53. package/srv/blockchain/wallet-worker/build-request.d.ts +26 -0
  54. package/srv/blockchain/wallet-worker/build-request.js +370 -0
  55. package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +117 -0
  56. package/srv/blockchain/wallet-worker/confirmation-tracker.js +290 -0
  57. package/srv/blockchain/wallet-worker/index.d.ts +14 -0
  58. package/srv/blockchain/wallet-worker/index.js +80 -0
  59. package/srv/blockchain/wallet-worker/job-store.d.ts +272 -0
  60. package/srv/blockchain/wallet-worker/job-store.js +597 -0
  61. package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +43 -0
  62. package/srv/blockchain/wallet-worker/lease-heartbeat.js +99 -0
  63. package/srv/blockchain/wallet-worker/signers.d.ts +57 -0
  64. package/srv/blockchain/wallet-worker/signers.js +131 -0
  65. package/srv/blockchain/wallet-worker/wallet-worker.d.ts +145 -0
  66. package/srv/blockchain/wallet-worker/wallet-worker.js +542 -0
  67. package/srv/cardano-agent-service.cds +150 -0
  68. package/srv/cardano-agent-service.d.ts +2 -0
  69. package/srv/cardano-agent-service.js +16 -0
  70. package/srv/cardano-indexer-service.cds +106 -0
  71. package/srv/cardano-indexer-service.d.ts +2 -0
  72. package/srv/cardano-indexer-service.js +79 -0
  73. package/srv/cardano-service.js +79 -4
  74. package/srv/cardano-sign-service.cds +200 -180
  75. package/srv/cardano-tx-service.cds +32 -26
  76. package/srv/cardano-tx-service.d.ts +1 -11
  77. package/srv/cardano-tx-service.js +107 -200
  78. package/srv/cardano-worker-service.cds +125 -0
  79. package/srv/cardano-worker-service.d.ts +2 -0
  80. package/srv/cardano-worker-service.js +199 -0
  81. package/srv/server.d.ts +34 -2
  82. package/srv/server.js +246 -36
  83. package/srv/utils/agent-grants-config.d.ts +65 -0
  84. package/srv/utils/agent-grants-config.js +148 -0
  85. package/srv/utils/agent-grants.d.ts +314 -0
  86. package/srv/utils/agent-grants.js +821 -0
  87. package/srv/utils/agent-token-auth.d.ts +19 -0
  88. package/srv/utils/agent-token-auth.js +81 -0
  89. package/srv/utils/collections.d.ts +13 -0
  90. package/srv/utils/collections.js +24 -0
  91. package/srv/utils/crypto.d.ts +16 -0
  92. package/srv/utils/crypto.js +75 -0
  93. package/srv/utils/db-sanitize.d.ts +40 -0
  94. package/srv/utils/db-sanitize.js +98 -0
  95. package/srv/utils/error-codes.d.ts +6 -0
  96. package/srv/utils/error-codes.js +6 -0
  97. package/srv/utils/errors.d.ts +12 -0
  98. package/srv/utils/errors.js +45 -0
  99. package/srv/utils/liveness.d.ts +23 -0
  100. package/srv/utils/liveness.js +49 -0
  101. package/srv/utils/mappers.d.ts +27 -0
  102. package/srv/utils/mappers.js +80 -10
  103. package/srv/utils/rate-limiter.d.ts +57 -0
  104. package/srv/utils/rate-limiter.js +126 -0
  105. package/srv/utils/service-events.d.ts +26 -0
  106. package/srv/utils/service-events.js +46 -0
  107. package/srv/utils/tx-request-parsers.d.ts +71 -0
  108. package/srv/utils/tx-request-parsers.js +202 -0
  109. package/srv/utils/tx-utils.d.ts +2 -1
  110. package/srv/utils/tx-utils.js +3 -2
  111. package/srv/utils/types.d.ts +17 -1
  112. package/@cds-models/CardanoODataService/index.d.ts.map +0 -1
  113. package/@cds-models/CardanoODataService/index.js.map +0 -1
  114. package/@cds-models/CardanoODataService/index.ts +0 -776
  115. package/@cds-models/CardanoSignService/index.d.ts.map +0 -1
  116. package/@cds-models/CardanoSignService/index.js.map +0 -1
  117. package/@cds-models/CardanoSignService/index.ts +0 -569
  118. package/@cds-models/CardanoTransactionService/index.d.ts.map +0 -1
  119. package/@cds-models/CardanoTransactionService/index.js.map +0 -1
  120. package/@cds-models/CardanoTransactionService/index.ts +0 -526
  121. package/@cds-models/_/index.d.ts.map +0 -1
  122. package/@cds-models/_/index.js.map +0 -1
  123. package/@cds-models/_/index.ts +0 -96
  124. package/@cds-models/cds/outbox/index.ts +0 -27
  125. package/@cds-models/index.d.ts.map +0 -1
  126. package/@cds-models/index.js.map +0 -1
  127. package/@cds-models/index.ts +0 -245
  128. package/@cds-models/odatano/cardano/index.d.ts.map +0 -1
  129. package/@cds-models/odatano/cardano/index.js.map +0 -1
  130. package/@cds-models/odatano/cardano/index.ts +0 -789
  131. package/@cds-models/sap/common/index.d.ts.map +0 -1
  132. package/@cds-models/sap/common/index.js.map +0 -1
  133. package/@cds-models/sap/common/index.ts +0 -249
@@ -1,180 +1,200 @@
1
- using {odatano.cardano as db} from '../db/schema';
2
- using {Bech32} from '../db/types';
3
-
4
- /**
5
- * Cardano Sign Service
6
- *
7
- * Handles the external signing workflow for Cardano transactions, including:
8
- * - Creating signing requests with transaction details and signing instructions
9
- * - Verifying signatures of signed transactions and storing verification results
10
- * - Submitting verified transactions to the blockchain and tracking submission status
11
- * - Providing actions for signing with a Hardware Security Module (HSM) and retrieving HSM status
12
- *
13
- * Security note: see CardanoODataService (cardano-service.cds) for the rationale
14
- * on service-level auth without per-resource ownership enforcement.
15
- */
16
- @requires: 'authenticated-user'
17
- service CardanoSignService @(impl: './cardano-sign-service') {
18
-
19
- // ---------------------------------------------------------------------------
20
- // Signing Workflow Projections
21
- // ---------------------------------------------------------------------------
22
- @readonly
23
- @title : 'Signature Verifications'
24
- @description: 'Projection for Signature Verifications - stores verification results'
25
- entity SignatureVerifications as projection on db.SignatureVerifications;
26
-
27
- @readonly
28
- @title : 'Address Signing Requests'
29
- @description: 'Projection for retrieving signing requests by address'
30
- entity AddressSigningRequests as projection on db.AddressSigningRequests;
31
-
32
- @readonly
33
- @title : 'Transaction Builds'
34
- @description: 'Projection for Transaction Builds - needed by CreateSigningRequest to look up build details'
35
- entity TransactionBuilds as projection on db.TransactionBuilds;
36
-
37
-
38
- @readonly
39
- @title : 'Transaction Submissions'
40
- @description: 'Projection for Transaction Submissions - stores submission results'
41
- entity TransactionSubmissions as projection on db.TransactionSubmissions;
42
-
43
- @readonly
44
- @title : 'Signing Requests'
45
- @description: 'Projection for Signing Requests - tracks signing workflow'
46
- entity SigningRequests as projection on db.SigningRequests;
47
-
48
- @title : 'Verify Signature'
49
- @description: 'Verify the signature of a signed transaction. Stores the verification result for audit trail.'
50
- action VerifySignature(
51
- @title: 'Signing Request ID'
52
- @description: 'The unique identifier of the signing request'
53
- signingRequestId: UUID,
54
- @title: 'Signed Transaction CBOR'
55
- @description: 'The signed transaction CBOR to verify'
56
- signedTxCbor: String,
57
- @title: 'Signer Type'
58
- @description: 'Type of signer used (cardano-cli | browser-wallet | hardware-wallet | custom)'
59
- signerType: String(20),
60
- @title: 'Signer Info'
61
- @description: 'Additional signer information (wallet name, etc.)'
62
- signerInfo: String(100),
63
- @title: 'Sender Address'
64
- @description: 'Optional sender address for ownership verification. When provided, verifies the signing request belongs to this address.'
65
- address: Bech32) returns SignatureVerifications;
66
-
67
- @title : 'Submit Verified Transaction'
68
- @description: 'Verify and submit a signed transaction in one step. Updates the signing request status and creates submission record.'
69
- action SubmitVerifiedTransaction(
70
- @title: 'Signing Request ID'
71
- @description: 'The unique identifier of the signing request'
72
- signingRequestId: UUID,
73
- @title: 'Signed Transaction CBOR'
74
- @description: 'The signed transaction CBOR'
75
- signedTxCbor: String,
76
- @title: 'Signer Type'
77
- @description: 'Type of signer used'
78
- signerType: String(20),
79
- @title: 'Signer Info'
80
- @description: 'Additional signer information'
81
- signerInfo: String(100),
82
- @title: 'Sender Address'
83
- @description: 'Optional sender address for ownership verification. When provided, verifies the signing request belongs to this address.'
84
- address: Bech32,
85
- @title: 'Defer Submit'
86
- @description: 'When true, verify + claim run on the caller''s transaction and the network submit happens detached AFTER the caller''s commit. Returns immediately with the tx hash (= tx body hash) and status ''pending''. Designed for in-process CAP consumers whose request transaction would otherwise deadlock the pooled sqlite connection (KNOWN_ISSUES #11). Track the outcome via the signing request / submission status.'
87
- deferSubmit: Boolean) returns TransactionSubmissions;
88
-
89
-
90
- // ---------------------------------------------------------------------------
91
- // CIP-30 signData (COSE_Sign1) message-signature verification
92
- // ---------------------------------------------------------------------------
93
-
94
- // Public override: this action is the crypto check behind wallet-based LOGIN,
95
- // so the caller is not yet authenticated. It is a stateless verification —
96
- // no DB write, no key access, no state — so exposing it leaks nothing.
97
- @requires : 'any'
98
- @title : 'Verify Data Signature (CIP-30 signData)'
99
- @description: 'Verify a COSE_Sign1 message signature against a bech32 address. Confirms the Ed25519 signature, that the signer key hashes to the address payment credential, and (optionally) that the signed payload matches an expected value.'
100
- action VerifyDataSignature(
101
- @description: 'Bech32 address the wallet claimed to sign with'
102
- address : Bech32,
103
- @description: 'Hex-encoded COSE_Sign1 CBOR (the `signature` field from CIP-30 signData)'
104
- coseSignature : String,
105
- @description: 'Hex-encoded COSE_Key CBOR (the `key` field from CIP-30 signData)'
106
- coseKey : String,
107
- @description: 'Optional expected UTF-8 payload; when set, the signed payload must equal it (anti-replay). When omitted, the decoded payload is returned for the caller to check.'
108
- expectedPayload: String) returns {
109
- @description: 'Whether the signature is valid and all checks passed' valid : Boolean;
110
- @description: 'Failure detail when not valid' reason : String;
111
- @description: 'UTF-8 of the signed payload, echoed back' signedPayload : String;
112
- @description: 'Hex blake2b-224 of the signer public key' signerVkh : String;
113
- };
114
-
115
- // ---------------------------------------------------------------------------
116
- // General Signing Workflow Actions
117
- // ---------------------------------------------------------------------------
118
-
119
- @title : 'Create Signing Request'
120
- @description: 'Create a signing request for external signing. Returns transaction details, signing instructions, and CLI commands. The request is persisted for audit trail.'
121
- action CreateSigningRequest(
122
- @title: 'Build ID'
123
- @description: 'The unique identifier of the transaction build'
124
- buildId: UUID,
125
- @title: 'Message to Signer'
126
- @description: 'A message to include for the signer'
127
- message: String) returns SigningRequests;
128
-
129
- @title : 'Get Signing Request'
130
- @description: 'Retrieve an existing signing request by ID'
131
- action GetSigningRequest(
132
- @title: 'Signing Request ID'
133
- @description: 'The unique identifier of the signing request'
134
- signingRequestId: UUID) returns SigningRequests;
135
-
136
- @title : 'Address Signing Requests'
137
- @description: 'Projection for retrieving signing requests by address'
138
- action GetSigningRequestsByAddress(
139
- @title: 'Bech32 Address'
140
- @description: 'The Bech32 encoded address to retrieve signing requests for'
141
- address: Bech32) returns array of AddressSigningRequests;
142
-
143
- // ---------------------------------------------------------------------------
144
- // HSM (Hardware Security Module) Signing Actions
145
- // ---------------------------------------------------------------------------
146
-
147
- @title : 'Sign with HSM'
148
- @description: 'Sign a transaction using the configured Hardware Security Module. Creates a signing request, signs with the HSM, and verifies the signature. Returns the signing request with status verified.'
149
- action SignWithHsm(
150
- @title: 'Build ID'
151
- @description: 'The unique identifier of the transaction build to sign'
152
- buildId: UUID,
153
- @title: 'Sender Address'
154
- @description: 'Optional sender address for ownership verification. When provided, verifies the build belongs to this address.'
155
- address: Bech32) returns SigningRequests;
156
-
157
- @title : 'Sign and Submit with HSM'
158
- @description: 'Sign a transaction using the HSM and submit it to the blockchain in one atomic operation. Returns the transaction submission details.'
159
- action SignAndSubmitWithHsm(
160
- @title: 'Build ID'
161
- @description: 'The unique identifier of the transaction build to sign and submit'
162
- buildId: UUID,
163
- @title: 'Sender Address'
164
- @description: 'Optional sender address for ownership verification. When provided, verifies the build belongs to this address.'
165
- address: Bech32,
166
- @title: 'Defer Submit'
167
- @description: 'When true, sign + verify + claim run on the caller''s transaction and the network submit happens detached AFTER the caller''s commit (see SubmitVerifiedTransaction.deferSubmit).'
168
- deferSubmit: Boolean) returns TransactionSubmissions;
169
-
170
- @title : 'Get HSM Status'
171
- @description: 'Check the current status of the HSM connection and key availability.'
172
- action GetHsmStatus() returns {
173
- @title: 'Connected' @description: 'Whether the HSM session is active' connected : Boolean;
174
- @title: 'Key ID' @description: 'The PKCS#11 key identifier in use' keyId : String;
175
- @title: 'Key Label' @description: 'The PKCS#11 key label in use' keyLabel : String;
176
- @title: 'Public Key Hash' @description: 'Blake2b-224 hash of the HSM Ed25519 public key (= Cardano verification key hash)' publicKeyHash : String;
177
- @title: 'Cardano Address' @description: 'Enterprise Cardano address derived from the HSM public key' cardanoAddress : String;
178
- };
179
-
180
- }
1
+ using {odatano.cardano as db} from '../db/schema';
2
+ using {Bech32} from '../db/types';
3
+
4
+ /**
5
+ * Cardano Sign Service
6
+ *
7
+ * Handles the external signing workflow for Cardano transactions, including:
8
+ * - Creating signing requests with transaction details and signing instructions
9
+ * - Verifying signatures of signed transactions and storing verification results
10
+ * - Submitting verified transactions to the blockchain and tracking submission status
11
+ * - Providing actions for signing with a Hardware Security Module (HSM) and retrieving HSM status
12
+ *
13
+ * Security note: see CardanoODataService (cardano-service.cds) for the rationale on auth
14
+ * without per-resource ownership enforcement. Deliberately NO service-level @requires:
15
+ * CAP checks it on every request BEFORE the operation annotation, which silenced the
16
+ * `any` on VerifyDataSignature (anonymous callers got the 401 challenge first). The
17
+ * requirement therefore sits on each element; VerifyDataSignature alone is public.
18
+ */
19
+ // Service-level 'any' on purpose: CAP authorizes the service BEFORE the operation and
20
+ // treats a service without a service-level @requires as authenticated-user under
21
+ // NODE_ENV=production, which would 401 the anonymous operation below despite its own
22
+ // 'any'. Every element carries its requirement; the service itself refuses nothing.
23
+ @requires: 'any'
24
+ service CardanoSignService @(impl: './cardano-sign-service') {
25
+
26
+ // ---------------------------------------------------------------------------
27
+ // Signing Workflow Projections
28
+ // ---------------------------------------------------------------------------
29
+ @readonly
30
+ @title : 'Signature Verifications'
31
+ @description: 'Projection for Signature Verifications - stores verification results'
32
+ @requires : 'authenticated-user'
33
+ entity SignatureVerifications as projection on db.SignatureVerifications;
34
+
35
+ @readonly
36
+ @title : 'Address Signing Requests'
37
+ @description: 'Projection for retrieving signing requests by address'
38
+ @requires : 'authenticated-user'
39
+ entity AddressSigningRequests as projection on db.AddressSigningRequests;
40
+
41
+ @readonly
42
+ @title : 'Transaction Builds'
43
+ @description: 'Projection for Transaction Builds - needed by CreateSigningRequest to look up build details'
44
+ @requires : 'authenticated-user'
45
+ entity TransactionBuilds as projection on db.TransactionBuilds;
46
+
47
+
48
+ @readonly
49
+ @title : 'Transaction Submissions'
50
+ @description: 'Projection for Transaction Submissions - stores submission results'
51
+ @requires : 'authenticated-user'
52
+ entity TransactionSubmissions as projection on db.TransactionSubmissions;
53
+
54
+ @readonly
55
+ @title : 'Signing Requests'
56
+ @description: 'Projection for Signing Requests - tracks signing workflow'
57
+ @requires : 'authenticated-user'
58
+ entity SigningRequests as projection on db.SigningRequests;
59
+
60
+ @title : 'Verify Signature'
61
+ @description: 'Verify the signature of a signed transaction. Stores the verification result for audit trail.'
62
+ @requires : 'authenticated-user'
63
+ action VerifySignature(
64
+ @title: 'Signing Request ID'
65
+ @description: 'The unique identifier of the signing request'
66
+ signingRequestId: UUID,
67
+ @title: 'Signed Transaction CBOR'
68
+ @description: 'The signed transaction CBOR to verify'
69
+ signedTxCbor: String,
70
+ @title: 'Signer Type'
71
+ @description: 'Type of signer used (cardano-cli | browser-wallet | hardware-wallet | custom)'
72
+ signerType: String(20),
73
+ @title: 'Signer Info'
74
+ @description: 'Additional signer information (wallet name, etc.)'
75
+ signerInfo: String(100),
76
+ @title: 'Sender Address'
77
+ @description: 'Optional sender address for ownership verification. When provided, verifies the signing request belongs to this address.'
78
+ address: Bech32) returns SignatureVerifications;
79
+
80
+ @title : 'Submit Verified Transaction'
81
+ @description: 'Verify and submit a signed transaction in one step. Updates the signing request status and creates submission record.'
82
+ @requires : 'authenticated-user'
83
+ action SubmitVerifiedTransaction(
84
+ @title: 'Signing Request ID'
85
+ @description: 'The unique identifier of the signing request'
86
+ signingRequestId: UUID,
87
+ @title: 'Signed Transaction CBOR'
88
+ @description: 'The signed transaction CBOR'
89
+ signedTxCbor: String,
90
+ @title: 'Signer Type'
91
+ @description: 'Type of signer used'
92
+ signerType: String(20),
93
+ @title: 'Signer Info'
94
+ @description: 'Additional signer information'
95
+ signerInfo: String(100),
96
+ @title: 'Sender Address'
97
+ @description: 'Optional sender address for ownership verification. When provided, verifies the signing request belongs to this address.'
98
+ address: Bech32,
99
+ @title: 'Defer Submit'
100
+ @description: 'When true, verify + claim run on the caller''s transaction and the network submit happens detached AFTER the caller''s commit. Returns immediately with the tx hash (= tx body hash) and status ''pending''. Designed for in-process CAP consumers whose request transaction would otherwise deadlock the pooled sqlite connection (KNOWN_ISSUES #11). Track the outcome via the signing request / submission status.'
101
+ deferSubmit: Boolean) returns TransactionSubmissions;
102
+
103
+
104
+ // ---------------------------------------------------------------------------
105
+ // CIP-30 signData (COSE_Sign1) message-signature verification
106
+ // ---------------------------------------------------------------------------
107
+
108
+ // Public override: this action is the crypto check behind wallet-based LOGIN,
109
+ // so the caller is not yet authenticated. It is a stateless verification —
110
+ // no DB write, no key access, no state — so exposing it leaks nothing.
111
+ @requires : 'any'
112
+ @title : 'Verify Data Signature (CIP-30 signData)'
113
+ @description: 'Verify a COSE_Sign1 message signature against a bech32 address. Confirms the Ed25519 signature, that the signer key hashes to the address payment credential, and (optionally) that the signed payload matches an expected value.'
114
+ action VerifyDataSignature(
115
+ @description: 'Bech32 address the wallet claimed to sign with'
116
+ address : Bech32,
117
+ @description: 'Hex-encoded COSE_Sign1 CBOR (the `signature` field from CIP-30 signData)'
118
+ coseSignature : String,
119
+ @description: 'Hex-encoded COSE_Key CBOR (the `key` field from CIP-30 signData)'
120
+ coseKey : String,
121
+ @description: 'Optional expected UTF-8 payload; when set, the signed payload must equal it (anti-replay). When omitted, the decoded payload is returned for the caller to check.'
122
+ expectedPayload: String) returns {
123
+ @description: 'Whether the signature is valid and all checks passed' valid : Boolean;
124
+ @description: 'Failure detail when not valid' reason : String;
125
+ @description: 'UTF-8 of the signed payload, echoed back' signedPayload : String;
126
+ @description: 'Hex blake2b-224 of the signer public key' signerVkh : String;
127
+ };
128
+
129
+ // ---------------------------------------------------------------------------
130
+ // General Signing Workflow Actions
131
+ // ---------------------------------------------------------------------------
132
+
133
+ @title : 'Create Signing Request'
134
+ @description: 'Create a signing request for external signing. Returns transaction details, signing instructions, and CLI commands. The request is persisted for audit trail.'
135
+ @requires : 'authenticated-user'
136
+ action CreateSigningRequest(
137
+ @title: 'Build ID'
138
+ @description: 'The unique identifier of the transaction build'
139
+ buildId: UUID,
140
+ @title: 'Message to Signer'
141
+ @description: 'A message to include for the signer'
142
+ message: String) returns SigningRequests;
143
+
144
+ @title : 'Get Signing Request'
145
+ @description: 'Retrieve an existing signing request by ID'
146
+ @requires : 'authenticated-user'
147
+ action GetSigningRequest(
148
+ @title: 'Signing Request ID'
149
+ @description: 'The unique identifier of the signing request'
150
+ signingRequestId: UUID) returns SigningRequests;
151
+
152
+ @title : 'Address Signing Requests'
153
+ @description: 'Projection for retrieving signing requests by address'
154
+ @requires : 'authenticated-user'
155
+ action GetSigningRequestsByAddress(
156
+ @title: 'Bech32 Address'
157
+ @description: 'The Bech32 encoded address to retrieve signing requests for'
158
+ address: Bech32) returns array of AddressSigningRequests;
159
+
160
+ // ---------------------------------------------------------------------------
161
+ // HSM (Hardware Security Module) Signing Actions
162
+ // ---------------------------------------------------------------------------
163
+
164
+ @title : 'Sign with HSM'
165
+ @description: 'Sign a transaction using the configured Hardware Security Module. Creates a signing request, signs with the HSM, and verifies the signature. Returns the signing request with status verified.'
166
+ @requires : 'authenticated-user'
167
+ action SignWithHsm(
168
+ @title: 'Build ID'
169
+ @description: 'The unique identifier of the transaction build to sign'
170
+ buildId: UUID,
171
+ @title: 'Sender Address'
172
+ @description: 'Optional sender address for ownership verification. When provided, verifies the build belongs to this address.'
173
+ address: Bech32) returns SigningRequests;
174
+
175
+ @title : 'Sign and Submit with HSM'
176
+ @description: 'Sign a transaction using the HSM and submit it to the blockchain in one atomic operation. Returns the transaction submission details.'
177
+ @requires : 'authenticated-user'
178
+ action SignAndSubmitWithHsm(
179
+ @title: 'Build ID'
180
+ @description: 'The unique identifier of the transaction build to sign and submit'
181
+ buildId: UUID,
182
+ @title: 'Sender Address'
183
+ @description: 'Optional sender address for ownership verification. When provided, verifies the build belongs to this address.'
184
+ address: Bech32,
185
+ @title: 'Defer Submit'
186
+ @description: 'When true, sign + verify + claim run on the caller''s transaction and the network submit happens detached AFTER the caller''s commit (see SubmitVerifiedTransaction.deferSubmit).'
187
+ deferSubmit: Boolean) returns TransactionSubmissions;
188
+
189
+ @title : 'Get HSM Status'
190
+ @description: 'Check the current status of the HSM connection and key availability.'
191
+ @requires : 'authenticated-user'
192
+ action GetHsmStatus() returns {
193
+ @title: 'Connected' @description: 'Whether the HSM session is active' connected : Boolean;
194
+ @title: 'Key ID' @description: 'The PKCS#11 key identifier in use' keyId : String;
195
+ @title: 'Key Label' @description: 'The PKCS#11 key label in use' keyLabel : String;
196
+ @title: 'Public Key Hash' @description: 'Blake2b-224 hash of the HSM Ed25519 public key (= Cardano verification key hash)' publicKeyHash : String;
197
+ @title: 'Cardano Address' @description: 'Enterprise Cardano address derived from the HSM public key' cardanoAddress : String;
198
+ };
199
+
200
+ }
@@ -1,5 +1,8 @@
1
1
  using {odatano.cardano as db} from '../db/schema';
2
- using {Bech32, Lovelace} from '../db/types';
2
+ using {
3
+ Bech32,
4
+ Lovelace
5
+ } from '../db/types';
3
6
 
4
7
 
5
8
  /**
@@ -43,20 +46,21 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
43
46
  @description: 'Projection for Transaction Build Output Assets'
44
47
  entity TransactionBuildOutputAssets as projection on db.TransactionBuildOutputAssets;
45
48
 
46
- @readonly
47
- @title : 'Transaction Submissions'
48
- @description: 'Projection for Transaction Submissions'
49
+ @readonly
50
+ @title : 'Transaction Submissions'
51
+ @description: 'Projection for Transaction Submissions'
49
52
  entity TransactionSubmissions as projection on db.TransactionSubmissions
50
53
  actions {
51
54
  @title : 'Check Submission Status'
52
55
  @description: 'Check the status of a submitted transaction by querying the blockchain for confirmation'
53
56
  action CheckSubmissionStatus() returns TransactionSubmissions;
54
57
  };
58
+
55
59
  /**
56
60
  * TransactionSubmissions status flow:
57
- * pending ──[submit to chain]──→ submitted (internal, in SubmitTransaction handler)
58
- * submitted ──[CheckSubmissionStatus]──→ confirmed | stays submitted (conditional)
59
- * pending | submitted ──→ failed (blockchain error)
61
+ * pending -> [submit to chain] -> submitted (internal, in SubmitTransaction handler)
62
+ * submitted -> [CheckSubmissionStatus] confirmed | stays submitted (conditional)
63
+ * pending | submitted -> failed (blockchain error)
60
64
  */
61
65
  annotate CardanoTransactionService.TransactionSubmissions with @flow.status: status actions {
62
66
  CheckSubmissionStatus @from : [ #submitted];
@@ -117,7 +121,7 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
117
121
  validityStartMs: String,
118
122
  @title: 'Validity End (Posix ms)'
119
123
  @description: 'Optional. Validity-interval end in Posix milliseconds. Passed through to the builder only; for non-script transfers the builder leaves bounds unset unless provided.'
120
- validityEndMs: String) returns TransactionBuilds;
124
+ validityEndMs: String) returns TransactionBuilds;
121
125
 
122
126
  @title : 'Build Transaction with Metadata'
123
127
  @description: 'Build a transaction with custom metadata from sender to recipient with specified amount and change address'
@@ -136,7 +140,7 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
136
140
  changeAddress: Bech32,
137
141
  @title: 'Metadata JSON'
138
142
  @description: 'The JSON representation of the transaction metadata as string'
139
- metadataJson: String) returns TransactionBuilds;
143
+ metadataJson: String) returns TransactionBuilds;
140
144
 
141
145
  @title : 'Build Multi-Asset Transaction'
142
146
  @description: 'Build a transaction to send native assets (tokens) along with ADA'
@@ -167,7 +171,7 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
167
171
  validityStartMs: String,
168
172
  @title: 'Validity End (Posix ms)'
169
173
  @description: 'Optional. Validity-interval end in Posix milliseconds. Passed through to the builder only; for non-script transfers the builder leaves bounds unset unless provided.'
170
- validityEndMs: String) returns TransactionBuilds;
174
+ validityEndMs: String) returns TransactionBuilds;
171
175
 
172
176
  @title : 'Build Minting Transaction'
173
177
  @description: 'Build a transaction to mint or burn native assets'
@@ -182,10 +186,10 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
182
186
  @description: 'The amount of ADA to send with minted assets in lovelace'
183
187
  lovelaceAmount: Lovelace,
184
188
  @title: 'Mint Actions JSON'
185
- @description: 'JSON array of mint/burn actions (format: [{"assetUnit":"policyId+assetName","quantity":"amount"}])'
189
+ @description: 'JSON array of mint/burn actions (format: [{"assetUnit":"policyId+assetName","quantity":"amount"}]). Multi-policy mints: each action may additionally carry its own "mintingPolicyScript" (CBOR hex, pre-applied) and "redeemerJson" (JSON-encoded PlutusData string), overriding the top-level policy/redeemer for that action. Actions resolving to the same policy must agree on their redeemer (the ledger carries one redeemer per policy).'
186
190
  mintActionsJson: String,
187
191
  @title: 'Minting Policy Script'
188
- @description: 'The minting policy script in CBOR hex format'
192
+ @description: 'The minting policy script in CBOR hex format. Actions without a per-action mintingPolicyScript mint under this script.'
189
193
  mintingPolicyScript: String,
190
194
  @title: 'Change Address'
191
195
  @description: 'The Bech32 encoded address for returning change -defaults to sender address if not specified'
@@ -211,6 +215,9 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
211
215
  @title: 'Reference Inputs JSON'
212
216
  @description: 'Optional JSON array of {txHash, outputIndex} UTxOs to include as CIP-31 reference inputs (read-only, not consumed). Use for oracle feeds, shared config UTxOs, or script reference UTxOs. Buildooor builder only.'
213
217
  referenceInputsJson: String,
218
+ @title: 'Extra Outputs JSON'
219
+ @description: 'Optional JSON array of additional outputs [{address, lovelaceAmount, assets?, inlineDatumJson?, referenceScriptHex?}] appended after the primary recipient output. When present, the extra outputs carry the minted assets (declare each minted unit in an entry''s assets) and the primary output stays ADA-only — used to place each minted token on its own output with its own inline datum (e.g. datum-bound predicate tokens). Each entry is independently min-ADA checked.'
220
+ extraOutputsJson: String,
214
221
  @title: 'Metadata JSON'
215
222
  @description: 'Optional transaction metadata as JSON (CIP-20 / label-674 etc.). Object keyed by numeric label string. Attached as auxiliary_data to the mint tx so chain-watchers can correlate off-chain context (receipt IDs, free-form notes).'
216
223
  metadataJson: String,
@@ -222,14 +229,14 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
222
229
  validityStartMs: String,
223
230
  @title: 'Validity End (Posix ms)'
224
231
  @description: 'Optional. Sets the transaction validity-interval end in Posix milliseconds. Required finite value for Plutus validators that call expect Finite(upper) on tx.validity_range.upper_bound. Defaults to now + 3 600 000 ms when omitted.'
225
- validityEndMs: String) returns TransactionBuilds;
232
+ validityEndMs: String) returns TransactionBuilds;
226
233
 
227
234
  @title : 'Get Build Details'
228
235
  @description: 'Retrieve transaction build details using the Build Id'
229
236
  action GetBuildDetails(
230
237
  @title: 'Build Id'
231
238
  @description: 'The unique identifier of the transaction build'
232
- buildId: UUID) returns TransactionBuilds;
239
+ buildId: UUID) returns TransactionBuilds;
233
240
 
234
241
  @title : 'Submit Transaction'
235
242
  @description: 'Submit a transaction to the Cardano network using a build ID and signed CBOR'
@@ -239,7 +246,7 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
239
246
  buildId: UUID,
240
247
  @title: 'Signed Transaction CBOR'
241
248
  @description: 'The CBOR of the signed transaction'
242
- signedTxCbor: String) returns TransactionSubmissions;
249
+ signedTxCbor: String) returns TransactionSubmissions;
243
250
 
244
251
  @title : 'Submit Signed Transaction'
245
252
  @description: 'Submit a signed transaction to the Cardano network'
@@ -249,7 +256,7 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
249
256
  signedTxCbor: String,
250
257
  @title: 'Network'
251
258
  @description: 'The Cardano network to submit the transaction to (e.g., mainnet, testnet)'
252
- network: String(10)) returns TransactionSubmissions;
259
+ network: String(10)) returns TransactionSubmissions;
253
260
 
254
261
  @title : 'Build Plutus Spend Transaction'
255
262
  @description: 'Build a transaction to spend a UTxO locked at a Plutus script address'
@@ -326,13 +333,14 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
326
333
  action SetCollateral(
327
334
  @title: 'Address'
328
335
  @description: 'The Bech32 encoded address to check and set up collateral for'
329
- address: Bech32) returns TransactionBuilds;
336
+ address: Bech32) returns TransactionBuilds;
337
+
330
338
  @title : 'Address Transaction Builds'
331
339
  @description: 'Projection for retrieving transaction builds by address'
332
340
  action GetTransactionBuildsByAddress(
333
341
  @title: 'Bech32 Address'
334
342
  @description: 'The Bech32 encoded address to retrieve transaction builds for'
335
- address: Bech32) returns array of AddressTransactionBuilds;
343
+ address: Bech32) returns array of AddressTransactionBuilds;
336
344
 
337
345
  @title : 'Derive Script Address'
338
346
  @description: 'Utility: Apply optional PlutusData parameters to a validator script and return its enterprise script address (bech32) and script hash (28-byte hex). Pure derivation, no transaction built, no blockchain call.'
@@ -346,19 +354,17 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
346
354
  @title: 'Network'
347
355
  @description: 'Optional network override (mainnet, preview, preprod). Defaults to the configured network.'
348
356
  network: String(10)) returns {
349
- scriptAddress: String(120);
350
- scriptHash: String(56);
351
- };
357
+ scriptAddress : String(120);
358
+ scriptHash : String(56);
359
+ };
352
360
 
353
361
  @title : 'Extract Payment Key Hash'
354
362
  @description: 'Utility: Decode a Bech32 Cardano address and return its 28-byte payment credential hash (hex). Pure bech32 decoding — no blockchain call. Use to obtain the key hash for requiredSignersJson on Plutus actions.'
355
363
  action ExtractPaymentKeyHash(
356
364
  @title: 'Address'
357
365
  @description: 'The Bech32 encoded Cardano address (addr / addr_test)'
358
- address: Bech32) returns {
359
- paymentKeyHash: String(56);
360
- };
366
+ address: Bech32) returns {
367
+ paymentKeyHash : String(56);
368
+ };
361
369
 
362
370
  }
363
-
364
-
@@ -1,12 +1,2 @@
1
- import type { JSONValue } from './utils/types';
2
- export interface ParsedExtraOutput {
3
- address: string;
4
- lovelaceAmount: string;
5
- assets?: Array<{
6
- unit: string;
7
- quantity: string;
8
- }>;
9
- inlineDatum?: JSONValue;
10
- referenceScript?: string;
11
- }
1
+ export {};
12
2
  //# sourceMappingURL=cardano-tx-service.d.ts.map