@odatano/core 2.0.0-rc.2 → 2.0.0-rc.21

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 (138) 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/CardanoIndexerService/index.d.ts +139 -2
  4. package/@cds-models/CardanoIndexerService/index.js +18 -0
  5. package/@cds-models/CardanoODataService/index.d.ts +231 -6
  6. package/@cds-models/CardanoODataService/index.js +27 -0
  7. package/@cds-models/CardanoSignService/index.d.ts +5 -2
  8. package/@cds-models/CardanoTransactionService/index.d.ts +9 -9
  9. package/@cds-models/odatano/cardano/index.d.ts +323 -6
  10. package/@cds-models/odatano/cardano/index.js +33 -0
  11. package/README.md +195 -136
  12. package/db/schema.cds +2133 -1633
  13. package/package.json +181 -173
  14. package/scripts/migrate-slot-leader.mjs +104 -0
  15. package/scripts/migrate-txseq.mjs +147 -0
  16. package/src/index.d.ts +10 -10
  17. package/src/index.js +24 -14
  18. package/src/plugin.js +39 -52
  19. package/srv/blockchain/backends/blockfrost-backend.d.ts +29 -131
  20. package/srv/blockchain/backends/blockfrost-backend.js +45 -158
  21. package/srv/blockchain/backends/cardano-backend.d.ts +83 -158
  22. package/srv/blockchain/backends/cardano-backend.js +14 -5
  23. package/srv/blockchain/backends/koios-backend.d.ts +126 -60
  24. package/srv/blockchain/backends/koios-backend.js +293 -203
  25. package/srv/blockchain/backends/ogmios-backend.d.ts +69 -94
  26. package/srv/blockchain/backends/ogmios-backend.js +319 -185
  27. package/srv/blockchain/backends/ogmios-frame-guard.d.ts +32 -0
  28. package/srv/blockchain/backends/ogmios-frame-guard.js +142 -0
  29. package/srv/blockchain/cardano-client.d.ts +57 -204
  30. package/srv/blockchain/cardano-client.js +94 -226
  31. package/srv/blockchain/cardano-indexer.d.ts +176 -240
  32. package/srv/blockchain/cardano-indexer.js +615 -338
  33. package/srv/blockchain/cardano-tx-builder.d.ts +29 -82
  34. package/srv/blockchain/cardano-tx-builder.js +88 -128
  35. package/srv/blockchain/crawler/certificate-backfill.d.ts +45 -0
  36. package/srv/blockchain/crawler/certificate-backfill.js +150 -0
  37. package/srv/blockchain/crawler/crawler.d.ts +121 -53
  38. package/srv/blockchain/crawler/crawler.js +403 -89
  39. package/srv/blockchain/crawler/hooks.d.ts +3 -14
  40. package/srv/blockchain/crawler/index.d.ts +5 -0
  41. package/srv/blockchain/crawler/index.js +35 -7
  42. package/srv/blockchain/crawler/sync-state.d.ts +44 -28
  43. package/srv/blockchain/crawler/sync-state.js +115 -43
  44. package/srv/blockchain/crawler/utxo-set-import.d.ts +69 -0
  45. package/srv/blockchain/crawler/utxo-set-import.js +269 -0
  46. package/srv/blockchain/ledger-state.d.ts +80 -0
  47. package/srv/blockchain/ledger-state.js +383 -0
  48. package/srv/blockchain/signing/cose-verifier.d.ts +5 -12
  49. package/srv/blockchain/signing/cose-verifier.js +6 -12
  50. package/srv/blockchain/signing/external-signer.d.ts +16 -113
  51. package/srv/blockchain/signing/external-signer.js +19 -122
  52. package/srv/blockchain/signing/hsm-signer.d.ts +13 -45
  53. package/srv/blockchain/signing/hsm-signer.js +23 -63
  54. package/srv/blockchain/signing/signature-verifier.d.ts +8 -44
  55. package/srv/blockchain/signing/signature-verifier.js +13 -54
  56. package/srv/blockchain/signing/submission-finalizer.d.ts +9 -36
  57. package/srv/blockchain/signing/submission-finalizer.js +16 -48
  58. package/srv/blockchain/transaction-building/buildooor-tx.d.ts +71 -160
  59. package/srv/blockchain/transaction-building/buildooor-tx.js +185 -260
  60. package/srv/blockchain/transaction-building/cardano-tx.d.ts +8 -34
  61. package/srv/blockchain/transaction-rows.d.ts +12 -0
  62. package/srv/blockchain/transaction-rows.js +42 -0
  63. package/srv/blockchain/wallet-worker/build-request.d.ts +4 -17
  64. package/srv/blockchain/wallet-worker/build-request.js +39 -23
  65. package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +25 -17
  66. package/srv/blockchain/wallet-worker/confirmation-tracker.js +87 -41
  67. package/srv/blockchain/wallet-worker/index.js +2 -8
  68. package/srv/blockchain/wallet-worker/job-store.d.ts +36 -103
  69. package/srv/blockchain/wallet-worker/job-store.js +0 -0
  70. package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +4 -20
  71. package/srv/blockchain/wallet-worker/lease-heartbeat.js +4 -20
  72. package/srv/blockchain/wallet-worker/signers.d.ts +6 -19
  73. package/srv/blockchain/wallet-worker/signers.js +3 -8
  74. package/srv/blockchain/wallet-worker/wallet-worker.d.ts +15 -71
  75. package/srv/blockchain/wallet-worker/wallet-worker.js +40 -91
  76. package/srv/cardano-agent-service.cds +146 -0
  77. package/srv/cardano-agent-service.d.ts +2 -0
  78. package/srv/cardano-agent-service.js +12 -0
  79. package/srv/cardano-indexer-service.cds +164 -73
  80. package/srv/cardano-indexer-service.js +156 -11
  81. package/srv/cardano-service.cds +45 -0
  82. package/srv/cardano-service.js +38 -96
  83. package/srv/cardano-sign-service.cds +200 -180
  84. package/srv/cardano-sign-service.js +55 -173
  85. package/srv/cardano-tx-service.cds +32 -26
  86. package/srv/cardano-tx-service.js +136 -196
  87. package/srv/cardano-worker-service.js +7 -15
  88. package/srv/server.d.ts +28 -86
  89. package/srv/server.js +95 -128
  90. package/srv/utils/agent-grants-config.d.ts +37 -0
  91. package/srv/utils/agent-grants-config.js +138 -0
  92. package/srv/utils/agent-grants.d.ts +262 -0
  93. package/srv/utils/agent-grants.js +914 -0
  94. package/srv/utils/agent-token-auth.d.ts +16 -0
  95. package/srv/utils/agent-token-auth.js +78 -0
  96. package/srv/utils/backend-request-handler.d.ts +2 -16
  97. package/srv/utils/backend-request-handler.js +3 -18
  98. package/srv/utils/collections.d.ts +4 -8
  99. package/srv/utils/collections.js +4 -8
  100. package/srv/utils/const.d.ts +19 -68
  101. package/srv/utils/const.js +20 -69
  102. package/srv/utils/crypto.d.ts +3 -12
  103. package/srv/utils/crypto.js +5 -18
  104. package/srv/utils/db-indexes.d.ts +25 -0
  105. package/srv/utils/db-indexes.js +93 -0
  106. package/srv/utils/db-sanitize.d.ts +27 -0
  107. package/srv/utils/db-sanitize.js +85 -0
  108. package/srv/utils/epoch-slots.d.ts +13 -0
  109. package/srv/utils/epoch-slots.js +25 -0
  110. package/srv/utils/error-codes.d.ts +18 -73
  111. package/srv/utils/error-codes.js +17 -70
  112. package/srv/utils/errors.d.ts +36 -179
  113. package/srv/utils/errors.js +62 -220
  114. package/srv/utils/liveness.d.ts +16 -0
  115. package/srv/utils/liveness.js +41 -0
  116. package/srv/utils/mappers.d.ts +89 -214
  117. package/srv/utils/mappers.js +289 -301
  118. package/srv/utils/network-context.js +2 -11
  119. package/srv/utils/pg-order-nulls.d.ts +14 -0
  120. package/srv/utils/pg-order-nulls.js +57 -0
  121. package/srv/utils/plutus-placeholders.d.ts +6 -18
  122. package/srv/utils/plutus-placeholders.js +6 -20
  123. package/srv/utils/rate-limiter.d.ts +46 -0
  124. package/srv/utils/rate-limiter.js +116 -0
  125. package/srv/utils/service-events.d.ts +2 -22
  126. package/srv/utils/service-events.js +3 -23
  127. package/srv/utils/signing-helper.d.ts +3 -18
  128. package/srv/utils/signing-helper.js +10 -32
  129. package/srv/utils/tx-build-helper.d.ts +18 -92
  130. package/srv/utils/tx-build-helper.js +32 -123
  131. package/srv/utils/tx-request-parsers.d.ts +14 -20
  132. package/srv/utils/tx-request-parsers.js +33 -20
  133. package/srv/utils/tx-utils.d.ts +4 -23
  134. package/srv/utils/tx-utils.js +12 -41
  135. package/srv/utils/types.d.ts +114 -169
  136. package/srv/utils/types.js +2 -6
  137. package/srv/utils/validators.d.ts +19 -89
  138. package/srv/utils/validators.js +31 -138
@@ -10,29 +10,20 @@ const cds_1 = __importDefault(require("@sap/cds"));
10
10
  const errors_1 = require("./errors");
11
11
  const error_codes_1 = require("./error-codes");
12
12
  /**
13
- * Transaction utilities shared by the sign-service and the background workers.
14
- *
15
- * Context: @cap-js/sqlite runs on a SINGLE pooled connection. A request
16
- * transaction begins lazily on its first CQL statement and holds that
17
- * connection until the request commits. Any code that then needs a NEW ROOT
18
- * transaction (detached committed bookkeeping) waits on the pool — forever,
19
- * if the waiter is awaited by the very request holding the connection
20
- * (docs/KNOWN_ISSUES.md issue 11).
13
+ * Transaction helpers for the sign-service and background workers. @cap-js/sqlite has a single pooled
14
+ * connection held by the request tx, so a new root tx awaited by that request would wait forever.
21
15
  */
22
16
  const logger = cds_1.default.log('tx-utils');
23
17
  /** Default acquire budget for detached bookkeeping transactions. */
24
18
  exports.DETACHED_TX_TIMEOUT_MS = 10_000;
25
- /** Effective timeout: env override (ODATANO_DETACHED_TX_TIMEOUT_MS) > default. Read per call so tests can tune it. */
19
+ /** ODATANO_DETACHED_TX_TIMEOUT_MS override, else the default; read per call. */
26
20
  function effectiveTimeoutMs() {
27
21
  const fromEnv = Number(process.env.ODATANO_DETACHED_TX_TIMEOUT_MS);
28
22
  return Number.isFinite(fromEnv) && fromEnv > 0 ? fromEnv : exports.DETACHED_TX_TIMEOUT_MS;
29
23
  }
30
24
  /**
31
- * Run `fn` with `cds.context` cleared, so any `db.run(...)` inside it gets a
32
- * fresh short-lived transaction instead of joining a long-lived ambient one.
33
- * Under @cap-js/sqlite (pool.max=1) this is what keeps the single pooled
34
- * connection free during long awaits (NIGHTGATE lesson 2; used by the
35
- * wallet-worker job loops).
25
+ * Run `fn` with `cds.context` cleared so inner `db.run` calls get short-lived transactions instead of
26
+ * joining a long-lived ambient one; keeps the single sqlite connection free during long awaits.
36
27
  */
37
28
  function runWithoutAmbientTx(fn) {
38
29
  return cds_1.default._with(undefined, fn);
@@ -45,34 +36,16 @@ class DetachedTxAbortedError extends Error {
45
36
  }
46
37
  }
47
38
  /**
48
- * `cds.tx(fn)` with a deadlock guard: a NEW ROOT transaction that fails fast
49
- * instead of hanging forever when no pooled connection becomes available.
50
- *
51
- * Why: the sign-service must commit its submit bookkeeping (claim, finalize,
52
- * failure marker) independently of the caller's request transaction. When an
53
- * in-process consumer awaits the action while its own request transaction
54
- * holds the single pooled sqlite connection, the acquire can never succeed —
55
- * without this guard that is a silent, zero-CPU, infinite hang.
56
- *
57
- * Guarantees:
58
- * - On timeout, throws `BackendError` 503 `ODATANO_NESTED_TX_TIMEOUT` with a
59
- * diagnosis pointing at KNOWN_ISSUES #11.
60
- * - A late connection grant (after the timeout already fired) performs NO
61
- * work: the callback forces the acquire via an explicit `begin()` and
62
- * checks the abort flag right after it, so it rolls back immediately and
63
- * the caller never observes an error for work that then silently happened
64
- * anyway. (A flag check at callback ENTRY would run long before the lazy
65
- * acquire and miss the timeout.)
39
+ * `cds.tx(fn)` as a new root transaction with a deadlock guard: throws BackendError 503
40
+ * `ODATANO_NESTED_TX_TIMEOUT` when no pooled connection arrives in time, and a late grant does no work.
66
41
  */
67
42
  async function detachedTx(label, fn, timeoutMs) {
68
43
  const effectiveTimeout = timeoutMs ?? effectiveTimeoutMs();
69
44
  let timedOut = false;
70
45
  let timer;
71
46
  const work = cds_1.default.tx(async (db) => {
72
- // cds.tx() starts this callback immediately; the pooled connection is only
73
- // acquired lazily by the first statement. Force the acquire NOW, then check
74
- // the abort flag — a late grant (after the caller already received the
75
- // timeout error) must roll back before doing any work.
47
+ // The connection is acquired lazily by the first statement: force it now, then check the abort
48
+ // flag so a grant after the timeout rolls back before doing any work.
76
49
  await db.begin();
77
50
  if (timedOut)
78
51
  throw new DetachedTxAbortedError(label);
@@ -84,8 +57,8 @@ async function detachedTx(label, fn, timeoutMs) {
84
57
  reject(new errors_1.BackendError(`${label}: could not begin a detached DB transaction within ${effectiveTimeout}ms. ` +
85
58
  `Most likely the calling request still holds the pooled DB connection open ` +
86
59
  `(in-process nested call — do not await this action while your request ` +
87
- `transaction is open; detach your reads into a committed cds.tx first, ` +
88
- `see docs/KNOWN_ISSUES.md issue 11). Alternatively the connection pool is exhausted.`, 503, error_codes_1.ERROR_CODES.NESTED_TX_TIMEOUT));
60
+ `transaction is open; detach your reads into a committed cds.tx first). ` +
61
+ `Alternatively the connection pool is exhausted.`, 503, error_codes_1.ERROR_CODES.NESTED_TX_TIMEOUT));
89
62
  }, effectiveTimeout);
90
63
  });
