Make non-view functions virtual (#2468)

This commit is contained in:
Hadrien Croubois
2021-01-13 22:25:39 +01:00
committed by GitHub
parent 65b7e515a2
commit faec973e09
12 changed files with 62 additions and 63 deletions

View File

@ -6,19 +6,19 @@ pragma solidity >=0.6.0 <0.8.0;
* @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
* instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
* be specified by overriding the virtual {_implementation} function.
*
*
* Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
* different contract through the {_delegate} function.
*
*
* The success and return data of the delegated call will be returned back to the caller of the proxy.
*/
abstract contract Proxy {
/**
* @dev Delegates the current call to `implementation`.
*
*
* This function does not return to its internall call site, it will return directly to the external caller.
*/
function _delegate(address implementation) internal {
function _delegate(address implementation) internal virtual {
// solhint-disable-next-line no-inline-assembly
assembly {
// Copy msg.data. We take full control of memory in this inline assembly
@ -48,10 +48,10 @@ abstract contract Proxy {
/**
* @dev Delegates the current call to the address returned by `_implementation()`.
*
*
* This function does not return to its internall call site, it will return directly to the external caller.
*/
function _fallback() internal {
function _fallback() internal virtual {
_beforeFallback();
_delegate(_implementation());
}
@ -60,7 +60,7 @@ abstract contract Proxy {
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
* function in the contract matches the call data.
*/
fallback () external payable {
fallback () external payable virtual {
_fallback();
}
@ -68,14 +68,14 @@ abstract contract Proxy {
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
* is empty.
*/
receive () external payable {
receive () external payable virtual {
_fallback();
}
/**
* @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
* call, or as part of the Solidity `fallback` or `receive` functions.
*
*
* If overriden should call `super._beforeFallback()`.
*/
function _beforeFallback() internal virtual {