Skip to content

Commit d782a2c

Browse files
authored
Merge pull request #398 from blocknative/develop
Release 1.10.3
2 parents 131a476 + f9de984 commit d782a2c

File tree

3 files changed

+38
-39
lines changed

3 files changed

+38
-39
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.10.2",
3+
"version": "1.10.3",
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/stores.ts

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ export let network: WalletStateSliceStore
5454
export let balance: BalanceStore | WalletStateSliceStore
5555
export let wallet: WritableStore
5656
export let state: ReadableStore
57+
export let walletInterface: WalletInterfaceStore
58+
59+
let currentSyncerIntervals: ({ clear: () => void } | undefined)[]
5760

5861
export function initializeStores() {
5962
address = createWalletStateSliceStore({
@@ -96,43 +99,39 @@ export function initializeStores() {
9699
}
97100
}
98101
)
99-
}
100102

101-
// keep track of intervals that are syncing state so they can be cleared
102-
let currentSyncerIntervals: ({ clear: () => void } | undefined)[] = []
103-
104-
export const walletInterface: WalletInterfaceStore = createWalletInterfaceStore(
105-
null
106-
)
107-
108-
walletInterface.subscribe((walletInterface: WalletInterface | null) => {
109-
// make sure that stores have been initialized
110-
if (state) {
111-
// clear all current intervals if they exist
112-
currentSyncerIntervals.forEach(
113-
(interval: { clear: () => void } | undefined) =>
114-
interval && interval.clear()
115-
)
116-
117-
const currentState = get(state)
118-
119-
// reset state
120-
currentState.balance && balance.reset()
121-
currentState.address && address.reset()
122-
currentState.network && network.reset()
123-
124-
if (walletInterface) {
125-
// start syncing state and save intervals
126-
currentSyncerIntervals = [
127-
address.setStateSyncer(walletInterface.address),
128-
network.setStateSyncer(walletInterface.network),
129-
balance.setStateSyncer(walletInterface.balance)
130-
]
131-
}
103+
currentSyncerIntervals = []
132104

133-
resetCheckModules()
134-
}
135-
})
105+
walletInterface = createWalletInterfaceStore(null)
106+
walletInterface.subscribe((walletInterface: WalletInterface | null) => {
107+
// make sure that stores have been initialized
108+
if (state) {
109+
// clear all current intervals if they exist
110+
currentSyncerIntervals.forEach(
111+
(interval: { clear: () => void } | undefined) =>
112+
interval && interval.clear()
113+
)
114+
115+
const currentState = get(state)
116+
117+
// reset state
118+
currentState.balance && balance.reset()
119+
currentState.address && address.reset()
120+
currentState.network && network.reset()
121+
122+
if (walletInterface) {
123+
// start syncing state and save intervals
124+
currentSyncerIntervals = [
125+
address.setStateSyncer(walletInterface.address),
126+
network.setStateSyncer(walletInterface.network),
127+
balance.setStateSyncer(walletInterface.balance)
128+
]
129+
}
130+
131+
resetCheckModules()
132+
}
133+
})
134+
}
136135

137136
export function resetWalletState(options?: {
138137
disconnected: boolean

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4743,9 +4743,9 @@ lodash.flatmap@^4.5.0:
47434743
integrity sha1-74y/QI9uSCaGYzRTBcaswLd4cC4=
47444744

47454745
lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.4:
4746-
version "4.17.15"
4747-
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
4748-
integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==
4746+
version "4.17.19"
4747+
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b"
4748+
integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==
47494749

47504750
loglevel@^1.6.8:
47514751
version "1.6.8"

0 commit comments

Comments
 (0)