wagmi 0.7.3 → 0.7.4
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/declarations/src/hooks/contracts/useContractInfiniteReads.d.ts +2 -2
- package/dist/declarations/src/hooks/contracts/usePrepareContractWrite.d.ts +2 -2
- package/dist/declarations/src/hooks/transactions/usePrepareSendTransaction.d.ts +2 -2
- package/dist/declarations/src/hooks/utils/query/useInfiniteQuery.d.ts +2 -2
- package/dist/declarations/src/hooks/utils/query/useQuery.d.ts +2 -2
- package/dist/wagmi.cjs.dev.js +14 -24
- package/dist/wagmi.cjs.prod.js +14 -24
- package/dist/wagmi.esm.js +14 -24
- package/package.json +1 -1
|
@@ -124,10 +124,10 @@ export declare function useContractInfiniteReads<TAbi extends Abi | readonly unk
|
|
|
124
124
|
functionName: TFunctionName_1;
|
|
125
125
|
}>[] : ({
|
|
126
126
|
[x: string]: unknown;
|
|
127
|
-
} & readonly unknown[])[], Error>, "error" | "data" | "fetchStatus" | "isError" | "isFetched" | "isFetching" | "isLoading" | "isRefetching" | "isSuccess" | "refetch" | "fetchNextPage" | "hasNextPage" | "isFetchingNextPage"> & {
|
|
127
|
+
} & readonly unknown[])[], Error>, "error" | "data" | "fetchStatus" | "isError" | "isFetched" | "isFetchedAfterMount" | "isFetching" | "isLoading" | "isRefetching" | "isSuccess" | "refetch" | "fetchNextPage" | "hasNextPage" | "isFetchingNextPage"> & {
|
|
128
128
|
isIdle: boolean;
|
|
129
129
|
status: "error" | "success" | "idle" | "loading";
|
|
130
|
-
internal: Pick<import("@tanstack/react-query").InfiniteQueryObserverResult<unknown, unknown>, "failureCount" | "isPaused" | "dataUpdatedAt" | "errorUpdatedAt" | "
|
|
130
|
+
internal: Pick<import("@tanstack/react-query").InfiniteQueryObserverResult<unknown, unknown>, "failureCount" | "isPaused" | "dataUpdatedAt" | "errorUpdatedAt" | "isLoadingError" | "isPlaceholderData" | "isPreviousData" | "isRefetchError" | "isStale" | "remove">;
|
|
131
131
|
};
|
|
132
132
|
export declare function paginatedIndexesConfig<TAbi extends Abi | readonly unknown[], TFunctionName extends string, TContracts extends {
|
|
133
133
|
abi: TAbi;
|
|
@@ -24,10 +24,10 @@ export declare type UsePrepareContractWriteConfig<TAbi extends Abi | readonly un
|
|
|
24
24
|
* const { data, isLoading, isSuccess, write } = useContractWrite(config)
|
|
25
25
|
*
|
|
26
26
|
*/
|
|
27
|
-
export declare function usePrepareContractWrite<TAbi extends Abi | readonly unknown[], TFunctionName extends string>({ address, abi, functionName, chainId, args, overrides, cacheTime, enabled, staleTime, suspense, onError, onSettled, onSuccess, }?: UsePrepareContractWriteConfig<TAbi, TFunctionName>): Pick<import("@tanstack/react-query").QueryObserverResult<PrepareWriteContractResult<Abi, string>, Error>, "error" | "data" | "fetchStatus" | "isError" | "isFetched" | "isFetching" | "isLoading" | "isRefetching" | "isSuccess" | "refetch"> & {
|
|
27
|
+
export declare function usePrepareContractWrite<TAbi extends Abi | readonly unknown[], TFunctionName extends string>({ address, abi, functionName, chainId, args, overrides, cacheTime, enabled, staleTime, suspense, onError, onSettled, onSuccess, }?: UsePrepareContractWriteConfig<TAbi, TFunctionName>): Pick<import("@tanstack/react-query").QueryObserverResult<PrepareWriteContractResult<Abi, string>, Error>, "error" | "data" | "fetchStatus" | "isError" | "isFetched" | "isFetchedAfterMount" | "isFetching" | "isLoading" | "isRefetching" | "isSuccess" | "refetch"> & {
|
|
28
28
|
isIdle: boolean;
|
|
29
29
|
status: "error" | "success" | "idle" | "loading";
|
|
30
|
-
internal: Pick<import("@tanstack/react-query").QueryObserverResult<unknown, unknown>, "failureCount" | "isPaused" | "dataUpdatedAt" | "errorUpdatedAt" | "
|
|
30
|
+
internal: Pick<import("@tanstack/react-query").QueryObserverResult<unknown, unknown>, "failureCount" | "isPaused" | "dataUpdatedAt" | "errorUpdatedAt" | "isLoadingError" | "isPlaceholderData" | "isPreviousData" | "isRefetchError" | "isStale" | "remove">;
|
|
31
31
|
} & {
|
|
32
32
|
config: PrepareWriteContractResult<TAbi, TFunctionName>;
|
|
33
33
|
};
|
|
@@ -16,10 +16,10 @@ export declare type UsePrepareSendTransactionConfig = Partial<PrepareSendTransac
|
|
|
16
16
|
* const result = useSendTransaction(config)
|
|
17
17
|
*/
|
|
18
18
|
export declare function usePrepareSendTransaction({ chainId, request, cacheTime, enabled, staleTime, // 24 hours
|
|
19
|
-
suspense, onError, onSettled, onSuccess, }?: UsePrepareSendTransactionConfig): Pick<import("@tanstack/react-query").QueryObserverResult<PrepareSendTransactionResult, Error>, "error" | "data" | "fetchStatus" | "isError" | "isFetched" | "isFetching" | "isLoading" | "isRefetching" | "isSuccess" | "refetch"> & {
|
|
19
|
+
suspense, onError, onSettled, onSuccess, }?: UsePrepareSendTransactionConfig): Pick<import("@tanstack/react-query").QueryObserverResult<PrepareSendTransactionResult, Error>, "error" | "data" | "fetchStatus" | "isError" | "isFetched" | "isFetchedAfterMount" | "isFetching" | "isLoading" | "isRefetching" | "isSuccess" | "refetch"> & {
|
|
20
20
|
isIdle: boolean;
|
|
21
21
|
status: "error" | "success" | "idle" | "loading";
|
|
22
|
-
internal: Pick<import("@tanstack/react-query").QueryObserverResult<unknown, unknown>, "failureCount" | "isPaused" | "dataUpdatedAt" | "errorUpdatedAt" | "
|
|
22
|
+
internal: Pick<import("@tanstack/react-query").QueryObserverResult<unknown, unknown>, "failureCount" | "isPaused" | "dataUpdatedAt" | "errorUpdatedAt" | "isLoadingError" | "isPlaceholderData" | "isPreviousData" | "isRefetchError" | "isStale" | "remove">;
|
|
23
23
|
} & {
|
|
24
24
|
config: PrepareSendTransactionResult;
|
|
25
25
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { InfiniteQueryObserverResult, QueryFunction, QueryKey, UseInfiniteQueryOptions } from '@tanstack/react-query';
|
|
2
|
-
declare type UseInfiniteQueryResult<TData, TError> = Pick<InfiniteQueryObserverResult<TData, TError>, 'data' | 'error' | 'fetchNextPage' | 'fetchStatus' | 'hasNextPage' | 'isError' | 'isFetched' | 'isFetching' | 'isFetchingNextPage' | 'isLoading' | 'isRefetching' | 'isSuccess' | 'refetch'> & {
|
|
2
|
+
declare type UseInfiniteQueryResult<TData, TError> = Pick<InfiniteQueryObserverResult<TData, TError>, 'data' | 'error' | 'fetchNextPage' | 'fetchStatus' | 'hasNextPage' | 'isError' | 'isFetched' | 'isFetchedAfterMount' | 'isFetching' | 'isFetchingNextPage' | 'isLoading' | 'isRefetching' | 'isSuccess' | 'refetch'> & {
|
|
3
3
|
isIdle: boolean;
|
|
4
4
|
status: 'idle' | 'loading' | 'success' | 'error';
|
|
5
|
-
internal: Pick<InfiniteQueryObserverResult, 'dataUpdatedAt' | 'errorUpdatedAt' | 'failureCount' | '
|
|
5
|
+
internal: Pick<InfiniteQueryObserverResult, 'dataUpdatedAt' | 'errorUpdatedAt' | 'failureCount' | 'isLoadingError' | 'isPaused' | 'isPlaceholderData' | 'isPreviousData' | 'isRefetchError' | 'isStale' | 'remove'>;
|
|
6
6
|
};
|
|
7
7
|
export declare function useInfiniteQuery<TQueryFnData = unknown, TError = unknown, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>): UseInfiniteQueryResult<TData, TError>;
|
|
8
8
|
export declare function useInfiniteQuery<TQueryFnData = unknown, TError = unknown, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(queryKey: TQueryKey, options?: Omit<UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>, 'queryKey'>): UseInfiniteQueryResult<TData, TError>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { QueryFunction, QueryKey, QueryObserverResult, UseQueryOptions } from '@tanstack/react-query';
|
|
2
|
-
export declare type UseQueryResult<TData, TError> = Pick<QueryObserverResult<TData, TError>, 'data' | 'error' | 'fetchStatus' | 'isError' | 'isFetched' | 'isFetching' | 'isLoading' | 'isRefetching' | 'isSuccess' | 'refetch'> & {
|
|
2
|
+
export declare type UseQueryResult<TData, TError> = Pick<QueryObserverResult<TData, TError>, 'data' | 'error' | 'fetchStatus' | 'isError' | 'isFetched' | 'isFetchedAfterMount' | 'isFetching' | 'isLoading' | 'isRefetching' | 'isSuccess' | 'refetch'> & {
|
|
3
3
|
isIdle: boolean;
|
|
4
4
|
status: 'idle' | 'loading' | 'success' | 'error';
|
|
5
|
-
internal: Pick<QueryObserverResult, 'dataUpdatedAt' | 'errorUpdatedAt' | 'failureCount' | '
|
|
5
|
+
internal: Pick<QueryObserverResult, 'dataUpdatedAt' | 'errorUpdatedAt' | 'failureCount' | 'isLoadingError' | 'isPaused' | 'isPlaceholderData' | 'isPreviousData' | 'isRefetchError' | 'isStale' | 'remove'>;
|
|
6
6
|
};
|
|
7
7
|
export declare type DefinedUseQueryResult<TData = unknown, TError = unknown> = Omit<UseQueryResult<TData, TError>, 'data'> & {
|
|
8
8
|
data: TData;
|
package/dist/wagmi.cjs.dev.js
CHANGED
|
@@ -383,6 +383,7 @@ function useInfiniteQuery(arg1, arg2, arg3) {
|
|
|
383
383
|
hasNextPage: baseQuery.hasNextPage,
|
|
384
384
|
isError: baseQuery.isError,
|
|
385
385
|
isFetched: baseQuery.isFetched,
|
|
386
|
+
isFetchedAfterMount: baseQuery.isFetchedAfterMount,
|
|
386
387
|
isFetching: baseQuery.isFetching,
|
|
387
388
|
isFetchingNextPage: baseQuery.isFetchingNextPage,
|
|
388
389
|
isIdle: baseQuery.isIdle,
|
|
@@ -395,6 +396,7 @@ function useInfiniteQuery(arg1, arg2, arg3) {
|
|
|
395
396
|
dataUpdatedAt: baseQuery.dataUpdatedAt,
|
|
396
397
|
errorUpdatedAt: baseQuery.errorUpdatedAt,
|
|
397
398
|
failureCount: baseQuery.failureCount,
|
|
399
|
+
// TODO: Remove `isFetchedAfterMount` in next minor version (v0.8).
|
|
398
400
|
isFetchedAfterMount: baseQuery.isFetchedAfterMount,
|
|
399
401
|
isLoadingError: baseQuery.isLoadingError,
|
|
400
402
|
isPaused: baseQuery.isPaused,
|
|
@@ -429,6 +431,7 @@ function useQuery(arg1, arg2, arg3) {
|
|
|
429
431
|
fetchStatus: baseQuery.fetchStatus,
|
|
430
432
|
isError: baseQuery.isError,
|
|
431
433
|
isFetched: baseQuery.isFetched,
|
|
434
|
+
isFetchedAfterMount: baseQuery.isFetchedAfterMount,
|
|
432
435
|
isFetching: baseQuery.isFetching,
|
|
433
436
|
isIdle: baseQuery.isIdle,
|
|
434
437
|
isLoading: baseQuery.isLoading,
|
|
@@ -440,6 +443,7 @@ function useQuery(arg1, arg2, arg3) {
|
|
|
440
443
|
dataUpdatedAt: baseQuery.dataUpdatedAt,
|
|
441
444
|
errorUpdatedAt: baseQuery.errorUpdatedAt,
|
|
442
445
|
failureCount: baseQuery.failureCount,
|
|
446
|
+
// TODO: Remove `isFetchedAfterMount` in next minor version (v0.8).
|
|
443
447
|
isFetchedAfterMount: baseQuery.isFetchedAfterMount,
|
|
444
448
|
isLoadingError: baseQuery.isLoadingError,
|
|
445
449
|
isPaused: baseQuery.isPaused,
|
|
@@ -703,35 +707,21 @@ function useSyncExternalStoreWithTracked(subscribe, getSnapshot) {
|
|
|
703
707
|
}
|
|
704
708
|
|
|
705
709
|
function useAccount() {
|
|
710
|
+
var _previousAccount$curr, _previousAccount$curr2, _previousAccount$curr3;
|
|
711
|
+
|
|
706
712
|
let {
|
|
707
713
|
onConnect,
|
|
708
714
|
onDisconnect
|
|
709
715
|
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
710
716
|
const account = useSyncExternalStoreWithTracked(core.watchAccount, core.getAccount);
|
|
711
|
-
const
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
if (!!onConnect && status === 'connected') {
|
|
720
|
-
const {
|
|
721
|
-
address,
|
|
722
|
-
connector
|
|
723
|
-
} = core.getAccount();
|
|
724
|
-
onConnect({
|
|
725
|
-
address,
|
|
726
|
-
connector,
|
|
727
|
-
isReconnected: prevStatus === 'reconnecting'
|
|
728
|
-
});
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
if (!!onDisconnect && prevStatus !== 'connecting' && status === 'disconnected') onDisconnect();
|
|
732
|
-
});
|
|
733
|
-
return unsubscribe;
|
|
734
|
-
}, [onConnect, onDisconnect, subscribe]);
|
|
717
|
+
const previousAccount = React__namespace.useRef();
|
|
718
|
+
if (!!onConnect && ((_previousAccount$curr = previousAccount.current) === null || _previousAccount$curr === void 0 ? void 0 : _previousAccount$curr.status) !== 'connected' && account.status === 'connected') onConnect({
|
|
719
|
+
address: account.address,
|
|
720
|
+
connector: account.connector,
|
|
721
|
+
isReconnected: ((_previousAccount$curr2 = previousAccount.current) === null || _previousAccount$curr2 === void 0 ? void 0 : _previousAccount$curr2.status) === 'reconnecting'
|
|
722
|
+
});
|
|
723
|
+
if (!!onDisconnect && ((_previousAccount$curr3 = previousAccount.current) === null || _previousAccount$curr3 === void 0 ? void 0 : _previousAccount$curr3.status) == 'connected' && account.status === 'disconnected') onDisconnect();
|
|
724
|
+
previousAccount.current = account;
|
|
735
725
|
return account;
|
|
736
726
|
}
|
|
737
727
|
|
package/dist/wagmi.cjs.prod.js
CHANGED
|
@@ -383,6 +383,7 @@ function useInfiniteQuery(arg1, arg2, arg3) {
|
|
|
383
383
|
hasNextPage: baseQuery.hasNextPage,
|
|
384
384
|
isError: baseQuery.isError,
|
|
385
385
|
isFetched: baseQuery.isFetched,
|
|
386
|
+
isFetchedAfterMount: baseQuery.isFetchedAfterMount,
|
|
386
387
|
isFetching: baseQuery.isFetching,
|
|
387
388
|
isFetchingNextPage: baseQuery.isFetchingNextPage,
|
|
388
389
|
isIdle: baseQuery.isIdle,
|
|
@@ -395,6 +396,7 @@ function useInfiniteQuery(arg1, arg2, arg3) {
|
|
|
395
396
|
dataUpdatedAt: baseQuery.dataUpdatedAt,
|
|
396
397
|
errorUpdatedAt: baseQuery.errorUpdatedAt,
|
|
397
398
|
failureCount: baseQuery.failureCount,
|
|
399
|
+
// TODO: Remove `isFetchedAfterMount` in next minor version (v0.8).
|
|
398
400
|
isFetchedAfterMount: baseQuery.isFetchedAfterMount,
|
|
399
401
|
isLoadingError: baseQuery.isLoadingError,
|
|
400
402
|
isPaused: baseQuery.isPaused,
|
|
@@ -429,6 +431,7 @@ function useQuery(arg1, arg2, arg3) {
|
|
|
429
431
|
fetchStatus: baseQuery.fetchStatus,
|
|
430
432
|
isError: baseQuery.isError,
|
|
431
433
|
isFetched: baseQuery.isFetched,
|
|
434
|
+
isFetchedAfterMount: baseQuery.isFetchedAfterMount,
|
|
432
435
|
isFetching: baseQuery.isFetching,
|
|
433
436
|
isIdle: baseQuery.isIdle,
|
|
434
437
|
isLoading: baseQuery.isLoading,
|
|
@@ -440,6 +443,7 @@ function useQuery(arg1, arg2, arg3) {
|
|
|
440
443
|
dataUpdatedAt: baseQuery.dataUpdatedAt,
|
|
441
444
|
errorUpdatedAt: baseQuery.errorUpdatedAt,
|
|
442
445
|
failureCount: baseQuery.failureCount,
|
|
446
|
+
// TODO: Remove `isFetchedAfterMount` in next minor version (v0.8).
|
|
443
447
|
isFetchedAfterMount: baseQuery.isFetchedAfterMount,
|
|
444
448
|
isLoadingError: baseQuery.isLoadingError,
|
|
445
449
|
isPaused: baseQuery.isPaused,
|
|
@@ -703,35 +707,21 @@ function useSyncExternalStoreWithTracked(subscribe, getSnapshot) {
|
|
|
703
707
|
}
|
|
704
708
|
|
|
705
709
|
function useAccount() {
|
|
710
|
+
var _previousAccount$curr, _previousAccount$curr2, _previousAccount$curr3;
|
|
711
|
+
|
|
706
712
|
let {
|
|
707
713
|
onConnect,
|
|
708
714
|
onDisconnect
|
|
709
715
|
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
710
716
|
const account = useSyncExternalStoreWithTracked(core.watchAccount, core.getAccount);
|
|
711
|
-
const
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
if (!!onConnect && status === 'connected') {
|
|
720
|
-
const {
|
|
721
|
-
address,
|
|
722
|
-
connector
|
|
723
|
-
} = core.getAccount();
|
|
724
|
-
onConnect({
|
|
725
|
-
address,
|
|
726
|
-
connector,
|
|
727
|
-
isReconnected: prevStatus === 'reconnecting'
|
|
728
|
-
});
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
if (!!onDisconnect && prevStatus !== 'connecting' && status === 'disconnected') onDisconnect();
|
|
732
|
-
});
|
|
733
|
-
return unsubscribe;
|
|
734
|
-
}, [onConnect, onDisconnect, subscribe]);
|
|
717
|
+
const previousAccount = React__namespace.useRef();
|
|
718
|
+
if (!!onConnect && ((_previousAccount$curr = previousAccount.current) === null || _previousAccount$curr === void 0 ? void 0 : _previousAccount$curr.status) !== 'connected' && account.status === 'connected') onConnect({
|
|
719
|
+
address: account.address,
|
|
720
|
+
connector: account.connector,
|
|
721
|
+
isReconnected: ((_previousAccount$curr2 = previousAccount.current) === null || _previousAccount$curr2 === void 0 ? void 0 : _previousAccount$curr2.status) === 'reconnecting'
|
|
722
|
+
});
|
|
723
|
+
if (!!onDisconnect && ((_previousAccount$curr3 = previousAccount.current) === null || _previousAccount$curr3 === void 0 ? void 0 : _previousAccount$curr3.status) == 'connected' && account.status === 'disconnected') onDisconnect();
|
|
724
|
+
previousAccount.current = account;
|
|
735
725
|
return account;
|
|
736
726
|
}
|
|
737
727
|
|
package/dist/wagmi.esm.js
CHANGED
|
@@ -359,6 +359,7 @@ function useInfiniteQuery(arg1, arg2, arg3) {
|
|
|
359
359
|
hasNextPage: baseQuery.hasNextPage,
|
|
360
360
|
isError: baseQuery.isError,
|
|
361
361
|
isFetched: baseQuery.isFetched,
|
|
362
|
+
isFetchedAfterMount: baseQuery.isFetchedAfterMount,
|
|
362
363
|
isFetching: baseQuery.isFetching,
|
|
363
364
|
isFetchingNextPage: baseQuery.isFetchingNextPage,
|
|
364
365
|
isIdle: baseQuery.isIdle,
|
|
@@ -371,6 +372,7 @@ function useInfiniteQuery(arg1, arg2, arg3) {
|
|
|
371
372
|
dataUpdatedAt: baseQuery.dataUpdatedAt,
|
|
372
373
|
errorUpdatedAt: baseQuery.errorUpdatedAt,
|
|
373
374
|
failureCount: baseQuery.failureCount,
|
|
375
|
+
// TODO: Remove `isFetchedAfterMount` in next minor version (v0.8).
|
|
374
376
|
isFetchedAfterMount: baseQuery.isFetchedAfterMount,
|
|
375
377
|
isLoadingError: baseQuery.isLoadingError,
|
|
376
378
|
isPaused: baseQuery.isPaused,
|
|
@@ -405,6 +407,7 @@ function useQuery(arg1, arg2, arg3) {
|
|
|
405
407
|
fetchStatus: baseQuery.fetchStatus,
|
|
406
408
|
isError: baseQuery.isError,
|
|
407
409
|
isFetched: baseQuery.isFetched,
|
|
410
|
+
isFetchedAfterMount: baseQuery.isFetchedAfterMount,
|
|
408
411
|
isFetching: baseQuery.isFetching,
|
|
409
412
|
isIdle: baseQuery.isIdle,
|
|
410
413
|
isLoading: baseQuery.isLoading,
|
|
@@ -416,6 +419,7 @@ function useQuery(arg1, arg2, arg3) {
|
|
|
416
419
|
dataUpdatedAt: baseQuery.dataUpdatedAt,
|
|
417
420
|
errorUpdatedAt: baseQuery.errorUpdatedAt,
|
|
418
421
|
failureCount: baseQuery.failureCount,
|
|
422
|
+
// TODO: Remove `isFetchedAfterMount` in next minor version (v0.8).
|
|
419
423
|
isFetchedAfterMount: baseQuery.isFetchedAfterMount,
|
|
420
424
|
isLoadingError: baseQuery.isLoadingError,
|
|
421
425
|
isPaused: baseQuery.isPaused,
|
|
@@ -679,35 +683,21 @@ function useSyncExternalStoreWithTracked(subscribe, getSnapshot) {
|
|
|
679
683
|
}
|
|
680
684
|
|
|
681
685
|
function useAccount() {
|
|
686
|
+
var _previousAccount$curr, _previousAccount$curr2, _previousAccount$curr3;
|
|
687
|
+
|
|
682
688
|
let {
|
|
683
689
|
onConnect,
|
|
684
690
|
onDisconnect
|
|
685
691
|
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
686
692
|
const account = useSyncExternalStoreWithTracked(watchAccount, getAccount);
|
|
687
|
-
const
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
if (!!onConnect && status === 'connected') {
|
|
696
|
-
const {
|
|
697
|
-
address,
|
|
698
|
-
connector
|
|
699
|
-
} = getAccount();
|
|
700
|
-
onConnect({
|
|
701
|
-
address,
|
|
702
|
-
connector,
|
|
703
|
-
isReconnected: prevStatus === 'reconnecting'
|
|
704
|
-
});
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
if (!!onDisconnect && prevStatus !== 'connecting' && status === 'disconnected') onDisconnect();
|
|
708
|
-
});
|
|
709
|
-
return unsubscribe;
|
|
710
|
-
}, [onConnect, onDisconnect, subscribe]);
|
|
693
|
+
const previousAccount = React.useRef();
|
|
694
|
+
if (!!onConnect && ((_previousAccount$curr = previousAccount.current) === null || _previousAccount$curr === void 0 ? void 0 : _previousAccount$curr.status) !== 'connected' && account.status === 'connected') onConnect({
|
|
695
|
+
address: account.address,
|
|
696
|
+
connector: account.connector,
|
|
697
|
+
isReconnected: ((_previousAccount$curr2 = previousAccount.current) === null || _previousAccount$curr2 === void 0 ? void 0 : _previousAccount$curr2.status) === 'reconnecting'
|
|
698
|
+
});
|
|
699
|
+
if (!!onDisconnect && ((_previousAccount$curr3 = previousAccount.current) === null || _previousAccount$curr3 === void 0 ? void 0 : _previousAccount$curr3.status) == 'connected' && account.status === 'disconnected') onDisconnect();
|
|
700
|
+
previousAccount.current = account;
|
|
711
701
|
return account;
|
|
712
702
|
}
|
|
713
703
|
|