@wagmi/core 0.6.12 → 0.7.0

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.
Files changed (184) hide show
  1. package/chains/package.json +2 -2
  2. package/connectors/coinbaseWallet/package.json +2 -2
  3. package/connectors/metaMask/package.json +2 -2
  4. package/connectors/mock/package.json +2 -2
  5. package/connectors/walletConnect/package.json +2 -2
  6. package/dist/{declarations/src/connectors/base.d.ts → base-5bd9b5ed.d.ts} +8 -5
  7. package/dist/chains.d.ts +3 -0
  8. package/dist/chains.js +29 -0
  9. package/dist/chunk-2EDVJWOA.js +3496 -0
  10. package/dist/chunk-4DNFSL2K.js +376 -0
  11. package/dist/chunk-MQXBDTVK.js +29 -0
  12. package/dist/{declarations/src/connectors → connectors}/coinbaseWallet.d.ts +10 -6
  13. package/dist/connectors/coinbaseWallet.js +215 -0
  14. package/dist/{declarations/src/connectors → connectors}/metaMask.d.ts +11 -4
  15. package/dist/connectors/metaMask.js +115 -0
  16. package/dist/connectors/mock/index.d.ts +78 -0
  17. package/dist/connectors/mock/index.js +190 -0
  18. package/dist/{declarations/src/connectors → connectors}/walletConnect.d.ts +9 -5
  19. package/dist/connectors/walletConnect.js +160 -0
  20. package/dist/{declarations/src/types/contracts.d.ts → contracts-fb6a6ff0.d.ts} +122 -17
  21. package/dist/{declarations/src/types/index.d.ts → index-bacc1c49.d.ts} +83 -15
  22. package/dist/index.d.ts +1738 -0
  23. package/dist/index.js +165 -0
  24. package/dist/{declarations/src/connectors/injected.d.ts → injected-6980e5c3.d.ts} +9 -6
  25. package/dist/internal.d.ts +8 -0
  26. package/dist/internal.js +8 -0
  27. package/dist/providers/alchemy.d.ts +11 -0
  28. package/dist/providers/alchemy.js +32 -0
  29. package/dist/providers/infura.d.ts +11 -0
  30. package/dist/providers/infura.js +32 -0
  31. package/dist/providers/jsonRpc.d.ts +14 -0
  32. package/dist/providers/jsonRpc.js +44 -0
  33. package/dist/providers/public.d.ts +8 -0
  34. package/dist/providers/public.js +30 -0
  35. package/internal/package.json +2 -2
  36. package/package.json +40 -51
  37. package/providers/alchemy/package.json +2 -2
  38. package/providers/infura/package.json +2 -2
  39. package/providers/jsonRpc/package.json +2 -2
  40. package/providers/public/package.json +2 -2
  41. package/chains/dist/wagmi-core-chains.cjs.d.ts +0 -1
  42. package/chains/dist/wagmi-core-chains.cjs.dev.js +0 -26
  43. package/chains/dist/wagmi-core-chains.cjs.js +0 -7
  44. package/chains/dist/wagmi-core-chains.cjs.prod.js +0 -26
  45. package/chains/dist/wagmi-core-chains.esm.js +0 -2
  46. package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.d.ts +0 -1
  47. package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.dev.js +0 -274
  48. package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.js +0 -7
  49. package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.prod.js +0 -274
  50. package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.esm.js +0 -252
  51. package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.d.ts +0 -1
  52. package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.dev.js +0 -153
  53. package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.js +0 -7
  54. package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.prod.js +0 -153
  55. package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.esm.js +0 -149
  56. package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.d.ts +0 -1
  57. package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.dev.js +0 -262
  58. package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.js +0 -7
  59. package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.prod.js +0 -262
  60. package/connectors/mock/dist/wagmi-core-connectors-mock.esm.js +0 -253
  61. package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.d.ts +0 -1
  62. package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.dev.js +0 -228
  63. package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.js +0 -7
  64. package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.prod.js +0 -228
  65. package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.esm.js +0 -206
  66. package/dist/chains-73cc6c23.cjs.prod.js +0 -526
  67. package/dist/chains-8fce19d8.esm.js +0 -502
  68. package/dist/chains-fe1f4131.cjs.dev.js +0 -526
  69. package/dist/debounce-0862bf88.esm.js +0 -18
  70. package/dist/debounce-2d836dc9.cjs.prod.js +0 -20
  71. package/dist/debounce-46ac0312.cjs.dev.js +0 -20
  72. package/dist/declarations/src/actions/accounts/connect.d.ts +0 -18
  73. package/dist/declarations/src/actions/accounts/disconnect.d.ts +0 -1
  74. package/dist/declarations/src/actions/accounts/fetchBalance.d.ts +0 -19
  75. package/dist/declarations/src/actions/accounts/fetchSigner.d.ts +0 -7
  76. package/dist/declarations/src/actions/accounts/getAccount.d.ts +0 -36
  77. package/dist/declarations/src/actions/accounts/getNetwork.d.ts +0 -8
  78. package/dist/declarations/src/actions/accounts/index.d.ts +0 -12
  79. package/dist/declarations/src/actions/accounts/signMessage.d.ts +0 -7
  80. package/dist/declarations/src/actions/accounts/signTypedData.d.ts +0 -23
  81. package/dist/declarations/src/actions/accounts/switchNetwork.d.ts +0 -6
  82. package/dist/declarations/src/actions/accounts/watchAccount.d.ts +0 -12
  83. package/dist/declarations/src/actions/accounts/watchNetwork.d.ts +0 -10
  84. package/dist/declarations/src/actions/accounts/watchSigner.d.ts +0 -5
  85. package/dist/declarations/src/actions/contracts/fetchToken.d.ts +0 -21
  86. package/dist/declarations/src/actions/contracts/getContract.d.ts +0 -113
  87. package/dist/declarations/src/actions/contracts/index.d.ts +0 -11
  88. package/dist/declarations/src/actions/contracts/multicall.d.ts +0 -17
  89. package/dist/declarations/src/actions/contracts/prepareWriteContract.d.ts +0 -47
  90. package/dist/declarations/src/actions/contracts/readContract.d.ts +0 -15
  91. package/dist/declarations/src/actions/contracts/readContracts.d.ts +0 -28
  92. package/dist/declarations/src/actions/contracts/watchContractEvent.d.ts +0 -28
  93. package/dist/declarations/src/actions/contracts/watchMulticall.d.ts +0 -10
  94. package/dist/declarations/src/actions/contracts/watchReadContract.d.ts +0 -7
  95. package/dist/declarations/src/actions/contracts/watchReadContracts.d.ts +0 -10
  96. package/dist/declarations/src/actions/contracts/writeContract.d.ts +0 -72
  97. package/dist/declarations/src/actions/ens/fetchEnsAddress.d.ts +0 -9
  98. package/dist/declarations/src/actions/ens/fetchEnsAvatar.d.ts +0 -8
  99. package/dist/declarations/src/actions/ens/fetchEnsName.d.ts +0 -9
  100. package/dist/declarations/src/actions/ens/fetchEnsResolver.d.ts +0 -9
  101. package/dist/declarations/src/actions/ens/index.d.ts +0 -4
  102. package/dist/declarations/src/actions/index.d.ts +0 -6
  103. package/dist/declarations/src/actions/network-status/fetchBlockNumber.d.ts +0 -5
  104. package/dist/declarations/src/actions/network-status/fetchFeeData.d.ts +0 -16
  105. package/dist/declarations/src/actions/network-status/index.d.ts +0 -3
  106. package/dist/declarations/src/actions/network-status/watchBlockNumber.d.ts +0 -7
  107. package/dist/declarations/src/actions/providers/getProvider.d.ts +0 -7
  108. package/dist/declarations/src/actions/providers/getWebSocketProvider.d.ts +0 -7
  109. package/dist/declarations/src/actions/providers/index.d.ts +0 -4
  110. package/dist/declarations/src/actions/providers/watchProvider.d.ts +0 -4
  111. package/dist/declarations/src/actions/providers/watchWebSocketProvider.d.ts +0 -4
  112. package/dist/declarations/src/actions/transactions/fetchTransaction.d.ts +0 -21
  113. package/dist/declarations/src/actions/transactions/index.d.ts +0 -4
  114. package/dist/declarations/src/actions/transactions/prepareSendTransaction.d.ts +0 -37
  115. package/dist/declarations/src/actions/transactions/sendTransaction.d.ts +0 -48
  116. package/dist/declarations/src/actions/transactions/waitForTransaction.d.ts +0 -18
  117. package/dist/declarations/src/chains.d.ts +0 -1
  118. package/dist/declarations/src/client.d.ts +0 -91
  119. package/dist/declarations/src/connectors/index.d.ts +0 -2
  120. package/dist/declarations/src/connectors/mock/connector.d.ts +0 -34
  121. package/dist/declarations/src/connectors/mock/index.d.ts +0 -2
  122. package/dist/declarations/src/connectors/mock/provider.d.ts +0 -41
  123. package/dist/declarations/src/constants/abis.d.ts +0 -941
  124. package/dist/declarations/src/constants/blockExplorers.d.ts +0 -9
  125. package/dist/declarations/src/constants/chains.d.ts +0 -64
  126. package/dist/declarations/src/constants/index.d.ts +0 -7
  127. package/dist/declarations/src/constants/rpcs.d.ts +0 -11
  128. package/dist/declarations/src/constants/units.d.ts +0 -1
  129. package/dist/declarations/src/errors.d.ts +0 -134
  130. package/dist/declarations/src/index.d.ts +0 -14
  131. package/dist/declarations/src/internal.d.ts +0 -3
  132. package/dist/declarations/src/providers/alchemy.d.ts +0 -6
  133. package/dist/declarations/src/providers/infura.d.ts +0 -6
  134. package/dist/declarations/src/providers/jsonRpc.d.ts +0 -10
  135. package/dist/declarations/src/providers/public.d.ts +0 -4
  136. package/dist/declarations/src/storage.d.ts +0 -12
  137. package/dist/declarations/src/types/utils.d.ts +0 -103
  138. package/dist/declarations/src/utils/assertActiveChain.d.ts +0 -5
  139. package/dist/declarations/src/utils/configureChains.d.ts +0 -26
  140. package/dist/declarations/src/utils/debounce.d.ts +0 -1
  141. package/dist/declarations/src/utils/deepEqual.d.ts +0 -2
  142. package/dist/declarations/src/utils/getInjectedName.d.ts +0 -2
  143. package/dist/declarations/src/utils/index.d.ts +0 -11
  144. package/dist/declarations/src/utils/logger.d.ts +0 -1
  145. package/dist/declarations/src/utils/minimizeContractInterface.d.ts +0 -5
  146. package/dist/declarations/src/utils/normalizeChainId.d.ts +0 -1
  147. package/dist/declarations/src/utils/normalizeFunctionName.d.ts +0 -17
  148. package/dist/declarations/src/utils/parseContractResult.d.ts +0 -7
  149. package/dist/getProvider-3b1af4e6.cjs.dev.js +0 -1143
  150. package/dist/getProvider-84f303a1.cjs.prod.js +0 -1143
  151. package/dist/getProvider-97db849e.esm.js +0 -1105
  152. package/dist/rpcs-38f4faba.cjs.prod.js +0 -57
  153. package/dist/rpcs-52ea3d8d.cjs.dev.js +0 -57
  154. package/dist/rpcs-d533516e.esm.js +0 -51
  155. package/dist/wagmi-core.cjs.d.ts +0 -1
  156. package/dist/wagmi-core.cjs.dev.js +0 -2683
  157. package/dist/wagmi-core.cjs.js +0 -7
  158. package/dist/wagmi-core.cjs.prod.js +0 -2683
  159. package/dist/wagmi-core.esm.js +0 -2599
  160. package/internal/dist/wagmi-core-internal.cjs.d.ts +0 -1
  161. package/internal/dist/wagmi-core-internal.cjs.dev.js +0 -9
  162. package/internal/dist/wagmi-core-internal.cjs.js +0 -7
  163. package/internal/dist/wagmi-core-internal.cjs.prod.js +0 -9
  164. package/internal/dist/wagmi-core-internal.esm.js +0 -1
  165. package/providers/alchemy/dist/wagmi-core-providers-alchemy.cjs.d.ts +0 -1
  166. package/providers/alchemy/dist/wagmi-core-providers-alchemy.cjs.dev.js +0 -36
  167. package/providers/alchemy/dist/wagmi-core-providers-alchemy.cjs.js +0 -7
  168. package/providers/alchemy/dist/wagmi-core-providers-alchemy.cjs.prod.js +0 -36
  169. package/providers/alchemy/dist/wagmi-core-providers-alchemy.esm.js +0 -32
  170. package/providers/infura/dist/wagmi-core-providers-infura.cjs.d.ts +0 -1
  171. package/providers/infura/dist/wagmi-core-providers-infura.cjs.dev.js +0 -36
  172. package/providers/infura/dist/wagmi-core-providers-infura.cjs.js +0 -7
  173. package/providers/infura/dist/wagmi-core-providers-infura.cjs.prod.js +0 -36
  174. package/providers/infura/dist/wagmi-core-providers-infura.esm.js +0 -32
  175. package/providers/jsonRpc/dist/wagmi-core-providers-jsonRpc.cjs.d.ts +0 -1
  176. package/providers/jsonRpc/dist/wagmi-core-providers-jsonRpc.cjs.dev.js +0 -46
  177. package/providers/jsonRpc/dist/wagmi-core-providers-jsonRpc.cjs.js +0 -7
  178. package/providers/jsonRpc/dist/wagmi-core-providers-jsonRpc.cjs.prod.js +0 -46
  179. package/providers/jsonRpc/dist/wagmi-core-providers-jsonRpc.esm.js +0 -42
  180. package/providers/public/dist/wagmi-core-providers-public.cjs.d.ts +0 -1
  181. package/providers/public/dist/wagmi-core-providers-public.cjs.dev.js +0 -32
  182. package/providers/public/dist/wagmi-core-providers-public.cjs.js +0 -7
  183. package/providers/public/dist/wagmi-core-providers-public.cjs.prod.js +0 -32
  184. package/providers/public/dist/wagmi-core-providers-public.esm.js +0 -28
