decentraland/dappeteer

Problems with 0.4.0 from npm: "not a function" and wrong initialization

FluiDoug opened this issue · 2 comments

Thank you for this useful tool!

Using MacOS 10.14.3, node v11.10.1 (via homebrew) and dAppeteer 0.4.0, I receive an error in the following code:

await (async () => {
    await metamask.importAccount('my secret words ...', 'password1234');
  })().catch(err => console.log(err));

The error is:

TypeError: metamask.importAccount is not a function
    at .../src/dAppeteer1/main1.js:21:20
    at .../src/dAppeteer1/main1.js:22:5
    at processTicksAndRejections (internal/process/next_tick.js:81:5)

The test harness (nearly identical to the one in your README) does start Chromium and does load MetaMask. However, MetaMask is not initialized with the appropriate account; the default account is used ("already turtle...").

Switching to Ropsten test chain does work, but I haven't tested anything else.

Downgrading to 0.3.0 fixes both issues (the Node error and the incorrect account message), at the cost of the older version of MetaMask.

Thanks for considering this problem.

Note: This seems to be caused by out of date documentation in the README. The fix is to set the account in the creation of the metamask object with dappeteer:

 const metamask = await dappeteer.getMetamask(browser, {seed: 'my secret words ...'});

I do note that, with the fix above, using 0.4.0 there is a confirmation screen with MetaMask that is not handled by dAppeteer. It shows "XXX would like to connect to your account" with CANCEL and CONNECT buttons.

This should be handled now by metamask.approve(), check #9