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

ethers-cfx-patch

v0.1.1-delta

Published

ethers-cfx-patch is used for compatiable ethers with conflux network

Downloads

5

Readme

Ethers Cfx Patch

Description

ethers-cfx-patch is used for compatiable ethers with conflux network. The purpose is to overwrite some methods to compatibale with cfx network, most are functions related address and transaction. And it will not break origin features.

Install

$ npm install ethers-cfx-patch

Usage

Overwrite methods

Load ethers-cfx-patch package in the head of your project. It will overwrite methods.

// load pacakge to overwrite methods
require("ethers-cfx-patch")
// your project
// ...

Use CFX proxy provider

We provide an JsonRpcProxy for adapter ethereum rpc to conflux rpc, use JsonRpcProxy to create an Web3Provider

const JsonRpcProxy = require("web3-provider-proxy");

const cfxProxy = new JsonRpcProxy("http://localhost:12537")
const povider = new ethers.providers.Web3Provider(cfxProxy)

Note

Auto setted fields

The JsonRpcProxy is a rpc proxy which adapt conflux rpc methods to ethereum rpc methods, and some concepts are auto handled for user, there are

rpc method cfx_sendTransaction

  • storageLimit
  • epochHeight
Difference with actual

All of fields block number in eth rpc request or response are correspending to epoch number in JsonRpcProxy, and sametime there also concept block number in conflux but is hidden in JsonRpcProxy, so if you use eth_getBlockNumber it will return epoch number of conflux, and currently could not get real block number use JsonRpcProxy.

So please don't use JsonRpcProxy to do bussiness dependencies block number. The bussiness dependencies Transaction and Events are not impacted.

CfxWallet

The CfxWallet is used for sign, sendTransaction, deploy contract in cfx format. It need one more param networkId which could access by provider.getNetowrk to create an instance.

let network = await provider.getNetwork()
let networkId = network.chainId
let signer = new CfxWallet("0x2139FB4C55CB9AF7F0086CD800962C2E9013E2292BAE77978A9209E3BEE71D49",p, networkId)
console.log("signer address", await signer.address)
console.log("sign message:", await signer.signMessage("hello"))
const txSended = await signer.sendTransaction({ ...tx, from: signer.address })
const receipt = await txSended.wait(1)
console.log("send tx by wallet", { txSended, receipt })

utils

There also provids some utils methods used for conflux network