npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cypress-ethereum-provider

v0.1.7

Published

A Universal Ethereum Provider for Testing

Downloads

439

Readme

CYPRESS-ETHEREUM-PROVIDER

Goals

  • Follows EIP 1193 Spec
  • Support all transport types (websocket, http, ipc & injected)
  • Attempt connection to an array of RPC endpoints until successful connection
  • Reconnect when connection is lost
  • Emit helpful status updates so apps can handle changes gracefully
  • Can overwrite the address returned by the call eth_address

Install

npm install cypress-ethereum-provider --save

Use

const provider = require('cypress-ethereum-provider')
const web3 = new Web3(provider('wss://rinkeby.infura.io/ws/v3/${INFURA_ID}))
  • When passing in multiple RPC targets order them by priority
  • When cypress-ethereum-provider fails to connect to a target it will automatically attempt to connect to the next priority target
  • For example ['injected', 'wss://rinkeby.infura.io/ws/v3/${INFURA_ID}'] will first try to discover injected providers and if unsuccessful connect to the Infura endpoint
const provider = require('cypress-ethereum-provider')
const web3 = new Web3(provider(['injected', 'wss://rinkeby.infura.io/ws/v3/${INFURA_ID}']))
  • In Node and Electron you'll have access to IPC endpoints created by Geth or Parity that cannot be accessed by the Browser. You can connect to these by using the 'direct' preset, or by passing custom IPC paths
const provider = require('cypress-ethereum-provider')
const web3 = new Web3(provider('direct'))
  • Yoy can force the address for special cases like ganache fork mainet with
  const provider = require('cypress-ethereum-provider')
  const web3 = new Web3(provider('http://localhost:8545'))
  web3.setFakeAccounts(["0x00000"])

Presets

  • injected - Discover providers injected by environment, usually by the browser or a browser extension
    • Browser
      • ['injected']
  • frame - Connect to Frame running on the user's device
    • Browser/Node/Electron
      • ['ws://127.0.0.1:1248', 'http://127.0.0.1:1248']
  • direct - Connect to local Ethereum nodes running on the user's device
    • Browser
      • ['ws://127.0.0.1:8546', 'http://127.0.0.1:8545']
    • Node/Electron
      • [/* Default IPC paths for platform */, 'ws://127.0.0.1:8546', 'http://127.0.0.1:8545']
  • infura - Connect to Mainnet Infura
    • Browser/Node/Electron
      • ['wss://mainnet.infura.io/ws/v3/${INFURA_ID}', 'https://mainnet.infura.io/v3/${INFURA_ID}']
  • infuraRinkeby - Connect to Rinkeby Infura
    • Browser/Node/Electron
      • ['wss://rinkeby.infura.io/ws/v3/${INFURA_ID}', 'https://rinkeby.infura.io/v3/${INFURA_ID}']
  • infuraRopsten - Connect to Ropsten Infura
    • Browser/Node/Electron
      • ['wss://ropsten.infura.io/ws/v3/${INFURA_ID}', 'https://ropsten.infura.io/v3/${INFURA_ID}']
  • infuraKovan - Connect to Kovan Infura
    • Browser/Node/Electron
      • ['wss://kovan.infura.io/ws/v3/${INFURA_ID}', 'https://kovan.infura.io/v3/${INFURA_ID}']

If you do not pass any targets, cypress-ethereum-provider will use default targets ['injected', 'frame'] in the Browser and ['frame', 'direct'] in Node and Electron.

Options

When creating the provider you can also pass an options object

  • infuraId - Your projects Infura ID
  • origin - Used when connecting from outside of a browser env to declare you're origin (this currently doesn't work with HTTP connections)

provider('infura', { infuraId: '123abc' }) or provider({ origin: 'DappName', infuraId: '123abc' })

The origin setting will only be applied when a dapp is connecting to from outside of a browser env.

Notes

Based from : https://github.com/floating/eth-provider