91
64
  try {
@@ -95,9 +68,7 @@ async function detachedTx(label, fn, timeoutMs) {
95
68
  if (timer)
96
69
  clearTimeout(timer);
97
70
  if (timedOut) {
98
- // The orphaned acquire may still be granted later; its callback aborts
99
- // itself via the flag. Observe the rejection so it never surfaces as an
100
- // unhandled promise rejection.
71
+ // The orphaned acquire may still be granted; observe its rejection so it is never unhandled.
101
72
  work.catch((e) => {
102
73
  if (!(e instanceof DetachedTxAbortedError)) {
103
74
  logger.warn(`Orphaned detached tx '${label}' failed after timeout: ${e instanceof Error ? e.message : String(e)}`);
@@ -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,57 @@ 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
+ /** Normalized transaction */
55
66
  export interface Transaction {
56
67
  hash: Hex;
57
68
  blockHash: Hex;
58
69
  blockHeight: number;
59
70
  slot: number;
60
71
  index: number;
72
+ /** What the ledger charged: the declared fee, or on a phase-2 failure the collateral consumed. */
61
73
  fee: Lovelace | string;
62
74
  deposit: Lovelace | string;
75
+ /**
76
+ * True when phase-2 failed: inputs/outputs not applied, collateral consumed, only the collateral
77
+ * return produced. Ogmios (`spends`) and Blockfrost (`valid_contract`) report it; Koios leaves it undefined.
78
+ */
79
+ spendsCollaterals?: boolean;
80
+ /**
81
+ * `total_collateral` from the body when declared; equals the collateral consumed on a phase-2 failure.
82
+ * Null when omitted, the charge is then derived from the resolved collateral inputs minus the return.
83
+ */
84
+ totalCollateral?: Lovelace | string | null;
85
+ /**
86
+ * Signed net mint/burn per unit (negative = burn), never `lovelace`. Ogmios and Koios report it;
87
+ * Blockfrost leaves it undefined and the indexer derives it from resolved input/output assets.
88
+ */
89
+ mint?: Amount[];
63
90
  /** Tx size in bytes; null when the source cannot provide it (Ogmios chain-sync). */
64
91
  size: number | null;
65
92
  blockTime: number;
@@ -67,10 +94,12 @@ export interface Transaction {
67
94
  inputs: TxInputLine[];
68
95
  outputs: TxOutputLine[];
69
96
  metadata?: MetadataLabelTx[];
97
+ /** Certificates; `[]` when the tx has none, undefined when the source does not report them (Blockfrost). */
98
+ certificates?: TxCertificate[];
99
+ /** Reward-account withdrawals; same `[]` vs undefined convention as `certificates`. */
100
+ withdrawals?: TxWithdrawal[];
70
101
  }
71
- /**
72
- * Address Data Structure Type - Address view, including current value and known UTxOs
73
- */
102
+ /** Address view with current value and known UTxOs */
74
103
  export interface Address {
75
104
  address: string;
76
105
  stakeAddress: string | null;
@@ -80,9 +109,7 @@ export interface Address {
80
109
  utxos: UTxO[];
81
110
  transactions?: Transaction[];
82
111
  }
83
- /**
84
- * UTxO Data Structure Type - Unspent transaction outputs (UTxOs)
85
- */
112
+ /** Unspent transaction output */
86
113
  export interface UTxO {
87
114
  txHash: Hex;
88
115
  outputIndex: number;
@@ -93,9 +120,7 @@ export interface UTxO {
93
120
  scriptRef?: Hex | null;
94
121
  inlineDatum?: string | null;
95
122
  }
96
- /**
97
- * Block Data Structure Type - Basic block information structure
98
- */
123
+ /** Basic block information */
99
124
  export interface BlockData {
100
125
  time: number;
101
126
  height: number | null;
@@ -107,10 +132,10 @@ export interface BlockData {
107
132
  size: number;
108
133
  txCount: number;
109
134
  fees?: string | null;
135
+ /** Header fields only (ledger tip): size, txCount, fees and slotLeader are placeholders, not block data. */
136
+ headerOnly?: boolean;
110
137
  }
111
- /**
112
- * Supply Data Structure Type - Network supply information
113
- */
138
+ /** Network supply */
114
139
  export interface Supply {
115
140
  max: string;
116
141
  total: string;
@@ -119,23 +144,17 @@ export interface Supply {
119
144
  treasury: string;
120
145
  reserves: string;
121
146
  }
122
- /**
123
- * Stake Data Structure Type - Network stake information
124
- */
147
+ /** Network stake */
125
148
  export interface Stake {
126
149
  live: string;
127
150
  active: string;
128
151
  }
129
- /**
130
- * Network Information Data Structure Type - Network supply and stake information
131
- */
152
+ /** Network supply and stake */
132
153
  export interface NetworkInformation {
133
154
  supply: Supply;
134
155
  stake: Stake;
135
156
  }
136
- /**
137
- * Epoch Data Structure Type - Epoch information
138
- */
157
+ /** Epoch information */
139
158
  export interface EpochData {
140
159
  epoch: number;
141
160
  start_time: number;
@@ -148,17 +167,13 @@ export interface EpochData {
148
167
  fees: string;
149
168
  active_stake: string | null;
150
169
  }
151
- /**
152
- * Metadata Label Transaction Data Structure Type - Transaction metadata under a specific label
153
- */
170
+ /** Transaction metadata under one label */
154
171
  export interface MetadataLabelTx {
155
172
  txHash: Hex;
156
173
  label: number | string;
157
174
  json?: JSONValue;
158
175
  }
159
- /**
160
- * Account Data Structure Type - Stake account information
161
- */
176
+ /** Stake account information */
162
177
  export interface AccountData {
163
178
  stakeaddress: string;
164
179
  active: boolean;
@@ -173,16 +188,16 @@ export interface AccountData {
173
188
  drepId: string | null;
174
189
  addresses: Address[];
175
190
  }
176
- /**
177
- * Pool Data Structure Type - Pool information
178
- */
191
+ /** Pool information */
179
192
  export interface PoolData {
180
193
  poolId: string;
181
194
  vrfKeyHash: string;
182
195
  blocksMinted: number;
183
- blocksEpoch: number;
196
+ /** Blocks minted in the current epoch; null when the backend has no such figure (Koios). */
197
+ blocksEpoch: number | null;
184
198
  liveStake: string;
185
199
  liveSize: number;
200
+ /** Fraction of the ideal (saturated) pool size, NOT percent: 0.7542 = 75.42 %. */
186
201
  liveSaturation: number;
187
202
  liveDelegators: number;
188
203
  activeStake: string;
@@ -192,9 +207,7 @@ export interface PoolData {
192
207
  fixedCost: string;
193
208
  rewardAccount: string;
194
209
  }
195
- /**
196
- * Drep Data Structure Type - Drep information
197
- */
210
+ /** DRep information */
198
211
  export interface DrepData {
199
212
  drepId: string;
200
213
  hex: string;
@@ -204,11 +217,7 @@ export interface DrepData {
204
217
  retired: boolean;
205
218
  expired: boolean;
206
219
  }
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
- */
220
+ /** Normalized native-asset metadata and supply; fields a backend does not expose are null. */
212
221
  export interface AssetInfo {
213
222
  unit: string;
214
223
  policyId: string;
@@ -227,10 +236,7 @@ export interface AssetInfo {
227
236
  registryUrl: string | null;
228
237
  registryLogo: string | null;
229
238
  }
230
- /**
231
- * Asset History Entry - single mint or burn event.
232
- * `quantity` is always the ABSOLUTE amount; sign info lives in `action`.
233
- */
239
+ /** One mint or burn event; `quantity` is absolute, the sign lives in `action`. */
234
240
  export interface AssetHistoryEntry {
235
241
  unit: string;
236
242
  txHash: string;
@@ -239,9 +245,7 @@ export interface AssetHistoryEntry {
239
245
  blockTime: number | null;
240
246
  blockHeight: number | null;
241
247
  }
242
- /**
243
- * Ledger Protocol Parameters Data Structure Type - Current protocol parameters
244
- */
248
+ /** Current protocol parameters */
245
249
  export type LedgerProtocolParameters = {
246
250
  network: string;
247
251
  epoch: number;
@@ -278,20 +282,26 @@ export type LedgerProtocolParameters = {
278
282
  fetchedAt: string;
279
283
  source: string;
280
284
  };
281
- /**
282
- * Mint/Burn Asset Action Type
283
- */
285
+ /** Mint/burn action */
284
286
  export type MintAction = {
285
287
  /** Asset unit to mint/burn (policyId + assetName) */
286
288
  assetUnit: string;
287
- /** Quantity to mint (positive) or burn (negative) */
289
+ /** Positive to mint, negative to burn */
288
290
  quantity: bigint;
289
- /** Optional redeemer data (integer). Defaults to 0 if not specified. */
291
+ /** Optional integer redeemer, default 0 */
290
292
  redeemer?: number;
293
+ /**
294
+ * Per-action minting policy (CBOR hex, applied as-is) for multi-policy transactions; overrides the
295
+ * top-level mintingPolicyScript. The assetUnit must carry this script's policyId.
296
+ */
297
+ mintingPolicyScript?: string;
298
+ /**
299
+ * Per-action redeemer (parsed PlutusData JSON), only with mintingPolicyScript; falls back to mintRedeemer.
300
+ * Actions on the same policy must agree (one redeemer per policy in the ledger).
301
+ */
302
+ redeemerJson?: JSONValue;
291
303
  };
292
- /**
293
- * Plutus Script Execution Type - For spending from script addresses
294
- */
304
+ /** Plutus script execution for spending from a script address */
295
305
  export type PlutusScriptExecution = {
296
306
  /** Validator script (CBOR hex) */
297
307
  validatorScript: string;
@@ -302,12 +312,10 @@ export type PlutusScriptExecution = {
302
312
  };
303
313
  /** Redeemer data (JSON value that will be converted to PlutusData) */
304
314
  redeemer: JSONValue;
305
- /** Datum data (JSON value, optional - required for hash-based datums) */
315
+ /** Datum (JSON value), required for hash-based datums */
306
316
  datum?: JSONValue;
307
317
  };
308
- /**
309
- * Transaction Build Request Type - Parameters for building a transaction, including optional minting and Plutus execution details
310
- */
318
+ /** Parameters for building a transaction, with optional minting and Plutus execution */
311
319
  export type TxBuildRequest = {
312
320
  network: 'mainnet' | 'preprod' | 'preview';
313
321
  senderAddress: string;
@@ -327,7 +335,7 @@ export type TxBuildRequest = {
327
335
  outputDatum?: JSONValue;
328
336
  /** Required signers - Ed25519 key hashes (hex, 28 bytes each) */
329
337
  requiredSigners?: string[];
330
- /** Script parameters — PlutusData JSON array applied to script before building */
338
+ /** Script parameters (PlutusData JSON array) applied to the script before building */
331
339
  scriptParams?: JSONValue[];
332
340
  /** Optional inline datum for minted token output (PlutusData JSON, parsed) */
333
341
  inlineDatum?: JSONValue;
@@ -336,29 +344,19 @@ export type TxBuildRequest = {
336
344
  /** When true, route output to enterprise script address derived from applied script hash */
337
345
  lockOnScript?: boolean;
338
346
  /**
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).
347
+ * UTxOs that must be consumed, added before coin selection (one-shot minting seeds);
348
+ * deduplicated against plutusScriptExecution.scriptUtxo.
343
349
  */
344
350
  forceInputs?: Array<{
345
351
  txHash: string;
346
352
  outputIndex: number;
347
353
  }>;
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
- */
354
+ /** CIP-31 reference inputs (read-only, not consumed), passed as readonlyRefInputs to Buildooor. */
353
355
  referenceInputs?: Array<{
354
356
  txHash: string;
355
357
  outputIndex: number;
356
358
  }>;
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
- */
359
+ /** Additional outputs after the primary recipient output, before change; each min-ADA checked. */
362
360
  extraOutputs?: Array<{
363
361
  address: string;
364
362
  lovelaceAmount: string;
@@ -369,52 +367,28 @@ export type TxBuildRequest = {
369
367
  inlineDatum?: JSONValue;
370
368
  referenceScript?: string;
371
369
  }>;
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
- */
370
+ /** Plutus V3 validator CBOR hex attached as CIP-33 reference script on the recipient output; raises its min-ADA. */
377
371
  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
- */
372
+ /** Validity start in Posix ms (`invalidBefore`); builder default `now - 120_000` for script builds. */
384
373
  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
- */
374
+ /** Validity end in Posix ms (`invalidAfter`, ledger TTL); builder default `now + 3_600_000` for script builds. */
389
375
  validityEndMs?: string;
390
376
  };
391
- /**
392
- * Transaction Build Request for Mint/Burn operations - requires mintActions and mintingPolicyScript
393
- */
377
+ /** Mint/burn build request: mintActions and mintingPolicyScript required */
394
378
  export type TxBuildMintRequest = TxBuildRequest & {
395
379
  mintActions: MintAction[];
396
380
  mintingPolicyScript: string;
397
381
  };
398
- /**
399
- * Transaction Build Request for Plutus spending - requires plutusScriptExecution
400
- */
382
+ /** Plutus spend build request: plutusScriptExecution required */
401
383
  export type TxBuildPlutusSpendRequest = TxBuildRequest & {
402
384
  plutusScriptExecution: PlutusScriptExecution;
403
385
  };
404
- /**
405
- * Execution Budget for Plutus scripts
406
- */
386
+ /** Execution budget for Plutus scripts */
407
387
  export type ExecutionBudget = {
408
388
  memory: number;
409
389
  cpu: number;
410
390
  };
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
- */
391
+ /** Ogmios validator descriptor: `purpose:index` (e.g. "spend:0") or `{ purpose, index }` depending on version */
418
392
  export type ScriptValidator = string | {
419
393
  purpose: string;
420
394
  index: number;
@@ -423,13 +397,9 @@ export type ScriptEvaluationResult = {
423
397
  validator: ScriptValidator;
424
398
  budget: ExecutionBudget;
425
399
  };
426
- /**
427
- * Transaction evaluator function type - evaluates script execution units
428
- */
400
+ /** Evaluates script execution units of an unsigned tx */
429
401
  export type TxEvaluator = (unsignedTxCbor: string) => Promise<ScriptEvaluationResult[]>;
430
- /**
431
- * Transaction Build Context Type - Context for building a transaction
432
- */
402
+ /** Context for building a transaction */
433
403
  export type TxBuildContext = {
434
404
  utxos: UTxO[];
435
405
  protocolParameters: LedgerProtocolParameter;
@@ -438,9 +408,7 @@ export type TxBuildContext = {
438
408
  /** CIP-31 reference input UTxOs (read-only, not consumed). Resolved from referenceInputs refs. */
439
409
  referenceInputUtxos?: UTxO[];
440
410
  };
441
- /**
442
- * Transaction Build Result Type
443
- */
411
+ /** Transaction build result */
444
412
  export type TxBuildResult = {
445
413
  senderAddress?: string;
446
414
  network?: 'mainnet' | 'preprod' | 'preview';
@@ -475,9 +443,7 @@ export type TxBuildResult = {
475
443
  /** Number of CIP-31 reference inputs included in the built transaction (0 if referenceInputs was not used). */
476
444
  referenceInputsUsed?: number;
477
445
  };
478
- /**
479
- * Supported external signer types
480
- */
446
+ /** Supported external signer types */
481
447
  export declare enum ExternalSignerType {
482
448
  /** Cardano CLI - Reference implementation for signing */
483
449
  CARDANO_CLI = "cardano-cli",
@@ -490,9 +456,7 @@ export declare enum ExternalSignerType {
490
456
  /** Hardware Security Module (server-side PKCS#11) */
491
457
  HSM = "hsm"
492
458
  }
493
- /**
494
- * Signing request status
495
- */
459
+ /** Signing request status */
496
460
  export declare enum SigningStatus {
497
461
  /** Request created, awaiting signing */
498
462
  PENDING = "pending",
@@ -507,9 +471,7 @@ export declare enum SigningStatus {
507
471
  /** Request expired (not signed within TTL) */
508
472
  EXPIRED = "expired"
509
473
  }
510
- /**
511
- * Instructions for external signers
512
- */
474
+ /** Instructions for external signers */
513
475
  export interface SigningInstructions {
514
476
  /** Signer type hint (which tool/wallet to use) */
515
477
  signerTypeHint: ExternalSignerType;
@@ -527,12 +489,7 @@ export interface SigningInstructions {
527
489
  /** Copy-pasteable cardano-cli signing recipe (for CLI/hardware signers) */
528
490
  cardanoCliCommand?: string;
529
491
  }
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
- */
492
+ /** Unsigned transaction payload returned by the Build actions for external signers */
536
493
  export interface UnsignedTxExportPayload {
537
494
  /** Unique identifier for this signing request */
538
495
  signingRequestId: string;
@@ -553,9 +510,7 @@ export interface UnsignedTxExportPayload {
553
510
  /** Signing instructions for the external signer */
554
511
  signingInstructions: SigningInstructions;
555
512
  }
556
- /**
557
- * Signed transaction submission payload
558
- */
513
+ /** Signed transaction submission payload */
559
514
  export interface SignedTxPayload {
560
515
  /** Original signing request ID */
561
516
  signingRequestId: string;
@@ -568,9 +523,7 @@ export interface SignedTxPayload {
568
523
  /** Optional: Signer identification (wallet name, etc.) */
569
524
  signerInfo?: string;
570
525
  }
571
- /**
572
- * Signing workflow state
573
- */
526
+ /** Signing workflow state */
574
527
  export interface SigningWorkflowState {
575
528
  /** Current status of the signing workflow */
576
529
  status: SigningStatus;
@@ -593,9 +546,7 @@ export interface SigningWorkflowState {
593
546
  failed?: string;
594
547
  };
595
548
  }
596
- /**
597
- * Result of signature verification
598
- */
549
+ /** Result of signature verification */
599
550
  export interface SignatureVerificationResult {
600
551
  /** Whether the signature is valid */
601
552
  isValid: boolean;
@@ -610,9 +561,7 @@ export interface SignatureVerificationResult {
610
561
  /** Error message if verification failed */
611
562
  errorMessage?: string;
612
563
  }
613
- /**
614
- * Options for signature verification
615
- */
564
+ /** Options for signature verification */
616
565
  export interface VerificationOptions {
617
566
  /** Expected transaction body hash (from the build) */
618
567
  expectedTxBodyHash?: string;
@@ -621,9 +570,7 @@ export interface VerificationOptions {
621
570
  /** List of required signer key hashes (public key hashes) */
622
571
  requiredSigners?: string[];
623
572
  }
624
- /**
625
- * HSM Configuration for PKCS#11 integration
626
- */
573
+ /** HSM configuration for PKCS#11 integration */
627
574
  export interface HsmConfig {
628
575
  /** Whether HSM signing is enabled */
629
576
  enabled: boolean;
@@ -637,12 +584,10 @@ export interface HsmConfig {
637
584
  keyId?: string;
638
585
  /** Key label for CKA_LABEL lookup */
639
586
  keyLabel?: string;
640
- /** Optional CDS role required for HSM actions (SignWithHsm, SignAndSubmitWithHsm, GetHsmStatus). When set, only users with this role can invoke HSM operations. */
587
+ /** CDS role required for the HSM actions (SignWithHsm, SignAndSubmitWithHsm, GetHsmStatus) */
641
588
  requiresRole?: string;
642
589
  }
643
- /**
644
- * HSM signing result
645
- */
590
+ /** HSM signing result */
646
591
  export interface HsmSignResult {
647
592
  /** Ed25519 signature (64 bytes, hex) */
648
593
  signatureHex: string;
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SigningStatus = exports.ExternalSignerType = void 0;
4
- /**
5
- * Supported external signer types
6
- */
4
+ /** Supported external signer types */
7
5
  var ExternalSignerType;
8
6
  (function (ExternalSignerType) {
9
7
  /** Cardano CLI - Reference implementation for signing */
@@ -17,9 +15,7 @@ var ExternalSignerType;
17
15
  /** Hardware Security Module (server-side PKCS#11) */
18
16
  ExternalSignerType["HSM"] = "hsm";
19
17
  })(ExternalSignerType || (exports.ExternalSignerType = ExternalSignerType = {}));
20
- /**
21
- * Signing request status
22
- */
18
+ /** Signing request status */
23
19
  var SigningStatus;
24
20
  (function (SigningStatus) {
25
21
  /** Request created, awaiting signing */