import { CborAccountAddress, TokenAmount } from './index.js'; import { EncodedTokenModuleRejectReason } from './types.js'; export declare enum TokenRejectReasonType { AddressNotFound = "addressNotFound", TokenBalanceInsufficient = "tokenBalanceInsufficient", DeserializationFailure = "deserializationFailure", UnsupportedOperation = "unsupportedOperation", OperationNotPermitted = "operationNotPermitted", MintWouldOverflow = "mintWouldOverflow" } type RejectReasonGen = Omit & { /** The type of rejection. */ type: T; /** Additional details about the rejection. */ details: D; }; /** * Represents a token module reject reason (found when decoding) unknown to the SDK. */ export type UnknownTokenRejectReason = Omit & { /** Additional details about the rejection. */ details: unknown; }; /** * The details of an "addressNotFound": an account address was not valid. */ export type AddressNotFoundDetails = { /** The index in the list of operations of the failing operation. */ index: number; /** The address that could not be resolved. */ address: CborAccountAddress.Type; }; /** * An account address was not valid. */ export type AddressNotFoundRejectReason = RejectReasonGen; /** * Details for a reject reason where the account's token balance is insufficient * for the attempted operation. * * See CIS-7: reject-reasons/tokenBalanceInsufficient */ export type TokenBalanceInsufficientDetails = { /** The index in the list of operations of the failing operation. */ index: number; /** The available balance for the sender at the time of the operation. */ availableBalance: TokenAmount.Type; /** The minimum required balance to perform the operation. */ requiredBalance: TokenAmount.Type; }; /** Typed reject reason for "tokenBalanceInsufficient". */ export type TokenBalanceInsufficientRejectReason = RejectReasonGen; /** * Details for a reject reason where the operation payload could not be deserialized. * * See CIS-7: reject-reasons/deserializationFailure */ export type DeserializationFailureDetails = { /** Text description of the failure mode. */ cause?: string; }; /** Typed reject reason for "deserializationFailure". */ export type DeserializationFailureRejectReason = RejectReasonGen; /** * Details for a reject reason where the specified operation is not supported by the module. * * See CIS-7: reject-reasons/unsupportedOperation */ export type UnsupportedOperationDetails = { /** The index in the list of operations of the failing operation. */ index: number; /** The type of operation that was not supported. */ operationType: string; /** The reason why the operation was not supported. */ reason?: string; }; /** Typed reject reason for "unsupportedOperation". */ export type UnsupportedOperationRejectReason = RejectReasonGen; /** * Details for a reject reason where the operation is recognized but not permitted * under the current state or policy (e.g., paused, allow/deny list). * * See CIS-7: reject-reasons/operationNotPermitted */ export type OperationNotPermittedDetails = { /** The index in the list of operations of the failing operation. */ index: number; /** (Optionally) the address that does not have the necessary permissions to perform the operation. */ address?: CborAccountAddress.Type; /** The reason why the operation is not permitted. */ reason?: string; }; /** Typed reject reason for "operationNotPermitted". */ export type OperationNotPermittedRejectReason = RejectReasonGen; /** * Details for a reject reason where minting would overflow supply constraints. * * See CIS-7: reject-reasons/mintWouldOverflow */ export type MintWouldOverflowDetails = { /** The index in the list of operations of the failing operation. */ index: number; /** The requested amount to mint. */ requestedAmount: TokenAmount.Type; /** The current supply of the token. */ currentSupply: TokenAmount.Type; /** The maximum representable token amount. */ maxRepresentableAmount: TokenAmount.Type; }; /** Typed reject reason for "mintWouldOverflow". */ export type MintWouldOverflowRejectReason = RejectReasonGen; /** * Union of all token module reject reasons defined by CIS-7, * with strongly-typed details per reason. * * @see https://proposals.concordium.com/CIS/cis-7.html#reject-reasons */ export type TokenModuleRejectReason = AddressNotFoundRejectReason | TokenBalanceInsufficientRejectReason | DeserializationFailureRejectReason | UnsupportedOperationRejectReason | OperationNotPermittedRejectReason | MintWouldOverflowRejectReason; /** * Parses a token module reject reason, decoding the details from CBOR format. * * @param rejectReason - The token module reject reason to parse. * @returns The parsed token module reject reason with decoded details. * * @example * const parsedReason = parseTokenModuleRejectReason(encodedReason); * switch (parsedReason.type) { * // typed details are now available, e.g.: * case TokenRejectReasonType.MintWouldOverflow: console.log(parsedReason.requestedAmount); * ... * default: console.warn('Unknown reject reason:', parsedReason); * } */ export declare function parseTokenModuleRejectReason(rejectReason: EncodedTokenModuleRejectReason): TokenModuleRejectReason | UnknownTokenRejectReason; export {};