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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/@cds-models/CardanoAgentService/index.d.ts +251 -0
  2. package/@cds-models/CardanoAgentService/index.js +36 -0
  3. package/@cds-models/CardanoBackendService/index.d.ts +357 -0
  4. package/@cds-models/CardanoBackendService/index.js +40 -0
  5. package/@cds-models/CardanoIndexerService/index.d.ts +194 -2
  6. package/@cds-models/CardanoIndexerService/index.js +25 -0
  7. package/@cds-models/CardanoODataService/index.d.ts +305 -7
  8. package/@cds-models/CardanoODataService/index.js +34 -0
  9. package/@cds-models/CardanoSignService/index.d.ts +28 -3
  10. package/@cds-models/CardanoSignService/index.js +3 -0
  11. package/@cds-models/CardanoTransactionService/index.d.ts +46 -13
  12. package/@cds-models/CardanoTransactionService/index.js +4 -0
  13. package/@cds-models/index.d.ts +72 -0
  14. package/@cds-models/index.js +12 -0
  15. package/@cds-models/odatano/cardano/index.d.ts +408 -7
  16. package/@cds-models/odatano/cardano/index.js +42 -0
  17. package/README.md +64 -5
  18. package/db/schema.cds +2297 -1633
  19. package/db/types.cds +114 -0
  20. package/package.json +27 -6
  21. package/scripts/migrate-slot-leader.mjs +104 -0
  22. package/scripts/migrate-txseq.mjs +147 -0
  23. package/src/index.d.ts +18 -11
  24. package/src/index.js +44 -14
  25. package/src/plugin.js +42 -52
  26. package/srv/blockchain/backends/blockfrost-backend.d.ts +29 -131
  27. package/srv/blockchain/backends/blockfrost-backend.js +53 -162
  28. package/srv/blockchain/backends/cardano-backend.d.ts +104 -158
  29. package/srv/blockchain/backends/cardano-backend.js +19 -5
  30. package/srv/blockchain/backends/koios-backend.d.ts +126 -60
  31. package/srv/blockchain/backends/koios-backend.js +376 -235
  32. package/srv/blockchain/backends/odatano-backend.d.ts +64 -0
  33. package/srv/blockchain/backends/odatano-backend.js +170 -0
  34. package/srv/blockchain/backends/ogmios-backend.d.ts +162 -94
  35. package/srv/blockchain/backends/ogmios-backend.js +556 -201
  36. package/srv/blockchain/backends/ogmios-frame-guard.d.ts +32 -0
  37. package/srv/blockchain/backends/ogmios-frame-guard.js +142 -0
  38. package/srv/blockchain/cardano-client.d.ts +87 -202
  39. package/srv/blockchain/cardano-client.js +210 -240
  40. package/srv/blockchain/cardano-indexer.d.ts +311 -242
  41. package/srv/blockchain/cardano-indexer.js +1238 -362
  42. package/srv/blockchain/cardano-tx-builder.d.ts +44 -81
  43. package/srv/blockchain/cardano-tx-builder.js +173 -132
  44. package/srv/blockchain/crawler/certificate-backfill.d.ts +67 -0
  45. package/srv/blockchain/crawler/certificate-backfill.js +169 -0
  46. package/srv/blockchain/crawler/crawler.d.ts +139 -54
  47. package/srv/blockchain/crawler/crawler.js +478 -96
  48. package/srv/blockchain/crawler/hooks.d.ts +3 -14
  49. package/srv/blockchain/crawler/index.d.ts +5 -0
  50. package/srv/blockchain/crawler/index.js +35 -7
  51. package/srv/blockchain/crawler/sync-state.d.ts +46 -28
  52. package/srv/blockchain/crawler/sync-state.js +128 -43
  53. package/srv/blockchain/crawler/transaction-backfill.d.ts +52 -0
  54. package/srv/blockchain/crawler/transaction-backfill.js +283 -0
  55. package/srv/blockchain/crawler/utxo-set-import.d.ts +78 -0
  56. package/srv/blockchain/crawler/utxo-set-import.js +363 -0
  57. package/srv/blockchain/ledger-state.d.ts +101 -0
  58. package/srv/blockchain/ledger-state.js +432 -0
  59. package/srv/blockchain/pending-spends.d.ts +28 -0
  60. package/srv/blockchain/pending-spends.js +89 -0
  61. package/srv/blockchain/signing/cose-verifier.d.ts +5 -12
  62. package/srv/blockchain/signing/cose-verifier.js +6 -12
  63. package/srv/blockchain/signing/external-signer.d.ts +16 -113
  64. package/srv/blockchain/signing/external-signer.js +19 -122
  65. package/srv/blockchain/signing/hsm-signer.d.ts +13 -45
  66. package/srv/blockchain/signing/hsm-signer.js +23 -63
  67. package/srv/blockchain/signing/signature-verifier.d.ts +14 -45
  68. package/srv/blockchain/signing/signature-verifier.js +73 -76
  69. package/srv/blockchain/signing/submission-finalizer.d.ts +9 -36
  70. package/srv/blockchain/signing/submission-finalizer.js +16 -49
  71. package/srv/blockchain/stored-chain.d.ts +33 -0
  72. package/srv/blockchain/stored-chain.js +234 -0
  73. package/srv/blockchain/transaction-building/buildooor-tx.d.ts +111 -173
  74. package/srv/blockchain/transaction-building/buildooor-tx.js +649 -326
  75. package/srv/blockchain/transaction-building/caller-datums.d.ts +29 -0
  76. package/srv/blockchain/transaction-building/caller-datums.js +139 -0
  77. package/srv/blockchain/transaction-building/cardano-tx.d.ts +10 -35
  78. package/srv/blockchain/transaction-rows.d.ts +12 -0
  79. package/srv/blockchain/transaction-rows.js +43 -0
  80. package/srv/blockchain/wallet-worker/build-request.d.ts +4 -17
  81. package/srv/blockchain/wallet-worker/build-request.js +18 -23
  82. package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +25 -17
  83. package/srv/blockchain/wallet-worker/confirmation-tracker.js +87 -41
  84. package/srv/blockchain/wallet-worker/index.js +2 -8
  85. package/srv/blockchain/wallet-worker/job-store.d.ts +36 -103
  86. package/srv/blockchain/wallet-worker/job-store.js +0 -0
  87. package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +4 -20
  88. package/srv/blockchain/wallet-worker/lease-heartbeat.js +4 -20
  89. package/srv/blockchain/wallet-worker/signers.d.ts +6 -19
  90. package/srv/blockchain/wallet-worker/signers.js +3 -8
  91. package/srv/blockchain/wallet-worker/wallet-worker.d.ts +15 -71
  92. package/srv/blockchain/wallet-worker/wallet-worker.js +40 -91
  93. package/srv/cardano-agent-service.cds +146 -0
  94. package/srv/cardano-agent-service.d.ts +2 -0
  95. package/srv/cardano-agent-service.js +12 -0
  96. package/srv/cardano-backend-service.cds +52 -0
  97. package/srv/cardano-backend-service.d.ts +2 -0
  98. package/srv/cardano-backend-service.js +244 -0
  99. package/srv/cardano-indexer-service.cds +201 -73
  100. package/srv/cardano-indexer-service.js +280 -11
  101. package/srv/cardano-service.cds +65 -2
  102. package/srv/cardano-service.js +170 -129
  103. package/srv/cardano-sign-service.cds +200 -180
  104. package/srv/cardano-sign-service.js +57 -184
  105. package/srv/cardano-tx-service.cds +439 -370
  106. package/srv/cardano-tx-service.js +231 -190
  107. package/srv/cardano-ui.cds +16 -16
  108. package/srv/cardano-worker-service.js +7 -15
  109. package/srv/cbor/index.d.ts +1 -1
  110. package/srv/cbor/parse.d.ts +27 -0
  111. package/srv/cbor/parse.js +63 -2
  112. package/srv/server.d.ts +28 -86
  113. package/srv/server.js +132 -135
  114. package/srv/utils/agent-grants-config.d.ts +37 -0
  115. package/srv/utils/agent-grants-config.js +138 -0
  116. package/srv/utils/agent-grants.d.ts +262 -0
  117. package/srv/utils/agent-grants.js +922 -0
  118. package/srv/utils/agent-token-auth.d.ts +16 -0
  119. package/srv/utils/agent-token-auth.js +78 -0
  120. package/srv/utils/backend-request-handler.d.ts +2 -16
  121. package/srv/utils/backend-request-handler.js +3 -18
  122. package/srv/utils/collections.d.ts +4 -8
  123. package/srv/utils/collections.js +4 -8
  124. package/srv/utils/const.d.ts +30 -67
  125. package/srv/utils/const.js +32 -72
  126. package/srv/utils/crypto.d.ts +3 -12
  127. package/srv/utils/crypto.js +5 -18
  128. package/srv/utils/db-indexes.d.ts +25 -0
  129. package/srv/utils/db-indexes.js +94 -0
  130. package/srv/utils/db-sanitize.d.ts +27 -0
  131. package/srv/utils/db-sanitize.js +85 -0
  132. package/srv/utils/epoch-slots.d.ts +20 -0
  133. package/srv/utils/epoch-slots.js +43 -0
  134. package/srv/utils/error-codes.d.ts +20 -73
  135. package/srv/utils/error-codes.js +19 -70
  136. package/srv/utils/errors.d.ts +50 -177
  137. package/srv/utils/errors.js +94 -218
  138. package/srv/utils/legacy-service-paths.d.ts +11 -0
  139. package/srv/utils/legacy-service-paths.js +58 -0
  140. package/srv/utils/liveness.d.ts +16 -0
  141. package/srv/utils/liveness.js +40 -0
  142. package/srv/utils/mappers.d.ts +128 -214
  143. package/srv/utils/mappers.js +354 -299
  144. package/srv/utils/network-context.js +2 -11
  145. package/srv/utils/pg-inline-json.d.ts +8 -0
  146. package/srv/utils/pg-inline-json.js +62 -0
  147. package/srv/utils/pg-order-nulls.d.ts +14 -0
  148. package/srv/utils/pg-order-nulls.js +56 -0
  149. package/srv/utils/plutus-placeholders.d.ts +23 -16
  150. package/srv/utils/plutus-placeholders.js +63 -27
  151. package/srv/utils/rate-limiter.d.ts +46 -0
  152. package/srv/utils/rate-limiter.js +116 -0
  153. package/srv/utils/service-events.d.ts +2 -22
  154. package/srv/utils/service-events.js +3 -23
  155. package/srv/utils/signing-helper.d.ts +6 -16
  156. package/srv/utils/signing-helper.js +36 -60
  157. package/srv/utils/tx-build-helper.d.ts +28 -93
  158. package/srv/utils/tx-build-helper.js +75 -124
  159. package/srv/utils/tx-request-parsers.d.ts +101 -28
  160. package/srv/utils/tx-request-parsers.js +410 -43
  161. package/srv/utils/tx-utils.d.ts +4 -23
  162. package/srv/utils/tx-utils.js +12 -41
  163. package/srv/utils/types.d.ts +252 -179
  164. package/srv/utils/types.js +2 -6
  165. package/srv/utils/validators.d.ts +24 -90
  166. package/srv/utils/validators.js +50 -147
@@ -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 transaction with a witness set from CIP-30 wallet signing
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
- // Parse at raw CBOR level — no Cardano type validation, preserves all encoding metadata
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
- if (origWs instanceof cbor_1.CborMap && walletWsObj instanceof cbor_1.CborMap) {
36
- // Find wallet's VKey witnesses (map key 0)
37
- const walletVkeyEntry = walletWsObj.map.find(e => e.k instanceof cbor_1.CborUInt && Number(e.k.num) === 0);
38
- if (walletVkeyEntry) {
39
- // Merge: keep all original entries (redeemers, datums, scripts at keys 3-7),
40
- // remove any existing key 0, then add wallet's key 0 (VKey witnesses)
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
- else {
62
- throw new errors_1.TransactionValidationError('Witness set must be CBOR map per Cardano spec');
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
- // Re-encode the tx as a NEW outer CborArray so the encoder cannot short-circuit
65
- // to the original full-tx bytes via the outer value's subCborRef (which no longer
66
- // matches now that the witness set changed). The INNER element subCborRefs are
67
- // deliberately kept: that byte-preserves the body (array[0]), so the tx body hash
68
- // the witnesses signed stays identical.
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
- * Check if a CBOR string is a witness set (vs a full transaction)
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
- try {
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
- * Assert that UTxO contains only ADA (lovelace)
12
- * @param u UTxO to check
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
- * Extract transaction hash from a transaction CBOR (signed or unsigned).
18
- * Hash is computed over the body, so witness presence does not affect it.
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
- * Extract the consumed input refs and the output addresses from a transaction
36
- * CBOR (signed or unsigned) — the rows a successful submit makes stale in the
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 builder errors to typed BackendErrors
49
- * Used by the Buildooor transaction builder.
50
- * When no assetUnit is provided, extracts it from the error message if possible
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
- * Normalize a backend-provided inline datum to canonical CBOR hex.
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 single script parameter into the UPLC constant the parameterized
99
- * script expects.
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
- * Each parameter becomes a successive UPLC Application wrapping the program body.
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