Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
Remove redirect url from qr code
Browse files Browse the repository at this point in the history
  • Loading branch information
dzbo committed Nov 7, 2024
1 parent 7aece5b commit c763a1d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
4 changes: 3 additions & 1 deletion components/WalletConnectButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ const { walletConnectProvider: provider } = storeToRefs(useAppStore())
onMounted(async () => {
await initProvider()
provider.value?.on('display_uri', (data: string) => {
deepLink.value = walletConnectDeepLinkUrl(data)
deepLink.value = walletConnectDeepLinkUrl(data, {
withRedirectUrl: true,
})
})
try {
Expand Down
24 changes: 18 additions & 6 deletions utils/externalUrls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,29 @@ export const universalSwapsAssetUrl = (address?: Address) => {
*
* @param data
*/
export const walletConnectDeepLinkUrl = (data: string) => {
export const walletConnectDeepLinkUrl = (
data: string,
options?: {
withRedirectUrl?: boolean
}
) => {
if (genericLog.enabled) {
genericLog(`Wallet Connect link: ${data}`)
}

const urlData = new URL(data)
const redirectUrl = location.href.replace(
'&modalTemplate=ConnectWallet&modalSize=auto',
''
)
const deepLink = `${MOBILE_APP_DEEP_LINK_PREFIX}://wallet-connect/${urlData.pathname}${urlData.search}&redirectUrl=${redirectUrl}`
let redirectQueryParam = ''

// add redirectUrl to deep link
if (options?.withRedirectUrl) {
const redirectUrl = location.href.replace(
'&modalTemplate=ConnectWallet&modalSize=auto',
''
)
redirectQueryParam = `&redirectUrl=${redirectUrl}`
}

const deepLink = `${MOBILE_APP_DEEP_LINK_PREFIX}://wallet-connect/${urlData.pathname}${urlData.search}${redirectQueryParam}`

if (genericLog.enabled) {
genericLog(`Mobile App link: ${deepLink}`)
Expand Down

0 comments on commit c763a1d

Please sign in to comment.