cupOJoseph / crypto-zoo

1 stars 2 forks source link

metamask injection requestion #7

Closed cupOJoseph closed 5 years ago

cupOJoseph commented 5 years ago

ask user to sign metamask to inject web3

cupOJoseph commented 5 years ago
try {
      if (this.state.config.DEBUG) console.log('DAPPARATUS - getting accounts...');
      window.web3.eth.getAccounts((err, _accounts) => {
        //console.log("ACCOUNTS",err,_accounts)
        if (!_accounts || _accounts.length <= 0 || this.state.web3Fellback) {
          if (!this.state.hasRequestedAccess) { // Prevent multiple prompts
            if (this.state.config.DEBUG) console.log('METAMASK - requesting access from user...');
            this.setState({ hasRequestedAccess: true},() => {
              this.props.onUpdate(this.state);
            });
            try{
              window.ethereum.enable().then(() => {
                 window.location.reload(true);
              })
            } catch (e) {
              console.log(e);
              this.setState({ status: 'private', network: network },() => {
                this.props.onUpdate(this.state);
              });
            }
          }
cupOJoseph commented 5 years ago

@blockchainbuddha

cupOJoseph commented 5 years ago

still open while fixing merge conflict

cupOJoseph commented 5 years ago

36

cupOJoseph commented 5 years ago

solved in #36