@odatano/core 2.0.0-rc.3 → 2.0.0-rc.30

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 (162) hide show
  1. package/@cds-models/CardanoAgentService/index.d.ts +251 -0
  2. package/@cds-models/CardanoAgentService/index.js +36 -0
  3. package/@cds-models/CardanoBackendService/index.d.ts +357 -0
  4. package/@cds-models/CardanoBackendService/index.js +40 -0
  5. package/@cds-models/CardanoIndexerService/index.d.ts +194 -2
  6. package/@cds-models/CardanoIndexerService/index.js +25 -0
  7. package/@cds-models/CardanoODataService/index.d.ts +294 -7
  8. package/@cds-models/CardanoODataService/index.js +33 -0
  9. package/@cds-models/CardanoSignService/index.d.ts +28 -3
  10. package/@cds-models/CardanoSignService/index.js +3 -0
  11. package/@cds-models/CardanoTransactionService/index.d.ts +52 -19
  12. package/@cds-models/CardanoTransactionService/index.js +4 -0
  13. package/@cds-models/index.d.ts +18 -0
  14. package/@cds-models/index.js +3 -0
  15. package/@cds-models/odatano/cardano/index.d.ts +408 -7
  16. package/@cds-models/odatano/cardano/index.js +42 -0
  17. package/README.md +64 -5
  18. package/db/schema.cds +677 -13
  19. package/db/types.cds +27 -0
  20. package/package.json +182 -173
  21. package/scripts/migrate-slot-leader.mjs +104 -0
  22. package/scripts/migrate-txseq.mjs +147 -0
  23. package/src/index.d.ts +11 -10
  24. package/src/index.js +28 -14
  25. package/src/plugin.js +39 -52
  26. package/srv/blockchain/backends/blockfrost-backend.d.ts +29 -131
  27. package/srv/blockchain/backends/blockfrost-backend.js +49 -160
  28. package/srv/blockchain/backends/cardano-backend.d.ts +104 -158
  29. package/srv/blockchain/backends/cardano-backend.js +19 -5
  30. package/srv/blockchain/backends/koios-backend.d.ts +126 -60
  31. package/srv/blockchain/backends/koios-backend.js +356 -217
  32. package/srv/blockchain/backends/odatano-backend.d.ts +64 -0
  33. package/srv/blockchain/backends/odatano-backend.js +170 -0
  34. package/srv/blockchain/backends/ogmios-backend.d.ts +162 -94
  35. package/srv/blockchain/backends/ogmios-backend.js +548 -197
  36. package/srv/blockchain/backends/ogmios-frame-guard.d.ts +32 -0
  37. package/srv/blockchain/backends/ogmios-frame-guard.js +142 -0
  38. package/srv/blockchain/cardano-client.d.ts +78 -205
  39. package/srv/blockchain/cardano-client.js +186 -242
  40. package/srv/blockchain/cardano-indexer.d.ts +302 -242
  41. package/srv/blockchain/cardano-indexer.js +1191 -362
  42. package/srv/blockchain/cardano-tx-builder.d.ts +43 -81
  43. package/srv/blockchain/cardano-tx-builder.js +177 -132
  44. package/srv/blockchain/crawler/certificate-backfill.d.ts +67 -0
  45. package/srv/blockchain/crawler/certificate-backfill.js +169 -0
  46. package/srv/blockchain/crawler/crawler.d.ts +139 -54
  47. package/srv/blockchain/crawler/crawler.js +478 -96
  48. package/srv/blockchain/crawler/hooks.d.ts +3 -14
  49. package/srv/blockchain/crawler/index.d.ts +5 -0
  50. package/srv/blockchain/crawler/index.js +35 -7
  51. package/srv/blockchain/crawler/sync-state.d.ts +46 -28
  52. package/srv/blockchain/crawler/sync-state.js +128 -43
  53. package/srv/blockchain/crawler/transaction-backfill.d.ts +52 -0
  54. package/srv/blockchain/crawler/transaction-backfill.js +283 -0
  55. package/srv/blockchain/crawler/utxo-set-import.d.ts +78 -0
  56. package/srv/blockchain/crawler/utxo-set-import.js +363 -0
  57. package/srv/blockchain/ledger-state.d.ts +101 -0
  58. package/srv/blockchain/ledger-state.js +432 -0
  59. package/srv/blockchain/pending-spends.d.ts +28 -0
  60. package/srv/blockchain/pending-spends.js +89 -0
  61. package/srv/blockchain/signing/cose-verifier.d.ts +5 -12
  62. package/srv/blockchain/signing/cose-verifier.js +6 -12
  63. package/srv/blockchain/signing/external-signer.d.ts +16 -113
  64. package/srv/blockchain/signing/external-signer.js +19 -122
  65. package/srv/blockchain/signing/hsm-signer.d.ts +13 -45
  66. package/srv/blockchain/signing/hsm-signer.js +23 -63
  67. package/srv/blockchain/signing/signature-verifier.d.ts +8 -44
  68. package/srv/blockchain/signing/signature-verifier.js +13 -54
  69. package/srv/blockchain/signing/submission-finalizer.d.ts +9 -36
  70. package/srv/blockchain/signing/submission-finalizer.js +16 -49
  71. package/srv/blockchain/stored-chain.d.ts +33 -0
  72. package/srv/blockchain/stored-chain.js +234 -0
  73. package/srv/blockchain/transaction-building/buildooor-tx.d.ts +108 -160
  74. package/srv/blockchain/transaction-building/buildooor-tx.js +620 -285
  75. package/srv/blockchain/transaction-building/caller-datums.d.ts +17 -0
  76. package/srv/blockchain/transaction-building/caller-datums.js +50 -0
  77. package/srv/blockchain/transaction-building/cardano-tx.d.ts +10 -35
  78. package/srv/blockchain/transaction-rows.d.ts +12 -0
  79. package/srv/blockchain/transaction-rows.js +43 -0
  80. package/srv/blockchain/wallet-worker/build-request.d.ts +4 -17
  81. package/srv/blockchain/wallet-worker/build-request.js +48 -24
  82. package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +25 -17
  83. package/srv/blockchain/wallet-worker/confirmation-tracker.js +87 -41
  84. package/srv/blockchain/wallet-worker/index.js +2 -8
  85. package/srv/blockchain/wallet-worker/job-store.d.ts +36 -103
  86. package/srv/blockchain/wallet-worker/job-store.js +0 -0
  87. package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +4 -20
  88. package/srv/blockchain/wallet-worker/lease-heartbeat.js +4 -20
  89. package/srv/blockchain/wallet-worker/signers.d.ts +6 -19
  90. package/srv/blockchain/wallet-worker/signers.js +3 -8
  91. package/srv/blockchain/wallet-worker/wallet-worker.d.ts +15 -71
  92. package/srv/blockchain/wallet-worker/wallet-worker.js +40 -91
  93. package/srv/cardano-agent-service.cds +146 -0
  94. package/srv/cardano-agent-service.d.ts +2 -0
  95. package/srv/cardano-agent-service.js +12 -0
  96. package/srv/cardano-backend-service.cds +52 -0
  97. package/srv/cardano-backend-service.d.ts +2 -0
  98. package/srv/cardano-backend-service.js +244 -0
  99. package/srv/cardano-indexer-service.cds +201 -73
  100. package/srv/cardano-indexer-service.js +280 -11
  101. package/srv/cardano-service.cds +56 -1
  102. package/srv/cardano-service.js +52 -113
  103. package/srv/cardano-sign-service.cds +200 -180
  104. package/srv/cardano-sign-service.js +55 -173
  105. package/srv/cardano-tx-service.cds +439 -364
  106. package/srv/cardano-tx-service.js +305 -209
  107. package/srv/cardano-ui.cds +16 -16
  108. package/srv/cardano-worker-service.js +7 -15
  109. package/srv/cbor/parse.js +13 -1
  110. package/srv/server.d.ts +28 -86
  111. package/srv/server.js +127 -135
  112. package/srv/utils/agent-grants-config.d.ts +37 -0
  113. package/srv/utils/agent-grants-config.js +138 -0
  114. package/srv/utils/agent-grants.d.ts +262 -0
  115. package/srv/utils/agent-grants.js +922 -0
  116. package/srv/utils/agent-token-auth.d.ts +16 -0
  117. package/srv/utils/agent-token-auth.js +78 -0
  118. package/srv/utils/backend-request-handler.d.ts +2 -16
  119. package/srv/utils/backend-request-handler.js +3 -18
  120. package/srv/utils/collections.d.ts +4 -8
  121. package/srv/utils/collections.js +4 -8
  122. package/srv/utils/const.d.ts +30 -67
  123. package/srv/utils/const.js +32 -72
  124. package/srv/utils/crypto.d.ts +3 -12
  125. package/srv/utils/crypto.js +5 -18
  126. package/srv/utils/db-indexes.d.ts +25 -0
  127. package/srv/utils/db-indexes.js +94 -0
  128. package/srv/utils/db-sanitize.d.ts +27 -0
  129. package/srv/utils/db-sanitize.js +85 -0
  130. package/srv/utils/epoch-slots.d.ts +13 -0
  131. package/srv/utils/epoch-slots.js +25 -0
  132. package/srv/utils/error-codes.d.ts +20 -73
  133. package/srv/utils/error-codes.js +19 -70
  134. package/srv/utils/errors.d.ts +50 -177
  135. package/srv/utils/errors.js +94 -218
  136. package/srv/utils/liveness.d.ts +16 -0
  137. package/srv/utils/liveness.js +40 -0
  138. package/srv/utils/mappers.d.ts +128 -214
  139. package/srv/utils/mappers.js +354 -299
  140. package/srv/utils/network-context.js +2 -11
  141. package/srv/utils/pg-inline-json.d.ts +8 -0
  142. package/srv/utils/pg-inline-json.js +62 -0
  143. package/srv/utils/pg-order-nulls.d.ts +14 -0
  144. package/srv/utils/pg-order-nulls.js +56 -0
  145. package/srv/utils/plutus-placeholders.d.ts +23 -16
  146. package/srv/utils/plutus-placeholders.js +63 -27
  147. package/srv/utils/rate-limiter.d.ts +46 -0
  148. package/srv/utils/rate-limiter.js +116 -0
  149. package/srv/utils/service-events.d.ts +2 -22
  150. package/srv/utils/service-events.js +3 -23
  151. package/srv/utils/signing-helper.d.ts +3 -18
  152. package/srv/utils/signing-helper.js +10 -32
  153. package/srv/utils/tx-build-helper.d.ts +26 -92
  154. package/srv/utils/tx-build-helper.js +68 -123
  155. package/srv/utils/tx-request-parsers.d.ts +107 -21
  156. package/srv/utils/tx-request-parsers.js +433 -34
  157. package/srv/utils/tx-utils.d.ts +4 -23
  158. package/srv/utils/tx-utils.js +12 -41
  159. package/srv/utils/types.d.ts +238 -169
  160. package/srv/utils/types.js +2 -6
  161. package/srv/utils/validators.d.ts +24 -90
  162. package/srv/utils/validators.js +50 -147
