@helios-lang/ledger
Advanced tools
Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "@helios-lang/ledger", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Ledger types (eg. for building transactions)", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -1,2 +0,1 @@ | ||
export { DEFAULT_ENCODING_CONFIG } from "./EncodingConfig.js" | ||
export { DEFAULT_NETWORK_PARAMS } from "./NetworkParams.js" | ||
@@ -6,5 +5,4 @@ export { NetworkParamsHelper } from "./NetworkParamsHelper.js" | ||
/** | ||
* @typedef {import("./EncodingConfig.js").EncodingConfig} EncodingConfig | ||
* @typedef {import("./NetworkParams.js").NetworkParams} NetworkParams | ||
* @typedef {import("./NetworkParamsHelper.js").NetworkParamsLike} NetworkParamsLike | ||
*/ |
@@ -6,3 +6,2 @@ import { | ||
} from "@helios-lang/uplc" | ||
import { DEFAULT_ENCODING_CONFIG } from "./EncodingConfig.js" | ||
@@ -12,3 +11,2 @@ /** | ||
* @typedef {import("@helios-lang/uplc").CostModelParamsV2} CostModelParamsV2 | ||
* @typedef {import("./EncodingConfig.js").EncodingConfig} EncodingConfig | ||
*/ | ||
@@ -26,3 +24,2 @@ | ||
* @typedef {{ | ||
* encodingConfig: EncodingConfig | ||
* shelleyGenesis: { | ||
@@ -148,3 +145,2 @@ * activeSlotsCoeff: number | ||
export const DEFAULT_NETWORK_PARAMS = { | ||
encodingConfig: DEFAULT_ENCODING_CONFIG, | ||
shelleyGenesis: { | ||
@@ -151,0 +147,0 @@ activeSlotsCoeff: 0.05, |
@@ -13,2 +13,3 @@ import { | ||
import { bytesToHex, compareBytes } from "@helios-lang/codec-utils" | ||
import { blake2b } from "@helios-lang/crypto" | ||
import { None, expectSome } from "@helios-lang/type-utils" | ||
@@ -23,14 +24,13 @@ import { | ||
import { NetworkParamsHelper } from "../params/index.js" | ||
import { ScriptPurpose } from "./ScriptPurpose.js" | ||
import { Signature } from "./Signature.js" | ||
import { StakingAddress } from "./StakingAddress.js" | ||
import { TxBody } from "./TxBody.js" | ||
import { TxId } from "./TxId.js" | ||
import { TxInput } from "./TxInput.js" | ||
import { TxMetadata } from "./TxMetadata.js" | ||
import { TxOutput } from "./TxOutput.js" | ||
import { TxOutputId } from "./TxOutputId.js" | ||
import { TxRedeemer } from "./TxRedeemer.js" | ||
import { TxWitnesses } from "./TxWitnesses.js" | ||
import { Signature } from "./Signature.js" | ||
import { TxId } from "./TxId.js" | ||
import { ScriptPurpose } from "./ScriptPurpose.js" | ||
import { TxInput } from "./TxInput.js" | ||
import { StakingAddress } from "./StakingAddress.js" | ||
import { TxRedeemer } from "./TxRedeemer.js" | ||
import { blake2b } from "@helios-lang/crypto" | ||
@@ -40,3 +40,2 @@ /** | ||
* @typedef {import("@helios-lang/uplc").UplcData} UplcData | ||
* @typedef {import("../params/index.js").EncodingConfig} EncodingConfig | ||
* @typedef {import("../params/index.js").NetworkParamsLike} NetworkParamsLike | ||
@@ -106,7 +105,7 @@ */ | ||
* Number of bytes | ||
* @param {EncodingConfig} config | ||
* @param {boolean} forFeeCalculation - see comment in `this.toCbor()` | ||
* @returns {number} | ||
*/ | ||
calcSize(config) { | ||
return this.toCbor(config).length | ||
calcSize(forFeeCalculation = false) { | ||
return this.toCbor(forFeeCalculation).length | ||
} | ||
@@ -118,7 +117,6 @@ | ||
* @param {Signature} signature | ||
* @param {EncodingConfig} config | ||
* @param {boolean} verify Defaults to `true` | ||
* @returns {Tx} | ||
*/ | ||
addSignature(signature, config, verify = true) { | ||
addSignature(signature, verify = true) { | ||
if (!this.valid) { | ||
@@ -129,3 +127,3 @@ throw new Error("invalid Tx") | ||
if (verify) { | ||
signature.verify(this.body.hash(config)) | ||
signature.verify(this.id().bytes) | ||
} | ||
@@ -142,9 +140,8 @@ | ||
* @param {Signature[]} signatures | ||
* @param {EncodingConfig} config | ||
* @param {boolean} verify | ||
* @returns {Tx} | ||
*/ | ||
addSignatures(signatures, config, verify = true) { | ||
addSignatures(signatures, verify = true) { | ||
for (let s of signatures) { | ||
this.addSignature(s, config, verify) | ||
this.addSignature(s, verify) | ||
} | ||
@@ -186,5 +183,3 @@ | ||
const sizeFee = | ||
BigInt(a) + | ||
BigInt(this.calcSize(helper.params.encodingConfig)) * BigInt(b) | ||
const sizeFee = BigInt(a) + BigInt(this.calcSize(true)) * BigInt(b) | ||
@@ -210,6 +205,5 @@ // clean up the dummy signatures | ||
/** | ||
* @param {EncodingConfig} config | ||
* @returns {Object} | ||
*/ | ||
dump(config) { | ||
dump() { | ||
return { | ||
@@ -219,3 +213,3 @@ body: this.body.dump(), | ||
metadata: this.metadata ? this.metadata.dump() : null, | ||
id: this.id(config).toString() | ||
id: this.id().toString() | ||
} | ||
@@ -225,7 +219,6 @@ } | ||
/** | ||
* @param {EncodingConfig} config | ||
* @returns {TxId} | ||
*/ | ||
id(config) { | ||
return new TxId(this.body.hash(config)) | ||
id() { | ||
return new TxId(this.body.hash()) | ||
} | ||
@@ -282,12 +275,25 @@ | ||
* Serialize a transaction. | ||
* @param {EncodingConfig} config | ||
* | ||
* Note: Babbage still follows Alonzo for the Tx size fee. | ||
* According to https://github.com/IntersectMBO/cardano-ledger/blob/cardano-ledger-spec-2023-04-03/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Tx.hs#L316, | ||
* the `isValid` field is omitted when calculating the size of the tx for fee calculation. This is to stay compatible with Mary (?why though, the txFeeFixed could've been changed instead?) | ||
* | ||
* @param {boolean} forFeeCalculation - set this to true if you want to calculate the size needed for the Tx fee, another great little Cardano quirk, pffff. | ||
* @returns {number[]} | ||
*/ | ||
toCbor(config) { | ||
return encodeTuple([ | ||
this.body.toCbor(config), | ||
this.witnesses.toCbor(), | ||
encodeBool(true), | ||
encodeNullOption(this.metadata) | ||
]) | ||
toCbor(forFeeCalculation = false) { | ||
if (forFeeCalculation) { | ||
return encodeTuple([ | ||
this.body.toCbor(), | ||
this.witnesses.toCbor(), | ||
encodeNullOption(this.metadata) | ||
]) | ||
} else { | ||
return encodeTuple([ | ||
this.body.toCbor(), | ||
this.witnesses.toCbor(), | ||
encodeBool(true), | ||
encodeNullOption(this.metadata) | ||
]) | ||
} | ||
} | ||
@@ -590,3 +596,3 @@ | ||
this.witnesses.datums, | ||
this.id(helper.params.encodingConfig) | ||
this.id() | ||
) | ||
@@ -762,3 +768,4 @@ | ||
if (this.calcSize(helper.params.encodingConfig) > helper.maxTxSize) { | ||
if (this.calcSize() > helper.maxTxSize) { | ||
// TODO: should we also use the fee calculation size instead of the real size for this? (i.e. 1 byte difference) | ||
throw new Error("tx too big") | ||
@@ -765,0 +772,0 @@ } |
@@ -23,9 +23,3 @@ import { | ||
} from "@helios-lang/uplc" | ||
import { | ||
DatumHash, | ||
MintingPolicyHash, | ||
PubKeyHash, | ||
ScriptHash, | ||
ValidatorHash | ||
} from "../hashes/index.js" | ||
import { DatumHash, PubKeyHash, ScriptHash } from "../hashes/index.js" | ||
import { Assets, Value } from "../money/index.js" | ||
@@ -41,3 +35,2 @@ import { NetworkParamsHelper } from "../params/index.js" | ||
import { TxRedeemer } from "./TxRedeemer.js" | ||
import { Signature } from "./Signature.js" | ||
import { ScriptPurpose } from "./ScriptPurpose.js" | ||
@@ -50,3 +43,2 @@ | ||
* @typedef {import("../hashes/index.js").Hash} Hash | ||
* @typedef {import("../params/index.js").EncodingConfig} EncodingConfig | ||
* @typedef {import("../params/index.js").NetworkParamsLike} NetworkParamsLike | ||
@@ -463,6 +455,5 @@ */ | ||
/** | ||
* @param {EncodingConfig} config | ||
* @returns {number[]} | ||
*/ | ||
toCbor(config) { | ||
toCbor() { | ||
/** | ||
@@ -473,10 +464,4 @@ * @type {Map<number, number[]>} | ||
m.set( | ||
0, | ||
encodeDefList(this.inputs.map((input) => input.toCbor(config))) | ||
) | ||
m.set( | ||
1, | ||
encodeDefList(this.outputs.map((output) => output.toCbor(config))) | ||
) | ||
m.set(0, encodeDefList(this.inputs)) | ||
m.set(1, encodeDefList(this.outputs)) | ||
m.set(2, encodeInt(this.fee)) | ||
@@ -521,6 +506,3 @@ | ||
if (this.collateral.length != 0) { | ||
m.set( | ||
13, | ||
encodeDefList(this.collateral.map((c) => c.toCbor(config))) | ||
) | ||
m.set(13, encodeDefList(this.collateral)) | ||
} | ||
@@ -536,3 +518,3 @@ | ||
if (isSome(this.collateralReturn)) { | ||
m.set(16, this.collateralReturn.toCbor(config)) | ||
m.set(16, this.collateralReturn.toCbor()) | ||
} | ||
@@ -545,6 +527,3 @@ | ||
if (this.refInputs.length != 0) { | ||
m.set( | ||
18, | ||
encodeDefList(this.refInputs.map((r) => r.toCbor(config))) | ||
) | ||
m.set(18, encodeDefList(this.refInputs)) | ||
} | ||
@@ -623,8 +602,7 @@ | ||
/** | ||
* @param {EncodingConfig} config | ||
* @returns {number[]} | ||
*/ | ||
hash(config) { | ||
return blake2b(this.toCbor(config)) | ||
hash() { | ||
return blake2b(this.toCbor()) | ||
} | ||
} |
@@ -20,3 +20,2 @@ import { | ||
* @typedef {import("@helios-lang/uplc").UplcData} UplcData | ||
* @typedef {import("../params/index.js").EncodingConfig} EncodingConfig | ||
* @typedef {import("./TxOutputDatum.js").TxOutputDatumKind} TxOutputDatumKind | ||
@@ -249,9 +248,8 @@ * @typedef {import("./TxOutputId.js").TxOutputIdLike} TxOutputIdLike | ||
* full = true is however useful for complete deserialization of the TxInput (and then eg. using it in off-chain applications) | ||
* @param {EncodingConfig} config | ||
* @param {boolean} full | ||
* @returns {number[]} | ||
*/ | ||
toCbor(config, full = false) { | ||
toCbor(full = false) { | ||
if (full) { | ||
return encodeTuple([this.id.toCbor(), this.output.toCbor(config)]) | ||
return encodeTuple([this.id.toCbor(), this.output.toCbor()]) | ||
} else { | ||
@@ -258,0 +256,0 @@ return this.id.toCbor() |
@@ -34,9 +34,22 @@ import { | ||
* @typedef {import("../money/index.js").ValueLike} ValueLike | ||
* @typedef {import("../params/index.js").EncodingConfig} EncodingConfig | ||
* @typedef {import("../params/index.js").NetworkParamsLike} NetworkParamsLike | ||
* @typedef {import("./Address.js").AddressLike} AddressLike | ||
* @typedef {import("./TxOutputDatum.js").TxOutputDatumKind} TxOutputDatumKind | ||
/** | ||
* Sadly the cbor encoding can be done in a variety of ways, for which a config must be passed around `toCbor()` calls | ||
* - strictBabbage: if true -> slighly more verbose TxOutput encoding | ||
* @typedef {{ | ||
* strictBabbage?: boolean | ||
* }} TxOutputEncodingConfig | ||
*/ | ||
/** | ||
* @type {TxOutputEncodingConfig} | ||
*/ | ||
export const DEFAULT_TX_OUTPUT_ENCODING_CONFIG = { | ||
strictBabbage: true | ||
} | ||
/** | ||
* Represents a transaction output that is used when building a transaction. | ||
@@ -71,2 +84,7 @@ * @template [CSpending=unknown] | ||
/** | ||
* @type {TxOutputEncodingConfig} | ||
*/ | ||
encodingConfig | ||
/** | ||
* Constructs a `TxOutput` instance using an `Address`, a `Value`, an optional `Datum`, and optional `UplcProgram` reference script. | ||
@@ -78,3 +96,9 @@ * @param {Address<CSpending, CStaking> | AddressLike} address | ||
*/ | ||
constructor(address, value, datum = None, refScript = None) { | ||
constructor( | ||
address, | ||
value, | ||
datum = None, | ||
refScript = None, | ||
encodingConfig = DEFAULT_TX_OUTPUT_ENCODING_CONFIG | ||
) { | ||
this.address = | ||
@@ -85,2 +109,3 @@ address instanceof Address ? address : Address.new(address) | ||
this.refScript = refScript | ||
this.encodingConfig = encodingConfig | ||
} | ||
@@ -143,3 +168,5 @@ | ||
return new TxOutput(address, value, datum, refScript) | ||
return new TxOutput(address, value, datum, refScript, { | ||
strictBabbage: true | ||
}) | ||
} else if (isTuple(bytes)) { | ||
@@ -165,5 +192,10 @@ const [address, value, datumHash] = decodeTuple( | ||
* @param {UplcData} data | ||
* @param {TxOutputEncodingConfig} encodingConfig | ||
* @returns {TxOutput} | ||
*/ | ||
static fromUplcData(isMainnet, data) { | ||
static fromUplcData( | ||
isMainnet, | ||
data, | ||
encodingConfig = DEFAULT_TX_OUTPUT_ENCODING_CONFIG | ||
) { | ||
ConstrData.assert(data, 0, 4) | ||
@@ -174,4 +206,5 @@ | ||
Value.fromUplcData(data.fields[1]), | ||
TxOutputDatum.fromUplcData(data.fields[2]) | ||
// The refScript hash isn't very useful | ||
TxOutputDatum.fromUplcData(data.fields[2]), | ||
None, // The refScript hash isn't very useful | ||
encodingConfig | ||
) | ||
@@ -203,3 +236,4 @@ } | ||
this.datum?.copy(), | ||
this.refScript | ||
this.refScript, | ||
this.encodingConfig | ||
) | ||
@@ -223,10 +257,9 @@ } | ||
/** | ||
* @param {EncodingConfig} config | ||
* @returns {number[]} | ||
*/ | ||
toCbor(config) { | ||
toCbor() { | ||
if ( | ||
(!this.datum || this.datum.isHash()) && | ||
!this.refScript && | ||
!config.strictBabbage | ||
!this.encodingConfig.strictBabbage | ||
) { | ||
@@ -300,4 +333,3 @@ // this is needed to match eternl wallet (de)serialization (annoyingly eternl deserializes the tx and then signs its own serialization) | ||
const correctedSize = | ||
this.toCbor(helper.params.encodingConfig).length + 160 // 160 accounts for some database overhead? | ||
const correctedSize = this.toCbor().length + 160 // 160 accounts for some database overhead? | ||
@@ -304,0 +336,0 @@ return BigInt(correctedSize) * BigInt(lovelacePerByte) |
@@ -1,7 +0,5 @@ | ||
export { DEFAULT_ENCODING_CONFIG } from "./EncodingConfig.js"; | ||
export { DEFAULT_NETWORK_PARAMS } from "./NetworkParams.js"; | ||
export { NetworkParamsHelper } from "./NetworkParamsHelper.js"; | ||
export type EncodingConfig = import("./EncodingConfig.js").EncodingConfig; | ||
export type NetworkParams = import("./NetworkParams.js").NetworkParams; | ||
export type NetworkParamsLike = import("./NetworkParamsHelper.js").NetworkParamsLike; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -7,3 +7,2 @@ /** | ||
export type CostModelParamsV2 = import("@helios-lang/uplc").CostModelParamsV2; | ||
export type EncodingConfig = import("./EncodingConfig.js").EncodingConfig; | ||
/** | ||
@@ -19,3 +18,2 @@ * The raw JSON can be downloaded from the following CDN locations: | ||
export type NetworkParams = { | ||
encodingConfig: EncodingConfig; | ||
shelleyGenesis: { | ||
@@ -22,0 +20,0 @@ activeSlotsCoeff: number; |
@@ -11,3 +11,2 @@ /** | ||
* @typedef {import("@helios-lang/uplc").UplcData} UplcData | ||
* @typedef {import("../params/index.js").EncodingConfig} EncodingConfig | ||
* @typedef {import("../params/index.js").NetworkParamsLike} NetworkParamsLike | ||
@@ -56,6 +55,6 @@ */ | ||
* Number of bytes | ||
* @param {EncodingConfig} config | ||
* @param {boolean} forFeeCalculation - see comment in `this.toCbor()` | ||
* @returns {number} | ||
*/ | ||
calcSize(config: EncodingConfig): number; | ||
calcSize(forFeeCalculation?: boolean): number; | ||
/** | ||
@@ -65,7 +64,6 @@ * Adds a signature created by a wallet. Only available after the transaction has been finalized. | ||
* @param {Signature} signature | ||
* @param {EncodingConfig} config | ||
* @param {boolean} verify Defaults to `true` | ||
* @returns {Tx} | ||
*/ | ||
addSignature(signature: Signature, config: EncodingConfig, verify?: boolean): Tx; | ||
addSignature(signature: Signature, verify?: boolean): Tx; | ||
/** | ||
@@ -75,7 +73,6 @@ * Adds multiple signatures at once. Only available after the transaction has been finalized. | ||
* @param {Signature[]} signatures | ||
* @param {EncodingConfig} config | ||
* @param {boolean} verify | ||
* @returns {Tx} | ||
*/ | ||
addSignatures(signatures: Signature[], config: EncodingConfig, verify?: boolean): Tx; | ||
addSignatures(signatures: Signature[], verify?: boolean): Tx; | ||
/** | ||
@@ -98,11 +95,9 @@ * @param {NetworkParamsHelper} networkParams | ||
/** | ||
* @param {EncodingConfig} config | ||
* @returns {Object} | ||
*/ | ||
dump(config: EncodingConfig): any; | ||
dump(): any; | ||
/** | ||
* @param {EncodingConfig} config | ||
* @returns {TxId} | ||
*/ | ||
id(config: EncodingConfig): TxId; | ||
id(): TxId; | ||
/** | ||
@@ -130,6 +125,11 @@ * @returns {boolean} | ||
* Serialize a transaction. | ||
* @param {EncodingConfig} config | ||
* | ||
* Note: Babbage still follows Alonzo for the Tx size fee. | ||
* According to https://github.com/IntersectMBO/cardano-ledger/blob/cardano-ledger-spec-2023-04-03/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Tx.hs#L316, | ||
* the `isValid` field is omitted when calculating the size of the tx for fee calculation. This is to stay compatible with Mary (?why though, the txFeeFixed could've been changed instead?) | ||
* | ||
* @param {boolean} forFeeCalculation - set this to true if you want to calculate the size needed for the Tx fee, another great little Cardano quirk, pffff. | ||
* @returns {number[]} | ||
*/ | ||
toCbor(config: EncodingConfig): number[]; | ||
toCbor(forFeeCalculation?: boolean): number[]; | ||
/** | ||
@@ -259,3 +259,2 @@ * Throws an error if the tx isn't valid | ||
export type UplcData = import("@helios-lang/uplc").UplcData; | ||
export type EncodingConfig = import("../params/index.js").EncodingConfig; | ||
export type NetworkParamsLike = import("../params/index.js").NetworkParamsLike; | ||
@@ -262,0 +261,0 @@ import { TxRedeemer } from "./TxRedeemer.js"; |
@@ -6,3 +6,2 @@ /** | ||
* @typedef {import("../hashes/index.js").Hash} Hash | ||
* @typedef {import("../params/index.js").EncodingConfig} EncodingConfig | ||
* @typedef {import("../params/index.js").NetworkParamsLike} NetworkParamsLike | ||
@@ -179,6 +178,5 @@ */ | ||
/** | ||
* @param {EncodingConfig} config | ||
* @returns {number[]} | ||
*/ | ||
toCbor(config: EncodingConfig): number[]; | ||
toCbor(): number[]; | ||
/** | ||
@@ -198,6 +196,5 @@ * Returns the on-chain Tx representation | ||
/** | ||
* @param {EncodingConfig} config | ||
* @returns {number[]} | ||
*/ | ||
hash(config: EncodingConfig): number[]; | ||
hash(): number[]; | ||
} | ||
@@ -208,3 +205,2 @@ export type ByteArrayLike = import("@helios-lang/codec-utils").ByteArrayLike; | ||
export type Hash = import("../hashes/index.js").Hash; | ||
export type EncodingConfig = import("../params/index.js").EncodingConfig; | ||
export type NetworkParamsLike = import("../params/index.js").NetworkParamsLike; | ||
@@ -211,0 +207,0 @@ export type TxBodyProps = { |
/** | ||
* @typedef {import("@helios-lang/codec-utils").ByteArrayLike} ByteArrayLike | ||
* @typedef {import("@helios-lang/uplc").UplcData} UplcData | ||
* @typedef {import("../params/index.js").EncodingConfig} EncodingConfig | ||
* @typedef {import("./TxOutputDatum.js").TxOutputDatumKind} TxOutputDatumKind | ||
@@ -121,7 +120,6 @@ * @typedef {import("./TxOutputId.js").TxOutputIdLike} TxOutputIdLike | ||
* full = true is however useful for complete deserialization of the TxInput (and then eg. using it in off-chain applications) | ||
* @param {EncodingConfig} config | ||
* @param {boolean} full | ||
* @returns {number[]} | ||
*/ | ||
toCbor(config: EncodingConfig, full?: boolean): number[]; | ||
toCbor(full?: boolean): number[]; | ||
/** | ||
@@ -136,3 +134,2 @@ * full representation (as used in ScriptContext) | ||
export type UplcData = import("@helios-lang/uplc").UplcData; | ||
export type EncodingConfig = import("../params/index.js").EncodingConfig; | ||
export type TxOutputDatumKind = import("./TxOutputDatum.js").TxOutputDatumKind; | ||
@@ -139,0 +136,0 @@ export type TxOutputIdLike = import("./TxOutputId.js").TxOutputIdLike; |
@@ -5,8 +5,18 @@ /** | ||
* @typedef {import("../money/index.js").ValueLike} ValueLike | ||
* @typedef {import("../params/index.js").EncodingConfig} EncodingConfig | ||
* @typedef {import("../params/index.js").NetworkParamsLike} NetworkParamsLike | ||
* @typedef {import("./Address.js").AddressLike} AddressLike | ||
* @typedef {import("./TxOutputDatum.js").TxOutputDatumKind} TxOutputDatumKind | ||
/** | ||
* Sadly the cbor encoding can be done in a variety of ways, for which a config must be passed around `toCbor()` calls | ||
* - strictBabbage: if true -> slighly more verbose TxOutput encoding | ||
* @typedef {{ | ||
* strictBabbage?: boolean | ||
* }} TxOutputEncodingConfig | ||
*/ | ||
/** | ||
* @type {TxOutputEncodingConfig} | ||
*/ | ||
export const DEFAULT_TX_OUTPUT_ENCODING_CONFIG: TxOutputEncodingConfig; | ||
/** | ||
* Represents a transaction output that is used when building a transaction. | ||
@@ -25,5 +35,6 @@ * @template [CSpending=unknown] | ||
* @param {UplcData} data | ||
* @param {TxOutputEncodingConfig} encodingConfig | ||
* @returns {TxOutput} | ||
*/ | ||
static fromUplcData(isMainnet: boolean, data: UplcData): TxOutput; | ||
static fromUplcData(isMainnet: boolean, data: UplcData, encodingConfig?: TxOutputEncodingConfig): TxOutput; | ||
/** | ||
@@ -36,3 +47,3 @@ * Constructs a `TxOutput` instance using an `Address`, a `Value`, an optional `Datum`, and optional `UplcProgram` reference script. | ||
*/ | ||
constructor(address: Address<CSpending, CStaking> | AddressLike, value: ValueLike, datum?: Option<TxOutputDatum>, refScript?: Option<UplcProgramV1 | UplcProgramV2>); | ||
constructor(address: Address<CSpending, CStaking> | AddressLike, value: ValueLike, datum?: Option<TxOutputDatum>, refScript?: Option<UplcProgramV1 | UplcProgramV2>, encodingConfig?: TxOutputEncodingConfig); | ||
/** | ||
@@ -58,2 +69,6 @@ * Mutation is useful when correcting the quantity of lovelace in a utxo | ||
/** | ||
* @type {TxOutputEncodingConfig} | ||
*/ | ||
encodingConfig: TxOutputEncodingConfig; | ||
/** | ||
* @type {CSpending} | ||
@@ -76,6 +91,5 @@ */ | ||
/** | ||
* @param {EncodingConfig} config | ||
* @returns {number[]} | ||
*/ | ||
toCbor(config: EncodingConfig): number[]; | ||
toCbor(): number[]; | ||
/** | ||
@@ -104,6 +118,13 @@ * @returns {ConstrData} | ||
export type ValueLike = import("../money/index.js").ValueLike; | ||
export type EncodingConfig = import("../params/index.js").EncodingConfig; | ||
export type NetworkParamsLike = import("../params/index.js").NetworkParamsLike; | ||
export type AddressLike = import("./Address.js").AddressLike; | ||
/** | ||
* /** | ||
* Sadly the cbor encoding can be done in a variety of ways, for which a config must be passed around `toCbor()` calls | ||
* - strictBabbage: if true -> slighly more verbose TxOutput encoding | ||
*/ | ||
export type TxOutputDatumKind = import("./TxOutputDatum.js").TxOutputDatumKind; | ||
export type TxOutputEncodingConfig = { | ||
strictBabbage?: boolean; | ||
}; | ||
import { Address } from "./Address.js"; | ||
@@ -110,0 +131,0 @@ import { Value } from "../money/index.js"; |
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
645931
332
18458