Metamask-extension: multiple providers: work tracker issue

Created on 24 Jul 2019  路  10Comments  路  Source: MetaMask/metamask-extension

goal:
initialize all providers instead of creating and destroying on network switch while maintaining same external behavior

high level todos:

  • [x] (Migration needed) pass in all end points
  • [X] remove the storage of endpoints from preferences controller
  • [x] initialize all providers
  • [x] continue same external behavior of the provider
  • [ ] QA
  • [ ] some UI tweaks for sanity of params
  • [ ] frankie dont go to overboard

Most helpful comment

Let's take a little time to explore H4v0c's work on abstracting multiple chain providers, see if there's a chance to leverage their work at all: http://chainstackjs.org/

All 10 comments

current status: broke up provider initialization and proxy management into to files

notes/low level todos:
default networks:
~- [ ] never initialize any local hosts unless it's tests. (side option try to initialize and have graceful fallback?)~

  • [ ] if selected network is a non infura fallback to infura if possible
    ~- [ ] network.stop()~
    metamaskController:
  • [x] async updateAndSetCustomRpc (rpcUrl, chainId, ticker = 'ETH', nickname, rpcPrefs) {

  • [x] async setCustomRpc (rpcTarget, chainId, ticker = 'ETH', nickname = '', rpcPrefs = {}) {

  • [x] async delCustomRpc (rpcTarget) {

MIGRATION NEEDS:

  • [x] PreferencesController.frequentRpcListDetail -> NetworkController.networkConfigs

~- [ ] network controller needs selected network and networkconfigs
include the defaults in networkConfigs
check what default ticker is needed~

  • [ ] if possible unify object in network controller:
  • [ ] rpcTarget -> rpcUrl
  • [ ] nickname -> name
  • [ ] flatten rpcPrefs
 networkConfig = {
    rpcUrl,
    type, // default#type(chainId) || custom#type(chainId) ???
    name,
    chainId,
    blockExplorer,
  }

network class config:

  config = { // should ever only be things for the provider or network class no extra bs
    rpcUrl,
    type,
    chainId, // for ethClassic
  }
  • [ ] ui needs some method updates
    more things to come

updateAndSetCustomRpc -> takes a single object
async updateAndSetCustomRpc (networkConfig) {

actual:

networkConfig = {
    rpcUrl,
    type, // infura#eth:mainnet || custom#eth:rpc
    custom: {
      name,
      chainId,
      blockExplorer,
      ticker,
    }
  }
  • [ ] ensure the initialize param is discarded if passed to the constructor

wooooooooooo

  1104 passing (5s)
  2 failing

sooooo close and yet so far

Let's take a little time to explore H4v0c's work on abstracting multiple chain providers, see if there's a chance to leverage their work at all: http://chainstackjs.org/

  • [ ] needs docs
Was this page helpful?
0 / 5 - 0 ratings

Related issues

beether picture beether  路  4Comments

rossbulat picture rossbulat  路  3Comments

aakilfernandes picture aakilfernandes  路  3Comments

1blockologist picture 1blockologist  路  3Comments

danfinlay picture danfinlay  路  3Comments