@mutants/cardano-tx-builder
Version:
A package that provides utility functions to build and destructure a cardano transaction
33 lines (32 loc) • 1.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.fromValueToUTxO = void 0;
const mocks_1 = require("./__mocks__/mocks");
const getMinUTxOCost_1 = require("./getMinUTxOCost");
/**
* This function makes sure we create a valid UTxO from a value,
* respecting the min UTxO value.
*/
const fromValueToUTxO = (address, value, datumInlined) => {
const txOut = {
address,
value,
datumInlined,
};
return {
...txOut,
value: {
...txOut.value,
coin: Math.max(parseFloat((0, getMinUTxOCost_1.getMinUTxOCost)({
...txOut,
value: {
...txOut.value,
coin: 1000000, // otherwise the min value is miscalculated
},
txHash: mocks_1.MOCK_TX_HASHES.A,
txIndex: 0,
}).toString()), parseFloat(txOut.value.coin.toString())),
},
};
};
exports.fromValueToUTxO = fromValueToUTxO;