@@ -1,30 +1,18 @@
1
1
  import { LedgerProtocolParameter } from "#cds-models/odatano/cardano";
2
- /**
3
- * Hex-encoded string (lower/upper-case depending on source)
4
- */
2
+ /** Hex-encoded string (case depends on source) */
5
3
  export type Hex = string;
6
- /**
7
- * Lovelace amount (integer) - represented as string to preserve precision for values > Number.MAX_SAFE_INTEGER.
8
- * Cardano max supply = 45B ADA = 45,000,000,000,000,000 lovelace (exceeds MAX_SAFE_INTEGER).
9
- * Provider APIs (Blockfrost, Koios) return lovelace as strings. Harmonic Labs uses bigint internally.
10
- */
4
+ /** Lovelace amount; a string preserves precision above Number.MAX_SAFE_INTEGER (max supply is 4.5e16). */
11
5
  export type Lovelace = number | string;
12
- /**
13
- * JSON Value Type - Represents any valid JSON value
14
- */
6
+ /** Any valid JSON value */
15
7
  export type JSONValue = string | number | boolean | {
16
8
  [key: string]: JSONValue;
17
9
  } | JSONValue[] | null;
18
- /**
19
- * Amount Data Structure Type - Multi-asset amount line as returned by common Cardano APIs
20
- */
10
+ /** Multi-asset amount line as returned by common Cardano APIs */
21
11
  export interface Amount {
22
12
  unit: string;
23
13
  quantity: string;
24
14
  }
