Skip to content

Commit 65dd697

Browse files
authored
Merge pull request #240 from blocknative/develop
Release 1.3.4
2 parents d6323b8 + 419f4ba commit 65dd697

File tree

11 files changed

+154
-365
lines changed

11 files changed

+154
-365
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bnc-onboard",
3-
"version": "1.3.3",
3+
"version": "1.3.4",
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",
@@ -42,7 +42,7 @@
4242
"@ledgerhq/hw-app-eth": "^5.7.0",
4343
"@ledgerhq/hw-transport-u2f": "^5.7.0",
4444
"@portis/web3": "^2.0.0-beta.42",
45-
"@toruslabs/torus-embed": "^0.2.11",
45+
"@toruslabs/torus-embed": "^1.1.1",
4646
"@walletconnect/web3-provider": "^1.0.0-beta.45",
4747
"authereum": "^0.0.4-beta.88",
4848
"bignumber.js": "^9.0.0",

src/components/Wallets.svelte

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
export let modalData: WalletSelectModalData
1212
export let handleWalletSelect: (wallet: WalletModule) => void
1313
export let loadingWallet: string | undefined
14-
15-
let showingAllWalletModules: boolean = false
14+
export let showingAllWalletModules: boolean = false
15+
export let showAllWallets: () => void
1616
let selectedWallet: WritableStore
1717
1818
const unsubscribe = wallet.subscribe(wallet => (selectedWallet = wallet))
@@ -80,9 +80,7 @@
8080

8181
{#if modalData.secondaryWallets && modalData.secondaryWallets.length && !showingAllWalletModules}
8282
<div>
83-
<Button onclick={() => (showingAllWalletModules = true)}>
84-
Show More
85-
</Button>
83+
<Button onclick={showAllWallets}>Show More</Button>
8684
</div>
8785
{/if}
8886

src/elements/IconButton.svelte

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
}
5656
5757
span {
58+
width: 100%;
59+
display: flex;
60+
justify-content: space-between;
61+
align-items: center;
5862
font-size: inherit;
5963
margin-left: 0.66em;
6064
font-weight: bold;
@@ -63,21 +67,28 @@
6367
}
6468
6569
i {
66-
font-size: 1.6rem;
67-
margin-left: 0.5rem;
70+
font-size: 0.8rem;
71+
font-weight: lighter;
72+
color: inherit;
73+
text-decoration: underline;
6874
}
6975
7076
@media only screen and (max-width: 450px) {
7177
button {
7278
width: 100%;
7379
}
7480
}
81+
82+
.bn-onboard-selected-wallet {
83+
background: #c3c3c3;
84+
}
7585
</style>
7686

