@wagmi/core 0.8.12 → 0.8.14-cjs
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/dist/chains.js +59 -59
- package/dist/chunk-7J7OLO4T.js +60 -60
- package/dist/{chunk-VRBYTA34.js → chunk-BTYZYIHC.js} +243 -245
- package/dist/chunk-BVC4KGLQ.js +8 -8
- package/dist/chunk-EQOEZP46.js +5 -5
- package/dist/chunk-KFW652VN.js +6 -6
- package/dist/chunk-KX4UEHS5.js +1 -0
- package/dist/chunk-MQXBDTVK.js +7 -7
- package/dist/connectors/coinbaseWallet.js +5 -5
- package/dist/connectors/index.js +9 -9
- package/dist/connectors/injected.js +7 -7
- package/dist/connectors/ledger.js +5 -5
- package/dist/connectors/metaMask.js +5 -5
- package/dist/connectors/mock.js +9 -9
- package/dist/connectors/walletConnect.js +5 -5
- package/dist/index.d.ts +4 -0
- package/dist/index.js +164 -164
- package/dist/internal/index.js +8 -8
- package/dist/internal/test.js +25 -25
- package/dist/providers/alchemy.js +11 -11
- package/dist/providers/infura.js +11 -11
- package/dist/providers/jsonRpc.js +8 -8
- package/dist/providers/public.js +7 -7
- package/internal/dist/wagmi-core-internal.cjs.d.ts +11 -0
- package/internal/dist/wagmi-core-internal.cjs.js +16 -0
- package/package.json +4 -5
- package/providers/alchemy/dist/wagmi-core-providers-alchemy.cjs.d.ts +11 -0
- package/providers/alchemy/dist/wagmi-core-providers-alchemy.cjs.js +16 -0
- package/providers/infura/dist/wagmi-core-providers-infura.cjs.d.ts +11 -0
- package/providers/infura/dist/wagmi-core-providers-infura.cjs.js +16 -0
- package/providers/jsonRpc/dist/wagmi-core-providers-jsonRpc.cjs.d.ts +11 -0
- package/providers/jsonRpc/dist/wagmi-core-providers-jsonRpc.cjs.js +16 -0
- package/providers/public/dist/wagmi-core-providers-public.cjs.d.ts +11 -0
- package/providers/public/dist/wagmi-core-providers-public.cjs.js +16 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkBVC4KGLQjs = require('./chunk-BVC4KGLQ.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkMQXBDTVKjs = require('./chunk-MQXBDTVK.js');
|
|
10
10
|
|
|
11
11
|
// src/utils/configureChains.ts
|
|
12
|
-
|
|
12
|
+
var _ethers = require('ethers');
|
|
13
13
|
function configureChains(defaultChains, providers2, {
|
|
14
14
|
minQuorum = 1,
|
|
15
15
|
pollingInterval = 4e3,
|
|
@@ -58,7 +58,7 @@ function configureChains(defaultChains, providers2, {
|
|
|
58
58
|
return {
|
|
59
59
|
chains,
|
|
60
60
|
provider: ({ chainId }) => {
|
|
61
|
-
const activeChain = chains.find((x) => x.id === chainId)
|
|
61
|
+
const activeChain = _nullishCoalesce(chains.find((x) => x.id === chainId), () => ( defaultChains[0]));
|
|
62
62
|
const chainProviders = providers_[activeChain.id];
|
|
63
63
|
if (!chainProviders || !chainProviders[0])
|
|
64
64
|
throw new Error(`No providers configured for chain "${activeChain.id}"`);
|
|
@@ -83,11 +83,11 @@ function configureChains(defaultChains, providers2, {
|
|
|
83
83
|
});
|
|
84
84
|
},
|
|
85
85
|
webSocketProvider: ({ chainId }) => {
|
|
86
|
-
const activeChain = chains.find((x) => x.id === chainId)
|
|
86
|
+
const activeChain = _nullishCoalesce(chains.find((x) => x.id === chainId), () => ( defaultChains[0]));
|
|
87
87
|
const chainWebSocketProviders = webSocketProviders_[activeChain.id];
|
|
88
88
|
if (!chainWebSocketProviders)
|
|
89
89
|
return void 0;
|
|
90
|
-
const provider = chainWebSocketProviders[0]
|
|
90
|
+
const provider = _optionalChain([chainWebSocketProviders, 'access', _ => _[0], 'optionalCall', _2 => _2()]);
|
|
91
91
|
if (provider && activeChain.id === 42220) {
|
|
92
92
|
provider.formatter.formats.block = {
|
|
93
93
|
...provider.formatter.formats.block,
|
|
@@ -103,22 +103,22 @@ function configureChains(defaultChains, providers2, {
|
|
|
103
103
|
}
|
|
104
104
|
function fallbackProvider(targetQuorum, minQuorum, providers_, { stallTimeout }) {
|
|
105
105
|
try {
|
|
106
|
-
return new providers.FallbackProvider(
|
|
106
|
+
return new _ethers.providers.FallbackProvider(
|
|
107
107
|
providers_.map((chainProvider, index) => {
|
|
108
108
|
const provider = chainProvider();
|
|
109
109
|
return {
|
|
110
110
|
provider,
|
|
111
|
-
priority: provider.priority
|
|
112
|
-
stallTimeout: provider.stallTimeout
|
|
111
|
+
priority: _nullishCoalesce(provider.priority, () => ( index)),
|
|
112
|
+
stallTimeout: _nullishCoalesce(provider.stallTimeout, () => ( stallTimeout)),
|
|
113
113
|
weight: provider.weight
|
|
114
114
|
};
|
|
115
115
|
}),
|
|
116
116
|
targetQuorum
|
|
117
117
|
);
|
|
118
118
|
} catch (error) {
|
|
119
|
-
if (error
|
|
119
|
+
if (_optionalChain([error, 'optionalAccess', _3 => _3.message, 'optionalAccess', _4 => _4.includes, 'call', _5 => _5(
|
|
120
120
|
"quorum will always fail; larger than total weight"
|
|
121
|
-
)) {
|
|
121
|
+
)])) {
|
|
122
122
|
if (targetQuorum === minQuorum)
|
|
123
123
|
throw error;
|
|
124
124
|
return fallbackProvider(targetQuorum - 1, minQuorum, providers_, {
|
|
@@ -130,8 +130,8 @@ function fallbackProvider(targetQuorum, minQuorum, providers_, { stallTimeout })
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
// src/client.ts
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
var _middleware = require('zustand/middleware');
|
|
134
|
+
var _vanilla = require('zustand/vanilla');
|
|
135
135
|
|
|
136
136
|
// src/utils/assertActiveChain.ts
|
|
137
137
|
function assertActiveChain({
|
|
@@ -139,20 +139,20 @@ function assertActiveChain({
|
|
|
139
139
|
signer
|
|
140
140
|
}) {
|
|
141
141
|
const { chain: activeChain, chains } = getNetwork();
|
|
142
|
-
const activeChainId = activeChain
|
|
142
|
+
const activeChainId = _optionalChain([activeChain, 'optionalAccess', _6 => _6.id]);
|
|
143
143
|
if (activeChainId && chainId !== activeChainId) {
|
|
144
144
|
throw new ChainMismatchError({
|
|
145
|
-
activeChain: chains.find((x) => x.id === activeChainId)
|
|
146
|
-
targetChain: chains.find((x) => x.id === chainId)
|
|
145
|
+
activeChain: _nullishCoalesce(_optionalChain([chains, 'access', _7 => _7.find, 'call', _8 => _8((x) => x.id === activeChainId), 'optionalAccess', _9 => _9.name]), () => ( `Chain ${activeChainId}`)),
|
|
146
|
+
targetChain: _nullishCoalesce(_optionalChain([chains, 'access', _10 => _10.find, 'call', _11 => _11((x) => x.id === chainId), 'optionalAccess', _12 => _12.name]), () => ( `Chain ${chainId}`))
|
|
147
147
|
});
|
|
148
148
|
}
|
|
149
149
|
if (signer) {
|
|
150
|
-
const signerChainId = signer.provider
|
|
150
|
+
const signerChainId = _optionalChain([signer, 'access', _13 => _13.provider, 'optionalAccess', _14 => _14.network, 'optionalAccess', _15 => _15.chainId]);
|
|
151
151
|
if (signerChainId && chainId !== signerChainId) {
|
|
152
152
|
const connector = getClient().connector;
|
|
153
153
|
throw new ChainNotConfiguredError({
|
|
154
154
|
chainId,
|
|
155
|
-
connectorId: connector
|
|
155
|
+
connectorId: _nullishCoalesce(_optionalChain([connector, 'optionalAccess', _16 => _16.id]), () => ( "unknown"))
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
158
|
}
|
|
@@ -213,7 +213,7 @@ function deepEqual(a, b) {
|
|
|
213
213
|
}
|
|
214
214
|
|
|
215
215
|
// src/utils/deserialize.ts
|
|
216
|
-
|
|
216
|
+
|
|
217
217
|
var findAndReplace = (cacheRef, {
|
|
218
218
|
find,
|
|
219
219
|
replace
|
|
@@ -242,14 +242,14 @@ function deserialize(cachedString) {
|
|
|
242
242
|
const cache = JSON.parse(cachedString);
|
|
243
243
|
const deserializedCacheWithBigNumbers = findAndReplace(cache, {
|
|
244
244
|
find: (data) => data.type === "BigNumber",
|
|
245
|
-
replace: (data) => BigNumber.from(data.hex)
|
|
245
|
+
replace: (data) => _ethers.BigNumber.from(data.hex)
|
|
246
246
|
});
|
|
247
247
|
return deserializedCacheWithBigNumbers;
|
|
248
248
|
}
|
|
249
249
|
|
|
250
250
|
// src/utils/normalizeFunctionName.ts
|
|
251
|
-
|
|
252
|
-
|
|
251
|
+
|
|
252
|
+
var _utilsjs = require('ethers/lib/utils.js');
|
|
253
253
|
function normalizeFunctionName({
|
|
254
254
|
contract,
|
|
255
255
|
functionName,
|
|
@@ -257,8 +257,8 @@ function normalizeFunctionName({
|
|
|
257
257
|
}) {
|
|
258
258
|
if (functionName in contract.functions)
|
|
259
259
|
return functionName;
|
|
260
|
-
const argsLength = args
|
|
261
|
-
const overloadFunctions = Object.keys(contract.functions).filter((x) => x.startsWith(`${functionName}(`)).map((x) => ({ name: x, fragment: FunctionFragment.fromString(x) })).filter((x) => argsLength === x.fragment.inputs.length);
|
|
260
|
+
const argsLength = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _17 => _17.length]), () => ( 0));
|
|
261
|
+
const overloadFunctions = Object.keys(contract.functions).filter((x) => x.startsWith(`${functionName}(`)).map((x) => ({ name: x, fragment: _utilsjs.FunctionFragment.fromString(x) })).filter((x) => argsLength === x.fragment.inputs.length);
|
|
262
262
|
for (const overloadFunction of overloadFunctions) {
|
|
263
263
|
const matched = args.every((arg, index) => {
|
|
264
264
|
const abiParameter = overloadFunction.fragment.inputs[index];
|
|
@@ -274,7 +274,7 @@ function isArgOfType(arg, abiParameter) {
|
|
|
274
274
|
const abiParameterType = abiParameter.type;
|
|
275
275
|
switch (abiParameterType) {
|
|
276
276
|
case "address":
|
|
277
|
-
return isAddress(arg);
|
|
277
|
+
return _utilsjs.isAddress.call(void 0, arg);
|
|
278
278
|
case "bool":
|
|
279
279
|
return argType === "boolean";
|
|
280
280
|
case "function":
|
|
@@ -294,7 +294,7 @@ function isArgOfType(arg, abiParameter) {
|
|
|
294
294
|
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(
|
|
295
295
|
abiParameterType
|
|
296
296
|
))
|
|
297
|
-
return argType === "number" || argType === "bigint" ||
|
|
297
|
+
return argType === "number" || argType === "bigint" || _ethers.BigNumber.isBigNumber(arg);
|
|
298
298
|
if (/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(abiParameterType))
|
|
299
299
|
return argType === "string" || arg instanceof Uint8Array;
|
|
300
300
|
if (/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(abiParameterType)) {
|
|
@@ -312,12 +312,12 @@ function isArgOfType(arg, abiParameter) {
|
|
|
312
312
|
|
|
313
313
|
// src/utils/logger.ts
|
|
314
314
|
function logWarn(message) {
|
|
315
|
-
getClient()
|
|
315
|
+
_optionalChain([getClient, 'call', _18 => _18(), 'optionalAccess', _19 => _19.config, 'access', _20 => _20.logger, 'optionalAccess', _21 => _21.warn, 'optionalCall', _22 => _22(message)]);
|
|
316
316
|
}
|
|
317
317
|
|
|
318
318
|
// src/utils/minimizeContractInterface.ts
|
|
319
|
-
|
|
320
|
-
|
|
319
|
+
|
|
320
|
+
|
|
321
321
|
function minimizeContractInterface(config) {
|
|
322
322
|
try {
|
|
323
323
|
const minimizedAbi = config.abi.filter(
|
|
@@ -327,8 +327,8 @@ function minimizeContractInterface(config) {
|
|
|
327
327
|
throw new Error("Invalid ABI");
|
|
328
328
|
return minimizedAbi;
|
|
329
329
|
} catch (error) {
|
|
330
|
-
const abi = Contract.getInterface(config.abi).format(
|
|
331
|
-
FormatTypes.full
|
|
330
|
+
const abi = _ethers.Contract.getInterface(config.abi).format(
|
|
331
|
+
_utilsjs.FormatTypes.full
|
|
332
332
|
);
|
|
333
333
|
const minimizedInterface = Array.isArray(abi) ? abi : [abi];
|
|
334
334
|
return minimizedInterface.filter((i) => i.includes(config.functionName));
|
|
@@ -348,7 +348,7 @@ function normalizeChainId(chainId) {
|
|
|
348
348
|
}
|
|
349
349
|
|
|
350
350
|
// src/utils/parseContractResult.ts
|
|
351
|
-
|
|
351
|
+
|
|
352
352
|
function isPlainArray(value) {
|
|
353
353
|
return Array.isArray(value) && Object.keys(value).length === value.length;
|
|
354
354
|
}
|
|
@@ -358,9 +358,9 @@ function parseContractResult({
|
|
|
358
358
|
functionName
|
|
359
359
|
}) {
|
|
360
360
|
if (data && isPlainArray(data)) {
|
|
361
|
-
const iface =
|
|
361
|
+
const iface = _ethers.Contract.getInterface(abi);
|
|
362
362
|
const fragment = iface.getFunction(functionName);
|
|
363
|
-
const isTuple = (fragment.outputs
|
|
363
|
+
const isTuple = (_optionalChain([fragment, 'access', _23 => _23.outputs, 'optionalAccess', _24 => _24.length]) || 0) > 1;
|
|
364
364
|
const data_ = isTuple ? data : [data];
|
|
365
365
|
const encodedResult = iface.encodeFunctionResult(functionName, data_);
|
|
366
366
|
const decodedResult = iface.decodeFunctionResult(
|
|
@@ -422,7 +422,7 @@ function serialize(value, replacer, indent, circularReplacer) {
|
|
|
422
422
|
return JSON.stringify(
|
|
423
423
|
value,
|
|
424
424
|
createReplacer(replacer, circularReplacer),
|
|
425
|
-
indent
|
|
425
|
+
_nullishCoalesce(indent, () => ( void 0))
|
|
426
426
|
);
|
|
427
427
|
}
|
|
428
428
|
|
|
@@ -470,7 +470,7 @@ var _isAutoConnecting, _lastUsedConnector, _addEffects, addEffects_fn;
|
|
|
470
470
|
var Client = class {
|
|
471
471
|
constructor({
|
|
472
472
|
autoConnect = false,
|
|
473
|
-
connectors = [new InjectedConnector()],
|
|
473
|
+
connectors = [new (0, _chunkBVC4KGLQjs.InjectedConnector)()],
|
|
474
474
|
provider,
|
|
475
475
|
storage = createStorage({
|
|
476
476
|
storage: typeof window !== "undefined" ? window.localStorage : noopStorage
|
|
@@ -480,11 +480,11 @@ var Client = class {
|
|
|
480
480
|
},
|
|
481
481
|
webSocketProvider
|
|
482
482
|
}) {
|
|
483
|
-
__privateAdd(this, _addEffects);
|
|
483
|
+
_chunkMQXBDTVKjs.__privateAdd.call(void 0, this, _addEffects);
|
|
484
484
|
this.providers = /* @__PURE__ */ new Map();
|
|
485
485
|
this.webSocketProviders = /* @__PURE__ */ new Map();
|
|
486
|
-
__privateAdd(this, _isAutoConnecting, void 0);
|
|
487
|
-
__privateAdd(this, _lastUsedConnector, void 0);
|
|
486
|
+
_chunkMQXBDTVKjs.__privateAdd.call(void 0, this, _isAutoConnecting, void 0);
|
|
487
|
+
_chunkMQXBDTVKjs.__privateAdd.call(void 0, this, _lastUsedConnector, void 0);
|
|
488
488
|
this.config = {
|
|
489
489
|
autoConnect,
|
|
490
490
|
connectors,
|
|
@@ -498,15 +498,15 @@ var Client = class {
|
|
|
498
498
|
if (autoConnect) {
|
|
499
499
|
try {
|
|
500
500
|
const rawState = storage.getItem(storeKey);
|
|
501
|
-
const data = rawState
|
|
502
|
-
status = data
|
|
503
|
-
chainId = data
|
|
501
|
+
const data = _optionalChain([rawState, 'optionalAccess', _25 => _25.state, 'optionalAccess', _26 => _26.data]);
|
|
502
|
+
status = _optionalChain([data, 'optionalAccess', _27 => _27.account]) ? "reconnecting" : "connecting";
|
|
503
|
+
chainId = _optionalChain([data, 'optionalAccess', _28 => _28.chain, 'optionalAccess', _29 => _29.id]);
|
|
504
504
|
} catch (_error) {
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
|
-
this.store =
|
|
508
|
-
subscribeWithSelector(
|
|
509
|
-
persist(
|
|
507
|
+
this.store = _vanilla.createStore.call(void 0,
|
|
508
|
+
_middleware.subscribeWithSelector.call(void 0,
|
|
509
|
+
_middleware.persist.call(void 0,
|
|
510
510
|
() => ({
|
|
511
511
|
connectors: typeof connectors === "function" ? connectors() : connectors,
|
|
512
512
|
provider: this.getProvider({ chainId }),
|
|
@@ -514,27 +514,25 @@ var Client = class {
|
|
|
514
514
|
webSocketProvider: this.getWebSocketProvider({ chainId })
|
|
515
515
|
}),
|
|
516
516
|
{
|
|
517
|
-
deserialize: (state) => state,
|
|
518
517
|
name: storeKey,
|
|
519
|
-
|
|
518
|
+
storage,
|
|
520
519
|
partialize: (state) => ({
|
|
521
520
|
...autoConnect && {
|
|
522
521
|
data: {
|
|
523
|
-
account: state
|
|
524
|
-
chain: state
|
|
522
|
+
account: _optionalChain([state, 'optionalAccess', _30 => _30.data, 'optionalAccess', _31 => _31.account]),
|
|
523
|
+
chain: _optionalChain([state, 'optionalAccess', _32 => _32.data, 'optionalAccess', _33 => _33.chain])
|
|
525
524
|
}
|
|
526
525
|
},
|
|
527
|
-
chains: state
|
|
526
|
+
chains: _optionalChain([state, 'optionalAccess', _34 => _34.chains])
|
|
528
527
|
}),
|
|
529
|
-
serialize: (state) => state,
|
|
530
528
|
version: 2
|
|
531
529
|
}
|
|
532
530
|
)
|
|
533
531
|
)
|
|
534
532
|
);
|
|
535
533
|
this.storage = storage;
|
|
536
|
-
__privateSet(this, _lastUsedConnector, storage
|
|
537
|
-
__privateMethod(this, _addEffects, addEffects_fn).call(this);
|
|
534
|
+
_chunkMQXBDTVKjs.__privateSet.call(void 0, this, _lastUsedConnector, _optionalChain([storage, 'optionalAccess', _35 => _35.getItem, 'call', _36 => _36("wallet")]));
|
|
535
|
+
_chunkMQXBDTVKjs.__privateMethod.call(void 0, this, _addEffects, addEffects_fn).call(this);
|
|
538
536
|
if (autoConnect && typeof window !== "undefined")
|
|
539
537
|
setTimeout(async () => await this.autoConnect(), 0);
|
|
540
538
|
}
|
|
@@ -554,7 +552,7 @@ var Client = class {
|
|
|
554
552
|
return this.store.getState().error;
|
|
555
553
|
}
|
|
556
554
|
get lastUsedChainId() {
|
|
557
|
-
return this.data
|
|
555
|
+
return _optionalChain([this, 'access', _37 => _37.data, 'optionalAccess', _38 => _38.chain, 'optionalAccess', _39 => _39.id]);
|
|
558
556
|
}
|
|
559
557
|
get provider() {
|
|
560
558
|
return this.store.getState().provider;
|
|
@@ -584,21 +582,21 @@ var Client = class {
|
|
|
584
582
|
}
|
|
585
583
|
async destroy() {
|
|
586
584
|
if (this.connector)
|
|
587
|
-
await this.connector.disconnect
|
|
588
|
-
__privateSet(this, _isAutoConnecting, false);
|
|
585
|
+
await _optionalChain([this, 'access', _40 => _40.connector, 'access', _41 => _41.disconnect, 'optionalCall', _42 => _42()]);
|
|
586
|
+
_chunkMQXBDTVKjs.__privateSet.call(void 0, this, _isAutoConnecting, false);
|
|
589
587
|
this.clearState();
|
|
590
588
|
this.store.destroy();
|
|
591
589
|
}
|
|
592
590
|
async autoConnect() {
|
|
593
|
-
if (__privateGet(this, _isAutoConnecting))
|
|
591
|
+
if (_chunkMQXBDTVKjs.__privateGet.call(void 0, this, _isAutoConnecting))
|
|
594
592
|
return;
|
|
595
|
-
__privateSet(this, _isAutoConnecting, true);
|
|
593
|
+
_chunkMQXBDTVKjs.__privateSet.call(void 0, this, _isAutoConnecting, true);
|
|
596
594
|
this.setState((x) => ({
|
|
597
595
|
...x,
|
|
598
|
-
status: x.data
|
|
596
|
+
status: _optionalChain([x, 'access', _43 => _43.data, 'optionalAccess', _44 => _44.account]) ? "reconnecting" : "connecting"
|
|
599
597
|
}));
|
|
600
|
-
const sorted = __privateGet(this, _lastUsedConnector) ? [...this.connectors].sort(
|
|
601
|
-
(x) => x.id === __privateGet(this, _lastUsedConnector) ? -1 : 1
|
|
598
|
+
const sorted = _chunkMQXBDTVKjs.__privateGet.call(void 0, this, _lastUsedConnector) ? [...this.connectors].sort(
|
|
599
|
+
(x) => x.id === _chunkMQXBDTVKjs.__privateGet.call(void 0, this, _lastUsedConnector) ? -1 : 1
|
|
602
600
|
) : this.connectors;
|
|
603
601
|
let connected = false;
|
|
604
602
|
for (const connector of sorted) {
|
|
@@ -611,7 +609,7 @@ var Client = class {
|
|
|
611
609
|
this.setState((x) => ({
|
|
612
610
|
...x,
|
|
613
611
|
connector,
|
|
614
|
-
chains: connector
|
|
612
|
+
chains: _optionalChain([connector, 'optionalAccess', _45 => _45.chains]),
|
|
615
613
|
data,
|
|
616
614
|
status: "connected"
|
|
617
615
|
}));
|
|
@@ -624,33 +622,33 @@ var Client = class {
|
|
|
624
622
|
data: void 0,
|
|
625
623
|
status: "disconnected"
|
|
626
624
|
}));
|
|
627
|
-
__privateSet(this, _isAutoConnecting, false);
|
|
625
|
+
_chunkMQXBDTVKjs.__privateSet.call(void 0, this, _isAutoConnecting, false);
|
|
628
626
|
return this.data;
|
|
629
627
|
}
|
|
630
628
|
getProvider({ bust, chainId } = {}) {
|
|
631
|
-
let provider_ = this.providers.get(chainId
|
|
629
|
+
let provider_ = this.providers.get(_nullishCoalesce(chainId, () => ( -1)));
|
|
632
630
|
if (provider_ && !bust)
|
|
633
631
|
return provider_;
|
|
634
632
|
const { provider } = this.config;
|
|
635
633
|
provider_ = typeof provider === "function" ? provider({ chainId }) : provider;
|
|
636
|
-
this.providers.set(chainId
|
|
634
|
+
this.providers.set(_nullishCoalesce(chainId, () => ( -1)), provider_);
|
|
637
635
|
return provider_;
|
|
638
636
|
}
|
|
639
637
|
getWebSocketProvider({
|
|
640
638
|
bust,
|
|
641
639
|
chainId
|
|
642
640
|
} = {}) {
|
|
643
|
-
let webSocketProvider_ = this.webSocketProviders.get(chainId
|
|
641
|
+
let webSocketProvider_ = this.webSocketProviders.get(_nullishCoalesce(chainId, () => ( -1)));
|
|
644
642
|
if (webSocketProvider_ && !bust)
|
|
645
643
|
return webSocketProvider_;
|
|
646
644
|
const { webSocketProvider } = this.config;
|
|
647
645
|
webSocketProvider_ = typeof webSocketProvider === "function" ? webSocketProvider({ chainId }) : webSocketProvider;
|
|
648
646
|
if (webSocketProvider_)
|
|
649
|
-
this.webSocketProviders.set(chainId
|
|
647
|
+
this.webSocketProviders.set(_nullishCoalesce(chainId, () => ( -1)), webSocketProvider_);
|
|
650
648
|
return webSocketProvider_;
|
|
651
649
|
}
|
|
652
650
|
setLastUsedConnector(lastUsedConnector = null) {
|
|
653
|
-
this.storage
|
|
651
|
+
_optionalChain([this, 'access', _46 => _46.storage, 'optionalAccess', _47 => _47.setItem, 'call', _48 => _48("wallet", lastUsedConnector)]);
|
|
654
652
|
}
|
|
655
653
|
};
|
|
656
654
|
_isAutoConnecting = new WeakMap();
|
|
@@ -672,14 +670,14 @@ addEffects_fn = function() {
|
|
|
672
670
|
this.store.subscribe(
|
|
673
671
|
({ connector }) => connector,
|
|
674
672
|
(connector, prevConnector) => {
|
|
675
|
-
prevConnector
|
|
676
|
-
prevConnector
|
|
677
|
-
prevConnector
|
|
673
|
+
_optionalChain([prevConnector, 'optionalAccess', _49 => _49.off, 'optionalCall', _50 => _50("change", onChange)]);
|
|
674
|
+
_optionalChain([prevConnector, 'optionalAccess', _51 => _51.off, 'optionalCall', _52 => _52("disconnect", onDisconnect)]);
|
|
675
|
+
_optionalChain([prevConnector, 'optionalAccess', _53 => _53.off, 'optionalCall', _54 => _54("error", onError)]);
|
|
678
676
|
if (!connector)
|
|
679
677
|
return;
|
|
680
|
-
connector.on
|
|
681
|
-
connector.on
|
|
682
|
-
connector.on
|
|
678
|
+
_optionalChain([connector, 'access', _55 => _55.on, 'optionalCall', _56 => _56("change", onChange)]);
|
|
679
|
+
_optionalChain([connector, 'access', _57 => _57.on, 'optionalCall', _58 => _58("disconnect", onDisconnect)]);
|
|
680
|
+
_optionalChain([connector, 'access', _59 => _59.on, 'optionalCall', _60 => _60("error", onError)]);
|
|
683
681
|
}
|
|
684
682
|
);
|
|
685
683
|
const { provider, webSocketProvider } = this.config;
|
|
@@ -687,7 +685,7 @@ addEffects_fn = function() {
|
|
|
687
685
|
const subscribeWebSocketProvider = typeof webSocketProvider === "function";
|
|
688
686
|
if (subscribeProvider || subscribeWebSocketProvider)
|
|
689
687
|
this.store.subscribe(
|
|
690
|
-
({ data }) => data
|
|
688
|
+
({ data }) => _optionalChain([data, 'optionalAccess', _61 => _61.chain, 'optionalAccess', _62 => _62.id]),
|
|
691
689
|
(chainId) => {
|
|
692
690
|
this.setState((x) => ({
|
|
693
691
|
...x,
|
|
@@ -731,7 +729,7 @@ async function connect({
|
|
|
731
729
|
client2.setState((x) => ({
|
|
732
730
|
...x,
|
|
733
731
|
connector,
|
|
734
|
-
chains: connector
|
|
732
|
+
chains: _optionalChain([connector, 'optionalAccess', _63 => _63.chains]),
|
|
735
733
|
data,
|
|
736
734
|
status: "connected"
|
|
737
735
|
}));
|
|
@@ -758,7 +756,7 @@ async function disconnect() {
|
|
|
758
756
|
}
|
|
759
757
|
|
|
760
758
|
// src/actions/accounts/fetchBalance.ts
|
|
761
|
-
|
|
759
|
+
|
|
762
760
|
|
|
763
761
|
// src/constants/abis.ts
|
|
764
762
|
var erc20ABI = [
|
|
@@ -2043,7 +2041,7 @@ var units = [
|
|
|
2043
2041
|
];
|
|
2044
2042
|
|
|
2045
2043
|
// src/actions/contracts/fetchToken.ts
|
|
2046
|
-
|
|
2044
|
+
|
|
2047
2045
|
async function fetchToken({
|
|
2048
2046
|
address,
|
|
2049
2047
|
chainId,
|
|
@@ -2066,7 +2064,7 @@ async function fetchToken({
|
|
|
2066
2064
|
name,
|
|
2067
2065
|
symbol,
|
|
2068
2066
|
totalSupply: {
|
|
2069
|
-
formatted: formatUnits(totalSupply, units2),
|
|
2067
|
+
formatted: _utilsjs.formatUnits.call(void 0, totalSupply, units2),
|
|
2070
2068
|
value: totalSupply
|
|
2071
2069
|
}
|
|
2072
2070
|
};
|
|
@@ -2079,8 +2077,8 @@ async function fetchToken({
|
|
|
2079
2077
|
abi: erc20ABI_bytes32
|
|
2080
2078
|
});
|
|
2081
2079
|
return {
|
|
2082
|
-
name: parseBytes32String(name),
|
|
2083
|
-
symbol: parseBytes32String(symbol),
|
|
2080
|
+
name: _utilsjs.parseBytes32String.call(void 0, name),
|
|
2081
|
+
symbol: _utilsjs.parseBytes32String.call(void 0, symbol),
|
|
2084
2082
|
...rest
|
|
2085
2083
|
};
|
|
2086
2084
|
}
|
|
@@ -2089,13 +2087,13 @@ async function fetchToken({
|
|
|
2089
2087
|
}
|
|
2090
2088
|
|
|
2091
2089
|
// src/actions/contracts/getContract.ts
|
|
2092
|
-
|
|
2090
|
+
|
|
2093
2091
|
function getContract({
|
|
2094
2092
|
address,
|
|
2095
2093
|
abi,
|
|
2096
2094
|
signerOrProvider
|
|
2097
2095
|
}) {
|
|
2098
|
-
return new
|
|
2096
|
+
return new (0, _ethers.Contract)(
|
|
2099
2097
|
address,
|
|
2100
2098
|
abi,
|
|
2101
2099
|
signerOrProvider
|
|
@@ -2112,7 +2110,7 @@ async function prepareWriteContract({
|
|
|
2112
2110
|
signer: signer_,
|
|
2113
2111
|
...config
|
|
2114
2112
|
}) {
|
|
2115
|
-
const signer = signer_
|
|
2113
|
+
const signer = await _asyncNullishCoalesce(signer_, async () => ( await fetchSigner({ chainId })));
|
|
2116
2114
|
if (!signer)
|
|
2117
2115
|
throw new ConnectorNotFoundError();
|
|
2118
2116
|
if (chainId)
|
|
@@ -2134,7 +2132,7 @@ async function prepareWriteContract({
|
|
|
2134
2132
|
address,
|
|
2135
2133
|
functionName: normalizedFunctionName
|
|
2136
2134
|
});
|
|
2137
|
-
const params = [...args
|
|
2135
|
+
const params = [..._nullishCoalesce(args, () => ( [])), ...overrides ? [overrides] : []];
|
|
2138
2136
|
const unsignedTransaction = await populateTransactionFn(
|
|
2139
2137
|
...params
|
|
2140
2138
|
);
|
|
@@ -2208,11 +2206,11 @@ async function multicall({
|
|
|
2208
2206
|
const chain = provider.chains.find((chain2) => chain2.id === chainId) || provider.chains[0];
|
|
2209
2207
|
if (!chain)
|
|
2210
2208
|
throw new ProviderChainsNotFound();
|
|
2211
|
-
if (!chain
|
|
2209
|
+
if (!_optionalChain([chain, 'optionalAccess', _64 => _64.contracts, 'optionalAccess', _65 => _65.multicall3]))
|
|
2212
2210
|
throw new ChainDoesNotSupportMulticallError({ chain });
|
|
2213
|
-
if (typeof overrides
|
|
2211
|
+
if (typeof _optionalChain([overrides, 'optionalAccess', _66 => _66.blockTag]) === "number" && _optionalChain([overrides, 'optionalAccess', _67 => _67.blockTag]) < (_nullishCoalesce(chain.contracts.multicall3.blockCreated, () => ( 0))))
|
|
2214
2212
|
throw new ChainDoesNotSupportMulticallError({
|
|
2215
|
-
blockNumber: overrides
|
|
2213
|
+
blockNumber: _optionalChain([overrides, 'optionalAccess', _68 => _68.blockTag]),
|
|
2216
2214
|
chain
|
|
2217
2215
|
});
|
|
2218
2216
|
const multicallContract = getContract({
|
|
@@ -2224,7 +2222,7 @@ async function multicall({
|
|
|
2224
2222
|
({ address, abi, functionName, ...config }) => {
|
|
2225
2223
|
const { args } = config || {};
|
|
2226
2224
|
const contract = getContract({ address, abi });
|
|
2227
|
-
const params2 = args
|
|
2225
|
+
const params2 = _nullishCoalesce(args, () => ( []));
|
|
2228
2226
|
const normalizedFunctionName = normalizeFunctionName({
|
|
2229
2227
|
contract,
|
|
2230
2228
|
functionName,
|
|
@@ -2354,8 +2352,8 @@ async function readContract({
|
|
|
2354
2352
|
address,
|
|
2355
2353
|
functionName: normalizedFunctionName
|
|
2356
2354
|
});
|
|
2357
|
-
const params = [...args
|
|
2358
|
-
return contractFunction
|
|
2355
|
+
const params = [..._nullishCoalesce(args, () => ( [])), ...overrides ? [overrides] : []];
|
|
2356
|
+
return _optionalChain([contractFunction, 'optionalCall', _69 => _69(...params)]);
|
|
2359
2357
|
}
|
|
2360
2358
|
|
|
2361
2359
|
// src/actions/contracts/readContracts.ts
|
|
@@ -2367,7 +2365,7 @@ async function readContracts({
|
|
|
2367
2365
|
try {
|
|
2368
2366
|
const provider = getProvider();
|
|
2369
2367
|
const contractsByChainId = contracts.reduce((contracts2, contract, index) => {
|
|
2370
|
-
const chainId = contract.chainId
|
|
2368
|
+
const chainId = _nullishCoalesce(contract.chainId, () => ( provider.network.chainId));
|
|
2371
2369
|
return {
|
|
2372
2370
|
...contracts2,
|
|
2373
2371
|
[chainId]: [...contracts2[chainId] || [], { contract, index }]
|
|
@@ -2419,7 +2417,7 @@ async function readContracts({
|
|
|
2419
2417
|
const error = new ContractMethodRevertedError({
|
|
2420
2418
|
address,
|
|
2421
2419
|
functionName,
|
|
2422
|
-
chainId: chainId
|
|
2420
|
+
chainId: _nullishCoalesce(chainId, () => ( 1)),
|
|
2423
2421
|
args,
|
|
2424
2422
|
errorMessage: result.reason
|
|
2425
2423
|
});
|
|
@@ -2431,7 +2429,7 @@ async function readContracts({
|
|
|
2431
2429
|
}
|
|
2432
2430
|
|
|
2433
2431
|
// src/actions/contracts/watchContractEvent.ts
|
|
2434
|
-
|
|
2432
|
+
var _shallow = require('zustand/shallow');
|
|
2435
2433
|
function watchContractEvent({
|
|
2436
2434
|
address,
|
|
2437
2435
|
abi,
|
|
@@ -2443,7 +2441,7 @@ function watchContractEvent({
|
|
|
2443
2441
|
let contract;
|
|
2444
2442
|
const watchEvent = async () => {
|
|
2445
2443
|
if (contract)
|
|
2446
|
-
contract
|
|
2444
|
+
_optionalChain([contract, 'optionalAccess', _70 => _70.off, 'call', _71 => _71(eventName, handler)]);
|
|
2447
2445
|
const signerOrProvider = getWebSocketProvider({ chainId }) || getProvider({ chainId });
|
|
2448
2446
|
contract = getContract({
|
|
2449
2447
|
address,
|
|
@@ -2463,16 +2461,16 @@ function watchContractEvent({
|
|
|
2463
2461
|
webSocketProvider
|
|
2464
2462
|
}),
|
|
2465
2463
|
watchEvent,
|
|
2466
|
-
{ equalityFn: shallow }
|
|
2464
|
+
{ equalityFn: _shallow.shallow }
|
|
2467
2465
|
);
|
|
2468
2466
|
return () => {
|
|
2469
|
-
contract
|
|
2467
|
+
_optionalChain([contract, 'optionalAccess', _72 => _72.off, 'call', _73 => _73(eventName, handler)]);
|
|
2470
2468
|
unsubscribe();
|
|
2471
2469
|
};
|
|
2472
2470
|
}
|
|
2473
2471
|
|
|
2474
2472
|
// src/actions/network-status/watchBlockNumber.ts
|
|
2475
|
-
|
|
2473
|
+
|
|
2476
2474
|
|
|
2477
2475
|
// src/actions/network-status/fetchBlockNumber.ts
|
|
2478
2476
|
async function fetchBlockNumber({
|
|
@@ -2489,12 +2487,12 @@ function watchBlockNumber(args, callback) {
|
|
|
2489
2487
|
let previousProvider;
|
|
2490
2488
|
const createListener = (provider) => {
|
|
2491
2489
|
if (previousProvider) {
|
|
2492
|
-
previousProvider
|
|
2490
|
+
_optionalChain([previousProvider, 'optionalAccess', _74 => _74.off, 'call', _75 => _75("block", debouncedCallback)]);
|
|
2493
2491
|
}
|
|
2494
2492
|
provider.on("block", debouncedCallback);
|
|
2495
2493
|
previousProvider = provider;
|
|
2496
2494
|
};
|
|
2497
|
-
const provider_ = getWebSocketProvider({ chainId: args.chainId })
|
|
2495
|
+
const provider_ = _nullishCoalesce(getWebSocketProvider({ chainId: args.chainId }), () => ( getProvider({ chainId: args.chainId })));
|
|
2498
2496
|
if (args.listen)
|
|
2499
2497
|
createListener(provider_);
|
|
2500
2498
|
let active = true;
|
|
@@ -2502,7 +2500,7 @@ function watchBlockNumber(args, callback) {
|
|
|
2502
2500
|
const unsubscribe = client2.subscribe(
|
|
2503
2501
|
({ provider, webSocketProvider }) => ({ provider, webSocketProvider }),
|
|
2504
2502
|
async ({ provider, webSocketProvider }) => {
|
|
2505
|
-
const provider_2 = webSocketProvider
|
|
2503
|
+
const provider_2 = _nullishCoalesce(webSocketProvider, () => ( provider));
|
|
2506
2504
|
if (args.listen && !args.chainId && provider_2) {
|
|
2507
2505
|
createListener(provider_2);
|
|
2508
2506
|
}
|
|
@@ -2512,14 +2510,14 @@ function watchBlockNumber(args, callback) {
|
|
|
2512
2510
|
callback(blockNumber);
|
|
2513
2511
|
},
|
|
2514
2512
|
{
|
|
2515
|
-
equalityFn:
|
|
2513
|
+
equalityFn: _shallow.shallow
|
|
2516
2514
|
}
|
|
2517
2515
|
);
|
|
2518
2516
|
return () => {
|
|
2519
2517
|
active = false;
|
|
2520
2518
|
unsubscribe();
|
|
2521
|
-
provider_
|
|
2522
|
-
previousProvider
|
|
2519
|
+
_optionalChain([provider_, 'optionalAccess', _76 => _76.off, 'call', _77 => _77("block", debouncedCallback)]);
|
|
2520
|
+
_optionalChain([previousProvider, 'optionalAccess', _78 => _78.off, 'call', _79 => _79("block", debouncedCallback)]);
|
|
2523
2521
|
};
|
|
2524
2522
|
}
|
|
2525
2523
|
|
|
@@ -2531,7 +2529,7 @@ function watchMulticall(config, callback) {
|
|
|
2531
2529
|
const unsubscribe = client2.subscribe(({ provider }) => provider, handleChange);
|
|
2532
2530
|
return () => {
|
|
2533
2531
|
unsubscribe();
|
|
2534
|
-
unwatch
|
|
2532
|
+
_optionalChain([unwatch, 'optionalCall', _80 => _80()]);
|
|
2535
2533
|
};
|
|
2536
2534
|
}
|
|
2537
2535
|
|
|
@@ -2543,7 +2541,7 @@ function watchReadContract(config, callback) {
|
|
|
2543
2541
|
const unsubscribe = client2.subscribe(({ provider }) => provider, handleChange);
|
|
2544
2542
|
return () => {
|
|
2545
2543
|
unsubscribe();
|
|
2546
|
-
unwatch
|
|
2544
|
+
_optionalChain([unwatch, 'optionalCall', _81 => _81()]);
|
|
2547
2545
|
};
|
|
2548
2546
|
}
|
|
2549
2547
|
|
|
@@ -2555,7 +2553,7 @@ function watchReadContracts(config, callback) {
|
|
|
2555
2553
|
const unsubscribe = client2.subscribe(({ provider }) => provider, handleChange);
|
|
2556
2554
|
return () => {
|
|
2557
2555
|
unsubscribe();
|
|
2558
|
-
unwatch
|
|
2556
|
+
_optionalChain([unwatch, 'optionalCall', _82 => _82()]);
|
|
2559
2557
|
};
|
|
2560
2558
|
}
|
|
2561
2559
|
|
|
@@ -2569,10 +2567,10 @@ async function fetchTransaction({
|
|
|
2569
2567
|
}
|
|
2570
2568
|
|
|
2571
2569
|
// src/actions/transactions/prepareSendTransaction.ts
|
|
2572
|
-
|
|
2570
|
+
|
|
2573
2571
|
|
|
2574
2572
|
// src/actions/ens/fetchEnsAddress.ts
|
|
2575
|
-
|
|
2573
|
+
|
|
2576
2574
|
async function fetchEnsAddress({
|
|
2577
2575
|
chainId,
|
|
2578
2576
|
name
|
|
@@ -2580,7 +2578,7 @@ async function fetchEnsAddress({
|
|
|
2580
2578
|
const provider = getProvider({ chainId });
|
|
2581
2579
|
const address = await provider.resolveName(name);
|
|
2582
2580
|
try {
|
|
2583
|
-
return address ? getAddress(address) : null;
|
|
2581
|
+
return address ? _utilsjs.getAddress.call(void 0, address) : null;
|
|
2584
2582
|
} catch (_error) {
|
|
2585
2583
|
return null;
|
|
2586
2584
|
}
|
|
@@ -2597,13 +2595,13 @@ async function fetchEnsAvatar({
|
|
|
2597
2595
|
}
|
|
2598
2596
|
|
|
2599
2597
|
// src/actions/ens/fetchEnsName.ts
|
|
2600
|
-
|
|
2598
|
+
|
|
2601
2599
|
async function fetchEnsName({
|
|
2602
2600
|
address,
|
|
2603
2601
|
chainId
|
|
2604
2602
|
}) {
|
|
2605
2603
|
const provider = getProvider({ chainId });
|
|
2606
|
-
return provider.lookupAddress(
|
|
2604
|
+
return provider.lookupAddress(_utilsjs.getAddress.call(void 0, address));
|
|
2607
2605
|
}
|
|
2608
2606
|
|
|
2609
2607
|
// src/actions/ens/fetchEnsResolver.ts
|
|
@@ -2622,13 +2620,13 @@ async function prepareSendTransaction({
|
|
|
2622
2620
|
request,
|
|
2623
2621
|
signer: signer_
|
|
2624
2622
|
}) {
|
|
2625
|
-
const signer = signer_
|
|
2623
|
+
const signer = await _asyncNullishCoalesce(signer_, async () => ( await fetchSigner({ chainId })));
|
|
2626
2624
|
if (!signer)
|
|
2627
2625
|
throw new ConnectorNotFoundError();
|
|
2628
2626
|
if (chainId)
|
|
2629
2627
|
assertActiveChain({ chainId, signer });
|
|
2630
2628
|
const [to, gasLimit] = await Promise.all([
|
|
2631
|
-
|
|
2629
|
+
_utilsjs.isAddress.call(void 0, request.to) ? Promise.resolve(request.to) : fetchEnsAddress({ name: request.to }),
|
|
2632
2630
|
request.gasLimit ? Promise.resolve(request.gasLimit) : signer.estimateGas(request)
|
|
2633
2631
|
]);
|
|
2634
2632
|
if (!to)
|
|
@@ -2658,8 +2656,8 @@ async function sendTransaction({
|
|
|
2658
2656
|
if (chainId)
|
|
2659
2657
|
assertActiveChain({ chainId, signer });
|
|
2660
2658
|
try {
|
|
2661
|
-
const uncheckedSigner = signer.connectUnchecked
|
|
2662
|
-
const { hash, wait } = await (uncheckedSigner
|
|
2659
|
+
const uncheckedSigner = _optionalChain([signer, 'access', _83 => _83.connectUnchecked, 'optionalCall', _84 => _84()]);
|
|
2660
|
+
const { hash, wait } = await (_nullishCoalesce(uncheckedSigner, () => ( signer))).sendTransaction(
|
|
2663
2661
|
request
|
|
2664
2662
|
);
|
|
2665
2663
|
return { hash, wait };
|
|
@@ -2671,10 +2669,10 @@ async function sendTransaction({
|
|
|
2671
2669
|
}
|
|
2672
2670
|
|
|
2673
2671
|
// src/actions/transactions/waitForTransaction.ts
|
|
2674
|
-
|
|
2672
|
+
|
|
2675
2673
|
|
|
2676
2674
|
// src/actions/network-status/fetchFeeData.ts
|
|
2677
|
-
|
|
2675
|
+
|
|
2678
2676
|
async function fetchFeeData({
|
|
2679
2677
|
chainId,
|
|
2680
2678
|
formatUnits: units2 = "wei"
|
|
@@ -2682,9 +2680,9 @@ async function fetchFeeData({
|
|
|
2682
2680
|
const provider = getProvider({ chainId });
|
|
2683
2681
|
const feeData = await provider.getFeeData();
|
|
2684
2682
|
const formatted = {
|
|
2685
|
-
gasPrice: feeData.gasPrice ?
|
|
2686
|
-
maxFeePerGas: feeData.maxFeePerGas ?
|
|
2687
|
-
maxPriorityFeePerGas: feeData.maxPriorityFeePerGas ?
|
|
2683
|
+
gasPrice: feeData.gasPrice ? _utilsjs.formatUnits.call(void 0, feeData.gasPrice, units2) : null,
|
|
2684
|
+
maxFeePerGas: feeData.maxFeePerGas ? _utilsjs.formatUnits.call(void 0, feeData.maxFeePerGas, units2) : null,
|
|
2685
|
+
maxPriorityFeePerGas: feeData.maxPriorityFeePerGas ? _utilsjs.formatUnits.call(void 0, feeData.maxPriorityFeePerGas, units2) : null
|
|
2688
2686
|
};
|
|
2689
2687
|
return { ...feeData, formatted };
|
|
2690
2688
|
}
|
|
@@ -2703,7 +2701,7 @@ async function waitForTransaction({
|
|
|
2703
2701
|
fetchTransaction({ hash })
|
|
2704
2702
|
]);
|
|
2705
2703
|
let replaceable = null;
|
|
2706
|
-
if (confirmations !== 0 && transaction
|
|
2704
|
+
if (confirmations !== 0 && _optionalChain([transaction, 'optionalAccess', _85 => _85.to])) {
|
|
2707
2705
|
replaceable = {
|
|
2708
2706
|
data: transaction.data,
|
|
2709
2707
|
from: transaction.from,
|
|
@@ -2722,15 +2720,15 @@ async function waitForTransaction({
|
|
|
2722
2720
|
);
|
|
2723
2721
|
if (receipt.status === 0) {
|
|
2724
2722
|
const code = await provider.call(receipt, receipt.blockNumber);
|
|
2725
|
-
const reason = toUtf8String(`0x${code.substring(138)}`);
|
|
2723
|
+
const reason = _utilsjs.toUtf8String.call(void 0, `0x${code.substring(138)}`);
|
|
2726
2724
|
throw new Error(reason);
|
|
2727
2725
|
}
|
|
2728
2726
|
return receipt;
|
|
2729
2727
|
} catch (err) {
|
|
2730
|
-
if (err
|
|
2731
|
-
onSpeedUp
|
|
2728
|
+
if (_optionalChain([err, 'optionalAccess', _86 => _86.reason]) === "repriced") {
|
|
2729
|
+
_optionalChain([onSpeedUp, 'optionalCall', _87 => _87(err.replacement)]);
|
|
2732
2730
|
return waitForTransaction({
|
|
2733
|
-
hash: err.replacement
|
|
2731
|
+
hash: _optionalChain([err, 'access', _88 => _88.replacement, 'optionalAccess', _89 => _89.hash]),
|
|
2734
2732
|
confirmations,
|
|
2735
2733
|
timeout
|
|
2736
2734
|
});
|
|
@@ -2740,35 +2738,35 @@ async function waitForTransaction({
|
|
|
2740
2738
|
}
|
|
2741
2739
|
|
|
2742
2740
|
// src/actions/transactions/watchPendingTransactions.ts
|
|
2743
|
-
|
|
2741
|
+
|
|
2744
2742
|
function watchPendingTransactions(args, callback) {
|
|
2745
2743
|
let previousProvider;
|
|
2746
2744
|
const createListener = (provider) => {
|
|
2747
2745
|
if (previousProvider) {
|
|
2748
|
-
previousProvider
|
|
2746
|
+
_optionalChain([previousProvider, 'optionalAccess', _90 => _90.off, 'call', _91 => _91("pending", callback)]);
|
|
2749
2747
|
}
|
|
2750
2748
|
provider.on("pending", callback);
|
|
2751
2749
|
previousProvider = provider;
|
|
2752
2750
|
};
|
|
2753
|
-
const provider_ = getWebSocketProvider({ chainId: args.chainId })
|
|
2751
|
+
const provider_ = _nullishCoalesce(getWebSocketProvider({ chainId: args.chainId }), () => ( getProvider({ chainId: args.chainId })));
|
|
2754
2752
|
createListener(provider_);
|
|
2755
2753
|
const client2 = getClient();
|
|
2756
2754
|
const unsubscribe = client2.subscribe(
|
|
2757
2755
|
({ provider, webSocketProvider }) => ({ provider, webSocketProvider }),
|
|
2758
2756
|
async ({ provider, webSocketProvider }) => {
|
|
2759
|
-
const provider_2 = webSocketProvider
|
|
2757
|
+
const provider_2 = _nullishCoalesce(webSocketProvider, () => ( provider));
|
|
2760
2758
|
if (!args.chainId && provider_2) {
|
|
2761
2759
|
createListener(provider_2);
|
|
2762
2760
|
}
|
|
2763
2761
|
},
|
|
2764
2762
|
{
|
|
2765
|
-
equalityFn:
|
|
2763
|
+
equalityFn: _shallow.shallow
|
|
2766
2764
|
}
|
|
2767
2765
|
);
|
|
2768
2766
|
return () => {
|
|
2769
2767
|
unsubscribe();
|
|
2770
|
-
provider_
|
|
2771
|
-
previousProvider
|
|
2768
|
+
_optionalChain([provider_, 'optionalAccess', _92 => _92.off, 'call', _93 => _93("pending", callback)]);
|
|
2769
|
+
_optionalChain([previousProvider, 'optionalAccess', _94 => _94.off, 'call', _95 => _95("pending", callback)]);
|
|
2772
2770
|
};
|
|
2773
2771
|
}
|
|
2774
2772
|
|
|
@@ -2833,7 +2831,7 @@ async function fetchBalance({
|
|
|
2833
2831
|
});
|
|
2834
2832
|
return {
|
|
2835
2833
|
decimals,
|
|
2836
|
-
formatted:
|
|
2834
|
+
formatted: _utilsjs.formatUnits.call(void 0, _nullishCoalesce(value2, () => ( "0")), _nullishCoalesce(unit, () => ( decimals))),
|
|
2837
2835
|
symbol,
|
|
2838
2836
|
value: value2
|
|
2839
2837
|
};
|
|
@@ -2846,20 +2844,20 @@ async function fetchBalance({
|
|
|
2846
2844
|
abi: erc20ABI_bytes32
|
|
2847
2845
|
});
|
|
2848
2846
|
return {
|
|
2849
|
-
symbol:
|
|
2847
|
+
symbol: _utilsjs.parseBytes32String.call(void 0, symbol),
|
|
2850
2848
|
...rest
|
|
2851
2849
|
};
|
|
2852
2850
|
}
|
|
2853
2851
|
throw err;
|
|
2854
2852
|
}
|
|
2855
2853
|
}
|
|
2856
|
-
const chains = [...client2.provider.chains || [], ...client2.chains
|
|
2854
|
+
const chains = [...client2.provider.chains || [], ..._nullishCoalesce(client2.chains, () => ( []))];
|
|
2857
2855
|
const value = await provider.getBalance(address);
|
|
2858
2856
|
const chain = chains.find((x) => x.id === provider.network.chainId);
|
|
2859
2857
|
return {
|
|
2860
|
-
decimals: chain
|
|
2861
|
-
formatted:
|
|
2862
|
-
symbol: chain
|
|
2858
|
+
decimals: _nullishCoalesce(_optionalChain([chain, 'optionalAccess', _96 => _96.nativeCurrency, 'access', _97 => _97.decimals]), () => ( 18)),
|
|
2859
|
+
formatted: _utilsjs.formatUnits.call(void 0, _nullishCoalesce(value, () => ( "0")), _nullishCoalesce(unit, () => ( "ether"))),
|
|
2860
|
+
symbol: _nullishCoalesce(_optionalChain([chain, 'optionalAccess', _98 => _98.nativeCurrency, 'access', _99 => _99.symbol]), () => ( "ETH")),
|
|
2863
2861
|
value
|
|
2864
2862
|
};
|
|
2865
2863
|
}
|
|
@@ -2869,7 +2867,7 @@ async function fetchSigner({
|
|
|
2869
2867
|
chainId
|
|
2870
2868
|
} = {}) {
|
|
2871
2869
|
const client2 = getClient();
|
|
2872
|
-
const signer = await client2.connector
|
|
2870
|
+
const signer = await _optionalChain([client2, 'access', _100 => _100.connector, 'optionalAccess', _101 => _101.getSigner, 'optionalCall', _102 => _102({ chainId })]) || null;
|
|
2873
2871
|
return signer;
|
|
2874
2872
|
}
|
|
2875
2873
|
|
|
@@ -2879,7 +2877,7 @@ function getAccount() {
|
|
|
2879
2877
|
switch (status) {
|
|
2880
2878
|
case "connected":
|
|
2881
2879
|
return {
|
|
2882
|
-
address: data
|
|
2880
|
+
address: _optionalChain([data, 'optionalAccess', _103 => _103.account]),
|
|
2883
2881
|
connector,
|
|
2884
2882
|
isConnected: true,
|
|
2885
2883
|
isConnecting: false,
|
|
@@ -2889,9 +2887,9 @@ function getAccount() {
|
|
|
2889
2887
|
};
|
|
2890
2888
|
case "reconnecting":
|
|
2891
2889
|
return {
|
|
2892
|
-
address: data
|
|
2890
|
+
address: _optionalChain([data, 'optionalAccess', _104 => _104.account]),
|
|
2893
2891
|
connector,
|
|
2894
|
-
isConnected: !!data
|
|
2892
|
+
isConnected: !!_optionalChain([data, 'optionalAccess', _105 => _105.account]),
|
|
2895
2893
|
isConnecting: false,
|
|
2896
2894
|
isDisconnected: false,
|
|
2897
2895
|
isReconnecting: true,
|
|
@@ -2899,7 +2897,7 @@ function getAccount() {
|
|
|
2899
2897
|
};
|
|
2900
2898
|
case "connecting":
|
|
2901
2899
|
return {
|
|
2902
|
-
address: data
|
|
2900
|
+
address: _optionalChain([data, 'optionalAccess', _106 => _106.account]),
|
|
2903
2901
|
connector,
|
|
2904
2902
|
isConnected: false,
|
|
2905
2903
|
isConnecting: true,
|
|
@@ -2923,11 +2921,11 @@ function getAccount() {
|
|
|
2923
2921
|
// src/actions/accounts/getNetwork.ts
|
|
2924
2922
|
function getNetwork() {
|
|
2925
2923
|
const client2 = getClient();
|
|
2926
|
-
const chainId = client2.data
|
|
2927
|
-
const activeChains = client2.chains
|
|
2928
|
-
const activeChain = [...client2.provider.chains || [], ...activeChains].find(
|
|
2924
|
+
const chainId = _optionalChain([client2, 'access', _107 => _107.data, 'optionalAccess', _108 => _108.chain, 'optionalAccess', _109 => _109.id]);
|
|
2925
|
+
const activeChains = _nullishCoalesce(client2.chains, () => ( []));
|
|
2926
|
+
const activeChain = _nullishCoalesce([...client2.provider.chains || [], ...activeChains].find(
|
|
2929
2927
|
(x) => x.id === chainId
|
|
2930
|
-
)
|
|
2928
|
+
), () => ( {
|
|
2931
2929
|
id: chainId,
|
|
2932
2930
|
name: `Chain ${chainId}`,
|
|
2933
2931
|
network: `${chainId}`,
|
|
@@ -2935,11 +2933,11 @@ function getNetwork() {
|
|
|
2935
2933
|
rpcUrls: {
|
|
2936
2934
|
default: { http: [""] }
|
|
2937
2935
|
}
|
|
2938
|
-
};
|
|
2936
|
+
}));
|
|
2939
2937
|
return {
|
|
2940
2938
|
chain: chainId ? {
|
|
2941
2939
|
...activeChain,
|
|
2942
|
-
...client2.data
|
|
2940
|
+
..._optionalChain([client2, 'access', _110 => _110.data, 'optionalAccess', _111 => _111.chain]),
|
|
2943
2941
|
id: chainId
|
|
2944
2942
|
} : void 0,
|
|
2945
2943
|
chains: activeChains
|
|
@@ -3003,41 +3001,41 @@ async function switchNetwork({
|
|
|
3003
3001
|
}
|
|
3004
3002
|
|
|
3005
3003
|
// src/actions/accounts/watchAccount.ts
|
|
3006
|
-
|
|
3004
|
+
|
|
3007
3005
|
function watchAccount(callback, { selector = (x) => x } = {}) {
|
|
3008
3006
|
const client2 = getClient();
|
|
3009
3007
|
const handleChange = () => callback(getAccount());
|
|
3010
3008
|
const unsubscribe = client2.subscribe(
|
|
3011
3009
|
({ data, connector, status }) => selector({
|
|
3012
|
-
address: data
|
|
3010
|
+
address: _optionalChain([data, 'optionalAccess', _112 => _112.account]),
|
|
3013
3011
|
connector,
|
|
3014
3012
|
status
|
|
3015
3013
|
}),
|
|
3016
3014
|
handleChange,
|
|
3017
3015
|
{
|
|
3018
|
-
equalityFn:
|
|
3016
|
+
equalityFn: _shallow.shallow
|
|
3019
3017
|
}
|
|
3020
3018
|
);
|
|
3021
3019
|
return unsubscribe;
|
|
3022
3020
|
}
|
|
3023
3021
|
|
|
3024
3022
|
// src/actions/accounts/watchNetwork.ts
|
|
3025
|
-
|
|
3023
|
+
|
|
3026
3024
|
function watchNetwork(callback, { selector = (x) => x } = {}) {
|
|
3027
3025
|
const client2 = getClient();
|
|
3028
3026
|
const handleChange = () => callback(getNetwork());
|
|
3029
3027
|
const unsubscribe = client2.subscribe(
|
|
3030
|
-
({ data, chains }) => selector({ chainId: data
|
|
3028
|
+
({ data, chains }) => selector({ chainId: _optionalChain([data, 'optionalAccess', _113 => _113.chain, 'optionalAccess', _114 => _114.id]), chains }),
|
|
3031
3029
|
handleChange,
|
|
3032
3030
|
{
|
|
3033
|
-
equalityFn:
|
|
3031
|
+
equalityFn: _shallow.shallow
|
|
3034
3032
|
}
|
|
3035
3033
|
);
|
|
3036
3034
|
return unsubscribe;
|
|
3037
3035
|
}
|
|
3038
3036
|
|
|
3039
3037
|
// src/actions/accounts/watchSigner.ts
|
|
3040
|
-
|
|
3038
|
+
|
|
3041
3039
|
function watchSigner({ chainId }, callback) {
|
|
3042
3040
|
const client2 = getClient();
|
|
3043
3041
|
const handleChange = async () => {
|
|
@@ -3048,13 +3046,13 @@ function watchSigner({ chainId }, callback) {
|
|
|
3048
3046
|
};
|
|
3049
3047
|
const unsubscribe = client2.subscribe(
|
|
3050
3048
|
({ data, connector }) => ({
|
|
3051
|
-
account: data
|
|
3052
|
-
chainId: data
|
|
3049
|
+
account: _optionalChain([data, 'optionalAccess', _115 => _115.account]),
|
|
3050
|
+
chainId: _optionalChain([data, 'optionalAccess', _116 => _116.chain, 'optionalAccess', _117 => _117.id]),
|
|
3053
3051
|
connector
|
|
3054
3052
|
}),
|
|
3055
3053
|
handleChange,
|
|
3056
3054
|
{
|
|
3057
|
-
equalityFn:
|
|
3055
|
+
equalityFn: _shallow.shallow
|
|
3058
3056
|
}
|
|
3059
3057
|
);
|
|
3060
3058
|
return unsubscribe;
|
|
@@ -3140,14 +3138,14 @@ var ContractMethodDoesNotExistError = class extends Error {
|
|
|
3140
3138
|
functionName
|
|
3141
3139
|
}) {
|
|
3142
3140
|
const { chains, network } = getProvider();
|
|
3143
|
-
const chain = chains
|
|
3144
|
-
const blockExplorer = chain
|
|
3141
|
+
const chain = _optionalChain([chains, 'optionalAccess', _118 => _118.find, 'call', _119 => _119(({ id }) => id === (chainId || network.chainId))]);
|
|
3142
|
+
const blockExplorer = _optionalChain([chain, 'optionalAccess', _120 => _120.blockExplorers, 'optionalAccess', _121 => _121.default]);
|
|
3145
3143
|
super(
|
|
3146
3144
|
[
|
|
3147
3145
|
`Function "${functionName}" on contract "${address}" does not exist.`,
|
|
3148
3146
|
...blockExplorer ? [
|
|
3149
3147
|
"",
|
|
3150
|
-
`${blockExplorer
|
|
3148
|
+
`${_optionalChain([blockExplorer, 'optionalAccess', _122 => _122.name])}: ${_optionalChain([blockExplorer, 'optionalAccess', _123 => _123.url])}/address/${address}#readContract`
|
|
3151
3149
|
] : []
|
|
3152
3150
|
].join("\n")
|
|
3153
3151
|
);
|
|
@@ -3294,78 +3292,78 @@ var UserRejectedRequestError = class extends ProviderRpcError {
|
|
|
3294
3292
|
}
|
|
3295
3293
|
};
|
|
3296
3294
|
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3295
|
+
|
|
3296
|
+
|
|
3297
|
+
|
|
3298
|
+
|
|
3299
|
+
|
|
3300
|
+
|
|
3301
|
+
|
|
3302
|
+
|
|
3303
|
+
|
|
3304
|
+
|
|
3305
|
+
|
|
3306
|
+
|
|
3307
|
+
|
|
3308
|
+
|
|
3309
|
+
|
|
3310
|
+
|
|
3311
|
+
|
|
3312
|
+
|
|
3313
|
+
|
|
3314
|
+
|
|
3315
|
+
|
|
3316
|
+
|
|
3317
|
+
|
|
3318
|
+
|
|
3319
|
+
|
|
3320
|
+
|
|
3321
|
+
|
|
3322
|
+
|
|
3323
|
+
|
|
3324
|
+
|
|
3325
|
+
|
|
3326
|
+
|
|
3327
|
+
|
|
3328
|
+
|
|
3329
|
+
|
|
3330
|
+
|
|
3331
|
+
|
|
3332
|
+
|
|
3333
|
+
|
|
3334
|
+
|
|
3335
|
+
|
|
3336
|
+
|
|
3337
|
+
|
|
3338
|
+
|
|
3339
|
+
|
|
3340
|
+
|
|
3341
|
+
|
|
3342
|
+
|
|
3343
|
+
|
|
3344
|
+
|
|
3345
|
+
|
|
3346
|
+
|
|
3347
|
+
|
|
3348
|
+
|
|
3349
|
+
|
|
3350
|
+
|
|
3351
|
+
|
|
3352
|
+
|
|
3353
|
+
|
|
3354
|
+
|
|
3355
|
+
|
|
3356
|
+
|
|
3357
|
+
|
|
3358
|
+
|
|
3359
|
+
|
|
3360
|
+
|
|
3361
|
+
|
|
3362
|
+
|
|
3363
|
+
|
|
3364
|
+
|
|
3365
|
+
|
|
3366
|
+
|
|
3367
|
+
|
|
3368
|
+
|
|
3369
|
+
exports.configureChains = configureChains; exports.RpcError = RpcError; exports.ProviderRpcError = ProviderRpcError; exports.AddChainError = AddChainError; exports.ChainDoesNotSupportMulticallError = ChainDoesNotSupportMulticallError; exports.ChainMismatchError = ChainMismatchError; exports.ChainNotConfiguredError = ChainNotConfiguredError; exports.ConnectorAlreadyConnectedError = ConnectorAlreadyConnectedError; exports.ConnectorNotFoundError = ConnectorNotFoundError; exports.ContractMethodDoesNotExistError = ContractMethodDoesNotExistError; exports.ContractMethodNoResultError = ContractMethodNoResultError; exports.ContractMethodRevertedError = ContractMethodRevertedError; exports.ContractResultDecodeError = ContractResultDecodeError; exports.ProviderChainsNotFound = ProviderChainsNotFound; exports.ResourceUnavailableError = ResourceUnavailableError; exports.SwitchChainError = SwitchChainError; exports.SwitchChainNotSupportedError = SwitchChainNotSupportedError; exports.UserRejectedRequestError = UserRejectedRequestError; exports.debounce = debounce; exports.deepEqual = deepEqual; exports.deserialize = deserialize; exports.minimizeContractInterface = minimizeContractInterface; exports.normalizeChainId = normalizeChainId; exports.parseContractResult = parseContractResult; exports.serialize = serialize; exports.noopStorage = noopStorage; exports.createStorage = createStorage; exports.Client = Client; exports.createClient = createClient; exports.getClient = getClient; exports.connect = connect; exports.disconnect = disconnect; exports.erc20ABI = erc20ABI; exports.erc721ABI = erc721ABI; exports.erc4626ABI = erc4626ABI; exports.units = units; exports.fetchToken = fetchToken; exports.getContract = getContract; exports.prepareWriteContract = prepareWriteContract; exports.getProvider = getProvider; exports.getWebSocketProvider = getWebSocketProvider; exports.watchProvider = watchProvider; exports.watchWebSocketProvider = watchWebSocketProvider; exports.multicall = multicall; exports.readContract = readContract; exports.readContracts = readContracts; exports.watchContractEvent = watchContractEvent; exports.fetchBlockNumber = fetchBlockNumber; exports.watchBlockNumber = watchBlockNumber; exports.watchMulticall = watchMulticall; exports.watchReadContract = watchReadContract; exports.watchReadContracts = watchReadContracts; exports.fetchTransaction = fetchTransaction; exports.fetchEnsAddress = fetchEnsAddress; exports.fetchEnsAvatar = fetchEnsAvatar; exports.fetchEnsName = fetchEnsName; exports.fetchEnsResolver = fetchEnsResolver; exports.prepareSendTransaction = prepareSendTransaction; exports.sendTransaction = sendTransaction; exports.fetchFeeData = fetchFeeData; exports.waitForTransaction = waitForTransaction; exports.watchPendingTransactions = watchPendingTransactions; exports.writeContract = writeContract; exports.fetchBalance = fetchBalance; exports.fetchSigner = fetchSigner; exports.getAccount = getAccount; exports.getNetwork = getNetwork; exports.signMessage = signMessage; exports.signTypedData = signTypedData; exports.switchNetwork = switchNetwork; exports.watchAccount = watchAccount; exports.watchNetwork = watchNetwork; exports.watchSigner = watchSigner;
|