Fixed commonjs imports missing types (#3703).

This commit is contained in:
Richard Moore 2023-02-02 22:04:33 -05:00
parent de2b1f66c6
commit 6cae18328d
169 changed files with 7721 additions and 0 deletions

View File

@ -0,0 +1,84 @@
export type TestBlockchainNetwork = "mainnet" | "goerli";
export interface TestBlockchainAddress {
test: string;
address: string;
code?: string;
nonce?: number;
name?: string;
balance?: bigint;
storage?: Record<string, string>;
}
export interface TestBlockchainBlock {
test: string;
hash: string;
parentHash: string;
number: number;
timestamp: number;
nonce: string;
difficulty: bigint;
gasLimit: bigint;
gasUsed: bigint;
miner: string;
extraData: string;
transactions: Array<string>;
baseFeePerGas?: bigint;
}
export interface TestBlockchainTransaction {
test: string;
hash: string;
blockHash: string;
blockNumber: number;
type: number;
from: string;
gasPrice: bigint;
gasLimit: bigint;
to: string;
value: bigint;
nonce: number;
data: string;
signature: {
r: string;
s: string;
yParity: 0 | 1;
v: number;
networkV: null | bigint;
};
creates: null | string;
chainId: bigint;
accessList?: Array<Record<string, Array<string>>>;
maxPriorityFeePerGas?: bigint;
maxFeePerGas?: bigint;
}
export interface TestBlockchainReceipt {
test: string;
blockHash: string;
blockNumber: number;
type: number;
contractAddress: null | string;
cumulativeGasUsed: bigint;
from: string;
gasUsed: bigint;
gasPrice: bigint;
logs: Array<{
address: string;
blockHash: string;
blockNumber: number;
data: string;
index: number;
topics: Array<string>;
transactionHash: string;
transactionIndex: number;
}>;
logsBloom: string;
root: null | string;
status: null | number;
to: string;
hash: string;
index: number;
}
export declare const testAddress: Record<TestBlockchainNetwork, Array<TestBlockchainAddress>>;
export declare const testBlock: Record<TestBlockchainNetwork, Array<TestBlockchainBlock>>;
export declare const testTransaction: Record<TestBlockchainNetwork, Array<TestBlockchainTransaction>>;
export declare const testReceipt: Record<TestBlockchainNetwork, Array<TestBlockchainReceipt>>;
export declare const networkNames: Array<TestBlockchainNetwork>;
export declare function networkFeatureAtBlock(feature: string, block: number): boolean;

View File

@ -0,0 +1,7 @@
import type { AbstractProvider } from "../index.js";
export declare function setupProviders(): void;
export declare const providerNames: readonly string[];
export declare function getProviderNetworks(provider: string): Array<string>;
export declare function getProvider(provider: string, network: string): null | AbstractProvider;
export declare function checkProvider(provider: string, network: string): boolean;
export declare function connect(network: string): AbstractProvider;

1
lib.commonjs/_tests/test-abi.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export {};

1
lib.commonjs/_tests/test-address.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1 @@
export {};

1
lib.commonjs/_tests/test-crypto.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1 @@
export {};

1
lib.commonjs/_tests/test-hash.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1 @@
export {};

1
lib.commonjs/_tests/test-rlp.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,12 @@
export type TestCaseBadString = {
name: string;
bytes: Uint8Array;
ignore: string;
replace: string;
error: string;
};
export type TestCaseCodePoints = {
name: string;
text: string;
codepoints: Array<number>;
};

View File

@ -0,0 +1,6 @@
declare global {
class TextDecoder {
decode(data: Uint8Array): string;
}
}
export {};

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1 @@
export {};

1
lib.commonjs/_tests/test-wallet.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1 @@
export {};

216
lib.commonjs/_tests/types.d.ts vendored Normal file
View File

@ -0,0 +1,216 @@
export type TestCaseAbiVerbose = {
type: "address" | "hexstring" | "number" | "string";
value: string;
} | {
type: "boolean";
value: boolean;
} | {
type: "array";
value: Array<TestCaseAbiVerbose>;
} | {
type: "object";
value: Array<TestCaseAbiVerbose>;
};
export interface TestCaseAbi {
name: string;
type: string;
value: any;
verbose: TestCaseAbiVerbose;
bytecode: string;
encoded: string;
}
export interface TestCaseAccount {
name: string;
privateKey: string;
address: string;
icap: string;
}
export type TestCaseCreate = {
sender: string;
creates: Array<{
name: string;
nonce: number;
address: string;
}>;
};
export type TestCaseCreate2 = {
sender: string;
creates: Array<{
name: string;
salt: string;
initCode: string;
initCodeHash: string;
address: string;
}>;
};
export interface TestCaseHash {
name: string;
data: string;
sha256: string;
sha512: string;
ripemd160: string;
keccak256: string;
}
export interface TestCasePbkdf {
name: string;
password: string;
salt: string;
dkLen: number;
pbkdf2: {
iterations: number;
algorithm: "sha256" | "sha512";
key: string;
};
scrypt: {
N: number;
r: number;
p: number;
key: string;
};
}
export interface TestCaseHmac {
name: string;
data: string;
key: string;
algorithm: "sha256" | "sha512";
hmac: string;
}
export interface TestCaseHash {
name: string;
data: string;
sha256: string;
sha512: string;
ripemd160: string;
keccak256: string;
}
export interface TestCaseNamehash {
name: string;
ensName: string;
error?: string;
namehash?: string;
}
export interface TestCaseTypedDataDomain {
name?: string;
version?: string;
chainId?: number;
verifyingContract?: string;
salt?: string;
}
export interface TestCaseTypedDataType {
name: string;
type: string;
}
export interface TestCaseTypedData {
name: string;
domain: TestCaseTypedDataDomain;
primaryType: string;
types: Record<string, Array<TestCaseTypedDataType>>;
data: any;
encoded: string;
digest: string;
privateKey?: string;
signature?: string;
}
export interface TestCaseSolidityHash {
name: string;
types: Array<string>;
keccak256: string;
ripemd160: string;
sha256: string;
values: Array<any>;
}
export interface TestCaseUnit {
name: string;
wei: string;
ethers: string;
ether_format: string;
kwei?: string;
mwei?: string;
gwei?: string;
szabo?: string;
finney?: string;
finney_format?: string;
szabo_format?: string;
gwei_format?: string;
mwei_format?: string;
kwei_format?: string;
}
export type NestedHexString = string | Array<string | NestedHexString>;
export interface TestCaseRlp {
name: string;
encoded: string;
decoded: NestedHexString;
}
export interface TestCaseTransactionTx {
to?: string;
nonce?: number;
gasLimit?: string;
gasPrice?: string;
maxFeePerGas?: string;
maxPriorityFeePerGas?: string;
data?: string;
value?: string;
accessList?: Array<{
address: string;
storageKeys: Array<string>;
}>;
chainId?: string;
}
export interface TestCaseTransactionSig {
r: string;
s: string;
v: string;
}
export interface TestCaseTransaction {
name: string;
transaction: TestCaseTransactionTx;
privateKey: string;
unsignedLegacy: string;
signedLegacy: string;
unsignedEip155: string;
signedEip155: string;
unsignedBerlin: string;
signedBerlin: string;
unsignedLondon: string;
signedLondon: string;
signatureLegacy: TestCaseTransactionSig;
signatureEip155: TestCaseTransactionSig;
signatureBerlin: TestCaseTransactionSig;
signatureLondon: TestCaseTransactionSig;
}
export interface TestCaseMnemonicNode {
path: string;
chainCode: string;
depth: number;
index: number;
parentFingerprint: string;
fingerprint: string;
publicKey: string;
privateKey: string;
xpriv: string;
xpub: string;
}
export interface TestCaseMnemonic {
name: string;
phrase: string;
phraseHash: string;
password: string;
locale: string;
entropy: string;
seed: string;
nodes: Array<TestCaseMnemonicNode>;
}
export interface TestCaseWallet {
name: string;
filename: string;
type: string;
address: string;
password: string;
content: string;
}
export interface TestCaseWordlist {
name: string;
filename: string;
locale: string;
content: string;
}

8
lib.commonjs/_tests/utils.d.ts vendored Normal file
View File

@ -0,0 +1,8 @@
export declare function loadTests<T>(tag: string): Array<T>;
export declare function log(context: any, text: string): void;
export declare function stall(duration: number): Promise<void>;
export interface MochaRunnable {
timeout: (value: number) => void;
skip: () => void;
}
export declare function retryIt(name: string, func: (this: MochaRunnable) => Promise<void>): Promise<void>;

1
lib.commonjs/_version.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export declare const version: string;

58
lib.commonjs/abi/abi-coder.d.ts vendored Normal file
View File

@ -0,0 +1,58 @@
/**
* When sending values to or receiving values from a [[Contract]], the
* data is generally encoded using the [ABI standard](solc-abi-standard).
*
* 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
*/
import { Result } from "./coders/abstract-coder.js";
import { ParamType } from "./fragments.js";
import type { BytesLike, CallExceptionAction, CallExceptionError } from "../utils/index.js";
/**
* About AbiCoder
*/
export declare class AbiCoder {
#private;
/**
* Get the default values for the given %%types%%.
*
* For example, a ``uint`` is by default ``0`` and ``bool``
* is by default ``false``.
*/
getDefaultValue(types: ReadonlyArray<string | ParamType>): Result;
/**
* Encode the %%values%% as the %%types%% into ABI data.
*
* @returns DataHexstring
*/
encode(types: ReadonlyArray<string | ParamType>, values: ReadonlyArray<any>): string;
/**
* 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.
*/
decode(types: ReadonlyArray<string | ParamType>, data: BytesLike, loose?: boolean): Result;
/**
* Returns the shared singleton instance of a default [[AbiCoder]].
*
* On the first call, the instance is created internally.
*/
static defaultAbiCoder(): AbiCoder;
/**
* Returns an ethers-compatible [[CALL_EXCEPTION]] Error for the given
* 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;
}

14
lib.commonjs/abi/bytes32.d.ts vendored Normal file
View File

@ -0,0 +1,14 @@
/**
* About bytes32 strings...
*
* @_docloc: api/utils:Bytes32 Strings
*/
import type { BytesLike } from "../utils/index.js";
/**
* Encodes %%text%% as a Bytes32 string.
*/
export declare function encodeBytes32String(text: string): string;
/**
* Encodes the Bytes32-encoded %%bytes%% into a string.
*/
export declare function decodeBytes32String(_bytes: BytesLike): string;

View File

@ -0,0 +1,116 @@
import type { BigNumberish, BytesLike } from "../../utils/index.js";
/**
* @_ignore:
*/
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
*/
export declare class Result extends Array<any> {
#private;
[K: string | number]: any;
/**
* @private
*/
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;
/**
* @_ignore
*/
filter(callback: (el: any, index: number, array: Result) => boolean, thisArg?: any): Result;
/**
* 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.
*/
getValue(name: string): any;
/**
* Creates a new [[Result]] for %%items%% with each entry
* also accessible by its corresponding name in %%keys%%.
*/
static fromItems(items: Array<any>, keys?: Array<null | string>): Result;
}
/**
* 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
*/
export declare function checkResultErrors(result: Result): Array<{
path: Array<string | number>;
error: Error;
}>;
/**
* @_ignore
*/
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;
}
/**
* @_ignore
*/
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;
}
/**
* @_ignore
*/
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;
}

12
lib.commonjs/abi/coders/address.d.ts vendored Normal file
View File

@ -0,0 +1,12 @@
import { Typed } from "../typed.js";
import { Coder } from "./abstract-coder.js";
import type { Reader, Writer } from "./abstract-coder.js";
/**
* @_ignore
*/
export declare class AddressCoder extends Coder {
constructor(localName: string);
defaultValue(): string;
encode(writer: Writer, _value: string | Typed): number;
decode(reader: Reader): any;
}

14
lib.commonjs/abi/coders/anonymous.d.ts vendored Normal file
View File

@ -0,0 +1,14 @@
import { Coder } from "./abstract-coder.js";
import type { Reader, Writer } from "./abstract-coder.js";
/**
* Clones the functionality of an existing Coder, but without a localName
*
* @_ignore
*/
export declare class AnonymousCoder extends Coder {
private coder;
constructor(coder: Coder);
defaultValue(): any;
encode(writer: Writer, value: any): number;
decode(reader: Reader): any;
}

24
lib.commonjs/abi/coders/array.d.ts vendored Normal file
View File

@ -0,0 +1,24 @@
import { Typed } from "../typed.js";
import { Coder, Result, Writer } from "./abstract-coder.js";
import type { Reader } from "./abstract-coder.js";
/**
* @_ignore
*/
export declare function pack(writer: Writer, coders: ReadonlyArray<Coder>, values: Array<any> | {
[name: string]: any;
}): number;
/**
* @_ignore
*/
export declare function unpack(reader: Reader, coders: ReadonlyArray<Coder>): Result;
/**
* @_ignore
*/
export declare class ArrayCoder extends Coder {
readonly coder: Coder;
readonly length: number;
constructor(coder: Coder, length: number, localName: string);
defaultValue(): Array<any>;
encode(writer: Writer, _value: Array<any> | Typed): number;
decode(reader: Reader): any;
}

12
lib.commonjs/abi/coders/boolean.d.ts vendored Normal file
View File

@ -0,0 +1,12 @@
import { Typed } from "../typed.js";
import { Coder } from "./abstract-coder.js";
import type { Reader, Writer } from "./abstract-coder.js";
/**
* @_ignore
*/
export declare class BooleanCoder extends Coder {
constructor(localName: string);
defaultValue(): boolean;
encode(writer: Writer, _value: boolean | Typed): number;
decode(reader: Reader): any;
}

18
lib.commonjs/abi/coders/bytes.d.ts vendored Normal file
View File

@ -0,0 +1,18 @@
import { Coder } from "./abstract-coder.js";
import type { Reader, Writer } from "./abstract-coder.js";
/**
* @_ignore
*/
export declare class DynamicBytesCoder extends Coder {
constructor(type: string, localName: string);
defaultValue(): string;
encode(writer: Writer, value: any): number;
decode(reader: Reader): any;
}
/**
* @_ignore
*/
export declare class BytesCoder extends DynamicBytesCoder {
constructor(localName: string);
decode(reader: Reader): any;
}

View File

@ -0,0 +1,14 @@
import { Typed } from "../typed.js";
import { Coder } from "./abstract-coder.js";
import type { BytesLike } from "../../utils/index.js";
import type { Reader, Writer } from "./abstract-coder.js";
/**
* @_ignore
*/
export declare class FixedBytesCoder extends Coder {
readonly size: number;
constructor(size: number, localName: string);
defaultValue(): string;
encode(writer: Writer, _value: BytesLike | Typed): number;
decode(reader: Reader): any;
}

11
lib.commonjs/abi/coders/null.d.ts vendored Normal file
View File

@ -0,0 +1,11 @@
import { Coder } from "./abstract-coder.js";
import type { Reader, Writer } from "./abstract-coder.js";
/**
* @_ignore
*/
export declare class NullCoder extends Coder {
constructor(localName: string);
defaultValue(): null;
encode(writer: Writer, value: any): number;
decode(reader: Reader): any;
}

15
lib.commonjs/abi/coders/number.d.ts vendored Normal file
View File

@ -0,0 +1,15 @@
import { Typed } from "../typed.js";
import { Coder } from "./abstract-coder.js";
import type { BigNumberish } from "../../utils/index.js";
import type { Reader, Writer } from "./abstract-coder.js";
/**
* @_ignore
*/
export declare class NumberCoder extends Coder {
readonly size: number;
readonly signed: boolean;
constructor(size: number, signed: boolean, localName: string);
defaultValue(): number;
encode(writer: Writer, _value: BigNumberish | Typed): number;
decode(reader: Reader): any;
}

12
lib.commonjs/abi/coders/string.d.ts vendored Normal file
View File