@@ -1,2683 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var getProvider = require('./getProvider-3b1af4e6.cjs.dev.js');
6
- var ethers$1 = require('ethers/lib/ethers');
7
- var utils = require('ethers/lib/utils');
8
- var ethers = require('ethers');
9
- var chains = require('./chains-fe1f4131.cjs.dev.js');
10
- var shallow = require('zustand/shallow');
11
- var debounce = require('./debounce-46ac0312.cjs.dev.js');
12
- var rpcs = require('./rpcs-52ea3d8d.cjs.dev.js');
13
- require('zustand/middleware');
14
- require('zustand/vanilla');
15
- require('eventemitter3');
16
-
17
- function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
18
-
19
- var shallow__default = /*#__PURE__*/_interopDefault(shallow);
20
-
21
- function configureChains(defaultChains, providers) {
22
- let {
23
- minQuorum = 1,
24
- pollingInterval = 4_000,
25
- targetQuorum = 1,
26
- stallTimeout
27
- } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
28
- if (!defaultChains.length) throw new Error('must have at least one chain');
29
- if (targetQuorum < minQuorum) throw new Error('quorum cannot be lower than minQuorum');
30
- let chains = [];
31
- const providers_ = {};
32
- const webSocketProviders_ = {};
33
-
34
- for (const chain of defaultChains) {
35
- let configExists = false;
36
-
37
- for (const provider of providers) {
38
- const apiConfig = provider(chain); // If no API configuration was found (ie. no RPC URL) for
39
- // this provider, then we skip and check the next one.
40
-
41
- if (!apiConfig) continue;
42
- configExists = true;
43
-
44
- if (!chains.some(_ref => {
45
- let {
46
- id
47
- } = _ref;
48
- return id === chain.id;
49
- })) {
50
- chains = [...chains, apiConfig.chain];
51
- }
52
-
53
- providers_[chain.id] = [...(providers_[chain.id] || []), apiConfig.provider];
54
-
55
- if (apiConfig.webSocketProvider) {
56
- webSocketProviders_[chain.id] = [...(webSocketProviders_[chain.id] || []), apiConfig.webSocketProvider];
57
- }
58
- } // If no API configuration was found across the providers
59
- // then we throw an error to the consumer.
60
-
61
-
62
- if (!configExists) {
63
- throw new Error([`Could not find valid provider configuration for chain "${chain.name}".\n`, "You may need to add `jsonRpcProvider` to `configureChains` with the chain's RPC URLs.", 'Read more: https://wagmi.sh/docs/providers/jsonRpc'].join('\n'));
64
- }
65
- }
66
-
67
- return {
68
- chains,
69
- provider: _ref2 => {
70
- let {
71
- chainId
72
- } = _ref2;
73
- const activeChain = chains.find(x => x.id === chainId) ?? defaultChains[0];
74
- const chainProviders = providers_[activeChain.id];
75
- if (!chainProviders || !chainProviders[0]) throw new Error(`No providers configured for chain "${activeChain.id}"`);
76
- let provider;
77
-
78
- if (chainProviders.length === 1) {
79
- provider = chainProviders[0]();
80
- } else {
81
- provider = fallbackProvider(targetQuorum, minQuorum, chainProviders, {
82
- stallTimeout
83
- });
84
- } // Formatter workaround as Celo does not provide `gasLimit` or `difficulty` on eth_getBlockByNumber.
85
-
86
-
87
- if (activeChain.id === 42220) {
88
- provider.formatter.formats.block = { ...provider.formatter.formats.block,
89
- difficulty: () => 0,
90
- gasLimit: () => 0
91
- };
92
- }
93
-
94
- return Object.assign(provider, {
95
- chains,
96
- pollingInterval
97
- });
98
- },
99
- webSocketProvider: _ref3 => {
100
- var _chainWebSocketProvid;
101
-
102
- let {
103
- chainId
104
- } = _ref3;
105
- const activeChain = chains.find(x => x.id === chainId) ?? defaultChains[0];
106
- const chainWebSocketProviders = webSocketProviders_[activeChain.id];
107
- if (!chainWebSocketProviders) return undefined;
108
- const provider = (_chainWebSocketProvid = chainWebSocketProviders[0]) === null || _chainWebSocketProvid === void 0 ? void 0 : _chainWebSocketProvid.call(chainWebSocketProviders); // Formatter workaround as Celo does not provide `gasLimit` or `difficulty` on eth_getBlockByNumber.
109
-
110
- if (provider && activeChain.id === 42220) {
111
- provider.formatter.formats.block = { ...provider.formatter.formats.block,
112
- difficulty: () => 0,
113
- gasLimit: () => 0
114
- };
115
- } // WebSockets do not work with `fallbackProvider`
116
- // Default to first available
117
-
118
-
119
- return Object.assign(provider || {}, {
120
- chains
121
- });
122
- }
123
- };
124
- }
125
-
126
- function fallbackProvider(targetQuorum, minQuorum, providers_, _ref4) {
127
- let {
128
- stallTimeout
129
- } = _ref4;
130
-
131
- try {
132
- return new ethers.providers.FallbackProvider(providers_.map((chainProvider, index) => {
133
- const provider = chainProvider();
134
- return {
135
- provider,
136
- priority: provider.priority ?? index,
137
- stallTimeout: provider.stallTimeout ?? stallTimeout,
138
- weight: provider.weight
139
- };
140
- }), targetQuorum);
141
- } catch (error) {
142
- var _error$message;
143
-
144
- if (error !== null && error !== void 0 && (_error$message = error.message) !== null && _error$message !== void 0 && _error$message.includes('quorum will always fail; larger than total weight')) {
145
- if (targetQuorum === minQuorum) throw error;
146
- return fallbackProvider(targetQuorum - 1, minQuorum, providers_, {
147
- stallTimeout
148
- });
149
- }
150
-
151
- throw error;
152
- }
153
- }
154
-
155
- function assertActiveChain(_ref) {
156
- let {
157
- chainId,
158
- signer
159
- } = _ref;
160
- // Check that active chain and target chain match
161
- const {
162
- chain: activeChain,
163
- chains
164
- } = getNetwork();
165
- const activeChainId = activeChain === null || activeChain === void 0 ? void 0 : activeChain.id;
166
-
167
- if (activeChainId && chainId !== activeChainId) {
168
- var _chains$find, _chains$find2;
169
-
170
- throw new getProvider.ChainMismatchError({
171
- activeChain: ((_chains$find = chains.find(x => x.id === activeChainId)) === null || _chains$find === void 0 ? void 0 : _chains$find.name) ?? `Chain ${activeChainId}`,
172
- targetChain: ((_chains$find2 = chains.find(x => x.id === chainId)) === null || _chains$find2 === void 0 ? void 0 : _chains$find2.name) ?? `Chain ${chainId}`
173
- });
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
- }
190
- }
191
-
192
- /** Forked from https://github.com/epoberezkin/fast-deep-equal */
193
- function deepEqual(a, b) {
194
- if (a === b) return true;
195
-
196
- if (a && b && typeof a === 'object' && typeof b === 'object') {
197
- if (a.constructor !== b.constructor) return false;
198
- let length;
199
- let i;
200
-
201
- if (Array.isArray(a) && Array.isArray(b)) {
202
- length = a.length;
203
- if (length != b.length) return false;
204
-
205
- for (i = length; i-- !== 0;) if (!deepEqual(a[i], b[i])) return false;
206
-
207
- return true;
208
- }
209
-
210
- if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
211
- if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
212
- const keys = Object.keys(a);
213
- length = keys.length;
214
- if (length !== Object.keys(b).length) return false;
215
-
216
- for (i = length; i-- !== 0;) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
217
-
218
- for (i = length; i-- !== 0;) {
219
- const key = keys[i];
220
- if (key && !deepEqual(a[key], b[key])) return false;
221
- }
222
-
223
- return true;
224
- } // true if both NaN, false otherwise
225
-
226
-
227
- return a !== a && b !== b;
228
- }
229
-
230
- /**
231
- * Get normalized function name from contract
232
- *
233
- * @param contract — Contract
234
- * @param functionName — Function name
235
- * @param args — Function arguments (used to disambiguate overloaded functions)
236
- *
237
- * @returns Normalized function name
238
- */
239
-
240
- function normalizeFunctionName(_ref) {
241
- let {
242
- contract,
243
- functionName,
244
- args = []
245
- } = _ref;
246
- // If `functionName` exists in contract, return it.
247
- if (functionName in contract.functions) return functionName; // Otherwise, check if `functionName` is an overloaded function based on `args` shape.
248
-
249
- const argsLength = (args === null || args === void 0 ? void 0 : args.length) ?? 0;
250
- const overloadFunctions = Object.keys(contract.functions).filter(x => x.startsWith(`${functionName}(`)).map(x => ({
251
- name: x,
252
- fragment: utils.FunctionFragment.fromString(x)
253
- })).filter(x => argsLength === x.fragment.inputs.length);
254
-
255
- for (const overloadFunction of overloadFunctions) {
256
- const matched = args.every((arg, index) => {
257
- const abiParameter = overloadFunction.fragment.inputs[index];
258
- return isArgOfType(arg, abiParameter);
259
- });
260
- if (matched) return overloadFunction.name;
261
- } // Wasn't able to find overload, just return function name.
262
-
263
-
264
- return functionName;
265
- }
266
- function isArgOfType(arg, abiParameter) {
267
- const argType = typeof arg;
268
- const abiParameterType = abiParameter.type;
269
-
270
- switch (abiParameterType) {
271
- case 'address':
272
- return utils.isAddress(arg);
273
-
274
- case 'bool':
275
- return argType === 'boolean';
276
-
277
- case 'function':
278
- return argType === 'string';
279
-
280
- case 'string':
281
- return argType === 'string';
282
-
283
- default:
284
- {
285
- if (abiParameterType === 'tuple' && 'components' in abiParameter) return Object.values(abiParameter.components).every((component, index) => {
286
- return isArgOfType(Object.values(arg)[index], component);
287
- }); // `(u)int<M>`: (un)signed integer type of `M` bits, `0 < M <= 256`, `M % 8 == 0`
288
- // https://regexr.com/6v8hp
289
-
290
- if (/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(abiParameterType)) return argType === 'number' || argType === 'bigint' || ethers.BigNumber.isBigNumber(arg); // `bytes<M>`: binary type of `M` bytes, `0 < M <= 32`
291
- // https://regexr.com/6va55
292
-
293
- if (/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(abiParameterType)) return argType === 'string' || arg instanceof Uint8Array; // fixed-length (`<type>[M]`) and dynamic (`<type>[]`) arrays
294
- // https://regexr.com/6va6i
295
-
296
- if (/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(abiParameterType)) {
297
- return Array.isArray(arg) && arg.every(x => isArgOfType(x, { ...abiParameter,
298
- // Pop off `[]` or `[M]` from end of type
299
- type: abiParameterType.replace(/(\[[0-9]{0,}\])$/, '')
300
- }));
301
- }
302
-
303
- return false;
304
- }
305
- }
306
- }
307
-
308
- function logWarn(message) {
309
- var _getClient, _getClient$config$log, _getClient$config$log2;
310
-
311
- (_getClient = getProvider.getClient()) === null || _getClient === void 0 ? void 0 : (_getClient$config$log = _getClient.config.logger) === null || _getClient$config$log === void 0 ? void 0 : (_getClient$config$log2 = _getClient$config$log.warn) === null || _getClient$config$log2 === void 0 ? void 0 : _getClient$config$log2.call(_getClient$config$log, message);
312
- }
313
-
314
- function minimizeContractInterface(config) {
315
- try {
316
- const minimizedAbi = config.abi.filter(x => x.type === 'function' && x.name === config.functionName);
317
- if (minimizedAbi.length === 0) throw new Error('Invalid ABI');
318
- return minimizedAbi;
319
- } catch (error) {
320
- const abi = ethers$1.Contract.getInterface(config.abi).format(utils.FormatTypes.full);
321
- const minimizedInterface = Array.isArray(abi) ? abi : [abi];
322
- return minimizedInterface.filter(i => i.includes(config.functionName));
323
- }
324
- }
325
-
326
- function isPlainArray(value) {
327
- return Array.isArray(value) && Object.keys(value).length === value.length;
328
- }
329
-
330
- function parseContractResult(_ref) {
331
- let {
332
- abi,
333
- data,
334
- functionName
335
- } = _ref;
336
-
337
- if (data && isPlainArray(data)) {
338
- var _fragment$outputs;
339
-
340
- const iface = ethers$1.Contract.getInterface(abi);
341
- const fragment = iface.getFunction(functionName);
342
- const isTuple = (((_fragment$outputs = fragment.outputs) === null || _fragment$outputs === void 0 ? void 0 : _fragment$outputs.length) || 0) > 1;
343
- const data_ = isTuple ? data : [data];
344
- const encodedResult = iface.encodeFunctionResult(functionName, data_);
345
- const decodedResult = iface.decodeFunctionResult(functionName, encodedResult);
346
- return isTuple ? decodedResult : decodedResult[0];
347
- }
348
-
349
- return data;
350
- }
351
-
352
- /**
353
- * [ERC-20 Token Standard](https://ethereum.org/en/developers/docs/standards/tokens/erc-20)
354
- */
355
- const erc20ABI = [{
356
- type: 'event',
357
- name: 'Approval',
358
- inputs: [{
359
- indexed: true,
360
- name: 'owner',
361
- type: 'address'
362
- }, {
363
- indexed: true,
364
- name: 'spender',
365
- type: 'address'
366
- }, {
367
- indexed: false,
368
- name: 'value',
369
- type: 'uint256'
370
- }]
371
- }, {
372
- type: 'event',
373
- name: 'Transfer',
374
- inputs: [{
375
- indexed: true,
376
- name: 'from',
377
- type: 'address'
378
- }, {
379
- indexed: true,
380
- name: 'to',
381
- type: 'address'
382
- }, {
383
- indexed: false,
384
- name: 'value',
385
- type: 'uint256'
386
- }]
387
- }, {
388
- type: 'function',
389
- name: 'allowance',
390
- stateMutability: 'view',
391
- inputs: [{
392
- name: 'owner',
393
- type: 'address'
394
- }, {
395
- name: 'spender',
396
- type: 'address'
397
- }],
398
- outputs: [{
399
- name: '',
400
- type: 'uint256'
401
- }]
402
- }, {
403
- type: 'function',
404
- name: 'approve',
405
- stateMutability: 'nonpayable',
406
- inputs: [{
407
- name: 'spender',
408
- type: 'address'
409
- }, {
410
- name: 'amount',
411
- type: 'uint256'
412
- }],
413
- outputs: [{
414
- name: '',
415
- type: 'bool'
416
- }]
417
- }, {
418
- type: 'function',
419
- name: 'balanceOf',
420
- stateMutability: 'view',
421
- inputs: [{
422
- name: 'account',
423
- type: 'address'
424
- }],
425
- outputs: [{
426
- name: '',
427
- type: 'uint256'
428
- }]
429
- }, {
430
- type: 'function',
431
- name: 'decimals',
432
- stateMutability: 'view',
433
- inputs: [],
434
- outputs: [{
435
- name: '',
436
- type: 'uint8'
437
- }]
438
- }, {
439
- type: 'function',
440
- name: 'name',
441
- stateMutability: 'view',
442
- inputs: [],
443
- outputs: [{
444
- name: '',
445
- type: 'string'
446
- }]
447
- }, {
448
- type: 'function',
449
- name: 'symbol',
450
- stateMutability: 'view',
451
- inputs: [],
452
- outputs: [{
453
- name: '',
454
- type: 'string'
455
- }]
456
- }, {
457
- type: 'function',
458
- name: 'totalSupply',
459
- stateMutability: 'view',
460
- inputs: [],
461
- outputs: [{
462
- name: '',
463
- type: 'uint256'
464
- }]
465
- }, {
466
- type: 'function',
467
- name: 'transfer',
468
- stateMutability: 'nonpayable',
469
- inputs: [{
470
- name: 'recipient',
471
- type: 'address'
472
- }, {
473
- name: 'amount',
474
- type: 'uint256'
475
- }],
476
- outputs: [{
477
- name: '',
478
- type: 'bool'
479
- }]
480
- }, {
481
- type: 'function',
482
- name: 'transferFrom',
483
- stateMutability: 'nonpayable',
484
- inputs: [{
485
- name: 'sender',
486
- type: 'address'
487
- }, {
488
- name: 'recipient',
489
- type: 'address'
490
- }, {
491
- name: 'amount',
492
- type: 'uint256'
493
- }],
494
- outputs: [{
495
- name: '',
496
- type: 'bool'
497
- }]
498
- }];
499
- /**
500
- * [bytes32-flavored ERC-20](https://docs.makerdao.com/smart-contract-modules/mkr-module#4.-gotchas-potential-source-of-user-error)
501
- * for tokens (ie. Maker) that use bytes32 instead of string.
502
- */
503
-
504
- const erc20ABI_bytes32 = [{
505
- type: 'event',
506
- name: 'Approval',
507
- inputs: [{
508
- indexed: true,
509
- name: 'owner',
510
- type: 'address'
511
- }, {
512
- indexed: true,
513
- name: 'spender',
514
- type: 'address'
515
- }, {
516
- indexed: false,
517
- name: 'value',
518
- type: 'uint256'
519
- }]
520
- }, {
521
- type: 'event',
522
- name: 'Transfer',
523
- inputs: [{
524
- indexed: true,
525
- name: 'from',
526
- type: 'address'
527
- }, {
528
- indexed: true,
529
- name: 'to',
530
- type: 'address'
531
- }, {
532
- indexed: false,
533
- name: 'value',
534
- type: 'uint256'
535
- }]
536
- }, {
537
- type: 'function',
538
- name: 'allowance',
539
- stateMutability: 'view',
540
- inputs: [{
541
- name: 'owner',
542
- type: 'address'
543
- }, {
544
- name: 'spender',
545
- type: 'address'
546
- }],
547
- outputs: [{
548
- name: '',
549
- type: 'uint256'
550
- }]
551
- }, {
552
- type: 'function',
553
- name: 'approve',
554
- stateMutability: 'nonpayable',
555
- inputs: [{
556
- name: 'spender',
557
- type: 'address'
558
- }, {
559
- name: 'amount',
560
- type: 'uint256'
561
- }],
562
- outputs: [{
563
- name: '',
564
- type: 'bool'
565
- }]
566
- }, {
567
- type: 'function',
568
- name: 'balanceOf',
569
- stateMutability: 'view',
570
- inputs: [{
571
- name: 'account',
572
- type: 'address'
573
- }],
574
- outputs: [{
575
- name: '',
576
- type: 'uint256'
577
- }]
578
- }, {
579
- type: 'function',
580
- name: 'decimals',
581
- stateMutability: 'view',
582
- inputs: [],
583
- outputs: [{
584
- name: '',
585
- type: 'uint8'
586
- }]
587
- }, {
588
- type: 'function',
589
- name: 'name',
590
- stateMutability: 'view',
591
- inputs: [],
592
- outputs: [{
593
- name: '',
594
- type: 'bytes32'
595
- }]
596
- }, {
597
- type: 'function',
598
- name: 'symbol',
599
- stateMutability: 'view',
600
- inputs: [],
601
- outputs: [{
602
- name: '',
603
- type: 'bytes32'
604
- }]
605
- }, {
606
- type: 'function',
607
- name: 'totalSupply',
608
- stateMutability: 'view',
609
- inputs: [],
610
- outputs: [{
611
- name: '',
612
- type: 'uint256'
613
- }]
614
- }, {
615
- type: 'function',
616
- name: 'transfer',
617
- stateMutability: 'nonpayable',
618
- inputs: [{
619
- name: 'recipient',
620
- type: 'address'
621
- }, {
622
- name: 'amount',
623
- type: 'uint256'
624
- }],
625
- outputs: [{
626
- name: '',
627
- type: 'bool'
628
- }]
629
- }, {
630
- type: 'function',
631
- name: 'transferFrom',
632
- stateMutability: 'nonpayable',
633
- inputs: [{
634
- name: 'sender',
635
- type: 'address'
636
- }, {
637
- name: 'recipient',
638
- type: 'address'
639
- }, {
640
- name: 'amount',
641
- type: 'uint256'
642
- }],
643
- outputs: [{
644
- name: '',
645
- type: 'bool'
646
- }]
647
- }];
648
- /**
649
- * [ERC-721 Non-Fungible Token Standard](https://ethereum.org/en/developers/docs/standards/tokens/erc-721)
650
- */
651
-
652
- const erc721ABI = [{
653
- type: 'event',
654
- name: 'Approval',
655
- inputs: [{
656
- indexed: true,
657
- name: 'owner',
658
- type: 'address'
659
- }, {
660
- indexed: true,
661
- name: 'spender',
662
- type: 'address'
663
- }, {
664
- indexed: true,
665
- name: 'tokenId',
666
- type: 'uint256'
667
- }]
668
- }, {
669
- type: 'event',
670
- name: 'ApprovalForAll',
671
- inputs: [{
672
- indexed: true,
673
- name: 'owner',
674
- type: 'address'
675
- }, {
676
- indexed: true,
677
- name: 'operator',
678
- type: 'address'
679
- }, {
680
- indexed: false,
681
- name: 'approved',
682
- type: 'bool'
683
- }]
684
- }, {
685
- type: 'event',
686
- name: 'Transfer',
687
- inputs: [{
688
- indexed: true,
689
- name: 'from',
690
- type: 'address'
691
- }, {
692
- indexed: true,
693
- name: 'to',
694
- type: 'address'
695
- }, {
696
- indexed: true,
697
- name: 'tokenId',
698
- type: 'uint256'
699
- }]
700
- }, {
701
- type: 'function',
702
- name: 'approve',
703
- stateMutability: 'payable',
704
- inputs: [{
705
- name: 'spender',
706
- type: 'address'
707
- }, {
708
- name: 'tokenId',
709
- type: 'uint256'
710
- }],
711
- outputs: []
712
- }, {
713
- type: 'function',
714
- name: 'balanceOf',
715
- stateMutability: 'view',
716
- inputs: [{
717
- name: 'account',
718
- type: 'address'
719
- }],
720
- outputs: [{
721
- name: '',
722
- type: 'uint256'
723
- }]
724
- }, {
725
- type: 'function',
726
- name: 'getApproved',
727
- stateMutability: 'view',
728
- inputs: [{
729
- name: 'tokenId',
730
- type: 'uint256'
731
- }],
732
- outputs: [{
733
- name: '',
734
- type: 'address'
735
- }]
736
- }, {
737
- type: 'function',
738
- name: 'isApprovedForAll',
739
- stateMutability: 'view',
740
- inputs: [{
741
- name: 'owner',
742
- type: 'address'
743
- }, {
744
- name: 'operator',
745
- type: 'address'
746
- }],
747
- outputs: [{
748
- name: '',
749
- type: 'bool'
750
- }]
751
- }, {
752
- type: 'function',
753
- name: 'name',
754
- stateMutability: 'view',
755
- inputs: [],
756
- outputs: [{
757
- name: '',
758
- type: 'string'
759
- }]
760
- }, {
761
- type: 'function',
762
- name: 'ownerOf',
763
- stateMutability: 'view',
764
- inputs: [{
765
- name: 'tokenId',
766
- type: 'uint256'
767
- }],
768
- outputs: [{
769
- name: 'owner',
770
- type: 'address'
771
- }]
772
- }, {
773
- type: 'function',
774
- name: 'safeTransferFrom',
775
- stateMutability: 'payable',
776
- inputs: [{
777
- name: 'from',
778
- type: 'address'
779
- }, {
780
- name: 'to',
781
- type: 'address'
782
- }, {
783
- name: 'tokenId',
784
- type: 'uint256'
785
- }],
786
- outputs: []
787
- }, {
788
- type: 'function',
789
- name: 'safeTransferFrom',
790
- stateMutability: 'nonpayable',
791
- inputs: [{
792
- name: 'from',
793
- type: 'address'
794
- }, {
795
- name: 'to',
796
- type: 'address'
797
- }, {
798
- name: 'id',
799
- type: 'uint256'
800
- }, {
801
- name: 'data',
802
- type: 'bytes'
803
- }],
804
- outputs: []
805
- }, {
806
- type: 'function',
807
- name: 'setApprovalForAll',
808
- stateMutability: 'nonpayable',
809
- inputs: [{
810
- name: 'operator',
811
- type: 'address'
812
- }, {
813
- name: 'approved',
814
- type: 'bool'
815
- }],
816
- outputs: []
817
- }, {
818
- type: 'function',
819
- name: 'symbol',
820
- stateMutability: 'view',
821
- inputs: [],
822
- outputs: [{
823
- name: '',
824
- type: 'string'
825
- }]
826
- }, {
827
- type: 'function',
828
- name: 'tokenByIndex',
829
- stateMutability: 'view',
830
- inputs: [{
831
- name: 'index',
832
- type: 'uint256'
833
- }],
834
- outputs: [{
835
- name: '',
836
- type: 'uint256'
837
- }]
838
- }, {
839
- type: 'function',
840
- name: 'tokenByIndex',
841
- stateMutability: 'view',
842
- inputs: [{
843
- name: 'owner',
844
- type: 'address'
845
- }, {
846
- name: 'index',
847
- type: 'uint256'
848
- }],
849
- outputs: [{
850
- name: 'tokenId',
851
- type: 'uint256'
852
- }]
853
- }, {
854
- type: 'function',
855
- name: 'tokenURI',
856
- stateMutability: 'view',
857
- inputs: [{
858
- name: 'tokenId',
859
- type: 'uint256'
860
- }],
861
- outputs: [{
862
- name: '',
863
- type: 'string'
864
- }]
865
- }, {
866
- type: 'function',
867
- name: 'totalSupply',
868
- stateMutability: 'view',
869
- inputs: [],
870
- outputs: [{
871
- name: '',
872
- type: 'uint256'
873
- }]
874
- }, {
875
- type: 'function',
876
- name: 'transferFrom',
877
- stateMutability: 'payable',
878
- inputs: [{
879
- name: 'sender',
880
- type: 'address'
881
- }, {
882
- name: 'recipient',
883
- type: 'address'
884
- }, {
885
- name: 'tokeId',
886
- type: 'uint256'
887
- }],
888
- outputs: []
889
- }];
890
- /**
891
- * [Multicall3](https://github.com/mds1/multicall)
892
- */
893
-
894
- const multicallABI = [{
895
- inputs: [{
896
- components: [{
897
- name: 'target',
898
- type: 'address'
899
- }, {
900
- name: 'allowFailure',
901
- type: 'bool'
902
- }, {
903
- name: 'callData',
904
- type: 'bytes'
905
- }],
906
- name: 'calls',
907
- type: 'tuple[]'
908
- }],
909
- name: 'aggregate3',
910
- outputs: [{
911
- components: [{
912
- name: 'success',
913
- type: 'bool'
914
- }, {
915
- name: 'returnData',
916
- type: 'bytes'
917
- }],
918
- name: 'returnData',
919
- type: 'tuple[]'
920
- }],
921
- stateMutability: 'view',
922
- type: 'function'
923
- }];
924
- /**
925
- * [ERC-4626 Tokenized Vaults Standard](https://ethereum.org/en/developers/docs/standards/tokens/erc-4626)
926
- */
927
-
928
- const erc4626ABI = [{
929
- anonymous: false,
930
- inputs: [{
931
- indexed: true,
932
- name: 'owner',
933
- type: 'address'
934
- }, {
935
- indexed: true,
936
- name: 'spender',
937
- type: 'address'
938
- }, {
939
- indexed: false,
940
- name: 'value',
941
- type: 'uint256'
942
- }],
943
- name: 'Approval',
944
- type: 'event'
945
- }, {
946
- anonymous: false,
947
- inputs: [{
948
- indexed: true,
949
- name: 'sender',
950
- type: 'address'
951
- }, {
952
- indexed: true,
953
- name: 'receiver',
954
- type: 'address'
955
- }, {
956
- indexed: false,
957
- name: 'assets',
958
- type: 'uint256'
959
- }, {
960
- indexed: false,
961
- name: 'shares',
962
- type: 'uint256'
963
- }],
964
- name: 'Deposit',
965
- type: 'event'
966
- }, {
967
- anonymous: false,
968
- inputs: [{
969
- indexed: true,
970
- name: 'from',
971
- type: 'address'
972
- }, {
973
- indexed: true,
974
- name: 'to',
975
- type: 'address'
976
- }, {
977
- indexed: false,
978
- name: 'value',
979
- type: 'uint256'
980
- }],
981
- name: 'Transfer',
982
- type: 'event'
983
- }, {
984
- anonymous: false,
985
- inputs: [{
986
- indexed: true,
987
- name: 'sender',
988
- type: 'address'
989
- }, {
990
- indexed: true,
991
- name: 'receiver',
992
- type: 'address'
993
- }, {
994
- indexed: true,
995
- name: 'owner',
996
- type: 'address'
997
- }, {
998
- indexed: false,
999
- name: 'assets',
1000
- type: 'uint256'
1001
- }, {
1002
- indexed: false,
1003
- name: 'shares',
1004
- type: 'uint256'
1005
- }],
1006
- name: 'Withdraw',
1007
- type: 'event'
1008
- }, {
1009
- inputs: [{
1010
- name: 'owner',
1011
- type: 'address'
1012
- }, {
1013
- name: 'spender',
1014
- type: 'address'
1015
- }],
1016
- name: 'allowance',
1017
- outputs: [{
1018
- name: '',
1019
- type: 'uint256'
1020
- }],
1021
- stateMutability: 'view',
1022
- type: 'function'
1023
- }, {
1024
- inputs: [{
1025
- name: 'spender',
1026
- type: 'address'
1027
- }, {
1028
- name: 'amount',
1029
- type: 'uint256'
1030
- }],
1031
- name: 'approve',
1032
- outputs: [{
1033
- name: '',
1034
- type: 'bool'
1035
- }],
1036
- stateMutability: 'nonpayable',
1037
- type: 'function'
1038
- }, {
1039
- inputs: [],
1040
- name: 'asset',
1041
- outputs: [{
1042
- name: 'assetTokenAddress',
1043
- type: 'address'
1044
- }],
1045
- stateMutability: 'view',
1046
- type: 'function'
1047
- }, {
1048
- inputs: [{
1049
- name: 'account',
1050
- type: 'address'
1051
- }],
1052
- name: 'balanceOf',
1053
- outputs: [{
1054
- name: '',
1055
- type: 'uint256'
1056
- }],
1057
- stateMutability: 'view',
1058
- type: 'function'
1059
- }, {
1060
- inputs: [{
1061
- name: 'shares',
1062
- type: 'uint256'
1063
- }],
1064
- name: 'convertToAssets',
1065
- outputs: [{
1066
- name: 'assets',
1067
- type: 'uint256'
1068
- }],
1069
- stateMutability: 'view',
1070
- type: 'function'
1071
- }, {
1072
- inputs: [{
1073
- name: 'assets',
1074
- type: 'uint256'
1075
- }],
1076
- name: 'convertToShares',
1077
- outputs: [{
1078
- name: 'shares',
1079
- type: 'uint256'
1080
- }],
1081
- stateMutability: 'view',
1082
- type: 'function'
1083
- }, {
1084
- inputs: [{
1085
- name: 'assets',
1086
- type: 'uint256'
1087
- }, {
1088
- name: 'receiver',
1089
- type: 'address'
1090
- }],
1091
- name: 'deposit',
1092
- outputs: [{
1093
- name: 'shares',
1094
- type: 'uint256'
1095
- }],
1096
- stateMutability: 'nonpayable',
1097
- type: 'function'
1098
- }, {
1099
- inputs: [{
1100
- name: 'caller',
1101
- type: 'address'
1102
- }],
1103
- name: 'maxDeposit',
1104
- outputs: [{
1105
- name: 'maxAssets',
1106
- type: 'uint256'
1107
- }],
1108
- stateMutability: 'view',
1109
- type: 'function'
1110
- }, {
1111
- inputs: [{
1112
- name: 'caller',
1113
- type: 'address'
1114
- }],
1115
- name: 'maxMint',
1116
- outputs: [{
1117
- name: 'maxShares',
1118
- type: 'uint256'
1119
- }],
1120
- stateMutability: 'view',
1121
- type: 'function'
1122
- }, {
1123
- inputs: [{
1124
- name: 'owner',
1125
- type: 'address'
1126
- }],
1127
- name: 'maxRedeem',
1128
- outputs: [{
1129
- name: 'maxShares',
1130
- type: 'uint256'
1131
- }],
1132
- stateMutability: 'view',
1133
- type: 'function'
1134
- }, {
1135
- inputs: [{
1136
- name: 'owner',
1137
- type: 'address'
1138
- }],
1139
- name: 'maxWithdraw',
1140
- outputs: [{
1141
- name: 'maxAssets',
1142
- type: 'uint256'
1143
- }],
1144
- stateMutability: 'view',
1145
- type: 'function'
1146
- }, {
1147
- inputs: [{
1148
- name: 'shares',
1149
- type: 'uint256'
1150
- }, {
1151
- name: 'receiver',
1152
- type: 'address'
1153
- }],
1154
- name: 'mint',
1155
- outputs: [{
1156
- name: 'assets',
1157
- type: 'uint256'
1158
- }],
1159
- stateMutability: 'nonpayable',
1160
- type: 'function'
1161
- }, {
1162
- inputs: [{
1163
- name: 'assets',
1164
- type: 'uint256'
1165
- }],
1166
- name: 'previewDeposit',
1167
- outputs: [{
1168
- name: 'shares',
1169
- type: 'uint256'
1170
- }],
1171
- stateMutability: 'view',
1172
- type: 'function'
1173
- }, {
1174
- inputs: [{
1175
- name: 'shares',
1176
- type: 'uint256'
1177
- }],
1178
- name: 'previewMint',
1179
- outputs: [{
1180
- name: 'assets',
1181
- type: 'uint256'
1182
- }],
1183
- stateMutability: 'view',
1184
- type: 'function'
1185
- }, {
1186
- inputs: [{
1187
- name: 'shares',
1188
- type: 'uint256'
1189
- }],
1190
- name: 'previewRedeem',
1191
- outputs: [{
1192
- name: 'assets',
1193
- type: 'uint256'
1194
- }],
1195
- stateMutability: 'view',
1196
- type: 'function'
1197
- }, {
1198
- inputs: [{
1199
- name: 'assets',
1200
- type: 'uint256'
1201
- }],
1202
- name: 'previewWithdraw',
1203
- outputs: [{
1204
- name: 'shares',
1205
- type: 'uint256'
1206
- }],
1207
- stateMutability: 'view',
1208
- type: 'function'
1209
- }, {
1210
- inputs: [{
1211
- name: 'shares',
1212
- type: 'uint256'
1213
- }, {
1214
- name: 'receiver',
1215
- type: 'address'
1216
- }, {
1217
- name: 'owner',
1218
- type: 'address'
1219
- }],
1220
- name: 'redeem',
1221
- outputs: [{
1222
- name: 'assets',
1223
- type: 'uint256'
1224
- }],
1225
- stateMutability: 'nonpayable',
1226
- type: 'function'
1227
- }, {
1228
- inputs: [],
1229
- name: 'totalAssets',
1230
- outputs: [{
1231
- name: 'totalManagedAssets',
1232
- type: 'uint256'
1233
- }],
1234
- stateMutability: 'view',
1235
- type: 'function'
1236
- }, {
1237
- inputs: [],
1238
- name: 'totalSupply',
1239
- outputs: [{
1240
- name: '',
1241
- type: 'uint256'
1242
- }],
1243
- stateMutability: 'view',
1244
- type: 'function'
1245
- }, {
1246
- inputs: [{
1247
- name: 'to',
1248
- type: 'address'
1249
- }, {
1250
- name: 'amount',
1251
- type: 'uint256'
1252
- }],
1253
- name: 'transfer',
1254
- outputs: [{
1255
- name: '',
1256
- type: 'bool'
1257
- }],
1258
- stateMutability: 'nonpayable',
1259
- type: 'function'
1260
- }, {
1261
- inputs: [{
1262
- name: 'from',
1263
- type: 'address'
1264
- }, {
1265
- name: 'to',
1266
- type: 'address'
1267
- }, {
1268
- name: 'amount',
1269
- type: 'uint256'
1270
- }],
1271
- name: 'transferFrom',
1272
- outputs: [{
1273
- name: '',
1274
- type: 'bool'
1275
- }],
1276
- stateMutability: 'nonpayable',
1277
- type: 'function'
1278
- }, {
1279
- inputs: [{
1280
- name: 'assets',
1281
- type: 'uint256'
1282
- }, {
1283
- name: 'receiver',
1284
- type: 'address'
1285
- }, {
1286
- name: 'owner',
1287
- type: 'address'
1288
- }],
1289
- name: 'withdraw',
1290
- outputs: [{
1291
- name: 'shares',
1292
- type: 'uint256'
1293
- }],
1294
- stateMutability: 'nonpayable',
1295
- type: 'function'
1296
- }];
1297
-
1298
- // https://github.com/ethers-io/ethers.js/blob/master/packages/units/src.ts/index.ts#L10-L18
1299
- const units = ['wei', 'kwei', 'mwei', 'gwei', 'szabo', 'finney', 'ether'];
1300
-
1301
- async function connect(_ref) {
1302
- let {
1303
- chainId,
1304
- connector
1305
- } = _ref;
1306
- const client = getProvider.getClient();
1307
- const activeConnector = client.connector;
1308
- if (connector.id === (activeConnector === null || activeConnector === void 0 ? void 0 : activeConnector.id)) throw new getProvider.ConnectorAlreadyConnectedError();
1309
-
1310
- try {
1311
- client.setState(x => ({ ...x,
1312
- status: 'connecting'
1313
- }));
1314
- const data = await connector.connect({
1315
- chainId
1316
- });
1317
- client.setLastUsedConnector(connector.id);
1318
- client.setState(x => ({ ...x,
1319
- connector,
1320
- chains: connector === null || connector === void 0 ? void 0 : connector.chains,
1321
- data,
1322
- status: 'connected'
1323
- }));
1324
- client.storage.setItem('connected', true);
1325
- return { ...data,
1326
- connector
1327
- };
1328
- } catch (err) {
1329
- client.setState(x => {
1330
- return { ...x,
1331
- // Keep existing connector connected in case of error
1332
- status: x.connector ? 'connected' : 'disconnected'
1333
- };
1334
- });
1335
- throw err;
1336
- }
1337
- }
1338
-
1339
- async function disconnect() {
1340
- const client = getProvider.getClient();
1341
- if (client.connector) await client.connector.disconnect();
1342
- client.clearState();
1343
- client.storage.removeItem('connected');
1344
- }
1345
-
1346
- async function fetchToken(_ref) {
1347
- let {
1348
- address,
1349
- chainId,
1350
- formatUnits: units = 'ether'
1351
- } = _ref;
1352
-
1353
- async function fetchToken_(_ref2) {
1354
- let {
1355
- abi
1356
- } = _ref2;
1357
- const erc20Config = {
1358
- address,
1359
- abi,
1360
- chainId
1361
- };
1362
- const [decimals, name, symbol, totalSupply] = await readContracts({
1363
- allowFailure: false,
1364
- contracts: [{ ...erc20Config,
1365
- functionName: 'decimals'
1366
- }, { ...erc20Config,
1367
- functionName: 'name'
1368
- }, { ...erc20Config,
1369
- functionName: 'symbol'
1370
- }, { ...erc20Config,
1371
- functionName: 'totalSupply'
1372
- }]
1373
- });
1374
- return {
1375
- address,
1376
- decimals,
1377
- name: name,
1378
- // protect against `ResolvedConfig['BytesType']`
1379
- symbol: symbol,
1380
- // protect against `ResolvedConfig['BytesType']`
1381
- totalSupply: {
1382
- formatted: utils.formatUnits(totalSupply, units),
1383
- value: totalSupply
1384
- }
1385
- };
1386
- }
1387
-
1388
- try {
1389
- return await fetchToken_({
1390
- abi: erc20ABI
1391
- });
1392
- } catch (err) {
1393
- // In the chance that there is an error upon decoding the contract result,
1394
- // it could be likely that the contract data is represented as bytes32 instead
1395
- // of a string.
1396
- if (err instanceof getProvider.ContractResultDecodeError) {
1397
- const {
1398
- name,
1399
- symbol,
1400
- ...rest
1401
- } = await fetchToken_({
1402
- abi: erc20ABI_bytes32
1403
- });
1404
- return {
1405
- name: utils.parseBytes32String(name),
1406
- symbol: utils.parseBytes32String(symbol),
1407
- ...rest
1408
- };
1409
- }
1410
-
1411
- throw err;
1412
- }
1413
- }
1414
-
1415
- function getContract(_ref) {
1416
- let {
1417
- address,
1418
- abi,
1419
- signerOrProvider
1420
- } = _ref;
1421
- return new ethers.Contract(address, abi, signerOrProvider);
1422
- } ////////////////////////////////////////////////////////////////////////////////////////////////////
1423
- // Contract
1424
- // TODO: Add remaining properties
1425
-
1426
- /**
1427
- * @description Prepares the parameters required for a contract write transaction.
1428
- *
1429
- * Returns config to be passed through to `writeContract`.
1430
- *
1431
- * @example
1432
- * import { prepareWriteContract, writeContract } from '@wagmi/core'
1433
- *
1434
- * const config = await prepareWriteContract({
1435
- * address: '0x...',
1436
- * abi: wagmiAbi,
1437
- * functionName: 'mint',
1438
- * })
1439
- * const result = await writeContract(config)
1440
- */
1441
- async function prepareWriteContract(_ref) {
1442
- let {
1443
- abi,
1444
- address,
1445
- args,
1446
- chainId,
1447
- functionName,
1448
- overrides,
1449
- signer: signer_
1450
- } = _ref;
1451
- const signer = signer_ ?? (await fetchSigner({
1452
- chainId
1453
- }));
1454
- if (!signer) throw new getProvider.ConnectorNotFoundError();
1455
- if (chainId) assertActiveChain({
1456
- chainId,
1457
- signer
1458
- });
1459
- const contract = getContract({
1460
- address,
1461
- abi: abi,
1462
- // TODO: Remove cast and still support `Narrow<TAbi>`
1463
- signerOrProvider: signer
1464
- });
1465
- const normalizedFunctionName = normalizeFunctionName({
1466
- contract,
1467
- functionName,
1468
- args
1469
- });
1470
- const populateTransactionFn = contract.populateTransaction[normalizedFunctionName];
1471
- if (!populateTransactionFn) throw new getProvider.ContractMethodDoesNotExistError({
1472
- address,
1473
- functionName: normalizedFunctionName
1474
- });
1475
- const params = [...(args ?? []), ...(overrides ? [overrides] : [])];
1476
- const unsignedTransaction = await populateTransactionFn(...params);
1477
- const gasLimit = unsignedTransaction.gasLimit || (await signer.estimateGas(unsignedTransaction));
1478
- const minimizedAbi = minimizeContractInterface({
1479
- abi: abi,
1480
- // TODO: Remove cast and still support `Narrow<TAbi>`
1481
- functionName
1482
- });
1483
- return {
1484
- abi: minimizedAbi,
1485
- address,
1486
- chainId,
1487
- // TODO: Remove cast
1488
- functionName: functionName,
1489
- mode: 'prepared',
1490
- request: { ...unsignedTransaction,
1491
- gasLimit
1492
- }
1493
- };
1494
- }
1495
-
1496
- function getWebSocketProvider() {
1497
- let {
1498
- chainId
1499
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1500
- const client = getProvider.getClient();
1501
- if (chainId) return client.getWebSocketProvider({
1502
- chainId
1503
- }) || client.webSocketProvider;
1504
- return client.webSocketProvider;
1505
- }
1506
-
1507
- function watchProvider(args, callback) {
1508
- const client = getProvider.getClient();
1509
-
1510
- const handleChange = async () => callback(getProvider.getProvider(args));
1511
-
1512
- const unsubscribe = client.subscribe(_ref => {
1513
- let {
1514
- provider
1515
- } = _ref;
1516
- return provider;
1517
- }, handleChange);
1518
- return unsubscribe;
1519
- }
1520
-
1521
- function watchWebSocketProvider(args, callback) {
1522
- const client = getProvider.getClient();
1523
-
1524
- const handleChange = async () => callback(getWebSocketProvider(args));
1525
-
1526
- const unsubscribe = client.subscribe(_ref => {
1527
- let {
1528
- webSocketProvider
1529
- } = _ref;
1530
- return webSocketProvider;
1531
- }, handleChange);
1532
- return unsubscribe;
1533
- }
1534
-
1535
- async function multicall(_ref) {
1536
- let {
1537
- allowFailure = true,
1538
- chainId,
1539
- contracts,
1540
- overrides
1541
- } = _ref;
1542
- const provider = getProvider.getProvider({
1543
- chainId
1544
- });
1545
- if (!provider.chains) throw new getProvider.ProviderChainsNotFound();
1546
- const chain = provider.chains.find(chain => chain.id === chainId) || provider.chains[0];
1547
- if (!chain) throw new getProvider.ProviderChainsNotFound();
1548
- if (!(chain !== null && chain !== void 0 && chain.multicall)) throw new getProvider.ChainDoesNotSupportMulticallError({
1549
- chain
1550
- });
1551
- if (typeof (overrides === null || overrides === void 0 ? void 0 : overrides.blockTag) === 'number' && (overrides === null || overrides === void 0 ? void 0 : overrides.blockTag) < chain.multicall.blockCreated) throw new getProvider.ChainDoesNotSupportMulticallError({
1552
- blockNumber: overrides === null || overrides === void 0 ? void 0 : overrides.blockTag,
1553
- chain
1554
- });
1555
- const multicallContract = getContract({
1556
- address: chain.multicall.address,
1557
- abi: multicallABI,
1558
- signerOrProvider: provider
1559
- });
1560
- const calls = contracts.map(_ref2 => {
1561
- let {
1562
- address,
1563
- abi,
1564
- functionName,
1565
- ...config
1566
- } = _ref2;
1567
- const {
1568
- args
1569
- } = config || {};
1570
- const contract = getContract({
1571
- address,
1572
- abi
1573
- });
1574
- const params = args ?? [];
1575
- const normalizedFunctionName = normalizeFunctionName({
1576
- contract,
1577
- functionName,
1578
- args
1579
- });
1580
-
1581
- try {
1582
- const contractFunction = contract[normalizedFunctionName];
1583
- if (!contractFunction) logWarn(`"${normalizedFunctionName}" is not in the interface for contract "${address}"`);
1584
- const callData = contract.interface.encodeFunctionData(normalizedFunctionName, params);
1585
- return {
1586
- target: address,
1587
- allowFailure,
1588
- callData
1589
- };
1590
- } catch (err) {
1591
- if (!allowFailure) throw err;
1592
- return {
1593
- target: address,
1594
- allowFailure,
1595
- callData: '0x'
1596
- };
1597
- }
1598
- });
1599
- const params = [...[calls], ...(overrides ? [overrides] : [])];
1600
- const results = await multicallContract.aggregate3( // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1601
- // @ts-ignore
1602
- ...params);
1603
- return results.map((_ref3, i) => {
1604
- let {
1605
- returnData,
1606
- success
1607
- } = _ref3;
1608
- const {
1609
- address,
1610
- abi,
1611
- args,
1612
- functionName
1613
- } = contracts[i];
1614
- const contract = getContract({
1615
- address,
1616
- abi: abi // TODO: Remove cast and still support `Narrow<TAbi>`
1617
-
1618
- });
1619
- const normalizedFunctionName = normalizeFunctionName({
1620
- contract,
1621
- functionName,
1622
- args
1623
- });
1624
-
1625
- if (!success) {
1626
- let error;
1627
-
1628
- try {
1629
- contract.interface.decodeFunctionResult(normalizedFunctionName, returnData);
1630
- } catch (err) {
1631
- error = new getProvider.ContractMethodRevertedError({
1632
- address,
1633
- args,
1634
- chainId: chain.id,
1635
- functionName: normalizedFunctionName,
1636
- errorMessage: err.message
1637
- });
1638
- if (!allowFailure) throw error;
1639
- logWarn(error.message);
1640
- }
1641
-
1642
- return null;
1643
- }
1644
-
1645
- if (returnData === '0x') {
1646
- const error = new getProvider.ContractMethodNoResultError({
1647
- address,
1648
- args,
1649
- chainId: chain.id,
1650
- functionName: normalizedFunctionName
1651
- });
1652
- if (!allowFailure) throw error;
1653
- logWarn(error.message);
1654
- return null;
1655
- }
1656
-
1657
- try {
1658
- const result = contract.interface.decodeFunctionResult(normalizedFunctionName, returnData);
1659
- return Array.isArray(result) && result.length === 1 ? result[0] : result;
1660
- } catch (err) {
1661
- const error = new getProvider.ContractResultDecodeError({
1662
- address,
1663
- args,
1664
- chainId: chain.id,
1665
- functionName: normalizedFunctionName,
1666
- errorMessage: err.message
1667
- });
1668
- if (!allowFailure) throw error;
1669
- logWarn(error.message);
1670
- return null;
1671
- }
1672
- });
1673
- }
1674
-
1675
- async function readContract(_ref) {
1676
- let {
1677
- address,
1678
- args,
1679
- chainId,
1680
- abi,
1681
- functionName,
1682
- overrides
1683
- } = _ref;
1684
- const provider = getProvider.getProvider({
1685
- chainId
1686
- });
1687
- const contract = getContract({
1688
- address,
1689
- abi: abi,
1690
- // TODO: Remove cast and still support `Narrow<TAbi>`
1691
- signerOrProvider: provider
1692
- });
1693
- const normalizedFunctionName = normalizeFunctionName({
1694
- contract,
1695
- functionName,
1696
- args
1697
- });
1698
- const contractFunction = contract[normalizedFunctionName];
1699
- if (!contractFunction) throw new getProvider.ContractMethodDoesNotExistError({
1700
- address,
1701
- functionName: normalizedFunctionName
1702
- });
1703
- const params = [...(args ?? []), ...(overrides ? [overrides] : [])];
1704
- return contractFunction === null || contractFunction === void 0 ? void 0 : contractFunction(...params);
1705
- }
1706
-
1707
- async function readContracts(_ref) {
1708
- let {
1709
- allowFailure = true,
1710
- contracts,
1711
- overrides
1712
- } = _ref;
1713
-
1714
- try {
1715
- const provider = getProvider.getProvider();
1716
- const contractsByChainId = contracts.reduce((contracts, contract, index) => {
1717
- const chainId = contract.chainId ?? provider.network.chainId;
1718
- return { ...contracts,
1719
- [chainId]: [...(contracts[chainId] || []), {
1720
- contract,
1721
- index
1722
- }]
1723
- };
1724
- }, {});
1725
-
1726
- const promises = () => Object.entries(contractsByChainId).map(_ref2 => {
1727
- let [chainId, contracts] = _ref2;
1728
- return multicall({
1729
- allowFailure,
1730
- chainId: parseInt(chainId),
1731
- contracts: contracts.map(_ref3 => {
1732
- let {
1733
- contract
1734
- } = _ref3;
1735
- return contract;
1736
- }),
1737
- overrides
1738
- });
1739
- });
1740
-
1741
- let results;
1742
-
1743
- if (allowFailure) {
1744
- results = (await Promise.allSettled(promises())).map(result => {
1745
- if (result.status === 'fulfilled') return result.value;
1746
-
1747
- if (result.reason instanceof getProvider.ChainDoesNotSupportMulticallError) {
1748
- logWarn(result.reason.message);
1749
- throw result.reason;
1750
- }
1751
-
1752
- return null;
1753
- }).flat();
1754
- } else {
1755
- results = (await Promise.all(promises())).flat();
1756
- } // Reorder the contract results back to the order they were
1757
- // provided in.
1758
-
1759
-
1760
- const resultIndexes = Object.values(contractsByChainId).map(contracts => contracts.map(_ref4 => {
1761
- let {
1762
- index
1763
- } = _ref4;
1764
- return index;
1765
- })).flat();
1766
- return results.reduce((results, result, index) => {
1767
- results[resultIndexes[index]] = result;
1768
- return results;
1769
- }, []);
1770
- } catch (err) {
1771
- if (err instanceof getProvider.ContractResultDecodeError) throw err;
1772
- if (err instanceof getProvider.ContractMethodNoResultError) throw err;
1773
- if (err instanceof getProvider.ContractMethodRevertedError) throw err;
1774
-
1775
- const promises = () => contracts.map(contract => readContract({ ...contract,
1776
- overrides
1777
- }));
1778
-
1779
- if (allowFailure) return (await Promise.allSettled(promises())).map((result, i) => {
1780
- if (result.status === 'fulfilled') return result.value;
1781
- const {
1782
- address,
1783
- args,
1784
- chainId,
1785
- functionName
1786
- } = contracts[i];
1787
- const error = new getProvider.ContractMethodRevertedError({
1788
- address,
1789
- functionName,
1790
- chainId: chainId ?? chains.mainnet.id,
1791
- args,
1792
- errorMessage: result.reason
1793
- });
1794
- logWarn(error.message);
1795
- return null;
1796
- });
1797
- return await Promise.all(promises());
1798
- }
1799
- }
1800
-
1801
- function watchContractEvent(_ref, callback) {
1802
- let {
1803
- address,
1804
- abi,
1805
- chainId,
1806
- eventName,
1807
- once
1808
- } = _ref;
1809
-
1810
- const handler = function () {
1811
- return callback(...arguments);
1812
- };
1813
-
1814
- let contract;
1815
-
1816
- const watchEvent = async () => {
1817
- var _contract;
1818
-
1819
- if (contract) (_contract = contract) === null || _contract === void 0 ? void 0 : _contract.off(eventName, handler);
1820
- const signerOrProvider = getWebSocketProvider({
1821
- chainId
1822
- }) || getProvider.getProvider({
1823
- chainId
1824
- });
1825
- contract = getContract({
1826
- address,
1827
- abi: abi,
1828
- // TODO: Remove cast and still support `Narrow<TAbi>`
1829
- signerOrProvider
1830
- });
1831
- if (once) contract.once(eventName, handler);else contract.on(eventName, handler);
1832
- };
1833
-
1834
- watchEvent();
1835
- const client = getProvider.getClient();
1836
- const unsubscribe = client.subscribe(_ref2 => {
1837
- let {
1838
- provider,
1839
- webSocketProvider
1840
- } = _ref2;
1841
- return {
1842
- provider,
1843
- webSocketProvider
1844
- };
1845
- }, watchEvent, {
1846
- equalityFn: shallow__default["default"]
1847
- });
1848
- return () => {
1849
- var _contract2;
1850
-
1851
- (_contract2 = contract) === null || _contract2 === void 0 ? void 0 : _contract2.off(eventName, handler);
1852
- unsubscribe();
1853
- };
1854
- }
1855
-
1856
- async function fetchBlockNumber() {
1857
- let {
1858
- chainId
1859
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1860
- const provider = getProvider.getProvider({
1861
- chainId
1862
- });
1863
- const blockNumber = await provider.getBlockNumber();
1864
- return blockNumber;
1865
- }
1866
-
1867
- function watchBlockNumber(args, callback) {
1868
- // We need to debounce the listener as we want to opt-out
1869
- // of the behavior where ethers emits a "block" event for
1870
- // every block that was missed in between the `pollingInterval`.
1871
- // We are setting a wait time of 1 as emitting an event in
1872
- // ethers takes ~0.1ms.
1873
- const debouncedCallback = debounce.debounce(callback, 1);
1874
- let previousProvider;
1875
-
1876
- const createListener = provider => {
1877
- if (previousProvider) {
1878
- var _previousProvider;
1879
-
1880
- (_previousProvider = previousProvider) === null || _previousProvider === void 0 ? void 0 : _previousProvider.off('block', debouncedCallback);
1881
- }
1882
-
1883
- provider.on('block', debouncedCallback);
1884
- previousProvider = provider;
1885
- };
1886
-
1887
- const provider_ = getWebSocketProvider({
1888
- chainId: args.chainId
1889
- }) ?? getProvider.getProvider({
1890
- chainId: args.chainId
1891
- });
1892
- if (args.listen) createListener(provider_);
1893
- let active = true;
1894
- const client = getProvider.getClient();
1895
- const unsubscribe = client.subscribe(_ref => {
1896
- let {
1897
- provider,
1898
- webSocketProvider
1899
- } = _ref;
1900
- return {
1901
- provider,
1902
- webSocketProvider
1903
- };
1904
- }, async _ref2 => {
1905
- let {
1906
- provider,
1907
- webSocketProvider
1908
- } = _ref2;
1909
- const provider_ = webSocketProvider ?? provider;
1910
-
1911
- if (args.listen && !args.chainId && provider_) {
1912
- createListener(provider_);
1913
- }
1914
-
1915
- const blockNumber = await fetchBlockNumber({
1916
- chainId: args.chainId
1917
- });
1918
- if (!active) return;
1919
- callback(blockNumber);
1920
- }, {
1921
- equalityFn: shallow__default["default"]
1922
- });
1923
- return () => {
1924
- var _previousProvider2;
1925
-
1926
- active = false;
1927
- unsubscribe();
1928
- provider_ === null || provider_ === void 0 ? void 0 : provider_.off('block', debouncedCallback);
1929
- (_previousProvider2 = previousProvider) === null || _previousProvider2 === void 0 ? void 0 : _previousProvider2.off('block', debouncedCallback);
1930
- };
1931
- }
1932
-
1933
- function watchMulticall(config, callback) {
1934
- const client = getProvider.getClient();
1935
-
1936
- const handleChange = async () => callback(await multicall(config));
1937
-
1938
- const unwatch = config.listenToBlock ? watchBlockNumber({
1939
- listen: true
1940
- }, handleChange) : undefined;
1941
- const unsubscribe = client.subscribe(_ref => {
1942
- let {
1943
- provider
1944
- } = _ref;
1945
- return provider;
1946
- }, handleChange);
1947
- return () => {
1948
- unsubscribe();
1949
- unwatch === null || unwatch === void 0 ? void 0 : unwatch();
1950
- };
1951
- }
1952
-
1953
- function watchReadContract(config, callback) {
1954
- const client = getProvider.getClient();
1955
-
1956
- const handleChange = async () => callback(await readContract(config));
1957
-
1958
- const unwatch = config.listenToBlock ? watchBlockNumber({
1959
- listen: true
1960
- }, handleChange) : undefined;
1961
- const unsubscribe = client.subscribe(_ref => {
1962
- let {
1963
- provider
1964
- } = _ref;
1965
- return provider;
1966
- }, handleChange);
1967
- return () => {
1968
- unsubscribe();
1969
- unwatch === null || unwatch === void 0 ? void 0 : unwatch();
1970
- };
1971
- }
1972
-
1973
- function watchReadContracts(config, callback) {
1974
- const client = getProvider.getClient();
1975
-
1976
- const handleChange = async () => callback(await readContracts(config));
1977
-
1978
- const unwatch = config.listenToBlock ? watchBlockNumber({
1979
- listen: true
1980
- }, handleChange) : undefined;
1981
- const unsubscribe = client.subscribe(_ref => {
1982
- let {
1983
- provider
1984
- } = _ref;
1985
- return provider;
1986
- }, handleChange);
1987
- return () => {
1988
- unsubscribe();
1989
- unwatch === null || unwatch === void 0 ? void 0 : unwatch();
1990
- };
1991
- }
1992
-
1993
- /**
1994
- * @description Fetches transaction for hash
1995
- *
1996
- * @example
1997
- * import { fetchTransaction } from '@wagmi/core'
1998
- *
1999
- * const transaction = await fetchTransaction({
2000
- * chainId: 1,
2001
- * hash: '0x...',
2002
- * })
2003
- */
2004
- async function fetchTransaction(_ref) {
2005
- let {
2006
- chainId,
2007
- hash
2008
- } = _ref;
2009
- const provider = getProvider.getProvider({
2010
- chainId
2011
- });
2012
- return provider.getTransaction(hash);
2013
- }
2014
-
2015
- async function fetchEnsAddress(_ref) {
2016
- let {
2017
- chainId,
2018
- name
2019
- } = _ref;
2020
- const provider = getProvider.getProvider({
2021
- chainId
2022
- });
2023
- const address = await provider.resolveName(name);
2024
-
2025
- try {
2026
- return address ? utils.getAddress(address) : null;
2027
- } catch (_error) {
2028
- return null;
2029
- }
2030
- }
2031
-
2032
- async function fetchEnsAvatar(_ref) {
2033
- let {
2034
- addressOrName,
2035
- chainId
2036
- } = _ref;
2037
- const provider = getProvider.getProvider({
2038
- chainId
2039
- }); // TODO: Update with more advanced logic
2040
- // https://github.com/ensdomains/ens-avatar
2041
-
2042
- const avatar = await provider.getAvatar(addressOrName);
2043
- return avatar;
2044
- }
2045
-
2046
- async function fetchEnsName(_ref) {
2047
- let {
2048
- address,
2049
- chainId
2050
- } = _ref;
2051
- const provider = getProvider.getProvider({
2052
- chainId
2053
- });
2054
- return provider.lookupAddress(utils.getAddress(address));
2055
- }
2056
-
2057
- async function fetchEnsResolver(_ref) {
2058
- let {
2059
- chainId,
2060
- name
2061
- } = _ref;
2062
- const provider = getProvider.getProvider({
2063
- chainId
2064
- });
2065
- const resolver = await provider.getResolver(name);
2066
- return resolver;
2067
- }
2068
-
2069
- /**
2070
- * @description Prepares the parameters required for sending a transaction.
2071
- *
2072
- * Returns config to be passed through to `sendTransaction`.
2073
- *
2074
- * @example
2075
- * import { prepareSendTransaction, sendTransaction } from '@wagmi/core'
2076
- *
2077
- * const config = await prepareSendTransaction({
2078
- * request: {
2079
- * to: 'moxey.eth',
2080
- * value: parseEther('1'),
2081
- * }
2082
- * })
2083
- * const result = await sendTransaction(config)
2084
- */
2085
- async function prepareSendTransaction(_ref) {
2086
- let {
2087
- chainId,
2088
- request,
2089
- signer: signer_
2090
- } = _ref;
2091
- const signer = signer_ ?? (await fetchSigner({
2092
- chainId
2093
- }));
2094
- if (!signer) throw new getProvider.ConnectorNotFoundError();
2095
- if (chainId) assertActiveChain({
2096
- chainId,
2097
- signer
2098
- });
2099
- const [to, gasLimit] = await Promise.all([utils.isAddress(request.to) ? Promise.resolve(request.to) : fetchEnsAddress({
2100
- name: request.to
2101
- }), request.gasLimit ? Promise.resolve(request.gasLimit) : signer.estimateGas(request)]);
2102
- if (!to) throw new Error('Could not resolve ENS name');
2103
- return { ...(chainId ? {
2104
- chainId
2105
- } : {}),
2106
- request: { ...request,
2107
- gasLimit,
2108
- to
2109
- },
2110
- mode: 'prepared'
2111
- };
2112
- }
2113
-
2114
- /**
2115
- * @description Function to send a transaction.
2116
- *
2117
- * It is recommended to pair this with the `prepareSendTransaction` function to avoid
2118
- * [UX pitfalls](https://wagmi.sh/docs/prepare-hooks/intro#ux-pitfalls-without-prepare-hooks).
2119
- *
2120
- * @example
2121
- * import { prepareSendTransaction, sendTransaction } from '@wagmi/core'
2122
- *
2123
- * const config = await prepareSendTransaction({
2124
- * to: 'moxey.eth',
2125
- * value: parseEther('1'),
2126
- * })
2127
- * const result = await sendTransaction(config)
2128
- */
2129
- async function sendTransaction(_ref) {
2130
- let {
2131
- chainId,
2132
- mode,
2133
- request
2134
- } = _ref;
2135
-
2136
- /********************************************************************/
2137
-
2138
- /** START: iOS App Link cautious code. */
2139
-
2140
- /** Do not perform any async operations in this block. */
2141
-
2142
- /** Ref: wagmi.sh/docs/prepare-hooks/intro#ios-app-link-constraints */
2143
-
2144
- /********************************************************************/
2145
- // `fetchSigner` isn't really "asynchronous" as we have already
2146
- // initialized the provider upon user connection, so it will return
2147
- // immediately.
2148
- const signer = await fetchSigner();
2149
- if (!signer) throw new getProvider.ConnectorNotFoundError();
2150
-
2151
- if (mode === 'prepared') {
2152
- if (!request.gasLimit) throw new Error('`gasLimit` is required');
2153
- if (!request.to) throw new Error('`to` is required');
2154
- }
2155
-
2156
- if (chainId) assertActiveChain({
2157
- chainId,
2158
- signer
2159
- });
2160
-
2161
- try {
2162
- var _connectUnchecked, _ref2;
2163
-
2164
- // Why don't we just use `signer.sendTransaction`?
2165
- // The `signer.sendTransaction` method performs async
2166
- // heavy operations (such as fetching block number)
2167
- // which is not really needed for our case.
2168
- // Having async heavy operations has side effects
2169
- // when using it in a click handler (iOS deep linking issues,
2170
- // delay to open wallet, etc).
2171
- const uncheckedSigner = (_connectUnchecked = (_ref2 = signer).connectUnchecked) === null || _connectUnchecked === void 0 ? void 0 : _connectUnchecked.call(_ref2);
2172
- const {
2173
- hash,
2174
- wait
2175
- } = await (uncheckedSigner ?? signer).sendTransaction(request);
2176
- /********************************************************************/
2177
-
2178
- /** END: iOS App Link cautious code. */
2179
-
2180
- /** Go nuts! */
2181
-
2182
- /********************************************************************/
2183
-
2184
- return {
2185
- hash: hash,
2186
- wait
2187
- };
2188
- } catch (error) {
2189
- if (error.code === 4001) throw new getProvider.UserRejectedRequestError(error);
2190
- throw error;
2191
- }
2192
- }
2193
-
2194
- async function waitForTransaction(_ref) {
2195
- let {
2196
- chainId,
2197
- confirmations,
2198
- hash,
2199
- timeout,
2200
- wait: wait_
2201
- } = _ref;
2202
- let promise;
2203
-
2204
- if (hash) {
2205
- const provider = getProvider.getProvider({
2206
- chainId
2207
- });
2208
- promise = provider.waitForTransaction(hash, confirmations, timeout);
2209
- } else if (wait_) promise = wait_(confirmations);else throw new Error('hash or wait is required');
2210
-
2211
- return promise;
2212
- }
2213
-
2214
- /**
2215
- * @description Function to call a contract write method.
2216
- *
2217
- * It is recommended to pair this with the {@link prepareWriteContract} function
2218
- * to avoid [UX pitfalls](https://wagmi.sh/docs/prepare-hooks/intro#ux-pitfalls-without-prepare-hooks).
2219
- *
2220
- * @example
2221
- * import { prepareWriteContract, writeContract } from '@wagmi/core'
2222
- *
2223
- * const config = await prepareWriteContract({
2224
- * address: '0x...',
2225
- * abi: wagmiAbi,
2226
- * functionName: 'mint',
2227
- * })
2228
- * const result = await writeContract(config)
2229
- */
2230
- async function writeContract(_ref) {
2231
- let {
2232
- address,
2233
- args,
2234
- chainId,
2235
- abi,
2236
- functionName,
2237
- mode,
2238
- overrides,
2239
- request: request_
2240
- } = _ref;
2241
-
2242
- /****************************************************************************/
2243
-
2244
- /** START: iOS App Link cautious code. */
2245
-
2246
- /** Do not perform any async operations in this block. */
2247
-
2248
- /** Ref: https://wagmi.sh/docs/prepare-hooks/intro#ios-app-link-constraints */
2249
-
2250
- /****************************************************************************/
2251
- const signer = await fetchSigner();
2252
- if (!signer) throw new getProvider.ConnectorNotFoundError();
2253
- if (chainId) assertActiveChain({
2254
- chainId,
2255
- signer
2256
- });
2257
- if (mode === 'prepared') if (!request_) throw new Error('`request` is required');
2258
- const request = mode === 'recklesslyUnprepared' ? (await prepareWriteContract({
2259
- address,
2260
- args,
2261
- chainId,
2262
- abi: abi,
2263
- // TODO: Remove cast and still support `Narrow<TAbi>`
2264
- functionName,
2265
- overrides
2266
- })).request : request_;
2267
- const transaction = await sendTransaction({
2268
- request,
2269
- mode: 'prepared'
2270
- });
2271
- /********************************************************************/
2272
-
2273
- /** END: iOS App Link cautious code. */
2274
-
2275
- /** Go nuts! */
2276
-
2277
- /********************************************************************/
2278
-
2279
- return transaction;
2280
- }
2281
-
2282
- async function fetchBalance(_ref) {
2283
- var _chain$nativeCurrency, _chain$nativeCurrency2;
2284
-
2285
- let {
2286
- addressOrName,
2287
- chainId,
2288
- formatUnits: unit,
2289
- token
2290
- } = _ref;
2291
- const client = getProvider.getClient();
2292
- const provider = getProvider.getProvider({
2293
- chainId
2294
- });
2295
-
2296
- if (token) {
2297
- // Convert ENS name to address if required
2298
- let resolvedAddress;
2299
- if (utils.isAddress(addressOrName)) resolvedAddress = addressOrName;else {
2300
- const address = await provider.resolveName(addressOrName); // Same error `provider.getBalance` throws for invalid ENS name
2301
-
2302
- if (!address) ethers$1.logger.throwError('ENS name not configured', utils.Logger.errors.UNSUPPORTED_OPERATION, {
2303
- operation: `resolveName(${JSON.stringify(addressOrName)})`
2304
- });
2305
- resolvedAddress = address;
2306
- }
2307
-
2308
- const fetchContractBalance = async _ref2 => {
2309
- let {
2310
- abi
2311
- } = _ref2;
2312
- const erc20Config = {
2313
- abi,
2314
- address: token,
2315
- chainId
2316
- };
2317
- const [value, decimals, symbol] = await readContracts({
2318
- allowFailure: false,
2319
- contracts: [{ ...erc20Config,
2320
- functionName: 'balanceOf',
2321
- args: [resolvedAddress]
2322
- }, { ...erc20Config,
2323
- functionName: 'decimals'
2324
- }, { ...erc20Config,
2325
- functionName: 'symbol'
2326
- }]
2327
- });
2328
- return {
2329
- decimals,
2330
- formatted: utils.formatUnits(value ?? '0', unit ?? decimals),
2331
- symbol: symbol,
2332
- // protect against `ResolvedConfig['BytesType']`
2333
- value
2334
- };
2335
- };
2336
-
2337
- try {
2338
- return await fetchContractBalance({
2339
- abi: erc20ABI
2340
- });
2341
- } catch (err) {
2342
- // In the chance that there is an error upon decoding the contract result,
2343
- // it could be likely that the contract data is represented as bytes32 instead
2344
- // of a string.
2345
- if (err instanceof getProvider.ContractResultDecodeError) {
2346
- const {
2347
- symbol,
2348
- ...rest
2349
- } = await fetchContractBalance({
2350
- abi: erc20ABI_bytes32
2351
- });
2352
- return {
2353
- symbol: utils.parseBytes32String(symbol),
2354
- ...rest
2355
- };
2356
- }
2357
-
2358
- throw err;
2359
- }
2360
- }
2361
-
2362
- const chains = [...(client.provider.chains || []), ...(client.chains ?? [])];
2363
- const value = await provider.getBalance(addressOrName);
2364
- const chain = chains.find(x => x.id === provider.network.chainId);
2365
- return {
2366
- decimals: (chain === null || chain === void 0 ? void 0 : (_chain$nativeCurrency = chain.nativeCurrency) === null || _chain$nativeCurrency === void 0 ? void 0 : _chain$nativeCurrency.decimals) ?? 18,
2367
- formatted: utils.formatUnits(value ?? '0', unit ?? 'ether'),
2368
- symbol: (chain === null || chain === void 0 ? void 0 : (_chain$nativeCurrency2 = chain.nativeCurrency) === null || _chain$nativeCurrency2 === void 0 ? void 0 : _chain$nativeCurrency2.symbol) ?? 'ETH',
2369
- value
2370
- };
2371
- }
2372
-
2373
- async function fetchSigner() {
2374
- var _client$connector, _client$connector$get;
2375
-
2376
- let {
2377
- chainId
2378
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2379
- const client = getProvider.getClient();
2380
- const signer = (await ((_client$connector = client.connector) === null || _client$connector === void 0 ? void 0 : (_client$connector$get = _client$connector.getSigner) === null || _client$connector$get === void 0 ? void 0 : _client$connector$get.call(_client$connector, {
2381
- chainId
2382
- }))) || null;
2383
- return signer;
2384
- }
2385
-
2386
- function getAccount() {
2387
- const {
2388
- data,
2389
- connector,
2390
- status
2391
- } = getProvider.getClient();
2392
-
2393
- switch (status) {
2394
- case 'connected':
2395
- return {
2396
- address: data === null || data === void 0 ? void 0 : data.account,
2397
- connector: connector,
2398
- isConnected: true,
2399
- isConnecting: false,
2400
- isDisconnected: false,
2401
- isReconnecting: false,
2402
- status
2403
- };
2404
-
2405
- case 'reconnecting':
2406
- return {
2407
- address: data === null || data === void 0 ? void 0 : data.account,
2408
- connector,
2409
- isConnected: !!(data !== null && data !== void 0 && data.account),
2410
- isConnecting: false,
2411
- isDisconnected: false,
2412
- isReconnecting: true,
2413
- status
2414
- };
2415
-
2416
- case 'connecting':
2417
- return {
2418
- address: undefined,
2419
- connector: undefined,
2420
- isConnected: false,
2421
- isConnecting: true,
2422
- isDisconnected: false,
2423
- isReconnecting: false,
2424
- status
2425
- };
2426
-
2427
- case 'disconnected':
2428
- return {
2429
- address: undefined,
2430
- connector: undefined,
2431
- isConnected: false,
2432
- isConnecting: false,
2433
- isDisconnected: true,
2434
- isReconnecting: false,
2435
- status
2436
- };
2437
- }
2438
- }
2439
-
2440
- function getNetwork() {
2441
- var _client$data, _client$data$chain, _client$data2;
2442
-
2443
- const client = getProvider.getClient();
2444
- const chainId = (_client$data = client.data) === null || _client$data === void 0 ? void 0 : (_client$data$chain = _client$data.chain) === null || _client$data$chain === void 0 ? void 0 : _client$data$chain.id;
2445
- const activeChains = client.chains ?? [];
2446
- const activeChain = [...(client.provider.chains || []), ...activeChains].find(x => x.id === chainId) ?? {
2447
- id: chainId,
2448
- name: `Chain ${chainId}`,
2449
- network: `${chainId}`,
2450
- rpcUrls: {
2451
- default: ''
2452
- }
2453
- };
2454
- return {
2455
- chain: chainId ? { ...activeChain,
2456
- ...((_client$data2 = client.data) === null || _client$data2 === void 0 ? void 0 : _client$data2.chain),
2457
- id: chainId
2458
- } : undefined,
2459
- chains: activeChains
2460
- };
2461
- }
2462
-
2463
- async function signMessage(args) {
2464
- try {
2465
- const signer = await fetchSigner();
2466
- if (!signer) throw new getProvider.ConnectorNotFoundError();
2467
- return await signer.signMessage(args.message);
2468
- } catch (error) {
2469
- if (error.code === 4001) throw new getProvider.UserRejectedRequestError(error);
2470
- throw error;
2471
- }
2472
- }
2473
-
2474
- async function signTypedData(_ref) {
2475
- let {
2476
- domain,
2477
- types,
2478
- value
2479
- } = _ref;
2480
- const signer = await fetchSigner();
2481
- if (!signer) throw new getProvider.ConnectorNotFoundError();
2482
- const {
2483
- chainId: chainId_
2484
- } = domain;
2485
- const chainId = chainId_ ? getProvider.normalizeChainId(chainId_) : undefined;
2486
- if (chainId) assertActiveChain({
2487
- chainId,
2488
- signer
2489
- }); // Method name may be changed in the future, see https://docs.ethers.io/v5/api/signer/#Signer-signTypedData
2490
-
2491
- return signer._signTypedData(domain, types, value);
2492
- }
2493
-
2494
- async function switchNetwork(_ref) {
2495
- let {
2496
- chainId
2497
- } = _ref;
2498
- const {
2499
- connector
2500
- } = getProvider.getClient();
2501
- if (!connector) throw new getProvider.ConnectorNotFoundError();
2502
- if (!connector.switchChain) throw new getProvider.SwitchChainNotSupportedError({
2503
- connector
2504
- });
2505
- return connector.switchChain(chainId);
2506
- }
2507
-
2508
- function watchAccount(callback) {
2509
- let {
2510
- selector = x => x
2511
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2512
- const client = getProvider.getClient();
2513
-
2514
- const handleChange = () => callback(getAccount());
2515
-
2516
- const unsubscribe = client.subscribe(_ref => {
2517
- let {
2518
- data,
2519
- connector,
2520
- status
2521
- } = _ref;
2522
- return selector({
2523
- address: data === null || data === void 0 ? void 0 : data.account,
2524
- connector,
2525
- status
2526
- });
2527
- }, handleChange, {
2528
- equalityFn: shallow__default["default"]
2529
- });
2530
- return unsubscribe;
2531
- }
2532
-
2533
- function watchNetwork(callback) {
2534
- let {
2535
- selector = x => x
2536
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2537
- const client = getProvider.getClient();
2538
-
2539
- const handleChange = () => callback(getNetwork());
2540
-
2541
- const unsubscribe = client.subscribe(_ref => {
2542
- var _data$chain;
2543
-
2544
- let {
2545
- data,
2546
- chains
2547
- } = _ref;
2548
- return selector({
2549
- chainId: data === null || data === void 0 ? void 0 : (_data$chain = data.chain) === null || _data$chain === void 0 ? void 0 : _data$chain.id,
2550
- chains
2551
- });
2552
- }, handleChange, {
2553
- equalityFn: shallow__default["default"]
2554
- });
2555
- return unsubscribe;
2556
- }
2557
-
2558
- function watchSigner(_ref, callback) {
2559
- let {
2560
- chainId
2561
- } = _ref;
2562
- const client = getProvider.getClient();
2563
-
2564
- const handleChange = async () => callback(await fetchSigner({
2565
- chainId
2566
- }));
2567
-
2568
- const unsubscribe = client.subscribe(_ref2 => {
2569
- var _data$chain;
2570
-
2571
- let {
2572
- data,
2573
- connector
2574
- } = _ref2;
2575
- return {
2576
- account: data === null || data === void 0 ? void 0 : data.account,
2577
- chainId: data === null || data === void 0 ? void 0 : (_data$chain = data.chain) === null || _data$chain === void 0 ? void 0 : _data$chain.id,
2578
- connector
2579
- };
2580
- }, handleChange, {
2581
- equalityFn: shallow__default["default"]
2582
- });
2583
- return unsubscribe;
2584
- }
2585
-
2586
- async function fetchFeeData() {
2587
- let {
2588
- chainId,
2589
- formatUnits: units = 'wei'
2590
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2591
- const provider = getProvider.getProvider({
2592
- chainId
2593
- });
2594
- const feeData = await provider.getFeeData();
2595
- const formatted = {
2596
- gasPrice: feeData.gasPrice ? utils.formatUnits(feeData.gasPrice, units) : null,
2597
- maxFeePerGas: feeData.maxFeePerGas ? utils.formatUnits(feeData.maxFeePerGas, units) : null,
2598
- maxPriorityFeePerGas: feeData.maxPriorityFeePerGas ? utils.formatUnits(feeData.maxPriorityFeePerGas, units) : null
2599
- };
2600
- return { ...feeData,
2601
- formatted
2602
- };
2603
- }
2604
-
2605
- exports.AddChainError = getProvider.AddChainError;
2606
- exports.ChainDoesNotSupportMulticallError = getProvider.ChainDoesNotSupportMulticallError;
2607
- exports.ChainMismatchError = getProvider.ChainMismatchError;
2608
- exports.ChainNotConfiguredError = getProvider.ChainNotConfiguredError;
2609
- exports.Client = getProvider.Client;
2610
- exports.Connector = getProvider.Connector;
2611
- exports.ConnectorAlreadyConnectedError = getProvider.ConnectorAlreadyConnectedError;
2612
- exports.ConnectorNotFoundError = getProvider.ConnectorNotFoundError;
2613
- exports.ContractMethodDoesNotExistError = getProvider.ContractMethodDoesNotExistError;
2614
- exports.ContractMethodNoResultError = getProvider.ContractMethodNoResultError;
2615
- exports.ContractMethodRevertedError = getProvider.ContractMethodRevertedError;
2616
- exports.ContractResultDecodeError = getProvider.ContractResultDecodeError;
2617
- exports.InjectedConnector = getProvider.InjectedConnector;
2618
- exports.ProviderChainsNotFound = getProvider.ProviderChainsNotFound;
2619
- exports.ProviderRpcError = getProvider.ProviderRpcError;
2620
- exports.ResourceUnavailableError = getProvider.ResourceUnavailableError;
2621
- exports.RpcError = getProvider.RpcError;
2622
- exports.SwitchChainError = getProvider.SwitchChainError;
2623
- exports.SwitchChainNotSupportedError = getProvider.SwitchChainNotSupportedError;
2624
- exports.UserRejectedRequestError = getProvider.UserRejectedRequestError;
2625
- exports.createClient = getProvider.createClient;
2626
- exports.createStorage = getProvider.createStorage;
2627
- exports.getProvider = getProvider.getProvider;
2628
- exports.noopStorage = getProvider.noopStorage;
2629
- exports.normalizeChainId = getProvider.normalizeChainId;
2630
- exports.allChains = chains.allChains;
2631
- exports.chain = chains.chain;
2632
- exports.chainId = chains.chainId;
2633
- exports.defaultChains = chains.defaultChains;
2634
- exports.defaultL2Chains = chains.defaultL2Chains;
2635
- exports.etherscanBlockExplorers = chains.etherscanBlockExplorers;
2636
- exports.alchemyRpcUrls = rpcs.alchemyRpcUrls;
2637
- exports.infuraRpcUrls = rpcs.infuraRpcUrls;
2638
- exports.publicRpcUrls = rpcs.publicRpcUrls;
2639
- exports.configureChains = configureChains;
2640
- exports.connect = connect;
2641
- exports.deepEqual = deepEqual;
2642
- exports.disconnect = disconnect;
2643
- exports.erc20ABI = erc20ABI;
2644
- exports.erc4626ABI = erc4626ABI;
2645
- exports.erc721ABI = erc721ABI;
2646
- exports.fetchBalance = fetchBalance;
2647
- exports.fetchBlockNumber = fetchBlockNumber;
2648
- exports.fetchEnsAddress = fetchEnsAddress;
2649
- exports.fetchEnsAvatar = fetchEnsAvatar;
2650
- exports.fetchEnsName = fetchEnsName;
2651
- exports.fetchEnsResolver = fetchEnsResolver;
2652
- exports.fetchFeeData = fetchFeeData;
2653
- exports.fetchSigner = fetchSigner;
2654
- exports.fetchToken = fetchToken;
2655
- exports.fetchTransaction = fetchTransaction;
2656
- exports.getAccount = getAccount;
2657
- exports.getContract = getContract;
2658
- exports.getNetwork = getNetwork;
2659
- exports.getWebSocketProvider = getWebSocketProvider;
2660
- exports.minimizeContractInterface = minimizeContractInterface;
2661
- exports.multicall = multicall;
2662
- exports.parseContractResult = parseContractResult;
2663
- exports.prepareSendTransaction = prepareSendTransaction;
2664
- exports.prepareWriteContract = prepareWriteContract;
2665
- exports.readContract = readContract;
2666
- exports.readContracts = readContracts;
2667
- exports.sendTransaction = sendTransaction;
2668
- exports.signMessage = signMessage;
2669
- exports.signTypedData = signTypedData;
2670
- exports.switchNetwork = switchNetwork;
2671
- exports.units = units;
2672
- exports.waitForTransaction = waitForTransaction;
2673
- exports.watchAccount = watchAccount;
2674
- exports.watchBlockNumber = watchBlockNumber;
2675
- exports.watchContractEvent = watchContractEvent;
2676
- exports.watchMulticall = watchMulticall;
2677
- exports.watchNetwork = watchNetwork;
2678
- exports.watchProvider = watchProvider;
2679
- exports.watchReadContract = watchReadContract;
2680
- exports.watchReadContracts = watchReadContracts;
2681
- exports.watchSigner = watchSigner;
2682
- exports.watchWebSocketProvider = watchWebSocketProvider;
2683
- exports.writeContract = writeContract;