diff --git a/packages/walletkit/__dev__/App.tsx b/packages/walletkit/__dev__/App.tsx index 7212c53..8c9ddce 100644 --- a/packages/walletkit/__dev__/App.tsx +++ b/packages/walletkit/__dev__/App.tsx @@ -11,6 +11,7 @@ import { binanceWeb3Wallet, bitgetWallet, coinbaseWallet, + EthereumScript, evmConfig, mathWallet, metaMask, diff --git a/packages/walletkit/src/core/index.ts b/packages/walletkit/src/core/index.ts index 2deccba..ecf63a5 100644 --- a/packages/walletkit/src/core/index.ts +++ b/packages/walletkit/src/core/index.ts @@ -1,21 +1,17 @@ -// evm -export * from '@/evm/components/EthereumScript'; - -// core +// utils export * from '@/core/base/utils/mobile'; export * from '@/core/base/utils/css'; +// providers export { type BaseWallet } from '@/core/configs/types'; export * from '@/core/providers/WalletKitProvider'; - export { type WalletKitConfig, useWalletKit } from '@/core/providers/WalletKitProvider/context'; +export { type ColorMode } from '@/core/providers/ThemeProvider/context'; +export { type Theme } from '@/core/providers/ThemeProvider'; + +// modals export * from '@/core/modals/EmbeddedConnectModal'; export * from '@/core/modals/ConnectModal'; export { useConnectModal } from '@/core/modals/ConnectModal/context'; - -export { type ColorMode } from '@/core/providers/ThemeProvider/context'; -export { type Theme } from '@/core/providers/ThemeProvider'; - -export * from '@/core/providers/WalletKitProvider'; diff --git a/packages/walletkit/src/core/providers/WalletKitProvider/context.ts b/packages/walletkit/src/core/providers/WalletKitProvider/context.ts index 1a87489..5e5ddaa 100644 --- a/packages/walletkit/src/core/providers/WalletKitProvider/context.ts +++ b/packages/walletkit/src/core/providers/WalletKitProvider/context.ts @@ -5,7 +5,6 @@ import { SolanaConfig } from '@/solana/utils/solanaConfig'; import { BaseWallet } from '@/core/configs/types'; import { useEvmConnect } from '@/evm/hooks/useEvmConnect'; import { useConnectors } from 'wagmi'; -import { toast } from '@/core/base/components/toast'; export type Action = 'add-network' | undefined; @@ -113,6 +112,7 @@ export function useSelectedWallet() { } export function useWalletKit() { + const log = useLogger(); const { wallets, setWallets } = useContext(WalletKitContext); const { connect } = useEvmConnect(); @@ -127,9 +127,7 @@ export function useWalletKit() { const wallet = wallets.find((item) => item.id === walletId); if (!wallet) { - toast.info({ - description: 'Wallet not found', - }); + log(`wallet not found, walletId: ${walletId}`); } else { const connector = connectors.find((item) => item.id === walletId); if (connector && wallet.isInstalled()) diff --git a/packages/walletkit/src/evm/components/SetEvmWalletClickRef/index.tsx b/packages/walletkit/src/evm/components/SetEvmWalletClickRef/index.tsx index f8be5af..44e7505 100644 --- a/packages/walletkit/src/evm/components/SetEvmWalletClickRef/index.tsx +++ b/packages/walletkit/src/evm/components/SetEvmWalletClickRef/index.tsx @@ -5,10 +5,10 @@ import { ViewRoutes } from '@/core/modals/ConnectModal/RouteProvider'; import { useRouter } from '@/core/modals/ConnectModal/RouteProvider/context'; import { useEventConfig, + useEvmConfig, useLogger, useSelectedWallet, } from '@/core/providers/WalletKitProvider/context'; -import { useEvmWallets } from '@/evm/hooks/useEvmWallets'; import { useWalletConnectModal } from '@/evm/hooks/useWalletConnectModal'; import { EvmWallet, isWalletConnect } from '@/evm/wallets'; import { useRef } from 'react'; @@ -34,7 +34,7 @@ export function SetEvmWalletClickRef(props: SetEvmWalletClickRefProps) { const timerRef = useRef(); const mobile = isMobile(); - const { wallets } = useEvmWallets(); + const { wallets } = useEvmConfig(); clickRef.current = (walletId: string, e: React.MouseEvent) => { const connector = connectors.find((item) => item.id === walletId)!; diff --git a/packages/walletkit/src/evm/hooks/useEvmWallets.ts b/packages/walletkit/src/evm/hooks/useEvmWallets.ts deleted file mode 100644 index 9b937e9..0000000 --- a/packages/walletkit/src/evm/hooks/useEvmWallets.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { WalletKitContext } from '@/core/providers/WalletKitProvider/context'; -import { useContext } from 'react'; - -export function useEvmWallets() { - const { wallets } = useContext(WalletKitContext); - - return { - wallets: wallets.filter((item) => item.walletType === 'evm'), - }; -} diff --git a/packages/walletkit/src/evm/index.ts b/packages/walletkit/src/evm/index.ts index 50cdc01..bb45c61 100644 --- a/packages/walletkit/src/evm/index.ts +++ b/packages/walletkit/src/evm/index.ts @@ -6,6 +6,3 @@ export * from './components/EthereumScript'; // utils export * from './utils/evmConfig'; - -// hooks -export * from './hooks/useEvmWallets'; diff --git a/packages/walletkit/src/solana/components/SetSolanaWalletClickRef/index.tsx b/packages/walletkit/src/solana/components/SetSolanaWalletClickRef/index.tsx index 502ea4e..47a27c7 100644 --- a/packages/walletkit/src/solana/components/SetSolanaWalletClickRef/index.tsx +++ b/packages/walletkit/src/solana/components/SetSolanaWalletClickRef/index.tsx @@ -5,8 +5,8 @@ import { useEventConfig, useLogger, useSelectedWallet, + useSolanaConfig, } from '@/core/providers/WalletKitProvider/context'; -import { useSolanaWallets } from '@/solana/hooks/useSolanaWallets'; import { SolanaWallet } from '@/solana/wallets'; import { useWallet } from '@solana/wallet-adapter-react'; import { useRef } from 'react'; @@ -23,7 +23,7 @@ export function SetSolanaWalletClickRef(props: SetSolanaWalletClickRefProps) { const { setSelectedWallet } = useSelectedWallet(); const { disconnect } = useWallet(); - const { wallets } = useSolanaWallets(); + const { wallets } = useSolanaConfig(); const connectModal = useConnectModal(); const router = useRouter(); diff --git a/packages/walletkit/src/solana/hooks/useSolanaWallets.ts b/packages/walletkit/src/solana/hooks/useSolanaWallets.ts deleted file mode 100644 index 433e49c..0000000 --- a/packages/walletkit/src/solana/hooks/useSolanaWallets.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { WalletKitContext } from '@/core/providers/WalletKitProvider/context'; -import { useContext } from 'react'; - -export function useSolanaWallets() { - const { wallets } = useContext(WalletKitContext); - - return { - wallets: wallets.filter((item) => item.walletType === 'solana'), - }; -} diff --git a/packages/walletkit/src/solana/index.ts b/packages/walletkit/src/solana/index.ts index 0182c38..4e055a1 100644 --- a/packages/walletkit/src/solana/index.ts +++ b/packages/walletkit/src/solana/index.ts @@ -3,6 +3,3 @@ export * from './utils/solanaConfig'; // wallets export * from './wallets'; - -// hooks -export * from './hooks/useSolanaWallets';