aragon / radspec

🤘 Radspec is a safe interpreter for Ethereum's NatSpec
MIT License
141 stars 36 forks source link

Would it be possible to have some toAscii helper for bytes arguments? #56

Closed ottodevs closed 5 years ago

ottodevs commented 5 years ago

Because bytesX arguments fit better than strings in some cases, I think it would be really helpful for the user to have a radspec helper that outputs the friendly ASCII or UTF8 value (as web3 utils has).

Example:

/**
 * @notice Add entity `@toAscii(_name)` with address `_addr` to the registry
 */
function addEntry(address _address, bytes32 _name) {...}

Those helpers would be pure functions, so they should not decrease overall safety

I can submit a PR for that if you find it is a good idea.

izqui commented 5 years ago

Sounds like a good idea to me! Let's make sure we support both bytesX and arbitrary-size bytes

sembrestels commented 5 years ago

In the latest version of web3, toAscii has been deprecated in favor of hexToAscii. And I would propose to expose hexToUtf8(hex) instead, as well as hexToNumber(hex). Do you agree?