Skip to content

Commit b51f73b

Browse files
Merge 27aa4b6 into 4777813
2 parents 4777813 + 27aa4b6 commit b51f73b

File tree

3 files changed

+51
-62
lines changed

3 files changed

+51
-62
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ REACT_APP_HOME_BRIDGE_ADDRESS=0xABb4C1399DcC28FBa3Beb76CAE2b50Be3e087353
22
REACT_APP_FOREIGN_BRIDGE_ADDRESS=0xE405F6872cE38a7a4Ff63DcF946236D458c2ca3a
33
REACT_APP_FOREIGN_HTTP_PARITY_URL=https://kovan.infura.io/mew
44
REACT_APP_HOME_HTTP_PARITY_URL=https://sokol.poa.network
5+
6+
REACT_APP_TITLE=TokenBridge UI app - %c
57
REACT_APP_HOME_NATIVE_NAME=POA
68

79
REACT_APP_HOME_NETWORK_NAME="POA Sokol"

package-lock.json

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

src/stores/utils/web3.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,33 @@
11
import Web3 from 'web3'
22
import { fromWei, toHex } from 'web3-utils'
33

4+
const updateTitle = (networkName = 'No chain specified') => {
5+
const defaultTitle = 'TokenBridge UI app'
6+
if (!process.env.REACT_APP_TITLE) {
7+
document.title = defaultTitle
8+
}
9+
else {
10+
const titleReplaceString = '%c'
11+
let appTitle = process.env.REACT_APP_TITLE || defaultTitle
12+
13+
if (appTitle.indexOf(titleReplaceString) !== -1) {
14+
document.title = appTitle.replace(titleReplaceString, networkName)
15+
}
16+
else {
17+
document.title = appTitle
18+
}
19+
}
20+
}
21+
422
const getWeb3 = () => {
523
return new Promise(function (resolve, reject) {
624
// Wait for loading completion to avoid race conditions with web3 injection timing.
725
window.addEventListener('load',async function () {
826
let web3 = window.web3
927
const { ethereum } = window
1028

29+
updateTitle()
30+
1131
if (ethereum) {
1232
web3 = new Web3(ethereum)
1333
try {
@@ -80,13 +100,18 @@ export const estimateGas = async (web3, to, gasPrice, from, value, data) =>{
80100
const processWeb3 = async (web3, resolve, reject) => {
81101
const netId = await web3.eth.getChainId()
82102
const netIdName = getNetworkName(netId)
103+
83104
console.log(`This is ${netIdName} network.`, netId)
84-
document.title = `${netIdName} - Bridge UI dApp`
105+
85106
const accounts = await web3.eth.getAccounts()
86107
const defaultAccount = accounts[0] || null;
108+
87109
if(defaultAccount === null){
88110
reject({ type: 'unlock', message: 'Please unlock your wallet and refresh the page' })
89111
}
112+
113+
updateTitle(netIdName)
114+
90115
const results = {
91116
web3Instance: new Web3(web3.currentProvider),
92117
netIdName,

0 commit comments

Comments
 (0)