@wagmi/core 0.4.4 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/chains/dist/wagmi-core-chains.cjs.dev.js +1 -1
- package/chains/dist/wagmi-core-chains.cjs.prod.js +1 -1
- package/chains/dist/wagmi-core-chains.esm.js +1 -1
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.dev.js +2 -2
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.prod.js +2 -2
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.esm.js +2 -2
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.dev.js +3 -3
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.prod.js +3 -3
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.esm.js +3 -3
- package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.dev.js +2 -2
- package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.prod.js +2 -2
- package/connectors/mock/dist/wagmi-core-connectors-mock.esm.js +2 -2
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.dev.js +3 -3
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.prod.js +3 -3
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.esm.js +3 -3
- package/dist/{base-e71ae4b2.cjs.dev.js → base-797ad073.cjs.prod.js} +17 -3
- package/dist/{base-2d484f6c.cjs.prod.js → base-90b7f3e4.cjs.dev.js} +17 -3
- package/dist/{base-68ec937e.esm.js → base-b565d5d4.esm.js} +17 -4
- package/dist/{chains-d970ee8d.cjs.dev.js → chains-7e6dc59c.cjs.dev.js} +1 -1
- package/dist/{chains-865492ea.cjs.prod.js → chains-f7bb3211.cjs.prod.js} +1 -1
- package/dist/{chains-c389721d.esm.js → chains-fd2c546c.esm.js} +1 -1
- package/dist/{client-90ae4735.cjs.dev.js → client-71ece661.cjs.dev.js} +1 -1
- package/dist/{client-5df5c2eb.esm.js → client-a05fd511.esm.js} +1 -1
- package/dist/{client-0140ab1f.cjs.prod.js → client-a6e61429.cjs.prod.js} +1 -1
- package/dist/declarations/src/errors.d.ts +9 -0
- package/dist/declarations/src/index.d.ts +2 -2
- package/dist/declarations/src/utils/deepEqual.d.ts +2 -0
- package/dist/declarations/src/utils/index.d.ts +2 -0
- package/dist/declarations/src/utils/parseContractResult.d.ts +7 -0
- package/dist/wagmi-core.cjs.dev.js +96 -8
- package/dist/wagmi-core.cjs.prod.js +96 -8
- package/dist/wagmi-core.esm.js +100 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,8 +18,8 @@ Check out the following places for more wagmi-related content:
|
|
|
18
18
|
|
|
19
19
|
- Join the [discussions on GitHub](https://github.com/tmm/wagmi/discussions)
|
|
20
20
|
- Follow [@awkweb](https://twitter.com/awkweb) and [@wagmi_sh](https://twitter.com/wagmi_sh) on Twitter for project updates
|
|
21
|
-
- Sign the [guestbook](https://github.com/tmm/wagmi/discussions/2)
|
|
22
21
|
- Share [your project/organization](https://github.com/tmm/wagmi/discussions/201) using wagmi
|
|
22
|
+
- Browse the [awesome-wagmi](https://github.com/tmm/awesome-wagmi) list of awesome projects and resources
|
|
23
23
|
|
|
24
24
|
## Support
|
|
25
25
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { g as arbitrum, h as arbitrumRinkeby, i as foundry, j as goerli, k as hardhat, l as kovan, m as localhost, n as mainnet, o as optimism, p as optimismKovan, q as polygon, r as polygonMumbai, s as rinkeby, t as ropsten } from '../../dist/chains-
|
|
1
|
+
export { g as arbitrum, h as arbitrumRinkeby, i as foundry, j as goerli, k as hardhat, l as kovan, m as localhost, n as mainnet, o as optimism, p as optimismKovan, q as polygon, r as polygonMumbai, s as rinkeby, t as ropsten } from '../../dist/chains-fd2c546c.esm.js';
|
|
2
2
|
import '../../dist/rpcs-b73a8f60.esm.js';
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var base = require('../../../dist/base-
|
|
5
|
+
var base = require('../../../dist/base-90b7f3e4.cjs.dev.js');
|
|
6
6
|
var ethers = require('ethers');
|
|
7
7
|
var utils = require('ethers/lib/utils');
|
|
8
8
|
require('eventemitter3');
|
|
9
|
-
require('../../../dist/chains-
|
|
9
|
+
require('../../../dist/chains-7e6dc59c.cjs.dev.js');
|
|
10
10
|
require('../../../dist/rpcs-f1d24f0e.cjs.dev.js');
|
|
11
11
|
|
|
12
12
|
function _interopNamespace(e) {
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var base = require('../../../dist/base-
|
|
5
|
+
var base = require('../../../dist/base-797ad073.cjs.prod.js');
|
|
6
6
|
var ethers = require('ethers');
|
|
7
7
|
var utils = require('ethers/lib/utils');
|
|
8
8
|
require('eventemitter3');
|
|
9
|
-
require('../../../dist/chains-
|
|
9
|
+
require('../../../dist/chains-f7bb3211.cjs.prod.js');
|
|
10
10
|
require('../../../dist/rpcs-1fd0a12f.cjs.prod.js');
|
|
11
11
|
|
|
12
12
|
function _interopNamespace(e) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { e as Connector, m as _classPrivateMethodInitSpec, _ as _defineProperty, j as _classPrivateFieldInitSpec, n as normalizeChainId, U as UserRejectedRequestError, k as _classPrivateFieldGet, l as _classPrivateFieldSet, f as ChainNotConfiguredError, o as _classPrivateMethodGet, A as AddChainError, i as SwitchChainError } from '../../../dist/base-b565d5d4.esm.js';
|
|
2
2
|
import { providers } from 'ethers';
|
|
3
3
|
import { getAddress, hexValue } from 'ethers/lib/utils';
|
|
4
4
|
import 'eventemitter3';
|
|
5
|
-
import '../../../dist/chains-
|
|
5
|
+
import '../../../dist/chains-fd2c546c.esm.js';
|
|
6
6
|
import '../../../dist/rpcs-b73a8f60.esm.js';
|
|
7
7
|
|
|
8
8
|
var _client = /*#__PURE__*/new WeakMap();
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var base = require('../../../dist/base-
|
|
6
|
-
var client = require('../../../dist/client-
|
|
5
|
+
var base = require('../../../dist/base-90b7f3e4.cjs.dev.js');
|
|
6
|
+
var client = require('../../../dist/client-71ece661.cjs.dev.js');
|
|
7
7
|
require('eventemitter3');
|
|
8
|
-
require('../../../dist/chains-
|
|
8
|
+
require('../../../dist/chains-7e6dc59c.cjs.dev.js');
|
|
9
9
|
require('../../../dist/rpcs-f1d24f0e.cjs.dev.js');
|
|
10
10
|
require('zustand/vanilla');
|
|
11
11
|
require('zustand/middleware');
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var base = require('../../../dist/base-
|
|
6
|
-
var client = require('../../../dist/client-
|
|
5
|
+
var base = require('../../../dist/base-797ad073.cjs.prod.js');
|
|
6
|
+
var client = require('../../../dist/client-a6e61429.cjs.prod.js');
|
|
7
7
|
require('eventemitter3');
|
|
8
|
-
require('../../../dist/chains-
|
|
8
|
+
require('../../../dist/chains-f7bb3211.cjs.prod.js');
|
|
9
9
|
require('../../../dist/rpcs-1fd0a12f.cjs.prod.js');
|
|
10
10
|
require('zustand/vanilla');
|
|
11
11
|
require('zustand/middleware');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { I as InjectedConnector, g as getClient, s as shimDisconnectKey } from '../../../dist/client-
|
|
1
|
+
import { m as _classPrivateMethodInitSpec, _ as _defineProperty, o as _classPrivateMethodGet, j as _classPrivateFieldInitSpec, l as _classPrivateFieldSet, c as ConnectorNotFoundError, k as _classPrivateFieldGet, U as UserRejectedRequestError, R as ResourceUnavailableError } from '../../../dist/base-b565d5d4.esm.js';
|
|
2
|
+
import { I as InjectedConnector, g as getClient, s as shimDisconnectKey } from '../../../dist/client-a05fd511.esm.js';
|
|
3
3
|
import 'eventemitter3';
|
|
4
|
-
import '../../../dist/chains-
|
|
4
|
+
import '../../../dist/chains-fd2c546c.esm.js';
|
|
5
5
|
import '../../../dist/rpcs-b73a8f60.esm.js';
|
|
6
6
|
import 'zustand/vanilla';
|
|
7
7
|
import 'zustand/middleware';
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var base = require('../../../dist/base-
|
|
5
|
+
var base = require('../../../dist/base-90b7f3e4.cjs.dev.js');
|
|
6
6
|
var utils = require('ethers/lib/utils');
|
|
7
7
|
var EventEmitter = require('eventemitter3');
|
|
8
8
|
var ethers = require('ethers');
|
|
9
|
-
require('../../../dist/chains-
|
|
9
|
+
require('../../../dist/chains-7e6dc59c.cjs.dev.js');
|
|
10
10
|
require('../../../dist/rpcs-f1d24f0e.cjs.dev.js');
|
|
11
11
|
|
|
12
12
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var base = require('../../../dist/base-
|
|
5
|
+
var base = require('../../../dist/base-797ad073.cjs.prod.js');
|
|
6
6
|
var utils = require('ethers/lib/utils');
|
|
7
7
|
var EventEmitter = require('eventemitter3');
|
|
8
8
|
var ethers = require('ethers');
|
|
9
|
-
require('../../../dist/chains-
|
|
9
|
+
require('../../../dist/chains-f7bb3211.cjs.prod.js');
|
|
10
10
|
require('../../../dist/rpcs-1fd0a12f.cjs.prod.js');
|
|
11
11
|
|
|
12
12
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { _ as _defineProperty,
|
|
1
|
+
import { _ as _defineProperty, j as _classPrivateFieldInitSpec, l as _classPrivateFieldSet, k as _classPrivateFieldGet, U as UserRejectedRequestError, e as Connector, m as _classPrivateMethodInitSpec, n as normalizeChainId, o as _classPrivateMethodGet } from '../../../dist/base-b565d5d4.esm.js';
|
|
2
2
|
import { getAddress } from 'ethers/lib/utils';
|
|
3
3
|
import EventEmitter from 'eventemitter3';
|
|
4
4
|
import { providers } from 'ethers';
|
|
5
|
-
import '../../../dist/chains-
|
|
5
|
+
import '../../../dist/chains-fd2c546c.esm.js';
|
|
6
6
|
import '../../../dist/rpcs-b73a8f60.esm.js';
|
|
7
7
|
|
|
8
8
|
var _options = /*#__PURE__*/new WeakMap();
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var base = require('../../../dist/base-
|
|
5
|
+
var base = require('../../../dist/base-90b7f3e4.cjs.dev.js');
|
|
6
6
|
var ethers = require('ethers');
|
|
7
7
|
var utils = require('ethers/lib/utils');
|
|
8
|
-
var client = require('../../../dist/client-
|
|
8
|
+
var client = require('../../../dist/client-71ece661.cjs.dev.js');
|
|
9
9
|
require('eventemitter3');
|
|
10
|
-
require('../../../dist/chains-
|
|
10
|
+
require('../../../dist/chains-7e6dc59c.cjs.dev.js');
|
|
11
11
|
require('../../../dist/rpcs-f1d24f0e.cjs.dev.js');
|
|
12
12
|
require('zustand/vanilla');
|
|
13
13
|
require('zustand/middleware');
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var base = require('../../../dist/base-
|
|
5
|
+
var base = require('../../../dist/base-797ad073.cjs.prod.js');
|
|
6
6
|
var ethers = require('ethers');
|
|
7
7
|
var utils = require('ethers/lib/utils');
|
|
8
|
-
var client = require('../../../dist/client-
|
|
8
|
+
var client = require('../../../dist/client-a6e61429.cjs.prod.js');
|
|
9
9
|
require('eventemitter3');
|
|
10
|
-
require('../../../dist/chains-
|
|
10
|
+
require('../../../dist/chains-f7bb3211.cjs.prod.js');
|
|
11
11
|
require('../../../dist/rpcs-1fd0a12f.cjs.prod.js');
|
|
12
12
|
require('zustand/vanilla');
|
|
13
13
|
require('zustand/middleware');
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { e as Connector, m as _classPrivateMethodInitSpec, _ as _defineProperty, j as _classPrivateFieldInitSpec, n as normalizeChainId, o as _classPrivateMethodGet, U as UserRejectedRequestError, k as _classPrivateFieldGet, l as _classPrivateFieldSet, i as SwitchChainError } from '../../../dist/base-b565d5d4.esm.js';
|
|
2
2
|
import { providers } from 'ethers';
|
|
3
3
|
import { getAddress, hexValue } from 'ethers/lib/utils';
|
|
4
|
-
import { g as getClient } from '../../../dist/client-
|
|
4
|
+
import { g as getClient } from '../../../dist/client-a05fd511.esm.js';
|
|
5
5
|
import 'eventemitter3';
|
|
6
|
-
import '../../../dist/chains-
|
|
6
|
+
import '../../../dist/chains-fd2c546c.esm.js';
|
|
7
7
|
import '../../../dist/rpcs-b73a8f60.esm.js';
|
|
8
8
|
import 'zustand/vanilla';
|
|
9
9
|
import 'zustand/middleware';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var EventEmitter = require('eventemitter3');
|
|
4
|
-
var chains = require('./chains-
|
|
4
|
+
var chains = require('./chains-f7bb3211.cjs.prod.js');
|
|
5
5
|
|
|
6
6
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
7
7
|
|
|
@@ -211,6 +211,19 @@ class ConnectorNotFoundError extends Error {
|
|
|
211
211
|
_defineProperty(this, "message", 'Connector not found');
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
+
}
|
|
215
|
+
class ContractMethodNoResultError extends Error {
|
|
216
|
+
constructor(_ref3) {
|
|
217
|
+
let {
|
|
218
|
+
addressOrName,
|
|
219
|
+
blockExplorer,
|
|
220
|
+
functionName
|
|
221
|
+
} = _ref3;
|
|
222
|
+
super(["Function \"".concat(functionName, "\" on contract \"").concat(addressOrName, "\" returned an empty response."), '', "Are you sure the function \"".concat(functionName, "\" exists on this contract?"), ...(blockExplorer ? ['', "".concat(blockExplorer === null || blockExplorer === void 0 ? void 0 : blockExplorer.name, ": ").concat(blockExplorer === null || blockExplorer === void 0 ? void 0 : blockExplorer.url, "/address/").concat(addressOrName, "#readContract")] : [])].join('\n'));
|
|
223
|
+
|
|
224
|
+
_defineProperty(this, "name", 'ContractMethodNoResultError');
|
|
225
|
+
}
|
|
226
|
+
|
|
214
227
|
}
|
|
215
228
|
class ProviderChainsNotFound extends Error {
|
|
216
229
|
constructor() {
|
|
@@ -239,10 +252,10 @@ class SwitchChainError extends ProviderRpcError {
|
|
|
239
252
|
|
|
240
253
|
}
|
|
241
254
|
class SwitchChainNotSupportedError extends Error {
|
|
242
|
-
constructor(
|
|
255
|
+
constructor(_ref4) {
|
|
243
256
|
let {
|
|
244
257
|
connector
|
|
245
|
-
} =
|
|
258
|
+
} = _ref4;
|
|
246
259
|
super("\"".concat(connector.name, "\" does not support programmatic chain switching."));
|
|
247
260
|
|
|
248
261
|
_defineProperty(this, "name", 'SwitchChainNotSupportedError');
|
|
@@ -313,6 +326,7 @@ exports.ChainNotConfiguredError = ChainNotConfiguredError;
|
|
|
313
326
|
exports.Connector = Connector;
|
|
314
327
|
exports.ConnectorAlreadyConnectedError = ConnectorAlreadyConnectedError;
|
|
315
328
|
exports.ConnectorNotFoundError = ConnectorNotFoundError;
|
|
329
|
+
exports.ContractMethodNoResultError = ContractMethodNoResultError;
|
|
316
330
|
exports.ProviderChainsNotFound = ProviderChainsNotFound;
|
|
317
331
|
exports.ProviderRpcError = ProviderRpcError;
|
|
318
332
|
exports.ResourceUnavailableError = ResourceUnavailableError;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var EventEmitter = require('eventemitter3');
|
|
4
|
-
var chains = require('./chains-
|
|
4
|
+
var chains = require('./chains-7e6dc59c.cjs.dev.js');
|
|
5
5
|
|
|
6
6
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
7
7
|
|
|
@@ -211,6 +211,19 @@ class ConnectorNotFoundError extends Error {
|
|
|
211
211
|
_defineProperty(this, "message", 'Connector not found');
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
+
}
|
|
215
|
+
class ContractMethodNoResultError extends Error {
|
|
216
|
+
constructor(_ref3) {
|
|
217
|
+
let {
|
|
218
|
+
addressOrName,
|
|
219
|
+
blockExplorer,
|
|
220
|
+
functionName
|
|
221
|
+
} = _ref3;
|
|
222
|
+
super(["Function \"".concat(functionName, "\" on contract \"").concat(addressOrName, "\" returned an empty response."), '', "Are you sure the function \"".concat(functionName, "\" exists on this contract?"), ...(blockExplorer ? ['', "".concat(blockExplorer === null || blockExplorer === void 0 ? void 0 : blockExplorer.name, ": ").concat(blockExplorer === null || blockExplorer === void 0 ? void 0 : blockExplorer.url, "/address/").concat(addressOrName, "#readContract")] : [])].join('\n'));
|
|
223
|
+
|
|
224
|
+
_defineProperty(this, "name", 'ContractMethodNoResultError');
|
|
225
|
+
}
|
|
226
|
+
|
|
214
227
|
}
|
|
215
228
|
class ProviderChainsNotFound extends Error {
|
|
216
229
|
constructor() {
|
|
@@ -239,10 +252,10 @@ class SwitchChainError extends ProviderRpcError {
|
|
|
239
252
|
|
|
240
253
|
}
|
|
241
254
|
class SwitchChainNotSupportedError extends Error {
|
|
242
|
-
constructor(
|
|
255
|
+
constructor(_ref4) {
|
|
243
256
|
let {
|
|
244
257
|
connector
|
|
245
|
-
} =
|
|
258
|
+
} = _ref4;
|
|
246
259
|
super("\"".concat(connector.name, "\" does not support programmatic chain switching."));
|
|
247
260
|
|
|
248
261
|
_defineProperty(this, "name", 'SwitchChainNotSupportedError');
|
|
@@ -313,6 +326,7 @@ exports.ChainNotConfiguredError = ChainNotConfiguredError;
|
|
|
313
326
|
exports.Connector = Connector;
|
|
314
327
|
exports.ConnectorAlreadyConnectedError = ConnectorAlreadyConnectedError;
|
|
315
328
|
exports.ConnectorNotFoundError = ConnectorNotFoundError;
|
|
329
|
+
exports.ContractMethodNoResultError = ContractMethodNoResultError;
|
|
316
330
|
exports.ProviderChainsNotFound = ProviderChainsNotFound;
|
|
317
331
|
exports.ProviderRpcError = ProviderRpcError;
|
|
318
332
|
exports.ResourceUnavailableError = ResourceUnavailableError;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import EventEmitter from 'eventemitter3';
|
|
2
|
-
import { d as defaultChains } from './chains-
|
|
2
|
+
import { d as defaultChains } from './chains-fd2c546c.esm.js';
|
|
3
3
|
|
|
4
4
|
function _checkPrivateRedeclaration(obj, privateCollection) {
|
|
5
5
|
if (privateCollection.has(obj)) {
|
|
@@ -205,6 +205,19 @@ class ConnectorNotFoundError extends Error {
|
|
|
205
205
|
_defineProperty(this, "message", 'Connector not found');
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
+
}
|
|
209
|
+
class ContractMethodNoResultError extends Error {
|
|
210
|
+
constructor(_ref3) {
|
|
211
|
+
let {
|
|
212
|
+
addressOrName,
|
|
213
|
+
blockExplorer,
|
|
214
|
+
functionName
|
|
215
|
+
} = _ref3;
|
|
216
|
+
super(["Function \"".concat(functionName, "\" on contract \"").concat(addressOrName, "\" returned an empty response."), '', "Are you sure the function \"".concat(functionName, "\" exists on this contract?"), ...(blockExplorer ? ['', "".concat(blockExplorer === null || blockExplorer === void 0 ? void 0 : blockExplorer.name, ": ").concat(blockExplorer === null || blockExplorer === void 0 ? void 0 : blockExplorer.url, "/address/").concat(addressOrName, "#readContract")] : [])].join('\n'));
|
|
217
|
+
|
|
218
|
+
_defineProperty(this, "name", 'ContractMethodNoResultError');
|
|
219
|
+
}
|
|
220
|
+
|
|
208
221
|
}
|
|
209
222
|
class ProviderChainsNotFound extends Error {
|
|
210
223
|
constructor() {
|
|
@@ -233,10 +246,10 @@ class SwitchChainError extends ProviderRpcError {
|
|
|
233
246
|
|
|
234
247
|
}
|
|
235
248
|
class SwitchChainNotSupportedError extends Error {
|
|
236
|
-
constructor(
|
|
249
|
+
constructor(_ref4) {
|
|
237
250
|
let {
|
|
238
251
|
connector
|
|
239
|
-
} =
|
|
252
|
+
} = _ref4;
|
|
240
253
|
super("\"".concat(connector.name, "\" does not support programmatic chain switching."));
|
|
241
254
|
|
|
242
255
|
_defineProperty(this, "name", 'SwitchChainNotSupportedError');
|
|
@@ -300,4 +313,4 @@ class Connector extends EventEmitter {
|
|
|
300
313
|
|
|
301
314
|
}
|
|
302
315
|
|
|
303
|
-
export { AddChainError as A, ConnectorAlreadyConnectedError as C, ProviderChainsNotFound as P, ResourceUnavailableError as R, SwitchChainNotSupportedError as S, UserRejectedRequestError as U, _defineProperty as _, ChainDoesNotSupportMulticallError as a,
|
|
316
|
+
export { AddChainError as A, ConnectorAlreadyConnectedError as C, ProviderChainsNotFound as P, ResourceUnavailableError as R, SwitchChainNotSupportedError as S, UserRejectedRequestError as U, _defineProperty as _, ChainDoesNotSupportMulticallError as a, ContractMethodNoResultError as b, ConnectorNotFoundError as c, ChainMismatchError as d, Connector as e, ChainNotConfiguredError as f, ProviderRpcError as g, RpcError as h, SwitchChainError as i, _classPrivateFieldInitSpec as j, _classPrivateFieldGet as k, _classPrivateFieldSet as l, _classPrivateMethodInitSpec as m, normalizeChainId as n, _classPrivateMethodGet as o };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { e as Connector, _ as _defineProperty, j as _classPrivateFieldInitSpec, n as normalizeChainId, k as _classPrivateFieldGet, l as _classPrivateFieldSet, c as ConnectorNotFoundError, U as UserRejectedRequestError, R as ResourceUnavailableError, f as ChainNotConfiguredError, A as AddChainError, i as SwitchChainError, m as _classPrivateMethodInitSpec, o as _classPrivateMethodGet } from './base-b565d5d4.esm.js';
|
|
2
2
|
import create from 'zustand/vanilla';
|
|
3
3
|
import { subscribeWithSelector, persist } from 'zustand/middleware';
|
|
4
4
|
import { providers } from 'ethers';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Connector } from './connectors';
|
|
2
|
+
import { BlockExplorer } from './constants';
|
|
2
3
|
import { Chain } from './types';
|
|
3
4
|
/**
|
|
4
5
|
* Error subclass implementing JSON RPC 2.0 errors and Ethereum RPC errors per EIP-1474.
|
|
@@ -70,6 +71,14 @@ export declare class ConnectorNotFoundError extends Error {
|
|
|
70
71
|
name: string;
|
|
71
72
|
message: string;
|
|
72
73
|
}
|
|
74
|
+
export declare class ContractMethodNoResultError extends Error {
|
|
75
|
+
name: string;
|
|
76
|
+
constructor({ addressOrName, blockExplorer, functionName, }: {
|
|
77
|
+
addressOrName: string;
|
|
78
|
+
blockExplorer?: BlockExplorer;
|
|
79
|
+
functionName: string;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
73
82
|
export declare class ProviderChainsNotFound extends Error {
|
|
74
83
|
name: string;
|
|
75
84
|
message: string;
|
|
@@ -5,9 +5,9 @@ export type { ClientConfig } from './client';
|
|
|
5
5
|
export { Connector, InjectedConnector } from './connectors';
|
|
6
6
|
export type { ConnectorData, ConnectorEvents } from './connectors';
|
|
7
7
|
export { alchemyRpcUrls, allChains, chain, chainId, defaultChains, defaultL2Chains, erc20ABI, erc721ABI, etherscanBlockExplorers, infuraRpcUrls, publicRpcUrls, units, } from './constants';
|
|
8
|
-
export { AddChainError, ChainDoesNotSupportMulticallError, ChainMismatchError, ChainNotConfiguredError, ConnectorAlreadyConnectedError, ConnectorNotFoundError, ProviderChainsNotFound, ProviderRpcError, ResourceUnavailableError, RpcError, SwitchChainError, SwitchChainNotSupportedError, UserRejectedRequestError, } from './errors';
|
|
8
|
+
export { AddChainError, ChainDoesNotSupportMulticallError, ChainMismatchError, ChainNotConfiguredError, ConnectorAlreadyConnectedError, ConnectorNotFoundError, ContractMethodNoResultError, ProviderChainsNotFound, ProviderRpcError, ResourceUnavailableError, RpcError, SwitchChainError, SwitchChainNotSupportedError, UserRejectedRequestError, } from './errors';
|
|
9
9
|
export { createStorage, noopStorage } from './storage';
|
|
10
10
|
export type { ClientStorage as Storage } from './storage';
|
|
11
11
|
export type { Chain, ChainProviderFn, FallbackProviderConfig, ProviderWithFallbackConfig, Provider, Unit, WebSocketProvider, } from './types';
|
|
12
|
-
export { configureChains, normalizeChainId } from './utils';
|
|
12
|
+
export { configureChains, deepEqual, normalizeChainId, parseContractResult, } from './utils';
|
|
13
13
|
export type { ConfigureChainsConfig } from './utils';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { configureChains } from './configureChains';
|
|
2
2
|
export type { ConfigureChainsConfig } from './configureChains';
|
|
3
|
+
export { deepEqual } from './deepEqual';
|
|
3
4
|
export { getInjectedName } from './getInjectedName';
|
|
4
5
|
export { normalizeChainId } from './normalizeChainId';
|
|
6
|
+
export { parseContractResult } from './parseContractResult';
|
|
5
7
|
export { warn } from './warn';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ContractInterface } from 'ethers/lib/ethers';
|
|
2
|
+
import { Result } from 'ethers/lib/utils';
|
|
3
|
+
export declare function parseContractResult({ contractInterface, data, functionName, }: {
|
|
4
|
+
contractInterface: ContractInterface;
|
|
5
|
+
data: Result;
|
|
6
|
+
functionName: string;
|
|
7
|
+
}): any;
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var client = require('./client-
|
|
6
|
-
var base = require('./base-
|
|
5
|
+
var client = require('./client-71ece661.cjs.dev.js');
|
|
6
|
+
var base = require('./base-90b7f3e4.cjs.dev.js');
|
|
7
7
|
var ethers$1 = require('ethers/lib/ethers');
|
|
8
8
|
var utils = require('ethers/lib/utils');
|
|
9
9
|
var ethers = require('ethers');
|
|
10
10
|
var shallow = require('zustand/shallow');
|
|
11
11
|
var rpcs = require('./rpcs-f1d24f0e.cjs.dev.js');
|
|
12
|
-
var chains = require('./chains-
|
|
12
|
+
var chains = require('./chains-7e6dc59c.cjs.dev.js');
|
|
13
13
|
require('zustand/vanilla');
|
|
14
14
|
require('zustand/middleware');
|
|
15
15
|
require('eventemitter3');
|
|
@@ -132,6 +132,70 @@ function fallbackProvider(targetQuorum, minQuorum, providers_, _ref4) {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
/** Forked from https://github.com/epoberezkin/fast-deep-equal */
|
|
136
|
+
function deepEqual(a, b) {
|
|
137
|
+
if (a === b) return true;
|
|
138
|
+
|
|
139
|
+
if (a && b && typeof a === 'object' && typeof b === 'object') {
|
|
140
|
+
if (a.constructor !== b.constructor) return false;
|
|
141
|
+
let length;
|
|
142
|
+
let i;
|
|
143
|
+
|
|
144
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
145
|
+
length = a.length;
|
|
146
|
+
if (length != b.length) return false;
|
|
147
|
+
|
|
148
|
+
for (i = length; i-- !== 0;) if (!deepEqual(a[i], b[i])) return false;
|
|
149
|
+
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
|
|
154
|
+
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
|
|
155
|
+
const keys = Object.keys(a);
|
|
156
|
+
length = keys.length;
|
|
157
|
+
if (length !== Object.keys(b).length) return false;
|
|
158
|
+
|
|
159
|
+
for (i = length; i-- !== 0;) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
160
|
+
|
|
161
|
+
for (i = length; i-- !== 0;) {
|
|
162
|
+
const key = keys[i];
|
|
163
|
+
if (key && !deepEqual(a[key], b[key])) return false;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return true;
|
|
167
|
+
} // true if both NaN, false otherwise
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
return a !== a && b !== b;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function isPlainArray(value) {
|
|
174
|
+
return Array.isArray(value) && Object.keys(value).length === value.length;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function parseContractResult(_ref) {
|
|
178
|
+
let {
|
|
179
|
+
contractInterface,
|
|
180
|
+
data,
|
|
181
|
+
functionName
|
|
182
|
+
} = _ref;
|
|
183
|
+
|
|
184
|
+
if (data && isPlainArray(data)) {
|
|
185
|
+
var _fragment$outputs;
|
|
186
|
+
|
|
187
|
+
const iface = ethers$1.Contract.getInterface(contractInterface);
|
|
188
|
+
const fragment = iface.getFunction(functionName);
|
|
189
|
+
const isTuple = (((_fragment$outputs = fragment.outputs) === null || _fragment$outputs === void 0 ? void 0 : _fragment$outputs.length) || 0) > 1;
|
|
190
|
+
const data_ = isTuple ? data : [data];
|
|
191
|
+
const encodedResult = iface.encodeFunctionResult(functionName, data_);
|
|
192
|
+
const decodedResult = iface.decodeFunctionResult(functionName, encodedResult);
|
|
193
|
+
return isTuple ? decodedResult : decodedResult[0];
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return data;
|
|
197
|
+
}
|
|
198
|
+
|
|
135
199
|
// https://ethereum.org/en/developers/docs/standards/tokens/erc-20
|
|
136
200
|
const erc20ABI = ['event Approval(address indexed _owner, address indexed _spender, uint256 _value)', 'event Transfer(address indexed _from, address indexed _to, uint256 _value)', 'function allowance(address _owner, address _spender) public view returns (uint256 remaining)', 'function approve(address _spender, uint256 _value) public returns (bool success)', 'function balanceOf(address _owner) public view returns (uint256 balance)', 'function decimals() public view returns (uint8)', 'function name() public view returns (string)', 'function symbol() public view returns (string)', 'function totalSupply() public view returns (uint256)', 'function transfer(address _to, uint256 _value) public returns (bool success)', 'function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)']; // https://ethereum.org/en/developers/docs/standards/tokens/erc-721
|
|
137
201
|
|
|
@@ -347,7 +411,7 @@ async function multicall(_ref) {
|
|
|
347
411
|
if (!contract[functionName]) console.warn("\"".concat(functionName, "\" is not in the interface for contract \"").concat(addressOrName, "\""));
|
|
348
412
|
return {
|
|
349
413
|
target: addressOrName,
|
|
350
|
-
allowFailure
|
|
414
|
+
allowFailure,
|
|
351
415
|
callData
|
|
352
416
|
};
|
|
353
417
|
});
|
|
@@ -358,18 +422,38 @@ async function multicall(_ref) {
|
|
|
358
422
|
returnData,
|
|
359
423
|
success
|
|
360
424
|
} = _ref3;
|
|
361
|
-
if (!success) return
|
|
425
|
+
if (!success) return null;
|
|
362
426
|
const {
|
|
363
427
|
addressOrName,
|
|
364
428
|
contractInterface,
|
|
365
429
|
functionName
|
|
366
430
|
} = contracts[i];
|
|
431
|
+
|
|
432
|
+
if (returnData === '0x') {
|
|
433
|
+
var _chain$blockExplorers;
|
|
434
|
+
|
|
435
|
+
const err = new base.ContractMethodNoResultError({
|
|
436
|
+
addressOrName,
|
|
437
|
+
blockExplorer: (_chain$blockExplorers = chain.blockExplorers) === null || _chain$blockExplorers === void 0 ? void 0 : _chain$blockExplorers.default,
|
|
438
|
+
functionName
|
|
439
|
+
});
|
|
440
|
+
if (!allowFailure) throw err;
|
|
441
|
+
console.warn(err.message);
|
|
442
|
+
return null;
|
|
443
|
+
}
|
|
444
|
+
|
|
367
445
|
const contract = getContract({
|
|
368
446
|
addressOrName,
|
|
369
447
|
contractInterface
|
|
370
448
|
});
|
|
371
|
-
|
|
372
|
-
|
|
449
|
+
|
|
450
|
+
try {
|
|
451
|
+
const result = contract.interface.decodeFunctionResult(functionName, returnData);
|
|
452
|
+
return Array.isArray(result) && result.length === 1 ? result[0] : result;
|
|
453
|
+
} catch (err) {
|
|
454
|
+
if (!allowFailure) throw err;
|
|
455
|
+
return null;
|
|
456
|
+
}
|
|
373
457
|
});
|
|
374
458
|
}
|
|
375
459
|
|
|
@@ -415,6 +499,7 @@ async function readContracts(_ref) {
|
|
|
415
499
|
|
|
416
500
|
return (await Promise.all(promises)).flat();
|
|
417
501
|
} catch (err) {
|
|
502
|
+
if (err instanceof base.ContractMethodNoResultError) throw err;
|
|
418
503
|
const promises = contracts.map(contract => readContract({ ...contract,
|
|
419
504
|
overrides
|
|
420
505
|
}));
|
|
@@ -423,7 +508,7 @@ async function readContracts(_ref) {
|
|
|
423
508
|
return (await Promise.allSettled(promises)).map(result => result.status === 'fulfilled' ? result.value : null);
|
|
424
509
|
}
|
|
425
510
|
|
|
426
|
-
return Promise.all(promises);
|
|
511
|
+
return await Promise.all(promises);
|
|
427
512
|
}
|
|
428
513
|
}
|
|
429
514
|
|
|
@@ -1085,6 +1170,7 @@ exports.ChainNotConfiguredError = base.ChainNotConfiguredError;
|
|
|
1085
1170
|
exports.Connector = base.Connector;
|
|
1086
1171
|
exports.ConnectorAlreadyConnectedError = base.ConnectorAlreadyConnectedError;
|
|
1087
1172
|
exports.ConnectorNotFoundError = base.ConnectorNotFoundError;
|
|
1173
|
+
exports.ContractMethodNoResultError = base.ContractMethodNoResultError;
|
|
1088
1174
|
exports.ProviderChainsNotFound = base.ProviderChainsNotFound;
|
|
1089
1175
|
exports.ProviderRpcError = base.ProviderRpcError;
|
|
1090
1176
|
exports.ResourceUnavailableError = base.ResourceUnavailableError;
|
|
@@ -1104,6 +1190,7 @@ exports.defaultL2Chains = chains.defaultL2Chains;
|
|
|
1104
1190
|
exports.etherscanBlockExplorers = chains.etherscanBlockExplorers;
|
|
1105
1191
|
exports.configureChains = configureChains;
|
|
1106
1192
|
exports.connect = connect;
|
|
1193
|
+
exports.deepEqual = deepEqual;
|
|
1107
1194
|
exports.disconnect = disconnect;
|
|
1108
1195
|
exports.erc20ABI = erc20ABI;
|
|
1109
1196
|
exports.erc721ABI = erc721ABI;
|
|
@@ -1121,6 +1208,7 @@ exports.getContract = getContract;
|
|
|
1121
1208
|
exports.getNetwork = getNetwork;
|
|
1122
1209
|
exports.getProvider = getProvider;
|
|
1123
1210
|
exports.getWebSocketProvider = getWebSocketProvider;
|
|
1211
|
+
exports.parseContractResult = parseContractResult;
|
|
1124
1212
|
exports.readContract = readContract;
|
|
1125
1213
|
exports.readContracts = readContracts;
|
|
1126
1214
|
exports.sendTransaction = sendTransaction;
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var client = require('./client-
|
|
6
|
-
var base = require('./base-
|
|
5
|
+
var client = require('./client-a6e61429.cjs.prod.js');
|
|
6
|
+
var base = require('./base-797ad073.cjs.prod.js');
|
|
7
7
|
var ethers$1 = require('ethers/lib/ethers');
|
|
8
8
|
var utils = require('ethers/lib/utils');
|
|
9
9
|
var ethers = require('ethers');
|
|
10
10
|
var shallow = require('zustand/shallow');
|
|
11
11
|
var rpcs = require('./rpcs-1fd0a12f.cjs.prod.js');
|
|
12
|
-
var chains = require('./chains-
|
|
12
|
+
var chains = require('./chains-f7bb3211.cjs.prod.js');
|
|
13
13
|
require('zustand/vanilla');
|
|
14
14
|
require('zustand/middleware');
|
|
15
15
|
require('eventemitter3');
|
|
@@ -132,6 +132,70 @@ function fallbackProvider(targetQuorum, minQuorum, providers_, _ref4) {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
/** Forked from https://github.com/epoberezkin/fast-deep-equal */
|
|
136
|
+
function deepEqual(a, b) {
|
|
137
|
+
if (a === b) return true;
|
|
138
|
+
|
|
139
|
+
if (a && b && typeof a === 'object' && typeof b === 'object') {
|
|
140
|
+
if (a.constructor !== b.constructor) return false;
|
|
141
|
+
let length;
|
|
142
|
+
let i;
|
|
143
|
+
|
|
144
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
145
|
+
length = a.length;
|
|
146
|
+
if (length != b.length) return false;
|
|
147
|
+
|
|
148
|
+
for (i = length; i-- !== 0;) if (!deepEqual(a[i], b[i])) return false;
|
|
149
|
+
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
|
|
154
|
+
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
|
|
155
|
+
const keys = Object.keys(a);
|
|
156
|
+
length = keys.length;
|
|
157
|
+
if (length !== Object.keys(b).length) return false;
|
|
158
|
+
|
|
159
|
+
for (i = length; i-- !== 0;) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
160
|
+
|
|
161
|
+
for (i = length; i-- !== 0;) {
|
|
162
|
+
const key = keys[i];
|
|
163
|
+
if (key && !deepEqual(a[key], b[key])) return false;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return true;
|
|
167
|
+
} // true if both NaN, false otherwise
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
return a !== a && b !== b;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function isPlainArray(value) {
|
|
174
|
+
return Array.isArray(value) && Object.keys(value).length === value.length;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function parseContractResult(_ref) {
|
|
178
|
+
let {
|
|
179
|
+
contractInterface,
|
|
180
|
+
data,
|
|
181
|
+
functionName
|
|
182
|
+
} = _ref;
|
|
183
|
+
|
|
184
|
+
if (data && isPlainArray(data)) {
|
|
185
|
+
var _fragment$outputs;
|
|
186
|
+
|
|
187
|
+
const iface = ethers$1.Contract.getInterface(contractInterface);
|
|
188
|
+
const fragment = iface.getFunction(functionName);
|
|
189
|
+
const isTuple = (((_fragment$outputs = fragment.outputs) === null || _fragment$outputs === void 0 ? void 0 : _fragment$outputs.length) || 0) > 1;
|
|
190
|
+
const data_ = isTuple ? data : [data];
|
|
191
|
+
const encodedResult = iface.encodeFunctionResult(functionName, data_);
|
|
192
|
+
const decodedResult = iface.decodeFunctionResult(functionName, encodedResult);
|
|
193
|
+
return isTuple ? decodedResult : decodedResult[0];
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return data;
|
|
197
|
+
}
|
|
198
|
+
|
|
135
199
|
// https://ethereum.org/en/developers/docs/standards/tokens/erc-20
|
|
136
200
|
const erc20ABI = ['event Approval(address indexed _owner, address indexed _spender, uint256 _value)', 'event Transfer(address indexed _from, address indexed _to, uint256 _value)', 'function allowance(address _owner, address _spender) public view returns (uint256 remaining)', 'function approve(address _spender, uint256 _value) public returns (bool success)', 'function balanceOf(address _owner) public view returns (uint256 balance)', 'function decimals() public view returns (uint8)', 'function name() public view returns (string)', 'function symbol() public view returns (string)', 'function totalSupply() public view returns (uint256)', 'function transfer(address _to, uint256 _value) public returns (bool success)', 'function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)']; // https://ethereum.org/en/developers/docs/standards/tokens/erc-721
|
|
137
201
|
|
|
@@ -347,7 +411,7 @@ async function multicall(_ref) {
|
|
|
347
411
|
if (!contract[functionName]) console.warn("\"".concat(functionName, "\" is not in the interface for contract \"").concat(addressOrName, "\""));
|
|
348
412
|
return {
|
|
349
413
|
target: addressOrName,
|
|
350
|
-
allowFailure
|
|
414
|
+
allowFailure,
|
|
351
415
|
callData
|
|
352
416
|
};
|
|
353
417
|
});
|
|
@@ -358,18 +422,38 @@ async function multicall(_ref) {
|
|
|
358
422
|
returnData,
|
|
359
423
|
success
|
|
360
424
|
} = _ref3;
|
|
361
|
-
if (!success) return
|
|
425
|
+
if (!success) return null;
|
|
362
426
|
const {
|
|
363
427
|
addressOrName,
|
|
364
428
|
contractInterface,
|
|
365
429
|
functionName
|
|
366
430
|
} = contracts[i];
|
|
431
|
+
|
|
432
|
+
if (returnData === '0x') {
|
|
433
|
+
var _chain$blockExplorers;
|
|
434
|
+
|
|
435
|
+
const err = new base.ContractMethodNoResultError({
|
|
436
|
+
addressOrName,
|
|
437
|
+
blockExplorer: (_chain$blockExplorers = chain.blockExplorers) === null || _chain$blockExplorers === void 0 ? void 0 : _chain$blockExplorers.default,
|
|
438
|
+
functionName
|
|
439
|
+
});
|
|
440
|
+
if (!allowFailure) throw err;
|
|
441
|
+
console.warn(err.message);
|
|
442
|
+
return null;
|
|
443
|
+
}
|
|
444
|
+
|
|
367
445
|
const contract = getContract({
|
|
368
446
|
addressOrName,
|
|
369
447
|
contractInterface
|
|
370
448
|
});
|
|
371
|
-
|
|
372
|
-
|
|
449
|
+
|
|
450
|
+
try {
|
|
451
|
+
const result = contract.interface.decodeFunctionResult(functionName, returnData);
|
|
452
|
+
return Array.isArray(result) && result.length === 1 ? result[0] : result;
|
|
453
|
+
} catch (err) {
|
|
454
|
+
if (!allowFailure) throw err;
|
|
455
|
+
return null;
|
|
456
|
+
}
|
|
373
457
|
});
|
|
374
458
|
}
|
|
375
459
|
|
|
@@ -415,6 +499,7 @@ async function readContracts(_ref) {
|
|
|
415
499
|
|
|
416
500
|
return (await Promise.all(promises)).flat();
|
|
417
501
|
} catch (err) {
|
|
502
|
+
if (err instanceof base.ContractMethodNoResultError) throw err;
|
|
418
503
|
const promises = contracts.map(contract => readContract({ ...contract,
|
|
419
504
|
overrides
|
|
420
505
|
}));
|
|
@@ -423,7 +508,7 @@ async function readContracts(_ref) {
|
|
|
423
508
|
return (await Promise.allSettled(promises)).map(result => result.status === 'fulfilled' ? result.value : null);
|
|
424
509
|
}
|
|
425
510
|
|
|
426
|
-
return Promise.all(promises);
|
|
511
|
+
return await Promise.all(promises);
|
|
427
512
|
}
|
|
428
513
|
}
|
|
429
514
|
|
|
@@ -1085,6 +1170,7 @@ exports.ChainNotConfiguredError = base.ChainNotConfiguredError;
|
|
|
1085
1170
|
exports.Connector = base.Connector;
|
|
1086
1171
|
exports.ConnectorAlreadyConnectedError = base.ConnectorAlreadyConnectedError;
|
|
1087
1172
|
exports.ConnectorNotFoundError = base.ConnectorNotFoundError;
|
|
1173
|
+
exports.ContractMethodNoResultError = base.ContractMethodNoResultError;
|
|
1088
1174
|
exports.ProviderChainsNotFound = base.ProviderChainsNotFound;
|
|
1089
1175
|
exports.ProviderRpcError = base.ProviderRpcError;
|
|
1090
1176
|
exports.ResourceUnavailableError = base.ResourceUnavailableError;
|
|
@@ -1104,6 +1190,7 @@ exports.defaultL2Chains = chains.defaultL2Chains;
|
|
|
1104
1190
|
exports.etherscanBlockExplorers = chains.etherscanBlockExplorers;
|
|
1105
1191
|
exports.configureChains = configureChains;
|
|
1106
1192
|
exports.connect = connect;
|
|
1193
|
+
exports.deepEqual = deepEqual;
|
|
1107
1194
|
exports.disconnect = disconnect;
|
|
1108
1195
|
exports.erc20ABI = erc20ABI;
|
|
1109
1196
|
exports.erc721ABI = erc721ABI;
|
|
@@ -1121,6 +1208,7 @@ exports.getContract = getContract;
|
|
|
1121
1208
|
exports.getNetwork = getNetwork;
|
|
1122
1209
|
exports.getProvider = getProvider;
|
|
1123
1210
|
exports.getWebSocketProvider = getWebSocketProvider;
|
|
1211
|
+
exports.parseContractResult = parseContractResult;
|
|
1124
1212
|
exports.readContract = readContract;
|
|
1125
1213
|
exports.readContracts = readContracts;
|
|
1126
1214
|
exports.sendTransaction = sendTransaction;
|
package/dist/wagmi-core.esm.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { g as getClient } from './client-
|
|
2
|
-
export { C as Client, I as InjectedConnector, c as createClient, a as createStorage, n as noopStorage } from './client-
|
|
3
|
-
import { C as ConnectorAlreadyConnectedError, P as ProviderChainsNotFound, a as ChainDoesNotSupportMulticallError, b as
|
|
4
|
-
export { A as AddChainError, a as ChainDoesNotSupportMulticallError,
|
|
5
|
-
import {
|
|
1
|
+
import { g as getClient } from './client-a05fd511.esm.js';
|
|
2
|
+
export { C as Client, I as InjectedConnector, c as createClient, a as createStorage, n as noopStorage } from './client-a05fd511.esm.js';
|
|
3
|
+
import { C as ConnectorAlreadyConnectedError, P as ProviderChainsNotFound, a as ChainDoesNotSupportMulticallError, b as ContractMethodNoResultError, c as ConnectorNotFoundError, d as ChainMismatchError, U as UserRejectedRequestError, n as normalizeChainId, S as SwitchChainNotSupportedError } from './base-b565d5d4.esm.js';
|
|
4
|
+
export { A as AddChainError, a as ChainDoesNotSupportMulticallError, d as ChainMismatchError, f as ChainNotConfiguredError, e as Connector, C as ConnectorAlreadyConnectedError, c as ConnectorNotFoundError, b as ContractMethodNoResultError, P as ProviderChainsNotFound, g as ProviderRpcError, R as ResourceUnavailableError, h as RpcError, i as SwitchChainError, S as SwitchChainNotSupportedError, U as UserRejectedRequestError, n as normalizeChainId } from './base-b565d5d4.esm.js';
|
|
5
|
+
import { Contract, logger } from 'ethers/lib/ethers';
|
|
6
6
|
import { isAddress, Logger, formatUnits, getAddress } from 'ethers/lib/utils';
|
|
7
|
-
import { providers, Contract } from 'ethers';
|
|
7
|
+
import { providers, Contract as Contract$1 } from 'ethers';
|
|
8
8
|
import shallow from 'zustand/shallow';
|
|
9
9
|
export { a as alchemyRpcUrls, i as infuraRpcUrls, p as publicRpcUrls } from './rpcs-b73a8f60.esm.js';
|
|
10
|
-
export { a as allChains, c as chain, b as chainId, d as defaultChains, e as defaultL2Chains, f as etherscanBlockExplorers } from './chains-
|
|
10
|
+
export { a as allChains, c as chain, b as chainId, d as defaultChains, e as defaultL2Chains, f as etherscanBlockExplorers } from './chains-fd2c546c.esm.js';
|
|
11
11
|
import 'zustand/vanilla';
|
|
12
12
|
import 'zustand/middleware';
|
|
13
13
|
import 'eventemitter3';
|
|
@@ -126,6 +126,70 @@ function fallbackProvider(targetQuorum, minQuorum, providers_, _ref4) {
|
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
/** Forked from https://github.com/epoberezkin/fast-deep-equal */
|
|
130
|
+
function deepEqual(a, b) {
|
|
131
|
+
if (a === b) return true;
|
|
132
|
+
|
|
133
|
+
if (a && b && typeof a === 'object' && typeof b === 'object') {
|
|
134
|
+
if (a.constructor !== b.constructor) return false;
|
|
135
|
+
let length;
|
|
136
|
+
let i;
|
|
137
|
+
|
|
138
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
139
|
+
length = a.length;
|
|
140
|
+
if (length != b.length) return false;
|
|
141
|
+
|
|
142
|
+
for (i = length; i-- !== 0;) if (!deepEqual(a[i], b[i])) return false;
|
|
143
|
+
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
|
|
148
|
+
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
|
|
149
|
+
const keys = Object.keys(a);
|
|
150
|
+
length = keys.length;
|
|
151
|
+
if (length !== Object.keys(b).length) return false;
|
|
152
|
+
|
|
153
|
+
for (i = length; i-- !== 0;) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
154
|
+
|
|
155
|
+
for (i = length; i-- !== 0;) {
|
|
156
|
+
const key = keys[i];
|
|
157
|
+
if (key && !deepEqual(a[key], b[key])) return false;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return true;
|
|
161
|
+
} // true if both NaN, false otherwise
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
return a !== a && b !== b;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function isPlainArray(value) {
|
|
168
|
+
return Array.isArray(value) && Object.keys(value).length === value.length;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function parseContractResult(_ref) {
|
|
172
|
+
let {
|
|
173
|
+
contractInterface,
|
|
174
|
+
data,
|
|
175
|
+
functionName
|
|
176
|
+
} = _ref;
|
|
177
|
+
|
|
178
|
+
if (data && isPlainArray(data)) {
|
|
179
|
+
var _fragment$outputs;
|
|
180
|
+
|
|
181
|
+
const iface = Contract.getInterface(contractInterface);
|
|
182
|
+
const fragment = iface.getFunction(functionName);
|
|
183
|
+
const isTuple = (((_fragment$outputs = fragment.outputs) === null || _fragment$outputs === void 0 ? void 0 : _fragment$outputs.length) || 0) > 1;
|
|
184
|
+
const data_ = isTuple ? data : [data];
|
|
185
|
+
const encodedResult = iface.encodeFunctionResult(functionName, data_);
|
|
186
|
+
const decodedResult = iface.decodeFunctionResult(functionName, encodedResult);
|
|
187
|
+
return isTuple ? decodedResult : decodedResult[0];
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return data;
|
|
191
|
+
}
|
|
192
|
+
|
|
129
193
|
// https://ethereum.org/en/developers/docs/standards/tokens/erc-20
|
|
130
194
|
const erc20ABI = ['event Approval(address indexed _owner, address indexed _spender, uint256 _value)', 'event Transfer(address indexed _from, address indexed _to, uint256 _value)', 'function allowance(address _owner, address _spender) public view returns (uint256 remaining)', 'function approve(address _spender, uint256 _value) public returns (bool success)', 'function balanceOf(address _owner) public view returns (uint256 balance)', 'function decimals() public view returns (uint8)', 'function name() public view returns (string)', 'function symbol() public view returns (string)', 'function totalSupply() public view returns (uint256)', 'function transfer(address _to, uint256 _value) public returns (bool success)', 'function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)']; // https://ethereum.org/en/developers/docs/standards/tokens/erc-721
|
|
131
195
|
|
|
@@ -220,7 +284,7 @@ function getContract(_ref) {
|
|
|
220
284
|
contractInterface,
|
|
221
285
|
signerOrProvider
|
|
222
286
|
} = _ref;
|
|
223
|
-
return new Contract(addressOrName, contractInterface, signerOrProvider);
|
|
287
|
+
return new Contract$1(addressOrName, contractInterface, signerOrProvider);
|
|
224
288
|
}
|
|
225
289
|
|
|
226
290
|
function getProvider() {
|
|
@@ -341,7 +405,7 @@ async function multicall(_ref) {
|
|
|
341
405
|
if (!contract[functionName]) console.warn("\"".concat(functionName, "\" is not in the interface for contract \"").concat(addressOrName, "\""));
|
|
342
406
|
return {
|
|
343
407
|
target: addressOrName,
|
|
344
|
-
allowFailure
|
|
408
|
+
allowFailure,
|
|
345
409
|
callData
|
|
346
410
|
};
|
|
347
411
|
});
|
|
@@ -352,18 +416,38 @@ async function multicall(_ref) {
|
|
|
352
416
|
returnData,
|
|
353
417
|
success
|
|
354
418
|
} = _ref3;
|
|
355
|
-
if (!success) return
|
|
419
|
+
if (!success) return null;
|
|
356
420
|
const {
|
|
357
421
|
addressOrName,
|
|
358
422
|
contractInterface,
|
|
359
423
|
functionName
|
|
360
424
|
} = contracts[i];
|
|
425
|
+
|
|
426
|
+
if (returnData === '0x') {
|
|
427
|
+
var _chain$blockExplorers;
|
|
428
|
+
|
|
429
|
+
const err = new ContractMethodNoResultError({
|
|
430
|
+
addressOrName,
|
|
431
|
+
blockExplorer: (_chain$blockExplorers = chain.blockExplorers) === null || _chain$blockExplorers === void 0 ? void 0 : _chain$blockExplorers.default,
|
|
432
|
+
functionName
|
|
433
|
+
});
|
|
434
|
+
if (!allowFailure) throw err;
|
|
435
|
+
console.warn(err.message);
|
|
436
|
+
return null;
|
|
437
|
+
}
|
|
438
|
+
|
|
361
439
|
const contract = getContract({
|
|
362
440
|
addressOrName,
|
|
363
441
|
contractInterface
|
|
364
442
|
});
|
|
365
|
-
|
|
366
|
-
|
|
443
|
+
|
|
444
|
+
try {
|
|
445
|
+
const result = contract.interface.decodeFunctionResult(functionName, returnData);
|
|
446
|
+
return Array.isArray(result) && result.length === 1 ? result[0] : result;
|
|
447
|
+
} catch (err) {
|
|
448
|
+
if (!allowFailure) throw err;
|
|
449
|
+
return null;
|
|
450
|
+
}
|
|
367
451
|
});
|
|
368
452
|
}
|
|
369
453
|
|
|
@@ -409,6 +493,7 @@ async function readContracts(_ref) {
|
|
|
409
493
|
|
|
410
494
|
return (await Promise.all(promises)).flat();
|
|
411
495
|
} catch (err) {
|
|
496
|
+
if (err instanceof ContractMethodNoResultError) throw err;
|
|
412
497
|
const promises = contracts.map(contract => readContract({ ...contract,
|
|
413
498
|
overrides
|
|
414
499
|
}));
|
|
@@ -417,7 +502,7 @@ async function readContracts(_ref) {
|
|
|
417
502
|
return (await Promise.allSettled(promises)).map(result => result.status === 'fulfilled' ? result.value : null);
|
|
418
503
|
}
|
|
419
504
|
|
|
420
|
-
return Promise.all(promises);
|
|
505
|
+
return await Promise.all(promises);
|
|
421
506
|
}
|
|
422
507
|
}
|
|
423
508
|
|
|
@@ -995,7 +1080,7 @@ async function fetchToken(_ref) {
|
|
|
995
1080
|
const provider = getProvider({
|
|
996
1081
|
chainId
|
|
997
1082
|
});
|
|
998
|
-
const contract = new Contract
|
|
1083
|
+
const contract = new Contract(address, erc20ABI, provider);
|
|
999
1084
|
const [symbol, decimals, totalSupply] = await Promise.all([contract.symbol(), contract.decimals(), contract.totalSupply()]);
|
|
1000
1085
|
const token = {
|
|
1001
1086
|
address,
|
|
@@ -1067,4 +1152,4 @@ async function waitForTransaction(_ref) {
|
|
|
1067
1152
|
return await promise;
|
|
1068
1153
|
}
|
|
1069
1154
|
|
|
1070
|
-
export { configureChains, connect, disconnect, erc20ABI, erc721ABI, fetchBalance, fetchBlockNumber, fetchEnsAddress, fetchEnsAvatar, fetchEnsName, fetchEnsResolver, fetchFeeData, fetchSigner, fetchToken, getAccount, getContract, getNetwork, getProvider, getWebSocketProvider, readContract, readContracts, sendTransaction, signMessage, signTypedData, switchNetwork, units, waitForTransaction, watchAccount, watchBlockNumber, watchContractEvent, watchNetwork, watchProvider, watchReadContract, watchReadContracts, watchSigner, watchWebSocketProvider, writeContract };
|
|
1155
|
+
export { configureChains, connect, deepEqual, disconnect, erc20ABI, erc721ABI, fetchBalance, fetchBlockNumber, fetchEnsAddress, fetchEnsAvatar, fetchEnsName, fetchEnsResolver, fetchFeeData, fetchSigner, fetchToken, getAccount, getContract, getNetwork, getProvider, getWebSocketProvider, parseContractResult, readContract, readContracts, sendTransaction, signMessage, signTypedData, switchNetwork, units, waitForTransaction, watchAccount, watchBlockNumber, watchContractEvent, watchNetwork, watchProvider, watchReadContract, watchReadContracts, watchSigner, watchWebSocketProvider, writeContract };
|