export type Address = ByronAddress | ShelleyAddress; /** * Byron-era address */ export type ByronAddress = { kind: "Address"; era: "Byron"; bytes: number[]; checksum: bigint; isEqual: (other: Address) => boolean; toBase58: () => string; toCbor: () => number[]; /** * Throws an error. Simplifies type-compatibility with ShelleyAddress, so you can simply call `Address.toUplcData()` */ toUplcData: () => UplcData; /** * Alias for toBase58() */ toString: () => string; }; /** * Wrapper for Cardano (post-Byron) address bytes. A `ShelleyAddress` consists of three parts internally: * - Header (1 byte, see [CIP 19](https://cips.cardano.org/cips/cip19/)) * - Witness hash (28 bytes that represent the `PubKeyHash` or `ValidatorHash`) * - Optional staking credential (0 or 28 bytes) */ export type ShelleyAddress = { kind: "Address"; era: "Shelley"; mainnet: boolean; bech32Prefix: "addr" | "addr_test"; spendingCredential: SC; stakingCredential: StakingCredential | undefined; bytes: number[]; copy: () => ShelleyAddress; dump: () => object; isEqual: (other: Address) => boolean; toBech32: () => string; toCbor: () => number[]; toHex: () => string; /** * Alias for toBech32() */ toString: () => string; toUplcData: () => UplcData; }; export type ShelleyAddressLike = ShelleyAddress | BytesLike; export type SpendingCredential = PubKeyHash | ValidatorHash; export type StakingCredential = PubKeyHash | StakingValidatorHash; /** * Wrapper for Cardano stake address bytes. An StakingAddress consists of two parts internally: * - Header (1 byte, see CIP 8) * - Staking witness hash (28 bytes that represent the `PubKeyHash` or `StakingValidatorHash`) * Staking addresses are used to query the assets held by given staking credentials. */ export type StakingAddress = { kind: "StakingAddress"; mainnet: boolean; stakingCredential: SC; bytes: number[]; bech32Prefix: "stake" | "stake_test"; isEqual: (other: StakingAddress) => boolean; toBech32: () => string; toCbor: () => number[]; toHex: () => string; /** * Alias for toBech32() */ toString: () => string; toUplcData: () => ConstrData; }; export type StakingAddressLike = StakingAddress | BytesLike | ShelleyAddress | StakingCredential | PubKeyHash | ValidatorHash; export type AssetClass = { kind: "AssetClass"; mph: MintingPolicyHash; tokenName: number[]; isEqual: (other: AssetClass) => boolean; isGreaterThan: (other: AssetClass) => boolean; toCbor: () => number[]; toFingerprint: () => string; toString: () => string; toUplcData: () => ConstrData; }; export type AssetClassLike = string | [MintingPolicyHashLike, BytesLike] | { mph: MintingPolicyHashLike; tokenName: BytesLike; }; /** * Represents a list of non-Ada tokens. */ export type Assets = { kind: "Assets"; assets: [MintingPolicyHash, [number[], bigint][]][]; assetClasses: AssetClass[]; add: (other: Assets) => Assets; /** * Mutates `this` */ addAssetClassQuantity: (assetClass: AssetClassLike, qty: IntLike) => void; /** * Mutates `this` */ addPolicyTokenQuantity: (mph: MintingPolicyHashLike, tokenName: BytesLike, qty: IntLike) => void; /** * Mutates 'this'. * Throws error if mph is already contained in 'this'. */ addPolicyTokens: (mph: MintingPolicyHashLike, tokens: [BytesLike, IntLike][]) => void; /** * Throws an error if any contained quantity <= 0n */ assertAllPositive: () => void; assertSorted: () => void; /** * Returns the number of unique tokens */ countTokens: () => number; copy: () => Assets; dump: () => object; /** * Returns 0n if not found */ getAssetClassQuantity: (assetClass: AssetClassLike) => bigint; /** * Returns 0n if not found */ getPolicyTokenQuantity: (mph: MintingPolicyHashLike, tokenName: BytesLike) => bigint; /** * Returns a list of all the minting policies. */ getPolicies: () => MintingPolicyHash[]; /** * Returns an empty list if the policy isn't found */ getPolicyTokens: (policy: MintingPolicyHashLike) => [number[], bigint][]; /** * Returns an empty list if the policy isn't found */ getPolicyTokenNames: (policy: MintingPolicyHashLike) => number[][]; hasAssetClass: (assetClass: AssetClassLike) => boolean; hasPolicyToken: (mph: MintingPolicyHashLike, tokenName: BytesLike) => boolean; isAllPositive: () => boolean; isEqual: (other: Assets) => boolean; isGreaterOrEqual: (other: Assets) => boolean; isGreaterThan: (other: Assets) => boolean; isZero: () => boolean; multiply: (scalar: IntLike) => Assets; /** * Removes zeroes and merges duplicates. * In-place algorithm. * Keeps the same order as much as possible. */ normalize: () => void; /** * Mutates `this` */ removeZeroes: () => void; /** * Makes sure minting policies are in correct order, and for each minting policy make sure the tokens are in the correct order * Mutates `this` * * **`shortestFirst`** * * If `shortestFirst` is `true`: * tokens are sorted in shortest-first order. * * The shortest-first order (also called "canonical order") is required by some hardware wallets when calculating the tx hash. * But the lexicographical order (i.e. alphabetical order independent of length) is used when evaluating a validator script. */ sort: (shortestFirst?: boolean) => void; subtract: (other: Assets) => Assets; toCbor: () => number[]; /** * Used when generating redeemers, datums or script contexts for running programs. * * **`isInScriptContext`** * * If `isInScriptContext` is `true`: * for each minting policy, tokens are sorted in strict lexicographical order instead of shortest-first order. * * The shortest-first order (also called "canonical order") is required by some hardware wallets when calculating the tx hash. * But the lexicographical order (i.e. alphabetical order independent of length) is used when evaluating a validator script. */ toUplcData: (isInScriptContext?: boolean) => MapData; }; export type TokensLike = [BytesLike, IntLike][] | Record; export type AssetsLike = Assets | [MintingPolicyHashLike, TokensLike][] | [AssetClassLike, IntLike][] | Record; /** * TODO: which class implements this? */ export type NativeContext = { isAfter: (slot: number) => boolean; isBefore: (slot: number) => boolean; isSignedBy: (hash: PubKeyHash) => boolean; }; export type NativeScriptJsonSafe = (SigScriptJsonSafe | AllScriptJsonSafe | AnyScriptJsonSafe | AtLeastScriptJsonSafe | AfterScriptJsonSafe | BeforeScriptJsonSafe); export type SigScriptJsonSafe = { type: "sig"; keyHash: string; }; export type AllScriptJsonSafe = { type: "all"; scripts: NativeScriptJsonSafe[]; }; export type AnyScriptJsonSafe = { type: "any"; scripts: NativeScriptJsonSafe[]; }; export type AtLeastScriptJsonSafe = { type: "atLeast"; required: number; scripts: NativeScriptJsonSafe[]; }; export type AfterScriptJsonSafe = { type: "after"; slot: number; }; export type BeforeScriptJsonSafe = { type: "before"; slot: number; }; export type NativeScript = (SigScript | AllScript | AnyScript | AtLeastScript | AfterScript | BeforeScript); /** * A NativeScript that validates a transaction if it signed by a given PubKeyHash */ export type SigScript = { kind: "Sig"; hash: PubKeyHash; eval: (ctx: NativeContext) => boolean; toCbor: () => number[]; toJsonSafe: () => SigScriptJsonSafe; }; /** * A NativeScript that validates a transaction if all child NativeScripts validate it */ export type AllScript = { kind: "All"; scripts: NativeScript[]; eval: (ctx: NativeContext) => boolean; toCbor: () => number[]; toJsonSafe: () => AllScriptJsonSafe; }; /** * A NativeScript that validates a transaction if any child NativeScript validates it */ export type AnyScript = { kind: "Any"; scripts: NativeScript[]; eval: (ctx: NativeContext) => boolean; toCbor: () => number[]; toJsonSafe: () => AnyScriptJsonSafe; }; /** * A NativeScript that validates a transaction if at least nRequired child NativeScripts validate it */ export type AtLeastScript = { kind: "AtLeast"; nRequired: number; scripts: NativeScript[]; eval: (ctx: NativeContext) => boolean; toCbor: () => number[]; toJsonSafe: () => AtLeastScriptJsonSafe; }; /** * A NativeScript that validates a transaction if the current time range validity interval is after the given slot */ export type AfterScript = { kind: "After"; slot: number; eval: (ctx: NativeContext) => boolean; toCbor: () => number[]; toJsonSafe: () => AfterScriptJsonSafe; }; /** * A NativeScript that validates a transaction if the current time range validity interval is before the given slot */ export type BeforeScript = { kind: "Before"; slot: number; eval: (ctx: NativeContext) => boolean; toCbor: () => number[]; toJsonSafe: () => BeforeScriptJsonSafe; }; /** * Represents a blake2b-256 (32 bytes) hash of datum data. */ export type DatumHash = { kind: "DatumHash"; bytes: number[]; /** * Alias for toHex() */ dump: () => string; isEqual: (other: DatumHash) => boolean; toCbor: () => number[]; toHex: () => string; /** * Alias for toHex() */ toString: () => string; toUplcData: () => ByteArrayData; }; export type DatumHashLike = DatumHash | BytesLike; /** * Represents a blake2b-224 (28 bytes) hash of a PubKey * **Note**: A `PubKeyHash` can also be used as the second part of a payment `Address`, or to construct a `StakeAddress`. */ export type PubKeyHash = { kind: "PubKeyHash"; bytes: number[]; dump: () => string; isEqual: (other: PubKeyHash) => boolean; toCbor: () => number[]; toHex: () => string; /** * Alias for toHex() */ toString: () => string; toUplcData: () => ByteArrayData; }; export type PubKeyHashLike = PubKeyHash | BytesLike; export type ShelleyGenesisParams = { activeSlotsCoeff: number; protocolParams: { protocolVersion: { minor: number; major: number; }; decentralisationParam: number; eMax: number; extraEntropy: { tag: string; }; maxTxSize: number; maxBlockBodySize: number; maxBlockHeaderSize: number; minFeeA: number; minFeeB: number; minUTxOValue: number; poolDeposit: number; minPoolCost: number; keyDeposit: number; nOpt: number; rho: number; tau: number; a0: number; }; genDelegs: { [key: string]: { delegate: string; vrf: string; }; }; updateQuorum: number; networkId: string; initialFunds: {}; maxLovelaceSupply: number; networkMagic: number; epochLength: number; systemStart: string; slotsPerKESPeriod: number; slotLength: number; maxKESEvolutions: number; securityParam: number; }; export type ScriptHash = MintingPolicyHash | StakingValidatorHash | ValidatorHash; /** * Represents a blake2b-224 hash of a minting policy script. * * **Note**: to calculate this hash the script is first encoded as a CBOR byte-array and then prepended by a script version byte. * * `C` is some optional context: * - `null`: unwitnessed or witnessed by NativeScript * - `unknown`: witnessed or unwitnessed (default) * - `{program: ..., redeemer: ...}`: witnessed by UplcProgram */ export type MintingPolicyHash = { bytes: number[]; context: C; kind: "MintingPolicyHash"; isEqual: (other: MintingPolicyHash) => boolean; toCbor: () => number[]; toHex: () => string; /** * Alias for toHex() */ toString: () => string; toUplcData: () => ByteArrayData; }; export type MintingPolicyHashLike = MintingPolicyHash | BytesLike; /** * Represents a blake2b-224 (28 bytes) hash of a staking validator script (first encoded as a CBOR byte-array and prepended by a script version byte). */ export type StakingValidatorHash = { bytes: number[]; context: C; kind: "StakingValidatorHash"; isEqual: (other: StakingValidatorHash) => boolean; toCbor: () => number[]; toHex: () => string; /** * Alias for toHex() */ toString: () => string; toUplcData: () => ByteArrayData; }; export type StakingValidatorHashLike = StakingValidatorHash | BytesLike; /** * Represents a blake2b-224 (28 bytes) hash of a spending validator script (first encoded as a CBOR byte-array and prepended by a script version byte). */ export type ValidatorHash = { bytes: number[]; context: C; kind: "ValidatorHash"; isEqual: (other: ValidatorHash) => boolean; toCbor: () => number[]; toHex: () => string; /** * Alias for toHex() */ toString: () => string; toUplcData: () => ByteArrayData; }; export type ValidatorHashLike = ValidatorHash | BytesLike; /** * The raw JSON can be downloaded from the following CDN locations: * * - Preview: [https://network-status.helios-lang.io/preview/config](https://network-status.helios-lang.io/preview/config) * - Preprod: [https://network-status.helios-lang.io/preprod/config](https://network-status.helios-lang.io/preprod/config) * - Mainnet: [https://network-status.helios-lang.io/mainnet/config](https://network-status.helios-lang.io/mainnet/config) * * These JSONs are updated every 15 minutes. * * Only include the minimum fields needed. flattened so it can be extended more easily * * NetworkParams are a summary of the Era-specific params, relevant for tx building and validation * * Optionally, NetworkParams returned by a private node can specify a `collateralUTXO` to use (# format). Any transaction submitted through that same node will then add the signature necessary to spend the collateral UTXO. * This allows the collateral UTXO managed to be done in a central place (i.e. the node). */ export type NetworkParams = { txFeeFixed: number; txFeePerByte: number; exMemFeePerUnit: number; exCpuFeePerUnit: number; utxoDepositPerByte: number; refScriptsFeePerByte: number; collateralPercentage: number; maxCollateralInputs: number; maxTxExMem: number; maxTxExCpu: number; maxTxSize: number; secondsPerSlot: number; stakeAddrDeposit: number; refTipSlot: number; refTipTime: number; costModelParamsV1: number[]; costModelParamsV2: number[]; costModelParamsV3: number[]; collateralUTXO?: string; }; export type CommonAlonzoBabbageParams = { collateralPercentage: number; maxCollateralInputs: number; maxValueSize: number; }; export type CommonBabbageConwayParams = CommonAlonzoBabbageParams & { executionUnitPrices: { priceMemory: number; priceSteps: number; }; maxBlockBodySize: number; maxBlockExecutionUnits: { memory: number; steps: number; }; maxBlockHeaderSize: number; maxTxExecutionUnits: { memory: number; steps: number; }; maxTxSize: number; minPoolCost: number; monetaryExpansion: number; poolPledgeInfluence: number; poolRetireMaxEpoch: number; protocolVersion: { major: number; minor: number; }; stakeAddressDeposit: number; stakePoolDeposit: number; stakePoolTargetNum: number; treasuryCut: number; txFeeFixed: number; txFeePerByte: number; utxoCostPerByte: number; }; export type BabbageParams = CommonBabbageConwayParams & { costModels: { PlutusV1: number[]; PlutusV2: number[]; }; }; export type ConwayGenesisParams = { poolVotingThresholds: { committeeNormal: number; committeeNoConfidence: number; hardForkInitiation: number; motionNoConfidence: number; ppSecurityGroup: number; }; dRepVotingThresholds: { motionNoConfidence: number; committeeNormal: number; committeeNoConfidence: number; updateToConstitution: number; hardForkInitiation: number; ppNetworkGroup: number; ppEconomicGroup: number; ppTechnicalGroup: number; ppGovGroup: number; treasuryWithdrawal: number; }; committeeMinSize: number; committeeMaxTermLength: number; govActionLifetime: number; govActionDeposit: number; dRepDeposit: number; dRepActivity: number; minFeeRefScriptCostPerByte: number; plutusV3CostModel: number[]; constitution: { anchor: { dataHash: string; url: string; }; script: string; }; committee: { members: Record; threshold: { numerator: number; denominator: number; }; }; }; export type ConwayParams = CommonBabbageConwayParams & { committeeMaxTermLength: number; committeeMinSize: number; costModels: { PlutusV1: number[]; PlutusV2: number[]; PlutusV3: number[]; }; dRepActivity: number; dRepDeposit: number; dRepVotingThresholds: { committeeNoConfidence: number; committeeNormal: number; hardForkInitiation: number; motionNoConfidence: number; ppEconomicGroup: number; ppGovGroup: number; ppNetworkGroup: number; ppTechnicalGroup: number; treasuryWithdrawal: number; updateToConstitution: number; }; govActionDeposit: number; govActionLifetime: number; minFeeRefScriptCostPerByte: number; poolVotingThresholds: { committeeNoConfidence: number; committeeNormal: number; hardForkInitiation: number; motionNoConfidence: number; ppSecurityGroup: number; }; }; export type NetworkParamsHelper = { params: T; costModelParamsV1: number[]; costModelParamsV2: number[]; costModelParamsV3: number[]; txFeeParams: [number, number]; exFeeParams: [number, number]; refScriptsFeePerByte: number; lovelacePerUtxoByte: number; minCollateralPct: number; maxCollateralInputs: number; maxTxExecutionBudget: [number, number]; /** * Tx balancing picks additional inputs by starting from maxTxFee. * This is done because the order of the inputs can have a huge impact on the tx fee, so the order must be known before balancing. * If there aren't enough inputs to cover the maxTxFee and the min deposits of newly created UTxOs, the balancing will fail. * TODO: make this private once we are in Conway era, because this should always take into account the cost of ref scripts */ maxTxFee: bigint; maxTxSize: number; secondsPerSlot: number; stakeAddressDeposit: bigint; latestTipSlot: number; latestTipTime: number; defaultCollateralUTXO: TxInput | undefined; slotToTime: (slot: IntLike) => number; timeToSlot: (time: IntLike) => number; calcMaxConwayTxFee: (refScriptsSize: bigint) => bigint; }; /** * Implemented in */ export type UplcDataConverter = { toUplcData: (x: TPermissive | UplcData) => UplcData; fromUplcData: (d: UplcData) => TStrict; }; export type TxId = { kind: "TxId"; bytes: number[]; isEqual: (other: TxId) => boolean; toCbor: () => number[]; toHex: () => string; /** * Alias for toHex */ toString: () => string; toUplcData: () => ConstrData; toUplcDataV3: () => UplcData; }; export type TxIdLike = TxId | BytesLike; export type TxOutputId = { kind: "TxOutputId"; txId: TxId; index: number; isEqual: (other: TxOutputId) => boolean; toCbor: () => number[]; /** * Encoded as `#` */ toString: () => string; /** * Encoded as `` (without the `#` symbol) */ toURLString: () => string; toUplcData: () => ConstrData; toUplcDataV3: () => ConstrData; }; export type TxOutputIdLike = TxOutputId | string | [TxId | BytesLike, IntLike] | { txId: TxId | BytesLike; utxoIdx: IntLike; }; export type PoolMetadata = { kind: "PoolMetadata"; url: string; toCbor: () => number[]; }; export type SingleAddrPoolRelay = { kind: "SingleAddrPoolRelay"; port?: number | undefined; ipv4?: number[] | undefined; ipv6?: number[] | undefined; toCbor: () => number[]; }; export type SingleNamePoolRelay = { kind: "SingleNamePoolRelay"; port?: number | undefined; record: string; toCbor: () => number[]; }; export type MultiNamePoolRelay = { kind: "MultiNamePoolRelay"; record: string; toCbor: () => number[]; }; export type PoolRelay = SingleAddrPoolRelay | SingleNamePoolRelay | MultiNamePoolRelay; export type PoolParameters = { id: PubKeyHash; vrf: PubKeyHash; pledge: bigint; margin: number; rewardAccount: StakingAddress; owners: PubKeyHash[]; relays: PoolRelay[]; metadata: PoolMetadata | undefined; toCbor: () => number[]; }; export type RegistrationDCert = { kind: "RegistrationDCert"; credential: StakingCredential; tag: 0; dump: () => object; toCbor: () => number[]; toUplcData: () => ConstrData; }; export type DeregistrationDCert = { kind: "DeregistrationDCert"; credential: StakingCredential; tag: 1; dump: () => object; toCbor: () => number[]; toUplcData: () => ConstrData; }; export type DelegationDCert = { kind: "DelegationDCert"; credential: StakingCredential; poolId: PubKeyHash; tag: 2; dump: () => object; toCbor: () => number[]; toUplcData: () => ConstrData; }; export type RegisterPoolDCert = { kind: "RegisterPoolDCert"; parameters: PoolParameters; tag: 3; dump: () => object; toCbor: () => number[]; toUplcData: () => ConstrData; }; export type RetirePoolDCert = { kind: "RetirePoolDCert"; poolId: PubKeyHash; epoch: number; tag: 4; dump: () => object; toCbor: () => number[]; toUplcData: () => ConstrData; }; export type DCert = RegistrationDCert | DeregistrationDCert | DelegationDCert | RegisterPoolDCert | RetirePoolDCert; export type MintingPurpose = { kind: "MintingPurpose"; policy: MintingPolicyHash; toUplcData: () => ConstrData; }; export type SpendingPurpose = { kind: "SpendingPurpose"; utxoId: TxOutputId; toUplcData: () => ConstrData; }; export type SpendingPurposeV3 = { kind: "SpendingPurposeV3"; utxoId: TxOutputId; datum: UplcData | undefined; toUplcData: () => ConstrData; }; export type RewardingPurpose = { kind: "RewardingPurpose"; credential: StakingCredential; toUplcData: () => ConstrData; }; export type CertifyingPurpose = { kind: "CertifyingPurpose"; dcert: DCert; toUplcData: () => ConstrData; }; export type ScriptPurpose = MintingPurpose | SpendingPurpose | RewardingPurpose | CertifyingPurpose; export type ScriptContextV2 = { kind: "ScriptContextV2"; txInfo: TxInfo; purpose: ScriptPurpose; toUplcData: () => UplcData; }; export type ScriptContextV3 = { kind: "ScriptContextV3"; txInfo: TxInfo; redeemerData: UplcData; purpose: ScriptPurpose | SpendingPurposeV3; toUplcData: () => UplcData; }; /** * Most fields are optional to make it easier to create dummy ScriptContexts for unit testing */ export type TxInfo = { inputs: TxInput[]; refInputs?: TxInput[]; outputs: TxOutput[]; fee?: IntLike; minted?: Assets; dcerts?: DCert[]; withdrawals?: [StakingAddress, IntLike][]; validityTimerange?: TimeRange; signers?: PubKeyHash[]; redeemers?: TxRedeemer[]; datums?: UplcData[]; id?: TxId; }; /** * TxInput represents UTxOs that are available for spending */ export type TxInput = { kind: "TxInput"; id: TxOutputId; address: Address; value: Value; datum: TxOutputDatum | undefined; /** * Throws an error if the TxInput hasn't been recovered */ output: TxOutput; dump: () => object; /** * The output itself isn't stored in the ledger, so must be recovered after deserializing blocks/transactions */ recover: (network: { getUtxo(id: TxOutputId): Promise; }) => Promise; /** * Deep copy of the TxInput so that Network interfaces don't allow accidental mutation of the underlying data */ copy: () => TxInput; isEqual: (other: TxInput) => boolean; /** * Ledger format is without original output (so full = false) * full = true is however useful for complete deserialization of the TxInput (and then eg. using it in off-chain applications) */ toCbor: (full?: boolean) => number[]; /** * Full representation (as used in ScriptContextV2) */ toUplcData: () => ConstrData; /** * Full representation (as used in ScriptContextV3) */ toUplcDataV3: () => ConstrData; }; /** * 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 TxOutputEncodingConfig = { strictBabbage?: boolean; }; /** * Represents a transaction output that is used when building a transaction. */ export type TxOutput = { kind: "TxOutput"; address: Address; value: Value; datum: TxOutputDatum | undefined; refScript: UplcProgram | undefined; encodingConfig: TxOutputEncodingConfig; /** * Deep copy of the TxOnput so that Network interfaces don't allow accidental mutation of the underlying data */ copy: () => TxOutput; dump: () => object; toCbor: () => number[]; toUplcData: () => ConstrData; calcDeposit: (params: NetworkParams) => bigint; correctLovelace: (params: NetworkParams, updater?: (output: TxOutput) => void) => void; }; export type InlineTxOutputDatum = { kind: "InlineTxOutputDatum"; data: UplcData; hash: DatumHash; copy: () => InlineTxOutputDatum; dump: () => object; toCbor: () => number[]; /** * Used by script context emulation */ toUplcData: () => ConstrData; }; export type HashedTxOutputDatum = { kind: "HashedTxOutputDatum"; data: UplcData | undefined; hash: DatumHash; copy: () => HashedTxOutputDatum; dump: () => object; toCbor: () => number[]; /** * Used by script context emulation */ toUplcData: () => ConstrData; }; export type TxOutputDatum = InlineTxOutputDatum | HashedTxOutputDatum; export type TxOutputDatumLike = (TxOutputDatum | undefined) | DatumHash | UplcData; export type TxOutputDatumCastable = { hash: T; } | { inline: T; }; /** * TxMetadataAttr is a simple JSON schema object */ export type TxMetadataAttr = string | number | { list: TxMetadataAttr[]; } | { map: [TxMetadataAttr, TxMetadataAttr][]; }; export type PermissiveTxMetadataAttrArray = PermissiveTxMetadataAttr[]; /** * PermissiveTxMetadataAttr is an extension of TxMetadataAttr that is compatible with Lucid */ export type PermissiveTxMetadataAttr = TxMetadataAttr | PermissiveTxMetadataAttrArray | { [mapKey: string]: PermissiveTxMetadataAttr; }; export type TxMetadata = { kind: "TxMetadata"; attributes: { [key: number]: TxMetadataAttr; }; keys: number[]; dump: () => object; hash: () => number[]; toCbor: () => number[]; }; export type RedeemerDetailsWithoutArgs = { /** * - a short label indicating the part of the txn unlocked by the redeemer */ summary: string; /** * - a more complete specifier of the redeemer */ description: string; /** * - the UplcProgram validating the redeemer */ script: UplcProgram; }; export type RedeemerDetailsWithArgs = { /** * - a short label indicating the part of the txn unlocked by the redeemer */ summary: string; /** * - a more complete specifier of the redeemer */ description: string; /** * - the UplcProgram validating the redeemer */ script: UplcProgram; /** * - the arguments to the script, included if `txInfo` is provided */ args: UplcDataValue[]; }; export type TxMintingRedeemer = { kind: "TxMintingRedeemer"; policyIndex: number; data: UplcData; cost: Cost; /** * On-chain ConstrData tag */ tag: number; calcExFee: (params: NetworkParams) => bigint; dump: () => object; /** * Extracts script details for a specific redeemer on a transaction. */ getRedeemerDetailsWithoutArgs: (tx: Tx) => RedeemerDetailsWithoutArgs; /** * Extracts script-evaluation details for a specific redeemer from the transaction */ getRedeemerDetailsWithArgs: (tx: Tx, txInfo: TxInfo) => RedeemerDetailsWithArgs; toCbor: () => number[]; }; export type TxSpendingRedeemer = { kind: "TxSpendingRedeemer"; inputIndex: number; data: UplcData; cost: Cost; /** * On-chain ConstrData tag */ tag: number; calcExFee: (params: NetworkParams) => bigint; dump: () => object; /** * Extracts script details for a specific redeemer on a transaction. */ getRedeemerDetailsWithoutArgs: (tx: Tx) => RedeemerDetailsWithoutArgs; /** * Extracts script-evaluation details for a specific redeemer from the transaction */ getRedeemerDetailsWithArgs: (tx: Tx, txInfo: TxInfo) => RedeemerDetailsWithArgs; toCbor: () => number[]; }; export type TxRewardingRedeemer = { kind: "TxRewardingRedeemer"; withdrawalIndex: number; data: UplcData; cost: Cost; /** * On-chain ConstrData tag */ tag: number; calcExFee: (params: NetworkParams) => bigint; dump: () => object; /** * Extracts script details for a specific redeemer on a transaction. */ getRedeemerDetailsWithoutArgs: (tx: Tx) => RedeemerDetailsWithoutArgs; /** * Extracts script-evaluation details for a specific redeemer from the transaction */ getRedeemerDetailsWithArgs: (tx: Tx, txInfo: TxInfo) => RedeemerDetailsWithArgs; toCbor: () => number[]; }; export type TxCertifyingRedeemer = { kind: "TxCertifyingRedeemer"; dcertIndex: number; data: UplcData; cost: Cost; /** * On-chain ConstrData tag */ tag: number; calcExFee: (params: NetworkParams) => bigint; dump: () => object; /** * Extracts script details for a specific redeemer on a transaction. */ getRedeemerDetailsWithoutArgs: (tx: Tx) => RedeemerDetailsWithoutArgs; /** * Extracts script-evaluation details for a specific redeemer from the transaction */ getRedeemerDetailsWithArgs: (tx: Tx, txInfo: TxInfo) => RedeemerDetailsWithArgs; toCbor: () => number[]; }; export type TxRedeemer = TxMintingRedeemer | TxSpendingRedeemer | TxRewardingRedeemer | TxCertifyingRedeemer; /** * Represents a collection of tokens. */ export type Value = { kind: "Value"; lovelace: bigint; assets: Assets; assetClasses: AssetClass[]; add: (other: Value) => Value; /** * Throws an error if any of the `Value` entries is negative. * Used when building transactions because transactions can't contain negative values. */ assertAllPositive: () => Value; /** * Deep copy */ copy: () => Value; dump: () => object; /** * Checks if two `Value` instances are equal (`Assets` need to be in the same order). */ isEqual: (other: Value) => boolean; /** * Checks if a `Value` instance is strictly greater or equal to another `Value` instance. Returns false if any asset is missing. */ isGreaterOrEqual: (other: Value) => boolean; /** * Checks if a `Value` instance is strictly greater than another `Value` instance. Returns false if any asset is missing. */ isGreaterThan: (other: Value) => boolean; /** * Multiplies a `Value` by a whole number. */ multiply: (scalar: IntLike) => Value; /** * Substracts one `Value` instance from another. Returns a new `Value` instance. */ subtract: (other: Value) => Value; toCbor: () => number[]; /** * Used when building datums, redeerms, or script contexts. * * **`isInScriptContext`** * * If `isInScriptContext` is `true`, the first entry in the returned map is always the lovelace entry. * If the `Value` doesn't contain any lovelace, a `0` lovelace entry is prepended. * * Also, the tokens of any minting policy in [`Value.assets`](#assets), are sorted in lexicographic order instead of shortest-first order. * * These changes are required to ensure validator script evaluation in Helios is identical to script evaluation in the reference node (and thus the same execution budget is obtained). */ toUplcData: (isInScriptContext?: boolean) => MapData; }; export type ValueLike = Value | IntLike | [IntLike, AssetsLike] | { lovelace: IntLike; assets?: AssetsLike; }; /** * Single asset class value (quantity can be more than 1) * For this special case we can preserve the context */ export type TokenValue = { assetClass: AssetClass; quantity: bigint; value: Value; /** * Multiplies a `TokenValue` by a whole number. */ multiply: (scalar: IntLike) => TokenValue; }; /** * Number representations are always milliseconds since 1970 */ export type TimeLike = number | bigint | Date; /** * Default TimeRange includes both `start` and `end`. */ export type TimeRangeOptions = { excludeStart?: boolean; excludeEnd?: boolean; }; export type TimeRangeLike = TimeRange | [TimeLike, TimeLike] | { start?: TimeLike; excludeStart?: boolean; end?: TimeLike; excludeEnd?: boolean; }; export type TimeRange = { kind: "TimeRange"; start: number; includeStart: boolean; end: number; includeEnd: boolean; finiteStart: number | undefined; finiteEnd: number | undefined; toString: () => string; toUplcData: () => ConstrData; }; export type DatumPaymentContext = { datum: UplcDataConverter; }; export type MintingContext = { program: UplcProgram; redeemer: UplcDataConverter; }; export type SpendingContext = DatumPaymentContext & { program: UplcProgram; datum: UplcDataConverter; redeemer: UplcDataConverter; }; export type StakingContext = { program: UplcProgram; redeemer: UplcDataConverter; }; export type PubKey = { kind: "PubKey"; bytes: number[]; dump: () => string; hash: () => PubKeyHash; isDummy: () => boolean; toCbor: () => number[]; toHex: () => string; /** * Alias for toHex() */ toString: () => string; toUplcData: () => ByteArrayData; }; export type PubKeyLike = PubKey | BytesLike; /** * Represents a Ed25519 signature. * Also contains a reference to the PubKey that did the signing. */ export type Signature = { kind: "Signature"; pubKey: PubKey; bytes: number[]; pubKeyHash: PubKeyHash; dump: () => object; isDummy: () => boolean; toCbor: () => number[]; /** * Throws an error if incorrect */ verify: (msg: number[]) => void; }; export type TxBodyEncodingConfig = { /** * Defaults to true */ inputsAsSet?: boolean | undefined; /** * Defaults to true */ dcertsAsSet?: boolean | undefined; /** * Defaults to true */ collateralInputsAsSet?: boolean | undefined; /** * Defaults to true */ signersAsSet?: boolean | undefined; /** * Defaults to true */ refInputsAsSet?: boolean | undefined; }; /** * Note: inputs, minted assets, and withdrawals need to be sorted in order to form a valid transaction */ export type TxBody = { kind: "TxBody"; encodingConfig: TxBodyEncodingConfig; /** * Optionally encoded as set. */ inputs: TxInput[]; outputs: TxOutput[]; fee: bigint; firstValidSlot: number | undefined; lastValidSlot: number | undefined; /** * Optionally encoded as set. */ dcerts: DCert[]; /** * Withdrawals must be sorted by address * Stake rewarding redeemers must point to the sorted withdrawals */ withdrawals: [StakingAddress, bigint][]; /** * Internally the assets must be sorted by mintingpolicyhash * Minting redeemers must point to the sorted minted assets */ minted: Assets; scriptDataHash: number[] | undefined; /** * Optionally encoded as set. * TODO: rename to `collateralInputs` */ collateral: TxInput[]; /** * Optionally encoded as set. */ signers: PubKeyHash[]; collateralReturn: TxOutput | undefined; totalCollateral: bigint; /** * Optionally encoded as set. */ refInputs: TxInput[]; metadataHash: number[] | undefined; /** * Used to validate if all the necessary scripts are included TxWitnesses (and that there are not redundant scripts) */ allScriptHashes: ScriptHash[]; /** * Calculates the number of dummy signatures needed to get precisely the right tx size. */ countUniqueSigners: () => number; dump: () => object; getValidityTimeRange: (params: NetworkParams) => TimeRange; /** * Used by (indirectly) by emulator to check if slot range is valid. * Note: firstValidSlot == lastValidSlot is allowed */ isValidSlot: (slot: IntLike) => boolean; /** * A serialized tx throws away input information * This must be refetched from the network if the tx needs to be analyzed * This must be done for the regular inputs because the datums are needed for correct budget calculation and min required signatures determination * This must be done for the reference inputs because they impact the budget calculation * This must be done for the collateral inputs as well, so that the minium required signatures can be determined correctly */ recover: (network: { getUtxo: (id: TxOutputId) => Promise; }) => Promise; sumInputValue: () => Value; /** * Throws error if any part of the sum is negative (i.e. more is burned than input) */ sumInputAndMintedValue: () => Value; /** * Excludes lovelace */ sumInputAndMintedAssets: () => Assets; sumOutputValue: () => Value; /** * Excludes lovelace */ sumOutputAssets: () => Assets; toCbor: () => number[]; /** * Returns the on-chain Tx representation */ toTxInfo: (params: NetworkParams, redeemers: TxRedeemer[], datums: UplcData[], txId: TxId) => TxInfo; /** * Not done in the same routine as sortInputs(), because balancing of assets happens after redeemer indices are set */ sortOutputs: () => void; /** * The bytes that form the TxId */ hash: () => number[]; }; export type TxWitnessesEncodingConfig = { /** * Defaults to true */ signaturesAsSet?: boolean | undefined; /** * Defaults to true */ nativeScriptsAsSet?: boolean | undefined; /** * Defaults to true */ v1ScriptsAsSet?: boolean | undefined; /** * Defaults to true */ datumsAsSet?: boolean | undefined; /** * Defaults to true */ v2ScriptsAsSet?: boolean | undefined; /** * Defaults to true */ v3ScriptsAsSet?: boolean | undefined; }; /** * Represents the pubkey signatures, and datums/redeemers/scripts that are witnessing a transaction. */ export type TxWitnesses = { kind: "TxWitnesses"; encodingConfig: TxWitnessesEncodingConfig; /** * Optionally encoded as set */ signatures: Signature[]; /** * Optionally encoded as set */ datums: UplcData[]; redeemers: TxRedeemer[]; /** * Optionally encoded as set */ nativeScripts: NativeScript[]; /** * Optionally encoded as set */ v1Scripts: UplcProgramV1[]; /** * Optionally encoded as set */ v2Scripts: UplcProgramV2[]; /** * Optionally encoded as set */ v3Scripts: UplcProgramV3[]; v2RefScripts: UplcProgramV2[]; v3RefScripts: UplcProgramV3[]; allScripts: (NativeScript | UplcProgram)[]; /** * Used to calculate the correct min fee */ addDummySignatures: (n: number) => void; addSignature: (signature: Signature) => void; calcExFee: (params: NetworkParams) => bigint; countNonDummySignatures: () => number; dump: () => object; findUplcProgram: (hash: number[] | MintingPolicyHash | ValidatorHash | StakingValidatorHash) => UplcProgram; isSmart: () => boolean; recover: (refScriptsInRefInputs: UplcProgram[]) => void; removeDummySignatures: (n: number) => void; toCbor: () => number[]; /** * Throws error if some signatures are incorrect */ verifySignatures: (bodyBytes: number[]) => void; }; export type TxValidationOptions = { /** * can be left as false for inspecting general transactions. The TxBuilder always uses strict=true. */ strict?: boolean | undefined; /** * provides more details of transaction-budget usage when the transaction is close to the limit */ verbose?: boolean | undefined; /** * hooks for script logging during transaction execution */ logOptions?: UplcLogger | undefined; }; /** * Represents a Cardano transaction. For transaction-building, see {@link TxBuilder} instead. */ export type Tx = { kind: "Tx"; body: TxBody; witnesses: TxWitnesses; metadata: TxMetadata | undefined; /** * Number of bytes of CBOR encoding of Tx * Is used for two things: * - tx fee calculation * - tx size validation */ calcSize: (forFeeCalculation?: boolean) => number; /** * Adds a signature created by a wallet. Only available after the transaction has been finalized. * Optionally verifies that the signature is correct (defaults to true) */ addSignature: (signature: Signature, verify?: boolean) => Tx; /** * Adds multiple signatures at once. Only available after the transaction has been finalized. * Optionally verifies each signature is correct (defaults to true) */ addSignatures: (signatures: Signature[], verify?: boolean) => Tx; /** * Returns a quantity in lovelace */ calcMinCollateral: (params: NetworkParams, recalcMinBaseFee?: boolean) => bigint; /** * Returns a quantity in lovelace */ calcMinFee: (params: NetworkParams) => bigint; /** * Creates a new Tx without the metadata for client-side signing where the client can't know the metadata before tx-submission. */ clearMetadata: () => Tx; dump: () => object; id: () => TxId; isSmart: () => boolean; /** * Indicates if the necessary signatures are present and valid */ isValid: () => boolean; /** * Indicates if a built transaction has passed all consistency checks. * - `null` if the transaction hasn't been validated yet * - `false` when the transaction is valid * - a `string` with the error message if any validation check failed * - a UplcRuntimeError in case of any UPLC script failure */ hasValidationError: string | UplcRuntimeError | false | undefined; /** * Used by emulator to check if tx is valid. */ isValidSlot: (slot: bigint) => boolean; /** * Restores input information after deserializing a CBOR-encoded transaction * A serialized tx throws away input information * This must be refetched from the network if the tx needs to be analyzed */ recover: (network: { getUtxo: (id: TxOutputId) => Promise; }) => Promise; /** * Serializes a transaction. * 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?) */ toCbor: (forFeeCalculation?: boolean) => number[]; /** * Throws an error if the tx isn't valid * Checks that are performed: * - size of tx <= params.maxTxSize * - body.fee >= calculated min fee * - value is conserved (minus what is burned, plus what is minted) * - enough collateral if smart * - no collateral if not smart * - all necessary scripts are attached * - no redundant scripts are attached (only checked if strict=true) * - each redeemer must have enough ex budget * - total ex budget can't exceed max tx ex budget for either mem or cpu * - each output contains enough lovelace (minDeposit) * - the assets in the output values are correctly sorted (only checked if strict=true, because only needed by some wallets) * - inputs are in the correct order * - ref inputs are in the correct order * - minted assets are in the correct order * - staking withdrawals are in the correct order * - metadatahash corresponds to metadata * - metadatahash is null if there isn't any metadata * - script data hash is correct * Checks that aren't performed: * - all necessary signatures are included (must done after tx has been signed) * - validity time range, which can only be checked upon submission */ validate: (params: NetworkParams, options?: TxValidationOptions) => void; /** * Validates the transaction without throwing an error if it isn't valid * If the transaction doesn't validate, the tx's `validationError` will be set */ validateUnsafe: (params: NetworkParams, options?: TxValidationOptions) => Tx; /** * Throws an error if all necessary signatures haven't yet been added * Separate from the other validation checks * If valid: this.valid is mutated to true */ validateSignatures: () => void; }; import type { UplcData } from "@helios-lang/uplc"; import type { BytesLike } from "@helios-lang/codec-utils"; import type { ConstrData } from "@helios-lang/uplc"; import type { IntLike } from "@helios-lang/codec-utils"; import type { MapData } from "@helios-lang/uplc"; import type { ByteArrayData } from "@helios-lang/uplc"; import type { UplcProgram } from "@helios-lang/uplc"; import type { UplcDataValue } from "@helios-lang/uplc"; import type { Cost } from "@helios-lang/uplc"; import type { UplcProgramV1 } from "@helios-lang/uplc"; import type { UplcProgramV2 } from "@helios-lang/uplc"; import type { UplcProgramV3 } from "@helios-lang/uplc"; import type { UplcLogger } from "@helios-lang/uplc"; import { UplcRuntimeError } from "@helios-lang/uplc"; export { compareStakingAddresses, compareStakingCredentials, convertSpendingCredentialToUplcData, convertStakingCredentialToUplcData, convertUplcDataToShelleyAddress, convertUplcDataToSpendingCredential, convertUplcDataToStakingAddress, convertUplcDataToStakingCredential, decodeAddress, decodeByronAddress, decodeShelleyAddress, decodeStakingAddress, decodeStakingCredential, encodeStakingCredential, isValidBech32Address, isValidBech32StakingAddress, makeAddress, makeByronAddress, makeDummyAddress, makeDummyShelleyAddress, makeDummyStakingAddress, makeShelleyAddress, makeStakingAddress, parseShelleyAddress, parseStakingAddress } from "./address/index.js"; export { compareDatumHashes, compareMintingPolicyHashes, comparePubKeyHashes, compareStakingValidatorHashes, compareValidatorHashes, convertUplcDataToDatumHash, convertUplcDataToMintingPolicyHash, convertUplcDataToPubKeyHash, convertUplcDataToStakingValidatorHash, convertUplcDataToTxId, convertUplcDataToValidatorHash, decodeDatumHash, decodeMintingPolicyHash, decodePubKeyHash, decodeStakingValidatorHash, decodeTxId, decodeValidatorHash, hashDatum, isValidMintingPolicyHash, isValidPubKeyHash, isValidStakingValidatorHash, isValidTxId, isValidValidatorHash, makeDummyMintingPolicyHash, makeDummyPubKeyHash, makeDummyStakingValidatorHash, makeDummyTxId, makeDummyValidatorHash, makeDatumHash, makeMintingPolicyHash, makePubKeyHash, makeStakingValidatorHash, makeTxId, makeValidatorHash } from "./hashes/index.js"; export { ADA, addValues, compareAssetClasses, convertUplcDataToAssetClass, convertUplcDataToValue, decodeAssetClass, decodeAssets, decodeValue, makeAssetClass, makeAssets, makeDummyAssetClass, makeTokenValue, makeValue, parseAssetClass, parseBlockfrostValue } from "./money/index.js"; export { decodeNativeScript, hashNativeScript, makeAfterScript, makeAllScript, makeAnyScript, makeAtLeastScript, makeBeforeScript, makeSigScript, parseNativeScript } from "./native/index.js"; export { BABBAGE_COST_MODEL_PARAMS_V1, BABBAGE_COST_MODEL_PARAMS_V2, BABBAGE_PARAMS, BABBAGE_NETWORK_PARAMS, CONWAY_GENESIS_PARAMS, DEFAULT_NETWORK_PARAMS, DEFAULT_CONWAY_PARAMS, SHELLEY_GENESIS_PARAMS, makeDefaultNetworkParamsHelper, makeNetworkParamsHelper } from "./params/index.js"; export { convertUplcDataToPubKey, decodePubKey, decodeSignature, makeDummyPubKey, makeDummySignature, makePubKey, makeSignature } from "./signature/index.js"; export { convertUplcDataToTimeRange, makeTimeRange, toTime } from "./time/index.js"; export { DEFAULT_TX_OUTPUT_ENCODING_CONFIG, appendTxInput, calcRefScriptsSize, calcScriptDataHash, compareTxInputs, compareTxOutputIds, convertUplcDataToTxInput, convertUplcDataToTxOutput, convertUplcDataToTxOutputDatum, convertUplcDataToTxOutputId, decodeDCert, decodeTx, decodeTxBody, decodeTxInput, decodeTxMetadata, decodeTxMetadataAttr, decodeTxOutput, decodeTxOutputDatum, decodeTxOutputId, decodeTxRedeemer, decodeTxWitnesses, encodeTxMetadataAttr, isTxMetadataAttrList, isTxMetadataAttrMap, isTxMetadataAttrNumber, isTxMetadataAttrString, isValidTxInputCbor, isValidTxOutputCbor, isValidTxOutputId, makeCertifyingPurpose, makeDelegationDCert, makeDeregistrationDCert, makeDummyTxOutputId, makeHashedTxOutputDatum, makeInlineTxOutputDatum, makeMintingPurpose, makeRegisterPoolDCert, makeRegistrationDCert, makeRetirePoolDCert, makeRewardingPurpose, makeScriptContextV2, makeScriptContextV3, makeSpendingPurpose, makeTx, makeTxBody, makeTxCertifyingRedeemer, makeTxInput, makeTxMetadata, makeTxMetadataAttr, makeTxMintingRedeemer, makeTxOutput, makeTxOutputDatum, makeTxOutputId, makeTxRewardingRedeemer, makeTxSpendingRedeemer, makeTxWitnesses, parseTxOutputId, UtxoAlreadySpentError, UtxoNotFoundError } from "./tx/index.js"; //# sourceMappingURL=index.d.ts.map