feat: initial commit for wtf-contract v2
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
/// @dev Minimal non-upgradeable delegatecall proxy for testing upgradeable
|
||||
/// contracts (WTFControllerV2 uses an initializer + _disableInitializers()).
|
||||
contract TestProxy {
|
||||
bytes32 private constant _IMPLEMENTATION_SLOT =
|
||||
bytes32(uint256(keccak256("test.proxy.implementation")) - 1);
|
||||
|
||||
constructor(address implementation_) {
|
||||
bytes32 slot = _IMPLEMENTATION_SLOT;
|
||||
assembly {
|
||||
sstore(slot, implementation_)
|
||||
}
|
||||
}
|
||||
|
||||
fallback() external payable {
|
||||
bytes32 slot = _IMPLEMENTATION_SLOT;
|
||||
address impl;
|
||||
assembly {
|
||||
impl := sload(slot)
|
||||
}
|
||||
assembly {
|
||||
calldatacopy(0, 0, calldatasize())
|
||||
let result := delegatecall(gas(), impl, 0, calldatasize(), 0, 0)
|
||||
returndatacopy(0, 0, returndatasize())
|
||||
switch result
|
||||
case 0 {
|
||||
revert(0, returndatasize())
|
||||
}
|
||||
default {
|
||||
return(0, returndatasize())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user