File tree Expand file tree Collapse file tree 6 files changed +35
-8
lines changed Expand file tree Collapse file tree 6 files changed +35
-8
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ export interface Initialization {
7
7
darkMode ?: boolean
8
8
apiUrl ?: string
9
9
hideBranding ?: boolean
10
+ blockPollingInterval ?: number
10
11
}
11
12
12
13
export interface Subscriptions {
Original file line number Diff line number Diff line change @@ -4,6 +4,10 @@ import HookedWalletSubprovider from 'web3-provider-engine/subproviders/hooked-wa
4
4
import SubscriptionSubprovider from 'web3-provider-engine/subproviders/subscriptions'
5
5
import FilterSubprovider from 'web3-provider-engine/subproviders/filters'
6
6
7
+ import { get } from 'svelte/store'
8
+
9
+ import { app } from '../../../stores'
10
+
7
11
function createProvider ( config : any ) {
8
12
const {
9
13
getAccounts,
@@ -12,9 +16,11 @@ function createProvider(config: any) {
12
16
processMessage,
13
17
processPersonalMessage,
14
18
signMessage,
15
- signPersonalMessage
19
+ signPersonalMessage,
16
20
} = config
17
21
22
+ const pollingInterval = get ( app ) . blockPollingInterval
23
+
18
24
const idMgmt =
19
25
getAccounts &&
20
26
new HookedWalletSubprovider ( {
@@ -30,7 +36,7 @@ function createProvider(config: any) {
30
36
rpcUrl : rpcUrl . includes ( 'http' ) ? rpcUrl : `https://${ rpcUrl } `
31
37
} )
32
38
33
- const provider = new Web3ProviderEngine ( )
39
+ const provider = new Web3ProviderEngine ( { pollingInterval } )
34
40
35
41
provider . addProvider ( new SubscriptionSubprovider ( ) )
36
42
provider . addProvider ( new FilterSubprovider ( ) )
Original file line number Diff line number Diff line change @@ -6,6 +6,12 @@ import {
6
6
7
7
import walletConnectIcon from '../wallet-icons/icon-wallet-connect'
8
8
9
+ import { get } from 'svelte/store'
10
+
11
+ import {
12
+ app ,
13
+ } from '../../../stores'
14
+
9
15
function walletConnect (
10
16
options : WalletConnectOptions & { networkId : number }
11
17
) : WalletModule {
@@ -20,6 +26,8 @@ function walletConnect(
20
26
networkId
21
27
} = options
22
28
29
+ const pollingInterval = get ( app ) . blockPollingInterval
30
+
23
31
if ( ! infuraKey ) {
24
32
if ( ! rpc || ! rpc [ networkId ] ) {
25
33
throw new Error (
@@ -50,7 +58,8 @@ function walletConnect(
50
58
const provider = new WalletConnectProvider ( {
51
59
infuraId : infuraKey ,
52
60
rpc,
53
- bridge
61
+ bridge,
62
+ pollingInterval
54
63
} )
55
64
56
65
provider . autoRefreshOnNetworkChange = false
Original file line number Diff line number Diff line change @@ -49,7 +49,8 @@ function init(initialization: Initialization): API {
49
49
networkId,
50
50
darkMode,
51
51
apiUrl,
52
- hideBranding
52
+ hideBranding,
53
+ blockPollingInterval = 4000
53
54
} = initialization
54
55
55
56
const { os, browser, isMobile } = getDeviceInfo ( )
@@ -86,7 +87,8 @@ function init(initialization: Initialization): API {
86
87
browser,
87
88
darkMode,
88
89
displayBranding,
89
- checkModules : initializedModules . walletCheck
90
+ checkModules : initializedModules . walletCheck ,
91
+ blockPollingInterval
90
92
} ) )
91
93
92
94
initializeStores ( )
Original file line number Diff line number Diff line change @@ -30,7 +30,8 @@ export const app: WritableStore = writable({
30
30
checkModules : [ ] ,
31
31
walletSelectDisplayedUI : false ,
32
32
walletCheckDisplayedUI : false ,
33
- displayBranding : false
33
+ displayBranding : false ,
34
+ blockPollingInterval : 4000 ,
34
35
} )
35
36
36
37
export const stateSyncStatus : {
Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ export function validateInit(init: Initialization): never | void {
64
64
darkMode,
65
65
apiUrl,
66
66
hideBranding,
67
+ blockPollingInterval,
67
68
...otherParams
68
69
} = init
69
70
@@ -77,7 +78,8 @@ export function validateInit(init: Initialization): never | void {
77
78
'walletCheck' ,
78
79
'darkMode' ,
79
80
'apiUrl' ,
80
- 'hideBranding'
81
+ 'hideBranding' ,
82
+ 'blockPollingInterval'
81
83
] ,
82
84
'init'
83
85
)
@@ -107,6 +109,12 @@ export function validateInit(init: Initialization): never | void {
107
109
type : 'boolean' ,
108
110
optional : true
109
111
} )
112
+ validateType ( {
113
+ name : 'blockPollingInterval' ,
114
+ value : blockPollingInterval ,
115
+ type : 'number' ,
116
+ optional : true
117
+ } )
110
118
111
119
validateType ( {
112
120
name : 'subscriptions' ,
@@ -640,7 +648,7 @@ export function validateWalletInit(
640
648
'rpcUri' ,
641
649
'webUri' ,
642
650
'xsUri' ,
643
- 'blockedPopupRedirect'
651
+ 'blockedPopupRedirect' ,
644
652
] ,
645
653
'walletInitObject'
646
654
)
You can’t perform that action at this time.
0 commit comments