Skip to content

Commit d192b1a

Browse files
committed
add pollingInterval param + validation
1 parent dc3950f commit d192b1a

File tree

5 files changed

+151
-84
lines changed

5 files changed

+151
-84
lines changed

src/interfaces.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface Initialization {
77
darkMode?: boolean
88
apiUrl?: string
99
hideBranding?: boolean
10+
pollingInterval?: number
1011
}
1112

1213
export interface Subscriptions {
@@ -181,6 +182,7 @@ export interface WalletConnectOptions extends CommonWalletOptions {
181182
[key: string]: string
182183
}
183184
bridge: string
185+
pollingInterval: number
184186
}
185187

186188
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
@@ -12,9 +12,12 @@ function createProvider(config: any) {
1212
processMessage,
1313
processPersonalMessage,
1414
signMessage,
15-
signPersonalMessage
15+
signPersonalMessage,
16+
pollingInterval
1617
} = config
1718

19+
console.log("from inside provider engine : " , {pollingInterval})
20+
1821
const idMgmt =
1922
getAccounts &&
2023
new HookedWalletSubprovider({
@@ -30,7 +33,7 @@ function createProvider(config: any) {
3033
rpcUrl: rpcUrl.includes('http') ? rpcUrl : `https://${rpcUrl}`
3134
})
3235

33-
const provider = new Web3ProviderEngine()
36+
const provider = new Web3ProviderEngine({pollingInterval})
3437

3538
provider.addProvider(new SubscriptionSubprovider())
3639
provider.addProvider(new FilterSubprovider())

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ function walletConnect(
1717
label,
1818
iconSrc,
1919
svg,
20-
networkId
20+
networkId,
21+
pollingInterval
2122
} = options
2223

24+
console.log({pollingInterval})
25+
2326
if (!infuraKey) {
2427
if (!rpc || !rpc[networkId]) {
2528
throw new Error(
@@ -45,12 +48,16 @@ function walletConnect(
4548
? rpc[networkId]
4649
: `https://${networkName(networkId)}.infura.io/v3/${infuraKey}`
4750

48-
const balanceProvider = createProvider({ rpcUrl })
51+
const balanceProvider = createProvider({
52+
rpcUrl,
53+
pollingInterval
54+
})
4955

5056
const provider = new WalletConnectProvider({
5157
infuraId: infuraKey,
5258
rpc,
53-
bridge
59+
bridge,
60+
pollingInterval
5461
})
5562

5663
provider.autoRefreshOnNetworkChange = false

src/validation.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export function validateInit(init: Initialization): never | void {
6464
darkMode,
6565
apiUrl,
6666
hideBranding,
67+
pollingInterval,
6768
...otherParams
6869
} = init
6970

@@ -77,7 +78,8 @@ export function validateInit(init: Initialization): never | void {
7778
'walletCheck',
7879
'darkMode',
7980
'apiUrl',
80-
'hideBranding'
81+
'hideBranding',
82+
'pollingInterval'
8183
],
8284
'init'
8385
)
@@ -107,6 +109,12 @@ export function validateInit(init: Initialization): never | void {
107109
type: 'boolean',
108110
optional: true
109111
})
112+
validateType({
113+
name: 'pollingInterval',
114+
value: pollingInterval,
115+
type: 'number',
116+
optional: true
117+
})
110118

111119
validateType({
112120
name: 'subscriptions',
@@ -640,7 +648,8 @@ export function validateWalletInit(
640648
'rpcUri',
641649
'webUri',
642650
'xsUri',
643-
'blockedPopupRedirect'
651+
'blockedPopupRedirect',
652+
'pollingInterval'
644653
],
645654
'walletInitObject'
646655
)

0 commit comments

Comments
 (0)