UNPKG

@harmoniclabs/buildooor

Version:

Cardano transaction builder in typescript

57 lines (56 loc) 2.84 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isNormalizedGenesisInfos = exports.isGenesisInfos = exports.defaultMainnetGenesisInfos = exports.defaultPreprodGenesisInfos = exports.defaultPreviewGenesisInfos = exports.normalizedGenesisInfos = void 0; var obj_utils_1 = require("@harmoniclabs/obj-utils"); var ints_1 = require("../utils/ints.js"); function normalizedGenesisInfos(gInfo) { var _a, _b, _c; return Object.freeze({ systemStartPosixMs: Number((_a = gInfo.systemStartPosixMs) !== null && _a !== void 0 ? _a : gInfo.systemStartPOSIX), slotLengthMs: Number((_b = gInfo.slotLengthMs) !== null && _b !== void 0 ? _b : gInfo.slotLengthInMilliseconds), startSlotNo: Number((_c = gInfo.startSlotNo) !== null && _c !== void 0 ? _c : 0) }); } exports.normalizedGenesisInfos = normalizedGenesisInfos; exports.defaultPreviewGenesisInfos = Object.freeze({ systemStartPOSIX: 1666656000000, systemStartPosixMs: 1666656000000, slotLengthInMilliseconds: 1000, slotLengthMs: 1000, startSlotNo: 0 }); exports.defaultPreprodGenesisInfos = Object.freeze({ systemStartPOSIX: 1654041600000 + 1728000000, systemStartPosixMs: 1654041600000 + 1728000000, slotLengthInMilliseconds: 1000, slotLengthMs: 1000, startSlotNo: 86400 }); exports.defaultMainnetGenesisInfos = Object.freeze({ systemStartPOSIX: 1596059091000, systemStartPosixMs: 1596059091000, slotLengthInMilliseconds: 1000, slotLengthMs: 1000, startSlotNo: 4492800 }); function isGenesisInfos(stuff) { return (typeof stuff === "object" && stuff !== null && (((0, obj_utils_1.hasOwn)(stuff, "systemStartPOSIX") && (0, ints_1.canBeUInteger)(stuff.systemStartPOSIX)) || ((0, obj_utils_1.hasOwn)(stuff, "systemStartPosixMs") && (0, ints_1.canBeUInteger)(stuff.systemStartPosixMs))) && (((0, obj_utils_1.hasOwn)(stuff, "slotLengthInMilliseconds") && (0, ints_1.canBeUInteger)(stuff.slotLengthInMilliseconds)) || ((0, obj_utils_1.hasOwn)(stuff, "slotLengthMs") && (0, ints_1.canBeUInteger)(stuff.slotLengthMs))) && ((0, obj_utils_1.hasOwn)(stuff, "startSlotNo") ? (0, ints_1.canBeUInteger)(stuff.startSlotNo) : true)); } exports.isGenesisInfos = isGenesisInfos; function isNormalizedGenesisInfos(stuff) { return (typeof stuff === "object" && stuff !== null && ((0, obj_utils_1.hasOwn)(stuff, "systemStartPosixMs") && (typeof stuff.systemStartPosixMs === "number")) && ((0, obj_utils_1.hasOwn)(stuff, "slotLengthMs") && (0, ints_1.canBeUInteger)(stuff.slotLengthMs)) && ((0, obj_utils_1.hasOwn)(stuff, "startSlotNo") && (0, ints_1.canBeUInteger)(stuff.startSlotNo))); } exports.isNormalizedGenesisInfos = isNormalizedGenesisInfos;