Add Prettier for linting and fix Solhint config (#2697)
Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
This commit is contained in:
@ -22,7 +22,6 @@ library Clones {
|
||||
* This function uses the create opcode, which should never revert.
|
||||
*/
|
||||
function clone(address implementation) internal returns (address instance) {
|
||||
// solhint-disable-next-line no-inline-assembly
|
||||
assembly {
|
||||
let ptr := mload(0x40)
|
||||
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
|
||||
@ -41,7 +40,6 @@ library Clones {
|
||||
* the clones cannot be deployed twice at the same address.
|
||||
*/
|
||||
function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {
|
||||
// solhint-disable-next-line no-inline-assembly
|
||||
assembly {
|
||||
let ptr := mload(0x40)
|
||||
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
|
||||
@ -55,8 +53,11 @@ library Clones {
|
||||
/**
|
||||
* @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
|
||||
*/
|
||||
function predictDeterministicAddress(address implementation, bytes32 salt, address deployer) internal pure returns (address predicted) {
|
||||
// solhint-disable-next-line no-inline-assembly
|
||||
function predictDeterministicAddress(
|
||||
address implementation,
|
||||
bytes32 salt,
|
||||
address deployer
|
||||
) internal pure returns (address predicted) {
|
||||
assembly {
|
||||
let ptr := mload(0x40)
|
||||
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
|
||||
@ -72,7 +73,11 @@ library Clones {
|
||||
/**
|
||||
* @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
|
||||
*/
|
||||
function predictDeterministicAddress(address implementation, bytes32 salt) internal view returns (address predicted) {
|
||||
function predictDeterministicAddress(address implementation, bytes32 salt)
|
||||
internal
|
||||
view
|
||||
returns (address predicted)
|
||||
{
|
||||
return predictDeterministicAddress(implementation, salt, address(this));
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,7 +60,11 @@ abstract contract ERC1967Upgrade {
|
||||
*
|
||||
* Emits an {Upgraded} event.
|
||||
*/
|
||||
function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal {
|
||||
function _upgradeToAndCall(
|
||||
address newImplementation,
|
||||
bytes memory data,
|
||||
bool forceCall
|
||||
) internal {
|
||||
_setImplementation(newImplementation);
|
||||
emit Upgraded(newImplementation);
|
||||
if (data.length > 0 || forceCall) {
|
||||
@ -73,7 +77,11 @@ abstract contract ERC1967Upgrade {
|
||||
*
|
||||
* Emits an {Upgraded} event.
|
||||
*/
|
||||
function _upgradeToAndCallSecure(address newImplementation, bytes memory data, bool forceCall) internal {
|
||||
function _upgradeToAndCallSecure(
|
||||
address newImplementation,
|
||||
bytes memory data,
|
||||
bool forceCall
|
||||
) internal {
|
||||
address oldImplementation = _getImplementation();
|
||||
|
||||
// Initial upgrade and setup call
|
||||
@ -89,10 +97,7 @@ abstract contract ERC1967Upgrade {
|
||||
rollbackTesting.value = true;
|
||||
Address.functionDelegateCall(
|
||||
newImplementation,
|
||||
abi.encodeWithSignature(
|
||||
"upgradeTo(address)",
|
||||
oldImplementation
|
||||
)
|
||||
abi.encodeWithSignature("upgradeTo(address)", oldImplementation)
|
||||
);
|
||||
rollbackTesting.value = false;
|
||||
// Check rollback was effective
|
||||
@ -109,7 +114,11 @@ abstract contract ERC1967Upgrade {
|
||||
*
|
||||
* Emits a {BeaconUpgraded} event.
|
||||
*/
|
||||
function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal {
|
||||
function _upgradeBeaconToAndCall(
|
||||
address newBeacon,
|
||||
bytes memory data,
|
||||
bool forceCall
|
||||
) internal {
|
||||
_setBeacon(newBeacon);
|
||||
emit BeaconUpgraded(newBeacon);
|
||||
if (data.length > 0 || forceCall) {
|
||||
@ -176,10 +185,7 @@ abstract contract ERC1967Upgrade {
|
||||
* @dev Stores a new beacon in the EIP1967 beacon slot.
|
||||
*/
|
||||
function _setBeacon(address newBeacon) private {
|
||||
require(
|
||||
Address.isContract(newBeacon),
|
||||
"ERC1967: new beacon is not a contract"
|
||||
);
|
||||
require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract");
|
||||
require(
|
||||
Address.isContract(IBeacon(newBeacon).implementation()),
|
||||
"ERC1967: beacon implementation is not a contract"
|
||||
|
||||
@ -19,7 +19,6 @@ abstract contract Proxy {
|
||||
* This function does not return to its internall call site, it will return directly to the external caller.
|
||||
*/
|
||||
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
|
||||
// block because it will not return to Solidity code. We overwrite the
|
||||
@ -35,8 +34,12 @@ abstract contract Proxy {
|
||||
|
||||
switch result
|
||||
// delegatecall returns 0 on error.
|
||||
case 0 { revert(0, returndatasize()) }
|
||||
default { return(0, returndatasize()) }
|
||||
case 0 {
|
||||
revert(0, returndatasize())
|
||||
}
|
||||
default {
|
||||
return(0, returndatasize())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,7 +63,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 virtual {
|
||||
fallback() external payable virtual {
|
||||
_fallback();
|
||||
}
|
||||
|
||||
@ -68,7 +71,7 @@ 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 virtual {
|
||||
receive() external payable virtual {
|
||||
_fallback();
|
||||
}
|
||||
|
||||
@ -78,6 +81,5 @@ abstract contract Proxy {
|
||||
*
|
||||
* If overriden should call `super._beforeFallback()`.
|
||||
*/
|
||||
function _beforeFallback() internal virtual {
|
||||
}
|
||||
function _beforeFallback() internal virtual {}
|
||||
}
|
||||
|
||||
@ -10,7 +10,6 @@ import "../../access/Ownable.sol";
|
||||
* explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.
|
||||
*/
|
||||
contract ProxyAdmin is Ownable {
|
||||
|
||||
/**
|
||||
* @dev Returns the current implementation of `proxy`.
|
||||
*
|
||||
@ -71,7 +70,11 @@ contract ProxyAdmin is Ownable {
|
||||
*
|
||||
* - This contract must be the admin of `proxy`.
|
||||
*/
|
||||
function upgradeAndCall(TransparentUpgradeableProxy proxy, address implementation, bytes memory data) public payable virtual onlyOwner {
|
||||
function upgradeAndCall(
|
||||
TransparentUpgradeableProxy proxy,
|
||||
address implementation,
|
||||
bytes memory data
|
||||
) public payable virtual onlyOwner {
|
||||
proxy.upgradeToAndCall{value: msg.value}(implementation, data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,7 +30,11 @@ contract TransparentUpgradeableProxy is ERC1967Proxy {
|
||||
* @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and
|
||||
* optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.
|
||||
*/
|
||||
constructor(address _logic, address admin_, bytes memory _data) payable ERC1967Proxy(_logic, _data) {
|
||||
constructor(
|
||||
address _logic,
|
||||
address admin_,
|
||||
bytes memory _data
|
||||
) payable ERC1967Proxy(_logic, _data) {
|
||||
assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1));
|
||||
_changeAdmin(admin_);
|
||||
}
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// solhint-disable-next-line compiler-version
|
||||
pragma solidity ^0.8.0;
|
||||
|
||||
/**
|
||||
@ -16,7 +15,6 @@ pragma solidity ^0.8.0;
|
||||
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
|
||||
*/
|
||||
abstract contract Initializable {
|
||||
|
||||
/**
|
||||
* @dev Indicates that the contract has been initialized.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user