@harmoniclabs/plu-ts-offchain
Advanced tools
Comparing version 0.1.12-dev1 to 0.1.12-dev2
@@ -6,2 +6,3 @@ "use strict"; | ||
var plutus_data_1 = require("@harmoniclabs/plutus-data"); | ||
var uint8array_utils_1 = require("@harmoniclabs/uint8array-utils"); | ||
function getSpendingPurposeData(rdmr, tx) { | ||
@@ -21,3 +22,11 @@ var _a, _b, _c, _d, _e; | ||
ctorIdx = 1; | ||
var utxoRef = (_b = tx.inputs[rdmr.index]) === null || _b === void 0 ? void 0 : _b.utxoRef; | ||
var sortedIns = tx.inputs.slice().sort(function (a, b) { | ||
var ord = (0, uint8array_utils_1.lexCompare)(a.utxoRef.id.toBuffer(), b.utxoRef.id.toBuffer()); | ||
// if equal tx id order based on tx output index | ||
if (ord === 0) | ||
return a.utxoRef.index - b.utxoRef.index; | ||
// else order by tx id | ||
return ord; | ||
}); | ||
var utxoRef = (_b = sortedIns[rdmr.index]) === null || _b === void 0 ? void 0 : _b.utxoRef; | ||
if (utxoRef === undefined) | ||
@@ -24,0 +33,0 @@ throw new Error("invalid 'Spend' redeemer index: " + rdmr.index.toString() + |
@@ -521,4 +521,13 @@ "use strict"; | ||
var isScriptValid = true; | ||
var _inputs = inputs.map(function (_a, i) { | ||
var utxo = _a.utxo, referenceScriptV2 = _a.referenceScriptV2, inputScript = _a.inputScript; | ||
// `sort` mutates the array; so we `slice` (clone) first | ||
var sortedIns = inputs.slice().sort(function (a, b) { | ||
var ord = (0, uint8array_utils_1.lexCompare)(a.utxo.utxoRef.id.toBuffer(), b.utxo.utxoRef.id.toBuffer()); | ||
// if equal tx id order based on tx output index | ||
if (ord === 0) | ||
return a.utxo.utxoRef.index - b.utxo.utxoRef.index; | ||
// else order by tx id | ||
return ord; | ||
}); | ||
var _inputs = inputs.map(function (input) { | ||
var utxo = input.utxo, referenceScriptV2 = input.referenceScriptV2, inputScript = input.inputScript; | ||
var addr = utxo.resolved.address; | ||
@@ -542,2 +551,5 @@ totInputValue = cardano_ledger_ts_1.Value.add(totInputValue, utxo.resolved.value); | ||
var dat = pushWitDatum(datum, utxo.resolved.datum); | ||
var i = sortedIns.indexOf(input); | ||
if (i < 0) | ||
throw new Error("input missing in sorted"); | ||
spendRedeemers.push(new cardano_ledger_ts_1.TxRedeemer({ | ||
@@ -557,2 +569,5 @@ data: (0, CanBeData_1.forceData)(redeemer), | ||
var dat = pushWitDatum(datum, utxo.resolved.datum); | ||
var i = sortedIns.indexOf(input); | ||
if (i < 0) | ||
throw new Error("input missing in sorted"); | ||
spendRedeemers.push(new cardano_ledger_ts_1.TxRedeemer({ | ||
@@ -559,0 +574,0 @@ data: (0, CanBeData_1.forceData)(redeemer), |
{ | ||
"name": "@harmoniclabs/plu-ts-offchain", | ||
"version": "0.1.12-dev1", | ||
"version": "0.1.12-dev2", | ||
"description": "An embedded DSL for Cardano smart contracts creation coupled with a library for Cardano transactions, all in Typescript", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
177484
3284