Skip to content

Commit 1218529

Browse files
authored
Merge pull request #304 from blocknative/develop
Release 1.7.4
2 parents ab47062 + dc21348 commit 1218529

File tree

7 files changed

+43
-33
lines changed

7 files changed

+43
-33
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.7.3",
3+
"version": "1.7.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",

rollup.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ export default {
2929
},
3030
{ format: 'cjs', dir: 'dist/cjs/' }
3131
],
32+
onwarn: (warning, warn) => {
33+
// supress warning as Typescript removes type definitions
34+
if (warning.code === 'NON_EXISTENT_EXPORT') {
35+
return
36+
}
37+
38+
warn(warning)
39+
},
3240
plugins: [
3341
json(),
3442
image(),

src/interfaces.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ export interface WalletCheckModule {
3333
reset?: () => void
3434
}
3535

36+
export interface Connect {
37+
(): Promise<{ message: string } | string[] | undefined>
38+
}
39+
3640
export interface WalletCheckModal {
3741
heading: string
3842
description: string
@@ -42,7 +46,7 @@ export interface WalletCheckModal {
4246
text: string
4347
}
4448
eventCode: string
45-
action?: () => Promise<{ message: string } | undefined>
49+
action?: Connect | null
4650
icon?: string
4751
}
4852

@@ -58,7 +62,7 @@ export interface UserState {
5862
address: string
5963
network: number
6064
balance: string
61-
wallet: Wallet | null
65+
wallet: Wallet
6266
mobileDevice: boolean
6367
appNetworkId: number
6468
}
@@ -127,7 +131,7 @@ export interface Helpers {
127131

128132
export interface WalletInterface {
129133
name: string | undefined
130-
connect?: () => Promise<{ message: string } | string[] | undefined>
134+
connect?: Connect | null
131135
disconnect?: () => void
132136
address: StateSyncer
133137
network: StateSyncer
@@ -141,12 +145,12 @@ export interface StateSyncer {
141145
}
142146

143147
export interface Wallet {
144-
name: string
145-
provider: any
146-
type: 'hardware' | 'injected' | 'sdk'
147-
instance?: any
148-
connect?: () => Promise<{ message: string } | undefined>
149-
dashboard?: () => void
148+
name: string | null
149+
provider: any | null
150+
type: 'hardware' | 'injected' | 'sdk' | null
151+
instance?: any | null
152+
connect?: Connect | null
153+
dashboard?: () => void | null
150154
}
151155

152156
export interface CommonWalletOptions {

src/modules/check/derivation-path.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { WalletCheckModal, StateAndHelpers } from '../../interfaces'
1+
import { WalletCheckModal, StateAndHelpers, Connect } from '../../interfaces'
22
import { usbIcon } from './icons'
33

44
interface DerivationPaths {
@@ -189,12 +189,13 @@ function derivationPath(
189189
wallet.name === 'Ledger' ? 'and the Ethereum app is open, ' : ''
190190
}then select a derivation path to connect your accounts:`,
191191
eventCode: 'derivationPath',
192-
html: derivationSelectHtmlString(wallet.name),
192+
html: derivationSelectHtmlString(wallet.name as string),
193193
button: {
194194
text: 'Connect',
195195
onclick: async () => {
196196
state.loading = true
197-
const path = state.dPath || derivationPaths[wallet.name][0].path
197+
const path =
198+
state.dPath || derivationPaths[wallet.name as string][0].path
198199
try {
199200
const validPath = await wallet.provider.setPath(
200201
path,
@@ -214,11 +215,9 @@ function derivationPath(
214215

215216
state.error = ''
216217

217-
wallet.connect &&
218-
wallet
219-
.connect()
218+
if (wallet.connect) {
219+
;(wallet.connect as Connect)()
220220
.then(() => {
221-
// @TODO add path to local store
222221
deleteWindowProperties()
223222
state.loading = false
224223
state.completed = true
@@ -227,6 +226,7 @@ function derivationPath(
227226
state.error = error.message
228227
state.loading = false
229228
})
229+
}
230230
}
231231
},
232232

src/modules/select/wallets/ledger.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,6 @@ async function ledgerProvider(options: {
352352
return `0x${transaction.serialize().toString('hex')}`
353353
} catch (error) {
354354
throw error
355-
} finally {
356-
transport.close()
357355
}
358356
}
359357

src/stores.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@ export function resetWalletState(options?: {
125125
// no options object, so do a full reset by disconnecting and setting interface to null
126126
if (!options) {
127127
wallet.update(() => ({
128-
name: undefined,
129-
provider: undefined,
130-
connect: undefined,
131-
instance: undefined,
132-
dashboard: undefined
128+
name: null,
129+
provider: null,
130+
connect: null,
131+
instance: null,
132+
dashboard: null
133133
}))
134134

135135
currentInterface.disconnect && currentInterface.disconnect()
@@ -142,11 +142,11 @@ export function resetWalletState(options?: {
142142
// if walletName is the same as the current interface name then do a full reset (checking if to do a disconnect)
143143
if (currentInterface.name === walletName) {
144144
wallet.update(() => ({
145-
name: undefined,
146-
provider: undefined,
147-
connect: undefined,
148-
instance: undefined,
149-
dashboard: undefined
145+
name: null,
146+
provider: null,
147+
connect: null,
148+
instance: null,
149+
dashboard: null
150150
}))
151151

152152
!disconnected &&

src/views/WalletCheck.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
WalletSelectFunction,
2929
AppState,
3030
WalletCheckModal,
31-
UserState
31+
UserState,
32+
Connect
3233
} from '../interfaces'
3334
3435
export let walletSelect: WalletSelectFunction
@@ -155,8 +156,7 @@
155156
156157
activeModal &&
157158
activeModal.action &&
158-
activeModal
159-
.action()
159+
(activeModal.action as Connect)()
160160
.then(() => {
161161
actionResolved = true
162162
loading = false
@@ -251,7 +251,7 @@
251251
if (!completed) {
252252
loadingModal = true
253253
}
254-
}, 150)
254+
}, 650)
255255
})
256256
257257
if (modal) {

0 commit comments

Comments
 (0)