Skip to content

Commit 54a6ba6

Browse files
committed
Merge branch 'develop' into feature/custom-derivation-path
2 parents b88b575 + 130a5ac commit 54a6ba6

File tree

13 files changed

+667
-271
lines changed

13 files changed

+667
-271
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.2",
3+
"version": "1.3.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",
@@ -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/Modal.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
font-family: 'Helvetica Neue';
1616
justify-content: center;
1717
align-items: center;
18-
position: absolute;
18+
position: fixed;
1919
font-size: 16px;
2020
z-index: 99;
2121
top: 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
@@ -162,6 +162,16 @@ export interface TorusOptions {
162162
showTorusButton?: boolean
163163
buttonPosition?: 'top-left' | 'top-right' | 'bottom-right' | 'bottom-left'
164164
enableLogging?: boolean
165+
enabledVerifiers: TorusVerifierStatus
166+
}
167+
168+
169+
interface TorusVerifierStatus {
170+
google?: boolean;
171+
facebook?: boolean;
172+
reddit?: boolean;
173+
twitch?: boolean;
174+
discord?: boolean;
165175
}
166176

167177
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+
const params = {
9+
jsonrpc: '2.0',
10+
method: 'net_version',
11+
params: [],
12+
id: 42
13+
}
14+
15+
const callback = (e: any, res: any) => {
16+
e && reject(e)
17+
const result = res && res.result
18+
resolve(result && Number(result))
19+
}
20+
21+
if (typeof provider.sendAsync === 'function') {
22+
provider.sendAsync(params, callback)
23+
} else if (typeof provider.send === 'function') {
24+
provider.send(params, callback)
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+
const params = {
34+
jsonrpc: '2.0',
35+
method: 'eth_accounts',
36+
params: [],
37+
id: 42
38+
}
39+
40+
const callback = (e: any, res: any) => {
41+
e && reject(e)
42+
const result = res && res.result && res.result[0]
43+
resolve(result)
44+
}
45+
46+
if (typeof provider.sendAsync === 'function') {
47+
provider.sendAsync(params, callback)
48+
} else if (typeof provider.send === 'function') {
49+
provider.send(params, callback)
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+
const params = {
66+
jsonrpc: '2.0',
67+
method: 'eth_getBalance',
68+
params: [currentAddress, 'latest'],
69+
id: 42
70+
}
71+
72+
const callback = (e: any, res: any) => {
73+
e && reject(e)
74+
const result = res && res.result
75+
resolve(result && new BigNumber(result).toString(10))
76+
}
77+
78+
if (typeof provider.sendAsync === 'function') {
79+
provider.sendAsync(params, callback)
80+
} else if (typeof provider.send === 'function') {
81+
provider.send(params, callback)
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
@@ -24,6 +24,10 @@
2424
background: #0e212a;
2525
}
2626
27+
:global(.bn-onboard-clickable) {
28+
text-decoration: none;
29+
}
30+
2731
:global(.bn-onboard-clickable:hover) {
2832
cursor: pointer;
2933
text-decoration: underline;

0 commit comments

Comments
 (0)