Allow nonpayable functions to override payable functions
- Dominant language
- C++
- Stars
- 25.7k
- Forks
- 6.2k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 21
Description
## Abstract
If an interface defines a `view` function, it is possible for a derived contract to provide a `pure` implementation of it.
Could it be possible to extend this so that `payable` functions can be implemented with non payable functions? It is the same kind of state mutability narrowing.
## Motivation
https://github.com/OpenZeppelin/openzeppelin-contracts/issues/2610
ERC721's `transferFrom` is defined as payable in the spec. Our standard implementation is not payable, because if it were payable we would have to define what to do with the message value, which isn't standardized so we don't want to define a specific way to handle it.
Because our implementation isn't payable, we've also defined the `interface` as non-payable, but people have pointed out that 1) this is more restrictive than the spec, and 2) there is no way to extend our implementation (through inheritance) to make it payable and add logic to handle msg.value.
## Specification
A nonPayable function should be a valid implementation of a payable function.
A child contract should be able to extend our nonPayable implementation with a payable function to add a way to handle msg.value before forwarding to `super.transferFrom`.
Contributor guide
Research direction
Use the specification as the acceptance criteria and inspect the compiler's existing state-mutability override checks and regression tests. Done means a nonpayable implementation is accepted for a payable declaration, a payable child can extend it, and coverage verifies both cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, solidity
- Domain
- blockchain, compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100