New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@helios-lang/ledger-conway

Package Overview
Dependencies
Maintainers
0
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@helios-lang/ledger-conway - npm Package Compare versions

Comparing version 0.2.12 to 0.2.13

2

package.json
{
"name": "@helios-lang/ledger-conway",
"version": "0.2.12",
"version": "0.2.13",
"description": "Cardano ledger types for Conway era",

@@ -5,0 +5,0 @@ "type": "module",

@@ -36,8 +36,10 @@ import { Tx as BabbageTx, TxInput } from "@helios-lang/ledger-babbage"

const refScriptSize = calcRefScriptsSize(
const refScriptsSize = calcRefScriptsSize(
this.body.inputs,
this.body.refInputs
)
const refScriptsFee =
BigInt(helper.refScriptsFeePerByte) * BigInt(refScriptSize)
const refScriptsFee = calcRefScriptsFee(
refScriptsSize,
helper.refScriptsFeePerByte
)

@@ -49,2 +51,32 @@ return sizeFee + exFee + refScriptsFee

/**
* @param {bigint} size
* @param {number} feePerByte
* @param {bigint} growthIncrement
* @param {number} growthFactor
* @returns {bigint} - a lovelace value
*/
export function calcRefScriptsFee(
size,
feePerByte,
growthIncrement = 25600n,
growthFactor = 1.2
) {
let multiplier = 1.0
let fee = 0n
while (size > growthIncrement) {
fee += BigInt(
Math.floor(Number(growthIncrement) * multiplier * feePerByte)
)
size -= growthIncrement
multiplier *= growthFactor
}
fee += BigInt(Math.floor(Number(size) * multiplier * feePerByte))
return fee
}
/**
* Calculates the total size of reference scripts in unique inputs
* @param {TxInput[]} inputs

@@ -55,5 +87,13 @@ * @param {Option<TxInput[]>} refInputs

export function calcRefScriptsSize(inputs, refInputs) {
const refScriptSize = inputs
.concat(refInputs ?? [])
.reduce((prev, txInput) => {
/**
* @type {Record<string, TxInput>}
*/
const uniqueInputs = {}
inputs.concat(refInputs ?? []).forEach((input) => {
uniqueInputs[input.id.toString()] = input
})
const refScriptSize = Object.values(uniqueInputs).reduce(
(prev, txInput) => {
if (txInput.output.refScript) {

@@ -64,5 +104,7 @@ return prev + BigInt(txInput.output.refScript.toCbor().length)

}
}, 0n)
},
0n
)
return refScriptSize
}
/**
* @param {bigint} size
* @param {number} feePerByte
* @param {bigint} growthIncrement
* @param {number} growthFactor
* @returns {bigint} - a lovelace value
*/
export function calcRefScriptsFee(size: bigint, feePerByte: number, growthIncrement?: bigint, growthFactor?: number): bigint;
/**
* Calculates the total size of reference scripts in unique inputs
* @param {TxInput[]} inputs

@@ -3,0 +12,0 @@ * @param {Option<TxInput[]>} refInputs

Sorry, the diff of this file is not supported yet

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