Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/v6.9-wip'
Browse files Browse the repository at this point in the history
  • Loading branch information
Woodpile37 committed Jan 14, 2024
2 parents 4ad25d0 + d60dfc1 commit 33b54dc
Show file tree
Hide file tree
Showing 25 changed files with 99 additions and 389 deletions.
17 changes: 1 addition & 16 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,7 @@ Change Log

This change log is maintained by `src.ts/_admin/update-changelog.ts` but may also be manually updated.

ethers/v6.10.0 (2024-01-12 19:46)
---------------------------------

- Limit decoded result imflation ratio from ABI-encoded data ([#4537](https://github.com/ethers-io/ethers.js/issues/4537); [1b4debd](https://github.com/ethers-io/ethers.js/commit/1b4debd4a9e61d171bfc60590116facb8bdbd2da)).

ethers/v6.9.2 (2024-01-02 19:12)
--------------------------------

- Fix Base58 padding for string representation of binary data ([#4527](https://github.com/ethers-io/ethers.js/issues/4527); [ccac24a](https://github.com/ethers-io/ethers.js/commit/ccac24a5b0a4d07a4b639c1c4d0a44703e32d418)).

ethers/v6.9.1 (2023-12-19 04:53)
--------------------------------

- Fix uncatchable issue when sending transactions over JSON-RPC and provide some retry-recovery for missing v ([#4513](https://github.com/ethers-io/ethers.js/issues/4513); [1802215](https://github.com/ethers-io/ethers.js/commit/180221574c5d2af9ad85404af4fab8752d3d5029)).

ethers/v6.9.0 (2023-11-27 06:15)
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)).
Expand Down
124 changes: 23 additions & 101 deletions dist/ethers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
/**
* The current version of Ethers.
*/
const version = "6.10.0";
const version = "6.9.0";

/**
* Property helper functions.
Expand Down Expand Up @@ -695,20 +695,12 @@ const BN_58 = BigInt(58);
* Encode %%value%% as a Base58-encoded string.
*/
function encodeBase58(_value) {
const bytes = getBytes(_value);
let value = toBigInt(bytes);
let value = toBigInt(getBytes(_value));
let result = "";
while (value) {
result = Alphabet[Number(value % BN_58)] + result;
value /= BN_58;
}
// Account for leading padding zeros
for (let i = 0; i < bytes.length; i++) {
if (bytes[i]) {
break;
}
result = Alphabet[0] + result;
}
return result;
}
/**
Expand Down Expand Up @@ -2970,35 +2962,15 @@ class Reader {
allowLoose;
#data;
#offset;
#bytesRead;
#parent;
#maxInflation;
constructor(data, allowLoose, maxInflation) {
constructor(data, allowLoose) {
defineProperties(this, { allowLoose: !!allowLoose });
this.#data = getBytesCopy(data);
this.#bytesRead = 0;
this.#parent = null;
this.#maxInflation = (maxInflation != null) ? maxInflation : 1024;
this.#offset = 0;
}
get data() { return hexlify(this.#data); }
get dataLength() { return this.#data.length; }
get consumed() { return this.#offset; }
get bytes() { return new Uint8Array(this.#data); }
#incrementBytesRead(count) {
if (this.#parent) {
return this.#parent.#incrementBytesRead(count);
}
this.#bytesRead += count;
// Check for excessive inflation (see: #4537)
assert(this.#maxInflation < 1 || this.#bytesRead <= this.#maxInflation * this.dataLength, `compressed ABI data exceeds inflation ratio of ${this.#maxInflation} ( see: https:/\/github.com/ethers-io/ethers.js/issues/4537 )`, "BUFFER_OVERRUN", {
buffer: getBytesCopy(this.#data), offset: this.#offset,
length: count, info: {
bytesRead: this.#bytesRead,
dataLength: this.dataLength
}
});
}
#peekBytes(offset, length, loose) {
let alignedLength = Math.ceil(length / WordSize) * WordSize;
if (this.#offset + alignedLength > this.#data.length) {
Expand All @@ -3017,14 +2989,11 @@ class Reader {
}
// Create a sub-reader with the same underlying data, but offset
subReader(offset) {
const reader = new Reader(this.#data.slice(this.#offset + offset), this.allowLoose, this.#maxInflation);
reader.#parent = this;
return reader;
return new Reader(this.#data.slice(this.#offset + offset), this.allowLoose);
}
// Read bytes
readBytes(length, loose) {
let bytes = this.#peekBytes(0, length, !!loose);
this.#incrementBytesRead(length);
this.#offset += bytes.length;
// @TODO: Make sure the length..end bytes are all 0?
return bytes.slice(0, length);
Expand Down Expand Up @@ -12255,7 +12224,6 @@ PanicReasons$1.set(0x51, "UNINITIALIZED_FUNCTION_CALL");
const paramTypeBytes = new RegExp(/^bytes([0-9]*)$/);
const paramTypeNumber = new RegExp(/^(u?int)([0-9]*)$/);
let defaultCoder = null;
let defaultMaxInflation = 1024;
function getBuiltinCallException(action, tx, data, abiCoder) {
let message = "missing revert data";
let reason = null;
Expand Down Expand Up @@ -12392,11 +12360,7 @@ class AbiCoder {
decode(types, data, loose) {
const coders = types.map((type) => this.#getCoder(ParamType.from(type)));
const coder = new TupleCoder(coders, "_");
return coder.decode(new Reader(data, loose, defaultMaxInflation));
}
static _setDefaultMaxInflation(value) {
assertArgument(typeof (value) === "number" && Number.isInteger(value), "invalid defaultMaxInflation factor", "value", value);
defaultMaxInflation = value;
return coder.decode(new Reader(data, loose));
}
/**
* Returns the shared singleton instance of a default [[AbiCoder]].
Expand Down Expand Up @@ -18084,19 +18048,16 @@ class AbstractProvider {
// No explicit network was set and this is our first time
if (this.#networkPromise == null) {
// Detect the current network (shared with all calls)
const detectNetwork = (async () => {
try {
const network = await this._detectNetwork();
this.emit("network", network, null);
return network;
}
catch (error) {
if (this.#networkPromise === detectNetwork) {
this.#networkPromise = null;
}
throw error;
const detectNetwork = this._detectNetwork().then((network) => {
this.emit("network", network, null);
return network;
}, (error) => {
// Reset the networkPromise on failure, so we will try again
if (this.#networkPromise === detectNetwork) {
this.#networkPromise = null;
}
})();
throw error;
});
this.#networkPromise = detectNetwork;
return (await detectNetwork).clone();
}
Expand Down Expand Up @@ -19483,45 +19444,12 @@ class JsonRpcSigner extends AbstractSigner {
// for it; it should show up very quickly
return await (new Promise((resolve, reject) => {
const timeouts = [1000, 100];
let invalids = 0;
const checkTx = async () => {
try {
// Try getting the transaction
const tx = await this.provider.getTransaction(hash);
if (tx != null) {
resolve(tx.replaceableTransaction(blockNumber));
return;
}
}
catch (error) {
// If we were cancelled: stop polling.
// If the data is bad: the node returns bad transactions
// If the network changed: calling again will also fail
// If unsupported: likely destroyed
if (isError(error, "CANCELLED") || isError(error, "BAD_DATA") ||
isError(error, "NETWORK_ERROR" )) {
if (error.info == null) {
error.info = {};
}
error.info.sendTransactionHash = hash;
reject(error);
return;
}
// Stop-gap for misbehaving backends; see #4513
if (isError(error, "INVALID_ARGUMENT")) {
invalids++;
if (error.info == null) {
error.info = {};
}
error.info.sendTransactionHash = hash;
if (invalids > 10) {
reject(error);
return;
}
}
// Notify anyone that cares; but we will try again, since
// it is likely an intermittent service error
this.provider.emit("error", makeError("failed to fetch transation after sending (will try again)", "UNKNOWN_ERROR", { error }));
// Try getting the transaction
const tx = await this.provider.getTransaction(hash);
if (tx != null) {
resolve(tx.replaceableTransaction(blockNumber));
return;
}
// Wait another 4 seconds
this.provider._setTimeout(() => { checkTx(); }, timeouts.pop() || 4000);
Expand Down Expand Up @@ -19599,7 +19527,7 @@ class JsonRpcApiProvider extends AbstractProvider {
if (this.#drainTimer) {
return;
}
// If we aren't using batching, no harm in sending it immediately
// If we aren't using batching, no hard in sending it immeidately
const stallTime = (this._getOption("batchMaxCount") === 1) ? 0 : this._getOption("batchStallTime");
this.#drainTimer = setTimeout(() => {
this.#drainTimer = null;
Expand Down Expand Up @@ -19762,15 +19690,9 @@ class JsonRpcApiProvider extends AbstractProvider {
// If we are ready, use ``send``, which enabled requests to be batched
if (this.ready) {
this.#pendingDetectNetwork = (async () => {
try {
const result = Network.from(getBigInt(await this.send("eth_chainId", [])));
this.#pendingDetectNetwork = null;
return result;
}
catch (error) {
this.#pendingDetectNetwork = null;
throw error;
}
const result = Network.from(getBigInt(await this.send("eth_chainId", [])));
this.#pendingDetectNetwork = null;
return result;
})();
return await this.#pendingDetectNetwork;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/ethers.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/ethers.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 33b54dc

Please sign in to comment.