Skip to content

Commit b126dad

Browse files
authored
1.28.0-0.2.1: [fix] - Switch Wallet Flow (#592)
* Call wallet check in switch flow * Increment version * Fix linter
1 parent ee6fa4f commit b126dad

File tree

6 files changed

+29
-18
lines changed

6 files changed

+29
-18
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.28.0-0.2.0",
3+
"version": "1.28.0-0.2.1",
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/interfaces.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export interface UserState {
8888
export interface StateAndHelpers extends UserState {
8989
BigNumber: any
9090
walletSelect: WalletSelectFunction
91+
walletCheck: WalletCheck
9192
wallet: Wallet
9293
exit: (completed?: boolean, state?: Partial<AppState>) => void
9394
stateSyncStatus: {
@@ -398,19 +399,19 @@ export interface WalletSelectFunction {
398399
(autoSelectWallet?: string): Promise<boolean>
399400
}
400401

401-
interface WalletCheck {
402+
export interface WalletCheck {
402403
(): Promise<boolean>
403404
}
404405

405-
interface AccountSelect {
406+
export interface AccountSelect {
406407
(): Promise<boolean>
407408
}
408409

409-
interface Config {
410+
export interface Config {
410411
(options: ConfigOptions): void
411412
}
412413

413-
interface GetState {
414+
export interface GetState {
414415
(): UserState
415416
}
416417

src/modules/check/network.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ function network(
1919
network,
2020
appNetworkId,
2121
walletSelect,
22+
walletCheck,
2223
exit,
2324
stateSyncStatus,
2425
stateStore
@@ -52,16 +53,16 @@ function network(
5253
)}</b> for this Dapp. <br><br> <i style="font-size: inherit; font-family: inherit;">*Some wallets may not support changing networks. If you can not change networks in your wallet you may consider switching to a different wallet.</i>`,
5354
eventCode: 'networkFail',
5455
button: button || {
55-
onclick: () => {
56+
onclick: async () => {
5657
exit(false, { switchingWallets: true })
58+
const walletSelected = await walletSelect()
59+
const walletReady = walletSelected && (await walletCheck())
5760

58-
walletSelect().then(result => {
59-
app.update((store: AppState) => ({
60-
...store,
61-
switchingWallets: false,
62-
walletCheckCompleted: result
63-
}))
64-
})
61+
app.update((store: AppState) => ({
62+
...store,
63+
switchingWallets: false,
64+
walletCheckCompleted: walletReady
65+
}))
6566
},
6667
text: 'Switch Wallet'
6768
},

src/onboard.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ function init(initialization: Initialization): API {
121121
target: document.body,
122122
props: {
123123
walletSelectModule: initializedModules.walletSelect,
124-
walletSelect
124+
walletSelect,
125+
walletCheck
125126
}
126127
})
127128

src/views/Onboard.svelte

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
88
import {
99
WalletSelectModule,
10-
WalletCheckModule,
11-
WalletSelectFunction
10+
WalletSelectFunction,
11+
WalletCheck as WalletCheckType
1212
} from '../interfaces'
1313
1414
export let walletSelectModule: WalletSelectModule
1515
export let walletSelect: WalletSelectFunction
16+
export let walletCheck: WalletCheckType
1617
</script>
1718

1819
<style>
@@ -49,9 +50,13 @@
4950
{/if}
5051

5152
{#if $app.walletCheckInProgress}
52-
<WalletCheck {walletSelect} />
53+
<WalletCheck modules={undefined} {walletSelect} {walletCheck} />
5354
{/if}
5455

5556
{#if $app.accountSelectInProgress}
56-
<WalletCheck modules={[derivationPath(), accountSelect()]} />
57+
<WalletCheck
58+
modules={[derivationPath(), accountSelect()]}
59+
{walletSelect}
60+
{walletCheck}
61+
/>
5762
{/if}

src/views/WalletCheck.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@
2626
import {
2727
WalletCheckModule,
2828
WalletSelectFunction,
29+
WalletCheck,
2930
AppState,
3031
WalletCheckModal,
3132
UserState,
3233
Connect
3334
} from '../interfaces'
3435
36+
export let walletCheck: WalletCheck
3537
export let walletSelect: WalletSelectFunction
3638
export let modules: WalletCheckModule[] | undefined
3739
@@ -222,6 +224,7 @@
222224
...state,
223225
BigNumber,
224226
walletSelect,
227+
walletCheck,
225228
exit: handleExit,
226229
wallet: get(wallet),
227230
stateSyncStatus,

0 commit comments

Comments
 (0)