@meshsdk/core-csl 1.9.0-beta.1 → 1.9.0-beta.11

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/dist/index.cjs CHANGED
@@ -72,6 +72,7 @@ __export(index_exports, {
72
72
  fromUTF8: () => fromUTF8,
73
73
  getDRepIds: () => getDRepIds,
74
74
  getTransactionInputs: () => getTransactionInputs,
75
+ getTransactionOutputs: () => getTransactionOutputs,
75
76
  getV2ScriptHash: () => getV2ScriptHash,
76
77
  keyHashToRewardAddress: () => keyHashToRewardAddress,
77
78
  meshTxBuilderBodyToObj: () => meshTxBuilderBodyToObj,
@@ -507,6 +508,9 @@ var keyHashToRewardAddress = (keyHashHex, network = 1) => {
507
508
  return rewardAddress;
508
509
  };
509
510
 
511
+ // src/utils/transaction.ts
512
+ var import_sidan_csl_rs_nodejs = require("@sidan-lab/sidan-csl-rs-nodejs");
513
+
510
514
  // src/wasm.ts
511
515
  var parseWasmResult = (result) => {
512
516
  if (result.get_status() !== "success") {
@@ -534,13 +538,16 @@ var signTransaction = (txHex, signingKeys) => {
534
538
  const result = csl.js_sign_transaction(txHex, cslSigningKeys);
535
539
  return parseWasmResult(result);
536
540
  };
537
- var evaluateTransaction = (txHex, resolvedUtxos, network, slotConfig) => {
541
+ var evaluateTransaction = (txHex, resolvedUtxos, chainedTxs, network, slotConfig) => {
538
542
  const additionalTxs = csl.JsVecString.new();
543
+ for (const tx of chainedTxs) {
544
+ additionalTxs.add(tx);
545
+ }
539
546
  const mappedUtxos = csl.JsVecString.new();
540
547
  for (const utxo of resolvedUtxos) {
541
548
  mappedUtxos.add(JSON.stringify(utxo));
542
549
  }
543
- const result = csl.evaluate_tx_scripts_js(
550
+ const result = csl.js_evaluate_tx_scripts(
544
551
  txHex,
545
552
  mappedUtxos,
546
553
  additionalTxs,
@@ -605,7 +612,7 @@ var getTransactionInputs = (txHex) => {
605
612
  const input = cslInputs.get(i);
606
613
  inputs.push({
607
614
  txHash: input.transaction_id().to_hex(),
608
- index: input.index()
615
+ outputIndex: input.index()
609
616
  });
610
617
  }
611
618
  const cslCollaterals = body.collateral();
@@ -614,7 +621,7 @@ var getTransactionInputs = (txHex) => {
614
621
  const collateral = cslCollaterals.get(i);
615
622
  inputs.push({
616
623
  txHash: collateral.transaction_id().to_hex(),
617
- index: collateral.index()
624
+ outputIndex: collateral.index()
618
625
  });
619
626
  }
620
627
  }
@@ -624,12 +631,17 @@ var getTransactionInputs = (txHex) => {
624
631
  const refInput = cslRefInputs.get(i);
625
632
  inputs.push({
626
633
  txHash: refInput.transaction_id().to_hex(),
627
- index: refInput.index()
634
+ outputIndex: refInput.index()
628
635
  });
629
636
  }
630
637
  }
631
638
  return inputs;
632
639
  };
640
+ var getTransactionOutputs = (txHex) => {
641
+ const outputs = (0, import_sidan_csl_rs_nodejs.js_get_tx_outs_utxo)(txHex).get_data();
642
+ const utxos = JSON.parse(outputs);
643
+ return utxos;
644
+ };
633
645
 
634
646
  // src/utils/aiken.ts
635
647
  var applyParamsToScript = (rawScript, params, type = "Mesh") => {
@@ -1362,7 +1374,12 @@ var CSLSerializer = class {
1362
1374
  this.protocolParams = protocolParams || import_common4.DEFAULT_PROTOCOL_PARAMETERS;
1363
1375
  this.verbose = verbose;
1364
1376
  }
1365
- serializeTxBody(txBody, protocolParams) {
1377
+ serializeTxBody(txBody, protocolParams, balanced = true) {
1378
+ if (!balanced) {
1379
+ throw new Error(
1380
+ "Unbalanced transactions are not supported with CSL serializer"
1381
+ );
1382
+ }
1366
1383
  const txBodyJson = import_json_bigint3.default.stringify(meshTxBuilderBodyToObj(txBody));
1367
1384
  const params = import_json_bigint3.default.stringify(protocolParams || this.protocolParams);
1368
1385
  if (this.verbose) {
@@ -1489,36 +1506,47 @@ var OfflineEvaluator = class {
1489
1506
  * - budget: Memory units and CPU steps required
1490
1507
  * @throws Error if any required UTXOs cannot be resolved or if script evaluation fails
1491
1508
  */
1492
- async evaluateTx(tx) {
1493
- const inputsToResolve = getTransactionInputs(tx);
1509
+ async evaluateTx(tx, additionalUtxos, additionalTxs) {
1510
+ const foundUtxos = /* @__PURE__ */ new Set();
1511
+ for (const utxo of additionalUtxos) {
1512
+ foundUtxos.add(`${utxo.input.txHash}:${utxo.input.outputIndex}`);
1513
+ }
1514
+ for (const tx2 of additionalTxs) {
1515
+ const outputs = getTransactionOutputs(tx2);
1516
+ for (const output of outputs) {
1517
+ foundUtxos.add(`${output.input.txHash}:${output.input.outputIndex}`);
1518
+ }
1519
+ }
1520
+ const inputsToResolve = getTransactionInputs(tx).filter(
1521
+ (input) => !foundUtxos.has(`${input.txHash}:${input.outputIndex}`)
1522
+ );
1494
1523
  const txHashesSet = new Set(inputsToResolve.map((input) => input.txHash));
1495
- const resolvedUTXOs = [];
1496
1524
  for (const txHash of txHashesSet) {
1497
1525
  const utxos = await this.fetcher.fetchUTxOs(txHash);
1498
1526
  for (const utxo of utxos) {
1499
1527
  if (utxo) {
1500
1528
  if (inputsToResolve.find(
1501
- (input) => input.txHash === txHash && input.index === utxo.input.outputIndex
1529
+ (input) => input.txHash === txHash && input.outputIndex === utxo.input.outputIndex
1502
1530
  )) {
1503
- resolvedUTXOs.push(utxo);
1531
+ additionalUtxos.push(utxo);
1532
+ foundUtxos.add(`${utxo.input.txHash}:${utxo.input.outputIndex}`);
1504
1533
  }
1505
1534
  }
1506
1535
  }
1507
1536
  }
1508
1537
  const missing = inputsToResolve.filter(
1509
- (input) => !resolvedUTXOs.find(
1510
- (utxo) => utxo.input.txHash === input.txHash && utxo.input.outputIndex === input.index
1511
- )
1538
+ (input) => !foundUtxos.has(`${input.txHash}:${input.outputIndex}`)
1512
1539
  );
1513
1540
  if (missing.length > 0) {
1514
- const missingList = missing.map((m) => `${m.txHash}:${m.index}`).join(", ");
1541
+ const missingList = missing.map((m) => `${m.txHash}:${m.outputIndex}`).join(", ");
1515
1542
  throw new Error(
1516
1543
  `Can't resolve these UTXOs to execute plutus scripts: ${missingList}`
1517
1544
  );
1518
1545
  }
1519
1546
  return evaluateTransaction(
1520
1547
  tx,
1521
- resolvedUTXOs,
1548
+ additionalUtxos,
1549
+ additionalTxs,
1522
1550
  this.network,
1523
1551
  this.slotConfig
1524
1552
  );
@@ -1568,6 +1596,7 @@ var OfflineEvaluator = class {
1568
1596
  fromUTF8,
1569
1597
  getDRepIds,
1570
1598
  getTransactionInputs,
1599
+ getTransactionOutputs,
1571
1600
  getV2ScriptHash,
1572
1601
  keyHashToRewardAddress,
1573
1602
  meshTxBuilderBodyToObj,
package/dist/index.d.cts CHANGED
@@ -30,11 +30,12 @@ declare const keyHashToRewardAddress: (keyHashHex: string, network?: number) =>
30
30
 
31
31
  declare const calculateTxHash: (txHex: string) => string;
32
32
  declare const signTransaction: (txHex: string, signingKeys: string[]) => string;
33
- declare const evaluateTransaction: (txHex: string, resolvedUtxos: UTxO[], network: Network, slotConfig: Omit<Omit<SlotConfig, "startEpoch">, "epochLength">) => Omit<Action, "data">[];
33
+ declare const evaluateTransaction: (txHex: string, resolvedUtxos: UTxO[], chainedTxs: string[], network: Network, slotConfig: Omit<Omit<SlotConfig, "startEpoch">, "epochLength">) => Omit<Action, "data">[];
34
34
  declare const getTransactionInputs: (txHex: string) => {
35
35
  txHash: string;
36
- index: number;
36
+ outputIndex: number;
37
37
  }[];
38
+ declare const getTransactionOutputs: (txHex: string) => UTxO[];
38
39
 
39
40
  /**
40
41
  * Apply parameters to a given script blueprint.
@@ -66,7 +67,7 @@ declare class CSLSerializer implements IMeshTxSerializer {
66
67
  protocolParams: Protocol;
67
68
  meshTxBuilderBody: MeshTxBuilderBody;
68
69
  constructor(protocolParams?: Protocol, verbose?: boolean);
69
- serializeTxBody(txBody: MeshTxBuilderBody, protocolParams?: Protocol): string;
70
+ serializeTxBody(txBody: MeshTxBuilderBody, protocolParams?: Protocol, balanced?: Boolean): string;
70
71
  addSigningKeys(txHex: string, signingKeys: string[]): string;
71
72
  serializeData(data: BuilderData): string;
72
73
  serializeAddress(address: Partial<DeserializedAddress>, networkId?: number): string;
@@ -264,7 +265,7 @@ declare class OfflineEvaluator implements IEvaluator {
264
265
  * - budget: Memory units and CPU steps required
265
266
  * @throws Error if any required UTXOs cannot be resolved or if script evaluation fails
266
267
  */
267
- evaluateTx(tx: string): Promise<Omit<Action, "data">[]>;
268
+ evaluateTx(tx: string, additionalUtxos: UTxO[], additionalTxs: string[]): Promise<Omit<Action, "data">[]>;
268
269
  }
269
270
 
270
- export { CSLSerializer, LANGUAGE_VERSIONS, OfflineEvaluator, POLICY_ID_LENGTH, REDEEMER_TAGS, addrBech32ToPlutusDataHex, addrBech32ToPlutusDataObj, applyCborEncoding, applyParamsToScript, baseAddressToStakeAddress, baseCertToObj, builderDataToCbor, calculateTxHash, castDataToPlutusData, castRawDataToJsonString, certificateToObj, collateralTxInToObj, deserializeAddress, deserializeBech32Address, deserializeBip32PrivateKey, deserializeDataHash, deserializeEd25519KeyHash, deserializeEd25519Signature, deserializeNativeScript, deserializePlutusData, deserializePlutusScript, deserializePublicKey, deserializeScriptHash, deserializeScriptRef, deserializeTx, deserializeTxBody, deserializeTxHash, deserializeTxUnspentOutput, deserializeTxWitnessSet, deserializeValue, evaluateTransaction, fromBytes, fromLovelace, fromUTF8, getDRepIds, getTransactionInputs, getV2ScriptHash, keyHashToRewardAddress, meshTxBuilderBodyToObj, mintItemToObj, mintParametersObj, nativeMintItemToObj, outputToObj, parseDatumCbor, parseInlineDatum, plutusMintItemToObj, poolIdBech32ToHex, poolIdHexToBech32, poolMetadataToObj, poolParamsToObj, redeemerToObj, relayToObj, resolveDataHash, resolveEd25519KeyHash, resolveNativeScriptAddress, resolveNativeScriptHash, resolveNativeScriptHex, resolvePlutusScriptAddress, resolvePrivateKey, resolveRewardAddress, resolveScriptHashDRepId, resolveScriptRef, resolveStakeKeyHash, rewardAddressToKeyHash, scriptHashToBech32, scriptHashToRewardAddress, scriptSourceToObj, scriptTxInParameterToObj, serializeAddressObj, serializePlutusAddressToBech32, serializePoolId, serialzeAddress, signTransaction, simpleScriptSourceToObj, simpleScriptTxInParameterToObj, skeyToPubKeyHash, toAddress, toBaseAddress, toBytes, toEnterpriseAddress, toLovelace, toNativeScript, toPlutusData, toRewardAddress, toScriptRef, toUTF8, txInParameterToObj, txInToObj, utxoToObj, v2ScriptToBech32, withdrawalToObj };
271
+ export { CSLSerializer, LANGUAGE_VERSIONS, OfflineEvaluator, POLICY_ID_LENGTH, REDEEMER_TAGS, addrBech32ToPlutusDataHex, addrBech32ToPlutusDataObj, applyCborEncoding, applyParamsToScript, baseAddressToStakeAddress, baseCertToObj, builderDataToCbor, calculateTxHash, castDataToPlutusData, castRawDataToJsonString, certificateToObj, collateralTxInToObj, deserializeAddress, deserializeBech32Address, deserializeBip32PrivateKey, deserializeDataHash, deserializeEd25519KeyHash, deserializeEd25519Signature, deserializeNativeScript, deserializePlutusData, deserializePlutusScript, deserializePublicKey, deserializeScriptHash, deserializeScriptRef, deserializeTx, deserializeTxBody, deserializeTxHash, deserializeTxUnspentOutput, deserializeTxWitnessSet, deserializeValue, evaluateTransaction, fromBytes, fromLovelace, fromUTF8, getDRepIds, getTransactionInputs, getTransactionOutputs, getV2ScriptHash, keyHashToRewardAddress, meshTxBuilderBodyToObj, mintItemToObj, mintParametersObj, nativeMintItemToObj, outputToObj, parseDatumCbor, parseInlineDatum, plutusMintItemToObj, poolIdBech32ToHex, poolIdHexToBech32, poolMetadataToObj, poolParamsToObj, redeemerToObj, relayToObj, resolveDataHash, resolveEd25519KeyHash, resolveNativeScriptAddress, resolveNativeScriptHash, resolveNativeScriptHex, resolvePlutusScriptAddress, resolvePrivateKey, resolveRewardAddress, resolveScriptHashDRepId, resolveScriptRef, resolveStakeKeyHash, rewardAddressToKeyHash, scriptHashToBech32, scriptHashToRewardAddress, scriptSourceToObj, scriptTxInParameterToObj, serializeAddressObj, serializePlutusAddressToBech32, serializePoolId, serialzeAddress, signTransaction, simpleScriptSourceToObj, simpleScriptTxInParameterToObj, skeyToPubKeyHash, toAddress, toBaseAddress, toBytes, toEnterpriseAddress, toLovelace, toNativeScript, toPlutusData, toRewardAddress, toScriptRef, toUTF8, txInParameterToObj, txInToObj, utxoToObj, v2ScriptToBech32, withdrawalToObj };
package/dist/index.d.ts CHANGED
@@ -30,11 +30,12 @@ declare const keyHashToRewardAddress: (keyHashHex: string, network?: number) =>
30
30
 
31
31
  declare const calculateTxHash: (txHex: string) => string;
32
32
  declare const signTransaction: (txHex: string, signingKeys: string[]) => string;
33
- declare const evaluateTransaction: (txHex: string, resolvedUtxos: UTxO[], network: Network, slotConfig: Omit<Omit<SlotConfig, "startEpoch">, "epochLength">) => Omit<Action, "data">[];
33
+ declare const evaluateTransaction: (txHex: string, resolvedUtxos: UTxO[], chainedTxs: string[], network: Network, slotConfig: Omit<Omit<SlotConfig, "startEpoch">, "epochLength">) => Omit<Action, "data">[];
34
34
  declare const getTransactionInputs: (txHex: string) => {
35
35
  txHash: string;
36
- index: number;
36
+ outputIndex: number;
37
37
  }[];
38
+ declare const getTransactionOutputs: (txHex: string) => UTxO[];
38
39
 
39
40
  /**
40
41
  * Apply parameters to a given script blueprint.
@@ -66,7 +67,7 @@ declare class CSLSerializer implements IMeshTxSerializer {
66
67
  protocolParams: Protocol;
67
68
  meshTxBuilderBody: MeshTxBuilderBody;
68
69
  constructor(protocolParams?: Protocol, verbose?: boolean);
69
- serializeTxBody(txBody: MeshTxBuilderBody, protocolParams?: Protocol): string;
70
+ serializeTxBody(txBody: MeshTxBuilderBody, protocolParams?: Protocol, balanced?: Boolean): string;
70
71
  addSigningKeys(txHex: string, signingKeys: string[]): string;
71
72
  serializeData(data: BuilderData): string;
72
73
  serializeAddress(address: Partial<DeserializedAddress>, networkId?: number): string;
@@ -264,7 +265,7 @@ declare class OfflineEvaluator implements IEvaluator {
264
265
  * - budget: Memory units and CPU steps required
265
266
  * @throws Error if any required UTXOs cannot be resolved or if script evaluation fails
266
267
  */
267
- evaluateTx(tx: string): Promise<Omit<Action, "data">[]>;
268
+ evaluateTx(tx: string, additionalUtxos: UTxO[], additionalTxs: string[]): Promise<Omit<Action, "data">[]>;
268
269
  }
269
270
 
270
- export { CSLSerializer, LANGUAGE_VERSIONS, OfflineEvaluator, POLICY_ID_LENGTH, REDEEMER_TAGS, addrBech32ToPlutusDataHex, addrBech32ToPlutusDataObj, applyCborEncoding, applyParamsToScript, baseAddressToStakeAddress, baseCertToObj, builderDataToCbor, calculateTxHash, castDataToPlutusData, castRawDataToJsonString, certificateToObj, collateralTxInToObj, deserializeAddress, deserializeBech32Address, deserializeBip32PrivateKey, deserializeDataHash, deserializeEd25519KeyHash, deserializeEd25519Signature, deserializeNativeScript, deserializePlutusData, deserializePlutusScript, deserializePublicKey, deserializeScriptHash, deserializeScriptRef, deserializeTx, deserializeTxBody, deserializeTxHash, deserializeTxUnspentOutput, deserializeTxWitnessSet, deserializeValue, evaluateTransaction, fromBytes, fromLovelace, fromUTF8, getDRepIds, getTransactionInputs, getV2ScriptHash, keyHashToRewardAddress, meshTxBuilderBodyToObj, mintItemToObj, mintParametersObj, nativeMintItemToObj, outputToObj, parseDatumCbor, parseInlineDatum, plutusMintItemToObj, poolIdBech32ToHex, poolIdHexToBech32, poolMetadataToObj, poolParamsToObj, redeemerToObj, relayToObj, resolveDataHash, resolveEd25519KeyHash, resolveNativeScriptAddress, resolveNativeScriptHash, resolveNativeScriptHex, resolvePlutusScriptAddress, resolvePrivateKey, resolveRewardAddress, resolveScriptHashDRepId, resolveScriptRef, resolveStakeKeyHash, rewardAddressToKeyHash, scriptHashToBech32, scriptHashToRewardAddress, scriptSourceToObj, scriptTxInParameterToObj, serializeAddressObj, serializePlutusAddressToBech32, serializePoolId, serialzeAddress, signTransaction, simpleScriptSourceToObj, simpleScriptTxInParameterToObj, skeyToPubKeyHash, toAddress, toBaseAddress, toBytes, toEnterpriseAddress, toLovelace, toNativeScript, toPlutusData, toRewardAddress, toScriptRef, toUTF8, txInParameterToObj, txInToObj, utxoToObj, v2ScriptToBech32, withdrawalToObj };
271
+ export { CSLSerializer, LANGUAGE_VERSIONS, OfflineEvaluator, POLICY_ID_LENGTH, REDEEMER_TAGS, addrBech32ToPlutusDataHex, addrBech32ToPlutusDataObj, applyCborEncoding, applyParamsToScript, baseAddressToStakeAddress, baseCertToObj, builderDataToCbor, calculateTxHash, castDataToPlutusData, castRawDataToJsonString, certificateToObj, collateralTxInToObj, deserializeAddress, deserializeBech32Address, deserializeBip32PrivateKey, deserializeDataHash, deserializeEd25519KeyHash, deserializeEd25519Signature, deserializeNativeScript, deserializePlutusData, deserializePlutusScript, deserializePublicKey, deserializeScriptHash, deserializeScriptRef, deserializeTx, deserializeTxBody, deserializeTxHash, deserializeTxUnspentOutput, deserializeTxWitnessSet, deserializeValue, evaluateTransaction, fromBytes, fromLovelace, fromUTF8, getDRepIds, getTransactionInputs, getTransactionOutputs, getV2ScriptHash, keyHashToRewardAddress, meshTxBuilderBodyToObj, mintItemToObj, mintParametersObj, nativeMintItemToObj, outputToObj, parseDatumCbor, parseInlineDatum, plutusMintItemToObj, poolIdBech32ToHex, poolIdHexToBech32, poolMetadataToObj, poolParamsToObj, redeemerToObj, relayToObj, resolveDataHash, resolveEd25519KeyHash, resolveNativeScriptAddress, resolveNativeScriptHash, resolveNativeScriptHex, resolvePlutusScriptAddress, resolvePrivateKey, resolveRewardAddress, resolveScriptHashDRepId, resolveScriptRef, resolveStakeKeyHash, rewardAddressToKeyHash, scriptHashToBech32, scriptHashToRewardAddress, scriptSourceToObj, scriptTxInParameterToObj, serializeAddressObj, serializePlutusAddressToBech32, serializePoolId, serialzeAddress, signTransaction, simpleScriptSourceToObj, simpleScriptTxInParameterToObj, skeyToPubKeyHash, toAddress, toBaseAddress, toBytes, toEnterpriseAddress, toLovelace, toNativeScript, toPlutusData, toRewardAddress, toScriptRef, toUTF8, txInParameterToObj, txInToObj, utxoToObj, v2ScriptToBech32, withdrawalToObj };
package/dist/index.js CHANGED
@@ -380,6 +380,9 @@ var keyHashToRewardAddress = (keyHashHex, network = 1) => {
380
380
  return rewardAddress;
381
381
  };
382
382
 
383
+ // src/utils/transaction.ts
384
+ import { js_get_tx_outs_utxo } from "@sidan-lab/sidan-csl-rs-nodejs";
385
+
383
386
  // src/wasm.ts
384
387
  var parseWasmResult = (result) => {
385
388
  if (result.get_status() !== "success") {
@@ -407,13 +410,16 @@ var signTransaction = (txHex, signingKeys) => {
407
410
  const result = csl.js_sign_transaction(txHex, cslSigningKeys);
408
411
  return parseWasmResult(result);
409
412
  };
410
- var evaluateTransaction = (txHex, resolvedUtxos, network, slotConfig) => {
413
+ var evaluateTransaction = (txHex, resolvedUtxos, chainedTxs, network, slotConfig) => {
411
414
  const additionalTxs = csl.JsVecString.new();
415
+ for (const tx of chainedTxs) {
416
+ additionalTxs.add(tx);
417
+ }
412
418
  const mappedUtxos = csl.JsVecString.new();
413
419
  for (const utxo of resolvedUtxos) {
414
420
  mappedUtxos.add(JSON.stringify(utxo));
415
421
  }
416
- const result = csl.evaluate_tx_scripts_js(
422
+ const result = csl.js_evaluate_tx_scripts(
417
423
  txHex,
418
424
  mappedUtxos,
419
425
  additionalTxs,
@@ -478,7 +484,7 @@ var getTransactionInputs = (txHex) => {
478
484
  const input = cslInputs.get(i);
479
485
  inputs.push({
480
486
  txHash: input.transaction_id().to_hex(),
481
- index: input.index()
487
+ outputIndex: input.index()
482
488
  });
483
489
  }
484
490
  const cslCollaterals = body.collateral();
@@ -487,7 +493,7 @@ var getTransactionInputs = (txHex) => {
487
493
  const collateral = cslCollaterals.get(i);
488
494
  inputs.push({
489
495
  txHash: collateral.transaction_id().to_hex(),
490
- index: collateral.index()
496
+ outputIndex: collateral.index()
491
497
  });
492
498
  }
493
499
  }
@@ -497,12 +503,17 @@ var getTransactionInputs = (txHex) => {
497
503
  const refInput = cslRefInputs.get(i);
498
504
  inputs.push({
499
505
  txHash: refInput.transaction_id().to_hex(),
500
- index: refInput.index()
506
+ outputIndex: refInput.index()
501
507
  });
502
508
  }
503
509
  }
504
510
  return inputs;
505
511
  };
512
+ var getTransactionOutputs = (txHex) => {
513
+ const outputs = js_get_tx_outs_utxo(txHex).get_data();
514
+ const utxos = JSON.parse(outputs);
515
+ return utxos;
516
+ };
506
517
 
507
518
  // src/utils/aiken.ts
508
519
  var applyParamsToScript = (rawScript, params, type = "Mesh") => {
@@ -1238,7 +1249,12 @@ var CSLSerializer = class {
1238
1249
  this.protocolParams = protocolParams || DEFAULT_PROTOCOL_PARAMETERS;
1239
1250
  this.verbose = verbose;
1240
1251
  }
1241
- serializeTxBody(txBody, protocolParams) {
1252
+ serializeTxBody(txBody, protocolParams, balanced = true) {
1253
+ if (!balanced) {
1254
+ throw new Error(
1255
+ "Unbalanced transactions are not supported with CSL serializer"
1256
+ );
1257
+ }
1242
1258
  const txBodyJson = JSONbig3.stringify(meshTxBuilderBodyToObj(txBody));
1243
1259
  const params = JSONbig3.stringify(protocolParams || this.protocolParams);
1244
1260
  if (this.verbose) {
@@ -1367,36 +1383,47 @@ var OfflineEvaluator = class {
1367
1383
  * - budget: Memory units and CPU steps required
1368
1384
  * @throws Error if any required UTXOs cannot be resolved or if script evaluation fails
1369
1385
  */
1370
- async evaluateTx(tx) {
1371
- const inputsToResolve = getTransactionInputs(tx);
1386
+ async evaluateTx(tx, additionalUtxos, additionalTxs) {
1387
+ const foundUtxos = /* @__PURE__ */ new Set();
1388
+ for (const utxo of additionalUtxos) {
1389
+ foundUtxos.add(`${utxo.input.txHash}:${utxo.input.outputIndex}`);
1390
+ }
1391
+ for (const tx2 of additionalTxs) {
1392
+ const outputs = getTransactionOutputs(tx2);
1393
+ for (const output of outputs) {
1394
+ foundUtxos.add(`${output.input.txHash}:${output.input.outputIndex}`);
1395
+ }
1396
+ }
1397
+ const inputsToResolve = getTransactionInputs(tx).filter(
1398
+ (input) => !foundUtxos.has(`${input.txHash}:${input.outputIndex}`)
1399
+ );
1372
1400
  const txHashesSet = new Set(inputsToResolve.map((input) => input.txHash));
1373
- const resolvedUTXOs = [];
1374
1401
  for (const txHash of txHashesSet) {
1375
1402
  const utxos = await this.fetcher.fetchUTxOs(txHash);
1376
1403
  for (const utxo of utxos) {
1377
1404
  if (utxo) {
1378
1405
  if (inputsToResolve.find(
1379
- (input) => input.txHash === txHash && input.index === utxo.input.outputIndex
1406
+ (input) => input.txHash === txHash && input.outputIndex === utxo.input.outputIndex
1380
1407
  )) {
1381
- resolvedUTXOs.push(utxo);
1408
+ additionalUtxos.push(utxo);
1409
+ foundUtxos.add(`${utxo.input.txHash}:${utxo.input.outputIndex}`);
1382
1410
  }
1383
1411
  }
1384
1412
  }
1385
1413
  }
1386
1414
  const missing = inputsToResolve.filter(
1387
- (input) => !resolvedUTXOs.find(
1388
- (utxo) => utxo.input.txHash === input.txHash && utxo.input.outputIndex === input.index
1389
- )
1415
+ (input) => !foundUtxos.has(`${input.txHash}:${input.outputIndex}`)
1390
1416
  );
1391
1417
  if (missing.length > 0) {
1392
- const missingList = missing.map((m) => `${m.txHash}:${m.index}`).join(", ");
1418
+ const missingList = missing.map((m) => `${m.txHash}:${m.outputIndex}`).join(", ");
1393
1419
  throw new Error(
1394
1420
  `Can't resolve these UTXOs to execute plutus scripts: ${missingList}`
1395
1421
  );
1396
1422
  }
1397
1423
  return evaluateTransaction(
1398
1424
  tx,
1399
- resolvedUTXOs,
1425
+ additionalUtxos,
1426
+ additionalTxs,
1400
1427
  this.network,
1401
1428
  this.slotConfig
1402
1429
  );
@@ -1445,6 +1472,7 @@ export {
1445
1472
  fromUTF8,
1446
1473
  getDRepIds,
1447
1474
  getTransactionInputs,
1475
+ getTransactionOutputs,
1448
1476
  getV2ScriptHash,
1449
1477
  keyHashToRewardAddress,
1450
1478
  meshTxBuilderBodyToObj,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshsdk/core-csl",
3
- "version": "1.9.0-beta.1",
3
+ "version": "1.9.0-beta.11",
4
4
  "description": "Types and utilities functions between Mesh and cardano-serialization-lib",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "devDependencies": {
33
33
  "@meshsdk/configs": "*",
34
- "@meshsdk/provider": "1.9.0-beta.1",
34
+ "@meshsdk/provider": "1.9.0-beta.11",
35
35
  "@types/json-bigint": "^1.0.4",
36
36
  "eslint": "^8.57.0",
37
37
  "ts-jest": "^29.1.4",
@@ -39,9 +39,9 @@
39
39
  "typescript": "^5.3.3"
40
40
  },
41
41
  "dependencies": {
42
- "@meshsdk/common": "1.9.0-beta.1",
43
- "@sidan-lab/sidan-csl-rs-browser": "0.9.18",
44
- "@sidan-lab/sidan-csl-rs-nodejs": "0.9.18",
42
+ "@meshsdk/common": "1.9.0-beta.11",
43
+ "@sidan-lab/sidan-csl-rs-browser": "0.9.21",
44
+ "@sidan-lab/sidan-csl-rs-nodejs": "0.9.21",
45
45
  "@types/base32-encoding": "^1.0.2",
46
46
  "base32-encoding": "^1.0.0",
47
47
  "bech32": "^2.0.0",
@@ -59,4 +59,4 @@
59
59
  "blockchain",
60
60
  "sdk"
61
61
  ]
62
- }
62
+ }