"use strict";
// Copyright 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TRANSACTION_FAILURE_REASON_STRINGS = exports.TransactionFailureReason = exports.OutputWithMetadata = exports.OutputWithMetadataResponse = exports.OutputResponse = exports.OutputIdProof = exports.ValueHash = exports.LeafHash = exports.HashableNode = exports.OutputCommitmentProof = exports.OutputCommitmentProofType = void 0;
// Temp solution for not double parsing JSON
const class_transformer_1 = require("class-transformer");
const output_1 = require("../../block/output");
/**
 * OutputCommitmentProof types.
 */
var OutputCommitmentProofType;
(function (OutputCommitmentProofType) {
    /** Denotes a HashableNode. */
    OutputCommitmentProofType[OutputCommitmentProofType["HashableNode"] = 0] = "HashableNode";
    /** Denotes a LeafHash. */
    OutputCommitmentProofType[OutputCommitmentProofType["LeafHash"] = 1] = "LeafHash";
    /** Denotes a ValueHash. */
    OutputCommitmentProofType[OutputCommitmentProofType["ValueHash"] = 2] = "ValueHash";
})(OutputCommitmentProofType = exports.OutputCommitmentProofType || (exports.OutputCommitmentProofType = {}));
class OutputCommitmentProof {
    /**
     * @param type The type of OutputCommitmentProof.
     */
    constructor(type) {
        this.type = type;
    }
    /**
     * Parse an OutputCommitmentProof from a plain JSON object.
     */
    static parse(data) {
        if (data.type == OutputCommitmentProofType.HashableNode) {
            return (0, class_transformer_1.plainToInstance)(HashableNode, data);
        }
        else if (data.type == OutputCommitmentProofType.LeafHash) {
            return (0, class_transformer_1.plainToInstance)(LeafHash, data);
        }
        else if (data.type == OutputCommitmentProofType.ValueHash) {
            return (0, class_transformer_1.plainToInstance)(ValueHash, data);
        }
        throw new Error('Invalid JSON');
    }
}
exports.OutputCommitmentProof = OutputCommitmentProof;
/**
 * Contains the hashes of the left and right children of a node in the OutputCommitmentProof tree.
 */
class HashableNode extends OutputCommitmentProof {
    /**
     * @param l Output commitment proof of the left subtree.
     * @param r Output commitment proof of the right subtree.
     */
    constructor(l, r) {
        super(OutputCommitmentProofType.HashableNode);
        this.l = l;
        this.r = r;
    }
}
exports.HashableNode = HashableNode;
/**
 * Contains the hash of a leaf in the OutputCommitmentProof tree.
 */
class LeafHash extends OutputCommitmentProof {
    /**
     * @param hash The hash of the leaf.
     */
    constructor(hash) {
        super(OutputCommitmentProofType.LeafHash);
        this.hash = hash;
    }
}
exports.LeafHash = LeafHash;
/**
 * Contains the hash of the value for which the OutputCommitmentProof is being computed.
 */
class ValueHash extends OutputCommitmentProof {
    /**
     * @param hash The hash of the value.
     */
    constructor(hash) {
        super(OutputCommitmentProofType.ValueHash);
        this.hash = hash;
    }
}
exports.ValueHash = ValueHash;
/**
 * The proof of the output identifier.
 */
class OutputIdProof {
    /**
     * @param slot The slot index of the output.
     * @param outputIndex The index of the output within the corresponding transaction.
     * @param transactionCommitment The commitment of the transaction that created the output. Hex-encoded with 0x prefix.
     * @param outputCommitmentProof The proof of the output commitment.
     */
    constructor(slot, outputIndex, transactionCommitment, outputCommitmentProof) {
        this.slot = slot;
        this.outputIndex = outputIndex;
        this.transactionCommitment = transactionCommitment;
        this.outputCommitmentProof = outputCommitmentProof;
    }
}
exports.OutputIdProof = OutputIdProof;
/**
 * An output with its output id proof.
 * Response of GET /api/core/v3/outputs/{outputId}.
 */
