Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Fix) Validators DApp shows an error when MetaMask is not installed #27

Open
phahulin opened this issue May 12, 2018 · 14 comments
Open

Comments

@phahulin
Copy link

Validators DApp on http://localhost:3001/ loads with error:

Unhandled Rejection (Error): Couldn't decode bytes32 from ABI: 0x The size doesn't match.
▶ 44 stack frames were collapsed.
Metadata._callee3$
src/contracts/Metadata.contract.js:81
  78 |   return {};
  79 | }
  80 | 
> 81 | let validatorData = await this.metadataInstance.methods.validators(miningKey).call();
  82 | let createdDate = validatorData.createdDate > 0 ? moment.unix(validatorData.createdDate).format('YYYY-MM-DD') : ''
  83 | let updatedDate = validatorData.updatedDate > 0 ? moment.unix(validatorData.updatedDate).format('YYYY-MM-DD') : ''
  84 | let expirationDate = validatorData.expirationDate > 0 ? moment.unix(validatorData.expirationDate).format('YYYY-MM-DD') : ''
View compiled
▶ 7 stack frames were collapsed.
Metadata._callee5$
src/contracts/Metadata.contract.js:116
  113 | 
  114 | async getAllValidatorsData(netId){
  115 |   let all = [];
> 116 |   return new Promise(async(resolve, reject) => {
  117 |     const poaInstance = new PoaConsensus()
  118 |     await poaInstance.init({web3: this.web3_10, netId, addresses: this.addresses})
  119 |     const keys = await poaInstance.getValidators()

Steps to reproduce:

npm install
npm run start-moc-setup
npm run launch-dapps
@varasev
Copy link
Contributor

varasev commented May 12, 2018

@phahulin @vbaranov Please, ensure that Metamask is installed. I've repeated the steps above and I see the same error only when I remove Metamask from my browser.

@varasev varasev changed the title Validators DApp does not get correct contract ABIs Validators DApp shows an error when MetaMask is not installed May 12, 2018
@varasev varasev changed the title Validators DApp shows an error when MetaMask is not installed (Fix) Validators DApp shows an error when MetaMask is not installed May 12, 2018
@varasev
Copy link
Contributor

varasev commented May 12, 2018

Please, don't close this issue. I will add some code to prepareValidatorsDapp.js later. It should modify submodules/poa-dapps-validators/src/getWeb3.js so that DApp could connect to localhost:8545 instead of core.poa.network in case of Metamask is not installed.

For now a user has to install MetaMask in order to Validators DApp could work properly after npm run launch-dapps step.

@phahulin
Copy link
Author

@varasev Hi, I did some more tests and the error seems to occur when connecting to sokol or core via MetaMask, this is probably related to what you wrote above - it tries to use core network by default.

I also noticed that it's impossible connect to localhost:8545 in MetaMask, though parity is running. As a consequence, localhost:3002 constantly displays spinner (POA Network...). This is probably because cors are set to null in toml file, maybe change it to ["all"]?

@varasev
Copy link
Contributor

varasev commented May 12, 2018

@phahulin What version of MetaMask do you use? It seems that MetaMask 4.6 won't connect to localhost:8545, but the previous 4.5.5 works fine.

This is probably because cors are set to null in toml file, maybe change it to ["all"]?

Yes, I'll try it.

@varasev
Copy link
Contributor

varasev commented May 12, 2018

the error seems to occur when connecting to sokol or core via MetaMask, this is probably related to what you wrote above - it tries to use core network by default.

The reason is that DApps inside poa-test-setup use contracts' addresses not from poa-chain-spec, but from the local setup. If the DApp doesn't see injected web3 from Metamask then it connects to Core network which of course doesn't contain contracts with the same addresses as in the local setup. So, the described error occurs.

The problem is that DApp doesn't see the web3 from MetaMask.

I'll try to change cors in toml to ["all"] and test localhost:8545 with MetaMask 4.6. But for now MetaMask 4.5.5 is working fine with localhost:8545.

varasev added a commit to varasev/poa-test-setup that referenced this issue May 12, 2018
@varasev
Copy link
Contributor

varasev commented May 12, 2018

@phahulin I have fixed cors to ["all"] in toml file: https://github.com/poanetwork/poa-test-setup/pull/28/files

Validators DApp with the latest version of MetaMask (4.6.1) works fine. I will recheck it again tomorrow morning.

Please, clone the repo again and repeat the steps on your side. Is everything ok?

@varasev
Copy link
Contributor

varasev commented May 13, 2018

I've tested it again. Everything is fine. All the steps of poa-test-setup are successful.

The right steps to follow to see that MetaMask successfully connects to DApps:

  1. Install MetaMask if it is not already installed.

  2. Perform the next commands:

$ git clone https://github.com/poanetwork/poa-test-setup.git
$ cd poa-test-setup
$ npm i
$ npm run start-moc-setup
$ npm run launch-dapps
  1. After the previous steps are completed switch MetaMask to Localhost 8545.

  2. Open any of the next pages in a browser:

Ceremony DApp: http://localhost:3000
Validators DApp: http://localhost:3001
Governance DApp: http://localhost:3002

@phahulin
Copy link
Author

Please, don't close this yet, need to check with Jim

@6proof
Copy link

6proof commented May 13, 2018

After complete new node deployment and poa-test-setup install, the Validators DApp on port 3001 still fails. Ceremony on port 3000 and Governance port 3002 work fine. NOTE: The DApp should not fail regardless of RPC source, and does not on Ceremony or Governance. Is is error output returned via web browser when accessing poa-test-setup Validators DApp on http://localhost:3001 -

×
Unhandled Rejection (Error): Couldn't decode bytes32 from ABI: 0x The size doesn't match.
▶ 44 stack frames were collapsed.
Metadata._callee3$
src/contracts/Metadata.contract.js:81
78 | return {};
79 | }
80 |

81 | let validatorData = await this.metadataInstance.methods.validators(miningKey).call();
82 | let createdDate = validatorData.createdDate > 0 ? moment.unix(validatorData.createdDate).format('YYYY-MM-DD') : ''
83 | let updatedDate = validatorData.updatedDate > 0 ? moment.unix(validatorData.updatedDate).format('YYYY-MM-DD') : ''
84 | let expirationDate = validatorData.expirationDate > 0 ? moment.unix(validatorData.expirationDate).format('YYYY-MM-DD') : ''
View compiled
▶ 7 stack frames were collapsed.
Metadata._callee5$
src/contracts/Metadata.contract.js:116
113 |
114 | async getAllValidatorsData(netId){
115 | let all = [];
116 | return new Promise(async(resolve, reject) => {
117 | const poaInstance = new PoaConsensus()
118 | await poaInstance.init({web3: this.web3_10, netId, addresses: this.addresses})
119 | const keys = await poaInstance.getValidators()
View compiled
▶ 5 stack frames were collapsed.
This screen is visible only in development. It will not appear if the app crashes in production.
Open your browser’s developer console to further inspect this error.

This used to work. Thanks for your help!

@varasev
Copy link
Contributor

varasev commented May 13, 2018

After complete new node deployment and poa-test-setup install, the Validators DApp on port 3001 still fails.

The reason is that DApp inside poa-test-setup uses contract addresses not from poa-chain-spec, but from the local setup. If MetaMask is switched to core.poa.network or sokol.poa.network DApp tries to read metadata from nonexistent contracts in Core or Sokol. So, the described error occurs. If you switch to Localhost 8545 the DApp will work fine.

Ceremony and Governance DApps don't display any errors because they use try...catch in the code, but they also try to read from nonexistent contracts in the case described above.

I can make the DApp use poa-chain-spec addresses in case of MetaMask is switched to core.poa.network or sokol.poa.network. In this case the Validators DApp will show a list of validators from Core or Sokol network, and the Governance DApp will show a list of ballots from the same network.

If it's important for your upcoming demo just let me know and I'll make a small fix for that soon. But in the current implementation you have to use Localhost 8545 in poa-test-setup.

@6proof
Copy link

6proof commented May 13, 2018

It would seem best that all three DApps show the same behavior, and that it is never good for a web page to be returned with a broken link or failed message; this is very confusion. A test or demonstration network, even in a lab environment, should be interactive and return results regardless of who is operating the controls. If not, we might as well just create a Power Point or PDF.

Yes, please have the Validators DApp on Port 3001 return the same sort of messages as teh Ceremony and Governance DApps on ports 3000 and 3002 vs failing. Thanks and please let me know how I can help.

@varasev
Copy link
Contributor

varasev commented May 14, 2018

Yes, the DApp in poa-test-setup must show an alert message when it is connected to the wrong network. We'll make that behavior later because we will not have time to do it fully before your upcoming demo.

For now please use Localhost 8545 as it was described in the short manual above: #27 (comment)

I.e. you have to switch MetaMask to Localhost 8545 before you open any of DApps on localhost.

If you need to show the demo of the current list of validators in Core or Sokol network you can use a separate tab in your browser with https://validators.poa.network opened there.

@phahulin
Copy link
Author

@varasev Jim and Co decided to deploy a test network in full, meaning they won't be using poa-test-setup. Can we close this issue or do you want to make any updates later?

@varasev
Copy link
Contributor

varasev commented May 16, 2018

@phahulin Don't close it, please. I'll make some fixes described above later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants