Skip to content

Commit

Permalink
Merge pull request #225 from blocknative/develop
Browse files Browse the repository at this point in the history
Release 1.3.2
  • Loading branch information
lnbc1QWFyb24 authored Mar 3, 2020
2 parents 75d74b9 + ec13054 commit cdf22cc
Show file tree
Hide file tree
Showing 4 changed files with 574 additions and 279 deletions.
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bnc-onboard",
"version": "1.3.1",
"version": "1.3.2",
"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.",
"keywords": [
"ethereum",
Expand Down Expand Up @@ -28,7 +28,6 @@
"@rollup/plugin-image": "^2.0.4",
"@rollup/plugin-json": "^4.0.0",
"@rollup/plugin-node-resolve": "^7.1.1",
"@types/lodash.debounce": "^4.0.6",
"@types/node": "^13.5.1",
"babel-plugin-external-helpers": "^6.18.0",
"rimraf": "^3.0.0",
Expand All @@ -47,11 +46,10 @@
"@walletconnect/web3-provider": "^1.0.0-beta.45",
"authereum": "^0.0.4-beta.88",
"bignumber.js": "^9.0.0",
"bnc-sdk": "1.0.3",
"bnc-sdk": "1.1.0",
"bowser": "^2.5.2",
"ethereumjs-tx": "^2.1.2",
"fortmatic": "^0.8.2",
"lodash.debounce": "^4.0.8",
"regenerator-runtime": "^0.13.3",
"squarelink": "^1.1.4",
"trezor-connect": "7.0.1",
Expand Down
1 change: 0 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export default {
'squarelink',
'authereum',
'@toruslabs/torus-embed',
'lodash.debounce',
'regenerator-runtime/runtime',
'trezor-connect',
'ethereumjs-tx',
Expand Down
42 changes: 23 additions & 19 deletions src/stores.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { getBlocknative } from './services'
import { writable, derived, get } from 'svelte/store'
import debounce from 'lodash.debounce'
import { wait, makeCancelable } from './utilities'
import { validateWalletInterface, validateType } from './validation'
import {
Expand Down Expand Up @@ -255,31 +254,36 @@ function createBalanceStore(initialState: string | null): BalanceStore {
if (emitterAddress !== $address) {
const blocknative = getBlocknative()

// unsubscribe from previous address
if (emitterAddress) {
blocknative.unsubscribe(blocknative.clientIndex, emitterAddress)
}

emitter = blocknative.account(blocknative.clientIndex, $address)
.emitter

emitter.on(
'txConfirmed',
debounce(() => {
if (stateSyncer.get) {
cancel = syncStateWithTimeout({
getState: stateSyncer.get,
setState: set,
timeout: 2000,
currentBalance: get(balance),
pollStart: Date.now()
})
}

return false
}, 500)
)

emitter.on('all', () => false)
emitter.on('txConfirmed', () => {
if (stateSyncer.get) {
cancel = syncStateWithTimeout({
getState: stateSyncer.get,
setState: set,
timeout: 2000,
currentBalance: get(balance),
pollStart: Date.now()
})
}

return false
})

emitterAddress = $address
}
} else if (emitterAddress && !$address) {
const blocknative = getBlocknative()

// unsubscribe from previous address
blocknative.unsubscribe(blocknative.clientIndex, emitterAddress)

// no address, so set balance to undefined
set && set(undefined)
emitterAddress = undefined
Expand Down
Loading

0 comments on commit cdf22cc

Please sign in to comment.