Implement recommendations from 5.0 audit Phase 1B (#4502)
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com> Co-authored-by: Francisco Giordano <fg@frang.io>
This commit is contained in:
@ -1,50 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
import {Address} from "../utils/Address.sol";
|
||||
|
||||
/**
|
||||
* @dev A mock to expose `Address`'s functions with function pointers.
|
||||
*/
|
||||
contract AddressFnPointerMock {
|
||||
error CustomRevert();
|
||||
|
||||
function functionCall(address target, bytes memory data) external returns (bytes memory) {
|
||||
return Address.functionCall(target, data, _customRevert);
|
||||
}
|
||||
|
||||
function functionCallWithValue(address target, bytes memory data, uint256 value) external returns (bytes memory) {
|
||||
return Address.functionCallWithValue(target, data, value, _customRevert);
|
||||
}
|
||||
|
||||
function functionStaticCall(address target, bytes memory data) external view returns (bytes memory) {
|
||||
return Address.functionStaticCall(target, data, _customRevert);
|
||||
}
|
||||
|
||||
function functionDelegateCall(address target, bytes memory data) external returns (bytes memory) {
|
||||
return Address.functionDelegateCall(target, data, _customRevert);
|
||||
}
|
||||
|
||||
function verifyCallResultFromTarget(
|
||||
address target,
|
||||
bool success,
|
||||
bytes memory returndata
|
||||
) external view returns (bytes memory) {
|
||||
return Address.verifyCallResultFromTarget(target, success, returndata, _customRevert);
|
||||
}
|
||||
|
||||
function verifyCallResult(bool success, bytes memory returndata) external view returns (bytes memory) {
|
||||
return Address.verifyCallResult(success, returndata, _customRevert);
|
||||
}
|
||||
|
||||
function verifyCallResultVoid(bool success, bytes memory returndata) external view returns (bytes memory) {
|
||||
return Address.verifyCallResult(success, returndata, _customRevertVoid);
|
||||
}
|
||||
|
||||
function _customRevert() internal pure {
|
||||
revert CustomRevert();
|
||||
}
|
||||
|
||||
function _customRevertVoid() internal pure {}
|
||||
}
|
||||
@ -59,3 +59,15 @@ contract CallReceiverMock {
|
||||
return "0x1234";
|
||||
}
|
||||
}
|
||||
|
||||
contract CallReceiverMockTrustingForwarder is CallReceiverMock {
|
||||
address private _trustedForwarder;
|
||||
|
||||
constructor(address trustedForwarder_) {
|
||||
_trustedForwarder = trustedForwarder_;
|
||||
}
|
||||
|
||||
function isTrustedForwarder(address forwarder) public view virtual returns (bool) {
|
||||
return forwarder == _trustedForwarder;
|
||||
}
|
||||
}
|
||||
|
||||
27
contracts/mocks/UpgradeableBeaconMock.sol
Normal file
27
contracts/mocks/UpgradeableBeaconMock.sol
Normal file
@ -0,0 +1,27 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
import {IBeacon} from "../proxy/beacon/IBeacon.sol";
|
||||
|
||||
contract UpgradeableBeaconMock is IBeacon {
|
||||
address public implementation;
|
||||
|
||||
constructor(address impl) {
|
||||
implementation = impl;
|
||||
}
|
||||
}
|
||||
|
||||
interface IProxyExposed {
|
||||
// solhint-disable-next-line func-name-mixedcase
|
||||
function $getBeacon() external view returns (address);
|
||||
}
|
||||
|
||||
contract UpgradeableBeaconReentrantMock is IBeacon {
|
||||
error BeaconProxyBeaconSlotAddress(address beacon);
|
||||
|
||||
function implementation() external view override returns (address) {
|
||||
// Revert with the beacon seen in the proxy at the moment of calling to check if it's
|
||||
// set before the call.
|
||||
revert BeaconProxyBeaconSlotAddress(IProxyExposed(msg.sender).$getBeacon());
|
||||
}
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
import {IBeacon} from "../proxy/beacon/IBeacon.sol";
|
||||
|
||||
contract UpgradeableBeaconMock is IBeacon {
|
||||
address public implementation;
|
||||
|
||||
constructor(address impl) {
|
||||
implementation = impl;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user