@cometh/connect-react-hooks 0.1.0-dev.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +19 -19
- package/dist/index.d.cts +1803 -25
- package/dist/index.d.ts +1803 -25
- package/dist/index.js +19 -19
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
@@ -79,8 +79,7 @@ var ConnectContext = _react.createContext.call(void 0, {
|
|
79
79
|
queryClient: void 0,
|
80
80
|
smartAccountClient: null,
|
81
81
|
smartAccountAddress: void 0,
|
82
|
-
updateSmartAccountClient: async () =>
|
83
|
-
},
|
82
|
+
updateSmartAccountClient: async () => null,
|
84
83
|
disconnectSmartAccount: async () => {
|
85
84
|
},
|
86
85
|
networksConfig: void 0
|
@@ -101,9 +100,9 @@ var ConnectProvider = ({
|
|
101
100
|
const paymasterUrl = _optionalChain([config, 'access', _8 => _8.networksConfig, 'access', _9 => _9.find, 'call', _10 => _10(
|
102
101
|
(network) => _optionalChain([network, 'access', _11 => _11.chain, 'optionalAccess', _12 => _12.id]) === chain.id
|
103
102
|
), 'optionalAccess', _13 => _13.paymasterUrl]);
|
104
|
-
const
|
103
|
+
const publicClient = _optionalChain([config, 'access', _14 => _14.networksConfig, 'access', _15 => _15.find, 'call', _16 => _16(
|
105
104
|
(network) => _optionalChain([network, 'access', _17 => _17.chain, 'optionalAccess', _18 => _18.id]) === chain.id
|
106
|
-
), 'optionalAccess', _19 => _19.
|
105
|
+
), 'optionalAccess', _19 => _19.publicClient]);
|
107
106
|
if (!bundlerUrl) throw new Error("Bundler url not found");
|
108
107
|
try {
|
109
108
|
const { client, address: newAddress } = await createSmartAccount({
|
@@ -111,7 +110,7 @@ var ConnectProvider = ({
|
|
111
110
|
chain,
|
112
111
|
bundlerUrl,
|
113
112
|
paymasterUrl,
|
114
|
-
|
113
|
+
publicClient,
|
115
114
|
smartAccountAddress: params.address,
|
116
115
|
comethSignerConfig: {
|
117
116
|
...config.comethSignerConfig,
|
@@ -121,8 +120,10 @@ var ConnectProvider = ({
|
|
121
120
|
setSmartAccountClient(client);
|
122
121
|
setSmartAccountAddress(newAddress);
|
123
122
|
localStorage.setItem(CHAIN_STORAGE_KEY, JSON.stringify(chain));
|
123
|
+
return client;
|
124
124
|
} catch (e) {
|
125
125
|
console.log(e);
|
126
|
+
return smartAccountClient;
|
126
127
|
}
|
127
128
|
},
|
128
129
|
[config, config.networksConfig[0].chain]
|
@@ -1271,14 +1272,15 @@ function useBaseQuery(options, Observer, queryClient) {
|
|
1271
1272
|
)
|
1272
1273
|
);
|
1273
1274
|
const result = observer.getOptimisticResult(defaultedOptions);
|
1275
|
+
const shouldSubscribe = !isRestoring && options.subscribed !== false;
|
1274
1276
|
React6.useSyncExternalStore(
|
1275
1277
|
React6.useCallback(
|
1276
1278
|
(onStoreChange) => {
|
1277
|
-
const unsubscribe =
|
1279
|
+
const unsubscribe = shouldSubscribe ? observer.subscribe(notifyManager.batchCalls(onStoreChange)) : noop2;
|
1278
1280
|
observer.updateResult();
|
1279
1281
|
return unsubscribe;
|
1280
1282
|
},
|
1281
|
-
[observer,
|
1283
|
+
[observer, shouldSubscribe]
|
1282
1284
|
),
|
1283
1285
|
() => observer.getCurrentResult(),
|
1284
1286
|
() => observer.getCurrentResult()
|
@@ -1957,15 +1959,11 @@ function useSetUpRecovery() {
|
|
1957
1959
|
const { smartAccountClient, queryClient } = useSmartAccount();
|
1958
1960
|
const { mutate, mutateAsync, ...result } = useMutation(
|
1959
1961
|
{
|
1960
|
-
mutationFn: async (
|
1962
|
+
mutationFn: async () => {
|
1961
1963
|
if (!smartAccountClient) {
|
1962
1964
|
throw new Error("No smart account found");
|
1963
1965
|
}
|
1964
|
-
return smartAccountClient.setUpRecoveryModule(
|
1965
|
-
passKeyName: variables.passKeyName,
|
1966
|
-
publicClient: variables.publicClient,
|
1967
|
-
webAuthnOptions: variables.webAuthnOptions
|
1968
|
-
});
|
1966
|
+
return smartAccountClient.setUpRecoveryModule();
|
1969
1967
|
}
|
1970
1968
|
},
|
1971
1969
|
queryClient
|
@@ -1986,7 +1984,7 @@ function useIsRecoveryActive(props = {}) {
|
|
1986
1984
|
const { smartAccountClient, queryClient } = useSmartAccount();
|
1987
1985
|
return useQuery(
|
1988
1986
|
{
|
1989
|
-
queryKey: ["isRecoveryActive"
|
1987
|
+
queryKey: ["isRecoveryActive"],
|
1990
1988
|
queryFn: async () => {
|
1991
1989
|
if (!smartAccountClient) {
|
1992
1990
|
throw new Error("No smart account found");
|
@@ -2004,7 +2002,7 @@ function useGetRecoveryRequest(props = {}, queryOptions) {
|
|
2004
2002
|
const { smartAccountClient, queryClient } = useSmartAccount();
|
2005
2003
|
const { data, isLoading, isError, error } = useQuery(
|
2006
2004
|
{
|
2007
|
-
queryKey: ["getRecoveryRequest"
|
2005
|
+
queryKey: ["getRecoveryRequest"],
|
2008
2006
|
queryFn: async () => {
|
2009
2007
|
if (!smartAccountClient) {
|
2010
2008
|
throw new Error("No smart account found");
|
@@ -2034,7 +2032,7 @@ function useCancelRecoveryRequest() {
|
|
2034
2032
|
throw new Error("No smart account found");
|
2035
2033
|
}
|
2036
2034
|
return smartAccountClient.cancelRecoveryRequest({
|
2037
|
-
|
2035
|
+
effectiveDelayAddress: variables.effectiveDelayAddress
|
2038
2036
|
});
|
2039
2037
|
}
|
2040
2038
|
},
|
@@ -2077,13 +2075,14 @@ var useSwitchChain = () => {
|
|
2077
2075
|
if (!selectedNetwork)
|
2078
2076
|
throw new Error("No current configuration found");
|
2079
2077
|
try {
|
2080
|
-
await updateSmartAccountClient({
|
2078
|
+
const client = await updateSmartAccountClient({
|
2081
2079
|
address: _optionalChain([smartAccountClient, 'optionalAccess', _103 => _103.account, 'access', _104 => _104.address]),
|
2082
2080
|
chain: selectedNetwork.chain
|
2083
2081
|
});
|
2084
2082
|
_optionalChain([queryClient, 'optionalAccess', _105 => _105.invalidateQueries, 'call', _106 => _106({
|
2085
2083
|
queryKey: ["switchChain"]
|
2086
2084
|
})]);
|
2085
|
+
return client;
|
2087
2086
|
} catch (e) {
|
2088
2087
|
throw e instanceof Error ? e : new Error("An error occurred while switching chain");
|
2089
2088
|
}
|
@@ -2099,7 +2098,7 @@ var useSwitchChain = () => {
|
|
2099
2098
|
(params) => {
|
2100
2099
|
setIsPending(true);
|
2101
2100
|
setError(null);
|
2102
|
-
switchChainInternal(params).catch((e) => {
|
2101
|
+
return switchChainInternal(params).catch((e) => {
|
2103
2102
|
const err = e instanceof Error ? e : new Error(
|
2104
2103
|
"An error occurred while switching chain"
|
2105
2104
|
);
|
@@ -2115,7 +2114,8 @@ var useSwitchChain = () => {
|
|
2115
2114
|
setIsPending(true);
|
2116
2115
|
setError(null);
|
2117
2116
|
try {
|
2118
|
-
await switchChainInternal(params);
|
2117
|
+
const client = await switchChainInternal(params);
|
2118
|
+
return client;
|
2119
2119
|
} catch (e) {
|
2120
2120
|
const err = e instanceof Error ? e : new Error("An error occurred while switching chain");
|
2121
2121
|
setError(err);
|