Skip to content

Commit

Permalink
Fix bugs with android wallet connect in browser (#608)
Browse files Browse the repository at this point in the history
* Fix bugs with android wallet connect in browser

* fix build

---------

Co-authored-by: bry <[email protected]>
  • Loading branch information
ChewingGlass and bryzettler authored Jan 17, 2024
1 parent 8edeca0 commit 47a0768
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
23 changes: 12 additions & 11 deletions src/features/browser/BrowserWebViewScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import { Transaction, VersionedTransaction } from '@solana/web3.js'
import { useSpacing } from '@theme/themeHooks'
import bs58 from 'bs58'
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import React, { useCallback, useMemo, useRef, useState } from 'react'
import { Platform, StyleSheet } from 'react-native'
import { Edge, useSafeAreaInsets } from 'react-native-safe-area-context'
import {
Expand Down Expand Up @@ -57,19 +57,16 @@ const BrowserWebViewScreen = () => {
const walletSignBottomSheetRef = useRef<WalletSignBottomSheetRef | null>(null)

const [currentUrl, setCurrentUrl] = useState(uri)
const [accountAddress, setAccountAddress] = useState<string>('')
const accountAddress = useMemo(
() => currentAccount?.solanaAddress,
[currentAccount?.solanaAddress],
)
const { top, bottom } = useSafeAreaInsets()
const navigation = useNavigation<BrowserNavigationProp>()
const { favorites, addFavorite, removeFavorite } = useBrowser()
const isAndroid = useMemo(() => Platform.OS === 'android', [])
const spacing = useSpacing()

useEffect(() => {
if (currentAccount?.solanaAddress) {
setAccountAddress(currentAccount?.solanaAddress || '')
}
}, [currentAccount])

const isFavorite = useMemo(() => {
return favorites.some((favorite) => favorite === currentUrl)
}, [favorites, currentUrl])
Expand Down Expand Up @@ -382,9 +379,9 @@ const BrowserWebViewScreen = () => {
${injectWalletStandard.toString()}
// noinspection JSIgnoredPromiseFromCall
injectWalletStandard("${accountAddress}", [${bs58.decode(
accountAddress,
)}], ${isAndroid});
injectWalletStandard("${accountAddress}", [${
accountAddress && bs58.decode(accountAddress)
}], ${isAndroid});
true;
`

Expand Down Expand Up @@ -512,6 +509,10 @@ const BrowserWebViewScreen = () => {
source={{
uri,
}}
onShouldStartLoadWithRequest={(event) => {
// Sites should not do this, but if you click MWA on realms it bricks us
return !event.url.startsWith('solana-wallet:')
}}
/>
<BrowserFooter />
</SafeAreaBox>
Expand Down
2 changes: 1 addition & 1 deletion src/features/governance/GovernanceTutorialScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const GovernanceTutorialScreen = () => {

const handleVotePressed = useCallback(() => {
setVoteTutorialCompleted()
navigation.replace('GovernanceScreen')
navigation.replace('GovernanceScreen', {})
}, [navigation, setVoteTutorialCompleted])

const onSnapToItem = useCallback((index: number) => {
Expand Down

0 comments on commit 47a0768

Please sign in to comment.