-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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
Add "fromAddress" to utils/Strings.sol #2197
Comments
I tried all the methods on that stackexchange link and only one (by k06a and Aliaksandr Adzinets) worked for me:
I don't know how efficient this is gas-wise, but that doesn't matter for my current purposes. |
Hi @wysenynja! Thanks for the suggestion, it is really appreciated. The project owner should review your suggestion during the next week. Please wait until we have discussed this idea before writing any code or submitting a Pull Request, so we can go through the design beforehand. We don’t want you to waste your time! |
You're welcome, and thank you! I'm using that code for now since it works. I'll let your team improve the design. |
Could you share a short snippet of how you're using this to create nicer error messages? I'd rather see tooling move in a direction where we can retrieve values directly without having to convert them to strings inside the EVM (!), though I guess there's not much harm in having such a helper. I wonder how easy it'd be to create these messages though. |
This is what I'm doing for now. I just wanted useful reverts in dev so I'm not caring about gas efficiency at all.
This one mostly works, but theres some bytes at the front of call_returned that I don't know how to deal with. That's a separate issue though.
|
Hello @wysenynja, sorry to have left you hanging. Even if usefulness of this feature is unclear, we think it might make sense to include it in the OpenZeppelin Contracts library to provide users with the flexibility to perform these sort of tasks. We arrived at a similar conclusion in #1795 (which is rather relevant here). Unfortunately, we don't have enough bandwidth to properly include features that will likely go unsed, with the associated tests, documentation and maintenance tasks, and think our effors will have a larger impact in areas where there's larger evidence of community demand. Head to our roadmap to learn about what we're currently working on. I'll keep this issue open as a space for people to discuss this and related features - if we find interesting use cases where such as thing is needed, then we can carry on work and think how to best support them from the Contracts library. Thank you very much for your work and suggestions @wysenynja! |
That makes sense. For now, I have a
|
Oops. I mis-clicked. |
I have a situation where The token metadata is generated using the string representation of the address of the linked contract. Something like This isn't the ideal UI feature, but compare it to Uniswap's tokens, for example, each of which is nondescriptly named "Uniswap V1 (UNI-V1)". |
Thanks for sharing your use case @ItsNickBarry! That's very interesting. A slight issue with this is that the addresses wouldn't be checksummed. It doesn't seem like it'd be terribly hard to implement the checksum, though we'd have to hash the address and access its bits, requiring some masking. |
This is resolved by this function.
|
@Amxx What do you think about adding an override for |
🧐 Motivation
I am trying to get more useful revert messages in my contracts and being able to format uint256 as a string has been really helpful. It would be nice if the other types had this, too. For now, I only need
fromAddress
.📝 Details
There are a couple (slightly outdated) implementations here: https://ethereum.stackexchange.com/questions/8346/convert-address-to-string
The text was updated successfully, but these errors were encountered: