ethers.js/lib.esm/abi/coders/abstract-coder.d.ts

117 lines
3.4 KiB
TypeScript
Raw Normal View History

2022-09-05 23:57:11 +03:00
import type { BigNumberish, BytesLike } from "../../utils/index.js";
2023-01-27 07:36:26 +03:00
/**
* @_ignore:
*/
2022-11-30 23:44:23 +03:00
export declare const WordSize: number;
/**
* A [[Result]] is a sub-class of Array, which allows accessing any
* of its values either positionally by its index or, if keys are
* provided by its name.
*
* @_docloc: api/abi
*/
2022-09-05 23:57:11 +03:00
export declare class Result extends Array<any> {
#private;
[K: string | number]: any;
2022-11-30 23:44:23 +03:00
/**
* @private
*/
2023-01-27 07:36:26 +03:00
constructor(...args: Array<any>);
/**
* Returns the Result as a normal Array.
*
* This will throw if there are any outstanding deferred
* errors.
*/
toArray(): Array<any>;
/**
* Returns the Result as an Object with each name-value pair.
*
* This will throw if any value is unnamed, or if there are
* any outstanding deferred errors.
*/
toObject(): Record<string, any>;
/**
* @_ignore
*/
slice(start?: number | undefined, end?: number | undefined): Result;
2022-11-30 23:44:23 +03:00
/**
* @_ignore
*/
2023-01-27 07:36:26 +03:00
filter(callback: (el: any, index: number, array: Result) => boolean, thisArg?: any): Result;
2022-11-30 23:44:23 +03:00
/**
* Returns the value for %%name%%.
*
* Since it is possible to have a key whose name conflicts with
* a method on a [[Result]] or its superclass Array, or any
* JavaScript keyword, this ensures all named values are still
* accessible by name.
*/
2022-09-05 23:57:11 +03:00
getValue(name: string): any;
2022-11-30 23:44:23 +03:00
/**
* Creates a new [[Result]] for %%items%% with each entry
* also accessible by its corresponding name in %%keys%%.
*/
2022-09-05 23:57:11 +03:00
static fromItems(items: Array<any>, keys?: Array<null | string>): Result;
}
2022-11-30 23:44:23 +03:00
/**
* Returns all errors found in a [[Result]].
*
* Since certain errors encountered when creating a [[Result]] do
* not impact the ability to continue parsing data, they are
* deferred until they are actually accessed. Hence a faulty string
* in an Event that is never used does not impact the program flow.
*
* However, sometimes it may be useful to access, identify or
* validate correctness of a [[Result]].
*
* @_docloc api/abi
*/
2022-09-05 23:57:11 +03:00
export declare function checkResultErrors(result: Result): Array<{
path: Array<string | number>;
error: Error;
}>;
2022-11-30 23:44:23 +03:00
/**
* @_ignore
*/
2022-09-05 23:57:11 +03:00
export declare abstract class Coder {
readonly name: string;
readonly type: string;
readonly localName: string;
readonly dynamic: boolean;
constructor(name: string, type: string, localName: string, dynamic: boolean);
_throwError(message: string, value: any): never;
abstract encode(writer: Writer, value: any): number;
abstract decode(reader: Reader): any;
abstract defaultValue(): any;
}
2022-11-30 23:44:23 +03:00
/**
* @_ignore
*/
2022-09-05 23:57:11 +03:00
export declare class Writer {
#private;
constructor();
get data(): string;
get length(): number;
appendWriter(writer: Writer): number;
writeBytes(value: BytesLike): number;
writeValue(value: BigNumberish): number;
writeUpdatableValue(): (value: BigNumberish) => void;
}
2022-11-30 23:44:23 +03:00
/**
* @_ignore
*/
2022-09-05 23:57:11 +03:00
export declare class Reader {
#private;
readonly allowLoose: boolean;
constructor(data: BytesLike, allowLoose?: boolean);
get data(): string;
get dataLength(): number;
get consumed(): number;
get bytes(): Uint8Array;
subReader(offset: number): Reader;
readBytes(length: number, loose?: boolean): Uint8Array;
readValue(): bigint;
readIndex(): number;
}
//# sourceMappingURL=abstract-coder.d.ts.map