ethereum / meteor-dapp-wallet

This is an archived repository of one of the early Ethereum wallets.
https://ethereum.org/en/wallets/find-wallet/
GNU General Public License v3.0
598 stars 408 forks source link

Upgrade to web3.js 1.0.0 with subscription support #469

Closed ryanio closed 6 years ago

ryanio commented 6 years ago

This PR upgrades meteor-dapp-wallet to use web3.js 1.0.0

The primary benefit is using subscriptions instead of filters, which results in much fewer web3 calls.

Currently waiting for subscription support in MetaMask before merging to not break wallet.ethereum.org for MetaMask users.

Checklist:


For testing, it would be great to help test in both Mist and any other browser with geth in websockets mode (geth --ws --wsorigins "*"). I would appreciate testing: sending transactions, sending erc20 tokens, creating wallets, sending transactions to/from wallets, watching contracts, deploying contracts.

wolovim commented 6 years ago

when viewing in firefox, i can see the "add account" button. clicking on it produces the console errors: TypeError: this.callback is not a function and ReferenceError: mist is not defined. the button should only be visible from within mist, right?

ryanio commented 6 years ago

hm that's interesting, looks like it's actually a bug/typo in isMist, it currently reads:

Template.registerHelper('isMist', function(){
    return (typeof window.mistMode === 'undefined');
});

I opened Mist and window.mistMode is actually undefined so it was technically working in reverse. window.mist is available though, so I'll switch it to that with !==

thanks, good catch!

wolovim commented 6 years ago

(Testing with --mode wallet) when creating accounts, the UI looks as expected (I see the warning to backup keystore files) and the keystore directory does contain the new file, but the UI doesn't update with the new account and the logs spam the following message:

[2018-03-09T12:14:24.597] [ERROR] ipcProviderBackend - Send request failed { code: -32000, message: 'no suitable peers available' }
(node:23380) Warning: a promise was rejected with a non-error: [object Object]

The error seems to appear whether or not I'm synced up. Upon restart, accounts are still not shown.

wolovim commented 6 years ago

Also, I get a ton of these warnings eventually (sometimes immediately). Don't think its prompted by user action. Haven't looked into it, but just documenting for now.

