check if no metamask

This commit is contained in:
Roman Storm 2017-12-06 23:11:01 -08:00
parent 53af9d9824
commit 9e43e34929
2 changed files with 9 additions and 6 deletions

View File

@ -25,7 +25,8 @@ class App extends Component {
this.onClick = this.onClick.bind(this);
this.state = {
web3Config: {},
mining: null
mining: null,
isDisabledBtn: false
}
this.keysManager = null;
getWeb3().then((web3Config) => {
@ -35,6 +36,7 @@ class App extends Component {
});
}).catch((error) => {
if(error.msg){
this.setState({isDisabledBtn: true});
swal({
icon: 'warning',
title: 'Warning',
@ -49,7 +51,6 @@ class App extends Component {
const isValid = await this.keysManager.isInitialKeyValid(initialKey);
console.log(isValid);
if(Number(isValid) !== 1){
this.setState({loading: false})
swal("Warning!", "The key is not valid initial Key! Please make sure you have loaded correct initial key in metamask", "warning");
return;
}
@ -100,7 +101,7 @@ class App extends Component {
Please proceed with care, don't lose your keys and follow instructions.
</h2>
<div className="create-keys-button-container">
<button className="create-keys-button" onClick={this.onClick}>Generate keys</button>
<button className="create-keys-button" onClick={this.onClick} disabled={this.state.isDisabledBtn}>Generate keys</button>
</div>
</div>)

View File

@ -2,10 +2,12 @@ import KeysManagerAbi from './keysManagerAbi.json'
import Web3 from 'web3';
import addressGenerator from './addressGenerator';
let web3_10 = new Web3(window.web3.currentProvider);
export default class KeysManager {
constructor({web3}){
this.keysInstance = new web3_10.eth.Contract(KeysManagerAbi, '0x758492834ed6454f41d6d3d6b73d6e46d4555429');
constructor(){
if(window.web3.currentProvider){
let web3_10 = new Web3(window.web3.currentProvider);
this.keysInstance = new web3_10.eth.Contract(KeysManagerAbi, '0x758492834ed6454f41d6d3d6b73d6e46d4555429');
}
}
async isInitialKeyValid(initialKey) {
return await this.keysInstance.methods.initialKeys(initialKey).call();