@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.
- package/@cds-models/CardanoAgentService/index.d.ts +251 -0
- package/@cds-models/CardanoAgentService/index.js +36 -0
- package/@cds-models/CardanoBackendService/index.d.ts +357 -0
- package/@cds-models/CardanoBackendService/index.js +40 -0
- package/@cds-models/CardanoIndexerService/index.d.ts +194 -2
- package/@cds-models/CardanoIndexerService/index.js +25 -0
- package/@cds-models/CardanoODataService/index.d.ts +305 -7
- package/@cds-models/CardanoODataService/index.js +34 -0
- package/@cds-models/CardanoSignService/index.d.ts +28 -3
- package/@cds-models/CardanoSignService/index.js +3 -0
- package/@cds-models/CardanoTransactionService/index.d.ts +46 -13
- package/@cds-models/CardanoTransactionService/index.js +4 -0
- package/@cds-models/index.d.ts +72 -0
- package/@cds-models/index.js +12 -0
- package/@cds-models/odatano/cardano/index.d.ts +408 -7
- package/@cds-models/odatano/cardano/index.js +42 -0
- package/README.md +64 -5
- package/db/schema.cds +2297 -1633
- package/db/types.cds +114 -0
- package/package.json +27 -6
- package/scripts/migrate-slot-leader.mjs +104 -0
- package/scripts/migrate-txseq.mjs +147 -0
- package/src/index.d.ts +18 -11
- package/src/index.js +44 -14
- package/src/plugin.js +42 -52
- package/srv/blockchain/backends/blockfrost-backend.d.ts +29 -131
- package/srv/blockchain/backends/blockfrost-backend.js +53 -162
- package/srv/blockchain/backends/cardano-backend.d.ts +104 -158
- package/srv/blockchain/backends/cardano-backend.js +19 -5
- package/srv/blockchain/backends/koios-backend.d.ts +126 -60
- package/srv/blockchain/backends/koios-backend.js +376 -235
- package/srv/blockchain/backends/odatano-backend.d.ts +64 -0
- package/srv/blockchain/backends/odatano-backend.js +170 -0
- package/srv/blockchain/backends/ogmios-backend.d.ts +162 -94
- package/srv/blockchain/backends/ogmios-backend.js +556 -201
- package/srv/blockchain/backends/ogmios-frame-guard.d.ts +32 -0
- package/srv/blockchain/backends/ogmios-frame-guard.js +142 -0
- package/srv/blockchain/cardano-client.d.ts +87 -202
- package/srv/blockchain/cardano-client.js +210 -240
- package/srv/blockchain/cardano-indexer.d.ts +311 -242
- package/srv/blockchain/cardano-indexer.js +1238 -362
- package/srv/blockchain/cardano-tx-builder.d.ts +44 -81
- package/srv/blockchain/cardano-tx-builder.js +173 -132
- package/srv/blockchain/crawler/certificate-backfill.d.ts +67 -0
- package/srv/blockchain/crawler/certificate-backfill.js +169 -0
- package/srv/blockchain/crawler/crawler.d.ts +139 -54
- package/srv/blockchain/crawler/crawler.js +478 -96
- package/srv/blockchain/crawler/hooks.d.ts +3 -14
- package/srv/blockchain/crawler/index.d.ts +5 -0
- package/srv/blockchain/crawler/index.js +35 -7
- package/srv/blockchain/crawler/sync-state.d.ts +46 -28
- package/srv/blockchain/crawler/sync-state.js +128 -43
- package/srv/blockchain/crawler/transaction-backfill.d.ts +52 -0
- package/srv/blockchain/crawler/transaction-backfill.js +283 -0
- package/srv/blockchain/crawler/utxo-set-import.d.ts +78 -0
- package/srv/blockchain/crawler/utxo-set-import.js +363 -0
- package/srv/blockchain/ledger-state.d.ts +101 -0
- package/srv/blockchain/ledger-state.js +432 -0
- package/srv/blockchain/pending-spends.d.ts +28 -0
- package/srv/blockchain/pending-spends.js +89 -0
- package/srv/blockchain/signing/cose-verifier.d.ts +5 -12
- package/srv/blockchain/signing/cose-verifier.js +6 -12
- package/srv/blockchain/signing/external-signer.d.ts +16 -113
- package/srv/blockchain/signing/external-signer.js +19 -122
- package/srv/blockchain/signing/hsm-signer.d.ts +13 -45
- package/srv/blockchain/signing/hsm-signer.js +23 -63
- package/srv/blockchain/signing/signature-verifier.d.ts +14 -45
- package/srv/blockchain/signing/signature-verifier.js +73 -76
- package/srv/blockchain/signing/submission-finalizer.d.ts +9 -36
- package/srv/blockchain/signing/submission-finalizer.js +16 -49
- package/srv/blockchain/stored-chain.d.ts +33 -0
- package/srv/blockchain/stored-chain.js +234 -0
- package/srv/blockchain/transaction-building/buildooor-tx.d.ts +111 -173
- package/srv/blockchain/transaction-building/buildooor-tx.js +649 -326
- package/srv/blockchain/transaction-building/caller-datums.d.ts +29 -0
- package/srv/blockchain/transaction-building/caller-datums.js +139 -0
- package/srv/blockchain/transaction-building/cardano-tx.d.ts +10 -35
- package/srv/blockchain/transaction-rows.d.ts +12 -0
- package/srv/blockchain/transaction-rows.js +43 -0
- package/srv/blockchain/wallet-worker/build-request.d.ts +4 -17
- package/srv/blockchain/wallet-worker/build-request.js +18 -23
- package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +25 -17
- package/srv/blockchain/wallet-worker/confirmation-tracker.js +87 -41
- package/srv/blockchain/wallet-worker/index.js +2 -8
- package/srv/blockchain/wallet-worker/job-store.d.ts +36 -103
- package/srv/blockchain/wallet-worker/job-store.js +0 -0
- package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +4 -20
- package/srv/blockchain/wallet-worker/lease-heartbeat.js +4 -20
- package/srv/blockchain/wallet-worker/signers.d.ts +6 -19
- package/srv/blockchain/wallet-worker/signers.js +3 -8
- package/srv/blockchain/wallet-worker/wallet-worker.d.ts +15 -71
- package/srv/blockchain/wallet-worker/wallet-worker.js +40 -91
- package/srv/cardano-agent-service.cds +146 -0
- package/srv/cardano-agent-service.d.ts +2 -0
- package/srv/cardano-agent-service.js +12 -0
- package/srv/cardano-backend-service.cds +52 -0
- package/srv/cardano-backend-service.d.ts +2 -0
- package/srv/cardano-backend-service.js +244 -0
- package/srv/cardano-indexer-service.cds +201 -73
- package/srv/cardano-indexer-service.js +280 -11
- package/srv/cardano-service.cds +65 -2
- package/srv/cardano-service.js +170 -129
- package/srv/cardano-sign-service.cds +200 -180
- package/srv/cardano-sign-service.js +57 -184
- package/srv/cardano-tx-service.cds +439 -370
- package/srv/cardano-tx-service.js +231 -190
- package/srv/cardano-ui.cds +16 -16
- package/srv/cardano-worker-service.js +7 -15
- package/srv/cbor/index.d.ts +1 -1
- package/srv/cbor/parse.d.ts +27 -0
- package/srv/cbor/parse.js +63 -2
- package/srv/server.d.ts +28 -86
- package/srv/server.js +132 -135
- package/srv/utils/agent-grants-config.d.ts +37 -0
- package/srv/utils/agent-grants-config.js +138 -0
- package/srv/utils/agent-grants.d.ts +262 -0
- package/srv/utils/agent-grants.js +922 -0
- package/srv/utils/agent-token-auth.d.ts +16 -0
- package/srv/utils/agent-token-auth.js +78 -0
- package/srv/utils/backend-request-handler.d.ts +2 -16
- package/srv/utils/backend-request-handler.js +3 -18
- package/srv/utils/collections.d.ts +4 -8
- package/srv/utils/collections.js +4 -8
- package/srv/utils/const.d.ts +30 -67
- package/srv/utils/const.js +32 -72
- package/srv/utils/crypto.d.ts +3 -12
- package/srv/utils/crypto.js +5 -18
- package/srv/utils/db-indexes.d.ts +25 -0
- package/srv/utils/db-indexes.js +94 -0
- package/srv/utils/db-sanitize.d.ts +27 -0
- package/srv/utils/db-sanitize.js +85 -0
- package/srv/utils/epoch-slots.d.ts +20 -0
- package/srv/utils/epoch-slots.js +43 -0
- package/srv/utils/error-codes.d.ts +20 -73
- package/srv/utils/error-codes.js +19 -70
- package/srv/utils/errors.d.ts +50 -177
- package/srv/utils/errors.js +94 -218
- package/srv/utils/legacy-service-paths.d.ts +11 -0
- package/srv/utils/legacy-service-paths.js +58 -0
- package/srv/utils/liveness.d.ts +16 -0
- package/srv/utils/liveness.js +40 -0
- package/srv/utils/mappers.d.ts +128 -214
- package/srv/utils/mappers.js +354 -299
- package/srv/utils/network-context.js +2 -11
- package/srv/utils/pg-inline-json.d.ts +8 -0
- package/srv/utils/pg-inline-json.js +62 -0
- package/srv/utils/pg-order-nulls.d.ts +14 -0
- package/srv/utils/pg-order-nulls.js +56 -0
- package/srv/utils/plutus-placeholders.d.ts +23 -16
- package/srv/utils/plutus-placeholders.js +63 -27
- package/srv/utils/rate-limiter.d.ts +46 -0
- package/srv/utils/rate-limiter.js +116 -0
- package/srv/utils/service-events.d.ts +2 -22
- package/srv/utils/service-events.js +3 -23
- package/srv/utils/signing-helper.d.ts +6 -16
- package/srv/utils/signing-helper.js +36 -60
- package/srv/utils/tx-build-helper.d.ts +28 -93
- package/srv/utils/tx-build-helper.js +75 -124
- package/srv/utils/tx-request-parsers.d.ts +101 -28
- package/srv/utils/tx-request-parsers.js +410 -43
- package/srv/utils/tx-utils.d.ts +4 -23
- package/srv/utils/tx-utils.js +12 -41
- package/srv/utils/types.d.ts +252 -179
- package/srv/utils/types.js +2 -6
- package/srv/utils/validators.d.ts +24 -90
- 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
|
|
15
|
-
*
|
|
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
|
|
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
|
-
*
|
|
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
|
|
45
|
-
*
|
|
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
|
|
58
|
-
*
|
|
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
|
|
79
|
-
*
|
|
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
|
-
*
|
|
87
|
-
*
|
|
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
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
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
|
-
*
|
|
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
|
|
125
|
-
*
|
|
126
|
-
*
|
|
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
|
|
134
|
-
*
|
|
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
|
-
*
|
|
140
|
-
*
|
|
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
|
|
145
|
-
* 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
|
-
*
|
|
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
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
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
|
-
*
|
|
171
|
-
*
|
|
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
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
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
|
|
195
|
-
*
|
|
196
|
-
*
|
|
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
|
|
206
|
-
*
|
|
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
|
-
*
|
|
213
|
-
*
|
|
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
|
|
227
|
-
*
|
|
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
|
-
*
|
|
233
|
-
*
|
|
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
|
|
240
|
-
*
|
|
241
|
-
*
|
|
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
|
|
251
|
-
*
|
|
252
|
-
*
|
|
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
|
-
*
|
|
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
|
}
|