Skip to content

Commit 96572c7

Browse files
1.29.0-0.5.5: [refactor] detected wallet (#625)
* Remove detectedwallet as a wallet init option
1 parent e0a0458 commit 96572c7

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bnc-onboard",
3-
"version": "1.29.0-0.5.4",
3+
"version": "1.29.0-0.5.5",
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",

src/modules/select/index.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ function select(
5050
: desktopDefaultWalletNames
5151

5252
if (wallets) {
53+
// If we detect an injected wallet then place the detected wallet
54+
// at the beginning of the list e.g. the of the wallet select modal
55+
if (injectedWalletDetected()) {
56+
wallets.unshift({ walletName: 'detectedwallet' })
57+
}
5358
return Promise.all(
54-
wallets
55-
// only include a detected wallet if it's not already one of the provided options
56-
.filter(
57-
wallet =>
58-
isWalletInit(wallet) &&
59-
(wallet.walletName !== 'detectedwallet' || injectedWalletDetected())
60-
)
61-
.map(wallet => {
59+
wallets.map(wallet => {
60+
// If this is a wallet init object then load the built-in wallet module
61+
if (isWalletInit(wallet)) {
6262
const { walletName, ...initParams } = wallet as WalletInitOptions
6363
try {
6464
return getModule(walletName).then((m: any) =>
@@ -71,15 +71,17 @@ function select(
7171
throw error
7272
}
7373
}
74+
}
7475

75-
return Promise.resolve(wallet)
76-
})
76+
// This is a custom wallet module so just return it
77+
return Promise.resolve(wallet)
78+
})
7779
)
7880
}
7981

8082
return Promise.all(
8183
defaultWalletNames
82-
// only include a detected wallet if it's not already one of the provided options
84+
// Include the detected wallet only if an injected wallet is detected
8385
.filter(
8486
walletName =>
8587
walletName !== 'detectedwallet' || injectedWalletDetected()

0 commit comments

Comments
 (0)