@wagmi/core 0.2.0-next.9 → 0.2.2
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/LICENSE +1 -1
- package/README.md +30 -0
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.d.ts +1 -11
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.dev.js +234 -0
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.js +6 -15
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.prod.js +234 -0
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.esm.js +212 -0
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.d.ts +1 -0
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.dev.js +62 -0
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.js +7 -0
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.prod.js +62 -0
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.esm.js +58 -0
- package/connectors/metaMask/package.json +4 -0
- package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.d.ts +1 -11
- package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.dev.js +250 -0
- package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.js +6 -15
- package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.prod.js +250 -0
- package/connectors/mock/dist/wagmi-core-connectors-mock.esm.js +241 -0
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.d.ts +1 -11
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.dev.js +183 -0
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.js +6 -15
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.prod.js +183 -0
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.esm.js +161 -0
- package/dist/base-159de546.esm.js +513 -0
- package/dist/base-5812b724.cjs.dev.js +540 -0
- package/dist/base-59f3457e.cjs.prod.js +540 -0
- package/dist/classPrivateMethodGet-55c9909f.esm.js +16 -0
- package/dist/classPrivateMethodGet-976c8120.cjs.dev.js +19 -0
- package/dist/classPrivateMethodGet-d7330ed7.cjs.prod.js +19 -0
- package/dist/client-4d8337e7.cjs.prod.js +606 -0
- package/dist/client-5d456446.esm.js +595 -0
- package/dist/client-f77a08e4.cjs.dev.js +606 -0
- package/dist/declarations/src/actions/accounts/connect.d.ts +16 -0
- package/dist/declarations/src/actions/accounts/disconnect.d.ts +1 -0
- package/dist/declarations/src/actions/accounts/fetchBalance.d.ts +20 -0
- package/dist/declarations/src/actions/accounts/fetchSigner.d.ts +3 -0
- package/dist/declarations/src/actions/accounts/getAccount.d.ts +7 -0
- package/dist/declarations/src/actions/accounts/getNetwork.d.ts +9 -0
- package/dist/declarations/src/actions/accounts/index.d.ts +12 -0
- package/dist/declarations/src/actions/accounts/signMessage.d.ts +9 -0
- package/dist/declarations/src/actions/accounts/signTypedData.d.ts +13 -0
- package/dist/declarations/src/actions/accounts/switchNetwork.d.ts +6 -0
- package/dist/declarations/src/actions/accounts/watchAccount.d.ts +4 -0
- package/dist/declarations/src/actions/accounts/watchNetwork.d.ts +3 -0
- package/dist/declarations/src/actions/accounts/watchSigner.d.ts +3 -0
- package/dist/declarations/src/actions/contracts/getContract.d.ts +11 -0
- package/dist/declarations/src/actions/contracts/index.d.ts +5 -0
- package/dist/declarations/src/actions/contracts/readContract.d.ts +14 -0
- package/dist/declarations/src/actions/contracts/watchContractEvent.d.ts +14 -0
- package/dist/declarations/src/actions/contracts/watchReadContract.d.ts +7 -0
- package/dist/declarations/src/actions/contracts/writeContract.d.ts +11 -0
- package/dist/declarations/src/actions/ens/fetchEnsAddress.d.ts +8 -0
- package/dist/declarations/src/actions/ens/fetchEnsAvatar.d.ts +8 -0
- package/dist/declarations/src/actions/ens/fetchEnsName.d.ts +8 -0
- package/dist/declarations/src/actions/ens/fetchEnsResolver.d.ts +9 -0
- package/dist/declarations/src/actions/ens/index.d.ts +4 -0
- package/dist/declarations/src/actions/index.d.ts +7 -0
- package/dist/declarations/src/actions/network-status/fetchBlockNumber.d.ts +5 -0
- package/dist/declarations/src/actions/network-status/fetchFeeData.d.ts +16 -0
- package/dist/declarations/src/actions/network-status/index.d.ts +3 -0
- package/dist/declarations/src/actions/network-status/watchBlockNumber.d.ts +6 -0
- package/dist/declarations/src/actions/providers/getProvider.d.ts +7 -0
- package/dist/declarations/src/actions/providers/getWebSocketProvider.d.ts +7 -0
- package/dist/declarations/src/actions/providers/index.d.ts +4 -0
- package/dist/declarations/src/actions/providers/watchProvider.d.ts +4 -0
- package/dist/declarations/src/actions/providers/watchWebSocketProvider.d.ts +4 -0
- package/dist/declarations/src/actions/tokens/fetchToken.d.ts +20 -0
- package/dist/declarations/src/actions/tokens/index.d.ts +1 -0
- package/dist/declarations/src/actions/transactions/index.d.ts +2 -0
- package/dist/declarations/src/actions/transactions/sendTransaction.d.ts +7 -0
- package/dist/declarations/src/actions/transactions/waitForTransaction.d.ts +17 -0
- package/dist/declarations/src/client.d.ts +81 -0
- package/dist/declarations/src/connectors/base.d.ts +55 -0
- package/dist/declarations/src/connectors/coinbaseWallet.d.ts +52 -0
- package/dist/declarations/src/connectors/index.d.ts +2 -0
- package/dist/declarations/src/connectors/injected.d.ts +48 -0
- package/dist/declarations/src/connectors/metaMask.d.ts +13 -0
- package/dist/declarations/src/connectors/mock/connector.d.ts +37 -0
- package/dist/declarations/src/connectors/mock/index.d.ts +2 -0
- package/dist/declarations/src/connectors/mock/provider.d.ts +42 -0
- package/dist/declarations/src/connectors/walletConnect.d.ts +32 -0
- package/dist/declarations/src/constants/abis.d.ts +2 -0
- package/dist/declarations/src/constants/blockExplorers.d.ts +9 -0
- package/dist/declarations/src/constants/chains.d.ts +21 -0
- package/dist/declarations/src/constants/index.d.ts +7 -0
- package/dist/declarations/src/constants/rpcs.d.ts +9 -0
- package/dist/declarations/src/constants/units.d.ts +1 -0
- package/dist/declarations/src/errors.d.ts +28 -0
- package/dist/declarations/src/index.d.ts +12 -0
- package/dist/declarations/src/storage.d.ts +12 -0
- package/dist/declarations/src/types/index.d.ts +101 -0
- package/dist/declarations/src/utils/getInjectedName.d.ts +1 -0
- package/dist/declarations/src/utils/index.d.ts +3 -0
- package/dist/declarations/src/utils/normalizeChainId.d.ts +1 -0
- package/dist/declarations/src/utils/warn.d.ts +1 -0
- package/dist/wagmi-core.cjs.d.ts +1 -11
- package/dist/wagmi-core.cjs.dev.js +653 -0
- package/dist/wagmi-core.cjs.js +6 -15
- package/dist/wagmi-core.cjs.prod.js +653 -0
- package/dist/wagmi-core.esm.js +593 -0
- package/package.json +24 -12
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
import EventEmitter from 'eventemitter3';
|
|
2
|
+
|
|
3
|
+
function _checkPrivateRedeclaration(obj, privateCollection) {
|
|
4
|
+
if (privateCollection.has(obj)) {
|
|
5
|
+
throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) {
|
|
10
|
+
_checkPrivateRedeclaration(obj, privateMap);
|
|
11
|
+
privateMap.set(obj, value);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function _defineProperty(obj, key, value) {
|
|
15
|
+
if (key in obj) {
|
|
16
|
+
Object.defineProperty(obj, key, {
|
|
17
|
+
value: value,
|
|
18
|
+
enumerable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
writable: true
|
|
21
|
+
});
|
|
22
|
+
} else {
|
|
23
|
+
obj[key] = value;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return obj;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function _classApplyDescriptorGet(receiver, descriptor) {
|
|
30
|
+
if (descriptor.get) {
|
|
31
|
+
return descriptor.get.call(receiver);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return descriptor.value;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function _classExtractFieldDescriptor(receiver, privateMap, action) {
|
|
38
|
+
if (!privateMap.has(receiver)) {
|
|
39
|
+
throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return privateMap.get(receiver);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function _classPrivateFieldGet(receiver, privateMap) {
|
|
46
|
+
var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get");
|
|
47
|
+
return _classApplyDescriptorGet(receiver, descriptor);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function _classApplyDescriptorSet(receiver, descriptor, value) {
|
|
51
|
+
if (descriptor.set) {
|
|
52
|
+
descriptor.set.call(receiver, value);
|
|
53
|
+
} else {
|
|
54
|
+
if (!descriptor.writable) {
|
|
55
|
+
throw new TypeError("attempted to set read only private field");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
descriptor.value = value;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function _classPrivateFieldSet(receiver, privateMap, value) {
|
|
63
|
+
var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set");
|
|
64
|
+
_classApplyDescriptorSet(receiver, descriptor, value);
|
|
65
|
+
return value;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const etherscanBlockExplorers = {
|
|
69
|
+
mainnet: {
|
|
70
|
+
name: 'Etherscan',
|
|
71
|
+
url: 'https://etherscan.io'
|
|
72
|
+
},
|
|
73
|
+
ropsten: {
|
|
74
|
+
name: 'Etherscan',
|
|
75
|
+
url: 'https://ropsten.etherscan.io'
|
|
76
|
+
},
|
|
77
|
+
rinkeby: {
|
|
78
|
+
name: 'Etherscan',
|
|
79
|
+
url: 'https://rinkeby.etherscan.io'
|
|
80
|
+
},
|
|
81
|
+
goerli: {
|
|
82
|
+
name: 'Etherscan',
|
|
83
|
+
url: 'https://goerli.etherscan.io'
|
|
84
|
+
},
|
|
85
|
+
kovan: {
|
|
86
|
+
name: 'Etherscan',
|
|
87
|
+
url: 'https://kovan.etherscan.io'
|
|
88
|
+
},
|
|
89
|
+
optimism: {
|
|
90
|
+
name: 'Etherscan',
|
|
91
|
+
url: 'https://optimistic.etherscan.io'
|
|
92
|
+
},
|
|
93
|
+
optimismKovan: {
|
|
94
|
+
name: 'Etherscan',
|
|
95
|
+
url: 'https://kovan-optimistic.etherscan.io'
|
|
96
|
+
},
|
|
97
|
+
polygon: {
|
|
98
|
+
name: 'PolygonScan',
|
|
99
|
+
url: 'https://polygonscan.com'
|
|
100
|
+
},
|
|
101
|
+
polygonMumbai: {
|
|
102
|
+
name: 'PolygonScan',
|
|
103
|
+
url: 'https://mumbai.polygonscan.com'
|
|
104
|
+
},
|
|
105
|
+
arbitrum: {
|
|
106
|
+
name: 'Arbiscan',
|
|
107
|
+
url: 'https://arbiscan.io'
|
|
108
|
+
},
|
|
109
|
+
arbitrumRinkeby: {
|
|
110
|
+
name: 'Arbiscan',
|
|
111
|
+
url: 'https://testnet.arbiscan.io'
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const defaultAlchemyId = '_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC';
|
|
116
|
+
const alchemyRpcUrls = {
|
|
117
|
+
mainnet: 'https://eth-mainnet.alchemyapi.io/v2',
|
|
118
|
+
ropsten: 'https://eth-ropsten.alchemyapi.io/v2',
|
|
119
|
+
rinkeby: 'https://eth-rinkeby.alchemyapi.io/v2',
|
|
120
|
+
goerli: 'https://eth-goerli.alchemyapi.io/v2',
|
|
121
|
+
kovan: 'https://eth-kovan.alchemyapi.io/v2',
|
|
122
|
+
optimism: 'https://opt-mainnet.g.alchemy.com/v2',
|
|
123
|
+
optimismKovan: 'https://opt-kovan.g.alchemy.com/v2',
|
|
124
|
+
polygon: 'https://polygon-mainnet.g.alchemy.com/v2',
|
|
125
|
+
polygonMumbai: 'https://polygon-mumbai.g.alchemy.com/v2',
|
|
126
|
+
arbitrum: 'https://arb-mainnet.g.alchemy.com/v2',
|
|
127
|
+
arbitrumRinkeby: 'https://arb-rinkeby.g.alchemy.com/v2'
|
|
128
|
+
};
|
|
129
|
+
const infuraRpcUrls = {
|
|
130
|
+
mainnet: 'https://mainnet.infura.io/v3',
|
|
131
|
+
ropsten: 'https://ropsten.infura.io/v3',
|
|
132
|
+
rinkeby: 'https://rinkeby.infura.io/v3',
|
|
133
|
+
goerli: 'https://goerli.infura.io/v3',
|
|
134
|
+
kovan: 'https://kovan.infura.io/v3',
|
|
135
|
+
optimism: 'https://optimism-mainnet.infura.io/v3',
|
|
136
|
+
optimismKovan: 'https://optimism-kovan.infura.io/v3',
|
|
137
|
+
polygon: 'https://polygon-mainnet.infura.io/v3',
|
|
138
|
+
polygonMumbai: 'https://polygon-mumbai.infura.io/v3',
|
|
139
|
+
arbitrum: 'https://arbitrum-mainnet.infura.io/v3',
|
|
140
|
+
arbitrumRinkeby: 'https://arbitrum-rinkeby.infura.io/v3'
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const chainId = {
|
|
144
|
+
mainnet: 1,
|
|
145
|
+
ropsten: 3,
|
|
146
|
+
rinkeby: 4,
|
|
147
|
+
goerli: 5,
|
|
148
|
+
kovan: 42,
|
|
149
|
+
optimism: 10,
|
|
150
|
+
optimismKovan: 69,
|
|
151
|
+
polygon: 137,
|
|
152
|
+
polygonMumbai: 80001,
|
|
153
|
+
arbitrum: 42161,
|
|
154
|
+
arbitrumRinkeby: 421611,
|
|
155
|
+
localhost: 1337,
|
|
156
|
+
hardhat: 31337
|
|
157
|
+
};
|
|
158
|
+
const chain = {
|
|
159
|
+
mainnet: {
|
|
160
|
+
id: chainId.mainnet,
|
|
161
|
+
name: 'Ethereum',
|
|
162
|
+
nativeCurrency: {
|
|
163
|
+
name: 'Ether',
|
|
164
|
+
symbol: 'ETH',
|
|
165
|
+
decimals: 18
|
|
166
|
+
},
|
|
167
|
+
rpcUrls: {
|
|
168
|
+
alchemy: alchemyRpcUrls.mainnet,
|
|
169
|
+
infura: infuraRpcUrls.mainnet,
|
|
170
|
+
default: "".concat(alchemyRpcUrls.mainnet, "/").concat(defaultAlchemyId)
|
|
171
|
+
},
|
|
172
|
+
blockExplorers: {
|
|
173
|
+
etherscan: etherscanBlockExplorers.mainnet,
|
|
174
|
+
default: etherscanBlockExplorers.mainnet
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
ropsten: {
|
|
178
|
+
id: chainId.ropsten,
|
|
179
|
+
name: 'Ropsten',
|
|
180
|
+
nativeCurrency: {
|
|
181
|
+
name: 'Ropsten Ether',
|
|
182
|
+
symbol: 'ropETH',
|
|
183
|
+
decimals: 18
|
|
184
|
+
},
|
|
185
|
+
rpcUrls: {
|
|
186
|
+
alchemy: alchemyRpcUrls.ropsten,
|
|
187
|
+
infura: infuraRpcUrls.ropsten,
|
|
188
|
+
default: "".concat(alchemyRpcUrls.ropsten, "/").concat(defaultAlchemyId)
|
|
189
|
+
},
|
|
190
|
+
blockExplorers: {
|
|
191
|
+
etherscan: etherscanBlockExplorers.ropsten,
|
|
192
|
+
default: etherscanBlockExplorers.ropsten
|
|
193
|
+
},
|
|
194
|
+
testnet: true
|
|
195
|
+
},
|
|
196
|
+
rinkeby: {
|
|
197
|
+
id: chainId.rinkeby,
|
|
198
|
+
name: 'Rinkeby',
|
|
199
|
+
nativeCurrency: {
|
|
200
|
+
name: 'Rinkeby Ether',
|
|
201
|
+
symbol: 'rETH',
|
|
202
|
+
decimals: 18
|
|
203
|
+
},
|
|
204
|
+
rpcUrls: {
|
|
205
|
+
alchemy: alchemyRpcUrls.rinkeby,
|
|
206
|
+
infura: infuraRpcUrls.rinkeby,
|
|
207
|
+
default: "".concat(alchemyRpcUrls.rinkeby, "/").concat(defaultAlchemyId)
|
|
208
|
+
},
|
|
209
|
+
blockExplorers: {
|
|
210
|
+
etherscan: etherscanBlockExplorers.rinkeby,
|
|
211
|
+
default: etherscanBlockExplorers.rinkeby
|
|
212
|
+
},
|
|
213
|
+
testnet: true
|
|
214
|
+
},
|
|
215
|
+
goerli: {
|
|
216
|
+
id: chainId.goerli,
|
|
217
|
+
name: 'Goerli',
|
|
218
|
+
nativeCurrency: {
|
|
219
|
+
name: 'Goerli Ether',
|
|
220
|
+
symbol: 'gETH',
|
|
221
|
+
decimals: 18
|
|
222
|
+
},
|
|
223
|
+
rpcUrls: {
|
|
224
|
+
alchemy: alchemyRpcUrls.goerli,
|
|
225
|
+
infura: infuraRpcUrls.goerli,
|
|
226
|
+
default: "".concat(alchemyRpcUrls.goerli, "/").concat(defaultAlchemyId)
|
|
227
|
+
},
|
|
228
|
+
blockExplorers: {
|
|
229
|
+
etherscan: etherscanBlockExplorers.goerli,
|
|
230
|
+
default: etherscanBlockExplorers.goerli
|
|
231
|
+
},
|
|
232
|
+
testnet: true
|
|
233
|
+
},
|
|
234
|
+
kovan: {
|
|
235
|
+
id: chainId.kovan,
|
|
236
|
+
name: 'Kovan',
|
|
237
|
+
nativeCurrency: {
|
|
238
|
+
name: 'Kovan Ether',
|
|
239
|
+
symbol: 'kETH',
|
|
240
|
+
decimals: 18
|
|
241
|
+
},
|
|
242
|
+
rpcUrls: {
|
|
243
|
+
alchemy: alchemyRpcUrls.kovan,
|
|
244
|
+
infura: infuraRpcUrls.kovan,
|
|
245
|
+
default: "".concat(alchemyRpcUrls.kovan, "/").concat(defaultAlchemyId)
|
|
246
|
+
},
|
|
247
|
+
blockExplorers: {
|
|
248
|
+
etherscan: etherscanBlockExplorers.kovan,
|
|
249
|
+
default: etherscanBlockExplorers.kovan
|
|
250
|
+
},
|
|
251
|
+
testnet: true
|
|
252
|
+
},
|
|
253
|
+
optimism: {
|
|
254
|
+
id: chainId.optimism,
|
|
255
|
+
name: 'Optimism',
|
|
256
|
+
nativeCurrency: {
|
|
257
|
+
name: 'Ether',
|
|
258
|
+
symbol: 'ETH',
|
|
259
|
+
decimals: 18
|
|
260
|
+
},
|
|
261
|
+
rpcUrls: {
|
|
262
|
+
alchemy: alchemyRpcUrls.optimism,
|
|
263
|
+
infura: infuraRpcUrls.optimism,
|
|
264
|
+
default: 'https://mainnet.optimism.io'
|
|
265
|
+
},
|
|
266
|
+
blockExplorers: {
|
|
267
|
+
etherscan: etherscanBlockExplorers.optimism,
|
|
268
|
+
default: etherscanBlockExplorers.optimism
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
optimismKovan: {
|
|
272
|
+
id: chainId.optimismKovan,
|
|
273
|
+
name: 'Optimism Kovan',
|
|
274
|
+
nativeCurrency: {
|
|
275
|
+
name: 'Kovan Ether',
|
|
276
|
+
symbol: 'KOR',
|
|
277
|
+
decimals: 18
|
|
278
|
+
},
|
|
279
|
+
rpcUrls: {
|
|
280
|
+
alchemy: alchemyRpcUrls.optimismKovan,
|
|
281
|
+
infura: infuraRpcUrls.optimismKovan,
|
|
282
|
+
default: 'https://kovan.optimism.io'
|
|
283
|
+
},
|
|
284
|
+
blockExplorers: {
|
|
285
|
+
etherscan: etherscanBlockExplorers.optimismKovan,
|
|
286
|
+
default: etherscanBlockExplorers.optimismKovan
|
|
287
|
+
},
|
|
288
|
+
testnet: true
|
|
289
|
+
},
|
|
290
|
+
polygon: {
|
|
291
|
+
id: chainId.polygon,
|
|
292
|
+
name: 'Polygon',
|
|
293
|
+
nativeCurrency: {
|
|
294
|
+
name: 'MATIC',
|
|
295
|
+
symbol: 'MATIC',
|
|
296
|
+
decimals: 18
|
|
297
|
+
},
|
|
298
|
+
rpcUrls: {
|
|
299
|
+
alchemy: alchemyRpcUrls.polygon,
|
|
300
|
+
infura: infuraRpcUrls.polygon,
|
|
301
|
+
default: 'https://polygon-rpc.com'
|
|
302
|
+
},
|
|
303
|
+
blockExplorers: {
|
|
304
|
+
etherscan: etherscanBlockExplorers.polygon,
|
|
305
|
+
default: etherscanBlockExplorers.polygon
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
polygonMumbai: {
|
|
309
|
+
id: chainId.polygonMumbai,
|
|
310
|
+
name: 'Polygon Mumbai',
|
|
311
|
+
nativeCurrency: {
|
|
312
|
+
name: 'MATIC',
|
|
313
|
+
symbol: 'MATIC',
|
|
314
|
+
decimals: 18
|
|
315
|
+
},
|
|
316
|
+
rpcUrls: {
|
|
317
|
+
alchemy: alchemyRpcUrls.polygonMumbai,
|
|
318
|
+
infura: infuraRpcUrls.polygonMumbai,
|
|
319
|
+
default: 'https://matic-mumbai.chainstacklabs.com'
|
|
320
|
+
},
|
|
321
|
+
blockExplorers: {
|
|
322
|
+
etherscan: etherscanBlockExplorers.polygonMumbai,
|
|
323
|
+
default: etherscanBlockExplorers.polygonMumbai
|
|
324
|
+
},
|
|
325
|
+
testnet: true
|
|
326
|
+
},
|
|
327
|
+
arbitrum: {
|
|
328
|
+
id: chainId.arbitrum,
|
|
329
|
+
name: 'Arbitrum',
|
|
330
|
+
nativeCurrency: {
|
|
331
|
+
name: 'Ether',
|
|
332
|
+
symbol: 'AETH',
|
|
333
|
+
decimals: 18
|
|
334
|
+
},
|
|
335
|
+
rpcUrls: {
|
|
336
|
+
alchemy: alchemyRpcUrls.arbitrum,
|
|
337
|
+
infura: infuraRpcUrls.arbitrum,
|
|
338
|
+
default: 'https://arb1.arbitrum.io/rpc'
|
|
339
|
+
},
|
|
340
|
+
blockExplorers: {
|
|
341
|
+
arbitrum: {
|
|
342
|
+
name: 'Arbitrum Explorer',
|
|
343
|
+
url: 'https://explorer.arbitrum.io'
|
|
344
|
+
},
|
|
345
|
+
etherscan: etherscanBlockExplorers.arbitrum,
|
|
346
|
+
default: etherscanBlockExplorers.arbitrum
|
|
347
|
+
}
|
|
348
|
+
},
|
|
349
|
+
arbitrumRinkeby: {
|
|
350
|
+
id: chainId.arbitrumRinkeby,
|
|
351
|
+
name: 'Arbitrum Rinkeby',
|
|
352
|
+
nativeCurrency: {
|
|
353
|
+
name: 'Arbitrum Rinkeby Ether',
|
|
354
|
+
symbol: 'ARETH',
|
|
355
|
+
decimals: 18
|
|
356
|
+
},
|
|
357
|
+
rpcUrls: {
|
|
358
|
+
alchemy: alchemyRpcUrls.arbitrumRinkeby,
|
|
359
|
+
infura: infuraRpcUrls.arbitrumRinkeby,
|
|
360
|
+
default: 'https://rinkeby.arbitrum.io/rpc'
|
|
361
|
+
},
|
|
362
|
+
blockExplorers: {
|
|
363
|
+
arbitrum: {
|
|
364
|
+
name: 'Arbitrum Explorer',
|
|
365
|
+
url: 'https://rinkeby-explorer.arbitrum.io'
|
|
366
|
+
},
|
|
367
|
+
etherscan: etherscanBlockExplorers.arbitrumRinkeby,
|
|
368
|
+
default: etherscanBlockExplorers.arbitrumRinkeby
|
|
369
|
+
},
|
|
370
|
+
testnet: true
|
|
371
|
+
},
|
|
372
|
+
localhost: {
|
|
373
|
+
id: chainId.localhost,
|
|
374
|
+
name: 'Localhost',
|
|
375
|
+
rpcUrls: {
|
|
376
|
+
default: 'http://127.0.0.1:8545'
|
|
377
|
+
}
|
|
378
|
+
},
|
|
379
|
+
hardhat: {
|
|
380
|
+
id: chainId.hardhat,
|
|
381
|
+
name: 'Hardhat',
|
|
382
|
+
rpcUrls: {
|
|
383
|
+
default: 'http://127.0.0.1:8545'
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
const allChains = Object.values(chain);
|
|
388
|
+
const defaultChains = [chain.mainnet, chain.ropsten, chain.rinkeby, chain.goerli, chain.kovan];
|
|
389
|
+
const defaultL2Chains = [chain.arbitrum, chain.arbitrumRinkeby, chain.optimism, chain.optimismKovan];
|
|
390
|
+
|
|
391
|
+
function normalizeChainId(chainId) {
|
|
392
|
+
if (typeof chainId === 'string') return Number.parseInt(chainId, chainId.trim().substring(0, 2) === '0x' ? 16 : 10);
|
|
393
|
+
return chainId;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
class AddChainError extends Error {
|
|
397
|
+
constructor() {
|
|
398
|
+
super(...arguments);
|
|
399
|
+
|
|
400
|
+
_defineProperty(this, "name", 'AddChainError');
|
|
401
|
+
|
|
402
|
+
_defineProperty(this, "message", 'Error adding chain');
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
}
|
|
406
|
+
class ChainNotConfiguredError extends Error {
|
|
407
|
+
constructor() {
|
|
408
|
+
super(...arguments);
|
|
409
|
+
|
|
410
|
+
_defineProperty(this, "name", 'ChainNotConfigured');
|
|
411
|
+
|
|
412
|
+
_defineProperty(this, "message", 'Chain not configured');
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
}
|
|
416
|
+
class ConnectorAlreadyConnectedError extends Error {
|
|
417
|
+
constructor() {
|
|
418
|
+
super(...arguments);
|
|
419
|
+
|
|
420
|
+
_defineProperty(this, "name", 'ConnectorAlreadyConnectedError');
|
|
421
|
+
|
|
422
|
+
_defineProperty(this, "message", 'Connector already connected');
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
}
|
|
426
|
+
class ConnectorNotFoundError extends Error {
|
|
427
|
+
constructor() {
|
|
428
|
+
super(...arguments);
|
|
429
|
+
|
|
430
|
+
_defineProperty(this, "name", 'ConnectorNotFoundError');
|
|
431
|
+
|
|
432
|
+
_defineProperty(this, "message", 'Connector not found');
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
}
|
|
436
|
+
class SwitchChainError extends Error {
|
|
437
|
+
constructor() {
|
|
438
|
+
super(...arguments);
|
|
439
|
+
|
|
440
|
+
_defineProperty(this, "name", 'SwitchChainError');
|
|
441
|
+
|
|
442
|
+
_defineProperty(this, "message", 'Error switching chain');
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
}
|
|
446
|
+
class SwitchChainNotSupportedError extends Error {
|
|
447
|
+
constructor() {
|
|
448
|
+
super(...arguments);
|
|
449
|
+
|
|
450
|
+
_defineProperty(this, "name", 'SwitchChainNotSupportedError');
|
|
451
|
+
|
|
452
|
+
_defineProperty(this, "message", 'Switch chain not supported by connector');
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
}
|
|
456
|
+
class UserRejectedRequestError extends Error {
|
|
457
|
+
constructor() {
|
|
458
|
+
super(...arguments);
|
|
459
|
+
|
|
460
|
+
_defineProperty(this, "name", 'UserRejectedRequestError');
|
|
461
|
+
|
|
462
|
+
_defineProperty(this, "message", 'User rejected request');
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
class Connector extends EventEmitter {
|
|
468
|
+
/** Unique connector id */
|
|
469
|
+
|
|
470
|
+
/** Connector name */
|
|
471
|
+
|
|
472
|
+
/** Chains connector supports */
|
|
473
|
+
|
|
474
|
+
/** Options to use with connector */
|
|
475
|
+
|
|
476
|
+
/** Whether connector is usable */
|
|
477
|
+
constructor(_ref) {
|
|
478
|
+
let {
|
|
479
|
+
chains = defaultChains,
|
|
480
|
+
options
|
|
481
|
+
} = _ref;
|
|
482
|
+
super();
|
|
483
|
+
|
|
484
|
+
_defineProperty(this, "id", void 0);
|
|
485
|
+
|
|
486
|
+
_defineProperty(this, "name", void 0);
|
|
487
|
+
|
|
488
|
+
_defineProperty(this, "chains", void 0);
|
|
489
|
+
|
|
490
|
+
_defineProperty(this, "options", void 0);
|
|
491
|
+
|
|
492
|
+
_defineProperty(this, "ready", void 0);
|
|
493
|
+
|
|
494
|
+
this.chains = chains;
|
|
495
|
+
this.options = options;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
getBlockExplorerUrls(chain) {
|
|
499
|
+
var _chain$blockExplorers;
|
|
500
|
+
|
|
501
|
+
const blockExplorer = (_chain$blockExplorers = chain.blockExplorers) === null || _chain$blockExplorers === void 0 ? void 0 : _chain$blockExplorers.default;
|
|
502
|
+
if (Array.isArray(blockExplorer)) return blockExplorer.map(x => x.url);
|
|
503
|
+
if (blockExplorer !== null && blockExplorer !== void 0 && blockExplorer.url) return [blockExplorer.url];
|
|
504
|
+
return [];
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
isChainUnsupported(chainId) {
|
|
508
|
+
return !this.chains.some(x => x.id === chainId);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
export { AddChainError as A, ConnectorAlreadyConnectedError as C, SwitchChainNotSupportedError as S, UserRejectedRequestError as U, _defineProperty as _, allChains as a, ConnectorNotFoundError as b, Connector as c, alchemyRpcUrls as d, chain as e, chainId as f, defaultChains as g, defaultL2Chains as h, etherscanBlockExplorers as i, infuraRpcUrls as j, ChainNotConfiguredError as k, SwitchChainError as l, _classPrivateFieldInitSpec as m, normalizeChainId as n, _classPrivateFieldSet as o, _classPrivateFieldGet as p, _checkPrivateRedeclaration as q };
|