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

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,9 +1,7 @@
1
1
  import type { CardanoTxBuilder } from "./cardano-tx";
2
- import type { TxBuildRequest, TxBuildMintRequest, TxBuildPlutusSpendRequest, TxBuildContext, TxBuildResult, LedgerProtocolParameters } from "../../utils/types";
2
+ import type { TxBuildRequest, TxBuildMintRequest, TxBuildPlutusSpendRequest, TxBuildPlutusRequest, TxBuildContext, TxBuildResult, LedgerProtocolParameters } from "../../utils/types";
3
3
  import { CardanoClient } from "../cardano-client";
4
- /**
5
- * BuildooorTxBuilder - Implementation of CardanoTxBuilder using Buildooor library
6
- */
4
+ /** CardanoTxBuilder implementation on top of Buildooor. */
7
5
  export declare class BuildooorTxBuilder implements CardanoTxBuilder {
8
6
  readonly name = "BuildooorTxBuilder";
9
7
  private txBuilder;
@@ -11,90 +9,74 @@ export declare class BuildooorTxBuilder implements CardanoTxBuilder {
11
9
  private genesisInfos;
12
10
  private paramsFingerprint;
13
11
  /**
14
- * Chain cost-model arrays kept verbatim for language-view hashing. Maintained by
15
- * _mapCostModels (in lockstep with the named-key models the TxBuilder is built
16
- * with); consumed by _languageViewCostModels. Empty when the current parameters
17
- * carry no usable cost models (library defaults in effect).
12
+ * Chain cost-model arrays kept verbatim for language-view hashing; set by _mapCostModels,
13
+ * empty when the current parameters carry no usable cost models.
18
14
  */
19
15
  private rawCostModelArrays;
20
16
  /**
21
- * Initialize the builder
22
- * @param client - The CardanoClient instance
23
- * @param protocolParams - Optional protocol parameters (if not provided, fetched from backend)
17
+ * Initialize the builder.
18
+ * @param protocolParams - optional; fetched from the backend when omitted
24
19
  */
25
20
  init(client: CardanoClient, protocolParams?: LedgerProtocolParameters): Promise<void>;
26
21
  /**
27
- * Rebuild the TxBuilder when the per-request protocol parameters differ from
28
- * the ones the current TxBuilder was constructed with. Buildooor's TxBuilder
29
- * has no setter for protocol params, but its constructor is cheap, so we
30
- * rebuild on change (effectively once per epoch) instead of staying frozen
31
- * at init-time parameters for the process lifetime.
22
+ * Rebuild the TxBuilder when the per-request protocol parameters differ from the current
23
+ * ones; the TxBuilder has no setter but its constructor is cheap (effectively once per epoch).
32
24
  */
33
25
  private _ensureCurrentProtocolParameters;
34
26
  private _applyProtocolParameters;
35
- /**
36
- * Build unsigned transfer transaction (ADA-only or with native assets).
37
- */
27
+ /** Build an unsigned transfer transaction (ADA-only or with native assets). */
38
28
  buildUnsignedTransfer(req: TxBuildRequest, ctx: TxBuildContext): Promise<TxBuildResult>;
39
- /**
40
- * Build unsigned transfer transaction with attached metadata.
41
- */
29
+ /** Build an unsigned transfer transaction with attached metadata. */
42
30
  buildUnsignedTransactionWithMetadata(req: TxBuildRequest, ctx: TxBuildContext): Promise<TxBuildResult>;
43
31
  /**
44
- * Shared non-script transfer build. The two public entry points only differ in
45
- * the optional pieces of the request they carry (assets/outputDatum on the
46
- * plain-transfer path, metadataJson on the metadata path) — all handled here
47
- * conditionally on the field being present, so behaviour matches both.
32
+ * Shared non-script transfer build; assets, outputDatum and metadataJson are each
33
+ * handled only when present in the request.
48
34
  */
49
35
  private _buildSimpleTransfer;
50
36
  buildUnsignedMintTransaction(req: TxBuildMintRequest, ctx: TxBuildContext): Promise<TxBuildResult>;
51
37
  buildUnsignedPlutusSpendTransaction(req: TxBuildPlutusSpendRequest, ctx: TxBuildContext): Promise<TxBuildResult>;
38
+ /**
39
+ * Several script inputs in one transaction, each with its own redeemer (inline validator or a
40
+ * reference-script UTxO), the outputs exactly in the given order and change after them.
41
+ */
42
+ buildUnsignedPlutusTransaction(req: TxBuildPlutusRequest, ctx: TxBuildContext): Promise<TxBuildResult>;
43
+ /**
44
+ * Outputs of a BuildPlutusTransaction in the given order: inline datum or datum hash, ref script, min-ADA each.
45
+ * Returns the inline datums given as CBOR, keyed by output index.
46
+ */
47
+ private _appendPlutusOutputs;
48
+ /**
49
+ * Min-ADA of an output, counting the caller's datum bytes where they are longer than
50
+ * Buildooor's encoding. `forAnyAmount` sizes the coin field for the largest amount, so the
51
+ * result stays valid once written into the output.
52
+ */
53
+ private _minOutputLovelace;
54
+ /** Build, then write the caller's datum bytes; when they are longer, a second build raises the fee. */
55
+ private _buildWithCallerDatums;
52
56
  /** Extract CBOR, hash, fee, size, inputs and outputs from a built Buildooor Tx */
53
57
  private _extractTxDetails;
54
58
  /** Build the standard TxBuildResult object */
55
59
  private _buildResult;
56
60
  /**
57
- * Build a script-bearing transaction whose redeemers carry *real* execution units and
58
- * whose fee covers them.
59
- *
60
- * Background (verified against the vendored Buildooor source): `initTxBuild` constructs
61
- * every redeemer with a dummy budget — caller-supplied execution units in the build args
62
- * are never read — and `onEvaluationResult` unconditionally stamps each redeemer with
63
- * the budget the local CEK run consumed, even when the script failed (partial budget).
64
- * So the declared units are whatever the *local* evaluation produced, and any cushion
65
- * passed into the args silently evaporates. This method makes the declared units real:
66
- *
67
- * 1. First pass: build once; redeemers now carry the local CEK budgets.
68
- * 2. Evaluate that CBOR via Ogmios (when configured) for authoritative per-redeemer
69
- * budgets, cushioned by EXECUTION_UNIT_BUFFER / ABS_*_BUFFER.
70
- * 3. Resolve target units per redeemer (Ogmios beats buffered-local; a local failure
71
- * without an Ogmios result aborts — see makeScriptBuildOpts).
72
- * 4. Second pass with a fee floor covering the target units (Buildooor prices the fee
73
- * from its own local budgets, so the floor adds the price + encoding-size delta).
74
- * 5. Stamp the target units into the redeemers and recompute scriptDataHash.
61
+ * Build a script-bearing transaction with real execution units: Buildooor stamps local CEK
62
+ * budgets and ignores caller-supplied units, so build once, evaluate via Ogmios when available,
63
+ * rebuild with a fee floor for the target units, then stamp them and recompute scriptDataHash.
75
64
  */
76
65
  private _buildScriptTx;
77
66
  /**
78
- * Evaluate a transaction via Ogmios and return cushioned budgets keyed per redeemer
79
- * (`tag:index`). Returns undefined when the evaluation is unusable (transient backend
80
- * failure, empty result) so callers fall back to buffered local units. A
81
- * TransactionValidationError or ScriptValidationError from the evaluator is
82
- * authoritative (the script really failed on the ledger) and is rethrown.
67
+ * Evaluate via Ogmios; returns cushioned budgets keyed `tag:index`, or undefined when the
68
+ * evaluation is unusable (transient failure, empty result). Validation errors are rethrown.
83
69
  */
84
70
  private _evaluateExUnitsByRedeemer;
85
71
  /**
86
- * Combined cushion: relative multiplier catches proportional drift on large
87
- * validators, absolute floor catches sub-percent drift on small ones (observed
88
- * when metadata affects the real tx body vs the evaluator's ScriptContext).
72
+ * Cushion: relative multiplier for proportional drift on large validators, absolute floor
73
+ * for sub-percent drift on small ones.
89
74
  */
90
75
  private _applyExUnitBuffer;
91
76
  /**
92
- * Decide the execution units each redeemer must declare.
93
- * - Local run succeeded + Ogmios result → max of both (local is a real lower bound).
94
- * - Local run succeeded, no Ogmios → buffered local (cushions local↔ledger drift).
95
- * - Local run failed + Ogmios result → Ogmios (the local partial budget is meaningless).
96
- * - Local run failed, no Ogmios → abort: declaring unreliable units would forfeit the
97
- * collateral of whoever signs and submits the returned CBOR.
77
+ * Execution units each redeemer must declare: max(local, Ogmios) when both exist, buffered
78
+ * local without Ogmios, Ogmios alone after a local failure; a local failure without Ogmios
79
+ * aborts because unreliable units would forfeit the signer's collateral.
98
80
  */
99
81
  private _resolveTargetExUnits;
100
82
  /** Fee delta of the target vs local units, priced like Buildooor's own fee loop. */
@@ -103,17 +85,18 @@ export declare class BuildooorTxBuilder implements CardanoTxBuilder {
103
85
  private _exUnitsSizeDelta;
104
86
  private _txFeePerByte;
105
87
  /**
106
- * Replace the redeemers' execution units and recompute scriptDataHash.
107
- *
108
- * Still not implemented via TxBuilder.overrideTxRedeemers, although buildooor
109
- * 0.2.9 fixed its old-witness-set hashing (our PR): that method hashes with the
110
- * builder's named-key cost models, which clamp the chain array to the parameter
111
- * count the library release knows — wrong whenever the on-chain cost model has
112
- * grown past that (ScriptIntegrityHashMismatch at submit). This recompute with
113
- * _languageViewCostModels (raw chain arrays) stays governance-proof, so the hash
114
- * is recomputed here even when the target units already match.
88
+ * Replace the redeemers' execution units and recompute scriptDataHash with the raw chain
89
+ * cost-model arrays (TxBuilder.overrideTxRedeemers hashes with clamped named-key models,
90
+ * which mismatches once the on-chain cost model grows). Recomputed even when units match.
115
91
  */
116
92
  private _stampExecUnits;
93
+ /** Language views the scriptDataHash covers, from the chain's cost models. */
94
+ private _languageViews;
95
+ /**
96
+ * Check a witness datum against the datum hash its script UTxO is locked with: the ledger
97
+ * finds the datum by the hash of its bytes. Inline-datum UTxOs need no witness datum.
98
+ */
99
+ private _checkWitnessDatum;
117
100
  /**
118
101
  * Language-view selection for scriptDataHash, mirroring Buildooor's initTxBuild
119
102
  * (which flags the languages of *executed* scripts). This builder only attaches
@@ -121,69 +104,65 @@ export declare class BuildooorTxBuilder implements CardanoTxBuilder {
121
104
  */
122
105
  private _usedLanguageViewOpts;
123
106
  /**
124
- * Cost models for language-view hashing. The named-key objects the TxBuilder was
125
- * constructed with clamp the chain array to the parameter count this costmodels-ts
126
- * release knows (e.g. 297 for V3 pre-protocol-11), but the ledger hashes EVERY
127
- * entry the chain serves (350 on protocol-11 networks). toCostModelArrVN passes
128
- * array form through unclamped, so substitute the raw chain arrays where we have
129
- * them. (The named-key form stays in the TxBuilder — the CEK machine needs it.)
107
+ * Cost models for language-view hashing: named-key objects clamp the chain array to the
108
+ * parameter count this library release knows, but the ledger hashes every entry served,
109
+ * so raw chain arrays (passed through unclamped) are substituted where available.
130
110
  */
131
111
  private _languageViewCostModels;
132
112
  /**
133
- * Split UTxOs into forced inputs (must be consumed) and remaining candidates (free for
134
- * coin selection / collateral). Refs in forceInputs that are not present in utxos are
135
- * silently ignored — the resolver upstream has already validated existence.
113
+ * Split UTxOs into forced inputs (must be consumed) and remaining candidates; forceInputs
114
+ * refs absent from utxos are ignored (existence is validated upstream).
136
115
  */
137
116
  private _partitionForcedInputs;
138
117
  /**
139
- * Map resolved CIP-31 reference input UTxOs to Buildooor LedgerUTxO format.
140
- * Returns empty array when no reference inputs are provided.
118
+ * Script of a withdrawal, certificate or mint: inline (swapped for a reference input that already
119
+ * carries the same hash), by reference, or none (key witness).
141
120
  */
121
+ private _resolveScriptWitness;
122
+ /**
123
+ * Withdrawal credential hashes in ledger order, which `__WDRL_IDX__` resolves against. Buildooor
124
+ * numbers withdrawal redeemers by hash alone, so a scripted withdrawal whose position differs
125
+ * between the two orders would get the wrong redeemer; such a build is refused.
126
+ */
127
+ private _ledgerWithdrawalOrder;
128
+ /**
129
+ * Forced inputs of other key addresses: the owner's payment key hash must be a required signer,
130
+ * and every unit they bring must be spent by the outputs, so none of it lands in the sender's change.
131
+ * Script addresses are refused; those UTxOs are script inputs.
132
+ */
133
+ private _checkForeignForcedInputs;
134
+ /** Keys (`txhash#index`) of the reference inputs of a build, from the resolved UTxOs and the request refs. */
135
+ private _referencedKeys;
136
+ /** Map resolved CIP-31 reference input UTxOs to Buildooor LedgerUTxO; empty when none. */
142
137
  private _mapReferenceInputs;
143
138
  /**
144
- * Funding requirement contributed by extra outputs on a mint build:
145
- * the summed lovelace of all entries plus, per asset unit, the demand the
146
- * transaction's own positive mints do NOT cover. Minted quantities are
147
- * aggregated per unit and subtracted from the aggregated output demand;
148
- * only a positive remainder is requested from the wallet (a fully covered
149
- * unit is not requested at all — it does not exist before this tx).
139
+ * Funding contributed by extra outputs on a mint build: their summed lovelace plus, per asset
140
+ * unit, the demand the transaction's own positive mints do not cover.
150
141
  */
151
142
  private _extraOutputsFundingAfterMint;
152
143
  /**
153
- * The script an individual mint action executes under: its own
154
- * per-action policy when set (multi-policy mint FR), else the request's
144
+ * Script a mint action executes under: its per-action policy when set, else the request's
155
145
  * top-level policy script.
156
146
  */
157
147
  private _mintActionScript;
158
148
  /**
159
- * Build the Buildooor mint-entry array shared by the mint-only flow and the
160
- * combined spend+mint flow (Buildooor ignores caller-supplied execution units;
161
- * they are stamped into the redeemers post-build by _buildScriptTx).
162
- *
163
- * Multi-policy mint FR: each action may carry its own policy script and
164
- * redeemer; absent fields fall back to the request-level ones. The ledger
165
- * carries ONE redeemer per policy, so actions resolving to the same policy
166
- * must agree on their redeemer, checked here.
149
+ * Buildooor mint entries shared by all mint flows. `scriptFor` gives each action's policy, inline
150
+ * or as a reference-script UTxO. Each action may carry its own redeemer (falling back to the
151
+ * request-level one); the ledger holds ONE redeemer per policy, so actions on the same policy must agree.
167
152
  */
168
153
  private _buildMintEntries;
169
154
  /**
170
- * Consumer-facing context for insufficient-funds rejections after the
171
- * collateral partition: the builder's own "not enough …" message counts only
172
- * the funding pool, and without this the reservation is invisible ("but the
173
- * address HAS enough ADA").
155
+ * Context for insufficient-funds rejections after the collateral partition: the builder's
156
+ * message counts only the funding pool, so the reservation would otherwise be invisible.
174
157
  */
175
158
  private _collateralPartitionContext;
176
159
  /**
177
- * Pick a collateral UTxO and return remaining funding UTxOs.
178
- * Throws if no ADA-only UTxO is available.
179
- *
180
- * Selection: the SMALLEST ADA-only UTxO that still covers the static
181
- * COLLATERAL_LOVELACE floor (5 ADA ≳ collateralPercentage × any realistic fee).
182
- * The previous "first ADA-only" pick failed both ways: a dust UTxO below
183
- * collateralPercentage × fee is rejected at submit, and a large UTxO is
184
- * fully forfeited on phase-2 failure (Buildooor sets no collateralReturn
185
- * for ADA-only collateral). Everything above the floor is therefore handed
186
- * back via an explicit collateralReturn when the excess satisfies min-ADA.
160
+ * Pick the smallest ADA-only UTxO covering COLLATERAL_LOVELACE as collateral and return the
161
+ * rest as funding; excess above the floor goes back via collateralReturn when it meets min-ADA
162
+ * (Buildooor sets no collateralReturn for ADA-only collateral). Throws without an ADA-only UTxO.
163
+ * When the rest cannot pay `requiredLovelace` plus fee and change, the collateral UTxO is
164
+ * funding too. The ledger allows one UTxO as input and as collateral.
165
+ * When no UTxO in `utxos` covers the floor, a forced input of the sender that does is the collateral.
187
166
  */
188
167
  private _setupCollateral;
189
168
  /** Build a Ledger Value from lovelace + optional multi-asset array */
@@ -191,100 +170,59 @@ export declare class BuildooorTxBuilder implements CardanoTxBuilder {
191
170
  /** Build a TxOut with optional inline datum and optional reference script (CIP-33) */
192
171
  private _buildTxOut;
193
172
  /**
194
- * Parse a consumer-provided, CBOR-wrapped Plutus script and reject UPLC 1.0.0
195
- * code (PlutusV1/V2). `Script.fromCbor` defaults to PlutusV3, so V1/V2 bytes
196
- * would be hashed with the 0x03 prefix — a silently wrong script hash, i.e.
197
- * wrong policy IDs and unspendable script addresses with no error anywhere
198
- * down the line. The UPLC version is the first three flat-encoded naturals
199
- * of the unwrapped script: [1,0,0] (V1/V2) vs [1,1,0] (V3).
173
+ * Parse a CBOR-wrapped Plutus script and reject UPLC 1.0.0 code (V1/V2): Script.fromCbor
174
+ * defaults to V3 and would hash with the 0x03 prefix, giving a silently wrong script hash.
175
+ * The UPLC version is the first three flat naturals of the unwrapped script: [1,0,0] vs [1,1,0].
200
176
  */
201
177
  private _parsePlutusV3Script;
202
178
  /** Parse a Plutus V3 CBOR hex into a Buildooor Script for refScript attachment. */
203
179
  private _parseReferenceScript;
204
180
  /**
205
- * Map an input UTxO's scriptRef field to a Buildooor Script when possible.
206
- * UTxO.scriptRef is overloaded across backends: Blockfrost/Ogmios set it to a 28-byte
207
- * hash (56 hex chars), Koios sets it to the full CBOR script bytes. Only full bytes
208
- * are usable here — hash-only entries are preserved only on-chain, not in local eval.
181
+ * Map an input UTxO's reference script to a Script: `scriptRefCbor` (Ogmios), else a full-CBOR
182
+ * `scriptRef` (Koios); Blockfrost and the tables carry the 28-byte hash only, unusable locally.
209
183
  */
210
184
  private _buildInputRefScript;
211
185
  /**
212
- * Compute the post-sort input order so __INPUT_IDX__ placeholders (FR-3) resolve to the
213
- * same indices Buildooor will assign during build(). Order: script-input first by convention,
214
- * then forced + funding sorted lexicographically on (txHash, outputIndex).
215
- * Buildooor sorts ALL inputs together; we mirror that exact behaviour via sortInputsLikeBuildooor.
186
+ * Post-sort input order so __INPUT_IDX__ placeholders resolve to the indices Buildooor assigns
187
+ * in build(): all inputs (script, forced, funding) sorted lexicographically on (txHash, outputIndex).
216
188
  */
217
189
  private _computeSortedInputs;
218
190
  /** Extract InputRef list from the Buildooor-shaped funding inputs returned by keepRelevant. */
219
191
  private _extractFundingRefs;
220
- /**
221
- * Resolve __INPUT_IDX__ placeholders (FR-3) inside each extraOutput.inlineDatum.
222
- * Returns a new array with resolved datums; non-datum fields pass through unchanged.
223
- */
192
+ /** Resolve __INPUT_IDX__ placeholders inside each extraOutput.inlineDatum; other fields pass through. */
224
193
  private _resolveExtraOutputPlaceholders;
225
194
  /**
226
- * Append parsed extraOutputs (FR-2) to the outputs array, enforcing min-ADA per entry.
227
- * Throws TransactionValidationError with the required min-ADA in the message so consumers
228
- * can adjust without having to inspect Buildooor internals.
195
+ * Append parsed extra outputs, enforcing min-ADA per entry; the rejection names the
196
+ * required min-ADA so consumers can adjust without inspecting Buildooor internals.
229
197
  */
230
198
  private _appendExtraOutputs;
231
199
  /**
232
- * Resolve the transaction's validity window (slots) from the request.
233
- * Falls back to `now - 2 min` / `now + 1 h` when the request omits bounds.
234
- * Script-validated builds must call this; plain transfers pass their own
235
- * explicit bounds through (no defaulting) so replay behavior is opt-in.
200
+ * Validity window (slots) from the request. Script builds default to `now - 2 min` / `now + 1 h`;
201
+ * plain transfers pass explicit bounds through without defaulting.
236
202
  */
237
203
  private _resolveValiditySlots;
238
204
  /**
239
- * Map ODATANO LedgerProtocolParameter to Buildooor's ProtocolParameters shape.
240
- *
241
- * Every field is null-guarded: a missing/null source value keeps the library
242
- * default instead of degrading to 0 (`Number(null) === 0` previously set
243
- * utxoCostPerByte = 0, disabling min-ADA checks entirely). Cost models and
244
- * execution-unit prices are mapped because they feed the scriptDataHash
245
- * (language views) and the fee/ExUnits math — stale defaults there cause
246
- * PPViewHashesDontMatch or fee underestimation on-chain.
205
+ * Map LedgerProtocolParameter to Buildooor's ProtocolParameters. Every field is null-guarded so a
206
+ * missing value keeps the library default instead of degrading to 0 (e.g. utxoCostPerByte = 0
207
+ * disables min-ADA); cost models and ExUnit prices feed scriptDataHash and the fee math.
247
208
  */
248
209
  private _mapLedgerParametersToBuildooorParams;
249
210
  /**
250
- * Parse the cost-models JSON blob (backend-normalized number arrays, keys
251
- * 'PlutusV1'/'PlutusV2'/'PlutusV3' or Ogmios 'plutus:vN') into Buildooor's
252
- * CostModels shape ('PlutusScriptVN' keys). Returns undefined when nothing
253
- * usable is found, so the caller can keep defaults and warn.
254
- *
255
- * Side effect: (re)sets this.rawCostModelArrays with the unclamped chain arrays
256
- * for the versions mapped here — the named-key conversion drops every entry past
257
- * the parameter count this costmodels-ts release knows, and the scriptDataHash
258
- * must cover all of them (see _languageViewCostModels).
211
+ * Parse the cost-models JSON (keys 'PlutusVN', 'plutus:vN' or 'PlutusScriptVN') into Buildooor's
212
+ * CostModels; undefined when nothing usable is found. Also (re)sets this.rawCostModelArrays with
213
+ * the unclamped chain arrays, which the scriptDataHash must cover (see _languageViewCostModels).
259
214
  */
260
215
  private _mapCostModels;
261
- /**
262
- * Map ODATANO UTxO to Ledger UTxO (ADA-only)
263
- */
216
+ /** Map an ADA-only UTxO to a Ledger UTxO. */
264
217
  private _mapOdatanoUtxoToLedgerUtxo;
265
- /**
266
- * Map ODATANO UTxO to Ledger UTxO (with multi-asset support)
267
- */
218
+ /** Map a UTxO (with multi-assets) to a Ledger UTxO. */
268
219
  private _mapMultiAssetUtxoToLedgerUtxo;
269
- /**
270
- * Map ODATANO metadata JSON to Ledger TxMetadata
271
- */
220
+ /** Map metadata JSON (label -> value) to Ledger TxMetadata. */
272
221
  private _mapOdatanoMetadataToLedgerMetadata;
273
222
  /**
274
- * Recursively convert JSON value to TxMetadatum.
275
- *
276
- * Ledger rules enforced here (instead of a node-side rejection or a raw 500):
277
- * - numbers must be integers (BigInt(1.5) would throw a bare RangeError)
278
- * - text and byte values are limited to 64 BYTES per metadatum — longer values
279
- * are chunked into a list of ≤64-byte pieces (the established convention,
280
- * e.g. CIP-25 long strings)
281
- * - strings prefixed with "0x" (even hex length) become byte metadata
282
- * - map keys are not auto-chunked (readers match on the literal key) — over-long
283
- * keys are rejected with a clear 400
284
- *
285
- * @param path position of `value` inside the metadata JSON (label-rooted, e.g.
286
- * "1155.result" or "721.files[0].src") — named in every rejection
287
- * so the consumer can locate the offending value.
223
+ * Recursively convert a JSON value to TxMetadatum, enforcing ledger rules: integers only, text/bytes
224
+ * over 64 BYTES chunked into a list, "0x..." strings become bytes, over-long map keys rejected.
225
+ * @param path label-rooted position of `value` (e.g. "721.files[0].src"), named in every rejection
288
226
  */
289
227
  private _jsonToTxMetadatum;
290
228
  }