Backport "Fix method registry initialization (#8200)" (#8459)

Backport #8200 to v7.7.9. Original commit description:

The method registry was being initialized with the global variable
`ethereumProvider` before that variable was set. As a result, the
method registry was falling back to an internally constructed provider
that used the wrong provider URL (an obsolete Infura API). This was
resulting in an error with the message "Project ID not found".

The method registry is now initialized lazily, when it's first needed.
This should be well after the initialization of `ethereumProvider`,
which occurs during the UI initialization.
feature/default_network_editable
Mark Stacey 5 years ago committed by GitHub
parent f91bd3a08d
commit 3dc8387a96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 7
      ui/app/helpers/utils/transactions.util.js

@ -8,6 +8,7 @@
- [#8447](https://github.com/MetaMask/metamask-extension/pull/8447): Delete Dai/Sai migration notification - [#8447](https://github.com/MetaMask/metamask-extension/pull/8447): Delete Dai/Sai migration notification
- [#8460](https://github.com/MetaMask/metamask-extension/pull/8460): Update deposit copy for Wyre - [#8460](https://github.com/MetaMask/metamask-extension/pull/8460): Update deposit copy for Wyre
- [#8458](https://github.com/MetaMask/metamask-extension/pull/8458): Snapshot txMeta without cloning history - [#8458](https://github.com/MetaMask/metamask-extension/pull/8458): Snapshot txMeta without cloning history
- [#8459](https://github.com/MetaMask/metamask-extension/pull/8459): Fix method registry initialization
## 7.7.8 Wed Mar 11 2020 ## 7.7.8 Wed Mar 11 2020
- [#8176](https://github.com/MetaMask/metamask-extension/pull/8176): Handle and set gas estimation when max mode is clicked - [#8176](https://github.com/MetaMask/metamask-extension/pull/8176): Handle and set gas estimation when max mode is clicked

@ -47,8 +47,7 @@ async function getMethodFrom4Byte (fourBytePrefix) {
return null return null
} }
} }
let registry
const registry = new MethodRegistry({ provider: global.ethereumProvider })
/** /**
* Attempts to return the method data from the MethodRegistry library, the message registry library and the token abi, in that order of preference * Attempts to return the method data from the MethodRegistry library, the message registry library and the token abi, in that order of preference
@ -62,6 +61,10 @@ export async function getMethodDataAsync (fourBytePrefix) {
return null return null
}) })
if (!registry) {
registry = new MethodRegistry({ provider: global.ethereumProvider })
}
let sig = await registry.lookup(fourBytePrefix) let sig = await registry.lookup(fourBytePrefix)
if (!sig) { if (!sig) {

Loading…
Cancel
Save