@harmoniclabs/plu-ts-onchain
Version:
An embedded DSL for Cardano smart contracts creation coupled with a library for Cardano transactions, all in Typescript
59 lines (58 loc) • 2.92 kB
JavaScript
;
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.addPBoolMethods = void 0;
var Term_1 = require("../../../Term/index.js");
var pBool_1 = require("../bool/pBool.js");
var bool_1 = require("../../builtins/bool/index.js");
var types_1 = require("../../../type_system/types.js");
var IRDelayed_1 = require("../../../../IR/IRNodes/IRDelayed.js");
var obj_utils_1 = require("@harmoniclabs/obj-utils");
var BaseUtilityTerm_1 = require("./BaseUtilityTerm.js");
// avoid circular dependency
// is nothing fancy anyway
function pdelay(toDelay) {
return new Term_1.Term((0, types_1.delayed)(toDelay.type), function (cfg, dbn) {
return new IRDelayed_1.IRDelayed(toDelay.toIR(cfg, dbn));
});
}
var getterOnly = {
set: function () { },
configurable: false,
enumerable: true
};
function addPBoolMethods(term) {
term = (0, BaseUtilityTerm_1.addBaseUtilityTerm)(term);
(0, obj_utils_1.definePropertyIfNotPresent)(term, "por", __assign({ get: function () { return bool_1.por.$(term); } }, getterOnly));
(0, obj_utils_1.defineReadOnlyProperty)(term, "or", function (other) {
return bool_1.por
.$(term)
.$(pdelay(typeof other === "boolean" ?
(0, pBool_1.pBool)(other) : other));
});
(0, obj_utils_1.definePropertyIfNotPresent)(term, "pstrictOr", __assign({ get: function () { return bool_1.pstrictOr.$(term); } }, getterOnly));
(0, obj_utils_1.defineReadOnlyProperty)(term, "strictOr", function (other) { return bool_1.pstrictOr.$(term).$(other); });
(0, obj_utils_1.definePropertyIfNotPresent)(term, "pand", __assign({ get: function () { return bool_1.pand.$(term); } }, getterOnly));
(0, obj_utils_1.defineReadOnlyProperty)(term, "and", function (other) {
return bool_1.pand
.$(term)
.$(pdelay(typeof other === "boolean" ?
(0, pBool_1.pBool)(other) : other));
});
(0, obj_utils_1.definePropertyIfNotPresent)(term, "pstrictAnd", __assign({ get: function () { return bool_1.pstrictAnd.$(term); } }, getterOnly));
(0, obj_utils_1.defineReadOnlyProperty)(term, "strictAnd", function (other) { return bool_1.pstrictAnd.$(term).$(other); });
(0, obj_utils_1.definePropertyIfNotPresent)(term, "peq", __assign({ get: function () { return bool_1.peqBool.$(term); } }, getterOnly));
(0, obj_utils_1.defineReadOnlyProperty)(term, "eq", function (other) { return bool_1.peqBool.$(term).$(other); });
return term;
}
exports.addPBoolMethods = addPBoolMethods;