@wagmi/core 0.6.9 → 0.6.11
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/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.dev.js +5 -2
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.prod.js +5 -2
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.esm.js +5 -2
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.dev.js +1 -1
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.prod.js +1 -1
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.esm.js +1 -1
- package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.dev.js +1 -1
- package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.prod.js +1 -1
- package/connectors/mock/dist/wagmi-core-connectors-mock.esm.js +1 -1
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.dev.js +1 -1
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.prod.js +1 -1
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.esm.js +1 -1
- package/dist/declarations/src/connectors/base.d.ts +1 -1
- package/dist/declarations/src/errors.d.ts +4 -1
- package/dist/declarations/src/utils/assertActiveChain.d.ts +3 -1
- package/dist/{getProvider-f27715b1.cjs.dev.js → getProvider-58ea0031.cjs.dev.js} +22 -18
- package/dist/{getProvider-b247fc37.cjs.prod.js → getProvider-922d7937.cjs.prod.js} +22 -18
- package/dist/{getProvider-cad59e6c.esm.js → getProvider-b69e06ef.esm.js} +23 -19
- package/dist/wagmi-core.cjs.dev.js +30 -8
- package/dist/wagmi-core.cjs.prod.js +30 -8
- package/dist/wagmi-core.esm.js +31 -9
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var getProvider = require('../../../dist/getProvider-
|
|
5
|
+
var getProvider = require('../../../dist/getProvider-58ea0031.cjs.dev.js');
|
|
6
6
|
var ethers = require('ethers');
|
|
7
7
|
var utils = require('ethers/lib/utils');
|
|
8
8
|
require('zustand/middleware');
|
|
@@ -214,7 +214,10 @@ class CoinbaseWalletConnector extends getProvider.Connector {
|
|
|
214
214
|
};
|
|
215
215
|
} catch (error) {
|
|
216
216
|
const chain = this.chains.find(x => x.id === chainId);
|
|
217
|
-
if (!chain) throw new getProvider.ChainNotConfiguredError(
|
|
217
|
+
if (!chain) throw new getProvider.ChainNotConfiguredError({
|
|
218
|
+
chainId,
|
|
219
|
+
connectorId: this.id
|
|
220
|
+
}); // Indicates chain is not added to provider
|
|
218
221
|
|
|
219
222
|
if (error.code === 4902) {
|
|
220
223
|
try {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var getProvider = require('../../../dist/getProvider-
|
|
5
|
+
var getProvider = require('../../../dist/getProvider-922d7937.cjs.prod.js');
|
|
6
6
|
var ethers = require('ethers');
|
|
7
7
|
var utils = require('ethers/lib/utils');
|
|
8
8
|
require('zustand/middleware');
|
|
@@ -214,7 +214,10 @@ class CoinbaseWalletConnector extends getProvider.Connector {
|
|
|
214
214
|
};
|
|
215
215
|
} catch (error) {
|
|
216
216
|
const chain = this.chains.find(x => x.id === chainId);
|
|
217
|
-
if (!chain) throw new getProvider.ChainNotConfiguredError(
|
|
217
|
+
if (!chain) throw new getProvider.ChainNotConfiguredError({
|
|
218
|
+
chainId,
|
|
219
|
+
connectorId: this.id
|
|
220
|
+
}); // Indicates chain is not added to provider
|
|
218
221
|
|
|
219
222
|
if (error.code === 4902) {
|
|
220
223
|
try {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { m as Connector, _ as _classPrivateMethodInitSpec, t as _defineProperty, v as _classPrivateFieldInitSpec, n as normalizeChainId, U as UserRejectedRequestError, x as _classPrivateFieldGet, w as _classPrivateFieldSet, a as ChainNotConfiguredError, u as _classPrivateMethodGet, A as AddChainError, q as SwitchChainError } from '../../../dist/getProvider-b69e06ef.esm.js';
|
|
2
2
|
import { providers } from 'ethers';
|
|
3
3
|
import { getAddress, hexValue } from 'ethers/lib/utils';
|
|
4
4
|
import 'zustand/middleware';
|
|
@@ -192,7 +192,10 @@ class CoinbaseWalletConnector extends Connector {
|
|
|
192
192
|
};
|
|
193
193
|
} catch (error) {
|
|
194
194
|
const chain = this.chains.find(x => x.id === chainId);
|
|
195
|
-
if (!chain) throw new ChainNotConfiguredError(
|
|
195
|
+
if (!chain) throw new ChainNotConfiguredError({
|
|
196
|
+
chainId,
|
|
197
|
+
connectorId: this.id
|
|
198
|
+
}); // Indicates chain is not added to provider
|
|
196
199
|
|
|
197
200
|
if (error.code === 4902) {
|
|
198
201
|
try {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var getProvider = require('../../../dist/getProvider-
|
|
5
|
+
var getProvider = require('../../../dist/getProvider-58ea0031.cjs.dev.js');
|
|
6
6
|
require('zustand/middleware');
|
|
7
7
|
require('zustand/vanilla');
|
|
8
8
|
require('ethers');
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var getProvider = require('../../../dist/getProvider-
|
|
5
|
+
var getProvider = require('../../../dist/getProvider-922d7937.cjs.prod.js');
|
|
6
6
|
require('zustand/middleware');
|
|
7
7
|
require('zustand/vanilla');
|
|
8
8
|
require('ethers');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as InjectedConnector, _ as _classPrivateMethodInitSpec, t as _defineProperty, u as _classPrivateMethodGet, v as _classPrivateFieldInitSpec, w as _classPrivateFieldSet,
|
|
1
|
+
import { I as InjectedConnector, _ as _classPrivateMethodInitSpec, t as _defineProperty, u as _classPrivateMethodGet, v as _classPrivateFieldInitSpec, w as _classPrivateFieldSet, d as ConnectorNotFoundError, x as _classPrivateFieldGet, g as getClient, U as UserRejectedRequestError, R as ResourceUnavailableError } from '../../../dist/getProvider-b69e06ef.esm.js';
|
|
2
2
|
import 'zustand/middleware';
|
|
3
3
|
import 'zustand/vanilla';
|
|
4
4
|
import 'ethers';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var getProvider = require('../../../dist/getProvider-
|
|
5
|
+
var getProvider = require('../../../dist/getProvider-58ea0031.cjs.dev.js');
|
|
6
6
|
var utils = require('ethers/lib/utils');
|
|
7
7
|
var ethers = require('ethers');
|
|
8
8
|
var EventEmitter = require('eventemitter3');
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var getProvider = require('../../../dist/getProvider-
|
|
5
|
+
var getProvider = require('../../../dist/getProvider-922d7937.cjs.prod.js');
|
|
6
6
|
var utils = require('ethers/lib/utils');
|
|
7
7
|
var ethers = require('ethers');
|
|
8
8
|
var EventEmitter = require('eventemitter3');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as _defineProperty, v as _classPrivateFieldInitSpec, w as _classPrivateFieldSet, x as _classPrivateFieldGet, U as UserRejectedRequestError,
|
|
1
|
+
import { t as _defineProperty, v as _classPrivateFieldInitSpec, w as _classPrivateFieldSet, x as _classPrivateFieldGet, U as UserRejectedRequestError, m as Connector, _ as _classPrivateMethodInitSpec, n as normalizeChainId, u as _classPrivateMethodGet } from '../../../dist/getProvider-b69e06ef.esm.js';
|
|
2
2
|
import { getAddress } from 'ethers/lib/utils';
|
|
3
3
|
import { providers } from 'ethers';
|
|
4
4
|
import EventEmitter from 'eventemitter3';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var getProvider = require('../../../dist/getProvider-
|
|
5
|
+
var getProvider = require('../../../dist/getProvider-58ea0031.cjs.dev.js');
|
|
6
6
|
var ethers = require('ethers');
|
|
7
7
|
var utils = require('ethers/lib/utils');
|
|
8
8
|
require('zustand/middleware');
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var getProvider = require('../../../dist/getProvider-
|
|
5
|
+
var getProvider = require('../../../dist/getProvider-922d7937.cjs.prod.js');
|
|
6
6
|
var ethers = require('ethers');
|
|
7
7
|
var utils = require('ethers/lib/utils');
|
|
8
8
|
require('zustand/middleware');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { m as Connector, _ as _classPrivateMethodInitSpec, t as _defineProperty, v as _classPrivateFieldInitSpec, n as normalizeChainId, g as getClient, u as _classPrivateMethodGet, U as UserRejectedRequestError, x as _classPrivateFieldGet, w as _classPrivateFieldSet, q as SwitchChainError } from '../../../dist/getProvider-b69e06ef.esm.js';
|
|
2
2
|
import { providers } from 'ethers';
|
|
3
3
|
import { getAddress, hexValue } from 'ethers/lib/utils';
|
|
4
4
|
import 'zustand/middleware';
|
|
@@ -57,6 +57,6 @@ export declare abstract class Connector<Provider = any, Options = any, Signer =
|
|
|
57
57
|
protected abstract onAccountsChanged(accounts: Address[]): void;
|
|
58
58
|
protected abstract onChainChanged(chain: number | string): void;
|
|
59
59
|
protected abstract onDisconnect(error: Error): void;
|
|
60
|
-
protected getBlockExplorerUrls(chain: Chain): string[];
|
|
60
|
+
protected getBlockExplorerUrls(chain: Chain): string[] | undefined;
|
|
61
61
|
protected isChainUnsupported(chainId: number): boolean;
|
|
62
62
|
}
|
|
@@ -60,7 +60,10 @@ export declare class ChainMismatchError extends Error {
|
|
|
60
60
|
}
|
|
61
61
|
export declare class ChainNotConfiguredError extends Error {
|
|
62
62
|
name: string;
|
|
63
|
-
|
|
63
|
+
constructor({ chainId, connectorId, }: {
|
|
64
|
+
chainId: number;
|
|
65
|
+
connectorId: string;
|
|
66
|
+
});
|
|
64
67
|
}
|
|
65
68
|
export declare class ConnectorAlreadyConnectedError extends Error {
|
|
66
69
|
name: string;
|
|
@@ -182,12 +182,14 @@ class ChainMismatchError extends Error {
|
|
|
182
182
|
|
|
183
183
|
}
|
|
184
184
|
class ChainNotConfiguredError extends Error {
|
|
185
|
-
constructor() {
|
|
186
|
-
|
|
185
|
+
constructor(_ref3) {
|
|
186
|
+
let {
|
|
187
|
+
chainId,
|
|
188
|
+
connectorId
|
|
189
|
+
} = _ref3;
|
|
190
|
+
super(`Chain "${chainId}" not configured for connector "${connectorId}".`);
|
|
187
191
|
|
|
188
192
|
_defineProperty(this, "name", 'ChainNotConfigured');
|
|
189
|
-
|
|
190
|
-
_defineProperty(this, "message", 'Chain not configured');
|
|
191
193
|
}
|
|
192
194
|
|
|
193
195
|
}
|
|
@@ -212,22 +214,22 @@ class ConnectorNotFoundError extends Error {
|
|
|
212
214
|
|
|
213
215
|
}
|
|
214
216
|
class ContractMethodDoesNotExistError extends Error {
|
|
215
|
-
constructor(
|
|
217
|
+
constructor(_ref4) {
|
|
216
218
|
var _chain$blockExplorers;
|
|
217
219
|
|
|
218
220
|
let {
|
|
219
221
|
address,
|
|
220
222
|
chainId,
|
|
221
223
|
functionName
|
|
222
|
-
} =
|
|
224
|
+
} = _ref4;
|
|
223
225
|
const {
|
|
224
226
|
chains,
|
|
225
227
|
network
|
|
226
228
|
} = getProvider();
|
|
227
|
-
const chain = chains === null || chains === void 0 ? void 0 : chains.find(
|
|
229
|
+
const chain = chains === null || chains === void 0 ? void 0 : chains.find(_ref5 => {
|
|
228
230
|
let {
|
|
229
231
|
id
|
|
230
|
-
} =
|
|
232
|
+
} = _ref5;
|
|
231
233
|
return id === (chainId || network.chainId);
|
|
232
234
|
});
|
|
233
235
|
const blockExplorer = chain === null || chain === void 0 ? void 0 : (_chain$blockExplorers = chain.blockExplorers) === null || _chain$blockExplorers === void 0 ? void 0 : _chain$blockExplorers.default;
|
|
@@ -238,13 +240,13 @@ class ContractMethodDoesNotExistError extends Error {
|
|
|
238
240
|
|
|
239
241
|
}
|
|
240
242
|
class ContractMethodNoResultError extends Error {
|
|
241
|
-
constructor(
|
|
243
|
+
constructor(_ref6) {
|
|
242
244
|
let {
|
|
243
245
|
address,
|
|
244
246
|
args,
|
|
245
247
|
chainId,
|
|
246
248
|
functionName
|
|
247
|
-
} =
|
|
249
|
+
} = _ref6;
|
|
248
250
|
super(['Contract read returned an empty response. This could be due to any of the following:', `- The contract does not have the function "${functionName}",`, '- The parameters passed to the contract function may be invalid, or', '- The address is not a contract.', '', `Config:`, JSON.stringify({
|
|
249
251
|
address,
|
|
250
252
|
abi: '...',
|
|
@@ -258,14 +260,14 @@ class ContractMethodNoResultError extends Error {
|
|
|
258
260
|
|
|
259
261
|
}
|
|
260
262
|
class ContractMethodRevertedError extends Error {
|
|
261
|
-
constructor(
|
|
263
|
+
constructor(_ref7) {
|
|
262
264
|
let {
|
|
263
265
|
address,
|
|
264
266
|
args,
|
|
265
267
|
chainId,
|
|
266
268
|
functionName,
|
|
267
269
|
errorMessage
|
|
268
|
-
} =
|
|
270
|
+
} = _ref7;
|
|
269
271
|
super(['Contract method reverted with an error.', '', `Config:`, JSON.stringify({
|
|
270
272
|
address,
|
|
271
273
|
abi: '...',
|
|
@@ -279,14 +281,14 @@ class ContractMethodRevertedError extends Error {
|
|
|
279
281
|
|
|
280
282
|
}
|
|
281
283
|
class ContractResultDecodeError extends Error {
|
|
282
|
-
constructor(
|
|
284
|
+
constructor(_ref8) {
|
|
283
285
|
let {
|
|
284
286
|
address,
|
|
285
287
|
args,
|
|
286
288
|
chainId,
|
|
287
289
|
functionName,
|
|
288
290
|
errorMessage
|
|
289
|
-
} =
|
|
291
|
+
} = _ref8;
|
|
290
292
|
super(['Failed to decode contract function result.', '', `Config:`, JSON.stringify({
|
|
291
293
|
address,
|
|
292
294
|
abi: '...',
|
|
@@ -326,10 +328,10 @@ class SwitchChainError extends ProviderRpcError {
|
|
|
326
328
|
|
|
327
329
|
}
|
|
328
330
|
class SwitchChainNotSupportedError extends Error {
|
|
329
|
-
constructor(
|
|
331
|
+
constructor(_ref9) {
|
|
330
332
|
let {
|
|
331
333
|
connector
|
|
332
|
-
} =
|
|
334
|
+
} = _ref9;
|
|
333
335
|
super(`"${connector.name}" does not support programmatic chain switching.`);
|
|
334
336
|
|
|
335
337
|
_defineProperty(this, "name", 'SwitchChainNotSupportedError');
|
|
@@ -438,7 +440,6 @@ class Connector extends EventEmitter__default["default"] {
|
|
|
438
440
|
...blockExplorers
|
|
439
441
|
} = chain.blockExplorers ?? {};
|
|
440
442
|
if (blockExplorer) return [blockExplorer.url, ...Object.values(blockExplorers).map(x => x.url)];
|
|
441
|
-
return [];
|
|
442
443
|
}
|
|
443
444
|
|
|
444
445
|
isChainUnsupported(chainId) {
|
|
@@ -665,7 +666,10 @@ class InjectedConnector extends Connector {
|
|
|
665
666
|
var _data, _data$originalError;
|
|
666
667
|
|
|
667
668
|
const chain = this.chains.find(x => x.id === chainId);
|
|
668
|
-
if (!chain) throw new ChainNotConfiguredError(
|
|
669
|
+
if (!chain) throw new ChainNotConfiguredError({
|
|
670
|
+
chainId,
|
|
671
|
+
connectorId: this.id
|
|
672
|
+
}); // Indicates chain is not added to provider
|
|
669
673
|
|
|
670
674
|
if (error.code === 4902 || // Unwrapping for MetaMask Mobile
|
|
671
675
|
// https://github.com/MetaMask/metamask-mobile/issues/2944#issuecomment-976988719
|
|
@@ -182,12 +182,14 @@ class ChainMismatchError extends Error {
|
|
|
182
182
|
|
|
183
183
|
}
|
|
184
184
|
class ChainNotConfiguredError extends Error {
|
|
185
|
-
constructor() {
|
|
186
|
-
|
|
185
|
+
constructor(_ref3) {
|
|
186
|
+
let {
|
|
187
|
+
chainId,
|
|
188
|
+
connectorId
|
|
189
|
+
} = _ref3;
|
|
190
|
+
super(`Chain "${chainId}" not configured for connector "${connectorId}".`);
|
|
187
191
|
|
|
188
192
|
_defineProperty(this, "name", 'ChainNotConfigured');
|
|
189
|
-
|
|
190
|
-
_defineProperty(this, "message", 'Chain not configured');
|
|
191
193
|
}
|
|
192
194
|
|
|
193
195
|
}
|
|
@@ -212,22 +214,22 @@ class ConnectorNotFoundError extends Error {
|
|
|
212
214
|
|
|
213
215
|
}
|
|
214
216
|
class ContractMethodDoesNotExistError extends Error {
|
|
215
|
-
constructor(
|
|
217
|
+
constructor(_ref4) {
|
|
216
218
|
var _chain$blockExplorers;
|
|
217
219
|
|
|
218
220
|
let {
|
|
219
221
|
address,
|
|
220
222
|
chainId,
|
|
221
223
|
functionName
|
|
222
|
-
} =
|
|
224
|
+
} = _ref4;
|
|
223
225
|
const {
|
|
224
226
|
chains,
|
|
225
227
|
network
|
|
226
228
|
} = getProvider();
|
|
227
|
-
const chain = chains === null || chains === void 0 ? void 0 : chains.find(
|
|
229
|
+
const chain = chains === null || chains === void 0 ? void 0 : chains.find(_ref5 => {
|
|
228
230
|
let {
|
|
229
231
|
id
|
|
230
|
-
} =
|
|
232
|
+
} = _ref5;
|
|
231
233
|
return id === (chainId || network.chainId);
|
|
232
234
|
});
|
|
233
235
|
const blockExplorer = chain === null || chain === void 0 ? void 0 : (_chain$blockExplorers = chain.blockExplorers) === null || _chain$blockExplorers === void 0 ? void 0 : _chain$blockExplorers.default;
|
|
@@ -238,13 +240,13 @@ class ContractMethodDoesNotExistError extends Error {
|
|
|
238
240
|
|
|
239
241
|
}
|
|
240
242
|
class ContractMethodNoResultError extends Error {
|
|
241
|
-
constructor(
|
|
243
|
+
constructor(_ref6) {
|
|
242
244
|
let {
|
|
243
245
|
address,
|
|
244
246
|
args,
|
|
245
247
|
chainId,
|
|
246
248
|
functionName
|
|
247
|
-
} =
|
|
249
|
+
} = _ref6;
|
|
248
250
|
super(['Contract read returned an empty response. This could be due to any of the following:', `- The contract does not have the function "${functionName}",`, '- The parameters passed to the contract function may be invalid, or', '- The address is not a contract.', '', `Config:`, JSON.stringify({
|
|
249
251
|
address,
|
|
250
252
|
abi: '...',
|
|
@@ -258,14 +260,14 @@ class ContractMethodNoResultError extends Error {
|
|
|
258
260
|
|
|
259
261
|
}
|
|
260
262
|
class ContractMethodRevertedError extends Error {
|
|
261
|
-
constructor(
|
|
263
|
+
constructor(_ref7) {
|
|
262
264
|
let {
|
|
263
265
|
address,
|
|
264
266
|
args,
|
|
265
267
|
chainId,
|
|
266
268
|
functionName,
|
|
267
269
|
errorMessage
|
|
268
|
-
} =
|
|
270
|
+
} = _ref7;
|
|
269
271
|
super(['Contract method reverted with an error.', '', `Config:`, JSON.stringify({
|
|
270
272
|
address,
|
|
271
273
|
abi: '...',
|
|
@@ -279,14 +281,14 @@ class ContractMethodRevertedError extends Error {
|
|
|
279
281
|
|
|
280
282
|
}
|
|
281
283
|
class ContractResultDecodeError extends Error {
|
|
282
|
-
constructor(
|
|
284
|
+
constructor(_ref8) {
|
|
283
285
|
let {
|
|
284
286
|
address,
|
|
285
287
|
args,
|
|
286
288
|
chainId,
|
|
287
289
|
functionName,
|
|
288
290
|
errorMessage
|
|
289
|
-
} =
|
|
291
|
+
} = _ref8;
|
|
290
292
|
super(['Failed to decode contract function result.', '', `Config:`, JSON.stringify({
|
|
291
293
|
address,
|
|
292
294
|
abi: '...',
|
|
@@ -326,10 +328,10 @@ class SwitchChainError extends ProviderRpcError {
|
|
|
326
328
|
|
|
327
329
|
}
|
|
328
330
|
class SwitchChainNotSupportedError extends Error {
|
|
329
|
-
constructor(
|
|
331
|
+
constructor(_ref9) {
|
|
330
332
|
let {
|
|
331
333
|
connector
|
|
332
|
-
} =
|
|
334
|
+
} = _ref9;
|
|
333
335
|
super(`"${connector.name}" does not support programmatic chain switching.`);
|
|
334
336
|
|
|
335
337
|
_defineProperty(this, "name", 'SwitchChainNotSupportedError');
|
|
@@ -438,7 +440,6 @@ class Connector extends EventEmitter__default["default"] {
|
|
|
438
440
|
...blockExplorers
|
|
439
441
|
} = chain.blockExplorers ?? {};
|
|
440
442
|
if (blockExplorer) return [blockExplorer.url, ...Object.values(blockExplorers).map(x => x.url)];
|
|
441
|
-
return [];
|
|
442
443
|
}
|
|
443
444
|
|
|
444
445
|
isChainUnsupported(chainId) {
|
|
@@ -665,7 +666,10 @@ class InjectedConnector extends Connector {
|
|
|
665
666
|
var _data, _data$originalError;
|
|
666
667
|
|
|
667
668
|
const chain = this.chains.find(x => x.id === chainId);
|
|
668
|
-
if (!chain) throw new ChainNotConfiguredError(
|
|
669
|
+
if (!chain) throw new ChainNotConfiguredError({
|
|
670
|
+
chainId,
|
|
671
|
+
connectorId: this.id
|
|
672
|
+
}); // Indicates chain is not added to provider
|
|
669
673
|
|
|
670
674
|
if (error.code === 4902 || // Unwrapping for MetaMask Mobile
|
|
671
675
|
// https://github.com/MetaMask/metamask-mobile/issues/2944#issuecomment-976988719
|
|
@@ -175,12 +175,14 @@ class ChainMismatchError extends Error {
|
|
|
175
175
|
|
|
176
176
|
}
|
|
177
177
|
class ChainNotConfiguredError extends Error {
|
|
178
|
-
constructor() {
|
|
179
|
-
|
|
178
|
+
constructor(_ref3) {
|
|
179
|
+
let {
|
|
180
|
+
chainId,
|
|
181
|
+
connectorId
|
|
182
|
+
} = _ref3;
|
|
183
|
+
super(`Chain "${chainId}" not configured for connector "${connectorId}".`);
|
|
180
184
|
|
|
181
185
|
_defineProperty(this, "name", 'ChainNotConfigured');
|
|
182
|
-
|
|
183
|
-
_defineProperty(this, "message", 'Chain not configured');
|
|
184
186
|
}
|
|
185
187
|
|
|
186
188
|
}
|
|
@@ -205,22 +207,22 @@ class ConnectorNotFoundError extends Error {
|
|
|
205
207
|
|
|
206
208
|
}
|
|
207
209
|
class ContractMethodDoesNotExistError extends Error {
|
|
208
|
-
constructor(
|
|
210
|
+
constructor(_ref4) {
|
|
209
211
|
var _chain$blockExplorers;
|
|
210
212
|
|
|
211
213
|
let {
|
|
212
214
|
address,
|
|
213
215
|
chainId,
|
|
214
216
|
functionName
|
|
215
|
-
} =
|
|
217
|
+
} = _ref4;
|
|
216
218
|
const {
|
|
217
219
|
chains,
|
|
218
220
|
network
|
|
219
221
|
} = getProvider();
|
|
220
|
-
const chain = chains === null || chains === void 0 ? void 0 : chains.find(
|
|
222
|
+
const chain = chains === null || chains === void 0 ? void 0 : chains.find(_ref5 => {
|
|
221
223
|
let {
|
|
222
224
|
id
|
|
223
|
-
} =
|
|
225
|
+
} = _ref5;
|
|
224
226
|
return id === (chainId || network.chainId);
|
|
225
227
|
});
|
|
226
228
|
const blockExplorer = chain === null || chain === void 0 ? void 0 : (_chain$blockExplorers = chain.blockExplorers) === null || _chain$blockExplorers === void 0 ? void 0 : _chain$blockExplorers.default;
|
|
@@ -231,13 +233,13 @@ class ContractMethodDoesNotExistError extends Error {
|
|
|
231
233
|
|
|
232
234
|
}
|
|
233
235
|
class ContractMethodNoResultError extends Error {
|
|
234
|
-
constructor(
|
|
236
|
+
constructor(_ref6) {
|
|
235
237
|
let {
|
|
236
238
|
address,
|
|
237
239
|
args,
|
|
238
240
|
chainId,
|
|
239
241
|
functionName
|
|
240
|
-
} =
|
|
242
|
+
} = _ref6;
|
|
241
243
|
super(['Contract read returned an empty response. This could be due to any of the following:', `- The contract does not have the function "${functionName}",`, '- The parameters passed to the contract function may be invalid, or', '- The address is not a contract.', '', `Config:`, JSON.stringify({
|
|
242
244
|
address,
|
|
243
245
|
abi: '...',
|
|
@@ -251,14 +253,14 @@ class ContractMethodNoResultError extends Error {
|
|
|
251
253
|
|
|
252
254
|
}
|
|
253
255
|
class ContractMethodRevertedError extends Error {
|
|
254
|
-
constructor(
|
|
256
|
+
constructor(_ref7) {
|
|
255
257
|
let {
|
|
256
258
|
address,
|
|
257
259
|
args,
|
|
258
260
|
chainId,
|
|
259
261
|
functionName,
|
|
260
262
|
errorMessage
|
|
261
|
-
} =
|
|
263
|
+
} = _ref7;
|
|
262
264
|
super(['Contract method reverted with an error.', '', `Config:`, JSON.stringify({
|
|
263
265
|
address,
|
|
264
266
|
abi: '...',
|
|
@@ -272,14 +274,14 @@ class ContractMethodRevertedError extends Error {
|
|
|
272
274
|
|
|
273
275
|
}
|
|
274
276
|
class ContractResultDecodeError extends Error {
|
|
275
|
-
constructor(
|
|
277
|
+
constructor(_ref8) {
|
|
276
278
|
let {
|
|
277
279
|
address,
|
|
278
280
|
args,
|
|
279
281
|
chainId,
|
|
280
282
|
functionName,
|
|
281
283
|
errorMessage
|
|
282
|
-
} =
|
|
284
|
+
} = _ref8;
|
|
283
285
|
super(['Failed to decode contract function result.', '', `Config:`, JSON.stringify({
|
|
284
286
|
address,
|
|
285
287
|
abi: '...',
|
|
@@ -319,10 +321,10 @@ class SwitchChainError extends ProviderRpcError {
|
|
|
319
321
|
|
|
320
322
|
}
|
|
321
323
|
class SwitchChainNotSupportedError extends Error {
|
|
322
|
-
constructor(
|
|
324
|
+
constructor(_ref9) {
|
|
323
325
|
let {
|
|
324
326
|
connector
|
|
325
|
-
} =
|
|
327
|
+
} = _ref9;
|
|
326
328
|
super(`"${connector.name}" does not support programmatic chain switching.`);
|
|
327
329
|
|
|
328
330
|
_defineProperty(this, "name", 'SwitchChainNotSupportedError');
|
|
@@ -431,7 +433,6 @@ class Connector extends EventEmitter {
|
|
|
431
433
|
...blockExplorers
|
|
432
434
|
} = chain.blockExplorers ?? {};
|
|
433
435
|
if (blockExplorer) return [blockExplorer.url, ...Object.values(blockExplorers).map(x => x.url)];
|
|
434
|
-
return [];
|
|
435
436
|
}
|
|
436
437
|
|
|
437
438
|
isChainUnsupported(chainId) {
|
|
@@ -658,7 +659,10 @@ class InjectedConnector extends Connector {
|
|
|
658
659
|
var _data, _data$originalError;
|
|
659
660
|
|
|
660
661
|
const chain = this.chains.find(x => x.id === chainId);
|
|
661
|
-
if (!chain) throw new ChainNotConfiguredError(
|
|
662
|
+
if (!chain) throw new ChainNotConfiguredError({
|
|
663
|
+
chainId,
|
|
664
|
+
connectorId: this.id
|
|
665
|
+
}); // Indicates chain is not added to provider
|
|
662
666
|
|
|
663
667
|
if (error.code === 4902 || // Unwrapping for MetaMask Mobile
|
|
664
668
|
// https://github.com/MetaMask/metamask-mobile/issues/2944#issuecomment-976988719
|
|
@@ -1098,4 +1102,4 @@ function getProvider() {
|
|
|
1098
1102
|
return client.provider;
|
|
1099
1103
|
}
|
|
1100
1104
|
|
|
1101
|
-
export { AddChainError as A, ChainMismatchError as C, InjectedConnector as I, ProviderChainsNotFound as P, ResourceUnavailableError as R, SwitchChainNotSupportedError as S, UserRejectedRequestError as U, _classPrivateMethodInitSpec as _,
|
|
1105
|
+
export { AddChainError as A, ChainMismatchError as C, InjectedConnector as I, ProviderChainsNotFound as P, ResourceUnavailableError as R, SwitchChainNotSupportedError as S, UserRejectedRequestError as U, _classPrivateMethodInitSpec as _, ChainNotConfiguredError as a, ConnectorAlreadyConnectedError as b, ContractResultDecodeError as c, ConnectorNotFoundError as d, ContractMethodDoesNotExistError as e, getProvider as f, getClient as g, ChainDoesNotSupportMulticallError as h, ContractMethodRevertedError as i, ContractMethodNoResultError as j, createClient as k, Client as l, Connector as m, normalizeChainId as n, ProviderRpcError as o, RpcError as p, SwitchChainError as q, createStorage as r, noopStorage as s, _defineProperty as t, _classPrivateMethodGet as u, _classPrivateFieldInitSpec as v, _classPrivateFieldSet as w, _classPrivateFieldGet as x };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var getProvider = require('./getProvider-
|
|
5
|
+
var getProvider = require('./getProvider-58ea0031.cjs.dev.js');
|
|
6
6
|
var ethers$1 = require('ethers/lib/ethers');
|
|
7
7
|
var utils = require('ethers/lib/utils');
|
|
8
8
|
var ethers = require('ethers');
|
|
@@ -154,15 +154,17 @@ function fallbackProvider(targetQuorum, minQuorum, providers_, _ref4) {
|
|
|
154
154
|
|
|
155
155
|
function assertActiveChain(_ref) {
|
|
156
156
|
let {
|
|
157
|
-
chainId
|
|
157
|
+
chainId,
|
|
158
|
+
signer
|
|
158
159
|
} = _ref;
|
|
160
|
+
// Check that active chain and target chain match
|
|
159
161
|
const {
|
|
160
162
|
chain: activeChain,
|
|
161
163
|
chains
|
|
162
164
|
} = getNetwork();
|
|
163
165
|
const activeChainId = activeChain === null || activeChain === void 0 ? void 0 : activeChain.id;
|
|
164
166
|
|
|
165
|
-
if (chainId !== activeChainId) {
|
|
167
|
+
if (activeChainId && chainId !== activeChainId) {
|
|
166
168
|
var _chains$find, _chains$find2;
|
|
167
169
|
|
|
168
170
|
throw new getProvider.ChainMismatchError({
|
|
@@ -170,6 +172,21 @@ function assertActiveChain(_ref) {
|
|
|
170
172
|
targetChain: ((_chains$find2 = chains.find(x => x.id === chainId)) === null || _chains$find2 === void 0 ? void 0 : _chains$find2.name) ?? `Chain ${chainId}`
|
|
171
173
|
});
|
|
172
174
|
}
|
|
175
|
+
|
|
176
|
+
if (signer) {
|
|
177
|
+
var _signer$provider, _signer$provider$netw;
|
|
178
|
+
|
|
179
|
+
// Check that signer's chain and target chain match
|
|
180
|
+
const signerChainId = (_signer$provider = signer.provider) === null || _signer$provider === void 0 ? void 0 : (_signer$provider$netw = _signer$provider.network) === null || _signer$provider$netw === void 0 ? void 0 : _signer$provider$netw.chainId;
|
|
181
|
+
|
|
182
|
+
if (signerChainId && chainId !== signerChainId) {
|
|
183
|
+
const connector = getProvider.getClient().connector;
|
|
184
|
+
throw new getProvider.ChainNotConfiguredError({
|
|
185
|
+
chainId,
|
|
186
|
+
connectorId: (connector === null || connector === void 0 ? void 0 : connector.id) ?? 'unknown'
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
173
190
|
}
|
|
174
191
|
|
|
175
192
|
/** Forked from https://github.com/epoberezkin/fast-deep-equal */
|
|
@@ -1436,7 +1453,8 @@ async function prepareWriteContract(_ref) {
|
|
|
1436
1453
|
}));
|
|
1437
1454
|
if (!signer) throw new getProvider.ConnectorNotFoundError();
|
|
1438
1455
|
if (chainId) assertActiveChain({
|
|
1439
|
-
chainId
|
|
1456
|
+
chainId,
|
|
1457
|
+
signer
|
|
1440
1458
|
});
|
|
1441
1459
|
const contract = getContract({
|
|
1442
1460
|
address,
|
|
@@ -2075,7 +2093,8 @@ async function prepareSendTransaction(_ref) {
|
|
|
2075
2093
|
}));
|
|
2076
2094
|
if (!signer) throw new getProvider.ConnectorNotFoundError();
|
|
2077
2095
|
if (chainId) assertActiveChain({
|
|
2078
|
-
chainId
|
|
2096
|
+
chainId,
|
|
2097
|
+
signer
|
|
2079
2098
|
});
|
|
2080
2099
|
const [to, gasLimit] = await Promise.all([utils.isAddress(request.to) ? Promise.resolve(request.to) : fetchEnsAddress({
|
|
2081
2100
|
name: request.to
|
|
@@ -2135,7 +2154,8 @@ async function sendTransaction(_ref) {
|
|
|
2135
2154
|
}
|
|
2136
2155
|
|
|
2137
2156
|
if (chainId) assertActiveChain({
|
|
2138
|
-
chainId
|
|
2157
|
+
chainId,
|
|
2158
|
+
signer
|
|
2139
2159
|
});
|
|
2140
2160
|
|
|
2141
2161
|
try {
|
|
@@ -2231,7 +2251,8 @@ async function writeContract(_ref) {
|
|
|
2231
2251
|
const signer = await fetchSigner();
|
|
2232
2252
|
if (!signer) throw new getProvider.ConnectorNotFoundError();
|
|
2233
2253
|
if (chainId) assertActiveChain({
|
|
2234
|
-
chainId
|
|
2254
|
+
chainId,
|
|
2255
|
+
signer
|
|
2235
2256
|
});
|
|
2236
2257
|
if (mode === 'prepared') if (!request_) throw new Error('`request` is required');
|
|
2237
2258
|
const request = mode === 'recklesslyUnprepared' ? (await prepareWriteContract({
|
|
@@ -2463,7 +2484,8 @@ async function signTypedData(_ref) {
|
|
|
2463
2484
|
} = domain;
|
|
2464
2485
|
const chainId = chainId_ ? getProvider.normalizeChainId(chainId_) : undefined;
|
|
2465
2486
|
if (chainId) assertActiveChain({
|
|
2466
|
-
chainId
|
|
2487
|
+
chainId,
|
|
2488
|
+
signer
|
|
2467
2489
|
}); // Method name may be changed in the future, see https://docs.ethers.io/v5/api/signer/#Signer-signTypedData
|
|
2468
2490
|
|
|
2469
2491
|
return signer._signTypedData(domain, types, value);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var getProvider = require('./getProvider-
|
|
5
|
+
var getProvider = require('./getProvider-922d7937.cjs.prod.js');
|
|
6
6
|
var ethers$1 = require('ethers/lib/ethers');
|
|
7
7
|
var utils = require('ethers/lib/utils');
|
|
8
8
|
var ethers = require('ethers');
|
|
@@ -154,15 +154,17 @@ function fallbackProvider(targetQuorum, minQuorum, providers_, _ref4) {
|
|
|
154
154
|
|
|
155
155
|
function assertActiveChain(_ref) {
|
|
156
156
|
let {
|
|
157
|
-
chainId
|
|
157
|
+
chainId,
|
|
158
|
+
signer
|
|
158
159
|
} = _ref;
|
|
160
|
+
// Check that active chain and target chain match
|
|
159
161
|
const {
|
|
160
162
|
chain: activeChain,
|
|
161
163
|
chains
|
|
162
164
|
} = getNetwork();
|
|
163
165
|
const activeChainId = activeChain === null || activeChain === void 0 ? void 0 : activeChain.id;
|
|
164
166
|
|
|
165
|
-
if (chainId !== activeChainId) {
|
|
167
|
+
if (activeChainId && chainId !== activeChainId) {
|
|
166
168
|
var _chains$find, _chains$find2;
|
|
167
169
|
|
|
168
170
|
throw new getProvider.ChainMismatchError({
|
|
@@ -170,6 +172,21 @@ function assertActiveChain(_ref) {
|
|
|
170
172
|
targetChain: ((_chains$find2 = chains.find(x => x.id === chainId)) === null || _chains$find2 === void 0 ? void 0 : _chains$find2.name) ?? `Chain ${chainId}`
|
|
171
173
|
});
|
|
172
174
|
}
|
|
175
|
+
|
|
176
|
+
if (signer) {
|
|
177
|
+
var _signer$provider, _signer$provider$netw;
|
|
178
|
+
|
|
179
|
+
// Check that signer's chain and target chain match
|
|
180
|
+
const signerChainId = (_signer$provider = signer.provider) === null || _signer$provider === void 0 ? void 0 : (_signer$provider$netw = _signer$provider.network) === null || _signer$provider$netw === void 0 ? void 0 : _signer$provider$netw.chainId;
|
|
181
|
+
|
|
182
|
+
if (signerChainId && chainId !== signerChainId) {
|
|
183
|
+
const connector = getProvider.getClient().connector;
|
|
184
|
+
throw new getProvider.ChainNotConfiguredError({
|
|
185
|
+
chainId,
|
|
186
|
+
connectorId: (connector === null || connector === void 0 ? void 0 : connector.id) ?? 'unknown'
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
173
190
|
}
|
|
174
191
|
|
|
175
192
|
/** Forked from https://github.com/epoberezkin/fast-deep-equal */
|
|
@@ -1436,7 +1453,8 @@ async function prepareWriteContract(_ref) {
|
|
|
1436
1453
|
}));
|
|
1437
1454
|
if (!signer) throw new getProvider.ConnectorNotFoundError();
|
|
1438
1455
|
if (chainId) assertActiveChain({
|
|
1439
|
-
chainId
|
|
1456
|
+
chainId,
|
|
1457
|
+
signer
|
|
1440
1458
|
});
|
|
1441
1459
|
const contract = getContract({
|
|
1442
1460
|
address,
|
|
@@ -2075,7 +2093,8 @@ async function prepareSendTransaction(_ref) {
|
|
|
2075
2093
|
}));
|
|
2076
2094
|
if (!signer) throw new getProvider.ConnectorNotFoundError();
|
|
2077
2095
|
if (chainId) assertActiveChain({
|
|
2078
|
-
chainId
|
|
2096
|
+
chainId,
|
|
2097
|
+
signer
|
|
2079
2098
|
});
|
|
2080
2099
|
const [to, gasLimit] = await Promise.all([utils.isAddress(request.to) ? Promise.resolve(request.to) : fetchEnsAddress({
|
|
2081
2100
|
name: request.to
|
|
@@ -2135,7 +2154,8 @@ async function sendTransaction(_ref) {
|
|
|
2135
2154
|
}
|
|
2136
2155
|
|
|
2137
2156
|
if (chainId) assertActiveChain({
|
|
2138
|
-
chainId
|
|
2157
|
+
chainId,
|
|
2158
|
+
signer
|
|
2139
2159
|
});
|
|
2140
2160
|
|
|
2141
2161
|
try {
|
|
@@ -2231,7 +2251,8 @@ async function writeContract(_ref) {
|
|
|
2231
2251
|
const signer = await fetchSigner();
|
|
2232
2252
|
if (!signer) throw new getProvider.ConnectorNotFoundError();
|
|
2233
2253
|
if (chainId) assertActiveChain({
|
|
2234
|
-
chainId
|
|
2254
|
+
chainId,
|
|
2255
|
+
signer
|
|
2235
2256
|
});
|
|
2236
2257
|
if (mode === 'prepared') if (!request_) throw new Error('`request` is required');
|
|
2237
2258
|
const request = mode === 'recklesslyUnprepared' ? (await prepareWriteContract({
|
|
@@ -2463,7 +2484,8 @@ async function signTypedData(_ref) {
|
|
|
2463
2484
|
} = domain;
|
|
2464
2485
|
const chainId = chainId_ ? getProvider.normalizeChainId(chainId_) : undefined;
|
|
2465
2486
|
if (chainId) assertActiveChain({
|
|
2466
|
-
chainId
|
|
2487
|
+
chainId,
|
|
2488
|
+
signer
|
|
2467
2489
|
}); // Method name may be changed in the future, see https://docs.ethers.io/v5/api/signer/#Signer-signTypedData
|
|
2468
2490
|
|
|
2469
2491
|
return signer._signTypedData(domain, types, value);
|
package/dist/wagmi-core.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ChainMismatchError, g as getClient, a as
|
|
2
|
-
export { A as AddChainError,
|
|
1
|
+
import { C as ChainMismatchError, g as getClient, a as ChainNotConfiguredError, b as ConnectorAlreadyConnectedError, c as ContractResultDecodeError, d as ConnectorNotFoundError, e as ContractMethodDoesNotExistError, f as getProvider, P as ProviderChainsNotFound, h as ChainDoesNotSupportMulticallError, i as ContractMethodRevertedError, j as ContractMethodNoResultError, U as UserRejectedRequestError, n as normalizeChainId, S as SwitchChainNotSupportedError } from './getProvider-b69e06ef.esm.js';
|
|
2
|
+
export { A as AddChainError, h as ChainDoesNotSupportMulticallError, C as ChainMismatchError, a as ChainNotConfiguredError, l as Client, m as Connector, b as ConnectorAlreadyConnectedError, d as ConnectorNotFoundError, e as ContractMethodDoesNotExistError, j as ContractMethodNoResultError, i as ContractMethodRevertedError, c as ContractResultDecodeError, I as InjectedConnector, P as ProviderChainsNotFound, o as ProviderRpcError, R as ResourceUnavailableError, p as RpcError, q as SwitchChainError, S as SwitchChainNotSupportedError, U as UserRejectedRequestError, k as createClient, r as createStorage, f as getProvider, s as noopStorage, n as normalizeChainId } from './getProvider-b69e06ef.esm.js';
|
|
3
3
|
import { Contract, logger } from 'ethers/lib/ethers';
|
|
4
4
|
import { FunctionFragment, isAddress, FormatTypes, parseBytes32String, formatUnits, getAddress, Logger } from 'ethers/lib/utils';
|
|
5
5
|
import { providers, BigNumber, Contract as Contract$1 } from 'ethers';
|
|
@@ -148,15 +148,17 @@ function fallbackProvider(targetQuorum, minQuorum, providers_, _ref4) {
|
|
|
148
148
|
|
|
149
149
|
function assertActiveChain(_ref) {
|
|
150
150
|
let {
|
|
151
|
-
chainId
|
|
151
|
+
chainId,
|
|
152
|
+
signer
|
|
152
153
|
} = _ref;
|
|
154
|
+
// Check that active chain and target chain match
|
|
153
155
|
const {
|
|
154
156
|
chain: activeChain,
|
|
155
157
|
chains
|
|
156
158
|
} = getNetwork();
|
|
157
159
|
const activeChainId = activeChain === null || activeChain === void 0 ? void 0 : activeChain.id;
|
|
158
160
|
|
|
159
|
-
if (chainId !== activeChainId) {
|
|
161
|
+
if (activeChainId && chainId !== activeChainId) {
|
|
160
162
|
var _chains$find, _chains$find2;
|
|
161
163
|
|
|
162
164
|
throw new ChainMismatchError({
|
|
@@ -164,6 +166,21 @@ function assertActiveChain(_ref) {
|
|
|
164
166
|
targetChain: ((_chains$find2 = chains.find(x => x.id === chainId)) === null || _chains$find2 === void 0 ? void 0 : _chains$find2.name) ?? `Chain ${chainId}`
|
|
165
167
|
});
|
|
166
168
|
}
|
|
169
|
+
|
|
170
|
+
if (signer) {
|
|
171
|
+
var _signer$provider, _signer$provider$netw;
|
|
172
|
+
|
|
173
|
+
// Check that signer's chain and target chain match
|
|
174
|
+
const signerChainId = (_signer$provider = signer.provider) === null || _signer$provider === void 0 ? void 0 : (_signer$provider$netw = _signer$provider.network) === null || _signer$provider$netw === void 0 ? void 0 : _signer$provider$netw.chainId;
|
|
175
|
+
|
|
176
|
+
if (signerChainId && chainId !== signerChainId) {
|
|
177
|
+
const connector = getClient().connector;
|
|
178
|
+
throw new ChainNotConfiguredError({
|
|
179
|
+
chainId,
|
|
180
|
+
connectorId: (connector === null || connector === void 0 ? void 0 : connector.id) ?? 'unknown'
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
167
184
|
}
|
|
168
185
|
|
|
169
186
|
/** Forked from https://github.com/epoberezkin/fast-deep-equal */
|
|
@@ -1430,7 +1447,8 @@ async function prepareWriteContract(_ref) {
|
|
|
1430
1447
|
}));
|
|
1431
1448
|
if (!signer) throw new ConnectorNotFoundError();
|
|
1432
1449
|
if (chainId) assertActiveChain({
|
|
1433
|
-
chainId
|
|
1450
|
+
chainId,
|
|
1451
|
+
signer
|
|
1434
1452
|
});
|
|
1435
1453
|
const contract = getContract({
|
|
1436
1454
|
address,
|
|
@@ -2069,7 +2087,8 @@ async function prepareSendTransaction(_ref) {
|
|
|
2069
2087
|
}));
|
|
2070
2088
|
if (!signer) throw new ConnectorNotFoundError();
|
|
2071
2089
|
if (chainId) assertActiveChain({
|
|
2072
|
-
chainId
|
|
2090
|
+
chainId,
|
|
2091
|
+
signer
|
|
2073
2092
|
});
|
|
2074
2093
|
const [to, gasLimit] = await Promise.all([isAddress(request.to) ? Promise.resolve(request.to) : fetchEnsAddress({
|
|
2075
2094
|
name: request.to
|
|
@@ -2129,7 +2148,8 @@ async function sendTransaction(_ref) {
|
|
|
2129
2148
|
}
|
|
2130
2149
|
|
|
2131
2150
|
if (chainId) assertActiveChain({
|
|
2132
|
-
chainId
|
|
2151
|
+
chainId,
|
|
2152
|
+
signer
|
|
2133
2153
|
});
|
|
2134
2154
|
|
|
2135
2155
|
try {
|
|
@@ -2225,7 +2245,8 @@ async function writeContract(_ref) {
|
|
|
2225
2245
|
const signer = await fetchSigner();
|
|
2226
2246
|
if (!signer) throw new ConnectorNotFoundError();
|
|
2227
2247
|
if (chainId) assertActiveChain({
|
|
2228
|
-
chainId
|
|
2248
|
+
chainId,
|
|
2249
|
+
signer
|
|
2229
2250
|
});
|
|
2230
2251
|
if (mode === 'prepared') if (!request_) throw new Error('`request` is required');
|
|
2231
2252
|
const request = mode === 'recklesslyUnprepared' ? (await prepareWriteContract({
|
|
@@ -2457,7 +2478,8 @@ async function signTypedData(_ref) {
|
|
|
2457
2478
|
} = domain;
|
|
2458
2479
|
const chainId = chainId_ ? normalizeChainId(chainId_) : undefined;
|
|
2459
2480
|
if (chainId) assertActiveChain({
|
|
2460
|
-
chainId
|
|
2481
|
+
chainId,
|
|
2482
|
+
signer
|
|
2461
2483
|
}); // Method name may be changed in the future, see https://docs.ethers.io/v5/api/signer/#Signer-signTypedData
|
|
2462
2484
|
|
|
2463
2485
|
return signer._signTypedData(domain, types, value);
|