Skip to content
This repository was archived by the owner on Oct 1, 2021. It is now read-only.
This repository was archived by the owner on Oct 1, 2021. It is now read-only.

Signer.getAddress() is not a function  #3

@pakaplace

Description

@pakaplace

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions