Code Monkey home page Code Monkey logo

ethers-web3-bridge's People

Contributors

ricmoo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ethers-web3-bridge's Issues

Signer.getAddress() is not a function

Hi there!

First off, thank you so much for Ethers.js. I use it as much as possible throughout my app. I recently used it to automating contract deployment and account funding on test-rpc, which cut down our setup time for testing by at least an hour. I'll be sharing gists soon to help others, and plan on demonstrating ethers in a hackathon I'm mentoring at this fall.

Now, I'm trying to do injected web3 Dapp testing with Cypress, an end-to-end javascript testing framework similar to selenium.

cy.on('window:before:load', async(win) => {
        var provider = new ethers.providers.getDefaultProvider('rinkeby')
        var wallet = new ethers.Wallet(process.env.PK)
        let providerBridge = new ProviderBridge(provider, wallet)
        console.log("Provider bridge", providerBridge) // Provider and Signer are properly set
        win.web3 = new Web3(providerBridge)
        win.web3.eth.getBlockNumber((err, res) => {
          console.log("result,", res)
        })
        win.web3.eth.getAccounts().then(console.log)
        win.web3.eth.getAccounts((err, accounts) => {console.log(accounts)})
      })

window.web3 is setting properly^^

I create a web3 instance and log it out, isConnected is true and signer is set with the correct address. However, when I call win.web3.eth.getAccounts(), I encounter the error signer.getAddress() is not a function. The error is occurring in line 337 of this module's index.js. web3.eth.getBlockNumber()`, which does not require a signer, is working as it should.

For more context, please see this article on web3 integration tests . Note that I could not replicate the code this author used in his example with truffle-privatekey-provider.

I've tried using your .connectEthers(Provider, Signer) method as well.

Thanks for your help!

Instantiating ProviderBridge sets an interval that hangs your node process

ProvideBridge's constructor sets up an interval here that is impossible to stop and doesn't let node processes finish.

Running this script in node is enough to reproduce the problem:

const ProviderBridge = require('ethers-web3-bridge');
new ProviderBridge();

The expected behavior is that the process finishes right after instantiating ProviderBridge, but it never does.

This could be fixed by adding some method to clear that interval, but IMO that would cripple ProviderBridge's API, as it won't be usable in a fire-and-forget scenario.

But I don't see a clear need for having that interval, can't the address be updated right after setting the signer here.

There's also this functionality, which may return an outdated address if the proposed change is implemented, but that's already happening.

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 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 Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

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

  • web

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

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

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

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

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

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.