0

I have a non payable function to propose function. It has a modifier called isSubmitFeePaid. Modifier call a payable function. I am writing a script to propose. But problem is when i try call purpose its revert with FundProject__NotEnoughPayment() which i didnt sent eth. But i cant because it is not payable. Because of it has payable modifier i have to sent some eth. I cant make purpose function payable. Its OpenZeppelin(governance) function its overriding and doesnt like to be payable. Have can i solve this?

 modifier isSubmitFeePaid() {
    paySubmitFee();
    _;
}
function paySubmitFee() public payable {
    if (msg.value < enteranceFee) {
        revert FundProject__NotEnoughPayment();
    }
    projectOwners = payable(msg.sender);
}


function propose(
    address[] memory targets,
    uint256[] memory values,
    bytes[] memory calldatas,
    string memory description
) public override(Governor, IGovernor) isSubmitFeePaid returns (uint256) {
    return super.propose(targets, values, calldatas, description);
}

1 Answer 1

0

Simple trick would be to create another method which calls the propose method. You can make this wrapper a payable method and attach the isSubmitFeePaid modifier to it.

3
  • Technically your are right but That will not work. Because anybody can call propose function without pay. Nov 8, 2022 at 15:42
  • make propose internal, then.
    – Foxxxey
    Nov 8, 2022 at 22:31
  • openzeppelin didnt like that either. Giving this error: overriding function visibility differs. Nov 10, 2022 at 5:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.