25
- /**
26
- * Transaction Input Data Structure Type
27
- */
15
+ /** Transaction input */
28
16
  export interface TxInputLine {
29
17
  address: string;
30
18
  amount: Amount[];
@@ -36,9 +24,7 @@ export interface TxInputLine {
36
24
  isCollateral?: boolean;
37
25
  isReference?: boolean;
38
26
  }
39
- /**
40
- * Transaction Output Data Structure Type
41
- */
27
+ /** Transaction output */
42
28
  export interface TxOutputLine {
43
29
  address: string;
44
30
  amount: Amount[];
@@ -50,16 +36,73 @@ export interface TxOutputLine {
50
36
  referenceScriptHash?: Hex | null;
51
37
  }
52
38
  /**
53
- * Transaction Data Structure Type - Normalized transaction structure
54
- */
39
+ * Normalized certificate kinds; unknown types pass through as the raw source string. A Conway
40
+ * stake+vote delegation is split into `pool_delegation` + `vote_delegation` sharing one `certIndex`.
41
+ */
42
+ export type CertificateKind = 'stake_registration' | 'stake_deregistration' | 'pool_delegation' | 'vote_delegation' | 'pool_registration' | 'pool_retirement' | 'drep_registration' | 'drep_update' | 'drep_retirement' | 'committee_hot_auth' | 'committee_resign' | 'genesis_delegation' | 'treasury_mir' | 'reserve_mir' | 'pot_transfer' | 'param_proposal' | (string & {});
43
+ /** One certificate of a transaction (crawler ledger-state coverage). */
44
+ export interface TxCertificate {
45
+ /** Position in the transaction's certificate list as the source reports it. */
46
+ certIndex: number;
47
+ kind: CertificateKind;
48
+ /** Reward account (bech32) the certificate concerns, when it has one. */
49
+ stakeAddress?: string | null;
50
+ /** Stake pool (bech32) for delegation / registration / retirement. */
51
+ poolId?: string | null;
52
+ /** DRep (CIP-129 bech32), or `drep_always_abstain` / `drep_always_no_confidence`. */
53
+ drepId?: string | null;
54
+ /** Deposit paid or refunded, lovelace as string. */
55
+ deposit?: Lovelace | string | null;
56
+ /** Retirement epoch of a pool retirement. */
57
+ epoch?: number | null;
58
+ }
59
+ /** One reward-account withdrawal of a transaction. */
60
+ export interface TxWithdrawal {
61
+ stakeAddress: string;
62
+ /** Lovelace as string. */
63
+ amount: Lovelace | string;
64
+ }
65
+ /** One redeemer of a transaction. */
66
+ export interface TxRedeemer {
67
+ /** spend | mint | publish | withdraw | vote | propose */
68
+ purpose: string;
69
+ /** Index within its purpose, as the ledger counts it. */
70
+ index: number;
71
+ /** PlutusData CBOR hex. */
72
+ data: string;
73
+ mem: string;
74
+ steps: string;
75
+ /** spend: the redeemed input. */
76
+ txHash?: Hex | null;
77
+ outputIndex?: number | null;
78
+ /** mint: the policy. */
79
+ policyId?: Hex | null;
80
+ }
81
+ /** Normalized transaction */
55
82
  export interface Transaction {
56
83
  hash: Hex;
57
84
  blockHash: Hex;
58
85
  blockHeight: number;
59
86
  slot: number;
60
87
  index: number;
88
+ /** What the ledger charged: the declared fee, or on a phase-2 failure the collateral consumed. */
61
89
  fee: Lovelace | string;
62
90
  deposit: Lovelace | string;
91
+ /**
92
+ * True when phase-2 failed: inputs/outputs not applied, collateral consumed, only the collateral
93
+ * return produced. Ogmios (`spends`) and Blockfrost (`valid_contract`) report it; Koios leaves it undefined.
94
+ */
95
+ spendsCollaterals?: boolean;
96
+ /**
97
+ * `total_collateral` from the body when declared; equals the collateral consumed on a phase-2 failure.
98
+ * Null when omitted, the charge is then derived from the resolved collateral inputs minus the return.
99
+ */
100
+ totalCollateral?: Lovelace | string | null;
101
+ /**
102
+ * Signed net mint/burn per unit (negative = burn), never `lovelace`. Ogmios and Koios report it;
103
+ * Blockfrost leaves it undefined and the indexer derives it from resolved input/output assets.
104
+ */
105
+ mint?: Amount[];
63
106
  /** Tx size in bytes; null when the source cannot provide it (Ogmios chain-sync). */
64
107
  size: number | null;
65
108
  blockTime: number;
@@ -67,10 +110,14 @@ export interface Transaction {
67
110
  inputs: TxInputLine[];
68
111
  outputs: TxOutputLine[];
69
112
  metadata?: MetadataLabelTx[];
113
+ /** Certificates; `[]` when the tx has none, undefined when the source does not report them (Blockfrost). */
114
+ certificates?: TxCertificate[];
115
+ /** Reward-account withdrawals; same `[]` vs undefined convention as `certificates`. */
116
+ withdrawals?: TxWithdrawal[];
117
+ /** Redeemers; `[]` when the tx has none, undefined when the source does not report them (Blockfrost, Koios). */
118
+ redeemers?: TxRedeemer[];
70
119
  }
71
- /**
72
- * Address Data Structure Type - Address view, including current value and known UTxOs
73
- */
120
+ /** Address view with current value and known UTxOs */
74
121
  export interface Address {
75
122
  address: string;
76
123
  stakeAddress: string | null;
@@ -80,9 +127,7 @@ export interface Address {
80
127
  utxos: UTxO[];
81
128
  transactions?: Transaction[];
82
129
  }
83
- /**
84
- * UTxO Data Structure Type - Unspent transaction outputs (UTxOs)
85
- */
130
+ /** Unspent transaction output */
86
131
  export interface UTxO {
87
132
  txHash: Hex;
88
133
  outputIndex: number;
@@ -91,11 +136,11 @@ export interface UTxO {
91
136
  blockHash?: Hex;
92
137
  datumHash?: Hex | null;
93
138
  scriptRef?: Hex | null;
139
+ /** Full CBOR of the reference script (Plutus) when the source delivers it; builder use only. */
140
+ scriptRefCbor?: Hex | null;
94
141
  inlineDatum?: string | null;
95
142
  }
96
- /**
97
- * Block Data Structure Type - Basic block information structure
98
- */
143
+ /** Basic block information */
99
144
  export interface BlockData {
100
145
  time: number;
101
146
  height: number | null;
@@ -107,10 +152,10 @@ export interface BlockData {
107
152
  size: number;
108
153
  txCount: number;
109
154
  fees?: string | null;
155
+ /** Header fields only (ledger tip): size, txCount, fees and slotLeader are placeholders, not block data. */
156
+ headerOnly?: boolean;
110
157
  }
111
- /**
112
- * Supply Data Structure Type - Network supply information
113
- */
158
+ /** Network supply */
114
159
  export interface Supply {
115
160
  max: string;
116
161
  total: string;
@@ -119,23 +164,17 @@ export interface Supply {
119
164
  treasury: string;
120
165
  reserves: string;
121
166
  }
122
- /**
123
- * Stake Data Structure Type - Network stake information
124
- */
167
+ /** Network stake */
125
168
  export interface Stake {
126
169
  live: string;
127
170
  active: string;
128
171
  }
129
- /**
130
- * Network Information Data Structure Type - Network supply and stake information
131
- */
172
+ /** Network supply and stake */
132
173
  export interface NetworkInformation {
133
174
  supply: Supply;
134
175
  stake: Stake;
135
176
  }
136
- /**
137
- * Epoch Data Structure Type - Epoch information
138
- */
177
+ /** Epoch information */
139
178
  export interface EpochData {
140
179
  epoch: number;
141
180
  start_time: number;
@@ -148,17 +187,13 @@ export interface EpochData {
148
187
  fees: string;
149
188
  active_stake: string | null;
150
189
  }
151
- /**
152
- * Metadata Label Transaction Data Structure Type - Transaction metadata under a specific label
153
- */
190
+ /** Transaction metadata under one label */
154
191
  export interface MetadataLabelTx {
155
192
  txHash: Hex;
156
193
  label: number | string;
157
194
  json?: JSONValue;
158
195
  }
159
- /**
160
- * Account Data Structure Type - Stake account information
161
- */
196
+ /** Stake account information */
162
197
  export interface AccountData {
163
198
  stakeaddress: string;
164
199
  active: boolean;
@@ -173,18 +208,19 @@ export interface AccountData {
173
208
  drepId: string | null;
174
209
  addresses: Address[];
175
210
  }
176
- /**
177
- * Pool Data Structure Type - Pool information
178
- */
211
+ /** Pool information */
179
212
  export interface PoolData {
180
213
  poolId: string;
181
214
  vrfKeyHash: string;
182
215
  blocksMinted: number;
183
- blocksEpoch: number;
216
+ /** Blocks minted in the current epoch; null when the backend has no such figure (Koios). */
217
+ blocksEpoch: number | null;
184
218
  liveStake: string;
185
219
  liveSize: number;
220
+ /** Fraction of the ideal (saturated) pool size, NOT percent: 0.7542 = 75.42 %. */
186
221
  liveSaturation: number;
187
- liveDelegators: number;
222
+ /** Null when the source cannot count delegators (Ogmios ledger state). */
223
+ liveDelegators: number | null;
188
224
  activeStake: string;
189
225
  activeSize: number;
190
226
  pledge: string;
@@ -192,9 +228,7 @@ export interface PoolData {
192
228
  fixedCost: string;
193
229
  rewardAccount: string;
194
230
  }
195
- /**
196
- * Drep Data Structure Type - Drep information
197
- */
231
+ /** DRep information */
198
232
  export interface DrepData {
199
233
  drepId: string;
200
234
  hex: string;
@@ -203,12 +237,14 @@ export interface DrepData {
203
237
  lastActiveEpoch: number;
204
238
  retired: boolean;
205
239
  expired: boolean;
240
+ /** Registration deposit (lovelace); only set by sources that report it. */
241
+ deposit?: string | null;
242
+ /** Epoch the mandate runs out; only set by sources that report it. */
243
+ expiresEpoch?: number | null;
244
+ /** Stake credentials delegated to the DRep; only set by sources that report it. */
245
+ delegatorCount?: number | null;
206
246
  }
207
- /**
208
- * Asset Info Data Structure Type - Normalized native-asset metadata + supply.
209
- * Backends provide overlapping but non-identical fields; the mapper produces
210
- * this canonical shape. Fields that one backend doesn't expose are null.
211
- */
247
+ /** Normalized native-asset metadata and supply; fields a backend does not expose are null. */
212
248
  export interface AssetInfo {
213
249
  unit: string;
214
250
  policyId: string;
@@ -227,10 +263,7 @@ export interface AssetInfo {
227
263
  registryUrl: string | null;
228
264
  registryLogo: string | null;
229
265
  }
230
- /**
231
- * Asset History Entry - single mint or burn event.
232
- * `quantity` is always the ABSOLUTE amount; sign info lives in `action`.
233
- */
266
+ /** One mint or burn event; `quantity` is absolute, the sign lives in `action`. */
234
267
  export interface AssetHistoryEntry {
235
268
  unit: string;
236
269
  txHash: string;
@@ -239,9 +272,7 @@ export interface AssetHistoryEntry {
239
272
  blockTime: number | null;
240
273
  blockHeight: number | null;
241
274
  }
242
- /**
243
- * Ledger Protocol Parameters Data Structure Type - Current protocol parameters
244
- */
275
+ /** Current protocol parameters */
245
276
  export type LedgerProtocolParameters = {
246
277
  network: string;
247
278
  epoch: number;
@@ -278,20 +309,31 @@ export type LedgerProtocolParameters = {
278
309
  fetchedAt: string;
279
310
  source: string;
280
311
  };
281
- /**
282
- * Mint/Burn Asset Action Type
283
- */
312
+ /** Mint/burn action */
284
313
  export type MintAction = {
285
314
  /** Asset unit to mint/burn (policyId + assetName) */
286
315
  assetUnit: string;
287
- /** Quantity to mint (positive) or burn (negative) */
316
+ /** Positive to mint, negative to burn */
288
317
  quantity: bigint;
289
- /** Optional redeemer data (integer). Defaults to 0 if not specified. */
318
+ /** Optional integer redeemer, default 0 */
290
319
  redeemer?: number;
320
+ /**
321
+ * Per-action minting policy (CBOR hex, applied as-is) for multi-policy transactions; overrides the
322
+ * top-level mintingPolicyScript. The assetUnit must carry this script's policyId.
323
+ */
324
+ mintingPolicyScript?: string;
325
+ /** BuildPlutusTransaction only: UTxO that carries the policy as reference script; exclusive with mintingPolicyScript. */
326
+ referenceScript?: {
327
+ txHash: string;
328
+ outputIndex: number;
329
+ };
330
+ /**
331
+ * Per-action redeemer (parsed PlutusData JSON), only with mintingPolicyScript or referenceScript; falls back to mintRedeemer.
332
+ * Actions on the same policy must agree (one redeemer per policy in the ledger).
333
+ */
334
+ redeemerJson?: JSONValue;
291
335
  };
292
- /**
293
- * Plutus Script Execution Type - For spending from script addresses
294
- */
336
+ /** Plutus script execution for spending from a script address */
295
337
  export type PlutusScriptExecution = {
296
338
  /** Validator script (CBOR hex) */
297
339
  validatorScript: string;
@@ -302,12 +344,10 @@ export type PlutusScriptExecution = {
302
344
  };
303
345
  /** Redeemer data (JSON value that will be converted to PlutusData) */
304
346
  redeemer: JSONValue;
305
- /** Datum data (JSON value, optional - required for hash-based datums) */
347
+ /** Datum (JSON value), required for hash-based datums */
306
348
  datum?: JSONValue;
307
349
  };
308
- /**
309
- * Transaction Build Request Type - Parameters for building a transaction, including optional minting and Plutus execution details
310
- */
350
+ /** Parameters for building a transaction, with optional minting and Plutus execution */
311
351
  export type TxBuildRequest = {
312
352
  network: 'mainnet' | 'preprod' | 'preview';
313
353
  senderAddress: string;
@@ -325,9 +365,13 @@ export type TxBuildRequest = {
325
365
  plutusScriptExecution?: PlutusScriptExecution;
326
366
  /** Inline datum to attach to the recipient output (optional) - for locking at script addresses */
327
367
  outputDatum?: JSONValue;
368
+ /** PlutusData CBOR hex; optional; inline datum on the recipient output, written byte for byte. Excludes outputDatum. */
369
+ outputDatumCbor?: string;
370
+ /** Raise lovelaceAmount to the recipient output's min-ADA instead of rejecting the request. */
371
+ ensureMinAda?: boolean;
328
372
  /** Required signers - Ed25519 key hashes (hex, 28 bytes each) */
329
373
  requiredSigners?: string[];
330
- /** Script parameters — PlutusData JSON array applied to script before building */
374
+ /** Script parameters (PlutusData JSON array) applied to the script before building */
331
375
  scriptParams?: JSONValue[];
332
376
  /** Optional inline datum for minted token output (PlutusData JSON, parsed) */
333
377
  inlineDatum?: JSONValue;
@@ -336,29 +380,24 @@ export type TxBuildRequest = {
336
380
  /** When true, route output to enterprise script address derived from applied script hash */
337
381
  lockOnScript?: boolean;
338
382
  /**
339
- * Optional UTxOs that MUST be consumed as inputs. Resolved and added to the TxBuilder
340
- * BEFORE coin selection runs. Coin selection then only covers the remaining shortfall.
341
- * Deduplicated against plutusScriptExecution.scriptUtxo in spend transactions.
342
- * Primary use case: one-shot minting seeds (policy parameterized with a specific TxOutRef).
383
+ * UTxOs that must be consumed, added before coin selection (one-shot minting seeds);
384
+ * deduplicated against plutusScriptExecution.scriptUtxo.
343
385
  */
344
386
  forceInputs?: Array<{
345
387
  txHash: string;
346
388
  outputIndex: number;
347
389
  }>;
348
- /**
349
- * Optional CIP-31 reference inputs (read-only, not consumed). Resolved to full UTxOs
350
- * and passed as readonlyRefInputs to Buildooor. The validator can read these UTxOs'
351
- * datums/values without consuming them (e.g., oracle feeds, shared config).
352
- */
390
+ /** UTxOs the build must never spend: left out of coin selection and collateral. */
391
+ protectInputs?: Array<{
392
+ txHash: string;
393
+ outputIndex: number;
394
+ }>;
395
+ /** CIP-31 reference inputs (read-only, not consumed), passed as readonlyRefInputs to Buildooor. */
353
396
  referenceInputs?: Array<{
354
397
  txHash: string;
355
398
  outputIndex: number;
356
399
  }>;
357
- /**
358
- * Optional additional outputs appended after the primary recipient output, before change.
359
- * Each extra output is independently min-ADA checked. Used for multi-output state-machine
360
- * transitions (e.g. counter update + batch NFT outputs in a single transaction).
361
- */
400
+ /** Additional outputs after the primary recipient output, before change; each min-ADA checked. */
362
401
  extraOutputs?: Array<{
363
402
  address: string;
364
403
  lovelaceAmount: string;
@@ -369,52 +408,104 @@ export type TxBuildRequest = {
369
408
  inlineDatum?: JSONValue;
370
409
  referenceScript?: string;
371
410
  }>;
372
- /**
373
- * Optional Plutus V3 validator CBOR hex to attach as a referenceScript on the primary
374
- * recipient output (CIP-33). Adding a ref script significantly increases the output's
375
- * min-ADA — consumers must provide enough lovelaceAmount to cover it.
376
- */
411
+ /** Plutus V3 validator CBOR hex attached as CIP-33 reference script on the recipient output; raises its min-ADA. */
377
412
  referenceScript?: string;
378
- /**
379
- * Optional validity-interval start in Posix milliseconds. Sets `invalidBefore`
380
- * on the built transaction so that Plutus validators checking
381
- * `expect Finite(lower) = tx.validity_range.lower_bound.bound_type` see a finite bound.
382
- * Defaults inside the builder to `Date.now() - 120_000` (script builds only).
383
- */
413
+ /** Validity start in Posix ms (`invalidBefore`); builder default `now - 120_000` for script builds. */
384
414
  validityStartMs?: string;
385
- /**
386
- * Optional validity-interval end in Posix milliseconds. Sets `invalidAfter` (ledger TTL).
387
- * Defaults inside the builder to `Date.now() + 3_600_000` (script builds only).
388
- */
415
+ /** Validity end in Posix ms (`invalidAfter`, ledger TTL); builder default `now + 3_600_000` for script builds. */
389
416
  validityEndMs?: string;
390
417
  };
391
- /**
392
- * Transaction Build Request for Mint/Burn operations - requires mintActions and mintingPolicyScript
393
- */
418
+ /** Mint/burn build request: mintActions and mintingPolicyScript required */
394
419
  export type TxBuildMintRequest = TxBuildRequest & {
395
420
  mintActions: MintAction[];
396
421
  mintingPolicyScript: string;
397
422
  };
398
- /**
399
- * Transaction Build Request for Plutus spending - requires plutusScriptExecution
400
- */
423
+ /** Plutus spend build request: plutusScriptExecution required */
401
424
  export type TxBuildPlutusSpendRequest = TxBuildRequest & {
402
425
  plutusScriptExecution: PlutusScriptExecution;
403
426
  };
427
+ /** One script UTxO spent by a BuildPlutusTransaction: an inline validator or a UTxO carrying the script. */
428
+ export type ScriptInput = {
429
+ txHash: string;
430
+ outputIndex: number;
431
+ /** Validator CBOR hex (script params already applied); exclusive with referenceScript. */
432
+ validatorScript?: string;
433
+ /** UTxO that carries the validator as reference script; added as reference input. */
434
+ referenceScript?: {
435
+ txHash: string;
436
+ outputIndex: number;
437
+ };
438
+ /** Redeemer (PlutusData JSON); `__INPUT_IDX__` placeholders resolve against the final inputs. */
439
+ redeemer: JSONValue;
440
+ /** Redeemer as PlutusData CBOR hex; wins over `redeemer`, no placeholders. */
441
+ redeemerCbor?: string;
442
+ /** Datum preimage (PlutusData JSON) for a hash-datum UTxO; inline datums are read from the UTxO. */
443
+ datum?: JSONValue;
444
+ /** Datum preimage as PlutusData CBOR hex; wins over `datum`. */
445
+ datumCbor?: string;
446
+ };
447
+ /** Output of a BuildPlutusTransaction, kept in the given order. */
448
+ export type PlutusTxOutput = NonNullable<TxBuildRequest['extraOutputs']>[number] & {
449
+ /** Datum hash to lock the output with (hex); exclusive with inlineDatum. */
450
+ datumHash?: string;
451
+ /** Inline datum as PlutusData CBOR hex, taken byte for byte; exclusive with inlineDatum. */
452
+ inlineDatumCbor?: string;
453
+ };
404
454
  /**
405
- * Execution Budget for Plutus scripts
406
- */
455
+ * Reward-account withdrawal of a BuildPlutusTransaction. A staking script (inline or by reference)
456
+ * runs with the redeemer under the Reward purpose; without a script the stake key signs.
457
+ */
458
+ export type WithdrawalInput = {
459
+ /** Bech32 reward account (stake address). */
460
+ rewardAddress: string;
461
+ /** Withdrawn lovelace; 0 for the withdraw-zero pattern. */
462
+ lovelace: string;
463
+ /** Staking script CBOR hex (script params already applied); exclusive with referenceScript. */
464
+ stakingScript?: string;
465
+ /** UTxO that carries the staking script as reference script; added as reference input. */
466
+ referenceScript?: {
467
+ txHash: string;
468
+ outputIndex: number;
469
+ };
470
+ /** Redeemer (PlutusData JSON); `__INPUT_IDX__` placeholders resolve against the final inputs. */
471
+ redeemer?: JSONValue;
472
+ /** Redeemer as PlutusData CBOR hex; wins over `redeemer`, no placeholders. */
473
+ redeemerCbor?: string;
474
+ };
475
+ /**
476
+ * Stake-credential certificate of a BuildPlutusTransaction. A registration without a script is the
477
+ * witness-free legacy form (key or script credential); with a script the Conway deposit form, run
478
+ * under the Certifying purpose. A deregistration needs the key's witness or the script.
479
+ */
480
+ export type CertificateInput = {
481
+ type: 'registerStake' | 'deregisterStake';
482
+ /** Bech32 stake address of the credential. */
483
+ stakeAddress: string;
484
+ /** Explicit deposit (lovelace) for the Conway forms; defaults to the protocol's stake deposit. */
485
+ deposit?: string;
486
+ stakingScript?: string;
487
+ referenceScript?: {
488
+ txHash: string;
489
+ outputIndex: number;
490
+ };
491
+ redeemer?: JSONValue;
492
+ redeemerCbor?: string;
493
+ };
494
+ /** BuildPlutusTransaction: several script inputs, the outputs as given, change after them. */
495
+ export type TxBuildPlutusRequest = Pick<TxBuildRequest, 'network' | 'senderAddress' | 'changeAddress' | 'requiredSigners' | 'forceInputs' | 'protectInputs' | 'referenceInputs' | 'mintActions' | 'validityStartMs' | 'validityEndMs'> & {
496
+ scriptInputs: ScriptInput[];
497
+ outputs: PlutusTxOutput[];
498
+ /** Reward-account withdrawals, with or without a staking script. */
499
+ withdrawals?: WithdrawalInput[];
500
+ /** Stake-credential registrations and deregistrations. */
501
+ certificates?: CertificateInput[];
502
+ };
503
+ /** Execution budget for Plutus scripts */
407
504
  export type ExecutionBudget = {
408
505
  memory: number;
409
506
  cpu: number;
410
507
  };
411
- /**
412
- * Script evaluation result from Ogmios
413
- */
414
- /**
415
- * Ogmios validator descriptor — `purpose:index` (e.g., "spend:0", "mint:1")
416
- * or a structured object with purpose + index fields depending on Ogmios version.
417
- */
508
+ /** Ogmios validator descriptor: `purpose:index` (e.g. "spend:0") or `{ purpose, index }` depending on version */
418
509
  export type ScriptValidator = string | {
419
510
  purpose: string;
420
511
  index: number;
@@ -423,13 +514,9 @@ export type ScriptEvaluationResult = {
423
514
  validator: ScriptValidator;
424
515
  budget: ExecutionBudget;
425
516
  };
426
- /**
427
- * Transaction evaluator function type - evaluates script execution units
428
- */
517
+ /** Evaluates script execution units of an unsigned tx */
429
518
  export type TxEvaluator = (unsignedTxCbor: string) => Promise<ScriptEvaluationResult[]>;
430
- /**
431
- * Transaction Build Context Type - Context for building a transaction
432
- */
519
+ /** Context for building a transaction */
433
520
  export type TxBuildContext = {
434
521
  utxos: UTxO[];
435
522
  protocolParameters: LedgerProtocolParameter;
@@ -438,9 +525,7 @@ export type TxBuildContext = {
438
525
  /** CIP-31 reference input UTxOs (read-only, not consumed). Resolved from referenceInputs refs. */
439
526
  referenceInputUtxos?: UTxO[];
440
527
  };
441
- /**
442
- * Transaction Build Result Type
443
- */
528
+ /** Transaction build result */
444
529
  export type TxBuildResult = {
445
530
  senderAddress?: string;
446
531
  network?: 'mainnet' | 'preprod' | 'preview';
@@ -474,10 +559,15 @@ export type TxBuildResult = {
474
559
  forcedInputsUsed?: number;
475
560
  /** Number of CIP-31 reference inputs included in the built transaction (0 if referenceInputs was not used). */
476
561
  referenceInputsUsed?: number;
562
+ /** Execution units stamped on each redeemer (script builds). */
563
+ redeemers?: Array<{
564
+ tag: string;
565
+ index: number;
566
+ mem: string;
567
+ steps: string;
568
+ }>;
477
569
  };
478
- /**
479
- * Supported external signer types
480
- */
570
+ /** Supported external signer types */
481
571
  export declare enum ExternalSignerType {
482
572
  /** Cardano CLI - Reference implementation for signing */
483
573
  CARDANO_CLI = "cardano-cli",
@@ -490,9 +580,7 @@ export declare enum ExternalSignerType {
490
580
  /** Hardware Security Module (server-side PKCS#11) */
491
581
  HSM = "hsm"
492
582
  }
493
- /**
494
- * Signing request status
495
- */
583
+ /** Signing request status */
496
584
  export declare enum SigningStatus {
497
585
  /** Request created, awaiting signing */
498
586
  PENDING = "pending",
@@ -507,9 +595,7 @@ export declare enum SigningStatus {
507
595
  /** Request expired (not signed within TTL) */
508
596
  EXPIRED = "expired"
509
597
  }
510
- /**
511
- * Instructions for external signers
512
- */
598
+ /** Instructions for external signers */
513
599
  export interface SigningInstructions {
514
600
  /** Signer type hint (which tool/wallet to use) */
515
601
  signerTypeHint: ExternalSignerType;
@@ -527,12 +613,7 @@ export interface SigningInstructions {
527
613
  /** Copy-pasteable cardano-cli signing recipe (for CLI/hardware signers) */
528
614
  cardanoCliCommand?: string;
529
615
  }
530
- /**
531
- * Unsigned transaction export payload for external signers
532
- *
533
- * This is the standardized format returned by BuildTransaction actions.
534
- * External signers use this payload to sign the transaction.
535
- */
616
+ /** Unsigned transaction payload returned by the Build actions for external signers */
536
617
  export interface UnsignedTxExportPayload {
537
618
  /** Unique identifier for this signing request */
538
619
  signingRequestId: string;
@@ -553,9 +634,7 @@ export interface UnsignedTxExportPayload {
553
634
  /** Signing instructions for the external signer */
554
635
  signingInstructions: SigningInstructions;
555
636
  }
556
- /**
557
- * Signed transaction submission payload
558
- */
637
+ /** Signed transaction submission payload */
559
638
  export interface SignedTxPayload {
560
639
  /** Original signing request ID */
561
640
  signingRequestId: string;
@@ -568,9 +647,7 @@ export interface SignedTxPayload {
568
647
  /** Optional: Signer identification (wallet name, etc.) */
569
648
  signerInfo?: string;
570
649
  }
571
- /**
572
- * Signing workflow state
573
- */
650
+ /** Signing workflow state */
574
651
  export interface SigningWorkflowState {
575
652
  /** Current status of the signing workflow */
576
653
  status: SigningStatus;
@@ -593,9 +670,7 @@ export interface SigningWorkflowState {
593
670
  failed?: string;
594
671
  };
595
672
  }
596
- /**
597
- * Result of signature verification
598
- */
673
+ /** Result of signature verification */
599
674
  export interface SignatureVerificationResult {
600
675
  /** Whether the signature is valid */
601
676
  isValid: boolean;
@@ -610,9 +685,7 @@ export interface SignatureVerificationResult {
610
685
  /** Error message if verification failed */
611
686
  errorMessage?: string;
612
687
  }
613
- /**
614
- * Options for signature verification
615
- */
688
+ /** Options for signature verification */
616
689
  export interface VerificationOptions {
617
690
  /** Expected transaction body hash (from the build) */
618
691
  expectedTxBodyHash?: string;
@@ -621,9 +694,7 @@ export interface VerificationOptions {
621
694
  /** List of required signer key hashes (public key hashes) */
622
695
  requiredSigners?: string[];
623
696
  }
624
- /**
625
- * HSM Configuration for PKCS#11 integration
626
- */
697
+ /** HSM configuration for PKCS#11 integration */
627
698
  export interface HsmConfig {
628
699
  /** Whether HSM signing is enabled */
629
700
  enabled: boolean;
@@ -637,12 +708,10 @@ export interface HsmConfig {
637
708
  keyId?: string;
638
709
  /** Key label for CKA_LABEL lookup */
639
710
  keyLabel?: string;
640
- /** Optional CDS role required for HSM actions (SignWithHsm, SignAndSubmitWithHsm, GetHsmStatus). When set, only users with this role can invoke HSM operations. */
711
+ /** CDS role required for the HSM actions (SignWithHsm, SignAndSubmitWithHsm, GetHsmStatus) */
641
712
  requiresRole?: string;
642
713
  }
643
- /**
644
- * HSM signing result
645
- */
714
+ /** HSM signing result */
646
715
  export interface HsmSignResult {
647
716
  /** Ed25519 signature (64 bytes, hex) */
648
717
  signatureHex: string;