ethers.js/lib.commonjs/providers/network.d.ts

99 lines
3.2 KiB
TypeScript
Raw Normal View History

2023-03-04 04:25:07 +03:00
/**
2023-06-02 00:52:58 +03:00
* A **Network** encapsulates the various properties required to
* interact with a specific chain.
2023-03-04 04:25:07 +03:00
*
* @_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;
};
2023-06-02 00:52:58 +03:00
/**
* A **Network** provides access to a chain's properties and allows
* for plug-ins to extend functionality.
*/
2023-03-04 04:25:07 +03:00
export declare class Network {
#private;
2023-06-02 00:52:58 +03:00
/**
* Creates a new **Network** for %%name%% and %%chainId%%.
*/
2023-03-04 04:25:07 +03:00
constructor(name: string, chainId: BigNumberish);
2023-06-02 00:52:58 +03:00
/**
* Returns a JSON-compatible representation of a Network.
*/
2023-03-04 04:25:07 +03:00
toJSON(): any;
2023-04-25 14:04:48 +03:00
/**
* The network common name.
*
* This is the canonical name, as networks migh have multiple
* names.
*/
2023-03-04 04:25:07 +03:00
get name(): string;
set name(value: string);
2023-04-25 14:04:48 +03:00
/**
* The network chain ID.
*/
2023-03-04 04:25:07 +03:00
get chainId(): bigint;
set chainId(value: BigNumberish);
2023-04-25 14:04:48 +03:00
/**
* Returns true if %%other%% matches this network. Any chain ID
* must match, and if no chain ID is present, the name must match.
*
* This method does not currently check for additional properties,
* such as ENS address or plug-in compatibility.
*/
matches(other: Networkish): boolean;
/**
* Returns the list of plugins currently attached to this Network.
*/
2023-03-04 04:25:07 +03:00
get plugins(): Array<NetworkPlugin>;
2023-04-25 14:04:48 +03:00
/**
* Attach a new %%plugin%% to this Network. The network name
* must be unique, excluding any fragment.
*/
2023-03-04 04:25:07 +03:00
attachPlugin(plugin: NetworkPlugin): this;
2023-04-25 14:04:48 +03:00
/**
* Return the plugin, if any, matching %%name%% exactly. Plugins
* with fragments will not be returned unless %%name%% includes
* a fragment.
*/
2023-03-04 04:25:07 +03:00
getPlugin<T extends NetworkPlugin = NetworkPlugin>(name: string): null | T;
2023-04-25 14:04:48 +03:00
/**
* Gets a list of all plugins that match %%name%%, with otr without
* a fragment.
*/
2023-03-04 04:25:07 +03:00
getPlugins<T extends NetworkPlugin = NetworkPlugin>(basename: string): Array<T>;
2023-04-25 14:04:48 +03:00
/**
* Create a copy of this Network.
*/
2023-03-04 04:25:07 +03:00
clone(): Network;
2023-04-25 14:04:48 +03:00
/**
* Compute the intrinsic gas required for a transaction.
*
* A GasCostPlugin can be attached to override the default
* values.
*/
2023-03-04 04:25:07 +03:00
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;
}
//# sourceMappingURL=network.d.ts.map