@wagmi/core 1.4.10-cjs → 1.4.10
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 +2 -2
- package/dist/chunk-4E64EZ7V.js +6 -6
- package/dist/chunk-BVC4KGLQ.js +8 -8
- package/dist/chunk-EQOEZP46.js +5 -5
- package/dist/chunk-KFW652VN.js +6 -6
- package/dist/chunk-MQXBDTVK.js +7 -7
- package/dist/chunk-TSH6VVF4.js +228 -228
- 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/safe.js +5 -5
- package/dist/connectors/walletConnect.js +5 -5
- package/dist/connectors/walletConnectLegacy.js +5 -5
- package/dist/index.js +135 -135
- package/dist/internal/index.js +10 -10
- package/dist/internal/test.js +32 -32
- package/dist/providers/alchemy.js +6 -6
- package/dist/providers/infura.js +6 -6
- package/dist/providers/jsonRpc.js +4 -4
- package/dist/providers/public.js +4 -4
- package/dist/window.js +0 -1
- package/package.json +3 -2
package/dist/chunk-TSH6VVF4.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import {
|
|
2
|
+
InjectedConnector
|
|
3
|
+
} from "./chunk-BVC4KGLQ.js";
|
|
4
|
+
import {
|
|
5
|
+
__privateAdd,
|
|
6
|
+
__privateGet,
|
|
7
|
+
__privateMethod,
|
|
8
|
+
__privateSet
|
|
9
|
+
} from "./chunk-MQXBDTVK.js";
|
|
10
10
|
|
|
11
11
|
// src/utils/configureChains.ts
|
|
12
|
-
|
|
12
|
+
import { createPublicClient, fallback, http, webSocket } from "viem";
|
|
13
13
|
function configureChains(defaultChains, providers, {
|
|
14
14
|
batch = { multicall: { wait: 32 } },
|
|
15
15
|
pollingInterval = 4e3,
|
|
@@ -58,15 +58,15 @@ function configureChains(defaultChains, providers, {
|
|
|
58
58
|
return {
|
|
59
59
|
chains,
|
|
60
60
|
publicClient: ({ chainId }) => {
|
|
61
|
-
const activeChain =
|
|
61
|
+
const activeChain = chains.find((x) => x.id === chainId) ?? defaultChains[0];
|
|
62
62
|
const chainHttpUrls = httpUrls[activeChain.id];
|
|
63
63
|
if (!chainHttpUrls || !chainHttpUrls[0])
|
|
64
64
|
throw new Error(`No providers configured for chain "${activeChain.id}"`);
|
|
65
|
-
const publicClient =
|
|
65
|
+
const publicClient = createPublicClient({
|
|
66
66
|
batch,
|
|
67
67
|
chain: activeChain,
|
|
68
|
-
transport:
|
|
69
|
-
chainHttpUrls.map((url) =>
|
|
68
|
+
transport: fallback(
|
|
69
|
+
chainHttpUrls.map((url) => http(url, { timeout: stallTimeout })),
|
|
70
70
|
{ rank, retryCount, retryDelay }
|
|
71
71
|
),
|
|
72
72
|
pollingInterval
|
|
@@ -76,15 +76,15 @@ function configureChains(defaultChains, providers, {
|
|
|
76
76
|
});
|
|
77
77
|
},
|
|
78
78
|
webSocketPublicClient: ({ chainId }) => {
|
|
79
|
-
const activeChain =
|
|
79
|
+
const activeChain = chains.find((x) => x.id === chainId) ?? defaultChains[0];
|
|
80
80
|
const chainWsUrls = wsUrls[activeChain.id];
|
|
81
81
|
if (!chainWsUrls || !chainWsUrls[0])
|
|
82
82
|
return void 0;
|
|
83
|
-
const publicClient =
|
|
83
|
+
const publicClient = createPublicClient({
|
|
84
84
|
batch,
|
|
85
85
|
chain: activeChain,
|
|
86
|
-
transport:
|
|
87
|
-
chainWsUrls.map((url) =>
|
|
86
|
+
transport: fallback(
|
|
87
|
+
chainWsUrls.map((url) => webSocket(url, { timeout: stallTimeout })),
|
|
88
88
|
{ rank, retryCount, retryDelay }
|
|
89
89
|
),
|
|
90
90
|
pollingInterval
|
|
@@ -97,7 +97,7 @@ function configureChains(defaultChains, providers, {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
// src/errors.ts
|
|
100
|
-
|
|
100
|
+
import { ConnectorNotFoundError } from "@wagmi/connectors";
|
|
101
101
|
var ChainMismatchError = class extends Error {
|
|
102
102
|
constructor({
|
|
103
103
|
activeChain,
|
|
@@ -247,13 +247,13 @@ function getSendTransactionParameters(args) {
|
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
// src/utils/getUnit.ts
|
|
250
|
-
|
|
250
|
+
import { weiUnits } from "viem";
|
|
251
251
|
function getUnit(unit) {
|
|
252
252
|
if (typeof unit === "number")
|
|
253
253
|
return unit;
|
|
254
254
|
if (unit === "wei")
|
|
255
255
|
return 0;
|
|
256
|
-
return Math.abs(
|
|
256
|
+
return Math.abs(weiUnits[unit]);
|
|
257
257
|
}
|
|
258
258
|
|
|
259
259
|
// src/utils/serialize.ts
|
|
@@ -307,15 +307,15 @@ function serialize(value, replacer, indent, circularReplacer) {
|
|
|
307
307
|
value,
|
|
308
308
|
createReplacer((key, value_) => {
|
|
309
309
|
const value2 = typeof value_ === "bigint" ? `#bigint.${value_.toString()}` : value_;
|
|
310
|
-
return
|
|
310
|
+
return replacer?.(key, value2) || value2;
|
|
311
311
|
}, circularReplacer),
|
|
312
|
-
|
|
312
|
+
indent ?? void 0
|
|
313
313
|
);
|
|
314
314
|
}
|
|
315
315
|
|
|
316
316
|
// src/config.ts
|
|
317
|
-
|
|
318
|
-
|
|
317
|
+
import { persist, subscribeWithSelector } from "zustand/middleware";
|
|
318
|
+
import { createStore } from "zustand/vanilla";
|
|
319
319
|
|
|
320
320
|
// src/storage.ts
|
|
321
321
|
var noopStorage = {
|
|
@@ -361,7 +361,7 @@ var _isAutoConnecting, _lastUsedConnector, _addEffects, addEffects_fn;
|
|
|
361
361
|
var Config = class {
|
|
362
362
|
constructor({
|
|
363
363
|
autoConnect = false,
|
|
364
|
-
connectors = [new
|
|
364
|
+
connectors = [new InjectedConnector()],
|
|
365
365
|
publicClient,
|
|
366
366
|
storage = createStorage({
|
|
367
367
|
storage: typeof window !== "undefined" ? window.localStorage : noopStorage
|
|
@@ -371,11 +371,11 @@ var Config = class {
|
|
|
371
371
|
},
|
|
372
372
|
webSocketPublicClient
|
|
373
373
|
}) {
|
|
374
|
-
|
|
374
|
+
__privateAdd(this, _addEffects);
|
|
375
375
|
this.publicClients = /* @__PURE__ */ new Map();
|
|
376
376
|
this.webSocketPublicClients = /* @__PURE__ */ new Map();
|
|
377
|
-
|
|
378
|
-
|
|
377
|
+
__privateAdd(this, _isAutoConnecting, void 0);
|
|
378
|
+
__privateAdd(this, _lastUsedConnector, void 0);
|
|
379
379
|
this.args = {
|
|
380
380
|
autoConnect,
|
|
381
381
|
connectors,
|
|
@@ -389,17 +389,17 @@ var Config = class {
|
|
|
389
389
|
if (autoConnect) {
|
|
390
390
|
try {
|
|
391
391
|
const rawState = storage.getItem(storeKey);
|
|
392
|
-
const data =
|
|
393
|
-
status =
|
|
394
|
-
chainId =
|
|
392
|
+
const data = rawState?.state?.data;
|
|
393
|
+
status = data?.account ? "reconnecting" : "connecting";
|
|
394
|
+
chainId = data?.chain?.id;
|
|
395
395
|
} catch (_error) {
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
398
|
const connectors_ = typeof connectors === "function" ? connectors() : connectors;
|
|
399
399
|
connectors_.forEach((connector) => connector.setStorage(storage));
|
|
400
|
-
this.store =
|
|
401
|
-
|
|
402
|
-
|
|
400
|
+
this.store = createStore(
|
|
401
|
+
subscribeWithSelector(
|
|
402
|
+
persist(
|
|
403
403
|
() => ({
|
|
404
404
|
connectors: connectors_,
|
|
405
405
|
publicClient: this.getPublicClient({ chainId }),
|
|
@@ -412,11 +412,11 @@ var Config = class {
|
|
|
412
412
|
partialize: (state) => ({
|
|
413
413
|
...autoConnect && {
|
|
414
414
|
data: {
|
|
415
|
-
account:
|
|
416
|
-
chain:
|
|
415
|
+
account: state?.data?.account,
|
|
416
|
+
chain: state?.data?.chain
|
|
417
417
|
}
|
|
418
418
|
},
|
|
419
|
-
chains:
|
|
419
|
+
chains: state?.chains
|
|
420
420
|
}),
|
|
421
421
|
version: 2
|
|
422
422
|
}
|
|
@@ -424,8 +424,8 @@ var Config = class {
|
|
|
424
424
|
)
|
|
425
425
|
);
|
|
426
426
|
this.storage = storage;
|
|
427
|
-
|
|
428
|
-
|
|
427
|
+
__privateSet(this, _lastUsedConnector, storage?.getItem("wallet"));
|
|
428
|
+
__privateMethod(this, _addEffects, addEffects_fn).call(this);
|
|
429
429
|
if (autoConnect && typeof window !== "undefined")
|
|
430
430
|
setTimeout(async () => await this.autoConnect(), 0);
|
|
431
431
|
}
|
|
@@ -445,7 +445,7 @@ var Config = class {
|
|
|
445
445
|
return this.store.getState().error;
|
|
446
446
|
}
|
|
447
447
|
get lastUsedChainId() {
|
|
448
|
-
return
|
|
448
|
+
return this.data?.chain?.id;
|
|
449
449
|
}
|
|
450
450
|
get publicClient() {
|
|
451
451
|
return this.store.getState().publicClient;
|
|
@@ -475,21 +475,21 @@ var Config = class {
|
|
|
475
475
|
}
|
|
476
476
|
async destroy() {
|
|
477
477
|
if (this.connector)
|
|
478
|
-
await
|
|
479
|
-
|
|
478
|
+
await this.connector.disconnect?.();
|
|
479
|
+
__privateSet(this, _isAutoConnecting, false);
|
|
480
480
|
this.clearState();
|
|
481
481
|
this.store.destroy();
|
|
482
482
|
}
|
|
483
483
|
async autoConnect() {
|
|
484
|
-
if (
|
|
484
|
+
if (__privateGet(this, _isAutoConnecting))
|
|
485
485
|
return;
|
|
486
|
-
|
|
486
|
+
__privateSet(this, _isAutoConnecting, true);
|
|
487
487
|
this.setState((x) => ({
|
|
488
488
|
...x,
|
|
489
|
-
status:
|
|
489
|
+
status: x.data?.account ? "reconnecting" : "connecting"
|
|
490
490
|
}));
|
|
491
|
-
const sorted =
|
|
492
|
-
(x) => x.id ===
|
|
491
|
+
const sorted = __privateGet(this, _lastUsedConnector) ? [...this.connectors].sort(
|
|
492
|
+
(x) => x.id === __privateGet(this, _lastUsedConnector) ? -1 : 1
|
|
493
493
|
) : this.connectors;
|
|
494
494
|
let connected = false;
|
|
495
495
|
for (const connector of sorted) {
|
|
@@ -502,7 +502,7 @@ var Config = class {
|
|
|
502
502
|
this.setState((x) => ({
|
|
503
503
|
...x,
|
|
504
504
|
connector,
|
|
505
|
-
chains:
|
|
505
|
+
chains: connector?.chains,
|
|
506
506
|
data,
|
|
507
507
|
status: "connected"
|
|
508
508
|
}));
|
|
@@ -515,7 +515,7 @@ var Config = class {
|
|
|
515
515
|
data: void 0,
|
|
516
516
|
status: "disconnected"
|
|
517
517
|
}));
|
|
518
|
-
|
|
518
|
+
__privateSet(this, _isAutoConnecting, false);
|
|
519
519
|
return this.data;
|
|
520
520
|
}
|
|
521
521
|
setConnectors(connectors) {
|
|
@@ -532,18 +532,18 @@ var Config = class {
|
|
|
532
532
|
}
|
|
533
533
|
getPublicClient({ chainId } = {}) {
|
|
534
534
|
let publicClient_ = this.publicClients.get(-1);
|
|
535
|
-
if (publicClient_ &&
|
|
535
|
+
if (publicClient_ && publicClient_?.chain.id === chainId)
|
|
536
536
|
return publicClient_;
|
|
537
|
-
publicClient_ = this.publicClients.get(
|
|
537
|
+
publicClient_ = this.publicClients.get(chainId ?? -1);
|
|
538
538
|
if (publicClient_)
|
|
539
539
|
return publicClient_;
|
|
540
540
|
const { publicClient } = this.args;
|
|
541
541
|
publicClient_ = typeof publicClient === "function" ? publicClient({ chainId }) : publicClient;
|
|
542
|
-
this.publicClients.set(
|
|
542
|
+
this.publicClients.set(chainId ?? -1, publicClient_);
|
|
543
543
|
return publicClient_;
|
|
544
544
|
}
|
|
545
545
|
setPublicClient(publicClient) {
|
|
546
|
-
const chainId =
|
|
546
|
+
const chainId = this.data?.chain?.id;
|
|
547
547
|
this.args = {
|
|
548
548
|
...this.args,
|
|
549
549
|
publicClient
|
|
@@ -556,19 +556,19 @@ var Config = class {
|
|
|
556
556
|
}
|
|
557
557
|
getWebSocketPublicClient({ chainId } = {}) {
|
|
558
558
|
let webSocketPublicClient_ = this.webSocketPublicClients.get(-1);
|
|
559
|
-
if (webSocketPublicClient_ &&
|
|
559
|
+
if (webSocketPublicClient_ && webSocketPublicClient_?.chain.id === chainId)
|
|
560
560
|
return webSocketPublicClient_;
|
|
561
|
-
webSocketPublicClient_ = this.webSocketPublicClients.get(
|
|
561
|
+
webSocketPublicClient_ = this.webSocketPublicClients.get(chainId ?? -1);
|
|
562
562
|
if (webSocketPublicClient_)
|
|
563
563
|
return webSocketPublicClient_;
|
|
564
564
|
const { webSocketPublicClient } = this.args;
|
|
565
565
|
webSocketPublicClient_ = typeof webSocketPublicClient === "function" ? webSocketPublicClient({ chainId }) : webSocketPublicClient;
|
|
566
566
|
if (webSocketPublicClient_)
|
|
567
|
-
this.webSocketPublicClients.set(
|
|
567
|
+
this.webSocketPublicClients.set(chainId ?? -1, webSocketPublicClient_);
|
|
568
568
|
return webSocketPublicClient_;
|
|
569
569
|
}
|
|
570
570
|
setWebSocketPublicClient(webSocketPublicClient) {
|
|
571
|
-
const chainId =
|
|
571
|
+
const chainId = this.data?.chain?.id;
|
|
572
572
|
this.args = {
|
|
573
573
|
...this.args,
|
|
574
574
|
webSocketPublicClient
|
|
@@ -582,7 +582,7 @@ var Config = class {
|
|
|
582
582
|
}));
|
|
583
583
|
}
|
|
584
584
|
setLastUsedConnector(lastUsedConnector = null) {
|
|
585
|
-
|
|
585
|
+
this.storage?.setItem("wallet", lastUsedConnector);
|
|
586
586
|
}
|
|
587
587
|
};
|
|
588
588
|
_isAutoConnecting = new WeakMap();
|
|
@@ -604,14 +604,14 @@ addEffects_fn = function() {
|
|
|
604
604
|
this.store.subscribe(
|
|
605
605
|
({ connector }) => connector,
|
|
606
606
|
(connector, prevConnector) => {
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
607
|
+
prevConnector?.off?.("change", onChange);
|
|
608
|
+
prevConnector?.off?.("disconnect", onDisconnect);
|
|
609
|
+
prevConnector?.off?.("error", onError);
|
|
610
610
|
if (!connector)
|
|
611
611
|
return;
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
612
|
+
connector.on?.("change", onChange);
|
|
613
|
+
connector.on?.("disconnect", onDisconnect);
|
|
614
|
+
connector.on?.("error", onError);
|
|
615
615
|
}
|
|
616
616
|
);
|
|
617
617
|
const { publicClient, webSocketPublicClient } = this.args;
|
|
@@ -619,7 +619,7 @@ addEffects_fn = function() {
|
|
|
619
619
|
const subscribeWebSocketPublicClient = typeof webSocketPublicClient === "function";
|
|
620
620
|
if (subscribePublicClient || subscribeWebSocketPublicClient)
|
|
621
621
|
this.store.subscribe(
|
|
622
|
-
({ data }) =>
|
|
622
|
+
({ data }) => data?.chain?.id,
|
|
623
623
|
(chainId) => {
|
|
624
624
|
this.setState((x) => ({
|
|
625
625
|
...x,
|
|
@@ -659,7 +659,7 @@ async function connect({ chainId, connector }) {
|
|
|
659
659
|
config2.setState((x) => ({
|
|
660
660
|
...x,
|
|
661
661
|
connector,
|
|
662
|
-
chains:
|
|
662
|
+
chains: connector?.chains,
|
|
663
663
|
data,
|
|
664
664
|
status: "connected"
|
|
665
665
|
}));
|
|
@@ -686,12 +686,12 @@ async function disconnect() {
|
|
|
686
686
|
}
|
|
687
687
|
|
|
688
688
|
// src/actions/accounts/fetchBalance.ts
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
689
|
+
import {
|
|
690
|
+
ContractFunctionExecutionError as ContractFunctionExecutionError3,
|
|
691
|
+
formatUnits as formatUnits2,
|
|
692
|
+
hexToString as hexToString2,
|
|
693
|
+
trim as trim2
|
|
694
|
+
} from "viem";
|
|
695
695
|
|
|
696
696
|
// src/constants/abis.ts
|
|
697
697
|
var erc20ABI = [
|
|
@@ -1922,12 +1922,12 @@ var erc4626ABI = [
|
|
|
1922
1922
|
];
|
|
1923
1923
|
|
|
1924
1924
|
// src/actions/contracts/fetchToken.ts
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1925
|
+
import {
|
|
1926
|
+
ContractFunctionExecutionError,
|
|
1927
|
+
formatUnits,
|
|
1928
|
+
hexToString,
|
|
1929
|
+
trim
|
|
1930
|
+
} from "viem";
|
|
1931
1931
|
async function fetchToken({
|
|
1932
1932
|
address,
|
|
1933
1933
|
chainId,
|
|
@@ -1950,7 +1950,7 @@ async function fetchToken({
|
|
|
1950
1950
|
name,
|
|
1951
1951
|
symbol,
|
|
1952
1952
|
totalSupply: {
|
|
1953
|
-
formatted:
|
|
1953
|
+
formatted: formatUnits(totalSupply, getUnit(unit)),
|
|
1954
1954
|
value: totalSupply
|
|
1955
1955
|
}
|
|
1956
1956
|
};
|
|
@@ -1958,13 +1958,13 @@ async function fetchToken({
|
|
|
1958
1958
|
try {
|
|
1959
1959
|
return await fetchToken_({ abi: erc20ABI });
|
|
1960
1960
|
} catch (err) {
|
|
1961
|
-
if (err instanceof
|
|
1961
|
+
if (err instanceof ContractFunctionExecutionError) {
|
|
1962
1962
|
const { name, symbol, ...rest } = await fetchToken_({
|
|
1963
1963
|
abi: erc20ABI_bytes32
|
|
1964
1964
|
});
|
|
1965
1965
|
return {
|
|
1966
|
-
name:
|
|
1967
|
-
symbol:
|
|
1966
|
+
name: hexToString(trim(name, { dir: "right" })),
|
|
1967
|
+
symbol: hexToString(trim(symbol, { dir: "right" })),
|
|
1968
1968
|
...rest
|
|
1969
1969
|
};
|
|
1970
1970
|
}
|
|
@@ -1985,7 +1985,7 @@ async function getWalletClient({
|
|
|
1985
1985
|
chainId
|
|
1986
1986
|
} = {}) {
|
|
1987
1987
|
const config2 = getConfig();
|
|
1988
|
-
const walletClient = await
|
|
1988
|
+
const walletClient = await config2.connector?.getWalletClient?.({ chainId }) || null;
|
|
1989
1989
|
return walletClient;
|
|
1990
1990
|
}
|
|
1991
1991
|
|
|
@@ -2011,7 +2011,7 @@ function watchPublicClient(args, callback) {
|
|
|
2011
2011
|
}
|
|
2012
2012
|
|
|
2013
2013
|
// src/actions/viem/watchWalletClient.ts
|
|
2014
|
-
|
|
2014
|
+
import { shallow } from "zustand/shallow";
|
|
2015
2015
|
function watchWalletClient({ chainId }, callback) {
|
|
2016
2016
|
const config2 = getConfig();
|
|
2017
2017
|
const handleChange = async ({ chainId: chainId_ }) => {
|
|
@@ -2024,13 +2024,13 @@ function watchWalletClient({ chainId }, callback) {
|
|
|
2024
2024
|
};
|
|
2025
2025
|
const unsubscribe = config2.subscribe(
|
|
2026
2026
|
({ data, connector }) => ({
|
|
2027
|
-
account:
|
|
2028
|
-
chainId:
|
|
2027
|
+
account: data?.account,
|
|
2028
|
+
chainId: data?.chain?.id,
|
|
2029
2029
|
connector
|
|
2030
2030
|
}),
|
|
2031
2031
|
handleChange,
|
|
2032
2032
|
{
|
|
2033
|
-
equalityFn:
|
|
2033
|
+
equalityFn: shallow
|
|
2034
2034
|
}
|
|
2035
2035
|
);
|
|
2036
2036
|
return unsubscribe;
|
|
@@ -2059,9 +2059,9 @@ async function prepareWriteContract({
|
|
|
2059
2059
|
...config2
|
|
2060
2060
|
}) {
|
|
2061
2061
|
const publicClient = getPublicClient({ chainId });
|
|
2062
|
-
const walletClient =
|
|
2062
|
+
const walletClient = walletClient_ ?? await getWalletClient({ chainId });
|
|
2063
2063
|
if (!walletClient)
|
|
2064
|
-
throw new
|
|
2064
|
+
throw new ConnectorNotFoundError();
|
|
2065
2065
|
if (chainId)
|
|
2066
2066
|
assertActiveChain({ chainId });
|
|
2067
2067
|
const {
|
|
@@ -2108,7 +2108,7 @@ async function prepareWriteContract({
|
|
|
2108
2108
|
}
|
|
2109
2109
|
|
|
2110
2110
|
// src/actions/contracts/getContract.ts
|
|
2111
|
-
|
|
2111
|
+
import { getContract as getContract_ } from "viem";
|
|
2112
2112
|
function getContract({
|
|
2113
2113
|
address,
|
|
2114
2114
|
abi,
|
|
@@ -2116,7 +2116,7 @@ function getContract({
|
|
|
2116
2116
|
walletClient
|
|
2117
2117
|
}) {
|
|
2118
2118
|
const publicClient = getPublicClient({ chainId });
|
|
2119
|
-
return
|
|
2119
|
+
return getContract_({
|
|
2120
2120
|
address,
|
|
2121
2121
|
abi,
|
|
2122
2122
|
publicClient,
|
|
@@ -2138,7 +2138,7 @@ async function multicall({
|
|
|
2138
2138
|
if (chainId && publicClient.chain.id !== chainId)
|
|
2139
2139
|
throw new ChainNotConfiguredError({ chainId });
|
|
2140
2140
|
return publicClient.multicall({
|
|
2141
|
-
allowFailure:
|
|
2141
|
+
allowFailure: args.allowFailure ?? true,
|
|
2142
2142
|
blockNumber,
|
|
2143
2143
|
blockTag,
|
|
2144
2144
|
contracts
|
|
@@ -2169,7 +2169,7 @@ async function readContract({
|
|
|
2169
2169
|
}
|
|
2170
2170
|
|
|
2171
2171
|
// src/actions/contracts/readContracts.ts
|
|
2172
|
-
|
|
2172
|
+
import { ContractFunctionExecutionError as ContractFunctionExecutionError2 } from "viem";
|
|
2173
2173
|
async function readContracts({
|
|
2174
2174
|
contracts,
|
|
2175
2175
|
blockNumber,
|
|
@@ -2180,7 +2180,7 @@ async function readContracts({
|
|
|
2180
2180
|
try {
|
|
2181
2181
|
const publicClient = getPublicClient();
|
|
2182
2182
|
const contractsByChainId = contracts.reduce((contracts2, contract, index) => {
|
|
2183
|
-
const chainId =
|
|
2183
|
+
const chainId = contract.chainId ?? publicClient.chain.id;
|
|
2184
2184
|
return {
|
|
2185
2185
|
...contracts2,
|
|
2186
2186
|
[chainId]: [...contracts2[chainId] || [], { contract, index }]
|
|
@@ -2207,7 +2207,7 @@ async function readContracts({
|
|
|
2207
2207
|
return results;
|
|
2208
2208
|
}, []);
|
|
2209
2209
|
} catch (err) {
|
|
2210
|
-
if (err instanceof
|
|
2210
|
+
if (err instanceof ContractFunctionExecutionError2)
|
|
2211
2211
|
throw err;
|
|
2212
2212
|
const promises = () => contracts.map(
|
|
2213
2213
|
(contract) => readContract({ ...contract, blockNumber, blockTag })
|
|
@@ -2223,7 +2223,7 @@ async function readContracts({
|
|
|
2223
2223
|
}
|
|
2224
2224
|
|
|
2225
2225
|
// src/actions/contracts/watchContractEvent.ts
|
|
2226
|
-
|
|
2226
|
+
import { shallow as shallow2 } from "zustand/shallow";
|
|
2227
2227
|
function watchContractEvent({
|
|
2228
2228
|
address,
|
|
2229
2229
|
abi,
|
|
@@ -2250,16 +2250,16 @@ function watchContractEvent({
|
|
|
2250
2250
|
webSocketPublicClient
|
|
2251
2251
|
}),
|
|
2252
2252
|
watchEvent,
|
|
2253
|
-
{ equalityFn:
|
|
2253
|
+
{ equalityFn: shallow2 }
|
|
2254
2254
|
);
|
|
2255
2255
|
return () => {
|
|
2256
|
-
|
|
2256
|
+
unwatch?.();
|
|
2257
2257
|
unsubscribe();
|
|
2258
2258
|
};
|
|
2259
2259
|
}
|
|
2260
2260
|
|
|
2261
2261
|
// src/actions/network-status/watchBlockNumber.ts
|
|
2262
|
-
|
|
2262
|
+
import { shallow as shallow3 } from "zustand/shallow";
|
|
2263
2263
|
function watchBlockNumber(args, callback) {
|
|
2264
2264
|
let unwatch;
|
|
2265
2265
|
const createListener = (publicClient) => {
|
|
@@ -2271,7 +2271,7 @@ function watchBlockNumber(args, callback) {
|
|
|
2271
2271
|
poll: true
|
|
2272
2272
|
});
|
|
2273
2273
|
};
|
|
2274
|
-
const publicClient_ =
|
|
2274
|
+
const publicClient_ = getWebSocketPublicClient({ chainId: args.chainId }) ?? getPublicClient({ chainId: args.chainId });
|
|
2275
2275
|
if (args.listen)
|
|
2276
2276
|
createListener(publicClient_);
|
|
2277
2277
|
const config2 = getConfig();
|
|
@@ -2281,18 +2281,18 @@ function watchBlockNumber(args, callback) {
|
|
|
2281
2281
|
webSocketPublicClient
|
|
2282
2282
|
}),
|
|
2283
2283
|
async ({ publicClient, webSocketPublicClient }) => {
|
|
2284
|
-
const publicClient_2 =
|
|
2284
|
+
const publicClient_2 = webSocketPublicClient ?? publicClient;
|
|
2285
2285
|
if (args.listen && !args.chainId && publicClient_2) {
|
|
2286
2286
|
createListener(publicClient_2);
|
|
2287
2287
|
}
|
|
2288
2288
|
},
|
|
2289
2289
|
{
|
|
2290
|
-
equalityFn:
|
|
2290
|
+
equalityFn: shallow3
|
|
2291
2291
|
}
|
|
2292
2292
|
);
|
|
2293
2293
|
return () => {
|
|
2294
2294
|
unsubscribe();
|
|
2295
|
-
|
|
2295
|
+
unwatch?.();
|
|
2296
2296
|
};
|
|
2297
2297
|
}
|
|
2298
2298
|
|
|
@@ -2307,7 +2307,7 @@ function watchMulticall(args, callback) {
|
|
|
2307
2307
|
);
|
|
2308
2308
|
return () => {
|
|
2309
2309
|
unsubscribe();
|
|
2310
|
-
|
|
2310
|
+
unwatch?.();
|
|
2311
2311
|
};
|
|
2312
2312
|
}
|
|
2313
2313
|
|
|
@@ -2322,7 +2322,7 @@ function watchReadContract(args, callback) {
|
|
|
2322
2322
|
);
|
|
2323
2323
|
return () => {
|
|
2324
2324
|
unsubscribe();
|
|
2325
|
-
|
|
2325
|
+
unwatch?.();
|
|
2326
2326
|
};
|
|
2327
2327
|
}
|
|
2328
2328
|
|
|
@@ -2337,7 +2337,7 @@ function watchReadContracts(args, callback) {
|
|
|
2337
2337
|
);
|
|
2338
2338
|
return () => {
|
|
2339
2339
|
unsubscribe();
|
|
2340
|
-
|
|
2340
|
+
unwatch?.();
|
|
2341
2341
|
};
|
|
2342
2342
|
}
|
|
2343
2343
|
|
|
@@ -2345,7 +2345,7 @@ function watchReadContracts(args, callback) {
|
|
|
2345
2345
|
async function writeContract(config2) {
|
|
2346
2346
|
const walletClient = await getWalletClient({ chainId: config2.chainId });
|
|
2347
2347
|
if (!walletClient)
|
|
2348
|
-
throw new
|
|
2348
|
+
throw new ConnectorNotFoundError();
|
|
2349
2349
|
if (config2.chainId)
|
|
2350
2350
|
assertActiveChain({ chainId: config2.chainId });
|
|
2351
2351
|
let request;
|
|
@@ -2389,7 +2389,7 @@ async function fetchBalance({
|
|
|
2389
2389
|
});
|
|
2390
2390
|
return {
|
|
2391
2391
|
decimals,
|
|
2392
|
-
formatted:
|
|
2392
|
+
formatted: formatUnits2(value2 ?? "0", getUnit(unit ?? decimals)),
|
|
2393
2393
|
symbol,
|
|
2394
2394
|
value: value2
|
|
2395
2395
|
};
|
|
@@ -2397,12 +2397,12 @@ async function fetchBalance({
|
|
|
2397
2397
|
try {
|
|
2398
2398
|
return await fetchContractBalance({ abi: erc20ABI });
|
|
2399
2399
|
} catch (err) {
|
|
2400
|
-
if (err instanceof
|
|
2400
|
+
if (err instanceof ContractFunctionExecutionError3) {
|
|
2401
2401
|
const { symbol, ...rest } = await fetchContractBalance({
|
|
2402
2402
|
abi: erc20ABI_bytes32
|
|
2403
2403
|
});
|
|
2404
2404
|
return {
|
|
2405
|
-
symbol:
|
|
2405
|
+
symbol: hexToString2(trim2(symbol, { dir: "right" })),
|
|
2406
2406
|
...rest
|
|
2407
2407
|
};
|
|
2408
2408
|
}
|
|
@@ -2411,14 +2411,14 @@ async function fetchBalance({
|
|
|
2411
2411
|
}
|
|
2412
2412
|
const chains = [
|
|
2413
2413
|
...config2.publicClient.chains || [],
|
|
2414
|
-
...
|
|
2414
|
+
...config2.chains ?? []
|
|
2415
2415
|
];
|
|
2416
2416
|
const value = await publicClient.getBalance({ address });
|
|
2417
2417
|
const chain = chains.find((x) => x.id === publicClient.chain.id);
|
|
2418
2418
|
return {
|
|
2419
|
-
decimals:
|
|
2420
|
-
formatted:
|
|
2421
|
-
symbol:
|
|
2419
|
+
decimals: chain?.nativeCurrency.decimals ?? 18,
|
|
2420
|
+
formatted: formatUnits2(value ?? "0", getUnit(unit ?? 18)),
|
|
2421
|
+
symbol: chain?.nativeCurrency.symbol ?? "ETH",
|
|
2422
2422
|
value
|
|
2423
2423
|
};
|
|
2424
2424
|
}
|
|
@@ -2429,7 +2429,7 @@ function getAccount() {
|
|
|
2429
2429
|
switch (status) {
|
|
2430
2430
|
case "connected":
|
|
2431
2431
|
return {
|
|
2432
|
-
address:
|
|
2432
|
+
address: data?.account,
|
|
2433
2433
|
connector,
|
|
2434
2434
|
isConnected: true,
|
|
2435
2435
|
isConnecting: false,
|
|
@@ -2439,9 +2439,9 @@ function getAccount() {
|
|
|
2439
2439
|
};
|
|
2440
2440
|
case "reconnecting":
|
|
2441
2441
|
return {
|
|
2442
|
-
address:
|
|
2442
|
+
address: data?.account,
|
|
2443
2443
|
connector,
|
|
2444
|
-
isConnected: !!
|
|
2444
|
+
isConnected: !!data?.account,
|
|
2445
2445
|
isConnecting: false,
|
|
2446
2446
|
isDisconnected: false,
|
|
2447
2447
|
isReconnecting: true,
|
|
@@ -2449,7 +2449,7 @@ function getAccount() {
|
|
|
2449
2449
|
};
|
|
2450
2450
|
case "connecting":
|
|
2451
2451
|
return {
|
|
2452
|
-
address:
|
|
2452
|
+
address: data?.account,
|
|
2453
2453
|
connector,
|
|
2454
2454
|
isConnected: false,
|
|
2455
2455
|
isConnecting: true,
|
|
@@ -2473,12 +2473,12 @@ function getAccount() {
|
|
|
2473
2473
|
// src/actions/accounts/getNetwork.ts
|
|
2474
2474
|
function getNetwork() {
|
|
2475
2475
|
const config2 = getConfig();
|
|
2476
|
-
const chainId =
|
|
2477
|
-
const activeChains =
|
|
2478
|
-
const activeChain =
|
|
2479
|
-
...
|
|
2476
|
+
const chainId = config2.data?.chain?.id;
|
|
2477
|
+
const activeChains = config2.chains ?? [];
|
|
2478
|
+
const activeChain = [
|
|
2479
|
+
...config2.publicClient?.chains || [],
|
|
2480
2480
|
...activeChains
|
|
2481
|
-
].find((x) => x.id === chainId)
|
|
2481
|
+
].find((x) => x.id === chainId) ?? {
|
|
2482
2482
|
id: chainId,
|
|
2483
2483
|
name: `Chain ${chainId}`,
|
|
2484
2484
|
network: `${chainId}`,
|
|
@@ -2487,11 +2487,11 @@ function getNetwork() {
|
|
|
2487
2487
|
default: { http: [""] },
|
|
2488
2488
|
public: { http: [""] }
|
|
2489
2489
|
}
|
|
2490
|
-
}
|
|
2490
|
+
};
|
|
2491
2491
|
return {
|
|
2492
2492
|
chain: chainId ? {
|
|
2493
2493
|
...activeChain,
|
|
2494
|
-
...
|
|
2494
|
+
...config2.data?.chain,
|
|
2495
2495
|
id: chainId
|
|
2496
2496
|
} : void 0,
|
|
2497
2497
|
chains: activeChains
|
|
@@ -2502,7 +2502,7 @@ function getNetwork() {
|
|
|
2502
2502
|
async function signMessage(args) {
|
|
2503
2503
|
const walletClient = await getWalletClient();
|
|
2504
2504
|
if (!walletClient)
|
|
2505
|
-
throw new
|
|
2505
|
+
throw new ConnectorNotFoundError();
|
|
2506
2506
|
return await walletClient.signMessage({
|
|
2507
2507
|
message: args.message
|
|
2508
2508
|
});
|
|
@@ -2517,7 +2517,7 @@ async function signTypedData({
|
|
|
2517
2517
|
}) {
|
|
2518
2518
|
const walletClient = await getWalletClient();
|
|
2519
2519
|
if (!walletClient)
|
|
2520
|
-
throw new
|
|
2520
|
+
throw new ConnectorNotFoundError();
|
|
2521
2521
|
const { chainId } = domain;
|
|
2522
2522
|
if (chainId)
|
|
2523
2523
|
assertActiveChain({ chainId });
|
|
@@ -2535,7 +2535,7 @@ async function switchNetwork({
|
|
|
2535
2535
|
}) {
|
|
2536
2536
|
const { connector } = getConfig();
|
|
2537
2537
|
if (!connector)
|
|
2538
|
-
throw new
|
|
2538
|
+
throw new ConnectorNotFoundError();
|
|
2539
2539
|
if (!connector.switchChain)
|
|
2540
2540
|
throw new SwitchChainNotSupportedError({
|
|
2541
2541
|
connector
|
|
@@ -2544,46 +2544,46 @@ async function switchNetwork({
|
|
|
2544
2544
|
}
|
|
2545
2545
|
|
|
2546
2546
|
// src/actions/accounts/watchAccount.ts
|
|
2547
|
-
|
|
2547
|
+
import { shallow as shallow4 } from "zustand/shallow";
|
|
2548
2548
|
function watchAccount(callback, { selector = (x) => x } = {}) {
|
|
2549
2549
|
const config2 = getConfig();
|
|
2550
2550
|
const handleChange = () => callback(getAccount());
|
|
2551
2551
|
const unsubscribe = config2.subscribe(
|
|
2552
2552
|
({ data, connector, status }) => selector({
|
|
2553
|
-
address:
|
|
2553
|
+
address: data?.account,
|
|
2554
2554
|
connector,
|
|
2555
2555
|
status
|
|
2556
2556
|
}),
|
|
2557
2557
|
handleChange,
|
|
2558
2558
|
{
|
|
2559
|
-
equalityFn:
|
|
2559
|
+
equalityFn: shallow4
|
|
2560
2560
|
}
|
|
2561
2561
|
);
|
|
2562
2562
|
return unsubscribe;
|
|
2563
2563
|
}
|
|
2564
2564
|
|
|
2565
2565
|
// src/actions/accounts/watchNetwork.ts
|
|
2566
|
-
|
|
2566
|
+
import { shallow as shallow5 } from "zustand/shallow";
|
|
2567
2567
|
function watchNetwork(callback, { selector = (x) => x } = {}) {
|
|
2568
2568
|
const config2 = getConfig();
|
|
2569
2569
|
const handleChange = () => callback(getNetwork());
|
|
2570
2570
|
const unsubscribe = config2.subscribe(
|
|
2571
|
-
({ data, chains }) => selector({ chainId:
|
|
2571
|
+
({ data, chains }) => selector({ chainId: data?.chain?.id, chains }),
|
|
2572
2572
|
handleChange,
|
|
2573
2573
|
{
|
|
2574
|
-
equalityFn:
|
|
2574
|
+
equalityFn: shallow5
|
|
2575
2575
|
}
|
|
2576
2576
|
);
|
|
2577
2577
|
return unsubscribe;
|
|
2578
2578
|
}
|
|
2579
2579
|
|
|
2580
2580
|
// src/actions/ens/fetchEnsAddress.ts
|
|
2581
|
-
|
|
2581
|
+
import { getAddress } from "viem";
|
|
2582
2582
|
async function fetchEnsAddress({
|
|
2583
2583
|
chainId,
|
|
2584
2584
|
name
|
|
2585
2585
|
}) {
|
|
2586
|
-
const { normalize } = await
|
|
2586
|
+
const { normalize } = await import("viem/ens");
|
|
2587
2587
|
const publicClient = getPublicClient({ chainId });
|
|
2588
2588
|
const address = await publicClient.getEnsAddress({
|
|
2589
2589
|
name: normalize(name)
|
|
@@ -2591,7 +2591,7 @@ async function fetchEnsAddress({
|
|
|
2591
2591
|
try {
|
|
2592
2592
|
if (address === "0x0000000000000000000000000000000000000000")
|
|
2593
2593
|
return null;
|
|
2594
|
-
return address ?
|
|
2594
|
+
return address ? getAddress(address) : null;
|
|
2595
2595
|
} catch (_error) {
|
|
2596
2596
|
return null;
|
|
2597
2597
|
}
|
|
@@ -2602,21 +2602,21 @@ async function fetchEnsAvatar({
|
|
|
2602
2602
|
name,
|
|
2603
2603
|
chainId
|
|
2604
2604
|
}) {
|
|
2605
|
-
const { normalize } = await
|
|
2605
|
+
const { normalize } = await import("viem/ens");
|
|
2606
2606
|
const publicClient = getPublicClient({ chainId });
|
|
2607
2607
|
const avatar = await publicClient.getEnsAvatar({ name: normalize(name) });
|
|
2608
2608
|
return avatar;
|
|
2609
2609
|
}
|
|
2610
2610
|
|
|
2611
2611
|
// src/actions/ens/fetchEnsName.ts
|
|
2612
|
-
|
|
2612
|
+
import { getAddress as getAddress2 } from "viem";
|
|
2613
2613
|
async function fetchEnsName({
|
|
2614
2614
|
address,
|
|
2615
2615
|
chainId
|
|
2616
2616
|
}) {
|
|
2617
2617
|
const publicClient = getPublicClient({ chainId });
|
|
2618
2618
|
return publicClient.getEnsName({
|
|
2619
|
-
address:
|
|
2619
|
+
address: getAddress2(address)
|
|
2620
2620
|
});
|
|
2621
2621
|
}
|
|
2622
2622
|
|
|
@@ -2625,7 +2625,7 @@ async function fetchEnsResolver({
|
|
|
2625
2625
|
chainId,
|
|
2626
2626
|
name
|
|
2627
2627
|
}) {
|
|
2628
|
-
const { normalize } = await
|
|
2628
|
+
const { normalize } = await import("viem/ens");
|
|
2629
2629
|
const publicClient = getPublicClient({ chainId });
|
|
2630
2630
|
const resolver = await publicClient.getEnsResolver({ name: normalize(name) });
|
|
2631
2631
|
return resolver;
|
|
@@ -2641,7 +2641,7 @@ async function fetchBlockNumber({
|
|
|
2641
2641
|
}
|
|
2642
2642
|
|
|
2643
2643
|
// src/actions/network-status/fetchFeeData.ts
|
|
2644
|
-
|
|
2644
|
+
import { formatUnits as formatUnits3, parseGwei } from "viem";
|
|
2645
2645
|
async function fetchFeeData({
|
|
2646
2646
|
chainId,
|
|
2647
2647
|
formatUnits: units = "gwei"
|
|
@@ -2651,21 +2651,21 @@ async function fetchFeeData({
|
|
|
2651
2651
|
let gasPrice = null;
|
|
2652
2652
|
try {
|
|
2653
2653
|
gasPrice = await publicClient.getGasPrice();
|
|
2654
|
-
} catch
|
|
2654
|
+
} catch {
|
|
2655
2655
|
}
|
|
2656
2656
|
let lastBaseFeePerGas = null;
|
|
2657
2657
|
let maxFeePerGas = null;
|
|
2658
2658
|
let maxPriorityFeePerGas = null;
|
|
2659
|
-
if (
|
|
2659
|
+
if (block?.baseFeePerGas) {
|
|
2660
2660
|
lastBaseFeePerGas = block.baseFeePerGas;
|
|
2661
|
-
maxPriorityFeePerGas =
|
|
2661
|
+
maxPriorityFeePerGas = parseGwei("1");
|
|
2662
2662
|
maxFeePerGas = block.baseFeePerGas * 2n + maxPriorityFeePerGas;
|
|
2663
2663
|
}
|
|
2664
2664
|
const unit = getUnit(units);
|
|
2665
2665
|
const formatted = {
|
|
2666
|
-
gasPrice: gasPrice ?
|
|
2667
|
-
maxFeePerGas: maxFeePerGas ?
|
|
2668
|
-
maxPriorityFeePerGas: maxPriorityFeePerGas ?
|
|
2666
|
+
gasPrice: gasPrice ? formatUnits3(gasPrice, unit) : null,
|
|
2667
|
+
maxFeePerGas: maxFeePerGas ? formatUnits3(maxFeePerGas, unit) : null,
|
|
2668
|
+
maxPriorityFeePerGas: maxPriorityFeePerGas ? formatUnits3(maxPriorityFeePerGas, unit) : null
|
|
2669
2669
|
};
|
|
2670
2670
|
return {
|
|
2671
2671
|
lastBaseFeePerGas,
|
|
@@ -2686,7 +2686,7 @@ async function fetchTransaction({
|
|
|
2686
2686
|
}
|
|
2687
2687
|
|
|
2688
2688
|
// src/actions/transactions/prepareSendTransaction.ts
|
|
2689
|
-
|
|
2689
|
+
import { isAddress } from "viem";
|
|
2690
2690
|
async function prepareSendTransaction({
|
|
2691
2691
|
accessList,
|
|
2692
2692
|
account,
|
|
@@ -2702,19 +2702,19 @@ async function prepareSendTransaction({
|
|
|
2702
2702
|
walletClient: walletClient_
|
|
2703
2703
|
}) {
|
|
2704
2704
|
const publicClient = getPublicClient({ chainId });
|
|
2705
|
-
const walletClient =
|
|
2705
|
+
const walletClient = walletClient_ ?? await getWalletClient({ chainId });
|
|
2706
2706
|
if (!walletClient)
|
|
2707
|
-
throw new
|
|
2707
|
+
throw new ConnectorNotFoundError();
|
|
2708
2708
|
if (chainId)
|
|
2709
2709
|
assertActiveChain({ chainId });
|
|
2710
|
-
const to = (to_ && !
|
|
2711
|
-
if (to && !
|
|
2710
|
+
const to = (to_ && !isAddress(to_) ? await fetchEnsAddress({ name: to_ }) : to_) || void 0;
|
|
2711
|
+
if (to && !isAddress(to))
|
|
2712
2712
|
throw new Error("Invalid address");
|
|
2713
2713
|
const gas = typeof gas_ === "undefined" ? await publicClient.estimateGas({
|
|
2714
2714
|
accessList,
|
|
2715
2715
|
account: walletClient.account,
|
|
2716
2716
|
data,
|
|
2717
|
-
gas:
|
|
2717
|
+
gas: gas_ ?? void 0,
|
|
2718
2718
|
gasPrice,
|
|
2719
2719
|
maxFeePerGas,
|
|
2720
2720
|
maxPriorityFeePerGas,
|
|
@@ -2755,7 +2755,7 @@ async function sendTransaction({
|
|
|
2755
2755
|
}) {
|
|
2756
2756
|
const walletClient = await getWalletClient({ chainId });
|
|
2757
2757
|
if (!walletClient)
|
|
2758
|
-
throw new
|
|
2758
|
+
throw new ConnectorNotFoundError();
|
|
2759
2759
|
if (chainId)
|
|
2760
2760
|
assertActiveChain({ chainId });
|
|
2761
2761
|
let args;
|
|
@@ -2796,7 +2796,7 @@ async function sendTransaction({
|
|
|
2796
2796
|
}
|
|
2797
2797
|
|
|
2798
2798
|
// src/actions/transactions/waitForTransaction.ts
|
|
2799
|
-
|
|
2799
|
+
import { hexToString as hexToString3 } from "viem";
|
|
2800
2800
|
async function waitForTransaction({
|
|
2801
2801
|
chainId,
|
|
2802
2802
|
confirmations = 1,
|
|
@@ -2821,14 +2821,14 @@ async function waitForTransaction({
|
|
|
2821
2821
|
maxFeePerGas: txn.type === "eip1559" ? txn.maxFeePerGas : void 0,
|
|
2822
2822
|
maxPriorityFeePerGas: txn.type === "eip1559" ? txn.maxPriorityFeePerGas : void 0
|
|
2823
2823
|
});
|
|
2824
|
-
const reason =
|
|
2824
|
+
const reason = hexToString3(`0x${code.substring(138)}`);
|
|
2825
2825
|
throw new Error(reason);
|
|
2826
2826
|
}
|
|
2827
2827
|
return receipt;
|
|
2828
2828
|
}
|
|
2829
2829
|
|
|
2830
2830
|
// src/actions/transactions/watchPendingTransactions.ts
|
|
2831
|
-
|
|
2831
|
+
import { shallow as shallow6 } from "zustand/shallow";
|
|
2832
2832
|
function watchPendingTransactions(args, callback) {
|
|
2833
2833
|
let unwatch;
|
|
2834
2834
|
const createListener = (publicClient) => {
|
|
@@ -2839,7 +2839,7 @@ function watchPendingTransactions(args, callback) {
|
|
|
2839
2839
|
poll: true
|
|
2840
2840
|
});
|
|
2841
2841
|
};
|
|
2842
|
-
const publicClient_ =
|
|
2842
|
+
const publicClient_ = getWebSocketPublicClient({ chainId: args.chainId }) ?? getPublicClient({ chainId: args.chainId });
|
|
2843
2843
|
createListener(publicClient_);
|
|
2844
2844
|
const config2 = getConfig();
|
|
2845
2845
|
const unsubscribe = config2.subscribe(
|
|
@@ -2848,92 +2848,92 @@ function watchPendingTransactions(args, callback) {
|
|
|
2848
2848
|
webSocketPublicClient
|
|
2849
2849
|
}),
|
|
2850
2850
|
async ({ publicClient, webSocketPublicClient }) => {
|
|
2851
|
-
const publicClient_2 =
|
|
2851
|
+
const publicClient_2 = webSocketPublicClient ?? publicClient;
|
|
2852
2852
|
if (!args.chainId && publicClient_2) {
|
|
2853
2853
|
createListener(publicClient_2);
|
|
2854
2854
|
}
|
|
2855
2855
|
},
|
|
2856
2856
|
{
|
|
2857
|
-
equalityFn:
|
|
2857
|
+
equalityFn: shallow6
|
|
2858
2858
|
}
|
|
2859
2859
|
);
|
|
2860
2860
|
return () => {
|
|
2861
2861
|
unsubscribe();
|
|
2862
|
-
|
|
2862
|
+
unwatch?.();
|
|
2863
2863
|
};
|
|
2864
2864
|
}
|
|
2865
2865
|
|
|
2866
2866
|
// src/utils/assertActiveChain.ts
|
|
2867
2867
|
function assertActiveChain({ chainId }) {
|
|
2868
2868
|
const { chain: activeChain, chains } = getNetwork();
|
|
2869
|
-
const activeChainId =
|
|
2869
|
+
const activeChainId = activeChain?.id;
|
|
2870
2870
|
if (activeChainId && chainId !== activeChainId) {
|
|
2871
2871
|
throw new ChainMismatchError({
|
|
2872
|
-
activeChain:
|
|
2873
|
-
targetChain:
|
|
2872
|
+
activeChain: chains.find((x) => x.id === activeChainId)?.name ?? `Chain ${activeChainId}`,
|
|
2873
|
+
targetChain: chains.find((x) => x.id === chainId)?.name ?? `Chain ${chainId}`
|
|
2874
2874
|
});
|
|
2875
2875
|
}
|
|
2876
2876
|
}
|
|
2877
2877
|
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2878
|
+
export {
|
|
2879
|
+
configureChains,
|
|
2880
|
+
ChainMismatchError,
|
|
2881
|
+
ChainNotConfiguredError,
|
|
2882
|
+
ConnectorAlreadyConnectedError,
|
|
2883
|
+
ConfigChainsNotFound,
|
|
2884
|
+
SwitchChainNotSupportedError,
|
|
2885
|
+
ConnectorNotFoundError,
|
|
2886
|
+
deepEqual,
|
|
2887
|
+
deserialize,
|
|
2888
|
+
getCallParameters,
|
|
2889
|
+
getSendTransactionParameters,
|
|
2890
|
+
getUnit,
|
|
2891
|
+
serialize,
|
|
2892
|
+
noopStorage,
|
|
2893
|
+
createStorage,
|
|
2894
|
+
Config,
|
|
2895
|
+
createConfig,
|
|
2896
|
+
getConfig,
|
|
2897
|
+
connect,
|
|
2898
|
+
disconnect,
|
|
2899
|
+
erc20ABI,
|
|
2900
|
+
erc721ABI,
|
|
2901
|
+
erc4626ABI,
|
|
2902
|
+
fetchToken,
|
|
2903
|
+
getPublicClient,
|
|
2904
|
+
getWalletClient,
|
|
2905
|
+
getWebSocketPublicClient,
|
|
2906
|
+
watchPublicClient,
|
|
2907
|
+
watchWalletClient,
|
|
2908
|
+
watchWebSocketPublicClient,
|
|
2909
|
+
prepareWriteContract,
|
|
2910
|
+
getContract,
|
|
2911
|
+
multicall,
|
|
2912
|
+
readContract,
|
|
2913
|
+
readContracts,
|
|
2914
|
+
watchContractEvent,
|
|
2915
|
+
watchBlockNumber,
|
|
2916
|
+
watchMulticall,
|
|
2917
|
+
watchReadContract,
|
|
2918
|
+
watchReadContracts,
|
|
2919
|
+
writeContract,
|
|
2920
|
+
fetchBalance,
|
|
2921
|
+
getAccount,
|
|
2922
|
+
getNetwork,
|
|
2923
|
+
signMessage,
|
|
2924
|
+
signTypedData,
|
|
2925
|
+
switchNetwork,
|
|
2926
|
+
watchAccount,
|
|
2927
|
+
watchNetwork,
|
|
2928
|
+
fetchEnsAddress,
|
|
2929
|
+
fetchEnsAvatar,
|
|
2930
|
+
fetchEnsName,
|
|
2931
|
+
fetchEnsResolver,
|
|
2932
|
+
fetchBlockNumber,
|
|
2933
|
+
fetchFeeData,
|
|
2934
|
+
fetchTransaction,
|
|
2935
|
+
prepareSendTransaction,
|
|
2936
|
+
sendTransaction,
|
|
2937
|
+
waitForTransaction,
|
|
2938
|
+
watchPendingTransactions
|
|
2939
|
+
};
|