2022-11-30 23:44:23 +03:00
|
|
|
/**
|
|
|
|
* When sending values to or receiving values from a [[Contract]], the
|
2023-03-04 04:25:07 +03:00
|
|
|
* data is generally encoded using the [ABI standard](link-solc-abi).
|
2022-11-30 23:44:23 +03:00
|
|
|
*
|
|
|
|
* The AbiCoder provides a utility to encode values to ABI data and
|
|
|
|
* decode values from ABI data.
|
|
|
|
*
|
|
|
|
* Most of the time, developers should favour the [[Contract]] class,
|
|
|
|
* which further abstracts a lot of the finer details of ABI data.
|
|
|
|
*
|
|
|
|
* @_section api/abi/abi-coder:ABI Encoding
|
|
|
|
*/
|
2022-09-05 23:57:11 +03:00
|
|
|
import { Result } from "./coders/abstract-coder.js";
|
|
|
|
import { ParamType } from "./fragments.js";
|
2022-10-20 12:03:32 +03:00
|
|
|
import type { BytesLike, CallExceptionAction, CallExceptionError } from "../utils/index.js";
|
2022-11-30 23:44:23 +03:00
|
|
|
/**
|
2023-06-02 00:52:58 +03:00
|
|
|
* The **AbiCoder** is a low-level class responsible for encoding JavaScript
|
|
|
|
* values into binary data and decoding binary data into JavaScript values.
|
|
|
|
*/
|
2022-09-05 23:57:11 +03:00
|
|
|
export declare class AbiCoder {
|
|
|
|
#private;
|
2022-11-30 23:44:23 +03:00
|
|
|
/**
|
|
|
|
* Get the default values for the given %%types%%.
|
|
|
|
*
|
|
|
|
* For example, a ``uint`` is by default ``0`` and ``bool``
|
|
|
|
* is by default ``false``.
|
|
|
|
*/
|
2022-09-05 23:57:11 +03:00
|
|
|
getDefaultValue(types: ReadonlyArray<string | ParamType>): Result;
|
2022-11-30 23:44:23 +03:00
|
|
|
/**
|
|
|
|
* Encode the %%values%% as the %%types%% into ABI data.
|
|
|
|
*
|
|
|
|
* @returns DataHexstring
|
|
|
|
*/
|
2022-09-05 23:57:11 +03:00
|
|
|
encode(types: ReadonlyArray<string | ParamType>, values: ReadonlyArray<any>): string;
|
2022-11-30 23:44:23 +03:00
|
|
|
/**
|
|
|
|
* Decode the ABI %%data%% as the %%types%% into values.
|
|
|
|
*
|
|
|
|
* If %%loose%% decoding is enabled, then strict padding is
|
|
|
|
* not enforced. Some older versions of Solidity incorrectly
|
|
|
|
* padded event data emitted from ``external`` functions.
|
|
|
|
*/
|
2022-09-05 23:57:11 +03:00
|
|
|
decode(types: ReadonlyArray<string | ParamType>, data: BytesLike, loose?: boolean): Result;
|
2022-11-30 23:44:23 +03:00
|
|
|
/**
|
|
|
|
* Returns the shared singleton instance of a default [[AbiCoder]].
|
|
|
|
*
|
|
|
|
* On the first call, the instance is created internally.
|
|
|
|
*/
|
|
|
|
static defaultAbiCoder(): AbiCoder;
|
|
|
|
/**
|
2023-02-13 06:14:26 +03:00
|
|
|
* Returns an ethers-compatible [[CallExceptionError]] Error for the given
|
2022-11-30 23:44:23 +03:00
|
|
|
* result %%data%% for the [[CallExceptionAction]] %%action%% against
|
|
|
|
* the Transaction %%tx%%.
|
|
|
|
*/
|
|
|
|
static getBuiltinCallException(action: CallExceptionAction, tx: {
|
|
|
|
to?: null | string;
|
|
|
|
from?: null | string;
|
|
|
|
data?: string;
|
|
|
|
}, data: null | BytesLike): CallExceptionError;
|
2022-09-05 23:57:11 +03:00
|
|
|
}
|
|
|
|
//# sourceMappingURL=abi-coder.d.ts.map
|