@ -0,0 +1,12 @@
import { Typed } from "../typed.js";
import { DynamicBytesCoder } from "./bytes.js";
import type { Reader, Writer } from "./abstract-coder.js";
/**
* @_ignore
*/
export declare class StringCoder extends DynamicBytesCoder {
constructor(localName: string);
defaultValue(): string;
encode(writer: Writer, _value: string | Typed): number;
decode(reader: Reader): any;
}

15
lib.commonjs/abi/coders/tuple.d.ts vendored Normal file
View File

@ -0,0 +1,15 @@
import { Typed } from "../typed.js";
import { Coder } from "./abstract-coder.js";
import type { Reader, Writer } from "./abstract-coder.js";
/**
* @_ignore
*/
export declare class TupleCoder extends Coder {
readonly coders: ReadonlyArray<Coder>;
constructor(coders: Array<Coder>, localName: string);
defaultValue(): any;
encode(writer: Writer, _value: Array<any> | {
[name: string]: any;
} | Typed): number;
decode(reader: Reader): any;
}

372
lib.commonjs/abi/fragments.d.ts vendored Normal file
View File

@ -0,0 +1,372 @@
/**
* About frgaments...
*
* @_subsection api/abi/abi-coder:Fragments
*/
/**
* A type description in a JSON API.
*/
export interface JsonFragmentType {
/**
* The parameter name.
*/
readonly name?: string;
/**
* If the parameter is indexed.
*/
readonly indexed?: boolean;
/**
* The type of the parameter.
*/
readonly type?: string;
/**
* The internal Solidity type.
*/
readonly internalType?: string;
/**
* The components for a tuple.
*/
readonly components?: ReadonlyArray<JsonFragmentType>;
}
/**
* A fragment for a method, event or error in a JSON API.
*/
export interface JsonFragment {
/**
* The name of the error, event, function, etc.
*/
readonly name?: string;
/**
* The type of the fragment (e.g. ``event``, ``"function"``, etc.)
*/
readonly type?: string;
/**
* If the event is anonymous.
*/
readonly anonymous?: boolean;
/**
* If the function is payable.
*/
readonly payable?: boolean;
/**
* If the function is constant.
*/
readonly constant?: boolean;
/**
* The mutability state of the function.
*/
readonly stateMutability?: string;
/**
* The input parameters.
*/
readonly inputs?: ReadonlyArray<JsonFragmentType>;
/**
* The output parameters.
*/
readonly outputs?: ReadonlyArray<JsonFragmentType>;
/**
* The gas limit to use when sending a transaction for this function.
*/
readonly gas?: string;
}
/**
* The format to serialize the output as.
*/
export type FormatType = "sighash" | "minimal" | "full" | "json";
/**
* When [walking](ParamType-walk) a [[ParamType]], this is called
* on each component.
*/
export type ParamTypeWalkFunc = (type: string, value: any) => any;
/**
* When [walking asynchronously](ParamType-walkAsync) a [[ParamType]],
* this is called on each component.
*/
export type ParamTypeWalkAsyncFunc = (type: string, value: any) => any | Promise<any>;
/**
* Each input and output of a [[Fragment]] is an Array of **PAramType**.
*/
export declare class ParamType {
#private;
/**
* The local name of the parameter (or ``""`` if unbound)
*/
readonly name: string;
/**
* The fully qualified type (e.g. ``"address"``, ``"tuple(address)"``,
* ``"uint256[3][]"``)
*/
readonly type: string;
/**
* The base type (e.g. ``"address"``, ``"tuple"``, ``"array"``)
*/
readonly baseType: string;
/**
* True if the parameters is indexed.
*
* For non-indexable types (see [[ParamType_isIndexable]]) this
* is ``null``.
*/
readonly indexed: null | boolean;
/**
* The components for the tuple.
*
* For non-tuple types (see [[ParamType_isTuple]]) this is ``null``.
*/
readonly components: null | ReadonlyArray<ParamType>;
/**
* The array length, or ``-1`` for dynamic-lengthed arrays.
*
* For non-array types (see [[ParamType_isArray]]) this is ``null``.
*/
readonly arrayLength: null | number;
/**
* The type of each child in the array.
*
* For non-array types (see [[ParamType_isArray]]) this is ``null``.
*/
readonly arrayChildren: null | ParamType;
/**
* @private
*/
constructor(guard: any, name: string, type: string, baseType: string, indexed: null | boolean, components: null | ReadonlyArray<ParamType>, arrayLength: null | number, arrayChildren: null | ParamType);
/**
* Return a string representation of this type.
*
* For example,
*
* ``sighash" => "(uint256,address)"``
*
* ``"minimal" => "tuple(uint256,address) indexed"``
*
* ``"full" => "tuple(uint256 foo, address bar) indexed baz"``
*/
format(format?: FormatType): string;
/**
* Returns true if %%this%% is an Array type.
*
* This provides a type gaurd ensuring that [[arrayChildren]]
* and [[arrayLength]] are non-null.
*/
isArray(): this is (ParamType & {
arrayChildren: ParamType;
arrayLength: number;
});
/**
* Returns true if %%this%% is a Tuple type.
*
* This provides a type gaurd ensuring that [[components]]
* is non-null.
*/
isTuple(): this is (ParamType & {
components: ReadonlyArray<ParamType>;
});
/**
* Returns true if %%this%% is an Indexable type.
*
* This provides a type gaurd ensuring that [[indexed]]
* is non-null.
*/
isIndexable(): this is (ParamType & {
indexed: boolean;
});
/**
* Walks the **ParamType** with %%value%%, calling %%process%%
* on each type, destructing the %%value%% recursively.
*/
walk(value: any, process: ParamTypeWalkFunc): any;
/**
* Walks the **ParamType** with %%value%%, asynchronously calling
* %%process%% on each type, destructing the %%value%% recursively.
*
* This can be used to resolve ENS naes by walking and resolving each
* ``"address"`` type.
*/
walkAsync(value: any, process: ParamTypeWalkAsyncFunc): Promise<any>;
/**
* Creates a new **ParamType** for %%obj%%.
*
* If %%allowIndexed%% then the ``indexed`` keyword is permitted,
* otherwise the ``indexed`` keyword will throw an error.
*/
static from(obj: any, allowIndexed?: boolean): ParamType;
/**
* Returns true if %%value%% is a **ParamType**.
*/
static isParamType(value: any): value is ParamType;
}
/**
* The type of a [[Fragment]].
*/
export type FragmentType = "constructor" | "error" | "event" | "fallback" | "function" | "struct";
/**
* An abstract class to represent An individual fragment from a parse ABI.
*/
export declare abstract class Fragment {
/**
* The type of the fragment.
*/
readonly type: FragmentType;
/**
* The inputs for the fragment.
*/
readonly inputs: ReadonlyArray<ParamType>;
/**
* @private
*/
constructor(guard: any, type: FragmentType, inputs: ReadonlyArray<ParamType>);
/**
* Returns a string representation of this fragment.
*/
abstract format(format?: FormatType): string;
/**
* Creates a new **Fragment** for %%obj%%, wich can be any supported
* ABI frgament type.
*/
static from(obj: any): Fragment;
/**
* Returns true if %%value%% is a [[ConstructorFragment]].
*/
static isConstructor(value: any): value is ConstructorFragment;
/**
* Returns true if %%value%% is an [[ErrorFragment]].
*/
static isError(value: any): value is ErrorFragment;
/**
* Returns true if %%value%% is an [[EventFragment]].
*/
static isEvent(value: any): value is EventFragment;
/**
* Returns true if %%value%% is a [[FunctionFragment]].
*/
static isFunction(value: any): value is FunctionFragment;
/**
* Returns true if %%value%% is a [[StructFragment]].
*/
static isStruct(value: any): value is StructFragment;
}
/**
* An abstract class to represent An individual fragment
* which has a name from a parse ABI.
*/
export declare abstract class NamedFragment extends Fragment {
/**
* The name of the fragment.
*/
readonly name: string;
/**
* @private
*/
constructor(guard: any, type: FragmentType, name: string, inputs: ReadonlyArray<ParamType>);
}
/**
* A Fragment which represents a //Custom Error//.
*/
export declare class ErrorFragment extends NamedFragment {
/**
* @private
*/
constructor(guard: any, name: string, inputs: ReadonlyArray<ParamType>);
/**
* The Custom Error selector.
*/
get selector(): string;
format(format?: FormatType): string;
static from(obj: any): ErrorFragment;
static isFragment(value: any): value is ErrorFragment;
}
/**
* A Fragment which represents an Event.
*/
export declare class EventFragment extends NamedFragment {
readonly anonymous: boolean;
/**
* @private
*/
constructor(guard: any, name: string, inputs: ReadonlyArray<ParamType>, anonymous: boolean);
/**
* The Event topic hash.
*/
get topicHash(): string;
format(format?: FormatType): string;
static getTopicHash(name: string, params?: Array<any>): string;
static from(obj: any): EventFragment;
static isFragment(value: any): value is EventFragment;
}
/**
* A Fragment which represents a constructor.
*/
export declare class ConstructorFragment extends Fragment {
readonly payable: boolean;
readonly gas: null | bigint;
/**
* @private
*/
constructor(guard: any, type: FragmentType, inputs: ReadonlyArray<ParamType>, payable: boolean, gas: null | bigint);
format(format?: FormatType): string;
static from(obj: any): ConstructorFragment;
static isFragment(value: any): value is ConstructorFragment;
}
/**
* A Fragment which represents a method.
*/
export declare class FallbackFragment extends Fragment {
/**
* If the function can be sent value during invocation.
*/
readonly payable: boolean;
constructor(guard: any, inputs: ReadonlyArray<ParamType>, payable: boolean);
format(format?: FormatType): string;
static from(obj: any): FallbackFragment;
static isFragment(value: any): value is FallbackFragment;
}
/**
* A Fragment which represents a method.
*/
export declare class FunctionFragment extends NamedFragment {
/**
* If the function is constant (e.g. ``pure`` or ``view`` functions).
*/
readonly constant: boolean;
/**
* The returned types for the result of calling this function.
*/
readonly outputs: ReadonlyArray<ParamType>;
/**
* The state mutability (e.g. ``payable``, ``nonpayable``, ``view``
* or ``pure``)
*/
readonly stateMutability: "payable" | "nonpayable" | "view" | "pure";
/**
* If the function can be sent value during invocation.
*/
readonly payable: boolean;
/**
* The amount of gas to send when calling this function
*/
readonly gas: null | bigint;
/**
* @private
*/
constructor(guard: any, name: string, stateMutability: "payable" | "nonpayable" | "view" | "pure", inputs: ReadonlyArray<ParamType>, outputs: ReadonlyArray<ParamType>, gas: null | bigint);
/**
* The Function selector.
*/
get selector(): string;
format(format?: FormatType): string;
static getSelector(name: string, params?: Array<any>): string;
static from(obj: any): FunctionFragment;
static isFragment(value: any): value is FunctionFragment;
}
/**
* A Fragment which represents a structure.
*/
export declare class StructFragment extends NamedFragment {
/**
* @private
*/
constructor(guard: any, name: string, inputs: ReadonlyArray<ParamType>);
format(): string;
static from(obj: any): StructFragment;
static isFragment(value: any): value is FunctionFragment;
}

13
lib.commonjs/abi/index.d.ts vendored Normal file
View File

@ -0,0 +1,13 @@
/**
* Explain about ABI here...
*
* @_section api/abi:Application Binary Interface [abi]
* @_navTitle: ABI
*/
export { AbiCoder } from "./abi-coder.js";
export { decodeBytes32String, encodeBytes32String } from "./bytes32.js";
export { ConstructorFragment, ErrorFragment, EventFragment, FallbackFragment, Fragment, FunctionFragment, NamedFragment, ParamType, StructFragment, } from "./fragments.js";
export { checkResultErrors, Indexed, Interface, ErrorDescription, LogDescription, TransactionDescription, Result } from "./interface.js";
export { Typed } from "./typed.js";
export type { JsonFragment, JsonFragmentType, FormatType, FragmentType, ParamTypeWalkAsyncFunc, ParamTypeWalkFunc } from "./fragments.js";
export type { InterfaceAbi, } from "./interface.js";

253
lib.commonjs/abi/interface.d.ts vendored Normal file
View File

