refactor: move brother_node development artifact to dev/test-nodes subdirectory
Development Artifact Cleanup: ✅ BROTHER_NODE REORGANIZATION: Moved development test node to appropriate location - dev/test-nodes/brother_node/: Moved from root directory for better organization - Contains development configuration, test logs, and test chain data - No impact on production systems - purely development/testing artifact ✅ DEVELOPMENT ARTIFACTS IDENTIFIED: - Chain ID: aitbc-brother-chain (test/development chain) - Ports: 8010 (P2P) and 8011 (RPC) - different from production - Environment: .env file with test configuration - Logs: rpc.log and node.log from development testing session (March 15, 2026) ✅ ROOT DIRECTORY CLEANUP: Removed development clutter from production directory - brother_node/ moved to dev/test-nodes/brother_node/ - Root directory now contains only production-ready components - Development artifacts properly organized in dev/ subdirectory DIRECTORY STRUCTURE IMPROVEMENT: 📁 dev/test-nodes/: Development and testing node configurations 🏗️ Root Directory: Clean production structure with only essential components 🧪 Development Isolation: Test environments separated from production BENEFITS: ✅ Clean Production Directory: No development artifacts in root ✅ Better Organization: Development nodes grouped in dev/ subdirectory ✅ Clear Separation: Production vs development environments clearly distinguished ✅ Maintainability: Easier to identify and manage development components RESULT: Successfully moved brother_node development artifact to dev/test-nodes/ subdirectory, cleaning up the root directory while preserving development testing environment for future use.
This commit is contained in:
451
dev/env/node_modules/ethers/lib.esm/providers/abstract-provider.d.ts
generated
vendored
Executable file
451
dev/env/node_modules/ethers/lib.esm/providers/abstract-provider.d.ts
generated
vendored
Executable file
@@ -0,0 +1,451 @@
|
||||
/**
|
||||
* The available providers should suffice for most developers purposes,
|
||||
* but the [[AbstractProvider]] class has many features which enable
|
||||
* sub-classing it for specific purposes.
|
||||
*
|
||||
* @_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";
|
||||
/**
|
||||
* The types of additional event values that can be emitted for the
|
||||
* ``"debug"`` event.
|
||||
*/
|
||||
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;
|
||||
};
|
||||
/**
|
||||
* The value passed to the [[AbstractProvider-_getSubscriber]] method.
|
||||
*
|
||||
* Only developers sub-classing [[AbstractProvider[[ will care about this,
|
||||
* if they are modifying a low-level feature of how subscriptions operate.
|
||||
*/
|
||||
export type Subscription = {
|
||||
type: "block" | "close" | "debug" | "error" | "finalized" | "network" | "pending" | "safe";
|
||||
tag: string;
|
||||
} | {
|
||||
type: "transaction";
|
||||
tag: string;
|
||||
hash: string;
|
||||
} | {
|
||||
type: "event";
|
||||
tag: string;
|
||||
filter: EventFilter;
|
||||
} | {
|
||||
type: "orphan";
|
||||
tag: string;
|
||||
filter: OrphanFilter;
|
||||
};
|
||||
/**
|
||||
* A **Subscriber** manages a subscription.
|
||||
*
|
||||
* Only developers sub-classing [[AbstractProvider[[ will care about this,
|
||||
* if they are modifying a low-level feature of how subscriptions operate.
|
||||
*/
|
||||
export interface Subscriber {
|
||||
/**
|
||||
* Called initially when a subscriber is added the first time.
|
||||
*/
|
||||
start(): void;
|
||||
/**
|
||||
* Called when there are no more subscribers to the event.
|
||||
*/
|
||||
stop(): void;
|
||||
/**
|
||||
* Called when the subscription should pause.
|
||||
*
|
||||
* If %%dropWhilePaused%%, events that occur while paused should not
|
||||
* be emitted [[resume]].
|
||||
*/
|
||||
pause(dropWhilePaused?: boolean): void;
|
||||
/**
|
||||
* Resume a paused subscriber.
|
||||
*/
|
||||
resume(): void;
|
||||
/**
|
||||
* The frequency (in ms) to poll for events, if polling is used by
|
||||
* the subscriber.
|
||||
*
|
||||
* For non-polling subscribers, this must return ``undefined``.
|
||||
*/
|
||||
pollingInterval?: number;
|
||||
}
|
||||
/**
|
||||
* An **UnmanagedSubscriber** is useful for events which do not require
|
||||
* any additional management, such as ``"debug"`` which only requires
|
||||
* emit in synchronous event loop triggered calls.
|
||||
*/
|
||||
export declare class UnmanagedSubscriber implements Subscriber {
|
||||
/**
|
||||
* The name fof the event.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* Create a new UnmanagedSubscriber with %%name%%.
|
||||
*/
|
||||
constructor(name: string);
|
||||
start(): void;
|
||||
stop(): void;
|
||||
pause(dropWhilePaused?: boolean): void;
|
||||
resume(): void;
|
||||
}
|
||||
/**
|
||||
* An **AbstractPlugin** is used to provide additional internal services
|
||||
* to an [[AbstractProvider]] without adding backwards-incompatible changes
|
||||
* to method signatures or other internal and complex logic.
|
||||
*/
|
||||
export interface AbstractProviderPlugin {
|
||||
/**
|
||||
* The reverse domain notation of the plugin.
|
||||
*/
|
||||
readonly name: string;
|
||||
/**
|
||||
* Creates a new instance of the plugin, connected to %%provider%%.
|
||||
*/
|
||||
connect(provider: AbstractProvider): AbstractProviderPlugin;
|
||||
}
|
||||
/**
|
||||
* A normalized filter used for [[PerformActionRequest]] objects.
|
||||
*/
|
||||
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;
|
||||
};
|
||||
/**
|
||||
* A normalized transactions used for [[PerformActionRequest]] objects.
|
||||
*/
|
||||
export interface PerformActionTransaction extends PreparedTransactionRequest {
|
||||
/**
|
||||
* The ``to`` address of the transaction.
|
||||
*/
|
||||
to?: string;
|
||||
/**
|
||||
* The sender of the transaction.
|
||||
*/
|
||||
from?: string;
|
||||
}
|
||||
/**
|
||||
* The [[AbstractProvider]] methods will normalize all values and pass this
|
||||
* type to [[AbstractProvider-_perform]].
|
||||
*/
|
||||
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: "getPriorityFee";
|
||||
} | {
|
||||
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;
|
||||
};
|
||||
/**
|
||||
* Options for configuring some internal aspects of an [[AbstractProvider]].
|
||||
*
|
||||
* **``cacheTimeout``** - how long to cache a low-level ``_perform``
|
||||
* for, based on input parameters. This reduces the number of calls
|
||||
* to getChainId and getBlockNumber, but may break test chains which
|
||||
* can perform operations (internally) synchronously. Use ``-1`` to
|
||||
* disable, ``0`` will only buffer within the same event loop and
|
||||
* any other value is in ms. (default: ``250``)
|
||||
*/
|
||||
export type AbstractProviderOptions = {
|
||||
cacheTimeout?: number;
|
||||
pollingInterval?: number;
|
||||
};
|
||||
/**
|
||||
* An **AbstractProvider** provides a base class for other sub-classes to
|
||||
* implement the [[Provider]] API by normalizing input arguments and
|
||||
* formatting output results as well as tracking events for consistent
|
||||
* behaviour on an eventually-consistent network.
|
||||
*/
|
||||
export declare class AbstractProvider implements Provider {
|
||||
#private;
|
||||
/**
|
||||
* Create a new **AbstractProvider** connected to %%network%%, or
|
||||
* use the various network detection capabilities to discover the
|
||||
* [[Network]] if necessary.
|
||||
*/
|
||||
constructor(_network?: "any" | Networkish, options?: AbstractProviderOptions);
|
||||
get pollingInterval(): number;
|
||||
/**
|
||||
* Returns ``this``, to allow an **AbstractProvider** to implement
|
||||
* the [[ContractRunner]] interface.
|
||||
*/
|
||||
get provider(): this;
|
||||
/**
|
||||
* Returns all the registered plug-ins.
|
||||
*/
|
||||
get plugins(): Array<AbstractProviderPlugin>;
|
||||
/**
|
||||
* Attach a new plug-in.
|
||||
*/
|
||||
attachPlugin(plugin: AbstractProviderPlugin): this;
|
||||
/**
|
||||
* Get a plugin by name.
|
||||
*/
|
||||
getPlugin<T extends AbstractProviderPlugin = AbstractProviderPlugin>(name: string): null | T;
|
||||
/**
|
||||
* Prevent any CCIP-read operation, regardless of whether requested
|
||||
* in a [[call]] using ``enableCcipRead``.
|
||||
*/
|
||||
get disableCcipRead(): boolean;
|
||||
set disableCcipRead(value: boolean);
|
||||
/**
|
||||
* Resolves to the data for executing the CCIP-read operations.
|
||||
*/
|
||||
ccipReadFetch(tx: PerformActionTransaction, calldata: string, urls: Array<string>): Promise<null | string>;
|
||||
/**
|
||||
* Provides the opportunity for a sub-class to wrap a block before
|
||||
* returning it, to add additional properties or an alternate
|
||||
* sub-class of [[Block]].
|
||||
*/
|
||||
_wrapBlock(value: BlockParams, network: Network): Block;
|
||||
/**
|
||||
* Provides the opportunity for a sub-class to wrap a log before
|
||||
* returning it, to add additional properties or an alternate
|
||||
* sub-class of [[Log]].
|
||||
*/
|
||||
_wrapLog(value: LogParams, network: Network): Log;
|
||||
/**
|
||||
* Provides the opportunity for a sub-class to wrap a transaction
|
||||
* receipt before returning it, to add additional properties or an
|
||||
* alternate sub-class of [[TransactionReceipt]].
|
||||
*/
|
||||
_wrapTransactionReceipt(value: TransactionReceiptParams, network: Network): TransactionReceipt;
|
||||
/**
|
||||
* Provides the opportunity for a sub-class to wrap a transaction
|
||||
* response before returning it, to add additional properties or an
|
||||
* alternate sub-class of [[TransactionResponse]].
|
||||
*/
|
||||
_wrapTransactionResponse(tx: TransactionResponseParams, network: Network): TransactionResponse;
|
||||
/**
|
||||
* Resolves to the Network, forcing a network detection using whatever
|
||||
* technique the sub-class requires.
|
||||
*
|
||||
* Sub-classes **must** override this.
|
||||
*/
|
||||
_detectNetwork(): Promise<Network>;
|
||||
/**
|
||||
* Sub-classes should use this to perform all built-in operations. All
|
||||
* methods sanitizes and normalizes the values passed into this.
|
||||
*
|
||||
* Sub-classes **must** override this.
|
||||
*/
|
||||
_perform<T = any>(req: PerformActionRequest): Promise<T>;
|
||||
getBlockNumber(): Promise<number>;
|
||||
/**
|
||||
* Returns or resolves to the address for %%address%%, resolving ENS
|
||||
* names and [[Addressable]] objects and returning if already an
|
||||
* address.
|
||||
*/
|
||||
_getAddress(address: AddressLike): string | Promise<string>;
|
||||
/**
|
||||
* Returns or resolves to a valid block tag for %%blockTag%%, resolving
|
||||
* negative values and returning if already a valid block tag.
|
||||
*/
|
||||
_getBlockTag(blockTag?: BlockTag): string | Promise<string>;
|
||||
/**
|
||||
* Returns or resolves to a filter for %%filter%%, resolving any ENS
|
||||
* names or [[Addressable]] object and returning if already a valid
|
||||
* filter.
|
||||
*/
|
||||
_getFilter(filter: Filter | FilterByBlockHash): PerformActionFilter | Promise<PerformActionFilter>;
|
||||
/**
|
||||
* Returns or resolves to a transaction for %%request%%, resolving
|
||||
* any ENS names or [[Addressable]] and returning if already a valid
|
||||
* transaction.
|
||||
*/
|
||||
_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>;
|
||||
/**
|
||||
* Clear a timer created using the [[_setTimeout]] method.
|
||||
*/
|
||||
_clearTimeout(timerId: number): void;
|
||||
/**
|
||||
* Create a timer that will execute %%func%% after at least %%timeout%%
|
||||
* (in ms). If %%timeout%% is unspecified, then %%func%% will execute
|
||||
* in the next event loop.
|
||||
*
|
||||
* [Pausing](AbstractProvider-paused) the provider will pause any
|
||||
* associated timers.
|
||||
*/
|
||||
_setTimeout(_func: () => void, timeout?: number): number;
|
||||
/**
|
||||
* Perform %%func%% on each subscriber.
|
||||
*/
|
||||
_forEachSubscriber(func: (s: Subscriber) => void): void;
|
||||
/**
|
||||
* Sub-classes may override this to customize subscription
|
||||
* implementations.
|
||||
*/
|
||||
_getSubscriber(sub: Subscription): Subscriber;
|
||||
/**
|
||||
* If a [[Subscriber]] fails and needs to replace itself, this
|
||||
* method may be used.
|
||||
*
|
||||
* For example, this is used for providers when using the
|
||||
* ``eth_getFilterChanges`` method, which can return null if state
|
||||
* filters are not supported by the backend, allowing the Subscriber
|
||||
* to swap in a [[PollingEventSubscriber]].
|
||||
*/
|
||||
_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>;
|
||||
/**
|
||||
* If this provider has been destroyed using the [[destroy]] method.
|
||||
*
|
||||
* Once destroyed, all resources are reclaimed, internal event loops
|
||||
* and timers are cleaned up and no further requests may be sent to
|
||||
* the provider.
|
||||
*/
|
||||
get destroyed(): boolean;
|
||||
/**
|
||||
* Sub-classes may use this to shutdown any sockets or release their
|
||||
* resources and reject any pending requests.
|
||||
*
|
||||
* Sub-classes **must** call ``super.destroy()``.
|
||||
*/
|
||||
destroy(): void;
|
||||
/**
|
||||
* Whether the provider is currently paused.
|
||||
*
|
||||
* A paused provider will not emit any events, and generally should
|
||||
* not make any requests to the network, but that is up to sub-classes
|
||||
* to manage.
|
||||
*
|
||||
* Setting ``paused = true`` is identical to calling ``.pause(false)``,
|
||||
* which will buffer any events that occur while paused until the
|
||||
* provider is unpaused.
|
||||
*/
|
||||
get paused(): boolean;
|
||||
set paused(pause: boolean);
|
||||
/**
|
||||
* Pause the provider. If %%dropWhilePaused%%, any events that occur
|
||||
* while paused are dropped, otherwise all events will be emitted once
|
||||
* the provider is unpaused.
|
||||
*/
|
||||
pause(dropWhilePaused?: boolean): void;
|
||||
/**
|
||||
* Resume the provider.
|
||||
*/
|
||||
resume(): void;
|
||||
}
|
||||
//# sourceMappingURL=abstract-provider.d.ts.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/abstract-provider.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/abstract-provider.d.ts.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
1404
dev/env/node_modules/ethers/lib.esm/providers/abstract-provider.js
generated
vendored
Executable file
1404
dev/env/node_modules/ethers/lib.esm/providers/abstract-provider.js
generated
vendored
Executable file
File diff suppressed because it is too large
Load Diff
1
dev/env/node_modules/ethers/lib.esm/providers/abstract-provider.js.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/abstract-provider.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
69
dev/env/node_modules/ethers/lib.esm/providers/abstract-signer.d.ts
generated
vendored
Executable file
69
dev/env/node_modules/ethers/lib.esm/providers/abstract-signer.d.ts
generated
vendored
Executable file
@@ -0,0 +1,69 @@
|
||||
import type { AuthorizationRequest, TypedDataDomain, TypedDataField } from "../hash/index.js";
|
||||
import type { Authorization, TransactionLike } from "../transaction/index.js";
|
||||
import type { BlockTag, Provider, TransactionRequest, TransactionResponse } from "./provider.js";
|
||||
import type { Signer } from "./signer.js";
|
||||
/**
|
||||
* An **AbstractSigner** includes most of teh functionality required
|
||||
* to get a [[Signer]] working as expected, but requires a few
|
||||
* Signer-specific methods be overridden.
|
||||
*
|
||||
*/
|
||||
export declare abstract class AbstractSigner<P extends null | Provider = null | Provider> implements Signer {
|
||||
/**
|
||||
* The provider this signer is connected to.
|
||||
*/
|
||||
readonly provider: P;
|
||||
/**
|
||||
* Creates a new Signer connected to %%provider%%.
|
||||
*/
|
||||
constructor(provider?: P);
|
||||
/**
|
||||
* Resolves to the Signer address.
|
||||
*/
|
||||
abstract getAddress(): Promise<string>;
|
||||
/**
|
||||
* Returns the signer connected to %%provider%%.
|
||||
*
|
||||
* This may throw, for example, a Signer connected over a Socket or
|
||||
* to a specific instance of a node may not be transferrable.
|
||||
*/
|
||||
abstract connect(provider: null | Provider): Signer;
|
||||
getNonce(blockTag?: BlockTag): Promise<number>;
|
||||
populateCall(tx: TransactionRequest): Promise<TransactionLike<string>>;
|
||||
populateTransaction(tx: TransactionRequest): Promise<TransactionLike<string>>;
|
||||
populateAuthorization(_auth: AuthorizationRequest): Promise<AuthorizationRequest>;
|
||||
estimateGas(tx: TransactionRequest): Promise<bigint>;
|
||||
call(tx: TransactionRequest): Promise<string>;
|
||||
resolveName(name: string): Promise<null | string>;
|
||||
sendTransaction(tx: TransactionRequest): Promise<TransactionResponse>;
|
||||
authorize(authorization: AuthorizationRequest): Promise<Authorization>;
|
||||
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>;
|
||||
}
|
||||
/**
|
||||
* A **VoidSigner** is a class designed to allow an address to be used
|
||||
* in any API which accepts a Signer, but for which there are no
|
||||
* credentials available to perform any actual signing.
|
||||
*
|
||||
* This for example allow impersonating an account for the purpose of
|
||||
* static calls or estimating gas, but does not allow sending transactions.
|
||||
*/
|
||||
export declare class VoidSigner extends AbstractSigner {
|
||||
#private;
|
||||
/**
|
||||
* The signer address.
|
||||
*/
|
||||
readonly address: string;
|
||||
/**
|
||||
* Creates a new **VoidSigner** with %%address%% attached to
|
||||
* %%provider%%.
|
||||
*/
|
||||
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>;
|
||||
}
|
||||
//# sourceMappingURL=abstract-signer.d.ts.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/abstract-signer.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/abstract-signer.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"abstract-signer.d.ts","sourceRoot":"","sources":["../../src.ts/providers/abstract-signer.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EACR,oBAAoB,EAAE,eAAe,EAAE,cAAc,EACxD,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE9E,OAAO,KAAK,EACR,QAAQ,EAAE,QAAQ,EAAE,kBAAkB,EAAE,mBAAmB,EAC9D,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AA8B1C;;;;;GAKG;AACH,8BAA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,CAAC,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;CAC7I;AAED;;;;;;;GAOG;AACH,qBAAa,UAAW,SAAQ,cAAc;;IAC1C;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAG,MAAM,CAAC;IAE1B;;;OAGG;gBACS,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,IAAI,GAAG,QAAQ;IAKjD,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAEnC,OAAO,CAAC,QAAQ,EAAE,IAAI,GAAG,QAAQ,GAAG,UAAU;IAQxC,eAAe,CAAC,EAAE,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC;IAIxD,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAI1D,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;CAG1I"}
|
||||
244
dev/env/node_modules/ethers/lib.esm/providers/abstract-signer.js
generated
vendored
Executable file
244
dev/env/node_modules/ethers/lib.esm/providers/abstract-signer.js
generated
vendored
Executable file
@@ -0,0 +1,244 @@
|
||||
/**
|
||||
* Generally the [[Wallet]] and [[JsonRpcSigner]] and their sub-classes
|
||||
* are sufficient for most developers, but this is provided to
|
||||
* fascilitate more complex Signers.
|
||||
*
|
||||
* @_section: api/providers/abstract-signer: Subclassing Signer [abstract-signer]
|
||||
*/
|
||||
import { resolveAddress } from "../address/index.js";
|
||||
import { Transaction } from "../transaction/index.js";
|
||||
import { defineProperties, getBigInt, resolveProperties, assert, assertArgument } from "../utils/index.js";
|
||||
import { copyRequest } from "./provider.js";
|
||||
function checkProvider(signer, operation) {
|
||||
if (signer.provider) {
|
||||
return signer.provider;
|
||||
}
|
||||
assert(false, "missing provider", "UNSUPPORTED_OPERATION", { operation });
|
||||
}
|
||||
async function populate(signer, tx) {
|
||||
let pop = copyRequest(tx);
|
||||
if (pop.to != null) {
|
||||
pop.to = resolveAddress(pop.to, signer);
|
||||
}
|
||||
if (pop.from != null) {
|
||||
const from = pop.from;
|
||||
pop.from = Promise.all([
|
||||
signer.getAddress(),
|
||||
resolveAddress(from, signer)
|
||||
]).then(([address, from]) => {
|
||||
assertArgument(address.toLowerCase() === from.toLowerCase(), "transaction from mismatch", "tx.from", from);
|
||||
return address;
|
||||
});
|
||||
}
|
||||
else {
|
||||
pop.from = signer.getAddress();
|
||||
}
|
||||
return await resolveProperties(pop);
|
||||
}
|
||||
/**
|
||||
* An **AbstractSigner** includes most of teh functionality required
|
||||
* to get a [[Signer]] working as expected, but requires a few
|
||||
* Signer-specific methods be overridden.
|
||||
*
|
||||
*/
|
||||
export class AbstractSigner {
|
||||
/**
|
||||
* The provider this signer is connected to.
|
||||
*/
|
||||
provider;
|
||||
/**
|
||||
* Creates a new Signer connected to %%provider%%.
|
||||
*/
|
||||
constructor(provider) {
|
||||
defineProperties(this, { provider: (provider || null) });
|
||||
}
|
||||
async getNonce(blockTag) {
|
||||
return checkProvider(this, "getTransactionCount").getTransactionCount(await this.getAddress(), blockTag);
|
||||
}
|
||||
async populateCall(tx) {
|
||||
const pop = await populate(this, tx);
|
||||
return pop;
|
||||
}
|
||||
async populateTransaction(tx) {
|
||||
const provider = checkProvider(this, "populateTransaction");
|
||||
const pop = await populate(this, tx);
|
||||
if (pop.nonce == null) {
|
||||
pop.nonce = await this.getNonce("pending");
|
||||
}
|
||||
if (pop.gasLimit == null) {
|
||||
pop.gasLimit = await this.estimateGas(pop);
|
||||
}
|
||||
// Populate the chain ID
|
||||
const network = await (this.provider).getNetwork();
|
||||
if (pop.chainId != null) {
|
||||
const chainId = getBigInt(pop.chainId);
|
||||
assertArgument(chainId === network.chainId, "transaction chainId mismatch", "tx.chainId", tx.chainId);
|
||||
}
|
||||
else {
|
||||
pop.chainId = network.chainId;
|
||||
}
|
||||
// Do not allow mixing pre-eip-1559 and eip-1559 properties
|
||||
const hasEip1559 = (pop.maxFeePerGas != null || pop.maxPriorityFeePerGas != null);
|
||||
if (pop.gasPrice != null && (pop.type === 2 || hasEip1559)) {
|
||||
assertArgument(false, "eip-1559 transaction do not support gasPrice", "tx", tx);
|
||||
}
|
||||
else if ((pop.type === 0 || pop.type === 1) && hasEip1559) {
|
||||
assertArgument(false, "pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas", "tx", tx);
|
||||
}
|
||||
if ((pop.type === 2 || pop.type == null) && (pop.maxFeePerGas != null && pop.maxPriorityFeePerGas != null)) {
|
||||
// Fully-formed EIP-1559 transaction (skip getFeeData)
|
||||
pop.type = 2;
|
||||
}
|
||||
else if (pop.type === 0 || pop.type === 1) {
|
||||
// Explicit Legacy or EIP-2930 transaction
|
||||
// We need to get fee data to determine things
|
||||
const feeData = await provider.getFeeData();
|
||||
assert(feeData.gasPrice != null, "network does not support gasPrice", "UNSUPPORTED_OPERATION", {
|
||||
operation: "getGasPrice"
|
||||
});
|
||||
// Populate missing gasPrice
|
||||
if (pop.gasPrice == null) {
|
||||
pop.gasPrice = feeData.gasPrice;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// We need to get fee data to determine things
|
||||
const feeData = await provider.getFeeData();
|
||||
if (pop.type == null) {
|
||||
// We need to auto-detect the intended type of this transaction...
|
||||
if (feeData.maxFeePerGas != null && feeData.maxPriorityFeePerGas != null) {
|
||||
// The network supports EIP-1559!
|
||||
// Upgrade transaction from null to eip-1559
|
||||
if (pop.authorizationList && pop.authorizationList.length) {
|
||||
pop.type = 4;
|
||||
}
|
||||
else {
|
||||
pop.type = 2;
|
||||
}
|
||||
if (pop.gasPrice != null) {
|
||||
// Using legacy gasPrice property on an eip-1559 network,
|
||||
// so use gasPrice as both fee properties
|
||||
const gasPrice = pop.gasPrice;
|
||||
delete pop.gasPrice;
|
||||
pop.maxFeePerGas = gasPrice;
|
||||
pop.maxPriorityFeePerGas = gasPrice;
|
||||
}
|
||||
else {
|
||||
// Populate missing fee data
|
||||
if (pop.maxFeePerGas == null) {
|
||||
pop.maxFeePerGas = feeData.maxFeePerGas;
|
||||
}
|
||||
if (pop.maxPriorityFeePerGas == null) {
|
||||
pop.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (feeData.gasPrice != null) {
|
||||
// Network doesn't support EIP-1559...
|
||||
// ...but they are trying to use EIP-1559 properties
|
||||
assert(!hasEip1559, "network does not support EIP-1559", "UNSUPPORTED_OPERATION", {
|
||||
operation: "populateTransaction"
|
||||
});
|
||||
// Populate missing fee data
|
||||
if (pop.gasPrice == null) {
|
||||
pop.gasPrice = feeData.gasPrice;
|
||||
}
|
||||
// Explicitly set untyped transaction to legacy
|
||||
// @TODO: Maybe this shold allow type 1?
|
||||
pop.type = 0;
|
||||
}
|
||||
else {
|
||||
// getFeeData has failed us.
|
||||
assert(false, "failed to get consistent fee data", "UNSUPPORTED_OPERATION", {
|
||||
operation: "signer.getFeeData"
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (pop.type === 2 || pop.type === 3 || pop.type === 4) {
|
||||
// Explicitly using EIP-1559 or EIP-4844
|
||||
// Populate missing fee data
|
||||
if (pop.maxFeePerGas == null) {
|
||||
pop.maxFeePerGas = feeData.maxFeePerGas;
|
||||
}
|
||||
if (pop.maxPriorityFeePerGas == null) {
|
||||
pop.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas;
|
||||
}
|
||||
}
|
||||
}
|
||||
//@TOOD: Don't await all over the place; save them up for
|
||||
// the end for better batching
|
||||
return await resolveProperties(pop);
|
||||
}
|
||||
async populateAuthorization(_auth) {
|
||||
const auth = Object.assign({}, _auth);
|
||||
// Add a chain ID if not explicitly set to 0
|
||||
if (auth.chainId == null) {
|
||||
auth.chainId = (await checkProvider(this, "getNetwork").getNetwork()).chainId;
|
||||
}
|
||||
// @TODO: Take chain ID into account when populating noce?
|
||||
if (auth.nonce == null) {
|
||||
auth.nonce = await this.getNonce();
|
||||
}
|
||||
return auth;
|
||||
}
|
||||
async estimateGas(tx) {
|
||||
return checkProvider(this, "estimateGas").estimateGas(await this.populateCall(tx));
|
||||
}
|
||||
async call(tx) {
|
||||
return checkProvider(this, "call").call(await this.populateCall(tx));
|
||||
}
|
||||
async resolveName(name) {
|
||||
const provider = checkProvider(this, "resolveName");
|
||||
return await provider.resolveName(name);
|
||||
}
|
||||
async sendTransaction(tx) {
|
||||
const provider = checkProvider(this, "sendTransaction");
|
||||
const pop = await this.populateTransaction(tx);
|
||||
delete pop.from;
|
||||
const txObj = Transaction.from(pop);
|
||||
return await provider.broadcastTransaction(await this.signTransaction(txObj));
|
||||
}
|
||||
// @TODO: in v7 move this to be abstract
|
||||
authorize(authorization) {
|
||||
assert(false, "authorization not implemented for this signer", "UNSUPPORTED_OPERATION", { operation: "authorize" });
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A **VoidSigner** is a class designed to allow an address to be used
|
||||
* in any API which accepts a Signer, but for which there are no
|
||||
* credentials available to perform any actual signing.
|
||||
*
|
||||
* This for example allow impersonating an account for the purpose of
|
||||
* static calls or estimating gas, but does not allow sending transactions.
|
||||
*/
|
||||
export class VoidSigner extends AbstractSigner {
|
||||
/**
|
||||
* The signer address.
|
||||
*/
|
||||
address;
|
||||
/**
|
||||
* Creates a new **VoidSigner** with %%address%% attached to
|
||||
* %%provider%%.
|
||||
*/
|
||||
constructor(address, provider) {
|
||||
super(provider);
|
||||
defineProperties(this, { address });
|
||||
}
|
||||
async getAddress() { return this.address; }
|
||||
connect(provider) {
|
||||
return new VoidSigner(this.address, provider);
|
||||
}
|
||||
#throwUnsupported(suffix, operation) {
|
||||
assert(false, `VoidSigner cannot sign ${suffix}`, "UNSUPPORTED_OPERATION", { operation });
|
||||
}
|
||||
async signTransaction(tx) {
|
||||
this.#throwUnsupported("transactions", "signTransaction");
|
||||
}
|
||||
async signMessage(message) {
|
||||
this.#throwUnsupported("messages", "signMessage");
|
||||
}
|
||||
async signTypedData(domain, types, value) {
|
||||
this.#throwUnsupported("typed-data", "signTypedData");
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=abstract-signer.js.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/abstract-signer.js.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/abstract-signer.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
29
dev/env/node_modules/ethers/lib.esm/providers/community.d.ts
generated
vendored
Executable file
29
dev/env/node_modules/ethers/lib.esm/providers/community.d.ts
generated
vendored
Executable file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* 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 if the instance is connected using the community
|
||||
* credentials.
|
||||
*/
|
||||
isCommunityResource(): boolean;
|
||||
}
|
||||
/**
|
||||
* Displays a warning in the 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;
|
||||
//# sourceMappingURL=community.d.ts.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/community.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/community.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"community.d.ts","sourceRoot":"","sources":["../../src.ts/providers/community.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACjC;;;OAGG;IACH,mBAAmB,IAAI,OAAO,CAAC;CAClC;AAKD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAgBzD"}
|
||||
36
dev/env/node_modules/ethers/lib.esm/providers/community.js
generated
vendored
Executable file
36
dev/env/node_modules/ethers/lib.esm/providers/community.js
generated
vendored
Executable file
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* 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]
|
||||
*/
|
||||
// Show the throttle message only once per service
|
||||
const shown = new Set();
|
||||
/**
|
||||
* Displays a warning in the 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 function showThrottleMessage(service) {
|
||||
if (shown.has(service)) {
|
||||
return;
|
||||
}
|
||||
shown.add(service);
|
||||
console.log("========= NOTICE =========");
|
||||
console.log(`Request-Rate Exceeded for ${service} (this message will not be repeated)`);
|
||||
console.log("");
|
||||
console.log("The default API keys for each service are provided as a highly-throttled,");
|
||||
console.log("community resource for low-traffic projects and early prototyping.");
|
||||
console.log("");
|
||||
console.log("While your application will continue to function, we highly recommended");
|
||||
console.log("signing up for your own API keys to improve performance, increase your");
|
||||
console.log("request rate/limit and enable other perks, such as metrics and advanced APIs.");
|
||||
console.log("");
|
||||
console.log("For more details: https:/\/docs.ethers.org/api-keys/");
|
||||
console.log("==========================");
|
||||
}
|
||||
//# sourceMappingURL=community.js.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/community.js.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/community.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"community.js","sourceRoot":"","sources":["../../src.ts/providers/community.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAeH,kDAAkD;AAClD,MAAM,KAAK,GAAgB,IAAI,GAAG,EAAE,CAAC;AAErC;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAe;IAC/C,IAAI,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;QAAE,OAAO;KAAE;IACnC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAEnB,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;IACzC,OAAO,CAAC,GAAG,CAAC,6BAA8B,OAAQ,sCAAsC,CAAC,CAAC;IAC1F,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,2EAA2E,CAAC,CAAC;IACzF,OAAO,CAAC,GAAG,CAAC,oEAAoE,CAAC,CAAC;IAClF,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,yEAAyE,CAAC,CAAC;IACvF,OAAO,CAAC,GAAG,CAAC,wEAAwE,CAAC,CAAC;IACtF,OAAO,CAAC,GAAG,CAAC,+EAA+E,CAAC,CAAC;IAC7F,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,sDAAsD,CAAC,CAAC;IACpE,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;AAC9C,CAAC"}
|
||||
36
dev/env/node_modules/ethers/lib.esm/providers/contracts.d.ts
generated
vendored
Executable file
36
dev/env/node_modules/ethers/lib.esm/providers/contracts.d.ts
generated
vendored
Executable file
@@ -0,0 +1,36 @@
|
||||
import type { Provider, TransactionRequest, TransactionResponse } from "./provider.js";
|
||||
/**
|
||||
* A **ContractRunner** is a generic interface which defines an object
|
||||
* capable of interacting with a Contract on the network.
|
||||
*
|
||||
* The more operations supported, the more utility it is capable of.
|
||||
*
|
||||
* The most common ContractRunners are [Providers](Provider) which enable
|
||||
* read-only access and [Signers](Signer) which enable write-access.
|
||||
*/
|
||||
export interface ContractRunner {
|
||||
/**
|
||||
* The provider used for necessary state querying operations.
|
||||
*
|
||||
* This can also point to the **ContractRunner** itself, in the
|
||||
* case of an [[AbstractProvider]].
|
||||
*/
|
||||
provider: null | Provider;
|
||||
/**
|
||||
* Required to estimate gas.
|
||||
*/
|
||||
estimateGas?: (tx: TransactionRequest) => Promise<bigint>;
|
||||
/**
|
||||
* Required for pure, view or static calls to contracts.
|
||||
*/
|
||||
call?: (tx: TransactionRequest) => Promise<string>;
|
||||
/**
|
||||
* Required to support ENS names
|
||||
*/
|
||||
resolveName?: (name: string) => Promise<null | string>;
|
||||
/**
|
||||
* Required for state mutating calls
|
||||
*/
|
||||
sendTransaction?: (tx: TransactionRequest) => Promise<TransactionResponse>;
|
||||
}
|
||||
//# sourceMappingURL=contracts.d.ts.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/contracts.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/contracts.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../src.ts/providers/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,QAAQ,EAAE,kBAAkB,EAAE,mBAAmB,EACpD,MAAM,eAAe,CAAC;AAEvB;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC3B;;;;;OAKG;IACH,QAAQ,EAAE,IAAI,GAAG,QAAQ,CAAC;IAE1B;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,EAAE,EAAE,kBAAkB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAE1D;;OAEG;IACH,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,kBAAkB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnD;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC;IAEvD;;OAEG;IACH,eAAe,CAAC,EAAE,CAAC,EAAE,EAAE,kBAAkB,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAC;CAC9E"}
|
||||
2
dev/env/node_modules/ethers/lib.esm/providers/contracts.js
generated
vendored
Executable file
2
dev/env/node_modules/ethers/lib.esm/providers/contracts.js
generated
vendored
Executable file
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=contracts.js.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/contracts.js.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/contracts.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../src.ts/providers/contracts.ts"],"names":[],"mappings":""}
|
||||
49
dev/env/node_modules/ethers/lib.esm/providers/default-provider.d.ts
generated
vendored
Executable file
49
dev/env/node_modules/ethers/lib.esm/providers/default-provider.d.ts
generated
vendored
Executable file
@@ -0,0 +1,49 @@
|
||||
import type { AbstractProvider } from "./abstract-provider.js";
|
||||
import type { Networkish } from "./network.js";
|
||||
import { WebSocketLike } from "./provider-websocket.js";
|
||||
/**
|
||||
* Returns a default provider for %%network%%.
|
||||
*
|
||||
* If %%network%% is a [[WebSocketLike]] or string that begins with
|
||||
* ``"ws:"`` or ``"wss:"``, a [[WebSocketProvider]] is returned backed
|
||||
* by that WebSocket or URL.
|
||||
*
|
||||
* If %%network%% is a string that begins with ``"HTTP:"`` or ``"HTTPS:"``,
|
||||
* a [[JsonRpcProvider]] is returned connected to that URL.
|
||||
*
|
||||
* Otherwise, a default provider is created backed by well-known public
|
||||
* Web3 backends (such as [[link-infura]]) using community-provided API
|
||||
* keys.
|
||||
*
|
||||
* The %%options%% allows specifying custom API keys per backend (setting
|
||||
* an API key to ``"-"`` will omit that provider) and ``options.exclusive``
|
||||
* can be set to either a backend name or and array of backend names, which
|
||||
* will whitelist **only** those backends.
|
||||
*
|
||||
* Current backend strings supported are:
|
||||
* - ``"alchemy"``
|
||||
* - ``"ankr"``
|
||||
* - ``"cloudflare"``
|
||||
* - ``"chainstack"``
|
||||
* - ``"etherscan"``
|
||||
* - ``"infura"``
|
||||
* - ``"publicPolygon"``
|
||||
* - ``"quicknode"``
|
||||
*
|
||||
* @example:
|
||||
* // Connect to a local Geth node
|
||||
* provider = getDefaultProvider("http://localhost:8545/");
|
||||
*
|
||||
* // Connect to Ethereum mainnet with any current and future
|
||||
* // third-party services available
|
||||
* provider = getDefaultProvider("mainnet");
|
||||
*
|
||||
* // Connect to Polygon, but only allow Etherscan and
|
||||
* // INFURA and use "MY_API_KEY" in calls to Etherscan.
|
||||
* provider = getDefaultProvider("matic", {
|
||||
* etherscan: "MY_API_KEY",
|
||||
* exclusive: [ "etherscan", "infura" ]
|
||||
* });
|
||||
*/
|
||||
export declare function getDefaultProvider(network?: string | Networkish | WebSocketLike, options?: any): AbstractProvider;
|
||||
//# sourceMappingURL=default-provider.d.ts.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/default-provider.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/default-provider.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"default-provider.d.ts","sourceRoot":"","sources":["../../src.ts/providers/default-provider.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AASxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,aAAa,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,gBAAgB,CAgIjH"}
|
||||
196
dev/env/node_modules/ethers/lib.esm/providers/default-provider.js
generated
vendored
Executable file
196
dev/env/node_modules/ethers/lib.esm/providers/default-provider.js
generated
vendored
Executable file
@@ -0,0 +1,196 @@
|
||||
import { assert } from "../utils/index.js";
|
||||
import { AnkrProvider } from "./provider-ankr.js";
|
||||
import { AlchemyProvider } from "./provider-alchemy.js";
|
||||
//import { BlockscoutProvider } from "./provider-blockscout.js";
|
||||
import { ChainstackProvider } from "./provider-chainstack.js";
|
||||
import { CloudflareProvider } from "./provider-cloudflare.js";
|
||||
import { EtherscanProvider } from "./provider-etherscan.js";
|
||||
import { InfuraProvider } from "./provider-infura.js";
|
||||
//import { PocketProvider } from "./provider-pocket.js";
|
||||
import { QuickNodeProvider } from "./provider-quicknode.js";
|
||||
import { FallbackProvider } from "./provider-fallback.js";
|
||||
import { JsonRpcProvider } from "./provider-jsonrpc.js";
|
||||
import { Network } from "./network.js";
|
||||
import { WebSocketProvider } from "./provider-websocket.js";
|
||||
function isWebSocketLike(value) {
|
||||
return (value && typeof (value.send) === "function" &&
|
||||
typeof (value.close) === "function");
|
||||
}
|
||||
const Testnets = "goerli kovan sepolia classicKotti optimism-goerli arbitrum-goerli matic-mumbai bnbt".split(" ");
|
||||
/**
|
||||
* Returns a default provider for %%network%%.
|
||||
*
|
||||
* If %%network%% is a [[WebSocketLike]] or string that begins with
|
||||
* ``"ws:"`` or ``"wss:"``, a [[WebSocketProvider]] is returned backed
|
||||
* by that WebSocket or URL.
|
||||
*
|
||||
* If %%network%% is a string that begins with ``"HTTP:"`` or ``"HTTPS:"``,
|
||||
* a [[JsonRpcProvider]] is returned connected to that URL.
|
||||
*
|
||||
* Otherwise, a default provider is created backed by well-known public
|
||||
* Web3 backends (such as [[link-infura]]) using community-provided API
|
||||
* keys.
|
||||
*
|
||||
* The %%options%% allows specifying custom API keys per backend (setting
|
||||
* an API key to ``"-"`` will omit that provider) and ``options.exclusive``
|
||||
* can be set to either a backend name or and array of backend names, which
|
||||
* will whitelist **only** those backends.
|
||||
*
|
||||
* Current backend strings supported are:
|
||||
* - ``"alchemy"``
|
||||
* - ``"ankr"``
|
||||
* - ``"cloudflare"``
|
||||
* - ``"chainstack"``
|
||||
* - ``"etherscan"``
|
||||
* - ``"infura"``
|
||||
* - ``"publicPolygon"``
|
||||
* - ``"quicknode"``
|
||||
*
|
||||
* @example:
|
||||
* // Connect to a local Geth node
|
||||
* provider = getDefaultProvider("http://localhost:8545/");
|
||||
*
|
||||
* // Connect to Ethereum mainnet with any current and future
|
||||
* // third-party services available
|
||||
* provider = getDefaultProvider("mainnet");
|
||||
*
|
||||
* // Connect to Polygon, but only allow Etherscan and
|
||||
* // INFURA and use "MY_API_KEY" in calls to Etherscan.
|
||||
* provider = getDefaultProvider("matic", {
|
||||
* etherscan: "MY_API_KEY",
|
||||
* exclusive: [ "etherscan", "infura" ]
|
||||
* });
|
||||
*/
|
||||
export function getDefaultProvider(network, options) {
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
const allowService = (name) => {
|
||||
if (options[name] === "-") {
|
||||
return false;
|
||||
}
|
||||
if (typeof (options.exclusive) === "string") {
|
||||
return (name === options.exclusive);
|
||||
}
|
||||
if (Array.isArray(options.exclusive)) {
|
||||
return (options.exclusive.indexOf(name) !== -1);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
if (typeof (network) === "string" && network.match(/^https?:/)) {
|
||||
return new JsonRpcProvider(network);
|
||||
}
|
||||
if (typeof (network) === "string" && network.match(/^wss?:/) || isWebSocketLike(network)) {
|
||||
return new WebSocketProvider(network);
|
||||
}
|
||||
// Get the network and name, if possible
|
||||
let staticNetwork = null;
|
||||
try {
|
||||
staticNetwork = Network.from(network);
|
||||
}
|
||||
catch (error) { }
|
||||
const providers = [];
|
||||
if (allowService("publicPolygon") && staticNetwork) {
|
||||
if (staticNetwork.name === "matic") {
|
||||
providers.push(new JsonRpcProvider("https:/\/polygon-rpc.com/", staticNetwork, { staticNetwork }));
|
||||
}
|
||||
else if (staticNetwork.name === "matic-amoy") {
|
||||
providers.push(new JsonRpcProvider("https:/\/rpc-amoy.polygon.technology/", staticNetwork, { staticNetwork }));
|
||||
}
|
||||
}
|
||||
if (allowService("alchemy")) {
|
||||
try {
|
||||
providers.push(new AlchemyProvider(network, options.alchemy));
|
||||
}
|
||||
catch (error) { }
|
||||
}
|
||||
if (allowService("ankr") && options.ankr != null) {
|
||||
try {
|
||||
providers.push(new AnkrProvider(network, options.ankr));
|
||||
}
|
||||
catch (error) { }
|
||||
}
|
||||
/* Temporarily remove until custom error issue is fixed
|
||||
if (allowService("blockscout")) {
|
||||
try {
|
||||
providers.push(new BlockscoutProvider(network, options.blockscout));
|
||||
} catch (error) { }
|
||||
}
|
||||
*/
|
||||
if (allowService("chainstack")) {
|
||||
try {
|
||||
providers.push(new ChainstackProvider(network, options.chainstack));
|
||||
}
|
||||
catch (error) { }
|
||||
}
|
||||
if (allowService("cloudflare")) {
|
||||
try {
|
||||
providers.push(new CloudflareProvider(network));
|
||||
}
|
||||
catch (error) { }
|
||||
}
|
||||
if (allowService("etherscan")) {
|
||||
try {
|
||||
providers.push(new EtherscanProvider(network, options.etherscan));
|
||||
}
|
||||
catch (error) { }
|
||||
}
|
||||
if (allowService("infura")) {
|
||||
try {
|
||||
let projectId = options.infura;
|
||||
let projectSecret = undefined;
|
||||
if (typeof (projectId) === "object") {
|
||||
projectSecret = projectId.projectSecret;
|
||||
projectId = projectId.projectId;
|
||||
}
|
||||
providers.push(new InfuraProvider(network, projectId, projectSecret));
|
||||
}
|
||||
catch (error) { }
|
||||
}
|
||||
/*
|
||||
if (options.pocket !== "-") {
|
||||
try {
|
||||
let appId = options.pocket;
|
||||
let secretKey: undefined | string = undefined;
|
||||
let loadBalancer: undefined | boolean = undefined;
|
||||
if (typeof(appId) === "object") {
|
||||
loadBalancer = !!appId.loadBalancer;
|
||||
secretKey = appId.secretKey;
|
||||
appId = appId.appId;
|
||||
}
|
||||
providers.push(new PocketProvider(network, appId, secretKey, loadBalancer));
|
||||
} catch (error) { console.log(error); }
|
||||
}
|
||||
*/
|
||||
if (allowService("quicknode")) {
|
||||
try {
|
||||
let token = options.quicknode;
|
||||
providers.push(new QuickNodeProvider(network, token));
|
||||
}
|
||||
catch (error) { }
|
||||
}
|
||||
assert(providers.length, "unsupported default network", "UNSUPPORTED_OPERATION", {
|
||||
operation: "getDefaultProvider"
|
||||
});
|
||||
// No need for a FallbackProvider
|
||||
if (providers.length === 1) {
|
||||
return providers[0];
|
||||
}
|
||||
// We use the floor because public third-party providers can be unreliable,
|
||||
// so a low number of providers with a large quorum will fail too often
|
||||
let quorum = Math.floor(providers.length / 2);
|
||||
if (quorum > 2) {
|
||||
quorum = 2;
|
||||
}
|
||||
// Testnets don't need as strong a security gaurantee and speed is
|
||||
// more useful during testing
|
||||
if (staticNetwork && Testnets.indexOf(staticNetwork.name) !== -1) {
|
||||
quorum = 1;
|
||||
}
|
||||
// Provided override qorum takes priority
|
||||
if (options && options.quorum) {
|
||||
quorum = options.quorum;
|
||||
}
|
||||
return new FallbackProvider(providers, undefined, { quorum });
|
||||
}
|
||||
//# sourceMappingURL=default-provider.js.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/default-provider.js.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/default-provider.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"default-provider.js","sourceRoot":"","sources":["../../src.ts/providers/default-provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,gEAAgE;AAChE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AC,CAAC;SACzE;QAAC,OAAO,KAAK,EAAE,GAAG;KACtB;IACL;;;;;;;;;;;;;;MAcE;IACE,IAAI,YAAY,CAAC,WAAW,CAAC,EAAE;QAC3B,IAAI;YACA,IAAI,KAAK,GAAG,OAAO,CAAC,SAAS,CAAC;YAC9B,SAAS,CAAC,IAAI,CAAC,IAAI,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;SACzD;QAAC,OAAO,KAAK,EAAE,GAAG;KACtB;IAED,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,6BAA6B,EAAE,uBAAuB,EAAE;QAC7E,SAAS,EAAE,oBAAoB;KAClC,CAAC,CAAC;IAEH,iCAAiC;IACjC,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;QAAE,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC;KAAE;IAEpD,2EAA2E;IAC3E,uEAAuE;IACvE,IAAI,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC9C,IAAI,MAAM,GAAG,CAAC,EAAE;QAAE,MAAM,GAAG,CAAC,CAAC;KAAE;IAE/B,kEAAkE;IAClE,6BAA6B;IAC7B,IAAI,aAAa,IAAI,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE;QAAE,MAAM,GAAG,CAAC,CAAC;KAAE;IAEjF,yCAAyC;IACzC,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE;QAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;KAAE;IAE3D,OAAO,IAAI,gBAAgB,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;AAClE,CAAC"}
|
||||
147
dev/env/node_modules/ethers/lib.esm/providers/ens-resolver.d.ts
generated
vendored
Executable file
147
dev/env/node_modules/ethers/lib.esm/providers/ens-resolver.d.ts
generated
vendored
Executable file
@@ -0,0 +1,147 @@
|
||||
/**
|
||||
* ENS is a service which allows easy-to-remember names to map to
|
||||
* network addresses.
|
||||
*
|
||||
* @_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 {
|
||||
/**
|
||||
* The type of linkage.
|
||||
*/
|
||||
type: AvatarLinkageType;
|
||||
/**
|
||||
* The linkage value.
|
||||
*/
|
||||
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 {
|
||||
/**
|
||||
* How the [[url]] was arrived at, resolving the many steps required
|
||||
* for an avatar URL.
|
||||
*/
|
||||
linkage: Array<AvatarLinkage>;
|
||||
/**
|
||||
* The avatar URL or null if the avatar was not set, or there was
|
||||
* an issue during validation (such as the address not owning the
|
||||
* avatar or a metadata error).
|
||||
*/
|
||||
url: null | string;
|
||||
}
|
||||
/**
|
||||
* A provider plugin super-class for processing multicoin address types.
|
||||
*/
|
||||
export declare abstract class MulticoinProviderPlugin implements AbstractProviderPlugin {
|
||||
/**
|
||||
* The name.
|
||||
*/
|
||||
readonly name: string;
|
||||
/**
|
||||
* Creates a new **MulticoinProviderPluing** for %%name%%.
|
||||
*/
|
||||
constructor(name: string);
|
||||
connect(proivder: Provider): MulticoinProviderPlugin;
|
||||
/**
|
||||
* Returns ``true`` if %%coinType%% is supported by this plugin.
|
||||
*/
|
||||
supportsCoinType(coinType: number): boolean;
|
||||
/**
|
||||
* Resolves to the encoded %%address%% for %%coinType%%.
|
||||
*/
|
||||
encodeAddress(coinType: number, address: string): Promise<string>;
|
||||
/**
|
||||
* Resolves to the decoded %%data%% for %%coinType%%.
|
||||
*/
|
||||
decodeAddress(coinType: number, data: BytesLike): Promise<string>;
|
||||
}
|
||||
/**
|
||||
* A **BasicMulticoinProviderPlugin** provides service for common
|
||||
* coin types, which do not require additional libraries to encode or
|
||||
* decode.
|
||||
*/
|
||||
export declare class BasicMulticoinProviderPlugin extends MulticoinProviderPlugin {
|
||||
/**
|
||||
* Creates a new **BasicMulticoinProviderPlugin**.
|
||||
*/
|
||||
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 resolver 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>;
|
||||
/**
|
||||
* Resolves to the EIP-634 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>;
|
||||
}
|
||||
//# sourceMappingURL=ens-resolver.d.ts.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/ens-resolver.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/ens-resolver.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ens-resolver.d.ts","sourceRoot":"","sources":["../../src.ts/providers/ens-resolver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAeH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEvF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAgB9C;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAC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AAM,CAAC;gBAOF,QAAQ,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAerE;;OAEG;IACG,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC;IA8D1C;;;OAGG;IACG,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC;IAoD3D;;;OAGG;IACG,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC;IAMlD;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC;IA6B9C;;;;;;;OAOG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC;IAKzC;;;;;;;OAOG;IACG,UAAU,IAAI,OAAO,CAAC,YAAY,CAAC;WAgK5B,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC;IAoC/D;;;OAGG;WACU,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,WAAW,CAAC;CA2B/F"}
|
||||
496
dev/env/node_modules/ethers/lib.esm/providers/ens-resolver.js
generated
vendored
Executable file
496
dev/env/node_modules/ethers/lib.esm/providers/ens-resolver.js
generated
vendored
Executable file
@@ -0,0 +1,496 @@
|
||||
/**
|
||||
* ENS is a service which allows easy-to-remember names to map to
|
||||
* network addresses.
|
||||
*
|
||||
* @_section: api/providers/ens-resolver:ENS Resolver [about-ens-rsolver]
|
||||
*/
|
||||
import { getAddress } from "../address/index.js";
|
||||
import { ZeroAddress } from "../constants/index.js";
|
||||
import { Contract } from "../contract/index.js";
|
||||
import { dnsEncode, namehash } from "../hash/index.js";
|
||||
import { hexlify, isHexString, toBeHex, defineProperties, encodeBase58, assert, assertArgument, isError, FetchRequest } from "../utils/index.js";
|
||||
// @TODO: This should use the fetch-data:ipfs gateway
|
||||
// Trim off the ipfs:// prefix and return the default gateway URL
|
||||
function getIpfsLink(link) {
|
||||
if (link.match(/^ipfs:\/\/ipfs\//i)) {
|
||||
link = link.substring(12);
|
||||
}
|
||||
else if (link.match(/^ipfs:\/\//i)) {
|
||||
link = link.substring(7);
|
||||
}
|
||||
else {
|
||||
assertArgument(false, "unsupported IPFS format", "link", link);
|
||||
}
|
||||
return `https:/\/gateway.ipfs.io/ipfs/${link}`;
|
||||
}
|
||||
;
|
||||
;
|
||||
/**
|
||||
* A provider plugin super-class for processing multicoin address types.
|
||||
*/
|
||||
export class MulticoinProviderPlugin {
|
||||
/**
|
||||
* The name.
|
||||
*/
|
||||
name;
|
||||
/**
|
||||
* Creates a new **MulticoinProviderPluing** for %%name%%.
|
||||
*/
|
||||
constructor(name) {
|
||||
defineProperties(this, { name });
|
||||
}
|
||||
connect(proivder) {
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Returns ``true`` if %%coinType%% is supported by this plugin.
|
||||
*/
|
||||
supportsCoinType(coinType) {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Resolves to the encoded %%address%% for %%coinType%%.
|
||||
*/
|
||||
async encodeAddress(coinType, address) {
|
||||
throw new Error("unsupported coin");
|
||||
}
|
||||
/**
|
||||
* Resolves to the decoded %%data%% for %%coinType%%.
|
||||
*/
|
||||
async decodeAddress(coinType, data) {
|
||||
throw new Error("unsupported coin");
|
||||
}
|
||||
}
|
||||
const BasicMulticoinPluginId = "org.ethers.plugins.provider.BasicMulticoin";
|
||||
/**
|
||||
* A **BasicMulticoinProviderPlugin** provides service for common
|
||||
* coin types, which do not require additional libraries to encode or
|
||||
* decode.
|
||||
*/
|
||||
export class BasicMulticoinProviderPlugin extends MulticoinProviderPlugin {
|
||||
/**
|
||||
* Creates a new **BasicMulticoinProviderPlugin**.
|
||||
*/
|
||||
constructor() {
|
||||
super(BasicMulticoinPluginId);
|
||||
}
|
||||
}
|
||||
const matcherIpfs = new RegExp("^(ipfs):/\/(.*)$", "i");
|
||||
const matchers = [
|
||||
new RegExp("^(https):/\/(.*)$", "i"),
|
||||
new RegExp("^(data):(.*)$", "i"),
|
||||
matcherIpfs,
|
||||
new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$", "i"),
|
||||
];
|
||||
/**
|
||||
* A connected object to a resolved ENS name resolver, which can be
|
||||
* used to query additional details.
|
||||
*/
|
||||
export class EnsResolver {
|
||||
/**
|
||||
* The connected provider.
|
||||
*/
|
||||
provider;
|
||||
/**
|
||||
* The address of the resolver.
|
||||
*/
|
||||
address;
|
||||
/**
|
||||
* The name this resolver was resolved against.
|
||||
*/
|
||||
name;
|
||||
// For EIP-2544 names, the ancestor that provided the resolver
|
||||
#supports2544;
|
||||
#resolver;
|
||||
constructor(provider, address, name) {
|
||||
defineProperties(this, { provider, address, name });
|
||||
this.#supports2544 = null;
|
||||
this.#resolver = new Contract(address, [
|
||||
"function supportsInterface(bytes4) view returns (bool)",
|
||||
"function resolve(bytes, bytes) view returns (bytes)",
|
||||
"function addr(bytes32) view returns (address)",
|
||||
"function addr(bytes32, uint) view returns (bytes)",
|
||||
"function text(bytes32, string) view returns (string)",
|
||||
"function contenthash(bytes32) view returns (bytes)",
|
||||
], provider);
|
||||
}
|
||||
/**
|
||||
* Resolves to true if the resolver supports wildcard resolution.
|
||||
*/
|
||||
async supportsWildcard() {
|
||||
if (this.#supports2544 == null) {
|
||||
this.#supports2544 = (async () => {
|
||||
try {
|
||||
return await this.#resolver.supportsInterface("0x9061b923");
|
||||
}
|
||||
catch (error) {
|
||||
// Wildcard resolvers must understand supportsInterface
|
||||
// and return true.
|
||||
if (isError(error, "CALL_EXCEPTION")) {
|
||||
return false;
|
||||
}
|
||||
// Let future attempts try again...
|
||||
this.#supports2544 = null;
|
||||
throw error;
|
||||
}
|
||||
})();
|
||||
}
|
||||
return await this.#supports2544;
|
||||
}
|
||||
async #fetch(funcName, params) {
|
||||
params = (params || []).slice();
|
||||
const iface = this.#resolver.interface;
|
||||
// The first parameters is always the nodehash
|
||||
params.unshift(namehash(this.name));
|
||||
let fragment = null;
|
||||
if (await this.supportsWildcard()) {
|
||||
fragment = iface.getFunction(funcName);
|
||||
assert(fragment, "missing fragment", "UNKNOWN_ERROR", {
|
||||
info: { funcName }
|
||||
});
|
||||
params = [
|
||||
dnsEncode(this.name, 255),
|
||||
iface.encodeFunctionData(fragment, params)
|
||||
];
|
||||
funcName = "resolve(bytes,bytes)";
|
||||
}
|
||||
params.push({
|
||||
enableCcipRead: true
|
||||
});
|
||||
try {
|
||||
const result = await this.#resolver[funcName](...params);
|
||||
if (fragment) {
|
||||
return iface.decodeFunctionResult(fragment, result)[0];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch (error) {
|
||||
if (!isError(error, "CALL_EXCEPTION")) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Resolves to the address for %%coinType%% or null if the
|
||||
* provided %%coinType%% has not been configured.
|
||||
*/
|
||||
async getAddress(coinType) {
|
||||
if (coinType == null) {
|
||||
coinType = 60;
|
||||
}
|
||||
if (coinType === 60) {
|
||||
try {
|
||||
const result = await this.#fetch("addr(bytes32)");
|
||||
// No address
|
||||
if (result == null || result === ZeroAddress) {
|
||||
return null;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch (error) {
|
||||
if (isError(error, "CALL_EXCEPTION")) {
|
||||
return null;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
// Try decoding its EVM canonical chain as an EVM chain address first
|
||||
if (coinType >= 0 && coinType < 0x80000000) {
|
||||
let ethCoinType = coinType + 0x80000000;
|
||||
const data = await this.#fetch("addr(bytes32,uint)", [ethCoinType]);
|
||||
if (isHexString(data, 20)) {
|
||||
return getAddress(data);
|
||||
}
|
||||
}
|
||||
let coinPlugin = null;
|
||||
for (const plugin of this.provider.plugins) {
|
||||
if (!(plugin instanceof MulticoinProviderPlugin)) {
|
||||
continue;
|
||||
}
|
||||
if (plugin.supportsCoinType(coinType)) {
|
||||
coinPlugin = plugin;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (coinPlugin == null) {
|
||||
return null;
|
||||
}
|
||||
// keccak256("addr(bytes32,uint256")
|
||||
const data = await this.#fetch("addr(bytes32,uint)", [coinType]);
|
||||
// No address
|
||||
if (data == null || data === "0x") {
|
||||
return null;
|
||||
}
|
||||
// Compute the address
|
||||
const address = await coinPlugin.decodeAddress(coinType, data);
|
||||
if (address != null) {
|
||||
return address;
|
||||
}
|
||||
assert(false, `invalid coin data`, "UNSUPPORTED_OPERATION", {
|
||||
operation: `getAddress(${coinType})`,
|
||||
info: { coinType, data }
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Resolves to the EIP-634 text record for %%key%%, or ``null``
|
||||
* if unconfigured.
|
||||
*/
|
||||
async getText(key) {
|
||||
const data = await this.#fetch("text(bytes32,string)", [key]);
|
||||
if (data == null || data === "0x") {
|
||||
return null;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
/**
|
||||
* Rsolves to the content-hash or ``null`` if unconfigured.
|
||||
*/
|
||||
async getContentHash() {
|
||||
// keccak256("contenthash()")
|
||||
const data = await this.#fetch("contenthash(bytes32)");
|
||||
// No contenthash
|
||||
if (data == null || data === "0x") {
|
||||
return null;
|
||||
}
|
||||
// IPFS (CID: 1, Type: 70=DAG-PB, 72=libp2p-key)
|
||||
const ipfs = data.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);
|
||||
if (ipfs) {
|
||||
const scheme = (ipfs[1] === "e3010170") ? "ipfs" : "ipns";
|
||||
const length = parseInt(ipfs[4], 16);
|
||||
if (ipfs[5].length === length * 2) {
|
||||
return `${scheme}:/\/${encodeBase58("0x" + ipfs[2])}`;
|
||||
}
|
||||
}
|
||||
// Swarm (CID: 1, Type: swarm-manifest; hash/length hard-coded to keccak256/32)
|
||||
const swarm = data.match(/^0xe40101fa011b20([0-9a-f]*)$/);
|
||||
if (swarm && swarm[1].length === 64) {
|
||||
return `bzz:/\/${swarm[1]}`;
|
||||
}
|
||||
assert(false, `invalid or unsupported content hash data`, "UNSUPPORTED_OPERATION", {
|
||||
operation: "getContentHash()",
|
||||
info: { data }
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
async getAvatar() {
|
||||
const avatar = await this._getAvatar();
|
||||
return avatar.url;
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
async _getAvatar() {
|
||||
const linkage = [{ type: "name", value: this.name }];
|
||||
try {
|
||||
// test data for ricmoo.eth
|
||||
//const avatar = "eip155:1/erc721:0x265385c7f4132228A0d54EB1A9e7460b91c0cC68/29233";
|
||||
const avatar = await this.getText("avatar");
|
||||
if (avatar == null) {
|
||||
linkage.push({ type: "!avatar", value: "" });
|
||||
return { url: null, linkage };
|
||||
}
|
||||
linkage.push({ type: "avatar", value: avatar });
|
||||
for (let i = 0; i < matchers.length; i++) {
|
||||
const match = avatar.match(matchers[i]);
|
||||
if (match == null) {
|
||||
continue;
|
||||
}
|
||||
const scheme = match[1].toLowerCase();
|
||||
switch (scheme) {
|
||||
case "https":
|
||||
case "data":
|
||||
linkage.push({ type: "url", value: avatar });
|
||||
return { linkage, url: avatar };
|
||||
case "ipfs": {
|
||||
const url = getIpfsLink(avatar);
|
||||
linkage.push({ type: "ipfs", value: avatar });
|
||||
linkage.push({ type: "url", value: url });
|
||||
return { linkage, url };
|
||||
}
|
||||
case "erc721":
|
||||
case "erc1155": {
|
||||
// Depending on the ERC type, use tokenURI(uint256) or url(uint256)
|
||||
const selector = (scheme === "erc721") ? "tokenURI(uint256)" : "uri(uint256)";
|
||||
linkage.push({ type: scheme, value: avatar });
|
||||
// The owner of this name
|
||||
const owner = await this.getAddress();
|
||||
if (owner == null) {
|
||||
linkage.push({ type: "!owner", value: "" });
|
||||
return { url: null, linkage };
|
||||
}
|
||||
const comps = (match[2] || "").split("/");
|
||||
if (comps.length !== 2) {
|
||||
linkage.push({ type: `!${scheme}caip`, value: (match[2] || "") });
|
||||
return { url: null, linkage };
|
||||
}
|
||||
const tokenId = comps[1];
|
||||
const contract = new Contract(comps[0], [
|
||||
// ERC-721
|
||||
"function tokenURI(uint) view returns (string)",
|
||||
"function ownerOf(uint) view returns (address)",
|
||||
// ERC-1155
|
||||
"function uri(uint) view returns (string)",
|
||||
"function balanceOf(address, uint256) view returns (uint)"
|
||||
], this.provider);
|
||||
// Check that this account owns the token
|
||||
if (scheme === "erc721") {
|
||||
const tokenOwner = await contract.ownerOf(tokenId);
|
||||
if (owner !== tokenOwner) {
|
||||
linkage.push({ type: "!owner", value: tokenOwner });
|
||||
return { url: null, linkage };
|
||||
}
|
||||
linkage.push({ type: "owner", value: tokenOwner });
|
||||
}
|
||||
else if (scheme === "erc1155") {
|
||||
const balance = await contract.balanceOf(owner, tokenId);
|
||||
if (!balance) {
|
||||
linkage.push({ type: "!balance", value: "0" });
|
||||
return { url: null, linkage };
|
||||
}
|
||||
linkage.push({ type: "balance", value: balance.toString() });
|
||||
}
|
||||
// Call the token contract for the metadata URL
|
||||
let metadataUrl = await contract[selector](tokenId);
|
||||
if (metadataUrl == null || metadataUrl === "0x") {
|
||||
linkage.push({ type: "!metadata-url", value: "" });
|
||||
return { url: null, linkage };
|
||||
}
|
||||
linkage.push({ type: "metadata-url-base", value: metadataUrl });
|
||||
// ERC-1155 allows a generic {id} in the URL
|
||||
if (scheme === "erc1155") {
|
||||
metadataUrl = metadataUrl.replace("{id}", toBeHex(tokenId, 32).substring(2));
|
||||
linkage.push({ type: "metadata-url-expanded", value: metadataUrl });
|
||||
}
|
||||
// Transform IPFS metadata links
|
||||
if (metadataUrl.match(/^ipfs:/i)) {
|
||||
metadataUrl = getIpfsLink(metadataUrl);
|
||||
}
|
||||
linkage.push({ type: "metadata-url", value: metadataUrl });
|
||||
// Get the token metadata
|
||||
let metadata = {};
|
||||
const response = await (new FetchRequest(metadataUrl)).send();
|
||||
response.assertOk();
|
||||
try {
|
||||
metadata = response.bodyJson;
|
||||
}
|
||||
catch (error) {
|
||||
try {
|
||||
linkage.push({ type: "!metadata", value: response.bodyText });
|
||||
}
|
||||
catch (error) {
|
||||
const bytes = response.body;
|
||||
if (bytes) {
|
||||
linkage.push({ type: "!metadata", value: hexlify(bytes) });
|
||||
}
|
||||
return { url: null, linkage };
|
||||
}
|
||||
return { url: null, linkage };
|
||||
}
|
||||
if (!metadata) {
|
||||
linkage.push({ type: "!metadata", value: "" });
|
||||
return { url: null, linkage };
|
||||
}
|
||||
linkage.push({ type: "metadata", value: JSON.stringify(metadata) });
|
||||
// Pull the image URL out
|
||||
let imageUrl = metadata.image;
|
||||
if (typeof (imageUrl) !== "string") {
|
||||
linkage.push({ type: "!imageUrl", value: "" });
|
||||
return { url: null, linkage };
|
||||
}
|
||||
if (imageUrl.match(/^(https:\/\/|data:)/i)) {
|
||||
// Allow
|
||||
}
|
||||
else {
|
||||
// Transform IPFS link to gateway
|
||||
const ipfs = imageUrl.match(matcherIpfs);
|
||||
if (ipfs == null) {
|
||||
linkage.push({ type: "!imageUrl-ipfs", value: imageUrl });
|
||||
return { url: null, linkage };
|
||||
}
|
||||
linkage.push({ type: "imageUrl-ipfs", value: imageUrl });
|
||||
imageUrl = getIpfsLink(imageUrl);
|
||||
}
|
||||
linkage.push({ type: "url", value: imageUrl });
|
||||
return { linkage, url: imageUrl };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (error) { }
|
||||
return { linkage, url: null };
|
||||
}
|
||||
static async getEnsAddress(provider) {
|
||||
const network = await provider.getNetwork();
|
||||
const ensPlugin = network.getPlugin("org.ethers.plugins.network.Ens");
|
||||
// No ENS...
|
||||
assert(ensPlugin, "network does not support ENS", "UNSUPPORTED_OPERATION", {
|
||||
operation: "getEnsAddress", info: { network }
|
||||
});
|
||||
return ensPlugin.address;
|
||||
}
|
||||
static async #getResolver(provider, name) {
|
||||
const ensAddr = await EnsResolver.getEnsAddress(provider);
|
||||
try {
|
||||
const contract = new Contract(ensAddr, [
|
||||
"function resolver(bytes32) view returns (address)"
|
||||
], provider);
|
||||
const addr = await contract.resolver(namehash(name), {
|
||||
enableCcipRead: true
|
||||
});
|
||||
if (addr === ZeroAddress) {
|
||||
return null;
|
||||
}
|
||||
return addr;
|
||||
}
|
||||
catch (error) {
|
||||
// ENS registry cannot throw errors on resolver(bytes32),
|
||||
// so probably a link error
|
||||
throw error;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Resolve to the ENS resolver for %%name%% using %%provider%% or
|
||||
* ``null`` if unconfigured.
|
||||
*/
|
||||
static async fromName(provider, name) {
|
||||
let currentName = name;
|
||||
while (true) {
|
||||
if (currentName === "" || currentName === ".") {
|
||||
return null;
|
||||
}
|
||||
// Optimization since the eth node cannot change and does
|
||||
// not have a wildcard resolver
|
||||
if (name !== "eth" && currentName === "eth") {
|
||||
return null;
|
||||
}
|
||||
// Check the current node for a resolver
|
||||
const addr = await EnsResolver.#getResolver(provider, currentName);
|
||||
// Found a resolver!
|
||||
if (addr != null) {
|
||||
const resolver = new EnsResolver(provider, addr, name);
|
||||
// Legacy resolver found, using EIP-2544 so it isn't safe to use
|
||||
if (currentName !== name && !(await resolver.supportsWildcard())) {
|
||||
return null;
|
||||
}
|
||||
return resolver;
|
||||
}
|
||||
// Get the parent node
|
||||
currentName = currentName.split(".").slice(1).join(".");
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=ens-resolver.js.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/ens-resolver.js.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/ens-resolver.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
15
dev/env/node_modules/ethers/lib.esm/providers/format.d.ts
generated
vendored
Executable file
15
dev/env/node_modules/ethers/lib.esm/providers/format.d.ts
generated
vendored
Executable file
@@ -0,0 +1,15 @@
|
||||
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, allowNull?: boolean): 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;
|
||||
//# sourceMappingURL=format.d.ts.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/format.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/format.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src.ts/providers/format.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACR,WAAW,EAAE,SAAS,EACtB,wBAAwB,EAAE,yBAAyB,EACtD,MAAM,iBAAiB,CAAC;AAKzB,MAAM,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC;AAE7C,wBAAgB,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,CAAC,EAAE,GAAG,GAAG,UAAU,CAKzE;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,CAAC,EAAE,OAAO,GAAG,UAAU,CAM3E;AAKD,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,CAwB/G;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAQjD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGhD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM,CAG7C;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM,CAKhD;AAgBD,wBAAgB,SAAS,CAAC,KAAK,EAAE,GAAG,GAAG,SAAS,CAE/C;AA+BD,wBAAgB,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,WAAW,CAOnD;AAeD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,GAAG,GAAG,SAAS,CAEtD;AA4BD,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,GAAG,GAAG,wBAAwB,CAE7E;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,GAAG,GAAG,yBAAyB,CA0I/E"}
|
||||
297
dev/env/node_modules/ethers/lib.esm/providers/format.js
generated
vendored
Executable file
297
dev/env/node_modules/ethers/lib.esm/providers/format.js
generated
vendored
Executable file
@@ -0,0 +1,297 @@
|
||||
/**
|
||||
* @_ignore
|
||||
*/
|
||||
import { getAddress, getCreateAddress } from "../address/index.js";
|
||||
import { Signature } from "../crypto/index.js";
|
||||
import { accessListify } from "../transaction/index.js";
|
||||
import { getBigInt, getNumber, hexlify, isHexString, zeroPadValue, assert, assertArgument } from "../utils/index.js";
|
||||
const BN_0 = BigInt(0);
|
||||
export function allowNull(format, nullValue) {
|
||||
return (function (value) {
|
||||
if (value == null) {
|
||||
return nullValue;
|
||||
}
|
||||
return format(value);
|
||||
});
|
||||
}
|
||||
export function arrayOf(format, allowNull) {
|
||||
return ((array) => {
|
||||
if (allowNull && array == null) {
|
||||
return null;
|
||||
}
|
||||
if (!Array.isArray(array)) {
|
||||
throw new Error("not an array");
|
||||
}
|
||||
return array.map((i) => format(i));
|
||||
});
|
||||
}
|
||||
// Requires an object which matches a fleet of other formatters
|
||||
// Any FormatFunc may return `undefined` to have the value omitted
|
||||
// from the result object. Calls preserve `this`.
|
||||
export function object(format, altNames) {
|
||||
return ((value) => {
|
||||
const result = {};
|
||||
for (const key in format) {
|
||||
let srcKey = key;
|
||||
if (altNames && key in altNames && !(srcKey in value)) {
|
||||
for (const altKey of altNames[key]) {
|
||||
if (altKey in value) {
|
||||
srcKey = altKey;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
const nv = format[key](value[srcKey]);
|
||||
if (nv !== undefined) {
|
||||
result[key] = nv;
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
const message = (error instanceof Error) ? error.message : "not-an-error";
|
||||
assert(false, `invalid value for value.${key} (${message})`, "BAD_DATA", { value });
|
||||
}
|
||||
}
|
||||
return result;
|
||||
});
|
||||
}
|
||||
export function formatBoolean(value) {
|
||||
switch (value) {
|
||||
case true:
|
||||
case "true":
|
||||
return true;
|
||||
case false:
|
||||
case "false":
|
||||
return false;
|
||||
}
|
||||
assertArgument(false, `invalid boolean; ${JSON.stringify(value)}`, "value", value);
|
||||
}
|
||||
export function formatData(value) {
|
||||
assertArgument(isHexString(value, true), "invalid data", "value", value);
|
||||
return value;
|
||||
}
|
||||
export function formatHash(value) {
|
||||
assertArgument(isHexString(value, 32), "invalid hash", "value", value);
|
||||
return value;
|
||||
}
|
||||
export function formatUint256(value) {
|
||||
if (!isHexString(value)) {
|
||||
throw new Error("invalid uint256");
|
||||
}
|
||||
return zeroPadValue(value, 32);
|
||||
}
|
||||
const _formatLog = object({
|
||||
address: getAddress,
|
||||
blockHash: formatHash,
|
||||
blockNumber: getNumber,
|
||||
data: formatData,
|
||||
index: getNumber,
|
||||
removed: allowNull(formatBoolean, false),
|
||||
topics: arrayOf(formatHash),
|
||||
transactionHash: formatHash,
|
||||
transactionIndex: getNumber,
|
||||
}, {
|
||||
index: ["logIndex"]
|
||||
});
|
||||
export function formatLog(value) {
|
||||
return _formatLog(value);
|
||||
}
|
||||
const _formatBlock = object({
|
||||
hash: allowNull(formatHash),
|
||||
parentHash: formatHash,
|
||||
parentBeaconBlockRoot: allowNull(formatHash, null),
|
||||
number: getNumber,
|
||||
timestamp: getNumber,
|
||||
nonce: allowNull(formatData),
|
||||
difficulty: getBigInt,
|
||||
gasLimit: getBigInt,
|
||||
gasUsed: getBigInt,
|
||||
stateRoot: allowNull(formatHash, null),
|
||||
receiptsRoot: allowNull(formatHash, null),
|
||||
blobGasUsed: allowNull(getBigInt, null),
|
||||
excessBlobGas: allowNull(getBigInt, null),
|
||||
miner: allowNull(getAddress),
|
||||
prevRandao: allowNull(formatHash, null),
|
||||
extraData: formatData,
|
||||
baseFeePerGas: allowNull(getBigInt)
|
||||
}, {
|
||||
prevRandao: ["mixHash"]
|
||||
});
|
||||
export function formatBlock(value) {
|
||||
const result = _formatBlock(value);
|
||||
result.transactions = value.transactions.map((tx) => {
|
||||
if (typeof (tx) === "string") {
|
||||
return tx;
|
||||
}
|
||||
return formatTransactionResponse(tx);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
const _formatReceiptLog = object({
|
||||
transactionIndex: getNumber,
|
||||
blockNumber: getNumber,
|
||||
transactionHash: formatHash,
|
||||
address: getAddress,
|
||||
topics: arrayOf(formatHash),
|
||||
data: formatData,
|
||||
index: getNumber,
|
||||
blockHash: formatHash,
|
||||
}, {
|
||||
index: ["logIndex"]
|
||||
});
|
||||
export function formatReceiptLog(value) {
|
||||
return _formatReceiptLog(value);
|
||||
}
|
||||
const _formatTransactionReceipt = object({
|
||||
to: allowNull(getAddress, null),
|
||||
from: allowNull(getAddress, null),
|
||||
contractAddress: allowNull(getAddress, null),
|
||||
// should be allowNull(hash), but broken-EIP-658 support is handled in receipt
|
||||
index: getNumber,
|
||||
root: allowNull(hexlify),
|
||||
gasUsed: getBigInt,
|
||||
blobGasUsed: allowNull(getBigInt, null),
|
||||
logsBloom: allowNull(formatData),
|
||||
blockHash: formatHash,
|
||||
hash: formatHash,
|
||||
logs: arrayOf(formatReceiptLog),
|
||||
blockNumber: getNumber,
|
||||
//confirmations: allowNull(getNumber, null),
|
||||
cumulativeGasUsed: getBigInt,
|
||||
effectiveGasPrice: allowNull(getBigInt),
|
||||
blobGasPrice: allowNull(getBigInt, null),
|
||||
status: allowNull(getNumber),
|
||||
type: allowNull(getNumber, 0)
|
||||
}, {
|
||||
effectiveGasPrice: ["gasPrice"],
|
||||
hash: ["transactionHash"],
|
||||
index: ["transactionIndex"],
|
||||
});
|
||||
export function formatTransactionReceipt(value) {
|
||||
return _formatTransactionReceipt(value);
|
||||
}
|
||||
export function formatTransactionResponse(value) {
|
||||
// Some clients (TestRPC) do strange things like return 0x0 for the
|
||||
// 0 address; correct this to be a real address
|
||||
if (value.to && getBigInt(value.to) === BN_0) {
|
||||
value.to = "0x0000000000000000000000000000000000000000";
|
||||
}
|
||||
const result = object({
|
||||
hash: formatHash,
|
||||
// Some nodes do not return this, usually test nodes (like Ganache)
|
||||
index: allowNull(getNumber, undefined),
|
||||
type: (value) => {
|
||||
if (value === "0x" || value == null) {
|
||||
return 0;
|
||||
}
|
||||
return getNumber(value);
|
||||
},
|
||||
accessList: allowNull(accessListify, null),
|
||||
blobVersionedHashes: allowNull(arrayOf(formatHash, true), null),
|
||||
authorizationList: allowNull(arrayOf((v) => {
|
||||
let sig;
|
||||
if (v.signature) {
|
||||
sig = v.signature;
|
||||
}
|
||||
else {
|
||||
let yParity = v.yParity;
|
||||
if (yParity === "0x1b") {
|
||||
yParity = 0;
|
||||
}
|
||||
else if (yParity === "0x1c") {
|
||||
yParity = 1;
|
||||
}
|
||||
sig = Object.assign({}, v, { yParity });
|
||||
}
|
||||
return {
|
||||
address: getAddress(v.address),
|
||||
chainId: getBigInt(v.chainId),
|
||||
nonce: getBigInt(v.nonce),
|
||||
signature: Signature.from(sig)
|
||||
};
|
||||
}, false), null),
|
||||
blockHash: allowNull(formatHash, null),
|
||||
blockNumber: allowNull(getNumber, null),
|
||||
transactionIndex: allowNull(getNumber, null),
|
||||
from: getAddress,
|
||||
// either (gasPrice) or (maxPriorityFeePerGas + maxFeePerGas) must be set
|
||||
gasPrice: allowNull(getBigInt),
|
||||
maxPriorityFeePerGas: allowNull(getBigInt),
|
||||
maxFeePerGas: allowNull(getBigInt),
|
||||
maxFeePerBlobGas: allowNull(getBigInt, null),
|
||||
gasLimit: getBigInt,
|
||||
to: allowNull(getAddress, null),
|
||||
value: getBigInt,
|
||||
nonce: getNumber,
|
||||
data: formatData,
|
||||
creates: allowNull(getAddress, null),
|
||||
chainId: allowNull(getBigInt, null)
|
||||
}, {
|
||||
data: ["input"],
|
||||
gasLimit: ["gas"],
|
||||
index: ["transactionIndex"]
|
||||
})(value);
|
||||
// If to and creates are empty, populate the creates from the value
|
||||
if (result.to == null && result.creates == null) {
|
||||
result.creates = getCreateAddress(result);
|
||||
}
|
||||
// @TODO: Check fee data
|
||||
// Add an access list to supported transaction types
|
||||
if ((value.type === 1 || value.type === 2) && value.accessList == null) {
|
||||
result.accessList = [];
|
||||
}
|
||||
// Compute the signature
|
||||
if (value.signature) {
|
||||
result.signature = Signature.from(value.signature);
|
||||
}
|
||||
else {
|
||||
result.signature = Signature.from(value);
|
||||
}
|
||||
// Some backends omit ChainId on legacy transactions, but we can compute it
|
||||
if (result.chainId == null) {
|
||||
const chainId = result.signature.legacyChainId;
|
||||
if (chainId != null) {
|
||||
result.chainId = chainId;
|
||||
}
|
||||
}
|
||||
// @TODO: check chainID
|
||||
/*
|
||||
if (value.chainId != null) {
|
||||
let chainId = value.chainId;
|
||||
|
||||
if (isHexString(chainId)) {
|
||||
chainId = BigNumber.from(chainId).toNumber();
|
||||
}
|
||||
|
||||
result.chainId = chainId;
|
||||
|
||||
} else {
|
||||
let chainId = value.networkId;
|
||||
|
||||
// geth-etc returns chainId
|
||||
if (chainId == null && result.v == null) {
|
||||
chainId = value.chainId;
|
||||
}
|
||||
|
||||
if (isHexString(chainId)) {
|
||||
chainId = BigNumber.from(chainId).toNumber();
|
||||
}
|
||||
|
||||
if (typeof(chainId) !== "number" && result.v != null) {
|
||||
chainId = (result.v - 35) / 2;
|
||||
if (chainId < 0) { chainId = 0; }
|
||||
chainId = parseInt(chainId);
|
||||
}
|
||||
|
||||
if (typeof(chainId) !== "number") { chainId = 0; }
|
||||
|
||||
result.chainId = chainId;
|
||||
}
|
||||
*/
|
||||
// 0x0000... should actually be null
|
||||
if (result.blockHash && getBigInt(result.blockHash) === BN_0) {
|
||||
result.blockHash = null;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//# sourceMappingURL=format.js.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/format.js.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/format.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
318
dev/env/node_modules/ethers/lib.esm/providers/formatting.d.ts
generated
vendored
Executable file
318
dev/env/node_modules/ethers/lib.esm/providers/formatting.d.ts
generated
vendored
Executable file
@@ -0,0 +1,318 @@
|
||||
/**
|
||||
* About provider formatting?
|
||||
*
|
||||
* @_section: api/providers/formatting:Formatting [provider-formatting]
|
||||
*/
|
||||
import type { Signature } from "../crypto/index.js";
|
||||
import type { Authorization, AccessList } from "../transaction/index.js";
|
||||
/**
|
||||
* a **BlockParams** encodes the minimal required properties for a
|
||||
* formatted block.
|
||||
*/
|
||||
export interface BlockParams {
|
||||
/**
|
||||
* The block hash.
|
||||
*/
|
||||
hash?: null | string;
|
||||
/**
|
||||
* The block number.
|
||||
*/
|
||||
number: number;
|
||||
/**
|
||||
* The timestamp for this block, which is the number of seconds
|
||||
* since epoch that this block was included.
|
||||
*/
|
||||
timestamp: number;
|
||||
/**
|
||||
* The hash of the previous block in the blockchain. The genesis block
|
||||
* has the parentHash of the [[ZeroHash]].
|
||||
*/
|
||||
parentHash: string;
|
||||
/**
|
||||
* The hash tree root of the parent beacon block for the given
|
||||
* execution block. See [[link-eip-4788]].
|
||||
*/
|
||||
parentBeaconBlockRoot?: null | string;
|
||||
/**
|
||||
* A random sequence provided during the mining process for
|
||||
* proof-of-work networks.
|
||||
*/
|
||||
nonce: string;
|
||||
/**
|
||||
* For proof-of-work networks, the difficulty target is used to
|
||||
* adjust the difficulty in mining to ensure an expected block rate.
|
||||
*/
|
||||
difficulty: bigint;
|
||||
/**
|
||||
* The maximum amount of gas a block can consume.
|
||||
*/
|
||||
gasLimit: bigint;
|
||||
/**
|
||||
* The amount of gas a block consumed.
|
||||
*/
|
||||
gasUsed: bigint;
|
||||
/**
|
||||
* The total amount of BLOb gas consumed by transactions within
|
||||
* the block. See [[link-eip4844].
|
||||
*/
|
||||
blobGasUsed?: null | bigint;
|
||||
/**
|
||||
* The running total of BLOb gas consumed in excess of the target
|
||||
* prior to the block. See [[link-eip-4844]].
|
||||
*/
|
||||
excessBlobGas?: null | bigint;
|
||||
/**
|
||||
* The miner (or author) of a block.
|
||||
*/
|
||||
miner: string;
|
||||
/**
|
||||
* The latest RANDAO mix of the post beacon state of
|
||||
* the previous block.
|
||||
*/
|
||||
prevRandao?: null | string;
|
||||
/**
|
||||
* Additional data the miner choose to include.
|
||||
*/
|
||||
extraData: string;
|
||||
/**
|
||||
* The protocol-defined base fee per gas in an [[link-eip-1559]]
|
||||
* block.
|
||||
*/
|
||||
baseFeePerGas: null | bigint;
|
||||
/**
|
||||
* The root hash for the global state after applying changes
|
||||
* in this block.
|
||||
*/
|
||||
stateRoot?: null | string;
|
||||
/**
|
||||
* The hash of the transaction receipts trie.
|
||||
*/
|
||||
receiptsRoot?: null | string;
|
||||
/**
|
||||
* The list of transactions in the block.
|
||||
*/
|
||||
transactions: ReadonlyArray<string | TransactionResponseParams>;
|
||||
}
|
||||
/**
|
||||
* a **LogParams** encodes the minimal required properties for a
|
||||
* formatted log.
|
||||
*/
|
||||
export interface LogParams {
|
||||
/**
|
||||
* The transaction hash for the transaxction the log occurred in.
|
||||
*/
|
||||
transactionHash: string;
|
||||
/**
|
||||
* The block hash of the block that included the transaction for this
|
||||
* log.
|
||||
*/
|
||||
blockHash: string;
|
||||
/**
|
||||
* The block number of the block that included the transaction for this
|
||||
* log.
|
||||
*/
|
||||
blockNumber: number;
|
||||
/**
|
||||
* Whether this log was removed due to the transaction it was included
|
||||
* in being removed dur to an orphaned block.
|
||||
*/
|
||||
removed: boolean;
|
||||
/**
|
||||
* The address of the contract that emitted this log.
|
||||
*/
|
||||
address: string;
|
||||
/**
|
||||
* The data emitted with this log.
|
||||
*/
|
||||
data: string;
|
||||
/**
|
||||
* The topics emitted with this log.
|
||||
*/
|
||||
topics: ReadonlyArray<string>;
|
||||
/**
|
||||
* The index of this log.
|
||||
*/
|
||||
index: number;
|
||||
/**
|
||||
* The transaction index of this log.
|
||||
*/
|
||||
transactionIndex: number;
|
||||
}
|
||||
/**
|
||||
* a **TransactionReceiptParams** encodes the minimal required properties
|
||||
* for a formatted transaction receipt.
|
||||
*/
|
||||
export interface TransactionReceiptParams {
|
||||
/**
|
||||
* The target of the transaction. If null, the transaction was trying
|
||||
* to deploy a transaction with the ``data`` as the initi=code.
|
||||
*/
|
||||
to: null | string;
|
||||
/**
|
||||
* The sender of the transaction.
|
||||
*/
|
||||
from: string;
|
||||
/**
|
||||
* If the transaction was directly deploying a contract, the [[to]]
|
||||
* will be null, the ``data`` will be initcode and if successful, this
|
||||
* will be the address of the contract deployed.
|
||||
*/
|
||||
contractAddress: null | string;
|
||||
/**
|
||||
* The transaction hash.
|
||||
*/
|
||||
hash: string;
|
||||
/**
|
||||
* The transaction index.
|
||||
*/
|
||||
index: number;
|
||||
/**
|
||||
* The block hash of the block that included this transaction.
|
||||
*/
|
||||
blockHash: string;
|
||||
/**
|
||||
* The block number of the block that included this transaction.
|
||||
*/
|
||||
blockNumber: number;
|
||||
/**
|
||||
* The bloom filter for the logs emitted during execution of this
|
||||
* transaction.
|
||||
*/
|
||||
logsBloom: string;
|
||||
/**
|
||||
* The logs emitted during the execution of this transaction.
|
||||
*/
|
||||
logs: ReadonlyArray<LogParams>;
|
||||
/**
|
||||
* The amount of gas consumed executing this transaction.
|
||||
*/
|
||||
gasUsed: bigint;
|
||||
/**
|
||||
* The amount of BLOb gas used. See [[link-eip-4844]].
|
||||
*/
|
||||
blobGasUsed?: null | bigint;
|
||||
/**
|
||||
* The total amount of gas consumed during the entire block up to
|
||||
* and including this transaction.
|
||||
*/
|
||||
cumulativeGasUsed: bigint;
|
||||
/**
|
||||
* The actual gas price per gas charged for this transaction.
|
||||
*/
|
||||
gasPrice?: null | bigint;
|
||||
/**
|
||||
* The actual BLOb gas price that was charged. See [[link-eip-4844]].
|
||||
*/
|
||||
blobGasPrice?: null | bigint;
|
||||
/**
|
||||
* The actual gas price per gas charged for this transaction.
|
||||
*/
|
||||
effectiveGasPrice?: null | bigint;
|
||||
/**
|
||||
* The [[link-eip-2718]] envelope type.
|
||||
*/
|
||||
type: number;
|
||||
/**
|
||||
* The status of the transaction execution. If ``1`` then the
|
||||
* the transaction returned success, if ``0`` then the transaction
|
||||
* was reverted. For pre-byzantium blocks, this is usually null, but
|
||||
* some nodes may have backfilled this data.
|
||||
*/
|
||||
status: null | number;
|
||||
/**
|
||||
* The root of this transaction in a pre-bazatium block. In
|
||||
* post-byzantium blocks this is null.
|
||||
*/
|
||||
root: null | string;
|
||||
}
|
||||
/**
|
||||
* a **TransactionResponseParams** encodes the minimal required properties
|
||||
* for a formatted transaction response.
|
||||
*/
|
||||
export interface TransactionResponseParams {
|
||||
/**
|
||||
* The block number of the block that included this transaction.
|
||||
*/
|
||||
blockNumber: null | number;
|
||||
/**
|
||||
* The block hash of the block that included this transaction.
|
||||
*/
|
||||
blockHash: null | string;
|
||||
/**
|
||||
* The transaction hash.
|
||||
*/
|
||||
hash: string;
|
||||
/**
|
||||
* The transaction index.
|
||||
*/
|
||||
index: number;
|
||||
/**
|
||||
* The [[link-eip-2718]] transaction type.
|
||||
*/
|
||||
type: number;
|
||||
/**
|
||||
* The target of the transaction. If ``null``, the ``data`` is initcode
|
||||
* and this transaction is a deployment transaction.
|
||||
*/
|
||||
to: null | string;
|
||||
/**
|
||||
* The sender of the transaction.
|
||||
*/
|
||||
from: string;
|
||||
/**
|
||||
* The nonce of the transaction, used for replay protection.
|
||||
*/
|
||||
nonce: number;
|
||||
/**
|
||||
* The maximum amount of gas this transaction is authorized to consume.
|
||||
*/
|
||||
gasLimit: bigint;
|
||||
/**
|
||||
* For legacy transactions, this is the gas price per gas to pay.
|
||||
*/
|
||||
gasPrice: bigint;
|
||||
/**
|
||||
* For [[link-eip-1559]] transactions, this is the maximum priority
|
||||
* fee to allow a producer to claim.
|
||||
*/
|
||||
maxPriorityFeePerGas: null | bigint;
|
||||
/**
|
||||
* For [[link-eip-1559]] transactions, this is the maximum fee that
|
||||
* will be paid.
|
||||
*/
|
||||
maxFeePerGas: null | bigint;
|
||||
/**
|
||||
* For [[link-eip-4844]] transactions, this is the maximum fee that
|
||||
* will be paid per BLOb.
|
||||
*/
|
||||
maxFeePerBlobGas?: null | bigint;
|
||||
/**
|
||||
* The transaction data.
|
||||
*/
|
||||
data: string;
|
||||
/**
|
||||
* The transaction value (in wei).
|
||||
*/
|
||||
value: bigint;
|
||||
/**
|
||||
* The chain ID this transaction is valid on.
|
||||
*/
|
||||
chainId: bigint;
|
||||
/**
|
||||
* The signature of the transaction.
|
||||
*/
|
||||
signature: Signature;
|
||||
/**
|
||||
* The transaction access list.
|
||||
*/
|
||||
accessList: null | AccessList;
|
||||
/**
|
||||
* The [[link-eip-4844]] BLOb versioned hashes.
|
||||
*/
|
||||
blobVersionedHashes?: null | Array<string>;
|
||||
/**
|
||||
* The [[link-eip-7702]] authorizations (if any).
|
||||
*/
|
||||
authorizationList: null | Array<Authorization>;
|
||||
}
|
||||
//# sourceMappingURL=formatting.d.ts.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/formatting.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/formatting.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../src.ts/providers/formatting.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAMzE;;;GAGG;AACH,MAAM,WAAW,WAAW;IACxB;;OAEG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAErB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAEtC;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,WAAW,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAE5B;;;OAGG;IACH,aAAa,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAE9B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,UAAU,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAE3B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,aAAa,EAAE,IAAI,GAA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;OAEG;IACH,SAAS,EAAE,SAAS,CAAC;IAErB;;OAEG;IACH,UAAU,EAAE,IAAI,GAAG,UAAU,CAAC;IAE9B;;OAEG;IACH,mBAAmB,CAAC,EAAE,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAE3C;;OAEG;IACH,iBAAiB,EAAE,IAAI,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC;CAClD"}
|
||||
9
dev/env/node_modules/ethers/lib.esm/providers/formatting.js
generated
vendored
Executable file
9
dev/env/node_modules/ethers/lib.esm/providers/formatting.js
generated
vendored
Executable file
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* About provider formatting?
|
||||
*
|
||||
* @_section: api/providers/formatting:Formatting [provider-formatting]
|
||||
*/
|
||||
;
|
||||
;
|
||||
export {};
|
||||
//# sourceMappingURL=formatting.js.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/formatting.js.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/formatting.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"formatting.js","sourceRoot":"","sources":["../../src.ts/providers/formatting.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAiHF,CAAC;AA0SD,CAAC"}
|
||||
50
dev/env/node_modules/ethers/lib.esm/providers/index.d.ts
generated
vendored
Executable file
50
dev/env/node_modules/ethers/lib.esm/providers/index.d.ts
generated
vendored
Executable file
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* A **Provider** provides a connection to the blockchain, whch can be
|
||||
* used to query its current state, simulate execution and send transactions
|
||||
* to update the state.
|
||||
*
|
||||
* It is one of the most fundamental components of interacting with a
|
||||
* blockchain application, and there are many ways to connect, such as over
|
||||
* HTTP, WebSockets or injected providers such as [MetaMask](link-metamask).
|
||||
*
|
||||
* @_section: api/providers:Providers [about-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, MulticoinProviderPlugin } from "./ens-resolver.js";
|
||||
export { Network } from "./network.js";
|
||||
export { NonceManager } from "./signer-noncemanager.js";
|
||||
export { NetworkPlugin, GasCostPlugin, EnsPlugin, FeeDataNetworkPlugin, FetchUrlFeeDataNetworkPlugin, } 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 { BlockscoutProvider } from "./provider-blockscout.js";
|
||||
export { AnkrProvider } from "./provider-ankr.js";
|
||||
export { CloudflareProvider } from "./provider-cloudflare.js";
|
||||
export { ChainstackProvider } from "./provider-chainstack.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 { AbstractProviderOptions, 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 { CommunityResourcable } from "./community.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 { BrowserDiscoverOptions, BrowserProviderOptions, DebugEventBrowserProvider, Eip1193Provider, Eip6963ProviderInfo } from "./provider-browser.js";
|
||||
export type { FallbackProviderOptions } from "./provider-fallback.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";
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/index.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/index.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src.ts/providers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EACH,gBAAgB,EAAE,mBAAmB,EACxC,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACH,cAAc,EACd,UAAU,GACb,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACH,mBAAmB,EACtB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EACH,WAAW,EACX,uBAAuB,EAC1B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,OAAO,EACH,aAAa,EACb,aAAa,EACb,SAAS,EACT,oBAAoB,EACpB,4BAA4B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MAAM,wBAAwB,CAAA;AAE/B,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,YAAY,EACR,WAAW,EAAE,SAAS,EAAE,wBAAwB,EAChD,yBAAyB,GAC5B,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EACR,oBAAoB,EACvB,MAAM,gBAAgB,CAAC;AAOxB,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,YAAY,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,YAAY,EACR,QAAQ,EACR,kBAAkB,EAAE,0BAA0B,EAC9C,WAAW,EAAE,MAAM,EAAE,iBAAiB,EAAE,YAAY,EAAE,aAAa,EACnE,WAAW,EACX,QAAQ,EACR,UAAU,EAAE,wBAAwB,EACvC,MAAM,eAAe,CAAC;AAEvB,YAAY,EACR,sBAAsB,EAAE,sBAAsB,EAAE,yBAAyB,EACzE,eAAe,EAAE,mBAAmB,EACvC,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEtE,YAAY,EACR,cAAc,EAAE,aAAa,EAAE,YAAY,EAC3C,yBAAyB,EACzB,yBAAyB,GAC5B,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EACR,gBAAgB,EAAE,aAAa,EAClC,MAAM,yBAAyB,CAAC;AAEjC,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
||||
40
dev/env/node_modules/ethers/lib.esm/providers/index.js
generated
vendored
Executable file
40
dev/env/node_modules/ethers/lib.esm/providers/index.js
generated
vendored
Executable file
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* A **Provider** provides a connection to the blockchain, whch can be
|
||||
* used to query its current state, simulate execution and send transactions
|
||||
* to update the state.
|
||||
*
|
||||
* It is one of the most fundamental components of interacting with a
|
||||
* blockchain application, and there are many ways to connect, such as over
|
||||
* HTTP, WebSockets or injected providers such as [MetaMask](link-metamask).
|
||||
*
|
||||
* @_section: api/providers:Providers [about-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, MulticoinProviderPlugin } from "./ens-resolver.js";
|
||||
export { Network } from "./network.js";
|
||||
export { NonceManager } from "./signer-noncemanager.js";
|
||||
export { NetworkPlugin, GasCostPlugin, EnsPlugin, FeeDataNetworkPlugin, FetchUrlFeeDataNetworkPlugin, } from "./plugins-network.js";
|
||||
export { Block, FeeData, Log, TransactionReceipt, TransactionResponse, copyRequest,
|
||||
//resolveTransactionRequest,
|
||||
} 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 { BlockscoutProvider } from "./provider-blockscout.js";
|
||||
export { AnkrProvider } from "./provider-ankr.js";
|
||||
export { CloudflareProvider } from "./provider-cloudflare.js";
|
||||
export { ChainstackProvider } from "./provider-chainstack.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"; /*-browser*/
|
||||
export { IpcSocketProvider };
|
||||
export { SocketProvider } from "./provider-socket.js";
|
||||
export { WebSocketProvider } from "./provider-websocket.js";
|
||||
export { SocketSubscriber, SocketBlockSubscriber, SocketPendingSubscriber, SocketEventSubscriber } from "./provider-socket.js";
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/index.js.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/index.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src.ts/providers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EACH,gBAAgB,EAAE,mBAAmB,EACxC,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACH,cAAc,EACd,UAAU,GACb,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACH,mBAAmB,EACtB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EACH,WAAW,EACX,uBAAuB,EAC1B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,OAAO,EACH,aAAa,EACb,aAAa,EACb,SAAS,EACT,oBAAoB,EACpB,4BAA4B,GAC/B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACH,KAAK,EACL,OAAO,EACP,GAAG,EACH,kBAAkB,EAClB,mBAAmB,EAEnB,WAAW;AACX,4BAA4B;EAC/B,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAE1F,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC,CAAC,YAAY;AACzE,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EACH,gBAAgB,EAAE,qBAAqB,EAAE,uBAAuB,EAChE,qBAAqB,EACxB,MAAM,sBAAsB,CAAC"}
|
||||
99
dev/env/node_modules/ethers/lib.esm/providers/network.d.ts
generated
vendored
Executable file
99
dev/env/node_modules/ethers/lib.esm/providers/network.d.ts
generated
vendored
Executable file
@@ -0,0 +1,99 @@
|
||||
/**
|
||||
* A **Network** encapsulates the various properties required to
|
||||
* interact with a specific chain.
|
||||
*
|
||||
* @_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;
|
||||
};
|
||||
/**
|
||||
* A **Network** provides access to a chain's properties and allows
|
||||
* for plug-ins to extend functionality.
|
||||
*/
|
||||
export declare class Network {
|
||||
#private;
|
||||
/**
|
||||
* Creates a new **Network** for %%name%% and %%chainId%%.
|
||||
*/
|
||||
constructor(name: string, chainId: BigNumberish);
|
||||
/**
|
||||
* Returns a JSON-compatible representation of a Network.
|
||||
*/
|
||||
toJSON(): any;
|
||||
/**
|
||||
* The network common name.
|
||||
*
|
||||
* This is the canonical name, as networks migh have multiple
|
||||
* names.
|
||||
*/
|
||||
get name(): string;
|
||||
set name(value: string);
|
||||
/**
|
||||
* The network chain ID.
|
||||
*/
|
||||
get chainId(): bigint;
|
||||
set chainId(value: BigNumberish);
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
get plugins(): Array<NetworkPlugin>;
|
||||
/**
|
||||
* Attach a new %%plugin%% to this Network. The network name
|
||||
* must be unique, excluding any fragment.
|
||||
*/
|
||||
attachPlugin(plugin: NetworkPlugin): this;
|
||||
/**
|
||||
* Return the plugin, if any, matching %%name%% exactly. Plugins
|
||||
* with fragments will not be returned unless %%name%% includes
|
||||
* a fragment.
|
||||
*/
|
||||
getPlugin<T extends NetworkPlugin = NetworkPlugin>(name: string): null | T;
|
||||
/**
|
||||
* Gets a list of all plugins that match %%name%%, with otr without
|
||||
* a fragment.
|
||||
*/
|
||||
getPlugins<T extends NetworkPlugin = NetworkPlugin>(basename: string): Array<T>;
|
||||
/**
|
||||
* Create a copy of this Network.
|
||||
*/
|
||||
clone(): Network;
|
||||
/**
|
||||
* Compute the intrinsic gas required for a transaction.
|
||||
*
|
||||
* A GasCostPlugin can be attached to override the default
|
||||
* values.
|
||||
*/
|
||||
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
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/network.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/network.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../src.ts/providers/network.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG;IAC1D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;CACtB,CAAC;AA2BF;;;GAGG;AACH,qBAAa,OAAO;;IAMhB;;OAEG;gBACS,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY;IAM/C;;OAEG;IACH,MAAM,IAAI,GAAG;IAIb;;;;;OAKG;IACH,IAAI,IAAI,IAAI,MAAM,CAAuB;IACzC,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,EAA0B;IAEhD;;OAEG;IACH,IAAI,OAAO,IAAI,MAAM,CAA0B;IAC/C,IAAI,OAAO,CAAC,KAAK,EAAE,YAAY,EAAkD;IAEjF;;;;;;OAMG;IACH,OAAO,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO;IAiCnC;;OAEG;IACH,IAAI,OAAO,IAAI,KAAK,CAAC,aAAa,CAAC,CAElC;IAED;;;OAGG;IACH,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI;IAQzC;;;;OAIG;IACH,SAAS,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,CAAC;IAI1E;;;OAGG;IACH,UAAU,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,EAAE,QAAQ,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC;IAI/E;;OAEG;IACH,KAAK,IAAI,OAAO;IAQhB;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,EAAE,eAAe,GAAG,MAAM;IAyBhD;;OAEG;IACH,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO;IA+C1C;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,WAAW,EAAE,MAAM,OAAO,GAAG,IAAI;CAQ7F"}
|
||||
365
dev/env/node_modules/ethers/lib.esm/providers/network.js
generated
vendored
Executable file
365
dev/env/node_modules/ethers/lib.esm/providers/network.js
generated
vendored
Executable file
@@ -0,0 +1,365 @@
|
||||
/**
|
||||
* A **Network** encapsulates the various properties required to
|
||||
* interact with a specific chain.
|
||||
*
|
||||
* @_subsection: api/providers:Networks [networks]
|
||||
*/
|
||||
import { accessListify } from "../transaction/index.js";
|
||||
import { getBigInt, assert, assertArgument } from "../utils/index.js";
|
||||
import { EnsPlugin, FetchUrlFeeDataNetworkPlugin, GasCostPlugin } from "./plugins-network.js";
|
||||
/* * * *
|
||||
// Networks which operation against an L2 can use this plugin to
|
||||
// specify how to access L1, for the purpose of resolving ENS,
|
||||
// for example.
|
||||
export class LayerOneConnectionPlugin extends NetworkPlugin {
|
||||
readonly provider!: Provider;
|
||||
// @TODO: Rename to ChainAccess and allow for connecting to any chain
|
||||
constructor(provider: Provider) {
|
||||
super("org.ethers.plugins.layer-one-connection");
|
||||
defineProperties<LayerOneConnectionPlugin>(this, { provider });
|
||||
}
|
||||
|
||||
clone(): LayerOneConnectionPlugin {
|
||||
return new LayerOneConnectionPlugin(this.provider);
|
||||
}
|
||||
}
|
||||
*/
|
||||
const Networks = new Map();
|
||||
/**
|
||||
* A **Network** provides access to a chain's properties and allows
|
||||
* for plug-ins to extend functionality.
|
||||
*/
|
||||
export class Network {
|
||||
#name;
|
||||
#chainId;
|
||||
#plugins;
|
||||
/**
|
||||
* Creates a new **Network** for %%name%% and %%chainId%%.
|
||||
*/
|
||||
constructor(name, chainId) {
|
||||
this.#name = name;
|
||||
this.#chainId = getBigInt(chainId);
|
||||
this.#plugins = new Map();
|
||||
}
|
||||
/**
|
||||
* Returns a JSON-compatible representation of a Network.
|
||||
*/
|
||||
toJSON() {
|
||||
return { name: this.name, chainId: String(this.chainId) };
|
||||
}
|
||||
/**
|
||||
* The network common name.
|
||||
*
|
||||
* This is the canonical name, as networks migh have multiple
|
||||
* names.
|
||||
*/
|
||||
get name() { return this.#name; }
|
||||
set name(value) { this.#name = value; }
|
||||
/**
|
||||
* The network chain ID.
|
||||
*/
|
||||
get chainId() { return this.#chainId; }
|
||||
set chainId(value) { this.#chainId = getBigInt(value, "chainId"); }
|
||||
/**
|
||||
* 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) {
|
||||
if (other == null) {
|
||||
return false;
|
||||
}
|
||||
if (typeof (other) === "string") {
|
||||
try {
|
||||
return (this.chainId === getBigInt(other));
|
||||
}
|
||||
catch (error) { }
|
||||
return (this.name === other);
|
||||
}
|
||||
if (typeof (other) === "number" || typeof (other) === "bigint") {
|
||||
try {
|
||||
return (this.chainId === getBigInt(other));
|
||||
}
|
||||
catch (error) { }
|
||||
return false;
|
||||
}
|
||||
if (typeof (other) === "object") {
|
||||
if (other.chainId != null) {
|
||||
try {
|
||||
return (this.chainId === getBigInt(other.chainId));
|
||||
}
|
||||
catch (error) { }
|
||||
return false;
|
||||
}
|
||||
if (other.name != null) {
|
||||
return (this.name === other.name);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Returns the list of plugins currently attached to this Network.
|
||||
*/
|
||||
get plugins() {
|
||||
return Array.from(this.#plugins.values());
|
||||
}
|
||||
/**
|
||||
* Attach a new %%plugin%% to this Network. The network name
|
||||
* must be unique, excluding any fragment.
|
||||
*/
|
||||
attachPlugin(plugin) {
|
||||
if (this.#plugins.get(plugin.name)) {
|
||||
throw new Error(`cannot replace existing plugin: ${plugin.name} `);
|
||||
}
|
||||
this.#plugins.set(plugin.name, plugin.clone());
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Return the plugin, if any, matching %%name%% exactly. Plugins
|
||||
* with fragments will not be returned unless %%name%% includes
|
||||
* a fragment.
|
||||
*/
|
||||
getPlugin(name) {
|
||||
return (this.#plugins.get(name)) || null;
|
||||
}
|
||||
/**
|
||||
* Gets a list of all plugins that match %%name%%, with otr without
|
||||
* a fragment.
|
||||
*/
|
||||
getPlugins(basename) {
|
||||
return (this.plugins.filter((p) => (p.name.split("#")[0] === basename)));
|
||||
}
|
||||
/**
|
||||
* Create a copy of this Network.
|
||||
*/
|
||||
clone() {
|
||||
const clone = new Network(this.name, this.chainId);
|
||||
this.plugins.forEach((plugin) => {
|
||||
clone.attachPlugin(plugin.clone());
|
||||
});
|
||||
return clone;
|
||||
}
|
||||
/**
|
||||
* Compute the intrinsic gas required for a transaction.
|
||||
*
|
||||
* A GasCostPlugin can be attached to override the default
|
||||
* values.
|
||||
*/
|
||||
computeIntrinsicGas(tx) {
|
||||
const costs = this.getPlugin("org.ethers.plugins.network.GasCost") || (new GasCostPlugin());
|
||||
let gas = costs.txBase;
|
||||
if (tx.to == null) {
|
||||
gas += costs.txCreate;
|
||||
}
|
||||
if (tx.data) {
|
||||
for (let i = 2; i < tx.data.length; i += 2) {
|
||||
if (tx.data.substring(i, i + 2) === "00") {
|
||||
gas += costs.txDataZero;
|
||||
}
|
||||
else {
|
||||
gas += costs.txDataNonzero;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tx.accessList) {
|
||||
const accessList = accessListify(tx.accessList);
|
||||
for (const addr in accessList) {
|
||||
gas += costs.txAccessListAddress + costs.txAccessListStorageKey * accessList[addr].storageKeys.length;
|
||||
}
|
||||
}
|
||||
return gas;
|
||||
}
|
||||
/**
|
||||
* Returns a new Network for the %%network%% name or chainId.
|
||||
*/
|
||||
static from(network) {
|
||||
injectCommonNetworks();
|
||||
// Default network
|
||||
if (network == null) {
|
||||
return Network.from("mainnet");
|
||||
}
|
||||
// Canonical name or chain ID
|
||||
if (typeof (network) === "number") {
|
||||
network = BigInt(network);
|
||||
}
|
||||
if (typeof (network) === "string" || typeof (network) === "bigint") {
|
||||
const networkFunc = Networks.get(network);
|
||||
if (networkFunc) {
|
||||
return networkFunc();
|
||||
}
|
||||
if (typeof (network) === "bigint") {
|
||||
return new Network("unknown", network);
|
||||
}
|
||||
assertArgument(false, "unknown network", "network", network);
|
||||
}
|
||||
// Clonable with network-like abilities
|
||||
if (typeof (network.clone) === "function") {
|
||||
const clone = network.clone();
|
||||
//if (typeof(network.name) !== "string" || typeof(network.chainId) !== "number") {
|
||||
//}
|
||||
return clone;
|
||||
}
|
||||
// Networkish
|
||||
if (typeof (network) === "object") {
|
||||
assertArgument(typeof (network.name) === "string" && typeof (network.chainId) === "number", "invalid network object name or chainId", "network", network);
|
||||
const custom = new Network((network.name), (network.chainId));
|
||||
if (network.ensAddress || network.ensNetwork != null) {
|
||||
custom.attachPlugin(new EnsPlugin(network.ensAddress, network.ensNetwork));
|
||||
}
|
||||
//if ((<any>network).layerOneConnection) {
|
||||
// custom.attachPlugin(new LayerOneConnectionPlugin((<any>network).layerOneConnection));
|
||||
//}
|
||||
return custom;
|
||||
}
|
||||
assertArgument(false, "invalid network", "network", network);
|
||||
}
|
||||
/**
|
||||
* Register %%nameOrChainId%% with a function which returns
|
||||
* an instance of a Network representing that chain.
|
||||
*/
|
||||
static register(nameOrChainId, networkFunc) {
|
||||
if (typeof (nameOrChainId) === "number") {
|
||||
nameOrChainId = BigInt(nameOrChainId);
|
||||
}
|
||||
const existing = Networks.get(nameOrChainId);
|
||||
if (existing) {
|
||||
assertArgument(false, `conflicting network for ${JSON.stringify(existing.name)}`, "nameOrChainId", nameOrChainId);
|
||||
}
|
||||
Networks.set(nameOrChainId, networkFunc);
|
||||
}
|
||||
}
|
||||
// We don't want to bring in formatUnits because it is backed by
|
||||
// FixedNumber and we want to keep Networks tiny. The values
|
||||
// included by the Gas Stations are also IEEE 754 with lots of
|
||||
// rounding issues and exceed the strict checks formatUnits has.
|
||||
function parseUnits(_value, decimals) {
|
||||
const value = String(_value);
|
||||
if (!value.match(/^[0-9.]+$/)) {
|
||||
throw new Error(`invalid gwei value: ${_value}`);
|
||||
}
|
||||
// Break into [ whole, fraction ]
|
||||
const comps = value.split(".");
|
||||
if (comps.length === 1) {
|
||||
comps.push("");
|
||||
}
|
||||
// More than 1 decimal point or too many fractional positions
|
||||
if (comps.length !== 2) {
|
||||
throw new Error(`invalid gwei value: ${_value}`);
|
||||
}
|
||||
// Pad the fraction to 9 decimalplaces
|
||||
while (comps[1].length < decimals) {
|
||||
comps[1] += "0";
|
||||
}
|
||||
// Too many decimals and some non-zero ending, take the ceiling
|
||||
if (comps[1].length > 9) {
|
||||
let frac = BigInt(comps[1].substring(0, 9));
|
||||
if (!comps[1].substring(9).match(/^0+$/)) {
|
||||
frac++;
|
||||
}
|
||||
comps[1] = frac.toString();
|
||||
}
|
||||
return BigInt(comps[0] + comps[1]);
|
||||
}
|
||||
// Used by Polygon to use a gas station for fee data
|
||||
function getGasStationPlugin(url) {
|
||||
return new FetchUrlFeeDataNetworkPlugin(url, async (fetchFeeData, provider, request) => {
|
||||
// Prevent Cloudflare from blocking our request in node.js
|
||||
request.setHeader("User-Agent", "ethers");
|
||||
let response;
|
||||
try {
|
||||
const [_response, _feeData] = await Promise.all([
|
||||
request.send(), fetchFeeData()
|
||||
]);
|
||||
response = _response;
|
||||
const payload = response.bodyJson.standard;
|
||||
const feeData = {
|
||||
gasPrice: _feeData.gasPrice,
|
||||
maxFeePerGas: parseUnits(payload.maxFee, 9),
|
||||
maxPriorityFeePerGas: parseUnits(payload.maxPriorityFee, 9),
|
||||
};
|
||||
return feeData;
|
||||
}
|
||||
catch (error) {
|
||||
assert(false, `error encountered with polygon gas station (${JSON.stringify(request.url)})`, "SERVER_ERROR", { request, response, error });
|
||||
}
|
||||
});
|
||||
}
|
||||
// See: https://chainlist.org
|
||||
let injected = false;
|
||||
function injectCommonNetworks() {
|
||||
if (injected) {
|
||||
return;
|
||||
}
|
||||
injected = true;
|
||||
/// Register popular Ethereum networks
|
||||
function registerEth(name, chainId, options) {
|
||||
const func = function () {
|
||||
const network = new Network(name, chainId);
|
||||
// We use 0 to disable ENS
|
||||
if (options.ensNetwork != null) {
|
||||
network.attachPlugin(new EnsPlugin(null, options.ensNetwork));
|
||||
}
|
||||
network.attachPlugin(new GasCostPlugin());
|
||||
(options.plugins || []).forEach((plugin) => {
|
||||
network.attachPlugin(plugin);
|
||||
});
|
||||
return network;
|
||||
};
|
||||
// Register the network by name and chain ID
|
||||
Network.register(name, func);
|
||||
Network.register(chainId, func);
|
||||
if (options.altNames) {
|
||||
options.altNames.forEach((name) => {
|
||||
Network.register(name, func);
|
||||
});
|
||||
}
|
||||
}
|
||||
registerEth("mainnet", 1, { ensNetwork: 1, altNames: ["homestead"] });
|
||||
registerEth("ropsten", 3, { ensNetwork: 3 });
|
||||
registerEth("rinkeby", 4, { ensNetwork: 4 });
|
||||
registerEth("goerli", 5, { ensNetwork: 5 });
|
||||
registerEth("kovan", 42, { ensNetwork: 42 });
|
||||
registerEth("sepolia", 11155111, { ensNetwork: 11155111 });
|
||||
registerEth("holesky", 17000, { ensNetwork: 17000 });
|
||||
registerEth("classic", 61, {});
|
||||
registerEth("classicKotti", 6, {});
|
||||
registerEth("arbitrum", 42161, {
|
||||
ensNetwork: 1,
|
||||
});
|
||||
registerEth("arbitrum-goerli", 421613, {});
|
||||
registerEth("arbitrum-sepolia", 421614, {});
|
||||
registerEth("base", 8453, { ensNetwork: 1 });
|
||||
registerEth("base-goerli", 84531, {});
|
||||
registerEth("base-sepolia", 84532, {});
|
||||
registerEth("bnb", 56, { ensNetwork: 1 });
|
||||
registerEth("bnbt", 97, {});
|
||||
registerEth("filecoin", 314, {});
|
||||
registerEth("filecoin-calibration", 314159, {});
|
||||
registerEth("linea", 59144, { ensNetwork: 1 });
|
||||
registerEth("linea-goerli", 59140, {});
|
||||
registerEth("linea-sepolia", 59141, {});
|
||||
registerEth("matic", 137, {
|
||||
ensNetwork: 1,
|
||||
plugins: [
|
||||
getGasStationPlugin("https:/\/gasstation.polygon.technology/v2")
|
||||
]
|
||||
});
|
||||
registerEth("matic-amoy", 80002, {});
|
||||
registerEth("matic-mumbai", 80001, {
|
||||
altNames: ["maticMumbai", "maticmum"],
|
||||
plugins: [
|
||||
getGasStationPlugin("https:/\/gasstation-testnet.polygon.technology/v2")
|
||||
]
|
||||
});
|
||||
registerEth("optimism", 10, {
|
||||
ensNetwork: 1,
|
||||
plugins: []
|
||||
});
|
||||
registerEth("optimism-goerli", 420, {});
|
||||
registerEth("optimism-sepolia", 11155420, {});
|
||||
registerEth("xdai", 100, { ensNetwork: 1 });
|
||||
}
|
||||
//# sourceMappingURL=network.js.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/network.js.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/network.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
6
dev/env/node_modules/ethers/lib.esm/providers/pagination.d.ts
generated
vendored
Executable file
6
dev/env/node_modules/ethers/lib.esm/providers/pagination.d.ts
generated
vendored
Executable file
@@ -0,0 +1,6 @@
|
||||
export interface PaginationResult<R> extends Array<R> {
|
||||
next(): Promise<PaginationResult<R>>;
|
||||
totalResults: null | number;
|
||||
done: boolean;
|
||||
}
|
||||
//# sourceMappingURL=pagination.d.ts.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/pagination.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/pagination.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../src.ts/providers/pagination.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB,CAAC,CAAC,CAAE,SAAQ,KAAK,CAAC,CAAC,CAAC;IACjD,IAAI,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;IAGrC,YAAY,EAAE,IAAI,GAAG,MAAM,CAAC;IAE5B,IAAI,EAAE,OAAO,CAAC;CACjB"}
|
||||
2
dev/env/node_modules/ethers/lib.esm/providers/pagination.js
generated
vendored
Executable file
2
dev/env/node_modules/ethers/lib.esm/providers/pagination.js
generated
vendored
Executable file
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=pagination.js.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/pagination.js.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/pagination.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"pagination.js","sourceRoot":"","sources":["../../src.ts/providers/pagination.ts"],"names":[],"mappings":""}
|
||||
13
dev/env/node_modules/ethers/lib.esm/providers/plugin-fallback.d.ts
generated
vendored
Executable file
13
dev/env/node_modules/ethers/lib.esm/providers/plugin-fallback.d.ts
generated
vendored
Executable file
@@ -0,0 +1,13 @@
|
||||
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;
|
||||
}
|
||||
//# sourceMappingURL=plugin-fallback.d.ts.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/plugin-fallback.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/plugin-fallback.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"plugin-fallback.d.ts","sourceRoot":"","sources":["../../src.ts/providers/plugin-fallback.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAGhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAGrF,eAAO,MAAM,wBAAwB,gDAAgD,CAAC;AAEtF,qBAAa,oBAAqB,YAAW,sBAAsB;IACvD,IAAI,EAAE,MAAM,CAAC;;IAMrB,OAAO,CAAC,QAAQ,EAAE,gBAAgB,GAAG,oBAAoB;IAMzD,WAAW,CAAC,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,GAAG,GAAG,OAAO;CAGlE;AAED,qBAAa,+BAAgC,SAAQ,oBAAoB;IACrE,WAAW,CAAC,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,GAAG,GAAG,OAAO;CAMlE"}
|
||||
26
dev/env/node_modules/ethers/lib.esm/providers/plugin-fallback.js
generated
vendored
Executable file
26
dev/env/node_modules/ethers/lib.esm/providers/plugin-fallback.js
generated
vendored
Executable file
@@ -0,0 +1,26 @@
|
||||
import { defineProperties } from "../utils/index.js";
|
||||
export const PluginIdFallbackProvider = "org.ethers.plugins.provider.QualifiedPlugin";
|
||||
export class CheckQualifiedPlugin {
|
||||
constructor() {
|
||||
defineProperties(this, { name: PluginIdFallbackProvider });
|
||||
}
|
||||
connect(provider) {
|
||||
return this;
|
||||
}
|
||||
// Retruns true if this value should be considered qualified for
|
||||
// inclusion in the quorum.
|
||||
isQualified(action, result) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
export class PossiblyPrunedTransactionPlugin extends CheckQualifiedPlugin {
|
||||
isQualified(action, result) {
|
||||
if (action.method === "getTransaction" || action.method === "getTransactionReceipt") {
|
||||
if (result == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return super.isQualified(action, result);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=plugin-fallback.js.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/plugin-fallback.js.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/plugin-fallback.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"plugin-fallback.js","sourceRoot":"","sources":["../../src.ts/providers/plugin-fallback.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAKrD,MAAM,CAAC,MAAM,wBAAwB,GAAG,6CAA6C,CAAC;AAEtF,MAAM,OAAO,oBAAoB;IAG7B;QACI,gBAAgB,CAAuB,IAAI,EAAE,EAAE,IAAI,EAAE,wBAAwB,EAAE,CAAC,CAAC;IACrF,CAAC;IAED,OAAO,CAAC,QAA0B;QAC9B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,gEAAgE;IAChE,2BAA2B;IAC3B,WAAW,CAAC,MAA4B,EAAE,MAAW;QACjD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,MAAM,OAAO,+BAAgC,SAAQ,oBAAoB;IACrE,WAAW,CAAC,MAA4B,EAAE,MAAW;QACjD,IAAI,MAAM,CAAC,MAAM,KAAK,gBAAgB,IAAI,MAAM,CAAC,MAAM,KAAK,uBAAuB,EAAE;YACjF,IAAI,MAAM,IAAI,IAAI,EAAE;gBAAE,OAAO,KAAK,CAAC;aAAE;SACxC;QACD,OAAO,KAAK,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7C,CAAC;CACJ"}
|
||||
170
dev/env/node_modules/ethers/lib.esm/providers/plugins-network.d.ts
generated
vendored
Executable file
170
dev/env/node_modules/ethers/lib.esm/providers/plugins-network.d.ts
generated
vendored
Executable file
@@ -0,0 +1,170 @@
|
||||
import type { FeeData, Provider } from "./provider.js";
|
||||
import type { FetchRequest } from "../utils/fetch.js";
|
||||
/**
|
||||
* A **NetworkPlugin** provides additional functionality on a [[Network]].
|
||||
*/
|
||||
export declare class NetworkPlugin {
|
||||
/**
|
||||
* The name of the plugin.
|
||||
*
|
||||
* It is recommended to use reverse-domain-notation, which permits
|
||||
* unique names with a known authority as well as hierarchal entries.
|
||||
*/
|
||||
readonly name: string;
|
||||
/**
|
||||
* Creates a new **NetworkPlugin**.
|
||||
*/
|
||||
constructor(name: string);
|
||||
/**
|
||||
* Creates a copy of this plugin.
|
||||
*/
|
||||
clone(): NetworkPlugin;
|
||||
}
|
||||
/**
|
||||
* The gas cost parameters for a [[GasCostPlugin]].
|
||||
*/
|
||||
export type GasCostParameters = {
|
||||
/**
|
||||
* The transactions base fee.
|
||||
*/
|
||||
txBase?: number;
|
||||
/**
|
||||
* The fee for creating a new account.
|
||||
*/
|
||||
txCreate?: number;
|
||||
/**
|
||||
* The fee per zero-byte in the data.
|
||||
*/
|
||||
txDataZero?: number;
|
||||
/**
|
||||
* The fee per non-zero-byte in the data.
|
||||
*/
|
||||
txDataNonzero?: number;
|
||||
/**
|
||||
* The fee per storage key in the [[link-eip-2930]] access list.
|
||||
*/
|
||||
txAccessListStorageKey?: number;
|
||||
/**
|
||||
* The fee per address in the [[link-eip-2930]] access list.
|
||||
*/
|
||||
txAccessListAddress?: number;
|
||||
};
|
||||
/**
|
||||
* A **GasCostPlugin** allows a network to provide alternative values when
|
||||
* computing the intrinsic gas required for a transaction.
|
||||
*/
|
||||
export declare class GasCostPlugin extends NetworkPlugin implements GasCostParameters {
|
||||
/**
|
||||
* The block number to treat these values as valid from.
|
||||
*
|
||||
* This allows a hardfork to have updated values included as well as
|
||||
* mulutiple hardforks to be supported.
|
||||
*/
|
||||
readonly effectiveBlock: number;
|
||||
/**
|
||||
* The transactions base fee.
|
||||
*/
|
||||
readonly txBase: number;
|
||||
/**
|
||||
* The fee for creating a new account.
|
||||
*/
|
||||
readonly txCreate: number;
|
||||
/**
|
||||
* The fee per zero-byte in the data.
|
||||
*/
|
||||
readonly txDataZero: number;
|
||||
/**
|
||||
* The fee per non-zero-byte in the data.
|
||||
*/
|
||||
readonly txDataNonzero: number;
|
||||
/**
|
||||
* The fee per storage key in the [[link-eip-2930]] access list.
|
||||
*/
|
||||
readonly txAccessListStorageKey: number;
|
||||
/**
|
||||
* The fee per address in the [[link-eip-2930]] access list.
|
||||
*/
|
||||
readonly txAccessListAddress: number;
|
||||
/**
|
||||
* Creates a new GasCostPlugin from %%effectiveBlock%% until the
|
||||
* latest block or another GasCostPlugin supercedes that block number,
|
||||
* with the associated %%costs%%.
|
||||
*/
|
||||
constructor(effectiveBlock?: number, costs?: GasCostParameters);
|
||||
clone(): GasCostPlugin;
|
||||
}
|
||||
/**
|
||||
* An **EnsPlugin** allows a [[Network]] to specify the ENS Registry
|
||||
* Contract address and the target network to use when using that
|
||||
* contract.
|
||||
*
|
||||
* Various testnets have their own instance of the contract to use, but
|
||||
* in general, the mainnet instance supports multi-chain addresses and
|
||||
* should be used.
|
||||
*/
|
||||
export declare class EnsPlugin extends NetworkPlugin {
|
||||
/**
|
||||
* The ENS Registrty Contract address.
|
||||
*/
|
||||
readonly address: string;
|
||||
/**
|
||||
* The chain ID that the ENS contract lives on.
|
||||
*/
|
||||
readonly targetNetwork: number;
|
||||
/**
|
||||
* Creates a new **EnsPlugin** connected to %%address%% on the
|
||||
* %%targetNetwork%%. The default ENS address and mainnet is used
|
||||
* if unspecified.
|
||||
*/
|
||||
constructor(address?: null | string, targetNetwork?: null | number);
|
||||
clone(): EnsPlugin;
|
||||
}
|
||||
/**
|
||||
* A **FeeDataNetworkPlugin** allows a network to provide and alternate
|
||||
* means to specify its fee data.
|
||||
*
|
||||
* For example, a network which does not support [[link-eip-1559]] may
|
||||
* choose to use a Gas Station site to approximate the gas price.
|
||||
*/
|
||||
export declare class FeeDataNetworkPlugin extends NetworkPlugin {
|
||||
#private;
|
||||
/**
|
||||
* The fee data function provided to the constructor.
|
||||
*/
|
||||
get feeDataFunc(): (provider: Provider) => Promise<FeeData>;
|
||||
/**
|
||||
* Creates a new **FeeDataNetworkPlugin**.
|
||||
*/
|
||||
constructor(feeDataFunc: (provider: Provider) => Promise<FeeData>);
|
||||
/**
|
||||
* Resolves to the fee data.
|
||||
*/
|
||||
getFeeData(provider: Provider): Promise<FeeData>;
|
||||
clone(): FeeDataNetworkPlugin;
|
||||
}
|
||||
export declare class FetchUrlFeeDataNetworkPlugin extends NetworkPlugin {
|
||||
#private;
|
||||
/**
|
||||
* The URL to initialize the FetchRequest with in %%processFunc%%.
|
||||
*/
|
||||
get url(): string;
|
||||
/**
|
||||
* The callback to use when computing the FeeData.
|
||||
*/
|
||||
get processFunc(): (f: () => Promise<FeeData>, p: Provider, r: FetchRequest) => Promise<{
|
||||
gasPrice?: null | bigint;
|
||||
maxFeePerGas?: null | bigint;
|
||||
maxPriorityFeePerGas?: null | bigint;
|
||||
}>;
|
||||
/**
|
||||
* Creates a new **FetchUrlFeeDataNetworkPlugin** which will
|
||||
* be used when computing the fee data for the network.
|
||||
*/
|
||||
constructor(url: string, processFunc: (f: () => Promise<FeeData>, p: Provider, r: FetchRequest) => Promise<{
|
||||
gasPrice?: null | bigint;
|
||||
maxFeePerGas?: null | bigint;
|
||||
maxPriorityFeePerGas?: null | bigint;
|
||||
}>);
|
||||
clone(): FetchUrlFeeDataNetworkPlugin;
|
||||
}
|
||||
//# sourceMappingURL=plugins-network.d.ts.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/plugins-network.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/plugins-network.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"plugins-network.d.ts","sourceRoot":"","sources":["../../src.ts/providers/plugins-network.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAKtD;;GAEG;AACH,qBAAa,aAAa;IACtB;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAG,MAAM,CAAC;IAEvB;;OAEG;gBACS,IAAI,EAAE,MAAM;IAIxB;;OAEG;IACH,KAAK,IAAI,aAAa;CAOzB;AAGD;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC5B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAEhC;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAChC,CAAC;AAEF;;;GAGG;AACH,qBAAa,aAAc,SAAQ,aAAc,YAAW,iBAAiB;IACzE;;;;;OAKG;IACH,QAAQ,CAAC,cAAc,EAAG,MAAM,CAAC;IAEjC;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAG,MAAM,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAG,MAAM,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAG,MAAM,CAAC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,YAAY,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;QAAC,oBAAoB,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;KAAE,CAAC,CAA8B;IAEvN;;;OAGG;gBACS,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC;QAAE,QAAQ,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;QAAC,oBAAoB,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;KAAE,CAAC;IAO5M,KAAK,IAAI,4BAA4B;CACxC"}
|
||||
208
dev/env/node_modules/ethers/lib.esm/providers/plugins-network.js
generated
vendored
Executable file
208
dev/env/node_modules/ethers/lib.esm/providers/plugins-network.js
generated
vendored
Executable file
@@ -0,0 +1,208 @@
|
||||
import { defineProperties } from "../utils/properties.js";
|
||||
import { assertArgument } from "../utils/index.js";
|
||||
const EnsAddress = "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
|
||||
/**
|
||||
* A **NetworkPlugin** provides additional functionality on a [[Network]].
|
||||
*/
|
||||
export class NetworkPlugin {
|
||||
/**
|
||||
* The name of the plugin.
|
||||
*
|
||||
* It is recommended to use reverse-domain-notation, which permits
|
||||
* unique names with a known authority as well as hierarchal entries.
|
||||
*/
|
||||
name;
|
||||
/**
|
||||
* Creates a new **NetworkPlugin**.
|
||||
*/
|
||||
constructor(name) {
|
||||
defineProperties(this, { name });
|
||||
}
|
||||
/**
|
||||
* Creates a copy of this plugin.
|
||||
*/
|
||||
clone() {
|
||||
return new NetworkPlugin(this.name);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A **GasCostPlugin** allows a network to provide alternative values when
|
||||
* computing the intrinsic gas required for a transaction.
|
||||
*/
|
||||
export class GasCostPlugin extends NetworkPlugin {
|
||||
/**
|
||||
* The block number to treat these values as valid from.
|
||||
*
|
||||
* This allows a hardfork to have updated values included as well as
|
||||
* mulutiple hardforks to be supported.
|
||||
*/
|
||||
effectiveBlock;
|
||||
/**
|
||||
* The transactions base fee.
|
||||
*/
|
||||
txBase;
|
||||
/**
|
||||
* The fee for creating a new account.
|
||||
*/
|
||||
txCreate;
|
||||
/**
|
||||
* The fee per zero-byte in the data.
|
||||
*/
|
||||
txDataZero;
|
||||
/**
|
||||
* The fee per non-zero-byte in the data.
|
||||
*/
|
||||
txDataNonzero;
|
||||
/**
|
||||
* The fee per storage key in the [[link-eip-2930]] access list.
|
||||
*/
|
||||
txAccessListStorageKey;
|
||||
/**
|
||||
* The fee per address in the [[link-eip-2930]] access list.
|
||||
*/
|
||||
txAccessListAddress;
|
||||
/**
|
||||
* Creates a new GasCostPlugin from %%effectiveBlock%% until the
|
||||
* latest block or another GasCostPlugin supercedes that block number,
|
||||
* with the associated %%costs%%.
|
||||
*/
|
||||
constructor(effectiveBlock, costs) {
|
||||
if (effectiveBlock == null) {
|
||||
effectiveBlock = 0;
|
||||
}
|
||||
super(`org.ethers.network.plugins.GasCost#${(effectiveBlock || 0)}`);
|
||||
const props = { effectiveBlock };
|
||||
function set(name, nullish) {
|
||||
let value = (costs || {})[name];
|
||||
if (value == null) {
|
||||
value = nullish;
|
||||
}
|
||||
assertArgument(typeof (value) === "number", `invalud value for ${name}`, "costs", costs);
|
||||
props[name] = value;
|
||||
}
|
||||
set("txBase", 21000);
|
||||
set("txCreate", 32000);
|
||||
set("txDataZero", 4);
|
||||
set("txDataNonzero", 16);
|
||||
set("txAccessListStorageKey", 1900);
|
||||
set("txAccessListAddress", 2400);
|
||||
defineProperties(this, props);
|
||||
}
|
||||
clone() {
|
||||
return new GasCostPlugin(this.effectiveBlock, this);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* An **EnsPlugin** allows a [[Network]] to specify the ENS Registry
|
||||
* Contract address and the target network to use when using that
|
||||
* contract.
|
||||
*
|
||||
* Various testnets have their own instance of the contract to use, but
|
||||
* in general, the mainnet instance supports multi-chain addresses and
|
||||
* should be used.
|
||||
*/
|
||||
export class EnsPlugin extends NetworkPlugin {
|
||||
/**
|
||||
* The ENS Registrty Contract address.
|
||||
*/
|
||||
address;
|
||||
/**
|
||||
* The chain ID that the ENS contract lives on.
|
||||
*/
|
||||
targetNetwork;
|
||||
/**
|
||||
* Creates a new **EnsPlugin** connected to %%address%% on the
|
||||
* %%targetNetwork%%. The default ENS address and mainnet is used
|
||||
* if unspecified.
|
||||
*/
|
||||
constructor(address, targetNetwork) {
|
||||
super("org.ethers.plugins.network.Ens");
|
||||
defineProperties(this, {
|
||||
address: (address || EnsAddress),
|
||||
targetNetwork: ((targetNetwork == null) ? 1 : targetNetwork)
|
||||
});
|
||||
}
|
||||
clone() {
|
||||
return new EnsPlugin(this.address, this.targetNetwork);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A **FeeDataNetworkPlugin** allows a network to provide and alternate
|
||||
* means to specify its fee data.
|
||||
*
|
||||
* For example, a network which does not support [[link-eip-1559]] may
|
||||
* choose to use a Gas Station site to approximate the gas price.
|
||||
*/
|
||||
export class FeeDataNetworkPlugin extends NetworkPlugin {
|
||||
#feeDataFunc;
|
||||
/**
|
||||
* The fee data function provided to the constructor.
|
||||
*/
|
||||
get feeDataFunc() {
|
||||
return this.#feeDataFunc;
|
||||
}
|
||||
/**
|
||||
* Creates a new **FeeDataNetworkPlugin**.
|
||||
*/
|
||||
constructor(feeDataFunc) {
|
||||
super("org.ethers.plugins.network.FeeData");
|
||||
this.#feeDataFunc = feeDataFunc;
|
||||
}
|
||||
/**
|
||||
* Resolves to the fee data.
|
||||
*/
|
||||
async getFeeData(provider) {
|
||||
return await this.#feeDataFunc(provider);
|
||||
}
|
||||
clone() {
|
||||
return new FeeDataNetworkPlugin(this.#feeDataFunc);
|
||||
}
|
||||
}
|
||||
export class FetchUrlFeeDataNetworkPlugin extends NetworkPlugin {
|
||||
#url;
|
||||
#processFunc;
|
||||
/**
|
||||
* The URL to initialize the FetchRequest with in %%processFunc%%.
|
||||
*/
|
||||
get url() { return this.#url; }
|
||||
/**
|
||||
* The callback to use when computing the FeeData.
|
||||
*/
|
||||
get processFunc() { return this.#processFunc; }
|
||||
/**
|
||||
* Creates a new **FetchUrlFeeDataNetworkPlugin** which will
|
||||
* be used when computing the fee data for the network.
|
||||
*/
|
||||
constructor(url, processFunc) {
|
||||
super("org.ethers.plugins.network.FetchUrlFeeDataPlugin");
|
||||
this.#url = url;
|
||||
this.#processFunc = processFunc;
|
||||
}
|
||||
// We are immutable, so we can serve as our own clone
|
||||
clone() { return this; }
|
||||
}
|
||||
/*
|
||||
export class CustomBlockNetworkPlugin extends NetworkPlugin {
|
||||
readonly #blockFunc: (provider: Provider, block: BlockParams<string>) => Block<string>;
|
||||
readonly #blockWithTxsFunc: (provider: Provider, block: BlockParams<TransactionResponseParams>) => Block<TransactionResponse>;
|
||||
|
||||
constructor(blockFunc: (provider: Provider, block: BlockParams<string>) => Block<string>, blockWithTxsFunc: (provider: Provider, block: BlockParams<TransactionResponseParams>) => Block<TransactionResponse>) {
|
||||
super("org.ethers.network-plugins.custom-block");
|
||||
this.#blockFunc = blockFunc;
|
||||
this.#blockWithTxsFunc = blockWithTxsFunc;
|
||||
}
|
||||
|
||||
async getBlock(provider: Provider, block: BlockParams<string>): Promise<Block<string>> {
|
||||
return await this.#blockFunc(provider, block);
|
||||
}
|
||||
|
||||
async getBlockions(provider: Provider, block: BlockParams<TransactionResponseParams>): Promise<Block<TransactionResponse>> {
|
||||
return await this.#blockWithTxsFunc(provider, block);
|
||||
}
|
||||
|
||||
clone(): CustomBlockNetworkPlugin {
|
||||
return new CustomBlockNetworkPlugin(this.#blockFunc, this.#blockWithTxsFunc);
|
||||
}
|
||||
}
|
||||
*/
|
||||
//# sourceMappingURL=plugins-network.js.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/plugins-network.js.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/plugins-network.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"plugins-network.js","sourceRoot":"","sources":["../../src.ts/providers/plugins-network.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAMnD,MAAM,UAAU,GAAG,4CAA4C,CAAC;AAEhE;;GAEG;AACH,MAAM,OAAO,aAAa;IACtB;;;;;OAKG;IACM,IAAI,CAAU;IAEvB;;OAEG;IACH,YAAY,IAAY;QACpB,gBAAgB,CAAgB,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IACpD,CAAC;IAED;;OAEG;IACH,KAAK;QACD,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;CAKJ;AAsCD;;;GAGG;AACH,MAAM,OAAO,aAAc,SAAQ,aAAa;IAC5C;;;;;OAKG;IACM,cAAc,CAAU;IAEjC;;OAEG;IACM,MAAM,CAAU;IAEzB;;OAEG;IACM,QAAQ,CAAU;IAE3B;;OAEG;IACM,UAAU,CAAU;IAE7B;;OAEG;IACM,aAAa,CAAU;IAEhC;;OAEG;IACM,sBAAsB,CAAU;IAEzC;;OAEG;IACM,mBAAmB,CAAU;IAGtC;;;;OAIG;IACH,YAAY,cAAuB,EAAE,KAAyB;QAC1D,IAAI,cAAc,IAAI,IAAI,EAAE;YAAE,cAAc,GAAG,CAAC,CAAC;SAAE;QACnD,KAAK,CAAC,sCAAuC,CAAC,cAAc,IAAI,CAAC,CAAE,EAAE,CAAC,CAAC;QAEvE,MAAM,KAAK,GAA2B,EAAE,cAAc,EAAE,CAAC;QACzD,SAAS,GAAG,CAAC,IAA6B,EAAE,OAAe;YACvD,IAAI,KAAK,GAAG,CAAC,KAAK,IAAI,EAAG,CAAC,CAAC,IAAI,CAAC,CAAC;YACjC,IAAI,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ACJ;AAED;;;;;;GAMG;AACH,MAAM,OAAO,oBAAqB,SAAQ,aAAa;IAC1C,YAAY,CAA2C;IAEhE;;OAEG;IACH,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,YAAY,WAAqD;QAC7D,KAAK,CAAC,oCAAoC,CAAC,CAAC;QAC5C,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU,CAAC,QAAkB;QAC/B,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAED,KAAK;QACD,OAAO,IAAI,oBAAoB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACvD,CAAC;CACJ;AAED,MAAM,OAAO,4BAA6B,SAAQ,aAAa;IAClD,IAAI,CAAS;IACb,YAAY,CAAyK;IAE9L;;OAEG;IACH,IAAI,GAAG,KAAa,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAEvC;;OAEG;IACH,IAAI,WAAW,KAA6K,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAEvN;;;OAGG;IACH,YAAY,GAAW,EAAE,WAAmL;QACxM,KAAK,CAAC,kDAAkD,CAAC,CAAC;QAC1D,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IACpC,CAAC;IAED,qDAAqD;IACrD,KAAK,KAAmC,OAAO,IAAI,CAAC,CAAC,CAAC;CACzD;AAED;;;;;;;;;;;;;;;;;;;;;;;EAuBE"}
|
||||
50
dev/env/node_modules/ethers/lib.esm/providers/provider-alchemy.d.ts
generated
vendored
Executable file
50
dev/env/node_modules/ethers/lib.esm/providers/provider-alchemy.d.ts
generated
vendored
Executable file
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* [[link-alchemy]] provides a third-party service for connecting to
|
||||
* various blockchains over JSON-RPC.
|
||||
*
|
||||
* **Supported Networks**
|
||||
*
|
||||
* - Ethereum Mainnet (``mainnet``)
|
||||
* - Goerli Testnet (``goerli``)
|
||||
* - Sepolia Testnet (``sepolia``)
|
||||
* - Arbitrum (``arbitrum``)
|
||||
* - Arbitrum Goerli Testnet (``arbitrum-goerli``)
|
||||
* - Arbitrum Sepolia Testnet (``arbitrum-sepolia``)
|
||||
* - Base (``base``)
|
||||
* - Base Goerlia Testnet (``base-goerli``)
|
||||
* - Base Sepolia Testnet (``base-sepolia``)
|
||||
* - Optimism (``optimism``)
|
||||
* - Optimism Goerli Testnet (``optimism-goerli``)
|
||||
* - Optimism Sepolia Testnet (``optimism-sepolia``)
|
||||
* - Polygon (``matic``)
|
||||
* - Polygon Amoy Testnet (``matic-amoy``)
|
||||
* - Polygon Mumbai Testnet (``matic-mumbai``)
|
||||
*
|
||||
* @_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;
|
||||
}
|
||||
//# sourceMappingURL=provider-alchemy.d.ts.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/provider-alchemy.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/provider-alchemy.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"provider-alchemy.d.ts","sourceRoot":"","sources":["../../src.ts/providers/provider-alchemy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAEH,YAAY,EACf,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AA2C/C;;;;;;;;;;GAUG;AACH,qBAAa,eAAgB,SAAQ,eAAgB,YAAW,oBAAoB;IAChF,QAAQ,CAAC,MAAM,EAAG,MAAM,CAAC;gBAEb,QAAQ,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,IAAI,GAAG,MAAM;IAWzD,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB;IAOzC,QAAQ,CAAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC;IAmCvD,mBAAmB,IAAI,OAAO;IAI9B,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,YAAY;CAerE"}
|
||||
147
dev/env/node_modules/ethers/lib.esm/providers/provider-alchemy.js
generated
vendored
Executable file
147
dev/env/node_modules/ethers/lib.esm/providers/provider-alchemy.js
generated
vendored
Executable file
@@ -0,0 +1,147 @@
|
||||
/**
|
||||
* [[link-alchemy]] provides a third-party service for connecting to
|
||||
* various blockchains over JSON-RPC.
|
||||
*
|
||||
* **Supported Networks**
|
||||
*
|
||||
* - Ethereum Mainnet (``mainnet``)
|
||||
* - Goerli Testnet (``goerli``)
|
||||
* - Sepolia Testnet (``sepolia``)
|
||||
* - Arbitrum (``arbitrum``)
|
||||
* - Arbitrum Goerli Testnet (``arbitrum-goerli``)
|
||||
* - Arbitrum Sepolia Testnet (``arbitrum-sepolia``)
|
||||
* - Base (``base``)
|
||||
* - Base Goerlia Testnet (``base-goerli``)
|
||||
* - Base Sepolia Testnet (``base-sepolia``)
|
||||
* - Optimism (``optimism``)
|
||||
* - Optimism Goerli Testnet (``optimism-goerli``)
|
||||
* - Optimism Sepolia Testnet (``optimism-sepolia``)
|
||||
* - Polygon (``matic``)
|
||||
* - Polygon Amoy Testnet (``matic-amoy``)
|
||||
* - Polygon Mumbai Testnet (``matic-mumbai``)
|
||||
*
|
||||
* @_subsection: api/providers/thirdparty:Alchemy [providers-alchemy]
|
||||
*/
|
||||
import { defineProperties, resolveProperties, assert, assertArgument, FetchRequest } from "../utils/index.js";
|
||||
import { showThrottleMessage } from "./community.js";
|
||||
import { Network } from "./network.js";
|
||||
import { JsonRpcProvider } from "./provider-jsonrpc.js";
|
||||
const defaultApiKey = "_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC";
|
||||
function getHost(name) {
|
||||
switch (name) {
|
||||
case "mainnet":
|
||||
return "eth-mainnet.g.alchemy.com";
|
||||
case "goerli":
|
||||
return "eth-goerli.g.alchemy.com";
|
||||
case "sepolia":
|
||||
return "eth-sepolia.g.alchemy.com";
|
||||
case "arbitrum":
|
||||
return "arb-mainnet.g.alchemy.com";
|
||||
case "arbitrum-goerli":
|
||||
return "arb-goerli.g.alchemy.com";
|
||||
case "arbitrum-sepolia":
|
||||
return "arb-sepolia.g.alchemy.com";
|
||||
case "base":
|
||||
return "base-mainnet.g.alchemy.com";
|
||||
case "base-goerli":
|
||||
return "base-goerli.g.alchemy.com";
|
||||
case "base-sepolia":
|
||||
return "base-sepolia.g.alchemy.com";
|
||||
case "matic":
|
||||
return "polygon-mainnet.g.alchemy.com";
|
||||
case "matic-amoy":
|
||||
return "polygon-amoy.g.alchemy.com";
|
||||
case "matic-mumbai":
|
||||
return "polygon-mumbai.g.alchemy.com";
|
||||
case "optimism":
|
||||
return "opt-mainnet.g.alchemy.com";
|
||||
case "optimism-goerli":
|
||||
return "opt-goerli.g.alchemy.com";
|
||||
case "optimism-sepolia":
|
||||
return "opt-sepolia.g.alchemy.com";
|
||||
}
|
||||
assertArgument(false, "unsupported network", "network", name);
|
||||
}
|
||||
/**
|
||||
* 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 class AlchemyProvider extends JsonRpcProvider {
|
||||
apiKey;
|
||||
constructor(_network, apiKey) {
|
||||
if (_network == null) {
|
||||
_network = "mainnet";
|
||||
}
|
||||
const network = Network.from(_network);
|
||||
if (apiKey == null) {
|
||||
apiKey = defaultApiKey;
|
||||
}
|
||||
const request = AlchemyProvider.getRequest(network, apiKey);
|
||||
super(request, network, { staticNetwork: network });
|
||||
defineProperties(this, { apiKey });
|
||||
}
|
||||
_getProvider(chainId) {
|
||||
try {
|
||||
return new AlchemyProvider(chainId, this.apiKey);
|
||||
}
|
||||
catch (error) { }
|
||||
return super._getProvider(chainId);
|
||||
}
|
||||
async _perform(req) {
|
||||
// https://docs.alchemy.com/reference/trace-transaction
|
||||
if (req.method === "getTransactionResult") {
|
||||
const { trace, tx } = await resolveProperties({
|
||||
trace: this.send("trace_transaction", [req.hash]),
|
||||
tx: this.getTransaction(req.hash)
|
||||
});
|
||||
if (trace == null || tx == null) {
|
||||
return null;
|
||||
}
|
||||
let data;
|
||||
let error = false;
|
||||
try {
|
||||
data = trace[0].result.output;
|
||||
error = (trace[0].error === "Reverted");
|
||||
}
|
||||
catch (error) { }
|
||||
if (data) {
|
||||
assert(!error, "an error occurred during transaction executions", "CALL_EXCEPTION", {
|
||||
action: "getTransactionResult",
|
||||
data,
|
||||
reason: null,
|
||||
transaction: tx,
|
||||
invocation: null,
|
||||
revert: null // @TODO
|
||||
});
|
||||
return data;
|
||||
}
|
||||
assert(false, "could not parse trace result", "BAD_DATA", { value: trace });
|
||||
}
|
||||
return await super._perform(req);
|
||||
}
|
||||
isCommunityResource() {
|
||||
return (this.apiKey === defaultApiKey);
|
||||
}
|
||||
static getRequest(network, apiKey) {
|
||||
if (apiKey == null) {
|
||||
apiKey = defaultApiKey;
|
||||
}
|
||||
const request = new FetchRequest(`https:/\/${getHost(network.name)}/v2/${apiKey}`);
|
||||
request.allowGzip = true;
|
||||
if (apiKey === defaultApiKey) {
|
||||
request.retryFunc = async (request, response, attempt) => {
|
||||
showThrottleMessage("alchemy");
|
||||
return true;
|
||||
};
|
||||
}
|
||||
return request;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=provider-alchemy.js.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/provider-alchemy.js.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/provider-alchemy.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"provider-alchemy.js","sourceRoot":"","sources":["../../src.ts/providers/provider-alchemy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EACH,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,EAAE,cAAc,EAC3D,YAAY,EACf,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD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gBACN,MAAM,CAAC,CAAC,KAAK,EAAE,iDAAiD,EAAE,gBAAgB,EAAE;oBAChF,MAAM,EAAE,sBAAsB;oBAC9B,IAAI;oBACJ,MAAM,EAAE,IAAI;oBACZ,WAAW,EAAE,EAAE;oBACf,UAAU,EAAE,IAAI;oBAChB,MAAM,EAAE,IAAI,CAAC,QAAQ;iBACxB,CAAC,CAAC;gBACH,OAAO,IAAI,CAAC;aACf;YAED,MAAM,CAAC,KAAK,EAAE,8BAA8B,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;SAC/E;QAED,OAAO,MAAM,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;IAED,mBAAmB;QACf,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,aAAa,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,OAAgB,EAAE,MAAe;QAC/C,IAAI,MAAM,IAAI,IAAI,EAAE;YAAE,MAAM,GAAG,aAAa,CAAC;SAAE;QAE/C,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,YAAa,OAAO,CAAC,OAAO,CAAC,IAAI,CAAE,OAAQ,MAAO,EAAE,CAAC,CAAC;QACvF,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;QAEzB,IAAI,MAAM,KAAK,aAAa,EAAE;YAC1B,OAAO,CAAC,SAAS,GAAG,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE;gBACrD,mBAAmB,CAAC,SAAS,CAAC,CAAC;gBAC/B,OAAO,IAAI,CAAC;YAChB,CAAC,CAAA;SACJ;QAED,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ"}
|
||||
63
dev/env/node_modules/ethers/lib.esm/providers/provider-ankr.d.ts
generated
vendored
Executable file
63
dev/env/node_modules/ethers/lib.esm/providers/provider-ankr.d.ts
generated
vendored
Executable file
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* [[link-ankr]] provides a third-party service for connecting to
|
||||
* various blockchains over JSON-RPC.
|
||||
*
|
||||
* **Supported Networks**
|
||||
*
|
||||
* - Ethereum Mainnet (``mainnet``)
|
||||
* - Goerli Testnet (``goerli``)
|
||||
* - Sepolia Testnet (``sepolia``)
|
||||
* - Arbitrum (``arbitrum``)
|
||||
* - Base (``base``)
|
||||
* - Base Goerlia Testnet (``base-goerli``)
|
||||
* - Base Sepolia Testnet (``base-sepolia``)
|
||||
* - BNB (``bnb``)
|
||||
* - BNB Testnet (``bnbt``)
|
||||
* - Filecoin (``filecoin``)
|
||||
* - Filecoin Calibration Testnet (``filecoin-calibration``)
|
||||
* - Optimism (``optimism``)
|
||||
* - Optimism Goerli Testnet (``optimism-goerli``)
|
||||
* - Optimism Sepolia Testnet (``optimism-sepolia``)
|
||||
* - Polygon (``matic``)
|
||||
* - Polygon Mumbai Testnet (``matic-mumbai``)
|
||||
*
|
||||
* @_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;
|
||||
}
|
||||
//# sourceMappingURL=provider-ankr.d.ts.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/provider-ankr.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/provider-ankr.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"provider-ankr.d.ts","sourceRoot":"","sources":["../../src.ts/providers/provider-ankr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EACe,YAAY,EACjC,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AA8C1E;;;;;;;;GAQG;AACH,qBAAa,YAAa,SAAQ,eAAgB,YAAW,oBAAoB;IAE7E;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAG,MAAM,CAAC;IAEzB;;;;;OAKG;gBACS,QAAQ,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,IAAI,GAAG,MAAM;IAczD,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB;IAO/C;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,YAAY;IAgBzE,WAAW,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,YAAY,GAAG,KAAK;IAUhE,mBAAmB,IAAI,OAAO;CAGjC"}
|
||||
139
dev/env/node_modules/ethers/lib.esm/providers/provider-ankr.js
generated
vendored
Executable file
139
dev/env/node_modules/ethers/lib.esm/providers/provider-ankr.js
generated
vendored
Executable file
@@ -0,0 +1,139 @@
|
||||
/**
|
||||
* [[link-ankr]] provides a third-party service for connecting to
|
||||
* various blockchains over JSON-RPC.
|
||||
*
|
||||
* **Supported Networks**
|
||||
*
|
||||
* - Ethereum Mainnet (``mainnet``)
|
||||
* - Goerli Testnet (``goerli``)
|
||||
* - Sepolia Testnet (``sepolia``)
|
||||
* - Arbitrum (``arbitrum``)
|
||||
* - Base (``base``)
|
||||
* - Base Goerlia Testnet (``base-goerli``)
|
||||
* - Base Sepolia Testnet (``base-sepolia``)
|
||||
* - BNB (``bnb``)
|
||||
* - BNB Testnet (``bnbt``)
|
||||
* - Filecoin (``filecoin``)
|
||||
* - Filecoin Calibration Testnet (``filecoin-calibration``)
|
||||
* - Optimism (``optimism``)
|
||||
* - Optimism Goerli Testnet (``optimism-goerli``)
|
||||
* - Optimism Sepolia Testnet (``optimism-sepolia``)
|
||||
* - Polygon (``matic``)
|
||||
* - Polygon Mumbai Testnet (``matic-mumbai``)
|
||||
*
|
||||
* @_subsection: api/providers/thirdparty:Ankr [providers-ankr]
|
||||
*/
|
||||
import { defineProperties, FetchRequest, assertArgument } from "../utils/index.js";
|
||||
import { showThrottleMessage } from "./community.js";
|
||||
import { Network } from "./network.js";
|
||||
import { JsonRpcProvider } from "./provider-jsonrpc.js";
|
||||
const defaultApiKey = "9f7d929b018cdffb338517efa06f58359e86ff1ffd350bc889738523659e7972";
|
||||
function getHost(name) {
|
||||
switch (name) {
|
||||
case "mainnet":
|
||||
return "rpc.ankr.com/eth";
|
||||
case "goerli":
|
||||
return "rpc.ankr.com/eth_goerli";
|
||||
case "sepolia":
|
||||
return "rpc.ankr.com/eth_sepolia";
|
||||
case "arbitrum":
|
||||
return "rpc.ankr.com/arbitrum";
|
||||
case "base":
|
||||
return "rpc.ankr.com/base";
|
||||
case "base-goerli":
|
||||
return "rpc.ankr.com/base_goerli";
|
||||
case "base-sepolia":
|
||||
return "rpc.ankr.com/base_sepolia";
|
||||
case "bnb":
|
||||
return "rpc.ankr.com/bsc";
|
||||
case "bnbt":
|
||||
return "rpc.ankr.com/bsc_testnet_chapel";
|
||||
case "filecoin":
|
||||
return "rpc.ankr.com/filecoin";
|
||||
case "filecoin-calibration":
|
||||
return "rpc.ankr.com/filecoin_testnet";
|
||||
case "matic":
|
||||
return "rpc.ankr.com/polygon";
|
||||
case "matic-mumbai":
|
||||
return "rpc.ankr.com/polygon_mumbai";
|
||||
case "optimism":
|
||||
return "rpc.ankr.com/optimism";
|
||||
case "optimism-goerli":
|
||||
return "rpc.ankr.com/optimism_testnet";
|
||||
case "optimism-sepolia":
|
||||
return "rpc.ankr.com/optimism_sepolia";
|
||||
}
|
||||
assertArgument(false, "unsupported network", "network", name);
|
||||
}
|
||||
/**
|
||||
* 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 class AnkrProvider extends JsonRpcProvider {
|
||||
/**
|
||||
* The API key for the Ankr connection.
|
||||
*/
|
||||
apiKey;
|
||||
/**
|
||||
* Create a new **AnkrProvider**.
|
||||
*
|
||||
* By default connecting to ``mainnet`` with a highly throttled
|
||||
* API key.
|
||||
*/
|
||||
constructor(_network, apiKey) {
|
||||
if (_network == null) {
|
||||
_network = "mainnet";
|
||||
}
|
||||
const network = Network.from(_network);
|
||||
if (apiKey == null) {
|
||||
apiKey = defaultApiKey;
|
||||
}
|
||||
// Ankr does not support filterId, so we force polling
|
||||
const options = { polling: true, staticNetwork: network };
|
||||
const request = AnkrProvider.getRequest(network, apiKey);
|
||||
super(request, network, options);
|
||||
defineProperties(this, { apiKey });
|
||||
}
|
||||
_getProvider(chainId) {
|
||||
try {
|
||||
return new AnkrProvider(chainId, this.apiKey);
|
||||
}
|
||||
catch (error) { }
|
||||
return super._getProvider(chainId);
|
||||
}
|
||||
/**
|
||||
* Returns a prepared request for connecting to %%network%% with
|
||||
* %%apiKey%%.
|
||||
*/
|
||||
static getRequest(network, apiKey) {
|
||||
if (apiKey == null) {
|
||||
apiKey = defaultApiKey;
|
||||
}
|
||||
const request = new FetchRequest(`https:/\/${getHost(network.name)}/${apiKey}`);
|
||||
request.allowGzip = true;
|
||||
if (apiKey === defaultApiKey) {
|
||||
request.retryFunc = async (request, response, attempt) => {
|
||||
showThrottleMessage("AnkrProvider");
|
||||
return true;
|
||||
};
|
||||
}
|
||||
return request;
|
||||
}
|
||||
getRpcError(payload, error) {
|
||||
if (payload.method === "eth_sendRawTransaction") {
|
||||
if (error && error.error && error.error.message === "INTERNAL_ERROR: could not replace existing tx") {
|
||||
error.error.message = "replacement transaction underpriced";
|
||||
}
|
||||
}
|
||||
return super.getRpcError(payload, error);
|
||||
}
|
||||
isCommunityResource() {
|
||||
return (this.apiKey === defaultApiKey);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=provider-ankr.js.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/provider-ankr.js.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/provider-ankr.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"provider-ankr.js","sourceRoot":"","sources":["../../src.ts/providers/provider-ankr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;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,CAAC,CAAC;gBACpC,OAAO,IAAI,CAAC;YAChB,CAAC,CAAC;SACL;QAED,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,WAAW,CAAC,OAAuB,EAAE,KAAmB;QACpD,IAAI,OAAO,CAAC,MAAM,KAAK,wBAAwB,EAAE;YAC7C,IAAI,KAAK,IAAI,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,KAAK,+CAA+C,EAAE;gBACjG,KAAK,CAAC,KAAK,CAAC,OAAO,GAAG,qCAAqC,CAAC;aAC/D;SACJ;QAED,OAAO,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC7C,CAAC;IAED,mBAAmB;QACf,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,aAAa,CAAC,CAAC;IAC3C,CAAC;CACJ"}
|
||||
59
dev/env/node_modules/ethers/lib.esm/providers/provider-blockscout.d.ts
generated
vendored
Executable file
59
dev/env/node_modules/ethers/lib.esm/providers/provider-blockscout.d.ts
generated
vendored
Executable file
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* [[link-blockscout]] provides a third-party service for connecting to
|
||||
* various blockchains over JSON-RPC.
|
||||
*
|
||||
* **Supported Networks**
|
||||
*
|
||||
* - Ethereum Mainnet (``mainnet``)
|
||||
* - Sepolia Testnet (``sepolia``)
|
||||
* - Holesky Testnet (``holesky``)
|
||||
* - Ethereum Classic (``classic``)
|
||||
* - Arbitrum (``arbitrum``)
|
||||
* - Base (``base``)
|
||||
* - Base Sepolia Testnet (``base-sepolia``)
|
||||
* - Gnosis (``xdai``)
|
||||
* - Optimism (``optimism``)
|
||||
* - Optimism Sepolia Testnet (``optimism-sepolia``)
|
||||
* - Polygon (``matic``)
|
||||
*
|
||||
* @_subsection: api/providers/thirdparty:Blockscout [providers-blockscout]
|
||||
*/
|
||||
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";
|
||||
import type { JsonRpcPayload, JsonRpcError } from "./provider-jsonrpc.js";
|
||||
/**
|
||||
* The **BlockscoutProvider** connects to the [[link-blockscout]]
|
||||
* 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-blockscout).
|
||||
*/
|
||||
export declare class BlockscoutProvider extends JsonRpcProvider implements CommunityResourcable {
|
||||
/**
|
||||
* The API key.
|
||||
*/
|
||||
readonly apiKey: null | string;
|
||||
/**
|
||||
* Creates a new **BlockscoutProvider**.
|
||||
*/
|
||||
constructor(_network?: Networkish, apiKey?: null | string);
|
||||
_getProvider(chainId: number): AbstractProvider;
|
||||
isCommunityResource(): boolean;
|
||||
getRpcRequest(req: PerformActionRequest): null | {
|
||||
method: string;
|
||||
args: Array<any>;
|
||||
};
|
||||
getRpcError(payload: JsonRpcPayload, _error: JsonRpcError): Error;
|
||||
/**
|
||||
* Returns a prepared request for connecting to %%network%%
|
||||
* with %%apiKey%%.
|
||||
*/
|
||||
static getRequest(network: Network): FetchRequest;
|
||||
}
|
||||
//# sourceMappingURL=provider-blockscout.d.ts.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/provider-blockscout.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/provider-blockscout.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"provider-blockscout.d.ts","sourceRoot":"","sources":["../../src.ts/providers/provider-blockscout.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAC+B,YAAY,EACjD,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAuC1E;;;;;;;;GAQG;AACH,qBAAa,kBAAmB,SAAQ,eAAgB,YAAW,oBAAoB;IACnF;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAG,IAAI,GAAG,MAAM,CAAC;IAEhC;;OAEG;gBACS,QAAQ,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,IAAI,GAAG,MAAM;IAYzD,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB;IAO/C,mBAAmB,IAAI,OAAO;IAI9B,aAAa,CAAC,GAAG,EAAE,oBAAoB,GAAG,IAAI,GAAG;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;KAAE;IAUrF,WAAW,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,GAAG,KAAK;IAoCjE;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY;CAKpD"}
|
||||
141
dev/env/node_modules/ethers/lib.esm/providers/provider-blockscout.js
generated
vendored
Executable file
141
dev/env/node_modules/ethers/lib.esm/providers/provider-blockscout.js
generated
vendored
Executable file
@@ -0,0 +1,141 @@
|
||||
/**
|
||||
* [[link-blockscout]] provides a third-party service for connecting to
|
||||
* various blockchains over JSON-RPC.
|
||||
*
|
||||
* **Supported Networks**
|
||||
*
|
||||
* - Ethereum Mainnet (``mainnet``)
|
||||
* - Sepolia Testnet (``sepolia``)
|
||||
* - Holesky Testnet (``holesky``)
|
||||
* - Ethereum Classic (``classic``)
|
||||
* - Arbitrum (``arbitrum``)
|
||||
* - Base (``base``)
|
||||
* - Base Sepolia Testnet (``base-sepolia``)
|
||||
* - Gnosis (``xdai``)
|
||||
* - Optimism (``optimism``)
|
||||
* - Optimism Sepolia Testnet (``optimism-sepolia``)
|
||||
* - Polygon (``matic``)
|
||||
*
|
||||
* @_subsection: api/providers/thirdparty:Blockscout [providers-blockscout]
|
||||
*/
|
||||
import { assertArgument, defineProperties, FetchRequest, isHexString } from "../utils/index.js";
|
||||
import { Network } from "./network.js";
|
||||
import { JsonRpcProvider } from "./provider-jsonrpc.js";
|
||||
function getUrl(name) {
|
||||
switch (name) {
|
||||
case "mainnet":
|
||||
return "https:/\/eth.blockscout.com/api/eth-rpc";
|
||||
case "sepolia":
|
||||
return "https:/\/eth-sepolia.blockscout.com/api/eth-rpc";
|
||||
case "holesky":
|
||||
return "https:/\/eth-holesky.blockscout.com/api/eth-rpc";
|
||||
case "classic":
|
||||
return "https:/\/etc.blockscout.com/api/eth-rpc";
|
||||
case "arbitrum":
|
||||
return "https:/\/arbitrum.blockscout.com/api/eth-rpc";
|
||||
case "base":
|
||||
return "https:/\/base.blockscout.com/api/eth-rpc";
|
||||
case "base-sepolia":
|
||||
return "https:/\/base-sepolia.blockscout.com/api/eth-rpc";
|
||||
case "matic":
|
||||
return "https:/\/polygon.blockscout.com/api/eth-rpc";
|
||||
case "optimism":
|
||||
return "https:/\/optimism.blockscout.com/api/eth-rpc";
|
||||
case "optimism-sepolia":
|
||||
return "https:/\/optimism-sepolia.blockscout.com/api/eth-rpc";
|
||||
case "xdai":
|
||||
return "https:/\/gnosis.blockscout.com/api/eth-rpc";
|
||||
}
|
||||
assertArgument(false, "unsupported network", "network", name);
|
||||
}
|
||||
/**
|
||||
* The **BlockscoutProvider** connects to the [[link-blockscout]]
|
||||
* 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-blockscout).
|
||||
*/
|
||||
export class BlockscoutProvider extends JsonRpcProvider {
|
||||
/**
|
||||
* The API key.
|
||||
*/
|
||||
apiKey;
|
||||
/**
|
||||
* Creates a new **BlockscoutProvider**.
|
||||
*/
|
||||
constructor(_network, apiKey) {
|
||||
if (_network == null) {
|
||||
_network = "mainnet";
|
||||
}
|
||||
const network = Network.from(_network);
|
||||
if (apiKey == null) {
|
||||
apiKey = null;
|
||||
}
|
||||
const request = BlockscoutProvider.getRequest(network);
|
||||
super(request, network, { staticNetwork: network });
|
||||
defineProperties(this, { apiKey });
|
||||
}
|
||||
_getProvider(chainId) {
|
||||
try {
|
||||
return new BlockscoutProvider(chainId, this.apiKey);
|
||||
}
|
||||
catch (error) { }
|
||||
return super._getProvider(chainId);
|
||||
}
|
||||
isCommunityResource() {
|
||||
return (this.apiKey === null);
|
||||
}
|
||||
getRpcRequest(req) {
|
||||
// Blockscout enforces the TAG argument for estimateGas
|
||||
const resp = super.getRpcRequest(req);
|
||||
if (resp && resp.method === "eth_estimateGas" && resp.args.length == 1) {
|
||||
resp.args = resp.args.slice();
|
||||
resp.args.push("latest");
|
||||
}
|
||||
return resp;
|
||||
}
|
||||
getRpcError(payload, _error) {
|
||||
const error = _error ? _error.error : null;
|
||||
// Blockscout currently drops the VM result and replaces it with a
|
||||
// human-readable string, so we need to make it machine-readable.
|
||||
if (error && error.code === -32015 && !isHexString(error.data || "", true)) {
|
||||
const panicCodes = {
|
||||
"assert(false)": "01",
|
||||
"arithmetic underflow or overflow": "11",
|
||||
"division or modulo by zero": "12",
|
||||
"out-of-bounds array access; popping on an empty array": "31",
|
||||
"out-of-bounds access of an array or bytesN": "32"
|
||||
};
|
||||
let panicCode = "";
|
||||
if (error.message === "VM execution error.") {
|
||||
// eth_call passes this message
|
||||
panicCode = panicCodes[error.data] || "";
|
||||
}
|
||||
else if (panicCodes[error.message || ""]) {
|
||||
panicCode = panicCodes[error.message || ""];
|
||||
}
|
||||
if (panicCode) {
|
||||
error.message += ` (reverted: ${error.data})`;
|
||||
error.data = "0x4e487b7100000000000000000000000000000000000000000000000000000000000000" + panicCode;
|
||||
}
|
||||
}
|
||||
else if (error && error.code === -32000) {
|
||||
if (error.message === "wrong transaction nonce") {
|
||||
error.message += " (nonce too low)";
|
||||
}
|
||||
}
|
||||
return super.getRpcError(payload, _error);
|
||||
}
|
||||
/**
|
||||
* Returns a prepared request for connecting to %%network%%
|
||||
* with %%apiKey%%.
|
||||
*/
|
||||
static getRequest(network) {
|
||||
const request = new FetchRequest(getUrl(network.name));
|
||||
request.allowGzip = true;
|
||||
return request;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=provider-blockscout.js.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/provider-blockscout.js.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/provider-blockscout.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"provider-blockscout.js","sourceRoot":"","sources":["../../src.ts/providers/provider-blockscout.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EACH,cAAc,EAAE,gBAAgB,EAAE,YAAY,EAAE,WAAW,EAC9D,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAQxD,SAAS,MAAM,CAAC,IAAY;IACxB,QAAO,IAAI,EAAE;QACT,KAAK,SAAS;YACV,OAAO,yCAAyC,CAAC;QACrD,KAAK,SAAS;YACV,OAAO,iDAAiD,CAAC;QAC7D,KAAK,SAAS;YACV,OAAO,iDAAiD,CAAC;QAE7D,KAAK,SAAS;YACV,OAAO,yCAAyC,CAAC;QAErD,KAAK,UAAU;YACX,OAAO,8CAA8C,CAAC;QAE1D,KAAK,MAAM;YAC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O,IAAI,eAAgB,KAAK,CAAC,IAAK,GAAG,CAAC;gBAChD,KAAK,CAAC,IAAI,GAAG,0EAA0E,GAAG,SAAS,CAAC;aACvG;SAEJ;aAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,EAAE;YACvC,IAAI,KAAK,CAAC,OAAO,KAAK,yBAAyB,EAAE;gBAC7C,KAAK,CAAC,OAAO,IAAI,kBAAkB,CAAC;aACvC;SACJ;QAED,OAAO,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC9C,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,OAAgB;QAC9B,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACvD,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;QACzB,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ"}
|
||||
108
dev/env/node_modules/ethers/lib.esm/providers/provider-browser.d.ts
generated
vendored
Executable file
108
dev/env/node_modules/ethers/lib.esm/providers/provider-browser.d.ts
generated
vendored
Executable file
@@ -0,0 +1,108 @@
|
||||
import { JsonRpcApiPollingProvider } from "./provider-jsonrpc.js";
|
||||
import type { JsonRpcError, JsonRpcPayload, JsonRpcResult, JsonRpcSigner } from "./provider-jsonrpc.js";
|
||||
import type { Network, Networkish } from "./network.js";
|
||||
/**
|
||||
* The interface to an [[link-eip-1193]] provider, which is a standard
|
||||
* used by most injected providers, which the [[BrowserProvider]] accepts
|
||||
* and exposes the API of.
|
||||
*/
|
||||
export interface Eip1193Provider {
|
||||
/**
|
||||
* See [[link-eip-1193]] for details on this method.
|
||||
*/
|
||||
request(request: {
|
||||
method: string;
|
||||
params?: Array<any> | Record<string, any>;
|
||||
}): Promise<any>;
|
||||
}
|
||||
/**
|
||||
* The possible additional events dispatched when using the ``"debug"``
|
||||
* event on a [[BrowserProvider]].
|
||||
*/
|
||||
export type DebugEventBrowserProvider = {
|
||||
action: "sendEip1193Payload";
|
||||
payload: {
|
||||
method: string;
|
||||
params: Array<any>;
|
||||
};
|
||||
} | {
|
||||
action: "receiveEip1193Result";
|
||||
result: any;
|
||||
} | {
|
||||
action: "receiveEip1193Error";
|
||||
error: Error;
|
||||
};
|
||||
/**
|
||||
* Provider info provided by the [[link-eip-6963]] discovery mechanism.
|
||||
*/
|
||||
export interface Eip6963ProviderInfo {
|
||||
uuid: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
rdns: string;
|
||||
}
|
||||
export type BrowserProviderOptions = {
|
||||
polling?: boolean;
|
||||
staticNetwork?: null | boolean | Network;
|
||||
cacheTimeout?: number;
|
||||
pollingInterval?: number;
|
||||
providerInfo?: Eip6963ProviderInfo;
|
||||
};
|
||||
/**
|
||||
* Specifies how [[link-eip-6963]] discovery should proceed.
|
||||
*
|
||||
* See: [[BrowserProvider-discover]]
|
||||
*/
|
||||
export interface BrowserDiscoverOptions {
|
||||
/**
|
||||
* Override provider detection with this provider.
|
||||
*/
|
||||
provider?: Eip1193Provider;
|
||||
/**
|
||||
* Duration to wait to detect providers. (default: 300ms)
|
||||
*/
|
||||
timeout?: number;
|
||||
/**
|
||||
* Return the first detected provider. Otherwise wait for %%timeout%%
|
||||
* and allowing filtering before selecting the desired provider.
|
||||
*/
|
||||
anyProvider?: boolean;
|
||||
/**
|
||||
* Use the provided window context. Useful in non-standard
|
||||
* environments or to hijack where a provider comes from.
|
||||
*/
|
||||
window?: any;
|
||||
/**
|
||||
* Explicitly choose which provider to used once scanning is complete.
|
||||
*/
|
||||
filter?: (found: Array<Eip6963ProviderInfo>) => null | BrowserProvider | Eip6963ProviderInfo;
|
||||
}
|
||||
/**
|
||||
* A **BrowserProvider** is intended to wrap an injected provider which
|
||||
* adheres to the [[link-eip-1193]] standard, which most (if not all)
|
||||
* currently do.
|
||||
*/
|
||||
export declare class BrowserProvider extends JsonRpcApiPollingProvider {
|
||||
#private;
|
||||
/**
|
||||
* Connect to the %%ethereum%% provider, optionally forcing the
|
||||
* %%network%%.
|
||||
*/
|
||||
constructor(ethereum: Eip1193Provider, network?: Networkish, _options?: BrowserProviderOptions);
|
||||
get providerInfo(): null | Eip6963ProviderInfo;
|
||||
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;
|
||||
/**
|
||||
* Resolves to ``true`` if the provider manages the %%address%%.
|
||||
*/
|
||||
hasSigner(address: number | string): Promise<boolean>;
|
||||
getSigner(address?: number | string): Promise<JsonRpcSigner>;
|
||||
/**
|
||||
* Discover and connect to a Provider in the Browser using the
|
||||
* [[link-eip-6963]] discovery mechanism. If no providers are
|
||||
* present, ``null`` is resolved.
|
||||
*/
|
||||
static discover(options?: BrowserDiscoverOptions): Promise<null | BrowserProvider>;
|
||||
}
|
||||
//# sourceMappingURL=provider-browser.d.ts.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/provider-browser.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/provider-browser.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"provider-browser.d.ts","sourceRoot":"","sources":["../../src.ts/providers/provider-browser.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE,OAAO,KAAK,EAER,YAAY,EAAE,cAAc,EAAE,aAAa,EAC3C,aAAa,EAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAExD;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC5B;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,KAAK,CAAC,GA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CACzB;AAGD;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,yBAAyB;;IAK1D;;;OAGG;gBACS,QAAQ,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,sBAAsB;IAkC9F,IAAI,YAAY,IAAI,IAAI,GAAG,mBAAmB,CAE7C;IAEK,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;IAM5E,KAAK,CAAC,OAAO,EAAE,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,aAAa,GAAG,YAAY,CAAC,CAAC;IAc1G,WAAW,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,YAAY,GAAG,KAAK;IAkBhE;;OAEG;IACG,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAYrD,SAAS,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAgBlE;;;;OAIG;WACU,QAAQ,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,GAAG,eAAe,CAAC;CAsG3F"}
|
||||
200
dev/env/node_modules/ethers/lib.esm/providers/provider-browser.js
generated
vendored
Executable file
200
dev/env/node_modules/ethers/lib.esm/providers/provider-browser.js
generated
vendored
Executable file
@@ -0,0 +1,200 @@
|
||||
import { assertArgument, makeError } from "../utils/index.js";
|
||||
import { JsonRpcApiPollingProvider } from "./provider-jsonrpc.js";
|
||||
;
|
||||
/**
|
||||
* A **BrowserProvider** is intended to wrap an injected provider which
|
||||
* adheres to the [[link-eip-1193]] standard, which most (if not all)
|
||||
* currently do.
|
||||
*/
|
||||
export class BrowserProvider extends JsonRpcApiPollingProvider {
|
||||
#request;
|
||||
#providerInfo;
|
||||
/**
|
||||
* Connect to the %%ethereum%% provider, optionally forcing the
|
||||
* %%network%%.
|
||||
*/
|
||||
constructor(ethereum, network, _options) {
|
||||
// Copy the options
|
||||
const options = Object.assign({}, ((_options != null) ? _options : {}), { batchMaxCount: 1 });
|
||||
assertArgument(ethereum && ethereum.request, "invalid EIP-1193 provider", "ethereum", ethereum);
|
||||
super(network, options);
|
||||
this.#providerInfo = null;
|
||||
if (_options && _options.providerInfo) {
|
||||
this.#providerInfo = _options.providerInfo;
|
||||
}
|
||||
this.#request = async (method, params) => {
|
||||
const payload = { method, params };
|
||||
this.emit("debug", { action: "sendEip1193Request", payload });
|
||||
try {
|
||||
const result = await ethereum.request(payload);
|
||||
this.emit("debug", { action: "receiveEip1193Result", result });
|
||||
return result;
|
||||
}
|
||||
catch (e) {
|
||||
const error = new Error(e.message);
|
||||
error.code = e.code;
|
||||
error.data = e.data;
|
||||
error.payload = payload;
|
||||
this.emit("debug", { action: "receiveEip1193Error", error });
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
}
|
||||
get providerInfo() {
|
||||
return this.#providerInfo;
|
||||
}
|
||||
async send(method, params) {
|
||||
await this._start();
|
||||
return await super.send(method, params);
|
||||
}
|
||||
async _send(payload) {
|
||||
assertArgument(!Array.isArray(payload), "EIP-1193 does not support batch request", "payload", payload);
|
||||
try {
|
||||
const result = await this.#request(payload.method, payload.params || []);
|
||||
return [{ id: payload.id, result }];
|
||||
}
|
||||
catch (e) {
|
||||
return [{
|
||||
id: payload.id,
|
||||
error: { code: e.code, data: e.data, message: e.message }
|
||||
}];
|
||||
}
|
||||
}
|
||||
getRpcError(payload, error) {
|
||||
error = JSON.parse(JSON.stringify(error));
|
||||
// EIP-1193 gives us some machine-readable error codes, so rewrite
|
||||
// them into Ethers standard errors.
|
||||
switch (error.error.code || -1) {
|
||||
case 4001:
|
||||
error.error.message = `ethers-user-denied: ${error.error.message}`;
|
||||
break;
|
||||
case 4200:
|
||||
error.error.message = `ethers-unsupported: ${error.error.message}`;
|
||||
break;
|
||||
}
|
||||
return super.getRpcError(payload, error);
|
||||
}
|
||||
/**
|
||||
* Resolves to ``true`` if the provider manages the %%address%%.
|
||||
*/
|
||||
async hasSigner(address) {
|
||||
if (address == null) {
|
||||
address = 0;
|
||||
}
|
||||
const accounts = await this.send("eth_accounts", []);
|
||||
if (typeof (address) === "number") {
|
||||
return (accounts.length > address);
|
||||
}
|
||||
address = address.toLowerCase();
|
||||
return accounts.filter((a) => (a.toLowerCase() === address)).length !== 0;
|
||||
}
|
||||
async getSigner(address) {
|
||||
if (address == null) {
|
||||
address = 0;
|
||||
}
|
||||
if (!(await this.hasSigner(address))) {
|
||||
try {
|
||||
await this.#request("eth_requestAccounts", []);
|
||||
}
|
||||
catch (error) {
|
||||
const payload = error.payload;
|
||||
throw this.getRpcError(payload, { id: payload.id, error });
|
||||
}
|
||||
}
|
||||
return await super.getSigner(address);
|
||||
}
|
||||
/**
|
||||
* Discover and connect to a Provider in the Browser using the
|
||||
* [[link-eip-6963]] discovery mechanism. If no providers are
|
||||
* present, ``null`` is resolved.
|
||||
*/
|
||||
static async discover(options) {
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
if (options.provider) {
|
||||
return new BrowserProvider(options.provider);
|
||||
}
|
||||
const context = options.window ? options.window :
|
||||
(typeof (window) !== "undefined") ? window : null;
|
||||
if (context == null) {
|
||||
return null;
|
||||
}
|
||||
const anyProvider = options.anyProvider;
|
||||
if (anyProvider && context.ethereum) {
|
||||
return new BrowserProvider(context.ethereum);
|
||||
}
|
||||
if (!("addEventListener" in context && "dispatchEvent" in context
|
||||
&& "removeEventListener" in context)) {
|
||||
return null;
|
||||
}
|
||||
const timeout = options.timeout ? options.timeout : 300;
|
||||
if (timeout === 0) {
|
||||
return null;
|
||||
}
|
||||
return await (new Promise((resolve, reject) => {
|
||||
let found = [];
|
||||
const addProvider = (event) => {
|
||||
found.push(event.detail);
|
||||
if (anyProvider) {
|
||||
finalize();
|
||||
}
|
||||
};
|
||||
const finalize = () => {
|
||||
clearTimeout(timer);
|
||||
if (found.length) {
|
||||
// If filtering is provided:
|
||||
if (options && options.filter) {
|
||||
// Call filter, with a copies of found provider infos
|
||||
const filtered = options.filter(found.map(i => Object.assign({}, (i.info))));
|
||||
if (filtered == null) {
|
||||
// No provider selected
|
||||
resolve(null);
|
||||
}
|
||||
else if (filtered instanceof BrowserProvider) {
|
||||
// Custom provider created
|
||||
resolve(filtered);
|
||||
}
|
||||
else {
|
||||
// Find the matching provider
|
||||
let match = null;
|
||||
if (filtered.uuid) {
|
||||
const matches = found.filter(f => (filtered.uuid === f.info.uuid));
|
||||
// @TODO: What should happen if multiple values
|
||||
// for the same UUID?
|
||||
match = matches[0];
|
||||
}
|
||||
if (match) {
|
||||
const { provider, info } = match;
|
||||
resolve(new BrowserProvider(provider, undefined, {
|
||||
providerInfo: info
|
||||
}));
|
||||
}
|
||||
else {
|
||||
reject(makeError("filter returned unknown info", "UNSUPPORTED_OPERATION", {
|
||||
value: filtered
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Pick the first found provider
|
||||
const { provider, info } = found[0];
|
||||
resolve(new BrowserProvider(provider, undefined, {
|
||||
providerInfo: info
|
||||
}));
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Nothing found
|
||||
resolve(null);
|
||||
}
|
||||
context.removeEventListener("eip6963:announceProvider", addProvider);
|
||||
};
|
||||
const timer = setTimeout(() => { finalize(); }, timeout);
|
||||
context.addEventListener("eip6963:announceProvider", addProvider);
|
||||
context.dispatchEvent(new Event("eip6963:requestProvider"));
|
||||
}));
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=provider-browser.js.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/provider-browser.js.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/provider-browser.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
46
dev/env/node_modules/ethers/lib.esm/providers/provider-chainstack.d.ts
generated
vendored
Executable file
46
dev/env/node_modules/ethers/lib.esm/providers/provider-chainstack.d.ts
generated
vendored
Executable file
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* [[link-chainstack]] provides a third-party service for connecting to
|
||||
* various blockchains over JSON-RPC.
|
||||
*
|
||||
* **Supported Networks**
|
||||
*
|
||||
* - Ethereum Mainnet (``mainnet``)
|
||||
* - Arbitrum (``arbitrum``)
|
||||
* - BNB Smart Chain Mainnet (``bnb``)
|
||||
* - Polygon (``matic``)
|
||||
*
|
||||
* @_subsection: api/providers/thirdparty:Chainstack [providers-chainstack]
|
||||
*/
|
||||
import { FetchRequest } from "../utils/index.js";
|
||||
import { Network } from "./network.js";
|
||||
import { JsonRpcProvider } from "./provider-jsonrpc.js";
|
||||
import type { AbstractProvider } from "./abstract-provider.js";
|
||||
import type { CommunityResourcable } from "./community.js";
|
||||
import type { Networkish } from "./network.js";
|
||||
/**
|
||||
* The **ChainstackProvider** connects to the [[link-chainstack]]
|
||||
* 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-chainstack).
|
||||
*/
|
||||
export declare class ChainstackProvider extends JsonRpcProvider implements CommunityResourcable {
|
||||
/**
|
||||
* The API key for the Chainstack connection.
|
||||
*/
|
||||
readonly apiKey: string;
|
||||
/**
|
||||
* Creates a new **ChainstackProvider**.
|
||||
*/
|
||||
constructor(_network?: Networkish, apiKey?: null | string);
|
||||
_getProvider(chainId: number): AbstractProvider;
|
||||
isCommunityResource(): boolean;
|
||||
/**
|
||||
* Returns a prepared request for connecting to %%network%%
|
||||
* with %%apiKey%% and %%projectSecret%%.
|
||||
*/
|
||||
static getRequest(network: Network, apiKey?: null | string): FetchRequest;
|
||||
}
|
||||
//# sourceMappingURL=provider-chainstack.d.ts.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/provider-chainstack.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/provider-chainstack.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"provider-chainstack.d.ts","sourceRoot":"","sources":["../../src.ts/providers/provider-chainstack.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EACe,YAAY,EACjC,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AA6B/C;;;;;;;;GAQG;AACH,qBAAa,kBAAmB,SAAQ,eAAgB,YAAW,oBAAoB;IACnF;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAG,MAAM,CAAC;IAEzB;;OAEG;gBACS,QAAQ,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,IAAI,GAAG,MAAM;IAYzD,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB;IAO/C,mBAAmB,IAAI,OAAO;IAI9B;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,YAAY;CAe5E"}
|
||||
98
dev/env/node_modules/ethers/lib.esm/providers/provider-chainstack.js
generated
vendored
Executable file
98
dev/env/node_modules/ethers/lib.esm/providers/provider-chainstack.js
generated
vendored
Executable file
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
* [[link-chainstack]] provides a third-party service for connecting to
|
||||
* various blockchains over JSON-RPC.
|
||||
*
|
||||
* **Supported Networks**
|
||||
*
|
||||
* - Ethereum Mainnet (``mainnet``)
|
||||
* - Arbitrum (``arbitrum``)
|
||||
* - BNB Smart Chain Mainnet (``bnb``)
|
||||
* - Polygon (``matic``)
|
||||
*
|
||||
* @_subsection: api/providers/thirdparty:Chainstack [providers-chainstack]
|
||||
*/
|
||||
import { defineProperties, FetchRequest, assertArgument } from "../utils/index.js";
|
||||
import { showThrottleMessage } from "./community.js";
|
||||
import { Network } from "./network.js";
|
||||
import { JsonRpcProvider } from "./provider-jsonrpc.js";
|
||||
function getApiKey(name) {
|
||||
switch (name) {
|
||||
case "mainnet": return "39f1d67cedf8b7831010a665328c9197";
|
||||
case "arbitrum": return "0550c209db33c3abf4cc927e1e18cea1";
|
||||
case "bnb": return "98b5a77e531614387366f6fc5da097f8";
|
||||
case "matic": return "cd9d4d70377471aa7c142ec4a4205249";
|
||||
}
|
||||
assertArgument(false, "unsupported network", "network", name);
|
||||
}
|
||||
function getHost(name) {
|
||||
switch (name) {
|
||||
case "mainnet":
|
||||
return "ethereum-mainnet.core.chainstack.com";
|
||||
case "arbitrum":
|
||||
return "arbitrum-mainnet.core.chainstack.com";
|
||||
case "bnb":
|
||||
return "bsc-mainnet.core.chainstack.com";
|
||||
case "matic":
|
||||
return "polygon-mainnet.core.chainstack.com";
|
||||
}
|
||||
assertArgument(false, "unsupported network", "network", name);
|
||||
}
|
||||
/**
|
||||
* The **ChainstackProvider** connects to the [[link-chainstack]]
|
||||
* 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-chainstack).
|
||||
*/
|
||||
export class ChainstackProvider extends JsonRpcProvider {
|
||||
/**
|
||||
* The API key for the Chainstack connection.
|
||||
*/
|
||||
apiKey;
|
||||
/**
|
||||
* Creates a new **ChainstackProvider**.
|
||||
*/
|
||||
constructor(_network, apiKey) {
|
||||
if (_network == null) {
|
||||
_network = "mainnet";
|
||||
}
|
||||
const network = Network.from(_network);
|
||||
if (apiKey == null) {
|
||||
apiKey = getApiKey(network.name);
|
||||
}
|
||||
const request = ChainstackProvider.getRequest(network, apiKey);
|
||||
super(request, network, { staticNetwork: network });
|
||||
defineProperties(this, { apiKey });
|
||||
}
|
||||
_getProvider(chainId) {
|
||||
try {
|
||||
return new ChainstackProvider(chainId, this.apiKey);
|
||||
}
|
||||
catch (error) { }
|
||||
return super._getProvider(chainId);
|
||||
}
|
||||
isCommunityResource() {
|
||||
return (this.apiKey === getApiKey(this._network.name));
|
||||
}
|
||||
/**
|
||||
* Returns a prepared request for connecting to %%network%%
|
||||
* with %%apiKey%% and %%projectSecret%%.
|
||||
*/
|
||||
static getRequest(network, apiKey) {
|
||||
if (apiKey == null) {
|
||||
apiKey = getApiKey(network.name);
|
||||
}
|
||||
const request = new FetchRequest(`https:/\/${getHost(network.name)}/${apiKey}`);
|
||||
request.allowGzip = true;
|
||||
if (apiKey === getApiKey(network.name)) {
|
||||
request.retryFunc = async (request, response, attempt) => {
|
||||
showThrottleMessage("ChainstackProvider");
|
||||
return true;
|
||||
};
|
||||
}
|
||||
return request;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=provider-chainstack.js.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/provider-chainstack.js.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/provider-chainstack.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"provider-chainstack.js","sourceRoot":"","sources":["../../src.ts/providers/provider-chainstack.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EACH,gBAAgB,EAAE,YAAY,EAAE,cAAc,EACjD,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;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B,CAAqB,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,YAAY,CAAC,OAAe;QACxB,IAAI;YACA,OAAO,IAAI,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;SACvD;QAAC,OAAO,KAAK,EAAE,GAAG;QACnB,OAAO,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;IAED,mBAAmB;QACf,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,OAAgB,EAAE,MAAsB;QACtD,IAAI,MAAM,IAAI,IAAI,EAAE;YAAE,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SAAE;QAEzD,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,YAAa,OAAO,CAAC,OAAO,CAAC,IAAI,CAAE,IAAK,MAAO,EAAE,CAAC,CAAC;QACpF,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;QAEzB,IAAI,MAAM,KAAK,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACpC,OAAO,CAAC,SAAS,GAAG,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE;gBACrD,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;gBAC1C,OAAO,IAAI,CAAC;YAChB,CAAC,CAAC;SACL;QAED,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ"}
|
||||
14
dev/env/node_modules/ethers/lib.esm/providers/provider-cloudflare.d.ts
generated
vendored
Executable file
14
dev/env/node_modules/ethers/lib.esm/providers/provider-cloudflare.d.ts
generated
vendored
Executable file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
//# sourceMappingURL=provider-cloudflare.d.ts.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/provider-cloudflare.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/provider-cloudflare.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"provider-cloudflare.d.ts","sourceRoot":"","sources":["../../src.ts/providers/provider-cloudflare.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,eAAe;gBACvC,QAAQ,CAAC,EAAE,UAAU;CAMpC"}
|
||||
22
dev/env/node_modules/ethers/lib.esm/providers/provider-cloudflare.js
generated
vendored
Executable file
22
dev/env/node_modules/ethers/lib.esm/providers/provider-cloudflare.js
generated
vendored
Executable file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* About Cloudflare
|
||||
*
|
||||
* @_subsection: api/providers/thirdparty:Cloudflare [providers-cloudflare]
|
||||
*/
|
||||
import { assertArgument } from "../utils/index.js";
|
||||
import { Network } from "./network.js";
|
||||
import { JsonRpcProvider } from "./provider-jsonrpc.js";
|
||||
/**
|
||||
* About Cloudflare...
|
||||
*/
|
||||
export class CloudflareProvider extends JsonRpcProvider {
|
||||
constructor(_network) {
|
||||
if (_network == null) {
|
||||
_network = "mainnet";
|
||||
}
|
||||
const network = Network.from(_network);
|
||||
assertArgument(network.name === "mainnet", "unsupported network", "network", _network);
|
||||
super("https:/\/cloudflare-eth.com/", network, { staticNetwork: network });
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=provider-cloudflare.js.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/provider-cloudflare.js.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/provider-cloudflare.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"provider-cloudflare.js","sourceRoot":"","sources":["../../src.ts/providers/provider-cloudflare.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAIxD;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,eAAe;IACnD,YAAY,QAAqB;QAC7B,IAAI,QAAQ,IAAI,IAAI,EAAE;YAAE,QAAQ,GAAG,SAAS,CAAC;SAAE;QAC/C,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvC,cAAc,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,qBAAqB,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;QACvF,KAAK,CAAC,8BAA8B,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC,CAAC;IAC/E,CAAC;CACJ"}
|
||||
152
dev/env/node_modules/ethers/lib.esm/providers/provider-etherscan.d.ts
generated
vendored
Executable file
152
dev/env/node_modules/ethers/lib.esm/providers/provider-etherscan.d.ts
generated
vendored
Executable file
@@ -0,0 +1,152 @@
|
||||
/**
|
||||
* [[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``)
|
||||
* - Holesky Testnet (``holesky``)
|
||||
* - Arbitrum (``arbitrum``)
|
||||
* - Arbitrum Goerli Testnet (``arbitrum-goerli``)
|
||||
* - Base (``base``)
|
||||
* - Base Sepolia Testnet (``base-sepolia``)
|
||||
* - BNB Smart Chain Mainnet (``bnb``)
|
||||
* - BNB Smart Chain Testnet (``bnbt``)
|
||||
* - Optimism (``optimism``)
|
||||
* - Optimism Goerli Testnet (``optimism-goerli``)
|
||||
* - Polygon (``matic``)
|
||||
* - Polygon Mumbai Testnet (``matic-mumbai``)
|
||||
* - Polygon Amoy Testnet (``matic-amoy``)
|
||||
*
|
||||
* @_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.
|
||||
*
|
||||
* Deprecated; for Etherscan v2 the base is no longer a simply
|
||||
* host, but instead a URL including a chainId parameter. Changing
|
||||
* this to return a URL prefix could break some libraries, so it
|
||||
* is left intact but will be removed in the future as it is unused.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
//# sourceMappingURL=provider-etherscan.d.ts.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/provider-etherscan.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/provider-etherscan.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"provider-etherscan.d.ts","sourceRoot":"","sources":["../../src.ts/providers/provider-etherscan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAWhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,KAAK,EAAE,kBAAk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,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC;IAIvC;;;;OAIG;IACG,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC;IAsFtF;;OAEG;IACH,uBAAuB,CAAC,WAAW,EAAE,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAoChF;;OAEG;IACH,WAAW,CAAC,GAAG,EAAE,oBAAoB,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,GAAG,KAAK;IAgEvE,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IAIlC,QAAQ,CAAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC;IAsMjD,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAIpC;;;;OAIG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAKtC;;;OAGG;IACG,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,QAAQ,CAAC;IAc7D,mBAAmB,IAAI,OAAO;CAGjC"}
|
||||
598
dev/env/node_modules/ethers/lib.esm/providers/provider-etherscan.js
generated
vendored
Executable file
598
dev/env/node_modules/ethers/lib.esm/providers/provider-etherscan.js
generated
vendored
Executable file
@@ -0,0 +1,598 @@
|
||||
/**
|
||||
* [[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``)
|
||||
* - Holesky Testnet (``holesky``)
|
||||
* - Arbitrum (``arbitrum``)
|
||||
* - Arbitrum Goerli Testnet (``arbitrum-goerli``)
|
||||
* - Base (``base``)
|
||||
* - Base Sepolia Testnet (``base-sepolia``)
|
||||
* - BNB Smart Chain Mainnet (``bnb``)
|
||||
* - BNB Smart Chain Testnet (``bnbt``)
|
||||
* - Optimism (``optimism``)
|
||||
* - Optimism Goerli Testnet (``optimism-goerli``)
|
||||
* - Polygon (``matic``)
|
||||
* - Polygon Mumbai Testnet (``matic-mumbai``)
|
||||
* - Polygon Amoy Testnet (``matic-amoy``)
|
||||
*
|
||||
* @_subsection api/providers/thirdparty:Etherscan [providers-etherscan]
|
||||
*/
|
||||
import { AbiCoder } from "../abi/index.js";
|
||||
import { Contract } from "../contract/index.js";
|
||||
import { accessListify, Transaction } from "../transaction/index.js";
|
||||
import { defineProperties, hexlify, toQuantity, FetchRequest, assert, assertArgument, isError,
|
||||
// parseUnits,
|
||||
toUtf8String } from "../utils/index.js";
|
||||
import { AbstractProvider } from "./abstract-provider.js";
|
||||
import { Network } from "./network.js";
|
||||
import { NetworkPlugin } from "./plugins-network.js";
|
||||
import { showThrottleMessage } from "./community.js";
|
||||
// See: https://docs.etherscan.io/supported-chains
|
||||
const Supported = ("1 11155111 17000 560048 2741 11124 33111 33139 42170 " +
|
||||
"42161 421614 43114 43113 8453 84532 80069 80094 199 1029 81457 " +
|
||||
"168587773 56 97 42220 11142220 252 2523 100 999 737373 747474 " +
|
||||
"59144 59141 5000 5003 43521 143 10143 1287 1284 1285 10 " +
|
||||
"11155420 204 5611 80002 137 534352 534351 1329 1328 146 14601 " +
|
||||
"988 2201 1923 1924 167013 167000 130 1301 480 4801 51 50 324 300").split(/ /g);
|
||||
const THROTTLE = 2000;
|
||||
function isPromise(value) {
|
||||
return (value && typeof (value.then) === "function");
|
||||
}
|
||||
const EtherscanPluginId = "org.ethers.plugins.provider.Etherscan";
|
||||
/**
|
||||
* A Network can include an **EtherscanPlugin** to provide
|
||||
* a custom base URL.
|
||||
*
|
||||
* @_docloc: api/providers/thirdparty:Etherscan
|
||||
*/
|
||||
export class EtherscanPlugin extends NetworkPlugin {
|
||||
/**
|
||||
* The Etherscan API base URL.
|
||||
*/
|
||||
baseUrl;
|
||||
/**
|
||||
* Creates a new **EtherscanProvider** which will use
|
||||
* %%baseUrl%%.
|
||||
*/
|
||||
constructor(baseUrl) {
|
||||
super(EtherscanPluginId);
|
||||
defineProperties(this, { baseUrl });
|
||||
}
|
||||
clone() {
|
||||
return new EtherscanPlugin(this.baseUrl);
|
||||
}
|
||||
}
|
||||
const skipKeys = ["enableCcipRead"];
|
||||
let nextId = 1;
|
||||
/**
|
||||
* 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 class EtherscanProvider extends AbstractProvider {
|
||||
/**
|
||||
* The connected network.
|
||||
*/
|
||||
network;
|
||||
/**
|
||||
* The API key or null if using the community provided bandwidth.
|
||||
*/
|
||||
apiKey;
|
||||
#plugin;
|
||||
/**
|
||||
* Creates a new **EtherscanBaseProvider**.
|
||||
*/
|
||||
constructor(_network, _apiKey) {
|
||||
const apiKey = (_apiKey != null) ? _apiKey : null;
|
||||
super();
|
||||
const network = Network.from(_network);
|
||||
assertArgument(Supported.indexOf(`${network.chainId}`) >= 0, "unsupported network", "network", network);
|
||||
this.#plugin = network.getPlugin(EtherscanPluginId);
|
||||
defineProperties(this, { apiKey, network });
|
||||
}
|
||||
/**
|
||||
* Returns the base URL.
|
||||
*
|
||||
* If an [[EtherscanPlugin]] is configured on the
|
||||
* [[EtherscanBaseProvider_network]], returns the plugin's
|
||||
* baseUrl.
|
||||
*
|
||||
* Deprecated; for Etherscan v2 the base is no longer a simply
|
||||
* host, but instead a URL including a chainId parameter. Changing
|
||||
* this to return a URL prefix could break some libraries, so it
|
||||
* is left intact but will be removed in the future as it is unused.
|
||||
*/
|
||||
getBaseUrl() {
|
||||
if (this.#plugin) {
|
||||
return this.#plugin.baseUrl;
|
||||
}
|
||||
switch (this.network.name) {
|
||||
case "mainnet":
|
||||
return "https:/\/api.etherscan.io";
|
||||
case "goerli":
|
||||
return "https:/\/api-goerli.etherscan.io";
|
||||
case "sepolia":
|
||||
return "https:/\/api-sepolia.etherscan.io";
|
||||
case "holesky":
|
||||
return "https:/\/api-holesky.etherscan.io";
|
||||
case "arbitrum":
|
||||
return "https:/\/api.arbiscan.io";
|
||||
case "arbitrum-goerli":
|
||||
return "https:/\/api-goerli.arbiscan.io";
|
||||
case "base":
|
||||
return "https:/\/api.basescan.org";
|
||||
case "base-sepolia":
|
||||
return "https:/\/api-sepolia.basescan.org";
|
||||
case "bnb":
|
||||
return "https:/\/api.bscscan.com";
|
||||
case "bnbt":
|
||||
return "https:/\/api-testnet.bscscan.com";
|
||||
case "matic":
|
||||
return "https:/\/api.polygonscan.com";
|
||||
case "matic-amoy":
|
||||
return "https:/\/api-amoy.polygonscan.com";
|
||||
case "matic-mumbai":
|
||||
return "https:/\/api-testnet.polygonscan.com";
|
||||
case "optimism":
|
||||
return "https:/\/api-optimistic.etherscan.io";
|
||||
case "optimism-goerli":
|
||||
return "https:/\/api-goerli-optimistic.etherscan.io";
|
||||
default:
|
||||
}
|
||||
assertArgument(false, "unsupported network", "network", this.network);
|
||||
}
|
||||
/**
|
||||
* Returns the URL for the %%module%% and %%params%%.
|
||||
*/
|
||||
getUrl(module, params) {
|
||||
let query = Object.keys(params).reduce((accum, key) => {
|
||||
const value = params[key];
|
||||
if (value != null) {
|
||||
accum += `&${key}=${value}`;
|
||||
}
|
||||
return accum;
|
||||
}, "");
|
||||
if (this.apiKey) {
|
||||
query += `&apikey=${this.apiKey}`;
|
||||
}
|
||||
return `https:/\/api.etherscan.io/v2/api?chainid=${this.network.chainId}&module=${module}${query}`;
|
||||
}
|
||||
/**
|
||||
* Returns the URL for using POST requests.
|
||||
*/
|
||||
getPostUrl() {
|
||||
return `https:/\/api.etherscan.io/v2/api?chainid=${this.network.chainId}`;
|
||||
}
|
||||
/**
|
||||
* Returns the parameters for using POST requests.
|
||||
*/
|
||||
getPostData(module, params) {
|
||||
params.module = module;
|
||||
params.apikey = this.apiKey;
|
||||
params.chainid = this.network.chainId;
|
||||
return params;
|
||||
}
|
||||
async detectNetwork() {
|
||||
return this.network;
|
||||
}
|
||||
/**
|
||||
* Resolves to the result of calling %%module%% with %%params%%.
|
||||
*
|
||||
* If %%post%%, the request is made as a POST request.
|
||||
*/
|
||||
async fetch(module, params, post) {
|
||||
const id = nextId++;
|
||||
const url = (post ? this.getPostUrl() : this.getUrl(module, params));
|
||||
const payload = (post ? this.getPostData(module, params) : null);
|
||||
this.emit("debug", { action: "sendRequest", id, url, payload: payload });
|
||||
const request = new FetchRequest(url);
|
||||
request.setThrottleParams({ slotInterval: 1000 });
|
||||
request.retryFunc = (req, resp, attempt) => {
|
||||
if (this.isCommunityResource()) {
|
||||
showThrottleMessage("Etherscan");
|
||||
}
|
||||
return Promise.resolve(true);
|
||||
};
|
||||
request.processFunc = async (request, response) => {
|
||||
const result = response.hasBody() ? JSON.parse(toUtf8String(response.body)) : {};
|
||||
const throttle = ((typeof (result.result) === "string") ? result.result : "").toLowerCase().indexOf("rate limit") >= 0;
|
||||
if (module === "proxy") {
|
||||
// This JSON response indicates we are being throttled
|
||||
if (result && result.status == 0 && result.message == "NOTOK" && throttle) {
|
||||
this.emit("debug", { action: "receiveError", id, reason: "proxy-NOTOK", error: result });
|
||||
response.throwThrottleError(result.result, THROTTLE);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (throttle) {
|
||||
this.emit("debug", { action: "receiveError", id, reason: "null result", error: result.result });
|
||||
response.throwThrottleError(result.result, THROTTLE);
|
||||
}
|
||||
}
|
||||
return response;
|
||||
};
|
||||
if (payload) {
|
||||
request.setHeader("content-type", "application/x-www-form-urlencoded; charset=UTF-8");
|
||||
request.body = Object.keys(payload).map((k) => `${k}=${payload[k]}`).join("&");
|
||||
}
|
||||
const response = await request.send();
|
||||
try {
|
||||
response.assertOk();
|
||||
}
|
||||
catch (error) {
|
||||
this.emit("debug", { action: "receiveError", id, error, reason: "assertOk" });
|
||||
assert(false, "response error", "SERVER_ERROR", { request, response });
|
||||
}
|
||||
if (!response.hasBody()) {
|
||||
this.emit("debug", { action: "receiveError", id, error: "missing body", reason: "null body" });
|
||||
assert(false, "missing response", "SERVER_ERROR", { request, response });
|
||||
}
|
||||
const result = JSON.parse(toUtf8String(response.body));
|
||||
if (module === "proxy") {
|
||||
if (result.jsonrpc != "2.0") {
|
||||
this.emit("debug", { action: "receiveError", id, result, reason: "invalid JSON-RPC" });
|
||||
assert(false, "invalid JSON-RPC response (missing jsonrpc='2.0')", "SERVER_ERROR", { request, response, info: { result } });
|
||||
}
|
||||
if (result.error) {
|
||||
this.emit("debug", { action: "receiveError", id, result, reason: "JSON-RPC error" });
|
||||
assert(false, "error response", "SERVER_ERROR", { request, response, info: { result } });
|
||||
}
|
||||
this.emit("debug", { action: "receiveRequest", id, result });
|
||||
return result.result;
|
||||
}
|
||||
else {
|
||||
// getLogs, getHistory have weird success responses
|
||||
if (result.status == 0 && (result.message === "No records found" || result.message === "No transactions found")) {
|
||||
this.emit("debug", { action: "receiveRequest", id, result });
|
||||
return result.result;
|
||||
}
|
||||
if (result.status != 1 || (typeof (result.message) === "string" && !result.message.match(/^OK/))) {
|
||||
this.emit("debug", { action: "receiveError", id, result });
|
||||
assert(false, "error response", "SERVER_ERROR", { request, response, info: { result } });
|
||||
}
|
||||
this.emit("debug", { action: "receiveRequest", id, result });
|
||||
return result.result;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns %%transaction%% normalized for the Etherscan API.
|
||||
*/
|
||||
_getTransactionPostData(transaction) {
|
||||
const result = {};
|
||||
for (let key in transaction) {
|
||||
if (skipKeys.indexOf(key) >= 0) {
|
||||
continue;
|
||||
}
|
||||
if (transaction[key] == null) {
|
||||
continue;
|
||||
}
|
||||
let value = transaction[key];
|
||||
if (key === "type" && value === 0) {
|
||||
continue;
|
||||
}
|
||||
if (key === "blockTag" && value === "latest") {
|
||||
continue;
|
||||
}
|
||||
// Quantity-types require no leading zero, unless 0
|
||||
if ({ type: true, gasLimit: true, gasPrice: true, maxFeePerGs: true, maxPriorityFeePerGas: true, nonce: true, value: true }[key]) {
|
||||
value = toQuantity(value);
|
||||
}
|
||||
else if (key === "accessList") {
|
||||
value = "[" + accessListify(value).map((set) => {
|
||||
return `{address:"${set.address}",storageKeys:["${set.storageKeys.join('","')}"]}`;
|
||||
}).join(",") + "]";
|
||||
}
|
||||
else if (key === "blobVersionedHashes") {
|
||||
if (value.length === 0) {
|
||||
continue;
|
||||
}
|
||||
// @TODO: update this once the API supports blobs
|
||||
assert(false, "Etherscan API does not support blobVersionedHashes", "UNSUPPORTED_OPERATION", {
|
||||
operation: "_getTransactionPostData",
|
||||
info: { transaction }
|
||||
});
|
||||
}
|
||||
else {
|
||||
value = hexlify(value);
|
||||
}
|
||||
result[key] = value;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Throws the normalized Etherscan error.
|
||||
*/
|
||||
_checkError(req, error, transaction) {
|
||||
// Pull any message out if, possible
|
||||
let message = "";
|
||||
if (isError(error, "SERVER_ERROR")) {
|
||||
// Check for an error emitted by a proxy call
|
||||
try {
|
||||
message = error.info.result.error.message;
|
||||
}
|
||||
catch (e) { }
|
||||
if (!message) {
|
||||
try {
|
||||
message = error.info.message;
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
}
|
||||
if (req.method === "estimateGas") {
|
||||
if (!message.match(/revert/i) && message.match(/insufficient funds/i)) {
|
||||
assert(false, "insufficient funds", "INSUFFICIENT_FUNDS", {
|
||||
transaction: req.transaction
|
||||
});
|
||||
}
|
||||
}
|
||||
if (req.method === "call" || req.method === "estimateGas") {
|
||||
if (message.match(/execution reverted/i)) {
|
||||
let data = "";
|
||||
try {
|
||||
data = error.info.result.error.data;
|
||||
}
|
||||
catch (error) { }
|
||||
const e = AbiCoder.getBuiltinCallException(req.method, req.transaction, data);
|
||||
e.info = { request: req, error };
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
if (message) {
|
||||
if (req.method === "broadcastTransaction") {
|
||||
const transaction = Transaction.from(req.signedTransaction);
|
||||
if (message.match(/replacement/i) && message.match(/underpriced/i)) {
|
||||
assert(false, "replacement fee too low", "REPLACEMENT_UNDERPRICED", {
|
||||
transaction
|
||||
});
|
||||
}
|
||||
if (message.match(/insufficient funds/)) {
|
||||
assert(false, "insufficient funds for intrinsic transaction cost", "INSUFFICIENT_FUNDS", {
|
||||
transaction
|
||||
});
|
||||
}
|
||||
if (message.match(/same hash was already imported|transaction nonce is too low|nonce too low/)) {
|
||||
assert(false, "nonce has already been used", "NONCE_EXPIRED", {
|
||||
transaction
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
// Something we could not process
|
||||
throw error;
|
||||
}
|
||||
async _detectNetwork() {
|
||||
return this.network;
|
||||
}
|
||||
async _perform(req) {
|
||||
switch (req.method) {
|
||||
case "chainId":
|
||||
return this.network.chainId;
|
||||
case "getBlockNumber":
|
||||
return this.fetch("proxy", { action: "eth_blockNumber" });
|
||||
case "getGasPrice":
|
||||
return this.fetch("proxy", { action: "eth_gasPrice" });
|
||||
case "getPriorityFee":
|
||||
// This is temporary until Etherscan completes support
|
||||
if (this.network.name === "mainnet") {
|
||||
return "1000000000";
|
||||
}
|
||||
else if (this.network.name === "optimism") {
|
||||
return "1000000";
|
||||
}
|
||||
else {
|
||||
throw new Error("fallback onto the AbstractProvider default");
|
||||
}
|
||||
/* Working with Etherscan to get this added:
|
||||
try {
|
||||
const test = await this.fetch("proxy", {
|
||||
action: "eth_maxPriorityFeePerGas"
|
||||
});
|
||||
console.log(test);
|
||||
return test;
|
||||
} catch (e) {
|
||||
console.log("DEBUG", e);
|
||||
throw e;
|
||||
}
|
||||
*/
|
||||
/* This might be safe; but due to rounding neither myself
|
||||
or Etherscan are necessarily comfortable with this. :)
|
||||
try {
|
||||
const result = await this.fetch("gastracker", { action: "gasoracle" });
|
||||
console.log(result);
|
||||
const gasPrice = parseUnits(result.SafeGasPrice, "gwei");
|
||||
const baseFee = parseUnits(result.suggestBaseFee, "gwei");
|
||||
const priorityFee = gasPrice - baseFee;
|
||||
if (priorityFee < 0) { throw new Error("negative priority fee; defer to abstract provider default"); }
|
||||
return priorityFee;
|
||||
} catch (error) {
|
||||
console.log("DEBUG", error);
|
||||
throw error;
|
||||
}
|
||||
*/
|
||||
case "getBalance":
|
||||
// Returns base-10 result
|
||||
return this.fetch("account", {
|
||||
action: "balance",
|
||||
address: req.address,
|
||||
tag: req.blockTag
|
||||
});
|
||||
case "getTransactionCount":
|
||||
return this.fetch("proxy", {
|
||||
action: "eth_getTransactionCount",
|
||||
address: req.address,
|
||||
tag: req.blockTag
|
||||
});
|
||||
case "getCode":
|
||||
return this.fetch("proxy", {
|
||||
action: "eth_getCode",
|
||||
address: req.address,
|
||||
tag: req.blockTag
|
||||
});
|
||||
case "getStorage":
|
||||
return this.fetch("proxy", {
|
||||
action: "eth_getStorageAt",
|
||||
address: req.address,
|
||||
position: req.position,
|
||||
tag: req.blockTag
|
||||
});
|
||||
case "broadcastTransaction":
|
||||
return this.fetch("proxy", {
|
||||
action: "eth_sendRawTransaction",
|
||||
hex: req.signedTransaction
|
||||
}, true).catch((error) => {
|
||||
return this._checkError(req, error, req.signedTransaction);
|
||||
});
|
||||
case "getBlock":
|
||||
if ("blockTag" in req) {
|
||||
return this.fetch("proxy", {
|
||||
action: "eth_getBlockByNumber",
|
||||
tag: req.blockTag,
|
||||
boolean: (req.includeTransactions ? "true" : "false")
|
||||
});
|
||||
}
|
||||
assert(false, "getBlock by blockHash not supported by Etherscan", "UNSUPPORTED_OPERATION", {
|
||||
operation: "getBlock(blockHash)"
|
||||
});
|
||||
case "getTransaction":
|
||||
return this.fetch("proxy", {
|
||||
action: "eth_getTransactionByHash",
|
||||
txhash: req.hash
|
||||
});
|
||||
case "getTransactionReceipt":
|
||||
return this.fetch("proxy", {
|
||||
action: "eth_getTransactionReceipt",
|
||||
txhash: req.hash
|
||||
});
|
||||
case "call": {
|
||||
if (req.blockTag !== "latest") {
|
||||
throw new Error("EtherscanProvider does not support blockTag for call");
|
||||
}
|
||||
const postData = this._getTransactionPostData(req.transaction);
|
||||
postData.module = "proxy";
|
||||
postData.action = "eth_call";
|
||||
try {
|
||||
return await this.fetch("proxy", postData, true);
|
||||
}
|
||||
catch (error) {
|
||||
return this._checkError(req, error, req.transaction);
|
||||
}
|
||||
}
|
||||
case "estimateGas": {
|
||||
const postData = this._getTransactionPostData(req.transaction);
|
||||
postData.module = "proxy";
|
||||
postData.action = "eth_estimateGas";
|
||||
try {
|
||||
return await this.fetch("proxy", postData, true);
|
||||
}
|
||||
catch (error) {
|
||||
return this._checkError(req, error, req.transaction);
|
||||
}
|
||||
}
|
||||
/*
|
||||
case "getLogs": {
|
||||
// Needs to complain if more than one address is passed in
|
||||
const args: Record<string, any> = { action: "getLogs" }
|
||||
|
||||
if (params.filter.fromBlock) {
|
||||
args.fromBlock = checkLogTag(params.filter.fromBlock);
|
||||
}
|
||||
|
||||
if (params.filter.toBlock) {
|
||||
args.toBlock = checkLogTag(params.filter.toBlock);
|
||||
}
|
||||
|
||||
if (params.filter.address) {
|
||||
args.address = params.filter.address;
|
||||
}
|
||||
|
||||
// @TODO: We can handle slightly more complicated logs using the logs API
|
||||
if (params.filter.topics && params.filter.topics.length > 0) {
|
||||
if (params.filter.topics.length > 1) {
|
||||
logger.throwError("unsupported topic count", Logger.Errors.UNSUPPORTED_OPERATION, { topics: params.filter.topics });
|
||||
}
|
||||
if (params.filter.topics.length === 1) {
|
||||
const topic0 = params.filter.topics[0];
|
||||
if (typeof(topic0) !== "string" || topic0.length !== 66) {
|
||||
logger.throwError("unsupported topic format", Logger.Errors.UNSUPPORTED_OPERATION, { topic0: topic0 });
|
||||
}
|
||||
args.topic0 = topic0;
|
||||
}
|
||||
}
|
||||
|
||||
const logs: Array<any> = await this.fetch("logs", args);
|
||||
|
||||
// Cache txHash => blockHash
|
||||
let blocks: { [tag: string]: string } = {};
|
||||
|
||||
// Add any missing blockHash to the logs
|
||||
for (let i = 0; i < logs.length; i++) {
|
||||
const log = logs[i];
|
||||
if (log.blockHash != null) { continue; }
|
||||
if (blocks[log.blockNumber] == null) {
|
||||
const block = await this.getBlock(log.blockNumber);
|
||||
if (block) {
|
||||
blocks[log.blockNumber] = block.hash;
|
||||
}
|
||||
}
|
||||
|
||||
log.blockHash = blocks[log.blockNumber];
|
||||
}
|
||||
|
||||
return logs;
|
||||
}
|
||||
*/
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return super._perform(req);
|
||||
}
|
||||
async getNetwork() {
|
||||
return this.network;
|
||||
}
|
||||
/**
|
||||
* Resolves to the current price of ether.
|
||||
*
|
||||
* This returns ``0`` on any network other than ``mainnet``.
|
||||
*/
|
||||
async getEtherPrice() {
|
||||
if (this.network.name !== "mainnet") {
|
||||
return 0.0;
|
||||
}
|
||||
return parseFloat((await this.fetch("stats", { action: "ethprice" })).ethusd);
|
||||
}
|
||||
/**
|
||||
* Resolves to a [Contract]] for %%address%%, using the
|
||||
* Etherscan API to retreive the Contract ABI.
|
||||
*/
|
||||
async getContract(_address) {
|
||||
let address = this._getAddress(_address);
|
||||
if (isPromise(address)) {
|
||||
address = await address;
|
||||
}
|
||||
try {
|
||||
const resp = await this.fetch("contract", {
|
||||
action: "getabi", address
|
||||
});
|
||||
const abi = JSON.parse(resp);
|
||||
return new Contract(address, abi, this);
|
||||
}
|
||||
catch (error) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
isCommunityResource() {
|
||||
return (this.apiKey == null);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=provider-etherscan.js.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/provider-etherscan.js.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/provider-etherscan.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
115
dev/env/node_modules/ethers/lib.esm/providers/provider-fallback.d.ts
generated
vendored
Executable file
115
dev/env/node_modules/ethers/lib.esm/providers/provider-fallback.d.ts
generated
vendored
Executable file
@@ -0,0 +1,115 @@
|
||||
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 {
|
||||
/**
|
||||
* The provider.
|
||||
*/
|
||||
provider: AbstractProvider;
|
||||
/**
|
||||
* The amount of time to wait before kicking off the next provider.
|
||||
*
|
||||
* Any providers that have not responded can still respond and be
|
||||
* counted, but this ensures new providers start.
|
||||
*/
|
||||
stallTimeout?: number;
|
||||
/**
|
||||
* The priority. Lower priority providers are dispatched first.
|
||||
*/
|
||||
priority?: number;
|
||||
/**
|
||||
* The amount of weight a provider is given against the quorum.
|
||||
*/
|
||||
weight?: number;
|
||||
}
|
||||
/**
|
||||
* The statistics and state maintained for a [[Provider]].
|
||||
*/
|
||||
export interface FallbackProviderState extends Required<FallbackProviderConfig> {
|
||||
/**
|
||||
* The most recent blockNumber this provider has reported (-2 if none).
|
||||
*/
|
||||
blockNumber: number;
|
||||
/**
|
||||
* The number of total requests ever sent to this provider.
|
||||
*/
|
||||
requests: number;
|
||||
/**
|
||||
* The number of responses that errored.
|
||||
*/
|
||||
errorResponses: number;
|
||||
/**
|
||||
* The number of responses that occured after the result resolved.
|
||||
*/
|
||||
lateResponses: number;
|
||||
/**
|
||||
* How many times syncing was required to catch up the expected block.
|
||||
*/
|
||||
outOfSync: number;
|
||||
/**
|
||||
* The number of requests which reported unsupported operation.
|
||||
*/
|
||||
unsupportedEvents: number;
|
||||
/**
|
||||
* A rolling average (5% current duration) for response time.
|
||||
*/
|
||||
rollingDuration: number;
|
||||
/**
|
||||
* The ratio of quorum-agreed results to total.
|
||||
*/
|
||||
score: number;
|
||||
}
|
||||
/**
|
||||
* Additional options to configure a [[FallbackProvider]].
|
||||
*/
|
||||
export type FallbackProviderOptions = {
|
||||
quorum?: number;
|
||||
eventQuorum?: number;
|
||||
eventWorkers?: number;
|
||||
cacheTimeout?: number;
|
||||
pollingInterval?: number;
|
||||
};
|
||||
/**
|
||||
* A **FallbackProvider** manages several [[Providers]] providing
|
||||
* resilience by switching between slow or misbehaving nodes, security
|
||||
* by requiring multiple backends to aggree and performance by allowing
|
||||
* faster backends to respond earlier.
|
||||
*
|
||||
*/
|
||||
export declare class FallbackProvider extends AbstractProvider {
|
||||
#private;
|
||||
/**
|
||||
* The number of backends that must agree on a value before it is
|
||||
* accpeted.
|
||||
*/
|
||||
readonly quorum: number;
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
readonly eventQuorum: number;
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
readonly eventWorkers: number;
|
||||
/**
|
||||
* Creates a new **FallbackProvider** with %%providers%% connected to
|
||||
* %%network%%.
|
||||
*
|
||||
* If a [[Provider]] is included in %%providers%%, defaults are used
|
||||
* for the configuration.
|
||||
*/
|
||||
constructor(providers: Array<AbstractProvider | FallbackProviderConfig>, network?: Networkish, options?: FallbackProviderOptions);
|
||||
get providerConfigs(): Array<FallbackProviderState>;
|
||||
_detectNetwork(): Promise<Network>;
|
||||
/**
|
||||
* Transforms a %%req%% into the correct method call on %%provider%%.
|
||||
*/
|
||||
_translatePerform(provider: AbstractProvider, req: PerformActionRequest): Promise<any>;
|
||||
_perform<T = any>(req: PerformActionRequest): Promise<T>;
|
||||
destroy(): Promise<void>;
|
||||
}
|
||||
//# sourceMappingURL=provider-fallback.d.ts.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/provider-fallback.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/provider-fallback.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"provider-fallback.d.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SAAQ,gBAAgB;;IAElD;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAO9B;;;;;;OAMG;gBACS,SAAS,EAAE,KAAK,CAAC,gBAAgB,GAAG,sBAAsB,CAAC,EAAE,OAAO,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,uBAAuB;IA8BhI,IAAI,eAAe,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAQlD;IAEK,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IASxC;;OAEG;IACG,iBAAiB,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC;IA6QtF,QAAQ,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,CAAC,CAAC;IA8ExD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAMjC"}
|
||||
620
dev/env/node_modules/ethers/lib.esm/providers/provider-fallback.js
generated
vendored
Executable file
620
dev/env/node_modules/ethers/lib.esm/providers/provider-fallback.js
generated
vendored
Executable file
@@ -0,0 +1,620 @@
|
||||
/**
|
||||
* A **FallbackProvider** provides resilience, security and performance
|
||||
* in a way that is customizable and configurable.
|
||||
*
|
||||
* @_section: api/providers/fallback-provider:Fallback Provider [about-fallback-provider]
|
||||
*/
|
||||
import { assert, assertArgument, getBigInt, getNumber, isError } from "../utils/index.js";
|
||||
import { AbstractProvider } from "./abstract-provider.js";
|
||||
import { Network } from "./network.js";
|
||||
const BN_1 = BigInt("1");
|
||||
const BN_2 = BigInt("2");
|
||||
function shuffle(array) {
|
||||
for (let i = array.length - 1; i > 0; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1));
|
||||
const tmp = array[i];
|
||||
array[i] = array[j];
|
||||
array[j] = tmp;
|
||||
}
|
||||
}
|
||||
function stall(duration) {
|
||||
return new Promise((resolve) => { setTimeout(resolve, duration); });
|
||||
}
|
||||
function getTime() { return (new Date()).getTime(); }
|
||||
function stringify(value) {
|
||||
return JSON.stringify(value, (key, value) => {
|
||||
if (typeof (value) === "bigint") {
|
||||
return { type: "bigint", value: value.toString() };
|
||||
}
|
||||
return value;
|
||||
});
|
||||
}
|
||||
;
|
||||
const defaultConfig = { stallTimeout: 400, priority: 1, weight: 1 };
|
||||
const defaultState = {
|
||||
blockNumber: -2, requests: 0, lateResponses: 0, errorResponses: 0,
|
||||
outOfSync: -1, unsupportedEvents: 0, rollingDuration: 0, score: 0,
|
||||
_network: null, _updateNumber: null, _totalTime: 0,
|
||||
_lastFatalError: null, _lastFatalErrorTimestamp: 0
|
||||
};
|
||||
async function waitForSync(config, blockNumber) {
|
||||
while (config.blockNumber < 0 || config.blockNumber < blockNumber) {
|
||||
if (!config._updateNumber) {
|
||||
config._updateNumber = (async () => {
|
||||
try {
|
||||
const blockNumber = await config.provider.getBlockNumber();
|
||||
if (blockNumber > config.blockNumber) {
|
||||
config.blockNumber = blockNumber;
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
config.blockNumber = -2;
|
||||
config._lastFatalError = error;
|
||||
config._lastFatalErrorTimestamp = getTime();
|
||||
}
|
||||
config._updateNumber = null;
|
||||
})();
|
||||
}
|
||||
await config._updateNumber;
|
||||
config.outOfSync++;
|
||||
if (config._lastFatalError) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
function _normalize(value) {
|
||||
if (value == null) {
|
||||
return "null";
|
||||
}
|
||||
if (Array.isArray(value)) {
|
||||
return "[" + (value.map(_normalize)).join(",") + "]";
|
||||
}
|
||||
if (typeof (value) === "object" && typeof (value.toJSON) === "function") {
|
||||
return _normalize(value.toJSON());
|
||||
}
|
||||
switch (typeof (value)) {
|
||||
case "boolean":
|
||||
case "symbol":
|
||||
return value.toString();
|
||||
case "bigint":
|
||||
case "number":
|
||||
return BigInt(value).toString();
|
||||
case "string":
|
||||
return JSON.stringify(value);
|
||||
case "object": {
|
||||
const keys = Object.keys(value);
|
||||
keys.sort();
|
||||
return "{" + keys.map((k) => `${JSON.stringify(k)}:${_normalize(value[k])}`).join(",") + "}";
|
||||
}
|
||||
}
|
||||
console.log("Could not serialize", value);
|
||||
throw new Error("Hmm...");
|
||||
}
|
||||
function normalizeResult(method, value) {
|
||||
if ("error" in value) {
|
||||
const error = value.error;
|
||||
let tag;
|
||||
if (isError(error, "CALL_EXCEPTION")) {
|
||||
tag = _normalize(Object.assign({}, error, {
|
||||
shortMessage: undefined, reason: undefined, info: undefined
|
||||
}));
|
||||
}
|
||||
else {
|
||||
tag = _normalize(error);
|
||||
}
|
||||
return { tag, value: error };
|
||||
}
|
||||
const result = value.result;
|
||||
return { tag: _normalize(result), value: result };
|
||||
}
|
||||
// This strategy picks the highest weight result, as long as the weight is
|
||||
// equal to or greater than quorum
|
||||
function checkQuorum(quorum, results) {
|
||||
const tally = new Map();
|
||||
for (const { value, tag, weight } of results) {
|
||||
const t = tally.get(tag) || { value, weight: 0 };
|
||||
t.weight += weight;
|
||||
tally.set(tag, t);
|
||||
}
|
||||
let best = null;
|
||||
for (const r of tally.values()) {
|
||||
if (r.weight >= quorum && (!best || r.weight > best.weight)) {
|
||||
best = r;
|
||||
}
|
||||
}
|
||||
if (best) {
|
||||
return best.value;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
function getMedian(quorum, results) {
|
||||
let resultWeight = 0;
|
||||
const errorMap = new Map();
|
||||
let bestError = null;
|
||||
const values = [];
|
||||
for (const { value, tag, weight } of results) {
|
||||
if (value instanceof Error) {
|
||||
const e = errorMap.get(tag) || { value, weight: 0 };
|
||||
e.weight += weight;
|
||||
errorMap.set(tag, e);
|
||||
if (bestError == null || e.weight > bestError.weight) {
|
||||
bestError = e;
|
||||
}
|
||||
}
|
||||
else {
|
||||
values.push(BigInt(value));
|
||||
resultWeight += weight;
|
||||
}
|
||||
}
|
||||
if (resultWeight < quorum) {
|
||||
// We have quorum for an error
|
||||
if (bestError && bestError.weight >= quorum) {
|
||||
return bestError.value;
|
||||
}
|
||||
// We do not have quorum for a result
|
||||
return undefined;
|
||||
}
|
||||
// Get the sorted values
|
||||
values.sort((a, b) => ((a < b) ? -1 : (b > a) ? 1 : 0));
|
||||
const mid = Math.floor(values.length / 2);
|
||||
// Odd-length; take the middle value
|
||||
if (values.length % 2) {
|
||||
return values[mid];
|
||||
}
|
||||
// Even length; take the ceiling of the mean of the center two values
|
||||
return (values[mid - 1] + values[mid] + BN_1) / BN_2;
|
||||
}
|
||||
function getAnyResult(quorum, results) {
|
||||
// If any value or error meets quorum, that is our preferred result
|
||||
const result = checkQuorum(quorum, results);
|
||||
if (result !== undefined) {
|
||||
return result;
|
||||
}
|
||||
// Otherwise, do we have any result?
|
||||
for (const r of results) {
|
||||
if (r.value) {
|
||||
return r.value;
|
||||
}
|
||||
}
|
||||
// Nope!
|
||||
return undefined;
|
||||
}
|
||||
function getFuzzyMode(quorum, results) {
|
||||
if (quorum === 1) {
|
||||
return getNumber(getMedian(quorum, results), "%internal");
|
||||
}
|
||||
const tally = new Map();
|
||||
const add = (result, weight) => {
|
||||
const t = tally.get(result) || { result, weight: 0 };
|
||||
t.weight += weight;
|
||||
tally.set(result, t);
|
||||
};
|
||||
for (const { weight, value } of results) {
|
||||
const r = getNumber(value);
|
||||
add(r - 1, weight);
|
||||
add(r, weight);
|
||||
add(r + 1, weight);
|
||||
}
|
||||
let bestWeight = 0;
|
||||
let bestResult = undefined;
|
||||
for (const { weight, result } of tally.values()) {
|
||||
// Use this result, if this result meets quorum and has either:
|
||||
// - a better weight
|
||||
// - or equal weight, but the result is larger
|
||||
if (weight >= quorum && (weight > bestWeight || (bestResult != null && weight === bestWeight && result > bestResult))) {
|
||||
bestWeight = weight;
|
||||
bestResult = result;
|
||||
}
|
||||
}
|
||||
return bestResult;
|
||||
}
|
||||
/**
|
||||
* A **FallbackProvider** manages several [[Providers]] providing
|
||||
* resilience by switching between slow or misbehaving nodes, security
|
||||
* by requiring multiple backends to aggree and performance by allowing
|
||||
* faster backends to respond earlier.
|
||||
*
|
||||
*/
|
||||
export class FallbackProvider extends AbstractProvider {
|
||||
/**
|
||||
* The number of backends that must agree on a value before it is
|
||||
* accpeted.
|
||||
*/
|
||||
quorum;
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
eventQuorum;
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
eventWorkers;
|
||||
#configs;
|
||||
#height;
|
||||
#initialSyncPromise;
|
||||
/**
|
||||
* Creates a new **FallbackProvider** with %%providers%% connected to
|
||||
* %%network%%.
|
||||
*
|
||||
* If a [[Provider]] is included in %%providers%%, defaults are used
|
||||
* for the configuration.
|
||||
*/
|
||||
constructor(providers, network, options) {
|
||||
super(network, options);
|
||||
this.#configs = providers.map((p) => {
|
||||
if (p instanceof AbstractProvider) {
|
||||
return Object.assign({ provider: p }, defaultConfig, defaultState);
|
||||
}
|
||||
else {
|
||||
return Object.assign({}, defaultConfig, p, defaultState);
|
||||
}
|
||||
});
|
||||
this.#height = -2;
|
||||
this.#initialSyncPromise = null;
|
||||
if (options && options.quorum != null) {
|
||||
this.quorum = options.quorum;
|
||||
}
|
||||
else {
|
||||
this.quorum = Math.ceil(this.#configs.reduce((accum, config) => {
|
||||
accum += config.weight;
|
||||
return accum;
|
||||
}, 0) / 2);
|
||||
}
|
||||
this.eventQuorum = 1;
|
||||
this.eventWorkers = 1;
|
||||
assertArgument(this.quorum <= this.#configs.reduce((a, c) => (a + c.weight), 0), "quorum exceed provider weight", "quorum", this.quorum);
|
||||
}
|
||||
get providerConfigs() {
|
||||
return this.#configs.map((c) => {
|
||||
const result = Object.assign({}, c);
|
||||
for (const key in result) {
|
||||
if (key[0] === "_") {
|
||||
delete result[key];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
});
|
||||
}
|
||||
async _detectNetwork() {
|
||||
return Network.from(getBigInt(await this._perform({ method: "chainId" })));
|
||||
}
|
||||
// @TODO: Add support to select providers to be the event subscriber
|
||||
//_getSubscriber(sub: Subscription): Subscriber {
|
||||
// throw new Error("@TODO");
|
||||
//}
|
||||
/**
|
||||
* Transforms a %%req%% into the correct method call on %%provider%%.
|
||||
*/
|
||||
async _translatePerform(provider, req) {
|
||||
switch (req.method) {
|
||||
case "broadcastTransaction":
|
||||
return await provider.broadcastTransaction(req.signedTransaction);
|
||||
case "call":
|
||||
return await provider.call(Object.assign({}, req.transaction, { blockTag: req.blockTag }));
|
||||
case "chainId":
|
||||
return (await provider.getNetwork()).chainId;
|
||||
case "estimateGas":
|
||||
return await provider.estimateGas(req.transaction);
|
||||
case "getBalance":
|
||||
return await provider.getBalance(req.address, req.blockTag);
|
||||
case "getBlock": {
|
||||
const block = ("blockHash" in req) ? req.blockHash : req.blockTag;
|
||||
return await provider.getBlock(block, req.includeTransactions);
|
||||
}
|
||||
case "getBlockNumber":
|
||||
return await provider.getBlockNumber();
|
||||
case "getCode":
|
||||
return await provider.getCode(req.address, req.blockTag);
|
||||
case "getGasPrice":
|
||||
return (await provider.getFeeData()).gasPrice;
|
||||
case "getPriorityFee":
|
||||
return (await provider.getFeeData()).maxPriorityFeePerGas;
|
||||
case "getLogs":
|
||||
return await provider.getLogs(req.filter);
|
||||
case "getStorage":
|
||||
return await provider.getStorage(req.address, req.position, req.blockTag);
|
||||
case "getTransaction":
|
||||
return await provider.getTransaction(req.hash);
|
||||
case "getTransactionCount":
|
||||
return await provider.getTransactionCount(req.address, req.blockTag);
|
||||
case "getTransactionReceipt":
|
||||
return await provider.getTransactionReceipt(req.hash);
|
||||
case "getTransactionResult":
|
||||
return await provider.getTransactionResult(req.hash);
|
||||
}
|
||||
}
|
||||
// Grab the next (random) config that is not already part of
|
||||
// the running set
|
||||
#getNextConfig(running) {
|
||||
// @TODO: Maybe do a check here to favour (heavily) providers that
|
||||
// do not require waitForSync and disfavour providers that
|
||||
// seem down-ish or are behaving slowly
|
||||
const configs = Array.from(running).map((r) => r.config);
|
||||
// Shuffle the states, sorted by priority
|
||||
const allConfigs = this.#configs.slice();
|
||||
shuffle(allConfigs);
|
||||
allConfigs.sort((a, b) => (a.priority - b.priority));
|
||||
for (const config of allConfigs) {
|
||||
if (config._lastFatalError) {
|
||||
continue;
|
||||
}
|
||||
if (configs.indexOf(config) === -1) {
|
||||
return config;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// Adds a new runner (if available) to running.
|
||||
#addRunner(running, req) {
|
||||
const config = this.#getNextConfig(running);
|
||||
// No runners available
|
||||
if (config == null) {
|
||||
return null;
|
||||
}
|
||||
// Create a new runner
|
||||
const runner = {
|
||||
config, result: null, didBump: false,
|
||||
perform: null, staller: null
|
||||
};
|
||||
const now = getTime();
|
||||
// Start performing this operation
|
||||
runner.perform = (async () => {
|
||||
try {
|
||||
config.requests++;
|
||||
const result = await this._translatePerform(config.provider, req);
|
||||
runner.result = { result };
|
||||
}
|
||||
catch (error) {
|
||||
config.errorResponses++;
|
||||
runner.result = { error };
|
||||
}
|
||||
const dt = (getTime() - now);
|
||||
config._totalTime += dt;
|
||||
config.rollingDuration = 0.95 * config.rollingDuration + 0.05 * dt;
|
||||
runner.perform = null;
|
||||
})();
|
||||
// Start a staller; when this times out, it's time to force
|
||||
// kicking off another runner because we are taking too long
|
||||
runner.staller = (async () => {
|
||||
await stall(config.stallTimeout);
|
||||
runner.staller = null;
|
||||
})();
|
||||
running.add(runner);
|
||||
return runner;
|
||||
}
|
||||
// Initializes the blockNumber and network for each runner and
|
||||
// blocks until initialized
|
||||
async #initialSync() {
|
||||
let initialSync = this.#initialSyncPromise;
|
||||
if (!initialSync) {
|
||||
const promises = [];
|
||||
this.#configs.forEach((config) => {
|
||||
promises.push((async () => {
|
||||
await waitForSync(config, 0);
|
||||
if (!config._lastFatalError) {
|
||||
config._network = await config.provider.getNetwork();
|
||||
}
|
||||
})());
|
||||
});
|
||||
this.#initialSyncPromise = initialSync = (async () => {
|
||||
// Wait for all providers to have a block number and network
|
||||
await Promise.all(promises);
|
||||
// Check all the networks match
|
||||
let chainId = null;
|
||||
for (const config of this.#configs) {
|
||||
if (config._lastFatalError) {
|
||||
continue;
|
||||
}
|
||||
const network = (config._network);
|
||||
if (chainId == null) {
|
||||
chainId = network.chainId;
|
||||
}
|
||||
else if (network.chainId !== chainId) {
|
||||
assert(false, "cannot mix providers on different networks", "UNSUPPORTED_OPERATION", {
|
||||
operation: "new FallbackProvider"
|
||||
});
|
||||
}
|
||||
}
|
||||
})();
|
||||
}
|
||||
await initialSync;
|
||||
}
|
||||
async #checkQuorum(running, req) {
|
||||
// Get all the result objects
|
||||
const results = [];
|
||||
for (const runner of running) {
|
||||
if (runner.result != null) {
|
||||
const { tag, value } = normalizeResult(req.method, runner.result);
|
||||
results.push({ tag, value, weight: runner.config.weight });
|
||||
}
|
||||
}
|
||||
// Are there enough results to event meet quorum?
|
||||
if (results.reduce((a, r) => (a + r.weight), 0) < this.quorum) {
|
||||
return undefined;
|
||||
}
|
||||
switch (req.method) {
|
||||
case "getBlockNumber": {
|
||||
// We need to get the bootstrap block height
|
||||
if (this.#height === -2) {
|
||||
this.#height = Math.ceil(getNumber(getMedian(this.quorum, this.#configs.filter((c) => (!c._lastFatalError)).map((c) => ({
|
||||
value: c.blockNumber,
|
||||
tag: getNumber(c.blockNumber).toString(),
|
||||
weight: c.weight
|
||||
})))));
|
||||
}
|
||||
// Find the mode across all the providers, allowing for
|
||||
// a little drift between block heights
|
||||
const mode = getFuzzyMode(this.quorum, results);
|
||||
if (mode === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
if (mode > this.#height) {
|
||||
this.#height = mode;
|
||||
}
|
||||
return this.#height;
|
||||
}
|
||||
case "getGasPrice":
|
||||
case "getPriorityFee":
|
||||
case "estimateGas":
|
||||
return getMedian(this.quorum, results);
|
||||
case "getBlock":
|
||||
// Pending blocks are in the mempool and already
|
||||
// quite untrustworthy; just grab anything
|
||||
if ("blockTag" in req && req.blockTag === "pending") {
|
||||
return getAnyResult(this.quorum, results);
|
||||
}
|
||||
return checkQuorum(this.quorum, results);
|
||||
case "call":
|
||||
case "chainId":
|
||||
case "getBalance":
|
||||
case "getTransactionCount":
|
||||
case "getCode":
|
||||
case "getStorage":
|
||||
case "getTransaction":
|
||||
case "getTransactionReceipt":
|
||||
case "getLogs":
|
||||
return checkQuorum(this.quorum, results);
|
||||
case "broadcastTransaction":
|
||||
return getAnyResult(this.quorum, results);
|
||||
}
|
||||
assert(false, "unsupported method", "UNSUPPORTED_OPERATION", {
|
||||
operation: `_perform(${stringify(req.method)})`
|
||||
});
|
||||
}
|
||||
async #waitForQuorum(running, req) {
|
||||
if (running.size === 0) {
|
||||
throw new Error("no runners?!");
|
||||
}
|
||||
// Any promises that are interesting to watch for; an expired stall
|
||||
// or a successful perform
|
||||
const interesting = [];
|
||||
let newRunners = 0;
|
||||
for (const runner of running) {
|
||||
// No responses, yet; keep an eye on it
|
||||
if (runner.perform) {
|
||||
interesting.push(runner.perform);
|
||||
}
|
||||
// Still stalling...
|
||||
if (runner.staller) {
|
||||
interesting.push(runner.staller);
|
||||
continue;
|
||||
}
|
||||
// This runner has already triggered another runner
|
||||
if (runner.didBump) {
|
||||
continue;
|
||||
}
|
||||
// Got a response (result or error) or stalled; kick off another runner
|
||||
runner.didBump = true;
|
||||
newRunners++;
|
||||
}
|
||||
// Check if we have reached quorum on a result (or error)
|
||||
const value = await this.#checkQuorum(running, req);
|
||||
if (value !== undefined) {
|
||||
if (value instanceof Error) {
|
||||
throw value;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
// Add any new runners, because a staller timed out or a result
|
||||
// or error response came in.
|
||||
for (let i = 0; i < newRunners; i++) {
|
||||
this.#addRunner(running, req);
|
||||
}
|
||||
// All providers have returned, and we have no result
|
||||
assert(interesting.length > 0, "quorum not met", "SERVER_ERROR", {
|
||||
request: "%sub-requests",
|
||||
info: { request: req, results: Array.from(running).map((r) => stringify(r.result)) }
|
||||
});
|
||||
// Wait for someone to either complete its perform or stall out
|
||||
await Promise.race(interesting);
|
||||
// This is recursive, but at worst case the depth is 2x the
|
||||
// number of providers (each has a perform and a staller)
|
||||
return await this.#waitForQuorum(running, req);
|
||||
}
|
||||
async _perform(req) {
|
||||
// Broadcasting a transaction is rare (ish) and already incurs
|
||||
// a cost on the user, so spamming is safe-ish. Just send it to
|
||||
// every backend.
|
||||
if (req.method === "broadcastTransaction") {
|
||||
// Once any broadcast provides a positive result, use it. No
|
||||
// need to wait for anyone else
|
||||
const results = this.#configs.map((c) => null);
|
||||
const broadcasts = this.#configs.map(async ({ provider, weight }, index) => {
|
||||
try {
|
||||
const result = await provider._perform(req);
|
||||
results[index] = Object.assign(normalizeResult(req.method, { result }), { weight });
|
||||
}
|
||||
catch (error) {
|
||||
results[index] = Object.assign(normalizeResult(req.method, { error }), { weight });
|
||||
}
|
||||
});
|
||||
// As each promise finishes...
|
||||
while (true) {
|
||||
// Check for a valid broadcast result
|
||||
const done = results.filter((r) => (r != null));
|
||||
for (const { value } of done) {
|
||||
if (!(value instanceof Error)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
// Check for a legit broadcast error (one which we cannot
|
||||
// recover from; some nodes may return the following red
|
||||
// herring events:
|
||||
// - alredy seend (UNKNOWN_ERROR)
|
||||
// - NONCE_EXPIRED
|
||||
// - REPLACEMENT_UNDERPRICED
|
||||
const result = checkQuorum(this.quorum, results.filter((r) => (r != null)));
|
||||
if (isError(result, "INSUFFICIENT_FUNDS")) {
|
||||
throw result;
|
||||
}
|
||||
// Kick off the next provider (if any)
|
||||
const waiting = broadcasts.filter((b, i) => (results[i] == null));
|
||||
if (waiting.length === 0) {
|
||||
break;
|
||||
}
|
||||
await Promise.race(waiting);
|
||||
}
|
||||
// Use standard quorum results; any result was returned above,
|
||||
// so this will find any error that met quorum if any
|
||||
const result = getAnyResult(this.quorum, results);
|
||||
assert(result !== undefined, "problem multi-broadcasting", "SERVER_ERROR", {
|
||||
request: "%sub-requests",
|
||||
info: { request: req, results: results.map(stringify) }
|
||||
});
|
||||
if (result instanceof Error) {
|
||||
throw result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
await this.#initialSync();
|
||||
// Bootstrap enough runners to meet quorum
|
||||
const running = new Set();
|
||||
let inflightQuorum = 0;
|
||||
while (true) {
|
||||
const runner = this.#addRunner(running, req);
|
||||
if (runner == null) {
|
||||
break;
|
||||
}
|
||||
inflightQuorum += runner.config.weight;
|
||||
if (inflightQuorum >= this.quorum) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
const result = await this.#waitForQuorum(running, req);
|
||||
// Track requests sent to a provider that are still
|
||||
// outstanding after quorum has been otherwise found
|
||||
for (const runner of running) {
|
||||
if (runner.perform && runner.result == null) {
|
||||
runner.config.lateResponses++;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
async destroy() {
|
||||
for (const { provider } of this.#configs) {
|
||||
provider.destroy();
|
||||
}
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=provider-fallback.js.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/provider-fallback.js.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/provider-fallback.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
101
dev/env/node_modules/ethers/lib.esm/providers/provider-infura.d.ts
generated
vendored
Executable file
101
dev/env/node_modules/ethers/lib.esm/providers/provider-infura.d.ts
generated
vendored
Executable file
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
* [[link-infura]] provides a third-party service for connecting to
|
||||
* various blockchains over JSON-RPC.
|
||||
*
|
||||
* **Supported Networks**
|
||||
*
|
||||
* - Ethereum Mainnet (``mainnet``)
|
||||
* - Goerli Testnet (``goerli``)
|
||||
* - Sepolia Testnet (``sepolia``)
|
||||
* - Arbitrum (``arbitrum``)
|
||||
* - Arbitrum Goerli Testnet (``arbitrum-goerli``)
|
||||
* - Arbitrum Sepolia Testnet (``arbitrum-sepolia``)
|
||||
* - Base (``base``)
|
||||
* - Base Goerlia Testnet (``base-goerli``)
|
||||
* - Base Sepolia Testnet (``base-sepolia``)
|
||||
* - BNB Smart Chain Mainnet (``bnb``)
|
||||
* - BNB Smart Chain Testnet (``bnbt``)
|
||||
* - Linea (``linea``)
|
||||
* - Linea Goerli Testnet (``linea-goerli``)
|
||||
* - Linea Sepolia Testnet (``linea-sepolia``)
|
||||
* - Optimism (``optimism``)
|
||||
* - Optimism Goerli Testnet (``optimism-goerli``)
|
||||
* - Optimism Sepolia Testnet (``optimism-sepolia``)
|
||||
* - Polygon (``matic``)
|
||||
* - Polygon Amoy Testnet (``matic-amoy``)
|
||||
* - Polygon Mumbai Testnet (``matic-mumbai``)
|
||||
*
|
||||
* @_subsection: api/providers/thirdparty:INFURA [providers-infura]
|
||||
*/
|
||||
import { FetchRequest } from "../utils/index.js";
|
||||
import { Network } from "./network.js";
|
||||
import { JsonRpcProvider } from "./provider-jsonrpc.js";
|
||||
import { WebSocketProvider } from "./provider-websocket.js";
|
||||
import type { AbstractProvider } from "./abstract-provider.js";
|
||||
import type { CommunityResourcable } from "./community.js";
|
||||
import type { Networkish } from "./network.js";
|
||||
/**
|
||||
* The **InfuraWebSocketProvider** connects to the [[link-infura]]
|
||||
* WebSocket 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-infura-signup).
|
||||
*/
|
||||
export declare class InfuraWebSocketProvider extends WebSocketProvider implements CommunityResourcable {
|
||||
/**
|
||||
* The Project ID for the INFURA connection.
|
||||
*/
|
||||
readonly projectId: string;
|
||||
/**
|
||||
* The Project Secret.
|
||||
*
|
||||
* If null, no authenticated requests are made. This should not
|
||||
* be used outside of private contexts.
|
||||
*/
|
||||
readonly projectSecret: null | string;
|
||||
/**
|
||||
* Creates a new **InfuraWebSocketProvider**.
|
||||
*/
|
||||
constructor(network?: Networkish, projectId?: string);
|
||||
isCommunityResource(): boolean;
|
||||
}
|
||||
/**
|
||||
* The **InfuraProvider** connects to the [[link-infura]]
|
||||
* 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-infura-signup).
|
||||
*/
|
||||
export declare class InfuraProvider extends JsonRpcProvider implements CommunityResourcable {
|
||||
/**
|
||||
* The Project ID for the INFURA connection.
|
||||
*/
|
||||
readonly projectId: string;
|
||||
/**
|
||||
* The Project Secret.
|
||||
*
|
||||
* If null, no authenticated requests are made. This should not
|
||||
* be used outside of private contexts.
|
||||
*/
|
||||
readonly projectSecret: null | string;
|
||||
/**
|
||||
* Creates a new **InfuraProvider**.
|
||||
*/
|
||||
constructor(_network?: Networkish, projectId?: null | string, projectSecret?: null | string);
|
||||
_getProvider(chainId: number): AbstractProvider;
|
||||
isCommunityResource(): boolean;
|
||||
/**
|
||||
* Creates a new **InfuraWebSocketProvider**.
|
||||
*/
|
||||
static getWebSocketProvider(network?: Networkish, projectId?: string): InfuraWebSocketProvider;
|
||||
/**
|
||||
* Returns a prepared request for connecting to %%network%%
|
||||
* with %%projectId%% and %%projectSecret%%.
|
||||
*/
|
||||
static getRequest(network: Network, projectId?: null | string, projectSecret?: null | string): FetchRequest;
|
||||
}
|
||||
//# sourceMappingURL=provider-infura.d.ts.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/provider-infura.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/provider-infura.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"provider-infura.d.ts","sourceRoot":"","sources":["../../src.ts/providers/provider-infura.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EACe,YAAY,EACjC,MAAM,mBAAmB,CAAC;AAG3B,O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EAAE,IAAI,GAAG,MAAM,EAAE,aAAa,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,YAAY;CAiB9G"}
|
||||
201
dev/env/node_modules/ethers/lib.esm/providers/provider-infura.js
generated
vendored
Executable file
201
dev/env/node_modules/ethers/lib.esm/providers/provider-infura.js
generated
vendored
Executable file
@@ -0,0 +1,201 @@
|
||||
/**
|
||||
* [[link-infura]] provides a third-party service for connecting to
|
||||
* various blockchains over JSON-RPC.
|
||||
*
|
||||
* **Supported Networks**
|
||||
*
|
||||
* - Ethereum Mainnet (``mainnet``)
|
||||
* - Goerli Testnet (``goerli``)
|
||||
* - Sepolia Testnet (``sepolia``)
|
||||
* - Arbitrum (``arbitrum``)
|
||||
* - Arbitrum Goerli Testnet (``arbitrum-goerli``)
|
||||
* - Arbitrum Sepolia Testnet (``arbitrum-sepolia``)
|
||||
* - Base (``base``)
|
||||
* - Base Goerlia Testnet (``base-goerli``)
|
||||
* - Base Sepolia Testnet (``base-sepolia``)
|
||||
* - BNB Smart Chain Mainnet (``bnb``)
|
||||
* - BNB Smart Chain Testnet (``bnbt``)
|
||||
* - Linea (``linea``)
|
||||
* - Linea Goerli Testnet (``linea-goerli``)
|
||||
* - Linea Sepolia Testnet (``linea-sepolia``)
|
||||
* - Optimism (``optimism``)
|
||||
* - Optimism Goerli Testnet (``optimism-goerli``)
|
||||
* - Optimism Sepolia Testnet (``optimism-sepolia``)
|
||||
* - Polygon (``matic``)
|
||||
* - Polygon Amoy Testnet (``matic-amoy``)
|
||||
* - Polygon Mumbai Testnet (``matic-mumbai``)
|
||||
*
|
||||
* @_subsection: api/providers/thirdparty:INFURA [providers-infura]
|
||||
*/
|
||||
import { defineProperties, FetchRequest, assert, assertArgument } from "../utils/index.js";
|
||||
import { showThrottleMessage } from "./community.js";
|
||||
import { Network } from "./network.js";
|
||||
import { JsonRpcProvider } from "./provider-jsonrpc.js";
|
||||
import { WebSocketProvider } from "./provider-websocket.js";
|
||||
const defaultProjectId = "84842078b09946638c03157f83405213";
|
||||
function getHost(name) {
|
||||
switch (name) {
|
||||
case "mainnet":
|
||||
return "mainnet.infura.io";
|
||||
case "goerli":
|
||||
return "goerli.infura.io";
|
||||
case "sepolia":
|
||||
return "sepolia.infura.io";
|
||||
case "arbitrum":
|
||||
return "arbitrum-mainnet.infura.io";
|
||||
case "arbitrum-goerli":
|
||||
return "arbitrum-goerli.infura.io";
|
||||
case "arbitrum-sepolia":
|
||||
return "arbitrum-sepolia.infura.io";
|
||||
case "base":
|
||||
return "base-mainnet.infura.io";
|
||||
case "base-goerlia": // @TODO: Remove this typo in the future!
|
||||
case "base-goerli":
|
||||
return "base-goerli.infura.io";
|
||||
case "base-sepolia":
|
||||
return "base-sepolia.infura.io";
|
||||
case "bnb":
|
||||
return "bsc-mainnet.infura.io";
|
||||
case "bnbt":
|
||||
return "bsc-testnet.infura.io";
|
||||
case "linea":
|
||||
return "linea-mainnet.infura.io";
|
||||
case "linea-goerli":
|
||||
return "linea-goerli.infura.io";
|
||||
case "linea-sepolia":
|
||||
return "linea-sepolia.infura.io";
|
||||
case "matic":
|
||||
return "polygon-mainnet.infura.io";
|
||||
case "matic-amoy":
|
||||
return "polygon-amoy.infura.io";
|
||||
case "matic-mumbai":
|
||||
return "polygon-mumbai.infura.io";
|
||||
case "optimism":
|
||||
return "optimism-mainnet.infura.io";
|
||||
case "optimism-goerli":
|
||||
return "optimism-goerli.infura.io";
|
||||
case "optimism-sepolia":
|
||||
return "optimism-sepolia.infura.io";
|
||||
}
|
||||
assertArgument(false, "unsupported network", "network", name);
|
||||
}
|
||||
/**
|
||||
* The **InfuraWebSocketProvider** connects to the [[link-infura]]
|
||||
* WebSocket 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-infura-signup).
|
||||
*/
|
||||
export class InfuraWebSocketProvider extends WebSocketProvider {
|
||||
/**
|
||||
* The Project ID for the INFURA connection.
|
||||
*/
|
||||
projectId;
|
||||
/**
|
||||
* The Project Secret.
|
||||
*
|
||||
* If null, no authenticated requests are made. This should not
|
||||
* be used outside of private contexts.
|
||||
*/
|
||||
projectSecret;
|
||||
/**
|
||||
* Creates a new **InfuraWebSocketProvider**.
|
||||
*/
|
||||
constructor(network, projectId) {
|
||||
const provider = new InfuraProvider(network, projectId);
|
||||
const req = provider._getConnection();
|
||||
assert(!req.credentials, "INFURA WebSocket project secrets unsupported", "UNSUPPORTED_OPERATION", { operation: "InfuraProvider.getWebSocketProvider()" });
|
||||
const url = req.url.replace(/^http/i, "ws").replace("/v3/", "/ws/v3/");
|
||||
super(url, provider._network);
|
||||
defineProperties(this, {
|
||||
projectId: provider.projectId,
|
||||
projectSecret: provider.projectSecret
|
||||
});
|
||||
}
|
||||
isCommunityResource() {
|
||||
return (this.projectId === defaultProjectId);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* The **InfuraProvider** connects to the [[link-infura]]
|
||||
* 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-infura-signup).
|
||||
*/
|
||||
export class InfuraProvider extends JsonRpcProvider {
|
||||
/**
|
||||
* The Project ID for the INFURA connection.
|
||||
*/
|
||||
projectId;
|
||||
/**
|
||||
* The Project Secret.
|
||||
*
|
||||
* If null, no authenticated requests are made. This should not
|
||||
* be used outside of private contexts.
|
||||
*/
|
||||
projectSecret;
|
||||
/**
|
||||
* Creates a new **InfuraProvider**.
|
||||
*/
|
||||
constructor(_network, projectId, projectSecret) {
|
||||
if (_network == null) {
|
||||
_network = "mainnet";
|
||||
}
|
||||
const network = Network.from(_network);
|
||||
if (projectId == null) {
|
||||
projectId = defaultProjectId;
|
||||
}
|
||||
if (projectSecret == null) {
|
||||
projectSecret = null;
|
||||
}
|
||||
const request = InfuraProvider.getRequest(network, projectId, projectSecret);
|
||||
super(request, network, { staticNetwork: network });
|
||||
defineProperties(this, { projectId, projectSecret });
|
||||
}
|
||||
_getProvider(chainId) {
|
||||
try {
|
||||
return new InfuraProvider(chainId, this.projectId, this.projectSecret);
|
||||
}
|
||||
catch (error) { }
|
||||
return super._getProvider(chainId);
|
||||
}
|
||||
isCommunityResource() {
|
||||
return (this.projectId === defaultProjectId);
|
||||
}
|
||||
/**
|
||||
* Creates a new **InfuraWebSocketProvider**.
|
||||
*/
|
||||
static getWebSocketProvider(network, projectId) {
|
||||
return new InfuraWebSocketProvider(network, projectId);
|
||||
}
|
||||
/**
|
||||
* Returns a prepared request for connecting to %%network%%
|
||||
* with %%projectId%% and %%projectSecret%%.
|
||||
*/
|
||||
static getRequest(network, projectId, projectSecret) {
|
||||
if (projectId == null) {
|
||||
projectId = defaultProjectId;
|
||||
}
|
||||
if (projectSecret == null) {
|
||||
projectSecret = null;
|
||||
}
|
||||
const request = new FetchRequest(`https:/\/${getHost(network.name)}/v3/${projectId}`);
|
||||
request.allowGzip = true;
|
||||
if (projectSecret) {
|
||||
request.setCredentials("", projectSecret);
|
||||
}
|
||||
if (projectId === defaultProjectId) {
|
||||
request.retryFunc = async (request, response, attempt) => {
|
||||
showThrottleMessage("InfuraProvider");
|
||||
return true;
|
||||
};
|
||||
}
|
||||
return request;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=provider-infura.js.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/provider-infura.js.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/provider-infura.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"provider-infura.js","sourceRoot":"","sources":["../../src.ts/providers/provider-infura.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EACH,gBAAgB,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,EACzD,MAAM,mBAAmB,CAAC;AAE3B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C,CAAC;QAC1F,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;QACzB,IAAI,aAAa,EAAE;YAAE,OAAO,CAAC,cAAc,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC;SAAE;QAEjE,IAAI,SAAS,KAAK,gBAAgB,EAAE;YAChC,OAAO,CAAC,SAAS,GAAG,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE;gBACrD,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;gBACtC,OAAO,IAAI,CAAC;YAChB,CAAC,CAAC;SACL;QAED,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ"}
|
||||
3
dev/env/node_modules/ethers/lib.esm/providers/provider-ipcsocket-browser.d.ts
generated
vendored
Executable file
3
dev/env/node_modules/ethers/lib.esm/providers/provider-ipcsocket-browser.d.ts
generated
vendored
Executable file
@@ -0,0 +1,3 @@
|
||||
declare const IpcSocketProvider: undefined;
|
||||
export { IpcSocketProvider };
|
||||
//# sourceMappingURL=provider-ipcsocket-browser.d.ts.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/provider-ipcsocket-browser.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/provider-ipcsocket-browser.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"provider-ipcsocket-browser.d.ts","sourceRoot":"","sources":["../../src.ts/providers/provider-ipcsocket-browser.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,iBAAiB,WAAY,CAAC;AAEpC,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
||||
3
dev/env/node_modules/ethers/lib.esm/providers/provider-ipcsocket-browser.js
generated
vendored
Executable file
3
dev/env/node_modules/ethers/lib.esm/providers/provider-ipcsocket-browser.js
generated
vendored
Executable file
@@ -0,0 +1,3 @@
|
||||
const IpcSocketProvider = undefined;
|
||||
export { IpcSocketProvider };
|
||||
//# sourceMappingURL=provider-ipcsocket-browser.js.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/provider-ipcsocket-browser.js.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/provider-ipcsocket-browser.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"provider-ipcsocket-browser.js","sourceRoot":"","sources":["../../src.ts/providers/provider-ipcsocket-browser.ts"],"names":[],"mappings":"AAAA,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAEpC,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
||||
21
dev/env/node_modules/ethers/lib.esm/providers/provider-ipcsocket.d.ts
generated
vendored
Executable file
21
dev/env/node_modules/ethers/lib.esm/providers/provider-ipcsocket.d.ts
generated
vendored
Executable file
@@ -0,0 +1,21 @@
|
||||
/// <reference types="node" />
|
||||
import { SocketProvider } from "./provider-socket.js";
|
||||
import type { Socket } from "net";
|
||||
import type { JsonRpcApiProviderOptions } from "./provider-jsonrpc.js";
|
||||
import type { Networkish } from "./network.js";
|
||||
/**
|
||||
* An **IpcSocketProvider** connects over an IPC socket on the host
|
||||
* which provides fast access to the node, but requires the node and
|
||||
* the script run on the same machine.
|
||||
*/
|
||||
export declare class IpcSocketProvider extends SocketProvider {
|
||||
#private;
|
||||
/**
|
||||
* The connected socket.
|
||||
*/
|
||||
get socket(): Socket;
|
||||
constructor(path: string, network?: Networkish, options?: JsonRpcApiProviderOptions);
|
||||
destroy(): void;
|
||||
_write(message: string): Promise<void>;
|
||||
}
|
||||
//# sourceMappingURL=provider-ipcsocket.d.ts.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/provider-ipcsocket.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/provider-ipcsocket.d.ts.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"provider-ipcsocket.d.ts","sourceRoot":"","sources":["../../src.ts/providers/provider-ipcsocket.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAElC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAmB/C;;;;GAIG;AACH,qBAAa,iBAAkB,SAAQ,cAAc;;IAGjD;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,CAAyB;gBAEjC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,yBAAyB;IA8BnF,OAAO,IAAI,IAAI;IAOT,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAI/C"}
|
||||
68
dev/env/node_modules/ethers/lib.esm/providers/provider-ipcsocket.js
generated
vendored
Executable file
68
dev/env/node_modules/ethers/lib.esm/providers/provider-ipcsocket.js
generated
vendored
Executable file
@@ -0,0 +1,68 @@
|
||||
import { connect } from "net";
|
||||
import { SocketProvider } from "./provider-socket.js";
|
||||
// @TODO: Is this sufficient? Is this robust? Will newlines occur between
|
||||
// all payloads and only between payloads?
|
||||
function splitBuffer(data) {
|
||||
const messages = [];
|
||||
let lastStart = 0;
|
||||
while (true) {
|
||||
const nl = data.indexOf(10, lastStart);
|
||||
if (nl === -1) {
|
||||
break;
|
||||
}
|
||||
messages.push(data.subarray(lastStart, nl).toString().trim());
|
||||
lastStart = nl + 1;
|
||||
}
|
||||
return { messages, remaining: data.subarray(lastStart) };
|
||||
}
|
||||
/**
|
||||
* An **IpcSocketProvider** connects over an IPC socket on the host
|
||||
* which provides fast access to the node, but requires the node and
|
||||
* the script run on the same machine.
|
||||
*/
|
||||
export class IpcSocketProvider extends SocketProvider {
|
||||
#socket;
|
||||
/**
|
||||
* The connected socket.
|
||||
*/
|
||||
get socket() { return this.#socket; }
|
||||
constructor(path, network, options) {
|
||||
super(network, options);
|
||||
this.#socket = connect(path);
|
||||
this.socket.on("ready", async () => {
|
||||
try {
|
||||
await this._start();
|
||||
}
|
||||
catch (error) {
|
||||
console.log("failed to start IpcSocketProvider", error);
|
||||
// @TODO: Now what? Restart?
|
||||
}
|
||||
});
|
||||
let response = Buffer.alloc(0);
|
||||
this.socket.on("data", (data) => {
|
||||
response = Buffer.concat([response, data]);
|
||||
const { messages, remaining } = splitBuffer(response);
|
||||
messages.forEach((message) => {
|
||||
this._processMessage(message);
|
||||
});
|
||||
response = remaining;
|
||||
});
|
||||
this.socket.on("end", () => {
|
||||
this.emit("close");
|
||||
this.socket.destroy();
|
||||
this.socket.end();
|
||||
});
|
||||
}
|
||||
destroy() {
|
||||
this.socket.destroy();
|
||||
this.socket.end();
|
||||
super.destroy();
|
||||
}
|
||||
async _write(message) {
|
||||
if (!message.endsWith("\n")) {
|
||||
message += "\n";
|
||||
}
|
||||
this.socket.write(message);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=provider-ipcsocket.js.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/provider-ipcsocket.js.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/provider-ipcsocket.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"provider-ipcsocket.js","sourceRoot":"","sources":["../../src.ts/providers/provider-ipcsocket.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAQtD,yEAAyE;AACzE,0CAA0C;AAC1C,SAAS,WAAW,CAAC,IAAY;IAC7B,MAAM,QAAQ,GAAkB,EAAG,CAAC;IAEpC,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,OAAO,IAAI,EAAE;QACT,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;QACvC,IAAI,EAAE,KAAK,CAAC,CAAC,EAAE;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AO,EAAE,EAAE;gBACzB,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;YAClC,CAAC,CAAC,CAAC;YACH,QAAQ,GAAG,SAAS,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;YACvB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACnB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACtB,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;QACtB,CAAC,CAAC,CAAC;IACP,CAAC;IAED,OAAO;QACH,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;QAElB,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAe;QACxB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;YAAE,OAAO,IAAI,IAAI,CAAC;SAAE;QACjD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;CACJ"}
|
||||
361
dev/env/node_modules/ethers/lib.esm/providers/provider-jsonrpc.d.ts
generated
vendored
Executable file
361
dev/env/node_modules/ethers/lib.esm/providers/provider-jsonrpc.d.ts
generated
vendored
Executable file
@@ -0,0 +1,361 @@
|
||||
/**
|
||||
* One of the most common ways to interact with the blockchain is
|
||||
* by a node running a JSON-RPC interface which can be connected to,
|
||||
* based on the transport, using:
|
||||
*
|
||||
* - HTTP or HTTPS - [[JsonRpcProvider]]
|
||||
* - WebSocket - [[WebSocketProvider]]
|
||||
* - IPC - [[IpcSocketProvider]]
|
||||
*
|
||||
* @_section: api/providers/jsonrpc:JSON-RPC Provider [about-jsonrpcProvider]
|
||||
*/
|
||||
import { FetchRequest } from "../utils/index.js";
|
||||
import { AbstractProvider } from "./abstract-provider.js";
|
||||
import { AbstractSigner } from "./abstract-signer.js";
|
||||
import { Network } from "./network.js";
|
||||
import type { TypedDataDomain, TypedDataField } from "../hash/index.js";
|
||||
import type { TransactionLike } from "../transaction/index.js";
|
||||
import type { PerformActionRequest, Subscriber, Subscription } from "./abstract-provider.js";
|
||||
import type { Networkish } from "./network.js";
|
||||
import type { Provider, TransactionRequest, TransactionResponse } from "./provider.js";
|
||||
import type { Signer } from "./signer.js";
|
||||
/**
|
||||
* A JSON-RPC payload, which are sent to a JSON-RPC server.
|
||||
*/
|
||||
export type JsonRpcPayload = {
|
||||
/**
|
||||
* The JSON-RPC request ID.
|
||||
*/
|
||||
id: number;
|
||||
/**
|
||||
* The JSON-RPC request method.
|
||||
*/
|
||||
method: string;
|
||||
/**
|
||||
* The JSON-RPC request parameters.
|
||||
*/
|
||||
params: Array<any> | Record<string, any>;
|
||||
/**
|
||||
* A required constant in the JSON-RPC specification.
|
||||
*/
|
||||
jsonrpc: "2.0";
|
||||
};
|
||||
/**
|
||||
* A JSON-RPC result, which are returned on success from a JSON-RPC server.
|
||||
*/
|
||||
export type JsonRpcResult = {
|
||||
/**
|
||||
* The response ID to match it to the relevant request.
|
||||
*/
|
||||
id: number;
|
||||
/**
|
||||
* The response result.
|
||||
*/
|
||||
result: any;
|
||||
};
|
||||
/**
|
||||
* A JSON-RPC error, which are returned on failure from a JSON-RPC server.
|
||||
*/
|
||||
export type JsonRpcError = {
|
||||
/**
|
||||
* The response ID to match it to the relevant request.
|
||||
*/
|
||||
id: number;
|
||||
/**
|
||||
* The response error.
|
||||
*/
|
||||
error: {
|
||||
code: number;
|
||||
message?: string;
|
||||
data?: any;
|
||||
};
|
||||
};
|
||||
/**
|
||||
* When subscribing to the ``"debug"`` event, the [[Listener]] will
|
||||
* receive this object as the first parameter.
|
||||
*/
|
||||
export type DebugEventJsonRpcApiProvider = {
|
||||
action: "sendRpcPayload";
|
||||
payload: JsonRpcPayload | Array<JsonRpcPayload>;
|
||||
} | {
|
||||
action: "receiveRpcResult";
|
||||
result: Array<JsonRpcResult | JsonRpcError>;
|
||||
} | {
|
||||
action: "receiveRpcError";
|
||||
error: Error;
|
||||
};
|
||||
/**
|
||||
* Options for configuring a [[JsonRpcApiProvider]]. Much of this
|
||||
* is targetted towards sub-classes, which often will not expose
|
||||
* any of these options to their consumers.
|
||||
*
|
||||
* **``polling``** - use the polling strategy is used immediately
|
||||
* for events; otherwise, attempt to use filters and fall back onto
|
||||
* polling (default: ``false``)
|
||||
*
|
||||
* **``staticNetwork``** - do not request chain ID on requests to
|
||||
* validate the underlying chain has not changed (default: ``null``)
|
||||
*
|
||||
* This should **ONLY** be used if it is **certain** that the network
|
||||
* cannot change, such as when using INFURA (since the URL dictates the
|
||||
* network). If the network is assumed static and it does change, this
|
||||
* can have tragic consequences. For example, this **CANNOT** be used
|
||||
* with MetaMask, since the user can select a new network from the
|
||||
* drop-down at any time.
|
||||
*
|
||||
* **``batchStallTime``** - how long (ms) to aggregate requests into a
|
||||
* single batch. ``0`` indicates batching will only encompass the current
|
||||
* event loop. If ``batchMaxCount = 1``, this is ignored. (default: ``10``)
|
||||
*
|
||||
* **``batchMaxSize``** - target maximum size (bytes) to allow per batch
|
||||
* request (default: 1Mb)
|
||||
*
|
||||
* **``batchMaxCount``** - maximum number of requests to allow in a batch.
|
||||
* If ``batchMaxCount = 1``, then batching is disabled. (default: ``100``)
|
||||
*
|
||||
* **``cacheTimeout``** - passed as [[AbstractProviderOptions]].
|
||||
*/
|
||||
export type JsonRpcApiProviderOptions = {
|
||||
polling?: boolean;
|
||||
staticNetwork?: null | boolean | Network;
|
||||
batchStallTime?: number;
|
||||
batchMaxSize?: number;
|
||||
batchMaxCount?: number;
|
||||
cacheTimeout?: number;
|
||||
pollingInterval?: number;
|
||||
};
|
||||
/**
|
||||
* A **JsonRpcTransactionRequest** is formatted as needed by the JSON-RPC
|
||||
* Ethereum API specification.
|
||||
*/
|
||||
export interface JsonRpcTransactionRequest {
|
||||
/**
|
||||
* The sender address to use when signing.
|
||||
*/
|
||||
from?: string;
|
||||
/**
|
||||
* The target address.
|
||||
*/
|
||||
to?: string;
|
||||
/**
|
||||
* The transaction data.
|
||||
*/
|
||||
data?: string;
|
||||
/**
|
||||
* The chain ID the transaction is valid on.
|
||||
*/
|
||||
chainId?: string;
|
||||
/**
|
||||
* The [[link-eip-2718]] transaction type.
|
||||
*/
|
||||
type?: string;
|
||||
/**
|
||||
* The maximum amount of gas to allow a transaction to consume.
|
||||
*
|
||||
* In most other places in ethers, this is called ``gasLimit`` which
|
||||
* differs from the JSON-RPC Ethereum API specification.
|
||||
*/
|
||||
gas?: string;
|
||||
/**
|
||||
* The gas price per wei for transactions prior to [[link-eip-1559]].
|
||||
*/
|
||||
gasPrice?: string;
|
||||
/**
|
||||
* The maximum fee per gas for [[link-eip-1559]] transactions.
|
||||
*/
|
||||
maxFeePerGas?: string;
|
||||
/**
|
||||
* The maximum priority fee per gas for [[link-eip-1559]] transactions.
|
||||
*/
|
||||
maxPriorityFeePerGas?: string;
|
||||
/**
|
||||
* The nonce for the transaction.
|
||||
*/
|
||||
nonce?: string;
|
||||
/**
|
||||
* The transaction value (in wei).
|
||||
*/
|
||||
value?: string;
|
||||
/**
|
||||
* The transaction access list.
|
||||
*/
|
||||
accessList?: Array<{
|
||||
address: string;
|
||||
storageKeys: Array<string>;
|
||||
}>;
|
||||
/**
|
||||
* The transaction authorization list.
|
||||
*/
|
||||
authorizationList?: Array<{
|
||||
address: string;
|
||||
nonce: string;
|
||||
chainId: string;
|
||||
yParity: string;
|
||||
r: string;
|
||||
s: string;
|
||||
}>;
|
||||
}
|
||||
export declare class JsonRpcSigner extends AbstractSigner<JsonRpcApiProvider> {
|
||||
address: string;
|
||||
constructor(provider: JsonRpcApiProvider, address: string);
|
||||
connect(provider: null | Provider): Signer;
|
||||
getAddress(): Promise<string>;
|
||||
populateTransaction(tx: TransactionRequest): Promise<TransactionLike<string>>;
|
||||
sendUncheckedTransaction(_tx: TransactionRequest): Promise<string>;
|
||||
sendTransaction(tx: TransactionRequest): Promise<TransactionResponse>;
|
||||
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>;
|
||||
unlock(password: string): Promise<boolean>;
|
||||
_legacySignMessage(_message: string | Uint8Array): Promise<string>;
|
||||
}
|
||||
/**
|
||||
* The JsonRpcApiProvider is an abstract class and **MUST** be
|
||||
* sub-classed.
|
||||
*
|
||||
* It provides the base for all JSON-RPC-based Provider interaction.
|
||||
*
|
||||
* Sub-classing Notes:
|
||||
* - a sub-class MUST override _send
|
||||
* - a sub-class MUST call the `_start()` method once connected
|
||||
*/
|
||||
export declare abstract class JsonRpcApiProvider extends AbstractProvider {
|
||||
#private;
|
||||
constructor(network?: Networkish, options?: JsonRpcApiProviderOptions);
|
||||
/**
|
||||
* Returns the value associated with the option %%key%%.
|
||||
*
|
||||
* Sub-classes can use this to inquire about configuration options.
|
||||
*/
|
||||
_getOption<K extends keyof JsonRpcApiProviderOptions>(key: K): JsonRpcApiProviderOptions[K];
|
||||
/**
|
||||
* Gets the [[Network]] this provider has committed to. On each call, the network
|
||||
* is detected, and if it has changed, the call will reject.
|
||||
*/
|
||||
get _network(): Network;
|
||||
/**
|
||||
* Sends a JSON-RPC %%payload%% (or a batch) to the underlying channel.
|
||||
*
|
||||
* Sub-classes **MUST** override this.
|
||||
*/
|
||||
abstract _send(payload: JsonRpcPayload | Array<JsonRpcPayload>): Promise<Array<JsonRpcResult | JsonRpcError>>;
|
||||
/**
|
||||
* Resolves to the non-normalized value by performing %%req%%.
|
||||
*
|
||||
* Sub-classes may override this to modify behavior of actions,
|
||||
* and should generally call ``super._perform`` as a fallback.
|
||||
*/
|
||||
_perform(req: PerformActionRequest): Promise<any>;
|
||||
/**
|
||||
* Sub-classes may override this; it detects the *actual* network that
|
||||
* we are **currently** connected to.
|
||||
*
|
||||
* Keep in mind that [[send]] may only be used once [[ready]], otherwise the
|
||||
* _send primitive must be used instead.
|
||||
*/
|
||||
_detectNetwork(): Promise<Network>;
|
||||
/**
|
||||
* Sub-classes **MUST** call this. Until [[_start]] has been called, no calls
|
||||
* will be passed to [[_send]] from [[send]]. If it is overridden, then
|
||||
* ``super._start()`` **MUST** be called.
|
||||
*
|
||||
* Calling it multiple times is safe and has no effect.
|
||||
*/
|
||||
_start(): void;
|
||||
/**
|
||||
* Resolves once the [[_start]] has been called. This can be used in
|
||||
* sub-classes to defer sending data until the connection has been
|
||||
* established.
|
||||
*/
|
||||
_waitUntilReady(): Promise<void>;
|
||||
/**
|
||||
* Return a Subscriber that will manage the %%sub%%.
|
||||
*
|
||||
* Sub-classes may override this to modify the behavior of
|
||||
* subscription management.
|
||||
*/
|
||||
_getSubscriber(sub: Subscription): Subscriber;
|
||||
/**
|
||||
* Returns true only if the [[_start]] has been called.
|
||||
*/
|
||||
get ready(): boolean;
|
||||
/**
|
||||
* Returns %%tx%% as a normalized JSON-RPC transaction request,
|
||||
* which has all values hexlified and any numeric values converted
|
||||
* to Quantity values.
|
||||
*/
|
||||
getRpcTransaction(tx: TransactionRequest): JsonRpcTransactionRequest;
|
||||
/**
|
||||
* Returns the request method and arguments required to perform
|
||||
* %%req%%.
|
||||
*/
|
||||
getRpcRequest(req: PerformActionRequest): null | {
|
||||
method: string;
|
||||
args: Array<any>;
|
||||
};
|
||||
/**
|
||||
* Returns an ethers-style Error for the given JSON-RPC error
|
||||
* %%payload%%, coalescing the various strings and error shapes
|
||||
* that different nodes return, coercing them into a machine-readable
|
||||
* standardized error.
|
||||
*/
|
||||
getRpcError(payload: JsonRpcPayload, _error: JsonRpcError): Error;
|
||||
/**
|
||||
* Requests the %%method%% with %%params%% via the JSON-RPC protocol
|
||||
* over the underlying channel. This can be used to call methods
|
||||
* on the backend that do not have a high-level API within the Provider
|
||||
* API.
|
||||
*
|
||||
* This method queues requests according to the batch constraints
|
||||
* in the options, assigns the request a unique ID.
|
||||
*
|
||||
* **Do NOT override** this method in sub-classes; instead
|
||||
* override [[_send]] or force the options values in the
|
||||
* call to the constructor to modify this method's behavior.
|
||||
*/
|
||||
send(method: string, params: Array<any> | Record<string, any>): Promise<any>;
|
||||
/**
|
||||
* Resolves to the [[Signer]] account for %%address%% managed by
|
||||
* the client.
|
||||
*
|
||||
* If the %%address%% is a number, it is used as an index in the
|
||||
* the accounts from [[listAccounts]].
|
||||
*
|
||||
* This can only be used on clients which manage accounts (such as
|
||||
* Geth with imported account or MetaMask).
|
||||
*
|
||||
* Throws if the account doesn't exist.
|
||||
*/
|
||||
getSigner(address?: number | string): Promise<JsonRpcSigner>;
|
||||
listAccounts(): Promise<Array<JsonRpcSigner>>;
|
||||
destroy(): void;
|
||||
}
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
export declare abstract class JsonRpcApiPollingProvider extends JsonRpcApiProvider {
|
||||
#private;
|
||||
constructor(network?: Networkish, options?: JsonRpcApiProviderOptions);
|
||||
_getSubscriber(sub: Subscription): Subscriber;
|
||||
/**
|
||||
* The polling interval (default: 4000 ms)
|
||||
*/
|
||||
get pollingInterval(): number;
|
||||
set pollingInterval(value: number);
|
||||
}
|
||||
/**
|
||||
* The JsonRpcProvider is one of the most common Providers,
|
||||
* which performs all operations over HTTP (or HTTPS) requests.
|
||||
*
|
||||
* Events are processed by polling the backend for the current block
|
||||
* number; when it advances, all block-base events are then checked
|
||||
* for updates.
|
||||
*/
|
||||
export declare class JsonRpcProvider extends JsonRpcApiPollingProvider {
|
||||
#private;
|
||||
constructor(url?: string | FetchRequest, network?: Networkish, options?: JsonRpcApiProviderOptions);
|
||||
_getConnection(): FetchRequest;
|
||||
send(method: string, params: Array<any> | Record<string, any>): Promise<any>;
|
||||
_send(payload: JsonRpcPayload | Array<JsonRpcPayload>): Promise<Array<JsonRpcResult>>;
|
||||
}
|
||||
//# sourceMappingURL=provider-jsonrpc.d.ts.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/provider-jsonrpc.d.ts.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/provider-jsonrpc.d.ts.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
973
dev/env/node_modules/ethers/lib.esm/providers/provider-jsonrpc.js
generated
vendored
Executable file
973
dev/env/node_modules/ethers/lib.esm/providers/provider-jsonrpc.js
generated
vendored
Executable file
@@ -0,0 +1,973 @@
|
||||
/**
|
||||
* One of the most common ways to interact with the blockchain is
|
||||
* by a node running a JSON-RPC interface which can be connected to,
|
||||
* based on the transport, using:
|
||||
*
|
||||
* - HTTP or HTTPS - [[JsonRpcProvider]]
|
||||
* - WebSocket - [[WebSocketProvider]]
|
||||
* - IPC - [[IpcSocketProvider]]
|
||||
*
|
||||
* @_section: api/providers/jsonrpc:JSON-RPC Provider [about-jsonrpcProvider]
|
||||
*/
|
||||
// @TODO:
|
||||
// - Add the batching API
|
||||
// https://playground.open-rpc.org/?schemaUrl=https://raw.githubusercontent.com/ethereum/eth1.0-apis/assembled-spec/openrpc.json&uiSchema%5BappBar%5D%5Bui:splitView%5D=true&uiSchema%5BappBar%5D%5Bui:input%5D=false&uiSchema%5BappBar%5D%5Bui:examplesDropdown%5D=false
|
||||
import { AbiCoder } from "../abi/index.js";
|
||||
import { getAddress, resolveAddress } from "../address/index.js";
|
||||
import { TypedDataEncoder } from "../hash/index.js";
|
||||
import { accessListify, authorizationify } from "../transaction/index.js";
|
||||
import { defineProperties, getBigInt, hexlify, isHexString, toQuantity, toUtf8Bytes, isError, makeError, assert, assertArgument, FetchRequest, resolveProperties } from "../utils/index.js";
|
||||
import { AbstractProvider, UnmanagedSubscriber } from "./abstract-provider.js";
|
||||
import { AbstractSigner } from "./abstract-signer.js";
|
||||
import { Network } from "./network.js";
|
||||
import { FilterIdEventSubscriber, FilterIdPendingSubscriber } from "./subscriber-filterid.js";
|
||||
import { PollingEventSubscriber } from "./subscriber-polling.js";
|
||||
const Primitive = "bigint,boolean,function,number,string,symbol".split(/,/g);
|
||||
//const Methods = "getAddress,then".split(/,/g);
|
||||
function deepCopy(value) {
|
||||
if (value == null || Primitive.indexOf(typeof (value)) >= 0) {
|
||||
return value;
|
||||
}
|
||||
// Keep any Addressable
|
||||
if (typeof (value.getAddress) === "function") {
|
||||
return value;
|
||||
}
|
||||
if (Array.isArray(value)) {
|
||||
return (value.map(deepCopy));
|
||||
}
|
||||
if (typeof (value) === "object") {
|
||||
return Object.keys(value).reduce((accum, key) => {
|
||||
accum[key] = value[key];
|
||||
return accum;
|
||||
}, {});
|
||||
}
|
||||
throw new Error(`should not happen: ${value} (${typeof (value)})`);
|
||||
}
|
||||
function stall(duration) {
|
||||
return new Promise((resolve) => { setTimeout(resolve, duration); });
|
||||
}
|
||||
function getLowerCase(value) {
|
||||
if (value) {
|
||||
return value.toLowerCase();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
function isPollable(value) {
|
||||
return (value && typeof (value.pollingInterval) === "number");
|
||||
}
|
||||
const defaultOptions = {
|
||||
polling: false,
|
||||
staticNetwork: null,
|
||||
batchStallTime: 10,
|
||||
batchMaxSize: (1 << 20),
|
||||
batchMaxCount: 100,
|
||||
cacheTimeout: 250,
|
||||
pollingInterval: 4000
|
||||
};
|
||||
// @TODO: Unchecked Signers
|
||||
export class JsonRpcSigner extends AbstractSigner {
|
||||
address;
|
||||
constructor(provider, address) {
|
||||
super(provider);
|
||||
address = getAddress(address);
|
||||
defineProperties(this, { address });
|
||||
}
|
||||
connect(provider) {
|
||||
assert(false, "cannot reconnect JsonRpcSigner", "UNSUPPORTED_OPERATION", {
|
||||
operation: "signer.connect"
|
||||
});
|
||||
}
|
||||
async getAddress() {
|
||||
return this.address;
|
||||
}
|
||||
// JSON-RPC will automatially fill in nonce, etc. so we just check from
|
||||
async populateTransaction(tx) {
|
||||
return await this.populateCall(tx);
|
||||
}
|
||||
// Returns just the hash of the transaction after sent, which is what
|
||||
// the bare JSON-RPC API does;
|
||||
async sendUncheckedTransaction(_tx) {
|
||||
const tx = deepCopy(_tx);
|
||||
const promises = [];
|
||||
// Make sure the from matches the sender
|
||||
if (tx.from) {
|
||||
const _from = tx.from;
|
||||
promises.push((async () => {
|
||||
const from = await resolveAddress(_from, this.provider);
|
||||
assertArgument(from != null && from.toLowerCase() === this.address.toLowerCase(), "from address mismatch", "transaction", _tx);
|
||||
tx.from = from;
|
||||
})());
|
||||
}
|
||||
else {
|
||||
tx.from = this.address;
|
||||
}
|
||||
// The JSON-RPC for eth_sendTransaction uses 90000 gas; if the user
|
||||
// wishes to use this, it is easy to specify explicitly, otherwise
|
||||
// we look it up for them.
|
||||
if (tx.gasLimit == null) {
|
||||
promises.push((async () => {
|
||||
tx.gasLimit = await this.provider.estimateGas({ ...tx, from: this.address });
|
||||
})());
|
||||
}
|
||||
// The address may be an ENS name or Addressable
|
||||
if (tx.to != null) {
|
||||
const _to = tx.to;
|
||||
promises.push((async () => {
|
||||
tx.to = await resolveAddress(_to, this.provider);
|
||||
})());
|
||||
}
|
||||
// Wait until all of our properties are filled in
|
||||
if (promises.length) {
|
||||
await Promise.all(promises);
|
||||
}
|
||||
const hexTx = this.provider.getRpcTransaction(tx);
|
||||
return this.provider.send("eth_sendTransaction", [hexTx]);
|
||||
}
|
||||
async sendTransaction(tx) {
|
||||
// This cannot be mined any earlier than any recent block
|
||||
const blockNumber = await this.provider.getBlockNumber();
|
||||
// Send the transaction
|
||||
const hash = await this.sendUncheckedTransaction(tx);
|
||||
// Unfortunately, JSON-RPC only provides and opaque transaction hash
|
||||
// for a response, and we need the actual transaction, so we poll
|
||||
// for it; it should show up very quickly
|
||||
return await (new Promise((resolve, reject) => {
|
||||
const timeouts = [1000, 100];
|
||||
let invalids = 0;
|
||||
const checkTx = async () => {
|
||||
try {
|
||||
// Try getting the transaction
|
||||
const tx = await this.provider.getTransaction(hash);
|
||||
if (tx != null) {
|
||||
resolve(tx.replaceableTransaction(blockNumber));
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
// If we were cancelled: stop polling.
|
||||
// If the data is bad: the node returns bad transactions
|
||||
// If the network changed: calling again will also fail
|
||||
// If unsupported: likely destroyed
|
||||
if (isError(error, "CANCELLED") || isError(error, "BAD_DATA") ||
|
||||
isError(error, "NETWORK_ERROR") || isError(error, "UNSUPPORTED_OPERATION")) {
|
||||
if (error.info == null) {
|
||||
error.info = {};
|
||||
}
|
||||
error.info.sendTransactionHash = hash;
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
// Stop-gap for misbehaving backends; see #4513
|
||||
if (isError(error, "INVALID_ARGUMENT")) {
|
||||
invalids++;
|
||||
if (error.info == null) {
|
||||
error.info = {};
|
||||
}
|
||||
error.info.sendTransactionHash = hash;
|
||||
if (invalids > 10) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Notify anyone that cares; but we will try again, since
|
||||
// it is likely an intermittent service error
|
||||
this.provider.emit("error", makeError("failed to fetch transation after sending (will try again)", "UNKNOWN_ERROR", { error }));
|
||||
}
|
||||
// Wait another 4 seconds
|
||||
this.provider._setTimeout(() => { checkTx(); }, timeouts.pop() || 4000);
|
||||
};
|
||||
checkTx();
|
||||
}));
|
||||
}
|
||||
async signTransaction(_tx) {
|
||||
const tx = deepCopy(_tx);
|
||||
// Make sure the from matches the sender
|
||||
if (tx.from) {
|
||||
const from = await resolveAddress(tx.from, this.provider);
|
||||
assertArgument(from != null && from.toLowerCase() === this.address.toLowerCase(), "from address mismatch", "transaction", _tx);
|
||||
tx.from = from;
|
||||
}
|
||||
else {
|
||||
tx.from = this.address;
|
||||
}
|
||||
const hexTx = this.provider.getRpcTransaction(tx);
|
||||
return await this.provider.send("eth_signTransaction", [hexTx]);
|
||||
}
|
||||
async signMessage(_message) {
|
||||
const message = ((typeof (_message) === "string") ? toUtf8Bytes(_message) : _message);
|
||||
return await this.provider.send("personal_sign", [
|
||||
hexlify(message), this.address.toLowerCase()
|
||||
]);
|
||||
}
|
||||
async signTypedData(domain, types, _value) {
|
||||
const value = deepCopy(_value);
|
||||
// Populate any ENS names (in-place)
|
||||
const populated = await TypedDataEncoder.resolveNames(domain, types, value, async (value) => {
|
||||
const address = await resolveAddress(value);
|
||||
assertArgument(address != null, "TypedData does not support null address", "value", value);
|
||||
return address;
|
||||
});
|
||||
return await this.provider.send("eth_signTypedData_v4", [
|
||||
this.address.toLowerCase(),
|
||||
JSON.stringify(TypedDataEncoder.getPayload(populated.domain, types, populated.value))
|
||||
]);
|
||||
}
|
||||
async unlock(password) {
|
||||
return this.provider.send("personal_unlockAccount", [
|
||||
this.address.toLowerCase(), password, null
|
||||
]);
|
||||
}
|
||||
// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign
|
||||
async _legacySignMessage(_message) {
|
||||
const message = ((typeof (_message) === "string") ? toUtf8Bytes(_message) : _message);
|
||||
return await this.provider.send("eth_sign", [
|
||||
this.address.toLowerCase(), hexlify(message)
|
||||
]);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* The JsonRpcApiProvider is an abstract class and **MUST** be
|
||||
* sub-classed.
|
||||
*
|
||||
* It provides the base for all JSON-RPC-based Provider interaction.
|
||||
*
|
||||
* Sub-classing Notes:
|
||||
* - a sub-class MUST override _send
|
||||
* - a sub-class MUST call the `_start()` method once connected
|
||||
*/
|
||||
export class JsonRpcApiProvider extends AbstractProvider {
|
||||
#options;
|
||||
// The next ID to use for the JSON-RPC ID field
|
||||
#nextId;
|
||||
// Payloads are queued and triggered in batches using the drainTimer
|
||||
#payloads;
|
||||
#drainTimer;
|
||||
#notReady;
|
||||
#network;
|
||||
#pendingDetectNetwork;
|
||||
#scheduleDrain() {
|
||||
if (this.#drainTimer) {
|
||||
return;
|
||||
}
|
||||
// If we aren't using batching, no harm in sending it immediately
|
||||
const stallTime = (this._getOption("batchMaxCount") === 1) ? 0 : this._getOption("batchStallTime");
|
||||
this.#drainTimer = setTimeout(() => {
|
||||
this.#drainTimer = null;
|
||||
const payloads = this.#payloads;
|
||||
this.#payloads = [];
|
||||
while (payloads.length) {
|
||||
// Create payload batches that satisfy our batch constraints
|
||||
const batch = [(payloads.shift())];
|
||||
while (payloads.length) {
|
||||
if (batch.length === this.#options.batchMaxCount) {
|
||||
break;
|
||||
}
|
||||
batch.push((payloads.shift()));
|
||||
const bytes = JSON.stringify(batch.map((p) => p.payload));
|
||||
if (bytes.length > this.#options.batchMaxSize) {
|
||||
payloads.unshift((batch.pop()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Process the result to each payload
|
||||
(async () => {
|
||||
const payload = ((batch.length === 1) ? batch[0].payload : batch.map((p) => p.payload));
|
||||
this.emit("debug", { action: "sendRpcPayload", payload });
|
||||
try {
|
||||
const result = await this._send(payload);
|
||||
this.emit("debug", { action: "receiveRpcResult", result });
|
||||
// Process results in batch order
|
||||
for (const { resolve, reject, payload } of batch) {
|
||||
if (this.destroyed) {
|
||||
reject(makeError("provider destroyed; cancelled request", "UNSUPPORTED_OPERATION", { operation: payload.method }));
|
||||
continue;
|
||||
}
|
||||
// Find the matching result
|
||||
const resp = result.filter((r) => (r.id === payload.id))[0];
|
||||
// No result; the node failed us in unexpected ways
|
||||
if (resp == null) {
|
||||
const error = makeError("missing response for request", "BAD_DATA", {
|
||||
value: result, info: { payload }
|
||||
});
|
||||
this.emit("error", error);
|
||||
reject(error);
|
||||
continue;
|
||||
}
|
||||
// The response is an error
|
||||
if ("error" in resp) {
|
||||
reject(this.getRpcError(payload, resp));
|
||||
continue;
|
||||
}
|
||||
// All good; send the result
|
||||
resolve(resp.result);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
this.emit("debug", { action: "receiveRpcError", error });
|
||||
for (const { reject } of batch) {
|
||||
// @TODO: augment the error with the payload
|
||||
reject(error);
|
||||
}
|
||||
}
|
||||
})();
|
||||
}
|
||||
}, stallTime);
|
||||
}
|
||||
constructor(network, options) {
|
||||
super(network, options);
|
||||
this.#nextId = 1;
|
||||
this.#options = Object.assign({}, defaultOptions, options || {});
|
||||
this.#payloads = [];
|
||||
this.#drainTimer = null;
|
||||
this.#network = null;
|
||||
this.#pendingDetectNetwork = null;
|
||||
{
|
||||
let resolve = null;
|
||||
const promise = new Promise((_resolve) => {
|
||||
resolve = _resolve;
|
||||
});
|
||||
this.#notReady = { promise, resolve };
|
||||
}
|
||||
const staticNetwork = this._getOption("staticNetwork");
|
||||
if (typeof (staticNetwork) === "boolean") {
|
||||
assertArgument(!staticNetwork || network !== "any", "staticNetwork cannot be used on special network 'any'", "options", options);
|
||||
if (staticNetwork && network != null) {
|
||||
this.#network = Network.from(network);
|
||||
}
|
||||
}
|
||||
else if (staticNetwork) {
|
||||
// Make sure any static network is compatbile with the provided netwrok
|
||||
assertArgument(network == null || staticNetwork.matches(network), "staticNetwork MUST match network object", "options", options);
|
||||
this.#network = staticNetwork;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns the value associated with the option %%key%%.
|
||||
*
|
||||
* Sub-classes can use this to inquire about configuration options.
|
||||
*/
|
||||
_getOption(key) {
|
||||
return this.#options[key];
|
||||
}
|
||||
/**
|
||||
* Gets the [[Network]] this provider has committed to. On each call, the network
|
||||
* is detected, and if it has changed, the call will reject.
|
||||
*/
|
||||
get _network() {
|
||||
assert(this.#network, "network is not available yet", "NETWORK_ERROR");
|
||||
return this.#network;
|
||||
}
|
||||
/**
|
||||
* Resolves to the non-normalized value by performing %%req%%.
|
||||
*
|
||||
* Sub-classes may override this to modify behavior of actions,
|
||||
* and should generally call ``super._perform`` as a fallback.
|
||||
*/
|
||||
async _perform(req) {
|
||||
// Legacy networks do not like the type field being passed along (which
|
||||
// is fair), so we delete type if it is 0 and a non-EIP-1559 network
|
||||
if (req.method === "call" || req.method === "estimateGas") {
|
||||
let tx = req.transaction;
|
||||
if (tx && tx.type != null && getBigInt(tx.type)) {
|
||||
// If there are no EIP-1559 or newer properties, it might be pre-EIP-1559
|
||||
if (tx.maxFeePerGas == null && tx.maxPriorityFeePerGas == null) {
|
||||
const feeData = await this.getFeeData();
|
||||
if (feeData.maxFeePerGas == null && feeData.maxPriorityFeePerGas == null) {
|
||||
// Network doesn't know about EIP-1559 (and hence type)
|
||||
req = Object.assign({}, req, {
|
||||
transaction: Object.assign({}, tx, { type: undefined })
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const request = this.getRpcRequest(req);
|
||||
if (request != null) {
|
||||
return await this.send(request.method, request.args);
|
||||
}
|
||||
return super._perform(req);
|
||||
}
|
||||
/**
|
||||
* Sub-classes may override this; it detects the *actual* network that
|
||||
* we are **currently** connected to.
|
||||
*
|
||||
* Keep in mind that [[send]] may only be used once [[ready]], otherwise the
|
||||
* _send primitive must be used instead.
|
||||
*/
|
||||
async _detectNetwork() {
|
||||
const network = this._getOption("staticNetwork");
|
||||
if (network) {
|
||||
if (network === true) {
|
||||
if (this.#network) {
|
||||
return this.#network;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return network;
|
||||
}
|
||||
}
|
||||
if (this.#pendingDetectNetwork) {
|
||||
return await this.#pendingDetectNetwork;
|
||||
}
|
||||
// If we are ready, use ``send``, which enabled requests to be batched
|
||||
if (this.ready) {
|
||||
this.#pendingDetectNetwork = (async () => {
|
||||
try {
|
||||
const result = Network.from(getBigInt(await this.send("eth_chainId", [])));
|
||||
this.#pendingDetectNetwork = null;
|
||||
return result;
|
||||
}
|
||||
catch (error) {
|
||||
this.#pendingDetectNetwork = null;
|
||||
throw error;
|
||||
}
|
||||
})();
|
||||
return await this.#pendingDetectNetwork;
|
||||
}
|
||||
// We are not ready yet; use the primitive _send
|
||||
this.#pendingDetectNetwork = (async () => {
|
||||
const payload = {
|
||||
id: this.#nextId++, method: "eth_chainId", params: [], jsonrpc: "2.0"
|
||||
};
|
||||
this.emit("debug", { action: "sendRpcPayload", payload });
|
||||
let result;
|
||||
try {
|
||||
result = (await this._send(payload))[0];
|
||||
this.#pendingDetectNetwork = null;
|
||||
}
|
||||
catch (error) {
|
||||
this.#pendingDetectNetwork = null;
|
||||
this.emit("debug", { action: "receiveRpcError", error });
|
||||
throw error;
|
||||
}
|
||||
this.emit("debug", { action: "receiveRpcResult", result });
|
||||
if ("result" in result) {
|
||||
return Network.from(getBigInt(result.result));
|
||||
}
|
||||
throw this.getRpcError(payload, result);
|
||||
})();
|
||||
return await this.#pendingDetectNetwork;
|
||||
}
|
||||
/**
|
||||
* Sub-classes **MUST** call this. Until [[_start]] has been called, no calls
|
||||
* will be passed to [[_send]] from [[send]]. If it is overridden, then
|
||||
* ``super._start()`` **MUST** be called.
|
||||
*
|
||||
* Calling it multiple times is safe and has no effect.
|
||||
*/
|
||||
_start() {
|
||||
if (this.#notReady == null || this.#notReady.resolve == null) {
|
||||
return;
|
||||
}
|
||||
this.#notReady.resolve();
|
||||
this.#notReady = null;
|
||||
(async () => {
|
||||
// Bootstrap the network
|
||||
while (this.#network == null && !this.destroyed) {
|
||||
try {
|
||||
this.#network = await this._detectNetwork();
|
||||
}
|
||||
catch (error) {
|
||||
if (this.destroyed) {
|
||||
break;
|
||||
}
|
||||
console.log("JsonRpcProvider failed to detect network and cannot start up; retry in 1s (perhaps the URL is wrong or the node is not started)");
|
||||
this.emit("error", makeError("failed to bootstrap network detection", "NETWORK_ERROR", { event: "initial-network-discovery", info: { error } }));
|
||||
await stall(1000);
|
||||
}
|
||||
}
|
||||
// Start dispatching requests
|
||||
this.#scheduleDrain();
|
||||
})();
|
||||
}
|
||||
/**
|
||||
* Resolves once the [[_start]] has been called. This can be used in
|
||||
* sub-classes to defer sending data until the connection has been
|
||||
* established.
|
||||
*/
|
||||
async _waitUntilReady() {
|
||||
if (this.#notReady == null) {
|
||||
return;
|
||||
}
|
||||
return await this.#notReady.promise;
|
||||
}
|
||||
/**
|
||||
* Return a Subscriber that will manage the %%sub%%.
|
||||
*
|
||||
* Sub-classes may override this to modify the behavior of
|
||||
* subscription management.
|
||||
*/
|
||||
_getSubscriber(sub) {
|
||||
// Pending Filters aren't availble via polling
|
||||
if (sub.type === "pending") {
|
||||
return new FilterIdPendingSubscriber(this);
|
||||
}
|
||||
if (sub.type === "event") {
|
||||
if (this._getOption("polling")) {
|
||||
return new PollingEventSubscriber(this, sub.filter);
|
||||
}
|
||||
return new FilterIdEventSubscriber(this, sub.filter);
|
||||
}
|
||||
// Orphaned Logs are handled automatically, by the filter, since
|
||||
// logs with removed are emitted by it
|
||||
if (sub.type === "orphan" && sub.filter.orphan === "drop-log") {
|
||||
return new UnmanagedSubscriber("orphan");
|
||||
}
|
||||
return super._getSubscriber(sub);
|
||||
}
|
||||
/**
|
||||
* Returns true only if the [[_start]] has been called.
|
||||
*/
|
||||
get ready() { return this.#notReady == null; }
|
||||
/**
|
||||
* Returns %%tx%% as a normalized JSON-RPC transaction request,
|
||||
* which has all values hexlified and any numeric values converted
|
||||
* to Quantity values.
|
||||
*/
|
||||
getRpcTransaction(tx) {
|
||||
const result = {};
|
||||
// JSON-RPC now requires numeric values to be "quantity" values
|
||||
["chainId", "gasLimit", "gasPrice", "type", "maxFeePerGas", "maxPriorityFeePerGas", "nonce", "value"].forEach((key) => {
|
||||
if (tx[key] == null) {
|
||||
return;
|
||||
}
|
||||
let dstKey = key;
|
||||
if (key === "gasLimit") {
|
||||
dstKey = "gas";
|
||||
}
|
||||
result[dstKey] = toQuantity(getBigInt(tx[key], `tx.${key}`));
|
||||
});
|
||||
// Make sure addresses and data are lowercase
|
||||
["from", "to", "data"].forEach((key) => {
|
||||
if (tx[key] == null) {
|
||||
return;
|
||||
}
|
||||
result[key] = hexlify(tx[key]);
|
||||
});
|
||||
// Normalize the access list object
|
||||
if (tx.accessList) {
|
||||
result["accessList"] = accessListify(tx.accessList);
|
||||
}
|
||||
if (tx.blobVersionedHashes) {
|
||||
// @TODO: Remove this <any> case once EIP-4844 added to prepared tx
|
||||
result["blobVersionedHashes"] = tx.blobVersionedHashes.map(h => h.toLowerCase());
|
||||
}
|
||||
if (tx.authorizationList) {
|
||||
result["authorizationList"] = tx.authorizationList.map((_a) => {
|
||||
const a = authorizationify(_a);
|
||||
return {
|
||||
address: a.address,
|
||||
nonce: toQuantity(a.nonce),
|
||||
chainId: toQuantity(a.chainId),
|
||||
yParity: toQuantity(a.signature.yParity),
|
||||
r: toQuantity(a.signature.r),
|
||||
s: toQuantity(a.signature.s),
|
||||
};
|
||||
});
|
||||
}
|
||||
// @TODO: blobs should probably also be copied over, optionally
|
||||
// accounting for the kzg property to backfill blobVersionedHashes
|
||||
// using the commitment. Or should that be left as an exercise to
|
||||
// the caller?
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Returns the request method and arguments required to perform
|
||||
* %%req%%.
|
||||
*/
|
||||
getRpcRequest(req) {
|
||||
switch (req.method) {
|
||||
case "chainId":
|
||||
return { method: "eth_chainId", args: [] };
|
||||
case "getBlockNumber":
|
||||
return { method: "eth_blockNumber", args: [] };
|
||||
case "getGasPrice":
|
||||
return { method: "eth_gasPrice", args: [] };
|
||||
case "getPriorityFee":
|
||||
return { method: "eth_maxPriorityFeePerGas", args: [] };
|
||||
case "getBalance":
|
||||
return {
|
||||
method: "eth_getBalance",
|
||||
args: [getLowerCase(req.address), req.blockTag]
|
||||
};
|
||||
case "getTransactionCount":
|
||||
return {
|
||||
method: "eth_getTransactionCount",
|
||||
args: [getLowerCase(req.address), req.blockTag]
|
||||
};
|
||||
case "getCode":
|
||||
return {
|
||||
method: "eth_getCode",
|
||||
args: [getLowerCase(req.address), req.blockTag]
|
||||
};
|
||||
case "getStorage":
|
||||
return {
|
||||
method: "eth_getStorageAt",
|
||||
args: [
|
||||
getLowerCase(req.address),
|
||||
("0x" + req.position.toString(16)),
|
||||
req.blockTag
|
||||
]
|
||||
};
|
||||
case "broadcastTransaction":
|
||||
return {
|
||||
method: "eth_sendRawTransaction",
|
||||
args: [req.signedTransaction]
|
||||
};
|
||||
case "getBlock":
|
||||
if ("blockTag" in req) {
|
||||
return {
|
||||
method: "eth_getBlockByNumber",
|
||||
args: [req.blockTag, !!req.includeTransactions]
|
||||
};
|
||||
}
|
||||
else if ("blockHash" in req) {
|
||||
return {
|
||||
method: "eth_getBlockByHash",
|
||||
args: [req.blockHash, !!req.includeTransactions]
|
||||
};
|
||||
}
|
||||
break;
|
||||
case "getTransaction":
|
||||
return {
|
||||
method: "eth_getTransactionByHash",
|
||||
args: [req.hash]
|
||||
};
|
||||
case "getTransactionReceipt":
|
||||
return {
|
||||
method: "eth_getTransactionReceipt",
|
||||
args: [req.hash]
|
||||
};
|
||||
case "call":
|
||||
return {
|
||||
method: "eth_call",
|
||||
args: [this.getRpcTransaction(req.transaction), req.blockTag]
|
||||
};
|
||||
case "estimateGas": {
|
||||
return {
|
||||
method: "eth_estimateGas",
|
||||
args: [this.getRpcTransaction(req.transaction)]
|
||||
};
|
||||
}
|
||||
case "getLogs":
|
||||
if (req.filter && req.filter.address != null) {
|
||||
if (Array.isArray(req.filter.address)) {
|
||||
req.filter.address = req.filter.address.map(getLowerCase);
|
||||
}
|
||||
else {
|
||||
req.filter.address = getLowerCase(req.filter.address);
|
||||
}
|
||||
}
|
||||
return { method: "eth_getLogs", args: [req.filter] };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Returns an ethers-style Error for the given JSON-RPC error
|
||||
* %%payload%%, coalescing the various strings and error shapes
|
||||
* that different nodes return, coercing them into a machine-readable
|
||||
* standardized error.
|
||||
*/
|
||||
getRpcError(payload, _error) {
|
||||
const { method } = payload;
|
||||
const { error } = _error;
|
||||
if (method === "eth_estimateGas" && error.message) {
|
||||
const msg = error.message;
|
||||
if (!msg.match(/revert/i) && msg.match(/insufficient funds/i)) {
|
||||
return makeError("insufficient funds", "INSUFFICIENT_FUNDS", {
|
||||
transaction: (payload.params[0]),
|
||||
info: { payload, error }
|
||||
});
|
||||
}
|
||||
else if (msg.match(/nonce/i) && msg.match(/too low/i)) {
|
||||
return makeError("nonce has already been used", "NONCE_EXPIRED", {
|
||||
transaction: (payload.params[0]),
|
||||
info: { payload, error }
|
||||
});
|
||||
}
|
||||
}
|
||||
if (method === "eth_call" || method === "eth_estimateGas") {
|
||||
const result = spelunkData(error);
|
||||
const e = AbiCoder.getBuiltinCallException((method === "eth_call") ? "call" : "estimateGas", (payload.params[0]), (result ? result.data : null));
|
||||
e.info = { error, payload };
|
||||
return e;
|
||||
}
|
||||
// Only estimateGas and call can return arbitrary contract-defined text, so now we
|
||||
// we can process text safely.
|
||||
const message = JSON.stringify(spelunkMessage(error));
|
||||
if (typeof (error.message) === "string" && error.message.match(/user denied|ethers-user-denied/i)) {
|
||||
const actionMap = {
|
||||
eth_sign: "signMessage",
|
||||
personal_sign: "signMessage",
|
||||
eth_signTypedData_v4: "signTypedData",
|
||||
eth_signTransaction: "signTransaction",
|
||||
eth_sendTransaction: "sendTransaction",
|
||||
eth_requestAccounts: "requestAccess",
|
||||
wallet_requestAccounts: "requestAccess",
|
||||
};
|
||||
return makeError(`user rejected action`, "ACTION_REJECTED", {
|
||||
action: (actionMap[method] || "unknown"),
|
||||
reason: "rejected",
|
||||
info: { payload, error }
|
||||
});
|
||||
}
|
||||
if (method === "eth_sendRawTransaction" || method === "eth_sendTransaction") {
|
||||
const transaction = (payload.params[0]);
|
||||
if (message.match(/insufficient funds|base fee exceeds gas limit/i)) {
|
||||
return makeError("insufficient funds for intrinsic transaction cost", "INSUFFICIENT_FUNDS", {
|
||||
transaction, info: { error }
|
||||
});
|
||||
}
|
||||
if (message.match(/nonce/i) && message.match(/too low/i)) {
|
||||
return makeError("nonce has already been used", "NONCE_EXPIRED", { transaction, info: { error } });
|
||||
}
|
||||
// "replacement transaction underpriced"
|
||||
if (message.match(/replacement transaction/i) && message.match(/underpriced/i)) {
|
||||
return makeError("replacement fee too low", "REPLACEMENT_UNDERPRICED", { transaction, info: { error } });
|
||||
}
|
||||
if (message.match(/only replay-protected/i)) {
|
||||
return makeError("legacy pre-eip-155 transactions not supported", "UNSUPPORTED_OPERATION", {
|
||||
operation: method, info: { transaction, info: { error } }
|
||||
});
|
||||
}
|
||||
}
|
||||
let unsupported = !!message.match(/the method .* does not exist/i);
|
||||
if (!unsupported) {
|
||||
if (error && error.details && error.details.startsWith("Unauthorized method:")) {
|
||||
unsupported = true;
|
||||
}
|
||||
}
|
||||
if (unsupported) {
|
||||
return makeError("unsupported operation", "UNSUPPORTED_OPERATION", {
|
||||
operation: payload.method, info: { error, payload }
|
||||
});
|
||||
}
|
||||
return makeError("could not coalesce error", "UNKNOWN_ERROR", { error, payload });
|
||||
}
|
||||
/**
|
||||
* Requests the %%method%% with %%params%% via the JSON-RPC protocol
|
||||
* over the underlying channel. This can be used to call methods
|
||||
* on the backend that do not have a high-level API within the Provider
|
||||
* API.
|
||||
*
|
||||
* This method queues requests according to the batch constraints
|
||||
* in the options, assigns the request a unique ID.
|
||||
*
|
||||
* **Do NOT override** this method in sub-classes; instead
|
||||
* override [[_send]] or force the options values in the
|
||||
* call to the constructor to modify this method's behavior.
|
||||
*/
|
||||
send(method, params) {
|
||||
// @TODO: cache chainId?? purge on switch_networks
|
||||
// We have been destroyed; no operations are supported anymore
|
||||
if (this.destroyed) {
|
||||
return Promise.reject(makeError("provider destroyed; cancelled request", "UNSUPPORTED_OPERATION", { operation: method }));
|
||||
}
|
||||
const id = this.#nextId++;
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
this.#payloads.push({
|
||||
resolve, reject,
|
||||
payload: { method, params, id, jsonrpc: "2.0" }
|
||||
});
|
||||
});
|
||||
// If there is not a pending drainTimer, set one
|
||||
this.#scheduleDrain();
|
||||
return promise;
|
||||
}
|
||||
/**
|
||||
* Resolves to the [[Signer]] account for %%address%% managed by
|
||||
* the client.
|
||||
*
|
||||
* If the %%address%% is a number, it is used as an index in the
|
||||
* the accounts from [[listAccounts]].
|
||||
*
|
||||
* This can only be used on clients which manage accounts (such as
|
||||
* Geth with imported account or MetaMask).
|
||||
*
|
||||
* Throws if the account doesn't exist.
|
||||
*/
|
||||
async getSigner(address) {
|
||||
if (address == null) {
|
||||
address = 0;
|
||||
}
|
||||
const accountsPromise = this.send("eth_accounts", []);
|
||||
// Account index
|
||||
if (typeof (address) === "number") {
|
||||
const accounts = (await accountsPromise);
|
||||
if (address >= accounts.length) {
|
||||
throw new Error("no such account");
|
||||
}
|
||||
return new JsonRpcSigner(this, accounts[address]);
|
||||
}
|
||||
const { accounts } = await resolveProperties({
|
||||
network: this.getNetwork(),
|
||||
accounts: accountsPromise
|
||||
});
|
||||
// Account address
|
||||
address = getAddress(address);
|
||||
for (const account of accounts) {
|
||||
if (getAddress(account) === address) {
|
||||
return new JsonRpcSigner(this, address);
|
||||
}
|
||||
}
|
||||
throw new Error("invalid account");
|
||||
}
|
||||
async listAccounts() {
|
||||
const accounts = await this.send("eth_accounts", []);
|
||||
return accounts.map((a) => new JsonRpcSigner(this, a));
|
||||
}
|
||||
destroy() {
|
||||
// Stop processing requests
|
||||
if (this.#drainTimer) {
|
||||
clearTimeout(this.#drainTimer);
|
||||
this.#drainTimer = null;
|
||||
}
|
||||
// Cancel all pending requests
|
||||
for (const { payload, reject } of this.#payloads) {
|
||||
reject(makeError("provider destroyed; cancelled request", "UNSUPPORTED_OPERATION", { operation: payload.method }));
|
||||
}
|
||||
this.#payloads = [];
|
||||
// Parent clean-up
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
// @TODO: remove this in v7, it is not exported because this functionality
|
||||
// is exposed in the JsonRpcApiProvider by setting polling to true. It should
|
||||
// be safe to remove regardless, because it isn't reachable, but just in case.
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
export class JsonRpcApiPollingProvider extends JsonRpcApiProvider {
|
||||
#pollingInterval;
|
||||
constructor(network, options) {
|
||||
super(network, options);
|
||||
let pollingInterval = this._getOption("pollingInterval");
|
||||
if (pollingInterval == null) {
|
||||
pollingInterval = defaultOptions.pollingInterval;
|
||||
}
|
||||
this.#pollingInterval = pollingInterval;
|
||||
}
|
||||
_getSubscriber(sub) {
|
||||
const subscriber = super._getSubscriber(sub);
|
||||
if (isPollable(subscriber)) {
|
||||
subscriber.pollingInterval = this.#pollingInterval;
|
||||
}
|
||||
return subscriber;
|
||||
}
|
||||
/**
|
||||
* The polling interval (default: 4000 ms)
|
||||
*/
|
||||
get pollingInterval() { return this.#pollingInterval; }
|
||||
set pollingInterval(value) {
|
||||
if (!Number.isInteger(value) || value < 0) {
|
||||
throw new Error("invalid interval");
|
||||
}
|
||||
this.#pollingInterval = value;
|
||||
this._forEachSubscriber((sub) => {
|
||||
if (isPollable(sub)) {
|
||||
sub.pollingInterval = this.#pollingInterval;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* The JsonRpcProvider is one of the most common Providers,
|
||||
* which performs all operations over HTTP (or HTTPS) requests.
|
||||
*
|
||||
* Events are processed by polling the backend for the current block
|
||||
* number; when it advances, all block-base events are then checked
|
||||
* for updates.
|
||||
*/
|
||||
export class JsonRpcProvider extends JsonRpcApiPollingProvider {
|
||||
#connect;
|
||||
constructor(url, network, options) {
|
||||
if (url == null) {
|
||||
url = "http:/\/localhost:8545";
|
||||
}
|
||||
super(network, options);
|
||||
if (typeof (url) === "string") {
|
||||
this.#connect = new FetchRequest(url);
|
||||
}
|
||||
else {
|
||||
this.#connect = url.clone();
|
||||
}
|
||||
}
|
||||
_getConnection() {
|
||||
return this.#connect.clone();
|
||||
}
|
||||
async send(method, params) {
|
||||
// All requests are over HTTP, so we can just start handling requests
|
||||
// We do this here rather than the constructor so that we don't send any
|
||||
// requests to the network (i.e. eth_chainId) until we absolutely have to.
|
||||
await this._start();
|
||||
return await super.send(method, params);
|
||||
}
|
||||
async _send(payload) {
|
||||
// Configure a POST connection for the requested method
|
||||
const request = this._getConnection();
|
||||
request.body = JSON.stringify(payload);
|
||||
request.setHeader("content-type", "application/json");
|
||||
const response = await request.send();
|
||||
response.assertOk();
|
||||
let resp = response.bodyJson;
|
||||
if (!Array.isArray(resp)) {
|
||||
resp = [resp];
|
||||
}
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
function spelunkData(value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
// These *are* the droids we're looking for.
|
||||
if (typeof (value.message) === "string" && value.message.match(/revert/i) && isHexString(value.data)) {
|
||||
return { message: value.message, data: value.data };
|
||||
}
|
||||
// Spelunk further...
|
||||
if (typeof (value) === "object") {
|
||||
for (const key in value) {
|
||||
const result = spelunkData(value[key]);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// Might be a JSON string we can further descend...
|
||||
if (typeof (value) === "string") {
|
||||
try {
|
||||
return spelunkData(JSON.parse(value));
|
||||
}
|
||||
catch (error) { }
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function _spelunkMessage(value, result) {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
// These *are* the droids we're looking for.
|
||||
if (typeof (value.message) === "string") {
|
||||
result.push(value.message);
|
||||
}
|
||||
// Spelunk further...
|
||||
if (typeof (value) === "object") {
|
||||
for (const key in value) {
|
||||
_spelunkMessage(value[key], result);
|
||||
}
|
||||
}
|
||||
// Might be a JSON string we can further descend...
|
||||
if (typeof (value) === "string") {
|
||||
try {
|
||||
return _spelunkMessage(JSON.parse(value), result);
|
||||
}
|
||||
catch (error) { }
|
||||
}
|
||||
}
|
||||
function spelunkMessage(value) {
|
||||
const result = [];
|
||||
_spelunkMessage(value, result);
|
||||
return result;
|
||||
}
|
||||
//# sourceMappingURL=provider-jsonrpc.js.map
|
||||
1
dev/env/node_modules/ethers/lib.esm/providers/provider-jsonrpc.js.map
generated
vendored
Executable file
1
dev/env/node_modules/ethers/lib.esm/providers/provider-jsonrpc.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user