Skip to content

Commit 6f1f18e

Browse files
Release: v1.18.0 (#477)
* 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 * Remove deprecated wallet modules/icons * Fixes issue where there was an undefined wallet in the list of wallets returned * getModule return type more specific and no longer returns undefined which simplifies things for the method's caller * 1.17.1-0.1.0: Updates GridPlus connector in anticipation of upcoming Lattice firmware release (#475)
1 parent 318ec5a commit 6f1f18e

File tree

13 files changed

+71
-341
lines changed

13 files changed

+71
-341
lines changed

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bnc-onboard",
3-
"version": "1.17.1",
3+
"version": "1.18.0",
44
"description": "Onboard users to web3 by allowing them to select a wallet, get that wallet ready to transact and have access to synced wallet state.",
55
"keywords": [
66
"ethereum",
@@ -49,19 +49,17 @@
4949
"@ledgerhq/hw-transport-u2f": "^5.21.0",
5050
"@portis/web3": "^2.0.0-beta.57",
5151
"@toruslabs/torus-embed": "^1.9.2",
52-
"@unilogin/provider": "^0.6.1",
5352
"@walletconnect/web3-provider": "^1.3.1",
5453
"authereum": "^0.1.12",
5554
"bignumber.js": "^9.0.0",
5655
"bnc-sdk": "^2.1.4",
5756
"bowser": "^2.10.0",
58-
"eth-lattice-keyring": "^0.2.4",
57+
"eth-lattice-keyring": "^0.2.7",
5958
"ethereumjs-tx": "^2.1.2",
6059
"ethereumjs-util": "^7.0.3",
6160
"fortmatic": "^2.2.1",
6261
"hdkey": "^2.0.1",
6362
"regenerator-runtime": "^0.13.7",
64-
"squarelink": "^1.1.4",
6563
"trezor-connect": "^8.1.9",
6664
"walletlink": "^2.0.2",
6765
"web3-provider-engine": "^15.0.4"

rollup.config.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,9 @@ export default {
6161
'@portis/web3',
6262
'@walletconnect/web3-provider',
6363
'fortmatic',
64-
'squarelink',
6564
'authereum',
6665
'@toruslabs/torus-embed',
6766
'walletlink',
68-
'@unilogin/provider',
6967
'regenerator-runtime/runtime',
7068
'trezor-connect',
7169
'ethereumjs-tx',

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: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,49 @@ 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)
3337

34-
if (!module) {
35-
throw new Error(`${walletName} is not a valid walletName.`)
38+
try {
39+
return getModule(walletName).then((m: any) =>
40+
m.default({ ...initParams, networkId })
41+
)
42+
} catch (error) {
43+
if (error.name === 'DeprecatedWalletError') {
44+
console.warn(error.message)
45+
} else {
46+
throw error
47+
}
3648
}
37-
38-
return (
39-
module &&
40-
module.then((m: any) => m.default({ ...initParams, networkId }))
41-
)
4249
}
4350

4451
return Promise.resolve(wallet)
@@ -47,29 +54,34 @@ function select(
4754
}
4855

4956
return Promise.all(
50-
defaultWalletNames.map(walletName => {
51-
const module = getModule(walletName)
52-
if (module) {
53-
return module.then((m: any) => m.default({ networkId }))
54-
}
55-
})
57+
defaultWalletNames.map(walletName =>
58+
getModule(walletName).then((m: any) => m.default({ networkId }))
59+
)
5660
)
5761
}
5862

59-
function getModule(name: string): Promise<any> | undefined {
63+
function getModule(
64+
name: string
65+
): Promise<{
66+
default: (options: any) => WalletModule
67+
}> {
6068
switch (name) {
69+
// Deprecated wallets
70+
case 'dapper':
71+
case 'squarelink':
72+
case 'unilogin':
73+
throw {
74+
name: 'DeprecatedWalletError',
75+
message: `${name} wallet has been deprecated`
76+
}
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':
@@ -113,7 +123,7 @@ function getModule(name: string): Promise<any> | undefined {
113123
case 'atoken':
114124
return import('./wallets/atoken')
115125
default:
116-
return
126+
throw new Error(`${name} is not a valid walletName.`)
117127
}
118128
}
119129

-1.24 KB
Binary file not shown.
Binary file not shown.

src/modules/select/wallet-icons/icon-squarelink.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)