[2018-03-09T12:30:17.408] [WARN] (ui: browser) - %cUnhandled rejection Error: Couldn't decode uint256 from ABI: 0x
    at SolidityTypeUInt.formatOutputUInt [as _outputFormatter] (http://localhost:3050/packages/ethereum_web3.js?hash=25765ce95f22be5c241cc3a02c37085d7930b3a5:31568:17)
    at SolidityTypeUInt.SolidityType.decode (http://localhost:3050/packages/ethereum_web3.js?hash=25765ce95f22be5c241cc3a02c37085d7930b3a5:32465:21)
    at http://localhost:3050/packages/ethereum_web3.js?hash=25765ce95f22be5c241cc3a02c37085d7930b3a5:31993:51
    at Array.forEach (<anonymous>)
    at ABICoder.decodeParameters (http://localhost:3050/packages/ethereum_web3.js?hash=25765ce95f22be5c241cc3a02c37085d7930b3a5:31992:17)
    at Contract._decodeMethodReturn (http://localhost:3050/packages/ethereum_web3.js?hash=25765ce95f22be5c241cc3a02c37085d7930b3a5:45218:26)
    at Method.outputFormatter (http://localhost:3050/packages/ethereum_web3.js?hash=25765ce95f22be5c241cc3a02c37085d7930b3a5:45556:40)
    at Method.formatOutput (http://localhost:3050/packages/ethereum_web3.js?hash=25765ce95f22be5c241cc3a02c37085d7930b3a5:21166:56)
    at sendTxCallback (http://localhost:3050/packages/ethereum_web3.js?hash=25765ce95f22be5c241cc3a02c37085d7930b3a5:21435:31)
    at Object.<anonymous> (http://localhost:3050/packages/ethereum_web3.js?hash=25765ce95f22be5c241cc3a02c37085d7930b3a5:27329:11)
    at <anonymous>:665:48
From previous event:
    at PromiEvent (http://localhost:3050/packages/ethereum_web3.js?hash=25765ce95f22be5c241cc3a02c37085d7930b3a5:26996:28)
    at send (http://localhost:3050/packages/ethereum_web3.js?hash=25765ce95f22be5c241cc3a02c37085d7930b3a5:21429:23)
    at Object._executeMethod (http://localhost:3050/packages/ethereum_web3.js?hash=25765ce95f22be5c241cc3a02c37085d7930b3a5:45564:22)
    at updateContractData (http://localhost:3050/app/client/lib/ethereum/observeWallets.js?hash=ae20ce86ea4f368c1f4e45d48c38a871dcf0ab57:128:43)
    at http://localhost:3050/app/client/lib/ethereum/observeBlocks.js?hash=8ba84680e97e440ed42cbd83d5b369be7379723e:47:21
    at Meteor.EnvironmentVariable.EVp.withValue (http://localhost:3050/packages/meteor.js?hash=b0f12795c8cc1423b5850502871996903f947ed5:1140:15)
    at http://localhost:3050/packages/meteor.js?hash=b0f12795c8cc1423b5850502871996903f947ed5:521:25
    at http://localhost:3050/packages/meteor.js?hash=b0f12795c8cc1423b5850502871996903f947ed5:1167:22 color: red
ryanio commented 6 years ago

(Testing with --mode wallet) when creating accounts, the UI looks as expected (I see the warning to backup keystore files) and the keystore directory does contain the new file, but the UI doesn't update with the new account

I'm able to reproduce the same issue in Mist, the keystore file is created but the Mist account list doesn't update with the new account. I'm not connected to any peers in light mode so I'm not sure if that's causing a race condition, but ideally they should be decoupled (creating a new account in Mist shouldn't need a dependency on being connected to the network, but could be a geth thing). I'll keep investigating and appreciate any more insights - doesn't seem related to the code changed in this PR because same thing is happening for me on current wallet.ethereum.org

Update: when connected to peers, the account list does seem to update correctly.

Also, I get a ton of these warnings eventually (sometimes immediately). Don't think its prompted by user action. Haven't looked into it, but just documenting for now.

I've seen that error intermittently as well, it seems like a web3.js issue https://github.com/ethereum/web3.js/issues/1089#issuecomment-367155633

wolovim commented 6 years ago

Confirmed that while synced to rinkeby via fast sync (light couldnt find peers), account creation, transfers, and wallet contract creation work as expected. Want to document another spammy warning first seen after sending a tx, though:

[2018-03-12T15:48:24.910] [WARN] (ui: browser) - %cWarning: a promise was created in a handler but was not returned from it
    at PromiEvent (http://localhost:3050/packages/ethereum_web3.js?hash=25765ce95f22be5c241cc3a02c37085d7930b3a5:26996:28)
    at Object._executeMethod (http://localhost:3050/packages/ethereum_web3.js?hash=25765ce95f22be5c241cc3a02c37085d7930b3a5:45507:21)
    at http://localhost:3050/app/client/lib/ethereum/observeWallets.js?hash=ae20ce86ea4f368c1f4e45d48c38a871dcf0ab57:137:50
From previous event:
    at updateContractData (http://localhost:3050/app/client/lib/ethereum/observeWallets.js?hash=ae20ce86ea4f368c1f4e45d48c38a871dcf0ab57:136:56)
    at http://localhost:3050/app/client/lib/ethereum/observeBlocks.js?hash=8ba84680e97e440ed42cbd83d5b369be7379723e:47:21
    at Meteor.EnvironmentVariable.EVp.withValue (http://localhost:3050/packages/meteor.js?hash=b0f12795c8cc1423b5850502871996903f947ed5:1140:15)
    at http://localhost:3050/packages/meteor.js?hash=b0f12795c8cc1423b5850502871996903f947ed5:521:25
    at http://localhost:3050/packages/meteor.js?hash=b0f12795c8cc1423b5850502871996903f947ed5:1167:22 color: darkorange
ryanio commented 6 years ago

Want to document another spammy warning first seen after sending a tx

Yeah those are bluebird warnings, I do think they are harmless: https://github.com/petkaantonov/bluebird/blob/master/docs/docs/warning-explanations.md#warning-a-promise-was-created-in-a-handler-but-was-not-returned-from-it

But they are annoying. I'll make sure all our promises return.

alexvandesande commented 6 years ago

LGTM!