编译器
0.8.21+commit.d9974bed
文件 1 的 3:Context.sol
pragma solidity ^0.8.20;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
文件 2 的 3:DeploymentRouter.sol
pragma solidity 0.8.21;
import "@openzeppelin/access/Ownable.sol";
interface ISafe {
function enableModule(address _module) external;
function setFallbackHandler(address _handler) external;
}
interface IFactory {
function deploy(bytes32 _hash, uint256 _x, uint256 _y) external returns (bool);
function getSafeReference() external view returns (address);
}
contract DeploymentRouter {
address public immutable factoryProxy;
event SafeModuleSet(address indexed _module, uint256 _version);
constructor(address _factoryProxy) {
factoryProxy = _factoryProxy;
}
function setupSafe(bytes32 _hash, uint256 _x, uint256 _y) public returns (bool) {
_setupSafe();
return _deploySigner(_hash, _x, _y);
}
function _deploySigner(bytes32 _hash, uint256 _x, uint256 _y) internal returns (bool) {
return IFactory(factoryProxy).deploy(_hash, _x, _y);
}
function _setupSafe() internal {
address safeModule = IFactory(factoryProxy).getSafeReference();
ISafe(address(this)).enableModule(safeModule);
ISafe(address(this)).setFallbackHandler(safeModule);
}
}
文件 3 的 3:Ownable.sol
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
abstract contract Ownable is Context {
address private _owner;
error OwnableUnauthorizedAccount(address account);
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
modifier onlyOwner() {
_checkOwner();
_;
}
function owner() public view virtual returns (address) {
return _owner;
}
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
{
"compilationTarget": {
"src/DeploymentRouter.sol": "DeploymentRouter"
},
"evmVersion": "paris",
"libraries": {
"lib/safe-singleton-deployer-sol/src/SafeSingletonDeployer.sol:SafeSingletonDeployer": "0xa6ab6c0b2570c17e403b344068d70fd81cf76a88"
},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 1000000
},
"remappings": [
":@FreshCryptoLib/=lib/FreshCryptoLib/solidity/src/",
":@account-abstraction/=lib/account-abstraction/contracts/",
":@deployer/=lib/safe-singleton-deployer-sol/src/",
":@openzeppelin/=lib/openzeppelin-contracts/contracts/",
":@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
":@safe-contracts/=lib/safe-contracts/contracts/",
":FreshCryptoLib/=lib/FreshCryptoLib/solidity/src/",
":account-abstraction/=lib/account-abstraction/contracts/",
":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/",
":safe-contracts/=lib/safe-contracts/",
":safe-modules/=lib/safe-modules/",
":safe-singleton-deployer-sol/=lib/safe-singleton-deployer-sol/"
]
}
[{"inputs":[{"internalType":"address","name":"_factoryProxy","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_module","type":"address"},{"indexed":false,"internalType":"uint256","name":"_version","type":"uint256"}],"name":"SafeModuleSet","type":"event"},{"inputs":[],"name":"factoryProxy","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_hash","type":"bytes32"},{"internalType":"uint256","name":"_x","type":"uint256"},{"internalType":"uint256","name":"_y","type":"uint256"}],"name":"setupSafe","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]