Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement _disableInitializers in constructor (#74)
* feat: Use _disableInitializers in constructor * feat: Add RentalsProxy for testing purposes * feat: Add proxy in tests * chore: Automine true in afterEach * fix: Tests * chore: Add test to check that the implementation cannot be initialized * chore: Add comment * chore: Update test
- Loading branch information
Showing
3 changed files
with
59 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.7; | ||
|
||
import "@openzeppelin/contracts/proxy/Proxy.sol"; | ||
|
||
/// @dev Contract used to test Rentals behind a proxy | ||
/// Implementation based on https://eips.ethereum.org/EIPS/eip-1967 | ||
contract RentalsProxy is Proxy { | ||
/// @dev This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1 | ||
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; | ||
|
||
constructor(address _impl) { | ||
StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = _impl; | ||
} | ||
|
||
function _implementation() internal view virtual override returns (address) { | ||
return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; | ||
} | ||
} | ||
|
||
library StorageSlot { | ||
struct AddressSlot { | ||
address value; | ||
} | ||
|
||
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { | ||
assembly { | ||
r.slot := slot | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters