Skip to content

Commit

Permalink
fix: rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaccoSordo committed Jan 12, 2024
1 parent 72b705b commit ec9ef2f
Showing 1 changed file with 35 additions and 46 deletions.
81 changes: 35 additions & 46 deletions packages/beacon-ui/src/ui/alert/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -531,57 +531,17 @@ const openAlert = async (config: AlertConfig): Promise<string> => {
})
)

if (
wallet?.types.includes('web') &&
!(
wallet?.types.includes('extension') ||
wallet?.types.includes('desktop') ||
wallet?.types.includes('ios')
)
) {
if (wallet?.types.includes('web') && wallet?.types.length === 1) {
handleNewTab(config, wallet)
return
}

if (wallet && wallet.supportedInteractionStandards?.includes('wallet_connect')) {
const uri = (await wcPayload)?.uri ?? ''
if (!!uri.length) {
if (isAndroid(window) || isIOS(window)) {
localStorage.setItem(
StorageKey.LAST_SELECTED_WALLET,
JSON.stringify({
key: wallet.key,
name: wallet.name,
type: 'mobile',
icon: currentWallet()?.image
})
)

let link = `${wallet.links[OSLink.IOS]}wc?uri=${encodeURIComponent(uri)}`
updateSelectedWalletWithURL(link)

if (isTwBrowser(window) && isAndroid(window)) {
link = `${uri}`
window.location.href = link
} else if (
isAndroid(window) &&
currentWallet()?.types.includes('ios') &&
currentWallet()?.types.length === 1
) {
window.open(link, '_blank', 'noopener')
} else if (
isIOS(window) &&
currentWallet()?.types.includes('ios') &&
currentWallet()?.types.length === 1
) {
logger.log('DO DEEPLINK WITH ' + link)
const a = document.createElement('a')
a.setAttribute('href', link)
a.setAttribute('rel', 'noopener')
a.dispatchEvent(
new MouseEvent('click', { view: window, bubbles: true, cancelable: true })
)
}
if (!!uri.length) {
if (_isMobileOS && wallet.types.includes('ios') && wallet.types.length === 1) {
handleDeepLinking(wallet, uri)
} else {
setCodeQR(uri)
setInstallState(wallet)
Expand Down Expand Up @@ -747,7 +707,7 @@ const openAlert = async (config: AlertConfig): Promise<string> => {
currentWallet()?.supportedInteractionStandards?.includes('wallet_connect') || false
}
isMobile={isMobile}
walletName={currentWallet()?.name || 'wallet'}
walletName={currentWallet()?.name || 'AirGap'}
code={codeQR()}
onClickLearnMore={handleClickLearnMore}
onClickQrCode={handleClickQrCode}
Expand Down Expand Up @@ -873,7 +833,36 @@ const openAlert = async (config: AlertConfig): Promise<string> => {
(currentWallet()?.types.length as number) <= 1 && (
<QRCode isMobile={true} />
)}
{isMobile() && codeQR().length > 0 && <QRCode isMobile={true} />}
{isMobile() && currentWallet()?.types.includes('ios') && (
<Info
border
title={'Open wallet in App'}
description={`Please connect below to use ${currentWallet()?.name}`}
buttons={[
{
label: 'Connect now',
type: 'primary',
onClick: async () => {
const wallet = currentWallet()

if (!wallet) {
return
}

let syncCode = ''
if (
wallet.supportedInteractionStandards?.includes('wallet_connect')
) {
syncCode = (await wcPayload)?.uri ?? ''
} else {
syncCode = await new Serializer().serialize(await p2pPayload)
}
handleDeepLinking(wallet, syncCode)
}
}
]}
/>
)}
</div>
)}
{currentInfo() === 'qr' && (
Expand Down

0 comments on commit ec9ef2f

Please sign in to comment.