@ -0,0 +1,253 @@
/**
* About Interface
*
* @_subsection api/abi:Interfaces [interfaces]
*/
import { AbiCoder } from "./abi-coder.js";
import { checkResultErrors, Result } from "./coders/abstract-coder.js";
import { ConstructorFragment, ErrorFragment, EventFragment, FallbackFragment, Fragment, FunctionFragment, ParamType } from "./fragments.js";
import { Typed } from "./typed.js";
import type { BigNumberish, BytesLike, CallExceptionError, CallExceptionTransaction } from "../utils/index.js";
import type { JsonFragment } from "./fragments.js";
export { checkResultErrors, Result };
export declare class LogDescription {
readonly fragment: EventFragment;
readonly name: string;
readonly signature: string;
readonly topic: string;
readonly args: Result;
constructor(fragment: EventFragment, topic: string, args: Result);
}
export declare class TransactionDescription {
readonly fragment: FunctionFragment;
readonly name: string;
readonly args: Result;
readonly signature: string;
readonly selector: string;
readonly value: bigint;
constructor(fragment: FunctionFragment, selector: string, args: Result, value: bigint);
}
export declare class ErrorDescription {
readonly fragment: ErrorFragment;
readonly name: string;
readonly args: Result;
readonly signature: string;
readonly selector: string;
constructor(fragment: ErrorFragment, selector: string, args: Result);
}
export declare class Indexed {
readonly hash: null | string;
readonly _isIndexed: boolean;
static isIndexed(value: any): value is Indexed;
constructor(hash: null | string);
}
/**
* @TODO
*/
export type InterfaceAbi = string | ReadonlyArray<Fragment | JsonFragment | string>;
/**
* An Interface abstracts many of the low-level details for
* encoding and decoding the data on the blockchain.
*
* An ABI provides information on how to encode data to send to
* a Contract, how to decode the results and events and how to
* interpret revert errors.
*
* The ABI can be specified by [any supported format](InterfaceAbi).
*/
export declare class Interface {
#private;
/**
* All the Contract ABI members (i.e. methods, events, errors, etc).
*/
readonly fragments: ReadonlyArray<Fragment>;
/**
* The Contract constructor.
*/
readonly deploy: ConstructorFragment;
/**
* The Fallback method, if any.
*/
readonly fallback: null | FallbackFragment;
/**
* If receiving ether is supported.
*/
readonly receive: boolean;
/**
* Create a new Interface for the %%fragments%%.
*/
constructor(fragments: InterfaceAbi);
/**
* Returns the entire Human-Readable ABI, as an array of
* signatures, optionally as %%minimal%% strings, which
* removes parameter names and unneceesary spaces.
*/
format(minimal?: boolean): Array<string>;
/**
* Return the JSON-encoded ABI. This is the format Solidiy
* returns.
*/
formatJson(): string;
/**
* The ABI coder that will be used to encode and decode binary
* data.
*/
getAbiCoder(): AbiCoder;
/**
* Get the function name for %%key%%, which may be a function selector,
* function name or function signature that belongs to the ABI.
*/
getFunctionName(key: string): string;
/**
* Get the [[FunctionFragment]] for %%key%%, which may be a function
* selector, function name or function signature that belongs to the ABI.
*
* If %%values%% is provided, it will use the Typed API to handle
* ambiguous cases where multiple functions match by name.
*
* If the %%key%% and %%values%% do not refine to a single function in
* the ABI, this will throw.
*/
getFunction(key: string, values?: Array<any | Typed>): null | FunctionFragment;
/**
* Iterate over all functions, calling %%callback%%, sorted by their name.
*/
forEachFunction(callback: (func: FunctionFragment, index: number) => void): void;
/**
* Get the event name for %%key%%, which may be a topic hash,
* event name or event signature that belongs to the ABI.
*/
getEventName(key: string): string;
/**
* Get the [[EventFragment]] for %%key%%, which may be a topic hash,
* event name or event signature that belongs to the ABI.
*
* If %%values%% is provided, it will use the Typed API to handle
* ambiguous cases where multiple events match by name.
*
* If the %%key%% and %%values%% do not refine to a single event in
* the ABI, this will throw.
*/
getEvent(key: string, values?: Array<any | Typed>): null | EventFragment;
/**
* Iterate over all events, calling %%callback%%, sorted by their name.
*/
forEachEvent(callback: (func: EventFragment, index: number) => void): void;
/**
* Get the [[ErrorFragment]] for %%key%%, which may be an error
* selector, error name or error signature that belongs to the ABI.
*
* If %%values%% is provided, it will use the Typed API to handle
* ambiguous cases where multiple errors match by name.
*
* If the %%key%% and %%values%% do not refine to a single error in
* the ABI, this will throw.
*/
getError(key: string, values?: Array<any | Typed>): null | ErrorFragment;
/**
* Iterate over all errors, calling %%callback%%, sorted by their name.
*/
forEachError(callback: (func: ErrorFragment, index: number) => void): void;
_decodeParams(params: ReadonlyArray<ParamType>, data: BytesLike): Result;
_encodeParams(params: ReadonlyArray<ParamType>, values: ReadonlyArray<any>): string;
/**
* Encodes a ``tx.data`` object for deploying the Contract with
* the %%values%% as the constructor arguments.
*/
encodeDeploy(values?: ReadonlyArray<any>): string;
/**
* Decodes the result %%data%% (e.g. from an ``eth_call``) for the
* specified error (see [[getError]] for valid values for
* %%key%%).
*
* Most developers should prefer the [[parseResult]] method instead,
* which will automatically detect a ``CALL_EXCEPTION`` and throw the
* corresponding error.
*/
decodeErrorResult(fragment: ErrorFragment | string, data: BytesLike): Result;
/**
* Encodes the transaction revert data for a call result that
* reverted from the the Contract with the sepcified %%error%%
* (see [[getError]] for valid values for %%fragment%%) with the %%values%%.
*
* This is generally not used by most developers, unless trying to mock
* a result from a Contract.
*/
encodeErrorResult(fragment: ErrorFragment | string, values?: ReadonlyArray<any>): string;
/**
* Decodes the %%data%% from a transaction ``tx.data`` for
* the function specified (see [[getFunction]] for valid values
* for %%fragment%%).
*
* Most developers should prefer the [[parseTransaction]] method
* instead, which will automatically detect the fragment.
*/
decodeFunctionData(fragment: FunctionFragment | string, data: BytesLike): Result;
/**
* Encodes the ``tx.data`` for a transaction that calls the function
* specified (see [[getFunction]] for valid values for %%fragment%%) with
* the %%values%%.
*/
encodeFunctionData(fragment: FunctionFragment | string, values?: ReadonlyArray<any>): string;
/**
* Decodes the result %%data%% (e.g. from an ``eth_call``) for the
* specified function (see [[getFunction]] for valid values for
* %%key%%).
*
* Most developers should prefer the [[parseResult]] method instead,
* which will automatically detect a ``CALL_EXCEPTION`` and throw the
* corresponding error.
*/
decodeFunctionResult(fragment: FunctionFragment | string, data: BytesLike): Result;
makeError(_data: BytesLike, tx: CallExceptionTransaction): CallExceptionError;
/**
* Encodes the result data (e.g. from an ``eth_call``) for the
* specified function (see [[getFunction]] for valid values
* for %%fragment%%) with %%values%%.
*
* This is generally not used by most developers, unless trying to mock
* a result from a Contract.
*/
encodeFunctionResult(fragment: FunctionFragment | string, values?: ReadonlyArray<any>): string;
encodeFilterTopics(fragment: EventFragment | string, values: ReadonlyArray<any>): Array<null | string | Array<string>>;
encodeEventLog(fragment: EventFragment | string, values: ReadonlyArray<any>): {
data: string;
topics: Array<string>;
};
decodeEventLog(fragment: EventFragment | string, data: BytesLike, topics?: ReadonlyArray<string>): Result;
/**
* Parses a transaction, finding the matching function and extracts
* the parameter values along with other useful function details.
*
* If the matching function cannot be found, return null.
*/
parseTransaction(tx: {
data: string;
value?: BigNumberish;
}): null | TransactionDescription;
parseCallResult(data: BytesLike): Result;
/**
* Parses a receipt log, finding the matching event and extracts
* the parameter values along with other useful event details.
*
* If the matching event cannot be found, returns null.
*/
parseLog(log: {
topics: Array<string>;
data: string;
}): null | LogDescription;
/**
* Parses a revert data, finding the matching error and extracts
* the parameter values along with other useful error details.
*
* If the matching event cannot be found, returns null.
*/
parseError(data: BytesLike): null | ErrorDescription;
/**
* Creates a new [[Interface]] from the ABI %%value%%.
*
* The %%value%% may be provided as an existing [[Interface]] object,
* a JSON-encoded ABI or any Human-Readable ABI format.
*/
static from(value: InterfaceAbi | Interface): Interface;
}

162
lib.commonjs/abi/typed.d.ts vendored Normal file
View File

@ -0,0 +1,162 @@
/**
* About typed...
*
* @_subsection: api/abi:Typed Values
*/
import type { Addressable } from "../address/index.js";
import type { BigNumberish, BytesLike } from "../utils/index.js";
import type { Result } from "./coders/abstract-coder.js";
export interface TypedNumber extends Typed {
value: number;
defaultValue(): number;
minValue(): number;
maxValue(): number;
}
export interface TypedBigInt extends Typed {
value: bigint;
defaultValue(): bigint;
minValue(): bigint;
maxValue(): bigint;
}
export interface TypedData extends Typed {
value: string;
defaultValue(): string;
}
export interface TypedString extends Typed {
value: string;
defaultValue(): string;
}
export declare class Typed {
#private;
readonly type: string;
readonly value: any;
readonly _typedSymbol: Symbol;
constructor(gaurd: any, type: string, value: any, options?: any);
format(): string;
defaultValue(): string | number | bigint | Result;
minValue(): string | number | bigint;
maxValue(): string | number | bigint;
isBigInt(): this is TypedBigInt;
isData(): this is TypedData;
isString(): this is TypedString;
get tupleName(): null | string;
get arrayLength(): null | number;
static from(type: string, value: any): Typed;
static uint8(v: BigNumberish): Typed;
static uint16(v: BigNumberish): Typed;
static uint24(v: BigNumberish): Typed;
static uint32(v: BigNumberish): Typed;
static uint40(v: BigNumberish): Typed;
static uint48(v: BigNumberish): Typed;
static uint56(v: BigNumberish): Typed;
static uint64(v: BigNumberish): Typed;
static uint72(v: BigNumberish): Typed;
static uint80(v: BigNumberish): Typed;
static uint88(v: BigNumberish): Typed;
static uint96(v: BigNumberish): Typed;
static uint104(v: BigNumberish): Typed;
static uint112(v: BigNumberish): Typed;
static uint120(v: BigNumberish): Typed;
static uint128(v: BigNumberish): Typed;
static uint136(v: BigNumberish): Typed;
static uint144(v: BigNumberish): Typed;
static uint152(v: BigNumberish): Typed;
static uint160(v: BigNumberish): Typed;
static uint168(v: BigNumberish): Typed;
static uint176(v: BigNumberish): Typed;
static uint184(v: BigNumberish): Typed;
static uint192(v: BigNumberish): Typed;
static uint200(v: BigNumberish): Typed;
static uint208(v: BigNumberish): Typed;
static uint216(v: BigNumberish): Typed;
static uint224(v: BigNumberish): Typed;
static uint232(v: BigNumberish): Typed;
static uint240(v: BigNumberish): Typed;
static uint248(v: BigNumberish): Typed;
static uint256(v: BigNumberish): Typed;
static uint(v: BigNumberish): Typed;
static int8(v: BigNumberish): Typed;
static int16(v: BigNumberish): Typed;
static int24(v: BigNumberish): Typed;
static int32(v: BigNumberish): Typed;
static int40(v: BigNumberish): Typed;
static int48(v: BigNumberish): Typed;
static int56(v: BigNumberish): Typed;
static int64(v: BigNumberish): Typed;
static int72(v: BigNumberish): Typed;
static int80(v: BigNumberish): Typed;
static int88(v: BigNumberish): Typed;
static int96(v: BigNumberish): Typed;
static int104(v: BigNumberish): Typed;
static int112(v: BigNumberish): Typed;
static int120(v: BigNumberish): Typed;
static int128(v: BigNumberish): Typed;
static int136(v: BigNumberish): Typed;
static int144(v: BigNumberish): Typed;
static int152(v: BigNumberish): Typed;
static int160(v: BigNumberish): Typed;
static int168(v: BigNumberish): Typed;
static int176(v: BigNumberish): Typed;
static int184(v: BigNumberish): Typed;
static int192(v: BigNumberish): Typed;
static int200(v: BigNumberish): Typed;
static int208(v: BigNumberish): Typed;
static int216(v: BigNumberish): Typed;
static int224(v: BigNumberish): Typed;
static int232(v: BigNumberish): Typed;
static int240(v: BigNumberish): Typed;
static int248(v: BigNumberish): Typed;
static int256(v: BigNumberish): Typed;
static int(v: BigNumberish): Typed;
static bytes1(v: BytesLike): Typed;
static bytes2(v: BytesLike): Typed;
static bytes3(v: BytesLike): Typed;
static bytes4(v: BytesLike): Typed;
static bytes5(v: BytesLike): Typed;
static bytes6(v: BytesLike): Typed;
static bytes7(v: BytesLike): Typed;
static bytes8(v: BytesLike): Typed;
static bytes9(v: BytesLike): Typed;
static bytes10(v: BytesLike): Typed;
static bytes11(v: BytesLike): Typed;
static bytes12(v: BytesLike): Typed;
static bytes13(v: BytesLike): Typed;
static bytes14(v: BytesLike): Typed;
static bytes15(v: BytesLike): Typed;
static bytes16(v: BytesLike): Typed;
static bytes17(v: BytesLike): Typed;
static bytes18(v: BytesLike): Typed;
static bytes19(v: BytesLike): Typed;
static bytes20(v: BytesLike): Typed;
static bytes21(v: BytesLike): Typed;
static bytes22(v: BytesLike): Typed;
static bytes23(v: BytesLike): Typed;
static bytes24(v: BytesLike): Typed;
static bytes25(v: BytesLike): Typed;
static bytes26(v: BytesLike): Typed;
static bytes27(v: BytesLike): Typed;
static bytes28(v: BytesLike): Typed;
static bytes29(v: BytesLike): Typed;
static bytes30(v: BytesLike): Typed;
static bytes31(v: BytesLike): Typed;
static bytes32(v: BytesLike): Typed;
static address(v: string | Addressable): Typed;
static bool(v: any): Typed;
static bytes(v: BytesLike): Typed;
static string(v: string): Typed;
static array(v: Array<any | Typed>, dynamic?: null | boolean): Typed;
static tuple(v: Array<any | Typed> | Record<string, any | Typed>, name?: string): Typed;
static overrides(v: Record<string, any>): Typed;
/**
* Returns true only if %%value%% is a [[Typed]] instance.
*/
static isTyped(value: any): value is Typed;
/**
* If the value is a [[Typed]] instance, validates the underlying value
* and returns it, otherwise returns value directly.
*
* This is useful for functions that with to accept either a [[Typed]]
* object or values.
*/
static dereference<T>(value: Typed | T, type: string): T;
}

55
lib.commonjs/address/address.d.ts vendored Normal file
View File

@ -0,0 +1,55 @@
/**
* Returns a normalized and checksumed address for %%address%%.
* This accepts non-checksum addresses, checksum addresses and
* [[getIcapAddress]] formats.
*
* The checksum in Ethereum uses the capitalization (upper-case
* vs lower-case) of the characters within an address to encode
* its checksum, which offers, on average, a checksum of 15-bits.
*
* If %%address%% contains both upper-case and lower-case, it is
* assumed to already be a checksum address and its checksum is
* validated, and if the address fails its expected checksum an
* error is thrown.
*
* If you wish the checksum of %%address%% to be ignore, it should
* be converted to lower-case (i.e. ``.toLowercase()``) before
* being passed in. This should be a very rare situation though,
* that you wish to bypass the safegaurds in place to protect
* against an address that has been incorrectly copied from another
* source.
*
* @example:
* // Adds the checksum (via upper-casing specific letters)
* getAddress("0x8ba1f109551bd432803012645ac136ddd64dba72")
* //_result:
*
* // Converts ICAP address and adds checksum
* getAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36");
* //_result:
*
* // Throws an error if an address contains mixed case,
* // but the checksum fails
* getAddress("0x8Ba1f109551bD432803012645Ac136ddd64DBA72")
* //_error:
*/
export declare function getAddress(address: string): string;
/**
* The [ICAP Address format](link-icap) format is an early checksum
* format which attempts to be compatible with the banking
* industry [IBAN format](link-wiki-iban] for bank accounts.
*
* It is no longer common or a recommended format.
*
* @example:
* getIcapAddress("0x8ba1f109551bd432803012645ac136ddd64dba72");
* //_result:
*
* getIcapAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36");
* //_result:
*
* // Throws an error if the ICAP checksum is wrong
* getIcapAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK37");
* //_error:
*/
export declare function getIcapAddress(address: string): string;

80
lib.commonjs/address/checks.d.ts vendored Normal file
View File

@ -0,0 +1,80 @@
import type { Addressable, AddressLike, NameResolver } from "./index.js";
/**
* Returns true if %%value%% is an object which implements the
* [[Addressable]] interface.
*
* @example:
* // Wallets and AbstractSigner sub-classes
* isAddressable(Wallet.createRandom())
* //_result:
*
* // Contracts
* contract = new Contract("dai.tokens.ethers.eth", [ ], provider)
* isAddressable(contract)
* //_result:
*/
export declare function isAddressable(value: any): value is Addressable;
/**
* Returns true if %%value%% is a valid address.
*
* @example:
* // Valid address
* isAddress("0x8ba1f109551bD432803012645Ac136ddd64DBA72")
* //_result:
*
* // Valid ICAP address
* isAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36")
* //_result:
*
* // Invalid checksum
* isAddress("0x8Ba1f109551bD432803012645Ac136ddd64DBa72")
* //_result:
*
* // Invalid ICAP checksum
* isAddress("0x8Ba1f109551bD432803012645Ac136ddd64DBA72")
* //_result:
*
* // Not an address (an ENS name requires a provided and an
* // asynchronous API to access)
* isAddress("ricmoo.eth")
* //_result:
*/
export declare function isAddress(value: any): value is string;
/**
* Resolves to an address for the %%target%%, which may be any
* supported address type, an [[Addressable]] or a Promise which
* resolves to an address.
*
* If an ENS name is provided, but that name has not been correctly
* configured a [[UnconfiguredNameError]] is thrown.
*
* @example:
* addr = "0x6B175474E89094C44Da98b954EedeAC495271d0F"
*
* // Addresses are return synchronously
* resolveAddress(addr, provider)
* //_result:
*
* // Address promises are resolved asynchronously
* resolveAddress(Promise.resolve(addr))
* //_result:
*
* // ENS names are resolved asynchronously
* resolveAddress("dai.tokens.ethers.eth", provider)
* //_result:
*
* // Addressable objects are resolved asynchronously
* contract = new Contract(addr, [ ])
* resolveAddress(contract, provider)
* //_result:
*
* // Unconfigured ENS names reject
* resolveAddress("nothing-here.ricmoo.eth", provider)
* //_error:
*
* // ENS names require a NameResolver object passed in
* // (notice the provider was omitted)
* resolveAddress("nothing-here.ricmoo.eth")
* //_error:
*/
export declare function resolveAddress(target: AddressLike, resolver?: null | NameResolver): string | Promise<string>;

View File

@ -0,0 +1,47 @@
import type { BigNumberish, BytesLike } from "../utils/index.js";
/**
* Returns the address that would result from a ``CREATE`` for %%tx%%.
*
* This can be used to compute the address a contract will be
* deployed to by an EOA when sending a deployment transaction (i.e.
* when the ``to`` address is ``null``).
*
* This can also be used to compute the address a contract will be
* deployed to by a contract, by using the contract's address as the
* ``to`` and the contract's nonce.
*
* @example
* from = "0x8ba1f109551bD432803012645Ac136ddd64DBA72";
* nonce = 5;
*
* getCreateAddress({ from, nonce });
* //_result:
*/
export declare function getCreateAddress(tx: {
from: string;
nonce: BigNumberish;
}): string;
/**
* Returns the address that would result from a ``CREATE2`` operation
* with the given %%from%%, %%salt%% and %%initCodeHash%%.
*
* To compute the %%initCodeHash%% from a contract's init code, use
* the [[keccak256]] function.
*
* For a quick overview and example of ``CREATE2``, see [[link-ricmoo-wisps]].
*
* @example
* // The address of the contract
* from = "0x8ba1f109551bD432803012645Ac136ddd64DBA72"
*
* // The salt
* salt = id("HelloWorld")
*
* // The hash of the initCode
* initCode = "0x6394198df16000526103ff60206004601c335afa6040516060f3";
* initCodeHash = keccak256(initCode)
*
* getCreate2Address(from, salt, initCodeHash)
* //_result:
*/
export declare function getCreate2Address(_from: string, _salt: BytesLike, _initCodeHash: BytesLike): string;

48
lib.commonjs/address/index.d.ts vendored Normal file
View File

@ -0,0 +1,48 @@
/**
* Addresses are a fundamental part of interacting with Ethereum. They
* represent the gloabal identity of Externally Owned Accounts (accounts
* backed by a private key) and contracts.
*
* The Ethereum Naming Service (ENS) provides an interconnected ecosystem
* of contracts, standards and libraries which enable looking up an
* address for an ENS name.
*
* These functions help convert between various formats, validate
* addresses and safely resolve ENS names.
*
* @_section: api/address:Addresses [addresses]
*/
/**
* An interface for objects which have an address, and can
* resolve it asyncronously.
*
* This allows objects such as [[Signer]] or [[Contract]] to
* be used most places an address can be, for example getting
* the [balance](Provider-getBalance).
*/
export interface Addressable {
/**
* Get the object address.
*/
getAddress(): Promise<string>;
}
/**
* Anything that can be used to return or resolve an address.
*/
export type AddressLike = string | Promise<string> | Addressable;
/**
* An interface for any object which can resolve an ENS name.
*/
export interface NameResolver {
/**
* Resolve to the address for the ENS %%name%%.
*
* Resolves to ``null`` if the name is unconfigued. Use
* [[resolveAddress]] (passing this object as %%resolver%%) to
* throw for names that are unconfigured.
*/
resolveName(name: string): Promise<null | string>;
}
export { getAddress, getIcapAddress } from "./address.js";
export { getCreateAddress, getCreate2Address } from "./contract-address.js";
export { isAddressable, isAddress, resolveAddress } from "./checks.js";

6
lib.commonjs/constants/addresses.d.ts vendored Normal file
View File

@ -0,0 +1,6 @@
/**
* A constant for the zero address.
*
* (**i.e.** ``"0x0000000000000000000000000000000000000000"``)
*/
export declare const ZeroAddress: string;

6
lib.commonjs/constants/hashes.d.ts vendored Normal file
View File

@ -0,0 +1,6 @@
/**
* A constant for the zero hash.
*
* (**i.e.** ``"0x0000000000000000000000000000000000000000000000000000000000000000"``)
*/
export declare const ZeroHash: string;

9
lib.commonjs/constants/index.d.ts vendored Normal file
View File

@ -0,0 +1,9 @@
/**
* Some common constants useful for Ethereum.
*
* @_section: api/constants: Constants [constants]
*/
export { ZeroAddress } from "./addresses.js";
export { ZeroHash } from "./hashes.js";
export { N, WeiPerEther, MaxUint256, MinInt256, MaxInt256 } from "./numbers.js";
export { EtherSymbol, MessagePrefix } from "./strings.js";

30
lib.commonjs/constants/numbers.d.ts vendored Normal file
View File

@ -0,0 +1,30 @@
/**
* A constant for the order N for the secp256k1 curve.
*
* (**i.e.** ``0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n``)
*/
export declare const N: bigint;
/**
* A constant for the number of wei in a single ether.
*
* (**i.e.** ``1000000000000000000n``)
*/
export declare const WeiPerEther: bigint;
/**
* A constant for the maximum value for a ``uint256``.
*
* (**i.e.** ``0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn``)
*/
export declare const MaxUint256: bigint;
/**
* A constant for the minimum value for an ``int256``.
*
* (**i.e.** ``-8000000000000000000000000000000000000000000000000000000000000000n``)
*/
export declare const MinInt256: bigint;
/**
* A constant for the maximum value for an ``int256``.
*
* (**i.e.** ``0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn``)
*/
export declare const MaxInt256: bigint;

12
lib.commonjs/constants/strings.d.ts vendored Normal file
View File

@ -0,0 +1,12 @@
/**
* A constant for the ether symbol (normalized using NFKC).
*
* (**i.e.** ``"\\u039e"``)
*/
export declare const EtherSymbol: string;
/**
* A constant for the [[link-eip-191]] personal message prefix.
*
* (**i.e.** ``"\\x19Ethereum Signed Message:\\n"``)
*/
export declare const MessagePrefix: string;

58
lib.commonjs/contract/contract.d.ts vendored Normal file
View File

