@wagmi/core 0.4.0 → 0.4.3
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/chains/dist/wagmi-core-chains.cjs.dev.js +2 -2
- package/chains/dist/wagmi-core-chains.cjs.prod.js +2 -2
- package/chains/dist/wagmi-core-chains.esm.js +2 -2
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.dev.js +6 -4
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.prod.js +6 -4
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.esm.js +6 -4
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.dev.js +4 -4
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.prod.js +4 -4
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.esm.js +4 -4
- package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.dev.js +3 -3
- package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.prod.js +3 -3
- package/connectors/mock/dist/wagmi-core-connectors-mock.esm.js +3 -3
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.dev.js +10 -7
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.prod.js +10 -7
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.esm.js +10 -7
- package/dist/{base-6f16410c.cjs.dev.js → base-2d484f6c.cjs.prod.js} +2 -1
- package/dist/{base-33eceda3.esm.js → base-e66f9622.esm.js} +2 -1
- package/dist/{base-457b5f55.cjs.prod.js → base-e71ae4b2.cjs.dev.js} +2 -1
- package/dist/{chains-1390c48d.cjs.prod.js → chains-865492ea.cjs.prod.js} +23 -12
- package/dist/{chains-e98fda1e.esm.js → chains-c389721d.esm.js} +23 -12
- package/dist/{chains-2ca34f98.cjs.dev.js → chains-d970ee8d.cjs.dev.js} +23 -12
- package/dist/{client-b3902dbf.cjs.dev.js → client-1feb9121.cjs.prod.js} +9 -3
- package/dist/{client-7864fb0c.cjs.prod.js → client-53f2119c.cjs.dev.js} +9 -3
- package/dist/{client-71653c40.esm.js → client-ffba0e25.esm.js} +9 -3
- package/dist/declarations/src/actions/accounts/signTypedData.d.ts +7 -3
- package/dist/declarations/src/connectors/walletConnect.d.ts +2 -1
- package/dist/declarations/src/constants/index.d.ts +1 -1
- package/dist/declarations/src/constants/rpcs.d.ts +3 -1
- package/dist/declarations/src/index.d.ts +1 -1
- package/dist/declarations/src/types/index.d.ts +1 -1
- package/dist/declarations/src/utils/configureChains.d.ts +2 -2
- package/dist/declarations/src/utils/normalizeChainId.d.ts +1 -1
- package/dist/{rpcs-9c4eb960.cjs.dev.js → rpcs-1fd0a12f.cjs.prod.js} +14 -0
- package/dist/{rpcs-7cfbd91c.esm.js → rpcs-b73a8f60.esm.js} +14 -1
- package/dist/{rpcs-b3c52116.cjs.prod.js → rpcs-f1d24f0e.cjs.dev.js} +14 -0
- package/dist/wagmi-core.cjs.dev.js +44 -14
- package/dist/wagmi-core.cjs.prod.js +44 -14
- package/dist/wagmi-core.esm.js +45 -16
- package/package.json +1 -1
- package/providers/alchemy/dist/wagmi-core-providers-alchemy.cjs.dev.js +1 -1
- package/providers/alchemy/dist/wagmi-core-providers-alchemy.cjs.prod.js +1 -1
- package/providers/alchemy/dist/wagmi-core-providers-alchemy.esm.js +1 -1
- package/providers/infura/dist/wagmi-core-providers-infura.cjs.dev.js +1 -1
- package/providers/infura/dist/wagmi-core-providers-infura.cjs.prod.js +1 -1
- package/providers/infura/dist/wagmi-core-providers-infura.esm.js +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var rpcs = require('./rpcs-
|
|
3
|
+
var rpcs = require('./rpcs-f1d24f0e.cjs.dev.js');
|
|
4
4
|
|
|
5
5
|
const etherscanBlockExplorers = {
|
|
6
6
|
mainnet: {
|
|
@@ -76,8 +76,9 @@ const mainnet = {
|
|
|
76
76
|
},
|
|
77
77
|
rpcUrls: {
|
|
78
78
|
alchemy: rpcs.alchemyRpcUrls.mainnet,
|
|
79
|
+
default: rpcs.publicRpcUrls.mainnet,
|
|
79
80
|
infura: rpcs.infuraRpcUrls.mainnet,
|
|
80
|
-
|
|
81
|
+
public: rpcs.publicRpcUrls.mainnet
|
|
81
82
|
},
|
|
82
83
|
blockExplorers: {
|
|
83
84
|
etherscan: etherscanBlockExplorers.mainnet,
|
|
@@ -102,8 +103,9 @@ const ropsten = {
|
|
|
102
103
|
},
|
|
103
104
|
rpcUrls: {
|
|
104
105
|
alchemy: rpcs.alchemyRpcUrls.ropsten,
|
|
106
|
+
default: rpcs.publicRpcUrls.ropsten,
|
|
105
107
|
infura: rpcs.infuraRpcUrls.ropsten,
|
|
106
|
-
|
|
108
|
+
public: rpcs.publicRpcUrls.ropsten
|
|
107
109
|
},
|
|
108
110
|
blockExplorers: {
|
|
109
111
|
etherscan: etherscanBlockExplorers.ropsten,
|
|
@@ -129,8 +131,9 @@ const rinkeby = {
|
|
|
129
131
|
},
|
|
130
132
|
rpcUrls: {
|
|
131
133
|
alchemy: rpcs.alchemyRpcUrls.rinkeby,
|
|
134
|
+
default: rpcs.publicRpcUrls.rinkeby,
|
|
132
135
|
infura: rpcs.infuraRpcUrls.rinkeby,
|
|
133
|
-
|
|
136
|
+
public: rpcs.publicRpcUrls.rinkeby
|
|
134
137
|
},
|
|
135
138
|
blockExplorers: {
|
|
136
139
|
etherscan: etherscanBlockExplorers.rinkeby,
|
|
@@ -156,8 +159,9 @@ const goerli = {
|
|
|
156
159
|
},
|
|
157
160
|
rpcUrls: {
|
|
158
161
|
alchemy: rpcs.alchemyRpcUrls.goerli,
|
|
162
|
+
default: rpcs.publicRpcUrls.goerli,
|
|
159
163
|
infura: rpcs.infuraRpcUrls.goerli,
|
|
160
|
-
|
|
164
|
+
public: rpcs.publicRpcUrls.goerli
|
|
161
165
|
},
|
|
162
166
|
blockExplorers: {
|
|
163
167
|
etherscan: etherscanBlockExplorers.goerli,
|
|
@@ -183,8 +187,9 @@ const kovan = {
|
|
|
183
187
|
},
|
|
184
188
|
rpcUrls: {
|
|
185
189
|
alchemy: rpcs.alchemyRpcUrls.kovan,
|
|
190
|
+
default: rpcs.publicRpcUrls.kovan,
|
|
186
191
|
infura: rpcs.infuraRpcUrls.kovan,
|
|
187
|
-
|
|
192
|
+
public: rpcs.publicRpcUrls.kovan
|
|
188
193
|
},
|
|
189
194
|
blockExplorers: {
|
|
190
195
|
etherscan: etherscanBlockExplorers.kovan,
|
|
@@ -207,8 +212,9 @@ const optimism = {
|
|
|
207
212
|
},
|
|
208
213
|
rpcUrls: {
|
|
209
214
|
alchemy: rpcs.alchemyRpcUrls.optimism,
|
|
215
|
+
default: rpcs.publicRpcUrls.optimism,
|
|
210
216
|
infura: rpcs.infuraRpcUrls.optimism,
|
|
211
|
-
|
|
217
|
+
public: rpcs.publicRpcUrls.optimism
|
|
212
218
|
},
|
|
213
219
|
blockExplorers: {
|
|
214
220
|
etherscan: etherscanBlockExplorers.optimism,
|
|
@@ -230,8 +236,9 @@ const optimismKovan = {
|
|
|
230
236
|
},
|
|
231
237
|
rpcUrls: {
|
|
232
238
|
alchemy: rpcs.alchemyRpcUrls.optimismKovan,
|
|
239
|
+
default: rpcs.publicRpcUrls.optimismKovan,
|
|
233
240
|
infura: rpcs.infuraRpcUrls.optimismKovan,
|
|
234
|
-
|
|
241
|
+
public: rpcs.publicRpcUrls.optimismKovan
|
|
235
242
|
},
|
|
236
243
|
blockExplorers: {
|
|
237
244
|
etherscan: etherscanBlockExplorers.optimismKovan,
|
|
@@ -254,8 +261,9 @@ const polygon = {
|
|
|
254
261
|
},
|
|
255
262
|
rpcUrls: {
|
|
256
263
|
alchemy: rpcs.alchemyRpcUrls.polygon,
|
|
264
|
+
default: rpcs.publicRpcUrls.polygon,
|
|
257
265
|
infura: rpcs.infuraRpcUrls.polygon,
|
|
258
|
-
|
|
266
|
+
public: rpcs.publicRpcUrls.polygon
|
|
259
267
|
},
|
|
260
268
|
blockExplorers: {
|
|
261
269
|
etherscan: etherscanBlockExplorers.polygon,
|
|
@@ -277,8 +285,9 @@ const polygonMumbai = {
|
|
|
277
285
|
},
|
|
278
286
|
rpcUrls: {
|
|
279
287
|
alchemy: rpcs.alchemyRpcUrls.polygonMumbai,
|
|
288
|
+
default: rpcs.publicRpcUrls.polygonMumbai,
|
|
280
289
|
infura: rpcs.infuraRpcUrls.polygonMumbai,
|
|
281
|
-
|
|
290
|
+
public: rpcs.publicRpcUrls.polygonMumbai
|
|
282
291
|
},
|
|
283
292
|
blockExplorers: {
|
|
284
293
|
etherscan: etherscanBlockExplorers.polygonMumbai,
|
|
@@ -301,8 +310,9 @@ const arbitrum = {
|
|
|
301
310
|
},
|
|
302
311
|
rpcUrls: {
|
|
303
312
|
alchemy: rpcs.alchemyRpcUrls.arbitrum,
|
|
313
|
+
default: rpcs.publicRpcUrls.arbitrum,
|
|
304
314
|
infura: rpcs.infuraRpcUrls.arbitrum,
|
|
305
|
-
|
|
315
|
+
public: rpcs.publicRpcUrls.arbitrum
|
|
306
316
|
},
|
|
307
317
|
blockExplorers: {
|
|
308
318
|
arbitrum: {
|
|
@@ -328,8 +338,9 @@ const arbitrumRinkeby = {
|
|
|
328
338
|
},
|
|
329
339
|
rpcUrls: {
|
|
330
340
|
alchemy: rpcs.alchemyRpcUrls.arbitrumRinkeby,
|
|
341
|
+
default: rpcs.publicRpcUrls.arbitrumRinkeby,
|
|
331
342
|
infura: rpcs.infuraRpcUrls.arbitrumRinkeby,
|
|
332
|
-
|
|
343
|
+
public: rpcs.publicRpcUrls.arbitrumRinkeby
|
|
333
344
|
},
|
|
334
345
|
blockExplorers: {
|
|
335
346
|
arbitrum: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var base = require('./base-
|
|
3
|
+
var base = require('./base-2d484f6c.cjs.prod.js');
|
|
4
4
|
var create = require('zustand/vanilla');
|
|
5
5
|
var middleware = require('zustand/middleware');
|
|
6
6
|
var ethers = require('ethers');
|
|
@@ -269,18 +269,24 @@ class InjectedConnector extends base.Connector {
|
|
|
269
269
|
}
|
|
270
270
|
};
|
|
271
271
|
} catch (error) {
|
|
272
|
+
var _data, _data$originalError;
|
|
273
|
+
|
|
272
274
|
const chain = this.chains.find(x => x.id === chainId);
|
|
273
275
|
if (!chain) throw new base.ChainNotConfiguredError(); // Indicates chain is not added to provider
|
|
274
276
|
|
|
275
|
-
if (error.code === 4902
|
|
277
|
+
if (error.code === 4902 || // Unwrapping for MetaMask Mobile
|
|
278
|
+
// https://github.com/MetaMask/metamask-mobile/issues/2944#issuecomment-976988719
|
|
279
|
+
(error === null || error === void 0 ? void 0 : (_data = error.data) === null || _data === void 0 ? void 0 : (_data$originalError = _data.originalError) === null || _data$originalError === void 0 ? void 0 : _data$originalError.code) === 4902) {
|
|
276
280
|
try {
|
|
281
|
+
var _chain$rpcUrls$public;
|
|
282
|
+
|
|
277
283
|
await provider.request({
|
|
278
284
|
method: 'wallet_addEthereumChain',
|
|
279
285
|
params: [{
|
|
280
286
|
chainId: id,
|
|
281
287
|
chainName: chain.name,
|
|
282
288
|
nativeCurrency: chain.nativeCurrency,
|
|
283
|
-
rpcUrls: [chain.rpcUrls.default],
|
|
289
|
+
rpcUrls: [(_chain$rpcUrls$public = chain.rpcUrls.public) !== null && _chain$rpcUrls$public !== void 0 ? _chain$rpcUrls$public : chain.rpcUrls.default],
|
|
284
290
|
blockExplorerUrls: this.getBlockExplorerUrls(chain)
|
|
285
291
|
}]
|
|
286
292
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var base = require('./base-
|
|
3
|
+
var base = require('./base-e71ae4b2.cjs.dev.js');
|
|
4
4
|
var create = require('zustand/vanilla');
|
|
5
5
|
var middleware = require('zustand/middleware');
|
|
6
6
|
var ethers = require('ethers');
|
|
@@ -269,18 +269,24 @@ class InjectedConnector extends base.Connector {
|
|
|
269
269
|
}
|
|
270
270
|
};
|
|
271
271
|
} catch (error) {
|
|
272
|
+
var _data, _data$originalError;
|
|
273
|
+
|
|
272
274
|
const chain = this.chains.find(x => x.id === chainId);
|
|
273
275
|
if (!chain) throw new base.ChainNotConfiguredError(); // Indicates chain is not added to provider
|
|
274
276
|
|
|
275
|
-
if (error.code === 4902
|
|
277
|
+
if (error.code === 4902 || // Unwrapping for MetaMask Mobile
|
|
278
|
+
// https://github.com/MetaMask/metamask-mobile/issues/2944#issuecomment-976988719
|
|
279
|
+
(error === null || error === void 0 ? void 0 : (_data = error.data) === null || _data === void 0 ? void 0 : (_data$originalError = _data.originalError) === null || _data$originalError === void 0 ? void 0 : _data$originalError.code) === 4902) {
|
|
276
280
|
try {
|
|
281
|
+
var _chain$rpcUrls$public;
|
|
282
|
+
|
|
277
283
|
await provider.request({
|
|
278
284
|
method: 'wallet_addEthereumChain',
|
|
279
285
|
params: [{
|
|
280
286
|
chainId: id,
|
|
281
287
|
chainName: chain.name,
|
|
282
288
|
nativeCurrency: chain.nativeCurrency,
|
|
283
|
-
rpcUrls: [chain.rpcUrls.default],
|
|
289
|
+
rpcUrls: [(_chain$rpcUrls$public = chain.rpcUrls.public) !== null && _chain$rpcUrls$public !== void 0 ? _chain$rpcUrls$public : chain.rpcUrls.default],
|
|
284
290
|
blockExplorerUrls: this.getBlockExplorerUrls(chain)
|
|
285
291
|
}]
|
|
286
292
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as Connector, _ as _classPrivateMethodInitSpec, i as _defineProperty, j as _classPrivateFieldInitSpec, n as normalizeChainId, k as _classPrivateFieldGet, l as _classPrivateFieldSet, b as ConnectorNotFoundError, m as _classPrivateMethodGet, U as UserRejectedRequestError, R as ResourceUnavailableError, e as ChainNotConfiguredError, A as AddChainError, h as SwitchChainError } from './base-
|
|
1
|
+
import { d as Connector, _ as _classPrivateMethodInitSpec, i as _defineProperty, j as _classPrivateFieldInitSpec, n as normalizeChainId, k as _classPrivateFieldGet, l as _classPrivateFieldSet, b as ConnectorNotFoundError, m as _classPrivateMethodGet, U as UserRejectedRequestError, R as ResourceUnavailableError, e as ChainNotConfiguredError, A as AddChainError, h as SwitchChainError } from './base-e66f9622.esm.js';
|
|
2
2
|
import create from 'zustand/vanilla';
|
|
3
3
|
import { subscribeWithSelector, persist } from 'zustand/middleware';
|
|
4
4
|
import { providers } from 'ethers';
|
|
@@ -263,18 +263,24 @@ class InjectedConnector extends Connector {
|
|
|
263
263
|
}
|
|
264
264
|
};
|
|
265
265
|
} catch (error) {
|
|
266
|
+
var _data, _data$originalError;
|
|
267
|
+
|
|
266
268
|
const chain = this.chains.find(x => x.id === chainId);
|
|
267
269
|
if (!chain) throw new ChainNotConfiguredError(); // Indicates chain is not added to provider
|
|
268
270
|
|
|
269
|
-
if (error.code === 4902
|
|
271
|
+
if (error.code === 4902 || // Unwrapping for MetaMask Mobile
|
|
272
|
+
// https://github.com/MetaMask/metamask-mobile/issues/2944#issuecomment-976988719
|
|
273
|
+
(error === null || error === void 0 ? void 0 : (_data = error.data) === null || _data === void 0 ? void 0 : (_data$originalError = _data.originalError) === null || _data$originalError === void 0 ? void 0 : _data$originalError.code) === 4902) {
|
|
270
274
|
try {
|
|
275
|
+
var _chain$rpcUrls$public;
|
|
276
|
+
|
|
271
277
|
await provider.request({
|
|
272
278
|
method: 'wallet_addEthereumChain',
|
|
273
279
|
params: [{
|
|
274
280
|
chainId: id,
|
|
275
281
|
chainName: chain.name,
|
|
276
282
|
nativeCurrency: chain.nativeCurrency,
|
|
277
|
-
rpcUrls: [chain.rpcUrls.default],
|
|
283
|
+
rpcUrls: [(_chain$rpcUrls$public = chain.rpcUrls.public) !== null && _chain$rpcUrls$public !== void 0 ? _chain$rpcUrls$public : chain.rpcUrls.default],
|
|
278
284
|
blockExplorerUrls: this.getBlockExplorerUrls(chain)
|
|
279
285
|
}]
|
|
280
286
|
});
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BytesLike } from 'ethers';
|
|
2
2
|
export declare type SignTypedDataArgs = {
|
|
3
3
|
/** Domain or domain signature for origin or contract */
|
|
4
4
|
domain: {
|
|
5
5
|
name?: string;
|
|
6
6
|
version?: string;
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Chain permitted for signing
|
|
9
|
+
* If signer is not active on this chain, it will attempt to programmatically switch
|
|
10
|
+
*/
|
|
11
|
+
chainId?: string | number | bigint;
|
|
8
12
|
verifyingContract?: string;
|
|
9
13
|
salt?: BytesLike;
|
|
10
14
|
};
|
|
@@ -17,4 +21,4 @@ export declare type SignTypedDataArgs = {
|
|
|
17
21
|
value: Record<string, any>;
|
|
18
22
|
};
|
|
19
23
|
export declare type SignTypedDataResult = string;
|
|
20
|
-
export declare function signTypedData(
|
|
24
|
+
export declare function signTypedData({ domain, types, value, }: SignTypedDataArgs): Promise<SignTypedDataResult>;
|
|
@@ -25,8 +25,9 @@ export declare class WalletConnectConnector extends Connector<WalletConnectProvi
|
|
|
25
25
|
disconnect(): Promise<void>;
|
|
26
26
|
getAccount(): Promise<string>;
|
|
27
27
|
getChainId(): Promise<number>;
|
|
28
|
-
getProvider({ chainId }?: {
|
|
28
|
+
getProvider({ chainId, create, }?: {
|
|
29
29
|
chainId?: number;
|
|
30
|
+
create?: boolean;
|
|
30
31
|
}): Promise<WalletConnectProvider>;
|
|
31
32
|
getSigner({ chainId }?: {
|
|
32
33
|
chainId?: number;
|
|
@@ -3,6 +3,6 @@ export { etherscanBlockExplorers } from './blockExplorers';
|
|
|
3
3
|
export type { BlockExplorer, BlockExplorerName } from './blockExplorers';
|
|
4
4
|
export { chain, chainId, allChains, defaultChains, defaultL2Chains, } from './chains';
|
|
5
5
|
export { multicallInterface } from './multicall';
|
|
6
|
-
export { alchemyRpcUrls, defaultAlchemyId, infuraRpcUrls,
|
|
6
|
+
export { alchemyRpcUrls, defaultAlchemyId, defaultInfuraId, infuraRpcUrls, publicRpcUrls, } from './rpcs';
|
|
7
7
|
export type { RpcProviderName } from './rpcs';
|
|
8
8
|
export { units } from './units';
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { ChainName } from './chains';
|
|
2
2
|
export declare const defaultAlchemyId = "_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC";
|
|
3
3
|
export declare const defaultInfuraId = "84842078b09946638c03157f83405213";
|
|
4
|
-
export declare type RpcProviderName = 'alchemy' | 'infura';
|
|
4
|
+
export declare type RpcProviderName = 'alchemy' | 'infura' | 'public';
|
|
5
5
|
declare type AlchemyChains = Extract<ChainName, 'mainnet' | 'ropsten' | 'rinkeby' | 'goerli' | 'kovan' | 'optimism' | 'optimismKovan' | 'polygon' | 'polygonMumbai' | 'arbitrum' | 'arbitrumRinkeby'>;
|
|
6
6
|
export declare const alchemyRpcUrls: Record<AlchemyChains, string>;
|
|
7
7
|
declare type InfuraChains = Extract<ChainName, 'mainnet' | 'ropsten' | 'rinkeby' | 'goerli' | 'kovan' | 'optimism' | 'optimismKovan' | 'polygon' | 'polygonMumbai' | 'arbitrum' | 'arbitrumRinkeby'>;
|
|
8
8
|
export declare const infuraRpcUrls: Record<InfuraChains, string>;
|
|
9
|
+
declare type PublicChains = Extract<ChainName, 'mainnet' | 'ropsten' | 'rinkeby' | 'goerli' | 'kovan' | 'optimism' | 'optimismKovan' | 'polygon' | 'polygonMumbai' | 'arbitrum' | 'arbitrumRinkeby'>;
|
|
10
|
+
export declare const publicRpcUrls: Record<PublicChains, string>;
|
|
9
11
|
export {};
|
|
@@ -4,7 +4,7 @@ export { createClient, Client } from './client';
|
|
|
4
4
|
export type { ClientConfig } from './client';
|
|
5
5
|
export { Connector, InjectedConnector } from './connectors';
|
|
6
6
|
export type { ConnectorData, ConnectorEvents } from './connectors';
|
|
7
|
-
export { alchemyRpcUrls, allChains, chain, chainId, defaultChains, defaultL2Chains, erc20ABI, erc721ABI, etherscanBlockExplorers, infuraRpcUrls, units, } from './constants';
|
|
7
|
+
export { alchemyRpcUrls, allChains, chain, chainId, defaultChains, defaultL2Chains, erc20ABI, erc721ABI, etherscanBlockExplorers, infuraRpcUrls, publicRpcUrls, units, } from './constants';
|
|
8
8
|
export { AddChainError, ChainDoesNotSupportMulticallError, ChainMismatchError, ChainNotConfiguredError, ConnectorAlreadyConnectedError, ConnectorNotFoundError, 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';
|
|
@@ -35,7 +35,7 @@ export declare type Chain = {
|
|
|
35
35
|
/** Flag for test networks */
|
|
36
36
|
testnet?: boolean;
|
|
37
37
|
};
|
|
38
|
-
export declare type ChainProviderFn<TProvider extends Provider =
|
|
38
|
+
export declare type ChainProviderFn<TProvider extends Provider = providers.BaseProvider, TWebSocketProvider extends WebSocketProvider = providers.WebSocketProvider, TChain extends Chain = Chain> = (chain: TChain) => {
|
|
39
39
|
chain: TChain;
|
|
40
40
|
provider: () => ProviderWithFallbackConfig<TProvider>;
|
|
41
41
|
webSocketProvider?: () => TWebSocketProvider;
|
|
@@ -20,7 +20,7 @@ export declare function configureChains<TProvider extends Provider = Provider, T
|
|
|
20
20
|
});
|
|
21
21
|
readonly webSocketProvider: ({ chainId }: {
|
|
22
22
|
chainId?: number | undefined;
|
|
23
|
-
}) => {
|
|
23
|
+
}) => (TWebSocketProvider & {
|
|
24
24
|
chains: TChain[];
|
|
25
|
-
} | undefined;
|
|
25
|
+
}) | undefined;
|
|
26
26
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function normalizeChainId(chainId: string | number): number;
|
|
1
|
+
export declare function normalizeChainId(chainId: string | number | bigint): number;
|
|
@@ -28,8 +28,22 @@ const infuraRpcUrls = {
|
|
|
28
28
|
arbitrum: 'https://arbitrum-mainnet.infura.io/v3',
|
|
29
29
|
arbitrumRinkeby: 'https://arbitrum-rinkeby.infura.io/v3'
|
|
30
30
|
};
|
|
31
|
+
const publicRpcUrls = {
|
|
32
|
+
mainnet: "".concat(alchemyRpcUrls.mainnet, "/").concat(defaultAlchemyId),
|
|
33
|
+
ropsten: "".concat(alchemyRpcUrls.ropsten, "/").concat(defaultAlchemyId),
|
|
34
|
+
rinkeby: "".concat(alchemyRpcUrls.rinkeby, "/").concat(defaultAlchemyId),
|
|
35
|
+
goerli: "".concat(alchemyRpcUrls.goerli, "/").concat(defaultAlchemyId),
|
|
36
|
+
kovan: "".concat(alchemyRpcUrls.kovan, "/").concat(defaultAlchemyId),
|
|
37
|
+
optimism: 'https://mainnet.optimism.io',
|
|
38
|
+
optimismKovan: 'https://kovan.optimism.io',
|
|
39
|
+
polygon: 'https://polygon-rpc.com',
|
|
40
|
+
polygonMumbai: 'https://matic-mumbai.chainstacklabs.com',
|
|
41
|
+
arbitrum: 'https://arb1.arbitrum.io/rpc',
|
|
42
|
+
arbitrumRinkeby: 'https://rinkeby.arbitrum.io/rpc'
|
|
43
|
+
};
|
|
31
44
|
|
|
32
45
|
exports.alchemyRpcUrls = alchemyRpcUrls;
|
|
33
46
|
exports.defaultAlchemyId = defaultAlchemyId;
|
|
34
47
|
exports.defaultInfuraId = defaultInfuraId;
|
|
35
48
|
exports.infuraRpcUrls = infuraRpcUrls;
|
|
49
|
+
exports.publicRpcUrls = publicRpcUrls;
|
|
@@ -26,5 +26,18 @@ const infuraRpcUrls = {
|
|
|
26
26
|
arbitrum: 'https://arbitrum-mainnet.infura.io/v3',
|
|
27
27
|
arbitrumRinkeby: 'https://arbitrum-rinkeby.infura.io/v3'
|
|
28
28
|
};
|
|
29
|
+
const publicRpcUrls = {
|
|
30
|
+
mainnet: "".concat(alchemyRpcUrls.mainnet, "/").concat(defaultAlchemyId),
|
|
31
|
+
ropsten: "".concat(alchemyRpcUrls.ropsten, "/").concat(defaultAlchemyId),
|
|
32
|
+
rinkeby: "".concat(alchemyRpcUrls.rinkeby, "/").concat(defaultAlchemyId),
|
|
33
|
+
goerli: "".concat(alchemyRpcUrls.goerli, "/").concat(defaultAlchemyId),
|
|
34
|
+
kovan: "".concat(alchemyRpcUrls.kovan, "/").concat(defaultAlchemyId),
|
|
35
|
+
optimism: 'https://mainnet.optimism.io',
|
|
36
|
+
optimismKovan: 'https://kovan.optimism.io',
|
|
37
|
+
polygon: 'https://polygon-rpc.com',
|
|
38
|
+
polygonMumbai: 'https://matic-mumbai.chainstacklabs.com',
|
|
39
|
+
arbitrum: 'https://arb1.arbitrum.io/rpc',
|
|
40
|
+
arbitrumRinkeby: 'https://rinkeby.arbitrum.io/rpc'
|
|
41
|
+
};
|
|
29
42
|
|
|
30
|
-
export { alchemyRpcUrls as a, defaultInfuraId as b, defaultAlchemyId as d, infuraRpcUrls as i };
|
|
43
|
+
export { alchemyRpcUrls as a, defaultInfuraId as b, defaultAlchemyId as d, infuraRpcUrls as i, publicRpcUrls as p };
|
|
@@ -28,8 +28,22 @@ const infuraRpcUrls = {
|
|
|
28
28
|
arbitrum: 'https://arbitrum-mainnet.infura.io/v3',
|
|
29
29
|
arbitrumRinkeby: 'https://arbitrum-rinkeby.infura.io/v3'
|
|
30
30
|
};
|
|
31
|
+
const publicRpcUrls = {
|
|
32
|
+
mainnet: "".concat(alchemyRpcUrls.mainnet, "/").concat(defaultAlchemyId),
|
|
33
|
+
ropsten: "".concat(alchemyRpcUrls.ropsten, "/").concat(defaultAlchemyId),
|
|
34
|
+
rinkeby: "".concat(alchemyRpcUrls.rinkeby, "/").concat(defaultAlchemyId),
|
|
35
|
+
goerli: "".concat(alchemyRpcUrls.goerli, "/").concat(defaultAlchemyId),
|
|
36
|
+
kovan: "".concat(alchemyRpcUrls.kovan, "/").concat(defaultAlchemyId),
|
|
37
|
+
optimism: 'https://mainnet.optimism.io',
|
|
38
|
+
optimismKovan: 'https://kovan.optimism.io',
|
|
39
|
+
polygon: 'https://polygon-rpc.com',
|
|
40
|
+
polygonMumbai: 'https://matic-mumbai.chainstacklabs.com',
|
|
41
|
+
arbitrum: 'https://arb1.arbitrum.io/rpc',
|
|
42
|
+
arbitrumRinkeby: 'https://rinkeby.arbitrum.io/rpc'
|
|
43
|
+
};
|
|
31
44
|
|
|
32
45
|
exports.alchemyRpcUrls = alchemyRpcUrls;
|
|
33
46
|
exports.defaultAlchemyId = defaultAlchemyId;
|
|
34
47
|
exports.defaultInfuraId = defaultInfuraId;
|
|
35
48
|
exports.infuraRpcUrls = infuraRpcUrls;
|
|
49
|
+
exports.publicRpcUrls = publicRpcUrls;
|
|
@@ -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-53f2119c.cjs.dev.js');
|
|
6
|
+
var base = require('./base-e71ae4b2.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
|
-
var rpcs = require('./rpcs-
|
|
12
|
-
var chains = require('./chains-
|
|
11
|
+
var rpcs = require('./rpcs-f1d24f0e.cjs.dev.js');
|
|
12
|
+
var chains = require('./chains-d970ee8d.cjs.dev.js');
|
|
13
13
|
require('zustand/vanilla');
|
|
14
14
|
require('zustand/middleware');
|
|
15
15
|
require('eventemitter3');
|
|
@@ -84,20 +84,17 @@ function configureChains(defaultChains, providers) {
|
|
|
84
84
|
});
|
|
85
85
|
},
|
|
86
86
|
webSocketProvider: _ref3 => {
|
|
87
|
-
var _defaultChains$2, _chainWebSocketProvid
|
|
87
|
+
var _defaultChains$2, _chainWebSocketProvid;
|
|
88
88
|
|
|
89
89
|
let {
|
|
90
90
|
chainId
|
|
91
91
|
} = _ref3;
|
|
92
92
|
const activeChainId = chainId && chains.some(x => x.id === chainId) ? chainId : (_defaultChains$2 = defaultChains[0]) === null || _defaultChains$2 === void 0 ? void 0 : _defaultChains$2.id;
|
|
93
93
|
const chainWebSocketProviders = webSocketProviders_[activeChainId];
|
|
94
|
-
if (!chainWebSocketProviders) return undefined;
|
|
95
|
-
if (chainWebSocketProviders.length === 1) return Object.assign(((_chainWebSocketProvid = chainWebSocketProviders[0]) === null || _chainWebSocketProvid === void 0 ? void 0 : _chainWebSocketProvid.call(chainWebSocketProviders)) || {}, {
|
|
96
|
-
chains
|
|
97
|
-
}); // WebSockets do not work with `fallbackProvider`
|
|
94
|
+
if (!chainWebSocketProviders) return undefined; // WebSockets do not work with `fallbackProvider`
|
|
98
95
|
// Default to first available
|
|
99
96
|
|
|
100
|
-
return Object.assign(((
|
|
97
|
+
return Object.assign(((_chainWebSocketProvid = chainWebSocketProviders[0]) === null || _chainWebSocketProvid === void 0 ? void 0 : _chainWebSocketProvid.call(chainWebSocketProviders)) || {}, {
|
|
101
98
|
chains
|
|
102
99
|
});
|
|
103
100
|
}
|
|
@@ -790,12 +787,44 @@ async function signMessage(args) {
|
|
|
790
787
|
}
|
|
791
788
|
}
|
|
792
789
|
|
|
793
|
-
async function signTypedData(
|
|
790
|
+
async function signTypedData(_ref) {
|
|
791
|
+
let {
|
|
792
|
+
domain,
|
|
793
|
+
types,
|
|
794
|
+
value
|
|
795
|
+
} = _ref;
|
|
796
|
+
const {
|
|
797
|
+
connector
|
|
798
|
+
} = client.getClient();
|
|
799
|
+
if (!connector) throw new base.ConnectorNotFoundError();
|
|
800
|
+
|
|
794
801
|
try {
|
|
795
|
-
|
|
796
|
-
|
|
802
|
+
var _chain;
|
|
803
|
+
|
|
804
|
+
const {
|
|
805
|
+
chainId
|
|
806
|
+
} = domain;
|
|
807
|
+
let chain;
|
|
808
|
+
|
|
809
|
+
if (chainId) {
|
|
810
|
+
const chainId_ = base.normalizeChainId(chainId);
|
|
811
|
+
const activeChainId = await connector.getChainId(); // Try to switch chain to provided `chainId`
|
|
812
|
+
|
|
813
|
+
if (chainId !== activeChainId) {
|
|
814
|
+
var _connector$chains$fin, _connector$chains$fin2, _connector$chains$fin3, _connector$chains$fin4;
|
|
815
|
+
|
|
816
|
+
if (connector.switchChain) chain = await connector.switchChain(chainId_);else throw new base.ChainMismatchError({
|
|
817
|
+
activeChain: (_connector$chains$fin = (_connector$chains$fin2 = connector.chains.find(x => x.id === activeChainId)) === null || _connector$chains$fin2 === void 0 ? void 0 : _connector$chains$fin2.name) !== null && _connector$chains$fin !== void 0 ? _connector$chains$fin : "Chain ".concat(activeChainId),
|
|
818
|
+
targetChain: (_connector$chains$fin3 = (_connector$chains$fin4 = connector.chains.find(x => x.id === chainId_)) === null || _connector$chains$fin4 === void 0 ? void 0 : _connector$chains$fin4.name) !== null && _connector$chains$fin3 !== void 0 ? _connector$chains$fin3 : "Chain ".concat(chainId_)
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
const signer = await connector.getSigner({
|
|
824
|
+
chainId: (_chain = chain) === null || _chain === void 0 ? void 0 : _chain.id
|
|
825
|
+
}); // Method name may be changed in the future, see https://docs.ethers.io/v5/api/signer/#Signer-signTypedData
|
|
797
826
|
|
|
798
|
-
return await signer._signTypedData(
|
|
827
|
+
return await signer._signTypedData(domain, types, value);
|
|
799
828
|
} catch (error) {
|
|
800
829
|
if (error.code === 4001) throw new base.UserRejectedRequestError(error);
|
|
801
830
|
throw error;
|
|
@@ -1065,6 +1094,7 @@ exports.UserRejectedRequestError = base.UserRejectedRequestError;
|
|
|
1065
1094
|
exports.normalizeChainId = base.normalizeChainId;
|
|
1066
1095
|
exports.alchemyRpcUrls = rpcs.alchemyRpcUrls;
|
|
1067
1096
|
exports.infuraRpcUrls = rpcs.infuraRpcUrls;
|
|
1097
|
+
exports.publicRpcUrls = rpcs.publicRpcUrls;
|
|
1068
1098
|
exports.allChains = chains.allChains;
|
|
1069
1099
|
exports.chain = chains.chain;
|
|
1070
1100
|
exports.chainId = chains.chainId;
|
|
@@ -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-1feb9121.cjs.prod.js');
|
|
6
|
+
var base = require('./base-2d484f6c.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
|
-
var rpcs = require('./rpcs-
|
|
12
|
-
var chains = require('./chains-
|
|
11
|
+
var rpcs = require('./rpcs-1fd0a12f.cjs.prod.js');
|
|
12
|
+
var chains = require('./chains-865492ea.cjs.prod.js');
|
|
13
13
|
require('zustand/vanilla');
|
|
14
14
|
require('zustand/middleware');
|
|
15
15
|
require('eventemitter3');
|
|
@@ -84,20 +84,17 @@ function configureChains(defaultChains, providers) {
|
|
|
84
84
|
});
|
|
85
85
|
},
|
|
86
86
|
webSocketProvider: _ref3 => {
|
|
87
|
-
var _defaultChains$2, _chainWebSocketProvid
|
|
87
|
+
var _defaultChains$2, _chainWebSocketProvid;
|
|
88
88
|
|
|
89
89
|
let {
|
|
90
90
|
chainId
|
|
91
91
|
} = _ref3;
|
|
92
92
|
const activeChainId = chainId && chains.some(x => x.id === chainId) ? chainId : (_defaultChains$2 = defaultChains[0]) === null || _defaultChains$2 === void 0 ? void 0 : _defaultChains$2.id;
|
|
93
93
|
const chainWebSocketProviders = webSocketProviders_[activeChainId];
|
|
94
|
-
if (!chainWebSocketProviders) return undefined;
|
|
95
|
-
if (chainWebSocketProviders.length === 1) return Object.assign(((_chainWebSocketProvid = chainWebSocketProviders[0]) === null || _chainWebSocketProvid === void 0 ? void 0 : _chainWebSocketProvid.call(chainWebSocketProviders)) || {}, {
|
|
96
|
-
chains
|
|
97
|
-
}); // WebSockets do not work with `fallbackProvider`
|
|
94
|
+
if (!chainWebSocketProviders) return undefined; // WebSockets do not work with `fallbackProvider`
|
|
98
95
|
// Default to first available
|
|
99
96
|
|
|
100
|
-
return Object.assign(((
|
|
97
|
+
return Object.assign(((_chainWebSocketProvid = chainWebSocketProviders[0]) === null || _chainWebSocketProvid === void 0 ? void 0 : _chainWebSocketProvid.call(chainWebSocketProviders)) || {}, {
|
|
101
98
|
chains
|
|
102
99
|
});
|
|
103
100
|
}
|
|
@@ -790,12 +787,44 @@ async function signMessage(args) {
|
|
|
790
787
|
}
|
|
791
788
|
}
|
|
792
789
|
|
|
793
|
-
async function signTypedData(
|
|
790
|
+
async function signTypedData(_ref) {
|
|
791
|
+
let {
|
|
792
|
+
domain,
|
|
793
|
+
types,
|
|
794
|
+
value
|
|
795
|
+
} = _ref;
|
|
796
|
+
const {
|
|
797
|
+
connector
|
|
798
|
+
} = client.getClient();
|
|
799
|
+
if (!connector) throw new base.ConnectorNotFoundError();
|
|
800
|
+
|
|
794
801
|
try {
|
|
795
|
-
|
|
796
|
-
|
|
802
|
+
var _chain;
|
|
803
|
+
|
|
804
|
+
const {
|
|
805
|
+
chainId
|
|
806
|
+
} = domain;
|
|
807
|
+
let chain;
|
|
808
|
+
|
|
809
|
+
if (chainId) {
|
|
810
|
+
const chainId_ = base.normalizeChainId(chainId);
|
|
811
|
+
const activeChainId = await connector.getChainId(); // Try to switch chain to provided `chainId`
|
|
812
|
+
|
|
813
|
+
if (chainId !== activeChainId) {
|
|
814
|
+
var _connector$chains$fin, _connector$chains$fin2, _connector$chains$fin3, _connector$chains$fin4;
|
|
815
|
+
|
|
816
|
+
if (connector.switchChain) chain = await connector.switchChain(chainId_);else throw new base.ChainMismatchError({
|
|
817
|
+
activeChain: (_connector$chains$fin = (_connector$chains$fin2 = connector.chains.find(x => x.id === activeChainId)) === null || _connector$chains$fin2 === void 0 ? void 0 : _connector$chains$fin2.name) !== null && _connector$chains$fin !== void 0 ? _connector$chains$fin : "Chain ".concat(activeChainId),
|
|
818
|
+
targetChain: (_connector$chains$fin3 = (_connector$chains$fin4 = connector.chains.find(x => x.id === chainId_)) === null || _connector$chains$fin4 === void 0 ? void 0 : _connector$chains$fin4.name) !== null && _connector$chains$fin3 !== void 0 ? _connector$chains$fin3 : "Chain ".concat(chainId_)
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
const signer = await connector.getSigner({
|
|
824
|
+
chainId: (_chain = chain) === null || _chain === void 0 ? void 0 : _chain.id
|
|
825
|
+
}); // Method name may be changed in the future, see https://docs.ethers.io/v5/api/signer/#Signer-signTypedData
|
|
797
826
|
|
|
798
|
-
return await signer._signTypedData(
|
|
827
|
+
return await signer._signTypedData(domain, types, value);
|
|
799
828
|
} catch (error) {
|
|
800
829
|
if (error.code === 4001) throw new base.UserRejectedRequestError(error);
|
|
801
830
|
throw error;
|
|
@@ -1065,6 +1094,7 @@ exports.UserRejectedRequestError = base.UserRejectedRequestError;
|
|
|
1065
1094
|
exports.normalizeChainId = base.normalizeChainId;
|
|
1066
1095
|
exports.alchemyRpcUrls = rpcs.alchemyRpcUrls;
|
|
1067
1096
|
exports.infuraRpcUrls = rpcs.infuraRpcUrls;
|
|
1097
|
+
exports.publicRpcUrls = rpcs.publicRpcUrls;
|
|
1068
1098
|
exports.allChains = chains.allChains;
|
|
1069
1099
|
exports.chain = chains.chain;
|
|
1070
1100
|
exports.chainId = chains.chainId;
|