UNPKG

@buddy-link/react

Version:

Buddy SDK - React components and hooks for wallet integration

44 lines (38 loc) 1.41 kB
export const WALLET_PHANTOM = 'phantom' export const WALLET_SOLFLARE = 'solflare' export const WALLET_BACKPACK = 'backpack' export const WALLET_OKX = 'okx' export const WALLET_BRAVE = 'brave' export const WALLET_SAFEPA = 'safepal' export const WALLET_COIN98 = 'coin98' export const WALLET_TRUST = 'trust' export const detectSolana = () => { if (typeof window === 'undefined') return {} const staticDetected = { [WALLET_PHANTOM]: !!window.solana?.isPhantom, [WALLET_SOLFLARE]: !!window.solflare?.isSolflare, [WALLET_BACKPACK]: !!window.backpack?.solana, [WALLET_OKX]: !!window.okxwallet?.solana, [WALLET_BRAVE]: !!window.solana?.isBraveWallet, [WALLET_SAFEPA]: !!window.safepal?.isSafePal, [WALLET_COIN98]: !!window.coin98?.solana, [WALLET_TRUST]: !!window.trustwallet?.solana, } let dynamicDetected = {} for (const key of Object.keys(window)) { const candidate = window[key] if ( candidate && typeof candidate === 'object' && typeof candidate.connect === 'function' && ('publicKey' in candidate || 'solana' in candidate || 'isWallet' in candidate) && !key?.toLowerCase()?.includes('solana') ) { dynamicDetected[key] = true; } } return { ...staticDetected, ...dynamicDetected, } };