@ -0,0 +1,58 @@
import { Interface } from "../abi/index.js";
import { Log, TransactionResponse } from "../providers/provider.js";
import { ContractTransactionResponse, EventLog } from "./wrappers.js";
import type { EventFragment, FunctionFragment, InterfaceAbi, ParamType } from "../abi/index.js";
import type { Addressable } from "../address/index.js";
import type { EventEmitterable, Listener } from "../utils/index.js";
import type { BlockTag, ContractRunner, TransactionRequest } from "../providers/index.js";
import type { ContractEventName, ContractInterface, ContractMethod, ContractEvent, ContractTransaction } from "./types.js";
/**
* @_ignore:
*/
export declare function copyOverrides<O extends string = "data" | "to">(arg: any, allowed?: Array<string>): Promise<Omit<ContractTransaction, O>>;
/**
* @_ignore:
*/
export declare function resolveArgs(_runner: null | ContractRunner, inputs: ReadonlyArray<ParamType>, args: Array<any>): Promise<Array<any>>;
declare class WrappedFallback {
readonly _contract: BaseContract;
constructor(contract: BaseContract);
populateTransaction(overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransaction>;
staticCall(overrides?: Omit<TransactionRequest, "to">): Promise<string>;
send(overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransactionResponse>;
estimateGas(overrides?: Omit<TransactionRequest, "to">): Promise<bigint>;
}
declare const internal: unique symbol;
export declare class BaseContract implements Addressable, EventEmitterable<ContractEventName> {
readonly target: string | Addressable;
readonly interface: Interface;
readonly runner: null | ContractRunner;
readonly filters: Record<string, ContractEvent>;
readonly [internal]: any;
readonly fallback: null | WrappedFallback;
constructor(target: string | Addressable, abi: Interface | InterfaceAbi, runner?: null | ContractRunner, _deployTx?: null | TransactionResponse);
connect(runner: null | ContractRunner): BaseContract;
getAddress(): Promise<string>;
getDeployedCode(): Promise<null | string>;
waitForDeployment(): Promise<this>;
deploymentTransaction(): null | ContractTransactionResponse;
getFunction<T extends ContractMethod = ContractMethod>(key: string | FunctionFragment): T;
getEvent(key: string | EventFragment): ContractEvent;
queryTransaction(hash: string): Promise<Array<EventLog>>;
queryFilter(event: ContractEventName, fromBlock?: BlockTag, toBlock?: BlockTag): Promise<Array<EventLog | Log>>;
on(event: ContractEventName, listener: Listener): Promise<this>;
once(event: ContractEventName, listener: Listener): Promise<this>;
emit(event: ContractEventName, ...args: Array<any>): Promise<boolean>;
listenerCount(event?: ContractEventName): Promise<number>;
listeners(event?: ContractEventName): Promise<Array<Listener>>;
off(event: ContractEventName, listener?: Listener): Promise<this>;
removeAllListeners(event?: ContractEventName): Promise<this>;
addListener(event: ContractEventName, listener: Listener): Promise<this>;
removeListener(event: ContractEventName, listener: Listener): Promise<this>;
static buildClass<T = ContractInterface>(abi: InterfaceAbi): new (target: string, runner?: null | ContractRunner) => BaseContract & Omit<T, keyof BaseContract>;
static from<T = ContractInterface>(target: string, abi: InterfaceAbi, runner?: null | ContractRunner): BaseContract & Omit<T, keyof BaseContract>;
}
declare const Contract_base: new (target: string, abi: InterfaceAbi, runner?: ContractRunner | null | undefined) => BaseContract & Omit<ContractInterface, keyof BaseContract>;
export declare class Contract extends Contract_base {
}
export {};

21
lib.commonjs/contract/factory.d.ts vendored Normal file
View File

@ -0,0 +1,21 @@
import { Interface } from "../abi/index.js";
import { BaseContract } from "./contract.js";
import type { InterfaceAbi } from "../abi/index.js";
import type { ContractRunner } from "../providers/index.js";
import type { BytesLike } from "../utils/index.js";
import type { ContractInterface, ContractMethodArgs, ContractDeployTransaction } from "./types.js";
import type { ContractTransactionResponse } from "./wrappers.js";
export declare class ContractFactory<A extends Array<any> = Array<any>, I = BaseContract> {
readonly interface: Interface;
readonly bytecode: string;
readonly runner: null | ContractRunner;
constructor(abi: Interface | InterfaceAbi, bytecode: BytesLike | {
object: string;
}, runner?: null | ContractRunner);
getDeployTransaction(...args: ContractMethodArgs<A>): Promise<ContractDeployTransaction>;
deploy(...args: ContractMethodArgs<A>): Promise<BaseContract & {
deploymentTransaction(): ContractTransactionResponse;
} & Omit<I, keyof BaseContract>>;
connect(runner: null | ContractRunner): ContractFactory<A, I>;
static fromSolidity<A extends Array<any> = Array<any>, I = ContractInterface>(output: any, runner?: ContractRunner): ContractFactory<A, I>;
}

9
lib.commonjs/contract/index.d.ts vendored Normal file
View File

@ -0,0 +1,9 @@
/**
* About contracts...
*
* @_section: api/contract:Contracts [contracts]
*/
export { BaseContract, Contract } from "./contract.js";
export { ContractFactory } from "./factory.js";
export { ContractEventPayload, ContractUnknownEventPayload, ContractTransactionReceipt, ContractTransactionResponse, EventLog, } from "./wrappers.js";
export type { BaseContractMethod, ConstantContractMethod, PostfixOverrides, ContractEvent, ContractEventArgs, ContractEventName, ContractDeployTransaction, ContractInterface, ContractMethod, ContractMethodArgs, ContractTransaction, DeferredTopicFilter, Overrides } from "./types.js";

48
lib.commonjs/contract/types.d.ts vendored Normal file
View File

@ -0,0 +1,48 @@
import type { EventFragment, FunctionFragment, Result, Typed } from "../abi/index.js";
import type { TransactionRequest, PreparedTransactionRequest, TopicFilter } from "../providers/index.js";
import type { ContractTransactionResponse } from "./wrappers.js";
export type ContractEventName = string | ContractEvent | TopicFilter | DeferredTopicFilter;
export interface ContractInterface {
[name: string]: BaseContractMethod;
}
export interface DeferredTopicFilter {
getTopicFilter(): Promise<TopicFilter>;
fragment: EventFragment;
}
export interface ContractTransaction extends PreparedTransactionRequest {
to: string;
data: string;
from?: string;
}
export interface ContractDeployTransaction extends Omit<ContractTransaction, "to"> {
}
export interface Overrides extends Omit<TransactionRequest, "to" | "data"> {
}
export type PostfixOverrides<A extends Array<any>> = A | [...A, Overrides];
export type ContractMethodArgs<A extends Array<any>> = PostfixOverrides<{
[I in keyof A]-?: A[I] | Typed;
}>;
export interface BaseContractMethod<A extends Array<any> = Array<any>, R = any, D extends R | ContractTransactionResponse = R | ContractTransactionResponse> {
(...args: ContractMethodArgs<A>): Promise<D>;
name: string;
fragment: FunctionFragment;
getFragment(...args: ContractMethodArgs<A>): FunctionFragment;
populateTransaction(...args: ContractMethodArgs<A>): Promise<ContractTransaction>;
staticCall(...args: ContractMethodArgs<A>): Promise<R>;
send(...args: ContractMethodArgs<A>): Promise<ContractTransactionResponse>;
estimateGas(...args: ContractMethodArgs<A>): Promise<bigint>;
staticCallResult(...args: ContractMethodArgs<A>): Promise<Result>;
}
export interface ContractMethod<A extends Array<any> = Array<any>, R = any, D extends R | ContractTransactionResponse = R | ContractTransactionResponse> extends BaseContractMethod<A, R, D> {
}
export interface ConstantContractMethod<A extends Array<any>, R = any> extends ContractMethod<A, R, R> {
}
export type ContractEventArgs<A extends Array<any>> = {
[I in keyof A]?: A[I] | Typed | null;
};
export interface ContractEvent<A extends Array<any> = Array<any>> {
(...args: ContractEventArgs<A>): DeferredTopicFilter;
name: string;
fragment: EventFragment;
getFragment(...args: ContractEventArgs<A>): EventFragment;
}

40
lib.commonjs/contract/wrappers.d.ts vendored Normal file
View File

@ -0,0 +1,40 @@
import { Block, Log, TransactionReceipt, TransactionResponse } from "../providers/provider.js";
import { EventPayload } from "../utils/index.js";
import type { EventFragment, Interface, Result } from "../abi/index.js";
import type { Listener } from "../utils/index.js";
import type { Provider } from "../providers/index.js";
import type { BaseContract } from "./contract.js";
import type { ContractEventName } from "./types.js";
export declare class EventLog extends Log {
readonly interface: Interface;
readonly fragment: EventFragment;
readonly args: Result;
constructor(log: Log, iface: Interface, fragment: EventFragment);
get eventName(): string;
get eventSignature(): string;
}
export declare class ContractTransactionReceipt extends TransactionReceipt {
#private;
constructor(iface: Interface, provider: Provider, tx: TransactionReceipt);
get logs(): Array<EventLog | Log>;
}
export declare class ContractTransactionResponse extends TransactionResponse {
#private;
constructor(iface: Interface, provider: Provider, tx: TransactionResponse);
wait(confirms?: number): Promise<null | ContractTransactionReceipt>;
}
export declare class ContractUnknownEventPayload extends EventPayload<ContractEventName> {
readonly log: Log;
constructor(contract: BaseContract, listener: null | Listener, filter: ContractEventName, log: Log);
getBlock(): Promise<Block>;
getTransaction(): Promise<TransactionResponse>;
getTransactionReceipt(): Promise<TransactionReceipt>;
}
export declare class ContractEventPayload extends ContractUnknownEventPayload {
readonly fragment: EventFragment;
readonly log: EventLog;
readonly args: Result;
constructor(contract: BaseContract, listener: null | Listener, filter: ContractEventName, fragment: EventFragment, _log: Log);
get eventName(): string;
get eventSignature(): string;
}

14
lib.commonjs/crypto/crypto-browser.d.ts vendored Normal file
View File

@ -0,0 +1,14 @@
declare global {
interface Window {
}
const window: Window;
const self: Window;
}
export interface CryptoHasher {
update(data: Uint8Array): CryptoHasher;
digest(): Uint8Array;
}
export declare function createHash(algo: string): CryptoHasher;
export declare function createHmac(_algo: string, key: Uint8Array): CryptoHasher;
export declare function pbkdf2Sync(password: Uint8Array, salt: Uint8Array, iterations: number, keylen: number, _algo: "sha256" | "sha512"): Uint8Array;
export declare function randomBytes(length: number): Uint8Array;

1
lib.commonjs/crypto/crypto.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export { createHash, createHmac, pbkdf2Sync, randomBytes } from "crypto";

24
lib.commonjs/crypto/hmac.d.ts vendored Normal file
View File

@ -0,0 +1,24 @@
import type { BytesLike } from "../utils/index.js";
/**
* Return the HMAC for %%data%% using the %%key%% key with the underlying
* %%algo%% used for compression.
*
* @example:
* key = id("some-secret")
*
* // Compute the HMAC
* computeHmac("sha256", key, "0x1337")
* //_result:
*
* // To compute the HMAC of UTF-8 data, the data must be
* // converted to UTF-8 bytes
* computeHmac("sha256", key, toUtf8Bytes("Hello World"))
* //_result:
*
*/
export declare function computeHmac(algorithm: "sha256" | "sha512", _key: BytesLike, _data: BytesLike): string;
export declare namespace computeHmac {
var _: (algorithm: "sha256" | "sha512", key: Uint8Array, data: Uint8Array) => BytesLike;
var lock: () => void;
var register: (func: (algorithm: "sha256" | "sha512", key: Uint8Array, data: Uint8Array) => BytesLike) => void;
}

20
lib.commonjs/crypto/index.d.ts vendored Normal file
View File

@ -0,0 +1,20 @@
/**
* A fundamental building block of Ethereum is the underlying
* cryptographic primitives.
*
* @_section: api/crypto:Cryptographic Functions [crypto]
*/
import { computeHmac } from "./hmac.js";
import { keccak256 } from "./keccak.js";
import { ripemd160 } from "./ripemd160.js";
import { pbkdf2 } from "./pbkdf2.js";
import { randomBytes } from "./random.js";
import { scrypt, scryptSync } from "./scrypt.js";
import { sha256, sha512 } from "./sha2.js";
export { computeHmac, randomBytes, keccak256, ripemd160, sha256, sha512, pbkdf2, scrypt, scryptSync };
export { SigningKey } from "./signing-key.js";
export { Signature } from "./signature.js";
declare function lock(): void;
export { lock };
export type { ProgressCallback } from "./scrypt.js";
export type { SignatureLike } from "./signature.js";

34
lib.commonjs/crypto/keccak.d.ts vendored Normal file
View File

@ -0,0 +1,34 @@
/**
* Cryptographic hashing functions
*
* @_subsection: api/crypto:Hash Functions [about-crypto-hashing]
*/
import type { BytesLike } from "../utils/index.js";
/**
* Compute the cryptographic KECCAK256 hash of %%data%%.
*
* The %%data%% **must** be a data representation, to compute the
* hash of UTF-8 data use the [[id]] function.
*
* @returns DataHexstring
* @example:
* keccak256("0x")
* //_result:
*
* keccak256("0x1337")
* //_result:
*
* keccak256(new Uint8Array([ 0x13, 0x37 ]))
* //_result:
*
* // Strings are assumed to be DataHexString, otherwise it will
* // throw. To hash UTF-8 data, see the note above.
* keccak256("Hello World")
* //_error:
*/
export declare function keccak256(_data: BytesLike): string;
export declare namespace keccak256 {
var _: (data: Uint8Array) => Uint8Array;
var lock: () => void;
var register: (func: (data: Uint8Array) => BytesLike) => void;
}

34
lib.commonjs/crypto/pbkdf2.d.ts vendored Normal file
View File

@ -0,0 +1,34 @@
/**
* A **Password-Based Key-Derivation Function** is designed to create
* a sequence of bytes suitible as a **key** from a human-rememberable
* password.
*
* @_subsection: api/crypto:Passwords [about-pbkdf]
*/
import type { BytesLike } from "../utils/index.js";
/**
* Return the [[link-pbkdf2]] for %%keylen%% bytes for %%password%% using
* the %%salt%% and using %%iterations%% of %%algo%%.
*
* This PBKDF is outdated and should not be used in new projects, but is
* required to decrypt older files.
*
* @example:
* // The password must be converted to bytes, and it is generally
* // best practices to ensure the string has been normalized. Many
* // formats explicitly indicate the normalization form to use.
* password = "hello"
* passwordBytes = toUtf8Bytes(password, "NFKC")
*
* salt = id("some-salt")
*
* // Compute the PBKDF2
* pbkdf2(passwordBytes, salt, 1024, 16, "sha256")
* //_result:
*/
export declare function pbkdf2(_password: BytesLike, _salt: BytesLike, iterations: number, keylen: number, algo: "sha256" | "sha512"): string;
export declare namespace pbkdf2 {
var _: (password: Uint8Array, salt: Uint8Array, iterations: number, keylen: number, algo: "sha256" | "sha512") => BytesLike;
var lock: () => void;
var register: (func: (password: Uint8Array, salt: Uint8Array, iterations: number, keylen: number, algo: "sha256" | "sha512") => BytesLike) => void;
}

13
lib.commonjs/crypto/random.d.ts vendored Normal file
View File

@ -0,0 +1,13 @@
/**
* Return %%length%% bytes of cryptographically secure random data.
*
* @example:
* randomBytes(8)
* //_result:
*/
export declare function randomBytes(length: number): Uint8Array;
export declare namespace randomBytes {
var _: (length: number) => Uint8Array;
var lock: () => void;
var register: (func: (length: number) => Uint8Array) => void;
}

24
lib.commonjs/crypto/ripemd160.d.ts vendored Normal file
View File

@ -0,0 +1,24 @@
import type { BytesLike } from "../utils/index.js";
/**
* Compute the cryptographic RIPEMD-160 hash of %%data%%.
*
* @_docloc: api/crypto:Hash Functions
* @returns DataHexstring
*
* @example:
* ripemd160("0x")
* //_result:
*
* ripemd160("0x1337")
* //_result:
*
* ripemd160(new Uint8Array([ 0x13, 0x37 ]))
* //_result:
*
*/
export declare function ripemd160(_data: BytesLike): string;
export declare namespace ripemd160 {
var _: (data: Uint8Array) => Uint8Array;
var lock: () => void;
var register: (func: (data: Uint8Array) => BytesLike) => void;
}

79
lib.commonjs/crypto/scrypt.d.ts vendored Normal file
View File

@ -0,0 +1,79 @@
import type { BytesLike } from "../utils/index.js";
/**
* A callback during long-running operations to update any
* UI or provide programatic access to the progress.
*
* The %%percent%% is a value between ``0`` and ``1``.
*/
export type ProgressCallback = (percent: number) => void;
/**
* The [[link-wiki-scrypt]] uses a memory and cpu hard method of
* derivation to increase the resource cost to brute-force a password
* for a given key.
*
* This means this algorithm is intentionally slow, and can be tuned to
* become slower. As computation and memory speed improve over time,
* increasing the difficulty maintains the cost of an attacker.
*
* For example, if a target time of 5 seconds is used, a legitimate user
* which knows their password requires only 5 seconds to unlock their
* account. A 6 character password has 68 billion possibilities, which
* would require an attacker to invest over 10,000 years of CPU time. This
* is of course a crude example (as password generally aren't random),
* but demonstrates to value of imposing large costs to decryption.
*
* For this reason, if building a UI which involved decrypting or
* encrypting datsa using scrypt, it is recommended to use a
* [[ProgressCallback]] (as event short periods can seem lik an eternity
* if the UI freezes). Including the phrase //"decrypting"// in the UI
* can also help, assuring the user their waiting is for a good reason.
*
* @_docloc: api/crypto:Passwords
*
* @example:
* // The password must be converted to bytes, and it is generally
* // best practices to ensure the string has been normalized. Many
* // formats explicitly indicate the normalization form to use.
* password = "hello"
* passwordBytes = toUtf8Bytes(password, "NFKC")
*
* salt = id("some-salt")
*
* // Compute the scrypt
* scrypt(passwordBytes, salt, 1024, 8, 1, 16)
* //_result:
*/
export declare function scrypt(_passwd: BytesLike, _salt: BytesLike, N: number, r: number, p: number, dkLen: number, progress?: ProgressCallback): Promise<string>;
export declare namespace scrypt {
var _: (passwd: Uint8Array, salt: Uint8Array, N: number, r: number, p: number, dkLen: number, onProgress?: ProgressCallback | undefined) => Promise<Uint8Array>;
var lock: () => void;
var register: (func: (passwd: Uint8Array, salt: Uint8Array, N: number, r: number, p: number, dkLen: number, progress?: ProgressCallback | undefined) => Promise<BytesLike>) => void;
}
/**
* Provides a synchronous variant of [[scrypt]].
*
* This will completely lock up and freeze the UI in a browser and will
* prevent any event loop from progressing. For this reason, it is
* preferred to use the [async variant](scrypt).
*
* @_docloc: api/crypto:Passwords
*
* @example:
* // The password must be converted to bytes, and it is generally
* // best practices to ensure the string has been normalized. Many
* // formats explicitly indicate the normalization form to use.
* password = "hello"
* passwordBytes = toUtf8Bytes(password, "NFKC")
*
* salt = id("some-salt")
*
* // Compute the scrypt
* scryptSync(passwordBytes, salt, 1024, 8, 1, 16)
* //_result:
*/
export declare function scryptSync(_passwd: BytesLike, _salt: BytesLike, N: number, r: number, p: number, dkLen: number): string;
export declare namespace scryptSync {
var _: (passwd: Uint8Array, salt: Uint8Array, N: number, r: number, p: number, dkLen: number) => Uint8Array;
var lock: () => void;
var register: (func: (passwd: Uint8Array, salt: Uint8Array, N: number, r: number, p: number, dkLen: number) => BytesLike) => void;
}

46
lib.commonjs/crypto/sha2.d.ts vendored Normal file
View File

@ -0,0 +1,46 @@
import type { BytesLike } from "../utils/index.js";
/**
* Compute the cryptographic SHA2-256 hash of %%data%%.
*
* @_docloc: api/crypto:Hash Functions
* @returns DataHexstring
*
* @example:
* sha256("0x")
* //_result:
*
* sha256("0x1337")
* //_result:
*
* sha256(new Uint8Array([ 0x13, 0x37 ]))
* //_result:
*
*/
export declare function sha256(_data: BytesLike): string;
export declare namespace sha256 {
var _: (data: Uint8Array) => Uint8Array;
var lock: () => void;
var register: (func: (data: Uint8Array) => BytesLike) => void;
}
/**
* Compute the cryptographic SHA2-512 hash of %%data%%.
*
* @_docloc: api/crypto:Hash Functions
* @returns DataHexstring
*
* @example:
* sha512("0x")
* //_result:
*
* sha512("0x1337")
* //_result:
*
* sha512(new Uint8Array([ 0x13, 0x37 ]))
* //_result:
*/
export declare function sha512(_data: BytesLike): string;
export declare namespace sha512 {
var _: (data: Uint8Array) => Uint8Array;
var lock: () => void;
var register: (func: (data: Uint8Array) => BytesLike) => void;
}

149
lib.commonjs/crypto/signature.d.ts vendored Normal file
View File

@ -0,0 +1,149 @@
import type { BigNumberish, BytesLike } from "../utils/index.js";
export type SignatureLike = Signature | string | {
r: string;
s: string;
v: BigNumberish;
yParity?: 0 | 1;
yParityAndS?: string;
} | {
r: string;
yParityAndS: string;
yParity?: 0 | 1;
s?: string;
v?: number;
} | {
r: string;
s: string;
yParity: 0 | 1;
v?: BigNumberish;
yParityAndS?: string;
};
/**
* A Signature @TODO
*/
export declare class Signature {
#private;
/**
* The ``r`` value for a signautre.
*
* This represents the ``x`` coordinate of a "reference" or
* challenge point, from which the ``y`` can be computed.
*/
get r(): string;
set r(value: BytesLike);
/**
* The ``s`` value for a signature.
*/
get s(): string;
set s(_value: BytesLike);
/**
* The ``v`` value for a signature.
*
* Since a given ``x`` value for ``r`` has two possible values for
* its correspondin ``y``, the ``v`` indicates which of the two ``y``
* values to use.
*
* It is normalized to the values ``27`` or ``28`` for legacy
* purposes.
*/
get v(): 27 | 28;
set v(value: BigNumberish);
/**
* The EIP-155 ``v`` for legacy transactions. For non-legacy
* transactions, this value is ``null``.
*/
get networkV(): null | bigint;
/**
* The chain ID for EIP-155 legacy transactions. For non-legacy
* transactions, this value is ``null``.
*/
get legacyChainId(): null | bigint;
/**
* The ``yParity`` for the signature.
*
* See ``v`` for more details on how this value is used.
*/
get yParity(): 0 | 1;
/**
* The [[link-eip-2098]] compact representation of the ``yParity``
* and ``s`` compacted into a single ``bytes32``.
*/
get yParityAndS(): string;
/**
* The [[link-eip-2098]] compact representation.
*/
get compactSerialized(): string;
/**
* The serialized representation.
*/
get serialized(): string;
/**
* @private
*/
constructor(guard: any, r: string, s: string, v: 27 | 28);
/**
* Returns a new identical [[Signature]].
*/
clone(): Signature;
/**
* Returns a representation that is compatible with ``JSON.stringify``.
*/
toJSON(): any;
/**
* Compute the chain ID from the ``v`` in a legacy EIP-155 transactions.
*
* @example:
* Signature.getChainId(45)
* //_result:
*
* Signature.getChainId(46)
* //_result:
*/
static getChainId(v: BigNumberish): bigint;
/**
* Compute the ``v`` for a chain ID for a legacy EIP-155 transactions.
*
* Legacy transactions which use [[link-eip-155]] hijack the ``v``
* property to include the chain ID.
*
* @example:
* Signature.getChainIdV(5, 27)
* //_result:
*
* Signature.getChainIdV(5, 28)
* //_result:
*
*/
static getChainIdV(chainId: BigNumberish, v: 27 | 28): bigint;
/**
* Compute the normalized legacy transaction ``v`` from a ``yParirty``,
* a legacy transaction ``v`` or a legacy [[link-eip-155]] transaction.
*
* @example:
* // The values 0 and 1 imply v is actually yParity
* Signature.getNormalizedV(0)
* //_result:
*
* // Legacy non-EIP-1559 transaction (i.e. 27 or 28)
* Signature.getNormalizedV(27)
* //_result:
*
* // Legacy EIP-155 transaction (i.e. >= 35)
* Signature.getNormalizedV(46)
* //_result:
*
* // Invalid values throw
* Signature.getNormalizedV(5)
* //_error:
*/
static getNormalizedV(v: BigNumberish): 27 | 28;
/**
* Creates a new [[Signature]].
*
* If no %%sig%% is provided, a new [[Signature]] is created
* with default values.
*
* If %%sig%% is a string, it is parsed.
*/
static from(sig?: SignatureLike): Signature;
}

116
lib.commonjs/crypto/signing-key.d.ts vendored Normal file
View File

@ -0,0 +1,116 @@
import { Signature } from "./signature.js";
import type { BytesLike } from "../utils/index.js";
import type { SignatureLike } from "./index.js";
/**
* A **SigningKey** provides high-level access to the elliptic curve
* cryptography (ECC) operations and key management.
*/
export declare class SigningKey {
#private;
/**
* Creates a new **SigningKey** for %%privateKey%%.
*/
constructor(privateKey: BytesLike);
/**
* The private key.
*/
get privateKey(): string;
/**
* The uncompressed public key.
*
* This will always begin with the prefix ``0x04`` and be 132
* characters long (the ``0x`` prefix and 130 hexadecimal nibbles).
*/
get publicKey(): string;
/**
* The compressed public key.
*
* This will always begin with either the prefix ``0x02`` or ``0x03``
* and be 68 characters long (the ``0x`` prefix and 33 hexadecimal
* nibbles)
*/
get compressedPublicKey(): string;
/**
* Return the signature of the signed %%digest%%.
*/
sign(digest: BytesLike): Signature;
/**
* Returns the [[link-wiki-ecdh]] shared secret between this
* private key and the %%other%% key.
*
* The %%other%% key may be any type of key, a raw public key,
* a compressed/uncompressed pubic key or aprivate key.
*
* Best practice is usually to use a cryptographic hash on the
* returned value before using it as a symetric secret.
*
* @example:
* sign1 = new SigningKey(id("some-secret-1"))
* sign2 = new SigningKey(id("some-secret-2"))
*
* // Notice that privA.computeSharedSecret(pubB)...
* sign1.computeSharedSecret(sign2.publicKey)
* //_result:
*
* // ...is equal to privB.computeSharedSecret(pubA).
* sign2.computeSharedSecret(sign1.publicKey)
* //_result:
*/
computeSharedSecret(other: BytesLike): string;
/**
* Compute the public key for %%key%%, optionally %%compressed%%.
*
* The %%key%% may be any type of key, a raw public key, a
* compressed/uncompressed public key or private key.
*
* @example:
* sign = new SigningKey(id("some-secret"));
*
* // Compute the uncompressed public key for a private key
* SigningKey.computePublicKey(sign.privateKey)
* //_result:
*
* // Compute the compressed public key for a private key
* SigningKey.computePublicKey(sign.privateKey, true)
* //_result:
*
* // Compute the uncompressed public key
* SigningKey.computePublicKey(sign.publicKey, false);
* //_result:
*
* // Compute the Compressed a public key
* SigningKey.computePublicKey(sign.publicKey, true);
* //_result:
*/
static computePublicKey(key: BytesLike, compressed?: boolean): string;
/**
* Returns the public key for the private key which produced the
* %%signature%% for the given %%digest%%.
*
* @example:
* key = new SigningKey(id("some-secret"))
* digest = id("hello world")
* sig = key.sign(digest)
*
* // Notice the signer public key...
* key.publicKey
* //_result:
*
* // ...is equal to the recovered public key
* SigningKey.recoverPublicKey(digest, sig)
* //_result:
*
*/
static recoverPublicKey(digest: BytesLike, signature: SignatureLike): string;
/**
* Returns the point resulting from adding the ellipic curve points
* %%p0%% and %%p1%%.
*
* This is not a common function most developers should require, but
* can be useful for certain privacy-specific techniques.
*
* For example, it is used by [[HDNodeWallet]] to compute child
* addresses from parent public keys and chain codes.
*/
static addPoints(p0: BytesLike, p1: BytesLike, compressed?: boolean): string;
}

21
lib.commonjs/ethers.d.ts vendored Normal file
View File

@ -0,0 +1,21 @@
export { version } from "./_version.js";
export { decodeBytes32String, encodeBytes32String, AbiCoder, ConstructorFragment, ErrorFragment, EventFragment, Fragment, FunctionFragment, ParamType, checkResultErrors, Indexed, Interface, LogDescription, Result, TransactionDescription, Typed, } from "./abi/index.js";
export { getAddress, getIcapAddress, getCreateAddress, getCreate2Address, isAddressable, isAddress, resolveAddress } from "./address/index.js";
export { ZeroAddress, WeiPerEther, MaxUint256, MinInt256, MaxInt256, N, ZeroHash, EtherSymbol, MessagePrefix } from "./constants/index.js";
export { BaseContract, Contract, ContractFactory, ContractEventPayload, ContractTransactionReceipt, ContractTransactionResponse, EventLog, } from "./contract/index.js";
export { computeHmac, randomBytes, keccak256, ripemd160, sha256, sha512, pbkdf2, scrypt, scryptSync, lock, Signature, SigningKey } from "./crypto/index.js";
export { id, ensNormalize, isValidName, namehash, dnsEncode, hashMessage, verifyMessage, solidityPacked, solidityPackedKeccak256, solidityPackedSha256, TypedDataEncoder } from "./hash/index.js";
export { getDefaultProvider, Block, FeeData, Log, TransactionReceipt, TransactionResponse, AbstractSigner, NonceManager, VoidSigner, AbstractProvider, FallbackProvider, JsonRpcApiProvider, JsonRpcProvider, JsonRpcSigner, BrowserProvider, AlchemyProvider, AnkrProvider, CloudflareProvider, EtherscanProvider, InfuraProvider, PocketProvider, QuickNodeProvider, IpcSocketProvider, SocketProvider, WebSocketProvider, EnsResolver, Network } from "./providers/index.js";
export { accessListify, computeAddress, recoverAddress, Transaction } from "./transaction/index.js";
export { decodeBase58, encodeBase58, decodeBase64, encodeBase64, concat, dataLength, dataSlice, getBytes, getBytesCopy, hexlify, isHexString, isBytesLike, stripZerosLeft, zeroPadBytes, zeroPadValue, defineProperties, assert, assertArgument, assertArgumentCount, assertNormalize, assertPrivate, makeError, isCallException, isError, FetchRequest, FetchResponse, FetchCancelSignal, FixedNumber, getBigInt, getNumber, getUint, toBeArray, toBigInt, toBeHex, toNumber, toQuantity, fromTwos, toTwos, mask, formatEther, parseEther, formatUnits, parseUnits, toUtf8Bytes, toUtf8CodePoints, toUtf8String, Utf8ErrorFuncs, decodeRlp, encodeRlp } from "./utils/index.js";
export { Mnemonic, BaseWallet, HDNodeWallet, HDNodeVoidWallet, Wallet, defaultPath, getAccountPath, isCrowdsaleJson, isKeystoreJson, decryptCrowdsaleJson, decryptKeystoreJsonSync, decryptKeystoreJson, encryptKeystoreJson, encryptKeystoreJsonSync, } from "./wallet/index.js";
export { Wordlist, LangEn, WordlistOwl, WordlistOwlA } from "./wordlists/index.js";
export type { JsonFragment, JsonFragmentType, InterfaceAbi, ParamTypeWalkFunc, ParamTypeWalkAsyncFunc } from "./abi/index.js";
export type { Addressable } from "./address/index.js";
export type { ConstantContractMethod, ContractEvent, ContractEventArgs, ContractEventName, ContractInterface, ContractMethod, ContractMethodArgs, ContractTransaction, DeferredTopicFilter, Overrides } from "./contract/index.js";
export type { ProgressCallback, SignatureLike } from "./crypto/index.js";
export type { TypedDataDomain, TypedDataField } from "./hash/index.js";
export type { Provider, Signer } from "./providers/index.js";
export type { AccessList, AccessListish, AccessListEntry, TransactionLike } from "./transaction/index.js";
export type { BytesLike, BigNumberish, Numeric, ErrorCode, FixedFormat, Utf8ErrorFunc, UnicodeNormalizationForm, Utf8ErrorReason, RlpStructuredData, GetUrlResponse, FetchPreflightFunc, FetchProcessFunc, FetchRetryFunc, FetchGatewayFunc, FetchGetUrlFunc, EthersError, UnknownError, NotImplementedError, UnsupportedOperationError, NetworkError, ServerError, TimeoutError, BadDataError, CancelledError, BufferOverrunError, NumericFaultError, InvalidArgumentError, MissingArgumentError, UnexpectedArgumentError, CallExceptionError, InsufficientFundsError, NonceExpiredError, OffchainFaultError, ReplacementUnderpricedError, TransactionReplacedError, UnconfiguredNameError, ActionRejectedError, CodedEthersError, } from "./utils/index.js";
export type { KeystoreAccount, EncryptOptions } from "./wallet/index.js";

12
lib.commonjs/hash/id.d.ts vendored Normal file
View File

@ -0,0 +1,12 @@
/**
* A simple hashing function which operates on UTF-8 strings to
* compute an 32-byte irentifier.
*
* This simply computes the [UTF-8 bytes](toUtf8Bytes) and computes
* the [[keccak256]].
*
* @example:
* id("hello world")
* //_result:
*/
export declare function id(value: string): string;

11
lib.commonjs/hash/index.d.ts vendored Normal file
View File

@ -0,0 +1,11 @@
/**
* About hashing here...
*
* @_section: api/hashing:Hashing Utilities [hashing]
*/
export { id } from "./id.js";
export { ensNormalize, isValidName, namehash, dnsEncode } from "./namehash.js";
export { hashMessage, verifyMessage } from "./message.js";
export { solidityPacked, solidityPackedKeccak256, solidityPackedSha256 } from "./solidity.js";
export { TypedDataEncoder } from "./typed-data.js";
export type { TypedDataDomain, TypedDataField } from "./typed-data.js";

31
lib.commonjs/hash/message.d.ts vendored Normal file
View File

@ -0,0 +1,31 @@
import type { SignatureLike } from "../crypto/index.js";
/**
* Computes the [[link-eip-191]] personal-sign message digest to sign.
*
* This prefixes the message with [[MessagePrefix]] and the decimal length
* of %%message%% and computes the [[keccak256]] digest.
*
* If %%message%% is a string, it is converted to its UTF-8 bytes
* first. To compute the digest of a [[DataHexString]], it must be converted
* to [bytes](getBytes).
*
* @example:
* hashMessage("Hello World")
* //_result:
*
* // Hashes the SIX (6) string characters, i.e.
* // [ "0", "x", "4", "2", "4", "3" ]
* hashMessage("0x4243")
* //_result:
*
* // Hashes the TWO (2) bytes [ 0x42, 0x43 ]...
* hashMessage(getBytes("0x4243"))
* //_result:
*
* // ...which is equal to using data
* hashMessage(new Uint8Array([ 0x42, 0x43 ]))
* //_result:
*
*/
export declare function hashMessage(message: Uint8Array | string): string;
export declare function verifyMessage(message: Uint8Array | string, sig: SignatureLike): string;

19
lib.commonjs/hash/namehash.d.ts vendored Normal file
View File

@ -0,0 +1,19 @@
/**
* Returns the ENS %%name%% normalized.
*/
export declare function ensNormalize(name: string): string;
/**
* Returns ``true`` if %%name%% is a valid ENS name.
*/
export declare function isValidName(name: string): name is string;
/**
* Returns the [[link-namehash]] for %%name%%.
*/
export declare function namehash(name: string): string;
/**
* Returns the DNS encoded %%name%%.
*
* This is used for various parts of ENS name resolution, such
* as the wildcard resolution.
*/
export declare function dnsEncode(name: string): string;

30
lib.commonjs/hash/solidity.d.ts vendored Normal file
View File

@ -0,0 +1,30 @@
/**
* Computes the [[link-solc-packed]] representation of %%values%%
* respectively to their %%types%%.
*
* @example:
* addr = "0x8ba1f109551bd432803012645ac136ddd64dba72"
* solidityPacked([ "address", "uint" ], [ addr, 45 ]);
* //_result:
*/
export declare function solidityPacked(types: ReadonlyArray<string>, values: ReadonlyArray<any>): string;
/**
* Computes the [[link-solc-packed]] [[keccak256]] hash of %%values%%
* respectively to their %%types%%.
*
* @example:
* addr = "0x8ba1f109551bd432803012645ac136ddd64dba72"
* solidityPackedKeccak256([ "address", "uint" ], [ addr, 45 ]);
* //_result:
*/
export declare function solidityPackedKeccak256(types: ReadonlyArray<string>, values: ReadonlyArray<any>): string;
/**
* Computes the [[link-solc-packed]] [[sha256]] hash of %%values%%
* respectively to their %%types%%.
*
* @example:
* addr = "0x8ba1f109551bd432803012645ac136ddd64dba72"
* solidityPackedSha256([ "address", "uint" ], [ addr, 45 ]);
* //_result:
*/
export declare function solidityPackedSha256(types: ReadonlyArray<string>, values: ReadonlyArray<any>): string;

37
lib.commonjs/hash/typed-data.d.ts vendored Normal file
View File

@ -0,0 +1,37 @@
import type { BigNumberish, BytesLike } from "../utils/index.js";
export interface TypedDataDomain {
name?: string;
version?: string;
chainId?: BigNumberish;
verifyingContract?: string;
salt?: BytesLike;
}
export interface TypedDataField {
name: string;
type: string;
}
export declare class TypedDataEncoder {
#private;
readonly primaryType: string;
get types(): Record<string, Array<TypedDataField>>;
constructor(types: Record<string, Array<TypedDataField>>);
getEncoder(type: string): (value: any) => string;
encodeType(name: string): string;
encodeData(type: string, value: any): string;
hashStruct(name: string, value: Record<string, any>): string;
encode(value: Record<string, any>): string;
hash(value: Record<string, any>): string;
_visit(type: string, value: any, callback: (type: string, data: any) => any): any;
visit(value: Record<string, any>, callback: (type: string, data: any) => any): any;
static from(types: Record<string, Array<TypedDataField>>): TypedDataEncoder;
static getPrimaryType(types: Record<string, Array<TypedDataField>>): string;
static hashStruct(name: string, types: Record<string, Array<TypedDataField>>, value: Record<string, any>): string;
static hashDomain(domain: TypedDataDomain): string;
static encode(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, any>): string;
static hash(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, any>): string;
static resolveNames(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, any>, resolveName: (name: string) => Promise<string>): Promise<{
domain: TypedDataDomain;
value: any;
}>;
static getPayload(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, any>): any;
}

10
lib.commonjs/index.d.ts vendored Normal file
View File

@ -0,0 +1,10 @@
/**
* The Application Programming Interface (API) is the collection of
* functions, classes and types offered by the Ethers library.
*
* @_section: api:Application Programming Interface [about-api]
* @_navTitle: API
*/
import * as ethers from "./ethers.js";
export { ethers };
export * from "./ethers.js";

View File

@ -0,0 +1,214 @@
/**
* About Subclassing the Provider...
*
* @_section: api/providers/abstract-provider: Subclassing Provider [abstract-provider]
*/
import { FetchRequest } from "../utils/index.js";
import { EnsResolver } from "./ens-resolver.js";
import { Network } from "./network.js";
import { Block, FeeData, Log, TransactionReceipt, TransactionResponse } from "./provider.js";
import type { AddressLike } from "../address/index.js";
import type { BigNumberish } from "../utils/index.js";
import type { Listener } from "../utils/index.js";
import type { Networkish } from "./network.js";
import type { BlockParams, LogParams, TransactionReceiptParams, TransactionResponseParams } from "./formatting.js";
import type { BlockTag, EventFilter, Filter, FilterByBlockHash, OrphanFilter, PreparedTransactionRequest, Provider, ProviderEvent, TransactionRequest } from "./provider.js";
export type DebugEventAbstractProvider = {
action: "sendCcipReadFetchRequest";
request: FetchRequest;
index: number;
urls: Array<string>;
} | {
action: "receiveCcipReadFetchResult";
request: FetchRequest;
result: any;
} | {
action: "receiveCcipReadFetchError";
request: FetchRequest;
result: any;
} | {
action: "sendCcipReadCall";
transaction: {
to: string;
data: string;
};
} | {
action: "receiveCcipReadCallResult";
transaction: {
to: string;
data: string;
};
result: string;
} | {
action: "receiveCcipReadCallError";
transaction: {
to: string;
data: string;
};
error: Error;
};
export type Subscription = {
type: "block" | "close" | "debug" | "network" | "pending";
tag: string;
} | {
type: "transaction";
tag: string;
hash: string;
} | {
type: "event";
tag: string;
filter: EventFilter;
} | {
type: "orphan";
tag: string;
filter: OrphanFilter;
};
export interface Subscriber {
start(): void;
stop(): void;
pause(dropWhilePaused?: boolean): void;
resume(): void;
pollingInterval?: number;
}
export declare class UnmanagedSubscriber implements Subscriber {
name: string;
constructor(name: string);
start(): void;
stop(): void;
pause(dropWhilePaused?: boolean): void;
resume(): void;
}
export interface AbstractProviderPlugin {
readonly name: string;
connect(provider: AbstractProvider): AbstractProviderPlugin;
}
export type PerformActionFilter = {
address?: string | Array<string>;
topics?: Array<null | string | Array<string>>;
fromBlock?: BlockTag;
toBlock?: BlockTag;
} | {
address?: string | Array<string>;
topics?: Array<null | string | Array<string>>;
blockHash?: string;
};
export interface PerformActionTransaction extends PreparedTransactionRequest {
to?: string;
from?: string;
}
export type PerformActionRequest = {
method: "broadcastTransaction";
signedTransaction: string;
} | {
method: "call";
transaction: PerformActionTransaction;
blockTag: BlockTag;
} | {
method: "chainId";
} | {
method: "estimateGas";
transaction: PerformActionTransaction;
} | {
method: "getBalance";
address: string;
blockTag: BlockTag;
} | {
method: "getBlock";
blockTag: BlockTag;
includeTransactions: boolean;
} | {
method: "getBlock";
blockHash: string;
includeTransactions: boolean;
} | {
method: "getBlockNumber";
} | {
method: "getCode";
address: string;
blockTag: BlockTag;
} | {
method: "getGasPrice";
} | {
method: "getLogs";
filter: PerformActionFilter;
} | {
method: "getStorage";
address: string;
position: bigint;
blockTag: BlockTag;
} | {
method: "getTransaction";
hash: string;
} | {
method: "getTransactionCount";
address: string;
blockTag: BlockTag;
} | {
method: "getTransactionReceipt";
hash: string;
} | {
method: "getTransactionResult";
hash: string;
};
export declare class AbstractProvider implements Provider {
#private;
constructor(_network?: "any" | Networkish);
get provider(): this;
get plugins(): Array<AbstractProviderPlugin>;
attachPlugin(plugin: AbstractProviderPlugin): this;
getPlugin<T extends AbstractProviderPlugin = AbstractProviderPlugin>(name: string): null | T;
get disableCcipRead(): boolean;
set disableCcipRead(value: boolean);
ccipReadFetch(tx: PerformActionTransaction, calldata: string, urls: Array<string>): Promise<null | string>;
_wrapBlock(value: BlockParams, network: Network): Block;
_wrapLog(value: LogParams, network: Network): Log;
_wrapTransactionReceipt(value: TransactionReceiptParams, network: Network): TransactionReceipt;
_wrapTransactionResponse(tx: TransactionResponseParams, network: Network): TransactionResponse;
_detectNetwork(): Promise<Network>;
_perform<T = any>(req: PerformActionRequest): Promise<T>;
getBlockNumber(): Promise<number>;
_getAddress(address: AddressLike): string | Promise<string>;
_getBlockTag(blockTag?: BlockTag): string | Promise<string>;
_getFilter(filter: Filter | FilterByBlockHash): PerformActionFilter | Promise<PerformActionFilter>;
_getTransactionRequest(_request: TransactionRequest): PerformActionTransaction | Promise<PerformActionTransaction>;
getNetwork(): Promise<Network>;
getFeeData(): Promise<FeeData>;
estimateGas(_tx: TransactionRequest): Promise<bigint>;
call(_tx: TransactionRequest): Promise<string>;
getBalance(address: AddressLike, blockTag?: BlockTag): Promise<bigint>;
getTransactionCount(address: AddressLike, blockTag?: BlockTag): Promise<number>;
getCode(address: AddressLike, blockTag?: BlockTag): Promise<string>;
getStorage(address: AddressLike, _position: BigNumberish, blockTag?: BlockTag): Promise<string>;
broadcastTransaction(signedTx: string): Promise<TransactionResponse>;
getBlock(block: BlockTag | string, prefetchTxs?: boolean): Promise<null | Block>;
getTransaction(hash: string): Promise<null | TransactionResponse>;
getTransactionReceipt(hash: string): Promise<null | TransactionReceipt>;
getTransactionResult(hash: string): Promise<null | string>;
getLogs(_filter: Filter | FilterByBlockHash): Promise<Array<Log>>;
_getProvider(chainId: number): AbstractProvider;
getResolver(name: string): Promise<null | EnsResolver>;
getAvatar(name: string): Promise<null | string>;
resolveName(name: string): Promise<null | string>;
lookupAddress(address: string): Promise<null | string>;
waitForTransaction(hash: string, _confirms?: null | number, timeout?: null | number): Promise<null | TransactionReceipt>;
waitForBlock(blockTag?: BlockTag): Promise<Block>;
_clearTimeout(timerId: number): void;
_setTimeout(_func: () => void, timeout?: number): number;
_forEachSubscriber(func: (s: Subscriber) => void): void;
_getSubscriber(sub: Subscription): Subscriber;
_recoverSubscriber(oldSub: Subscriber, newSub: Subscriber): void;
on(event: ProviderEvent, listener: Listener): Promise<this>;
once(event: ProviderEvent, listener: Listener): Promise<this>;
emit(event: ProviderEvent, ...args: Array<any>): Promise<boolean>;
listenerCount(event?: ProviderEvent): Promise<number>;
listeners(event?: ProviderEvent): Promise<Array<Listener>>;
off(event: ProviderEvent, listener?: Listener): Promise<this>;
removeAllListeners(event?: ProviderEvent): Promise<this>;
addListener(event: ProviderEvent, listener: Listener): Promise<this>;
removeListener(event: ProviderEvent, listener: Listener): Promise<this>;
destroy(): void;
get paused(): boolean;
set paused(pause: boolean);
pause(dropWhilePaused?: boolean): void;
resume(): void;
}

View File

@ -0,0 +1,30 @@
import type { TypedDataDomain, TypedDataField } from "../hash/index.js";
import type { TransactionLike } from "../transaction/index.js";
import type { BlockTag, Provider, TransactionRequest, TransactionResponse } from "./provider.js";
import type { Signer } from "./signer.js";
export declare abstract class AbstractSigner<P extends null | Provider = null | Provider> implements Signer {
readonly provider: P;
constructor(provider?: P);
abstract getAddress(): Promise<string>;
abstract connect(provider: null | Provider): Signer;
getNonce(blockTag?: BlockTag): Promise<number>;
populateCall(tx: TransactionRequest): Promise<TransactionLike<string>>;
populateTransaction(tx: TransactionRequest): Promise<TransactionLike<string>>;
estimateGas(tx: TransactionRequest): Promise<bigint>;
call(tx: TransactionRequest): Promise<string>;
resolveName(name: string): Promise<null | string>;
sendTransaction(tx: TransactionRequest): Promise<TransactionResponse>;
abstract signTransaction(tx: TransactionRequest): Promise<string>;
abstract signMessage(message: string | Uint8Array): Promise<string>;
abstract signTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, any>): Promise<string>;
}
export declare class VoidSigner extends AbstractSigner {
#private;
readonly address: string;
constructor(address: string, provider?: null | Provider);
getAddress(): Promise<string>;
connect(provider: null | Provider): VoidSigner;
signTransaction(tx: TransactionRequest): Promise<string>;
signMessage(message: string | Uint8Array): Promise<string>;
signTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, any>): Promise<string>;
}

