Skip to content

Commit

Permalink
fix: add error message for nonpayable check (#3466)
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed May 26, 2023
1 parent 056dfd8 commit 64733b9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion vyper/codegen/function_definitions/external_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion vyper/codegen/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 64733b9

Please sign in to comment.