Skip to content

Commit 8ea22ae

Browse files
authored
1.22.0-0.2.0: [enhancement] - Filter Confirmed Status (#527)
* Update SDK * Filter transaction events to confirmed status * Fix formatting * Fix subscribe * Increment version * Increment version
1 parent 86b1e64 commit 8ea22ae

File tree

4 files changed

+37
-23
lines changed

4 files changed

+37
-23
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bnc-onboard",
3-
"version": "1.22.0-0.1.0",
3+
"version": "1.22.0-0.2.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",
@@ -53,7 +53,7 @@
5353
"@walletconnect/web3-provider": "^1.4.1",
5454
"authereum": "^0.1.12",
5555
"bignumber.js": "^9.0.0",
56-
"bnc-sdk": "^3.1.0",
56+
"bnc-sdk": "^3.2.0",
5757
"bowser": "^2.10.0",
5858
"eth-lattice-keyring": "^0.2.7",
5959
"eth-provider": "^0.6.1",

src/stores.ts

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { getBlocknative } from './services'
1+
import { Emitter } from 'bnc-sdk/dist/types/src/interfaces'
22
import { writable, derived, get } from 'svelte/store'
3+
import { getBlocknative } from './services'
34
import { wait, makeCancelable, createInterval } from './utilities'
45
import { validateWalletInterface, validateType } from './validation'
56
import {
@@ -318,23 +319,34 @@ function createBalanceStore(initialState: string | null): BalanceStore {
318319
blocknative.unsubscribe(emitterAddress)
319320
}
320321

321-
emitter = blocknative.account($address).emitter
322-
323-
emitter.on('txConfirmed', () => {
324-
if (stateSyncer.get) {
325-
cancel = syncStateWithTimeout({
326-
getState: stateSyncer.get,
327-
setState: set,
328-
timeout: 2000,
329-
currentBalance: get(balance),
330-
pollStart: Date.now()
322+
// subscribe to new address and filter to just confirmed status
323+
blocknative
324+
.configuration({
325+
scope: $address,
326+
filters: [{ status: 'confirmed' }],
327+
watchAddress: true
328+
})
329+
.then((result: { emitter: Emitter }) => {
330+
emitter = result.emitter
331+
332+
emitter.on('txConfirmed', () => {
333+
if (stateSyncer.get) {
334+
cancel = syncStateWithTimeout({
335+
getState: stateSyncer.get,
336+
setState: set,
337+
timeout: 2000,
338+
currentBalance: get(balance),
339+
pollStart: Date.now()
340+
})
341+
}
342+
343+
return false
331344
})
332-
}
333-
334-
return false
335-
})
336345

337-
emitterAddress = $address
346+
emitterAddress = $address
347+
})
348+
// swallow possible timeout error for sending configuration
349+
.catch(() => {})
338350
}
339351
} else if (emitterAddress && !$address) {
340352
const blocknative = getBlocknative()

src/utilities.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,11 @@ export function getProviderName(provider: any): string | undefined {
192192
if (provider.isWalletIO) {
193193
return 'wallet.io'
194194
}
195+
195196
if (provider.isDcentWallet) {
196197
return 'D\'CENT'
197198
}
199+
198200
if (provider.isTokenPocket) {
199201
return 'TokenPocket'
200202
}
@@ -270,7 +272,7 @@ export function getProviderName(provider: any): string | undefined {
270272
if (provider.isLiquality) {
271273
return 'Liquality'
272274
}
273-
275+
274276
if (provider.isAlphaWallet) {
275277
return 'AlphaWallet'
276278
}

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2591,10 +2591,10 @@ bn.js@^5.1.3:
25912591
resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.1.3.tgz#beca005408f642ebebea80b042b4d18d2ac0ee6b"
25922592
integrity sha512-GkTiFpjFtUzU9CbMeJ5iazkCzGL3jrhzerzZIuqLABjbwRaFt33I9tUdSNryIptM+RxDet6OKm2WnLXzW51KsQ==
25932593

2594-
bnc-sdk@^3.1.0:
2595-
version "3.1.0"
2596-
resolved "https://registry.yarnpkg.com/bnc-sdk/-/bnc-sdk-3.1.0.tgz#b568d357a3fe95b627701470c051b72d6c9199a8"
2597-
integrity sha512-qr299cdBiAxFjTharZNlF+qpxjtB49oexSVwDnsW5fczJjBLG1ibJHoUD/GtJbCiVPS+hqq+qH6HJnpsQknRZA==
2594+
bnc-sdk@^3.2.0:
2595+
version "3.2.0"
2596+
resolved "https://registry.yarnpkg.com/bnc-sdk/-/bnc-sdk-3.2.0.tgz#421a9151107785bc075447c8cff260df0c3aed48"
2597+
integrity sha512-7nyb+zRiKYRz0DTdceWHW1whC2nMVj+2uyg91giq8pwV02oDYMpdBsQssKBFghOQMaUqv2TBSZmD5p9hgA5FsA==
25982598
dependencies:
25992599
crypto-es "^1.2.2"
26002600
rxjs "^6.6.3"

0 commit comments

Comments
 (0)