import { useCallback, useEffect, useState } from 'react' import { Connector } from '../connectors' import { useStarknet } from '../providers' /** Value returned from `useConnectors`. */ export interface UseConnectorsResult { /** List of all registered connectors. */ connectors: Connector[] /** List of available connectors. */ available: Connector[] /** Connect the given connector. */ connect: (conn: Connector) => void /** Disconnect the currently connected connector. */ disconnect: () => void /** Refresh the list of available connectors. */ refresh: () => void } /** * Hook to work with connectors. * * @remarks * * This hook is the recommended way to interact with the connectors. * * Notice that the `available` connectors are computed as soon as the hook is * rendered, which could happen _before_ the browser wallets had the opportunity * to inject themselves in the page. * * The best practice is to periodically `refresh` the available connectors. * * @example * This example shows all registered connectors and connects * to the specified one. * ```tsx * function Component() { * const { connect, connectors } = useConnectors() * * return ( *