Skip to content

Commit

Permalink
Optional WS provider
Browse files Browse the repository at this point in the history
  • Loading branch information
bonustrack committed Sep 20, 2020
1 parent 255b91f commit bfcc98d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/Modal/About.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</div>
<div class="d-flex">
<span v-text="'Network'" class="flex-auto text-gray mr-1" />
{{ config.network === 'homestead' ? 'mainnet' : config.network }}
{{ config.network }}
</div>
<div class="d-flex">
<span v-text="'Block number'" class="flex-auto text-gray mr-1" />
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/ws.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { WebSocketProvider } from '@ethersproject/providers';

let provider;
const url: any = process.env.VUE_APP_WS_URL;
const provider = new WebSocketProvider(url);
if (url) provider = new WebSocketProvider(url);

export default provider;
8 changes: 5 additions & 3 deletions src/store/modules/web3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ import rpcProvider from '@/helpers/rpc';
let auth;
let web3;

wsProvider.on('block', blockNumber => {
store.commit('GET_BLOCK_SUCCESS', blockNumber);
});
if (wsProvider) {
wsProvider.on('block', blockNumber => {
store.commit('GET_BLOCK_SUCCESS', blockNumber);
});
}

const state = {
injectedLoaded: false,
Expand Down

0 comments on commit bfcc98d

Please sign in to comment.