编译器
0.8.26+commit.8a97fa7a
文件 1 的 27:Address.sol
pragma solidity ^0.8.20;
library Address {
error AddressInsufficientBalance(address account);
error AddressEmptyCode(address target);
error FailedInnerCall();
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
function _revert(bytes memory returndata) private pure {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert FailedInnerCall();
}
}
}
文件 2 的 27:Cast.sol
pragma solidity ^0.8.20;
library Cast {
function _toBytes32(address value) internal pure returns (bytes32) {
return bytes32(uint256(uint160(value)));
}
}
文件 3 的 27: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;
}
}
文件 4 的 27:ControlCenter.sol
pragma solidity ^0.8.20;
import {IERC165} from "@openzeppelin/contracts/interfaces/IERC165.sol";
import {ControlCenterEventUtils} from "./ControlCenterEventUtils.sol";
import {Errors} from "../error/Errors.sol";
import {IControlCenter} from "../interfaces/IControlCenter.sol";
import {EventEmitter} from "../event/EventEmitter.sol";
import {IKnightSafeAnalyser} from "../interfaces/IKnightSafeAnalyser.sol";
import {SettingSelectors} from "../setting/SettingUtils.sol";
contract ControlCenter is IControlCenter, EventEmitter {
string public constant override VERSION = "0.0.0";
struct AccountLimit {
uint256 dailyLimit;
uint256 dailyLimitExpiryDate;
uint256 volume;
uint256 volumeExpiryDate;
}
mapping(address => bool) private _adminMap;
address private _priceFeed;
uint256 public baseTradingVolume = 100_000 * (10 ** 30);
uint256 public _minPolicyAllowed = 3;
mapping(address => AccountLimit) private _tradingLimitMap;
mapping(address => bytes32) private _controlCenterVersionMap;
mapping(address => bytes32) private _knightSafeVersionMap;
mapping(address => bytes32) private _analyserVersionMap;
mapping(address => bool) private _spendingLimitMap;
mapping(address => uint256) private _maxPolicyAllowedMap;
bytes4[8] private _adminEventAccess = [
SettingSelectors.CREATE_POLICY,
SettingSelectors.UPDATE_WHITELIST,
SettingSelectors.ADD_TRADER,
SettingSelectors.REMOVE_POLICY,
SettingSelectors.REMOVE_TRADER,
SettingSelectors.REMOVE_WHITELIST,
SettingSelectors.INCREASE_SPENDING_LIMIT,
SettingSelectors.RESET_SPENDING_LIMIT
];
constructor(address owner) EventEmitter(owner) {
_adminMap[owner] = true;
_analyserVersionMap[address(0)] = "0x0";
_analyserVersionMap[address(1)] = "0x1";
}
modifier onlyAdmin() {
if (owner() != _msgSender() && !_checkAdmin()) revert Errors.Unauthorized(_msgSender(), "ADMIN");
_;
}
function _checkAdmin() private view returns (bool) {
return _adminMap[_msgSender()];
}
function setAdmin(address admin, bool isAdmin) public onlyOwner {
_adminMap[admin] = isAdmin;
ControlCenterEventUtils.emitSetAdmin(this, admin, isAdmin);
}
function isOfficialControlCenter(address controlCenterAddress) public view returns (bool) {
return _controlCenterVersionMap[controlCenterAddress] != 0;
}
function addOfficialControlCenter(address controlCenterAddress, bytes32 version) public onlyOwner {
if (isOfficialControlCenter(controlCenterAddress)) revert Errors.AddressAlreadyExist(controlCenterAddress);
if (version == 0) revert Errors.IsNullValue();
_controlCenterVersionMap[controlCenterAddress] = version;
ControlCenterEventUtils.emitAddedOfficialControlCenter(this, controlCenterAddress, version);
}
function removeOfficialControlCenter(address controlCenterAddress) public onlyOwner {
if (!isOfficialControlCenter(controlCenterAddress)) revert Errors.AddressNotExist(controlCenterAddress);
_controlCenterVersionMap[controlCenterAddress] = 0;
ControlCenterEventUtils.emitRemovedOfficialControlCenter(this, controlCenterAddress);
}
function isOfficialImplementation(address implementationAddress) public view returns (bool) {
return _knightSafeVersionMap[implementationAddress] != 0;
}
function addOfficialImplementation(address implementationAddress, bytes32 version) public onlyOwner {
if (isOfficialImplementation(implementationAddress)) revert Errors.AddressAlreadyExist(implementationAddress);
if (version == 0) revert Errors.IsNullValue();
_knightSafeVersionMap[implementationAddress] = version;
ControlCenterEventUtils.emitAddedOfficialImplementation(this, implementationAddress, version);
}
function removeOfficialImplementation(address implementationAddress) public onlyOwner {
if (!isOfficialImplementation(implementationAddress)) revert Errors.AddressNotExist(implementationAddress);
_knightSafeVersionMap[implementationAddress] = 0;
ControlCenterEventUtils.emitRemovedOfficialImplementation(this, implementationAddress);
}
function isOfficialAnalyser(address analyserAddress) public view returns (bool) {
return _analyserVersionMap[analyserAddress] != 0;
}
function addOfficialAnalyser(address analyserAddress, bytes32 version) public onlyAdmin {
if (isOfficialAnalyser(analyserAddress)) revert Errors.AddressAlreadyExist(analyserAddress);
if (version == 0) revert Errors.IsNullValue();
if (!_isKnightSafeAnalyser(analyserAddress)) {
revert Errors.InterfaceNotSupport(analyserAddress);
}
_analyserVersionMap[analyserAddress] = version;
ControlCenterEventUtils.emitAddedOfficialAnalyser(this, analyserAddress, version);
}
function removeOfficialAnalyser(address analyserAddress) public onlyAdmin {
if (!isOfficialAnalyser(analyserAddress)) revert Errors.AddressNotExist(analyserAddress);
_analyserVersionMap[analyserAddress] = 0;
ControlCenterEventUtils.emitRemoveOfficialAnalyser(this, analyserAddress);
}
function isSpendingLimitEnabled(address knightSafeAddress) public view returns (bool) {
return _spendingLimitMap[knightSafeAddress];
}
function setSpendingLimitEnabled(address knightSafeAddress, bool isEnabled) public onlyAdmin {
_spendingLimitMap[knightSafeAddress] = isEnabled;
ControlCenterEventUtils.emitSetSpendingLimitEnabled(this, knightSafeAddress, isEnabled);
}
function getMaxPolicyAllowed(address knightSafeAddress) public view returns (uint256) {
return _maxPolicyAllowedMap[knightSafeAddress] > _minPolicyAllowed
? _maxPolicyAllowedMap[knightSafeAddress]
: _minPolicyAllowed;
}
function setMaxPolicyAllowed(address knightSafeAddress, uint256 maxPolicyAllowed) public onlyAdmin {
_maxPolicyAllowedMap[knightSafeAddress] = maxPolicyAllowed;
ControlCenterEventUtils.emitSetMaxPolicyAllowed(this, knightSafeAddress, maxPolicyAllowed);
}
function setGlobalMinPolicyAllowed(uint256 minPolicyAllowed) public onlyOwner {
_minPolicyAllowed = minPolicyAllowed;
ControlCenterEventUtils.emitSetGlobalMinPolicyAllowed(this, minPolicyAllowed);
}
function getAdminEventAccess() external view returns (bytes4[] memory) {
bytes4[] memory eventList = new bytes4[](_adminEventAccess.length);
for (uint256 i = 0; i < _adminEventAccess.length; i++) {
eventList[i] = _adminEventAccess[i];
}
return eventList;
}
function getAdminEventAccessCount() external view returns (uint256) {
return _adminEventAccess.length;
}
function getAdminEventAccessById(uint8 id) public view returns (bytes4) {
return _adminEventAccess[id];
}
function _isKnightSafeAnalyser(address _address) internal view returns (bool) {
bytes memory encodedParams = abi.encodeCall(IERC165.supportsInterface, (type(IKnightSafeAnalyser).interfaceId));
bool success;
uint256 returnSize;
uint256 returnValue;
assembly {
success := staticcall(30000, _address, add(encodedParams, 0x20), mload(encodedParams), 0x00, 0x20)
returnSize := returndatasize()
returnValue := mload(0x00)
}
return success && returnSize >= 0x20 && returnValue > 0;
}
function setPriceFeed(address priceFeed) public onlyOwner {
isKnightSafe[_priceFeed] = false;
_priceFeed = priceFeed;
isKnightSafe[priceFeed] = true;
ControlCenterEventUtils.emitSetPriceFeed(this, priceFeed);
}
function getPriceFeed() public view returns (address) {
return _priceFeed;
}
function setBaseVolume(uint256 volume) public onlyOwner {
if (volume == 0) revert Errors.IsNullValue();
baseTradingVolume = volume;
ControlCenterEventUtils.emitSetBaseLimit(this, volume);
}
function getDailyVolume(address knightSafeAddress) public view returns (uint256) {
if (
_tradingLimitMap[knightSafeAddress].dailyLimitExpiryDate < block.timestamp
|| _tradingLimitMap[knightSafeAddress].dailyLimit < baseTradingVolume
) {
return baseTradingVolume;
}
return _tradingLimitMap[knightSafeAddress].dailyLimit;
}
function setDailyVolume(address knightSafeAddress, uint256 volume) public onlyAdmin {
_tradingLimitMap[knightSafeAddress].dailyLimit = volume;
ControlCenterEventUtils.emitSetDailyLimit(this, knightSafeAddress, volume);
}
function setDailyVolumeExpiryDate(address knightSafeAddress, uint256 expiryDate) public onlyAdmin {
_tradingLimitMap[knightSafeAddress].dailyLimitExpiryDate = expiryDate;
ControlCenterEventUtils.emitSetDailyLimitExpiry(this, knightSafeAddress, expiryDate);
}
function setMaxTradingVolume(address knightSafeAddress, uint256 volume) public onlyAdmin {
_tradingLimitMap[knightSafeAddress].volume = volume;
ControlCenterEventUtils.emitSetMaxTradingVolume(this, knightSafeAddress, volume);
}
function setMaxTradingVolumeExpiryDate(address knightSafeAddress, uint256 expiryDate) public onlyAdmin {
_tradingLimitMap[knightSafeAddress].volumeExpiryDate = expiryDate;
ControlCenterEventUtils.emitSetMaxTradingVolumeExpiry(this, knightSafeAddress, expiryDate);
}
function getMaxTradingVolume(address knightSafeAddress) public view returns (uint256) {
if (_tradingLimitMap[knightSafeAddress].volumeExpiryDate < block.timestamp) {
return 0;
}
return _tradingLimitMap[knightSafeAddress].volume;
}
function getMaxVolumeExpiryDate(address knightSafeAddress) public view returns (uint256) {
return _tradingLimitMap[knightSafeAddress].volumeExpiryDate;
}
}
文件 5 的 27:ControlCenterEventUtils.sol
pragma solidity ^0.8.20;
import {EventUtils} from "../event/EventUtils.sol";
import {EventEmitter} from "../event/EventEmitter.sol";
import {Cast} from "../utils/Cast.sol";
library ControlCenterEventUtils {
using EventUtils for EventUtils.AddressItems;
using EventUtils for EventUtils.UintItems;
using EventUtils for EventUtils.BytesItems;
using EventUtils for EventUtils.Bytes32Items;
using EventUtils for EventUtils.BoolItems;
function emitSetAdmin(EventEmitter eventEmitter, address _admin, bool _isAdmin) external {
EventUtils.EventLogData memory eventData;
eventData.addressItems.initItems(1);
eventData.addressItems.setItem(0, "admin", _admin);
eventData.boolItems.initItems(1);
eventData.boolItems.setItem(0, "isAdmin", _isAdmin);
eventEmitter.emitEventLog1("SetAdmin", Cast._toBytes32(_admin), eventData);
}
function emitAddedOfficialControlCenter(EventEmitter eventEmitter, address controlCenterAddress, bytes32 version)
external
{
EventUtils.EventLogData memory eventData;
eventData.bytes32Items.initItems(1);
eventData.bytes32Items.setItem(0, "version", version);
eventEmitter.emitEventLog1("AddedOfficialControlCenter", Cast._toBytes32(controlCenterAddress), eventData);
}
function emitRemovedOfficialControlCenter(EventEmitter eventEmitter, address controlCenterAddress) external {
EventUtils.EventLogData memory eventData;
eventEmitter.emitEventLog1("RemovedOfficialControlCenter", Cast._toBytes32(controlCenterAddress), eventData);
}
function emitAddedOfficialImplementation(EventEmitter eventEmitter, address implementationAddress, bytes32 version)
external
{
EventUtils.EventLogData memory eventData;
eventData.bytes32Items.initItems(1);
eventData.bytes32Items.setItem(0, "version", version);
eventEmitter.emitEventLog1("AddedOfficialImplementation", Cast._toBytes32(implementationAddress), eventData);
}
function emitRemovedOfficialImplementation(EventEmitter eventEmitter, address implementationAddress) external {
EventUtils.EventLogData memory eventData;
eventEmitter.emitEventLog1("RemovedOfficialImplementation", Cast._toBytes32(implementationAddress), eventData);
}
function emitAddedOfficialAnalyser(EventEmitter eventEmitter, address analyser, bytes32 version) external {
EventUtils.EventLogData memory eventData;
eventData.bytes32Items.initItems(1);
eventData.bytes32Items.setItem(0, "version", version);
eventEmitter.emitEventLog1("AddedOfficialAnalyser", Cast._toBytes32(analyser), eventData);
}
function emitRemoveOfficialAnalyser(EventEmitter eventEmitter, address analyser) external {
EventUtils.EventLogData memory eventData;
eventEmitter.emitEventLog1("RemoveOfficialAnalyser", Cast._toBytes32(analyser), eventData);
}
function emitSetSpendingLimitEnabled(EventEmitter eventEmitter, address knightSafeAddress, bool _isSpendingLimit)
external
{
EventUtils.EventLogData memory eventData;
eventData.addressItems.initItems(1);
eventData.addressItems.setItem(0, "knightSafeAddress", knightSafeAddress);
eventData.boolItems.initItems(1);
eventData.boolItems.setItem(0, "isSpendingLimit", _isSpendingLimit);
eventEmitter.emitEventLog1("SetSpendingLimitEnabled", Cast._toBytes32(knightSafeAddress), eventData);
}
function emitSetMaxPolicyAllowed(EventEmitter eventEmitter, address knightSafeAddress, uint256 _maxPolicyAllowed)
external
{
EventUtils.EventLogData memory eventData;
eventData.addressItems.initItems(1);
eventData.addressItems.setItem(0, "knightSafeAddress", knightSafeAddress);
eventData.uintItems.initItems(1);
eventData.uintItems.setItem(0, "maxPolicyAllowed", _maxPolicyAllowed);
eventEmitter.emitEventLog1("SetMaxPolicyAllowed", Cast._toBytes32(knightSafeAddress), eventData);
}
function emitSetGlobalMinPolicyAllowed(EventEmitter eventEmitter, uint256 _maxPolicyAllowed) external {
EventUtils.EventLogData memory eventData;
eventData.uintItems.initItems(1);
eventData.uintItems.setItem(0, "maxPolicyAllowed", _maxPolicyAllowed);
eventEmitter.emitEventLog("SetGlobalMinPolicyAllowed", eventData);
}
function emitSetPriceFeed(EventEmitter eventEmitter, address priceFeed) external {
EventUtils.EventLogData memory eventData;
eventData.addressItems.initItems(1);
eventData.addressItems.setItem(0, "priceFeed", priceFeed);
eventEmitter.emitEventLog("SetPriceFeed", eventData);
}
function emitSetBaseLimit(EventEmitter eventEmitter, uint256 volume) external {
EventUtils.EventLogData memory eventData;
eventData.uintItems.initItems(1);
eventData.uintItems.setItem(0, "baseLimit", volume);
eventEmitter.emitEventLog1("SetBaseLimit", Cast._toBytes32(msg.sender), eventData);
}
function emitSetDailyLimit(EventEmitter eventEmitter, address knightSafeAddress, uint256 volume) external {
EventUtils.EventLogData memory eventData;
eventData.addressItems.initItems(1);
eventData.addressItems.setItem(0, "knightSafeAddress", knightSafeAddress);
eventData.uintItems.initItems(1);
eventData.uintItems.setItem(0, "dailyLimit", volume);
eventEmitter.emitEventLog1("SetDailyLimit", Cast._toBytes32(knightSafeAddress), eventData);
}
function emitSetDailyLimitExpiry(EventEmitter eventEmitter, address knightSafeAddress, uint256 expirationDate)
external
{
EventUtils.EventLogData memory eventData;
eventData.addressItems.initItems(1);
eventData.addressItems.setItem(0, "knightSafeAddress", knightSafeAddress);
eventData.uintItems.initItems(1);
eventData.uintItems.setItem(0, "expirationDate", expirationDate);
eventEmitter.emitEventLog1("SetDailyLimitExpiry", Cast._toBytes32(knightSafeAddress), eventData);
}
function emitSetMaxTradingVolume(EventEmitter eventEmitter, address knightSafeAddress, uint256 maxTradingVolume)
external
{
EventUtils.EventLogData memory eventData;
eventData.addressItems.initItems(1);
eventData.addressItems.setItem(0, "knightSafeAddress", knightSafeAddress);
eventData.uintItems.initItems(1);
eventData.uintItems.setItem(0, "maxTradingVolume", maxTradingVolume);
eventEmitter.emitEventLog1("SetMaxTradingVolume", Cast._toBytes32(knightSafeAddress), eventData);
}
function emitSetMaxTradingVolumeExpiry(EventEmitter eventEmitter, address knightSafeAddress, uint256 expirationDate)
external
{
EventUtils.EventLogData memory eventData;
eventData.addressItems.initItems(1);
eventData.addressItems.setItem(0, "knightSafeAddress", knightSafeAddress);
eventData.uintItems.initItems(1);
eventData.uintItems.setItem(0, "expirationDate", expirationDate);
eventEmitter.emitEventLog1("SetMaxTradingVolumeExpiry", Cast._toBytes32(knightSafeAddress), eventData);
}
}
文件 6 的 27:ControlCenterManager.sol
pragma solidity ^0.8.20;
import {ControlCenter} from "../controlCenter/ControlCenter.sol";
import {Errors} from "../error/Errors.sol";
import "../common/TokenCallbackHandler.sol";
abstract contract ControlCenterManager {
ControlCenter internal _controlCenter;
function _setControlCenter(address addr) internal {
if (addr == address(0)) revert Errors.InvalidAddress(addr);
_controlCenter = ControlCenter(addr);
}
function getControlCenter() public view returns (address) {
return address(_controlCenter);
}
}
文件 7 的 27:ERC1967Utils.sol
pragma solidity ^0.8.20;
import {IBeacon} from "../beacon/IBeacon.sol";
import {Address} from "../../utils/Address.sol";
import {StorageSlot} from "../../utils/StorageSlot.sol";
library ERC1967Utils {
event Upgraded(address indexed implementation);
event AdminChanged(address previousAdmin, address newAdmin);
event BeaconUpgraded(address indexed beacon);
bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
error ERC1967InvalidImplementation(address implementation);
error ERC1967InvalidAdmin(address admin);
error ERC1967InvalidBeacon(address beacon);
error ERC1967NonPayable();
function getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;
}
function _setImplementation(address newImplementation) private {
if (newImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(newImplementation);
}
StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;
}
function upgradeToAndCall(address newImplementation, bytes memory data) internal {
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
if (data.length > 0) {
Address.functionDelegateCall(newImplementation, data);
} else {
_checkNonPayable();
}
}
bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
function getAdmin() internal view returns (address) {
return StorageSlot.getAddressSlot(ADMIN_SLOT).value;
}
function _setAdmin(address newAdmin) private {
if (newAdmin == address(0)) {
revert ERC1967InvalidAdmin(address(0));
}
StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;
}
function changeAdmin(address newAdmin) internal {
emit AdminChanged(getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
function getBeacon() internal view returns (address) {
return StorageSlot.getAddressSlot(BEACON_SLOT).value;
}
function _setBeacon(address newBeacon) private {
if (newBeacon.code.length == 0) {
revert ERC1967InvalidBeacon(newBeacon);
}
StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;
address beaconImplementation = IBeacon(newBeacon).implementation();
if (beaconImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(beaconImplementation);
}
}
function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {
_setBeacon(newBeacon);
emit BeaconUpgraded(newBeacon);
if (data.length > 0) {
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
} else {
_checkNonPayable();
}
}
function _checkNonPayable() private {
if (msg.value > 0) {
revert ERC1967NonPayable();
}
}
}
文件 8 的 27:Errors.sol
pragma solidity ^0.8.20;
library Errors {
error FailedDeployment();
error InvalidOperation();
error Unauthorized(address msgSender, string role);
error InvalidAddress(address _address);
error AddressAlreadyExist(address _address);
error AddressNotExist(address _address);
error IsNullValue();
error InvalidLength();
error InvalidValue();
error PolicyNotExist(uint256 policyId);
error MaxPolicyCountReached(uint256 maxPolicyCount);
error InvalidTakeoverStatus(bool inProgress);
error TakeoverIsNotReady();
error InvalidReqId(uint256 reqId);
error InvalidTransactionStatus();
error InvalidSettingStatus();
error InterfaceNotSupport(address _address);
error AddressIsNotKnightSafeImplementation(address _address);
error AddressIsNotKnightSafeAnalyser(address _address);
error AddressIsReadOnlyWhitelist(uint256 policyId, address _address);
error AddressNotInWhitelist(uint256 policyId, address _address);
error SelectorNotSupport();
error ExceedMaxTradingVolume(uint256 txnVolume, uint256 maxVolume);
error ExceedPolicyVolume(uint256 policyId, uint256 volume);
error ExecutionFailed();
error ExecutionFailedWith(bytes data);
error FeatureNotSupport(string plan);
}
文件 9 的 27:EventEmitter.sol
pragma solidity ^0.8.20;
import {Context} from "@openzeppelin/contracts/utils/Context.sol";
import {Ownable2Step, Ownable} from "@openzeppelin/contracts/access/Ownable2Step.sol";
import {Errors} from "../error/Errors.sol";
import {IEventEmitter, EventUtils} from "../interfaces/IEventEmitter.sol";
abstract contract EventEmitter is IEventEmitter, Context, Ownable2Step {
mapping(address => bool) private _factory;
mapping(address => bool) internal isKnightSafe;
constructor(address owner) Ownable(owner) {}
modifier onlyKnightSafe() {
if (!isActiveAccount(_msgSender()) && !isFactory(_msgSender()) && _msgSender() != address(this)) {
revert Errors.Unauthorized(_msgSender(), "KNIGHTSAFE");
}
_;
}
function isFactory(address sender) public view returns (bool) {
return _factory[sender];
}
function setFactory(address factory) public onlyOwner {
_factory[factory] = true;
}
function disableFactory(address factory) public onlyOwner {
_factory[factory] = false;
}
function isActiveAccount(address sender) public view returns (bool) {
return isKnightSafe[sender];
}
function setActiveAccount(address sender) public {
if (!isFactory(_msgSender())) {
revert Errors.Unauthorized(_msgSender(), "FACTORY");
}
isKnightSafe[sender] = true;
}
function disableActiveAccount(address sender) public onlyOwner {
isKnightSafe[sender] = false;
}
function emitEventLog(string memory eventName, EventUtils.EventLogData memory eventData) external onlyKnightSafe {
emit EventLog((address(_msgSender())), eventName, eventName, eventData);
}
function emitEventLog1(string memory eventName, bytes32 profile, EventUtils.EventLogData memory eventData)
external
onlyKnightSafe
{
emit EventLog1((address(_msgSender())), eventName, eventName, profile, eventData);
}
function emitEventLog2(
string memory eventName,
bytes32 profile,
bytes32 topic2,
EventUtils.EventLogData memory eventData
) external onlyKnightSafe {
emit EventLog2((address(_msgSender())), eventName, eventName, profile, topic2, eventData);
}
function emitTransactionEventLog(string memory eventName, bytes32 profile, uint256 reqId) external onlyKnightSafe {
emit TransactionEventLog((address(_msgSender())), eventName, eventName, profile, reqId);
}
function emitSettingEventLog(string memory eventName, bytes32 profile, uint256 reqId) external onlyKnightSafe {
emit SettingEventLog((address(_msgSender())), eventName, eventName, profile, reqId);
}
function renounceOwnership() public virtual override onlyOwner {
}
}
文件 10 的 27:EventUtils.sol
pragma solidity ^0.8.0;
library EventUtils {
struct EventLogData {
AddressItems addressItems;
UintItems uintItems;
IntItems intItems;
BoolItems boolItems;
Bytes32Items bytes32Items;
BytesItems bytesItems;
StringItems stringItems;
}
struct AddressItems {
AddressKeyValue[] items;
AddressArrayKeyValue[] arrayItems;
}
struct UintItems {
UintKeyValue[] items;
UintArrayKeyValue[] arrayItems;
}
struct IntItems {
IntKeyValue[] items;
IntArrayKeyValue[] arrayItems;
}
struct BoolItems {
BoolKeyValue[] items;
BoolArrayKeyValue[] arrayItems;
}
struct Bytes32Items {
Bytes32KeyValue[] items;
Bytes32ArrayKeyValue[] arrayItems;
}
struct BytesItems {
BytesKeyValue[] items;
BytesArrayKeyValue[] arrayItems;
}
struct StringItems {
StringKeyValue[] items;
StringArrayKeyValue[] arrayItems;
}
struct AddressKeyValue {
string key;
address value;
}
struct AddressArrayKeyValue {
string key;
address[] value;
}
struct UintKeyValue {
string key;
uint256 value;
}
struct UintArrayKeyValue {
string key;
uint256[] value;
}
struct IntKeyValue {
string key;
int256 value;
}
struct IntArrayKeyValue {
string key;
int256[] value;
}
struct BoolKeyValue {
string key;
bool value;
}
struct BoolArrayKeyValue {
string key;
bool[] value;
}
struct Bytes32KeyValue {
string key;
bytes32 value;
}
struct Bytes32ArrayKeyValue {
string key;
bytes32[] value;
}
struct BytesKeyValue {
string key;
bytes value;
}
struct BytesArrayKeyValue {
string key;
bytes[] value;
}
struct StringKeyValue {
string key;
string value;
}
struct StringArrayKeyValue {
string key;
string[] value;
}
function initItems(AddressItems memory items, uint256 size) internal pure {
items.items = new EventUtils.AddressKeyValue[](size);
}
function initArrayItems(AddressItems memory items, uint256 size) internal pure {
items.arrayItems = new EventUtils.AddressArrayKeyValue[](size);
}
function setItem(AddressItems memory items, uint256 index, string memory key, address value) internal pure {
items.items[index].key = key;
items.items[index].value = value;
}
function setItem(AddressItems memory items, uint256 index, string memory key, address[] memory value)
internal
pure
{
items.arrayItems[index].key = key;
items.arrayItems[index].value = value;
}
function initItems(UintItems memory items, uint256 size) internal pure {
items.items = new EventUtils.UintKeyValue[](size);
}
function initArrayItems(UintItems memory items, uint256 size) internal pure {
items.arrayItems = new EventUtils.UintArrayKeyValue[](size);
}
function setItem(UintItems memory items, uint256 index, string memory key, uint256 value) internal pure {
items.items[index].key = key;
items.items[index].value = value;
}
function setItem(UintItems memory items, uint256 index, string memory key, uint256[] memory value) internal pure {
items.arrayItems[index].key = key;
items.arrayItems[index].value = value;
}
function initItems(IntItems memory items, uint256 size) internal pure {
items.items = new EventUtils.IntKeyValue[](size);
}
function initArrayItems(IntItems memory items, uint256 size) internal pure {
items.arrayItems = new EventUtils.IntArrayKeyValue[](size);
}
function setItem(IntItems memory items, uint256 index, string memory key, int256 value) internal pure {
items.items[index].key = key;
items.items[index].value = value;
}
function setItem(IntItems memory items, uint256 index, string memory key, int256[] memory value) internal pure {
items.arrayItems[index].key = key;
items.arrayItems[index].value = value;
}
function initItems(BoolItems memory items, uint256 size) internal pure {
items.items = new EventUtils.BoolKeyValue[](size);
}
function initArrayItems(BoolItems memory items, uint256 size) internal pure {
items.arrayItems = new EventUtils.BoolArrayKeyValue[](size);
}
function setItem(BoolItems memory items, uint256 index, string memory key, bool value) internal pure {
items.items[index].key = key;
items.items[index].value = value;
}
function setItem(BoolItems memory items, uint256 index, string memory key, bool[] memory value) internal pure {
items.arrayItems[index].key = key;
items.arrayItems[index].value = value;
}
function initItems(Bytes32Items memory items, uint256 size) internal pure {
items.items = new EventUtils.Bytes32KeyValue[](size);
}
function initArrayItems(Bytes32Items memory items, uint256 size) internal pure {
items.arrayItems = new EventUtils.Bytes32ArrayKeyValue[](size);
}
function setItem(Bytes32Items memory items, uint256 index, string memory key, bytes32 value) internal pure {
items.items[index].key = key;
items.items[index].value = value;
}
function setItem(Bytes32Items memory items, uint256 index, string memory key, bytes32[] memory value)
internal
pure
{
items.arrayItems[index].key = key;
items.arrayItems[index].value = value;
}
function initItems(BytesItems memory items, uint256 size) internal pure {
items.items = new EventUtils.BytesKeyValue[](size);
}
function initArrayItems(BytesItems memory items, uint256 size) internal pure {
items.arrayItems = new EventUtils.BytesArrayKeyValue[](size);
}
function setItem(BytesItems memory items, uint256 index, string memory key, bytes memory value) internal pure {
items.items[index].key = key;
items.items[index].value = value;
}
function setItem(BytesItems memory items, uint256 index, string memory key, bytes[] memory value) internal pure {
items.arrayItems[index].key = key;
items.arrayItems[index].value = value;
}
function initItems(StringItems memory items, uint256 size) internal pure {
items.items = new EventUtils.StringKeyValue[](size);
}
function initArrayItems(StringItems memory items, uint256 size) internal pure {
items.arrayItems = new EventUtils.StringArrayKeyValue[](size);
}
function setItem(StringItems memory items, uint256 index, string memory key, string memory value) internal pure {
items.items[index].key = key;
items.items[index].value = value;
}
function setItem(StringItems memory items, uint256 index, string memory key, string[] memory value) internal pure {
items.arrayItems[index].key = key;
items.arrayItems[index].value = value;
}
}
文件 11 的 27:IBeacon.sol
pragma solidity ^0.8.20;
interface IBeacon {
function implementation() external view returns (address);
}
文件 12 的 27:IControlCenter.sol
pragma solidity ^0.8.20;
import "./IEventEmitter.sol";
interface IControlCenter is IEventEmitter {
function VERSION() external view returns (string memory);
function setAdmin(address admin, bool isAdmin) external;
function isOfficialControlCenter(address controlCenterAddress) external view returns (bool);
function addOfficialControlCenter(address controlCenterAddress, bytes32 version) external;
function removeOfficialControlCenter(address controlCenterAddress) external;
function isOfficialImplementation(address implementationAddress) external view returns (bool);
function addOfficialImplementation(address implementationAddress, bytes32 version) external;
function removeOfficialImplementation(address implementationAddress) external;
function isOfficialAnalyser(address analyserAddress) external view returns (bool);
function addOfficialAnalyser(address analyserAddress, bytes32 version) external;
function removeOfficialAnalyser(address analyserAddress) external;
function getMaxPolicyAllowed(address knightSafeAddress) external view returns (uint256);
function setMaxPolicyAllowed(address knightSafeAddress, uint256 maxPolicyAllowed) external;
function setGlobalMinPolicyAllowed(uint256 minPolicyAllowed) external;
function getAdminEventAccess() external view returns (bytes4[] memory);
function getAdminEventAccessCount() external view returns (uint256);
function getAdminEventAccessById(uint8 id) external view returns (bytes4);
function isSpendingLimitEnabled(address knightSafeAddress) external view returns (bool);
function setSpendingLimitEnabled(address knightSafeAddress, bool isEnabled) external;
function getPriceFeed() external view returns (address);
function setPriceFeed(address priceFeed) external;
function setBaseVolume(uint256 volume) external;
function getDailyVolume(address knightSafeAddress) external view returns (uint256);
function setDailyVolume(address knightSafeAddress, uint256 volume) external;
function setDailyVolumeExpiryDate(address knightSafeAddress, uint256 expiryDate) external;
function getMaxTradingVolume(address knightSafeAddress) external view returns (uint256);
function getMaxVolumeExpiryDate(address knightSafeAddress) external view returns (uint256);
function setMaxTradingVolume(address knightSafeAddress, uint256 volume) external;
function setMaxTradingVolumeExpiryDate(address knightSafeAddress, uint256 expiryDate) external;
}
文件 13 的 27:IERC1155Receiver.sol
pragma solidity ^0.8.20;
import {IERC1155Receiver} from "../token/ERC1155/IERC1155Receiver.sol";
文件 14 的 27:IERC165.sol
pragma solidity ^0.8.20;
import {IERC165} from "../utils/introspection/IERC165.sol";
文件 15 的 27:IERC721Receiver.sol
pragma solidity ^0.8.20;
interface IERC721Receiver {
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
文件 16 的 27:IERC777Recipient.sol
pragma solidity ^0.8.20;
interface IERC777Recipient {
function tokensReceived(
address operator,
address from,
address to,
uint256 amount,
bytes calldata userData,
bytes calldata operatorData
) external;
}
文件 17 的 27:IEventEmitter.sol
pragma solidity ^0.8.20;
import "../event/EventUtils.sol";
import "../transaction/Transaction.sol";
import "../setting/SettingUtils.sol";
interface IEventEmitter {
event TransactionEventLog(
address msgSender, string eventName, string indexed eventNameHash, bytes32 indexed profile, uint256 reqId
);
event SettingEventLog(
address msgSender, string eventName, string indexed eventNameHash, bytes32 indexed profile, uint256 reqId
);
event EventLog(
address msgSender, string eventName, string indexed eventNameHash, EventUtils.EventLogData eventData
);
event EventLog1(
address msgSender,
string eventName,
string indexed eventNameHash,
bytes32 indexed profile,
EventUtils.EventLogData eventData
);
event EventLog2(
address msgSender,
string eventName,
string indexed eventNameHash,
bytes32 indexed profile,
bytes32 indexed topic2,
EventUtils.EventLogData eventData
);
function isFactory(address sender) external view returns (bool);
function setFactory(address factory) external;
function disableFactory(address factory) external;
function isActiveAccount(address sender) external view returns (bool);
function setActiveAccount(address sender) external;
function disableActiveAccount(address sender) external;
function emitEventLog(string memory eventName, EventUtils.EventLogData memory eventData) external;
function emitEventLog1(string memory eventName, bytes32 profile, EventUtils.EventLogData memory eventData)
external;
function emitEventLog2(
string memory eventName,
bytes32 profile,
bytes32 topic2,
EventUtils.EventLogData memory eventData
) external;
function emitTransactionEventLog(string memory eventName, bytes32 profile, uint256 reqId) external;
function emitSettingEventLog(string memory eventName, bytes32 profile, uint256 reqId) external;
}
文件 18 的 27:IKnightSafeAnalyser.sol
pragma solidity ^0.8.20;
interface IKnightSafeAnalyser {
function extractAddressesWithValue(address to, bytes memory data)
external
view
returns (address[] memory, uint256[] memory);
}
文件 19 的 27:IOwnerManager.sol
pragma solidity ^0.8.20;
interface IOwnerManager {
function getOwner() external view returns (address);
function setBackupOwner(address backupOwner, uint256 takeoverDelayIsSecond) external;
function getIsTakeoverInProgress() external view returns (bool);
function getTakeoverTimestamp() external view returns (uint256);
function getTakeoverStatus() external view returns (address, bool, uint256, uint256);
function requestTakeover() external;
function confirmTakeover() external;
function instantTakeover() external;
function revokeTakeover() external;
function getAdmins() external view returns (address[] memory);
function isAdmin(address admin) external view returns (bool);
function addAdmin(address admin) external;
function removeAdmin(address admin) external;
}
文件 20 的 27:KnightSafeProxy.sol
pragma solidity ^0.8.20;
import {Proxy} from "@openzeppelin/contracts/proxy/Proxy.sol";
import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
import {ControlCenterManager} from "../base/ControlCenterManager.sol";
import {IControlCenter} from "../interfaces/IControlCenter.sol";
import {IOwnerManager} from "../interfaces/IOwnerManager.sol";
import "@/error/Errors.sol";
contract KnightSafeProxy is Proxy {
constructor(address implementation) {
if (implementation == address(0)) revert Errors.IsNullValue();
bytes memory _data;
ERC1967Utils.upgradeToAndCall(implementation, _data);
}
function _implementation() internal view virtual override returns (address) {
return ERC1967Utils.getImplementation();
}
function upgradeTo(address implementation) public returns (address) {
if (implementation == address(0)) revert Errors.IsNullValue();
if (IOwnerManager(address(this)).getOwner() != msg.sender) {
revert Errors.Unauthorized(msg.sender, "OWNER");
}
address controlCenter = ControlCenterManager(address(this)).getControlCenter();
if (!IControlCenter(controlCenter).isOfficialImplementation(implementation)) {
revert Errors.AddressIsNotKnightSafeImplementation(implementation);
}
bytes memory _data;
ERC1967Utils.upgradeToAndCall(implementation, _data);
}
}
文件 21 的 27: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);
}
}
文件 22 的 27:Ownable2Step.sol
pragma solidity ^0.8.20;
import {Ownable} from "./Ownable.sol";
abstract contract Ownable2Step is Ownable {
address private _pendingOwner;
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
function pendingOwner() public view virtual returns (address) {
return _pendingOwner;
}
function transferOwnership(address newOwner) public virtual override onlyOwner {
_pendingOwner = newOwner;
emit OwnershipTransferStarted(owner(), newOwner);
}
function _transferOwnership(address newOwner) internal virtual override {
delete _pendingOwner;
super._transferOwnership(newOwner);
}
function acceptOwnership() public virtual {
address sender = _msgSender();
if (pendingOwner() != sender) {
revert OwnableUnauthorizedAccount(sender);
}
_transferOwnership(sender);
}
}
文件 23 的 27:Proxy.sol
pragma solidity ^0.8.20;
abstract contract Proxy {
function _delegate(address implementation) internal virtual {
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())
}
}
}
function _implementation() internal view virtual returns (address);
function _fallback() internal virtual {
_delegate(_implementation());
}
fallback() external payable virtual {
_fallback();
}
}
文件 24 的 27:SettingUtils.sol
pragma solidity ^0.8.20;
library SettingUtils {
enum Status {
Pending,
Cancelled,
Completed,
Rejected
}
struct Request {
address requester;
uint8 selector;
bytes data;
Status status;
}
}
library SettingSelectors {
bytes4 internal constant CREATE_POLICY = 0xa91a0ca3;
bytes4 internal constant UPDATE_WHITELIST = 0x725d42f5;
bytes4 internal constant ADD_TRADER = 0xedbdf62b;
bytes4 internal constant REMOVE_POLICY = 0x6caddcdc;
bytes4 internal constant REMOVE_TRADER = 0x29953ff5;
bytes4 internal constant REMOVE_WHITELIST = 0x94008a6e;
bytes4 internal constant INCREASE_SPENDING_LIMIT = 0xcc19223b;
bytes4 internal constant RESET_SPENDING_LIMIT = 0x86e43e16;
}
文件 25 的 27:StorageSlot.sol
pragma solidity ^0.8.20;
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly {
r.slot := slot
}
}
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly {
r.slot := slot
}
}
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
assembly {
r.slot := slot
}
}
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
assembly {
r.slot := slot
}
}
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
assembly {
r.slot := slot
}
}
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
assembly {
r.slot := store.slot
}
}
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
assembly {
r.slot := slot
}
}
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
assembly {
r.slot := store.slot
}
}
}
文件 26 的 27:TokenCallbackHandler.sol
pragma solidity ^0.8.20;
import {IERC721Receiver} from "@openzeppelin/contracts/interfaces/IERC721Receiver.sol";
import {IERC777Recipient} from "@openzeppelin/contracts/interfaces/IERC777Recipient.sol";
import {IERC1155Receiver} from "@openzeppelin/contracts/interfaces/IERC1155Receiver.sol";
import {IERC165} from "@openzeppelin/contracts/interfaces/IERC165.sol";
contract TokenCallbackHandler is IERC1155Receiver, IERC777Recipient, IERC721Receiver {
function onERC1155Received(address, address, uint256, uint256, bytes calldata)
external
pure
override
returns (bytes4)
{
return 0xf23a6e61;
}
function onERC1155BatchReceived(address, address, uint256[] calldata, uint256[] calldata, bytes calldata)
external
pure
override
returns (bytes4)
{
return 0xbc197c81;
}
function onERC721Received(address, address, uint256, bytes calldata) external pure override returns (bytes4) {
return 0x150b7a02;
}
function tokensReceived(address, address, address, uint256, bytes calldata, bytes calldata)
external
pure
override
{
}
function supportsInterface(bytes4 interfaceId) external view virtual override returns (bool) {
return interfaceId == type(IERC1155Receiver).interfaceId || interfaceId == type(IERC721Receiver).interfaceId
|| interfaceId == type(IERC165).interfaceId;
}
}
文件 27 的 27:Transaction.sol
pragma solidity ^0.8.20;
library Transaction {
enum Status {
Pending,
Cancelled,
Completed,
Rejected
}
struct Request {
address requester;
uint256 policyId;
Params params;
Status status;
}
struct Params {
address to;
uint256 value;
bytes data;
}
}
{
"compilationTarget": {
"contracts/proxies/KnightSafeProxy.sol": "KnightSafeProxy"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [
":@/=contracts/",
":@chainlink/contracts/=lib/chainlink-brownie-contracts/contracts/src/",
":@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
":chainlink-brownie-contracts/=lib/chainlink-brownie-contracts/contracts/src/v0.6/vendor/@arbitrum/nitro-contracts/src/",
":ds-test/=lib/foundry-chainlink-toolkit/lib/forge-std/lib/ds-test/src/",
":eth-gas-reporter/=node_modules/eth-gas-reporter/",
":forge-std/=lib/forge-std/src/",
":hardhat/=node_modules/hardhat/",
":openzeppelin-contracts/=lib/openzeppelin-contracts/"
]
}
[{"inputs":[{"internalType":"address","name":"implementation","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"AddressIsNotKnightSafeImplementation","type":"error"},{"inputs":[{"internalType":"address","name":"implementation","type":"address"}],"name":"ERC1967InvalidImplementation","type":"error"},{"inputs":[],"name":"ERC1967NonPayable","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"IsNullValue","type":"error"},{"inputs":[{"internalType":"address","name":"msgSender","type":"address"},{"internalType":"string","name":"role","type":"string"}],"name":"Unauthorized","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[{"internalType":"address","name":"implementation","type":"address"}],"name":"upgradeTo","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"}]