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

MetaMask 8 only - RPC Error: The requested account and/or method has not been authorized by the user. #8922

Closed
rstormsf opened this issue Jul 4, 2020 · 9 comments · Fixed by #8923

Comments

@rstormsf
Copy link

rstormsf commented Jul 4, 2020

In new metamask 8, my dapps stopped working and the issue is
MetaMask - RPC Error: The requested account and/or method has not been authorized by the user.

what are the breaking changes? what should I look for?

image

@rstormsf
Copy link
Author

rstormsf commented Jul 4, 2020

const ethAccounts = await ethereum.enable() isn't enough anymore?

ethereum.sendAsync({
        method,
        params,
        jsonrpc: '2.0',
        from
      }, (err, response) => {
        if (err) {
          reject(err)
        }
        if (response.error) {
          reject(response.error)
        } else {
          resolve(response.result)
        }
      })```

@rstormsf
Copy link
Author

rstormsf commented Jul 4, 2020

I found the issue:
params:[{from: checksummed address}]
while Metamask v8 expects address in lowercase!

What a bummer, metamask team
@danfinlay

fix it up that either: accepts checksummed address, like you did in v7, or accept both, lowercased and checksummed

@rekmarks
Copy link
Member

rekmarks commented Jul 4, 2020

@rstormsf it should accept addresses regardless of casing, so this is a bug, that we will fix.

@rekmarks
Copy link
Member

rekmarks commented Jul 4, 2020

Could you please share a more detailed snippet from your dapp code? Specifically, it'd be helpful to see example values of the following: method, params, from

Edit: For any addresses, I just want to know where they come from (e.g. ethereum.enable() or the accountsChanged event).

@rstormsf
Copy link
Author

rstormsf commented Jul 4, 2020

@rekmarks the validation check for authorized accounts don't respect checksummed addresses if I use sendAsync or request method in params array for from value

@rekmarks
Copy link
Member

rekmarks commented Jul 4, 2020

@rstormsf this issue will be closed by #8923, which resolves the issue. That PR will be included in 8.0.3 of the extension, which will be released no later than Monday, Pacific Time.

As an aside, for calls to ethereum.request and ethereum.sendAsync, the top-level from property has been ignored in practice for MetaMask for some time. Likewise, callers do not need to specify the jsonrpc property. For example, instead of this:

ethereum.sendAsync({
    method: 'eth_sendTransaction',
    params: [{ to, from, value }],
    jsonrpc: '2.0',
    from
  },
  (err, result) => { /* stuff */ }
)

You can just do this:

ethereum.sendAsync({
    method: 'eth_sendTransaction',
    params: [{ to, from, value }],
  },
  (err, result) => { /* callback */ }
)

// or, in MetaMask v8

try {
  const transactionHash = await ethereum.request({
    method: 'eth_sendTransaction',
    params: [{ to, from, value }],
  })
catch (error) {
  // handle error
}

@rstormsf
Copy link
Author

rstormsf commented Jul 6, 2020

@rekmarks true. I left it as a legacy code that works with other web3 providers (Forks of old metamask, etc)

@rekmarks
Copy link
Member

rekmarks commented Jul 6, 2020

@rstormsf Yeah, that makes sense! I believe that the next significant EIP (after EIP-1193, which is past its review period end) related to the JavaScript provider is a way to quickly determine the capabilities/interface of a particular provider. For now, the presence of the request method should signal the existence of an 1193-compatible provider.

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

Successfully merging a pull request may close this issue.

3 participants
@rstormsf @rekmarks and others