Skip to content

Commit a16f20b

Browse files
committed
fix(Proxy): remove unneeded fallback function
https://forum.openzeppelin.com/t/proxy-sol-fallback/36951/8 The fallback alone would indeed be enough. Fallback is not limited to` msg.value == 0` (if its marked `payable`). Both functions can support value. The difference between receive and fallback is in the msg.data. If the calldata is empty and if there is a receive function, it fill be used. Otherwise, fallback is used. This means that regardless of the value, fallback will be called if there is some data. `fallback` is also the one that is called if there is no data, but receive is not defined. So why do we have a receive function that is not really needed? To silent solidity warnings that sometimes happen when you have a fallback function but no receive function. - @Amxx see <OpenZeppelin/openzeppelin-contracts#4434 (comment)>
1 parent 4ec77af commit a16f20b

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

src/Proxy.sol

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: MIT
22
// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)
33

4-
pragma solidity 0.8.19;
4+
pragma solidity ^0.8.19;
55

66
/**
77
* @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
@@ -68,14 +68,6 @@ abstract contract Proxy {
6868
_fallback();
6969
}
7070

71-
/**
72-
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
73-
* is empty.
74-
*/
75-
receive() external payable virtual {
76-
_fallback();
77-
}
78-
7971
/**
8072
* @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
8173
* call, or as part of the Solidity `fallback` or `receive` functions.

0 commit comments

Comments
 (0)