From 64733b9d15935ecd2bfcfdfbb9606d5ab500d70c Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Fri, 26 May 2023 11:36:30 -0400 Subject: [PATCH] fix: add error message for nonpayable check (#3466) --- vyper/codegen/function_definitions/external_function.py | 5 ++++- vyper/codegen/module.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/vyper/codegen/function_definitions/external_function.py b/vyper/codegen/function_definitions/external_function.py index 6104a86c16..312cb75cf8 100644 --- a/vyper/codegen/function_definitions/external_function.py +++ b/vyper/codegen/function_definitions/external_function.py @@ -200,7 +200,10 @@ def generate_ir_for_external_function(code, func_t, context, skip_nonpayable_che if not func_t.is_payable and not skip_nonpayable_check: # if the contract contains payable functions, but this is not one of them # add an assertion that the value of the call is zero - body += [["assert", ["iszero", "callvalue"]]] + nonpayable_check = IRnode.from_list( + ["assert", ["iszero", "callvalue"]], error_msg="nonpayable check" + ) + body.append(nonpayable_check) body += nonreentrant_pre diff --git a/vyper/codegen/module.py b/vyper/codegen/module.py index 2fece47a9e..2d498460be 100644 --- a/vyper/codegen/module.py +++ b/vyper/codegen/module.py @@ -97,7 +97,10 @@ def _runtime_ir(runtime_functions, global_ctx): selector_section.append(func_ir) if batch_payable_check: - selector_section.append(["assert", ["iszero", "callvalue"]]) + nonpayable_check = IRnode.from_list( + ["assert", ["iszero", "callvalue"]], error_msg="nonpayable check" + ) + selector_section.append(nonpayable_check) for func_ast in nonpayables: func_ir = generate_ir_for_function(func_ast, global_ctx, skip_nonpayable_check)