diff --git a/apps/laboratory/src/components/Solana/SolanaSendTransactionTest.tsx b/apps/laboratory/src/components/Solana/SolanaSendTransactionTest.tsx index 1c3b8a2af7..89bf025ef0 100644 --- a/apps/laboratory/src/components/Solana/SolanaSendTransactionTest.tsx +++ b/apps/laboratory/src/components/Solana/SolanaSendTransactionTest.tsx @@ -13,7 +13,7 @@ import { import { solana } from '../../utils/ChainsUtil' import { useChakraToast } from '../Toast' -const PHANTOM_TESTNET_ADDRESS = 'EmT8r4E8ZjoQgt8sXGbaWBRMKfUXsVT1wonoSnJZ4nBn' +const PHANTOM_TESTNET_ADDRESS = '8vCyX7oB6Pc3pbWMGYYZF5pbSnAdQ7Gyr32JqxqCy8ZR' const recipientAddress = new PublicKey(PHANTOM_TESTNET_ADDRESS) const amountInLamports = 100000000 diff --git a/apps/laboratory/src/components/Solana/SolanaSignTransactionTest.tsx b/apps/laboratory/src/components/Solana/SolanaSignTransactionTest.tsx index 653fb300ef..01771564ef 100644 --- a/apps/laboratory/src/components/Solana/SolanaSignTransactionTest.tsx +++ b/apps/laboratory/src/components/Solana/SolanaSignTransactionTest.tsx @@ -13,7 +13,7 @@ import { useWeb3ModalAccount, useWeb3ModalProvider } from '@web3modal/solana/rea import { solana } from '../../utils/ChainsUtil' import { useChakraToast } from '../Toast' -const PHANTOM_DEVNET_ADDRESS = 'EmT8r4E8ZjoQgt8sXGbaWBRMKfUXsVT1wonoSnJZ4nBn' +const PHANTOM_DEVNET_ADDRESS = '8vCyX7oB6Pc3pbWMGYYZF5pbSnAdQ7Gyr32JqxqCy8ZR' const recipientAddress = new PublicKey(PHANTOM_DEVNET_ADDRESS) const amountInLamports = 100000000 diff --git a/packages/solana/src/client.ts b/packages/solana/src/client.ts index d4e6c3c860..11c8789de6 100644 --- a/packages/solana/src/client.ts +++ b/packages/solana/src/client.ts @@ -255,9 +255,36 @@ export class Web3Modal extends Web3ModalScaffold { } }) - if (typeof window === 'object') { + if (CoreHelperUtil.isClient()) { this.checkActiveProviders() this.syncConnectors() + let timer = 0 + /* + * Brave browser doesn't inject window.solflare immediately + * so there is delay to detect injected wallets + * issue: https://github.com/anza-xyz/wallet-adapter/issues/329 + */ + if ( + window.navigator.brave !== undefined && + window.navigator.brave.isBrave.name === 'isBrave' + ) { + timer = 100 + } + + const checkWallet = () => { + if (window.solflare) { + this.checkActiveProviders() + this.syncConnectors() + } else { + setTimeout(() => { + checkWallet() + }, timer) + } + } + + setTimeout(() => { + checkWallet() + }, timer) } } @@ -337,7 +364,6 @@ export class Web3Modal extends Web3ModalScaffold { } syncInjectedWallets(w3mConnectors, this.walletAdapters) - this.setConnectors(w3mConnectors) } diff --git a/packages/solana/src/utils/defaultConfig.ts b/packages/solana/src/utils/defaultConfig.ts index e4b20811da..111736625c 100644 --- a/packages/solana/src/utils/defaultConfig.ts +++ b/packages/solana/src/utils/defaultConfig.ts @@ -3,13 +3,18 @@ import '@web3modal/polyfills' import type { Chain, Metadata, Provider, ProviderType } from './scaffold/index.js' declare global { + interface Navigator { + brave?: { + isBrave(): boolean + } + } interface Window { originalSolana?: Record solana?: Provider - solflare?: { solana: Provider } + solflare?: { solana: Provider & { isSoflare: boolean } } backpack?: { solana: Provider } trustWallet?: { solana: Provider } - phantom?: { solana: Provider } + phantom?: { solana: Provider & { isPhantom: boolean } } getHashedName: (name: string) => Buffer } }