From df4af8615b7b8305d3f86a07c01c0d1cd5367f0d Mon Sep 17 00:00:00 2001 From: Davide Carpini Date: Mon, 12 Feb 2024 16:34:23 +0100 Subject: [PATCH] fix: deep linking for veworld extension --- .../src/components/modals/connect-modal/connect-modal.ts | 9 +++++++++ packages/dapp-kit-ui/src/constants/index.ts | 1 + packages/dapp-kit-ui/src/constants/veworld.ts | 1 + packages/dapp-kit/src/classes/wallet-manager.ts | 4 +--- 4 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 packages/dapp-kit-ui/src/constants/veworld.ts diff --git a/packages/dapp-kit-ui/src/components/modals/connect-modal/connect-modal.ts b/packages/dapp-kit-ui/src/components/modals/connect-modal/connect-modal.ts index 846eab5e..6bb7187b 100644 --- a/packages/dapp-kit-ui/src/components/modals/connect-modal/connect-modal.ts +++ b/packages/dapp-kit-ui/src/components/modals/connect-modal/connect-modal.ts @@ -9,6 +9,7 @@ import { defaultI18n, Font, WalletSources, + VEWORLD_WEBSITE, } from '../../../constants'; import { DarkChevronLeftSvg, @@ -97,6 +98,14 @@ export class ConnectModal extends LitElement { @property({ type: Function }) onSourceClick = (source?: SourceInfo): void => { if (source) { + if (source.id === 'veworld' && !window.vechain) { + const path = `${location.host}${location.pathname}${location.search}`; + window.open( + `${VEWORLD_WEBSITE}/?discoveryUrl=${path}`, + '_self', + ); + return; + } if (source.id !== 'wallet-connect') { this.setWaitingForTheSignature(true); this.requestForConnectionCertificate = true; diff --git a/packages/dapp-kit-ui/src/constants/index.ts b/packages/dapp-kit-ui/src/constants/index.ts index 7389832e..e8337817 100644 --- a/packages/dapp-kit-ui/src/constants/index.ts +++ b/packages/dapp-kit-ui/src/constants/index.ts @@ -6,3 +6,4 @@ export * from './stores'; export * from './font'; export * from './i18n'; export * from './z-index'; +export * from './veworld'; diff --git a/packages/dapp-kit-ui/src/constants/veworld.ts b/packages/dapp-kit-ui/src/constants/veworld.ts new file mode 100644 index 00000000..6676ad83 --- /dev/null +++ b/packages/dapp-kit-ui/src/constants/veworld.ts @@ -0,0 +1 @@ +export const VEWORLD_WEBSITE = 'https://veworld.com'; diff --git a/packages/dapp-kit/src/classes/wallet-manager.ts b/packages/dapp-kit/src/classes/wallet-manager.ts index 622df128..674ae52c 100644 --- a/packages/dapp-kit/src/classes/wallet-manager.ts +++ b/packages/dapp-kit/src/classes/wallet-manager.ts @@ -275,9 +275,7 @@ class WalletManager { private getAvailableSources = (): WalletSource[] => { const wallets: WalletSource[] = []; - if (window.vechain) { - wallets.push('veworld'); - } + wallets.push('veworld'); if (this.options.walletConnectOptions) { wallets.push('wallet-connect');