Fix: Error message is not friendly, if no metamask; relates to #28
This commit is contained in:
parent
ab1761adf9
commit
47bbb9de8c
|
@ -10,6 +10,12 @@ constants.AFFECTED_KEY_IS_NOT_ADDRESS_MSG = `Ballot affectedKey isn't address`;
|
|||
constants.MINING_KEY_IS_NOT_ADDRESS_MSG = `Ballot miningKey isn't address`;
|
||||
constants.PROPOSED_ADDRESS_IS_NOT_ADDRESS_MSG = `Ballot proposedAddress isn't address`;
|
||||
constants.END_TIME_SHOULD_BE_GREATER_THAN_NOW_MSG = "Ballot end time should be greater than now";
|
||||
constants.NO_METAMASK_MSG = `You haven't chosen any account in MetaMask.
|
||||
Please, choose your voting key in MetaMask and reload the page.
|
||||
Check POA Network <a href='https://github.com/poanetwork/wiki' target='blank'>wiki</a> for more info.`;
|
||||
constants.WRONG_NETWORK_MSG = `You aren't connected to POA Network.
|
||||
Please, switch on POA plugin and refresh the page.
|
||||
Check POA Network <a href='https://github.com/poanetwork/wiki' target='blank'>wiki</a> for more info.`;
|
||||
module.exports = {
|
||||
constants
|
||||
}
|
|
@ -1,6 +1,4 @@
|
|||
let errorMsgNoMetamaskAccount = `You haven't chosen any account in MetaMask.
|
||||
Please, choose your initial key in MetaMask and reload the page.
|
||||
Check POA Network <a href='https://github.com/poanetwork/wiki' target='blank'>wiki</a> for more info.`;
|
||||
import { constants } from "./constants";
|
||||
|
||||
let getWeb3 = () => {
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
@ -28,14 +26,12 @@ let getWeb3 = () => {
|
|||
break;
|
||||
default:
|
||||
netIdName = 'ERROR'
|
||||
errorMsg = `You aren't connected to POA Network.
|
||||
Please, switch on POA plugin and refresh the page.
|
||||
Check POA Network <a href='https://github.com/poanetwork/wiki' target='blank'>wiki</a> for more info.`
|
||||
errorMsg = constants.WRONG_NETWORK_MSG
|
||||
console.log('This is an unknown network.', netId)
|
||||
}
|
||||
var defaultAccount = web3.eth.defaultAccount || null;
|
||||
if(defaultAccount === null){
|
||||
reject({message: errorMsgNoMetamaskAccount})
|
||||
reject({message: constants.NO_METAMASK_MSG})
|
||||
}
|
||||
if(errorMsg !== null){
|
||||
reject({message: errorMsg})
|
||||
|
@ -53,7 +49,7 @@ let getWeb3 = () => {
|
|||
console.log('Injected web3 detected.');
|
||||
|
||||
} else {
|
||||
reject({message: errorMsgNoMetamaskAccount})
|
||||
reject({message: constants.NO_METAMASK_MSG})
|
||||
console.error('Metamask not found');
|
||||
}
|
||||
})
|
||||
|
|
|
@ -55,11 +55,11 @@ class AppMainRouter extends Component {
|
|||
console.log("miningKey", contractsStore.miningKey)
|
||||
}).catch((error) => {
|
||||
commonStore.hideLoading();
|
||||
console.error(error.message);
|
||||
swal({
|
||||
icon: 'error',
|
||||
title: 'Error',
|
||||
content: generateElement(error.message)
|
||||
html: error.message,
|
||||
type: 'error'
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue