@harmoniclabs/buildooor 0.1.6 → 0.1.7
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.
|
@@ -13,10 +13,17 @@ function getScriptByHash(tx, hash) {
|
|
|
13
13
|
return ((_f = (_d = (_b = (_a = witnesses.plutusV1Scripts) === null || _a === void 0 ? void 0 : _a.find(function (s) { return (0, uint8array_utils_1.uint8ArrayEq)(hash, s.hash.toBuffer()); })) !== null && _b !== void 0 ? _b : (_c = witnesses.plutusV2Scripts) === null || _c === void 0 ? void 0 : _c.find(function (s) { return (0, uint8array_utils_1.uint8ArrayEq)(hash, s.hash.toBuffer()); })) !== null && _d !== void 0 ? _d : (_e = witnesses.plutusV3Scripts) === null || _e === void 0 ? void 0 : _e.find(function (s) { return (0, uint8array_utils_1.uint8ArrayEq)(hash, s.hash.toBuffer()); })) !== null && _f !== void 0 ? _f : (_h = (_g = tx.body.refInputs) === null || _g === void 0 ? void 0 : _g.find(function (i) { return i.resolved.refScript && (0, uint8array_utils_1.uint8ArrayEq)(hash, i.resolved.refScript.hash.toBuffer()); })) === null || _h === void 0 ? void 0 : _h.resolved.refScript);
|
|
14
14
|
}
|
|
15
15
|
function getSpendingScript(tx, index) {
|
|
16
|
-
|
|
17
|
-
if (allScriptInputs.length === 0)
|
|
16
|
+
if (tx.body.inputs.length <= index)
|
|
18
17
|
return undefined;
|
|
19
|
-
var
|
|
18
|
+
var sortedIns = tx.body.inputs.slice().sort(function (a, b) {
|
|
19
|
+
var ord = (0, uint8array_utils_1.lexCompare)(a.utxoRef.id.toBuffer(), b.utxoRef.id.toBuffer());
|
|
20
|
+
// if equal tx id order based on tx output index
|
|
21
|
+
if (ord === 0)
|
|
22
|
+
return a.utxoRef.index - b.utxoRef.index;
|
|
23
|
+
// else order by tx id
|
|
24
|
+
return ord;
|
|
25
|
+
});
|
|
26
|
+
var scriptInput = sortedIns[index];
|
|
20
27
|
if (!scriptInput)
|
|
21
28
|
return undefined;
|
|
22
29
|
var scriptHash = scriptInput.resolved.address.paymentCreds.hash.toBuffer();
|