28
lib.commonjs/providers/community.d.ts vendored Normal file
View File

@ -0,0 +1,28 @@
/**
* There are many awesome community services that provide Ethereum
* nodes both for developers just starting out and for large-scale
* communities.
*
* @_section: api/providers/thirdparty: Community Providers [thirdparty]
*/
/**
* Providers which offer community credentials should extend this
* to notify any interested consumers whether community credentials
* are in-use.
*/
export interface CommunityResourcable {
/**
* Returns true of the instance is connected using the community
* credentials.
*/
isCommunityResource(): boolean;
}
/**
* Displays a warning in tht console when the community resource is
* being used too heavily by the app, recommending the developer
* acquire their own credentials instead of using the community
* credentials.
*
* The notification will only occur once per service.
*/
export declare function showThrottleMessage(service: string): void;

8
lib.commonjs/providers/contracts.d.ts vendored Normal file
View File

@ -0,0 +1,8 @@
import type { Provider, TransactionRequest, TransactionResponse } from "./provider.js";
export interface ContractRunner {
provider: null | Provider;
estimateGas?: (tx: TransactionRequest) => Promise<bigint>;
call?: (tx: TransactionRequest) => Promise<string>;
resolveName?: (name: string) => Promise<null | string>;
sendTransaction?: (tx: TransactionRequest) => Promise<TransactionResponse>;
}

View File

@ -0,0 +1,4 @@
import type { AbstractProvider } from "./abstract-provider.js";
import type { Networkish } from "./network.js";
import { WebSocketLike } from "./provider-websocket.js";
export declare function getDefaultProvider(network: string | Networkish | WebSocketLike, options?: any): AbstractProvider;

110
lib.commonjs/providers/ens-resolver.d.ts vendored Normal file
View File

@ -0,0 +1,110 @@
/**
* About ENS Resolver
*
* @_section: api/providers/ens-resolver:ENS Resolver [about-ens-rsolver]
*/
import type { BytesLike } from "../utils/index.js";
import type { AbstractProvider, AbstractProviderPlugin } from "./abstract-provider.js";
import type { Provider } from "./provider.js";
/**
* The type of data found during a steip during avatar resolution.
*/
export type AvatarLinkageType = "name" | "avatar" | "!avatar" | "url" | "data" | "ipfs" | "erc721" | "erc1155" | "!erc721-caip" | "!erc1155-caip" | "!owner" | "owner" | "!balance" | "balance" | "metadata-url-base" | "metadata-url-expanded" | "metadata-url" | "!metadata-url" | "!metadata" | "metadata" | "!imageUrl" | "imageUrl-ipfs" | "imageUrl" | "!imageUrl-ipfs";
/**
* An individual record for each step during avatar resolution.
*/
export interface AvatarLinkage {
type: AvatarLinkageType;
value: string;
}
/**
* When resolving an avatar for an ENS name, there are many
* steps involved, fetching metadata, validating results, et cetera.
*
* Some applications may wish to analyse this data, or use this data
* to diagnose promblems, so an **AvatarResult** provides details of
* each completed step during avatar resolution.
*/
export interface AvatarResult {
linkage: Array<AvatarLinkage>;
url: null | string;
}
/**
* A provider plugin super-class for processing multicoin address types.
*/
export declare abstract class MulticoinProviderPlugin implements AbstractProviderPlugin {
readonly name: string;
constructor(name: string);
connect(proivder: Provider): MulticoinProviderPlugin;
supportsCoinType(coinType: number): boolean;
encodeAddress(coinType: number, address: string): Promise<string>;
decodeAddress(coinType: number, data: BytesLike): Promise<string>;
}
/**
* A basic multicoin provider plugin.
*/
export declare class BasicMulticoinProviderPlugin extends MulticoinProviderPlugin {
constructor();
}
/**
* A connected object to a resolved ENS name resolver, which can be
* used to query additional details.
*/
export declare class EnsResolver {
#private;
/**
* The connected provider.
*/
provider: AbstractProvider;
/**
* The address of the resolver.
*/
address: string;
/**
* The name this resovler was resolved against.
*/
name: string;
constructor(provider: AbstractProvider, address: string, name: string);
/**
* Resolves to true if the resolver supports wildcard resolution.
*/
supportsWildcard(): Promise<boolean>;
/**
* Resolves to the address for %%coinType%% or null if the
* provided %%coinType%% has not been configured.
*/
getAddress(coinType?: number): Promise<null | string>;
/**
* Resovles to the EIP-643 text record for %%key%%, or ``null``
* if unconfigured.
*/
getText(key: string): Promise<null | string>;
/**
* Rsolves to the content-hash or ``null`` if unconfigured.
*/
getContentHash(): Promise<null | string>;
/**
* Resolves to the avatar url or ``null`` if the avatar is either
* unconfigured or incorrectly configured (e.g. references an NFT
* not owned by the address).
*
* If diagnosing issues with configurations, the [[_getAvatar]]
* method may be useful.
*/
getAvatar(): Promise<null | string>;
/**
* When resolving an avatar, there are many steps involved, such
* fetching metadata and possibly validating ownership of an
* NFT.
*
* This method can be used to examine each step and the value it
* was working from.
*/
_getAvatar(): Promise<AvatarResult>;
static getEnsAddress(provider: Provider): Promise<string>;
/**
* Resolve to the ENS resolver for %%name%% using %%provider%% or
* ``null`` if unconfigured.
*/
static fromName(provider: AbstractProvider, name: string): Promise<null | EnsResolver>;
}

14
lib.commonjs/providers/format.d.ts vendored Normal file
View File

@ -0,0 +1,14 @@
import type { BlockParams, LogParams, TransactionReceiptParams, TransactionResponseParams } from "./formatting.js";
export type FormatFunc = (value: any) => any;
export declare function allowNull(format: FormatFunc, nullValue?: any): FormatFunc;
export declare function arrayOf(format: FormatFunc): FormatFunc;
export declare function object(format: Record<string, FormatFunc>, altNames?: Record<string, Array<string>>): FormatFunc;
export declare function formatBoolean(value: any): boolean;
export declare function formatData(value: string): string;
export declare function formatHash(value: any): string;
export declare function formatUint256(value: any): string;
export declare function formatLog(value: any): LogParams;
export declare function formatBlock(value: any): BlockParams;
export declare function formatReceiptLog(value: any): LogParams;
export declare function formatTransactionReceipt(value: any): TransactionReceiptParams;
export declare function formatTransactionResponse(value: any): TransactionResponseParams;

69
lib.commonjs/providers/formatting.d.ts vendored Normal file
View File

@ -0,0 +1,69 @@
/**
* About provider formatting?
*
* @_section: api/providers/formatting:Formatting [provider-formatting]
*/
import type { Signature } from "../crypto/index.js";
import type { AccessList } from "../transaction/index.js";
export interface BlockParams {
hash?: null | string;
number: number;
timestamp: number;
parentHash: string;
nonce: string;
difficulty: bigint;
gasLimit: bigint;
gasUsed: bigint;
miner: string;
extraData: string;
baseFeePerGas: null | bigint;
transactions: ReadonlyArray<string | TransactionResponseParams>;
}
export interface LogParams {
transactionHash: string;
blockHash: string;
blockNumber: number;
removed: boolean;
address: string;
data: string;
topics: ReadonlyArray<string>;
index: number;
transactionIndex: number;
}
export interface TransactionReceiptParams {
to: null | string;
from: string;
contractAddress: null | string;
hash: string;
index: number;
blockHash: string;
blockNumber: number;
logsBloom: string;
logs: ReadonlyArray<LogParams>;
gasUsed: bigint;
cumulativeGasUsed: bigint;
gasPrice?: null | bigint;
effectiveGasPrice?: null | bigint;
type: number;
status: null | number;
root: null | string;
}
export interface TransactionResponseParams {
blockNumber: null | number;
blockHash: null | string;
hash: string;
index: number;
type: number;
to: null | string;
from: string;
nonce: number;
gasLimit: bigint;
gasPrice: bigint;
maxPriorityFeePerGas: null | bigint;
maxFeePerGas: null | bigint;
data: string;
value: bigint;
chainId: bigint;
signature: Signature;
accessList: null | AccessList;
}

39
lib.commonjs/providers/index.d.ts vendored Normal file
View File

