Skip to content

Commit 0c3f01a

Browse files
authored
Merge pull request #213 from blocknative/develop
Release 1.3.0
2 parents 2ea71ed + d3fed9f commit 0c3f01a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1398
-441
lines changed

package.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bnc-onboard",
3-
"version": "1.2.4",
3+
"version": "1.3.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",
@@ -25,32 +25,37 @@
2525
"@babel/core": "^7.5.5",
2626
"@babel/preset-env": "^7.5.5",
2727
"@pyoner/svelte-ts-preprocess": "^1.2.1",
28+
"@rollup/plugin-image": "^2.0.4",
2829
"@rollup/plugin-json": "^4.0.0",
30+
"@rollup/plugin-node-resolve": "^7.1.1",
2931
"@types/lodash.debounce": "^4.0.6",
32+
"@types/node": "^13.5.1",
3033
"babel-plugin-external-helpers": "^6.18.0",
3134
"rimraf": "^3.0.0",
3235
"rollup": "^1.27.5",
33-
"rollup-plugin-commonjs": "^10.0.0",
34-
"rollup-plugin-img": "^1.1.0",
35-
"rollup-plugin-node-resolve": "^5.2.0",
3636
"rollup-plugin-svelte": "^5.0.3",
3737
"rollup-plugin-typescript2": "0.21.0",
3838
"svelte": "^3.12.1",
3939
"svelte-i18n": "^1.1.2-beta",
4040
"typescript": "^3.6.4"
4141
},
4242
"dependencies": {
43+
"@ledgerhq/hw-app-eth": "^5.7.0",
44+
"@ledgerhq/hw-transport-u2f": "^5.7.0",
4345
"@portis/web3": "^2.0.0-beta.42",
4446
"@toruslabs/torus-embed": "^0.2.11",
4547
"@walletconnect/web3-provider": "^1.0.0-beta.45",
4648
"authereum": "^0.0.4-beta.88",
4749
"bignumber.js": "^9.0.0",
4850
"bnc-sdk": "1.0.3",
4951
"bowser": "^2.5.2",
52+
"ethereumjs-tx": "^2.1.2",
5053
"fortmatic": "^0.8.2",
5154
"lodash.debounce": "^4.0.8",
5255
"regenerator-runtime": "^0.13.3",
53-
"squarelink": "^1.1.4"
56+
"squarelink": "^1.1.4",
57+
"trezor-connect": "7.0.1",
58+
"web3-provider-engine": "^15.0.4"
5459
},
5560
"scripts": {
5661
"build": "rimraf dist && rollup -c && babel dist/cjs --out-dir dist/cjs && babel dist/esm --out-dir dist/esm",

rollup.config.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import svelte from 'rollup-plugin-svelte'
2-
import resolve from 'rollup-plugin-node-resolve'
2+
import resolve from '@rollup/plugin-node-resolve'
33
import json from '@rollup/plugin-json'
4-
import image from 'rollup-plugin-img'
5-
import commonjs from 'rollup-plugin-commonjs'
4+
import image from '@rollup/plugin-image'
65
import typescript from 'rollup-plugin-typescript2'
76

87
import {
@@ -25,7 +24,7 @@ export default {
2524
input: 'src/onboard.ts',
2625
output: [
2726
{
28-
format: 'es',
27+
format: 'esm',
2928
dir: 'dist/esm/'
3029
},
3130
{ format: 'cjs', dir: 'dist/cjs/' }
@@ -39,9 +38,9 @@ export default {
3938
resolve({
4039
browser: true,
4140
dedupe: importee =>
42-
importee === 'svelte' || importee.startsWith('svelte/')
41+
importee === 'svelte' || importee.startsWith('svelte/'),
42+
preferBuiltins: true
4343
}),
44-
commonjs(),
4544
typescript({
4645
clean: true,
4746
useTsconfigDeclarationDir: true
@@ -58,6 +57,19 @@ export default {
5857
'authereum',
5958
'@toruslabs/torus-embed',
6059
'lodash.debounce',
61-
'regenerator-runtime/runtime'
60+
'regenerator-runtime/runtime',
61+
'trezor-connect',
62+
'ethereumjs-tx',
63+
'@ledgerhq/hw-transport-u2f',
64+
'@ledgerhq/hw-app-eth',
65+
'util',
66+
'assert',
67+
'buffer',
68+
'stream',
69+
'web3-provider-engine',
70+
'web3-provider-engine/subproviders/hooked-wallet',
71+
'web3-provider-engine/subproviders/rpc',
72+
'web3-provider-engine/subproviders/subscriptions',
73+
'web3-provider-engine/subproviders/filters'
6274
]
6375
}

src/@types/index.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
declare module 'fortmatic'
22
declare module 'squarelink'
33
declare module '@walletconnect/web3-provider'
4+
declare module 'web3-provider-engine'
5+
declare module 'web3-provider-engine/subproviders/rpc'
6+
declare module 'web3-provider-engine/subproviders/hooked-wallet'
7+
declare module 'web3-provider-engine/subproviders/subscriptions'
8+
declare module 'web3-provider-engine/subproviders/filters'
9+
declare module 'trezor-connect'
10+
declare module 'ethereumjs-tx'
11+
declare module '@ledgerhq/hw-app-eth'
12+
declare module '@ledgerhq/hw-transport-u2f'
413

514
declare module '*.png'
615
declare module '*.svg'

src/components/Wallets.svelte

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
<script lang="ts">
2+
import { onDestroy } from 'svelte'
23
import Button from '../elements/Button.svelte'
34
import IconButton from '../elements/IconButton.svelte'
4-
import { WalletSelectModalData, WalletModule } from '../interfaces'
5+
import { wallet } from '../stores'
6+
import {
7+
WalletSelectModalData,
8+
WalletModule,
9+
WritableStore
10+
} from '../interfaces'
511
export let modalData: WalletSelectModalData
612
export let handleWalletSelect: (wallet: WalletModule) => void
713
export let loadingWallet: string | undefined
814
915
let showingAllWalletModules: boolean = false
16+
let selectedWallet: WritableStore
17+
18+
const unsubscribe = wallet.subscribe(wallet => (selectedWallet = wallet))
19+
20+
onDestroy(() => unsubscribe())
1021
</script>
1122

1223
<style>
@@ -62,6 +73,7 @@
6273
iconSrcSet={wallet.iconSrcSet}
6374
svg={wallet.svg}
6475
text={wallet.name}
76+
currentlySelected={wallet.name === selectedWallet.name}
6577
{loadingWallet} />
6678
</li>
6779
{/each}
@@ -83,6 +95,7 @@
8395
iconSrcSet={wallet.iconSrcSet}
8496
svg={wallet.svg}
8597
text={wallet.name}
98+
currentlySelected={wallet.name === selectedWallet.name}
8699
{loadingWallet} />
87100
</li>
88101
{/each}

src/elements/IconButton.svelte

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
export let onclick: () => void = () => {}
88
export let text: string
99
export let loadingWallet: string | undefined
10+
export let currentlySelected: boolean = false
1011
</script>
1112

1213
<style>
@@ -61,6 +62,11 @@
6162
font-family: inherit;
6263
}
6364
65+
i {
66+
font-size: 1.6rem;
67+
margin-left: 0.5rem;
68+
}
69+
6470
@media only screen and (max-width: 450px) {
6571
button {
6672
width: 100%;
@@ -82,4 +88,7 @@
8288
{/if}
8389
</div>
8490
<span>{text}</span>
91+
{#if currentlySelected}
92+
<i>*</i>
93+
{/if}
8594
</button>

src/elements/Spinner.svelte

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<style>
2-
.bn-onboard-loading {
2+
:global(.bn-onboard-loading) {
33
display: inline-block;
44
position: relative;
55
width: 2em;
66
height: 2em;
77
}
8-
.bn-onboard-loading div {
8+
:global(.bn-onboard-loading) :global(div) {
99
box-sizing: border-box;
1010
font-size: inherit;
1111
display: block;
@@ -17,16 +17,16 @@
1717
animation: bn-onboard-loading 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
1818
border-color: currentColor transparent transparent transparent;
1919
}
20-
.bn-onboard-loading div:nth-child(1) {
20+
:global(.bn-onboard-loading) :global(.bn-onboard-loading-first) {
2121
animation-delay: -0.45s;
2222
}
23-
.bn-onboard-loading div:nth-child(2) {
23+
:global(.bn-onboard-loading) :global(.bn-onboard-loading-second) {
2424
animation-delay: -0.3s;
2525
}
26-
.bn-onboard-loading div:nth-child(3) {
26+
:global(.bn-onboard-loading) :global(.bn-onboard-loading-third) {
2727
animation-delay: -0.15s;
2828
}
29-
@keyframes bn-onboard-loading {
29+
@keyframes -global-bn-onboard-loading {
3030
0% {
3131
transform: rotate(0deg);
3232
}
@@ -37,8 +37,7 @@
3737
</style>
3838

3939
<div class="bn-onboard-custom bn-onboard-loading">
40-
<div />
41-
<div />
42-
<div />
43-
<div />
40+
<div class="bn-onboard-loading-first" />
41+
<div class="bn-onboard-loading-second" />
42+
<div class="bn-onboard-loading-third" />
4443
</div>

src/interfaces.ts

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,19 @@ export interface WalletCheckModule {
2525
| WalletCheckModal
2626
| undefined
2727
| Promise<WalletCheckModal | undefined>
28+
id?: string
2829
}
2930

3031
export interface WalletCheckModal {
3132
heading: string
3233
description: string
34+
html?: string
3335
button?: {
3436
onclick: () => void
3537
text: string
3638
}
3739
eventCode: string
3840
action?: () => Promise<{ message: string } | undefined>
39-
loading?: Promise<undefined>
4041
icon?: string
4142
}
4243

@@ -59,7 +60,8 @@ export interface UserState {
5960
export interface StateAndHelpers extends UserState {
6061
BigNumber: any
6162
walletSelect: WalletSelectFunction
62-
exit: () => void
63+
wallet: Wallet
64+
exit: (completed?: boolean) => void
6365
}
6466

6567
export interface WalletModule {
@@ -74,6 +76,7 @@ export interface WalletModule {
7476
interface: WalletInterface | null
7577
instance?: any
7678
}>
79+
type: 'hardware' | 'injected' | 'sdk'
7780
link?: string
7881
url?: string
7982
installMessage?: (wallets: {
@@ -91,6 +94,7 @@ export interface Helpers {
9194
createLegacyProviderInterface: (provider: any) => WalletInterface
9295
createModernProviderInterface: (provider: any) => WalletInterface
9396
BigNumber: any
97+
networkName: (id: number) => string
9498
getAddress: (provider: any) => Promise<string | any>
9599
getNetwork: (provider: any) => Promise<number | any>
96100
getBalance: (provider: any) => Promise<string | any>
@@ -104,7 +108,6 @@ export interface WalletInterface {
104108
name: string | undefined
105109
connect?: () => Promise<{ message: string } | undefined>
106110
disconnect?: () => void
107-
loading?: Promise<undefined>
108111
address: StateSyncer
109112
network: StateSyncer
110113
balance: StateSyncer
@@ -118,9 +121,9 @@ export interface StateSyncer {
118121
export interface Wallet {
119122
name: string
120123
provider: any
124+
type: 'hardware' | 'injected' | 'sdk'
121125
instance?: any
122126
connect?: () => Promise<{ message: string } | undefined>
123-
loading?: Promise<undefined>
124127
}
125128

126129
export interface CommonWalletOptions {
@@ -139,6 +142,16 @@ export interface WalletConnectOptions {
139142
infuraKey: string
140143
}
141144

145+
export interface TrezorOptions {
146+
appUrl: string
147+
email: string
148+
rpcUrl: string
149+
}
150+
151+
export interface LedgerOptions {
152+
rpcUrl: string
153+
}
154+
142155
export interface TorusOptions {
143156
loginMethod?: 'google' | 'facebook' | 'twitch' | 'reddit' | 'discord'
144157
buildEnv?: 'production' | 'development' | 'staging' | 'testing'
@@ -151,15 +164,19 @@ export interface AuthereumOptions {
151164
disableNotifications?: boolean
152165
}
153166

154-
export interface WalletInitOptions
155-
extends CommonWalletOptions,
156-
SdkWalletOptions,
157-
WalletConnectOptions,
158-
TorusOptions,
159-
AuthereumOptions {
167+
interface WalletName {
160168
walletName: string
161169
}
162170

171+
export type WalletInitOptions = CommonWalletOptions &
172+
SdkWalletOptions &
173+
WalletConnectOptions &
174+
TorusOptions &
175+
TrezorOptions &
176+
AuthereumOptions &
177+
LedgerOptions &
178+
WalletName
179+
163180
export interface WalletCheckInit {
164181
checkName: string
165182
minimumBalance?: string
@@ -173,6 +190,10 @@ interface WalletCheck {
173190
(): Promise<boolean>
174191
}
175192

193+
interface AccountSelect {
194+
(): Promise<boolean>
195+
}
196+
176197
interface Config {
177198
(options: ConfigOptions): void
178199
}
@@ -192,6 +213,7 @@ export interface API {
192213
walletReset: () => void
193214
config: Config
194215
getState: GetState
216+
accountSelect: AccountSelect
195217
}
196218

197219
export interface WritableStore {
@@ -232,6 +254,7 @@ export interface AppState {
232254
walletSelectCompleted: boolean
233255
walletCheckInProgress: boolean
234256
walletCheckCompleted: boolean
257+
accountSelectInProgress: boolean
235258
}
236259

237260
export interface CancelablePromise extends Promise<any> {

0 commit comments

Comments
 (0)