class OutputResponse {
}
__decorate([
    (0, class_transformer_1.Type)(() => output_1.Output, {
        discriminator: output_1.OutputDiscriminator,
    })
], OutputResponse.prototype, "output", void 0);
exports.OutputResponse = OutputResponse;
/**
 * An output with its output id proof and its metadata.
 * Response of GET /api/core/v3/outputs/{outputId}/full.
 */
class OutputWithMetadataResponse {
}
exports.OutputWithMetadataResponse = OutputWithMetadataResponse;
/**
 * An output and its metadata.
 */
class OutputWithMetadata {
}
exports.OutputWithMetadata = OutputWithMetadata;
/**
 * Reason for transaction failure.
 */
var TransactionFailureReason;
(function (TransactionFailureReason) {
    TransactionFailureReason[TransactionFailureReason["None"] = 0] = "None";
    TransactionFailureReason[TransactionFailureReason["ConflictRejected"] = 1] = "ConflictRejected";
    TransactionFailureReason[TransactionFailureReason["Orphaned"] = 2] = "Orphaned";
    TransactionFailureReason[TransactionFailureReason["InputAlreadySpent"] = 3] = "InputAlreadySpent";
    TransactionFailureReason[TransactionFailureReason["InputCreationAfterTxCreation"] = 4] = "InputCreationAfterTxCreation";
    TransactionFailureReason[TransactionFailureReason["UnlockSignatureInvalid"] = 5] = "UnlockSignatureInvalid";
    TransactionFailureReason[TransactionFailureReason["ChainAddressUnlockInvalid"] = 6] = "ChainAddressUnlockInvalid";
    TransactionFailureReason[TransactionFailureReason["DirectUnlockableAddressUnlockInvalid"] = 7] = "DirectUnlockableAddressUnlockInvalid";
    TransactionFailureReason[TransactionFailureReason["MultiAddressUnlockInvalid"] = 8] = "MultiAddressUnlockInvalid";
    TransactionFailureReason[TransactionFailureReason["CommitmentInputReferenceInvalid"] = 9] = "CommitmentInputReferenceInvalid";
    TransactionFailureReason[TransactionFailureReason["BicInputReferenceInvalid"] = 10] = "BicInputReferenceInvalid";
    TransactionFailureReason[TransactionFailureReason["RewardInputReferenceInvalid"] = 11] = "RewardInputReferenceInvalid";
    TransactionFailureReason[TransactionFailureReason["StakingRewardCalculationFailure"] = 12] = "StakingRewardCalculationFailure";
    TransactionFailureReason[TransactionFailureReason["DelegationRewardCalculationFailure"] = 13] = "DelegationRewardCalculationFailure";
    TransactionFailureReason[TransactionFailureReason["InputOutputBaseTokenMismatch"] = 14] = "InputOutputBaseTokenMismatch";
    TransactionFailureReason[TransactionFailureReason["ManaOverflow"] = 15] = "ManaOverflow";
    TransactionFailureReason[TransactionFailureReason["InputOutputManaMismatch"] = 16] = "InputOutputManaMismatch";
    TransactionFailureReason[TransactionFailureReason["ManaDecayCreationIndexExceedsTargetIndex"] = 17] = "ManaDecayCreationIndexExceedsTargetIndex";
    TransactionFailureReason[TransactionFailureReason["NativeTokenSumUnbalanced"] = 18] = "NativeTokenSumUnbalanced";
    TransactionFailureReason[TransactionFailureReason["SimpleTokenSchemeMintedMeltedTokenDecrease"] = 19] = "SimpleTokenSchemeMintedMeltedTokenDecrease";
    TransactionFailureReason[TransactionFailureReason["SimpleTokenSchemeMintingInvalid"] = 20] = "SimpleTokenSchemeMintingInvalid";
    TransactionFailureReason[TransactionFailureReason["SimpleTokenSchemeMeltingInvalid"] = 21] = "SimpleTokenSchemeMeltingInvalid";
    TransactionFailureReason[TransactionFailureReason["SimpleTokenSchemeMaximumSupplyChanged"] = 22] = "SimpleTokenSchemeMaximumSupplyChanged";
    TransactionFailureReason[TransactionFailureReason["SimpleTokenSchemeGenesisInvalid"] = 23] = "SimpleTokenSchemeGenesisInvalid";
    TransactionFailureReason[TransactionFailureReason["MultiAddressLengthUnlockLengthMismatch"] = 24] = "MultiAddressLengthUnlockLengthMismatch";
    TransactionFailureReason[TransactionFailureReason["MultiAddressUnlockThresholdNotReached"] = 25] = "MultiAddressUnlockThresholdNotReached";
    TransactionFailureReason[TransactionFailureReason["SenderFeatureNotUnlocked"] = 26] = "SenderFeatureNotUnlocked";
    TransactionFailureReason[TransactionFailureReason["IssuerFeatureNotUnlocked"] = 27] = "IssuerFeatureNotUnlocked";
    TransactionFailureReason[TransactionFailureReason["StakingRewardInputMissing"] = 28] = "StakingRewardInputMissing";
    TransactionFailureReason[TransactionFailureReason["StakingCommitmentInputMissing"] = 29] = "StakingCommitmentInputMissing";
    TransactionFailureReason[TransactionFailureReason["StakingRewardClaimingInvalid"] = 30] = "StakingRewardClaimingInvalid";
    TransactionFailureReason[TransactionFailureReason["StakingFeatureRemovedBeforeUnbonding"] = 31] = "StakingFeatureRemovedBeforeUnbonding";
    TransactionFailureReason[TransactionFailureReason["StakingFeatureModifiedBeforeUnbonding"] = 32] = "StakingFeatureModifiedBeforeUnbonding";
    TransactionFailureReason[TransactionFailureReason["StakingStartEpochInvalid"] = 33] = "StakingStartEpochInvalid";
    TransactionFailureReason[TransactionFailureReason["StakingEndEpochTooEarly"] = 34] = "StakingEndEpochTooEarly";
    TransactionFailureReason[TransactionFailureReason["BlockIssuerCommitmentInputMissing"] = 35] = "BlockIssuerCommitmentInputMissing";
    TransactionFailureReason[TransactionFailureReason["BlockIssuanceCreditInputMissing"] = 36] = "BlockIssuanceCreditInputMissing";
    TransactionFailureReason[TransactionFailureReason["BlockIssuerNotExpired"] = 37] = "BlockIssuerNotExpired";
    TransactionFailureReason[TransactionFailureReason["BlockIssuerExpiryTooEarly"] = 38] = "BlockIssuerExpiryTooEarly";
    TransactionFailureReason[TransactionFailureReason["ManaMovedOffBlockIssuerAccount"] = 39] = "ManaMovedOffBlockIssuerAccount";
    TransactionFailureReason[TransactionFailureReason["AccountLocked"] = 40] = "AccountLocked";
    TransactionFailureReason[TransactionFailureReason["TimelockCommitmentInputMissing"] = 41] = "TimelockCommitmentInputMissing";
    TransactionFailureReason[TransactionFailureReason["TimelockNotExpired"] = 42] = "TimelockNotExpired";
    TransactionFailureReason[TransactionFailureReason["ExpirationCommitmentInputMissing"] = 43] = "ExpirationCommitmentInputMissing";
    TransactionFailureReason[TransactionFailureReason["ExpirationNotUnlockable"] = 44] = "ExpirationNotUnlockable";
    TransactionFailureReason[TransactionFailureReason["ReturnAmountNotFulFilled"] = 45] = "ReturnAmountNotFulFilled";
    TransactionFailureReason[TransactionFailureReason["NewChainOutputHasNonZeroedId"] = 46] = "NewChainOutputHasNonZeroedId";
    TransactionFailureReason[TransactionFailureReason["ChainOutputImmutableFeaturesChanged"] = 47] = "ChainOutputImmutableFeaturesChanged";
    TransactionFailureReason[TransactionFailureReason["ImplicitAccountDestructionDisallowed"] = 48] = "ImplicitAccountDestructionDisallowed";
    TransactionFailureReason[TransactionFailureReason["MultipleImplicitAccountCreationAddresses"] = 49] = "MultipleImplicitAccountCreationAddresses";
    TransactionFailureReason[TransactionFailureReason["AccountInvalidFoundryCounter"] = 50] = "AccountInvalidFoundryCounter";
    TransactionFailureReason[TransactionFailureReason["AnchorInvalidStateTransition"] = 51] = "AnchorInvalidStateTransition";
    TransactionFailureReason[TransactionFailureReason["AnchorInvalidGovernanceTransition"] = 52] = "AnchorInvalidGovernanceTransition";
    TransactionFailureReason[TransactionFailureReason["FoundryTransitionWithoutAccount"] = 53] = "FoundryTransitionWithoutAccount";
    TransactionFailureReason[TransactionFailureReason["FoundrySerialInvalid"] = 54] = "FoundrySerialInvalid";
    TransactionFailureReason[TransactionFailureReason["DelegationCommitmentInputMissing"] = 55] = "DelegationCommitmentInputMissing";
    TransactionFailureReason[TransactionFailureReason["DelegationRewardInputMissing"] = 56] = "DelegationRewardInputMissing";
    TransactionFailureReason[TransactionFailureReason["DelegationRewardsClaimingInvalid"] = 57] = "DelegationRewardsClaimingInvalid";
    TransactionFailureReason[TransactionFailureReason["DelegationOutputTransitionedTwice"] = 58] = "DelegationOutputTransitionedTwice";
    TransactionFailureReason[TransactionFailureReason["DelegationModified"] = 59] = "DelegationModified";
    TransactionFailureReason[TransactionFailureReason["DelegationStartEpochInvalid"] = 60] = "DelegationStartEpochInvalid";
    TransactionFailureReason[TransactionFailureReason["DelegationAmountMismatch"] = 61] = "DelegationAmountMismatch";
    TransactionFailureReason[TransactionFailureReason["DelegationEndEpochNotZero"] = 62] = "DelegationEndEpochNotZero";
    TransactionFailureReason[TransactionFailureReason["DelegationEndEpochInvalid"] = 63] = "DelegationEndEpochInvalid";
    TransactionFailureReason[TransactionFailureReason["CapabilitiesNativeTokenBurningNotAllowed"] = 64] = "CapabilitiesNativeTokenBurningNotAllowed";
    TransactionFailureReason[TransactionFailureReason["CapabilitiesManaBurningNotAllowed"] = 65] = "CapabilitiesManaBurningNotAllowed";
    TransactionFailureReason[TransactionFailureReason["CapabilitiesAccountDestructionNotAllowed"] = 66] = "CapabilitiesAccountDestructionNotAllowed";
    TransactionFailureReason[TransactionFailureReason["CapabilitiesAnchorDestructionNotAllowed"] = 67] = "CapabilitiesAnchorDestructionNotAllowed";
    TransactionFailureReason[TransactionFailureReason["CapabilitiesFoundryDestructionNotAllowed"] = 68] = "CapabilitiesFoundryDestructionNotAllowed";
    TransactionFailureReason[TransactionFailureReason["CapabilitiesNftDestructionNotAllowed"] = 69] = "CapabilitiesNftDestructionNotAllowed";
    TransactionFailureReason[TransactionFailureReason["SemanticValidationFailed"] = 255] = "SemanticValidationFailed";
})(TransactionFailureReason = exports.TransactionFailureReason || (exports.TransactionFailureReason = {}));
/**
 * Transaction failure reason strings.
 */