7787
<button
7888
on:click={onclick}
7989
class="bn-onboard-custom bn-onboard-icon-button"
80-
class:bn-onboard-dark-mode-background-hover={$app.darkMode}>
90+
class:bn-onboard-dark-mode-background-hover={$app.darkMode}
91+
class:bn-onboard-selected-wallet={currentlySelected}>
8192
<div>
8293
{#if loadingWallet === text}
8394
<Spinner />
@@ -87,8 +98,10 @@
8798
<img src={iconSrc} srcset={iconSrcSet} alt={text} />
8899
{/if}
89100
</div>
90-
<span>{text}</span>
91-
{#if currentlySelected}
92-
<i>*</i>
93-
{/if}
101+
<span>
102+
{text}
103+
{#if currentlySelected}
104+
<i>selected</i>
105+
{/if}
106+
</span>
94107
</button>

src/interfaces.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,16 @@ export interface TorusOptions {
158158
showTorusButton?: boolean
159159
buttonPosition?: 'top-left' | 'top-right' | 'bottom-right' | 'bottom-left'
160160
enableLogging?: boolean
161+
enabledVerifiers: TorusVerifierStatus
162+
}
163+
164+
165+
interface TorusVerifierStatus {
166+
google?: boolean;
167+
facebook?: boolean;
168+
reddit?: boolean;
169+
twitch?: boolean;
170+
discord?: boolean;
161171
}
162172

163173
export interface AuthereumOptions {

src/modules/select/content.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,16 @@ export const extensionInstallMessage = (helpers: {
3131
<p style="font-size: 0.889rem; font-family: inherit; margin: 0.889rem 0;">
3232
You'll need to install <b>${selectedWallet}</b> to continue. Once you have it installed, go ahead and
3333
<span
34-
class="bn-clickable"
34+
class="bn-onboard-clickable"
3535
style="color: #4a90e2; font-size: 0.889rem; font-family: inherit;"
3636
onclick={window.location.reload();}>
3737
refresh the page.
3838
</span>
39+
${
40+
selectedWallet === 'Opera'
41+
? '<br><br><i>Hint: If you already have Opera installed, make sure that your web3 wallet is <a style="color: #4a90e2; font-size: 0.889rem; font-family: inherit;" class="bn-onboard-clickable" href="https://help.opera.com/en/touch/crypto-wallet/" rel="noreferrer noopener" target="_blank">enabled</a></i>'
42+
: ''
43+
}
3944
</p>
4045
`
4146
}

src/modules/select/wallets/torus.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ function torus(options: TorusOptions & CommonWalletOptions): WalletModule {
1818
buttonPosition,
1919
enableLogging,
2020
loginMethod,
21-
showTorusButton
21+
showTorusButton,
22+
enabledVerifiers
2223
} = options
2324

2425
return {
@@ -39,7 +40,8 @@ function torus(options: TorusOptions & CommonWalletOptions): WalletModule {
3940
chainId: networkId, // default: 1
4041
networkName: `${networkName(networkId)} Network` // default: Main Ethereum Network
4142
},
42-
showTorusButton: showTorusButton // default: true
43+
showTorusButton: showTorusButton, // default: true
44+
enabledVerifiers: enabledVerifiers
4345
})
4446

4547
const provider = instance.provider

src/utilities.ts

Lines changed: 65 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,51 @@ import { WalletInterface } from './interfaces'
55

66
export function getNetwork(provider: any): Promise<number | any> {
77
return new Promise((resolve, reject) => {
8-
provider.sendAsync(
9-
{
10-
jsonrpc: '2.0',
11-
method: 'net_version',
12-
params: [],
13-
id: 42
14-
},
15-
(e: any, res: any) => {
16-
e && reject(e)
17-
const result = res && res.result
18-
resolve(result && Number(result))
19-
}
20-
)
8+
// web3.js sometimes deletes sendAsync method
9+
const method = provider.sendAsync || provider.send
10+
11+
if (method) {
12+
method(
13+
{
14+
jsonrpc: '2.0',
15+
method: 'net_version',
16+
params: [],
17+
id: 42
18+
},
19+
(e: any, res: any) => {
20+
e && reject(e)
21+
const result = res && res.result
22+
resolve(result && Number(result))
23+
}
24+
)
25+
} else {
26+
resolve(null)
27+
}
2128
})
2229
}
2330

2431
export function getAddress(provider: any): Promise<string | any> {
2532
return new Promise((resolve, reject) => {
26-
provider.sendAsync(
27-
{
28-
jsonrpc: '2.0',
29-
method: 'eth_accounts',
30-
params: [],
31-
id: 42
32-
},
33-
(e: any, res: any) => {
34-
e && reject(e)
35-
const result = res && res.result && res.result[0]
36-
resolve(result)
37-
}
38-
)
33+
// web3.js sometimes deletes sendAsync method
34+
const method = provider.sendAsync || provider.send
35+
36+
if (method) {
37+
method(
38+
{
39+
jsonrpc: '2.0',
40+
method: 'eth_accounts',
41+
params: [],
42+
id: 42
43+
},
44+
(e: any, res: any) => {
45+
e && reject(e)
46+
const result = res && res.result && res.result[0]
47+
resolve(result)
48+
}
49+
)
50+
} else {
51+
resolve(null)
52+
}
3953
})
4054
}
4155

@@ -48,19 +62,26 @@ export function getBalance(provider: any): Promise<string | any> {
4862
return
4963
}
5064

51-
provider.sendAsync(
52-
{
53-
jsonrpc: '2.0',
54-
method: 'eth_getBalance',
55-
params: [currentAddress, 'latest'],
56-
id: 42
57-
},
58-
(e: any, res: any) => {
59-
e && reject(e)
60-
const result = res && res.result
61-
resolve(result && new BigNumber(result).toString(10))
62-
}
63-
)
65+
// web3.js sometimes deletes sendAsync method
66+
const method = provider.sendAsync || provider.send
67+
68+
if (method) {
69+
method(
70+
{
71+
jsonrpc: '2.0',
72+
method: 'eth_getBalance',
73+
params: [currentAddress, 'latest'],
74+
id: 42
75+
},
76+
(e: any, res: any) => {
77+
e && reject(e)
78+
const result = res && res.result
79+
resolve(result && new BigNumber(result).toString(10))
80+
}
81+
)
82+
} else {
83+
resolve(null)
84+
}
6485
})
6586
}
6687

@@ -132,6 +153,11 @@ export function createLegacyProviderInterface(provider: any): WalletInterface {
132153
export function getProviderName(provider: any): string | undefined {
133154
if (!provider) return
134155

156+
// Torus also exports isMetamask to be true for backward compatibility
157+
if (provider.isTorus) {
158+
return 'Torus'
159+
}
160+
135161
if (provider.isMetaMask) {
136162
return 'MetaMask'
137163
}
@@ -156,10 +182,6 @@ export function getProviderName(provider: any): string | undefined {
156182
return 'Toshi'
157183
}
158184

159-
if (provider.isTorus) {
160-
return 'Torus'
161-
}
162-
163185
if (provider.isCipher) {
164186
return 'Cipher'
165187
}

src/validation.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ export function validateWalletInit(
532532
enableLogging,
533533
loginMethod,
534534
showTorusButton,
535+
enabledVerifiers,
535536
disableNotifications,
536537
...otherParams
537538
} = walletInit
@@ -554,7 +555,8 @@ export function validateWalletInit(
554555
'buttonPosition',
555556
'enableLogging',
556557
'loginMethod',
557-
'showTorusButton'
558+
'showTorusButton',
559+
'enabledVerifiers'
558560
],
559561
'walletInitObject'
560562
)
@@ -658,6 +660,14 @@ export function validateWalletInit(
658660
optional: true
659661
})
660662

663+
664+
validateType({
665+
name: 'walletInit.enabledVerifiers',
666+
value: enabledVerifiers,
667+
type: 'object',
668+
optional: true
669+
})
670+
661671
validateType({
662672
name: 'walletInit.buttonPosition',
663673
value: buttonPosition,

src/views/Onboard.svelte

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
background: #0e212a;
2626
}
2727
28+
:global(.bn-onboard-clickable) {
29+
text-decoration: none;
30+
}
31+
2832
:global(.bn-onboard-clickable:hover) {
2933
cursor: pointer;
3034
text-decoration: underline;

src/views/WalletSelect.svelte

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
5454
let loadingWallet: string | undefined = undefined
5555
56+
let showingAllWalletModules = false
57+
const showAllWallets = () => (showingAllWalletModules = true)
58+
5659
renderWalletSelect()
5760
5861
async function renderWalletSelect() {
@@ -207,7 +210,12 @@
207210
<p class="bn-onboard-custom bn-onboard-select-description">
208211
{@html modalData.description}
209212
</p>
210-
<Wallets {modalData} {handleWalletSelect} {loadingWallet} />
213+
<Wallets
214+
{modalData}
215+
{handleWalletSelect}
216+
{loadingWallet}
217+
{showingAllWalletModules}
218+
{showAllWallets} />
211219
<div class="bn-onboard-custom bn-onboard-select-info-container">
212220
<span
213221
class="bn-onboard-custom bn-onboard-select-wallet-info"

0 commit comments

Comments
 (0)