Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: remove unused custom hooks #2539

Merged
merged 1 commit into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions libs/hooks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ This package contains all hooks required for proper functioning of the AKASHA Co

- getLegalDoc

### [useNetworkState](./src/use-network-state.ts)

> handles checks to ensure that the user is on the appropriate ethereum network required for the app. Available actions include;

- checkNetwork

### [useNotifications](./src/use-notifications.ts)

> handles enabling of notifications and exposes status of pending signature request.
Expand Down
10 changes: 0 additions & 10 deletions libs/hooks/src/__tests__/use-network-state.spec.ts

This file was deleted.

3 changes: 0 additions & 3 deletions libs/hooks/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ export { hasOwn } from './utils/has-own';
export { sortByKey } from './utils/sort-by-key';
export { createReactiveVar } from './utils/create-reactive-var';
export {
useNetworkState,
useCurrentNetwork,
useRequiredNetwork,
switchToRequiredNetwork,
useNetworkChangeListener,
Expand All @@ -30,7 +28,6 @@ export { useModalData } from './use-modal-data';
// the following hooks needs refactor/reimplementation
export { useListenForMutationEvents } from './use-mutation-events-listener';

export { useShowFeedback } from './use-show-feedback';
export { useTheme } from './use-theme';
export { useProfileStats } from './use-profile-stats';
export { useSaveSettings, useGetSettings } from './use-settings';
Expand Down
82 changes: 0 additions & 82 deletions libs/hooks/src/use-network-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,94 +23,12 @@ const checkNetworkState = async () => {
return res;
};

/**
* Hook to check if the web3 provider is set to function on the Rinkeby test network
* @param enabler - boolean (optional) that can control when to start verifying network state
* @returns networkNotSupported: true if web3 provider is not on the specified network
* @example useNetworkState hook
* ```typescript
* const networkStateQuery = useNetworkState(true);
*
* const networkNotSupported = networkStateQuery.data.networkNotSupported;
* ```
*/
export function useNetworkState(enabler?: boolean) {
const [data, setData] = useState<{
networkNotSupported: boolean;
}>(undefined);
const [isLoading, setIsLoading] = useState<boolean>(true);
const [isFetched, setIsFetched] = useState<boolean>(false);
const [error, setError] = useState<Error | null>(null);

useEffect(() => {
const fetchData = async () => {
try {
const res = await checkNetworkState();
if (res) {
setData(res);
setIsLoading(false);
setIsFetched(true);
}
} catch (err) {
setError(err);
logError('useNetworkState', err);
setIsLoading(false);
setIsFetched(true);
}
};

if (enabler) {
fetchData();
}
}, [enabler]);

return { data, isLoading, error, isFetched };
}

const getCurrentNetwork = () => {
const sdk = getSDK();
const res = sdk.services.common.web3.network;
return res;
};

/**
* Hook to check the user's current web3 network
* @returns network name
* @example useCurrentNetwork hook
* ```typescript
* const currentNetworkQuery = useCurrentNetwork(true);
*
* const network = currentNetworkQuery.data;
* ```
*/
export function useCurrentNetwork(enabler?: boolean) {
const [data, setData] = useState<string>(undefined);
const [isLoading, setIsLoading] = useState<boolean>(true);
const [error, setError] = useState<Error | null>(null);

useEffect(() => {
const fetchData = async () => {
try {
const res = await getCurrentNetwork();
if (res) {
setData(res);
setIsLoading(false);
}
} catch (err) {
setError(err);
logError('useCurrentNetwork', err);
setIsLoading(false);
}
};

if (enabler) {
fetchData();
}
}, [enabler]);

return { data, isLoading, error };
}

const getRequiredNetwork = async () => {
const sdk = getSDK();
const networkName = sdk.services.common.web3.getRequiredNetwork();
Expand Down
29 changes: 0 additions & 29 deletions libs/hooks/src/use-show-feedback.ts

This file was deleted.