Skip to content

Commit

Permalink
include browser support for each pegin wallets on the feature flags
Browse files Browse the repository at this point in the history
  • Loading branch information
ronaldsg20 committed Dec 6, 2024
1 parent 6f9a042 commit 0b3b4b0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/common/components/exchange/SelectBitcoinWallet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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<BtcWallet>('pegInTx', 'bitcoinWallet');
Expand Down
10 changes: 10 additions & 0 deletions src/common/types/Feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
}
7 changes: 5 additions & 2 deletions src/common/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 0b3b4b0

Please sign in to comment.