Skip to content

Commit 90c1171

Browse files
committed
Modify default wallets:
* Separates default wallets into mobile and desktop * Moves Authereum to 2nd place * Adds isMobile parameter to determine which wallets to display * Adds deprecation warning for deprecated wallets
1 parent 65bfdcc commit 90c1171

File tree

3 files changed

+31
-15
lines changed

3 files changed

+31
-15
lines changed

src/modules/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@ const defaultWalletExplanation = `Wallets are used to send, receive, and store d
1313
export default function initializeModules(
1414
networkId: number,
1515
walletSelect: WalletSelectModuleOptions | undefined,
16-
walletCheck: Array<WalletCheckModule | WalletCheckInit> | undefined
16+
walletCheck: Array<WalletCheckModule | WalletCheckInit> | undefined,
17+
isMobile: boolean
1718
) {
18-
const wallets = select(walletSelect && walletSelect.wallets, networkId)
19+
const wallets = select(
20+
walletSelect && walletSelect.wallets,
21+
networkId,
22+
isMobile
23+
)
1924

2025
return {
2126
walletSelect: {

src/modules/select/index.ts

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,44 @@ import { isWalletInit } from '../../validation'
33

44
// wallets that qualify for default wallets need to have no
55
// init parameters that are required for full functionality
6-
const defaultWalletNames = [
6+
const desktopDefaultWalletNames = ['metamask', 'authereum', 'torus', 'opera']
7+
8+
const mobileDefaultWalletNames = [
79
'metamask',
8-
'dapper',
10+
'authereum',
911
'coinbase',
1012
'trust',
11-
'authereum',
1213
'torus',
1314
'opera',
1415
'operaTouch',
1516
'status',
1617
'hyperpay',
17-
'unilogin',
1818
'tokenpocket',
1919
'dcent',
2020
'atoken'
2121
]
2222

2323
function select(
2424
wallets: Array<WalletInitOptions | WalletModule> | undefined,
25-
networkId: number
25+
networkId: number,
26+
isMobile: boolean
2627
) {
28+
const defaultWalletNames = isMobile
29+
? mobileDefaultWalletNames
30+
: desktopDefaultWalletNames
31+
2732
if (wallets) {
2833
return Promise.all(
2934
wallets.map(wallet => {
3035
if (isWalletInit(wallet)) {
3136
const { walletName, ...initParams } = wallet
32-
const module = getModule(walletName)
37+
38+
let module
39+
try {
40+
module = getModule(walletName)
41+
} catch (error) {
42+
console.warn(error)
43+
}
3344

3445
if (!module) {
3546
throw new Error(`${walletName} is not a valid walletName.`)
@@ -58,18 +69,19 @@ function select(
5869

5970
function getModule(name: string): Promise<any> | undefined {
6071
switch (name) {
72+
// Deprecated wallets
73+
case 'dapper':
74+
case 'squarelink':
75+
case 'unilogin':
76+
throw new Error(`${name.toUpperCase()} wallet has been deprecated`)
6177
case 'meetone':
6278
return import('./wallets/meetone')
6379
case 'metamask':
6480
return import('./wallets/metamask')
65-
case 'dapper':
66-
return import('./wallets/dapper')
6781
case 'portis':
6882
return import('./wallets/portis')
6983
case 'fortmatic':
7084
return import('./wallets/fortmatic')
71-
case 'squarelink':
72-
return import('./wallets/squarelink')
7385
case 'authereum':
7486
return import('./wallets/authereum')
7587
case 'trust':
@@ -96,8 +108,6 @@ function getModule(name: string): Promise<any> | undefined {
96108
return import('./wallets/wallet-link')
97109
case 'imToken':
98110
return import('./wallets/imtoken')
99-
case 'unilogin':
100-
return import('./wallets/unilogin')
101111
case 'mykey':
102112
return import('./wallets/mykey')
103113
case 'huobiwallet':

src/onboard.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ function init(initialization: Initialization): API {
5858
const initializedModules = initializeModules(
5959
networkId,
6060
initialization.walletSelect,
61-
initialization.walletCheck
61+
initialization.walletCheck,
62+
isMobile
6263
)
6364

6465
let displayBranding: boolean

0 commit comments

Comments
 (0)