Part of https://www.notion.so/Simplify-login-flow-in-deploy-laconic-com-190a6b22d47280a9924cc38f8cf4c891 - Auto sign SIWE message received if auto-sign-in is enabled - Functionality to check account balance Co-authored-by: Shreerang Kale <shreerangkale@gmail.com> Co-authored-by: IshaVenikar <ishavenikar7@gmail.com> Reviewed-on: cerc-io/laconic-wallet-web#20
24 lines
605 B
TypeScript
24 lines
605 B
TypeScript
import { useCallback } from "react";
|
|
|
|
import { retrieveAccounts } from "../utils/accounts";
|
|
import { useNetworks } from "../context/NetworksContext";
|
|
|
|
const useAccountsData = () => {
|
|
const { networksData } = useNetworks();
|
|
|
|
const getAccountsData = useCallback(async (chainId: string) => {
|
|
const targetNetwork = networksData.find(network => network.chainId === chainId);
|
|
|
|
if (!targetNetwork) {
|
|
return [];
|
|
}
|
|
|
|
const accounts = await retrieveAccounts(targetNetwork);
|
|
return accounts || [];
|
|
}, [networksData]);
|
|
|
|
return { getAccountsData };
|
|
};
|
|
|
|
export default useAccountsData;
|