admin: updated dist files

This commit is contained in:
Richard Moore 2023-11-27 06:11:49 -05:00
parent f8f11c754a
commit d60dfc14a3
100 changed files with 1247 additions and 322 deletions

@ -3,6 +3,17 @@ Change Log
This change log is maintained by `src.ts/_admin/update-changelog.ts` but may also be manually updated.
ethers/v6.9.0 (2023-11-27 06:07)
--------------------------------
- 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)
--------------------------------

237
dist/ethers.js vendored

@ -3,7 +3,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
/**
* The current version of Ethers.
*/
const version = "6.8.1";
const version = "6.9.0";
/**
* Property helper functions.
@ -11335,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 {
@ -17176,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() {
@ -17235,6 +17215,9 @@ function injectCommonNetworks() {
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 +17236,7 @@ function injectCommonNetworks() {
});
registerEth("optimism", 10, {
ensNetwork: 1,
plugins: [
getPriorityFeePlugin(BigInt("1000000"))
]
plugins: []
});
registerEth("optimism-goerli", 420, {});
registerEth("xdai", 100, { ensNetwork: 1 });
@ -17391,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:
*
@ -17589,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 };
}
}
@ -17890,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)) {
@ -18076,12 +18087,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;
@ -18092,7 +18111,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);
@ -18470,6 +18489,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":
@ -19500,6 +19522,7 @@ class JsonRpcApiProvider extends AbstractProvider {
#drainTimer;
#notReady;
#network;
#pendingDetectNetwork;
#scheduleDrain() {
if (this.#drainTimer) {
return;
@ -19575,6 +19598,7 @@ class JsonRpcApiProvider extends AbstractProvider {
this.#payloads = [];
this.#drainTimer = null;
this.#network = null;
this.#pendingDetectNetwork = null;
{
let resolve = null;
const promise = new Promise((_resolve) => {
@ -19582,9 +19606,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;
}
@ -19645,13 +19675,29 @@ class JsonRpcApiProvider extends AbstractProvider {
async _detectNetwork() {
const network = this._getOption("staticNetwork");
if (network) {
if (network === true) {
if (this.#network) {
return this.#network;
}
}
else {
return network;
}
}
if (this.#pendingDetectNetwork) {
return await this.#pendingDetectNetwork;
}
// If we are ready, use ``send``, which enabled requests to be batched
if (this.ready) {
return Network.from(getBigInt(await this.send("eth_chainId", [])));
this.#pendingDetectNetwork = (async () => {
const result = Network.from(getBigInt(await this.send("eth_chainId", [])));
this.#pendingDetectNetwork = null;
return result;
})();
return await this.#pendingDetectNetwork;
}
// We are not ready yet; use the primitive _send
this.#pendingDetectNetwork = (async () => {
const payload = {
id: this.#nextId++, method: "eth_chainId", params: [], jsonrpc: "2.0"
};
@ -19659,8 +19705,10 @@ class JsonRpcApiProvider extends AbstractProvider {
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;
}
@ -19669,6 +19717,8 @@ class JsonRpcApiProvider extends AbstractProvider {
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 +19834,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",
@ -20277,6 +20329,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":
@ -20725,6 +20781,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", {
@ -21015,8 +21109,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();
@ -21160,8 +21267,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();
@ -21778,6 +21885,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":
@ -21923,6 +22032,7 @@ class FallbackProvider extends AbstractProvider {
return this.#height;
}
case "getGasPrice":
case "getPriorityFee":
case "estimateGas":
return getMedian(this.quorum, results);
case "getBlock":
@ -22004,15 +22114,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",
@ -22026,8 +22167,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

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

237
dist/ethers.umd.js vendored

@ -9,7 +9,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
/**
* The current version of Ethers.
*/
const version = "6.8.1";
const version = "6.9.0";
/**
* Property helper functions.
@ -11341,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 {
@ -17182,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() {
@ -17241,6 +17221,9 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
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 });
@ -17259,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 });
@ -17397,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:
*
@ -17595,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 };
}
}
@ -17896,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)) {
@ -18082,12 +18093,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;
@ -18098,7 +18117,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);
@ -18476,6 +18495,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":
@ -19506,6 +19528,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
#drainTimer;
#notReady;
#network;
#pendingDetectNetwork;
#scheduleDrain() {
if (this.#drainTimer) {
return;
@ -19581,6 +19604,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) => {
@ -19588,9 +19612,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;
}
@ -19651,13 +19681,29 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
async _detectNetwork() {
const network = this._getOption("staticNetwork");
if (network) {
if (network === true) {
if (this.#network) {
return this.#network;
}
}
else {
return network;
}
}
if (this.#pendingDetectNetwork) {
return await this.#pendingDetectNetwork;
}
// If we are ready, use ``send``, which enabled requests to be batched
if (this.ready) {
return Network.from(getBigInt(await this.send("eth_chainId", [])));
this.#pendingDetectNetwork = (async () => {
const result = Network.from(getBigInt(await this.send("eth_chainId", [])));
this.#pendingDetectNetwork = null;
return result;
})();
return await this.#pendingDetectNetwork;
}
// We are not ready yet; use the primitive _send
this.#pendingDetectNetwork = (async () => {
const payload = {
id: this.#nextId++, method: "eth_chainId", params: [], jsonrpc: "2.0"
};
@ -19665,8 +19711,10 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
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;
}
@ -19675,6 +19723,8 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
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
@ -19790,6 +19840,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",
@ -20283,6 +20335,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":
@ -20731,6 +20787,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", {
@ -21021,8 +21115,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();
@ -21166,8 +21273,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();
@ -21784,6 +21891,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":
@ -21929,6 +22038,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":
@ -22010,15 +22120,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",
@ -22032,8 +22173,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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -100,7 +100,7 @@ const rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
/**
* The current version of Ethers.
*/
const version = "6.8.1";
const version = "6.9.0";
/**
* Property helper functions.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -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

@ -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"}

@ -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

@ -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,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;AAbD,oCAaC;AAED,QAAQ,CAAC,yBAAyB,EAAE;IAEhC,MAAM,MAAM,GAAG,oEAAoE,CAAC;IAEpF,KAAK,UAAU,IAAI,CAAC,OAAkD;QAClE,qGAAqG;QACrG,MAAM,EAAE,GAAG,sPAAsP,CAAC;QAElQ,MAAM,SAAS,GAAwB,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE;YACtE,OAAO,IAAI,YAAY,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;gBAChC,IAAI,CAAC,CAAC,MAAM,KAAK,gBAAgB,E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EAAE,eAAe,EAAE,GAAG;YACtC,MAAM;SACT,CAAC,CAAC;QACH,MAAM,QAAQ,CAAC,UAAU,CAAC,sBAAW,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,gBAAM,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"}

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

File diff suppressed because one or more lines are too long

@ -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 {

File diff suppressed because one or more lines are too long

@ -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

@ -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)) {
@ -581,12 +583,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 +607,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 +985,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

@ -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() {
@ -350,6 +333,9 @@ function injectCommonNetworks() {
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

@ -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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AE,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"}

@ -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":

@ -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,CAAC;QACvC,KAAK,iBAAiB;YAClB,OAAO,0BAA0B,CAAC;QACtC,KAAK,OAAO;YACR,OAAO,+BAA+B,CAAC;QAC3C,KAAK,cAAc;YACf,OAAO,8BAA8B,CAAC;QAC1C,KAAK,UAAU;YACX,OAAO,2BAA2B,CAAC;QACvC,KAAK,iBAAiB;YAClB,OAAO,0BAA0B,CAAC;KACzC;IAED,IAAA,yBAAc,EAAC,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,IAAI,CAAC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AAQ,EAAE,OAAO,EAAE,EAAE;gBACrD,IAAA,kCAAmB,EAAC,SAAS,CAAC,CAAC;gBAC/B,OAAO,IAAI,CAAC;YAChB,CAAC,CAAA;SACJ;QAED,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AA3ED,0CA2EC"}
{"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,CAAC;QACvC,KAAK,iBAAiB;YAClB,OAAO,0BAA0B,CAAC;QACtC,KAAK,MAAM;YACP,OAAO,4BAA4B,CAAC;QACxC,KAAK,aAAa;YACd,OAAO,2BAA2B,CAAC;QACvC,KAAK,OAAO;YACR,OAAO,+BAA+B,CAAC;QAC3C,KAAK,cAAc;YACf,OAAO,8BAA8B,CAAC;QAC1C,KAAK,UAAU;YACX,OAAO,2BAA2B,CAAC;QACvC,KAAK,iBAAiB;YAClB,OAAO,0BAA0B,CAAC;KACzC;IAED,IAAA,yBAAc,EAAC,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;AAClE,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAa,eAAgB,SAAQ,qCAAe;IACvC,MAAM,CAAU;IAEzB,YAAY,QAAqB,EAAE,MAAsB;QACrD,IAAI,QAAQ,IAAI,IAAI,EAAE;YAAE,QAAQ,GAAG,SAAS,CAAC;SAAE;QAC/C,MAAM,OAAO,GAAG,oBAAO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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

@ -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,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AA6B9C;;GAEG;AACH,MAAM,WAAW,sBAAsB;IAEnC;;OAEG;IACH,QAAQ,EAAE,gBAAgB,CAAC;IAE3B;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAMD;;GAEG;AACH,MAAM,WAAW,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KrB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAwKF;;;;;;GAMG;AACH,qBAAa,gBAAiB,SAAQ,gBAAgB;;IAElD;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAO9B;;;;;;OAMG;gBACS,SAAS,EAAE,KAAK,CAAC,gBAAgB,GAAG,sBAAsB,CAAC,EAAE,OAAO,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,uBAAuB;IA8BhI,IAAI,eAAe,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAQlD;IAEK,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IASxC;;OAEG;IACG,iBAAiB,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC;IA6QtF,QAAQ,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,CAAC,CAAC;IA8ExD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAMjC"}

@ -301,6 +301,8 @@ class FallbackProvider extends abstract_provider_js_1.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":
@ -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

@ -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>;
}

@ -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"}

@ -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 {

@ -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,CAAC,IAAI,EAAE,CAAC,CAAC;QAC9D,SAAS,GAAG,EAAE,GAAG,CAAC,CAAC;KACtB;IAED,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;AAC7D,CAAC;AAED;;;;GAIG;AACH,MAAa,iBAAkB,SAAQ,mCAAc;IACjD,OAAO,CAAS;IAEhB;;OAEG;IACH,IAAI,MAAM,KAAa,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAE7C,YAAY,IAAY,EAAE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;AAhDD,8CAgDC"}

@ -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

@ -215,6 +215,7 @@ class JsonRpcApiProvider extends abstract_provider_js_1.AbstractProvider {
#drainTimer;
#notReady;
#network;
#pendingDetectNetwork;
#scheduleDrain() {
if (this.#drainTimer) {
return;
@ -290,6 +291,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 +299,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,13 +368,29 @@ class JsonRpcApiProvider extends abstract_provider_js_1.AbstractProvider {
async _detectNetwork() {
const network = this._getOption("staticNetwork");
if (network) {
if (network === true) {
if (this.#network) {
return this.#network;
}
}
else {
return network;
}
}
if (this.#pendingDetectNetwork) {
return await this.#pendingDetectNetwork;
}
// If we are ready, use ``send``, which enabled requests to be batched
if (this.ready) {
return network_js_1.Network.from((0, index_js_5.getBigInt)(await this.send("eth_chainId", [])));
this.#pendingDetectNetwork = (async () => {
const result = network_js_1.Network.from((0, index_js_5.getBigInt)(await this.send("eth_chainId", [])));
this.#pendingDetectNetwork = null;
return result;
})();
return await this.#pendingDetectNetwork;
}
// We are not ready yet; use the primitive _send
this.#pendingDetectNetwork = (async () => {
const payload = {
id: this.#nextId++, method: "eth_chainId", params: [], jsonrpc: "2.0"
};
@ -374,8 +398,10 @@ class JsonRpcApiProvider extends abstract_provider_js_1.AbstractProvider {
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;
}
@ -384,6 +410,8 @@ class JsonRpcApiProvider extends abstract_provider_js_1.AbstractProvider {
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 +527,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

@ -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

@ -1 +1 @@
{"version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AAe,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"}

@ -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

@ -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>;
}

@ -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;IAEnB,IAAI,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI,CAAC;IACzB,KAAK,CAAC,IAAI,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;IA2C1E,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA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"}

@ -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();

@ -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,OAAO,IAAI,iBAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YACtD,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;SACrC;aAAM,IAAI,OAAM,CAAC,GAAG,CAAC,KAAK,UAAU,EAAE;YACnC,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC;YACpB,IAAI,CAAC,UAAU,GAAG,GAAG,EAAE,CAAC;SAC3B;aAAM;YACH,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YACrB,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;SACzB;QAED,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,KAAK,IAAI,EAAE;YAC/B,IAAI;gBACA,MAAM,IAAI,CAAC,MAAM,EAAE,CAAA;gBACnB,IAAI,CAAC,MAAM,EAAE,CAAC;aACjB;YAAC,OAAO,KAAK,EAAE;gBACZ,OAAO,CAAC,GAAG,CAAC,mCAAmC,EAAE,KAAK,CAAC,CAAC;gBACxD,sCAAsC;aACzC;QACL,CAAC,CAAC;QAEF,IAAI,CAAC,SAAS,CAAC,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"}
{"version":3,"file":"provider-websocket.js","sourceRoot":"","sources":["../../src.ts/providers/provider-websocket.ts"],"names":[],"mappings":";;;AAEA,mCAAkD,CAAC,YAAY;AAE/D,6DAAsD;AAyBtD;;;;;;;;;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,EAAE,OAAmC;QACjH,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,OAAM,CAAC,GAAG,CAAC,K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C;CACJ;AA/DD,8CA+DC"}

@ -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:
*

@ -1 +1 @@
{"version":3,"file":"subscriber-polling.d.ts","sourceRoot":"","sources":["../../src.ts/providers/subscriber-polling.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAM9E;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,gBAAgB,EAAE,KAAK,EAAE,aAAa,GAAG,UAAU,CAOjG;AAID;;;;;GAKG;AACH,qBAAa,sBAAuB,YAAW,UAAU;;IAUrD;;OAEG;gBACS,QAAQ,EAAE,gBAAgB;IAQtC;;OAEG;IACH,IAAI,eAAe,IAAI,MAAM,CAA2B;IACxD,IAAI,eAAe,CAAC,KAAK,EAAE,MAAM,EAA6B;IAqC9D,KAAK,IAAI,IAAI;IAMb,IAAI,IAAI,IAAI;IAMZ,KAAK,CAAC,eAAe,CAAC,EAAE,OAAO,GAAG,IAAI;IAKtC,MAAM,IAAI,IAAI;CAGjB;AAED;;;;;GAKG;AACH,qBAAa,iBAAkB,YAAW,UAAU;;IAKhD;;OAEG;gBACS,QAAQ,EAAE,gBAAgB;IAQtC;;OAEG;IACG,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAI3E,KAAK,IAAI,IAAI;IAQb,IAAI,IAAI,IAAI;IAOZ,KAAK,CAAC,eAAe,CAAC,EAAE,OAAO,G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IAWrD;;;OAGG;gBACS,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,WAAW;IAqC3D,KAAK,IAAI,IAAI;IAYb,IAAI,IAAI,IAAI;IAOZ,KAAK,CAAC,eAAe,CAAC,EAAE,OAAO,GAAG,IAAI;IAKtC,MAAM,IAAI,IAAI;CAGjB"}

@ -1,6 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PollingEventSubscriber = exports.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

File diff suppressed because one or more lines are too long

@ -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

@ -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"}

@ -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

@ -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,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
export const version = "6.8.1";
export const version = "6.9.0";
//# sourceMappingURL=_version.js.map

File diff suppressed because one or more lines are too long

@ -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 {

File diff suppressed because one or more lines are too long

@ -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

@ -22,7 +22,7 @@ import { EnsResolver } from "./ens-resolver.js";
import { formatBlock, formatLog, formatTransactionReceipt, formatTransactionResponse } from "./format.js";
import { Network } from "./network.js";
import { copyRequest, Block, FeeData, Log, TransactionReceipt, TransactionResponse } from "./provider.js";
import { PollingBlockSubscriber, PollingEventSubscriber, PollingOrphanSubscriber, PollingTransactionSubscriber } from "./subscriber-polling.js";
import { PollingBlockSubscriber, PollingBlockTagSubscriber, PollingEventSubscriber, PollingOrphanSubscriber, PollingTransactionSubscriber } from "./subscriber-polling.js";
// Constants
const BN_2 = BigInt(2);
const MAX_CCIP_REDIRECTS = 10;
@ -90,10 +90,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 };
}
}
@ -391,10 +393,10 @@ export class AbstractProvider {
switch (blockTag) {
case "earliest":
return "0x0";
case "finalized":
case "latest":
case "pending":
case "safe":
case "finalized":
return blockTag;
}
if (isHexString(blockTag)) {
@ -577,12 +579,20 @@ export 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;
@ -593,7 +603,7 @@ export 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 FeeData(gasPrice, maxFeePerGas, maxPriorityFeePerGas);
@ -971,6 +981,9 @@ export 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":

File diff suppressed because one or more lines are too long

@ -287,23 +287,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() {
@ -346,6 +329,9 @@ function injectCommonNetworks() {
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 });
@ -364,9 +350,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

@ -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"}

@ -20,6 +20,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":

@ -1 +1 @@
{"version":3,"file":"provider-alchemy.js","sourceRoot":"","sources":["../../src.ts/providers/provider-alchemy.ts"],"names":[],"mappings":"AAAA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E,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAMvE,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC;IAIvC;;;;OAIG;IACG,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC;IAsFtF;;OAEG;IACH,uBAAuB,CAAC,WAAW,EAAE,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAyBhF;;OAEG;IACH,WAAW,CAAC,GAAG,EAAE,oBAAoB,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,GAAG,KAAK;IAiEvE,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IAIlC,QAAQ,CAAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC;IAsMjD,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAIpC;;;;OAIG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAKtC;;;OAGG;IACG,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,QAAQ,CAAC;IAc7D,mBAAmB,IAAI,OAAO;CAGjC"}

@ -20,7 +20,9 @@
import { AbiCoder } from "../abi/index.js";
import { Contract } from "../contract/index.js";
import { accessListify, Transaction } from "../transaction/index.js";
import { defineProperties, hexlify, toQuantity, FetchRequest, assert, assertArgument, isError, toUtf8String } from "../utils/index.js";
import { defineProperties, hexlify, toQuantity, FetchRequest, assert, assertArgument, isError,
// parseUnits,
toUtf8String } from "../utils/index.js";
import { AbstractProvider } from "./abstract-provider.js";
import { Network } from "./network.js";
import { NetworkPlugin } from "./plugins-network.js";
@ -342,6 +344,44 @@ export 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", {

File diff suppressed because one or more lines are too long

@ -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,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AA6B9C;;GAEG;AACH,MAAM,WAAW,sBAAsB;IAEnC;;OAEG;IACH,QAAQ,EAAE,gBAAgB,CAAC;IAE3B;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAMD;;GAEG;AACH,MAAM,WAAW,qBAAsB,S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,CAAC,EAAE,MAAM,CAAC;IAEtB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAwKF;;;;;;GAMG;AACH,qBAAa,gBAAiB,SAAQ,gBAAgB;;IAElD;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAO9B;;;;;;OAMG;gBACS,SAAS,EAAE,KAAK,CAAC,gBAAgB,GAAG,sBAAsB,CAAC,EAAE,OAAO,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,uBAAuB;IA8BhI,IAAI,eAAe,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAQlD;IAEK,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IASxC;;OAEG;IACG,iBAAiB,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC;IA6QtF,QAAQ,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,CAAC,CAAC;IA8ExD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAMjC"}

@ -4,7 +4,7 @@
*
* @_section: api/providers/fallback-provider:Fallback Provider [about-fallback-provider]
*/
import { getBigInt, getNumber, assert, assertArgument } from "../utils/index.js";
import { assert, assertArgument, getBigInt, getNumber, isError } from "../utils/index.js";
import { AbstractProvider } from "./abstract-provider.js";
import { Network } from "./network.js";
const BN_1 = BigInt("1");
@ -298,6 +298,8 @@ export 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":
@ -443,6 +445,7 @@ export class FallbackProvider extends AbstractProvider {
return this.#height;
}
case "getGasPrice":
case "getPriorityFee":
case "estimateGas":
return getMedian(this.quorum, results);
case "getBlock":
@ -524,15 +527,46 @@ export 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",
@ -546,8 +580,16 @@ export 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

