Skip to content

Commit

Permalink
fix(types): bump ethers with updated provider & signer classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubilmax committed Apr 5, 2024
1 parent 453c15b commit e20fb83
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 55 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ethers-multicall-provider",
"version": "6.2.0",
"version": "6.3.0",
"description": "⚡🕰️ Drop-in solution to batch smart contract RPC calls in a single RPC query via Multicall!",
"main": "lib/index.js",
"files": [
Expand Down Expand Up @@ -42,7 +42,7 @@
"homepage": "https://github.com/rubilmax/ethers-multicall-provider#readme",
"dependencies": {
"dataloader": "^2.2.2",
"ethers": "^6.0.0"
"ethers": "^6.11.0"
},
"devDependencies": {
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
Expand Down
45 changes: 11 additions & 34 deletions src/multicall-provider.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import DataLoader from "dataloader";
import {
BlockTag,
BytesLike,
AbstractProvider,
PerformActionRequest,
Network,
isHexString,
} from "ethers";
import { BlockTag, AbstractProvider, PerformActionRequest } from "ethers";

import { multicallAddresses } from "./constants";
import { Multicall2, Multicall3 } from "./types";
Expand All @@ -25,9 +18,7 @@ export interface ContractCallRequest {

export type MulticallProvider<T extends AbstractProvider = AbstractProvider> = T & {
readonly _isMulticallProvider: boolean;

fetchNetwork(): Promise<Network>;
_networkPromise: Promise<Network>;
readonly cache: boolean;

maxMulticallDataLength: number;
isMulticallEnabled: boolean;
Expand Down Expand Up @@ -62,7 +53,7 @@ export class MulticallWrapper {

// Overload provider

Object.defineProperties(provider, {
const multicallProvider = Object.defineProperties(provider, {
_isMulticallProvider: {
value: true,
writable: false,
Expand All @@ -75,6 +66,12 @@ export class MulticallWrapper {
enumerable: true,
configurable: false,
},
cache: {
value: cache,
writable: false,
enumerable: true,
configurable: false,
},
maxMulticallDataLength: {
value: maxMulticallDataLength,
writable: true,
Expand All @@ -87,9 +84,7 @@ export class MulticallWrapper {
enumerable: true,
configurable: true,
},
});

const multicallProvider = provider as MulticallProvider<T>;
}) as MulticallProvider<T>;

// Define execution context

Expand Down Expand Up @@ -171,24 +166,6 @@ export class MulticallWrapper {
}
);

// Expose `Provider.fetchNetwork` to fetch & update the network cache when needed

const getNetwork = provider.getNetwork.bind(provider);

multicallProvider.fetchNetwork = async function fetchNetwork(): Promise<Network> {
this._networkPromise = getNetwork();

return this._networkPromise;
};

multicallProvider.fetchNetwork();

// Overload `Provider._detectNetwork` to disable polling the network at each RPC call

multicallProvider._detectNetwork = async function _detectNetwork(): Promise<Network> {
return this._networkPromise;
};

// Overload `Provider._perform`

const _perform = provider._perform.bind(provider);
Expand All @@ -203,7 +180,7 @@ export class MulticallWrapper {

if (!to || !data || multicallAddresses.has(to.toString().toLowerCase())) return _perform(req);

const network = await this._networkPromise;
const network = await this._detectNetwork();

const blockNumber = getBlockNumber(blockTag);
const multicall = getMulticall(blockNumber, Number(network.chainId), provider);
Expand Down
40 changes: 21 additions & 19 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# yarn lockfile v1


"@adraffy/ens-normalize@1.9.2":
version "1.9.2"
resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.9.2.tgz#60111a5d9db45b2e5cbb6231b0bb8d97e8659316"
integrity sha512-0h+FrQDqe2Wn+IIGFkTCd4aAwTJ+7834Ek1COohCyV26AXhwQ7WQaz+4F/nLOeVl/3BtWHOHLPsq46V8YB46Eg==
"@adraffy/ens-normalize@1.10.1":
version "1.10.1"
resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.10.1.tgz#63430d04bd8c5e74f8d7d049338f1cd9d4f02069"
integrity sha512-96Z2IP3mYmF1Xg2cDm8f1gWGf/HUVedQ3FMifV4kG/PQ4yEP51xDtRAEfhVNt5f/uzpNkZHwWQuUcu6D6K+Ekw==

"@ampproject/remapping@^2.2.0":
version "2.2.1"
Expand Down Expand Up @@ -714,15 +714,17 @@
"@jridgewell/resolve-uri" "^3.1.0"
"@jridgewell/sourcemap-codec" "^1.4.14"

"@noble/[email protected]":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.1.2.tgz#e9e035b9b166ca0af657a7848eb2718f0f22f183"
integrity sha512-KYRCASVTv6aeUi1tsF8/vpyR7zpfs3FUzy2Jqm+MU+LmUKhQ0y2FpfwqkCcxSg2ua4GALJd8k2R76WxwZGbQpA==
"@noble/[email protected]":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.2.0.tgz#92d7e12e4e49b23105a2555c6984d41733d65c35"
integrity sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==
dependencies:
"@noble/hashes" "1.3.2"

"@noble/secp256k1@1.7.1":
version "1.7.1"
resolved "https://registry.yarnpkg.com/@noble/secp256k1/-/secp256k1-1.7.1.tgz#b251c70f824ce3ca7f8dc3df08d58f005cc0507c"
integrity sha512-hOUk6AyBFmqVrv7k5WAw/LpszxVbj9gGN4JRkIX52fdFAj1UA61KXmZDvqVEm+pOyec3+fIeZB02LYa/pWOArw==
"@noble/hashes@1.3.2":
version "1.3.2"
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.2.tgz#6f26dbc8fbc7205873ce3cee2f690eba0d421b39"
integrity sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==

"@sinclair/typebox@^0.27.8":
version "0.27.8"
Expand Down Expand Up @@ -1569,14 +1571,14 @@ esprima@^4.0.0:
resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71"
integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==

ethers@^6.0.0:
version "6.7.1"
resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.7.1.tgz#9c65e8b5d8e9ad77b7e8cf1c46099892cfafad49"
integrity sha512-qX5kxIFMfg1i+epfgb0xF4WM7IqapIIu50pOJ17aebkxxa4BacW5jFrQRmCJpDEg2ZK2oNtR5QjrQ1WDBF29dA==
ethers@^6.11.0:
version "6.11.1"
resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.11.1.tgz#96aae00b627c2e35f9b0a4d65c7ab658259ee6af"
integrity sha512-mxTAE6wqJQAbp5QAe/+o+rXOID7Nw91OZXvgpjDa1r4fAbq2Nu314oEZSbjoRLacuCzs7kUC3clEvkCQowffGg==
dependencies:
"@adraffy/ens-normalize" "1.9.2"
"@noble/hashes" "1.1.2"
"@noble/secp256k1" "1.7.1"
"@adraffy/ens-normalize" "1.10.1"
"@noble/curves" "1.2.0"
"@noble/hashes" "1.3.2"
"@types/node" "18.15.13"
aes-js "4.0.0-beta.5"
tslib "2.4.0"
Expand Down

0 comments on commit e20fb83

Please sign in to comment.