UNPKG

@harmoniclabs/buildooor

Version:

Cardano transaction builder in typescript

41 lines (40 loc) 1.89 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.normalizeVotingProcedureEntry = exports.normalizeITxBuildVotingProcedure = exports.eqIVoter = void 0; var cardano_ledger_ts_1 = require("@harmoniclabs/cardano-ledger-ts"); var ScriptWithRedeemer_1 = require("./ScriptWithRedeemer.js"); var obj_utils_1 = require("@harmoniclabs/obj-utils"); var uint8array_utils_1 = require("@harmoniclabs/uint8array-utils"); function eqIVoter(a, b) { if (!(0, obj_utils_1.isObject)(a)) return false; if (!(0, obj_utils_1.isObject)(b)) return false; return ((0, cardano_ledger_ts_1.isVoterKind)(a.kind) && a.kind === b.kind && (0, cardano_ledger_ts_1.canBeHash28)(a.hash) && (0, cardano_ledger_ts_1.canBeHash28)(b.hash) && (0, uint8array_utils_1.uint8ArrayEq)(new cardano_ledger_ts_1.Hash28(a.hash).toBuffer(), new cardano_ledger_ts_1.Hash28(b.hash).toBuffer())); } exports.eqIVoter = eqIVoter; function normalizeITxBuildVotingProcedure(_a) { var votingProcedure = _a.votingProcedure, script = _a.script; return { votingProcedure: normalizeVotingProcedureEntry(votingProcedure), script: script === undefined ? undefined : (0, ScriptWithRedeemer_1.normalizeIScriptWithRedeemer)(script) }; } exports.normalizeITxBuildVotingProcedure = normalizeITxBuildVotingProcedure; function normalizeVotesEntry(_a) { var govActionId = _a.govActionId, vote = _a.vote; return { govActionId: (0, cardano_ledger_ts_1.forceTxOutRef)(govActionId), vote: new cardano_ledger_ts_1.VotingProcedure(vote) }; } function normalizeVotingProcedureEntry(votingProcedure) { return { voter: new cardano_ledger_ts_1.Voter(votingProcedure.voter), votes: votingProcedure.votes.map(normalizeVotesEntry) }; } exports.normalizeVotingProcedureEntry = normalizeVotingProcedureEntry;