Skip to content
This repository was archived by the owner on May 19, 2023. It is now read-only.

Commit 795dd98

Browse files
committed
fix: added validation before using window.ethereum
1 parent ba21b98 commit 795dd98

File tree

6 files changed

+20
-7
lines changed

6 files changed

+20
-7
lines changed

dist/index.js

Lines changed: 10 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.modern.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.modern.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/models/index.d.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/providers/Web3Provider.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ class Web3Provider extends Component<{}, Web3ProviderState> {
126126
}
127127

128128
private initialize(): void {
129+
if (!window.ethereum) {
130+
return
131+
}
129132
window.ethereum.autoRefreshOnNetworkChange = false
130133
// handle on networkChange
131134
window.ethereum.on('networkChanged', async (_netId) => {
@@ -168,7 +171,7 @@ class Web3Provider extends Component<{}, Web3ProviderState> {
168171
this.setState({
169172
account,
170173
},
171-
() => this.onConnectedAccountChange && this.onConnectedAccountChange())
174+
() => this.onConnectedAccountChange && this.onConnectedAccountChange())
172175
}
173176
}
174177
})

0 commit comments

Comments
 (0)