Web3 Cannot Read Property 'rpcengine' of Null

providers

MetaMask / providers Goto Github PK

96.0 28.0 59.0 ane.57 MB

An Ethereum Provider that connects over a stream, as injected into websites by MetaMask

License: MIT License

JavaScript ii.35% TypeScript 97.65%

providers's Introduction

MetaMask Providers

The Ethereum provider object injected by MetaMask into diverse environments. Contains a lot of implementation details specific to MetaMask, and is probably not suitable for out-of-the-box apply with other wallets.

The BaseProvider implements the Ethereum JavaScript provider specification, EIP-1193. MetamaskInpageProvider implements EIP-1193 and legacy interfaces.

Usage

                    import                    {                    initializeProvider                    }                    from                    '@metamask/providers'                    ;                    // Create a stream to a remote provider:                    const                    metamaskStream                    =                    new                    LocalMessageDuplexStream                    (                    {                    proper noun:                    'inpage'                    ,                    target:                    'contentscript'                    ,                    }                    )                    ;                    // this will initialize the provider and set it equally window.ethereum                    initializeProvider                    (                    {                    connectionStream:                    metamaskStream                    ,                    }                    )                    ;                    const                    {                    ethereum                    }                    =                    window                    ;                  

Types

Types are exposed at index.d.ts. They require Node.js EventEmitter and Duplex stream types, which you lot can grab from due east.yard. @types/node.

Do Not Alter the Provider

The Provider object should not exist mutated by consumers under whatever circumstances. The maintainers of this package will neither fix nor have responsbility for bugs caused by tertiary parties mutating the provider object.

Contributing

Setup

  • Install Node.js version 12
    • If you lot are using nvm (recommended) running nvm use volition automatically choose the right node version for you.
  • Install Yarn v1
  • Run yarn setup to install dependencies and run any requried post-install scripts
    • Alert: Do non use the yarn / yarn install command directly. Use yarn setup instead. The normal install command volition skip required mail-install scripts, leaving your development environment in an invalid state.

Testing and Linting

Run yarn test to run the tests once. To run tests on file changes, run yarn examination:watch.

Run yarn lint to run the linter, or run yarn lint:fix to run the linter and fix any automatically fixable issues.

Release & Publishing

The project follows the same release process as the other libraries in the MetaMask organization:

  1. Create a release branch
    • For a typical release, this would be based on principal
    • To update an older maintained major version, base of operations the release branch on the major version co-operative (east.g. 1.10)
  2. Update the changelog
  3. Update version in package.json file (e.g. yarn version --small-scale --no-git-tag-version)
  4. Create a pull request targeting the base branch (eastward.g. primary or 1.x)
  5. Code review and QA
  6. In one case approved, the PR is squashed & merged
  7. The commit on the base branch is tagged
  8. The tag can exist published equally needed

providers'southward People

providers'due south Issues

Provider instance is created even when MetaMask is non installed

I am using this parcel to piece of work around a Firefox issue where the eth provider cannot be injected: MetaMask/metamask-extension#3133

On Chromium with no metamask extension installed, this package still creates a total provider object, though some of the properties are undefined.

I am merely wondering what is the right way to check if the provider is good to use. I am planning for now to check the value of chainId, but I don't know if this is actually a problems.

Here is the console.log output for the provider:

                  Proxy {_events: {…}, _eventsCount: 1, _maxListeners: 100, isMetaMask: true, _state: {…}, …} [[Handler]]: Object deleteProperty: () => truthful __proto__: Object [[Target]]: MetamaskInpageProvider autoRefreshOnNetworkChange: fake chainId: undefined enable: Æ’ () isMetaMask: true networkVersion: undefined request: Æ’ () selectedAddress: null send: Æ’ () sendAsync: Æ’ () _events: {connect: Æ’} _eventsCount: 1 _handleAccountsChanged: Æ’ () _handleDisconnect: Æ’ () _maxListeners: 100 _metamask: Proxy {isUnlocked: Æ’, requestBatch: Æ’, isEnabled: Æ’, isApproved: Æ’} _publicConfigStore: ObservableStore {_events: {…}, _eventsCount: 1, _maxListeners: undefined, _state: {…}} _rpcEngine: RpcEngine {_events: {…}, _eventsCount: 0, _maxListeners: undefined, _middleware: Array(3)} _rpcRequest: Æ’ () _sendSync: Æ’ () _state: {sentWarnings: {…}, isConnected: true, accounts: undefined, isUnlocked: undefined} _warnOfDeprecation: Æ’ () _web3Ref: undefined __proto__: SafeEventEmitter [[IsRevoked]]: false                                  

migrate repo to use github actions instead of circleci

`publicConfigStore` property renamed in v4.0.0

The provider property publicConfigStore was renamed in #xi and released in v4.0.0 of the inpage provider. Nosotros hadn't realized at the fourth dimension that dapps were using this belongings directly, and that this alter would break dapps.

We should restore the old belongings proper name for at present equally an alias, and warn that the property volition soon be removed. Ultimately we'll withal need to remove it at some point, since we're planning on replacing the publicConfigStore altogether.

Make an event emitter & emit connectedness errors.

A requirement for adept third-party connections to MetaMask, like in the metamask-extension-provider.

Currently the inpage provider simply logs any stream disconnects, but this would let programmatic responses to these events.

Add CircleCI config

This projection should take a CircleCI config

Unlike behavior of 'eth_sign' between MetaMask and ETH Rpc api

MetaMask: 'eth_accounts' unexpectedly updated accounts

remove index.d.ts

this should be generated from typescript at present

Update @metamask/eslint-config

Nosotros should update @metamask/eslint-config and its relevant siblings packages to ^6.0.0. Lint scripts should be updated to follow the module template.

Incorporate backwards-compat with pre-v9 MetaMask

`data` event missing deprecation warning

The data consequence warns upon use because it is deprecated, but the deprecation message itself is missing. Instead undefined is printed to the console equally a warning.

Split inpage-provider into multiple packages

This bundle should be split into the following packages, or at least classes:

  • A BaseProvider, implementing the EIP-1193 API and nothing else
  • A MetaMaskInpageProvider, for window environments
    • This class should be the only one that contains our legacy provider features.
  • An ExtensionProvider, for other extensions
    • The following should probably be merged into this repo: https://github.com/MetaMask/extension-provider

For future environments, e.grand. Snaps, we'll add together a class/bundle in the hereafter.

Utilise v2 of the shared ESLint config

This project currently uses v1 of the org's shared ESLint config

Add LICENSE file

This projection should have a LICENSE file

chainChanged emits on page load

Depict the bug
Sometimes chainChanged message emits on every folio load. Then if I accept this line in my code: ethereum.on('chainChanged', (_chainId) => window.location.reload()); so user gets countless folio refresh loop.

To Reproduce
I couldn't reproduce this, but one of our user shared his screen and I saw this endless page refresh loop. I added console.log('chainChanged'); to that upshot callback, and panel showed this log every fourth dimension before page refreshed.

Expected behavior
chainChanged event should exist sent only on chain alter, not on page load

Browser details

  • OS: OS X
  • Browser: last Chrome
  • MetaMask Version: 8.0.8

Events don't piece of work

I use the inpage-provider with the "extension-port-stream" package at my extension'southward index folio.
The application with the provider can't get subscription events (for case at newBlockHeaders, or receive transaction receipts after send).

                  this                  .                  web3                  .                  customer                  .                  eth                  .                  subscribe                  (                  'newBlockHeaders'                  ,                  (                  fault                  ,                  result                  )                  =>                  {                  if                  (                  error                  )                  {                  console                  .                  fault                  (                  "Error happened at new cake"                  ,                  error                  )                  ;                  return                  ;                  }                  }                  )                  .                  on                  (                  "data"                  ,                  part                  (                  blockHeader                  )                  {                  panel                  .                  log                  (                  "blockHeader"                  ,                  blockHeader                  )                  ;                  }                  )                  ;                

It shows some errors considering of wallet_sendDomainMetadata, unexcepted business relationship alter
and as well the eventemitter memory leak, but the provider also seems initialized correct manner, also I can send transactions, etc.
Screenshot from 2020-02-06 19-01-25
Screenshot from 2020-02-06 17-46-03
Screenshot from 2020-02-06 17-46-14

Init procedure:

                  const                  metamaskPort                  =                  chrome                  .                  runtime                  .                  connect                  (                  "nkbihfbeogaeaoehlefnkodbefgpgknn"                  )                  ;                  const                  pluginStream                  =                  new                  PortStream                  (                  metamaskPort                  )                  ;                  let                  provider                  =                  new                  MetamaskInpageProvider                  (                  pluginStream                  )                  ;                  console                  .                  log                  (                  "provider"                  ,                  provider                  )                  ;                  this                  .                  web3                  .                  client                  =                  new                  Web3                  (                  provider                  )                  ;                

version: 4.0.4 (npm)
web3: one.2.half dozen
browser: Chrome 80.0.3987.87

Better error message when calling `BaseProvider.request()` without `params`?

Environment:
Brave browser with MetaMask v9.viii.4 extension installed. Running lawmaking in panel


The post-obit fails with a confusing fault: MetaMask - RPC Error: Cannot read holding 'length' of undefined

                  window                  .                  ethereum                  .                  request                  (                  {                  method:                  "eth_blockNumber"                  ,                  }                  )                

Nonetheless, this succeeds:

                  window                  .                  ethereum                  .                  request                  (                  {                  method:                  "eth_blockNumber"                  ,                  params:                  [                  ]                  ,                  }                  )                

Some methods like ethereum.request({ method: "eth_requestAccounts" }) don't require params to be set, and so I spent an embarrassing of time trying to find out why one telephone call worked and the other didn't.

Context:

I was trying to figure out why a convenience library was failing and figured that going down a level downward to the RPC level might aid. I tried the most basic RPC asking I could remember of (getting block number) when I got this mistake.

Possible solutions:

  1. One solution might be for the MetaMask to add params: [] when no params are specified.
  2. Another solution might be to add together some more error checking to the BaseProvider request method?

Rename package

This package at present contains a base 1193 provider, a window/DOM provider, and an external extension provider.

We should rename this package to @metamask/providers to reverberate this.

Enable clone()

Every bit identified in Web3 Issue 3573, when using both TruffleContract and web3 functions it is important that they have dissever Provider objects.

In the browser, the injected web3 has a web3.currentProvider which is a MetamaskInpageProvider, merely passing this same object to a TruffleContract'due south setProvider function seems likely to produce problems like that 1 identified in web3.

To address this, the MetamaskInpageProvider might do good from a clone() function producing another copy of the object, so that there can be independent queues serving overlapping sequences of requests from calls to the web3 object directly + calls to TruffleContract objects.

drift tests to typescript

currently they are in javascript and require stuff out of ../dist

Correctly stand for connectivity

According to EIP-1193 (permalink), the provider is "connected" when it can "service RPC requests to at least one chain". Currently the inpage provider doesn't brand much of an attempt to guarantee this. Instead, 'connectivity' effectively represents whether or not the stream between the provider and MetaMask is active.

Certainly if the provider tin't communicate with MetaMask, it can't service RPC requests either. Just there remain many cases when the stream is live and the provider is "connected" merely servicing RPC requests is incommunicable (e.g. when MetaMask is in the procedure of connecting to a network).

No certificate object in background.js

I'm trying to use the metamask provider from a groundwork script in a chrome extension, but background scripts have no document object then I'thou being thrown a "certificate is not divers" error. This is due to this line:

if ( document . readyState === 'complete' ) {

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the spider web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Spider web framework for perfectionists with deadlines.

  • Laravel photo Laravel

    A PHP framework for web artisans

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming linguistic communication with first-class functions.

  • web

    Some thing interesting about web. New door for the earth.

  • server

    A server is a plan made to process requests and deliver information to clients.

  • Car learning

    Car learning is a style of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Visualization

    Some thing interesting about visualization, utilize data art

  • Game

    Some matter interesting about game, make anybody happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open up source technology. NB: members must have ii-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • Alibaba photo Alibaba

    Alibaba Open up Source for everyone

  • D3 photo D3

    Data-Driven Documents codes.

  • Tencent photo Tencent

    China tencent open source team.

Jobs

Jooble

hayesladden.blogspot.com

Source: https://githubhelp.com/MetaMask/providers

0 Response to "Web3 Cannot Read Property 'rpcengine' of Null"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel