@wagmi/core 0.5.8 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/chains/dist/wagmi-core-chains.cjs.dev.js +2 -2
- package/chains/dist/wagmi-core-chains.cjs.prod.js +2 -2
- package/chains/dist/wagmi-core-chains.esm.js +2 -2
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.dev.js +11 -12
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.prod.js +11 -12
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.esm.js +11 -12
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.dev.js +4 -3
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.prod.js +4 -3
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.esm.js +4 -3
- package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.dev.js +9 -13
- package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.prod.js +9 -13
- package/connectors/mock/dist/wagmi-core-connectors-mock.esm.js +9 -13
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.dev.js +9 -11
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.prod.js +9 -11
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.esm.js +9 -11
- package/dist/{chains-8c76af1b.esm.js → chains-2970e5fa.esm.js} +17 -11
- package/dist/{chains-ec1de502.cjs.dev.js → chains-45d5aa86.cjs.prod.js} +17 -11
- package/dist/{chains-789e0c2e.cjs.prod.js → chains-524f4950.cjs.dev.js} +17 -11
- package/dist/declarations/src/actions/accounts/fetchBalance.d.ts +4 -4
- package/dist/declarations/src/actions/accounts/fetchSigner.d.ts +5 -1
- package/dist/declarations/src/actions/accounts/index.d.ts +1 -1
- package/dist/declarations/src/actions/accounts/signMessage.d.ts +3 -5
- package/dist/declarations/src/actions/accounts/signTypedData.d.ts +19 -20
- package/dist/declarations/src/actions/accounts/watchSigner.d.ts +5 -3
- package/dist/declarations/src/actions/contracts/fetchToken.d.ts +5 -5
- package/dist/declarations/src/actions/contracts/getContract.d.ts +111 -8
- package/dist/declarations/src/actions/contracts/index.d.ts +5 -4
- package/dist/declarations/src/actions/contracts/multicall.d.ts +11 -15
- package/dist/declarations/src/actions/contracts/prepareWriteContract.d.ts +26 -16
- package/dist/declarations/src/actions/contracts/readContract.d.ts +12 -14
- package/dist/declarations/src/actions/contracts/readContracts.d.ts +25 -16
- package/dist/declarations/src/actions/contracts/watchContractEvent.d.ts +22 -8
- package/dist/declarations/src/actions/contracts/watchMulticall.d.ts +10 -0
- package/dist/declarations/src/actions/contracts/watchReadContract.d.ts +4 -3
- package/dist/declarations/src/actions/contracts/watchReadContracts.d.ts +7 -3
- package/dist/declarations/src/actions/contracts/writeContract.d.ts +43 -23
- package/dist/declarations/src/actions/ens/fetchEnsAddress.d.ts +1 -1
- package/dist/declarations/src/actions/ens/fetchEnsName.d.ts +2 -1
- package/dist/declarations/src/actions/index.d.ts +3 -3
- package/dist/declarations/src/actions/transactions/index.d.ts +0 -1
- package/dist/declarations/src/actions/transactions/prepareSendTransaction.d.ts +5 -4
- package/dist/declarations/src/actions/transactions/sendTransaction.d.ts +3 -2
- package/dist/declarations/src/actions/transactions/waitForTransaction.d.ts +2 -1
- package/dist/declarations/src/connectors/base.d.ts +5 -4
- package/dist/declarations/src/connectors/coinbaseWallet.d.ts +5 -3
- package/dist/declarations/src/connectors/injected.d.ts +10 -9
- package/dist/declarations/src/connectors/metaMask.d.ts +1 -1
- package/dist/declarations/src/connectors/mock/connector.d.ts +1 -1
- package/dist/declarations/src/connectors/mock/provider.d.ts +1 -1
- package/dist/declarations/src/connectors/walletConnect.d.ts +2 -2
- package/dist/declarations/src/constants/abis.d.ts +421 -2
- package/dist/declarations/src/constants/blockExplorers.d.ts +1 -1
- package/dist/declarations/src/constants/index.d.ts +1 -2
- package/dist/declarations/src/errors.d.ts +8 -8
- package/dist/declarations/src/index.d.ts +4 -3
- package/dist/declarations/src/internal.d.ts +2 -0
- package/dist/declarations/src/types/contracts.d.ts +241 -0
- package/dist/declarations/src/types/index.d.ts +31 -9
- package/dist/declarations/src/types/utils.d.ts +103 -0
- package/dist/declarations/src/utils/assertActiveChain.d.ts +3 -0
- package/dist/declarations/src/utils/configureChains.d.ts +3 -5
- package/dist/declarations/src/utils/index.d.ts +2 -0
- package/dist/declarations/src/utils/minimizeContractInterface.d.ts +5 -5
- package/dist/declarations/src/utils/normalizeFunctionName.d.ts +17 -0
- package/dist/declarations/src/utils/parseContractResult.d.ts +4 -4
- package/dist/{getProvider-5b4b62c3.esm.js → getProvider-24ec6544.esm.js} +49 -50
- package/dist/{getProvider-1b3eeda8.cjs.dev.js → getProvider-ed469b94.cjs.prod.js} +48 -49
- package/dist/{getProvider-ad4ce6a4.cjs.prod.js → getProvider-f6f17fa1.cjs.dev.js} +48 -49
- package/dist/{rpcs-d2cd65f1.cjs.dev.js → rpcs-0d21dfe8.cjs.dev.js} +5 -5
- package/dist/{rpcs-8d636858.esm.js → rpcs-b4aa70b9.esm.js} +6 -6
- package/dist/{rpcs-edec227e.cjs.prod.js → rpcs-c62bf9b0.cjs.prod.js} +5 -5
- package/dist/wagmi-core.cjs.dev.js +847 -395
- package/dist/wagmi-core.cjs.prod.js +847 -395
- package/dist/wagmi-core.esm.js +849 -397
- package/package.json +3 -2
- package/providers/alchemy/dist/wagmi-core-providers-alchemy.cjs.dev.js +2 -2
- package/providers/alchemy/dist/wagmi-core-providers-alchemy.cjs.prod.js +2 -2
- package/providers/alchemy/dist/wagmi-core-providers-alchemy.esm.js +2 -2
- package/providers/infura/dist/wagmi-core-providers-infura.cjs.dev.js +2 -2
- package/providers/infura/dist/wagmi-core-providers-infura.cjs.prod.js +2 -2
- package/providers/infura/dist/wagmi-core-providers-infura.esm.js +2 -2
- package/dist/declarations/src/actions/contracts/deprecatedWriteContract.d.ts +0 -16
- package/dist/declarations/src/actions/transactions/deprecatedSendTransaction.d.ts +0 -12
- package/dist/declarations/src/constants/multicall.d.ts +0 -25
- package/providers/coinbaseNode/dist/wagmi-core-providers-coinbaseNode.cjs.d.ts +0 -11
- package/providers/coinbaseNode/dist/wagmi-core-providers-coinbaseNode.cjs.js +0 -16
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var getProvider = require('./getProvider-
|
|
6
|
-
var ethers = require('ethers');
|
|
5
|
+
var getProvider = require('./getProvider-f6f17fa1.cjs.dev.js');
|
|
7
6
|
var ethers$1 = require('ethers/lib/ethers');
|
|
8
7
|
var utils = require('ethers/lib/utils');
|
|
9
|
-
var
|
|
8
|
+
var ethers = require('ethers');
|
|
9
|
+
var chains = require('./chains-524f4950.cjs.dev.js');
|
|
10
10
|
var shallow = require('zustand/shallow');
|
|
11
11
|
var debounce = require('./debounce-46ac0312.cjs.dev.js');
|
|
12
|
-
var rpcs = require('./rpcs-
|
|
12
|
+
var rpcs = require('./rpcs-0d21dfe8.cjs.dev.js');
|
|
13
13
|
require('zustand/middleware');
|
|
14
14
|
require('zustand/vanilla');
|
|
15
15
|
require('eventemitter3');
|
|
@@ -21,7 +21,7 @@ var shallow__default = /*#__PURE__*/_interopDefault(shallow);
|
|
|
21
21
|
function configureChains(defaultChains, providers) {
|
|
22
22
|
let {
|
|
23
23
|
minQuorum = 1,
|
|
24
|
-
pollingInterval =
|
|
24
|
+
pollingInterval = 4_000,
|
|
25
25
|
targetQuorum = 1,
|
|
26
26
|
stallTimeout
|
|
27
27
|
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
@@ -60,48 +60,63 @@ function configureChains(defaultChains, providers) {
|
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
if (!configExists) {
|
|
63
|
-
throw new Error([
|
|
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
64
|
}
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
return {
|
|
68
68
|
chains,
|
|
69
69
|
provider: _ref2 => {
|
|
70
|
-
var _defaultChains$;
|
|
71
|
-
|
|
72
70
|
let {
|
|
73
71
|
chainId
|
|
74
72
|
} = _ref2;
|
|
75
|
-
const
|
|
76
|
-
const chainProviders = providers_[
|
|
77
|
-
if (!chainProviders || !chainProviders[0]) throw new Error(
|
|
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;
|
|
78
77
|
|
|
79
78
|
if (chainProviders.length === 1) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
provider = chainProviders[0]();
|
|
80
|
+
} else {
|
|
81
|
+
provider = fallbackProvider(targetQuorum, minQuorum, chainProviders, {
|
|
82
|
+
stallTimeout
|
|
83
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
|
+
};
|
|
84
92
|
}
|
|
85
93
|
|
|
86
|
-
return Object.assign(
|
|
87
|
-
stallTimeout
|
|
88
|
-
}), {
|
|
94
|
+
return Object.assign(provider, {
|
|
89
95
|
chains,
|
|
90
96
|
pollingInterval
|
|
91
97
|
});
|
|
92
98
|
},
|
|
93
99
|
webSocketProvider: _ref3 => {
|
|
94
|
-
var
|
|
100
|
+
var _chainWebSocketProvid;
|
|
95
101
|
|
|
96
102
|
let {
|
|
97
103
|
chainId
|
|
98
104
|
} = _ref3;
|
|
99
|
-
const
|
|
100
|
-
const chainWebSocketProviders = webSocketProviders_[
|
|
101
|
-
if (!chainWebSocketProviders) return undefined;
|
|
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`
|
|
102
116
|
// Default to first available
|
|
103
117
|
|
|
104
|
-
|
|
118
|
+
|
|
119
|
+
return Object.assign(provider || {}, {
|
|
105
120
|
chains
|
|
106
121
|
});
|
|
107
122
|
}
|
|
@@ -115,13 +130,11 @@ function fallbackProvider(targetQuorum, minQuorum, providers_, _ref4) {
|
|
|
115
130
|
|
|
116
131
|
try {
|
|
117
132
|
return new ethers.providers.FallbackProvider(providers_.map((chainProvider, index) => {
|
|
118
|
-
var _provider$priority, _provider$stallTimeou;
|
|
119
|
-
|
|
120
133
|
const provider = chainProvider();
|
|
121
134
|
return {
|
|
122
135
|
provider,
|
|
123
|
-
priority:
|
|
124
|
-
stallTimeout:
|
|
136
|
+
priority: provider.priority ?? index,
|
|
137
|
+
stallTimeout: provider.stallTimeout ?? stallTimeout,
|
|
125
138
|
weight: provider.weight
|
|
126
139
|
};
|
|
127
140
|
}), targetQuorum);
|
|
@@ -139,6 +152,26 @@ function fallbackProvider(targetQuorum, minQuorum, providers_, _ref4) {
|
|
|
139
152
|
}
|
|
140
153
|
}
|
|
141
154
|
|
|
155
|
+
function assertActiveChain(_ref) {
|
|
156
|
+
let {
|
|
157
|
+
chainId
|
|
158
|
+
} = _ref;
|
|
159
|
+
const {
|
|
160
|
+
chain: activeChain,
|
|
161
|
+
chains
|
|
162
|
+
} = getNetwork();
|
|
163
|
+
const activeChainId = activeChain === null || activeChain === void 0 ? void 0 : activeChain.id;
|
|
164
|
+
|
|
165
|
+
if (chainId !== activeChainId) {
|
|
166
|
+
var _chains$find, _chains$find2;
|
|
167
|
+
|
|
168
|
+
throw new getProvider.ChainMismatchError({
|
|
169
|
+
activeChain: ((_chains$find = chains.find(x => x.id === activeChainId)) === null || _chains$find === void 0 ? void 0 : _chains$find.name) ?? `Chain ${activeChainId}`,
|
|
170
|
+
targetChain: ((_chains$find2 = chains.find(x => x.id === chainId)) === null || _chains$find2 === void 0 ? void 0 : _chains$find2.name) ?? `Chain ${chainId}`
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
142
175
|
/** Forked from https://github.com/epoberezkin/fast-deep-equal */
|
|
143
176
|
function deepEqual(a, b) {
|
|
144
177
|
if (a === b) return true;
|
|
@@ -177,20 +210,100 @@ function deepEqual(a, b) {
|
|
|
177
210
|
return a !== a && b !== b;
|
|
178
211
|
}
|
|
179
212
|
|
|
213
|
+
/**
|
|
214
|
+
* Get normalized function name from contract
|
|
215
|
+
*
|
|
216
|
+
* @param contract — Contract
|
|
217
|
+
* @param functionName — Function name
|
|
218
|
+
* @param args — Function arguments (used to disambiguate overloaded functions)
|
|
219
|
+
*
|
|
220
|
+
* @returns Normalized function name
|
|
221
|
+
*/
|
|
222
|
+
|
|
223
|
+
function normalizeFunctionName(_ref) {
|
|
224
|
+
let {
|
|
225
|
+
contract,
|
|
226
|
+
functionName,
|
|
227
|
+
args = []
|
|
228
|
+
} = _ref;
|
|
229
|
+
// If `functionName` exists in contract, return it.
|
|
230
|
+
if (functionName in contract.functions) return functionName; // Otherwise, check if `functionName` is an overloaded function based on `args` shape.
|
|
231
|
+
|
|
232
|
+
const argsLength = (args === null || args === void 0 ? void 0 : args.length) ?? 0;
|
|
233
|
+
const overloadFunctions = Object.keys(contract.functions).filter(x => x.startsWith(`${functionName}(`)).map(x => ({
|
|
234
|
+
name: x,
|
|
235
|
+
fragment: utils.FunctionFragment.fromString(x)
|
|
236
|
+
})).filter(x => argsLength === x.fragment.inputs.length);
|
|
237
|
+
|
|
238
|
+
for (const overloadFunction of overloadFunctions) {
|
|
239
|
+
const matched = args.every((arg, index) => {
|
|
240
|
+
const abiParameter = overloadFunction.fragment.inputs[index];
|
|
241
|
+
return isArgOfType(arg, abiParameter);
|
|
242
|
+
});
|
|
243
|
+
if (matched) return overloadFunction.name;
|
|
244
|
+
} // Wasn't able to find overload, just return function name.
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
return functionName;
|
|
248
|
+
}
|
|
249
|
+
function isArgOfType(arg, abiParameter) {
|
|
250
|
+
const argType = typeof arg;
|
|
251
|
+
const abiParameterType = abiParameter.type;
|
|
252
|
+
|
|
253
|
+
switch (abiParameterType) {
|
|
254
|
+
case 'address':
|
|
255
|
+
return utils.isAddress(arg);
|
|
256
|
+
|
|
257
|
+
case 'bool':
|
|
258
|
+
return argType === 'boolean';
|
|
259
|
+
|
|
260
|
+
case 'function':
|
|
261
|
+
return argType === 'string';
|
|
262
|
+
|
|
263
|
+
case 'string':
|
|
264
|
+
return argType === 'string';
|
|
265
|
+
|
|
266
|
+
default:
|
|
267
|
+
{
|
|
268
|
+
if (abiParameterType === 'tuple' && 'components' in abiParameter) return Object.values(abiParameter.components).every((component, index) => {
|
|
269
|
+
return isArgOfType(Object.values(arg)[index], component);
|
|
270
|
+
}); // `(u)int<M>`: (un)signed integer type of `M` bits, `0 < M <= 256`, `M % 8 == 0`
|
|
271
|
+
// https://regexr.com/6v8hp
|
|
272
|
+
|
|
273
|
+
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`
|
|
274
|
+
// https://regexr.com/6va55
|
|
275
|
+
|
|
276
|
+
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
|
|
277
|
+
// https://regexr.com/6va6i
|
|
278
|
+
|
|
279
|
+
if (/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(abiParameterType)) {
|
|
280
|
+
return Array.isArray(arg) && arg.every(x => isArgOfType(x, { ...abiParameter,
|
|
281
|
+
// Pop off `[]` or `[M]` from end of type
|
|
282
|
+
type: abiParameterType.replace(/(\[[0-9]{0,}\])$/, '')
|
|
283
|
+
}));
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
180
291
|
function logWarn(message) {
|
|
181
292
|
var _getClient, _getClient$config$log, _getClient$config$log2;
|
|
182
293
|
|
|
183
294
|
(_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);
|
|
184
295
|
}
|
|
185
296
|
|
|
186
|
-
function minimizeContractInterface(
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
297
|
+
function minimizeContractInterface(config) {
|
|
298
|
+
try {
|
|
299
|
+
const minimizedAbi = config.abi.filter(x => x.type === 'function' && x.name === config.functionName);
|
|
300
|
+
if (minimizedAbi.length === 0) throw new Error('Invalid ABI');
|
|
301
|
+
return minimizedAbi;
|
|
302
|
+
} catch (error) {
|
|
303
|
+
const abi = ethers$1.Contract.getInterface(config.abi).format(utils.FormatTypes.full);
|
|
304
|
+
const minimizedInterface = Array.isArray(abi) ? abi : [abi];
|
|
305
|
+
return minimizedInterface.filter(i => i.includes(config.functionName));
|
|
306
|
+
}
|
|
194
307
|
}
|
|
195
308
|
|
|
196
309
|
function isPlainArray(value) {
|
|
@@ -199,7 +312,7 @@ function isPlainArray(value) {
|
|
|
199
312
|
|
|
200
313
|
function parseContractResult(_ref) {
|
|
201
314
|
let {
|
|
202
|
-
|
|
315
|
+
abi,
|
|
203
316
|
data,
|
|
204
317
|
functionName
|
|
205
318
|
} = _ref;
|
|
@@ -207,7 +320,7 @@ function parseContractResult(_ref) {
|
|
|
207
320
|
if (data && isPlainArray(data)) {
|
|
208
321
|
var _fragment$outputs;
|
|
209
322
|
|
|
210
|
-
const iface = ethers$1.Contract.getInterface(
|
|
323
|
+
const iface = ethers$1.Contract.getInterface(abi);
|
|
211
324
|
const fragment = iface.getFunction(functionName);
|
|
212
325
|
const isTuple = (((_fragment$outputs = fragment.outputs) === null || _fragment$outputs === void 0 ? void 0 : _fragment$outputs.length) || 0) > 1;
|
|
213
326
|
const data_ = isTuple ? data : [data];
|
|
@@ -219,8 +332,153 @@ function parseContractResult(_ref) {
|
|
|
219
332
|
return data;
|
|
220
333
|
}
|
|
221
334
|
|
|
222
|
-
|
|
223
|
-
|
|
335
|
+
/**
|
|
336
|
+
* [ERC-20 Token Standard](https://ethereum.org/en/developers/docs/standards/tokens/erc-20)
|
|
337
|
+
*/
|
|
338
|
+
const erc20ABI = [{
|
|
339
|
+
type: 'event',
|
|
340
|
+
name: 'Approval',
|
|
341
|
+
inputs: [{
|
|
342
|
+
indexed: true,
|
|
343
|
+
name: 'owner',
|
|
344
|
+
type: 'address'
|
|
345
|
+
}, {
|
|
346
|
+
indexed: true,
|
|
347
|
+
name: 'spender',
|
|
348
|
+
type: 'address'
|
|
349
|
+
}, {
|
|
350
|
+
indexed: false,
|
|
351
|
+
name: 'value',
|
|
352
|
+
type: 'uint256'
|
|
353
|
+
}]
|
|
354
|
+
}, {
|
|
355
|
+
type: 'event',
|
|
356
|
+
name: 'Transfer',
|
|
357
|
+
inputs: [{
|
|
358
|
+
indexed: true,
|
|
359
|
+
name: 'from',
|
|
360
|
+
type: 'address'
|
|
361
|
+
}, {
|
|
362
|
+
indexed: true,
|
|
363
|
+
name: 'to',
|
|
364
|
+
type: 'address'
|
|
365
|
+
}, {
|
|
366
|
+
indexed: false,
|
|
367
|
+
name: 'value',
|
|
368
|
+
type: 'uint256'
|
|
369
|
+
}]
|
|
370
|
+
}, {
|
|
371
|
+
type: 'function',
|
|
372
|
+
name: 'allowance',
|
|
373
|
+
stateMutability: 'view',
|
|
374
|
+
inputs: [{
|
|
375
|
+
name: 'owner',
|
|
376
|
+
type: 'address'
|
|
377
|
+
}, {
|
|
378
|
+
name: 'spender',
|
|
379
|
+
type: 'address'
|
|
380
|
+
}],
|
|
381
|
+
outputs: [{
|
|
382
|
+
name: '',
|
|
383
|
+
type: 'uint256'
|
|
384
|
+
}]
|
|
385
|
+
}, {
|
|
386
|
+
type: 'function',
|
|
387
|
+
name: 'approve',
|
|
388
|
+
stateMutability: 'nonpayable',
|
|
389
|
+
inputs: [{
|
|
390
|
+
name: 'spender',
|
|
391
|
+
type: 'address'
|
|
392
|
+
}, {
|
|
393
|
+
name: 'amount',
|
|
394
|
+
type: 'uint256'
|
|
395
|
+
}],
|
|
396
|
+
outputs: [{
|
|
397
|
+
name: '',
|
|
398
|
+
type: 'bool'
|
|
399
|
+
}]
|
|
400
|
+
}, {
|
|
401
|
+
type: 'function',
|
|
402
|
+
name: 'balanceOf',
|
|
403
|
+
stateMutability: 'view',
|
|
404
|
+
inputs: [{
|
|
405
|
+
name: 'account',
|
|
406
|
+
type: 'address'
|
|
407
|
+
}],
|
|
408
|
+
outputs: [{
|
|
409
|
+
name: '',
|
|
410
|
+
type: 'uint256'
|
|
411
|
+
}]
|
|
412
|
+
}, {
|
|
413
|
+
type: 'function',
|
|
414
|
+
name: 'decimals',
|
|
415
|
+
stateMutability: 'view',
|
|
416
|
+
inputs: [],
|
|
417
|
+
outputs: [{
|
|
418
|
+
name: '',
|
|
419
|
+
type: 'uint8'
|
|
420
|
+
}]
|
|
421
|
+
}, {
|
|
422
|
+
type: 'function',
|
|
423
|
+
name: 'name',
|
|
424
|
+
stateMutability: 'view',
|
|
425
|
+
inputs: [],
|
|
426
|
+
outputs: [{
|
|
427
|
+
name: '',
|
|
428
|
+
type: 'string'
|
|
429
|
+
}]
|
|
430
|
+
}, {
|
|
431
|
+
type: 'function',
|
|
432
|
+
name: 'symbol',
|
|
433
|
+
stateMutability: 'view',
|
|
434
|
+
inputs: [],
|
|
435
|
+
outputs: [{
|
|
436
|
+
name: '',
|
|
437
|
+
type: 'string'
|
|
438
|
+
}]
|
|
439
|
+
}, {
|
|
440
|
+
type: 'function',
|
|
441
|
+
name: 'totalSupply',
|
|
442
|
+
stateMutability: 'view',
|
|
443
|
+
inputs: [],
|
|
444
|
+
outputs: [{
|
|
445
|
+
name: '',
|
|
446
|
+
type: 'uint256'
|
|
447
|
+
}]
|
|
448
|
+
}, {
|
|
449
|
+
type: 'function',
|
|
450
|
+
name: 'transfer',
|
|
451
|
+
stateMutability: 'nonpayable',
|
|
452
|
+
inputs: [{
|
|
453
|
+
name: 'recipient',
|
|
454
|
+
type: 'address'
|
|
455
|
+
}, {
|
|
456
|
+
name: 'amount',
|
|
457
|
+
type: 'uint256'
|
|
458
|
+
}],
|
|
459
|
+
outputs: [{
|
|
460
|
+
name: '',
|
|
461
|
+
type: 'bool'
|
|
462
|
+
}]
|
|
463
|
+
}, {
|
|
464
|
+
type: 'function',
|
|
465
|
+
name: 'transferFrom',
|
|
466
|
+
stateMutability: 'nonpayable',
|
|
467
|
+
inputs: [{
|
|
468
|
+
name: 'sender',
|
|
469
|
+
type: 'address'
|
|
470
|
+
}, {
|
|
471
|
+
name: 'recipient',
|
|
472
|
+
type: 'address'
|
|
473
|
+
}, {
|
|
474
|
+
name: 'amount',
|
|
475
|
+
type: 'uint256'
|
|
476
|
+
}],
|
|
477
|
+
outputs: [{
|
|
478
|
+
name: '',
|
|
479
|
+
type: 'bool'
|
|
480
|
+
}]
|
|
481
|
+
}];
|
|
224
482
|
/**
|
|
225
483
|
* [bytes32-flavored ERC-20](https://docs.makerdao.com/smart-contract-modules/mkr-module#4.-gotchas-potential-source-of-user-error)
|
|
226
484
|
* for tokens (ie. Maker) that use bytes32 instead of string.
|
|
@@ -369,41 +627,277 @@ const erc20ABI_bytes32 = [{
|
|
|
369
627
|
name: '',
|
|
370
628
|
type: 'bool'
|
|
371
629
|
}]
|
|
372
|
-
}];
|
|
630
|
+
}];
|
|
631
|
+
/**
|
|
632
|
+
* [ERC-721 Non-Fungible Token Standard](https://ethereum.org/en/developers/docs/standards/tokens/erc-721)
|
|
633
|
+
*/
|
|
373
634
|
|
|
374
|
-
const erc721ABI = [
|
|
635
|
+
const erc721ABI = [{
|
|
636
|
+
type: 'event',
|
|
637
|
+
name: 'Approval',
|
|
638
|
+
inputs: [{
|
|
639
|
+
indexed: true,
|
|
640
|
+
name: 'owner',
|
|
641
|
+
type: 'address'
|
|
642
|
+
}, {
|
|
643
|
+
indexed: true,
|
|
644
|
+
name: 'spender',
|
|
645
|
+
type: 'address'
|
|
646
|
+
}, {
|
|
647
|
+
indexed: true,
|
|
648
|
+
name: 'tokenId',
|
|
649
|
+
type: 'uint256'
|
|
650
|
+
}]
|
|
651
|
+
}, {
|
|
652
|
+
type: 'event',
|
|
653
|
+
name: 'ApprovalForAll',
|
|
654
|
+
inputs: [{
|
|
655
|
+
indexed: true,
|
|
656
|
+
name: 'owner',
|
|
657
|
+
type: 'address'
|
|
658
|
+
}, {
|
|
659
|
+
indexed: true,
|
|
660
|
+
name: 'operator',
|
|
661
|
+
type: 'address'
|
|
662
|
+
}, {
|
|
663
|
+
indexed: false,
|
|
664
|
+
name: 'approved',
|
|
665
|
+
type: 'bool'
|
|
666
|
+
}]
|
|
667
|
+
}, {
|
|
668
|
+
type: 'event',
|
|
669
|
+
name: 'Transfer',
|
|
670
|
+
inputs: [{
|
|
671
|
+
indexed: true,
|
|
672
|
+
name: 'from',
|
|
673
|
+
type: 'address'
|
|
674
|
+
}, {
|
|
675
|
+
indexed: true,
|
|
676
|
+
name: 'to',
|
|
677
|
+
type: 'address'
|
|
678
|
+
}, {
|
|
679
|
+
indexed: true,
|
|
680
|
+
name: 'tokenId',
|
|
681
|
+
type: 'uint256'
|
|
682
|
+
}]
|
|
683
|
+
}, {
|
|
684
|
+
type: 'function',
|
|
685
|
+
name: 'approve',
|
|
686
|
+
stateMutability: 'payable',
|
|
687
|
+
inputs: [{
|
|
688
|
+
name: 'spender',
|
|
689
|
+
type: 'address'
|
|
690
|
+
}, {
|
|
691
|
+
name: 'tokenId',
|
|
692
|
+
type: 'uint256'
|
|
693
|
+
}],
|
|
694
|
+
outputs: []
|
|
695
|
+
}, {
|
|
696
|
+
type: 'function',
|
|
697
|
+
name: 'balanceOf',
|
|
698
|
+
stateMutability: 'view',
|
|
699
|
+
inputs: [{
|
|
700
|
+
name: 'account',
|
|
701
|
+
type: 'address'
|
|
702
|
+
}],
|
|
703
|
+
outputs: [{
|
|
704
|
+
name: '',
|
|
705
|
+
type: 'uint256'
|
|
706
|
+
}]
|
|
707
|
+
}, {
|
|
708
|
+
type: 'function',
|
|
709
|
+
name: 'getApproved',
|
|
710
|
+
stateMutability: 'view',
|
|
711
|
+
inputs: [{
|
|
712
|
+
name: 'tokenId',
|
|
713
|
+
type: 'uint256'
|
|
714
|
+
}],
|
|
715
|
+
outputs: [{
|
|
716
|
+
name: '',
|
|
717
|
+
type: 'address'
|
|
718
|
+
}]
|
|
719
|
+
}, {
|
|
720
|
+
type: 'function',
|
|
721
|
+
name: 'isApprovedForAll',
|
|
722
|
+
stateMutability: 'view',
|
|
723
|
+
inputs: [{
|
|
724
|
+
name: 'owner',
|
|
725
|
+
type: 'address'
|
|
726
|
+
}, {
|
|
727
|
+
name: 'operator',
|
|
728
|
+
type: 'address'
|
|
729
|
+
}],
|
|
730
|
+
outputs: [{
|
|
731
|
+
name: '',
|
|
732
|
+
type: 'bool'
|
|
733
|
+
}]
|
|
734
|
+
}, {
|
|
735
|
+
type: 'function',
|
|
736
|
+
name: 'name',
|
|
737
|
+
stateMutability: 'view',
|
|
738
|
+
inputs: [],
|
|
739
|
+
outputs: [{
|
|
740
|
+
name: '',
|
|
741
|
+
type: 'string'
|
|
742
|
+
}]
|
|
743
|
+
}, {
|
|
744
|
+
type: 'function',
|
|
745
|
+
name: 'ownerOf',
|
|
746
|
+
stateMutability: 'view',
|
|
747
|
+
inputs: [{
|
|
748
|
+
name: 'tokenId',
|
|
749
|
+
type: 'uint256'
|
|
750
|
+
}],
|
|
751
|
+
outputs: [{
|
|
752
|
+
name: 'owner',
|
|
753
|
+
type: 'address'
|
|
754
|
+
}]
|
|
755
|
+
}, {
|
|
756
|
+
type: 'function',
|
|
757
|
+
name: 'safeTransferFrom',
|
|
758
|
+
stateMutability: 'payable',
|
|
759
|
+
inputs: [{
|
|
760
|
+
name: 'from',
|
|
761
|
+
type: 'address'
|
|
762
|
+
}, {
|
|
763
|
+
name: 'to',
|
|
764
|
+
type: 'address'
|
|
765
|
+
}, {
|
|
766
|
+
name: 'tokenId',
|
|
767
|
+
type: 'uint256'
|
|
768
|
+
}],
|
|
769
|
+
outputs: []
|
|
770
|
+
}, {
|
|
771
|
+
type: 'function',
|
|
772
|
+
name: 'safeTransferFrom',
|
|
773
|
+
stateMutability: 'nonpayable',
|
|
774
|
+
inputs: [{
|
|
775
|
+
name: 'from',
|
|
776
|
+
type: 'address'
|
|
777
|
+
}, {
|
|
778
|
+
name: 'to',
|
|
779
|
+
type: 'address'
|
|
780
|
+
}, {
|
|
781
|
+
name: 'id',
|
|
782
|
+
type: 'uint256'
|
|
783
|
+
}, {
|
|
784
|
+
name: 'data',
|
|
785
|
+
type: 'bytes'
|
|
786
|
+
}],
|
|
787
|
+
outputs: []
|
|
788
|
+
}, {
|
|
789
|
+
type: 'function',
|
|
790
|
+
name: 'setApprovalForAll',
|
|
791
|
+
stateMutability: 'nonpayable',
|
|
792
|
+
inputs: [{
|
|
793
|
+
name: 'operator',
|
|
794
|
+
type: 'address'
|
|
795
|
+
}, {
|
|
796
|
+
name: 'approved',
|
|
797
|
+
type: 'bool'
|
|
798
|
+
}],
|
|
799
|
+
outputs: []
|
|
800
|
+
}, {
|
|
801
|
+
type: 'function',
|
|
802
|
+
name: 'symbol',
|
|
803
|
+
stateMutability: 'view',
|
|
804
|
+
inputs: [],
|
|
805
|
+
outputs: [{
|
|
806
|
+
name: '',
|
|
807
|
+
type: 'string'
|
|
808
|
+
}]
|
|
809
|
+
}, {
|
|
810
|
+
type: 'function',
|
|
811
|
+
name: 'tokenByIndex',
|
|
812
|
+
stateMutability: 'view',
|
|
813
|
+
inputs: [{
|
|
814
|
+
name: 'index',
|
|
815
|
+
type: 'uint256'
|
|
816
|
+
}],
|
|
817
|
+
outputs: [{
|
|
818
|
+
name: '',
|
|
819
|
+
type: 'uint256'
|
|
820
|
+
}]
|
|
821
|
+
}, {
|
|
822
|
+
type: 'function',
|
|
823
|
+
name: 'tokenByIndex',
|
|
824
|
+
stateMutability: 'view',
|
|
825
|
+
inputs: [{
|
|
826
|
+
name: 'owner',
|
|
827
|
+
type: 'address'
|
|
828
|
+
}, {
|
|
829
|
+
name: 'index',
|
|
830
|
+
type: 'uint256'
|
|
831
|
+
}],
|
|
832
|
+
outputs: [{
|
|
833
|
+
name: 'tokenId',
|
|
834
|
+
type: 'uint256'
|
|
835
|
+
}]
|
|
836
|
+
}, {
|
|
837
|
+
type: 'function',
|
|
838
|
+
name: 'tokenURI',
|
|
839
|
+
stateMutability: 'view',
|
|
840
|
+
inputs: [{
|
|
841
|
+
name: 'tokenId',
|
|
842
|
+
type: 'uint256'
|
|
843
|
+
}],
|
|
844
|
+
outputs: [{
|
|
845
|
+
name: '',
|
|
846
|
+
type: 'string'
|
|
847
|
+
}]
|
|
848
|
+
}, {
|
|
849
|
+
type: 'function',
|
|
850
|
+
name: 'totalSupply',
|
|
851
|
+
stateMutability: 'view',
|
|
852
|
+
inputs: [],
|
|
853
|
+
outputs: [{
|
|
854
|
+
name: '',
|
|
855
|
+
type: 'uint256'
|
|
856
|
+
}]
|
|
857
|
+
}, {
|
|
858
|
+
type: 'function',
|
|
859
|
+
name: 'transferFrom',
|
|
860
|
+
stateMutability: 'payable',
|
|
861
|
+
inputs: [{
|
|
862
|
+
name: 'sender',
|
|
863
|
+
type: 'address'
|
|
864
|
+
}, {
|
|
865
|
+
name: 'recipient',
|
|
866
|
+
type: 'address'
|
|
867
|
+
}, {
|
|
868
|
+
name: 'tokeId',
|
|
869
|
+
type: 'uint256'
|
|
870
|
+
}],
|
|
871
|
+
outputs: []
|
|
872
|
+
}];
|
|
873
|
+
/**
|
|
874
|
+
* [Multicall3](https://github.com/mds1/multicall)
|
|
875
|
+
*/
|
|
375
876
|
|
|
376
|
-
const
|
|
877
|
+
const multicallABI = [{
|
|
377
878
|
inputs: [{
|
|
378
879
|
components: [{
|
|
379
|
-
internalType: 'address',
|
|
380
880
|
name: 'target',
|
|
381
881
|
type: 'address'
|
|
382
882
|
}, {
|
|
383
|
-
internalType: 'bool',
|
|
384
883
|
name: 'allowFailure',
|
|
385
884
|
type: 'bool'
|
|
386
885
|
}, {
|
|
387
|
-
internalType: 'bytes',
|
|
388
886
|
name: 'callData',
|
|
389
887
|
type: 'bytes'
|
|
390
888
|
}],
|
|
391
|
-
internalType: 'struct Multicall3.Call3[]',
|
|
392
889
|
name: 'calls',
|
|
393
890
|
type: 'tuple[]'
|
|
394
891
|
}],
|
|
395
892
|
name: 'aggregate3',
|
|
396
893
|
outputs: [{
|
|
397
894
|
components: [{
|
|
398
|
-
internalType: 'bool',
|
|
399
895
|
name: 'success',
|
|
400
896
|
type: 'bool'
|
|
401
897
|
}, {
|
|
402
|
-
internalType: 'bytes',
|
|
403
898
|
name: 'returnData',
|
|
404
899
|
type: 'bytes'
|
|
405
900
|
}],
|
|
406
|
-
internalType: 'struct Multicall3.Result[]',
|
|
407
901
|
name: 'returnData',
|
|
408
902
|
type: 'tuple[]'
|
|
409
903
|
}],
|
|
@@ -444,82 +938,21 @@ async function connect(_ref) {
|
|
|
444
938
|
} catch (err) {
|
|
445
939
|
client.setState(x => {
|
|
446
940
|
return { ...x,
|
|
447
|
-
// Keep existing connector connected in case of error
|
|
448
|
-
status: x.connector ? 'connected' : 'disconnected'
|
|
449
|
-
};
|
|
450
|
-
});
|
|
451
|
-
throw err;
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
async function disconnect() {
|
|
456
|
-
const client = getProvider.getClient();
|
|
457
|
-
if (client.connector) await client.connector.disconnect();
|
|
458
|
-
client.clearState();
|
|
459
|
-
client.storage.removeItem('connected');
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
function getContract(_ref) {
|
|
463
|
-
let {
|
|
464
|
-
addressOrName,
|
|
465
|
-
contractInterface,
|
|
466
|
-
signerOrProvider
|
|
467
|
-
} = _ref;
|
|
468
|
-
return new ethers.Contract(addressOrName, contractInterface, signerOrProvider);
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
async function deprecatedWriteContract(_ref) {
|
|
472
|
-
let {
|
|
473
|
-
addressOrName,
|
|
474
|
-
args,
|
|
475
|
-
chainId,
|
|
476
|
-
contractInterface,
|
|
477
|
-
functionName,
|
|
478
|
-
overrides,
|
|
479
|
-
signerOrProvider
|
|
480
|
-
} = _ref;
|
|
481
|
-
const {
|
|
482
|
-
connector
|
|
483
|
-
} = getProvider.getClient();
|
|
484
|
-
if (!connector) throw new getProvider.ConnectorNotFoundError();
|
|
485
|
-
const params = [...(Array.isArray(args) ? args : args ? [args] : []), ...(overrides ? [overrides] : [])];
|
|
486
|
-
|
|
487
|
-
try {
|
|
488
|
-
var _chain;
|
|
489
|
-
|
|
490
|
-
let chain;
|
|
491
|
-
|
|
492
|
-
if (chainId) {
|
|
493
|
-
const activeChainId = await connector.getChainId(); // Try to switch chain to provided `chainId`
|
|
494
|
-
|
|
495
|
-
if (chainId !== activeChainId) {
|
|
496
|
-
var _connector$chains$fin, _connector$chains$fin2, _connector$chains$fin3, _connector$chains$fin4;
|
|
497
|
-
|
|
498
|
-
if (connector.switchChain) chain = await connector.switchChain(chainId);else throw new getProvider.ChainMismatchError({
|
|
499
|
-
activeChain: (_connector$chains$fin = (_connector$chains$fin2 = connector.chains.find(x => x.id === activeChainId)) === null || _connector$chains$fin2 === void 0 ? void 0 : _connector$chains$fin2.name) !== null && _connector$chains$fin !== void 0 ? _connector$chains$fin : "Chain ".concat(activeChainId),
|
|
500
|
-
targetChain: (_connector$chains$fin3 = (_connector$chains$fin4 = connector.chains.find(x => x.id === chainId)) === null || _connector$chains$fin4 === void 0 ? void 0 : _connector$chains$fin4.name) !== null && _connector$chains$fin3 !== void 0 ? _connector$chains$fin3 : "Chain ".concat(chainId)
|
|
501
|
-
});
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
const signer = await connector.getSigner({
|
|
506
|
-
chainId: (_chain = chain) === null || _chain === void 0 ? void 0 : _chain.id
|
|
507
|
-
});
|
|
508
|
-
const contract = getContract({
|
|
509
|
-
addressOrName,
|
|
510
|
-
contractInterface,
|
|
511
|
-
signerOrProvider
|
|
941
|
+
// Keep existing connector connected in case of error
|
|
942
|
+
status: x.connector ? 'connected' : 'disconnected'
|
|
943
|
+
};
|
|
512
944
|
});
|
|
513
|
-
|
|
514
|
-
const contractFunction = contractWithSigner[functionName];
|
|
515
|
-
if (!contractFunction) logWarn("\"".concat(functionName, "\" does not exist in interface for contract \"").concat(addressOrName, "\""));
|
|
516
|
-
return await contractFunction(...params);
|
|
517
|
-
} catch (error) {
|
|
518
|
-
if (error.code === 4001) throw new getProvider.UserRejectedRequestError(error);
|
|
519
|
-
throw error;
|
|
945
|
+
throw err;
|
|
520
946
|
}
|
|
521
947
|
}
|
|
522
948
|
|
|
949
|
+
async function disconnect() {
|
|
950
|
+
const client = getProvider.getClient();
|
|
951
|
+
if (client.connector) await client.connector.disconnect();
|
|
952
|
+
client.clearState();
|
|
953
|
+
client.storage.removeItem('connected');
|
|
954
|
+
}
|
|
955
|
+
|
|
523
956
|
async function fetchToken(_ref) {
|
|
524
957
|
let {
|
|
525
958
|
address,
|
|
@@ -529,11 +962,11 @@ async function fetchToken(_ref) {
|
|
|
529
962
|
|
|
530
963
|
async function fetchToken_(_ref2) {
|
|
531
964
|
let {
|
|
532
|
-
|
|
965
|
+
abi
|
|
533
966
|
} = _ref2;
|
|
534
967
|
const erc20Config = {
|
|
535
|
-
|
|
536
|
-
|
|
968
|
+
address,
|
|
969
|
+
abi,
|
|
537
970
|
chainId
|
|
538
971
|
};
|
|
539
972
|
const [decimals, name, symbol, totalSupply] = await readContracts({
|
|
@@ -551,8 +984,10 @@ async function fetchToken(_ref) {
|
|
|
551
984
|
return {
|
|
552
985
|
address,
|
|
553
986
|
decimals,
|
|
554
|
-
name,
|
|
555
|
-
|
|
987
|
+
name: name,
|
|
988
|
+
// protect against `ResolvedConfig['BytesType']`
|
|
989
|
+
symbol: symbol,
|
|
990
|
+
// protect against `ResolvedConfig['BytesType']`
|
|
556
991
|
totalSupply: {
|
|
557
992
|
formatted: utils.formatUnits(totalSupply, units),
|
|
558
993
|
value: totalSupply
|
|
@@ -562,7 +997,7 @@ async function fetchToken(_ref) {
|
|
|
562
997
|
|
|
563
998
|
try {
|
|
564
999
|
return await fetchToken_({
|
|
565
|
-
|
|
1000
|
+
abi: erc20ABI
|
|
566
1001
|
});
|
|
567
1002
|
} catch (err) {
|
|
568
1003
|
// In the chance that there is an error upon decoding the contract result,
|
|
@@ -574,7 +1009,7 @@ async function fetchToken(_ref) {
|
|
|
574
1009
|
symbol,
|
|
575
1010
|
...rest
|
|
576
1011
|
} = await fetchToken_({
|
|
577
|
-
|
|
1012
|
+
abi: erc20ABI_bytes32
|
|
578
1013
|
});
|
|
579
1014
|
return {
|
|
580
1015
|
name: utils.parseBytes32String(name),
|
|
@@ -587,6 +1022,17 @@ async function fetchToken(_ref) {
|
|
|
587
1022
|
}
|
|
588
1023
|
}
|
|
589
1024
|
|
|
1025
|
+
function getContract(_ref) {
|
|
1026
|
+
let {
|
|
1027
|
+
address,
|
|
1028
|
+
abi,
|
|
1029
|
+
signerOrProvider
|
|
1030
|
+
} = _ref;
|
|
1031
|
+
return new ethers.Contract(address, abi, signerOrProvider);
|
|
1032
|
+
} ////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
1033
|
+
// Contract
|
|
1034
|
+
// TODO: Add remaining properties
|
|
1035
|
+
|
|
590
1036
|
/**
|
|
591
1037
|
* @description Prepares the parameters required for a contract write transaction.
|
|
592
1038
|
*
|
|
@@ -596,58 +1042,63 @@ async function fetchToken(_ref) {
|
|
|
596
1042
|
* import { prepareWriteContract, writeContract } from '@wagmi/core'
|
|
597
1043
|
*
|
|
598
1044
|
* const config = await prepareWriteContract({
|
|
599
|
-
*
|
|
600
|
-
*
|
|
1045
|
+
* address: '0x...',
|
|
1046
|
+
* abi: wagmiAbi,
|
|
601
1047
|
* functionName: 'mint',
|
|
602
1048
|
* })
|
|
603
1049
|
* const result = await writeContract(config)
|
|
604
1050
|
*/
|
|
605
1051
|
async function prepareWriteContract(_ref) {
|
|
606
1052
|
let {
|
|
607
|
-
|
|
1053
|
+
abi,
|
|
1054
|
+
address,
|
|
608
1055
|
args,
|
|
609
1056
|
chainId,
|
|
610
|
-
contractInterface: contractInterface_,
|
|
611
1057
|
functionName,
|
|
612
1058
|
overrides,
|
|
613
1059
|
signer: signer_
|
|
614
1060
|
} = _ref;
|
|
615
|
-
const signer = signer_
|
|
1061
|
+
const signer = signer_ ?? (await fetchSigner({
|
|
1062
|
+
chainId
|
|
1063
|
+
}));
|
|
616
1064
|
if (!signer) throw new getProvider.ConnectorNotFoundError();
|
|
1065
|
+
if (chainId) assertActiveChain({
|
|
1066
|
+
chainId
|
|
1067
|
+
});
|
|
617
1068
|
const contract = getContract({
|
|
618
|
-
|
|
619
|
-
|
|
1069
|
+
address,
|
|
1070
|
+
abi: abi,
|
|
1071
|
+
// TODO: Remove cast and still support `Narrow<TAbi>`
|
|
620
1072
|
signerOrProvider: signer
|
|
621
1073
|
});
|
|
622
|
-
const
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
const contractInterface = minimizeContractInterface({
|
|
632
|
-
contractInterface: contract.interface,
|
|
633
|
-
functionName
|
|
1074
|
+
const normalizedFunctionName = normalizeFunctionName({
|
|
1075
|
+
contract,
|
|
1076
|
+
functionName,
|
|
1077
|
+
args
|
|
1078
|
+
});
|
|
1079
|
+
const populateTransactionFn = contract.populateTransaction[normalizedFunctionName];
|
|
1080
|
+
if (!populateTransactionFn) throw new getProvider.ContractMethodDoesNotExistError({
|
|
1081
|
+
address,
|
|
1082
|
+
functionName: normalizedFunctionName
|
|
634
1083
|
});
|
|
635
|
-
const params = [...(
|
|
1084
|
+
const params = [...(args ?? []), ...(overrides ? [overrides] : [])];
|
|
636
1085
|
const unsignedTransaction = await populateTransactionFn(...params);
|
|
637
1086
|
const gasLimit = unsignedTransaction.gasLimit || (await signer.estimateGas(unsignedTransaction));
|
|
1087
|
+
const minimizedAbi = minimizeContractInterface({
|
|
1088
|
+
abi: abi,
|
|
1089
|
+
// TODO: Remove cast and still support `Narrow<TAbi>`
|
|
1090
|
+
functionName
|
|
1091
|
+
});
|
|
638
1092
|
return {
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
functionName,
|
|
646
|
-
overrides,
|
|
1093
|
+
abi: minimizedAbi,
|
|
1094
|
+
address,
|
|
1095
|
+
chainId,
|
|
1096
|
+
// TODO: Remove cast
|
|
1097
|
+
functionName: functionName,
|
|
1098
|
+
mode: 'prepared',
|
|
647
1099
|
request: { ...unsignedTransaction,
|
|
648
1100
|
gasLimit
|
|
649
|
-
}
|
|
650
|
-
mode: 'prepared'
|
|
1101
|
+
}
|
|
651
1102
|
};
|
|
652
1103
|
}
|
|
653
1104
|
|
|
@@ -690,30 +1141,6 @@ function watchWebSocketProvider(args, callback) {
|
|
|
690
1141
|
return unsubscribe;
|
|
691
1142
|
}
|
|
692
1143
|
|
|
693
|
-
async function readContract(_ref) {
|
|
694
|
-
let {
|
|
695
|
-
addressOrName,
|
|
696
|
-
args,
|
|
697
|
-
chainId,
|
|
698
|
-
contractInterface,
|
|
699
|
-
functionName,
|
|
700
|
-
overrides
|
|
701
|
-
} = _ref;
|
|
702
|
-
const provider = getProvider.getProvider({
|
|
703
|
-
chainId
|
|
704
|
-
});
|
|
705
|
-
const contract = getContract({
|
|
706
|
-
addressOrName,
|
|
707
|
-
contractInterface,
|
|
708
|
-
signerOrProvider: provider
|
|
709
|
-
});
|
|
710
|
-
const params = [...(Array.isArray(args) ? args : args ? [args] : []), ...(overrides ? [overrides] : [])];
|
|
711
|
-
const contractFunction = contract[functionName];
|
|
712
|
-
if (!contractFunction) logWarn("\"".concat(functionName, "\" is not in the interface for contract \"").concat(addressOrName, "\""));
|
|
713
|
-
const response = await (contractFunction === null || contractFunction === void 0 ? void 0 : contractFunction(...params));
|
|
714
|
-
return response;
|
|
715
|
-
}
|
|
716
|
-
|
|
717
1144
|
async function multicall(_ref) {
|
|
718
1145
|
let {
|
|
719
1146
|
allowFailure = true,
|
|
@@ -735,14 +1162,14 @@ async function multicall(_ref) {
|
|
|
735
1162
|
chain
|
|
736
1163
|
});
|
|
737
1164
|
const multicallContract = getContract({
|
|
738
|
-
|
|
739
|
-
|
|
1165
|
+
address: chain.multicall.address,
|
|
1166
|
+
abi: multicallABI,
|
|
740
1167
|
signerOrProvider: provider
|
|
741
1168
|
});
|
|
742
1169
|
const calls = contracts.map(_ref2 => {
|
|
743
1170
|
let {
|
|
744
|
-
|
|
745
|
-
|
|
1171
|
+
address,
|
|
1172
|
+
abi,
|
|
746
1173
|
functionName,
|
|
747
1174
|
...config
|
|
748
1175
|
} = _ref2;
|
|
@@ -750,57 +1177,71 @@ async function multicall(_ref) {
|
|
|
750
1177
|
args
|
|
751
1178
|
} = config || {};
|
|
752
1179
|
const contract = getContract({
|
|
753
|
-
|
|
754
|
-
|
|
1180
|
+
address,
|
|
1181
|
+
abi
|
|
1182
|
+
});
|
|
1183
|
+
const params = args ?? [];
|
|
1184
|
+
const normalizedFunctionName = normalizeFunctionName({
|
|
1185
|
+
contract,
|
|
1186
|
+
functionName,
|
|
1187
|
+
args
|
|
755
1188
|
});
|
|
756
|
-
const params = Array.isArray(args) ? args : args ? [args] : [];
|
|
757
1189
|
|
|
758
1190
|
try {
|
|
759
|
-
const
|
|
760
|
-
if (!
|
|
1191
|
+
const contractFunction = contract[normalizedFunctionName];
|
|
1192
|
+
if (!contractFunction) logWarn(`"${normalizedFunctionName}" is not in the interface for contract "${address}"`);
|
|
1193
|
+
const callData = contract.interface.encodeFunctionData(normalizedFunctionName, params);
|
|
761
1194
|
return {
|
|
762
|
-
target:
|
|
1195
|
+
target: address,
|
|
763
1196
|
allowFailure,
|
|
764
1197
|
callData
|
|
765
1198
|
};
|
|
766
1199
|
} catch (err) {
|
|
767
1200
|
if (!allowFailure) throw err;
|
|
768
1201
|
return {
|
|
769
|
-
target:
|
|
1202
|
+
target: address,
|
|
770
1203
|
allowFailure,
|
|
771
1204
|
callData: '0x'
|
|
772
1205
|
};
|
|
773
1206
|
}
|
|
774
1207
|
});
|
|
775
1208
|
const params = [...[calls], ...(overrides ? [overrides] : [])];
|
|
776
|
-
const results = await multicallContract.aggregate3(
|
|
1209
|
+
const results = await multicallContract.aggregate3( // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1210
|
+
// @ts-ignore
|
|
1211
|
+
...params);
|
|
777
1212
|
return results.map((_ref3, i) => {
|
|
778
1213
|
let {
|
|
779
1214
|
returnData,
|
|
780
1215
|
success
|
|
781
1216
|
} = _ref3;
|
|
782
1217
|
const {
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
1218
|
+
address,
|
|
1219
|
+
abi,
|
|
1220
|
+
args,
|
|
1221
|
+
functionName
|
|
787
1222
|
} = contracts[i];
|
|
788
1223
|
const contract = getContract({
|
|
789
|
-
|
|
790
|
-
|
|
1224
|
+
address,
|
|
1225
|
+
abi: abi // TODO: Remove cast and still support `Narrow<TAbi>`
|
|
1226
|
+
|
|
1227
|
+
});
|
|
1228
|
+
const normalizedFunctionName = normalizeFunctionName({
|
|
1229
|
+
contract,
|
|
1230
|
+
functionName,
|
|
1231
|
+
args
|
|
791
1232
|
});
|
|
792
1233
|
|
|
793
1234
|
if (!success) {
|
|
794
1235
|
let error;
|
|
795
1236
|
|
|
796
1237
|
try {
|
|
797
|
-
contract.interface.decodeFunctionResult(
|
|
1238
|
+
contract.interface.decodeFunctionResult(normalizedFunctionName, returnData);
|
|
798
1239
|
} catch (err) {
|
|
799
1240
|
error = new getProvider.ContractMethodRevertedError({
|
|
800
|
-
|
|
1241
|
+
address,
|
|
801
1242
|
args,
|
|
802
1243
|
chainId: chain.id,
|
|
803
|
-
functionName,
|
|
1244
|
+
functionName: normalizedFunctionName,
|
|
804
1245
|
errorMessage: err.message
|
|
805
1246
|
});
|
|
806
1247
|
if (!allowFailure) throw error;
|
|
@@ -812,10 +1253,10 @@ async function multicall(_ref) {
|
|
|
812
1253
|
|
|
813
1254
|
if (returnData === '0x') {
|
|
814
1255
|
const error = new getProvider.ContractMethodNoResultError({
|
|
815
|
-
|
|
1256
|
+
address,
|
|
816
1257
|
args,
|
|
817
1258
|
chainId: chain.id,
|
|
818
|
-
functionName
|
|
1259
|
+
functionName: normalizedFunctionName
|
|
819
1260
|
});
|
|
820
1261
|
if (!allowFailure) throw error;
|
|
821
1262
|
logWarn(error.message);
|
|
@@ -823,14 +1264,14 @@ async function multicall(_ref) {
|
|
|
823
1264
|
}
|
|
824
1265
|
|
|
825
1266
|
try {
|
|
826
|
-
const result = contract.interface.decodeFunctionResult(
|
|
1267
|
+
const result = contract.interface.decodeFunctionResult(normalizedFunctionName, returnData);
|
|
827
1268
|
return Array.isArray(result) && result.length === 1 ? result[0] : result;
|
|
828
1269
|
} catch (err) {
|
|
829
1270
|
const error = new getProvider.ContractResultDecodeError({
|
|
830
|
-
|
|
1271
|
+
address,
|
|
831
1272
|
args,
|
|
832
1273
|
chainId: chain.id,
|
|
833
|
-
functionName,
|
|
1274
|
+
functionName: normalizedFunctionName,
|
|
834
1275
|
errorMessage: err.message
|
|
835
1276
|
});
|
|
836
1277
|
if (!allowFailure) throw error;
|
|
@@ -840,6 +1281,38 @@ async function multicall(_ref) {
|
|
|
840
1281
|
});
|
|
841
1282
|
}
|
|
842
1283
|
|
|
1284
|
+
async function readContract(_ref) {
|
|
1285
|
+
let {
|
|
1286
|
+
address,
|
|
1287
|
+
args,
|
|
1288
|
+
chainId,
|
|
1289
|
+
abi,
|
|
1290
|
+
functionName,
|
|
1291
|
+
overrides
|
|
1292
|
+
} = _ref;
|
|
1293
|
+
const provider = getProvider.getProvider({
|
|
1294
|
+
chainId
|
|
1295
|
+
});
|
|
1296
|
+
const contract = getContract({
|
|
1297
|
+
address,
|
|
1298
|
+
abi: abi,
|
|
1299
|
+
// TODO: Remove cast and still support `Narrow<TAbi>`
|
|
1300
|
+
signerOrProvider: provider
|
|
1301
|
+
});
|
|
1302
|
+
const normalizedFunctionName = normalizeFunctionName({
|
|
1303
|
+
contract,
|
|
1304
|
+
functionName,
|
|
1305
|
+
args
|
|
1306
|
+
});
|
|
1307
|
+
const contractFunction = contract[normalizedFunctionName];
|
|
1308
|
+
if (!contractFunction) throw new getProvider.ContractMethodDoesNotExistError({
|
|
1309
|
+
address,
|
|
1310
|
+
functionName: normalizedFunctionName
|
|
1311
|
+
});
|
|
1312
|
+
const params = [...(args ?? []), ...(overrides ? [overrides] : [])];
|
|
1313
|
+
return contractFunction === null || contractFunction === void 0 ? void 0 : contractFunction(...params);
|
|
1314
|
+
}
|
|
1315
|
+
|
|
843
1316
|
async function readContracts(_ref) {
|
|
844
1317
|
let {
|
|
845
1318
|
allowFailure = true,
|
|
@@ -849,12 +1322,13 @@ async function readContracts(_ref) {
|
|
|
849
1322
|
|
|
850
1323
|
try {
|
|
851
1324
|
const provider = getProvider.getProvider();
|
|
852
|
-
const contractsByChainId = contracts.reduce((contracts, contract) => {
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
const chainId = (_contract$chainId = contract.chainId) !== null && _contract$chainId !== void 0 ? _contract$chainId : provider.network.chainId;
|
|
1325
|
+
const contractsByChainId = contracts.reduce((contracts, contract, index) => {
|
|
1326
|
+
const chainId = contract.chainId ?? provider.network.chainId;
|
|
856
1327
|
return { ...contracts,
|
|
857
|
-
[chainId]: [...(contracts[chainId] || []),
|
|
1328
|
+
[chainId]: [...(contracts[chainId] || []), {
|
|
1329
|
+
contract,
|
|
1330
|
+
index
|
|
1331
|
+
}]
|
|
858
1332
|
};
|
|
859
1333
|
}, {});
|
|
860
1334
|
|
|
@@ -863,13 +1337,20 @@ async function readContracts(_ref) {
|
|
|
863
1337
|
return multicall({
|
|
864
1338
|
allowFailure,
|
|
865
1339
|
chainId: parseInt(chainId),
|
|
866
|
-
contracts
|
|
1340
|
+
contracts: contracts.map(_ref3 => {
|
|
1341
|
+
let {
|
|
1342
|
+
contract
|
|
1343
|
+
} = _ref3;
|
|
1344
|
+
return contract;
|
|
1345
|
+
}),
|
|
867
1346
|
overrides
|
|
868
1347
|
});
|
|
869
1348
|
});
|
|
870
1349
|
|
|
1350
|
+
let results;
|
|
1351
|
+
|
|
871
1352
|
if (allowFailure) {
|
|
872
|
-
|
|
1353
|
+
results = (await Promise.allSettled(promises())).map(result => {
|
|
873
1354
|
if (result.status === 'fulfilled') return result.value;
|
|
874
1355
|
|
|
875
1356
|
if (result.reason instanceof getProvider.ChainDoesNotSupportMulticallError) {
|
|
@@ -879,9 +1360,22 @@ async function readContracts(_ref) {
|
|
|
879
1360
|
|
|
880
1361
|
return null;
|
|
881
1362
|
}).flat();
|
|
882
|
-
}
|
|
1363
|
+
} else {
|
|
1364
|
+
results = (await Promise.all(promises())).flat();
|
|
1365
|
+
} // Reorder the contract results back to the order they were
|
|
1366
|
+
// provided in.
|
|
883
1367
|
|
|
884
|
-
|
|
1368
|
+
|
|
1369
|
+
const resultIndexes = Object.values(contractsByChainId).map(contracts => contracts.map(_ref4 => {
|
|
1370
|
+
let {
|
|
1371
|
+
index
|
|
1372
|
+
} = _ref4;
|
|
1373
|
+
return index;
|
|
1374
|
+
})).flat();
|
|
1375
|
+
return results.reduce((results, result, index) => {
|
|
1376
|
+
results[resultIndexes[index]] = result;
|
|
1377
|
+
return results;
|
|
1378
|
+
}, []);
|
|
885
1379
|
} catch (err) {
|
|
886
1380
|
if (err instanceof getProvider.ContractResultDecodeError) throw err;
|
|
887
1381
|
if (err instanceof getProvider.ContractMethodNoResultError) throw err;
|
|
@@ -891,67 +1385,68 @@ async function readContracts(_ref) {
|
|
|
891
1385
|
overrides
|
|
892
1386
|
}));
|
|
893
1387
|
|
|
894
|
-
if (allowFailure) {
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
errorMessage: result.reason
|
|
909
|
-
});
|
|
910
|
-
logWarn(error.message);
|
|
911
|
-
return null;
|
|
1388
|
+
if (allowFailure) return (await Promise.allSettled(promises())).map((result, i) => {
|
|
1389
|
+
if (result.status === 'fulfilled') return result.value;
|
|
1390
|
+
const {
|
|
1391
|
+
address,
|
|
1392
|
+
args,
|
|
1393
|
+
chainId,
|
|
1394
|
+
functionName
|
|
1395
|
+
} = contracts[i];
|
|
1396
|
+
const error = new getProvider.ContractMethodRevertedError({
|
|
1397
|
+
address,
|
|
1398
|
+
functionName,
|
|
1399
|
+
chainId: chainId ?? chains.mainnet.id,
|
|
1400
|
+
args,
|
|
1401
|
+
errorMessage: result.reason
|
|
912
1402
|
});
|
|
913
|
-
|
|
914
|
-
|
|
1403
|
+
logWarn(error.message);
|
|
1404
|
+
return null;
|
|
1405
|
+
});
|
|
915
1406
|
return await Promise.all(promises());
|
|
916
1407
|
}
|
|
917
1408
|
}
|
|
918
1409
|
|
|
919
|
-
function watchContractEvent(
|
|
920
|
-
/** Contract configuration */
|
|
921
|
-
contractArgs,
|
|
922
|
-
/** Event name to listen to */
|
|
923
|
-
eventName, callback) {
|
|
1410
|
+
function watchContractEvent(_ref, callback) {
|
|
924
1411
|
let {
|
|
1412
|
+
address,
|
|
1413
|
+
abi,
|
|
925
1414
|
chainId,
|
|
1415
|
+
eventName,
|
|
926
1416
|
once
|
|
927
|
-
} =
|
|
1417
|
+
} = _ref;
|
|
1418
|
+
|
|
1419
|
+
const handler = function () {
|
|
1420
|
+
return callback(...arguments);
|
|
1421
|
+
};
|
|
1422
|
+
|
|
928
1423
|
let contract;
|
|
929
1424
|
|
|
930
1425
|
const watchEvent = async () => {
|
|
931
|
-
|
|
932
|
-
var _contract;
|
|
933
|
-
|
|
934
|
-
(_contract = contract) === null || _contract === void 0 ? void 0 : _contract.off(eventName, callback);
|
|
935
|
-
}
|
|
1426
|
+
var _contract;
|
|
936
1427
|
|
|
1428
|
+
if (contract) (_contract = contract) === null || _contract === void 0 ? void 0 : _contract.off(eventName, handler);
|
|
1429
|
+
const signerOrProvider = getWebSocketProvider({
|
|
1430
|
+
chainId
|
|
1431
|
+
}) || getProvider.getProvider({
|
|
1432
|
+
chainId
|
|
1433
|
+
});
|
|
937
1434
|
contract = getContract({
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
}),
|
|
943
|
-
...contractArgs
|
|
1435
|
+
address,
|
|
1436
|
+
abi: abi,
|
|
1437
|
+
// TODO: Remove cast and still support `Narrow<TAbi>`
|
|
1438
|
+
signerOrProvider
|
|
944
1439
|
});
|
|
945
|
-
if (once) contract.once(eventName,
|
|
1440
|
+
if (once) contract.once(eventName, handler);else contract.on(eventName, handler);
|
|
946
1441
|
};
|
|
947
1442
|
|
|
948
1443
|
watchEvent();
|
|
949
1444
|
const client = getProvider.getClient();
|
|
950
|
-
const unsubscribe = client.subscribe(
|
|
1445
|
+
const unsubscribe = client.subscribe(_ref2 => {
|
|
951
1446
|
let {
|
|
952
1447
|
provider,
|
|
953
1448
|
webSocketProvider
|
|
954
|
-
} =
|
|
1449
|
+
} = _ref2;
|
|
955
1450
|
return {
|
|
956
1451
|
provider,
|
|
957
1452
|
webSocketProvider
|
|
@@ -962,7 +1457,7 @@ eventName, callback) {
|
|
|
962
1457
|
return () => {
|
|
963
1458
|
var _contract2;
|
|
964
1459
|
|
|
965
|
-
(_contract2 = contract) === null || _contract2 === void 0 ? void 0 : _contract2.off(eventName,
|
|
1460
|
+
(_contract2 = contract) === null || _contract2 === void 0 ? void 0 : _contract2.off(eventName, handler);
|
|
966
1461
|
unsubscribe();
|
|
967
1462
|
};
|
|
968
1463
|
}
|
|
@@ -979,8 +1474,6 @@ async function fetchBlockNumber() {
|
|
|
979
1474
|
}
|
|
980
1475
|
|
|
981
1476
|
function watchBlockNumber(args, callback) {
|
|
982
|
-
var _getWebSocketProvider;
|
|
983
|
-
|
|
984
1477
|
// We need to debounce the listener as we want to opt-out
|
|
985
1478
|
// of the behavior where ethers emits a "block" event for
|
|
986
1479
|
// every block that was missed in between the `pollingInterval`.
|
|
@@ -1000,9 +1493,9 @@ function watchBlockNumber(args, callback) {
|
|
|
1000
1493
|
previousProvider = provider;
|
|
1001
1494
|
};
|
|
1002
1495
|
|
|
1003
|
-
const provider_ =
|
|
1496
|
+
const provider_ = getWebSocketProvider({
|
|
1004
1497
|
chainId: args.chainId
|
|
1005
|
-
})
|
|
1498
|
+
}) ?? getProvider.getProvider({
|
|
1006
1499
|
chainId: args.chainId
|
|
1007
1500
|
});
|
|
1008
1501
|
if (args.listen) createListener(provider_);
|
|
@@ -1022,7 +1515,7 @@ function watchBlockNumber(args, callback) {
|
|
|
1022
1515
|
provider,
|
|
1023
1516
|
webSocketProvider
|
|
1024
1517
|
} = _ref2;
|
|
1025
|
-
const provider_ = webSocketProvider
|
|
1518
|
+
const provider_ = webSocketProvider ?? provider;
|
|
1026
1519
|
|
|
1027
1520
|
if (args.listen && !args.chainId && provider_) {
|
|
1028
1521
|
createListener(provider_);
|
|
@@ -1046,10 +1539,10 @@ function watchBlockNumber(args, callback) {
|
|
|
1046
1539
|
};
|
|
1047
1540
|
}
|
|
1048
1541
|
|
|
1049
|
-
function
|
|
1542
|
+
function watchMulticall(config, callback) {
|
|
1050
1543
|
const client = getProvider.getClient();
|
|
1051
1544
|
|
|
1052
|
-
const handleChange = async () => callback(await
|
|
1545
|
+
const handleChange = async () => callback(await multicall(config));
|
|
1053
1546
|
|
|
1054
1547
|
const unwatch = config.listenToBlock ? watchBlockNumber({
|
|
1055
1548
|
listen: true
|
|
@@ -1066,10 +1559,10 @@ function watchReadContract(config, callback) {
|
|
|
1066
1559
|
};
|
|
1067
1560
|
}
|
|
1068
1561
|
|
|
1069
|
-
function
|
|
1562
|
+
function watchReadContract(config, callback) {
|
|
1070
1563
|
const client = getProvider.getClient();
|
|
1071
1564
|
|
|
1072
|
-
const handleChange = async () => callback(await
|
|
1565
|
+
const handleChange = async () => callback(await readContract(config));
|
|
1073
1566
|
|
|
1074
1567
|
const unwatch = config.listenToBlock ? watchBlockNumber({
|
|
1075
1568
|
listen: true
|
|
@@ -1086,42 +1579,24 @@ function watchReadContracts(config, callback) {
|
|
|
1086
1579
|
};
|
|
1087
1580
|
}
|
|
1088
1581
|
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
chainId,
|
|
1092
|
-
request
|
|
1093
|
-
} = _ref;
|
|
1094
|
-
const {
|
|
1095
|
-
connector
|
|
1096
|
-
} = getProvider.getClient();
|
|
1097
|
-
if (!connector) throw new getProvider.ConnectorNotFoundError();
|
|
1098
|
-
|
|
1099
|
-
try {
|
|
1100
|
-
var _chain;
|
|
1101
|
-
|
|
1102
|
-
let chain;
|
|
1103
|
-
|
|
1104
|
-
if (chainId) {
|
|
1105
|
-
const activeChainId = await connector.getChainId(); // Try to switch chain to provided `chainId`
|
|
1106
|
-
|
|
1107
|
-
if (chainId !== activeChainId) {
|
|
1108
|
-
var _connector$chains$fin, _connector$chains$fin2, _connector$chains$fin3, _connector$chains$fin4;
|
|
1582
|
+
function watchReadContracts(config, callback) {
|
|
1583
|
+
const client = getProvider.getClient();
|
|
1109
1584
|
|
|
1110
|
-
|
|
1111
|
-
activeChain: (_connector$chains$fin = (_connector$chains$fin2 = connector.chains.find(x => x.id === activeChainId)) === null || _connector$chains$fin2 === void 0 ? void 0 : _connector$chains$fin2.name) !== null && _connector$chains$fin !== void 0 ? _connector$chains$fin : "Chain ".concat(activeChainId),
|
|
1112
|
-
targetChain: (_connector$chains$fin3 = (_connector$chains$fin4 = connector.chains.find(x => x.id === chainId)) === null || _connector$chains$fin4 === void 0 ? void 0 : _connector$chains$fin4.name) !== null && _connector$chains$fin3 !== void 0 ? _connector$chains$fin3 : "Chain ".concat(chainId)
|
|
1113
|
-
});
|
|
1114
|
-
}
|
|
1115
|
-
}
|
|
1585
|
+
const handleChange = async () => callback(await readContracts(config));
|
|
1116
1586
|
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1587
|
+
const unwatch = config.listenToBlock ? watchBlockNumber({
|
|
1588
|
+
listen: true
|
|
1589
|
+
}, handleChange) : undefined;
|
|
1590
|
+
const unsubscribe = client.subscribe(_ref => {
|
|
1591
|
+
let {
|
|
1592
|
+
provider
|
|
1593
|
+
} = _ref;
|
|
1594
|
+
return provider;
|
|
1595
|
+
}, handleChange);
|
|
1596
|
+
return () => {
|
|
1597
|
+
unsubscribe();
|
|
1598
|
+
unwatch === null || unwatch === void 0 ? void 0 : unwatch();
|
|
1599
|
+
};
|
|
1125
1600
|
}
|
|
1126
1601
|
|
|
1127
1602
|
/**
|
|
@@ -1220,13 +1695,18 @@ async function prepareSendTransaction(_ref) {
|
|
|
1220
1695
|
let {
|
|
1221
1696
|
chainId,
|
|
1222
1697
|
request,
|
|
1223
|
-
|
|
1224
|
-
chainId
|
|
1225
|
-
})
|
|
1698
|
+
signer: signer_
|
|
1226
1699
|
} = _ref;
|
|
1700
|
+
const signer = signer_ ?? (await fetchSigner({
|
|
1701
|
+
chainId
|
|
1702
|
+
}));
|
|
1703
|
+
if (!signer) throw new getProvider.ConnectorNotFoundError();
|
|
1704
|
+
if (chainId) assertActiveChain({
|
|
1705
|
+
chainId
|
|
1706
|
+
});
|
|
1227
1707
|
const [to, gasLimit] = await Promise.all([utils.isAddress(request.to) ? Promise.resolve(request.to) : fetchEnsAddress({
|
|
1228
1708
|
name: request.to
|
|
1229
|
-
}), request.gasLimit ? Promise.resolve(request.gasLimit) :
|
|
1709
|
+
}), request.gasLimit ? Promise.resolve(request.gasLimit) : signer.estimateGas(request)]);
|
|
1230
1710
|
if (!to) throw new Error('Could not resolve ENS name');
|
|
1231
1711
|
return { ...(chainId ? {
|
|
1232
1712
|
chainId
|
|
@@ -1281,20 +1761,9 @@ async function sendTransaction(_ref) {
|
|
|
1281
1761
|
if (!request.to) throw new Error('`to` is required');
|
|
1282
1762
|
}
|
|
1283
1763
|
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
} = getNetwork();
|
|
1288
|
-
const activeChainId = activeChain === null || activeChain === void 0 ? void 0 : activeChain.id;
|
|
1289
|
-
|
|
1290
|
-
if (chainId && chainId !== (activeChain === null || activeChain === void 0 ? void 0 : activeChain.id)) {
|
|
1291
|
-
var _chains$find$name, _chains$find, _chains$find$name2, _chains$find2;
|
|
1292
|
-
|
|
1293
|
-
throw new getProvider.ChainMismatchError({
|
|
1294
|
-
activeChain: (_chains$find$name = (_chains$find = chains.find(x => x.id === activeChainId)) === null || _chains$find === void 0 ? void 0 : _chains$find.name) !== null && _chains$find$name !== void 0 ? _chains$find$name : "Chain ".concat(activeChainId),
|
|
1295
|
-
targetChain: (_chains$find$name2 = (_chains$find2 = chains.find(x => x.id === chainId)) === null || _chains$find2 === void 0 ? void 0 : _chains$find2.name) !== null && _chains$find$name2 !== void 0 ? _chains$find$name2 : "Chain ".concat(chainId)
|
|
1296
|
-
});
|
|
1297
|
-
}
|
|
1764
|
+
if (chainId) assertActiveChain({
|
|
1765
|
+
chainId
|
|
1766
|
+
});
|
|
1298
1767
|
|
|
1299
1768
|
try {
|
|
1300
1769
|
var _connectUnchecked, _ref2;
|
|
@@ -1310,7 +1779,7 @@ async function sendTransaction(_ref) {
|
|
|
1310
1779
|
const {
|
|
1311
1780
|
hash,
|
|
1312
1781
|
wait
|
|
1313
|
-
} = await (uncheckedSigner
|
|
1782
|
+
} = await (uncheckedSigner ?? signer).sendTransaction(request);
|
|
1314
1783
|
/********************************************************************/
|
|
1315
1784
|
|
|
1316
1785
|
/** END: iOS App Link cautious code. */
|
|
@@ -1320,7 +1789,7 @@ async function sendTransaction(_ref) {
|
|
|
1320
1789
|
/********************************************************************/
|
|
1321
1790
|
|
|
1322
1791
|
return {
|
|
1323
|
-
hash,
|
|
1792
|
+
hash: hash,
|
|
1324
1793
|
wait
|
|
1325
1794
|
};
|
|
1326
1795
|
} catch (error) {
|
|
@@ -1359,58 +1828,45 @@ async function waitForTransaction(_ref) {
|
|
|
1359
1828
|
* import { prepareWriteContract, writeContract } from '@wagmi/core'
|
|
1360
1829
|
*
|
|
1361
1830
|
* const config = await prepareWriteContract({
|
|
1362
|
-
*
|
|
1363
|
-
*
|
|
1831
|
+
* address: '0x...',
|
|
1832
|
+
* abi: wagmiAbi,
|
|
1364
1833
|
* functionName: 'mint',
|
|
1365
1834
|
* })
|
|
1366
1835
|
* const result = await writeContract(config)
|
|
1367
1836
|
*/
|
|
1368
1837
|
async function writeContract(_ref) {
|
|
1369
1838
|
let {
|
|
1370
|
-
|
|
1839
|
+
address,
|
|
1371
1840
|
args,
|
|
1372
1841
|
chainId,
|
|
1373
|
-
|
|
1842
|
+
abi,
|
|
1374
1843
|
functionName,
|
|
1375
1844
|
mode,
|
|
1376
1845
|
overrides,
|
|
1377
1846
|
request: request_
|
|
1378
1847
|
} = _ref;
|
|
1379
1848
|
|
|
1380
|
-
|
|
1849
|
+
/****************************************************************************/
|
|
1381
1850
|
|
|
1382
|
-
/** START: iOS App Link cautious code.
|
|
1851
|
+
/** START: iOS App Link cautious code. */
|
|
1383
1852
|
|
|
1384
|
-
/** Do not perform any async operations in this block.
|
|
1853
|
+
/** Do not perform any async operations in this block. */
|
|
1385
1854
|
|
|
1386
|
-
/** Ref: wagmi.sh/docs/prepare-hooks/intro#ios-app-link-constraints */
|
|
1855
|
+
/** Ref: https://wagmi.sh/docs/prepare-hooks/intro#ios-app-link-constraints */
|
|
1387
1856
|
|
|
1388
|
-
|
|
1857
|
+
/****************************************************************************/
|
|
1389
1858
|
const signer = await fetchSigner();
|
|
1390
1859
|
if (!signer) throw new getProvider.ConnectorNotFoundError();
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
const activeChainId = activeChain === null || activeChain === void 0 ? void 0 : activeChain.id;
|
|
1396
|
-
|
|
1397
|
-
if (chainId && chainId !== activeChainId) {
|
|
1398
|
-
var _chains$find$name, _chains$find, _chains$find$name2, _chains$find2;
|
|
1399
|
-
|
|
1400
|
-
throw new getProvider.ChainMismatchError({
|
|
1401
|
-
activeChain: (_chains$find$name = (_chains$find = chains.find(x => x.id === activeChainId)) === null || _chains$find === void 0 ? void 0 : _chains$find.name) !== null && _chains$find$name !== void 0 ? _chains$find$name : "Chain ".concat(activeChainId),
|
|
1402
|
-
targetChain: (_chains$find$name2 = (_chains$find2 = chains.find(x => x.id === chainId)) === null || _chains$find2 === void 0 ? void 0 : _chains$find2.name) !== null && _chains$find$name2 !== void 0 ? _chains$find$name2 : "Chain ".concat(chainId)
|
|
1403
|
-
});
|
|
1404
|
-
}
|
|
1405
|
-
|
|
1406
|
-
if (mode === 'prepared') {
|
|
1407
|
-
if (!request_) throw new Error('`request` is required');
|
|
1408
|
-
}
|
|
1409
|
-
|
|
1860
|
+
if (chainId) assertActiveChain({
|
|
1861
|
+
chainId
|
|
1862
|
+
});
|
|
1863
|
+
if (mode === 'prepared') if (!request_) throw new Error('`request` is required');
|
|
1410
1864
|
const request = mode === 'recklesslyUnprepared' ? (await prepareWriteContract({
|
|
1411
|
-
|
|
1865
|
+
address,
|
|
1412
1866
|
args,
|
|
1413
|
-
|
|
1867
|
+
chainId,
|
|
1868
|
+
abi: abi,
|
|
1869
|
+
// TODO: Remove cast and still support `Narrow<TAbi>`
|
|
1414
1870
|
functionName,
|
|
1415
1871
|
overrides
|
|
1416
1872
|
})).request : request_;
|
|
@@ -1430,7 +1886,7 @@ async function writeContract(_ref) {
|
|
|
1430
1886
|
}
|
|
1431
1887
|
|
|
1432
1888
|
async function fetchBalance(_ref) {
|
|
1433
|
-
var
|
|
1889
|
+
var _chain$nativeCurrency, _chain$nativeCurrency2;
|
|
1434
1890
|
|
|
1435
1891
|
let {
|
|
1436
1892
|
addressOrName,
|
|
@@ -1450,25 +1906,25 @@ async function fetchBalance(_ref) {
|
|
|
1450
1906
|
const address = await provider.resolveName(addressOrName); // Same error `provider.getBalance` throws for invalid ENS name
|
|
1451
1907
|
|
|
1452
1908
|
if (!address) ethers$1.logger.throwError('ENS name not configured', utils.Logger.errors.UNSUPPORTED_OPERATION, {
|
|
1453
|
-
operation:
|
|
1909
|
+
operation: `resolveName(${JSON.stringify(addressOrName)})`
|
|
1454
1910
|
});
|
|
1455
1911
|
resolvedAddress = address;
|
|
1456
1912
|
}
|
|
1457
1913
|
|
|
1458
1914
|
const fetchContractBalance = async _ref2 => {
|
|
1459
1915
|
let {
|
|
1460
|
-
|
|
1916
|
+
abi
|
|
1461
1917
|
} = _ref2;
|
|
1462
1918
|
const erc20Config = {
|
|
1463
|
-
|
|
1464
|
-
|
|
1919
|
+
abi,
|
|
1920
|
+
address: token,
|
|
1465
1921
|
chainId
|
|
1466
1922
|
};
|
|
1467
1923
|
const [value, decimals, symbol] = await readContracts({
|
|
1468
1924
|
allowFailure: false,
|
|
1469
1925
|
contracts: [{ ...erc20Config,
|
|
1470
1926
|
functionName: 'balanceOf',
|
|
1471
|
-
args: resolvedAddress
|
|
1927
|
+
args: [resolvedAddress]
|
|
1472
1928
|
}, { ...erc20Config,
|
|
1473
1929
|
functionName: 'decimals'
|
|
1474
1930
|
}, { ...erc20Config,
|
|
@@ -1477,15 +1933,16 @@ async function fetchBalance(_ref) {
|
|
|
1477
1933
|
});
|
|
1478
1934
|
return {
|
|
1479
1935
|
decimals,
|
|
1480
|
-
formatted: utils.formatUnits(value
|
|
1481
|
-
symbol,
|
|
1936
|
+
formatted: utils.formatUnits(value ?? '0', unit ?? decimals),
|
|
1937
|
+
symbol: symbol,
|
|
1938
|
+
// protect against `ResolvedConfig['BytesType']`
|
|
1482
1939
|
value
|
|
1483
1940
|
};
|
|
1484
1941
|
};
|
|
1485
1942
|
|
|
1486
1943
|
try {
|
|
1487
1944
|
return await fetchContractBalance({
|
|
1488
|
-
|
|
1945
|
+
abi: erc20ABI
|
|
1489
1946
|
});
|
|
1490
1947
|
} catch (err) {
|
|
1491
1948
|
// In the chance that there is an error upon decoding the contract result,
|
|
@@ -1496,7 +1953,7 @@ async function fetchBalance(_ref) {
|
|
|
1496
1953
|
symbol,
|
|
1497
1954
|
...rest
|
|
1498
1955
|
} = await fetchContractBalance({
|
|
1499
|
-
|
|
1956
|
+
abi: erc20ABI_bytes32
|
|
1500
1957
|
});
|
|
1501
1958
|
return {
|
|
1502
1959
|
symbol: utils.parseBytes32String(symbol),
|
|
@@ -1508,13 +1965,13 @@ async function fetchBalance(_ref) {
|
|
|
1508
1965
|
}
|
|
1509
1966
|
}
|
|
1510
1967
|
|
|
1511
|
-
const chains = [...(client.provider.chains || []), ...(
|
|
1968
|
+
const chains = [...(client.provider.chains || []), ...(client.chains ?? [])];
|
|
1512
1969
|
const value = await provider.getBalance(addressOrName);
|
|
1513
1970
|
const chain = chains.find(x => x.id === provider.network.chainId);
|
|
1514
1971
|
return {
|
|
1515
|
-
decimals: (
|
|
1516
|
-
formatted: utils.formatUnits(value
|
|
1517
|
-
symbol: (
|
|
1972
|
+
decimals: (chain === null || chain === void 0 ? void 0 : (_chain$nativeCurrency = chain.nativeCurrency) === null || _chain$nativeCurrency === void 0 ? void 0 : _chain$nativeCurrency.decimals) ?? 18,
|
|
1973
|
+
formatted: utils.formatUnits(value ?? '0', unit ?? 'ether'),
|
|
1974
|
+
symbol: (chain === null || chain === void 0 ? void 0 : (_chain$nativeCurrency2 = chain.nativeCurrency) === null || _chain$nativeCurrency2 === void 0 ? void 0 : _chain$nativeCurrency2.symbol) ?? 'ETH',
|
|
1518
1975
|
value
|
|
1519
1976
|
};
|
|
1520
1977
|
}
|
|
@@ -1522,8 +1979,13 @@ async function fetchBalance(_ref) {
|
|
|
1522
1979
|
async function fetchSigner() {
|
|
1523
1980
|
var _client$connector, _client$connector$get;
|
|
1524
1981
|
|
|
1982
|
+
let {
|
|
1983
|
+
chainId
|
|
1984
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1525
1985
|
const client = getProvider.getClient();
|
|
1526
|
-
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
|
|
1986
|
+
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, {
|
|
1987
|
+
chainId
|
|
1988
|
+
}))) || null;
|
|
1527
1989
|
return signer;
|
|
1528
1990
|
}
|
|
1529
1991
|
|
|
@@ -1582,15 +2044,15 @@ function getAccount() {
|
|
|
1582
2044
|
}
|
|
1583
2045
|
|
|
1584
2046
|
function getNetwork() {
|
|
1585
|
-
var _client$data, _client$data$chain, _client$
|
|
2047
|
+
var _client$data, _client$data$chain, _client$data2;
|
|
1586
2048
|
|
|
1587
2049
|
const client = getProvider.getClient();
|
|
1588
2050
|
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;
|
|
1589
|
-
const activeChains =
|
|
1590
|
-
const activeChain =
|
|
2051
|
+
const activeChains = client.chains ?? [];
|
|
2052
|
+
const activeChain = [...(client.provider.chains || []), ...activeChains].find(x => x.id === chainId) ?? {
|
|
1591
2053
|
id: chainId,
|
|
1592
|
-
name:
|
|
1593
|
-
network:
|
|
2054
|
+
name: `Chain ${chainId}`,
|
|
2055
|
+
network: `${chainId}`,
|
|
1594
2056
|
rpcUrls: {
|
|
1595
2057
|
default: ''
|
|
1596
2058
|
}
|
|
@@ -1623,28 +2085,13 @@ async function signTypedData(_ref) {
|
|
|
1623
2085
|
} = _ref;
|
|
1624
2086
|
const signer = await fetchSigner();
|
|
1625
2087
|
if (!signer) throw new getProvider.ConnectorNotFoundError();
|
|
1626
|
-
const {
|
|
1627
|
-
chain: activeChain,
|
|
1628
|
-
chains
|
|
1629
|
-
} = getNetwork();
|
|
1630
2088
|
const {
|
|
1631
2089
|
chainId: chainId_
|
|
1632
2090
|
} = domain;
|
|
1633
|
-
|
|
1634
|
-
if (
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
if (chainId !== (activeChain === null || activeChain === void 0 ? void 0 : activeChain.id)) {
|
|
1639
|
-
var _chains$find$name, _chains$find, _chains$find$name2, _chains$find2;
|
|
1640
|
-
|
|
1641
|
-
throw new getProvider.ChainMismatchError({
|
|
1642
|
-
activeChain: (_chains$find$name = (_chains$find = chains.find(x => x.id === activeChainId)) === null || _chains$find === void 0 ? void 0 : _chains$find.name) !== null && _chains$find$name !== void 0 ? _chains$find$name : "Chain ".concat(activeChainId),
|
|
1643
|
-
targetChain: (_chains$find$name2 = (_chains$find2 = chains.find(x => x.id === chainId)) === null || _chains$find2 === void 0 ? void 0 : _chains$find2.name) !== null && _chains$find$name2 !== void 0 ? _chains$find$name2 : "Chain ".concat(chainId)
|
|
1644
|
-
});
|
|
1645
|
-
}
|
|
1646
|
-
} // Method name may be changed in the future, see https://docs.ethers.io/v5/api/signer/#Signer-signTypedData
|
|
1647
|
-
|
|
2091
|
+
const chainId = chainId_ ? getProvider.normalizeChainId(chainId_) : undefined;
|
|
2092
|
+
if (chainId) assertActiveChain({
|
|
2093
|
+
chainId
|
|
2094
|
+
}); // Method name may be changed in the future, see https://docs.ethers.io/v5/api/signer/#Signer-signTypedData
|
|
1648
2095
|
|
|
1649
2096
|
return await signer._signTypedData(domain, types, value);
|
|
1650
2097
|
}
|
|
@@ -1713,18 +2160,23 @@ function watchNetwork(callback) {
|
|
|
1713
2160
|
return unsubscribe;
|
|
1714
2161
|
}
|
|
1715
2162
|
|
|
1716
|
-
function watchSigner(callback) {
|
|
2163
|
+
function watchSigner(_ref, callback) {
|
|
2164
|
+
let {
|
|
2165
|
+
chainId
|
|
2166
|
+
} = _ref;
|
|
1717
2167
|
const client = getProvider.getClient();
|
|
1718
2168
|
|
|
1719
|
-
const handleChange = async () => callback(await fetchSigner(
|
|
2169
|
+
const handleChange = async () => callback(await fetchSigner({
|
|
2170
|
+
chainId
|
|
2171
|
+
}));
|
|
1720
2172
|
|
|
1721
|
-
const unsubscribe = client.subscribe(
|
|
2173
|
+
const unsubscribe = client.subscribe(_ref2 => {
|
|
1722
2174
|
var _data$chain;
|
|
1723
2175
|
|
|
1724
2176
|
let {
|
|
1725
2177
|
data,
|
|
1726
2178
|
connector
|
|
1727
|
-
} =
|
|
2179
|
+
} = _ref2;
|
|
1728
2180
|
return {
|
|
1729
2181
|
account: data === null || data === void 0 ? void 0 : data.account,
|
|
1730
2182
|
chainId: data === null || data === void 0 ? void 0 : (_data$chain = data.chain) === null || _data$chain === void 0 ? void 0 : _data$chain.id,
|
|
@@ -1792,8 +2244,6 @@ exports.publicRpcUrls = rpcs.publicRpcUrls;
|
|
|
1792
2244
|
exports.configureChains = configureChains;
|
|
1793
2245
|
exports.connect = connect;
|
|
1794
2246
|
exports.deepEqual = deepEqual;
|
|
1795
|
-
exports.deprecatedSendTransaction = deprecatedSendTransaction;
|
|
1796
|
-
exports.deprecatedWriteContract = deprecatedWriteContract;
|
|
1797
2247
|
exports.disconnect = disconnect;
|
|
1798
2248
|
exports.erc20ABI = erc20ABI;
|
|
1799
2249
|
exports.erc721ABI = erc721ABI;
|
|
@@ -1812,6 +2262,7 @@ exports.getContract = getContract;
|
|
|
1812
2262
|
exports.getNetwork = getNetwork;
|
|
1813
2263
|
exports.getWebSocketProvider = getWebSocketProvider;
|
|
1814
2264
|
exports.minimizeContractInterface = minimizeContractInterface;
|
|
2265
|
+
exports.multicall = multicall;
|
|
1815
2266
|
exports.parseContractResult = parseContractResult;
|
|
1816
2267
|
exports.prepareSendTransaction = prepareSendTransaction;
|
|
1817
2268
|
exports.prepareWriteContract = prepareWriteContract;
|
|
@@ -1826,6 +2277,7 @@ exports.waitForTransaction = waitForTransaction;
|
|
|
1826
2277
|
exports.watchAccount = watchAccount;
|
|
1827
2278
|
exports.watchBlockNumber = watchBlockNumber;
|
|
1828
2279
|
exports.watchContractEvent = watchContractEvent;
|
|
2280
|
+
exports.watchMulticall = watchMulticall;
|
|
1829
2281
|
exports.watchNetwork = watchNetwork;
|
|
1830
2282
|
exports.watchProvider = watchProvider;
|
|
1831
2283
|
exports.watchReadContract = watchReadContract;
|