From e520c25cf46e1090f243706b26e8562c2a6047de Mon Sep 17 00:00:00 2001 From: tserg <8017125+tserg@users.noreply.github.com> Date: Thu, 26 Oct 2023 09:04:07 +0800 Subject: [PATCH] revert changes to sha and keccak --- vyper/builtins/functions.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/vyper/builtins/functions.py b/vyper/builtins/functions.py index f0d5d5542d..3d7bbb4c02 100644 --- a/vyper/builtins/functions.py +++ b/vyper/builtins/functions.py @@ -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): @@ -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") @@ -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): @@ -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")