Compare commits

..

38 Commits

Author SHA1 Message Date
Richard Moore
ccac24a5b0 Fix Base58 padding for string representation of binary data (#4527). 2024-01-02 19:11:11 -05:00
Richard Moore
f6d155c820 admin: update dist files 2023-12-19 04:53:50 -05:00
Richard Moore
180221574c Fix uncatchable issue when sending transactions over JSON-RPC and provide some retry-recovery for missing v (#4513). 2023-12-19 04:52:38 -05:00
Richard Moore
6ee1a5f8bb docs: Fixed some grammar in getting-started (#4486, #4487, #4488) 2023-12-05 16:51:45 -05:00
Richard Moore
98910ba01e admin: update changelog after build-clean 2023-11-27 06:14:57 -05:00
Richard Moore
d60dfc14a3 admin: updated dist files 2023-11-27 06:11:49 -05:00
Richard Moore
f8f11c754a Use provider-specified suggested priority fee when available, otherwise fallback onto existing logic of 1 gwei (#4463). 2023-11-27 06:04:52 -05:00
Richard Moore
4681b83d51 Add auto-detected static network support to providers and allow customizing socket provider options (#4199, #4418, #4441). 2023-11-27 05:23:10 -05:00
Richard Moore
9e74d14432 Added Base network to AlchemyProvider (#4384). 2023-11-25 17:52:15 -05:00
Richard Moore
2b67488151 Fixed ParamType formatting causing bad tuple full and minimal ABI output (#4329, #4479). 2023-11-25 17:46:30 -05:00
Richard Moore
da34e3569e Account for provider config weight when kicking off a request in FallbackProvider (#4298). 2023-11-23 21:26:26 -05:00
Richard Moore
e2485b8ef9 More robust FallbackProvider broadcast (#4186, #4297, #4442). 2023-11-16 20:39:21 -05:00
Richard Moore
93fb138809 admin: style fix (#4356) 2023-11-11 18:48:30 -05:00
Richard Moore
944cbbc0a5 tests: bumped Node versions for testing (#4451) 2023-11-11 18:47:10 -05:00
Richard Moore
a92766e56a Added safe and finalized provider events (#3921). 2023-11-11 18:41:40 -05:00
Richard Moore
cf00331309 admin: updated dist files 2023-11-11 18:00:39 -05:00
Richard Moore
ee79d7d005 admin: added diff scripts for build page 2023-11-11 17:58:48 -05:00
Richard Moore
aff7addfd9 docs: fixed typo in jsdocs for Wallet.createRandom (#4461) 2023-11-10 23:00:50 -05:00
Richard Moore
39315288be docs: updated the readme with more recent URLs and info 2023-11-02 14:56:36 -04:00
Richard Moore
1c71ec6df6 docs: fixed jsdocs for signMessage (#4314) 2023-11-02 14:48:45 -04:00
Richard Moore
1d9c0197a2 docs: removed Pocket from list of community resources (#4345) 2023-11-02 14:47:56 -04:00
Richard Moore
168518f1cb docs: fixed typos in Fetch jsdocs (#4355) 2023-11-02 14:44:53 -04:00
Richard Moore
e9fac926c9 docs: fixed typo in ENS cookbook (#4379) 2023-11-02 14:39:03 -04:00
Richard Moore
238f4f64ca docs: fixed typo from copy-paste ENS cookbook example (#4382) 2023-11-02 14:38:04 -04:00
Richard Moore
d11a2b5a5e docs: fixed typos in signing cookbook (#4400) 2023-11-02 14:37:05 -04:00
Richard Moore
61a66e413a docs: fixed typo in ens cookbook (#4401) 2023-11-02 14:35:19 -04:00
Richard Moore
22b7a2c111 docs: fixed typo in jsdocs (#4417) 2023-11-02 14:33:28 -04:00
Richard Moore
5d62591796 docs: fixed typos in jsdocs (#4421). 2023-11-02 14:32:39 -04:00
Richard Moore
85a039f180 docs: fixed typo in migrations docs (#4435) 2023-11-02 14:29:08 -04:00
Richard Moore
5431723ec3 admin: updated dist files 2023-11-01 16:17:49 -04:00
Richard Moore
8fed2f8476 Fixed typo in error description when converting values to arrays (#4427, #4446). 2023-11-01 16:04:27 -04:00
Richard Moore
73adb393e8 docs: fixed typo in jsdocs (#4391). 2023-11-01 15:58:07 -04:00
Richard Moore
2e0bd90744 Fix invalid token nonpayable being included in formatted constructor (#4412). 2023-11-01 15:56:47 -04:00
Richard Moore
1da50ae286 Add ENS support for Sepolia (#4422). 2023-11-01 15:55:05 -04:00
Richard Moore
e0c1d976b2 tests: only trigger browser testing when relevant code changed 2023-10-11 02:14:04 -04:00
Richard Moore
e454afb2fa tests: fix typo in env prepare scripts 2023-10-11 02:12:06 -04:00
Richard Moore
4772915f0c tests: updated env tests for TypeScript 5.2 2023-10-11 02:10:52 -04:00
Richard Moore
3a73c56ee3 admin: updated dist files 2023-10-10 22:41:46 -04:00
179 changed files with 2799 additions and 703 deletions

View File

@@ -21,7 +21,7 @@ jobs:
steps:
- uses: actions/setup-node@v1
with:
node-version: 18.x
node-version: 20.x
- name: Checkout repository
uses: actions/checkout@v3

View File

@@ -4,6 +4,11 @@ on:
push:
branches:
- main
paths:
- "src.ts/**"
- "lib.esm/**"
- "lib.commonjs/**"
- "misc/test-browser/**"
jobs:
test-browser:
@@ -20,7 +25,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v1
with:
node-version: 18.x
node-version: 20.x
- name: Install and run Geth
uses: ethers-io/run-geth-action@main

View File

@@ -25,7 +25,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [ 16.x, 18.x ]
node-version: [ 18.x, 20.x ]
test-type: [ esm, commonjs ]
steps:
@@ -66,7 +66,7 @@ jobs:
steps:
- uses: actions/setup-node@v1
with:
node-version: 18.x
node-version: 20.x
- name: Install and run Geth
uses: ethers-io/run-geth-action@main

View File

@@ -25,7 +25,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 18.x
node-version: 20.x
- name: Checkout repository
uses: actions/checkout@v3
@@ -65,7 +65,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 18.x
node-version: 20.x
- name: Checkout repository
uses: actions/checkout@v3

View File

@@ -3,11 +3,36 @@ Change Log
This change log is maintained by `src.ts/_admin/update-changelog.ts` but may also be manually updated.
ethers/v6.8.0 (2023-10-09 20:22)
ethers/v6.9.1 (2023-12-19 04:53)
--------------------------------
- Fix uncatchable issue when sending transactions over JSON-RPC and provide some retry-recovery for missing v ([#4513](https://github.com/ethers-io/ethers.js/issues/4513); [1802215](https://github.com/ethers-io/ethers.js/commit/180221574c5d2af9ad85404af4fab8752d3d5029)).
ethers/v6.9.0 (2023-11-27 06:15)
--------------------------------
- Use provider-specified suggested priority fee when available, otherwise fallback onto existing logic of 1 gwei ([#4463](https://github.com/ethers-io/ethers.js/issues/4463); [f8f11c7](https://github.com/ethers-io/ethers.js/commit/f8f11c754aa2c9b541db73d3bde66a8ffa5146f0)).
- Add auto-detected static network support to providers and allow customizing socket provider options ([#4199](https://github.com/ethers-io/ethers.js/issues/4199), [#4418](https://github.com/ethers-io/ethers.js/issues/4418), [#4441](https://github.com/ethers-io/ethers.js/issues/4441); [4681b83](https://github.com/ethers-io/ethers.js/commit/4681b83d516ab2eb41ddb68b5021c97e14c6f2cf)).
- Added Base network to AlchemyProvider ([#4384](https://github.com/ethers-io/ethers.js/issues/4384); [9e74d14](https://github.com/ethers-io/ethers.js/commit/9e74d14432e6efebdff21b9a7d2e6143af55e143)).
- Fixed ParamType formatting causing bad tuple full and minimal ABI output ([#4329](https://github.com/ethers-io/ethers.js/issues/4329), [#4479](https://github.com/ethers-io/ethers.js/issues/4479); [2b67488](https://github.com/ethers-io/ethers.js/commit/2b6748815169abf2c99a647131875c13b8b6a787)).
- Adjust for provider config weight when kicking off a request in FallbackProvider ([#4298](https://github.com/ethers-io/ethers.js/issues/4298); [da34e35](https://github.com/ethers-io/ethers.js/commit/da34e3569e95357d9469209d926cb645f0750bfa)).
- More robust FallbackProvider broadcast ([#4186](https://github.com/ethers-io/ethers.js/issues/4186), [#4297](https://github.com/ethers-io/ethers.js/issues/4297), [#4442](https://github.com/ethers-io/ethers.js/issues/4442); [e2485b8](https://github.com/ethers-io/ethers.js/commit/e2485b8ef927d18c7a15d2d29b3b0feffec9991a)).
- Added safe and finalized provider events ([#3921](https://github.com/ethers-io/ethers.js/issues/3921); [a92766e](https://github.com/ethers-io/ethers.js/commit/a92766e56ad04185625037d84fc28adaac7fae8c)).
ethers/v6.8.1 (2023-11-01 16:08)
--------------------------------
- Fixed typo in error description when converting values to arrays ([#4427](https://github.com/ethers-io/ethers.js/issues/4427), [#4446](https://github.com/ethers-io/ethers.js/issues/4446); [8fed2f8](https://github.com/ethers-io/ethers.js/commit/8fed2f84768ace4bf3e5742c931a74841da7c637)).
- Fix invalid token nonpayable being included in formatted constructor ([#4412](https://github.com/ethers-io/ethers.js/issues/4412); [2e0bd90](https://github.com/ethers-io/ethers.js/commit/2e0bd90744b8e76fcf03f75a66cb0061d50f7bd9)).
- Add ENS support for Sepolia ([#4422](https://github.com/ethers-io/ethers.js/issues/4422); [1da50ae](https://github.com/ethers-io/ethers.js/commit/1da50ae286da01e58a70bb8df8aa5cc5d260e33e)).
ethers/v6.8.0 (2023-10-10 22:42)
--------------------------------
- Replicated former ENS normalize behaviour for empty strings and update namehash testcases ([125ff11](https://github.com/ethers-io/ethers.js/commit/125ff1189b9cefb8abfd7da9c104c75e382a50cc)).
- Initial shortMessage support for errors ([#4241](https://github.com/ethers-io/ethers.js/issues/4241); [d6a8c14](https://github.com/ethers-io/ethers.js/commit/d6a8c14d907cf8b90347444c0186b83a5db2e293)).
- Fixed resolving ENS addresses used as from parameters ([#3961](https://github.com/ethers-io/ethers.js/issues/3961); [2616f4c](https://github.com/ethers-io/ethers.js/commit/2616f4c30c82bd45449b73fa37ef269d60a07d80)).
- Merge: 9a4b7534 0c9c23b0 Merge branch 'v5.8-progress' ([cd5f0fe](https://github.com/ethers-io/ethers.js/commit/cd5f0fe03f2137fbc47e295f8db38a5151111e72)).
- Allow more loose input format for RLP encoder ([#4402](https://github.com/ethers-io/ethers.js/issues/4402); [9a4b753](https://github.com/ethers-io/ethers.js/commit/9a4b7534458fc79a0654b0eb57fc956bffa02a2f)).
- Update to latest noble crypto libraries ([#3975](https://github.com/ethers-io/ethers.js/issues/3975); [b27faa0](https://github.com/ethers-io/ethers.js/commit/b27faa02ac8f90e2e54b188e8139c59d98c469e3)).
- More robust configuration options for FetchRequest getUrl functions ([#4353](https://github.com/ethers-io/ethers.js/issues/4353); [9541f2f](https://github.com/ethers-io/ethers.js/commit/9541f2f70cd7f5c6f3caf93f5a3d5e34eae5281a)).

View File

@@ -47,6 +47,7 @@ For the latest changes, see the
**Summaries**
- [August 2023](https://blog.ricmoo.com/highlights-ethers-js-august-2023-fb68354c576c)
- [September 2022](https://blog.ricmoo.com/highlights-ethers-js-september-2022-d7bda0fc37ed)
- [June 2022](https://blog.ricmoo.com/highlights-ethers-js-june-2022-f5328932e35d)
- [March 2022](https://blog.ricmoo.com/highlights-ethers-js-march-2022-f511fe1e88a1)
@@ -116,7 +117,6 @@ A special thanks to these services for providing community resources:
- [Etherscan](https://etherscan.io/)
- [INFURA](https://infura.io/)
- [Alchemy](https://dashboard.alchemyapi.io/signup?referral=55a35117-028e-4b7c-9e47-e275ad0acc6d)
- [Pocket](https://pokt.network/pocket-gateway-ethereum-mainnet/)
Extension Packages
@@ -126,8 +126,11 @@ The `ethers` package only includes the most common and most core
functionality to interact with Ethereum. There are many other
packages designed to further enhance the functionality and experience.
- Hardware Wallets (coming soon)
- Account Abstraction (coming soon)
- [MulticallProvider](https://github.com/ethers-io/ext-provider-multicall) - A Provider which bundles multiple call requests into a single `call` to reduce latency and backend request capacity
- [MulticoinPlugin](https://github.com/ethers-io/ext-provider-plugin-multicoin) - A Provider plugin to expand the support of ENS coin types
- [GanaceProvider](https://github.com/ethers-io/ext-provider-ganache) - A Provider for in-memory node instances, for fast debugging, testing and simulating blockchain operations
- [Optimism Utilities](https://github.com/ethers-io/ext-utils-optimism) - A collection of Optimism utilities
- [LedgerSigner](https://github.com/ethers-io/ext-signer-ledger) - A Signer to interact directly with Ledger Hardware Wallets
License

399
dist/ethers.js vendored
View File

@@ -3,7 +3,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
/**
* The current version of Ethers.
*/
const version = "6.8.0";
const version = "6.9.1";
/**
* Property helper functions.
@@ -109,7 +109,7 @@ function stringify$1(value) {
* Returns true if the %%error%% matches an error thrown by ethers
* that matches the error %%code%%.
*
* In TypeScript envornoments, this can be used to check that %%error%%
* In TypeScript environments, this can be used to check that %%error%%
* matches an EthersError type, which means the expected properties will
* be set.
*
@@ -135,13 +135,13 @@ function isCallException(error) {
}
/**
* Returns a new Error configured to the format ethers emits errors, with
* the %%message%%, [[api:ErrorCode]] %%code%% and additioanl properties
* the %%message%%, [[api:ErrorCode]] %%code%% and additional properties
* for the corresponding EthersError.
*
* Each error in ethers includes the version of ethers, a
* machine-readable [[ErrorCode]], and depneding on %%code%%, additional
* required properties. The error message will also include the %%meeage%%,
* ethers version, %%code%% and all aditional properties, serialized.
* machine-readable [[ErrorCode]], and depending on %%code%%, additional
* required properties. The error message will also include the %%message%%,
* ethers version, %%code%% and all additional properties, serialized.
*/
function makeError(message, code, info) {
let shortMessage = message;
@@ -614,7 +614,7 @@ function toBeHex(_value, _width) {
}
else {
const width = getNumber(_width, "width");
assert(width * 2 >= result.length, `value exceeds width (${width} bits)`, "NUMERIC_FAULT", {
assert(width * 2 >= result.length, `value exceeds width (${width} bytes)`, "NUMERIC_FAULT", {
operation: "toBeHex",
fault: "overflow",
value: _value
@@ -1031,7 +1031,7 @@ function createGetUrl(options) {
/**
* Fetching content from the web is environment-specific, so Ethers
* provides an abstraction the each environment can implement to provide
* provides an abstraction that each environment can implement to provide
* this service.
*
* On [Node.js](link-node), the ``http`` and ``https`` libs are used to
@@ -1039,10 +1039,10 @@ function createGetUrl(options) {
* and populate the [[FetchResponse]].
*
* In a browser, the [DOM fetch](link-js-fetch) is used, and the resulting
* ``Promise`` is waited on to retreive the payload.
* ``Promise`` is waited on to retrieve the payload.
*
* The [[FetchRequest]] is responsible for handling many common situations,
* such as redirects, server throttling, authentcation, etc.
* such as redirects, server throttling, authentication, etc.
*
* It also handles common gateways, such as IPFS and data URIs.
*
@@ -1166,7 +1166,7 @@ class FetchRequest {
#throttle;
#getUrlFunc;
/**
* The fetch URI to requrest.
* The fetch URL to request.
*/
get url() { return this.#url; }
set url(url) {
@@ -1180,15 +1180,15 @@ class FetchRequest {
* header.
*
* If %%body%% is null, the body is cleared (along with the
* intrinsic ``Content-Type``) and the .
* intrinsic ``Content-Type``).
*
* If %%body%% is a string, the intrincis ``Content-Type`` is set to
* If %%body%% is a string, the intrinsic ``Content-Type`` is set to
* ``text/plain``.
*
* If %%body%% is a Uint8Array, the intrincis ``Content-Type`` is set to
* If %%body%% is a Uint8Array, the intrinsic ``Content-Type`` is set to
* ``application/octet-stream``.
*
* If %%body%% is any other object, the intrincis ``Content-Type`` is
* If %%body%% is any other object, the intrinsic ``Content-Type`` is
* set to ``application/json``.
*/
get body() {
@@ -1248,7 +1248,7 @@ class FetchRequest {
* The headers that will be used when requesting the URI. All
* keys are lower-case.
*
* This object is a copy, so any chnages will **NOT** be reflected
* This object is a copy, so any changes will **NOT** be reflected
* in the ``FetchRequest``.
*
* To set a header entry, use the ``setHeader`` method.
@@ -1340,7 +1340,7 @@ class FetchRequest {
this.#allowInsecure = !!value;
}
/**
* The timeout (in milliseconds) to wait for a complere response.
* The timeout (in milliseconds) to wait for a complete response.
* //(default: 5 minutes)//
*/
get timeout() { return this.#timeout; }
@@ -1547,7 +1547,7 @@ class FetchRequest {
* to %%location%%.
*/
redirect(location) {
// Redirection; for now we only support absolute locataions
// Redirection; for now we only support absolute locations
const current = this.url.split(":")[0].toLowerCase();
const target = location.split(":")[0].toLowerCase();
// Don't allow redirecting:
@@ -1685,7 +1685,7 @@ class FetchRequest {
}
}
/**
* The response for a FetchREquest.
* The response for a FetchRequest.
*/
class FetchResponse {
#statusCode;
@@ -1815,7 +1815,7 @@ class FetchResponse {
return this.headers[key.toLowerCase()];
}
/**
* Returns true of the response has a body.
* Returns true if the response has a body.
*/
hasBody() {
return (this.#body != null);
@@ -9445,6 +9445,9 @@ function ensNameSplit(name) {
*/
function ensNormalize(name) {
try {
if (name.length === 0) {
throw new Error("empty label");
}
return ens_normalize(name);
}
catch (error) {
@@ -9466,6 +9469,7 @@ function isValidName(name) {
*/
function namehash(name) {
assertArgument(typeof (name) === "string", "invalid ENS name; not a string", "name", name);
assertArgument(name.length, `invalid ENS name (empty label)`, "name", name);
let result = Zeros;
const comps = ensNameSplit(name);
while (comps.length) {
@@ -11331,9 +11335,6 @@ class ParamType {
}
else {
if (this.isTuple()) {
if (format !== "sighash") {
result += this.type;
}
result += "(" + this.components.map((comp) => comp.format(format)).join((format === "full") ? ", " : ",") + ")";
}
else {
@@ -11875,7 +11876,9 @@ class ConstructorFragment extends Fragment {
});
}
const result = [`constructor${joinParams(format, this.inputs)}`];
result.push((this.payable) ? "payable" : "nonpayable");
if (this.payable) {
result.push("payable");
}
if (this.gas != null) {
result.push(`@${this.gas.toString()}`);
}
@@ -14028,7 +14031,7 @@ class TransactionReceipt {
*/
provider;
/**
* The address the transaction was send to.
* The address the transaction was sent to.
*/
to;
/**
@@ -17170,23 +17173,6 @@ function getGasStationPlugin(url) {
}
});
}
// Used by Optimism for a custom priority fee
function getPriorityFeePlugin(maxPriorityFeePerGas) {
return new FetchUrlFeeDataNetworkPlugin("data:", async (fetchFeeData, provider, request) => {
const feeData = await fetchFeeData();
// This should always fail
if (feeData.maxFeePerGas == null || feeData.maxPriorityFeePerGas == null) {
return feeData;
}
// Compute the corrected baseFee to recompute the updated values
const baseFee = feeData.maxFeePerGas - feeData.maxPriorityFeePerGas;
return {
gasPrice: feeData.gasPrice,
maxFeePerGas: (baseFee + maxPriorityFeePerGas),
maxPriorityFeePerGas
};
});
}
// See: https://chainlist.org
let injected = false;
function injectCommonNetworks() {
@@ -17222,13 +17208,16 @@ function injectCommonNetworks() {
registerEth("rinkeby", 4, { ensNetwork: 4 });
registerEth("goerli", 5, { ensNetwork: 5 });
registerEth("kovan", 42, { ensNetwork: 42 });
registerEth("sepolia", 11155111, {});
registerEth("sepolia", 11155111, { ensNetwork: 11155111 });
registerEth("classic", 61, {});
registerEth("classicKotti", 6, {});
registerEth("arbitrum", 42161, {
ensNetwork: 1,
});
registerEth("arbitrum-goerli", 421613, {});
registerEth("base", 8453, { ensNetwork: 1 });
registerEth("base-goerli", 84531, {});
registerEth("base-sepolia", 84532, {});
registerEth("bnb", 56, { ensNetwork: 1 });
registerEth("bnbt", 97, {});
registerEth("linea", 59144, { ensNetwork: 1 });
@@ -17247,9 +17236,7 @@ function injectCommonNetworks() {
});
registerEth("optimism", 10, {
ensNetwork: 1,
plugins: [
getPriorityFeePlugin(BigInt("1000000"))
]
plugins: []
});
registerEth("optimism-goerli", 420, {});
registerEth("xdai", 100, { ensNetwork: 1 });
@@ -17385,6 +17372,34 @@ class OnBlockSubscriber {
pause(dropWhilePaused) { this.stop(); }
resume() { this.start(); }
}
class PollingBlockTagSubscriber extends OnBlockSubscriber {
#tag;
#lastBlock;
constructor(provider, tag) {
super(provider);
this.#tag = tag;
this.#lastBlock = -2;
}
pause(dropWhilePaused) {
if (dropWhilePaused) {
this.#lastBlock = -2;
}
super.pause(dropWhilePaused);
}
async _poll(blockNumber, provider) {
const block = await provider.getBlock(this.#tag);
if (block == null) {
return;
}
if (this.#lastBlock === -2) {
this.#lastBlock = block.number;
}
else if (block.number > this.#lastBlock) {
provider.emit(this.#tag, block.number);
this.#lastBlock = block.number;
}
}
}
/**
* @_ignore:
*
@@ -17583,10 +17598,12 @@ async function getSubscription(_event, provider) {
if (typeof (_event) === "string") {
switch (_event) {
case "block":
case "pending":
case "debug":
case "error":
case "network": {
case "finalized":
case "network":
case "pending":
case "safe": {
return { type: _event, tag: _event };
}
}
@@ -17884,10 +17901,10 @@ class AbstractProvider {
switch (blockTag) {
case "earliest":
return "0x0";
case "finalized":
case "latest":
case "pending":
case "safe":
case "finalized":
return blockTag;
}
if (isHexString(blockTag)) {
@@ -18031,16 +18048,19 @@ class AbstractProvider {
// No explicit network was set and this is our first time
if (this.#networkPromise == null) {
// Detect the current network (shared with all calls)
const detectNetwork = this._detectNetwork().then((network) => {
this.emit("network", network, null);
return network;
}, (error) => {
// Reset the networkPromise on failure, so we will try again
if (this.#networkPromise === detectNetwork) {
this.#networkPromise = null;
const detectNetwork = (async () => {
try {
const network = await this._detectNetwork();
this.emit("network", network, null);
return network;
}
throw error;
});
catch (error) {
if (this.#networkPromise === detectNetwork) {
this.#networkPromise = null;
}
throw error;
}
})();
this.#networkPromise = detectNetwork;
return (await detectNetwork).clone();
}
@@ -18070,12 +18090,20 @@ class AbstractProvider {
async getFeeData() {
const network = await this.getNetwork();
const getFeeDataFunc = async () => {
const { _block, gasPrice } = await resolveProperties({
const { _block, gasPrice, priorityFee } = await resolveProperties({
_block: this.#getBlock("latest", false),
gasPrice: ((async () => {
try {
const gasPrice = await this.#perform({ method: "getGasPrice" });
return getBigInt(gasPrice, "%response");
const value = await this.#perform({ method: "getGasPrice" });
return getBigInt(value, "%response");
}
catch (error) { }
return null;
})()),
priorityFee: ((async () => {
try {
const value = await this.#perform({ method: "getPriorityFee" });
return getBigInt(value, "%response");
}
catch (error) { }
return null;
@@ -18086,7 +18114,7 @@ class AbstractProvider {
// These are the recommended EIP-1559 heuristics for fee data
const block = this._wrapBlock(_block, network);
if (block && block.baseFeePerGas) {
maxPriorityFeePerGas = BigInt("1000000000");
maxPriorityFeePerGas = (priorityFee != null) ? priorityFee : BigInt("1000000000");
maxFeePerGas = (block.baseFeePerGas * BN_2$1) + maxPriorityFeePerGas;
}
return new FeeData(gasPrice, maxFeePerGas, maxPriorityFeePerGas);
@@ -18464,6 +18492,9 @@ class AbstractProvider {
subscriber.pollingInterval = this.pollingInterval;
return subscriber;
}
case "safe":
case "finalized":
return new PollingBlockTagSubscriber(this, sub.type);
case "event":
return new PollingEventSubscriber(this, sub.filter);
case "transaction":
@@ -19416,12 +19447,45 @@ class JsonRpcSigner extends AbstractSigner {
// 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 getting the transaction
const tx = await this.provider.getTransaction(hash);
if (tx != null) {
resolve(tx.replaceableTransaction(blockNumber));
return;
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" )) {
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);
@@ -19494,11 +19558,12 @@ class JsonRpcApiProvider extends AbstractProvider {
#drainTimer;
#notReady;
#network;
#pendingDetectNetwork;
#scheduleDrain() {
if (this.#drainTimer) {
return;
}
// If we aren't using batching, no hard in sending it immeidately
// 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;
@@ -19569,6 +19634,7 @@ class JsonRpcApiProvider extends AbstractProvider {
this.#payloads = [];
this.#drainTimer = null;
this.#network = null;
this.#pendingDetectNetwork = null;
{
let resolve = null;
const promise = new Promise((_resolve) => {
@@ -19576,9 +19642,15 @@ class JsonRpcApiProvider extends AbstractProvider {
});
this.#notReady = { promise, resolve };
}
// Make sure any static network is compatbile with the provided netwrok
const staticNetwork = this._getOption("staticNetwork");
if (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;
}
@@ -19639,30 +19711,56 @@ class JsonRpcApiProvider extends AbstractProvider {
async _detectNetwork() {
const network = this._getOption("staticNetwork");
if (network) {
return 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) {
return Network.from(getBigInt(await this.send("eth_chainId", [])));
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
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];
}
catch (error) {
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);
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
@@ -19778,6 +19876,8 @@ class JsonRpcApiProvider extends AbstractProvider {
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",
@@ -20271,6 +20371,10 @@ function getHost$3(name) {
return "arb-mainnet.g.alchemy.com";
case "arbitrum-goerli":
return "arb-goerli.g.alchemy.com";
case "base":
return "base-mainnet.g.alchemy.com";
case "base-goerli":
return "base-goerli.g.alchemy.com";
case "matic":
return "polygon-mainnet.g.alchemy.com";
case "matic-mumbai":
@@ -20719,6 +20823,44 @@ class EtherscanProvider extends AbstractProvider {
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", {
@@ -21009,8 +21151,21 @@ class SocketProvider extends JsonRpcApiProvider {
*
* If unspecified, the network will be discovered.
*/
constructor(network) {
super(network, { batchMaxCount: 1 });
constructor(network, _options) {
// Copy the options
const options = Object.assign({}, (_options != null) ? _options : {});
// Support for batches is generally not supported for
// connection-base providers; if this changes in the future
// the _send should be updated to reflect this
assertArgument(options.batchMaxCount == null || options.batchMaxCount === 1, "sockets-based providers do not support batches", "options.batchMaxCount", _options);
options.batchMaxCount = 1;
// Socket-based Providers (generally) cannot change their network,
// since they have a long-lived connection; but let people override
// this if they have just cause.
if (options.staticNetwork == null) {
options.staticNetwork = true;
}
super(network, options);
this.#callbacks = new Map();
this.#subs = new Map();
this.#pending = new Map();
@@ -21154,8 +21309,8 @@ class WebSocketProvider extends SocketProvider {
}
return this.#websocket;
}
constructor(url, network) {
super(network);
constructor(url, network, options) {
super(network, options);
if (typeof (url) === "string") {
this.#connect = () => { return new _WebSocket(url); };
this.#websocket = this.#connect();
@@ -21772,6 +21927,8 @@ class FallbackProvider extends AbstractProvider {
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":
@@ -21917,6 +22074,7 @@ class FallbackProvider extends AbstractProvider {
return this.#height;
}
case "getGasPrice":
case "getPriorityFee":
case "estimateGas":
return getMedian(this.quorum, results);
case "getBlock":
@@ -21998,15 +22156,46 @@ class FallbackProvider extends AbstractProvider {
// a cost on the user, so spamming is safe-ish. Just send it to
// every backend.
if (req.method === "broadcastTransaction") {
const results = await Promise.all(this.#configs.map(async ({ provider, weight }) => {
// 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);
return Object.assign(normalizeResult({ result }), { weight });
results[index] = Object.assign(normalizeResult({ result }), { weight });
}
catch (error) {
return Object.assign(normalizeResult({ error }), { weight });
results[index] = Object.assign(normalizeResult({ 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",
@@ -22020,8 +22209,16 @@ class FallbackProvider extends AbstractProvider {
await this.#initialSync();
// Bootstrap enough runners to meet quorum
const running = new Set();
for (let i = 0; i < this.quorum; i++) {
this.#addRunner(running, req);
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
@@ -22082,7 +22279,7 @@ const Testnets = "goerli kovan sepolia classicKotti optimism-goerli arbitrum-goe
* // third-party services available
* provider = getDefaultProvider("mainnet");
*
* // Connect to Polygoin, but only allow Etherscan and
* // 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",
@@ -24363,7 +24560,7 @@ class Wallet extends BaseWallet {
return Wallet.#fromAccount(account);
}
/**
* Creates a new random [[HDNodeWallet]] using the avavilable
* Creates a new random [[HDNodeWallet]] using the available
* [cryptographic random source](randomBytes).
*
* If there is no crytographic random source, this will throw.

2
dist/ethers.js.map vendored

File diff suppressed because one or more lines are too long

2
dist/ethers.min.js vendored

File diff suppressed because one or more lines are too long

399
dist/ethers.umd.js vendored
View File

@@ -9,7 +9,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
/**
* The current version of Ethers.
*/
const version = "6.8.0";
const version = "6.9.1";
/**
* Property helper functions.
@@ -115,7 +115,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
* Returns true if the %%error%% matches an error thrown by ethers
* that matches the error %%code%%.
*
* In TypeScript envornoments, this can be used to check that %%error%%
* In TypeScript environments, this can be used to check that %%error%%
* matches an EthersError type, which means the expected properties will
* be set.
*
@@ -141,13 +141,13 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
}
/**
* Returns a new Error configured to the format ethers emits errors, with
* the %%message%%, [[api:ErrorCode]] %%code%% and additioanl properties
* the %%message%%, [[api:ErrorCode]] %%code%% and additional properties
* for the corresponding EthersError.
*
* Each error in ethers includes the version of ethers, a
* machine-readable [[ErrorCode]], and depneding on %%code%%, additional
* required properties. The error message will also include the %%meeage%%,
* ethers version, %%code%% and all aditional properties, serialized.
* machine-readable [[ErrorCode]], and depending on %%code%%, additional
* required properties. The error message will also include the %%message%%,
* ethers version, %%code%% and all additional properties, serialized.
*/
function makeError(message, code, info) {
let shortMessage = message;
@@ -620,7 +620,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
}
else {
const width = getNumber(_width, "width");
assert(width * 2 >= result.length, `value exceeds width (${width} bits)`, "NUMERIC_FAULT", {
assert(width * 2 >= result.length, `value exceeds width (${width} bytes)`, "NUMERIC_FAULT", {
operation: "toBeHex",
fault: "overflow",
value: _value
@@ -1037,7 +1037,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
/**
* Fetching content from the web is environment-specific, so Ethers
* provides an abstraction the each environment can implement to provide
* provides an abstraction that each environment can implement to provide
* this service.
*
* On [Node.js](link-node), the ``http`` and ``https`` libs are used to
@@ -1045,10 +1045,10 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
* and populate the [[FetchResponse]].
*
* In a browser, the [DOM fetch](link-js-fetch) is used, and the resulting
* ``Promise`` is waited on to retreive the payload.
* ``Promise`` is waited on to retrieve the payload.
*
* The [[FetchRequest]] is responsible for handling many common situations,
* such as redirects, server throttling, authentcation, etc.
* such as redirects, server throttling, authentication, etc.
*
* It also handles common gateways, such as IPFS and data URIs.
*
@@ -1172,7 +1172,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
#throttle;
#getUrlFunc;
/**
* The fetch URI to requrest.
* The fetch URL to request.
*/
get url() { return this.#url; }
set url(url) {
@@ -1186,15 +1186,15 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
* header.
*
* If %%body%% is null, the body is cleared (along with the
* intrinsic ``Content-Type``) and the .
* intrinsic ``Content-Type``).
*
* If %%body%% is a string, the intrincis ``Content-Type`` is set to
* If %%body%% is a string, the intrinsic ``Content-Type`` is set to
* ``text/plain``.
*
* If %%body%% is a Uint8Array, the intrincis ``Content-Type`` is set to
* If %%body%% is a Uint8Array, the intrinsic ``Content-Type`` is set to
* ``application/octet-stream``.
*
* If %%body%% is any other object, the intrincis ``Content-Type`` is
* If %%body%% is any other object, the intrinsic ``Content-Type`` is
* set to ``application/json``.
*/
get body() {
@@ -1254,7 +1254,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
* The headers that will be used when requesting the URI. All
* keys are lower-case.
*
* This object is a copy, so any chnages will **NOT** be reflected
* This object is a copy, so any changes will **NOT** be reflected
* in the ``FetchRequest``.
*
* To set a header entry, use the ``setHeader`` method.
@@ -1346,7 +1346,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
this.#allowInsecure = !!value;
}
/**
* The timeout (in milliseconds) to wait for a complere response.
* The timeout (in milliseconds) to wait for a complete response.
* //(default: 5 minutes)//
*/
get timeout() { return this.#timeout; }
@@ -1553,7 +1553,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
* to %%location%%.
*/
redirect(location) {
// Redirection; for now we only support absolute locataions
// Redirection; for now we only support absolute locations
const current = this.url.split(":")[0].toLowerCase();
const target = location.split(":")[0].toLowerCase();
// Don't allow redirecting:
@@ -1691,7 +1691,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
}
}
/**
* The response for a FetchREquest.
* The response for a FetchRequest.
*/
class FetchResponse {
#statusCode;
@@ -1821,7 +1821,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
return this.headers[key.toLowerCase()];
}
/**
* Returns true of the response has a body.
* Returns true if the response has a body.
*/
hasBody() {
return (this.#body != null);
@@ -9451,6 +9451,9 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
*/
function ensNormalize(name) {
try {
if (name.length === 0) {
throw new Error("empty label");
}
return ens_normalize(name);
}
catch (error) {
@@ -9472,6 +9475,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
*/
function namehash(name) {
assertArgument(typeof (name) === "string", "invalid ENS name; not a string", "name", name);
assertArgument(name.length, `invalid ENS name (empty label)`, "name", name);
let result = Zeros;
const comps = ensNameSplit(name);
while (comps.length) {
@@ -11337,9 +11341,6 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
}
else {
if (this.isTuple()) {
if (format !== "sighash") {
result += this.type;
}
result += "(" + this.components.map((comp) => comp.format(format)).join((format === "full") ? ", " : ",") + ")";
}
else {
@@ -11881,7 +11882,9 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
});
}
const result = [`constructor${joinParams(format, this.inputs)}`];
result.push((this.payable) ? "payable" : "nonpayable");
if (this.payable) {
result.push("payable");
}
if (this.gas != null) {
result.push(`@${this.gas.toString()}`);
}
@@ -14034,7 +14037,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
*/
provider;
/**
* The address the transaction was send to.
* The address the transaction was sent to.
*/
to;
/**
@@ -17176,23 +17179,6 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
}
});
}
// Used by Optimism for a custom priority fee
function getPriorityFeePlugin(maxPriorityFeePerGas) {
return new FetchUrlFeeDataNetworkPlugin("data:", async (fetchFeeData, provider, request) => {
const feeData = await fetchFeeData();
// This should always fail
if (feeData.maxFeePerGas == null || feeData.maxPriorityFeePerGas == null) {
return feeData;
}
// Compute the corrected baseFee to recompute the updated values
const baseFee = feeData.maxFeePerGas - feeData.maxPriorityFeePerGas;
return {
gasPrice: feeData.gasPrice,
maxFeePerGas: (baseFee + maxPriorityFeePerGas),
maxPriorityFeePerGas
};
});
}
// See: https://chainlist.org
let injected = false;
function injectCommonNetworks() {
@@ -17228,13 +17214,16 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
registerEth("rinkeby", 4, { ensNetwork: 4 });
registerEth("goerli", 5, { ensNetwork: 5 });
registerEth("kovan", 42, { ensNetwork: 42 });
registerEth("sepolia", 11155111, {});
registerEth("sepolia", 11155111, { ensNetwork: 11155111 });
registerEth("classic", 61, {});
registerEth("classicKotti", 6, {});
registerEth("arbitrum", 42161, {
ensNetwork: 1,
});
registerEth("arbitrum-goerli", 421613, {});
registerEth("base", 8453, { ensNetwork: 1 });
registerEth("base-goerli", 84531, {});
registerEth("base-sepolia", 84532, {});
registerEth("bnb", 56, { ensNetwork: 1 });
registerEth("bnbt", 97, {});
registerEth("linea", 59144, { ensNetwork: 1 });
@@ -17253,9 +17242,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
});
registerEth("optimism", 10, {
ensNetwork: 1,
plugins: [
getPriorityFeePlugin(BigInt("1000000"))
]
plugins: []
});
registerEth("optimism-goerli", 420, {});
registerEth("xdai", 100, { ensNetwork: 1 });
@@ -17391,6 +17378,34 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
pause(dropWhilePaused) { this.stop(); }
resume() { this.start(); }
}
class PollingBlockTagSubscriber extends OnBlockSubscriber {
#tag;
#lastBlock;
constructor(provider, tag) {
super(provider);
this.#tag = tag;
this.#lastBlock = -2;
}
pause(dropWhilePaused) {
if (dropWhilePaused) {
this.#lastBlock = -2;
}
super.pause(dropWhilePaused);
}
async _poll(blockNumber, provider) {
const block = await provider.getBlock(this.#tag);
if (block == null) {
return;
}
if (this.#lastBlock === -2) {
this.#lastBlock = block.number;
}
else if (block.number > this.#lastBlock) {
provider.emit(this.#tag, block.number);
this.#lastBlock = block.number;
}
}
}
/**
* @_ignore:
*
@@ -17589,10 +17604,12 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
if (typeof (_event) === "string") {
switch (_event) {
case "block":
case "pending":
case "debug":
case "error":
case "network": {
case "finalized":
case "network":
case "pending":
case "safe": {
return { type: _event, tag: _event };
}
}
@@ -17890,10 +17907,10 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
switch (blockTag) {
case "earliest":
return "0x0";
case "finalized":
case "latest":
case "pending":
case "safe":
case "finalized":
return blockTag;
}
if (isHexString(blockTag)) {
@@ -18037,16 +18054,19 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
// No explicit network was set and this is our first time
if (this.#networkPromise == null) {
// Detect the current network (shared with all calls)
const detectNetwork = this._detectNetwork().then((network) => {
this.emit("network", network, null);
return network;
}, (error) => {
// Reset the networkPromise on failure, so we will try again
if (this.#networkPromise === detectNetwork) {
this.#networkPromise = null;
const detectNetwork = (async () => {
try {
const network = await this._detectNetwork();
this.emit("network", network, null);
return network;
}
throw error;
});
catch (error) {
if (this.#networkPromise === detectNetwork) {
this.#networkPromise = null;
}
throw error;
}
})();
this.#networkPromise = detectNetwork;
return (await detectNetwork).clone();
}
@@ -18076,12 +18096,20 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
async getFeeData() {
const network = await this.getNetwork();
const getFeeDataFunc = async () => {
const { _block, gasPrice } = await resolveProperties({
const { _block, gasPrice, priorityFee } = await resolveProperties({
_block: this.#getBlock("latest", false),
gasPrice: ((async () => {
try {
const gasPrice = await this.#perform({ method: "getGasPrice" });
return getBigInt(gasPrice, "%response");
const value = await this.#perform({ method: "getGasPrice" });
return getBigInt(value, "%response");
}
catch (error) { }
return null;
})()),
priorityFee: ((async () => {
try {
const value = await this.#perform({ method: "getPriorityFee" });
return getBigInt(value, "%response");
}
catch (error) { }
return null;
@@ -18092,7 +18120,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
// These are the recommended EIP-1559 heuristics for fee data
const block = this._wrapBlock(_block, network);
if (block && block.baseFeePerGas) {
maxPriorityFeePerGas = BigInt("1000000000");
maxPriorityFeePerGas = (priorityFee != null) ? priorityFee : BigInt("1000000000");
maxFeePerGas = (block.baseFeePerGas * BN_2$1) + maxPriorityFeePerGas;
}
return new FeeData(gasPrice, maxFeePerGas, maxPriorityFeePerGas);
@@ -18470,6 +18498,9 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
subscriber.pollingInterval = this.pollingInterval;
return subscriber;
}
case "safe":
case "finalized":
return new PollingBlockTagSubscriber(this, sub.type);
case "event":
return new PollingEventSubscriber(this, sub.filter);
case "transaction":
@@ -19422,12 +19453,45 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
// 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 getting the transaction
const tx = await this.provider.getTransaction(hash);
if (tx != null) {
resolve(tx.replaceableTransaction(blockNumber));
return;
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" )) {
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);
@@ -19500,11 +19564,12 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
#drainTimer;
#notReady;
#network;
#pendingDetectNetwork;
#scheduleDrain() {
if (this.#drainTimer) {
return;
}
// If we aren't using batching, no hard in sending it immeidately
// 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;
@@ -19575,6 +19640,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
this.#payloads = [];
this.#drainTimer = null;
this.#network = null;
this.#pendingDetectNetwork = null;
{
let resolve = null;
const promise = new Promise((_resolve) => {
@@ -19582,9 +19648,15 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
});
this.#notReady = { promise, resolve };
}
// Make sure any static network is compatbile with the provided netwrok
const staticNetwork = this._getOption("staticNetwork");
if (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;
}
@@ -19645,30 +19717,56 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
async _detectNetwork() {
const network = this._getOption("staticNetwork");
if (network) {
return 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) {
return Network.from(getBigInt(await this.send("eth_chainId", [])));
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
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];
}
catch (error) {
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);
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
@@ -19784,6 +19882,8 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
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",
@@ -20277,6 +20377,10 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
return "arb-mainnet.g.alchemy.com";
case "arbitrum-goerli":
return "arb-goerli.g.alchemy.com";
case "base":
return "base-mainnet.g.alchemy.com";
case "base-goerli":
return "base-goerli.g.alchemy.com";
case "matic":
return "polygon-mainnet.g.alchemy.com";
case "matic-mumbai":
@@ -20725,6 +20829,44 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
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", {
@@ -21015,8 +21157,21 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
*
* If unspecified, the network will be discovered.
*/
constructor(network) {
super(network, { batchMaxCount: 1 });
constructor(network, _options) {
// Copy the options
const options = Object.assign({}, (_options != null) ? _options : {});
// Support for batches is generally not supported for
// connection-base providers; if this changes in the future
// the _send should be updated to reflect this
assertArgument(options.batchMaxCount == null || options.batchMaxCount === 1, "sockets-based providers do not support batches", "options.batchMaxCount", _options);
options.batchMaxCount = 1;
// Socket-based Providers (generally) cannot change their network,
// since they have a long-lived connection; but let people override
// this if they have just cause.
if (options.staticNetwork == null) {
options.staticNetwork = true;
}
super(network, options);
this.#callbacks = new Map();
this.#subs = new Map();
this.#pending = new Map();
@@ -21160,8 +21315,8 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
}
return this.#websocket;
}
constructor(url, network) {
super(network);
constructor(url, network, options) {
super(network, options);
if (typeof (url) === "string") {
this.#connect = () => { return new _WebSocket(url); };
this.#websocket = this.#connect();
@@ -21778,6 +21933,8 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
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":
@@ -21923,6 +22080,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
return this.#height;
}
case "getGasPrice":
case "getPriorityFee":
case "estimateGas":
return getMedian(this.quorum, results);
case "getBlock":
@@ -22004,15 +22162,46 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
// a cost on the user, so spamming is safe-ish. Just send it to
// every backend.
if (req.method === "broadcastTransaction") {
const results = await Promise.all(this.#configs.map(async ({ provider, weight }) => {
// 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);
return Object.assign(normalizeResult({ result }), { weight });
results[index] = Object.assign(normalizeResult({ result }), { weight });
}
catch (error) {
return Object.assign(normalizeResult({ error }), { weight });
results[index] = Object.assign(normalizeResult({ 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",
@@ -22026,8 +22215,16 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
await this.#initialSync();
// Bootstrap enough runners to meet quorum
const running = new Set();
for (let i = 0; i < this.quorum; i++) {
this.#addRunner(running, req);
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
@@ -22088,7 +22285,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
* // third-party services available
* provider = getDefaultProvider("mainnet");
*
* // Connect to Polygoin, but only allow Etherscan and
* // 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",
@@ -24369,7 +24566,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
return Wallet.#fromAccount(account);
}
/**
* Creates a new random [[HDNodeWallet]] using the avavilable
* Creates a new random [[HDNodeWallet]] using the available
* [cryptographic random source](randomBytes).
*
* If there is no crytographic random source, this will throw.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -100,7 +100,7 @@ const rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
/**
* The current version of Ethers.
*/
const version = "6.8.0";
const version = "6.9.1";
/**
* Property helper functions.
@@ -192,13 +192,13 @@ function stringify(value) {
}
/**
* Returns a new Error configured to the format ethers emits errors, with
* the %%message%%, [[api:ErrorCode]] %%code%% and additioanl properties
* the %%message%%, [[api:ErrorCode]] %%code%% and additional properties
* for the corresponding EthersError.
*
* Each error in ethers includes the version of ethers, a
* machine-readable [[ErrorCode]], and depneding on %%code%%, additional
* required properties. The error message will also include the %%meeage%%,
* ethers version, %%code%% and all aditional properties, serialized.
* machine-readable [[ErrorCode]], and depending on %%code%%, additional
* required properties. The error message will also include the %%message%%,
* ethers version, %%code%% and all additional properties, serialized.
*/
function makeError(message, code, info) {
let shortMessage = message;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -4,7 +4,7 @@ Here is a collection of short, but useful examples of working with
ENS entries.
_subsection: Get all Text rectods @<cookbook-ens-allText>
_subsection: Get all Text records @<cookbook-ens-allText>
Here is a short recipe to get all the text records set for an ENS
name.
@@ -19,7 +19,7 @@ to install:
_code: Fetching all ENS text records. @lang<script>
mport { ethers } from "ethers";
import { ethers } from "ethers";
import { MulticallProvider } from "@ethers-ext/provider-multicall";
async function getTextRecords(_provider, name) {
@@ -43,7 +43,7 @@ async function getTextRecords(_provider, name) {
// Filter the *unique* keys
const keys = [ ...(new Set(logs.map((log) => log.args.key))) ];
// Get the values for the keys; failures are discard
// Get the values for the keys; failures are discarded
const values = await Promise.all(keys.map((key) => {
try {
return resolver.getText(key);

View File

@@ -22,7 +22,7 @@ user from accidentally authorizing an action they didn't intend.
_subsection: Messages @<cookbook-signing-messages>
A signed message can be any data, bu it is generally recommended
A signed message can be any data, but it is generally recommended
to use human-readable text, as this is easier for a user to
verify visually.
@@ -30,7 +30,7 @@ This technique could be used, for example, to sign into a service
by using the text ``"I am signing into ethers.org on 2023-06-04 12:57pm"``.
The user can then see the message in MetaMask or on a Ledger
Hardware Wallet and accept that they wish to sign the message which
the site can then autheticate them with. By providing a timestamp
the site can then authenticate them with. By providing a timestamp
the site can ensure that an older signed message cannot be used again
in the future.
@@ -48,7 +48,7 @@ since 0x19 is invalid as the first byte of a transaction (in [[link-rlp]] it
indicates a single byte of value 25), the initial byte ``\\x19`` has
now been adopted as a prefix for //some sort of signed data//,
where the second byte determines how to interpret that data. If the
second bytes is 69 (the letter ``"E"``, as in
second byte is 69 (the letter ``"E"``, as in
``"Ethereum Signed Message:\\n"``), then the format is a
the above prefixed message format.
@@ -105,7 +105,7 @@ await contract.recoverStringFromExpanded(message, sig);
await contract.recoverStringFromVRS(message, sig.v, sig.r, sig.s);
//_result:
// Or if using a an API that expects a raw signature.
// Or if using an API that expects a raw signature.
await contract.recoverStringFromRaw(message, rawSig);
//_result:
@@ -202,7 +202,7 @@ contract RecoverMessage {
return _ecrecover(message, v, sig.r, s);
}
// Recover the address from the an expanded Signature struct.
// Recover the address from the expanded Signature struct.
//
// This Signature format is 96 bytes in length.
function recoverStringFromExpanded(string calldata message, SignatureExpanded calldata sig) public pure returns (address) {

View File

@@ -129,8 +129,8 @@ _code: @lang<script>
// If MetaMask is not installed, we use the default provider,
// which is backed by a variety of third-party services (such
// as INFURA). They do not have private keys installed so are
// only have read-only access
// as INFURA). They do not have private keys installed,
// so they only have read-only access
console.log("MetaMask not installed; using read-only defaults")
provider = ethers.getDefaultProvider()
@@ -156,7 +156,7 @@ you can use the [[JsonRpcProvider]] directly, which communicates
using the [[link-jsonrpc]] protocol.
When using your own Ethereum node or a developer-base blockchain,
such as Hardhat or Ganache, you can get access the accounts with
such as Hardhat or Ganache, you can get access to the accounts with
[[JsonRpcProvider-getSigner]].
_code: connecting to a JSON-RPC URL @lang<script>
@@ -177,7 +177,7 @@ results when performing mathematic operations.
As a result, the internal units used (e.g. wei) which are suited for
machine-readable purposes and maths are often very large and not
terribly human-readable.
easily human-readable.
For example, imagine dealing with dollars and cents; you would show
values like ``"$2.56"``. In the blockchain world, we would keep all

View File

@@ -353,8 +353,8 @@ _code: solidity non-standard packed @lang<script>
// v6
ethers.solidityPacked(types, values)
ethers.utils.solidityPackedKeccak256(types, values)
ethers.utils.solidityPackedSha256(types, values)
ethers.solidityPackedKeccak256(types, values)
ethers.solidityPackedSha256(types, values)
_code: property manipulation @lang<script>
// v5

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=test-provider-jsonrpc.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"test-provider-jsonrpc.d.ts","sourceRoot":"","sources":["../../src.ts/_tests/test-provider-jsonrpc.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,160 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const assert_1 = tslib_1.__importDefault(require("assert"));
const index_js_1 = require("../index.js");
const StatusMessages = {
200: "OK",
400: "BAD REQUEST",
500: "SERVER ERROR",
};
const wallet = new index_js_1.Wallet((0, index_js_1.id)("test"));
function createProvider(testFunc) {
let blockNumber = 1;
const ticker = setInterval(() => { blockNumber++; }, 100);
if (ticker.unref) {
ticker.unref();
}
const processReq = (req) => {
let result = testFunc(req.method, req.params, blockNumber);
if (result === undefined) {
switch (req.method) {
case "eth_blockNumber":
result = blockNumber;
break;
case "eth_chainId":
result = "0x1337";
break;
case "eth_accounts":
result = [wallet.address];
break;
default:
console.log("****", req);
return { id: index_js_1.id, error: "unsupported", jsonrpc: "2.0" };
}
}
return { id: req.id, result, jsonrpc: "2.0" };
};
const req = new index_js_1.FetchRequest("http:/\/localhost:8082/");
req.getUrlFunc = async (_req, signal) => {
const req = JSON.parse(_req.hasBody() ? (0, index_js_1.toUtf8String)(_req.body) : "");
let statusCode = 200;
const headers = {};
let resp;
try {
if (Array.isArray(req)) {
resp = req.map((r) => processReq(r));
}
else {
resp = processReq(req);
}
}
catch (error) {
statusCode = 500;
resp = error.message;
}
const body = (0, index_js_1.toUtf8Bytes)(JSON.stringify(resp));
return {
statusCode,
statusMessage: StatusMessages[statusCode],
headers, body
};
};
return new index_js_1.JsonRpcProvider(req, undefined, { cacheTimeout: -1 });
}
describe("Ensure Catchable Errors", function () {
it("Can catch bad broadcast replies", async function () {
this.timeout(15000);
const txInfo = {
chainId: 1337,
gasLimit: 100000,
maxFeePerGas: 2000000000,
maxPriorityFeePerGas: 1000000000,
to: wallet.address,
value: 1,
};
const txSign = await wallet.signTransaction(txInfo);
const txObj = index_js_1.Transaction.from(txSign);
let count = 0;
const provider = createProvider((method, params, blockNumber) => {
switch (method) {
case "eth_sendTransaction":
return txObj.hash;
case "eth_getTransactionByHash": {
count++;
// First time; fail!
if (count === 1) {
throw (0, index_js_1.makeError)("Faux Error", "SERVER_ERROR", {
request: ({})
});
}
// Second time; return null
if (count === 2) {
return null;
}
// Return a valid tx...
const result = Object.assign({}, txObj.toJSON(), txObj.signature.toJSON(), { hash: txObj.hash, from: wallet.address });
// ...eventually mined
if (count > 4) {
result.blockNumber = blockNumber;
result.blockHash = (0, index_js_1.id)("test");
}
return result;
}
}
return undefined;
});
const signer = await provider.getSigner();
const tx = await signer.sendTransaction(txInfo);
(0, assert_1.default)(tx);
});
it("Missing v is recovered", async function () {
this.timeout(15000);
const txInfo = {
chainId: 1337,
gasLimit: 100000,
maxFeePerGas: 2000000000,
maxPriorityFeePerGas: 1000000000,
to: wallet.address,
value: 1,
};
const txSign = await wallet.signTransaction(txInfo);
const txObj = index_js_1.Transaction.from(txSign);
let count = 0;
// A provider which is mocked to return a "missing v"
// in getTransaction
const provider = createProvider((method, params, blockNumber) => {
switch (method) {
case "eth_sendTransaction":
return txObj.hash;
case "eth_getTransactionByHash": {
count++;
// The fully valid tx response
const result = Object.assign({}, txObj.toJSON(), txObj.signature.toJSON(), { hash: txObj.hash, from: wallet.address, sig: null });
// First time; fail with a missing v!
if (count < 2) {
delete result.v;
}
// Debug
result._count = count;
return result;
}
}
return undefined;
});
// Track any "missing v" error
let missingV = null;
provider.on("error", (e) => {
if ((0, index_js_1.isError)(e, "UNKNOWN_ERROR") && (0, index_js_1.isError)(e.error, "INVALID_ARGUMENT")) {
if (e.error.argument === "signature" && e.error.shortMessage === "missing v") {
missingV = e.error;
}
}
});
const signer = await provider.getSigner();
const tx = await signer.sendTransaction(txInfo);
assert_1.default.ok(!!tx, "we got a transaction");
assert_1.default.ok(!!missingV, "missing v error present");
});
});
//# sourceMappingURL=test-provider-jsonrpc.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
import { AbstractProvider, Network } from "../index.js";
import type { PerformActionRequest } from "../index.js";
export type Performer = (req: PerformActionRequest) => Promise<any>;
export declare class MockProvider extends AbstractProvider {
readonly _perform: Performer;
constructor(perform: Performer);
_detectNetwork(): Promise<Network>;
perform(req: PerformActionRequest): Promise<any>;
}
//# sourceMappingURL=test-providers-fallback.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"test-providers-fallback.d.ts","sourceRoot":"","sources":["../../src.ts/_tests/test-providers-fallback.ts"],"names":[],"mappings":"AAEA,OAAO,EAGH,gBAAgB,EAAoB,OAAO,EAE9C,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EACR,oBAAoB,EACvB,MAAM,aAAa,CAAC;AAWrB,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,oBAAoB,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAEpE,qBAAa,YAAa,SAAQ,gBAAgB;IAC9C,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;gBAEjB,OAAO,EAAE,SAAS;IAKxB,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IAElC,OAAO,CAAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC;CAGzD"}

View File

@@ -0,0 +1,138 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MockProvider = void 0;
const tslib_1 = require("tslib");
const assert_1 = tslib_1.__importDefault(require("assert"));
const index_js_1 = require("../index.js");
const network = index_js_1.Network.from("mainnet");
function stall(duration) {
return new Promise((resolve) => { setTimeout(resolve, duration); });
}
class MockProvider extends index_js_1.AbstractProvider {
_perform;
constructor(perform) {
super(network, { cacheTimeout: -1 });
this._perform = perform;
}
async _detectNetwork() { return network; }
async perform(req) {
return await this._perform(req);
}
}
exports.MockProvider = MockProvider;
describe("Test Fallback broadcast", function () {
const txHash = "0x33017397ef7c7943dee3b422aec52b0a210de58d73d49c1b3ce455970f01c83a";
async function test(actions) {
// https://sepolia.etherscan.io/tx/0x33017397ef7c7943dee3b422aec52b0a210de58d73d49c1b3ce455970f01c83a
const tx = "0x02f87683aa36a7048459682f00845d899ef982520894b5bdaa442bb34f27e793861c456cd5bdc527ac8c89056bc75e2d6310000080c001a07503893743e94445b2361a444343757e6f59d52e19e9b3f65eb138d802eaa972a06e4e9bc10ff55474f9aac0a4c284733b4195cb7b273de5e7465ce75a168e0c38";
const providers = actions.map(({ timeout, error }) => {
return new MockProvider(async (r) => {
if (r.method === "getBlockNumber") {
return 1;
}
if (r.method === "broadcastTransaction") {
await stall(timeout);
if (error) {
throw error;
}
return txHash;
}
throw new Error(`unhandled method: ${r.method}`);
});
});
;
const provider = new index_js_1.FallbackProvider(providers);
return await provider.broadcastTransaction(tx);
}
it("picks late non-failed broadcasts", async function () {
const result = await test([
{ timeout: 200, error: (0, index_js_1.makeError)("already seen", "UNKNOWN_ERROR") },
{ timeout: 4000, error: (0, index_js_1.makeError)("already seen", "UNKNOWN_ERROR") },
{ timeout: 400 },
]);
(0, assert_1.default)(result.hash === txHash, "result.hash === txHash");
});
it("picks late non-failed broadcasts with quorum-met red-herrings", async function () {
const result = await test([
{ timeout: 200, error: (0, index_js_1.makeError)("bad nonce", "NONCE_EXPIRED") },
{ timeout: 400, error: (0, index_js_1.makeError)("bad nonce", "NONCE_EXPIRED") },
{ timeout: 1000 },
]);
(0, assert_1.default)(result.hash === txHash, "result.hash === txHash");
});
it("insufficient funds short-circuit broadcast", async function () {
await assert_1.default.rejects(async function () {
const result = await test([
{ timeout: 200, error: (0, index_js_1.makeError)("is broke", "INSUFFICIENT_FUNDS") },
{ timeout: 400, error: (0, index_js_1.makeError)("is broke", "INSUFFICIENT_FUNDS") },
{ timeout: 800 },
{ timeout: 1000 },
]);
console.log(result);
}, function (error) {
(0, assert_1.default)((0, index_js_1.isError)(error, "INSUFFICIENT_FUNDS"));
return true;
});
});
});
describe("Test Inflight Quorum", function () {
// Fires the %%actions%% as providers which will delay before returning,
// and returns an array of arrays, where each sub-array indicates which
// providers were inflight at once.
async function test(actions, quorum) {
const inflights = [[]];
const configs = actions.map(({ delay, stallTimeout, priority, weight }, index) => ({
provider: new MockProvider(async (r) => {
if (r.method === "getBlockNumber") {
return 1;
}
if (r.method === "getBalance") {
// Add this as inflight
let last = inflights.pop();
if (last == null) {
throw new Error("no elements");
}
inflights.push(last);
last = last.slice();
last.push(index);
inflights.push(last);
// Do the thing
await stall(delay);
// Remove as inflight
last = inflights.pop();
if (last == null) {
throw new Error("no elements");
}
inflights.push(last);
last = last.filter((v) => (v !== index));
inflights.push(last);
return 0;
}
console.log(r);
throw new Error(`unhandled method: ${r.method}`);
}),
stallTimeout, priority, weight
}));
const provider = new index_js_1.FallbackProvider(configs, network, {
cacheTimeout: -1, pollingInterval: 100,
quorum
});
await provider.getBalance(index_js_1.ZeroAddress);
return inflights;
}
// See: #4298
it("applies weights against inflight requests", async function () {
this.timeout(2000);
const inflights = await test([
{ delay: 50, stallTimeout: 1000, priority: 1, weight: 2 },
{ delay: 50, stallTimeout: 1000, priority: 1, weight: 2 },
], 2);
// Make sure there is never more than 1 inflight provider at once
for (const running of inflights) {
assert_1.default.ok(running.length <= 1, `too many inflight requests: ${JSON.stringify(inflights)}`);
}
});
// @TODO: add lots more tests, checking on priority, weight and stall
// configurations
});
//# sourceMappingURL=test-providers-fallback.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"test-providers-fallback.js","sourceRoot":"","sources":["../../src.ts/_tests/test-providers-fallback.ts"],"names":[],"mappings":";;;;AAAA,4DAA4B;AAE5B,0CAKqB;AAQrB,MAAM,OAAO,GAAG,kBAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAExC,SAAS,KAAK,CAAC,QAAgB;IAC3B,OAAQ,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,GAAG,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACzE,CAAC;AAKD,MAAa,YAAa,SAAQ,2BAAgB;IACrC,QAAQ,CAAY;IAE7B,YAAY,OAAkB;QAC1B,KAAK,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QACrC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC5B,CAAC;IAED,KAA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,SAAS,CAAC,SAAS,CAAE,EAAE,CAAC,CAAC;SAChG;IACL,CAAC,CAAC,CAAC;IAEH,qEAAqE;IACrE,wBAAwB;AAC5B,CAAC,CAAC,CAAC"}

View File

@@ -5,5 +5,5 @@ exports.version = void 0;
/**
* The current version of Ethers.
*/
exports.version = "6.8.0";
exports.version = "6.9.1";
//# sourceMappingURL=_version.js.map

File diff suppressed because one or more lines are too long

View File

@@ -458,9 +458,6 @@ class ParamType {
}
else {
if (this.isTuple()) {
if (format !== "sighash") {
result += this.type;
}
result += "(" + this.components.map((comp) => comp.format(format)).join((format === "full") ? ", " : ",") + ")";
}
else {
@@ -1007,7 +1004,9 @@ class ConstructorFragment extends Fragment {
});
}
const result = [`constructor${joinParams(format, this.inputs)}`];
result.push((this.payable) ? "payable" : "nonpayable");
if (this.payable) {
result.push("payable");
}
if (this.gas != null) {
result.push(`@${this.gas.toString()}`);
}

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
{"version":3,"file":"namehash.d.ts","sourceRoot":"","sources":["../../src.ts/hash/namehash.ts"],"names":[],"mappings":"AAyCA;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMjD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,MAAM,CAKxD;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAW7C;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAa9C"}
{"version":3,"file":"namehash.d.ts","sourceRoot":"","sources":["../../src.ts/hash/namehash.ts"],"names":[],"mappings":"AAyCA;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAOjD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,MAAM,CAKxD;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAa7C;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAa9C"}

View File

@@ -35,6 +35,9 @@ function ensNameSplit(name) {
*/
function ensNormalize(name) {
try {
if (name.length === 0) {
throw new Error("empty label");
}
return (0, ens_normalize_1.ens_normalize)(name);
}
catch (error) {
@@ -58,6 +61,7 @@ exports.isValidName = isValidName;
*/
function namehash(name) {
(0, index_js_2.assertArgument)(typeof (name) === "string", "invalid ENS name; not a string", "name", name);
(0, index_js_2.assertArgument)(name.length, `invalid ENS name (empty label)`, "name", name);
let result = Zeros;
const comps = ensNameSplit(name);
while (comps.length) {

View File

@@ -1 +1 @@
{"version":3,"file":"namehash.js","sourceRoot":"","sources":["../../src.ts/hash/namehash.ts"],"names":[],"mappings":";;;AACA,iDAA+C;AAC/C,gDAE2B;AAG3B,0DAAuD;AAEvD,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;AACjC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAEd,SAAS,cAAc,CAAC,IAAgB;IACpC,IAAA,yBAAc,EAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,mCAAmC,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;IACpF,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,SAAS,YAAY,CAAC,IAAY;IAC9B,MAAM,KAAK,GAAG,IAAA,sBAAW,EAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAsB,EAAG,CAAC;IAErC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QAAE,OAAO,KAAK,CAAC;KAAE;IAExC,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EA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E;QAED,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC9C,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QACnB,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;QAC5B,OAAO,KAAK,CAAC;IAEjB,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;AAChB,CAAC;AAbD,8BAaC"}

View File

@@ -60,7 +60,7 @@ export type DebugEventAbstractProvider = {
* if they are modifying a low-level feature of how subscriptions operate.
*/
export type Subscription = {
type: "block" | "close" | "debug" | "error" | "network" | "pending";
type: "block" | "close" | "debug" | "error" | "finalized" | "network" | "pending" | "safe";
tag: string;
} | {
type: "transaction";
@@ -208,6 +208,8 @@ export type PerformActionRequest = {
} | {
method: "getLogs";
filter: PerformActionFilter;
} | {
method: "getPriorityFee";
} | {
method: "getStorage";
address: string;

File diff suppressed because one or more lines are too long

View File

@@ -94,10 +94,12 @@ async function getSubscription(_event, provider) {
if (typeof (_event) === "string") {
switch (_event) {
case "block":
case "pending":
case "debug":
case "error":
case "network": {
case "finalized":
case "network":
case "pending":
case "safe": {
return { type: _event, tag: _event };
}
}
@@ -395,10 +397,10 @@ class AbstractProvider {
switch (blockTag) {
case "earliest":
return "0x0";
case "finalized":
case "latest":
case "pending":
case "safe":
case "finalized":
return blockTag;
}
if ((0, index_js_6.isHexString)(blockTag)) {
@@ -542,16 +544,19 @@ class AbstractProvider {
// No explicit network was set and this is our first time
if (this.#networkPromise == null) {
// Detect the current network (shared with all calls)
const detectNetwork = this._detectNetwork().then((network) => {
this.emit("network", network, null);
return network;
}, (error) => {
// Reset the networkPromise on failure, so we will try again
if (this.#networkPromise === detectNetwork) {
this.#networkPromise = null;
const detectNetwork = (async () => {
try {
const network = await this._detectNetwork();
this.emit("network", network, null);
return network;
}
throw error;
});
catch (error) {
if (this.#networkPromise === detectNetwork) {
this.#networkPromise = null;
}
throw error;
}
})();
this.#networkPromise = detectNetwork;
return (await detectNetwork).clone();
}
@@ -581,12 +586,20 @@ class AbstractProvider {
async getFeeData() {
const network = await this.getNetwork();
const getFeeDataFunc = async () => {
const { _block, gasPrice } = await (0, index_js_6.resolveProperties)({
const { _block, gasPrice, priorityFee } = await (0, index_js_6.resolveProperties)({
_block: this.#getBlock("latest", false),
gasPrice: ((async () => {
try {
const gasPrice = await this.#perform({ method: "getGasPrice" });
return (0, index_js_6.getBigInt)(gasPrice, "%response");
const value = await this.#perform({ method: "getGasPrice" });
return (0, index_js_6.getBigInt)(value, "%response");
}
catch (error) { }
return null;
})()),
priorityFee: ((async () => {
try {
const value = await this.#perform({ method: "getPriorityFee" });
return (0, index_js_6.getBigInt)(value, "%response");
}
catch (error) { }
return null;
@@ -597,7 +610,7 @@ class AbstractProvider {
// These are the recommended EIP-1559 heuristics for fee data
const block = this._wrapBlock(_block, network);
if (block && block.baseFeePerGas) {
maxPriorityFeePerGas = BigInt("1000000000");
maxPriorityFeePerGas = (priorityFee != null) ? priorityFee : BigInt("1000000000");
maxFeePerGas = (block.baseFeePerGas * BN_2) + maxPriorityFeePerGas;
}
return new provider_js_1.FeeData(gasPrice, maxFeePerGas, maxPriorityFeePerGas);
@@ -975,6 +988,9 @@ class AbstractProvider {
subscriber.pollingInterval = this.pollingInterval;
return subscriber;
}
case "safe":
case "finalized":
return new subscriber_polling_js_1.PollingBlockTagSubscriber(this, sub.type);
case "event":
return new subscriber_polling_js_1.PollingEventSubscriber(this, sub.filter);
case "transaction":

File diff suppressed because one or more lines are too long

View File

@@ -37,7 +37,7 @@ import { WebSocketLike } from "./provider-websocket.js";
* // third-party services available
* provider = getDefaultProvider("mainnet");
*
* // Connect to Polygoin, but only allow Etherscan and
* // 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",

View File

@@ -54,7 +54,7 @@ const Testnets = "goerli kovan sepolia classicKotti optimism-goerli arbitrum-goe
* // third-party services available
* provider = getDefaultProvider("mainnet");
*
* // Connect to Polygoin, but only allow Etherscan and
* // 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",

View File

@@ -291,23 +291,6 @@ function getGasStationPlugin(url) {
}
});
}
// Used by Optimism for a custom priority fee
function getPriorityFeePlugin(maxPriorityFeePerGas) {
return new plugins_network_js_1.FetchUrlFeeDataNetworkPlugin("data:", async (fetchFeeData, provider, request) => {
const feeData = await fetchFeeData();
// This should always fail
if (feeData.maxFeePerGas == null || feeData.maxPriorityFeePerGas == null) {
return feeData;
}
// Compute the corrected baseFee to recompute the updated values
const baseFee = feeData.maxFeePerGas - feeData.maxPriorityFeePerGas;
return {
gasPrice: feeData.gasPrice,
maxFeePerGas: (baseFee + maxPriorityFeePerGas),
maxPriorityFeePerGas
};
});
}
// See: https://chainlist.org
let injected = false;
function injectCommonNetworks() {
@@ -343,13 +326,16 @@ function injectCommonNetworks() {
registerEth("rinkeby", 4, { ensNetwork: 4 });
registerEth("goerli", 5, { ensNetwork: 5 });
registerEth("kovan", 42, { ensNetwork: 42 });
registerEth("sepolia", 11155111, {});
registerEth("sepolia", 11155111, { ensNetwork: 11155111 });
registerEth("classic", 61, {});
registerEth("classicKotti", 6, {});
registerEth("arbitrum", 42161, {
ensNetwork: 1,
});
registerEth("arbitrum-goerli", 421613, {});
registerEth("base", 8453, { ensNetwork: 1 });
registerEth("base-goerli", 84531, {});
registerEth("base-sepolia", 84532, {});
registerEth("bnb", 56, { ensNetwork: 1 });
registerEth("bnbt", 97, {});
registerEth("linea", 59144, { ensNetwork: 1 });
@@ -368,9 +354,7 @@ function injectCommonNetworks() {
});
registerEth("optimism", 10, {
ensNetwork: 1,
plugins: [
getPriorityFeePlugin(BigInt("1000000"))
]
plugins: []
});
registerEth("optimism-goerli", 420, {});
registerEth("xdai", 100, { ensNetwork: 1 });

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
{"version":3,"file":"provider-alchemy.d.ts","sourceRoot":"","sources":["../../src.ts/providers/provider-alchemy.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,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;AA+B/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"}
{"version":3,"file":"provider-alchemy.d.ts","sourceRoot":"","sources":["../../src.ts/providers/provider-alchemy.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,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;AAmC/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"}

View File

@@ -23,6 +23,10 @@ function getHost(name) {
return "arb-mainnet.g.alchemy.com";
case "arbitrum-goerli":
return "arb-goerli.g.alchemy.com";
case "base":
return "base-mainnet.g.alchemy.com";
case "base-goerli":
return "base-goerli.g.alchemy.com";
case "matic":
return "polygon-mainnet.g.alchemy.com";
case "matic-mumbai":

View File

@@ -1 +1 @@
{"version":3,"file":"provider-alchemy.js","sourceRoot":"","sources":["../../src.ts/providers/provider-alchemy.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,gDAG2B;AAE3B,iDAAqD;AACrD,6CAAuC;AACvC,+DAAwD;AAOxD,MAAM,aAAa,GAAG,kCAAkC,CAAA;AAExD,SAAS,OAAO,CAAC,IAAY;IACzB,QAAO,IAAI,EAAE;QACT,KAAK,SAAS;YACV,OAAO,2BAA2B,CAAC;QACvC,KAAK,QAAQ;YACT,OAAO,0BAA0B,CAAC;QACtC,KAAK,SAAS;YACV,OAAO,2BAA2B,CAAC;QAEvC,KAAK,UAAU;YACX,OAAO,2BAA2B,CAA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C,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"}

View File

@@ -346,6 +346,44 @@ class EtherscanProvider extends abstract_provider_js_1.AbstractProvider {
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", {

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
{"version":3,"file":"provider-fallback.d.ts","sourceRoot":"","sources":["../../src.ts/providers/provider-fallback.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,O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
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":
@@ -446,6 +448,7 @@ class FallbackProvider extends abstract_provider_js_1.AbstractProvider {
return this.#height;
}
case "getGasPrice":
case "getPriorityFee":
case "estimateGas":
return getMedian(this.quorum, results);
case "getBlock":
@@ -527,15 +530,46 @@ class FallbackProvider extends abstract_provider_js_1.AbstractProvider {
// a cost on the user, so spamming is safe-ish. Just send it to
// every backend.
if (req.method === "broadcastTransaction") {
const results = await Promise.all(this.#configs.map(async ({ provider, weight }) => {
// 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);
return Object.assign(normalizeResult({ result }), { weight });
results[index] = Object.assign(normalizeResult({ result }), { weight });
}
catch (error) {
return Object.assign(normalizeResult({ error }), { weight });
results[index] = Object.assign(normalizeResult({ 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 ((0, index_js_1.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);
(0, index_js_1.assert)(result !== undefined, "problem multi-broadcasting", "SERVER_ERROR", {
request: "%sub-requests",
@@ -549,8 +583,16 @@ class FallbackProvider extends abstract_provider_js_1.AbstractProvider {
await this.#initialSync();
// Bootstrap enough runners to meet quorum
const running = new Set();
for (let i = 0; i < this.quorum; i++) {
this.#addRunner(running, req);
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

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,7 @@
/// <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
@@ -13,7 +14,7 @@ export declare class IpcSocketProvider extends SocketProvider {
* The connected socket.
*/
get socket(): Socket;
constructor(path: string, network?: Networkish);
constructor(path: string, network?: Networkish, options?: JsonRpcApiProviderOptions);
destroy(): void;
_write(message: string): Promise<void>;
}

View File

@@ -1 +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;AAClC,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;IA8B9C,OAAO,IAAI,IAAI;IAOT,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG/C"}
{"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;CAG/C"}

View File

@@ -29,8 +29,8 @@ class IpcSocketProvider extends provider_socket_js_1.SocketProvider {
* The connected socket.
*/
get socket() { return this.#socket; }
constructor(path, network) {
super(network);
constructor(path, network, options) {
super(network, options);
this.#socket = (0, net_1.connect)(path);
this.socket.on("ready", async () => {
try {

View File

@@ -1 +1 @@
{"version":3,"file":"provider-ipcsocket.js","sourceRoot":"","sources":["../../src.ts/providers/provider-ipcsocket.ts"],"names":[],"mappings":";;;AACA,6BAA8B;AAC9B,6DAAsD;AAMtD,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;YAAE,MAAM;SAAE;QACzB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,QAAQ,EAAE,CA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;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,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;CACJ;AAhDD,8CAgDC"}

View File

@@ -117,7 +117,7 @@ export type DebugEventJsonRpcApiProvider = {
*/
export type JsonRpcApiProviderOptions = {
polling?: boolean;
staticNetwork?: null | Network;
staticNetwork?: null | boolean | Network;
batchStallTime?: number;
batchMaxSize?: number;
batchMaxCount?: number;

File diff suppressed because one or more lines are too long

View File

@@ -136,12 +136,45 @@ class JsonRpcSigner extends abstract_signer_js_1.AbstractSigner {
// 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 getting the transaction
const tx = await this.provider.getTransaction(hash);
if (tx != null) {
resolve(tx.replaceableTransaction(blockNumber));
return;
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 ((0, index_js_5.isError)(error, "CANCELLED") || (0, index_js_5.isError)(error, "BAD_DATA") ||
(0, index_js_5.isError)(error, "NETWORK_ERROR" || (0, index_js_5.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 ((0, index_js_5.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", (0, index_js_5.makeError)("failed to fetch transation after sending (will try again)", "UNKNOWN_ERROR", { error }));
}
// Wait another 4 seconds
this.provider._setTimeout(() => { checkTx(); }, timeouts.pop() || 4000);
@@ -215,11 +248,12 @@ class JsonRpcApiProvider extends abstract_provider_js_1.AbstractProvider {
#drainTimer;
#notReady;
#network;
#pendingDetectNetwork;
#scheduleDrain() {
if (this.#drainTimer) {
return;
}
// If we aren't using batching, no hard in sending it immeidately
// 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;
@@ -290,6 +324,7 @@ class JsonRpcApiProvider extends abstract_provider_js_1.AbstractProvider {
this.#payloads = [];
this.#drainTimer = null;
this.#network = null;
this.#pendingDetectNetwork = null;
{
let resolve = null;
const promise = new Promise((_resolve) => {
@@ -297,9 +332,15 @@ class JsonRpcApiProvider extends abstract_provider_js_1.AbstractProvider {
});
this.#notReady = { promise, resolve };
}
// Make sure any static network is compatbile with the provided netwrok
const staticNetwork = this._getOption("staticNetwork");
if (staticNetwork) {
if (typeof (staticNetwork) === "boolean") {
(0, index_js_5.assertArgument)(!staticNetwork || network !== "any", "staticNetwork cannot be used on special network 'any'", "options", options);
if (staticNetwork && network != null) {
this.#network = network_js_1.Network.from(network);
}
}
else if (staticNetwork) {
// Make sure any static network is compatbile with the provided netwrok
(0, index_js_5.assertArgument)(network == null || staticNetwork.matches(network), "staticNetwork MUST match network object", "options", options);
this.#network = staticNetwork;
}
@@ -360,30 +401,56 @@ class JsonRpcApiProvider extends abstract_provider_js_1.AbstractProvider {
async _detectNetwork() {
const network = this._getOption("staticNetwork");
if (network) {
return 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) {
return network_js_1.Network.from((0, index_js_5.getBigInt)(await this.send("eth_chainId", [])));
this.#pendingDetectNetwork = (async () => {
try {
const result = network_js_1.Network.from((0, index_js_5.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
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];
}
catch (error) {
this.emit("debug", { action: "receiveRpcError", error });
throw error;
}
this.emit("debug", { action: "receiveRpcResult", result });
if ("result" in result) {
return network_js_1.Network.from((0, index_js_5.getBigInt)(result.result));
}
throw this.getRpcError(payload, result);
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_js_1.Network.from((0, index_js_5.getBigInt)(result.result));
}
throw this.getRpcError(payload, result);
})();
return await this.#pendingDetectNetwork;
}
/**
* Sub-classes **MUST** call this. Until [[_start]] has been called, no calls
@@ -499,6 +566,8 @@ class JsonRpcApiProvider extends abstract_provider_js_1.AbstractProvider {
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",

File diff suppressed because one or more lines are too long

View File

@@ -11,7 +11,7 @@
import { JsonRpcApiProvider } from "./provider-jsonrpc.js";
import type { Subscriber, Subscription } from "./abstract-provider.js";
import type { EventFilter } from "./provider.js";
import type { JsonRpcError, JsonRpcPayload, JsonRpcResult } from "./provider-jsonrpc.js";
import type { JsonRpcApiProviderOptions, JsonRpcError, JsonRpcPayload, JsonRpcResult } from "./provider-jsonrpc.js";
import type { Networkish } from "./network.js";
/**
* A **SocketSubscriber** uses a socket transport to handle events and
@@ -91,7 +91,7 @@ export declare class SocketProvider extends JsonRpcApiProvider {
*
* If unspecified, the network will be discovered.
*/
constructor(network?: Networkish);
constructor(network?: Networkish, _options?: JsonRpcApiProviderOptions);
_getSubscriber(sub: Subscription): Subscriber;
/**
* Register a new subscriber. This is used internalled by Subscribers

View File

@@ -1 +1 @@
{"version":3,"file":"provider-socket.d.ts","sourceRoot":"","sources":["../../src.ts/providers/provider-socket.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACzF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAW/C;;;GAGG;AACH,qBAAa,gBAAiB,YAAW,UAAU;;IAK/C;;OAEG;IACH,IAAI,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAqC;IAO7D;;;OAGG;gBACS,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC;IAQxD,KAAK,IAAI,IAAI;IAOb,IAAI,IAAI,IAAI;IASZ,KAAK,CAAC,eAAe,CAAC,EAAE,OAAO,GAAG,IAAI;IAMtC,MAAM,IAAI,IAAI;IAId;;OAEG;IACH,cAAc,CAAC,OAAO,EAAE,GAAG,G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,SAAQ,gBAAgB;IAEzD;;OAEG;gBACS,QAAQ,EAAE,cAAc;IAI9B,KAAK,CAAC,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;CAGrE;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,gBAAgB;;IAGvD;;OAEG;IACH,IAAI,SAAS,IAAI,WAAW,CAAwC;IAEpE;;OAEG;gBACS,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW;IAKnD,KAAK,CAAC,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;CAGrE;AAED;;;;GAIG;AACH,qBAAa,cAAe,SAAQ,kBAAkB;;IAUlD;;;;OAIG;gBACS,OAAO,CAAC,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,yBAAyB;IAgCtE,cAAc,CAAC,GAAG,EAAE,YAAY,GAAG,UAAU;IAoB7C;;;OAGG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,UAAU,EAAE,gBAAgB,GAAG,IAAI;IAWlE,KAAK,CAAC,OAAO,EAAE,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,aAAa,GAAG,YAAY,CAAC,CAAC;IAmC1G;;;OAGG;IACG,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAuCrD;;;OAGG;IACG,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG/C"}

View File

@@ -164,8 +164,21 @@ class SocketProvider extends provider_jsonrpc_js_1.JsonRpcApiProvider {
*
* If unspecified, the network will be discovered.
*/
constructor(network) {
super(network, { batchMaxCount: 1 });
constructor(network, _options) {
// Copy the options
const options = Object.assign({}, (_options != null) ? _options : {});
// Support for batches is generally not supported for
// connection-base providers; if this changes in the future
// the _send should be updated to reflect this
(0, index_js_1.assertArgument)(options.batchMaxCount == null || options.batchMaxCount === 1, "sockets-based providers do not support batches", "options.batchMaxCount", _options);
options.batchMaxCount = 1;
// Socket-based Providers (generally) cannot change their network,
// since they have a long-lived connection; but let people override
// this if they have just cause.
if (options.staticNetwork == null) {
options.staticNetwork = true;
}
super(network, options);
this.#callbacks = new Map();
this.#subs = new Map();
this.#pending = new Map();

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,5 @@
import { SocketProvider } from "./provider-socket.js";
import type { JsonRpcApiProviderOptions } from "./provider-jsonrpc.js";
import type { Networkish } from "./network.js";
/**
* A generic interface to a Websocket-like object.
@@ -29,7 +30,7 @@ export type WebSocketCreator = () => WebSocketLike;
export declare class WebSocketProvider extends SocketProvider {
#private;
get websocket(): WebSocketLike;
constructor(url: string | WebSocketLike | WebSocketCreator, network?: Networkish);
constructor(url: string | WebSocketLike | WebSocketCreator, network?: Networkish, options?: JsonRpcApiProviderOptions);
_write(message: string): Promise<void>;
destroy(): Promise<void>;
}

View File

@@ -1 +1 @@
{"version":3,"file":"provider-websocket.d.ts","sourceRoot":"","sources":["../../src.ts/providers/provider-websocket.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B,MAAM,EAAE,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC;IAC9C,SAAS,EAAE,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC;IACjD,OAAO,EAAE,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC;IAE/C,UAAU,EAAE,MAAM,CAAC;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,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/C;AAED;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,aAAa,CAAC;AAEnD;;;;;;;;;GASG;AACH,qBAAa,iBAAkB,SAAQ,cAAc;;IAIjD,IAAI,SAAS,IAAI,aAAa,CAG7B;gBAEW,GAAG,EAAE,MAAM,GAAG,aAAa,GAAG,gBAAgB,EAAE,OAAO,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,yBAAyB;IA2C/G,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAItC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAOjC"}

View File

@@ -22,8 +22,8 @@ class WebSocketProvider extends provider_socket_js_1.SocketProvider {
}
return this.#websocket;
}
constructor(url, network) {
super(network);
constructor(url, network, options) {
super(network, options);
if (typeof (url) === "string") {
this.#connect = () => { return new ws_js_1.WebSocket(url); };
this.#websocket = this.#connect();

View File

@@ -1 +1 @@
{"version":3,"file":"provider-websocket.js","sourceRoot":"","sources":["../../src.ts/providers/provider-websocket.ts"],"names":[],"mappings":";;;AAEA,mCAAkD,CAAC,YAAY;AAE/D,6DAAsD;AAwBtD;;;;;;;;;GASG;AACH,MAAa,iBAAkB,SAAQ,mCAAc;IACjD,QAAQ,CAA0B;IAElC,UAAU,CAAuB;IACjC,IAAI,SAAS;QACT,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;SAAE;QACrE,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED,YAAY,GAA8C,EAAE,OAAoB;QAC5E,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,OAAM,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE;YAC1B,IAAI,CAAC,QAAQ,GAAG,GAAG,EAAE,GAAG,OAA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,SAAS,GAAG,CAAC,OAAyB,EAAE,EAAE;YACrD,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACvC,CAAC,CAAC;QACV;;;;;;;;;;;;;;UAcE;IACE,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAe;QACxB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,OAAO;QACT,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,EAAE;YACzB,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;YACxB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;SAC1B;QACD,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ;AA/DD,8CA+DC"}

View File

@@ -494,7 +494,7 @@ export declare class TransactionReceipt implements TransactionReceiptParams, Ite
*/
readonly provider: Provider;
/**
* The address the transaction was send to.
* The address the transaction was sent to.
*/
readonly to: null | string;
/**

View File

@@ -528,7 +528,7 @@ class TransactionReceipt {
*/
provider;
/**
* The address the transaction was send to.
* The address the transaction was sent to.
*/
to;
/**

View File

@@ -100,7 +100,7 @@ export interface Signer extends Addressable, ContractRunner, NameResolver {
*/
sendTransaction(tx: TransactionRequest): Promise<TransactionResponse>;
/**
* Signers an [[link-eip-191]] prefixed personal message.
* Signs an [[link-eip-191]] prefixed personal message.
*
* If the %%message%% is a string, it is signed as UTF-8 encoded bytes. It is **not**
* interpretted as a [[BytesLike]]; so the string ``"0x1234"`` is signed as six

View File

@@ -49,6 +49,12 @@ export declare class OnBlockSubscriber implements Subscriber {
pause(dropWhilePaused?: boolean): void;
resume(): void;
}
export declare class PollingBlockTagSubscriber extends OnBlockSubscriber {
#private;
constructor(provider: AbstractProvider, tag: string);
pause(dropWhilePaused?: boolean): void;
_poll(blockNumber: number, provider: AbstractProvider): Promise<void>;
}
/**
* @_ignore:
*

View File

@@ -1 +1 @@
{"version":3,"file":"subscriber-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ports.PollingTransactionSubscriber = exports.PollingOrphanSubscriber = exports.OnBlockSubscriber = exports.PollingBlockSubscriber = exports.getPollingSubscriber = void 0;
exports.PollingEventSubscriber = exports.PollingTransactionSubscriber = exports.PollingOrphanSubscriber = exports.PollingBlockTagSubscriber = exports.OnBlockSubscriber = exports.PollingBlockSubscriber = exports.getPollingSubscriber = void 0;
const index_js_1 = require("../utils/index.js");
function copy(obj) {
return JSON.parse(JSON.stringify(obj));
@@ -151,6 +151,35 @@ class OnBlockSubscriber {
resume() { this.start(); }
}
exports.OnBlockSubscriber = OnBlockSubscriber;
class PollingBlockTagSubscriber extends OnBlockSubscriber {
#tag;
#lastBlock;
constructor(provider, tag) {
super(provider);
this.#tag = tag;
this.#lastBlock = -2;
}
pause(dropWhilePaused) {
if (dropWhilePaused) {
this.#lastBlock = -2;
}
super.pause(dropWhilePaused);
}
async _poll(blockNumber, provider) {
const block = await provider.getBlock(this.#tag);
if (block == null) {
return;
}
if (this.#lastBlock === -2) {
this.#lastBlock = block.number;
}
else if (block.number > this.#lastBlock) {
provider.emit(this.#tag, block.number);
this.#lastBlock = block.number;
}
}
}
exports.PollingBlockTagSubscriber = PollingBlockTagSubscriber;
/**
* @_ignore:
*

File diff suppressed because one or more lines are too long

View File

@@ -11,14 +11,14 @@ import type { TransactionRequest, TransactionReceipt, TransactionResponse } from
import type { FetchRequest, FetchResponse } from "./fetch.js";
/**
* An error may contain additional properties, but those must not
* conflict with any impliciat properties.
* conflict with any implicit properties.
*/
export type ErrorInfo<T> = Omit<T, "code" | "name" | "message" | "shortMessage"> & {
shortMessage?: string;
};
/**
* All errors emitted by ethers have an **ErrorCode** to help
* identify and coalesce errors to simplfy programatic analysis.
* identify and coalesce errors to simplify programmatic analysis.
*
* Each **ErrorCode** is the %%code%% proerty of a coresponding
* [[EthersError]].
@@ -123,7 +123,7 @@ export interface NotImplementedError extends EthersError<"NOT_IMPLEMENTED"> {
/**
* This Error indicates that the attempted operation is not supported.
*
* This could range from a specifc JSON-RPC end-point not supporting
* This could range from a specific JSON-RPC end-point not supporting
* a feature to a specific configuration of an object prohibiting the
* operation.
*
@@ -137,7 +137,7 @@ export interface UnsupportedOperationError extends EthersError<"UNSUPPORTED_OPER
operation: string;
}
/**
* This Error indicates a proplem connecting to a network.
* This Error indicates a problem connecting to a network.
*/
export interface NetworkError extends EthersError<"NETWORK_ERROR"> {
/**
@@ -183,7 +183,7 @@ export interface TimeoutError extends EthersError<"TIMEOUT"> {
}
/**
* This Error indicates that a provided set of data cannot
* be correctly interpretted.
* be correctly interpreted.
*/
export interface BadDataError extends EthersError<"BAD_DATA"> {
/**
@@ -451,7 +451,7 @@ export type CodedEthersError<T> = T extends "UNKNOWN_ERROR" ? UnknownError : T e
* Returns true if the %%error%% matches an error thrown by ethers
* that matches the error %%code%%.
*
* In TypeScript envornoments, this can be used to check that %%error%%
* In TypeScript environments, this can be used to check that %%error%%
* matches an EthersError type, which means the expected properties will
* be set.
*
@@ -473,13 +473,13 @@ export declare function isError<K extends ErrorCode, T extends CodedEthersError<
export declare function isCallException(error: any): error is CallExceptionError;
/**
* Returns a new Error configured to the format ethers emits errors, with
* the %%message%%, [[api:ErrorCode]] %%code%% and additioanl properties
* the %%message%%, [[api:ErrorCode]] %%code%% and additional properties
* for the corresponding EthersError.
*
* Each error in ethers includes the version of ethers, a
* machine-readable [[ErrorCode]], and depneding on %%code%%, additional
* required properties. The error message will also include the %%meeage%%,
* ethers version, %%code%% and all aditional properties, serialized.
* machine-readable [[ErrorCode]], and depending on %%code%%, additional
* required properties. The error message will also include the %%message%%,
* ethers version, %%code%% and all additional properties, serialized.
*/
export declare function makeError<K extends ErrorCode, T extends CodedEthersError<K>>(message: string, code: K, info?: ErrorInfo<T>): T;
/**

View File

@@ -53,7 +53,7 @@ function stringify(value) {
* Returns true if the %%error%% matches an error thrown by ethers
* that matches the error %%code%%.
*
* In TypeScript envornoments, this can be used to check that %%error%%
* In TypeScript environments, this can be used to check that %%error%%
* matches an EthersError type, which means the expected properties will
* be set.
*
@@ -81,13 +81,13 @@ function isCallException(error) {
exports.isCallException = isCallException;
/**
* Returns a new Error configured to the format ethers emits errors, with
* the %%message%%, [[api:ErrorCode]] %%code%% and additioanl properties
* the %%message%%, [[api:ErrorCode]] %%code%% and additional properties
* for the corresponding EthersError.
*
* Each error in ethers includes the version of ethers, a
* machine-readable [[ErrorCode]], and depneding on %%code%%, additional
* required properties. The error message will also include the %%meeage%%,
* ethers version, %%code%% and all aditional properties, serialized.
* machine-readable [[ErrorCode]], and depending on %%code%%, additional
* required properties. The error message will also include the %%message%%,
* ethers version, %%code%% and all additional properties, serialized.
*/
function makeError(message, code, info) {
let shortMessage = message;

View File

@@ -1,5 +1,5 @@
/**
* An environments implementation of ``getUrl`` must return this type.
* An environment's implementation of ``getUrl`` must return this type.
*/
export type GetUrlResponse = {
statusCode: number;
@@ -65,7 +65,7 @@ export declare class FetchCancelSignal {
export declare class FetchRequest implements Iterable<[key: string, value: string]> {
#private;
/**
* The fetch URI to requrest.
* The fetch URL to request.
*/
get url(): string;
set url(url: string);
@@ -77,15 +77,15 @@ export declare class FetchRequest implements Iterable<[key: string, value: strin
* header.
*
* If %%body%% is null, the body is cleared (along with the
* intrinsic ``Content-Type``) and the .
* intrinsic ``Content-Type``).
*
* If %%body%% is a string, the intrincis ``Content-Type`` is set to
* If %%body%% is a string, the intrinsic ``Content-Type`` is set to
* ``text/plain``.
*
* If %%body%% is a Uint8Array, the intrincis ``Content-Type`` is set to
* If %%body%% is a Uint8Array, the intrinsic ``Content-Type`` is set to
* ``application/octet-stream``.
*
* If %%body%% is any other object, the intrincis ``Content-Type`` is
* If %%body%% is any other object, the intrinsic ``Content-Type`` is
* set to ``application/json``.
*/
get body(): null | Uint8Array;
@@ -107,7 +107,7 @@ export declare class FetchRequest implements Iterable<[key: string, value: strin
* The headers that will be used when requesting the URI. All
* keys are lower-case.
*
* This object is a copy, so any chnages will **NOT** be reflected
* This object is a copy, so any changes will **NOT** be reflected
* in the ``FetchRequest``.
*
* To set a header entry, use the ``setHeader`` method.
@@ -150,7 +150,7 @@ export declare class FetchRequest implements Iterable<[key: string, value: strin
get allowInsecureAuthentication(): boolean;
set allowInsecureAuthentication(value: boolean);
/**
* The timeout (in milliseconds) to wait for a complere response.
* The timeout (in milliseconds) to wait for a complete response.
* //(default: 5 minutes)//
*/
get timeout(): number;
@@ -288,7 +288,7 @@ export declare class FetchRequest implements Iterable<[key: string, value: strin
static createIpfsGatewayFunc(baseUrl: string): FetchGatewayFunc;
}
/**
* The response for a FetchREquest.
* The response for a FetchRequest.
*/
export declare class FetchResponse implements Iterable<[key: string, value: string]> {
#private;
@@ -342,7 +342,7 @@ export declare class FetchResponse implements Iterable<[key: string, value: stri
*/
getHeader(key: string): string;
/**
* Returns true of the response has a body.
* Returns true if the response has a body.
*/
hasBody(): this is (FetchResponse & {
body: Uint8Array;

View File

@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.FetchResponse = exports.FetchRequest = exports.FetchCancelSignal = void 0;
/**
* Fetching content from the web is environment-specific, so Ethers
* provides an abstraction the each environment can implement to provide
* provides an abstraction that each environment can implement to provide
* this service.
*
* On [Node.js](link-node), the ``http`` and ``https`` libs are used to
@@ -11,10 +11,10 @@ exports.FetchResponse = exports.FetchRequest = exports.FetchCancelSignal = void
* and populate the [[FetchResponse]].
*
* In a browser, the [DOM fetch](link-js-fetch) is used, and the resulting
* ``Promise`` is waited on to retreive the payload.
* ``Promise`` is waited on to retrieve the payload.
*
* The [[FetchRequest]] is responsible for handling many common situations,
* such as redirects, server throttling, authentcation, etc.
* such as redirects, server throttling, authentication, etc.
*
* It also handles common gateways, such as IPFS and data URIs.
*
@@ -145,7 +145,7 @@ class FetchRequest {
#throttle;
#getUrlFunc;
/**
* The fetch URI to requrest.
* The fetch URL to request.
*/
get url() { return this.#url; }
set url(url) {
@@ -159,15 +159,15 @@ class FetchRequest {
* header.
*
* If %%body%% is null, the body is cleared (along with the
* intrinsic ``Content-Type``) and the .
* intrinsic ``Content-Type``).
*
* If %%body%% is a string, the intrincis ``Content-Type`` is set to
* If %%body%% is a string, the intrinsic ``Content-Type`` is set to
* ``text/plain``.
*
* If %%body%% is a Uint8Array, the intrincis ``Content-Type`` is set to
* If %%body%% is a Uint8Array, the intrinsic ``Content-Type`` is set to
* ``application/octet-stream``.
*
* If %%body%% is any other object, the intrincis ``Content-Type`` is
* If %%body%% is any other object, the intrinsic ``Content-Type`` is
* set to ``application/json``.
*/
get body() {
@@ -227,7 +227,7 @@ class FetchRequest {
* The headers that will be used when requesting the URI. All
* keys are lower-case.
*
* This object is a copy, so any chnages will **NOT** be reflected
* This object is a copy, so any changes will **NOT** be reflected
* in the ``FetchRequest``.
*
* To set a header entry, use the ``setHeader`` method.
@@ -320,7 +320,7 @@ class FetchRequest {
this.#allowInsecure = !!value;
}
/**
* The timeout (in milliseconds) to wait for a complere response.
* The timeout (in milliseconds) to wait for a complete response.
* //(default: 5 minutes)//
*/
get timeout() { return this.#timeout; }
@@ -528,7 +528,7 @@ class FetchRequest {
* to %%location%%.
*/
redirect(location) {
// Redirection; for now we only support absolute locataions
// Redirection; for now we only support absolute locations
const current = this.url.split(":")[0].toLowerCase();
const target = location.split(":")[0].toLowerCase();
// Don't allow redirecting:
@@ -668,7 +668,7 @@ class FetchRequest {
exports.FetchRequest = FetchRequest;
;
/**
* The response for a FetchREquest.
* The response for a FetchRequest.
*/
class FetchResponse {
#statusCode;
@@ -798,7 +798,7 @@ class FetchResponse {
return this.headers[key.toLowerCase()];
}
/**
* Returns true of the response has a body.
* Returns true if the response has a body.
*/
hasBody() {
return (this.#body != null);

File diff suppressed because one or more lines are too long

View File

@@ -175,7 +175,7 @@ function toBeHex(_value, _width) {
}
else {
const width = getNumber(_width, "width");
(0, errors_js_1.assert)(width * 2 >= result.length, `value exceeds width (${width} bits)`, "NUMERIC_FAULT", {
(0, errors_js_1.assert)(width * 2 >= result.length, `value exceeds width (${width} bytes)`, "NUMERIC_FAULT", {
operation: "toBeHex",
fault: "overflow",
value: _value

File diff suppressed because one or more lines are too long

View File

@@ -57,7 +57,7 @@ export declare class Wallet extends BaseWallet {
*/
static fromEncryptedJsonSync(json: string, password: Uint8Array | string): HDNodeWallet | Wallet;
/**
* Creates a new random [[HDNodeWallet]] using the avavilable
* Creates a new random [[HDNodeWallet]] using the available
* [cryptographic random source](randomBytes).
*
* If there is no crytographic random source, this will throw.

View File

@@ -121,7 +121,7 @@ class Wallet extends base_wallet_js_1.BaseWallet {
return Wallet.#fromAccount(account);
}
/**
* Creates a new random [[HDNodeWallet]] using the avavilable
* Creates a new random [[HDNodeWallet]] using the available
* [cryptographic random source](randomBytes).
*
* If there is no crytographic random source, this will throw.

View File

@@ -1,13 +1,25 @@
import fs from "fs";
import { getVersions } from "./utils/npm.js";
import { resolve } from "./utils/path.js";
import { getDiff } from "./utils/git.js";
function escver(v) {
return v.replace(/\./, "-");
}
(async function () {
let versions = await getVersions("ethers");
versions = versions.filter((h) => (h.version.match(/^6\.[0-9]+\.[0-9]+$/)));
for (let i = 1; i < versions.length; i++) {
const tag0 = versions[i - 1].gitHead, tag1 = versions[i].gitHead;
const diff = await getDiff(resolve("dist/ethers.js"), tag0, tag1);
console.log(diff);
fs.writeFileSync(resolve("misc/diffs/versions.txt"), versions.map((h) => h.version).join(","));
for (let i = 0; i < versions.length; i++) {
for (let j = i + 1; j < versions.length; j++) {
const filename = resolve(`misc/diffs/diff-${escver(versions[i].version)}_${escver(versions[j].version)}.txt`);
if (fs.existsSync(filename)) {
continue;
}
const tag0 = versions[i].gitHead, tag1 = versions[j].gitHead;
const diff = await getDiff(resolve("src.ts"), tag0, tag1);
console.log({ diff });
fs.writeFileSync(filename, diff);
}
}
})();
//# sourceMappingURL=generate-diffs.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"generate-diffs.js","sourceRoot":"","sources":["../../src.ts/_admin/generate-diffs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;A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tag1: string;
}, limit?: null | number): Promise<Array<GitLog>>;
export declare function getDiff(filename: string, tag0: string, tag1: string): Promise<string>;
export declare function getTags(): Promise<Array<string>>;
//# sourceMappingURL=git.d.ts.map

View File

@@ -1 +1 @@
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../../src.ts/_admin/utils/git.ts"],"names":[],"mappings":"AASA,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,CAUxE;AAED,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,CAiB9E;AACD,MAAM,WAAW,MAAM;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,OAAO,CAAC,KAAK,CAAC,EAAE,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,IAAI,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,KAAK,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAsCxJ;AAED,wBAAsB,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAI3F"}
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../../src.ts/_admin/utils/git.ts"],"names":[],"mappings":"AASA,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,CAUxE;AAED,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,CAiB9E;AAED,MAAM,WAAW,MAAM;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,OAAO,CAAC,KAAK,CAAC,EAAE,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,IAAI,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,KAAK,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAsCxJ;AAED,wBAAsB,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAI3F;AAED,wBAAsB,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAItD"}

View File

@@ -87,4 +87,11 @@ export async function getDiff(filename, tag0, tag1) {
}
return result.stdout.trim();
}
export async function getTags() {
const result = await run("git", ["tag"]);
if (!result.ok) {
throw new Error(`git log error`);
}
return result.stdout.trim().split("\n");
}
//# sourceMappingURL=git.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../../src.ts/_admin/utils/git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AAEnC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACjD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;AAErC,+DAA+D;AAC/D,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,QA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AAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;aAC7F;SACJ;KACL;IAED,0BAA0B;IAC1B,OAAO,CAAC,KAAK,EAAE,CAAC;IAEhB,OAAO,OAAO,CAAC;AACnB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,QAAgB,EAAE,IAAY,EAAE,IAAY;IACtE,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,KAAK,EAAE,CAAE,MAAM,EAAE,GAAI,IAAK,KAAM,IAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAE,CAAC,CAAC;IACpF,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;KAAE;IACrD,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;AAChC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,OAAO;IACzB,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,KAAK,EAAE,CAAE,KAAK,CAAE,CAAC,CAAC;IAC3C,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;KAAE;IACrD,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC5C,CAAC"}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=test-provider-jsonrpc.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"test-provider-jsonrpc.d.ts","sourceRoot":"","sources":["../../src.ts/_tests/test-provider-jsonrpc.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,157 @@
import assert from "assert";
import { id, isError, makeError, toUtf8Bytes, toUtf8String, FetchRequest, JsonRpcProvider, Transaction, Wallet } from "../index.js";
const StatusMessages = {
200: "OK",
400: "BAD REQUEST",
500: "SERVER ERROR",
};
const wallet = new Wallet(id("test"));
function createProvider(testFunc) {
let blockNumber = 1;
const ticker = setInterval(() => { blockNumber++; }, 100);
if (ticker.unref) {
ticker.unref();
}
const processReq = (req) => {
let result = testFunc(req.method, req.params, blockNumber);
if (result === undefined) {
switch (req.method) {
case "eth_blockNumber":
result = blockNumber;
break;
case "eth_chainId":
result = "0x1337";
break;
case "eth_accounts":
result = [wallet.address];
break;
default:
console.log("****", req);
return { id, error: "unsupported", jsonrpc: "2.0" };
}
}
return { id: req.id, result, jsonrpc: "2.0" };
};
const req = new FetchRequest("http:/\/localhost:8082/");
req.getUrlFunc = async (_req, signal) => {
const req = JSON.parse(_req.hasBody() ? toUtf8String(_req.body) : "");
let statusCode = 200;
const headers = {};
let resp;
try {
if (Array.isArray(req)) {
resp = req.map((r) => processReq(r));
}
else {
resp = processReq(req);
}
}
catch (error) {
statusCode = 500;
resp = error.message;
}
const body = toUtf8Bytes(JSON.stringify(resp));
return {
statusCode,
statusMessage: StatusMessages[statusCode],
headers, body
};
};
return new JsonRpcProvider(req, undefined, { cacheTimeout: -1 });
}
describe("Ensure Catchable Errors", function () {
it("Can catch bad broadcast replies", async function () {
this.timeout(15000);
const txInfo = {
chainId: 1337,
gasLimit: 100000,
maxFeePerGas: 2000000000,
maxPriorityFeePerGas: 1000000000,
to: wallet.address,
value: 1,
};
const txSign = await wallet.signTransaction(txInfo);
const txObj = Transaction.from(txSign);
let count = 0;
const provider = createProvider((method, params, blockNumber) => {
switch (method) {
case "eth_sendTransaction":
return txObj.hash;
case "eth_getTransactionByHash": {
count++;
// First time; fail!
if (count === 1) {
throw makeError("Faux Error", "SERVER_ERROR", {
request: ({})
});
}
// Second time; return null
if (count === 2) {
return null;
}
// Return a valid tx...
const result = Object.assign({}, txObj.toJSON(), txObj.signature.toJSON(), { hash: txObj.hash, from: wallet.address });
// ...eventually mined
if (count > 4) {
result.blockNumber = blockNumber;
result.blockHash = id("test");
}
return result;
}
}
return undefined;
});
const signer = await provider.getSigner();
const tx = await signer.sendTransaction(txInfo);
assert(tx);
});
it("Missing v is recovered", async function () {
this.timeout(15000);
const txInfo = {
chainId: 1337,
gasLimit: 100000,
maxFeePerGas: 2000000000,
maxPriorityFeePerGas: 1000000000,
to: wallet.address,
value: 1,
};
const txSign = await wallet.signTransaction(txInfo);
const txObj = Transaction.from(txSign);
let count = 0;
// A provider which is mocked to return a "missing v"
// in getTransaction
const provider = createProvider((method, params, blockNumber) => {
switch (method) {
case "eth_sendTransaction":
return txObj.hash;
case "eth_getTransactionByHash": {
count++;
// The fully valid tx response
const result = Object.assign({}, txObj.toJSON(), txObj.signature.toJSON(), { hash: txObj.hash, from: wallet.address, sig: null });
// First time; fail with a missing v!
if (count < 2) {
delete result.v;
}
// Debug
result._count = count;
return result;
}
}
return undefined;
});
// Track any "missing v" error
let missingV = null;
provider.on("error", (e) => {
if (isError(e, "UNKNOWN_ERROR") && isError(e.error, "INVALID_ARGUMENT")) {
if (e.error.argument === "signature" && e.error.shortMessage === "missing v") {
missingV = e.error;
}
}
});
const signer = await provider.getSigner();
const tx = await signer.sendTransaction(txInfo);
assert.ok(!!tx, "we got a transaction");
assert.ok(!!missingV, "missing v error present");
});
});
//# sourceMappingURL=test-provider-jsonrpc.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
import { AbstractProvider, Network } from "../index.js";
import type { PerformActionRequest } from "../index.js";
export type Performer = (req: PerformActionRequest) => Promise<any>;
export declare class MockProvider extends AbstractProvider {
readonly _perform: Performer;
constructor(perform: Performer);
_detectNetwork(): Promise<Network>;
perform(req: PerformActionRequest): Promise<any>;
}
//# sourceMappingURL=test-providers-fallback.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"test-providers-fallback.d.ts","sourceRoot":"","sources":["../../src.ts/_tests/test-providers-fallback.ts"],"names":[],"mappings":"AAEA,OAAO,EAGH,gBAAgB,EAAoB,OAAO,EAE9C,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EACR,oBAAoB,EACvB,MAAM,aAAa,CAAC;AAWrB,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,oBAAoB,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAEpE,qBAAa,YAAa,SAAQ,gBAAgB;IAC9C,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;gBAEjB,OAAO,EAAE,SAAS;IAKxB,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IAElC,OAAO,CAAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC;CAGzD"}

View File

@@ -0,0 +1,133 @@
import assert from "assert";
import { isError, makeError, AbstractProvider, FallbackProvider, Network, ZeroAddress } from "../index.js";
const network = Network.from("mainnet");
function stall(duration) {
return new Promise((resolve) => { setTimeout(resolve, duration); });
}
export class MockProvider extends AbstractProvider {
_perform;
constructor(perform) {
super(network, { cacheTimeout: -1 });
this._perform = perform;
}
async _detectNetwork() { return network; }
async perform(req) {
return await this._perform(req);
}
}
describe("Test Fallback broadcast", function () {
const txHash = "0x33017397ef7c7943dee3b422aec52b0a210de58d73d49c1b3ce455970f01c83a";
async function test(actions) {
// https://sepolia.etherscan.io/tx/0x33017397ef7c7943dee3b422aec52b0a210de58d73d49c1b3ce455970f01c83a
const tx = "0x02f87683aa36a7048459682f00845d899ef982520894b5bdaa442bb34f27e793861c456cd5bdc527ac8c89056bc75e2d6310000080c001a07503893743e94445b2361a444343757e6f59d52e19e9b3f65eb138d802eaa972a06e4e9bc10ff55474f9aac0a4c284733b4195cb7b273de5e7465ce75a168e0c38";
const providers = actions.map(({ timeout, error }) => {
return new MockProvider(async (r) => {
if (r.method === "getBlockNumber") {
return 1;
}
if (r.method === "broadcastTransaction") {
await stall(timeout);
if (error) {
throw error;
}
return txHash;
}
throw new Error(`unhandled method: ${r.method}`);
});
});
;
const provider = new FallbackProvider(providers);
return await provider.broadcastTransaction(tx);
}
it("picks late non-failed broadcasts", async function () {
const result = await test([
{ timeout: 200, error: makeError("already seen", "UNKNOWN_ERROR") },
{ timeout: 4000, error: makeError("already seen", "UNKNOWN_ERROR") },
{ timeout: 400 },
]);
assert(result.hash === txHash, "result.hash === txHash");
});
it("picks late non-failed broadcasts with quorum-met red-herrings", async function () {
const result = await test([
{ timeout: 200, error: makeError("bad nonce", "NONCE_EXPIRED") },
{ timeout: 400, error: makeError("bad nonce", "NONCE_EXPIRED") },
{ timeout: 1000 },
]);
assert(result.hash === txHash, "result.hash === txHash");
});
it("insufficient funds short-circuit broadcast", async function () {
await assert.rejects(async function () {
const result = await test([
{ timeout: 200, error: makeError("is broke", "INSUFFICIENT_FUNDS") },
{ timeout: 400, error: makeError("is broke", "INSUFFICIENT_FUNDS") },
{ timeout: 800 },
{ timeout: 1000 },
]);
console.log(result);
}, function (error) {
assert(isError(error, "INSUFFICIENT_FUNDS"));
return true;
});
});
});
describe("Test Inflight Quorum", function () {
// Fires the %%actions%% as providers which will delay before returning,
// and returns an array of arrays, where each sub-array indicates which
// providers were inflight at once.
async function test(actions, quorum) {
const inflights = [[]];
const configs = actions.map(({ delay, stallTimeout, priority, weight }, index) => ({
provider: new MockProvider(async (r) => {
if (r.method === "getBlockNumber") {
return 1;
}
if (r.method === "getBalance") {
// Add this as inflight
let last = inflights.pop();
if (last == null) {
throw new Error("no elements");
}
inflights.push(last);
last = last.slice();
last.push(index);
inflights.push(last);
// Do the thing
await stall(delay);
// Remove as inflight
last = inflights.pop();
if (last == null) {
throw new Error("no elements");
}
inflights.push(last);
last = last.filter((v) => (v !== index));
inflights.push(last);
return 0;
}
console.log(r);
throw new Error(`unhandled method: ${r.method}`);
}),
stallTimeout, priority, weight
}));
const provider = new FallbackProvider(configs, network, {
cacheTimeout: -1, pollingInterval: 100,
quorum
});
await provider.getBalance(ZeroAddress);
return inflights;
}
// See: #4298
it("applies weights against inflight requests", async function () {
this.timeout(2000);
const inflights = await test([
{ delay: 50, stallTimeout: 1000, priority: 1, weight: 2 },
{ delay: 50, stallTimeout: 1000, priority: 1, weight: 2 },
], 2);
// Make sure there is never more than 1 inflight provider at once
for (const running of inflights) {
assert.ok(running.length <= 1, `too many inflight requests: ${JSON.stringify(inflights)}`);
}
});
// @TODO: add lots more tests, checking on priority, weight and stall
// configurations
});
//# sourceMappingURL=test-providers-fallback.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"test-providers-fallback.js","sourceRoot":"","sources":["../../src.ts/_tests/test-providers-fallback.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EACH,OAAO,EAAE,SAAS,EAElB,gBAAgB,EAAE,gBAAgB,EAAE,OAAO,EAC3C,WAAW,EACd,MAAM,aAAa,CAAC;AAQrB,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAExC,SAAS,KAAK,CAAC,QAAgB;IAC3B,OAAQ,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,GAAG,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACzE,CAAC;AAKD,MAAM,OAAO,YAAa,SAAQ,gBAAgB;IACrC,QAAQ,CAAY;IAE7B,YAAY,OAAkB;QAC1B,KAAK,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QACrC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,cAAc,KAAuB,OAAO,OAAO,CAAC,CAAC,CAAC;IAE5D,KAAK,CAAC,OAAO,CAAC,GAAyB;QACnC,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;CACJ;AAED,QAAQ,CAAC,yBAAyB,EAAE;IAEhC,MAAM,MAAM,GAAG,oEAAoE,CAAC;IAEpF,KAAK,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,CAAC,MAAO,EAAE,CAAC,CAAC;YACvD,CAAC,CAAC;YACF,YAAY,EAAE,QAAQ,EAAE,MAAM;SACjC,CAAC,CAAC,CAAC;QAEJ,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE;YACpD,YAAY,EAAE,CAAC,CAAC,EAAE,eAAe,EAAE,GAAG;YACtC,MAAM;SACT,CAAC,CAAC;QACH,MAAM,QAAQ,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QAEvC,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,aAAa;IACb,EAAE,CAAC,2CAA2C,EAAE,KAAK;QACjD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAEnB,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC;YACzB,EAAE,KAAK,EAAE,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;YACzD,EAAE,KAAK,EAAE,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;SAC5D,EAAE,CAAC,CAAC,CAAC;QAEN,iEAAiE;QACjE,KAAK,MAAM,OAAO,IAAI,SAAS,EAAE;YAC7B,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,EAAE,+BAAgC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAE,EAAE,CAAC,CAAC;SAChG;IACL,CAAC,CAAC,CAAC;IAEH,qEAAqE;IACrE,wBAAwB;AAC5B,CAAC,CAAC,CAAC"}

View File

@@ -2,5 +2,5 @@
/**
* The current version of Ethers.
*/
export const version = "6.8.0";
export const version = "6.9.1";
//# sourceMappingURL=_version.js.map

File diff suppressed because one or more lines are too long

View File

@@ -455,9 +455,6 @@ export class ParamType {
}
else {
if (this.isTuple()) {
if (format !== "sighash") {
result += this.type;
}
result += "(" + this.components.map((comp) => comp.format(format)).join((format === "full") ? ", " : ",") + ")";
}
else {
@@ -999,7 +996,9 @@ export class ConstructorFragment extends Fragment {
});
}
const result = [`constructor${joinParams(format, this.inputs)}`];
result.push((this.payable) ? "payable" : "nonpayable");
if (this.payable) {
result.push("payable");
}
if (this.gas != null) {
result.push(`@${this.gas.toString()}`);
}

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