Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@harmoniclabs/plu-ts

Package Overview
Dependencies
Maintainers
1
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@harmoniclabs/plu-ts - npm Package Compare versions

Comparing version 0.3.0-dev1 to 0.3.0-dev2

9

dist/offchain/tx/builder/txBuild/ITxBuildInput.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.cloneITxBuildInput = void 0;
var CanBeData_1 = require("../../../../types/Data/CanBeData/index.js");
function cloneITxBuildInput(_a) {

@@ -9,4 +10,4 @@ var utxo = _a.utxo, ref = _a.referenceScriptV2, inScript = _a.inputScript;

refUtxo: ref.refUtxo.clone(),
datum: ref.datum === "inline" ? "inline" : ref.datum.clone(),
redeemer: ref.redeemer.clone()
datum: ref.datum === "inline" ? "inline" : (0, CanBeData_1.cloneCanBeData)(ref.datum),
redeemer: (0, CanBeData_1.cloneCanBeData)(ref.redeemer)
};

@@ -16,4 +17,4 @@ var inputScript = inScript === undefined ? undefined :

script: inScript.script.clone(),
datum: inScript.datum === "inline" ? "inline" : inScript.datum.clone(),
redeemer: inScript.redeemer.clone()
datum: inScript.datum === "inline" ? "inline" : (0, CanBeData_1.cloneCanBeData)(inScript.datum),
redeemer: (0, CanBeData_1.cloneCanBeData)(inScript.redeemer)
};

@@ -20,0 +21,0 @@ return {

@@ -12,3 +12,3 @@ "use strict";

if (node instanceof IRLetted_1.IRLetted && (0, isClosedIRTerm_1.isClosedIRTerm)(node.value)) {
(0, _modifyChildFromTo_1._modifyChildFromTo)(node.parent, node, new IRHoisted_1.IRHoisted(node.value));
(0, _modifyChildFromTo_1._modifyChildFromTo)(node.parent, node, new IRHoisted_1.IRHoisted(node.value, node.meta));
return true;

@@ -15,0 +15,0 @@ }

import { CborObj } from "../../../cbor/CborObj/index.js";
import { CborString } from "../../../cbor/CborString/index.js";
import { Data } from "../Data.js";
import { Term } from "../../../onchain/pluts/Term/index.js";
import { PData } from "../../../onchain/pluts/PTypes/PData/PData.js";
import { PStruct } from "../../../onchain/pluts/PTypes/PStruct/pstruct.js";
export type CanBeData = Data | Term<PData> | Term<PStruct<any>> | CborObj | CborString;
import { ToUPLC } from "../../../onchain/UPLC/interfaces/ToUPLC.js";
export type CanBeData = Data | ToUPLC | CborObj | CborString;
export declare function cloneCanBeData(stuff: CanBeData): CanBeData;
export declare function canBeData(something: any): something is CanBeData;
export declare function forceData(data: CanBeData): Data;

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.forceData = exports.canBeData = void 0;
exports.forceData = exports.canBeData = exports.cloneCanBeData = void 0;
var JsRuntime_1 = __importDefault(require("../../../utils/JsRuntime/index.js"));

@@ -15,6 +15,21 @@ var CborObj_1 = require("../../../cbor/CborObj/index.js");

var UPLCConst_1 = require("../../../onchain/UPLC/UPLCTerms/UPLCConst/index.js");
var Term_1 = require("../../../onchain/pluts/Term/index.js");
var fromCbor_1 = require("../fromCbor.js");
var types_1 = require("../../../onchain/pluts/type_system/types.js");
var typeExtends_1 = require("../../../onchain/pluts/type_system/typeExtends.js");
var ObjectUtils_1 = __importDefault(require("../../../utils/ObjectUtils/index.js"));
function cloneCanBeData(stuff) {
if (stuff instanceof CborString_1.CborString ||
(0, CborObj_1.isCborObj)(stuff) ||
(0, Data_1.isData)(stuff))
return stuff.clone();
var result = Machine_1.Machine.evalSimple(stuff.toUPLC());
if (!(result instanceof UPLCConst_1.UPLCConst)) {
throw new BasePlutsError_1.BasePlutsError("`CanBeData` object that implements `ToUPLC` did not evaluated to a constant");
}
var value = result.value;
if (!(0, Data_1.isData)(value)) {
throw new BasePlutsError_1.BasePlutsError("`CanBeData` object that implements `ToUPLC` evaluated to a constant with a non-Data value");
}
return value;
}
exports.cloneCanBeData = cloneCanBeData;
function canBeData(something) {

@@ -24,4 +39,5 @@ if (typeof something !== "object")

return ((0, Data_1.isData)(something) ||
(something instanceof Term_1.Term &&
(0, typeExtends_1.typeExtends)(something.type, types_1.data)) ||
(typeof types_1.data === "object" &&
ObjectUtils_1.default.hasOwn(types_1.data, "toUPLC") &&
typeof types_1.data.toUPLC === "function") ||
something instanceof CborString_1.CborString ||

@@ -31,3 +47,2 @@ (0, CborObj_1.isCborObj)(something));

exports.canBeData = canBeData;
var data_t = types_1.data;
function forceData(data) {

@@ -37,7 +52,6 @@ if ((0, Data_1.isData)(data)) {

}
if (data instanceof Term_1.Term) {
if (!(0, typeExtends_1.typeExtends)(data.type, data_t)) {
throw new BasePlutsError_1.BasePlutsError("datum was a term of a type that doesn't extends 'data'");
}
var uplcData = Machine_1.Machine.evalSimple(data);
if (typeof data === "object" &&
ObjectUtils_1.default.hasOwn(data, "toUPLC") &&
typeof data.toUPLC === "function") {
var uplcData = Machine_1.Machine.evalSimple(data.toUPLC());
if (!(uplcData instanceof UPLCConst_1.UPLCConst)) {

@@ -44,0 +58,0 @@ throw new BasePlutsError_1.BasePlutsError("term passed as 'datum' field evaluated to an error");

@@ -11,2 +11,3 @@ export * from "./Data.js";

export * from "./hashData.js";
export * from "./CanBeData/index.js";
export * from "./toData/interface.js";

@@ -27,2 +27,3 @@ "use strict";

__exportStar(require("./hashData.js"), exports);
__exportStar(require("./CanBeData/index.js"), exports);
__exportStar(require("./toData/interface.js"), exports);
{
"name": "@harmoniclabs/plu-ts",
"version": "0.3.0-dev1",
"version": "0.3.0-dev2",
"description": "An embedded DSL for Cardano smart contracts creation coupled with a library for Cardano transactions, all in Typescript",

@@ -19,3 +19,3 @@ "main": "./dist/index.js",

"test-coverage": "jest --coverage",
"build": "tsc --project ./tsconfig.json && tsc-alias -p ./tsconfig.json",
"build": "rm -rf ./dist && tsc --project ./tsconfig.json && tsc-alias -p ./tsconfig.json",
"buidl": "npm run build",

@@ -22,0 +22,0 @@ "prerelease": "npm run test && npm run build",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc