编译器
0.8.20+commit.a1b79de6
文件 1 的 3:Implementation.sol
pragma solidity 0.8.20;
abstract contract Implementation {
error OnlyDelegateCallError();
error OnlyConstructorError();
address public immutable IMPL;
constructor() {
IMPL = address(this);
}
modifier onlyDelegateCall() virtual {
if (address(this) == IMPL) {
revert OnlyDelegateCallError();
}
_;
}
modifier onlyConstructor() {
if (address(this).code.length != 0) {
revert OnlyConstructorError();
}
_;
}
}
文件 2 的 3:LibRawResult.sol
pragma solidity 0.8.20;
library LibRawResult {
function rawRevert(bytes memory b) internal pure {
assembly {
revert(add(b, 32), mload(b))
}
}
function rawReturn(bytes memory b) internal pure {
assembly {
return(add(b, 32), mload(b))
}
}
}
文件 3 的 3:Proxy.sol
pragma solidity 0.8.20;
import "./LibRawResult.sol";
import "./Implementation.sol";
contract Proxy {
using LibRawResult for bytes;
Implementation public immutable IMPL;
constructor(Implementation impl, bytes memory initCallData) payable {
IMPL = impl;
(bool s, bytes memory r) = address(impl).delegatecall(initCallData);
if (!s) {
r.rawRevert();
}
}
fallback() external payable {
Implementation impl = IMPL;
assembly {
calldatacopy(0x00, 0x00, calldatasize())
let s := delegatecall(gas(), impl, 0x00, calldatasize(), 0x00, 0)
returndatacopy(0x00, 0x00, returndatasize())
if iszero(s) {
revert(0x00, returndatasize())
}
return(0x00, returndatasize())
}
}
}
{
"compilationTarget": {
"contracts/utils/Proxy.sol": "Proxy"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [
":ds-test/=lib/forge-std/lib/ds-test/src/",
":erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
":forge-std/=lib/forge-std/src/",
":openzeppelin-contracts/=lib/openzeppelin-contracts/",
":openzeppelin/=lib/openzeppelin-contracts/",
":solmate/=lib/solmate/src/"
],
"viaIR": true
}
[{"inputs":[{"internalType":"contract Implementation","name":"impl","type":"address"},{"internalType":"bytes","name":"initCallData","type":"bytes"}],"stateMutability":"payable","type":"constructor"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"IMPL","outputs":[{"internalType":"contract Implementation","name":"","type":"address"}],"stateMutability":"view","type":"function"}]