@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.
- 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
|
@@ -5,25 +5,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.combineTransactionWithWitnesses = combineTransactionWithWitnesses;
|
|
7
7
|
exports.isWitnessSetCbor = isWitnessSetCbor;
|
|
8
|
+
exports.toSignedTransaction = toSignedTransaction;
|
|
8
9
|
const cds_1 = __importDefault(require("@sap/cds"));
|
|
9
10
|
const cbor_1 = require("@harmoniclabs/cbor");
|
|
10
11
|
const uint8array_utils_1 = require("@harmoniclabs/uint8array-utils");
|
|
11
12
|
const errors_1 = require("./errors");
|
|
12
13
|
const logger = cds_1.default.log('SigningHelper');
|
|
13
14
|
/**
|
|
14
|
-
* Combine an unsigned
|
|
15
|
-
*
|
|
16
|
-
* CIP-30 signTx() returns only the witness set, not a complete signed transaction.
|
|
17
|
-
* This function combines the original unsigned transaction with the witness set
|
|
18
|
-
* to create a complete signed transaction that can be submitted to the network.
|
|
19
|
-
*
|
|
20
|
-
* @param unsignedTxCbor - The unsigned transaction CBOR (hex)
|
|
21
|
-
* @param witnessSetCbor - The witness set CBOR from CIP-30 signTx() (hex)
|
|
22
|
-
* @returns Complete signed transaction CBOR (hex)
|
|
15
|
+
* Combine an unsigned tx with the witness set a CIP-30 `signTx()` returns into a submittable signed tx.
|
|
16
|
+
* @returns complete signed transaction CBOR (hex)
|
|
23
17
|
*/
|
|
24
18
|
function combineTransactionWithWitnesses(unsignedTxCbor, witnessSetCbor) {
|
|
25
19
|
try {
|
|
26
|
-
//
|
|
20
|
+
// Raw CBOR level: no Cardano type validation, preserves all encoding metadata
|
|
27
21
|
const txObj = cbor_1.Cbor.parse((0, uint8array_utils_1.fromHex)(unsignedTxCbor));
|
|
28
22
|
if (!(txObj instanceof cbor_1.CborArray) || txObj.array.length < 2) {
|
|
29
23
|
throw new errors_1.TransactionValidationError('Invalid transaction CBOR structure');
|
|
@@ -31,41 +25,29 @@ function combineTransactionWithWitnesses(unsignedTxCbor, witnessSetCbor) {
|
|
|
31
25
|
const walletWsObj = cbor_1.Cbor.parse((0, uint8array_utils_1.fromHex)(witnessSetCbor));
|
|
32
26
|
// txObj.array[0] = body, [1] = witness_set, [2] = is_valid, [3] = auxiliary_data
|
|
33
27
|
const origWs = txObj.array[1];
|
|
28
|
+
if (!(origWs instanceof cbor_1.CborMap) || !(walletWsObj instanceof cbor_1.CborMap)) {
|
|
29
|
+
throw new errors_1.TransactionValidationError('Witness set must be CBOR map per Cardano spec');
|
|
30
|
+
}
|
|
31
|
+
// The wallet signs with vkey witnesses (map key 0) or, for Byron addresses, bootstrap witnesses (key 2)
|
|
32
|
+
const isSignatureKey = (k) => k instanceof cbor_1.CborUInt && (Number(k.num) === 0 || Number(k.num) === 2);
|
|
33
|
+
const walletSignatures = walletWsObj.map.filter(e => isSignatureKey(e.k));
|
|
34
34
|
let witnessCount = 0;
|
|
35
|
-
|
|
36
|
-
//
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const mergedEntries = origWs.map
|
|
42
|
-
.filter(e => !(e.k instanceof cbor_1.CborUInt && Number(e.k.num) === 0))
|
|
43
|
-
.concat([walletVkeyEntry]);
|
|
44
|
-
// Construct new witness set CborMap preserving the original's encoding style
|
|
45
|
-
txObj.array[1] = new cbor_1.CborMap(mergedEntries, {
|
|
46
|
-
indefinite: origWs.indefinite,
|
|
47
|
-
});
|
|
48
|
-
// Count VKey witnesses — value may be CborArray or CborTag(258, CborArray) in Conway era
|
|
49
|
-
const vkeyValue = walletVkeyEntry.v;
|
|
50
|
-
if (vkeyValue instanceof cbor_1.CborArray) {
|
|
51
|
-
witnessCount = vkeyValue.array.length;
|
|
52
|
-
}
|
|
53
|
-
else if (vkeyValue instanceof cbor_1.CborTag && vkeyValue.data instanceof cbor_1.CborArray) {
|
|
54
|
-
witnessCount = vkeyValue.data.array.length;
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
throw new errors_1.TransactionValidationError('Unexpected VKey witness format in witness set');
|
|
58
|
-
}
|
|
59
|
-
}
|
|
35
|
+
for (const { v } of walletSignatures) {
|
|
36
|
+
// CborArray, or CborTag(258, CborArray) in Conway
|
|
37
|
+
const items = v instanceof cbor_1.CborArray ? v.array : v instanceof cbor_1.CborTag && v.data instanceof cbor_1.CborArray ? v.data.array : undefined;
|
|
38
|
+
if (!items)
|
|
39
|
+
throw new errors_1.TransactionValidationError('Unexpected witness format in witness set');
|
|
40
|
+
witnessCount += items.length;
|
|
60
41
|
}
|
|
61
|
-
|
|
62
|
-
throw new errors_1.TransactionValidationError('Witness set
|
|
42
|
+
if (witnessCount === 0) {
|
|
43
|
+
throw new errors_1.TransactionValidationError('Witness set carries no vkey or bootstrap witness; the wallet did not sign');
|
|
63
44
|
}
|
|
64
|
-
//
|
|
65
|
-
|
|
66
|
-
//
|
|
67
|
-
|
|
68
|
-
// the
|
|
45
|
+
// Keep original entries (redeemers, datums, scripts at keys 3-7), take the signatures from the wallet
|
|
46
|
+
const mergedEntries = origWs.map.filter(e => !isSignatureKey(e.k)).concat(walletSignatures);
|
|
47
|
+
// New witness set map preserving the original's encoding style
|
|
48
|
+
txObj.array[1] = new cbor_1.CborMap(mergedEntries, { indefinite: origWs.indefinite });
|
|
49
|
+
// New outer CborArray so the encoder cannot reuse the stale outer subCborRef; the inner
|
|
50
|
+
// subCborRefs are kept so the body bytes (and thus the signed body hash) stay identical.
|
|
69
51
|
const signedTxCbor = (0, uint8array_utils_1.toHex)(cbor_1.Cbor.encode(new cbor_1.CborArray(txObj.array, { indefinite: txObj.indefinite })));
|
|
70
52
|
logger.info({
|
|
71
53
|
unsignedTxLength: unsignedTxCbor.length,
|
|
@@ -82,26 +64,20 @@ function combineTransactionWithWitnesses(unsignedTxCbor, witnessSetCbor) {
|
|
|
82
64
|
}
|
|
83
65
|
}
|
|
84
66
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* CIP-30 returns witness sets, not full transactions.
|
|
88
|
-
* This helps detect when we need to call combineTransactionWithWitnesses.
|
|
89
|
-
*
|
|
90
|
-
* @param cborHex - CBOR hex string
|
|
91
|
-
* @returns true if it's a witness set, false if it's a full transaction
|
|
67
|
+
* True when the CBOR is a CIP-30 witness set (map) rather than a full transaction (array).
|
|
68
|
+
* Reads the major type of the first byte only; a malformed map fails later in the combine step.
|
|
92
69
|
*/
|
|
93
70
|
function isWitnessSetCbor(cborHex) {
|
|
94
|
-
|
|
95
|
-
const obj = cbor_1.Cbor.parse((0, uint8array_utils_1.fromHex)(cborHex));
|
|
96
|
-
// A full transaction is a CBOR array ([body, witness_set, is_valid, aux_data]);
|
|
97
|
-
// a CIP-30 witness set is a CBOR map. The two shapes are unambiguous.
|
|
98
|
-
if (obj instanceof cbor_1.CborArray)
|
|
99
|
-
return false;
|
|
100
|
-
return obj instanceof cbor_1.CborMap;
|
|
101
|
-
}
|
|
102
|
-
catch {
|
|
103
|
-
// Invalid / unparseable CBOR
|
|
71
|
+
if (!/^[0-9a-f]{2}/i.test(cborHex))
|
|
104
72
|
return false;
|
|
105
|
-
|
|
73
|
+
return parseInt(cborHex.slice(0, 2), 16) >> 5 === 5;
|
|
74
|
+
}
|
|
75
|
+
/** The signed transaction: as given, or the unsigned one plus a CIP-30 witness set. */
|
|
76
|
+
function toSignedTransaction(unsignedTxCbor, signedTxOrWitnessSet) {
|
|
77
|
+
if (!isWitnessSetCbor(signedTxOrWitnessSet))
|
|
78
|
+
return signedTxOrWitnessSet;
|
|
79
|
+
if (!unsignedTxCbor)
|
|
80
|
+
throw new errors_1.TransactionValidationError('No unsigned transaction to add the witness set to');
|
|
81
|
+
return combineTransactionWithWitnesses(unsignedTxCbor, signedTxOrWitnessSet);
|
|
106
82
|
}
|
|
107
83
|
//# sourceMappingURL=signing-helper.js.map
|
|
@@ -1,24 +1,15 @@
|
|
|
1
1
|
import type { UTxO as OdatanoUtxo, JSONValue } from '../utils/types';
|
|
2
2
|
import { type Data } from '@harmoniclabs/plutus-data';
|
|
3
3
|
import { UPLCConst } from '@harmoniclabs/uplc';
|
|
4
|
-
/**
|
|
5
|
-
* Extract lovelace amount from UTxO
|
|
6
|
-
* @param u UTxO to extract from
|
|
7
|
-
* @returns {bigint} lovelace amount
|
|
8
|
-
*/
|
|
4
|
+
/** Lovelace amount of a UTxO. */
|
|
9
5
|
export declare function getLovelace(u: OdatanoUtxo): bigint;
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
* @throws {MixedAssetsError} if UTxO contains non-ADA assets
|
|
14
|
-
*/
|
|
6
|
+
/** A UTxO the builders may take as collateral: lovelace only and no reference script. */
|
|
7
|
+
export declare function isCollateralCandidate(u: OdatanoUtxo): boolean;
|
|
8
|
+
/** Throws MixedAssetsError when the UTxO carries non-ADA assets. */
|
|
15
9
|
export declare function assertAdaOnly(u: OdatanoUtxo): void;
|
|
16
10
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* @param txCbor transaction in CBOR hex format
|
|
20
|
-
* @returns {string} transaction hash (64 character hex string)
|
|
21
|
-
* @throws {Error} if CBOR is invalid or transaction hash cannot be extracted
|
|
11
|
+
* Transaction hash of a signed or unsigned tx CBOR: blake2b-256 over the body bytes, so witnesses do not affect it.
|
|
12
|
+
* @returns 64-char hex string
|
|
22
13
|
*/
|
|
23
14
|
export declare function getTxHashFromCbor(txCbor: string): string;
|
|
24
15
|
/** Cache-invalidation targets of a submitted transaction (see extractTxCacheTargets). */
|
|
@@ -32,102 +23,46 @@ export interface TxCacheTargets {
|
|
|
32
23
|
outputAddresses: string[];
|
|
33
24
|
}
|
|
34
25
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* UTxO cache. Works at the raw-CBOR level for the same reason as
|
|
38
|
-
* getTxHashFromCbor (byte-exact, no high-level Tx round-trip).
|
|
39
|
-
*
|
|
40
|
-
* Outputs whose address bytes cannot be decoded (e.g. Byron bootstrap
|
|
41
|
-
* addresses) are skipped — invalidation is best-effort per address.
|
|
42
|
-
*
|
|
43
|
-
* @param txCbor transaction in CBOR hex format
|
|
44
|
-
* @throws {TransactionValidationError} if the CBOR is not a transaction
|
|
26
|
+
* Consumed input refs and output addresses of a tx CBOR: the UTxO-cache rows a submit makes stale.
|
|
27
|
+
* Outputs whose address bytes cannot be decoded (Byron) are skipped.
|
|
45
28
|
*/
|
|
46
29
|
export declare function extractTxCacheTargets(txCbor: string): TxCacheTargets;
|
|
47
30
|
/**
|
|
48
|
-
* Maps
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* (e.g. "not enough <policyId.assetName>"), falling back to 'lovelace'.
|
|
52
|
-
* @param err Error from builder
|
|
53
|
-
* @param assetUnit Optional asset unit override (auto-extracted from error message if omitted)
|
|
54
|
-
* @param context Optional build-flow context (e.g. the collateral/funding partition)
|
|
55
|
-
* appended to the consumer-facing message — the builder's own message
|
|
56
|
-
* has no way of knowing it
|
|
57
|
-
* @throws {InsufficientFundsError} if error is related to insufficient funds
|
|
58
|
-
* @throws {Error} original error if not mappable
|
|
59
|
-
*/
|
|
60
|
-
export declare function mapBuilderError(err: unknown, assetUnit?: string, context?: string): never;
|
|
61
|
-
/**
|
|
62
|
-
* Parse asset unit string into policyId and assetName
|
|
63
|
-
* Format: policyId (56 hex chars) + assetName (remaining hex)
|
|
64
|
-
* Used by the Buildooor transaction builder
|
|
31
|
+
* Maps Buildooor errors to typed BackendErrors. Asset unit is parsed from "not enough <unit>" when not given;
|
|
32
|
+
* `context` (e.g. the collateral partition) is appended to the consumer-facing message.
|
|
33
|
+
* `requestedOutputs` is the number of outputs the caller asked for; Buildooor appends the change after them.
|
|
65
34
|
*/
|
|
35
|
+
export declare function mapBuilderError(err: unknown, assetUnit?: string, context?: string, requestedOutputs?: number): never;
|
|
36
|
+
/** Split an asset unit into policyId (56 hex chars) and assetName (remaining hex). */
|
|
66
37
|
export declare function parseAssetUnit(assetUnit: string): {
|
|
67
38
|
policyId: string;
|
|
68
39
|
assetName: string;
|
|
69
40
|
};
|
|
70
|
-
/**
|
|
71
|
-
* Convert JSON value to Buildooor PlutusData (Data type).
|
|
72
|
-
* Accepts both cardano-cli format ("constructor") and Buildooor format ("constr").
|
|
73
|
-
* - { "int": 42 } → DataI(42)
|
|
74
|
-
* - { "bytes": "deadbeef" } → DataB("deadbeef")
|
|
75
|
-
* - { "list": [...] } → DataList([...])
|
|
76
|
-
* - { "map": [{ "k": ..., "v": ... }] } → DataMap([...])
|
|
77
|
-
* - { "constructor": 0, "fields": [...] } or { "constr": 0, "fields": [...] } → DataConstr(0, [...])
|
|
78
|
-
* @param json JSON value representing PlutusData
|
|
79
|
-
* @returns Buildooor Data object
|
|
80
|
-
*/
|
|
41
|
+
/** JSON (`int` / `bytes` / `list` / `map` / `constructor`|`constr`) to Buildooor PlutusData. */
|
|
81
42
|
export declare function jsonToPlutusData(json: JSONValue): Data;
|
|
82
43
|
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* Backends report inline datums in different shapes:
|
|
86
|
-
* - Blockfrost: hex CBOR string (e.g. "19a6aa")
|
|
87
|
-
* - Koios (_extended): wrapper { bytes: "<hex>", value: { ...PlutusData JSON... } }
|
|
88
|
-
* - Koios (sometimes empty): { bytes: null, value: null }
|
|
89
|
-
* - Some endpoints: raw PlutusData JSON ({ "int": 42 } / { "constructor": 0, "fields": [] })
|
|
90
|
-
*
|
|
91
|
-
* Returns hex CBOR (lowercase) or null. Defensive: returns null on unknown
|
|
92
|
-
* shapes rather than throwing — backend mappers must not crash on malformed data.
|
|
44
|
+
* Backend inline datum to lowercase CBOR hex: hex string (Blockfrost), `{ bytes, value }` wrapper (Koios)
|
|
45
|
+
* or raw PlutusData JSON. Returns null on unknown shapes instead of throwing.
|
|
93
46
|
*/
|
|
94
47
|
export declare function inlineDatumToHex(datum: unknown): string | null;
|
|
95
48
|
/** UPLC type tag for a typed script parameter (see {@link encodeScriptParam}). */
|
|
96
49
|
export type ScriptParamUplcType = 'data' | 'bytes' | 'int' | 'bool' | 'unit';
|
|
97
50
|
/**
|
|
98
|
-
* Encode a
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
* A script parameter is applied as a UPLC constant whose TYPE must match what
|
|
102
|
-
* the compiled validator expects for that parameter. Two input shapes are
|
|
103
|
-
* accepted:
|
|
104
|
-
*
|
|
105
|
-
* 1. Typed — `{ "uplc": "<type>", "value": <...> }`:
|
|
106
|
-
* - `"data"` → `UPLCConst.data(...)` value: PlutusData JSON ("constr"/cardano-cli form)
|
|
107
|
-
* - `"bytes"` → `UPLCConst.byteString(...)` value: even-length hex string
|
|
108
|
-
* - `"int"` → `UPLCConst.int(...)` value: number | numeric string
|
|
109
|
-
* - `"bool"` → `UPLCConst.bool(...)` value: boolean
|
|
110
|
-
* - `"unit"` → `UPLCConst.unit` value: omitted
|
|
111
|
-
* Required for compilers whose scalar params are NATIVE-typed rather than
|
|
112
|
-
* Data-wrapped (e.g. Pebble: `param x: PubKeyHash` expects a native
|
|
113
|
-
* `bytestring`, not a `Data` bytestring).
|
|
114
|
-
*
|
|
115
|
-
* 2. Bare PlutusData object (e.g. `{ "bytes": "ab.." }`, `{ "constructor": 0, ... }`)
|
|
116
|
-
* — shorthand for `{ "uplc": "data", "value": <object> }`. This is the
|
|
117
|
-
* Aiken / CIP-57 blueprint convention, where every parameter is Data.
|
|
51
|
+
* Encode a script parameter as the UPLC constant of the type the validator expects: typed
|
|
52
|
+
* `{ uplc: data|bytes|int|bool|unit, value }` for native-typed params, or a bare PlutusData object
|
|
53
|
+
* (Aiken / CIP-57 convention) as shorthand for `uplc: "data"`.
|
|
118
54
|
*/
|
|
119
55
|
export declare function encodeScriptParam(param: JSONValue): UPLCConst;
|
|
120
56
|
/**
|
|
121
|
-
* Apply parameters to a parameterized PlutusV3 script (CBOR-wrapped flat UPLC)
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
* Parameters are applied in their declared UPLC type via {@link encodeScriptParam}:
|
|
125
|
-
* pass `{ uplc, value }` entries for native-typed params (e.g. Pebble scalars),
|
|
126
|
-
* or bare PlutusData objects for the Data convention (Aiken / CIP-57 blueprints).
|
|
127
|
-
*
|
|
128
|
-
* @param scriptHex CBOR hex of the unapplied Plutus script (as output by Aiken/Pebble/Plutus compilers)
|
|
129
|
-
* @param params Array of script parameters (typed `{uplc,value}` and/or bare PlutusData JSON) to apply in order
|
|
130
|
-
* @returns CBOR hex of the applied script (ready for transaction building)
|
|
57
|
+
* Apply parameters to a parameterized PlutusV3 script (CBOR-wrapped flat UPLC): each parameter becomes a
|
|
58
|
+
* UPLC Application around the program body, encoded via {@link encodeScriptParam}.
|
|
59
|
+
* @returns CBOR hex of the applied script
|
|
131
60
|
*/
|
|
132
61
|
export declare function applyScriptParameters(scriptHex: string, params: JSONValue[]): string;
|
|
62
|
+
/**
|
|
63
|
+
* Script hash of a Plutus script, CBOR-wrapped once or twice as cardano-cli writes it:
|
|
64
|
+
* blake2b-224 over the language byte and the once-wrapped CBOR. The version cannot be read
|
|
65
|
+
* from the script, so the caller names it.
|
|
66
|
+
*/
|
|
67
|
+
export declare function plutusScriptHash(scriptHex: string, version: 'plutusV2' | 'plutusV3'): string;
|
|
133
68
|
//# sourceMappingURL=tx-build-helper.d.ts.map
|