@harmoniclabs/plu-ts-onchain
Version:
An embedded DSL for Cardano smart contracts creation coupled with a library for Cardano transactions, all in Typescript
52 lines (51 loc) • 4.09 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.addPByteStringMethods = void 0;
var obj_utils_1 = require("@harmoniclabs/obj-utils");
var bs_1 = require("../../builtins/bs/index.js");
var str_1 = require("../../builtins/str/index.js");
var plet_1 = require("../../plet/index.js");
var BaseUtilityTerm_1 = require("./BaseUtilityTerm.js");
var getterOnly = {
set: function () { },
configurable: false,
enumerable: true
};
function addPByteStringMethods(term) {
term = (0, BaseUtilityTerm_1.addBaseUtilityTerm)(term);
(0, obj_utils_1.definePropertyIfNotPresent)(term, "length", __assign({ get: function () { return (0, plet_1.plet)(bs_1.plengthBs.$(term)); } }, getterOnly));
(0, obj_utils_1.definePropertyIfNotPresent)(term, "utf8Decoded", __assign({ get: function () { return (0, plet_1.plet)(str_1.pdecodeUtf8.$(term)); } }, getterOnly));
(0, obj_utils_1.definePropertyIfNotPresent)(term, "pconcat", __assign({ get: function () { return bs_1.pappendBs.$(term); } }, getterOnly));
(0, obj_utils_1.defineReadOnlyProperty)(term, "concat", function (other) { return bs_1.pappendBs.$(term).$(other); });
(0, obj_utils_1.definePropertyIfNotPresent)(term, "pprepend", __assign({ get: function () { return bs_1.flippedCons.$(term); } }, getterOnly));
(0, obj_utils_1.defineReadOnlyProperty)(term, "prepend", function (byte) { return bs_1.pconsBs.$(byte).$(term); });
(0, obj_utils_1.definePropertyIfNotPresent)(term, "psubByteString", __assign({ get: function () { return bs_1.subByteString.$(term); } }, getterOnly));
(0, obj_utils_1.defineReadOnlyProperty)(term, "subByteString", function (fromInclusive, ofLength) { return bs_1.psliceBs.$(fromInclusive).$(ofLength).$(term); });
(0, obj_utils_1.definePropertyIfNotPresent)(term, "pslice", __assign({ get: function () { return bs_1.jsLikeSlice.$(term); } }, getterOnly));
(0, obj_utils_1.defineReadOnlyProperty)(term, "slice", function (fromInclusive, toExclusive) { return bs_1.jsLikeSlice.$(term).$(fromInclusive).$(toExclusive); });
(0, obj_utils_1.definePropertyIfNotPresent)(term, "pat", __assign({ get: function () { return bs_1.pindexBs.$(term); } }, getterOnly));
(0, obj_utils_1.defineReadOnlyProperty)(term, "at", function (index) { return bs_1.pindexBs.$(term).$(index); });
(0, obj_utils_1.definePropertyIfNotPresent)(term, "peq", __assign({ get: function () { return bs_1.peqBs.$(term); } }, getterOnly));
(0, obj_utils_1.defineReadOnlyProperty)(term, "eq", function (other) { return bs_1.peqBs.$(term).$(other); });
(0, obj_utils_1.definePropertyIfNotPresent)(term, "plt", __assign({ get: function () { return bs_1.plessBs.$(term); } }, getterOnly));
(0, obj_utils_1.defineReadOnlyProperty)(term, "lt", function (other) { return bs_1.plessBs.$(term).$(other); });
(0, obj_utils_1.definePropertyIfNotPresent)(term, "pltEq", __assign({ get: function () { return bs_1.plessEqBs.$(term); } }, getterOnly));
(0, obj_utils_1.defineReadOnlyProperty)(term, "ltEq", function (other) { return bs_1.plessEqBs.$(term).$(other); });
(0, obj_utils_1.definePropertyIfNotPresent)(term, "pgt", __assign({ get: function () { return bs_1.pgreaterBS.$(term); } }, getterOnly));
(0, obj_utils_1.defineReadOnlyProperty)(term, "gt", function (other) { return bs_1.pgreaterBS.$(term).$(other); });
(0, obj_utils_1.definePropertyIfNotPresent)(term, "pgtEq", __assign({ get: function () { return bs_1.pgreaterEqBS.$(term); } }, getterOnly));
(0, obj_utils_1.defineReadOnlyProperty)(term, "gtEq", function (other) { return bs_1.pgreaterEqBS.$(term).$(other); });
return term;
}
exports.addPByteStringMethods = addPByteStringMethods;