Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getAddress function is not callable #4165

Open
mariogutval opened this issue Jun 20, 2023 · 10 comments
Open

getAddress function is not callable #4165

mariogutval opened this issue Jun 20, 2023 · 10 comments
Assignees
Labels
investigate Under investigation and may be a bug. v6 Issues regarding v6

Comments

@mariogutval
Copy link

Ethers Version

6.6.0

Search Terms

getAddress

Describe the Problem

I faced this issue when I created an instance of AaveLendingPoolAddressProvider contract and tried to call the getAddress function, whose signature is getAddress(bytes32). Apparently, the function call is being ignored and the returned result corresponds to the async getAddress() method included in the BaseContract type.

It's interesting that when I remove the argument on the contract call, it requires me to add an argument, but when I change the type of the argument to, for example, ethers.Typed.int24, no warning/error is displayed.

I tried all the approaches you can see in the code snippet, but the result was same.

Code Snippet

const protocolDataProvider1 = await lendingPoolAddressProvider.getAddress(
  "0x0100000000000000000000000000000000000000000000000000000000000000",
);

const protocolDataProvider2 = await addressProvider.getAddress(
  ethers.Typed.bytes32(
    "0x0100000000000000000000000000000000000000000000000000000000000000"
  )
);

const protocolDataProvider3 = await lendingPoolAddressProvider["getAddress"](
  "0x0100000000000000000000000000000000000000000000000000000000000000",
);

const protocolDataProvider4 = await addressProvider["getAddress"](
  ethers.Typed.bytes32(
    "0x0100000000000000000000000000000000000000000000000000000000000000"
  )
);

Contract ABI

No response

Errors

No response

Environment

Hardhat

Environment (Other)

No response

@mariogutval mariogutval added investigate Under investigation and may be a bug. v6 Issues regarding v6 labels Jun 20, 2023
@eladiosch
Copy link

I've encountered the same problem. A workaround to get the desired result is to call the function like this:

const protocolDataProvider1 = await (addressesProvider.getFunction("getAddress"))(yourId)

@mariogutval
Copy link
Author

I've encountered the same problem. A workaround to get the desired result is to call the function like this:

const protocolDataProvider1 = await (addressesProvider.getFunction("getAddress"))(yourId)

It worked! Thank you!

I will still leave this issue open because I think it's something that needs to be fixed.

@eladiosch
Copy link

Agreed

@voltrevo
Copy link

voltrevo commented Aug 9, 2023

Ran into this issue on eth-infinitism/account-abstraction:
eth-infinitism/account-abstraction#323

@nickshatilo
Copy link

Hey, also encountered this issue. Any updates on this?

@Siponek
Copy link

Siponek commented May 25, 2024

When trying to get address of the signer it returns an error saying that it is private field. How are you able to create apps without it?
await this.signer.getAddress()
The workaround that @eladiosch posted doesn't work for me. I cannot get the getFunction() fucntion on an object 😿

@eladiosch
Copy link

For a signer, you should be able to just do this.signer.address, the issue is with contracts

@ricmoo
Copy link
Member

ricmoo commented May 25, 2024

A Signer should also have a getAddress() async function; what is the error you are getting?

But the OP was about contracts, I which is unrelated.

@Siponek
Copy link

Siponek commented May 31, 2024

Hey,

@ricmoo Sorry, you are right this is unrelated. Since I am a noob regarding daps, I didn't know about .address property and I couldn't find the easy way through docs. I switched to web3js in the end.

The error was that the getAddress() is trying to access private field, which I found weird since it is referenced down the classes. I am using Metamask with chrome for that. If I will find the time, I will rollback to check the exact error.


@eladiosch You are right, thanks

@jaa2
Copy link

jaa2 commented Oct 1, 2024

I spent a very long time trying to debug a problem today (the case of the perpetually empty storage slot) only to find this was the cause. It is unfortunate that the type of the internal getAddress is exactly the same as a contract's getAddress function, TypeScript compiled correctly, and no errors are thrown even when arguments are passed to getAddress. I suggest ensuring the argument length is zero.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigate Under investigation and may be a bug. v6 Issues regarding v6
Projects
None yet
Development

No branches or pull requests

7 participants