Skip to content

Commit 32ac638

Browse files
committed
blockPollingInterval add
1 parent d192b1a commit 32ac638

File tree

6 files changed

+25
-17
lines changed

6 files changed

+25
-17
lines changed

src/interfaces.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export interface Initialization {
77
darkMode?: boolean
88
apiUrl?: string
99
hideBranding?: boolean
10-
pollingInterval?: number
10+
blockPollingInterval?: number
1111
}
1212

1313
export interface Subscriptions {
@@ -182,7 +182,6 @@ export interface WalletConnectOptions extends CommonWalletOptions {
182182
[key: string]: string
183183
}
184184
bridge: string
185-
pollingInterval: number
186185
}
187186

188187
export interface TrezorOptions extends CommonWalletOptions {

src/modules/select/wallets/providerEngine.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import HookedWalletSubprovider from 'web3-provider-engine/subproviders/hooked-wa
44
import SubscriptionSubprovider from 'web3-provider-engine/subproviders/subscriptions'
55
import FilterSubprovider from 'web3-provider-engine/subproviders/filters'
66

7+
import { get } from 'svelte/store'
8+
9+
import { app } from '../../../stores'
10+
711
function createProvider(config: any) {
812
const {
913
getAccounts,
@@ -13,10 +17,9 @@ function createProvider(config: any) {
1317
processPersonalMessage,
1418
signMessage,
1519
signPersonalMessage,
16-
pollingInterval
1720
} = config
1821

19-
console.log("from inside provider engine : " , {pollingInterval})
22+
const pollingInterval = get(app).blockPollingInterval
2023

2124
const idMgmt =
2225
getAccounts &&

src/modules/select/wallets/wallet-connect.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ import {
66

77
import walletConnectIcon from '../wallet-icons/icon-wallet-connect'
88

9+
import { get } from 'svelte/store'
10+
11+
import {
12+
app,
13+
} from '../../../stores'
14+
915
function walletConnect(
1016
options: WalletConnectOptions & { networkId: number }
1117
): WalletModule {
@@ -17,11 +23,10 @@ function walletConnect(
1723
label,
1824
iconSrc,
1925
svg,
20-
networkId,
21-
pollingInterval
26+
networkId
2227
} = options
2328

24-
console.log({pollingInterval})
29+
const pollingInterval = get(app).blockPollingInterval
2530

2631
if (!infuraKey) {
2732
if (!rpc || !rpc[networkId]) {
@@ -49,8 +54,7 @@ function walletConnect(
4954
: `https://${networkName(networkId)}.infura.io/v3/${infuraKey}`
5055

5156
const balanceProvider = createProvider({
52-
rpcUrl,
53-
pollingInterval
57+
rpcUrl
5458
})
5559

5660
const provider = new WalletConnectProvider({

src/onboard.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ function init(initialization: Initialization): API {
4949
networkId,
5050
darkMode,
5151
apiUrl,
52-
hideBranding
52+
hideBranding,
53+
blockPollingInterval = 40000
5354
} = initialization
5455

5556
const { os, browser, isMobile } = getDeviceInfo()
@@ -86,7 +87,8 @@ function init(initialization: Initialization): API {
8687
browser,
8788
darkMode,
8889
displayBranding,
89-
checkModules: initializedModules.walletCheck
90+
checkModules: initializedModules.walletCheck,
91+
blockPollingInterval
9092
}))
9193

9294
initializeStores()

src/stores.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ export const app: WritableStore = writable({
3030
checkModules: [],
3131
walletSelectDisplayedUI: false,
3232
walletCheckDisplayedUI: false,
33-
displayBranding: false
33+
displayBranding: false,
34+
blockPollingInterval: 4000,
3435
})
3536

3637
export const stateSyncStatus: {

src/validation.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export function validateInit(init: Initialization): never | void {
6464
darkMode,
6565
apiUrl,
6666
hideBranding,
67-
pollingInterval,
67+
blockPollingInterval,
6868
...otherParams
6969
} = init
7070

@@ -79,7 +79,7 @@ export function validateInit(init: Initialization): never | void {
7979
'darkMode',
8080
'apiUrl',
8181
'hideBranding',
82-
'pollingInterval'
82+
'blockPollingInterval'
8383
],
8484
'init'
8585
)
@@ -110,8 +110,8 @@ export function validateInit(init: Initialization): never | void {
110110
optional: true
111111
})
112112
validateType({
113-
name: 'pollingInterval',
114-
value: pollingInterval,
113+
name: 'blockPollingInterval',
114+
value: blockPollingInterval,
115115
type: 'number',
116116
optional: true
117117
})
@@ -649,7 +649,6 @@ export function validateWalletInit(
649649
'webUri',
650650
'xsUri',
651651
'blockedPopupRedirect',
652-
'pollingInterval'
653652
],
654653
'walletInitObject'
655654
)

0 commit comments

Comments
 (0)