@cometh/connect-react-hooks 0.0.11-dev.1 → 0.0.11-dev.3
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 +48 -45
- package/dist/index.d.cts +5 -7
- package/dist/index.d.ts +5 -7
- package/dist/index.js +13 -10
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
@@ -104,14 +104,17 @@ var ConnectProvider = ({
|
|
104
104
|
const paymasterUrl = _optionalChain([config, 'access', _8 => _8.networksConfig, 'access', _9 => _9.find, 'call', _10 => _10(
|
105
105
|
(network) => _optionalChain([network, 'access', _11 => _11.chain, 'optionalAccess', _12 => _12.id]) === chain.id
|
106
106
|
), 'optionalAccess', _13 => _13.paymasterUrl]);
|
107
|
-
|
108
|
-
|
107
|
+
const rpcUrl = _optionalChain([config, 'access', _14 => _14.networksConfig, 'access', _15 => _15.find, 'call', _16 => _16(
|
108
|
+
(network) => _optionalChain([network, 'access', _17 => _17.chain, 'optionalAccess', _18 => _18.id]) === chain.id
|
109
|
+
), 'optionalAccess', _19 => _19.rpcUrl]);
|
110
|
+
if (!bundlerUrl) throw new Error("Bundler url not found");
|
109
111
|
try {
|
110
112
|
const { client, address: newAddress } = await createSmartAccount({
|
111
113
|
...config,
|
112
114
|
chain,
|
113
115
|
bundlerUrl,
|
114
116
|
paymasterUrl,
|
117
|
+
rpcUrl,
|
115
118
|
smartAccountAddress: params.address,
|
116
119
|
comethSignerConfig: {
|
117
120
|
...config.comethSignerConfig,
|
@@ -168,8 +171,8 @@ var useAccount = () => {
|
|
168
171
|
const { smartAccountClient, smartAccountAddress } = context;
|
169
172
|
const { chain, chainId } = _react.useMemo.call(void 0,
|
170
173
|
() => ({
|
171
|
-
chain: _optionalChain([smartAccountClient, 'optionalAccess',
|
172
|
-
chainId: _optionalChain([smartAccountClient, 'optionalAccess',
|
174
|
+
chain: _optionalChain([smartAccountClient, 'optionalAccess', _20 => _20.chain]),
|
175
|
+
chainId: _optionalChain([smartAccountClient, 'optionalAccess', _21 => _21.chain, 'optionalAccess', _22 => _22.id])
|
173
176
|
}),
|
174
177
|
[smartAccountClient]
|
175
178
|
);
|
@@ -385,7 +388,7 @@ var FocusManager = (_a = class extends Subscribable {
|
|
385
388
|
if (typeof __privateGet(this, _focused) === "boolean") {
|
386
389
|
return __privateGet(this, _focused);
|
387
390
|
}
|
388
|
-
return _optionalChain([globalThis, 'access',
|
391
|
+
return _optionalChain([globalThis, 'access', _23 => _23.document, 'optionalAccess', _24 => _24.visibilityState]) !== "hidden";
|
389
392
|
}
|
390
393
|
}, _focused = new WeakMap(), _cleanup = new WeakMap(), _setup = new WeakMap(), _a);
|
391
394
|
var focusManager = new FocusManager();
|
@@ -675,7 +678,7 @@ var QueryObserver = (_a3 = class extends Subscribable {
|
|
675
678
|
enumerable: true,
|
676
679
|
get: () => {
|
677
680
|
this.trackProp(key);
|
678
|
-
_optionalChain([onPropTracked, 'optionalCall',
|
681
|
+
_optionalChain([onPropTracked, 'optionalCall', _25 => _25(key)]);
|
679
682
|
return result[key];
|
680
683
|
}
|
681
684
|
});
|
@@ -736,13 +739,13 @@ var QueryObserver = (_a3 = class extends Subscribable {
|
|
736
739
|
}
|
737
740
|
let { error, errorUpdatedAt, status } = newState;
|
738
741
|
if (options.select && newState.data !== void 0) {
|
739
|
-
if (prevResult && newState.data === _optionalChain([prevResultState, 'optionalAccess',
|
742
|
+
if (prevResult && newState.data === _optionalChain([prevResultState, 'optionalAccess', _26 => _26.data]) && options.select === __privateGet(this, _selectFn)) {
|
740
743
|
data = __privateGet(this, _selectResult);
|
741
744
|
} else {
|
742
745
|
try {
|
743
746
|
__privateSet(this, _selectFn, options.select);
|
744
747
|
data = options.select(newState.data);
|
745
|
-
data = replaceData(_optionalChain([prevResult, 'optionalAccess',
|
748
|
+
data = replaceData(_optionalChain([prevResult, 'optionalAccess', _27 => _27.data]), data, options);
|
746
749
|
__privateSet(this, _selectResult, data);
|
747
750
|
__privateSet(this, _selectError, null);
|
748
751
|
} catch (selectError) {
|
@@ -754,11 +757,11 @@ var QueryObserver = (_a3 = class extends Subscribable {
|
|
754
757
|
}
|
755
758
|
if (options.placeholderData !== void 0 && data === void 0 && status === "pending") {
|
756
759
|
let placeholderData;
|
757
|
-
if (_optionalChain([prevResult, 'optionalAccess',
|
760
|
+
if (_optionalChain([prevResult, 'optionalAccess', _28 => _28.isPlaceholderData]) && options.placeholderData === _optionalChain([prevResultOptions, 'optionalAccess', _29 => _29.placeholderData])) {
|
758
761
|
placeholderData = prevResult.data;
|
759
762
|
} else {
|
760
763
|
placeholderData = typeof options.placeholderData === "function" ? options.placeholderData(
|
761
|
-
_optionalChain([__privateGet, 'call',
|
764
|
+
_optionalChain([__privateGet, 'call', _30 => _30(this, _lastQueryWithDefinedData), 'optionalAccess', _31 => _31.state, 'access', _32 => _32.data]),
|
762
765
|
__privateGet(this, _lastQueryWithDefinedData)
|
763
766
|
) : options.placeholderData;
|
764
767
|
if (options.select && placeholderData !== void 0) {
|
@@ -773,7 +776,7 @@ var QueryObserver = (_a3 = class extends Subscribable {
|
|
773
776
|
if (placeholderData !== void 0) {
|
774
777
|
status = "success";
|
775
778
|
data = replaceData(
|
776
|
-
_optionalChain([prevResult, 'optionalAccess',
|
779
|
+
_optionalChain([prevResult, 'optionalAccess', _33 => _33.data]),
|
777
780
|
placeholderData,
|
778
781
|
options
|
779
782
|
);
|
@@ -853,7 +856,7 @@ var QueryObserver = (_a3 = class extends Subscribable {
|
|
853
856
|
return changed && includedProps.has(typedKey);
|
854
857
|
});
|
855
858
|
};
|
856
|
-
if (_optionalChain([notifyOptions, 'optionalAccess',
|
859
|
+
if (_optionalChain([notifyOptions, 'optionalAccess', _34 => _34.listeners]) !== false && shouldNotifyListeners()) {
|
857
860
|
defaultNotifyOptions.listeners = true;
|
858
861
|
}
|
859
862
|
__privateMethod(this, _QueryObserver_instances, notify_fn).call(this, { ...defaultNotifyOptions, ...notifyOptions });
|
@@ -870,7 +873,7 @@ var QueryObserver = (_a3 = class extends Subscribable {
|
|
870
873
|
this.options,
|
871
874
|
fetchOptions
|
872
875
|
);
|
873
|
-
if (!_optionalChain([fetchOptions, 'optionalAccess',
|
876
|
+
if (!_optionalChain([fetchOptions, 'optionalAccess', _35 => _35.throwOnError])) {
|
874
877
|
promise = promise.catch(noop);
|
875
878
|
}
|
876
879
|
return promise;
|
@@ -925,7 +928,7 @@ var QueryObserver = (_a3 = class extends Subscribable {
|
|
925
928
|
__privateSet(this, _currentQuery, query);
|
926
929
|
__privateSet(this, _currentQueryInitialState, query.state);
|
927
930
|
if (this.hasListeners()) {
|
928
|
-
_optionalChain([prevQuery, 'optionalAccess',
|
931
|
+
_optionalChain([prevQuery, 'optionalAccess', _36 => _36.removeObserver, 'call', _37 => _37(this)]);
|
929
932
|
query.addObserver(this);
|
930
933
|
}
|
931
934
|
}, notify_fn = function(notifyOptions) {
|
@@ -996,15 +999,15 @@ var MutationObserver = (_a4 = class extends Subscribable {
|
|
996
999
|
observer: this
|
997
1000
|
});
|
998
1001
|
}
|
999
|
-
if (_optionalChain([prevOptions, 'optionalAccess',
|
1002
|
+
if (_optionalChain([prevOptions, 'optionalAccess', _38 => _38.mutationKey]) && this.options.mutationKey && hashKey(prevOptions.mutationKey) !== hashKey(this.options.mutationKey)) {
|
1000
1003
|
this.reset();
|
1001
|
-
} else if (_optionalChain([__privateGet, 'call',
|
1004
|
+
} else if (_optionalChain([__privateGet, 'call', _39 => _39(this, _currentMutation), 'optionalAccess', _40 => _40.state, 'access', _41 => _41.status]) === "pending") {
|
1002
1005
|
__privateGet(this, _currentMutation).setOptions(this.options);
|
1003
1006
|
}
|
1004
1007
|
}
|
1005
1008
|
onUnsubscribe() {
|
1006
1009
|
if (!this.hasListeners()) {
|
1007
|
-
_optionalChain([__privateGet, 'call',
|
1010
|
+
_optionalChain([__privateGet, 'call', _42 => _42(this, _currentMutation), 'optionalAccess', _43 => _43.removeObserver, 'call', _44 => _44(this)]);
|
1008
1011
|
}
|
1009
1012
|
}
|
1010
1013
|
onMutationUpdate(action) {
|
@@ -1015,20 +1018,20 @@ var MutationObserver = (_a4 = class extends Subscribable {
|
|
1015
1018
|
return __privateGet(this, _currentResult2);
|
1016
1019
|
}
|
1017
1020
|
reset() {
|
1018
|
-
_optionalChain([__privateGet, 'call',
|
1021
|
+
_optionalChain([__privateGet, 'call', _45 => _45(this, _currentMutation), 'optionalAccess', _46 => _46.removeObserver, 'call', _47 => _47(this)]);
|
1019
1022
|
__privateSet(this, _currentMutation, void 0);
|
1020
1023
|
__privateMethod(this, _MutationObserver_instances, updateResult_fn).call(this);
|
1021
1024
|
__privateMethod(this, _MutationObserver_instances, notify_fn2).call(this);
|
1022
1025
|
}
|
1023
1026
|
mutate(variables, options) {
|
1024
1027
|
__privateSet(this, _mutateOptions, options);
|
1025
|
-
_optionalChain([__privateGet, 'call',
|
1028
|
+
_optionalChain([__privateGet, 'call', _48 => _48(this, _currentMutation), 'optionalAccess', _49 => _49.removeObserver, 'call', _50 => _50(this)]);
|
1026
1029
|
__privateSet(this, _currentMutation, __privateGet(this, _client2).getMutationCache().build(__privateGet(this, _client2), this.options));
|
1027
1030
|
__privateGet(this, _currentMutation).addObserver(this);
|
1028
1031
|
return __privateGet(this, _currentMutation).execute(variables);
|
1029
1032
|
}
|
1030
1033
|
}, _client2 = new WeakMap(), _currentResult2 = new WeakMap(), _currentMutation = new WeakMap(), _mutateOptions = new WeakMap(), _MutationObserver_instances = new WeakSet(), updateResult_fn = function() {
|
1031
|
-
const state = _nullishCoalesce(_optionalChain([__privateGet, 'call',
|
1034
|
+
const state = _nullishCoalesce(_optionalChain([__privateGet, 'call', _51 => _51(this, _currentMutation), 'optionalAccess', _52 => _52.state]), () => ( getDefaultState()));
|
1032
1035
|
__privateSet(this, _currentResult2, {
|
1033
1036
|
...state,
|
1034
1037
|
isPending: state.status === "pending",
|
@@ -1043,12 +1046,12 @@ var MutationObserver = (_a4 = class extends Subscribable {
|
|
1043
1046
|
if (__privateGet(this, _mutateOptions) && this.hasListeners()) {
|
1044
1047
|
const variables = __privateGet(this, _currentResult2).variables;
|
1045
1048
|
const context = __privateGet(this, _currentResult2).context;
|
1046
|
-
if (_optionalChain([action, 'optionalAccess',
|
1047
|
-
_optionalChain([__privateGet, 'call',
|
1048
|
-
_optionalChain([__privateGet, 'call',
|
1049
|
-
} else if (_optionalChain([action, 'optionalAccess',
|
1050
|
-
_optionalChain([__privateGet, 'call',
|
1051
|
-
_optionalChain([__privateGet, 'call',
|
1049
|
+
if (_optionalChain([action, 'optionalAccess', _53 => _53.type]) === "success") {
|
1050
|
+
_optionalChain([__privateGet, 'call', _54 => _54(this, _mutateOptions), 'access', _55 => _55.onSuccess, 'optionalCall', _56 => _56(action.data, variables, context)]);
|
1051
|
+
_optionalChain([__privateGet, 'call', _57 => _57(this, _mutateOptions), 'access', _58 => _58.onSettled, 'optionalCall', _59 => _59(action.data, null, variables, context)]);
|
1052
|
+
} else if (_optionalChain([action, 'optionalAccess', _60 => _60.type]) === "error") {
|
1053
|
+
_optionalChain([__privateGet, 'call', _61 => _61(this, _mutateOptions), 'access', _62 => _62.onError, 'optionalCall', _63 => _63(action.error, variables, context)]);
|
1054
|
+
_optionalChain([__privateGet, 'call', _64 => _64(this, _mutateOptions), 'access', _65 => _65.onSettled, 'optionalCall', _66 => _66(
|
1052
1055
|
void 0,
|
1053
1056
|
action.error,
|
1054
1057
|
variables,
|
@@ -1148,7 +1151,7 @@ var ensureStaleTime = (defaultedOptions) => {
|
|
1148
1151
|
}
|
1149
1152
|
}
|
1150
1153
|
};
|
1151
|
-
var shouldSuspend = (defaultedOptions, result) => _optionalChain([defaultedOptions, 'optionalAccess',
|
1154
|
+
var shouldSuspend = (defaultedOptions, result) => _optionalChain([defaultedOptions, 'optionalAccess', _67 => _67.suspense]) && result.isPending;
|
1152
1155
|
var fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).catch(() => {
|
1153
1156
|
errorResetBoundary.clearReset();
|
1154
1157
|
});
|
@@ -1167,7 +1170,7 @@ function useBaseQuery(options, Observer, queryClient) {
|
|
1167
1170
|
const isRestoring = useIsRestoring();
|
1168
1171
|
const errorResetBoundary = useQueryErrorResetBoundary();
|
1169
1172
|
const defaultedOptions = client.defaultQueryOptions(options);
|
1170
|
-
_optionalChain([client, 'access',
|
1173
|
+
_optionalChain([client, 'access', _68 => _68.getDefaultOptions, 'call', _69 => _69(), 'access', _70 => _70.queries, 'optionalAccess', _71 => _71._experimental_beforeQuery, 'optionalCall', _72 => _72(
|
1171
1174
|
defaultedOptions
|
1172
1175
|
)]);
|
1173
1176
|
defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic";
|
@@ -1208,7 +1211,7 @@ function useBaseQuery(options, Observer, queryClient) {
|
|
1208
1211
|
throw result.error;
|
1209
1212
|
}
|
1210
1213
|
;
|
1211
|
-
_optionalChain([client, 'access',
|
1214
|
+
_optionalChain([client, 'access', _73 => _73.getDefaultOptions, 'call', _74 => _74(), 'access', _75 => _75.queries, 'optionalAccess', _76 => _76._experimental_afterQuery, 'optionalCall', _77 => _77(
|
1212
1215
|
defaultedOptions,
|
1213
1216
|
result
|
1214
1217
|
)]);
|
@@ -1412,7 +1415,7 @@ var useConnect = () => {
|
|
1412
1415
|
setIsPending(true);
|
1413
1416
|
setError(null);
|
1414
1417
|
updateSmartAccountClient(params).then(() => {
|
1415
|
-
_optionalChain([queryClient, 'optionalAccess',
|
1418
|
+
_optionalChain([queryClient, 'optionalAccess', _78 => _78.invalidateQueries, 'call', _79 => _79({
|
1416
1419
|
queryKey: ["connect"]
|
1417
1420
|
})]);
|
1418
1421
|
}).catch((e) => {
|
@@ -1430,7 +1433,7 @@ var useConnect = () => {
|
|
1430
1433
|
setError(null);
|
1431
1434
|
try {
|
1432
1435
|
await updateSmartAccountClient(params);
|
1433
|
-
_optionalChain([queryClient, 'optionalAccess',
|
1436
|
+
_optionalChain([queryClient, 'optionalAccess', _80 => _80.invalidateQueries, 'call', _81 => _81({ queryKey: ["connect"] })]);
|
1434
1437
|
} catch (e) {
|
1435
1438
|
const err = e instanceof Error ? e : new Error("An error occurred");
|
1436
1439
|
setError(err);
|
@@ -1463,7 +1466,7 @@ var useDisconnect = () => {
|
|
1463
1466
|
setIsPending(true);
|
1464
1467
|
setError(null);
|
1465
1468
|
disconnectSmartAccount().then(() => {
|
1466
|
-
_optionalChain([queryClient, 'optionalAccess',
|
1469
|
+
_optionalChain([queryClient, 'optionalAccess', _82 => _82.invalidateQueries, 'call', _83 => _83({
|
1467
1470
|
queryKey: ["connect"]
|
1468
1471
|
})]);
|
1469
1472
|
}).catch((e) => {
|
@@ -1478,7 +1481,7 @@ var useDisconnect = () => {
|
|
1478
1481
|
setError(null);
|
1479
1482
|
try {
|
1480
1483
|
await disconnectSmartAccount();
|
1481
|
-
_optionalChain([queryClient, 'optionalAccess',
|
1484
|
+
_optionalChain([queryClient, 'optionalAccess', _84 => _84.invalidateQueries, 'call', _85 => _85({ queryKey: ["connect"] })]);
|
1482
1485
|
} catch (e) {
|
1483
1486
|
const err = e instanceof Error ? e : new Error("An error occurred during disconnection");
|
1484
1487
|
setError(err);
|
@@ -1915,7 +1918,7 @@ var useCreateNewSigner = (apiKey, baseUrl) => {
|
|
1915
1918
|
setIsPending(true);
|
1916
1919
|
setError(null);
|
1917
1920
|
_connectsdk4337.createNewSigner.call(void 0, { apiKey, baseUrl, params }).then((signer) => {
|
1918
|
-
_optionalChain([queryClient, 'optionalAccess',
|
1921
|
+
_optionalChain([queryClient, 'optionalAccess', _86 => _86.invalidateQueries, 'call', _87 => _87({ queryKey: ["signer"] })]);
|
1919
1922
|
return signer;
|
1920
1923
|
}).catch((e) => {
|
1921
1924
|
const err = e instanceof Error ? e : new Error("An error occurred");
|
@@ -1936,7 +1939,7 @@ var useCreateNewSigner = (apiKey, baseUrl) => {
|
|
1936
1939
|
baseUrl,
|
1937
1940
|
params
|
1938
1941
|
});
|
1939
|
-
_optionalChain([queryClient, 'optionalAccess',
|
1942
|
+
_optionalChain([queryClient, 'optionalAccess', _88 => _88.invalidateQueries, 'call', _89 => _89({ queryKey: ["signer"] })]);
|
1940
1943
|
return signer;
|
1941
1944
|
} catch (e) {
|
1942
1945
|
const err = e instanceof Error ? e : new Error("An error occurred");
|
@@ -2182,9 +2185,7 @@ function useCancelRecoveryRequest() {
|
|
2182
2185
|
|
2183
2186
|
// src/hooks/useSwitchChain.ts
|
2184
2187
|
|
2185
|
-
|
2186
2188
|
var useSwitchChain = () => {
|
2187
|
-
const { address } = _wagmi.useAccount.call(void 0, );
|
2188
2189
|
const context = _react.useContext.call(void 0, ConnectContext);
|
2189
2190
|
if (context === void 0) {
|
2190
2191
|
throw new Error("useSwitchChain must be used within a ConnectProvider");
|
@@ -2199,16 +2200,20 @@ var useSwitchChain = () => {
|
|
2199
2200
|
const [error, setError] = _react.useState.call(void 0, null);
|
2200
2201
|
const switchChainInternal = _react.useCallback.call(void 0,
|
2201
2202
|
async (params) => {
|
2202
|
-
const {
|
2203
|
-
if (!networksConfig)
|
2203
|
+
const { chainId } = params;
|
2204
|
+
if (!networksConfig)
|
2205
|
+
throw new Error("No current configuration found");
|
2206
|
+
const selectedNetwork = _optionalChain([networksConfig, 'optionalAccess', _90 => _90.find, 'call', _91 => _91(
|
2207
|
+
(network) => _optionalChain([network, 'access', _92 => _92.chain, 'optionalAccess', _93 => _93.id]) === chainId
|
2208
|
+
)]);
|
2209
|
+
if (!selectedNetwork)
|
2204
2210
|
throw new Error("No current configuration found");
|
2205
|
-
}
|
2206
2211
|
try {
|
2207
2212
|
await updateSmartAccountClient({
|
2208
|
-
address: _optionalChain([smartAccountClient, 'optionalAccess',
|
2209
|
-
chain
|
2213
|
+
address: _optionalChain([smartAccountClient, 'optionalAccess', _94 => _94.account, 'access', _95 => _95.address]),
|
2214
|
+
chain: selectedNetwork.chain
|
2210
2215
|
});
|
2211
|
-
_optionalChain([queryClient, 'optionalAccess',
|
2216
|
+
_optionalChain([queryClient, 'optionalAccess', _96 => _96.invalidateQueries, 'call', _97 => _97({
|
2212
2217
|
queryKey: ["switchChain"]
|
2213
2218
|
})]);
|
2214
2219
|
} catch (e) {
|
@@ -2224,7 +2229,6 @@ var useSwitchChain = () => {
|
|
2224
2229
|
);
|
2225
2230
|
const switchChain = _react.useCallback.call(void 0,
|
2226
2231
|
(params) => {
|
2227
|
-
if (!address) throw new Error("No connected wallet");
|
2228
2232
|
setIsPending(true);
|
2229
2233
|
setError(null);
|
2230
2234
|
switchChainInternal(params).catch((e) => {
|
@@ -2240,7 +2244,6 @@ var useSwitchChain = () => {
|
|
2240
2244
|
);
|
2241
2245
|
const switchChainAsync = _react.useCallback.call(void 0,
|
2242
2246
|
async (params) => {
|
2243
|
-
if (!address) throw new Error("No connected wallet");
|
2244
2247
|
setIsPending(true);
|
2245
2248
|
setError(null);
|
2246
2249
|
try {
|
package/dist/index.d.cts
CHANGED
@@ -45,14 +45,12 @@ type NetworkParams = {
|
|
45
45
|
chain?: Chain;
|
46
46
|
bundlerUrl?: string;
|
47
47
|
paymasterUrl?: string;
|
48
|
+
rpcUrl?: string;
|
48
49
|
};
|
49
|
-
type OmitConfig<T> = Omit<T, "chain" | "paymasterUrl" | "bundlerUrl"> & {
|
50
|
+
type OmitConfig<T> = Omit<T, "chain" | "paymasterUrl" | "bundlerUrl" | "rpcUrl"> & {
|
50
51
|
networksConfig: NetworkParams[];
|
51
52
|
};
|
52
|
-
type ConnectConfig = OmitConfig<createSafeSmartAccountParameters<ENTRYPOINT_ADDRESS_V07_TYPE
|
53
|
-
bundlerUrl: string;
|
54
|
-
paymasterUrl?: string;
|
55
|
-
}>;
|
53
|
+
type ConnectConfig = OmitConfig<createSafeSmartAccountParameters<ENTRYPOINT_ADDRESS_V07_TYPE>>;
|
56
54
|
type ContextComethSmartAccountClient = ComethSmartAccountClient<SafeSmartAccount<ENTRYPOINT_ADDRESS_V07_TYPE, Transport, Chain>, Transport, Chain, ENTRYPOINT_ADDRESS_V07_TYPE>;
|
57
55
|
declare const ConnectProvider: <TConfig extends ConnectConfig, TQueryClient extends b | undefined>({ children, config, queryClient, }: {
|
58
56
|
children: ReactNode;
|
@@ -941,10 +939,10 @@ declare function useCancelRecoveryRequest(): UseCancelRecoveryRequestReturn;
|
|
941
939
|
|
942
940
|
declare const useSwitchChain: () => {
|
943
941
|
switchChain: (params: {
|
944
|
-
|
942
|
+
chainId: number;
|
945
943
|
}) => void;
|
946
944
|
switchChainAsync: (params: {
|
947
|
-
|
945
|
+
chainId: number;
|
948
946
|
}) => Promise<void>;
|
949
947
|
isPending: boolean;
|
950
948
|
error: Error | null;
|
package/dist/index.d.ts
CHANGED
@@ -45,14 +45,12 @@ type NetworkParams = {
|
|
45
45
|
chain?: Chain;
|
46
46
|
bundlerUrl?: string;
|
47
47
|
paymasterUrl?: string;
|
48
|
+
rpcUrl?: string;
|
48
49
|
};
|
49
|
-
type OmitConfig<T> = Omit<T, "chain" | "paymasterUrl" | "bundlerUrl"> & {
|
50
|
+
type OmitConfig<T> = Omit<T, "chain" | "paymasterUrl" | "bundlerUrl" | "rpcUrl"> & {
|
50
51
|
networksConfig: NetworkParams[];
|
51
52
|
};
|
52
|
-
type ConnectConfig = OmitConfig<createSafeSmartAccountParameters<ENTRYPOINT_ADDRESS_V07_TYPE
|
53
|
-
bundlerUrl: string;
|
54
|
-
paymasterUrl?: string;
|
55
|
-
}>;
|
53
|
+
type ConnectConfig = OmitConfig<createSafeSmartAccountParameters<ENTRYPOINT_ADDRESS_V07_TYPE>>;
|
56
54
|
type ContextComethSmartAccountClient = ComethSmartAccountClient<SafeSmartAccount<ENTRYPOINT_ADDRESS_V07_TYPE, Transport, Chain>, Transport, Chain, ENTRYPOINT_ADDRESS_V07_TYPE>;
|
57
55
|
declare const ConnectProvider: <TConfig extends ConnectConfig, TQueryClient extends b | undefined>({ children, config, queryClient, }: {
|
58
56
|
children: ReactNode;
|
@@ -941,10 +939,10 @@ declare function useCancelRecoveryRequest(): UseCancelRecoveryRequestReturn;
|
|
941
939
|
|
942
940
|
declare const useSwitchChain: () => {
|
943
941
|
switchChain: (params: {
|
944
|
-
|
942
|
+
chainId: number;
|
945
943
|
}) => void;
|
946
944
|
switchChainAsync: (params: {
|
947
|
-
|
945
|
+
chainId: number;
|
948
946
|
}) => Promise<void>;
|
949
947
|
isPending: boolean;
|
950
948
|
error: Error | null;
|
package/dist/index.js
CHANGED
@@ -104,14 +104,17 @@ var ConnectProvider = ({
|
|
104
104
|
const paymasterUrl = config.networksConfig.find(
|
105
105
|
(network) => network.chain?.id === chain.id
|
106
106
|
)?.paymasterUrl;
|
107
|
-
|
108
|
-
|
107
|
+
const rpcUrl = config.networksConfig.find(
|
108
|
+
(network) => network.chain?.id === chain.id
|
109
|
+
)?.rpcUrl;
|
110
|
+
if (!bundlerUrl) throw new Error("Bundler url not found");
|
109
111
|
try {
|
110
112
|
const { client, address: newAddress } = await createSmartAccount({
|
111
113
|
...config,
|
112
114
|
chain,
|
113
115
|
bundlerUrl,
|
114
116
|
paymasterUrl,
|
117
|
+
rpcUrl,
|
115
118
|
smartAccountAddress: params.address,
|
116
119
|
comethSignerConfig: {
|
117
120
|
...config.comethSignerConfig,
|
@@ -2182,9 +2185,7 @@ function useCancelRecoveryRequest() {
|
|
2182
2185
|
|
2183
2186
|
// src/hooks/useSwitchChain.ts
|
2184
2187
|
import { useCallback as useCallback8, useContext as useContext8, useState as useState9 } from "react";
|
2185
|
-
import { useAccount as useAccount2 } from "wagmi";
|
2186
2188
|
var useSwitchChain = () => {
|
2187
|
-
const { address } = useAccount2();
|
2188
2189
|
const context = useContext8(ConnectContext);
|
2189
2190
|
if (context === void 0) {
|
2190
2191
|
throw new Error("useSwitchChain must be used within a ConnectProvider");
|
@@ -2199,14 +2200,18 @@ var useSwitchChain = () => {
|
|
2199
2200
|
const [error, setError] = useState9(null);
|
2200
2201
|
const switchChainInternal = useCallback8(
|
2201
2202
|
async (params) => {
|
2202
|
-
const {
|
2203
|
-
if (!networksConfig)
|
2203
|
+
const { chainId } = params;
|
2204
|
+
if (!networksConfig)
|
2205
|
+
throw new Error("No current configuration found");
|
2206
|
+
const selectedNetwork = networksConfig?.find(
|
2207
|
+
(network) => network.chain?.id === chainId
|
2208
|
+
);
|
2209
|
+
if (!selectedNetwork)
|
2204
2210
|
throw new Error("No current configuration found");
|
2205
|
-
}
|
2206
2211
|
try {
|
2207
2212
|
await updateSmartAccountClient({
|
2208
2213
|
address: smartAccountClient?.account.address,
|
2209
|
-
chain
|
2214
|
+
chain: selectedNetwork.chain
|
2210
2215
|
});
|
2211
2216
|
queryClient?.invalidateQueries({
|
2212
2217
|
queryKey: ["switchChain"]
|
@@ -2224,7 +2229,6 @@ var useSwitchChain = () => {
|
|
2224
2229
|
);
|
2225
2230
|
const switchChain = useCallback8(
|
2226
2231
|
(params) => {
|
2227
|
-
if (!address) throw new Error("No connected wallet");
|
2228
2232
|
setIsPending(true);
|
2229
2233
|
setError(null);
|
2230
2234
|
switchChainInternal(params).catch((e) => {
|
@@ -2240,7 +2244,6 @@ var useSwitchChain = () => {
|
|
2240
2244
|
);
|
2241
2245
|
const switchChainAsync = useCallback8(
|
2242
2246
|
async (params) => {
|
2243
|
-
if (!address) throw new Error("No connected wallet");
|
2244
2247
|
setIsPending(true);
|
2245
2248
|
setError(null);
|
2246
2249
|
try {
|
package/package.json
CHANGED