Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phantom deeplinks #2281

Merged
merged 46 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
caf0721
feat: phantom deeplink for mobile app browsers
phoenixVS May 12, 2024
22c6b48
fix: ssr kept up
phoenixVS May 14, 2024
b304417
fix: readability
phoenixVS May 14, 2024
7c5de29
Merge branch 'V4' into phantom-deeplinks
phoenixVS May 14, 2024
5e68c78
fix: isclient approach
phoenixVS May 14, 2024
ad8f350
fix: types
phoenixVS May 14, 2024
d769d9b
chore: phantom check
phoenixVS May 15, 2024
693afd2
chore: loggin phantom inner browser
phoenixVS May 15, 2024
3757fff
chore: loggin phantom inner browser
phoenixVS May 15, 2024
a083b7e
chore: testing adding connectors
phoenixVS May 15, 2024
55c5453
chore: test phantom object
phoenixVS May 15, 2024
7bc8ece
chore: test phantom object
phoenixVS May 15, 2024
d9b0c42
chore: testing isPhantom
phoenixVS May 16, 2024
464ba8f
chore: testing isPhantom
phoenixVS May 16, 2024
4fdab8a
fix: removed no mobile flag
phoenixVS May 16, 2024
b6ccfcb
fix: remove alerts
phoenixVS May 16, 2024
ec70182
chore: some unnecessary changes
phoenixVS May 22, 2024
94e4e06
fix: merge with V4, updated testnet wallet address
phoenixVS May 30, 2024
79998cd
fix: conflict
phoenixVS May 30, 2024
b7c623e
Merge branch 'V4' into phantom-deeplinks
phoenixVS May 30, 2024
f631ab5
fix: prettier
phoenixVS May 30, 2024
15207c5
fix: unnecessary throw error
phoenixVS May 30, 2024
732c998
Merge branch 'V4' into phantom-deeplinks
enesozturk May 31, 2024
a8d2bc1
Merge branch 'V4' into phantom-deeplinks
phoenixVS Jun 4, 2024
a4a2311
test: logs
phoenixVS Jun 4, 2024
735c140
test: logs
phoenixVS Jun 4, 2024
05792d0
test: more logs
phoenixVS Jun 4, 2024
443ffd1
test: more logs
phoenixVS Jun 4, 2024
b1af293
test: more logs
phoenixVS Jun 4, 2024
e475efb
fix: removed logs, added delay for brave browser
phoenixVS Jun 4, 2024
22fdb9f
fix: prettier
phoenixVS Jun 4, 2024
8fe6212
Merge branch 'V4' into phantom-deeplinks
phoenixVS Jun 4, 2024
d36646c
Merge branch 'V4' into phantom-deeplinks
phoenixVS Jun 4, 2024
e318622
fix: improving brave delay
phoenixVS Jun 6, 2024
50f8423
Merge branch 'phantom-deeplinks' of https://github.com/WalletConnect/…
phoenixVS Jun 6, 2024
a2302a2
fix: fetching non-solflare connectors
phoenixVS Jun 6, 2024
4f30f6e
fix: prettier
phoenixVS Jun 6, 2024
47185d0
Merge branch 'V4' into phantom-deeplinks
phoenixVS Jun 6, 2024
f73a818
Merge branch 'V4' into phantom-deeplinks
enesozturk Jun 6, 2024
7473c06
Merge branch 'V4' into phantom-deeplinks
valentyn-solana Jun 7, 2024
e8b9a49
Merge branch 'V4' into phantom-deeplinks
valentyn-solana Jun 7, 2024
dacb421
fix: removed logs
phoenixVS Jun 7, 2024
d6f9503
Merge branch 'phantom-deeplinks' of https://github.com/WalletConnect/…
phoenixVS Jun 7, 2024
3493a55
fix: jsdoc
phoenixVS Jun 10, 2024
71f576b
fix: format
phoenixVS Jun 10, 2024
8d67368
fix: sources
phoenixVS Jun 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
enesozturk marked this conversation as resolved.
Show resolved Hide resolved
const recipientAddress = new PublicKey(PHANTOM_DEVNET_ADDRESS)
const amountInLamports = 100000000

Expand Down
30 changes: 28 additions & 2 deletions packages/solana/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
enesozturk marked this conversation as resolved.
Show resolved Hide resolved
checkWallet()
}, timer)
}
}

Expand Down Expand Up @@ -337,7 +364,6 @@ export class Web3Modal extends Web3ModalScaffold {
}

syncInjectedWallets(w3mConnectors, this.walletAdapters)

this.setConnectors(w3mConnectors)
}

Expand Down
9 changes: 7 additions & 2 deletions packages/solana/src/utils/defaultConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, unknown>
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
}
enesozturk marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Down
Loading