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

@helios-lang/ledger

Package Overview
Dependencies
Maintainers
1
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@helios-lang/ledger - npm Package Compare versions

Comparing version

to
0.1.18

src/babbage/tx/MintingContext.js

2

package.json
{
"name": "@helios-lang/ledger",
"version": "0.1.17",
"version": "0.1.18",
"description": "Ledger types (eg. for building transactions)",

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

@@ -10,1 +10,15 @@ export * from "./hashes/index.js"

*/
/**
* @template TRedeemerStrict
* @template TRedeemerPermissive
* @typedef {import("./tx/index.js").MintingContext<TRedeemerStrict, TRedeemerPermissive>} MintingContext
*/
/**
* @template TDatumStrict
* @template TDatumPermissive
* @template TRedeemerStrict
* @template TRedeemerPermissive
* @typedef {import("./tx/index.js").SpendingContext<TDatumStrict, TDatumPermissive, TRedeemerStrict, TRedeemerPermissive>} SpendingContext
*/

@@ -20,1 +20,15 @@ export { Address } from "./Address.js"

*/
/**
* @template TRedeemerStrict
* @template TRedeemerPermissive
* @typedef {import("./MintingContext.js").MintingContext<TRedeemerStrict, TRedeemerPermissive>} MintingContext
*/
/**
* @template TDatumStrict
* @template TDatumPermissive
* @template TRedeemerStrict
* @template TRedeemerPermissive
* @typedef {import("./SpendingContext.js").SpendingContext<TDatumStrict, TDatumPermissive, TRedeemerStrict, TRedeemerPermissive>} SpendingContext
*/

@@ -45,2 +45,8 @@ import { bytesToHex, equalsBytes } from "@helios-lang/codec-utils"

/**
* @template TRedeemerStrict
* @template TRedeemerPermissive
* @typedef {import("./MintingContext.js").MintingContext<TRedeemerStrict, TRedeemerPermissive>} MintingContext
*/
/**
* @template TDatumStrict

@@ -358,25 +364,81 @@ * @template TDatumPermissive

* @overload
* @param {AssetClassLike} assetClass
* @param {AssetClass<null>} assetClass
* @param {bigint | number} quantity
* @param {Option<UplcData>} redeemer - isn't required when minting from a Native script
* @returns {TxBuilder}
*/
/**
*
* @overload
* @param {MintingPolicyHash<null>} policy
* @param {[ByteArrayLike, bigint | number][]} tokens
* @returns {TxBuilder}
*
* @template TRedeemer
* @overload
* @param {MintingPolicyHash<TRedeemer>} policy
* @param {[ByteArrayLike, number | bigint][]} tokens
* @param {AssetClass<MintingContext<any, TRedeemer>>} assetClass
* @param {bigint | number} quantity
* @param {TRedeemer} redeemer
* @returns {TxBuilder}
*
* @template TRedeemer
* @overload
* @param {MintingPolicyHash<MintingContext<any, TRedeemer>>} policy
* @param {[ByteArrayLike, bigint | number][]} tokens
* @param {TRedeemer} redeemer
* @returns {TxBuilder}
*/
/**
* @overload
* @param {MintingPolicyHashLike} policy
* @param {[ByteArrayLike, number | bigint][]} tokens - list of pairs of [tokenName, quantity], tokenName can be list of bytes or hex-string
* @param {Option<UplcData>} redeemer - isn't required when minting from a Native script
* @template TRedeemer
* @param {[
* AssetClass<null> | MintingPolicyHash<null>,
* bigint | number | [ByteArrayLike, bigint | number][]
* ] | [
* AssetClass<MintingContext<any, TRedeemer>> | MintingPolicyHash<MintingContext<any, TRedeemer>>,
* bigint | number | [ByteArrayLike, bigint | number][],
* TRedeemer
* ]} args
* @returns {TxBuilder}
*/
mint(...args) {
if (args.length == 2) {
const [a, b] = args
if (
a instanceof AssetClass &&
(typeof b == "bigint" || typeof b == "number")
) {
return this.mintUnsafe(a, b, None)
} else if (a instanceof MintingPolicyHash && Array.isArray(b)) {
return this.mintUnsafe(a, b, None)
} else {
throw new Error("invalid arguments")
}
} else if (args.length == 3) {
const [a, b, redeemer] = args
if (
a instanceof AssetClass &&
(typeof b == "bigint" || typeof b == "number")
) {
this.attachUplcProgram(a.context.program)
return this.mintUnsafe(
a,
b,
a.context.redeemer.toUplcData(redeemer)
)
} else if (a instanceof MintingPolicyHash && Array.isArray(b)) {
this.attachUplcProgram(a.context.program)
return this.mintUnsafe(
a,
b,
a.context.redeemer.toUplcData(redeemer)
)
} else {
throw new Error("invalid arguments")
}
} else {
throw new Error("invalid number of arguments")
}
}
/**

@@ -389,2 +451,14 @@ * Mint a list of tokens associated with a given `MintingPolicyHash`.

*
* @overload
* @param {AssetClassLike} assetClass
* @param {bigint | number} quantity
* @param {Option<UplcData>} redeemer - can be None when minting from a Native script (but not set by default)
* @returns {TxBuilder}
*
* @overload
* @param {MintingPolicyHashLike} policy
* @param {[ByteArrayLike, number | bigint][]} tokens - list of pairs of [tokenName, quantity], tokenName can be list of bytes or hex-string
* @param {Option<UplcData>} redeemer - can be None when minting from a Native script (but not set by default)
* @returns {TxBuilder}
*
* @template TRedeemer

@@ -394,4 +468,2 @@ * @param {[

* ] | [
* MintingPolicyHash<TRedeemer>, [ByteArrayLike, number | bigint][], TRedeemer
* ] | [
* MintingPolicyHashLike, [ByteArrayLike, number | bigint][], Option<UplcData>

@@ -401,10 +473,12 @@ * ]} args

*/
mint(...args) {
mintUnsafe(...args) {
const [a, b, redeemer] = args
// handle the overloads
const [mph, tokens] = (() => {
const tokens = args[1]
if (typeof tokens == "bigint" || typeof tokens == "number") {
if (typeof b == "bigint" || typeof b == "number") {
const assetClass = AssetClass.fromAlike(
/** @type {AssetClassLike} */ (args[0])
/** @type {AssetClassLike} */ (a)
)
return [

@@ -415,12 +489,12 @@ assetClass.mph,

assetClass.tokenName,
tokens
b
])
]
]
} else if (Array.isArray(tokens)) {
} else if (Array.isArray(b)) {
return [
MintingPolicyHash.fromAlike(
/** @type {MintingPolicyHashLike} */ (args[0])
/** @type {MintingPolicyHashLike} */ (a)
),
tokens
b
]

@@ -432,8 +506,2 @@ } else {

const redeemer = mph.context
? /** @type {MintingPolicyHash<any, any>} */ (
mph
).context.redeemer.toUplcData(/** @type {TRedeemer} */ (args[2]))
: /** @type {Option<UplcData>} */ (args[2])
this.mintedTokens.addTokens(mph, tokens)

@@ -448,6 +516,2 @@

if (mph.context) {
this.attachUplcProgram(mph.context.program)
}
if (!this.hasUplcScript(mph.bytes)) {

@@ -483,6 +547,4 @@ throw new Error(

* @returns {TxBuilder}
*/
/**
* @template [TDatum=UplcData]
*
* @template TDatum
* @param {[

@@ -489,0 +551,0 @@ * Address<null, any>, ValueLike

@@ -8,1 +8,15 @@ export * as byron from "./byron/index.js"

export * as conway from "./conway/index.js"
/**
* @template TRedeemerStrict
* @template TRedeemerPermissive
* @typedef {import("./babbage/index.js").MintingContext<TRedeemerStrict, TRedeemerPermissive>} MintingContext
*/
/**
* @template TDatumStrict
* @template TDatumPermissive
* @template TRedeemerStrict
* @template TRedeemerPermissive
* @typedef {import("./babbage/index.js").SpendingContext<TDatumStrict, TDatumPermissive, TRedeemerStrict, TRedeemerPermissive>} SpendingContext
*/

@@ -19,2 +19,6 @@ /**

/**
* @returns {StakingValidatorHash<unknown>}
*/
static dummy(): StakingValidatorHash<unknown>;
/**
* @template {StakingValidatorHashLike} T

@@ -21,0 +25,0 @@ * @param {T} arg

@@ -16,2 +16,6 @@ /**

/**
* @returns {ValidatorHash<unknown>}
*/
static dummy(): ValidatorHash<unknown>;
/**
* @template {ValidatorHashLike} T

@@ -18,0 +22,0 @@ * @param {T} arg

@@ -7,2 +7,4 @@ export * from "./hashes/index.js";

export type UplcData = import("@helios-lang/uplc").UplcData;
export type MintingContext<TRedeemerStrict, TRedeemerPermissive> = import("./tx/index.js").MintingContext<TRedeemerStrict, TRedeemerPermissive>;
export type SpendingContext<TDatumStrict, TDatumPermissive, TRedeemerStrict, TRedeemerPermissive> = import("./tx/index.js").SpendingContext<TDatumStrict, TDatumPermissive, TRedeemerStrict, TRedeemerPermissive>;
//# sourceMappingURL=index.d.ts.map

@@ -17,2 +17,4 @@ export { Address } from "./Address.js";

export type TxOutputDatumKind = import("./TxOutputDatum.js").TxOutputDatumKind;
export type MintingContext<TRedeemerStrict, TRedeemerPermissive> = import("./MintingContext.js").MintingContext<TRedeemerStrict, TRedeemerPermissive>;
export type SpendingContext<TDatumStrict, TDatumPermissive, TRedeemerStrict, TRedeemerPermissive> = import("./SpendingContext.js").SpendingContext<TDatumStrict, TDatumPermissive, TRedeemerStrict, TRedeemerPermissive>;
//# sourceMappingURL=index.d.ts.map

@@ -14,2 +14,7 @@ /**

/**
* @template TRedeemerStrict
* @template TRedeemerPermissive
* @typedef {import("./MintingContext.js").MintingContext<TRedeemerStrict, TRedeemerPermissive>} MintingContext
*/
/**
* @template TDatumStrict

@@ -161,27 +166,162 @@ * @template TDatumPermissive

* @overload
* @param {AssetClassLike} assetClass
* @param {AssetClass<null>} assetClass
* @param {bigint | number} quantity
* @param {Option<UplcData>} redeemer - isn't required when minting from a Native script
* @returns {TxBuilder}
*
* @overload
* @param {MintingPolicyHash<null>} policy
* @param {[ByteArrayLike, bigint | number][]} tokens
* @returns {TxBuilder}
*
* @template TRedeemer
* @overload
* @param {AssetClass<MintingContext<any, TRedeemer>>} assetClass
* @param {bigint | number} quantity
* @param {TRedeemer} redeemer
* @returns {TxBuilder}
*
* @template TRedeemer
* @overload
* @param {MintingPolicyHash<MintingContext<any, TRedeemer>>} policy
* @param {[ByteArrayLike, bigint | number][]} tokens
* @param {TRedeemer} redeemer
* @returns {TxBuilder}
*/
mint(assetClass: AssetClassLike, quantity: bigint | number, redeemer: Option<UplcData>): TxBuilder;
mint<TRedeemer>(assetClass: AssetClass<null>, quantity: bigint | number): TxBuilder;
/**
* @overload
* @param {AssetClass<null>} assetClass
* @param {bigint | number} quantity
* @returns {TxBuilder}
*
* @overload
* @param {MintingPolicyHash<null>} policy
* @param {[ByteArrayLike, bigint | number][]} tokens
* @returns {TxBuilder}
*
* @template TRedeemer
* @overload
* @param {MintingPolicyHash<TRedeemer>} policy
* @param {[ByteArrayLike, number | bigint][]} tokens
* @param {AssetClass<MintingContext<any, TRedeemer>>} assetClass
* @param {bigint | number} quantity
* @param {TRedeemer} redeemer
* @returns {TxBuilder}
*
* @template TRedeemer
* @overload
* @param {MintingPolicyHash<MintingContext<any, TRedeemer>>} policy
* @param {[ByteArrayLike, bigint | number][]} tokens
* @param {TRedeemer} redeemer
* @returns {TxBuilder}
*/
mint<TRedeemer>(policy: MintingPolicyHash<TRedeemer>, tokens: [ByteArrayLike, number | bigint][], redeemer: TRedeemer): TxBuilder;
mint<TRedeemer>(policy: MintingPolicyHash<null>, tokens: [ByteArrayLike, bigint | number][]): TxBuilder;
/**
* @overload
* @param {AssetClass<null>} assetClass
* @param {bigint | number} quantity
* @returns {TxBuilder}
*
* @overload
* @param {MintingPolicyHash<null>} policy
* @param {[ByteArrayLike, bigint | number][]} tokens
* @returns {TxBuilder}
*
* @template TRedeemer
* @overload
* @param {AssetClass<MintingContext<any, TRedeemer>>} assetClass
* @param {bigint | number} quantity
* @param {TRedeemer} redeemer
* @returns {TxBuilder}
*
* @template TRedeemer
* @overload
* @param {MintingPolicyHash<MintingContext<any, TRedeemer>>} policy
* @param {[ByteArrayLike, bigint | number][]} tokens
* @param {TRedeemer} redeemer
* @returns {TxBuilder}
*/
mint<TRedeemer>(assetClass: AssetClass<MintingContext<any, TRedeemer>>, quantity: bigint | number, redeemer: TRedeemer): TxBuilder;
/**
* @overload
* @param {AssetClass<null>} assetClass
* @param {bigint | number} quantity
* @returns {TxBuilder}
*
* @overload
* @param {MintingPolicyHash<null>} policy
* @param {[ByteArrayLike, bigint | number][]} tokens
* @returns {TxBuilder}
*
* @template TRedeemer
* @overload
* @param {AssetClass<MintingContext<any, TRedeemer>>} assetClass
* @param {bigint | number} quantity
* @param {TRedeemer} redeemer
* @returns {TxBuilder}
*
* @template TRedeemer
* @overload
* @param {MintingPolicyHash<MintingContext<any, TRedeemer>>} policy
* @param {[ByteArrayLike, bigint | number][]} tokens
* @param {TRedeemer} redeemer
* @returns {TxBuilder}
*/
mint<TRedeemer>(policy: MintingPolicyHash<MintingContext<any, TRedeemer>>, tokens: [ByteArrayLike, bigint | number][], redeemer: TRedeemer): TxBuilder;
/**
* Mint a list of tokens associated with a given `MintingPolicyHash`.
* Throws an error if the given `MintingPolicyHash` was already used in a previous call to `mint()`.
* The token names can either by a list of bytes or a hexadecimal string.
*
* Also throws an error if the redeemer is `null`, and the minting policy isn't a known `NativeScript`.
*
* @overload
* @param {AssetClassLike} assetClass
* @param {bigint | number} quantity
* @param {Option<UplcData>} redeemer - can be None when minting from a Native script (but not set by default)
* @returns {TxBuilder}
*
* @overload
* @param {MintingPolicyHashLike} policy
* @param {[ByteArrayLike, number | bigint][]} tokens - list of pairs of [tokenName, quantity], tokenName can be list of bytes or hex-string
* @param {Option<UplcData>} redeemer - isn't required when minting from a Native script
* @param {Option<UplcData>} redeemer - can be None when minting from a Native script (but not set by default)
* @returns {TxBuilder}
*
* @template TRedeemer
* @param {[
* AssetClassLike, bigint | number, Option<UplcData>
* ] | [
* MintingPolicyHashLike, [ByteArrayLike, number | bigint][], Option<UplcData>
* ]} args
* @returns {TxBuilder}
*/
mint(policy: MintingPolicyHashLike, tokens: [ByteArrayLike, number | bigint][], redeemer: Option<UplcData>): TxBuilder;
mintUnsafe<TRedeemer_1>(assetClass: AssetClassLike, quantity: bigint | number, redeemer: Option<UplcData>): TxBuilder;
/**
* Mint a list of tokens associated with a given `MintingPolicyHash`.
* Throws an error if the given `MintingPolicyHash` was already used in a previous call to `mint()`.
* The token names can either by a list of bytes or a hexadecimal string.
*
* Also throws an error if the redeemer is `null`, and the minting policy isn't a known `NativeScript`.
*
* @overload
* @param {AssetClassLike} assetClass
* @param {bigint | number} quantity
* @param {Option<UplcData>} redeemer - can be None when minting from a Native script (but not set by default)
* @returns {TxBuilder}
*
* @overload
* @param {MintingPolicyHashLike} policy
* @param {[ByteArrayLike, number | bigint][]} tokens - list of pairs of [tokenName, quantity], tokenName can be list of bytes or hex-string
* @param {Option<UplcData>} redeemer - can be None when minting from a Native script (but not set by default)
* @returns {TxBuilder}
*
* @template TRedeemer
* @param {[
* AssetClassLike, bigint | number, Option<UplcData>
* ] | [
* MintingPolicyHashLike, [ByteArrayLike, number | bigint][], Option<UplcData>
* ]} args
* @returns {TxBuilder}
*/
mintUnsafe<TRedeemer_1>(policy: MintingPolicyHashLike, tokens: [ByteArrayLike, number | bigint][], redeemer: Option<UplcData>): TxBuilder;
/**
* @overload
* @param {Address<null, any>} address

@@ -197,4 +337,12 @@ * @param {ValueLike} value

* @returns {TxBuilder}
*
* @template TDatum
* @param {[
* Address<null, any>, ValueLike
* ] | [
* Address<SpendingContext<any, TDatum, any, any>, any>, ValueLike, TxOutputDatumCastable<TDatum>
* ]} args
* @returns {TxBuilder}
*/
pay<TDatum = import("@helios-lang/uplc").UplcData>(address: Address<null, any>, value: ValueLike): TxBuilder;
pay<TDatum>(address: Address<null, any>, value: ValueLike): TxBuilder;
/**

@@ -212,4 +360,12 @@ * @overload

* @returns {TxBuilder}
*
* @template TDatum
* @param {[
* Address<null, any>, ValueLike
* ] | [
* Address<SpendingContext<any, TDatum, any, any>, any>, ValueLike, TxOutputDatumCastable<TDatum>
* ]} args
* @returns {TxBuilder}
*/
pay<TDatum = import("@helios-lang/uplc").UplcData>(address: Address<SpendingContext<any, TDatum, any, any>, any>, value: ValueLike, datum: TxOutputDatumCastable<TDatum>): TxBuilder;
pay<TDatum>(address: Address<SpendingContext<any, TDatum, any, any>, any>, value: ValueLike, datum: TxOutputDatumCastable<TDatum>): TxBuilder;
/**

@@ -303,3 +459,3 @@ * @overload

*/
spend<TRedeemer_1>(utxos: TxInput<null, any> | TxInput<null, any>[]): TxBuilder;
spend<TRedeemer_2>(utxos: TxInput<null, any> | TxInput<null, any>[]): TxBuilder;
/**

@@ -316,3 +472,3 @@ * @overload

*/
spend<TRedeemer_1>(utxos: TxInput<SpendingContext<any, any, any, TRedeemer_1>, any> | TxInput<SpendingContext<any, any, any, TRedeemer_1>, any>[], redeemer: TRedeemer_1): TxBuilder;
spend<TRedeemer_2>(utxos: TxInput<SpendingContext<any, any, any, TRedeemer_2>, any> | TxInput<SpendingContext<any, any, any, TRedeemer_2>, any>[], redeemer: TRedeemer_2): TxBuilder;
/**

@@ -615,2 +771,3 @@ * Add a UTxO instance as an input to the transaction being built.

export type TxMetadataAttr = import("./TxMetadataAttr.js").TxMetadataAttr;
export type MintingContext<TRedeemerStrict, TRedeemerPermissive> = import("./MintingContext.js").MintingContext<TRedeemerStrict, TRedeemerPermissive>;
export type SpendingContext<TDatumStrict, TDatumPermissive, TRedeemerStrict, TRedeemerPermissive> = import("./SpendingContext.js").SpendingContext<TDatumStrict, TDatumPermissive, TRedeemerStrict, TRedeemerPermissive>;

@@ -627,2 +784,3 @@ export type TxOutputDatumCastable<T> = import("./TxOutputDatum.js").TxOutputDatumCastable<T>;

import { UplcProgramV2 } from "@helios-lang/uplc";
import { AssetClass } from "../money/index.js";
import { MintingPolicyHash } from "../hashes/index.js";

@@ -629,0 +787,0 @@ import { TxOutputDatum } from "./TxOutputDatum.js";

@@ -8,2 +8,4 @@ export * as byron from "./byron/index.js";

export * as conway from "./conway/index.js";
export type MintingContext<TRedeemerStrict, TRedeemerPermissive> = import("./babbage/index.js").MintingContext<TRedeemerStrict, TRedeemerPermissive>;
export type SpendingContext<TDatumStrict, TDatumPermissive, TRedeemerStrict, TRedeemerPermissive> = import("./babbage/index.js").SpendingContext<TDatumStrict, TDatumPermissive, TRedeemerStrict, TRedeemerPermissive>;
//# sourceMappingURL=index.d.ts.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet