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

VIP: extract32 should be able to output types: decimal, int128, uint256, address or bytes32 #1540

Open
brockelmore opened this issue Jul 22, 2019 · 1 comment
Labels
Easy Pickings Used to denote issues that should be easy to implement VIP: Approved VIP Approved

Comments

@brockelmore
Copy link
Contributor

brockelmore commented 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:

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
  """

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

@brockelmore 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
@jacqueswww jacqueswww added VIP: Approved VIP Approved Easy Pickings Used to denote issues that should be easy to implement labels Aug 6, 2019
@charles-cooper
Copy link
Member

related: #1093

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Easy Pickings Used to denote issues that should be easy to implement VIP: Approved VIP Approved
Projects
None yet
Development

No branches or pull requests

3 participants