From 0b3b4b0df768bf5d6c4e8ec353ea5a66c00e32c1 Mon Sep 17 00:00:00 2001 From: ronaldsg Date: Fri, 6 Dec 2024 10:30:29 -0500 Subject: [PATCH] include browser support for each pegin wallets on the feature flags --- src/common/components/exchange/SelectBitcoinWallet.vue | 7 +++++-- src/common/types/Feature.ts | 10 ++++++++++ src/common/utils/utils.ts | 7 +++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/common/components/exchange/SelectBitcoinWallet.vue b/src/common/components/exchange/SelectBitcoinWallet.vue index 69ce12d48..aeaef6b78 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 c478838db..98ec7a107 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 0de917604..a45745548 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) {