import type * as Proto from '../grpc-api/v2/concordium/protocol-level-tokens.js'; import type { HexString } from '../types.js'; export type JSON = HexString; /** * Enum representing the types of errors that can occur with token module references. */ export declare enum ErrorType { /** Error type indicating the length of module reference is incorrect. */ INCORRECT_LENGTH = "INCORRECT_LENGTH" } /** * Custom error to represent issues with token module references. */ export declare class Err extends Error { /** The {@linkcode ErrorType} of the error. Can be used as to distinguish different types of errors. */ readonly type: ErrorType; private constructor(); /** * Creates a TokenModuleReference.Err indicating the length of module reference is incorrect. */ static incorrectLength(bytes: Uint8Array): Err; } /** * Reference to a protocol level token (PLT) module. */ declare class ModuleReference { #private; /** Internal field, buffer containing the 32 bytes for the module reference. */ readonly bytes: Uint8Array; /** * Constructs a new ModuleReference instance. * Validates that the value is exactly the accepted byte length. * * @throws {Err} If the value is not exactly 32 bytes. */ constructor( /** Internal field, buffer containing the 32 bytes for the module reference. */ bytes: Uint8Array); /** * Get a string representation of the module reference. * @returns {string} The string representation. */ toString(): string; /** * Get a JSON-serializable representation of the module reference. This is called implicitly when serialized with JSON.stringify. * @returns {HexString} The JSON representation. */ toJSON(): JSON; } /** * Reference to a smart contract module. */ export type Type = ModuleReference; /** * Type predicate for {@linkcode Type} * * @param value value to check. * @returns whether `value` is of type {@linkcode Type} */ export declare function instanceOf(value: unknown): value is ModuleReference; /** * Create a ModuleReference from a buffer of 32 bytes. * @param {ArrayBuffer} buffer Buffer containing 32 bytes for the hash. * @throws If the provided buffer does not contain exactly 32 bytes. * @returns {ModuleReference} A module reference. * @throws {Err} If the value is not exactly 32 bytes. */ export declare function fromBuffer(buffer: ArrayBuffer): ModuleReference; /** * Create a ModuleReference from a hex string. * @param {HexString} moduleRef Hex encoding of the module reference. * @throws If the provided hex encoding does not correspond to a buffer of exactly 32 bytes. * @returns {ModuleReference} A module reference. * @throws {Err} If the value is not exactly 32 bytes. */ export declare function fromHexString(moduleRef: HexString): ModuleReference; /** * Get the module reference bytes encoded as hex. * @param {ModuleReference} moduleReference The module reference. * @returns {HexString} String with hex encoding. */ export declare function toHexString(moduleReference: ModuleReference): HexString; /** * Converts a {@linkcode HexString} to a module reference. * @param {HexString} json The JSON representation of the module reference. * @returns {ModuleReference} The module reference. * @throws {Err} If the value is not exactly 32 bytes. */ export declare function fromJSON(json: JSON): ModuleReference; /** * Convert module reference from its protobuf encoding. * @param {Proto.TokenModuleRef} moduleReference The module reference in protobuf. * @returns {ModuleReference} The module reference. * @throws {Err} If the value is not exactly 32 bytes. */ export declare function fromProto(moduleReference: Proto.TokenModuleRef): ModuleReference; /** * Convert module reference into its protobuf encoding. * @param {ModuleReference} moduleReference The module reference. * @returns {Proto.TokenModuleRef} The protobuf encoding. */ export declare function toProto(moduleReference: ModuleReference): Proto.TokenModuleRef; /** * Check if two module references are the same. * @param {ModuleReference} left * @param {ModuleReference} right * @returns {boolean} True if they are equal. */ export declare function equals(left: ModuleReference, right: ModuleReference): boolean; export {};