Skip to content

Commit

Permalink
revert changes to sha and keccak
Browse files Browse the repository at this point in the history
  • Loading branch information
tserg committed Oct 26, 2023
1 parent 0ccc9cc commit e520c25
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions vyper/builtins/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,8 @@ def build_IR(self, expr, context):

class Keccak256(BuiltinFunction):
_id = "keccak256"
_inputs = [("value", (BytesT.any(), BytesM_T.any(), StringT.any()))]
# TODO allow any BytesM_T
_inputs = [("value", (BytesT.any(), BYTES32_T, StringT.any()))]
_return_type = BYTES32_T

def evaluate(self, node):
Expand All @@ -611,7 +612,7 @@ def evaluate(self, node):
arg_typ = self.infer_arg_types(node).pop()
if isinstance(arg_typ, StringT):
value = value.encode()
elif isinstance(arg_typ, BytesM_T):
elif arg_typ == BYTES32_T:
length = len(value) // 2 - 1
value = int(value, 16).to_bytes(length, "big")

Expand Down Expand Up @@ -647,7 +648,7 @@ def _make_sha256_call(inp_start, inp_len, out_start, out_len):

class Sha256(BuiltinFunction):
_id = "sha256"
_inputs = [("value", (BytesM_T.any(), BytesT.any(), StringT.any()))]
_inputs = [("value", (BYTES32_T, BytesT.any(), StringT.any()))]
_return_type = BYTES32_T

def evaluate(self, node):
Expand All @@ -662,7 +663,7 @@ def evaluate(self, node):
arg_typ = self.infer_arg_types(node).pop()
if isinstance(arg_typ, StringT):
value = value.encode()
elif isinstance(arg_typ, BytesM_T):
elif arg_typ == BYTES32_T:
length = len(value) // 2 - 1
value = int(value, 16).to_bytes(length, "big")

Expand Down

0 comments on commit e520c25

Please sign in to comment.