exports.TRANSACTION_FAILURE_REASON_STRINGS = {
    [TransactionFailureReason.None]: 'None.',
    [TransactionFailureReason.ConflictRejected]: 'Transaction was conflicting and was rejected.',
    [TransactionFailureReason.Orphaned]: 'Transaction was orphaned.',
    [TransactionFailureReason.InputAlreadySpent]: 'Input already spent.',
    [TransactionFailureReason.InputCreationAfterTxCreation]: 'Input creation slot after tx creation slot.',
    [TransactionFailureReason.UnlockSignatureInvalid]: 'Signature in unlock is invalid.',
    [TransactionFailureReason.ChainAddressUnlockInvalid]: 'invalid unlock for chain address.',
    [TransactionFailureReason.DirectUnlockableAddressUnlockInvalid]: 'invalid unlock for direct unlockable address.',
    [TransactionFailureReason.MultiAddressUnlockInvalid]: 'invalid unlock for multi address.',
    [TransactionFailureReason.CommitmentInputReferenceInvalid]: 'Commitment input references an invalid or non-existent commitment.',
    [TransactionFailureReason.BicInputReferenceInvalid]: 'BIC input reference cannot be loaded.',
    [TransactionFailureReason.RewardInputReferenceInvalid]: 'Reward input does not reference a staking account or a delegation output.',
    [TransactionFailureReason.StakingRewardCalculationFailure]: 'Staking rewards could not be calculated due to storage issues or overflow.',
    [TransactionFailureReason.DelegationRewardCalculationFailure]: 'Delegation rewards could not be calculated due to storage issues or overflow.',
    [TransactionFailureReason.InputOutputBaseTokenMismatch]: 'Inputs and outputs do not spend/deposit the same amount of base tokens.',
    [TransactionFailureReason.ManaOverflow]: 'Under- or overflow in Mana calculations.',
    [TransactionFailureReason.InputOutputManaMismatch]: 'Inputs and outputs do not contain the same amount of Mana.',
    [TransactionFailureReason.ManaDecayCreationIndexExceedsTargetIndex]: 'Mana decay creation slot/epoch index exceeds target slot/epoch index.',
    [TransactionFailureReason.NativeTokenSumUnbalanced]: 'Native token sums are unbalanced.',
    [TransactionFailureReason.SimpleTokenSchemeMintedMeltedTokenDecrease]: "Simple token scheme's minted or melted tokens decreased.",
    [TransactionFailureReason.SimpleTokenSchemeMintingInvalid]: "Simple token scheme's minted tokens did not increase by the minted amount or melted tokens changed.",
    [TransactionFailureReason.SimpleTokenSchemeMeltingInvalid]: "Simple token scheme's melted tokens did not increase by the melted amount or minted tokens changed.",
    [TransactionFailureReason.SimpleTokenSchemeMaximumSupplyChanged]: "Simple token scheme's maximum supply cannot change during transition.",
    [TransactionFailureReason.SimpleTokenSchemeGenesisInvalid]: "Newly created simple token scheme's melted tokens are not zero or minted tokens do not equal native token amount in transaction.",
    [TransactionFailureReason.MultiAddressLengthUnlockLengthMismatch]: 'Multi address length and multi unlock length do not match.',
    [TransactionFailureReason.MultiAddressUnlockThresholdNotReached]: 'Multi address unlock threshold not reached.',
    [TransactionFailureReason.SenderFeatureNotUnlocked]: 'Sender feature is not unlocked.',
    [TransactionFailureReason.IssuerFeatureNotUnlocked]: 'Issuer feature is not unlocked.',
    [TransactionFailureReason.StakingRewardInputMissing]: 'Staking feature removal or resetting requires a reward input.',
    [TransactionFailureReason.StakingCommitmentInputMissing]: 'Staking feature validation requires a commitment input.',
    [TransactionFailureReason.StakingRewardClaimingInvalid]: 'Staking feature must be removed or reset in order to claim rewards.',
    [TransactionFailureReason.StakingFeatureRemovedBeforeUnbonding]: 'Staking feature can only be removed after the unbonding period.',
    [TransactionFailureReason.StakingFeatureModifiedBeforeUnbonding]: 'Staking start epoch, fixed cost and staked amount cannot be modified while bonded.',
    [TransactionFailureReason.StakingStartEpochInvalid]: 'Staking start epoch must be the epoch of the transaction.',
    [TransactionFailureReason.StakingEndEpochTooEarly]: 'Staking end epoch must be set to the transaction epoch plus the unbonding period.',
    [TransactionFailureReason.BlockIssuerCommitmentInputMissing]: 'Commitment input missing for block issuer feature.',
    [TransactionFailureReason.BlockIssuanceCreditInputMissing]: 'Block issuance credit input missing for account with block issuer feature.',
    [TransactionFailureReason.BlockIssuerNotExpired]: 'Block issuer feature has not expired.',
    [TransactionFailureReason.BlockIssuerExpiryTooEarly]: 'Block issuer feature expiry set too early.',
    [TransactionFailureReason.ManaMovedOffBlockIssuerAccount]: 'Mana cannot be moved off block issuer accounts except with manalocks.',
    [TransactionFailureReason.AccountLocked]: 'Account is locked due to negative block issuance credits.',
    [TransactionFailureReason.TimelockCommitmentInputMissing]: "Transaction's containing a timelock condition require a commitment input.",
    [TransactionFailureReason.TimelockNotExpired]: 'Timelock not expired.',
    [TransactionFailureReason.ExpirationCommitmentInputMissing]: "Transaction's containing an expiration condition require a commitment input.",
    [TransactionFailureReason.ExpirationNotUnlockable]: 'Expiration unlock condition cannot be unlocked.',
    [TransactionFailureReason.ReturnAmountNotFulFilled]: 'Return amount not fulfilled.',
    [TransactionFailureReason.NewChainOutputHasNonZeroedId]: 'New chain output has non-zeroed ID.',
    [TransactionFailureReason.ChainOutputImmutableFeaturesChanged]: 'Immutable features in chain output modified during transition.',
    [TransactionFailureReason.ImplicitAccountDestructionDisallowed]: 'Cannot destroy implicit account; must be transitioned to account.',
    [TransactionFailureReason.MultipleImplicitAccountCreationAddresses]: 'Multiple implicit account creation addresses on the input side.',
    [TransactionFailureReason.AccountInvalidFoundryCounter]: 'Foundry counter in account decreased or did not increase by the number of new foundries.',
    [TransactionFailureReason.AnchorInvalidStateTransition]: 'Invalid anchor state transition.',
    [TransactionFailureReason.AnchorInvalidGovernanceTransition]: 'Invalid anchor governance transition.',
    [TransactionFailureReason.FoundryTransitionWithoutAccount]: 'Foundry output transitioned without accompanying account on input or output side.',
    [TransactionFailureReason.FoundrySerialInvalid]: 'Foundry output serial number is invalid.',
    [TransactionFailureReason.DelegationCommitmentInputMissing]: 'Delegation output validation requires a commitment input.',
    [TransactionFailureReason.DelegationRewardInputMissing]: 'Delegation output cannot be destroyed without a reward input.',
    [TransactionFailureReason.DelegationRewardsClaimingInvalid]: 'Invalid delegation mana rewards claiming.',
    [TransactionFailureReason.DelegationOutputTransitionedTwice]: 'Delegation output attempted to be transitioned twice.',
    [TransactionFailureReason.DelegationModified]: 'Delegated amount, validator ID and start epoch cannot be modified.',
    [TransactionFailureReason.DelegationStartEpochInvalid]: 'Delegation output has invalid start epoch.',
    [TransactionFailureReason.DelegationAmountMismatch]: 'Delegated amount does not match amount.',
    [TransactionFailureReason.DelegationEndEpochNotZero]: 'End epoch must be set to zero at output genesis.',
    [TransactionFailureReason.DelegationEndEpochInvalid]: 'Delegation end epoch does not match current epoch.',
    [TransactionFailureReason.CapabilitiesNativeTokenBurningNotAllowed]: 'Native token burning is not allowed by the transaction capabilities.',
    [TransactionFailureReason.CapabilitiesManaBurningNotAllowed]: 'Mana burning is not allowed by the transaction capabilities.',
    [TransactionFailureReason.CapabilitiesAccountDestructionNotAllowed]: 'Account destruction is not allowed by the transaction capabilities.',
    [TransactionFailureReason.CapabilitiesAnchorDestructionNotAllowed]: 'Anchor destruction is not allowed by the transaction capabilities.',
    [TransactionFailureReason.CapabilitiesFoundryDestructionNotAllowed]: 'Foundry destruction is not allowed by the transaction capabilities.',
    [TransactionFailureReason.CapabilitiesNftDestructionNotAllowed]: 'NFT destruction is not allowed by the transaction capabilities.',
    [TransactionFailureReason.SemanticValidationFailed]: 'Semantic validation failed.',
};
//# sourceMappingURL=utxo.js.map