You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We shouldn't have to use convert when we are using extract32 to get currently unsupported return types.
Abstract
Currently, extract32 only supports bytes32, int128, and address as output types - if we are going to have type conversions integrated into this, we should allow for all supported conversions. Currently, if we want decimal, or uint256, we have to wrap the extract32 in a convert(extract32(byteArr, start, bytes32), uint256).
Motivation
This improves code readability.
Specification
The following should work:
extract32(byteArr, start, type=uint256)
extract32(byteArr, start, type=decimal)
Where extract32:
def extract32(a, b, type=c) -> d:
"""
:param a: where 32 bytes are extracted from
:type a: bytes
:param b: start point of bytes to be extracted
:type b: int128
:param c: type of output (Optional, default: bytes32)
:type c: either bytes32, int128, address, uint256, or decimal
:output d: either bytes32, int128, address, uint256, or decimal
"""
The text was updated successfully, but these errors were encountered:
brockelmore
changed the title
VIP: extract32 should be able to output types: decimal, int128, uint256 or bytes32
VIP: extract32 should be able to output types: decimal, int128, uint256, address or bytes32
Jul 22, 2019
Simple Summary
We shouldn't have to use convert when we are using extract32 to get currently unsupported return types.
Abstract
Currently, extract32 only supports bytes32, int128, and address as output types - if we are going to have type conversions integrated into this, we should allow for all supported conversions. Currently, if we want decimal, or uint256, we have to wrap the extract32 in a convert(extract32(byteArr, start, bytes32), uint256).
Motivation
This improves code readability.
Specification
The following should work:
Where extract32:
I think this could be achieved by just implementing convert into the underlying code https://github.com/ethereum/vyper/blob/f890abe1907d9c4329950c400f348f9102a5263b/vyper/functions/functions.py#L553 in this area, instead of manually doing this.
Totally open to this idea being dumb, and definitely dont understand everything as I am relatively new to the repo.
Backwards Compatibility
Not totally sure
Dependencies
Copyright
Copyright and related rights waived via CC0
The text was updated successfully, but these errors were encountered: