@odatano/core 2.0.0-rc.4 → 2.0.0-rc.41

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 (166) 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 +305 -7
  8. package/@cds-models/CardanoODataService/index.js +34 -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 +46 -13
  12. package/@cds-models/CardanoTransactionService/index.js +4 -0
  13. package/@cds-models/index.d.ts +72 -0
  14. package/@cds-models/index.js +12 -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 +2297 -1633
  19. package/db/types.cds +114 -0
  20. package/package.json +27 -6
  21. package/scripts/migrate-slot-leader.mjs +104 -0
  22. package/scripts/migrate-txseq.mjs +147 -0
  23. package/src/index.d.ts +18 -11
  24. package/src/index.js +44 -14
  25. package/src/plugin.js +42 -52
  26. package/srv/blockchain/backends/blockfrost-backend.d.ts +29 -131
  27. package/srv/blockchain/backends/blockfrost-backend.js +53 -162
  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 +376 -235
  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 +556 -201
  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 +87 -202
  39. package/srv/blockchain/cardano-client.js +210 -240
  40. package/srv/blockchain/cardano-indexer.d.ts +311 -242
  41. package/srv/blockchain/cardano-indexer.js +1238 -362
  42. package/srv/blockchain/cardano-tx-builder.d.ts +44 -81
  43. package/srv/blockchain/cardano-tx-builder.js +173 -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 +14 -45
  68. package/srv/blockchain/signing/signature-verifier.js +73 -76
  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 +111 -173
  74. package/srv/blockchain/transaction-building/buildooor-tx.js +649 -326
  75. package/srv/blockchain/transaction-building/caller-datums.d.ts +29 -0
  76. package/srv/blockchain/transaction-building/caller-datums.js +139 -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 +18 -23
  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 +65 -2
  102. package/srv/cardano-service.js +170 -129
  103. package/srv/cardano-sign-service.cds +200 -180
  104. package/srv/cardano-sign-service.js +57 -184
  105. package/srv/cardano-tx-service.cds +439 -370
  106. package/srv/cardano-tx-service.js +231 -190
  107. package/srv/cardano-ui.cds +16 -16
  108. package/srv/cardano-worker-service.js +7 -15
  109. package/srv/cbor/index.d.ts +1 -1
  110. package/srv/cbor/parse.d.ts +27 -0
  111. package/srv/cbor/parse.js +63 -2
  112. package/srv/server.d.ts +28 -86
  113. package/srv/server.js +132 -135
  114. package/srv/utils/agent-grants-config.d.ts +37 -0
  115. package/srv/utils/agent-grants-config.js +138 -0
  116. package/srv/utils/agent-grants.d.ts +262 -0
  117. package/srv/utils/agent-grants.js +922 -0
  118. package/srv/utils/agent-token-auth.d.ts +16 -0
  119. package/srv/utils/agent-token-auth.js +78 -0
  120. package/srv/utils/backend-request-handler.d.ts +2 -16
  121. package/srv/utils/backend-request-handler.js +3 -18
  122. package/srv/utils/collections.d.ts +4 -8
  123. package/srv/utils/collections.js +4 -8
  124. package/srv/utils/const.d.ts +30 -67
  125. package/srv/utils/const.js +32 -72
  126. package/srv/utils/crypto.d.ts +3 -12
  127. package/srv/utils/crypto.js +5 -18
  128. package/srv/utils/db-indexes.d.ts +25 -0
  129. package/srv/utils/db-indexes.js +94 -0
  130. package/srv/utils/db-sanitize.d.ts +27 -0
  131. package/srv/utils/db-sanitize.js +85 -0
  132. package/srv/utils/epoch-slots.d.ts +20 -0
  133. package/srv/utils/epoch-slots.js +43 -0
  134. package/srv/utils/error-codes.d.ts +20 -73
  135. package/srv/utils/error-codes.js +19 -70
  136. package/srv/utils/errors.d.ts +50 -177
  137. package/srv/utils/errors.js +94 -218
  138. package/srv/utils/legacy-service-paths.d.ts +11 -0
  139. package/srv/utils/legacy-service-paths.js +58 -0
  140. package/srv/utils/liveness.d.ts +16 -0
  141. package/srv/utils/liveness.js +40 -0
  142. package/srv/utils/mappers.d.ts +128 -214
  143. package/srv/utils/mappers.js +354 -299
  144. package/srv/utils/network-context.js +2 -11
  145. package/srv/utils/pg-inline-json.d.ts +8 -0
  146. package/srv/utils/pg-inline-json.js +62 -0
  147. package/srv/utils/pg-order-nulls.d.ts +14 -0
  148. package/srv/utils/pg-order-nulls.js +56 -0
  149. package/srv/utils/plutus-placeholders.d.ts +23 -16
  150. package/srv/utils/plutus-placeholders.js +63 -27
  151. package/srv/utils/rate-limiter.d.ts +46 -0
  152. package/srv/utils/rate-limiter.js +116 -0
  153. package/srv/utils/service-events.d.ts +2 -22
  154. package/srv/utils/service-events.js +3 -23
  155. package/srv/utils/signing-helper.d.ts +6 -16
  156. package/srv/utils/signing-helper.js +36 -60
  157. package/srv/utils/tx-build-helper.d.ts +28 -93
  158. package/srv/utils/tx-build-helper.js +75 -124
  159. package/srv/utils/tx-request-parsers.d.ts +101 -28
  160. package/srv/utils/tx-request-parsers.js +410 -43
  161. package/srv/utils/tx-utils.d.ts +4 -23
  162. package/srv/utils/tx-utils.js +12 -41
  163. package/srv/utils/types.d.ts +252 -179
  164. package/srv/utils/types.js +2 -6
  165. package/srv/utils/validators.d.ts +24 -90
  166. 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,20 @@ 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
- liveSize: number;
219
+ /** Share of the total live stake; null when the backend has no such figure (Koios). */
220
+ liveSize: number | null;
221
+ /** Fraction of the ideal (saturated) pool size, NOT percent: 0.7542 = 75.42 %. */
186
222
  liveSaturation: number;
187
- liveDelegators: number;
223
+ /** Null when the source cannot count delegators (Ogmios ledger state). */
224
+ liveDelegators: number | null;
188
225
  activeStake: string;
189
226
  activeSize: number;
190
227
  pledge: string;
@@ -192,9 +229,7 @@ export interface PoolData {
192
229
  fixedCost: string;
193
230
  rewardAccount: string;
194
231
  }
195
- /**
196
- * Drep Data Structure Type - Drep information
197
- */
232
+ /** DRep information */
198
233
  export interface DrepData {
199
234
  drepId: string;
200
235
  hex: string;
@@ -203,12 +238,14 @@ export interface DrepData {
203
238
  lastActiveEpoch: number;
204
239
  retired: boolean;
205
240
  expired: boolean;
241
+ /** Registration deposit (lovelace); only set by sources that report it. */
242
+ deposit?: string | null;
243
+ /** Epoch the mandate runs out; only set by sources that report it. */
244
+ expiresEpoch?: number | null;
245
+ /** Stake credentials delegated to the DRep; only set by sources that report it. */
246
+ delegatorCount?: number | null;
206
247
  }
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
- */
248
+ /** Normalized native-asset metadata and supply; fields a backend does not expose are null. */
212
249
  export interface AssetInfo {
213
250
  unit: string;
214
251
  policyId: string;
@@ -227,10 +264,7 @@ export interface AssetInfo {
227
264
  registryUrl: string | null;
228
265
  registryLogo: string | null;
229
266
  }
230
- /**
231
- * Asset History Entry - single mint or burn event.
232
- * `quantity` is always the ABSOLUTE amount; sign info lives in `action`.
233
- */
267
+ /** One mint or burn event; `quantity` is absolute, the sign lives in `action`. */
234
268
  export interface AssetHistoryEntry {
235
269
  unit: string;
236
270
  txHash: string;
@@ -239,9 +273,7 @@ export interface AssetHistoryEntry {
239
273
  blockTime: number | null;
240
274
  blockHeight: number | null;
241
275
  }
242
- /**
243
- * Ledger Protocol Parameters Data Structure Type - Current protocol parameters
244
- */
276
+ /** Current protocol parameters */
245
277
  export type LedgerProtocolParameters = {
246
278
  network: string;
247
279
  epoch: number;
@@ -278,35 +310,31 @@ export type LedgerProtocolParameters = {
278
310
  fetchedAt: string;
279
311
  source: string;
280
312
  };
281
- /**
282
- * Mint/Burn Asset Action Type
283
- */
313
+ /** Mint/burn action */
284
314
  export type MintAction = {
285
315
  /** Asset unit to mint/burn (policyId + assetName) */
286
316
  assetUnit: string;
287
- /** Quantity to mint (positive) or burn (negative) */
317
+ /** Positive to mint, negative to burn */
288
318
  quantity: bigint;
289
- /** Optional redeemer data (integer). Defaults to 0 if not specified. */
319
+ /** Optional integer redeemer, default 0 */
290
320
  redeemer?: number;
291
321
  /**
292
- * Optional PER-ACTION minting policy (CBOR hex). When set, this action
293
- * mints under THIS script instead of the request's top-level
294
- * mintingPolicyScript, enabling multiple policies in one transaction.
295
- * Passed as-is (a parameterized script must be pre-applied); the action's
296
- * assetUnit must carry this script's policyId.
322
+ * Per-action minting policy (CBOR hex, applied as-is) for multi-policy transactions; overrides the
323
+ * top-level mintingPolicyScript. The assetUnit must carry this script's policyId.
297
324
  */
298
325
  mintingPolicyScript?: string;
326
+ /** BuildPlutusTransaction only: UTxO that carries the policy as reference script; exclusive with mintingPolicyScript. */
327
+ referenceScript?: {
328
+ txHash: string;
329
+ outputIndex: number;
330
+ };
299
331
  /**
300
- * Optional PER-ACTION redeemer (parsed PlutusData JSON). Only valid
301
- * together with mintingPolicyScript; falls back to the request's
302
- * mintRedeemer when absent. Actions resolving to the SAME policy must
303
- * agree on their redeemer (the ledger carries one redeemer per policy).
332
+ * Per-action redeemer (parsed PlutusData JSON), only with mintingPolicyScript or referenceScript; falls back to mintRedeemer.
333
+ * Actions on the same policy must agree (one redeemer per policy in the ledger).
304
334
  */
305
335
  redeemerJson?: JSONValue;
306
336
  };
307
- /**
308
- * Plutus Script Execution Type - For spending from script addresses
309
- */
337
+ /** Plutus script execution for spending from a script address */
310
338
  export type PlutusScriptExecution = {
311
339
  /** Validator script (CBOR hex) */
312
340
  validatorScript: string;
@@ -317,12 +345,10 @@ export type PlutusScriptExecution = {
317
345
  };
318
346
  /** Redeemer data (JSON value that will be converted to PlutusData) */
319
347
  redeemer: JSONValue;
320
- /** Datum data (JSON value, optional - required for hash-based datums) */
348
+ /** Datum (JSON value), required for hash-based datums */
321
349
  datum?: JSONValue;
322
350
  };
323
- /**
324
- * Transaction Build Request Type - Parameters for building a transaction, including optional minting and Plutus execution details
325
- */
351
+ /** Parameters for building a transaction, with optional minting and Plutus execution */
326
352
  export type TxBuildRequest = {
327
353
  network: 'mainnet' | 'preprod' | 'preview';
328
354
  senderAddress: string;
@@ -340,9 +366,13 @@ export type TxBuildRequest = {
340
366
  plutusScriptExecution?: PlutusScriptExecution;
341
367
  /** Inline datum to attach to the recipient output (optional) - for locking at script addresses */
342
368
  outputDatum?: JSONValue;
369
+ /** PlutusData CBOR hex; optional; inline datum on the recipient output, written byte for byte. Excludes outputDatum. */
370
+ outputDatumCbor?: string;
371
+ /** Raise lovelaceAmount to the recipient output's min-ADA instead of rejecting the request. */
372
+ ensureMinAda?: boolean;
343
373
  /** Required signers - Ed25519 key hashes (hex, 28 bytes each) */
344
374
  requiredSigners?: string[];
345
- /** Script parameters — PlutusData JSON array applied to script before building */
375
+ /** Script parameters (PlutusData JSON array) applied to the script before building */
346
376
  scriptParams?: JSONValue[];
347
377
  /** Optional inline datum for minted token output (PlutusData JSON, parsed) */
348
378
  inlineDatum?: JSONValue;
@@ -351,29 +381,24 @@ export type TxBuildRequest = {
351
381
  /** When true, route output to enterprise script address derived from applied script hash */
352
382
  lockOnScript?: boolean;
353
383
  /**
354
- * Optional UTxOs that MUST be consumed as inputs. Resolved and added to the TxBuilder
355
- * BEFORE coin selection runs. Coin selection then only covers the remaining shortfall.
356
- * Deduplicated against plutusScriptExecution.scriptUtxo in spend transactions.
357
- * Primary use case: one-shot minting seeds (policy parameterized with a specific TxOutRef).
384
+ * UTxOs that must be consumed, added before coin selection (one-shot minting seeds);
385
+ * deduplicated against plutusScriptExecution.scriptUtxo.
358
386
  */
359
387
  forceInputs?: Array<{
360
388
  txHash: string;
361
389
  outputIndex: number;
362
390
  }>;
363
- /**
364
- * Optional CIP-31 reference inputs (read-only, not consumed). Resolved to full UTxOs
365
- * and passed as readonlyRefInputs to Buildooor. The validator can read these UTxOs'
366
- * datums/values without consuming them (e.g., oracle feeds, shared config).
367
- */
391
+ /** UTxOs the build must never spend: left out of coin selection and collateral. */
392
+ protectInputs?: Array<{
393
+ txHash: string;
394
+ outputIndex: number;
395
+ }>;
396
+ /** CIP-31 reference inputs (read-only, not consumed), passed as readonlyRefInputs to Buildooor. */
368
397
  referenceInputs?: Array<{
369
398
  txHash: string;
370
399
  outputIndex: number;
371
400
  }>;
372
- /**
373
- * Optional additional outputs appended after the primary recipient output, before change.
374
- * Each extra output is independently min-ADA checked. Used for multi-output state-machine
375
- * transitions (e.g. counter update + batch NFT outputs in a single transaction).
376
- */
401
+ /** Additional outputs after the primary recipient output, before change; each min-ADA checked. */
377
402
  extraOutputs?: Array<{
378
403
  address: string;
379
404
  lovelaceAmount: string;
@@ -384,52 +409,104 @@ export type TxBuildRequest = {
384
409
  inlineDatum?: JSONValue;
385
410
  referenceScript?: string;
386
411
  }>;
387
- /**
388
- * Optional Plutus V3 validator CBOR hex to attach as a referenceScript on the primary
389
- * recipient output (CIP-33). Adding a ref script significantly increases the output's
390
- * min-ADA — consumers must provide enough lovelaceAmount to cover it.
391
- */
412
+ /** Plutus V3 validator CBOR hex attached as CIP-33 reference script on the recipient output; raises its min-ADA. */
392
413
  referenceScript?: string;
393
- /**
394
- * Optional validity-interval start in Posix milliseconds. Sets `invalidBefore`
395
- * on the built transaction so that Plutus validators checking
396
- * `expect Finite(lower) = tx.validity_range.lower_bound.bound_type` see a finite bound.
397
- * Defaults inside the builder to `Date.now() - 120_000` (script builds only).
398
- */
414
+ /** Validity start in Posix ms (`invalidBefore`); builder default `now - 120_000` for script builds. */
399
415
  validityStartMs?: string;
400
- /**
401
- * Optional validity-interval end in Posix milliseconds. Sets `invalidAfter` (ledger TTL).
402
- * Defaults inside the builder to `Date.now() + 3_600_000` (script builds only).
403
- */
416
+ /** Validity end in Posix ms (`invalidAfter`, ledger TTL); builder default `now + 3_600_000` for script builds. */
404
417
  validityEndMs?: string;
405
418
  };
406
- /**
407
- * Transaction Build Request for Mint/Burn operations - requires mintActions and mintingPolicyScript
408
- */
419
+ /** Mint/burn build request: mintActions and mintingPolicyScript required */
409
420
  export type TxBuildMintRequest = TxBuildRequest & {
410
421
  mintActions: MintAction[];
411
422
  mintingPolicyScript: string;
412
423
  };
413
- /**
414
- * Transaction Build Request for Plutus spending - requires plutusScriptExecution
415
- */
424
+ /** Plutus spend build request: plutusScriptExecution required */
416
425
  export type TxBuildPlutusSpendRequest = TxBuildRequest & {
417
426
  plutusScriptExecution: PlutusScriptExecution;
418
427
  };
428
+ /** One script UTxO spent by a BuildPlutusTransaction: an inline validator or a UTxO carrying the script. */
429
+ export type ScriptInput = {
430
+ txHash: string;
431
+ outputIndex: number;
432
+ /** Validator CBOR hex (script params already applied); exclusive with referenceScript. */
433
+ validatorScript?: string;
434
+ /** UTxO that carries the validator as reference script; added as reference input. */
435
+ referenceScript?: {
436
+ txHash: string;
437
+ outputIndex: number;
438
+ };
439
+ /** Redeemer (PlutusData JSON); `__INPUT_IDX__` placeholders resolve against the final inputs. */
440
+ redeemer: JSONValue;
441
+ /** Redeemer as PlutusData CBOR hex; wins over `redeemer`, no placeholders. */
442
+ redeemerCbor?: string;
443
+ /** Datum preimage (PlutusData JSON) for a hash-datum UTxO; inline datums are read from the UTxO. */
444
+ datum?: JSONValue;
445
+ /** Datum preimage as PlutusData CBOR hex; wins over `datum`. */
446
+ datumCbor?: string;
447
+ };
448
+ /** Output of a BuildPlutusTransaction, kept in the given order. */
449
+ export type PlutusTxOutput = NonNullable<TxBuildRequest['extraOutputs']>[number] & {
450
+ /** Datum hash to lock the output with (hex); exclusive with inlineDatum. */
451
+ datumHash?: string;
452
+ /** Inline datum as PlutusData CBOR hex, taken byte for byte; exclusive with inlineDatum. */
453
+ inlineDatumCbor?: string;
454
+ };
419
455
  /**
420
- * Execution Budget for Plutus scripts
421
- */
456
+ * Reward-account withdrawal of a BuildPlutusTransaction. A staking script (inline or by reference)
457
+ * runs with the redeemer under the Reward purpose; without a script the stake key signs.
458
+ */
459
+ export type WithdrawalInput = {
460
+ /** Bech32 reward account (stake address). */
461
+ rewardAddress: string;
462
+ /** Withdrawn lovelace; 0 for the withdraw-zero pattern. */
463
+ lovelace: string;
464
+ /** Staking script CBOR hex (script params already applied); exclusive with referenceScript. */
465
+ stakingScript?: string;
466
+ /** UTxO that carries the staking script as reference script; added as reference input. */
467
+ referenceScript?: {
468
+ txHash: string;
469
+ outputIndex: number;
470
+ };
471
+ /** Redeemer (PlutusData JSON); `__INPUT_IDX__` placeholders resolve against the final inputs. */
472
+ redeemer?: JSONValue;
473
+ /** Redeemer as PlutusData CBOR hex; wins over `redeemer`, no placeholders. */
474
+ redeemerCbor?: string;
475
+ };
476
+ /**
477
+ * Stake-credential certificate of a BuildPlutusTransaction. A registration without a script is the
478
+ * witness-free legacy form (key or script credential); with a script the Conway deposit form, run
479
+ * under the Certifying purpose. A deregistration needs the key's witness or the script.
480
+ */
481
+ export type CertificateInput = {
482
+ type: 'registerStake' | 'deregisterStake';
483
+ /** Bech32 stake address of the credential. */
484
+ stakeAddress: string;
485
+ /** Explicit deposit (lovelace) for the Conway forms; defaults to the protocol's stake deposit. */
486
+ deposit?: string;
487
+ stakingScript?: string;
488
+ referenceScript?: {
489
+ txHash: string;
490
+ outputIndex: number;
491
+ };
492
+ redeemer?: JSONValue;
493
+ redeemerCbor?: string;
494
+ };
495
+ /** BuildPlutusTransaction: several script inputs, the outputs as given, change after them. */
496
+ export type TxBuildPlutusRequest = Pick<TxBuildRequest, 'network' | 'senderAddress' | 'changeAddress' | 'requiredSigners' | 'forceInputs' | 'protectInputs' | 'referenceInputs' | 'mintActions' | 'validityStartMs' | 'validityEndMs'> & {
497
+ scriptInputs: ScriptInput[];
498
+ outputs: PlutusTxOutput[];
499
+ /** Reward-account withdrawals, with or without a staking script. */
500
+ withdrawals?: WithdrawalInput[];
501
+ /** Stake-credential registrations and deregistrations. */
502
+ certificates?: CertificateInput[];
503
+ };
504
+ /** Execution budget for Plutus scripts */
422
505
  export type ExecutionBudget = {
423
506
  memory: number;
424
507
  cpu: number;
425
508
  };
426
- /**
427
- * Script evaluation result from Ogmios
428
- */
429
- /**
430
- * Ogmios validator descriptor — `purpose:index` (e.g., "spend:0", "mint:1")
431
- * or a structured object with purpose + index fields depending on Ogmios version.
432
- */
509
+ /** Ogmios validator descriptor: `purpose:index` (e.g. "spend:0") or `{ purpose, index }` depending on version */
433
510
  export type ScriptValidator = string | {
434
511
  purpose: string;
435
512
  index: number;
@@ -438,13 +515,9 @@ export type ScriptEvaluationResult = {
438
515
  validator: ScriptValidator;
439
516
  budget: ExecutionBudget;
440
517
  };
441
- /**
442
- * Transaction evaluator function type - evaluates script execution units
443
- */
518
+ /** Evaluates script execution units of an unsigned tx */
444
519
  export type TxEvaluator = (unsignedTxCbor: string) => Promise<ScriptEvaluationResult[]>;
445
- /**
446
- * Transaction Build Context Type - Context for building a transaction
447
- */
520
+ /** Context for building a transaction */
448
521
  export type TxBuildContext = {
449
522
  utxos: UTxO[];
450
523
  protocolParameters: LedgerProtocolParameter;
@@ -453,9 +526,7 @@ export type TxBuildContext = {
453
526
  /** CIP-31 reference input UTxOs (read-only, not consumed). Resolved from referenceInputs refs. */
454
527
  referenceInputUtxos?: UTxO[];
455
528
  };
456
- /**
457
- * Transaction Build Result Type
458
- */
529
+ /** Transaction build result */
459
530
  export type TxBuildResult = {
460
531
  senderAddress?: string;
461
532
  network?: 'mainnet' | 'preprod' | 'preview';
@@ -489,10 +560,15 @@ export type TxBuildResult = {
489
560
  forcedInputsUsed?: number;
490
561
  /** Number of CIP-31 reference inputs included in the built transaction (0 if referenceInputs was not used). */
491
562
  referenceInputsUsed?: number;
563
+ /** Execution units stamped on each redeemer (script builds). */
564
+ redeemers?: Array<{
565
+ tag: string;
566
+ index: number;
567
+ mem: string;
568
+ steps: string;
569
+ }>;
492
570
  };
493
- /**
494
- * Supported external signer types
495
- */
571
+ /** Supported external signer types */
496
572
  export declare enum ExternalSignerType {
497
573
  /** Cardano CLI - Reference implementation for signing */
498
574
  CARDANO_CLI = "cardano-cli",
@@ -505,9 +581,7 @@ export declare enum ExternalSignerType {
505
581
  /** Hardware Security Module (server-side PKCS#11) */
506
582
  HSM = "hsm"
507
583
  }
508
- /**
509
- * Signing request status
510
- */
584
+ /** Signing request status */
511
585
  export declare enum SigningStatus {
512
586
  /** Request created, awaiting signing */
513
587
  PENDING = "pending",
@@ -522,9 +596,7 @@ export declare enum SigningStatus {
522
596
  /** Request expired (not signed within TTL) */
523
597
  EXPIRED = "expired"
524
598
  }
525
- /**
526
- * Instructions for external signers
527
- */
599
+ /** Instructions for external signers */
528
600
  export interface SigningInstructions {
529
601
  /** Signer type hint (which tool/wallet to use) */
530
602
  signerTypeHint: ExternalSignerType;
@@ -542,12 +614,7 @@ export interface SigningInstructions {
542
614
  /** Copy-pasteable cardano-cli signing recipe (for CLI/hardware signers) */
543
615
  cardanoCliCommand?: string;
544
616
  }
545
- /**
546
- * Unsigned transaction export payload for external signers
547
- *
548
- * This is the standardized format returned by BuildTransaction actions.
549
- * External signers use this payload to sign the transaction.
550
- */
617
+ /** Unsigned transaction payload returned by the Build actions for external signers */
551
618
  export interface UnsignedTxExportPayload {
552
619
  /** Unique identifier for this signing request */
553
620
  signingRequestId: string;
@@ -568,9 +635,7 @@ export interface UnsignedTxExportPayload {
568
635
  /** Signing instructions for the external signer */
569
636
  signingInstructions: SigningInstructions;
570
637
  }
571
- /**
572
- * Signed transaction submission payload
573
- */
638
+ /** Signed transaction submission payload */
574
639
  export interface SignedTxPayload {
575
640
  /** Original signing request ID */
576
641
  signingRequestId: string;
@@ -583,9 +648,7 @@ export interface SignedTxPayload {
583
648
  /** Optional: Signer identification (wallet name, etc.) */
584
649
  signerInfo?: string;
585
650
  }
586
- /**
587
- * Signing workflow state
588
- */
651
+ /** Signing workflow state */
589
652
  export interface SigningWorkflowState {
590
653
  /** Current status of the signing workflow */
591
654
  status: SigningStatus;
@@ -608,9 +671,25 @@ export interface SigningWorkflowState {
608
671
  failed?: string;
609
672
  };
610
673
  }
611
- /**
612
- * Result of signature verification
613
- */
674
+ /** Depth of a transaction in the chain. Depth 1 means it sits in the tip block. */
675
+ export interface TransactionConfirmations {
676
+ txHash: string;
677
+ /** null while the tx is not on chain. */
678
+ blockHeight: number | null;
679
+ tipHeight: number | null;
680
+ /** 0 while the tx is not on chain. */
681
+ confirmations: number;
682
+ }
683
+ /** Result of verifyTxWitnesses: every vkey signature checked against the body hash. */
684
+ export interface TxWitnessVerification {
685
+ valid: boolean;
686
+ /** null when the CBOR could not be read. */
687
+ txBodyHash: string | null;
688
+ /** blake2b-224 of each vkey whose signature verifies. */
689
+ signerKeyHashes: string[];
690
+ errors: string[];
691
+ }
692
+ /** Result of signature verification */
614
693
  export interface SignatureVerificationResult {
615
694
  /** Whether the signature is valid */
616
695
  isValid: boolean;
@@ -625,9 +704,7 @@ export interface SignatureVerificationResult {
625
704
  /** Error message if verification failed */
626
705
  errorMessage?: string;
627
706
  }
628
- /**
629
- * Options for signature verification
630
- */
707
+ /** Options for signature verification */
631
708
  export interface VerificationOptions {
632
709
  /** Expected transaction body hash (from the build) */
633
710
  expectedTxBodyHash?: string;
@@ -636,9 +713,7 @@ export interface VerificationOptions {
636
713
  /** List of required signer key hashes (public key hashes) */
637
714
  requiredSigners?: string[];
638
715
  }
639
- /**
640
- * HSM Configuration for PKCS#11 integration
641
- */
716
+ /** HSM configuration for PKCS#11 integration */
642
717
  export interface HsmConfig {
643
718
  /** Whether HSM signing is enabled */
644
719
  enabled: boolean;
@@ -652,12 +727,10 @@ export interface HsmConfig {
652
727
  keyId?: string;
653
728
  /** Key label for CKA_LABEL lookup */
654
729
  keyLabel?: string;
655
- /** Optional CDS role required for HSM actions (SignWithHsm, SignAndSubmitWithHsm, GetHsmStatus). When set, only users with this role can invoke HSM operations. */
730
+ /** CDS role required for the HSM actions (SignWithHsm, SignAndSubmitWithHsm, GetHsmStatus) */
656
731
  requiresRole?: string;
657
732
  }
658
- /**
659
- * HSM signing result
660
- */
733
+ /** HSM signing result */
661
734
  export interface HsmSignResult {
662
735
  /** Ed25519 signature (64 bytes, hex) */
663
736
  signatureHex: string;