编译器
0.8.25+commit.b61c2a91
文件 1 的 4:Call.sol
pragma solidity 0.8.25;
library Call {
function verifyResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert();
}
}
}
}
文件 2 的 4:ERC1967.sol
pragma solidity 0.8.25;
library ERC1967 {
bytes32 public constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
function load() internal view returns (address implementation) {
assembly {
implementation := sload(_IMPLEMENTATION_SLOT)
}
}
function store(address implementation) internal {
assembly {
sstore(_IMPLEMENTATION_SLOT, implementation)
}
}
}
文件 3 的 4:GatewayProxy.sol
pragma solidity 0.8.25;
import {ERC1967} from "./utils/ERC1967.sol";
import {Call} from "./utils/Call.sol";
import {IInitializable} from "./interfaces/IInitializable.sol";
contract GatewayProxy is IInitializable {
error Unauthorized();
error NativeCurrencyNotAccepted();
constructor(address implementation, bytes memory params) {
ERC1967.store(implementation);
(bool success, bytes memory returndata) =
implementation.delegatecall(abi.encodeCall(IInitializable.initialize, params));
Call.verifyResult(success, returndata);
}
function initialize(bytes calldata) external pure {
revert Unauthorized();
}
fallback() external payable {
address implementation = ERC1967.load();
assembly {
calldatacopy(0, 0, calldatasize())
let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
switch result
case 0 { revert(0, returndatasize()) }
default { return(0, returndatasize()) }
}
}
receive() external payable {
revert NativeCurrencyNotAccepted();
}
}
文件 4 的 4:IInitializable.sol
pragma solidity 0.8.25;
interface IInitializable {
function initialize(bytes calldata data) external;
}
{
"compilationTarget": {
"src/GatewayProxy.sol": "GatewayProxy"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs",
"useLiteralContent": true
},
"optimizer": {
"enabled": true,
"runs": 999999
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"implementation","type":"address"},{"internalType":"bytes","name":"params","type":"bytes"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"NativeCurrencyNotAccepted","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"stateMutability":"payable","type":"fallback"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"initialize","outputs":[],"stateMutability":"pure","type":"function"},{"stateMutability":"payable","type":"receive"}]