Skip to content

Commit b978ea2

Browse files
committed
Update Firefox verification on main page and rlogin feature flags
1 parent b374d16 commit b978ea2

File tree

4 files changed

+39
-18
lines changed

4 files changed

+39
-18
lines changed

src/common/store/session/actions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import { toUtf8Bytes } from 'ethers/lib/utils';
1919

2020
export const actions: ActionTree<SessionState, RootState> = {
2121
[constants.SESSION_CONNECT_WEB3]: ({ commit, state, dispatch }): Promise<void> => {
22-
const rLogin = state.rLoginInstance === undefined ? getRloginInstance() : state.rLoginInstance;
22+
const rLogin = state.rLoginInstance === undefined
23+
? getRloginInstance(state.features) : state.rLoginInstance;
2324
return new Promise<void>((resolve, reject) => {
2425
rLogin.connect()
2526
.then((rLoginResponse) => {

src/common/utils/rlogin.ts

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@ import { EnvironmentAccessorService } from '@/common/services/enviroment-accesso
33
import WalletConnectProvider from '@walletconnect/web3-provider';
44
import { trezorProviderOptions } from '@rsksmart/rlogin-trezor-provider';
55
import { ledgerProviderOptions } from '@rsksmart/rlogin-ledger-provider';
6+
import * as constants from '@/common/store/constants';
7+
import {
8+
Browser, Feature, FeatureNames, SupportedBrowsers,
9+
} from '../types';
10+
import { getBrowserName } from './utils';
611

7-
export function getRloginInstance(): RLogin {
12+
export function getRloginInstance(features: Array<Feature>): RLogin {
13+
const currentBrowser = getBrowserName() as Browser;
814
const rpcUrls = {};
915
const customLedgerProviderOptions = ledgerProviderOptions;
1016
customLedgerProviderOptions.connector = async (ProviderPackage, options) => {
@@ -14,6 +20,16 @@ export function getRloginInstance(): RLogin {
1420
await provider.connect();
1521
return provider;
1622
};
23+
const customTrezorProviderOptions = {
24+
...trezorProviderOptions,
25+
options: {
26+
dPath: "m/44'/37310'/0'/0/0",
27+
manifestEmail: EnvironmentAccessorService
28+
.getEnvironmentVariables().vueAppManifestEmail,
29+
manifestAppUrl: EnvironmentAccessorService
30+
.getEnvironmentVariables().vueAppManifestAppUrl,
31+
},
32+
};
1733
const { vueAppRskNodeHost, chainId } = EnvironmentAccessorService.getEnvironmentVariables();
1834
Object
1935
.defineProperty(rpcUrls, chainId, {
@@ -23,30 +39,34 @@ export function getRloginInstance(): RLogin {
2339
enumerable: true,
2440
});
2541
const supportedChains = Object.keys(rpcUrls).map(Number);
26-
const rLoginSetup = new RLogin({
42+
const rLoginOptions = {
2743
cacheProvider: false,
28-
defaultTheme: 'dark',
44+
defaultTheme: 'dark' as 'dark' | 'light',
2945
providerOptions: {
3046
walletconnect: {
3147
package: WalletConnectProvider,
3248
options: {
3349
rpc: rpcUrls,
3450
},
3551
},
36-
'custom-ledger': customLedgerProviderOptions,
37-
'custom-trezor': {
38-
...trezorProviderOptions,
39-
options: {
40-
dPath: "m/44'/37310'/0'/0/0",
41-
manifestEmail: EnvironmentAccessorService
42-
.getEnvironmentVariables().vueAppManifestEmail,
43-
manifestAppUrl: EnvironmentAccessorService
44-
.getEnvironmentVariables().vueAppManifestAppUrl,
45-
},
46-
},
4752
},
4853
rpcUrls,
4954
supportedChains,
50-
});
55+
};
56+
const ledgerFeature = features.find((feature) => feature.name === FeatureNames.WALLET_LEDGER);
57+
if (ledgerFeature?.value === constants.ENABLED
58+
&& ledgerFeature.supportedBrowsers[currentBrowser.toLowerCase() as keyof SupportedBrowsers]) {
59+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
60+
// @ts-ignore
61+
rLoginOptions.providerOptions['custom-ledger'] = customLedgerProviderOptions;
62+
}
63+
const trezorFeature = features.find((feature) => feature.name === FeatureNames.WALLET_TREZOR);
64+
if (trezorFeature?.value === constants.ENABLED
65+
&& trezorFeature.supportedBrowsers[currentBrowser.toLowerCase() as keyof SupportedBrowsers]) {
66+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
67+
// @ts-ignore
68+
rLoginOptions.providerOptions['custom-trezor'] = customTrezorProviderOptions;
69+
}
70+
const rLoginSetup = new RLogin(rLoginOptions);
5171
return rLoginSetup;
5272
}

src/common/utils/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export function getBrowserName() {
127127
}
128128

129129
export function isAllowedCurrentBrowser() {
130-
return getBrowserName() === Browser.CHROME || window.navigator.brave;
130+
return getBrowserName() === Browser.CHROME || window.navigator.brave || Browser.FIREFOX;
131131
}
132132

133133
export function isBTCAmountValidRegex(bitcoinAmount: string) {

src/common/views/Home.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<v-container fluid class="home">
33
<v-alert v-if="!isAllowedBrowser" variant="outlined" type="warning" prominent>
4-
Only Chrome and Brave browsers are allowed
4+
Only Chrome, Firefox and Brave browsers are allowed
55
</v-alert>
66
<v-row v-else no-gutters justify="space-around">
77
<v-col lg="4" xl="3" xxl="2">

0 commit comments

Comments
 (0)