wagmi 1.3.3-cjs → 1.3.4-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/index.js +37 -54
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -622,39 +622,22 @@ function useSyncExternalStoreWithTracked(subscribe, getSnapshot, getServerSnapsh
|
|
|
622
622
|
|
|
623
623
|
// src/hooks/accounts/useAccount.ts
|
|
624
624
|
function useAccount({ onConnect, onDisconnect } = {}) {
|
|
625
|
-
const
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
const unsubscribe = config.subscribe(
|
|
629
|
-
(state) => ({
|
|
630
|
-
address: _optionalChain([state, 'access', _12 => _12.data, 'optionalAccess', _13 => _13.account]),
|
|
631
|
-
connector: state.connector,
|
|
632
|
-
status: state.status
|
|
633
|
-
}),
|
|
634
|
-
(curr, prev) => {
|
|
635
|
-
if (!!onConnect && prev.status !== "connected" && curr.status === "connected")
|
|
636
|
-
onConnect({
|
|
637
|
-
address: curr.address,
|
|
638
|
-
connector: curr.connector,
|
|
639
|
-
isReconnected: prev.status === "reconnecting"
|
|
640
|
-
});
|
|
641
|
-
if (!!onDisconnect && prev.status === "connected" && curr.status === "disconnected")
|
|
642
|
-
onDisconnect();
|
|
643
|
-
return callback(_core.getAccount.call(void 0, ));
|
|
644
|
-
}
|
|
645
|
-
);
|
|
646
|
-
return unsubscribe;
|
|
647
|
-
},
|
|
648
|
-
[onConnect, onDisconnect]
|
|
649
|
-
);
|
|
650
|
-
const account = useSyncExternalStoreWithTracked(watchAccount, _core.getAccount);
|
|
651
|
-
const previousStatusRef = React9.useRef();
|
|
652
|
-
const { address, connector, status } = account;
|
|
625
|
+
const account = useSyncExternalStoreWithTracked(_core.watchAccount, _core.getAccount);
|
|
626
|
+
const previousAccountRef = React9.useRef();
|
|
627
|
+
const previousAccount = previousAccountRef.current;
|
|
653
628
|
React9.useEffect(() => {
|
|
654
|
-
if (
|
|
655
|
-
onConnect
|
|
656
|
-
|
|
657
|
-
|
|
629
|
+
if (_optionalChain([previousAccount, 'optionalAccess', _12 => _12.status]) !== "connected" && account.status === "connected") {
|
|
630
|
+
_optionalChain([onConnect, 'optionalCall', _13 => _13({
|
|
631
|
+
address: account.address,
|
|
632
|
+
connector: account.connector,
|
|
633
|
+
isReconnected: _optionalChain([previousAccount, 'optionalAccess', _14 => _14.status]) === "reconnecting" || _optionalChain([previousAccount, 'optionalAccess', _15 => _15.status]) === void 0
|
|
634
|
+
})]);
|
|
635
|
+
}
|
|
636
|
+
if (_optionalChain([previousAccount, 'optionalAccess', _16 => _16.status]) === "connected" && account.status === "disconnected") {
|
|
637
|
+
_optionalChain([onDisconnect, 'optionalCall', _17 => _17()]);
|
|
638
|
+
}
|
|
639
|
+
previousAccountRef.current = account;
|
|
640
|
+
}, [onConnect, onDisconnect, previousAccount, account]);
|
|
658
641
|
return account;
|
|
659
642
|
}
|
|
660
643
|
|
|
@@ -763,8 +746,8 @@ function useConnect({
|
|
|
763
746
|
const connect2 = React11.useCallback(
|
|
764
747
|
(args) => {
|
|
765
748
|
return mutate({
|
|
766
|
-
chainId: _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
767
|
-
connector: _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
749
|
+
chainId: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _18 => _18.chainId]), () => ( chainId)),
|
|
750
|
+
connector: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _19 => _19.connector]), () => ( connector))
|
|
768
751
|
});
|
|
769
752
|
},
|
|
770
753
|
[chainId, connector, mutate]
|
|
@@ -772,8 +755,8 @@ function useConnect({
|
|
|
772
755
|
const connectAsync = React11.useCallback(
|
|
773
756
|
(args) => {
|
|
774
757
|
return mutateAsync({
|
|
775
|
-
chainId: _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
776
|
-
connector: _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
758
|
+
chainId: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _20 => _20.chainId]), () => ( chainId)),
|
|
759
|
+
connector: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _21 => _21.connector]), () => ( connector))
|
|
777
760
|
});
|
|
778
761
|
},
|
|
779
762
|
[chainId, connector, mutateAsync]
|
|
@@ -788,7 +771,7 @@ function useConnect({
|
|
|
788
771
|
isIdle,
|
|
789
772
|
isLoading,
|
|
790
773
|
isSuccess,
|
|
791
|
-
pendingConnector: _optionalChain([variables, 'optionalAccess',
|
|
774
|
+
pendingConnector: _optionalChain([variables, 'optionalAccess', _22 => _22.connector]),
|
|
792
775
|
reset,
|
|
793
776
|
status,
|
|
794
777
|
variables
|
|
@@ -974,19 +957,19 @@ function useSignTypedData({
|
|
|
974
957
|
);
|
|
975
958
|
const signTypedData2 = React13.useCallback(
|
|
976
959
|
(args) => mutate({
|
|
977
|
-
domain: _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
978
|
-
types: _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
979
|
-
message: _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
980
|
-
primaryType: _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
960
|
+
domain: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _23 => _23.domain]), () => ( domain)),
|
|
961
|
+
types: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _24 => _24.types]), () => ( types)),
|
|
962
|
+
message: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _25 => _25.message]), () => ( message)),
|
|
963
|
+
primaryType: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _26 => _26.primaryType]), () => ( primaryType))
|
|
981
964
|
}),
|
|
982
965
|
[domain, types, primaryType, message, mutate]
|
|
983
966
|
);
|
|
984
967
|
const signTypedDataAsync = React13.useCallback(
|
|
985
968
|
(args) => mutateAsync({
|
|
986
|
-
domain: _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
987
|
-
types: _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
988
|
-
message: _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
989
|
-
primaryType: _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
969
|
+
domain: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _27 => _27.domain]), () => ( domain)),
|
|
970
|
+
types: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _28 => _28.types]), () => ( types)),
|
|
971
|
+
message: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _29 => _29.message]), () => ( message)),
|
|
972
|
+
primaryType: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _30 => _30.primaryType]), () => ( primaryType))
|
|
990
973
|
}),
|
|
991
974
|
[domain, types, primaryType, message, mutateAsync]
|
|
992
975
|
);
|
|
@@ -1063,7 +1046,7 @@ function useSwitchNetwork({
|
|
|
1063
1046
|
}, [config, forceUpdate]);
|
|
1064
1047
|
let switchNetwork2;
|
|
1065
1048
|
let switchNetworkAsync;
|
|
1066
|
-
const supportsSwitchChain = !!_optionalChain([config, 'access',
|
|
1049
|
+
const supportsSwitchChain = !!_optionalChain([config, 'access', _31 => _31.connector, 'optionalAccess', _32 => _32.switchChain]);
|
|
1067
1050
|
if (throwForSwitchChainNotSupported || supportsSwitchChain) {
|
|
1068
1051
|
switchNetwork2 = switchNetwork_;
|
|
1069
1052
|
switchNetworkAsync = switchNetworkAsync_;
|
|
@@ -1076,7 +1059,7 @@ function useSwitchNetwork({
|
|
|
1076
1059
|
isIdle,
|
|
1077
1060
|
isLoading,
|
|
1078
1061
|
isSuccess,
|
|
1079
|
-
pendingChainId: _optionalChain([variables, 'optionalAccess',
|
|
1062
|
+
pendingChainId: _optionalChain([variables, 'optionalAccess', _33 => _33.chainId]),
|
|
1080
1063
|
reset,
|
|
1081
1064
|
status,
|
|
1082
1065
|
switchNetwork: switchNetwork2,
|
|
@@ -1108,7 +1091,7 @@ function useContractEvent({
|
|
|
1108
1091
|
onLogs: listener
|
|
1109
1092
|
});
|
|
1110
1093
|
return unwatch.current;
|
|
1111
|
-
}, [abi, address, eventName, publicClient.uid, _optionalChain([webSocketPublicClient, 'optionalAccess',
|
|
1094
|
+
}, [abi, address, eventName, publicClient.uid, _optionalChain([webSocketPublicClient, 'optionalAccess', _34 => _34.uid])]);
|
|
1112
1095
|
return unwatch.current;
|
|
1113
1096
|
}
|
|
1114
1097
|
|
|
@@ -1203,7 +1186,7 @@ function paginatedIndexesConfig(fn, {
|
|
|
1203
1186
|
return {
|
|
1204
1187
|
contracts,
|
|
1205
1188
|
getNextPageParam(lastPage, pages) {
|
|
1206
|
-
return _optionalChain([lastPage, 'optionalAccess',
|
|
1189
|
+
return _optionalChain([lastPage, 'optionalAccess', _35 => _35.length]) === perPage ? pages.length : void 0;
|
|
1207
1190
|
}
|
|
1208
1191
|
};
|
|
1209
1192
|
}
|
|
@@ -1438,7 +1421,7 @@ function useContractReads({
|
|
|
1438
1421
|
);
|
|
1439
1422
|
const enabled = React18.useMemo(() => {
|
|
1440
1423
|
let enabled2 = Boolean(
|
|
1441
|
-
enabled_ && _optionalChain([contracts, 'optionalAccess',
|
|
1424
|
+
enabled_ && _optionalChain([contracts, 'optionalAccess', _36 => _36.every, 'call', _37 => _37(
|
|
1442
1425
|
(x) => x.abi && x.address && x.functionName
|
|
1443
1426
|
)])
|
|
1444
1427
|
);
|
|
@@ -1824,7 +1807,7 @@ function usePrepareContractWrite({
|
|
|
1824
1807
|
queryKey8({
|
|
1825
1808
|
accessList,
|
|
1826
1809
|
account,
|
|
1827
|
-
activeChainId: _optionalChain([activeChain, 'optionalAccess',
|
|
1810
|
+
activeChainId: _optionalChain([activeChain, 'optionalAccess', _38 => _38.id]),
|
|
1828
1811
|
address,
|
|
1829
1812
|
args,
|
|
1830
1813
|
blockNumber,
|
|
@@ -1837,7 +1820,7 @@ function usePrepareContractWrite({
|
|
|
1837
1820
|
maxPriorityFeePerGas,
|
|
1838
1821
|
nonce,
|
|
1839
1822
|
scopeKey,
|
|
1840
|
-
walletClientAddress: _optionalChain([walletClient, 'optionalAccess',
|
|
1823
|
+
walletClientAddress: _optionalChain([walletClient, 'optionalAccess', _39 => _39.account, 'access', _40 => _40.address]),
|
|
1841
1824
|
value
|
|
1842
1825
|
}),
|
|
1843
1826
|
queryFn8({
|
|
@@ -2159,7 +2142,7 @@ function usePrepareSendTransaction({
|
|
|
2159
2142
|
const prepareSendTransactionQuery = useQuery(
|
|
2160
2143
|
queryKey14({
|
|
2161
2144
|
accessList,
|
|
2162
|
-
activeChainId: _optionalChain([activeChain, 'optionalAccess',
|
|
2145
|
+
activeChainId: _optionalChain([activeChain, 'optionalAccess', _41 => _41.id]),
|
|
2163
2146
|
account,
|
|
2164
2147
|
chainId,
|
|
2165
2148
|
data,
|
|
@@ -2171,7 +2154,7 @@ function usePrepareSendTransaction({
|
|
|
2171
2154
|
scopeKey,
|
|
2172
2155
|
to,
|
|
2173
2156
|
value,
|
|
2174
|
-
walletClientAddress: _optionalChain([walletClient, 'optionalAccess',
|
|
2157
|
+
walletClientAddress: _optionalChain([walletClient, 'optionalAccess', _42 => _42.account, 'access', _43 => _43.address])
|
|
2175
2158
|
}),
|
|
2176
2159
|
queryFn14({ walletClient }),
|
|
2177
2160
|
{
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "wagmi",
|
|
3
3
|
"description": "React Hooks for Ethereum",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "1.3.
|
|
5
|
+
"version": "1.3.4-cjs",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/wagmi-dev/wagmi.git",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
"@tanstack/react-query-persist-client": "^4.28.0",
|
|
123
123
|
"abitype": "0.8.7",
|
|
124
124
|
"use-sync-external-store": "^1.2.0",
|
|
125
|
-
"@wagmi/core": "1.3.
|
|
125
|
+
"@wagmi/core": "1.3.4-cjs"
|
|
126
126
|
},
|
|
127
127
|
"devDependencies": {
|
|
128
128
|
"@testing-library/react": "^13.3.0",
|