@meshsdk/core-csl 1.9.0-beta.1 → 1.9.0-beta.3
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 +39 -15
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +38 -15
- package/package.json +6 -6
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.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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") => {
|
|
@@ -1489,36 +1501,47 @@ var OfflineEvaluator = class {
|
|
|
1489
1501
|
* - budget: Memory units and CPU steps required
|
|
1490
1502
|
* @throws Error if any required UTXOs cannot be resolved or if script evaluation fails
|
|
1491
1503
|
*/
|
|
1492
|
-
async evaluateTx(tx) {
|
|
1493
|
-
const
|
|
1504
|
+
async evaluateTx(tx, additionalUtxos, additionalTxs) {
|
|
1505
|
+
const foundUtxos = /* @__PURE__ */ new Set();
|
|
1506
|
+
for (const utxo of additionalUtxos) {
|
|
1507
|
+
foundUtxos.add(`${utxo.input.txHash}:${utxo.input.outputIndex}`);
|
|
1508
|
+
}
|
|
1509
|
+
for (const tx2 of additionalTxs) {
|
|
1510
|
+
const outputs = getTransactionOutputs(tx2);
|
|
1511
|
+
for (const output of outputs) {
|
|
1512
|
+
foundUtxos.add(`${output.input.txHash}:${output.input.outputIndex}`);
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
const inputsToResolve = getTransactionInputs(tx).filter(
|
|
1516
|
+
(input) => !foundUtxos.has(`${input.txHash}:${input.outputIndex}`)
|
|
1517
|
+
);
|
|
1494
1518
|
const txHashesSet = new Set(inputsToResolve.map((input) => input.txHash));
|
|
1495
|
-
const resolvedUTXOs = [];
|
|
1496
1519
|
for (const txHash of txHashesSet) {
|
|
1497
1520
|
const utxos = await this.fetcher.fetchUTxOs(txHash);
|
|
1498
1521
|
for (const utxo of utxos) {
|
|
1499
1522
|
if (utxo) {
|
|
1500
1523
|
if (inputsToResolve.find(
|
|
1501
|
-
(input) => input.txHash === txHash && input.
|
|
1524
|
+
(input) => input.txHash === txHash && input.outputIndex === utxo.input.outputIndex
|
|
1502
1525
|
)) {
|
|
1503
|
-
|
|
1526
|
+
additionalUtxos.push(utxo);
|
|
1527
|
+
foundUtxos.add(`${utxo.input.txHash}:${utxo.input.outputIndex}`);
|
|
1504
1528
|
}
|
|
1505
1529
|
}
|
|
1506
1530
|
}
|
|
1507
1531
|
}
|
|
1508
1532
|
const missing = inputsToResolve.filter(
|
|
1509
|
-
(input) => !
|
|
1510
|
-
(utxo) => utxo.input.txHash === input.txHash && utxo.input.outputIndex === input.index
|
|
1511
|
-
)
|
|
1533
|
+
(input) => !foundUtxos.has(`${input.txHash}:${input.outputIndex}`)
|
|
1512
1534
|
);
|
|
1513
1535
|
if (missing.length > 0) {
|
|
1514
|
-
const missingList = missing.map((m) => `${m.txHash}:${m.
|
|
1536
|
+
const missingList = missing.map((m) => `${m.txHash}:${m.outputIndex}`).join(", ");
|
|
1515
1537
|
throw new Error(
|
|
1516
1538
|
`Can't resolve these UTXOs to execute plutus scripts: ${missingList}`
|
|
1517
1539
|
);
|
|
1518
1540
|
}
|
|
1519
1541
|
return evaluateTransaction(
|
|
1520
1542
|
tx,
|
|
1521
|
-
|
|
1543
|
+
additionalUtxos,
|
|
1544
|
+
additionalTxs,
|
|
1522
1545
|
this.network,
|
|
1523
1546
|
this.slotConfig
|
|
1524
1547
|
);
|
|
@@ -1568,6 +1591,7 @@ var OfflineEvaluator = class {
|
|
|
1568
1591
|
fromUTF8,
|
|
1569
1592
|
getDRepIds,
|
|
1570
1593
|
getTransactionInputs,
|
|
1594
|
+
getTransactionOutputs,
|
|
1571
1595
|
getV2ScriptHash,
|
|
1572
1596
|
keyHashToRewardAddress,
|
|
1573
1597
|
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
|
-
|
|
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.
|
|
@@ -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
|
-
|
|
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.
|
|
@@ -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.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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") => {
|
|
@@ -1367,36 +1378,47 @@ var OfflineEvaluator = class {
|
|
|
1367
1378
|
* - budget: Memory units and CPU steps required
|
|
1368
1379
|
* @throws Error if any required UTXOs cannot be resolved or if script evaluation fails
|
|
1369
1380
|
*/
|
|
1370
|
-
async evaluateTx(tx) {
|
|
1371
|
-
const
|
|
1381
|
+
async evaluateTx(tx, additionalUtxos, additionalTxs) {
|
|
1382
|
+
const foundUtxos = /* @__PURE__ */ new Set();
|
|
1383
|
+
for (const utxo of additionalUtxos) {
|
|
1384
|
+
foundUtxos.add(`${utxo.input.txHash}:${utxo.input.outputIndex}`);
|
|
1385
|
+
}
|
|
1386
|
+
for (const tx2 of additionalTxs) {
|
|
1387
|
+
const outputs = getTransactionOutputs(tx2);
|
|
1388
|
+
for (const output of outputs) {
|
|
1389
|
+
foundUtxos.add(`${output.input.txHash}:${output.input.outputIndex}`);
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
const inputsToResolve = getTransactionInputs(tx).filter(
|
|
1393
|
+
(input) => !foundUtxos.has(`${input.txHash}:${input.outputIndex}`)
|
|
1394
|
+
);
|
|
1372
1395
|
const txHashesSet = new Set(inputsToResolve.map((input) => input.txHash));
|
|
1373
|
-
const resolvedUTXOs = [];
|
|
1374
1396
|
for (const txHash of txHashesSet) {
|
|
1375
1397
|
const utxos = await this.fetcher.fetchUTxOs(txHash);
|
|
1376
1398
|
for (const utxo of utxos) {
|
|
1377
1399
|
if (utxo) {
|
|
1378
1400
|
if (inputsToResolve.find(
|
|
1379
|
-
(input) => input.txHash === txHash && input.
|
|
1401
|
+
(input) => input.txHash === txHash && input.outputIndex === utxo.input.outputIndex
|
|
1380
1402
|
)) {
|
|
1381
|
-
|
|
1403
|
+
additionalUtxos.push(utxo);
|
|
1404
|
+
foundUtxos.add(`${utxo.input.txHash}:${utxo.input.outputIndex}`);
|
|
1382
1405
|
}
|
|
1383
1406
|
}
|
|
1384
1407
|
}
|
|
1385
1408
|
}
|
|
1386
1409
|
const missing = inputsToResolve.filter(
|
|
1387
|
-
(input) => !
|
|
1388
|
-
(utxo) => utxo.input.txHash === input.txHash && utxo.input.outputIndex === input.index
|
|
1389
|
-
)
|
|
1410
|
+
(input) => !foundUtxos.has(`${input.txHash}:${input.outputIndex}`)
|
|
1390
1411
|
);
|
|
1391
1412
|
if (missing.length > 0) {
|
|
1392
|
-
const missingList = missing.map((m) => `${m.txHash}:${m.
|
|
1413
|
+
const missingList = missing.map((m) => `${m.txHash}:${m.outputIndex}`).join(", ");
|
|
1393
1414
|
throw new Error(
|
|
1394
1415
|
`Can't resolve these UTXOs to execute plutus scripts: ${missingList}`
|
|
1395
1416
|
);
|
|
1396
1417
|
}
|
|
1397
1418
|
return evaluateTransaction(
|
|
1398
1419
|
tx,
|
|
1399
|
-
|
|
1420
|
+
additionalUtxos,
|
|
1421
|
+
additionalTxs,
|
|
1400
1422
|
this.network,
|
|
1401
1423
|
this.slotConfig
|
|
1402
1424
|
);
|
|
@@ -1445,6 +1467,7 @@ export {
|
|
|
1445
1467
|
fromUTF8,
|
|
1446
1468
|
getDRepIds,
|
|
1447
1469
|
getTransactionInputs,
|
|
1470
|
+
getTransactionOutputs,
|
|
1448
1471
|
getV2ScriptHash,
|
|
1449
1472
|
keyHashToRewardAddress,
|
|
1450
1473
|
meshTxBuilderBodyToObj,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meshsdk/core-csl",
|
|
3
|
-
"version": "1.9.0-beta.
|
|
3
|
+
"version": "1.9.0-beta.3",
|
|
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.
|
|
34
|
+
"@meshsdk/provider": "1.9.0-beta.3",
|
|
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.
|
|
43
|
-
"@sidan-lab/sidan-csl-rs-browser": "0.9.
|
|
44
|
-
"@sidan-lab/sidan-csl-rs-nodejs": "0.9.
|
|
42
|
+
"@meshsdk/common": "1.9.0-beta.3",
|
|
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
|
+
}
|