@ -0,0 +1,39 @@
/**
* About providers.
*
* @_section: api/providers:Providers [providers]
*/
export { AbstractProvider, UnmanagedSubscriber } from "./abstract-provider.js";
export { AbstractSigner, VoidSigner, } from "./abstract-signer.js";
export { showThrottleMessage } from "./community.js";
export { getDefaultProvider } from "./default-provider.js";
export { EnsResolver } from "./ens-resolver.js";
export { Network } from "./network.js";
export { NonceManager } from "./signer-noncemanager.js";
export { NetworkPlugin, GasCostPlugin, EnsPlugin, FeeDataNetworkPlugin, } from "./plugins-network.js";
export { Block, FeeData, Log, TransactionReceipt, TransactionResponse, copyRequest, } from "./provider.js";
export { FallbackProvider } from "./provider-fallback.js";
export { JsonRpcApiProvider, JsonRpcProvider, JsonRpcSigner } from "./provider-jsonrpc.js";
export { BrowserProvider } from "./provider-browser.js";
export { AlchemyProvider } from "./provider-alchemy.js";
export { AnkrProvider } from "./provider-ankr.js";
export { CloudflareProvider } from "./provider-cloudflare.js";
export { EtherscanProvider, EtherscanPlugin } from "./provider-etherscan.js";
export { InfuraProvider, InfuraWebSocketProvider } from "./provider-infura.js";
export { PocketProvider } from "./provider-pocket.js";
export { QuickNodeProvider } from "./provider-quicknode.js";
import { IpcSocketProvider } from "./provider-ipcsocket.js";
export { IpcSocketProvider };
export { SocketProvider } from "./provider-socket.js";
export { WebSocketProvider } from "./provider-websocket.js";
export { SocketSubscriber, SocketBlockSubscriber, SocketPendingSubscriber, SocketEventSubscriber } from "./provider-socket.js";
export type { Subscription, Subscriber, AbstractProviderPlugin, PerformActionFilter, PerformActionTransaction, PerformActionRequest, } from "./abstract-provider.js";
export type { ContractRunner } from "./contracts.js";
export type { BlockParams, LogParams, TransactionReceiptParams, TransactionResponseParams, } from "./formatting.js";
export type { Networkish } from "./network.js";
export type { GasCostParameters } from "./plugins-network.js";
export type { BlockTag, TransactionRequest, PreparedTransactionRequest, EventFilter, Filter, FilterByBlockHash, OrphanFilter, ProviderEvent, TopicFilter, Provider, MinedBlock, MinedTransactionResponse } from "./provider.js";
export type { DebugEventBrowserProvider, Eip1193Provider } from "./provider-browser.js";
export type { JsonRpcPayload, JsonRpcResult, JsonRpcError, JsonRpcApiProviderOptions, JsonRpcTransactionRequest, } from "./provider-jsonrpc.js";
export type { WebSocketCreator, WebSocketLike } from "./provider-websocket.js";
export type { Signer } from "./signer.js";

45
lib.commonjs/providers/network.d.ts vendored Normal file
View File

@ -0,0 +1,45 @@
/**
* About networks
*
* @_subsection: api/providers:Networks [networks]
*/
import type { BigNumberish } from "../utils/index.js";
import type { TransactionLike } from "../transaction/index.js";
import type { NetworkPlugin } from "./plugins-network.js";
/**
* A Networkish can be used to allude to a Network, by specifing:
* - a [[Network]] object
* - a well-known (or registered) network name
* - a well-known (or registered) chain ID
* - an object with sufficient details to describe a network
*/
export type Networkish = Network | number | bigint | string | {
name?: string;
chainId?: number;
ensAddress?: string;
ensNetwork?: number;
};
export declare class Network {
#private;
constructor(name: string, chainId: BigNumberish);
toJSON(): any;
get name(): string;
set name(value: string);
get chainId(): bigint;
set chainId(value: BigNumberish);
get plugins(): Array<NetworkPlugin>;
attachPlugin(plugin: NetworkPlugin): this;
getPlugin<T extends NetworkPlugin = NetworkPlugin>(name: string): null | T;
getPlugins<T extends NetworkPlugin = NetworkPlugin>(basename: string): Array<T>;
clone(): Network;
computeIntrinsicGas(tx: TransactionLike): number;
/**
* Returns a new Network for the %%network%% name or chainId.
*/
static from(network?: Networkish): Network;
/**
* Register %%nameOrChainId%% with a function which returns
* an instance of a Network representing that chain.
*/
static register(nameOrChainId: string | number | bigint, networkFunc: () => Network): void;
}

View File

@ -0,0 +1,5 @@
export interface PaginationResult<R> extends Array<R> {
next(): Promise<PaginationResult<R>>;
totalResults: null | number;
done: boolean;
}

View File

@ -0,0 +1,12 @@
import { AbstractProviderPlugin } from "./abstract-provider.js";
import type { AbstractProvider, PerformActionRequest } from "./abstract-provider.js";
export declare const PluginIdFallbackProvider = "org.ethers.plugins.provider.QualifiedPlugin";
export declare class CheckQualifiedPlugin implements AbstractProviderPlugin {
name: string;
constructor();
connect(provider: AbstractProvider): CheckQualifiedPlugin;
isQualified(action: PerformActionRequest, result: any): boolean;
}
export declare class PossiblyPrunedTransactionPlugin extends CheckQualifiedPlugin {
isQualified(action: PerformActionRequest, result: any): boolean;
}

View File

@ -0,0 +1,38 @@
import type { FeeData, Provider } from "./provider.js";
export declare class NetworkPlugin {
readonly name: string;
constructor(name: string);
clone(): NetworkPlugin;
}
export type GasCostParameters = {
txBase?: number;
txCreate?: number;
txDataZero?: number;
txDataNonzero?: number;
txAccessListStorageKey?: number;
txAccessListAddress?: number;
};
export declare class GasCostPlugin extends NetworkPlugin implements GasCostParameters {
readonly effectiveBlock: number;
readonly txBase: number;
readonly txCreate: number;
readonly txDataZero: number;
readonly txDataNonzero: number;
readonly txAccessListStorageKey: number;
readonly txAccessListAddress: number;
constructor(effectiveBlock?: number, costs?: GasCostParameters);
clone(): GasCostPlugin;
}
export declare class EnsPlugin extends NetworkPlugin {
readonly address: string;
readonly targetNetwork: number;
constructor(address?: null | string, targetNetwork?: null | number);
clone(): EnsPlugin;
}
export declare class FeeDataNetworkPlugin extends NetworkPlugin {
#private;
get feeDataFunc(): (provider: Provider) => Promise<FeeData>;
constructor(feeDataFunc: (provider: Provider) => Promise<FeeData>);
getFeeData(provider: Provider): Promise<FeeData>;
clone(): FeeDataNetworkPlugin;
}

View File

@ -0,0 +1,30 @@
/**
* About Alchemy
*
* @_subsection: api/providers/thirdparty:Alchemy [providers-alchemy]
*/
import { FetchRequest } from "../utils/index.js";
import { Network } from "./network.js";
import { JsonRpcProvider } from "./provider-jsonrpc.js";
import type { AbstractProvider, PerformActionRequest } from "./abstract-provider.js";
import type { CommunityResourcable } from "./community.js";
import type { Networkish } from "./network.js";
/**
* The **AlchemyProvider** connects to the [[link-alchemy]]
* JSON-RPC end-points.
*
* By default, a highly-throttled API key is used, which is
* appropriate for quick prototypes and simple scripts. To
* gain access to an increased rate-limit, it is highly
* recommended to [sign up here](link-alchemy-signup).
*
* @_docloc: api/providers/thirdparty
*/
export declare class AlchemyProvider extends JsonRpcProvider implements CommunityResourcable {
readonly apiKey: string;
constructor(_network?: Networkish, apiKey?: null | string);
_getProvider(chainId: number): AbstractProvider;
_perform(req: PerformActionRequest): Promise<any>;
isCommunityResource(): boolean;
static getRequest(network: Network, apiKey?: string): FetchRequest;
}

View File

@ -0,0 +1,50 @@
/**
* [[link-ankr]] provides a third-party service for connecting to
* various blockchains over JSON-RPC.
*
* **Supported Networks**
*
* - Ethereum Mainnet (``mainnet``)
* - Goerli Testnet (``goerli``)
* - Polygon (``matic``)
* - Arbitrum (``arbitrum``)
*
* @_subsection: api/providers/thirdparty:Ankr [providers-ankr]
*/
import { FetchRequest } from "../utils/index.js";
import { AbstractProvider } from "./abstract-provider.js";
import { Network } from "./network.js";
import { JsonRpcProvider } from "./provider-jsonrpc.js";
import type { CommunityResourcable } from "./community.js";
import type { Networkish } from "./network.js";
import type { JsonRpcError, JsonRpcPayload } from "./provider-jsonrpc.js";
/**
* The **AnkrProvider** connects to the [[link-ankr]]
* JSON-RPC end-points.
*
* By default, a highly-throttled API key is used, which is
* appropriate for quick prototypes and simple scripts. To
* gain access to an increased rate-limit, it is highly
* recommended to [sign up here](link-ankr-signup).
*/
export declare class AnkrProvider extends JsonRpcProvider implements CommunityResourcable {
/**
* The API key for the Ankr connection.
*/
readonly apiKey: string;
/**
* Create a new **AnkrProvider**.
*
* By default connecting to ``mainnet`` with a highly throttled
* API key.
*/
constructor(_network?: Networkish, apiKey?: null | string);
_getProvider(chainId: number): AbstractProvider;
/**
* Returns a prepared request for connecting to %%network%% with
* %%apiKey%%.
*/
static getRequest(network: Network, apiKey?: null | string): FetchRequest;
getRpcError(payload: JsonRpcPayload, error: JsonRpcError): Error;
isCommunityResource(): boolean;
}

View File

@ -0,0 +1,31 @@
import { JsonRpcApiPollingProvider } from "./provider-jsonrpc.js";
import type { JsonRpcError, JsonRpcPayload, JsonRpcResult, JsonRpcSigner } from "./provider-jsonrpc.js";
import type { Networkish } from "./network.js";
export interface Eip1193Provider {
request(request: {
method: string;
params?: Array<any> | Record<string, any>;
}): Promise<any>;
}
export type DebugEventBrowserProvider = {
action: "sendEip1193Payload";
payload: {
method: string;
params: Array<any>;
};
} | {
action: "receiveEip1193Result";
result: any;
} | {
action: "receiveEip1193Error";
error: Error;
};
export declare class BrowserProvider extends JsonRpcApiPollingProvider {
#private;
constructor(ethereum: Eip1193Provider, network?: Networkish);
send(method: string, params: Array<any> | Record<string, any>): Promise<any>;
_send(payload: JsonRpcPayload | Array<JsonRpcPayload>): Promise<Array<JsonRpcResult | JsonRpcError>>;
getRpcError(payload: JsonRpcPayload, error: JsonRpcError): Error;
hasSigner(address: number | string): Promise<boolean>;
getSigner(address?: number | string): Promise<JsonRpcSigner>;
}

View File

@ -0,0 +1,13 @@
/**
* About Cloudflare
*
* @_subsection: api/providers/thirdparty:Cloudflare [providers-cloudflare]
*/
import { JsonRpcProvider } from "./provider-jsonrpc.js";
import type { Networkish } from "./network.js";
/**
* About Cloudflare...
*/
export declare class CloudflareProvider extends JsonRpcProvider {
constructor(_network?: Networkish);
}

View File

@ -0,0 +1,140 @@
/**
* [[link-etherscan]] provides a third-party service for connecting to
* various blockchains over a combination of JSON-RPC and custom API
* endpoints.
*
* **Supported Networks**
*
* - Ethereum Mainnet (``mainnet``)
* - Goerli Testnet (``goerli``)
* - Sepolia Testnet (``sepolia``)
* - Arbitrum (``arbitrum``)
* - Arbitrum Goerli Testnet (``arbitrum-goerli``)
* - Optimism (``optimism``)
* - Optimism Goerli Testnet (``optimism-goerli``)
* - Polygon (``matic``)
* - Polygon Mumbai Testnet (``maticmum``)
*
* @_subsection api/providers/thirdparty:Etherscan [providers-etherscan]
*/
import { Contract } from "../contract/index.js";
import { AbstractProvider } from "./abstract-provider.js";
import { Network } from "./network.js";
import { NetworkPlugin } from "./plugins-network.js";
import { PerformActionRequest } from "./abstract-provider.js";
import type { Networkish } from "./network.js";
import type { TransactionRequest } from "./provider.js";
/**
* When subscribing to the ``"debug"`` event on an Etherscan-based
* provider, the events receive a **DebugEventEtherscanProvider**
* payload.
*
* @_docloc: api/providers/thirdparty:Etherscan
*/
export type DebugEventEtherscanProvider = {
action: "sendRequest";
id: number;
url: string;
payload: Record<string, any>;
} | {
action: "receiveRequest";
id: number;
result: any;
} | {
action: "receiveError";
id: number;
error: any;
};
/**
* A Network can include an **EtherscanPlugin** to provide
* a custom base URL.
*
* @_docloc: api/providers/thirdparty:Etherscan
*/
export declare class EtherscanPlugin extends NetworkPlugin {
/**
* The Etherscan API base URL.
*/
readonly baseUrl: string;
/**
* Creates a new **EtherscanProvider** which will use
* %%baseUrl%%.
*/
constructor(baseUrl: string);
clone(): EtherscanPlugin;
}
/**
* The **EtherscanBaseProvider** is the super-class of
* [[EtherscanProvider]], which should generally be used instead.
*
* Since the **EtherscanProvider** includes additional code for
* [[Contract]] access, in //rare cases// that contracts are not
* used, this class can reduce code size.
*
* @_docloc: api/providers/thirdparty:Etherscan
*/
export declare class EtherscanProvider extends AbstractProvider {
#private;
/**
* The connected network.
*/
readonly network: Network;
/**
* The API key or null if using the community provided bandwidth.
*/
readonly apiKey: null | string;
/**
* Creates a new **EtherscanBaseProvider**.
*/
constructor(_network?: Networkish, _apiKey?: string);
/**
* Returns the base URL.
*
* If an [[EtherscanPlugin]] is configured on the
* [[EtherscanBaseProvider_network]], returns the plugin's
* baseUrl.
*/
getBaseUrl(): string;
/**
* Returns the URL for the %%module%% and %%params%%.
*/
getUrl(module: string, params: Record<string, string>): string;
/**
* Returns the URL for using POST requests.
*/
getPostUrl(): string;
/**
* Returns the parameters for using POST requests.
*/
getPostData(module: string, params: Record<string, any>): Record<string, any>;
detectNetwork(): Promise<Network>;
/**
* Resolves to the result of calling %%module%% with %%params%%.
*
* If %%post%%, the request is made as a POST request.
*/
fetch(module: string, params: Record<string, any>, post?: boolean): Promise<any>;
/**
* Returns %%transaction%% normalized for the Etherscan API.
*/
_getTransactionPostData(transaction: TransactionRequest): Record<string, string>;
/**
* Throws the normalized Etherscan error.
*/
_checkError(req: PerformActionRequest, error: Error, transaction: any): never;
_detectNetwork(): Promise<Network>;
_perform(req: PerformActionRequest): Promise<any>;
getNetwork(): Promise<Network>;
/**
* Resolves to the current price of ether.
*
* This returns ``0`` on any network other than ``mainnet``.
*/
getEtherPrice(): Promise<number>;
/**
* Resolves to a [Contract]] for %%address%%, using the
* Etherscan API to retreive the Contract ABI.
*/
getContract(_address: string): Promise<null | Contract>;
isCommunityResource(): boolean;
}

View File

@ -0,0 +1,50 @@
import { AbstractProvider } from "./abstract-provider.js";
import { Network } from "./network.js";
import type { PerformActionRequest } from "./abstract-provider.js";
import type { Networkish } from "./network.js";
/**
* A configuration entry for how to use a [[Provider]].
*/
export interface FallbackProviderConfig {
provider: AbstractProvider;
stallTimeout?: number;
priority?: number;
weight?: number;
}
/**
* The statistics and state maintained for a [[Provider]].
*/
export interface FallbackProviderState extends Required<FallbackProviderConfig> {
blockNumber: number;
requests: number;
errorResponses: number;
lateResponses: number;
outOfSync: number;
unsupportedEvents: number;
rollingDuration: number;
score: number;
}
/**
* Additional options to configure a [[FallbackProvider]].
*/
export type FallbackProviderOptions = {
quorum: number;
eventQuorum: number;
eventWorkers: number;
};
/**
* A Fallback Provider.
*
*/
export declare class FallbackProvider extends AbstractProvider {
#private;
readonly quorum: number;
readonly eventQuorum: number;
readonly eventWorkers: number;
constructor(providers: Array<AbstractProvider | FallbackProviderConfig>, network?: Networkish);
get providerConfigs(): Array<FallbackProviderState>;
_detectNetwork(): Promise<Network>;
_translatePerform(provider: AbstractProvider, req: PerformActionRequest): Promise<any>;
_perform<T = any>(req: PerformActionRequest): Promise<T>;
destroy(): Promise<void>;
}

Some files were not shown because too many files have changed in this diff Show More