编译器
0.8.24+commit.e11b9ed9
文件 1 的 9: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 的 9:IGuard.sol
pragma solidity =0.8.24;
import {Enum} from "./ISafe.sol";
interface IGuard {
function checkTransaction(
address to,
uint256 value,
bytes memory data,
Enum.Operation operation,
uint256 safeTxGas,
uint256 baseGas,
uint256 gasPrice,
address gasToken,
address payable refundReceiver,
bytes memory signatures,
address msgSender
) external;
function checkAfterExecution(bytes32 txHash, bool success) external;
}
文件 3 的 9:ISafe.sol
pragma solidity =0.8.24;
library Enum {
enum Operation {
Call,
DelegateCall
}
}
interface ISafe {
function getTransactionHash(
address to,
uint256 value,
bytes calldata data,
Enum.Operation operation,
uint256 safeTxGas,
uint256 baseGas,
uint256 gasPrice,
address gasToken,
address refundReceiver,
uint256 _nonce
) external view returns (bytes32);
function execTransaction(
address to,
uint256 value,
bytes calldata data,
Enum.Operation operation,
uint256 safeTxGas,
uint256 baseGas,
uint256 gasPrice,
address gasToken,
address payable refundReceiver,
bytes memory signatures
) external payable returns (bool success);
function execTransactionFromModule(address to, uint256 value, bytes memory data, Enum.Operation operation)
external
returns (bool success);
function setup(
address[] calldata _owners,
uint256 _threshold,
address to,
bytes calldata data,
address fallbackHandler,
address paymentToken,
uint256 payment,
address payable paymentReceiver
) external;
function enableModule(address module) external;
function disableModule(address prevModule, address module) external;
function setGuard(address guard) external;
function getGuard() external view returns (address);
function getOwners() external view returns (address[] memory);
function getThreshold() external view returns (uint256);
function isModuleEnabled(address module) external view returns (bool);
function nonce() external view returns (uint256);
function execute(address to, uint256 value, bytes memory data, Enum.Operation operation, uint256 txGas)
external
returns (bool success);
function domainSeparator() external view returns (bytes32);
function signedMessages(bytes32 messageHash) external returns (uint256);
function addOwnerWithThreshold(address owner, uint256 _threshold) external;
function isValidSignature(bytes32 _dataHash, bytes calldata _signature) external view returns (bytes4);
function isValidSignature(bytes calldata _data, bytes calldata _signature) external view returns (bytes4);
}
文件 4 的 9:ISafeProxyFactory.sol
pragma solidity =0.8.24;
interface ISafeProxyFactory {
function createProxyWithNonce(address _singleton, bytes memory _initializer, uint256 _saltNonce)
external
returns (address);
function proxyCreationCode() external pure returns (bytes memory);
}
文件 5 的 9:InitializationScript.sol
pragma solidity =0.8.24;
import {ISafe} from "./interfaces/external/ISafe.sol";
import {Enum} from "./interfaces/external/ISafe.sol";
import {RumpelGuard} from "./RumpelGuard.sol";
contract InitializationScript {
error InitializationFailed();
event InitialCall(address to, bytes data);
struct InitCall {
address to;
bytes data;
}
function initialize(address module, address guard, InitCall[] memory initCalls) external {
ISafe safe = ISafe(address(this));
safe.enableModule(module);
safe.setGuard(guard);
for (uint256 i = 0; i < initCalls.length; i++) {
address to = initCalls[i].to;
bytes memory data = initCalls[i].data;
RumpelGuard(guard).checkTransaction(
to, 0, data, Enum.Operation.Call, 0, 0, 0, address(0), payable(address(0)), bytes(""), address(0)
);
bool success;
assembly {
success := call(sub(gas(), 500), to, 0, add(data, 0x20), mload(data), 0, 0)
}
if (!success) revert InitializationFailed();
emit InitialCall(to, data);
}
}
}
文件 6 的 9: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);
}
}
文件 7 的 9:Pausable.sol
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
abstract contract Pausable is Context {
bool private _paused;
event Paused(address account);
event Unpaused(address account);
error EnforcedPause();
error ExpectedPause();
constructor() {
_paused = false;
}
modifier whenNotPaused() {
_requireNotPaused();
_;
}
modifier whenPaused() {
_requirePaused();
_;
}
function paused() public view virtual returns (bool) {
return _paused;
}
function _requireNotPaused() internal view virtual {
if (paused()) {
revert EnforcedPause();
}
}
function _requirePaused() internal view virtual {
if (!paused()) {
revert ExpectedPause();
}
}
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
文件 8 的 9:RumpelGuard.sol
pragma solidity =0.8.24;
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {Enum} from "./interfaces/external/ISafe.sol";
import {IGuard} from "./interfaces/external/IGuard.sol";
contract RumpelGuard is Ownable, IGuard {
mapping(address => mapping(bytes4 => AllowListState)) public allowedCalls;
address public immutable signMessageLib;
enum AllowListState {
OFF,
ON,
PERMANENTLY_ON
}
event SetCallAllowed(address indexed target, bytes4 indexed functionSelector, AllowListState allowListState);
error CallNotAllowed(address target, bytes4 functionSelector);
error PermanentlyOn();
constructor(address _signMessageLib) Ownable(msg.sender) {
signMessageLib = _signMessageLib;
}
function checkTransaction(
address to,
uint256,
bytes memory data,
Enum.Operation operation,
uint256,
uint256,
uint256,
address,
address payable,
bytes memory,
address
) external view {
if (data.length > 0 && data.length < 4) {
revert CallNotAllowed(to, bytes4(data));
}
bytes4 functionSelector = bytes4(data);
if (operation == Enum.Operation.DelegateCall) {
if (to == signMessageLib) {
return;
} else {
revert CallNotAllowed(to, functionSelector);
}
}
bool toSafe = msg.sender == to;
if (toSafe) {
if (allowedCalls[address(0)][functionSelector] == AllowListState.OFF) {
revert CallNotAllowed(to, functionSelector);
}
} else if (data.length == 0) {
if (allowedCalls[address(0)][bytes4(0)] == AllowListState.OFF) {
revert CallNotAllowed(address(0), bytes4(0));
}
} else {
if (allowedCalls[to][functionSelector] == AllowListState.OFF) {
revert CallNotAllowed(to, functionSelector);
}
}
}
function checkAfterExecution(bytes32, bool) external view {}
function supportsInterface(bytes4 interfaceId) public view returns (bool) {
return interfaceId == type(IGuard).interfaceId;
}
function setCallAllowed(address target, bytes4 functionSelector, AllowListState allowListState)
external
onlyOwner
{
if (allowedCalls[target][functionSelector] == AllowListState.PERMANENTLY_ON) {
revert PermanentlyOn();
}
allowedCalls[target][functionSelector] = allowListState;
emit SetCallAllowed(target, functionSelector, allowListState);
}
}
文件 9 的 9:RumpelWalletFactory.sol
pragma solidity =0.8.24;
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {Pausable} from "@openzeppelin/contracts/utils/Pausable.sol";
import {ISafe} from "./interfaces/external/ISafe.sol";
import {ISafeProxyFactory} from "./interfaces/external/ISafeProxyFactory.sol";
import {InitializationScript} from "./InitializationScript.sol";
contract RumpelWalletFactory is Ownable, Pausable {
mapping(address => uint256) public saltNonce;
ISafeProxyFactory public proxyFactory;
address public compatibilityFallback;
address public safeSingleton;
address public rumpelModule;
address public rumpelGuard;
address public initializationScript;
event SafeCreated(address indexed safe, address[] indexed owners, uint256 threshold);
event ParamChanged(bytes32 what, address data);
error UnrecognizedParam(bytes32 what);
constructor(
ISafeProxyFactory _proxyFactory,
address _compatibilityFallback,
address _safeSingleton,
address _rumpelModule,
address _rumpelGuard,
address _initializationScript
) Ownable(msg.sender) {
proxyFactory = _proxyFactory;
compatibilityFallback = _compatibilityFallback;
safeSingleton = _safeSingleton;
rumpelModule = _rumpelModule;
rumpelGuard = _rumpelGuard;
initializationScript = _initializationScript;
}
function createWallet(
address[] calldata owners,
uint256 threshold,
InitializationScript.InitCall[] calldata initCalls
) external whenNotPaused returns (address) {
uint256 salt = uint256(keccak256(abi.encodePacked(msg.sender, saltNonce[msg.sender]++)));
address safe = proxyFactory.createProxyWithNonce(
safeSingleton,
abi.encodeWithSelector(
ISafe.setup.selector,
owners,
threshold,
initializationScript,
abi.encodeWithSelector(InitializationScript.initialize.selector, rumpelModule, rumpelGuard, initCalls),
compatibilityFallback,
address(0),
0,
address(0)
),
salt
);
emit SafeCreated(safe, owners, threshold);
return safe;
}
function precomputeAddress(bytes memory _initializer, address _sender, uint256 _saltNonce)
external
view
returns (address)
{
bytes32 salt = keccak256(
abi.encodePacked(keccak256(_initializer), uint256(keccak256(abi.encodePacked(_sender, _saltNonce))))
);
bytes memory deploymentData =
abi.encodePacked(proxyFactory.proxyCreationCode(), uint256(uint160(safeSingleton)));
bytes32 deploymentHash =
keccak256(abi.encodePacked(bytes1(0xff), address(proxyFactory), salt, keccak256(deploymentData)));
return address(uint160(uint256(deploymentHash)));
}
function setParam(bytes32 what, address data) external onlyOwner {
if (what == "PROXY_FACTORY") proxyFactory = ISafeProxyFactory(data);
else if (what == "SAFE_SINGLETON") safeSingleton = data;
else if (what == "RUMPEL_MODULE") rumpelModule = data;
else if (what == "RUMPEL_GUARD") rumpelGuard = data;
else if (what == "INITIALIZATION_SCRIPT") initializationScript = data;
else if (what == "COMPATIBILITY_FALLBACK") compatibilityFallback = data;
else revert UnrecognizedParam(what);
emit ParamChanged(what, data);
}
function pauseWalletCreation() external onlyOwner {
_pause();
}
function unpauseWalletCreation() external onlyOwner {
_unpause();
}
}
{
"compilationTarget": {
"src/RumpelWalletFactory.sol": "RumpelWalletFactory"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [
":@openzeppelin/=lib/openzeppelin-contracts/",
":@openzeppelin/contracts-upgradeable/=lib/point-tokenization-vault/lib/openzeppelin-contracts-upgradeable/contracts/",
":@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
":create3-factory/=lib/point-tokenization-vault/lib/create3-factory/",
":ds-test/=lib/solmate/lib/ds-test/src/",
":erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
":forge-safe/=lib/point-tokenization-vault/lib/forge-safe/",
":forge-std/=lib/forge-std/src/",
":openzeppelin-contracts-upgradeable/=lib/point-tokenization-vault/lib/openzeppelin-contracts-upgradeable/",
":openzeppelin-contracts/=lib/openzeppelin-contracts/",
":openzeppelin-foundry-upgrades/=lib/point-tokenization-vault/lib/openzeppelin-foundry-upgrades/src/",
":point-tokenization-vault/=lib/point-tokenization-vault/contracts/",
":safe-smart-account/=safe-smart-account/",
":solady/=lib/point-tokenization-vault/lib/solady/src/",
":solidity-stringutils/=lib/point-tokenization-vault/lib/openzeppelin-foundry-upgrades/lib/solidity-stringutils/",
":solmate/=lib/solmate/src/",
":surl/=lib/point-tokenization-vault/lib/forge-safe/lib/surl/"
]
}
[{"inputs":[{"internalType":"contract ISafeProxyFactory","name":"_proxyFactory","type":"address"},{"internalType":"address","name":"_compatibilityFallback","type":"address"},{"internalType":"address","name":"_safeSingleton","type":"address"},{"internalType":"address","name":"_rumpelModule","type":"address"},{"internalType":"address","name":"_rumpelGuard","type":"address"},{"internalType":"address","name":"_initializationScript","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"bytes32","name":"what","type":"bytes32"}],"name":"UnrecognizedParam","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"what","type":"bytes32"},{"indexed":false,"internalType":"address","name":"data","type":"address"}],"name":"ParamChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"safe","type":"address"},{"indexed":true,"internalType":"address[]","name":"owners","type":"address[]"},{"indexed":false,"internalType":"uint256","name":"threshold","type":"uint256"}],"name":"SafeCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"compatibilityFallback","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"owners","type":"address[]"},{"internalType":"uint256","name":"threshold","type":"uint256"},{"components":[{"internalType":"address","name":"to","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct InitializationScript.InitCall[]","name":"initCalls","type":"tuple[]"}],"name":"createWallet","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initializationScript","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pauseWalletCreation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"_initializer","type":"bytes"},{"internalType":"address","name":"_sender","type":"address"},{"internalType":"uint256","name":"_saltNonce","type":"uint256"}],"name":"precomputeAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxyFactory","outputs":[{"internalType":"contract ISafeProxyFactory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rumpelGuard","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rumpelModule","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"safeSingleton","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"saltNonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"what","type":"bytes32"},{"internalType":"address","name":"data","type":"address"}],"name":"setParam","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpauseWalletCreation","outputs":[],"stateMutability":"nonpayable","type":"function"}]