import { AliasEntity, Artifact, ContractEntity, LibraryEntity, StaticEntity, StructEntity } from './types/artifact.js'; import { Arguments, TypeResolver } from './types/abi.js'; import { StructObject, SupportedParamType } from './types/primitives.js'; import { Script } from './types/script.js'; /** * @ignore */ export declare function buildTypeResolverFromArtifact(artifact: Artifact): TypeResolver; /** * @ignore */ export declare function hasGeneric(entity: StructEntity | LibraryEntity): boolean; /** * build a resolver which can only resolve type * @ignore */ export declare function buildTypeResolver(_contract: string, _alias: AliasEntity[], structs: StructEntity[], library: LibraryEntity[], contracts?: ContractEntity[], _statics?: StaticEntity[]): TypeResolver; /** * ABI encoding and decoding utility for smart contracts. * @ignore * This class provides methods to: * - Encode constructor calls and public function calls into scripts * - Decode public function calls from unlocking scripts * - Check if a method is a public function * - Handle various parameter types including arrays, structs, and libraries * - Validate arguments against contract ABI definitions * * The coder uses the contract's artifact which contains the ABI and hex template * to properly encode and decode contract interactions. */ export declare class ABICoder { readonly artifact: Artifact; constructor(artifact: Artifact); /** * Encodes constructor arguments into a script using the contract's ABI. * Validates that all required parameters are present in the ASM template. * * @param ctorArgs - Array of constructor arguments to encode * @returns Script containing the encoded constructor call * @throws Error if any required parameter is missing from the ASM template */ encodeConstructorCall(ctorArgs: SupportedParamType[]): Script; /** * Checks if the given method name is a public function in the contract's ABI. * @param method - The name of the method to check. * @returns True if the method exists as a public function in the ABI, false otherwise. */ isPubFunction(method: string): boolean; /** * Encodes a public function call into a script by flattening and serializing the arguments. * * @param method - The name of the public function to call. * @param args - The arguments to pass to the function. * @returns A script containing the encoded function call. * @throws Error if the specified public function is not found in the contract ABI. */ encodePubFunctionCall(method: string, args: SupportedParamType[]): Script; /** * Decodes a public function call from an unlocking script. * * @param unlockingScript - The unlocking script to decode, which can be provided as a Script object, Uint8Array, or hex string. * @returns An object containing the decoded method name and arguments. * @throws {Error} If no public function is found in the contract, or if the unlocking script doesn't match the contract's ABI. * * The function handles both single-function contracts and contracts with multiple public functions. * For multi-function contracts, it extracts the function index from the unlocking script ASM. * Validates argument count and decodes each argument using the contract's type resolver. */ decodePubFunctionCall(unlockingScript: Script | Uint8Array | string): { method: string; args: Arguments; }; /** * Flattens a struct object into Arguments format using the contract's ABI type resolver. * @param arg - The struct object to flatten * @param type - The type definition of the struct * @param ignoreValue - Whether to ignore the actual values (default: false) * @returns The flattened arguments representation of the struct */ flattenStruct(arg: StructObject, type: string, ignoreValue?: boolean): Arguments; /** * Transforms input arguments according to parameter definitions. * @param args - Input arguments to transform * @param params - Parameter definitions to use for transformation * @returns Array of transformed arguments */ private transformerArgs; /** * Transforms a contract argument based on its parameter type definition. * Handles array, library, struct, and numeric type conversions recursively. * * @param arg - The input argument to transform * @param param - The parameter type definition from the ABI * @returns The transformed argument matching the expected parameter type */ private transformerArg; } //# sourceMappingURL=abi.d.ts.map