File diff suppressed because one or more lines are too long

@ -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>;
}

@ -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"}

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

@ -1 +1 @@
{"version":3,"file":"provider-ipcsocket.js","sourceRoot":"","sources":["../../src.ts/providers/provider-ipcsocket.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;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,CAAC,IAAI,EAAE,CAAC,CAAC;QAC9D,SAAS,GAAG,EAAE,GAAG,CAAC,CAAC;KACtB;IAED,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;AAC7D,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AO,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"}

@ -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

@ -211,6 +211,7 @@ export class JsonRpcApiProvider extends AbstractProvider {
#drainTimer;
#notReady;
#network;
#pendingDetectNetwork;
#scheduleDrain() {
if (this.#drainTimer) {
return;
@ -286,6 +287,7 @@ export class JsonRpcApiProvider extends AbstractProvider {
this.#payloads = [];
this.#drainTimer = null;
this.#network = null;
this.#pendingDetectNetwork = null;
{
let resolve = null;
const promise = new Promise((_resolve) => {
@ -293,9 +295,15 @@ export 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;
}
@ -356,13 +364,29 @@ export class JsonRpcApiProvider extends AbstractProvider {
async _detectNetwork() {
const network = this._getOption("staticNetwork");
if (network) {
if (network === true) {
if (this.#network) {
return this.#network;
}
}
else {
return network;
}
}
if (this.#pendingDetectNetwork) {
return await this.#pendingDetectNetwork;
}
// If we are ready, use ``send``, which enabled requests to be batched
if (this.ready) {
return Network.from(getBigInt(await this.send("eth_chainId", [])));
this.#pendingDetectNetwork = (async () => {
const result = Network.from(getBigInt(await this.send("eth_chainId", [])));
this.#pendingDetectNetwork = null;
return result;
})();
return await this.#pendingDetectNetwork;
}
// We are not ready yet; use the primitive _send
this.#pendingDetectNetwork = (async () => {
const payload = {
id: this.#nextId++, method: "eth_chainId", params: [], jsonrpc: "2.0"
};
@ -370,8 +394,10 @@ export class JsonRpcApiProvider extends AbstractProvider {
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;
}
@ -380,6 +406,8 @@ export class JsonRpcApiProvider extends AbstractProvider {
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
@ -495,6 +523,8 @@ export 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",

File diff suppressed because one or more lines are too long

@ -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

@ -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,GAAG,IAAI;IAmBlC;;;OAGG;IACG,KAAK,CAAC,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;CAGrE;AAED;;;GAGG;AACH,qBAAa,qBAAsB,SAAQ,gBAAgB;IACvD;;OAEG;gBACS,QAAQ,EAAE,cAAc;IAI9B,KAAK,CAAC,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;CAGrE;AAED;;;GAGG;AACH,qBAAa,uBAAwB,SAAQ,gBAAgB;IAEzD;;OAEG;gBACS,QAAQ,EAAE,cAAc;IAI9B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AAC;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"}

@ -157,8 +157,21 @@ export 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();

File diff suppressed because one or more lines are too long

@ -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>;
}

@ -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;IAEnB,IAAI,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI,CAAC;IACzB,KAAK,CAAC,IAAI,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;IA2C1E,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IA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CAAC;CAOjC"}

@ -19,8 +19,8 @@ export 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();

@ -1 +1 @@
{"version":3,"file":"provider-websocket.js","sourceRoot":"","sources":["../../src.ts/providers/provider-websocket.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC,CAAC,YAAY;AAE/D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAwBtD;;;;;;;;;GASG;AACH,MAAM,OAAO,iBAAkB,SAAQ,cAAc;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,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YACtD,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;SACrC;aAAM,IAAI,OAAM,CAAC,GAAG,CAAC,KAAK,UAAU,EAAE;YACnC,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC;YACpB,IAAI,CAAC,UAAU,GAAG,GAAG,EAAE,CAAC;SAC3B;aAAM;YACH,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YACrB,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;SACzB;QAED,IAAI,CAAC,SAAS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E;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"}

@ -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:
*

@ -1 +1 @@
{"version":3,"file":"subscriber-polling.d.ts","sourceRoot":"","sources":["../../src.ts/providers/subscriber-polling.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAM9E;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,gBAAgB,EAAE,KAAK,EAAE,aAAa,GAAG,UAAU,CAOjG;AAID;;;;;GAKG;AACH,qBAAa,sBAAuB,YAAW,UAAU;;IAUrD;;OAEG;gBACS,QAAQ,EAAE,gBAAgB;IAQtC;;OAEG;IACH,IAAI,eAAe,IAAI,MAAM,CAA2B;IACxD,IAAI,eAAe,CAAC,KAAK,EAAE,MAAM,EAA6B;IAqC9D,KAAK,IAAI,IAAI;IAMb,IAAI,IAAI,IAAI;IAMZ,KAAK,CAAC,eAAe,CAAC,EAAE,OAAO,GAAG,IAAI;IAKtC,MAAM,IAAI,IAAI;CAGjB;AAED;;;;;GAKG;AACH,qBAAa,iBAAkB,YAAW,UAAU;;IAKhD;;OAEG;gBACS,QAAQ,EAAE,gBAAgB;IAQtC;;OAEG;IACG,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,gBA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AW,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;CAI9E;AAED;;;;GAIG;AACH,qBAAa,sBAAuB,YAAW,UAAU;;IAWrD;;;OAGG;gBACS,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,WAAW;IAqC3D,KAAK,IAAI,IAAI;IAYb,IAAI,IAAI,IAAI;IAOZ,KAAK,CAAC,eAAe,CAAC,EAAE,OAAO,GAAG,IAAI;IAKtC,MAAM,IAAI,IAAI;CAGjB"}

@ -145,6 +145,34 @@ export class OnBlockSubscriber {
pause(dropWhilePaused) { this.stop(); }
resume() { this.start(); }
}
export 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:
*

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -93,7 +93,7 @@
"url": "https://www.buymeacoffee.com/ricmoo"
}
],
"gitHead": "8fed2f84768ace4bf3e5742c931a74841da7c637",
"gitHead": "f8f11c754aa2c9b541db73d3bde66a8ffa5146f0",
"homepage": "https://ethers.org",
"keywords": [
"ethereum",
@ -131,5 +131,5 @@
"test-esm": "mocha --reporter ./reporter.cjs ./lib.esm/_tests/test-*.js"
},
"sideEffects": false,
"version": "6.8.1"
"version": "6.9.0"
}

@ -3,4 +3,4 @@
/**
* The current version of Ethers.
*/
export const version: string = "6.8.1";
export const version: string = "6.9.0";