MetaMask / metamask-snaps-beta

Fork of MetaMask that supports plugins! Read the Wiki!
https://github.com/MetaMask/metamask-snaps-beta/wiki
MIT License
144 stars 57 forks source link

Updated web3-eth-contract usage #113

Closed jazzandrock closed 5 years ago

jazzandrock commented 5 years ago

You have web3-eth-contract@1.0.0-beta.35 in your yarn.lock, but you use it as if it was of older version. These changes remove a lot of web3.eth.contract is not a function exceptions.

jazzandrock commented 5 years ago

@rekmarks To confirm that it can check token balances, I added this piece of code in metamask-controller.js:

setInterval(() => {
  this.detectTokensController
    .detectTokenBalance('0x5D858bcd53E085920620549214a8b27CE2f04670')
    .then(res => console.log('detectTokenBalance in metamask controller js', res))
    .catch(e => console.log('error in detectTokenBalance in metamask controller js:', e));

  this.detectTokensController
    .detectNewTokens()
    .then(res => console.log('detectNewTokens in metamask controller js', res))
    .catch(e => console.log('error in detectNewTokens metamask controller js:', e));
}, 2000);

After printing a lot of local variables, I can say it does work.