UNPKG

@particle-network/connectkit

Version:
8 lines (7 loc) 1.18 kB
{ "version": 3, "sources": ["../../src/hooks/useWalletConnectors.ts"], "sourcesContent": ["import type { WalletConnector, WalletConnectorType } from '@particle-network/connector-core';\nimport { useContext } from '../context';\nimport type { AuthWalletConnectorProperties, EVMWalletConnectorProperties } from '../types/properties';\n\nexport const useWalletConnectors = () => {\n const { config } = useContext();\n\n return config.walletConnectors;\n};\n\nexport const useWalletConnector = <T extends WalletConnectorType>(\n walletConnectorType: T\n): T extends 'particleAuth'\n ? WalletConnector<AuthWalletConnectorProperties>\n : T extends 'evmWallet'\n ? WalletConnector<EVMWalletConnectorProperties>\n : WalletConnector => {\n const walletConnectors = useWalletConnectors();\n return walletConnectors.find((item) => item.type === walletConnectorType) as any;\n};\n"], "mappings": ";;;;;;;;;;AAAA,IAIa,qBAMA;AAVb;AAAA;AAAA;AACA;AAGO,IAAM,sBAAsB,MAAM;AACvC,YAAM,EAAE,OAAO,IAAI,WAAW;AAE9B,aAAO,OAAO;AAAA,IAChB;AAEO,IAAM,qBAAqB,CAChC,wBAKuB;AACvB,YAAM,mBAAmB,oBAAoB;AAC7C,aAAO,iBAAiB,KAAK,CAAC,SAAS,KAAK,SAAS,mBAAmB;AAAA,IAC1E;AAAA;AAAA;", "names": [] }