Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@harmoniclabs/plu-ts-offchain

Package Overview
Dependencies
Maintainers
0
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@harmoniclabs/plu-ts-offchain - npm Package Compare versions

Comparing version 0.1.13-dev13 to 0.1.13-dev14

1

dist/TxBuilder/TxBuilder.d.ts

@@ -19,2 +19,3 @@ import { GenesisInfos, NormalizedGenesisInfos } from "./GenesisInfos.js";

calcLinearFee(tx: Tx | CborString): bigint;
calcMinFee(tx: Tx): bigint;
getMinimumOutputLovelaces(tx_out: TxOut | CanBeCborString): bigint;

@@ -21,0 +22,0 @@ /**

62

dist/TxBuilder/TxBuilder.js

@@ -117,2 +117,3 @@ "use strict";

var utils_1 = require("./utils.js");
var Rational_1 = require("../utils/Rational.js");
// const scriptCache: { [x: string]: UPLCTerm } = {};

@@ -173,2 +174,28 @@ function getScriptLikeUplc(scriptLike) {

};
TxBuilder.prototype.calcMinFee = function (tx) {
var _a;
var totRefScriptBytes = ((_a = tx.body.refInputs) !== null && _a !== void 0 ? _a : [])
.reduce(function (sum, refIn) {
if (refIn.resolved.refScript)
return sum + BigInt(refIn.resolved.refScript.toCbor().toBuffer().length
+ 10 // second Cbor wrap
);
return sum;
}, BigInt(0));
var minRefScriptFee = this.protocolParamters.minfeeRefScriptCostPerByte ? (totRefScriptBytes * this.protocolParamters.minfeeRefScriptCostPerByte.num /
this.protocolParamters.minfeeRefScriptCostPerByte.den) : (totRefScriptBytes * (0, Rational_1.cborFromRational)(cardano_ledger_ts_1.defaultProtocolParameters.minfeeRefScriptCostPerByte).num /
(0, Rational_1.cborFromRational)(cardano_ledger_ts_1.defaultProtocolParameters.minfeeRefScriptCostPerByte).den);
var minFeeMultiplier = (0, ints_1.forceBigUInt)(this.protocolParamters.txFeePerByte);
var nVkeyWits = BigInt((0, utils_1.estimateMaxSignersNeeded)(tx));
var minFee = this.calcLinearFee(tx) +
minRefScriptFee +
// consider also vkeys witnesses to be added
// each vkey witness has fixed size of 102 cbor bytes
// (1 bytes cbor array tag (length 2)) + (34 cbor bytes of length 32) + (67 cbor bytes of length 64)
// for a fixed length of 102
BigInt(102) * nVkeyWits * minFeeMultiplier +
// we add some more bytes for the array tag
BigInt(nVkeyWits < 24 ? 1 : (nVkeyWits < 256 ? 2 : 3)) * minFeeMultiplier;
return minFee;
};
TxBuilder.prototype.getMinimumOutputLovelaces = function (tx_out) {

@@ -256,4 +283,5 @@ var size = BigInt(0);

// tx,
scriptsToExec = _initBuild.scriptsToExec, minFee = _initBuild.minFee, datumsScriptData = _initBuild.datumsScriptData, languageViews = _initBuild.languageViews, totInputValue = _initBuild.totInputValue, requiredOutputValue = _initBuild.requiredOutputValue, outs = _initBuild.outs, change = _initBuild.change;
scriptsToExec = _initBuild.scriptsToExec, datumsScriptData = _initBuild.datumsScriptData, languageViews = _initBuild.languageViews, totInputValue = _initBuild.totInputValue, requiredOutputValue = _initBuild.requiredOutputValue, outs = _initBuild.outs, change = _initBuild.change;
var tx = _initBuild.tx;
var minFee = _initBuild.minFee;
var rdmrs = (_b = tx.witnesses.redeemers) !== null && _b !== void 0 ? _b : [];

@@ -363,2 +391,3 @@ var nRdmrs = rdmrs.length;

}
minFee = this_1.calcMinFee(tx);
fee = minFee +

@@ -376,3 +405,5 @@ ((totExBudget.mem * memRational.num) / memRational.den) +

return "break";
outs.forEach(function (txO, i) { return txOuts[i] = txO.clone(); });
for (var i = 0; i < outs.length; i++) {
txOuts[i] = outs[i].clone();
}
txOuts[txOuts.length - 1] = (new cardano_ledger_ts_1.TxOut({

@@ -387,3 +418,3 @@ address: change.address,

var nextWitnesses = new cardano_ledger_ts_1.TxWitnessSet(__assign(__assign({}, tx.witnesses), { redeemers: rdmrs }));
tx = new cardano_ledger_ts_1.Tx(__assign(__assign({}, tx), { body: new cardano_ledger_ts_1.TxBody(__assign(__assign({}, tx.body), { outputs: txOuts, fee: fee, scriptDataHash: getScriptDataHash(nextWitnesses, languageViews) })), witnesses: nextWitnesses, isScriptValid: _isScriptValid }));
tx = new cardano_ledger_ts_1.Tx(__assign(__assign({}, tx), { body: new cardano_ledger_ts_1.TxBody(__assign(__assign({}, tx.body), { outputs: txOuts.slice(), fee: fee, scriptDataHash: getScriptDataHash(nextWitnesses, languageViews) })), witnesses: nextWitnesses, isScriptValid: _isScriptValid }));
_isScriptValid = true;

@@ -422,4 +453,3 @@ totExBudget = new plutus_machine_1.ExBudget({ mem: 0, cpu: 0 });

TxBuilder.prototype.initTxBuild = function (buildArgs) {
var _a;
var _b = (0, txBuild_1.normalizeITxBuildArgs)(buildArgs), outputs = _b.outputs, requiredSigners = _b.requiredSigners, mints = _b.mints, invalidAfter = _b.invalidAfter, certificates = _b.certificates, withdrawals = _b.withdrawals, metadata = _b.metadata, votingProcedures = _b.votingProcedures, proposalProcedures = _b.proposalProcedures, currentTreasuryValue = _b.currentTreasuryValue, paymentToTreasury = _b.paymentToTreasury, args = __rest(_b, ["outputs", "requiredSigners", "mints", "invalidAfter", "certificates", "withdrawals", "metadata", "votingProcedures", "proposalProcedures", "currentTreasuryValue", "paymentToTreasury"]);
var _a = (0, txBuild_1.normalizeITxBuildArgs)(buildArgs), outputs = _a.outputs, requiredSigners = _a.requiredSigners, mints = _a.mints, invalidAfter = _a.invalidAfter, certificates = _a.certificates, withdrawals = _a.withdrawals, metadata = _a.metadata, votingProcedures = _a.votingProcedures, proposalProcedures = _a.proposalProcedures, currentTreasuryValue = _a.currentTreasuryValue, paymentToTreasury = _a.paymentToTreasury, args = __rest(_a, ["outputs", "requiredSigners", "mints", "invalidAfter", "certificates", "withdrawals", "metadata", "votingProcedures", "proposalProcedures", "currentTreasuryValue", "paymentToTreasury"]);
// mutable args

@@ -881,23 +911,3 @@ var inputs = args.inputs, changeAddress = args.changeAddress, change = args.change, invalidBefore = args.invalidBefore, readonlyRefInputs = args.readonlyRefInputs, collaterals = args.collaterals, collateralReturn = args.collateralReturn;

});
var totRefScriptBytes = ((_a = dummyTx.body.refInputs) !== null && _a !== void 0 ? _a : [])
.reduce(function (sum, refIn) {
if (refIn.resolved.refScript)
return sum + BigInt(refIn.resolved.refScript.toCbor().toBuffer().length
+ 10 // second Cbor wrap
);
return sum;
}, BigInt(0));
var minRefScriptFee = this.protocolParamters.minfeeRefScriptCostPerByte ? (totRefScriptBytes * this.protocolParamters.minfeeRefScriptCostPerByte.num /
this.protocolParamters.minfeeRefScriptCostPerByte.den) : BigInt(0);
var minFeeMultiplier = (0, ints_1.forceBigUInt)(this.protocolParamters.txFeePerByte);
var nVkeyWits = BigInt((0, utils_1.estimateMaxSignersNeeded)(dummyTx));
var minFee = this.calcLinearFee(dummyTx) +
minRefScriptFee +
// consider also vkeys witnesses to be added
// each vkey witness has fixed size of 102 cbor bytes
// (1 bytes cbor array tag (length 2)) + (34 cbor bytes of length 32) + (67 cbor bytes of length 64)
// for a fixed length of 102
BigInt(102) * nVkeyWits * minFeeMultiplier +
// we add some more bytes for the array tag
BigInt(nVkeyWits < 24 ? 1 : (nVkeyWits < 256 ? 2 : 3)) * minFeeMultiplier;
var minFee = this.calcMinFee(dummyTx);
var txOuts = new Array(outs.length + 1);

@@ -904,0 +914,0 @@ outs.forEach(function (txO, i) { return txOuts[i] = txO.clone(); });

{
"name": "@harmoniclabs/plu-ts-offchain",
"version": "0.1.13-dev13",
"version": "0.1.13-dev14",
"description": "An embedded DSL for Cardano smart contracts creation coupled with a library for Cardano transactions, all in Typescript",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc