diff --git a/src/common/components/exchange/SelectBitcoinWallet.vue b/src/common/components/exchange/SelectBitcoinWallet.vue index 69ce12d4..aeaef6b7 100644 --- a/src/common/components/exchange/SelectBitcoinWallet.vue +++ b/src/common/components/exchange/SelectBitcoinWallet.vue @@ -51,7 +51,8 @@ import { useAction, useGetter, useStateAttribute } from '@/common/store/helper'; import walletConf from '@/common/walletConf.json'; import { mdiArrowLeft } from '@mdi/js'; import { useTheme } from 'vuetify'; -import { Feature, FeatureNames } from '@/common/types'; +import { Browser, Feature, FeatureNames } from '@/common/types'; +import { getBrowserName } from '@/common/utils'; export default { name: 'SelectBitcoinWallet', @@ -62,11 +63,13 @@ export default { const storeConstants = constants; const environmentContext = EnvironmentContextProviderService.getEnvironmentContext(); const getFeature = useGetter<(name: FeatureNames) => Feature>('web3Session', constants.SESSION_GET_FEATURE); + const currentBrowser = getBrowserName() as Browser; const wallets = computed(() => walletConf.wallets.filter((wallet) => { const walletConfJsonConstant = wallet.constant as BtcWallet; const flag = getFeature.value(FeatureNames[walletConfJsonConstant]); - return flag?.value === constants.ENABLED; + return (flag?.value === constants.ENABLED) + && (flag.supportedBrowsers.includes(currentBrowser)); })); const bitcoinWallet = useStateAttribute('pegInTx', 'bitcoinWallet'); diff --git a/src/common/types/Feature.ts b/src/common/types/Feature.ts index c478838d..98ec7a10 100644 --- a/src/common/types/Feature.ts +++ b/src/common/types/Feature.ts @@ -9,8 +9,18 @@ export enum FeatureNames { WALLET_TREZOR = 'wallet_trezor', WALLET_LEDGER = 'wallet_ledger', } + +export enum Browser { + CHROME = 'Chrome', + FIREFOX = 'Firefox', + SAFARI = 'Safari', + EDGE = 'Edge', + BRAVE = 'Brave', + OPERA = 'Opera', +} export interface Feature { name: FeatureNames; value: string; version: number; + supportedBrowsers: Browser[]; } diff --git a/src/common/utils/utils.ts b/src/common/utils/utils.ts index 0de91760..a4574554 100644 --- a/src/common/utils/utils.ts +++ b/src/common/utils/utils.ts @@ -121,9 +121,12 @@ export function isMobileDevice() { return platform === 'mobile'; } +export function getBrowserName() { + return Bowser.getParser(window.navigator.userAgent).getBrowserName(); +} + export function isAllowedCurrentBrowser() { - const browser = Bowser.getParser(window.navigator.userAgent); - return browser.getBrowserName() === 'Chrome' || window.navigator.brave; + return getBrowserName() === 'Chrome' || window.navigator.brave; } export function isBTCAmountValidRegex(bitcoinAmount: string) {