/******************************************************************************* * (c) 2023 unipackage * * Licensed under either the MIT License (the "MIT License") or the Apache License, Version 2.0 * (the "Apache License"). You may not use this file except in compliance with one of these * licenses. You may obtain a copy of the MIT License at * * https://opensource.org/licenses/MIT * * Or the Apache License, Version 2.0 at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the MIT License or the Apache License for the specific language governing permissions and * limitations under the respective licenses. ********************************************************************************/ import { Result } from "@unipackage/utils"; import { JsonFragment } from "ethers"; import { AbiFunctionFragment } from "web3"; import { EvmTransactionOptions } from "../../interface"; import { IWallet } from "../../interface/wallet"; /** * Represents a parsed data object. * The keys are string representations, and the values can be of any type. */ export type EvmReplyData = { [key: string]: any; }; /** * Converts the output array of a function call to an object using ABI and method name. * * @param abi An array containing fragments (AbiFunctionFragment or JsonFragment). * @param name The name of the method to search for. * @param type The type of the method to search for. * @param data The output array of a function call. * @param isInputs true:inputs,false:output * @returns The converted object. Returns undefined if the output array is empty, or the single element if there's only one. * @throws Throws an error if the ABI function fragment is undefined. */ export declare function convertArrayToObjectByAbiAndName(abi: AbiFunctionFragment[] | JsonFragment[], type: string, name: string, data: any[], isInputs?: boolean): any; /** * Converts the output array of a function call to an object. * * @param abi The ABI information of the function, including the output parameters. * @param data The output array of a function call. * @param isInputs true:inputs,false:output * @returns The converted object. Returns undefined if the output array is empty, or the single element if there's only one. */ export declare function convertArrayToObjectByAbiFragment(abi: AbiFunctionFragment | JsonFragment, data: any[], isInputs?: boolean): any; /** * Retrieves a fragment from the ABI based on the method name. * * @param abi An array containing fragments (AbiFunctionFragment or JsonFragment). * @param name The name of the method to search for. * @param type The type of the method to search for. * @returns The matching AbiFunctionFragment or JsonFragment object, or undefined if not found. */ export declare function getAbiFragmentByMethodName(abi: AbiFunctionFragment[] | JsonFragment[], type: string, name: string): AbiFunctionFragment | JsonFragment | undefined; /** * Gets the encoded parameters from the transaction input. * * @param txInput - The transaction input. * @returns Result object with the encoded parameters. */ export declare function getEncodedParamsFromTxinput(txInput: string): Result; /** * Gets the function signatureFromInput from the transaction input. * * @param txInput - The transaction input. * @returns Result object with the encoded function name. */ export declare function getFunctionSignatureFromTxinput(txInput: string): Result; /** * Parse data object. * * @param data - The data object. * @returns Parsed data as a record. */ export declare function parseEvmReplyData(data: any): Array | any; /** * Retrieves the address from which the transaction should originate. * * If the `options.from` field is provided, it returns that address. * Otherwise, it attempts to retrieve the default address from the provided wallet. * * @param wallet - The wallet from which to retrieve the default address. * @param options - Transaction options that may contain the `from` address. * @returns The address from which the transaction should originate. */ export declare function getFromAddress(wallet: IWallet, options?: EvmTransactionOptions): string; /** * Retrieves the private key corresponding to the address from which the transaction should originate. * * If the `options.privateKey` field is provided, it returns that private key. * Otherwise, it attempts to retrieve the private key corresponding to the default address from the provided wallet. * * @param wallet - The wallet from which to retrieve the default address and its corresponding private key. * @param options - Transaction options that may contain the `privateKey` or `from` address. * @returns The private key corresponding to the address from which the transaction should originate. */ export declare function getFromPrivateKey(wallet: IWallet, options?: EvmTransactionOptions): string; /** * Recursively converts an object of type Result from the ethers package to a plain array. * @param {any} result - The object to be converted. * @returns {any} - The converted object. */ export declare function unwrapEthersResult(result: any): any; //# sourceMappingURL=index.d.ts.map