import { TokenUpdatePayload } from '../types.js'; import { Cbor, CborAccountAddress, CborMemo, TokenAmount, TokenId } from './index.js'; /** * Enum representing the types of token operations. */ export declare enum TokenOperationType { Transfer = "transfer", Mint = "mint", Burn = "burn", AddAllowList = "addAllowList", RemoveAllowList = "removeAllowList", AddDenyList = "addDenyList", RemoveDenyList = "removeDenyList", Pause = "pause", Unpause = "unpause" } export type Memo = CborMemo.Type | Uint8Array; /** * The structure of a PLT transfer. */ export type TokenTransfer = { /** The amount to transfer. */ amount: TokenAmount.Type; /** The recipient of the transfer. */ recipient: CborAccountAddress.Type; /** An optional memo for the transfer. A string will be CBOR encoded, while raw bytes are included in the * transaction as is. */ memo?: Memo; }; /** * Generic type for a token operation. * @template TokenOperationType - The type of the token operation. * @template T - The specific operation details. */ type TokenOperationGen = { [K in Type]: T; }; /** * Represents a token transfer operation. */ export type TokenTransferOperation = TokenOperationGen; /** * The structure of a PLT mint/burn operation. */ export type TokenSupplyUpdate = { /** The amount to mint/burn. */ amount: TokenAmount.Type; }; /** * Represents a token mint operation. */ export type TokenMintOperation = TokenOperationGen; /** * Represents a token burn operation. */ export type TokenBurnOperation = TokenOperationGen; /** * The structure of any list update operation for a PLT. */ export type TokenListUpdate = { /** The target of the list update. */ target: CborAccountAddress.Type; }; /** * Represents an operation to add an account to the allow list. */ export type TokenAddAllowListOperation = TokenOperationGen; /** * Represents an operation to remove an account from the allow list. */ export type TokenRemoveAllowListOperation = TokenOperationGen; /** * Represents an operation to add an account to the deny list. */ export type TokenAddDenyListOperation = TokenOperationGen; /** * Represents an operation to remove an account from the deny list. */ export type TokenRemoveDenyListOperation = TokenOperationGen; /** * Represents an operation to pause the execution any operation that involves token balance * changes. */ export type TokenPauseOperation = TokenOperationGen; /** * Represents an operation to unpause the execution any operation that involves token balance * changes. */ export type TokenUnpauseOperation = TokenOperationGen; /** * Union type representing all possible operations for a token. */ export type TokenOperation = TokenTransferOperation | TokenMintOperation | TokenBurnOperation | TokenAddAllowListOperation | TokenRemoveAllowListOperation | TokenAddDenyListOperation | TokenRemoveDenyListOperation | TokenPauseOperation | TokenUnpauseOperation; /** * Creates a payload for token operations. * This function encodes the provided token operation(s) into a CBOR format. * * @param tokenId - The unique identifier of the token for which the operation(s) is being performed. * @param operations - A single token operation or an array of token operations. * * @returns The encoded token governance payload. */ export declare function createTokenUpdatePayload(tokenId: TokenId.Type, operations: TokenOperation | TokenOperation[]): TokenUpdatePayload; /** * Represents a token operation (found when decoding) unknown to the SDK. */ export type UnknownTokenOperation = { [key: string]: unknown; }; /** * Decodes a token operation. * * @param cbor - The CBOR encoding to decode. * @returns The decoded token operation. * * @example * const op = decodeTokenOperation(cbor); * switch (true) { * case TokenOperationType.Transfer in op: { * const details = op[TokenOperationType.Transfer]; // type is known at this point. * console.log(details); * } * ... * default: console.warn('Unknown operation', op); * } */ export declare function decodeTokenOperation(cbor: Cbor.Type): TokenOperation | UnknownTokenOperation; /** * Decodes a list of token operations. * * @param cbor - The CBOR encoding to decode. * @returns The decoded token operations. * * @example * const ops = decodeTokenOperations(cbor); * ops.forEach(op => { * switch (true) { * case TokenOperationType.Transfer in op: { * const details = op[TokenOperationType.Transfer]; // type is known at this point. * console.log(details); * } * ... * default: console.warn('Unknown operation', op); * } * }); */ export declare function decodeTokenOperations(cbor: Cbor.Type): (TokenOperation | UnknownTokenOperation)[]; /** * Parses a token update payload, decoding the operations from CBOR format. * * @param payload - The token update payload to parse. * @returns The parsed token update payload with decoded operations. * * @example * const parsedPayload = parseTokenUpdatePayload(encodedPayload); * parsedPayload.operations.forEach(op => { * switch (true) { * case TokenOperationType.Transfer in op: { * const details = op[TokenOperationType.Transfer]; // type is known at this point. * console.log(details); * } * ... * default: console.warn('Unknown operation', op); * } * }); */ export declare function parseTokenUpdatePayload(payload: TokenUpdatePayload): Omit & { operations: (TokenOperation | UnknownTokenOperation)[]; }; export {};