// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)pragmasolidity ^0.8.20;/**
* @dev Collection of functions related to the address type
*/libraryAddress{
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/errorAddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/errorAddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/errorFailedInnerCall();
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/functionsendValue(addresspayable recipient, uint256 amount) internal{
if (address(this).balance< amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {FailedInnerCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*/functionfunctionCall(address target, bytesmemory data) internalreturns (bytesmemory) {
return functionCallWithValue(target, data, 0);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*/functionfunctionCallWithValue(address target, bytesmemory data, uint256 value) internalreturns (bytesmemory) {
if (address(this).balance< value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytesmemory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/functionfunctionStaticCall(address target, bytesmemory data) internalviewreturns (bytesmemory) {
(bool success, bytesmemory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/functionfunctionDelegateCall(address target, bytesmemory data) internalreturns (bytesmemory) {
(bool success, bytesmemory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/functionverifyCallResultFromTarget(address target,
bool success,
bytesmemory returndata
) internalviewreturns (bytesmemory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty// otherwise we already know that it was a contractif (returndata.length==0&& target.code.length==0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {FailedInnerCall} error.
*/functionverifyCallResult(bool success, bytesmemory returndata) internalpurereturns (bytesmemory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
*/function_revert(bytesmemory returndata) privatepure{
// Look for revert reason and bubble it up if presentif (returndata.length>0) {
// The easiest way to bubble the revert reason is using memory via assembly/// @solidity memory-safe-assemblyassembly {
let returndata_size :=mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert FailedInnerCall();
}
}
}
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)pragmasolidity ^0.8.20;/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/abstractcontractContext{
function_msgSender() internalviewvirtualreturns (address) {
returnmsg.sender;
}
function_msgData() internalviewvirtualreturns (bytescalldata) {
returnmsg.data;
}
function_contextSuffixLength() internalviewvirtualreturns (uint256) {
return0;
}
}
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v5.0.0) (proxy/ERC1967/ERC1967Utils.sol)pragmasolidity ^0.8.20;import {IBeacon} from"../beacon/IBeacon.sol";
import {Address} from"../../utils/Address.sol";
import {StorageSlot} from"../../utils/StorageSlot.sol";
/**
* @dev This abstract contract provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
*/libraryERC1967Utils{
// We re-declare ERC-1967 events here because they can't be used directly from IERC1967.// This will be fixed in Solidity 0.8.21. At that point we should remove these events./**
* @dev Emitted when the implementation is upgraded.
*/eventUpgraded(addressindexed implementation);
/**
* @dev Emitted when the admin account has changed.
*/eventAdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Emitted when the beacon is changed.
*/eventBeaconUpgraded(addressindexed beacon);
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
*/// solhint-disable-next-line private-vars-leading-underscorebytes32internalconstant IMPLEMENTATION_SLOT =0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev The `implementation` of the proxy is invalid.
*/errorERC1967InvalidImplementation(address implementation);
/**
* @dev The `admin` of the proxy is invalid.
*/errorERC1967InvalidAdmin(address admin);
/**
* @dev The `beacon` of the proxy is invalid.
*/errorERC1967InvalidBeacon(address beacon);
/**
* @dev An upgrade function sees `msg.value > 0` that may be lost.
*/errorERC1967NonPayable();
/**
* @dev Returns the current implementation address.
*/functiongetImplementation() internalviewreturns (address) {
return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 implementation slot.
*/function_setImplementation(address newImplementation) private{
if (newImplementation.code.length==0) {
revert ERC1967InvalidImplementation(newImplementation);
}
StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value= newImplementation;
}
/**
* @dev Performs implementation upgrade with additional setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-Upgraded} event.
*/functionupgradeToAndCall(address newImplementation, bytesmemory data) internal{
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
if (data.length>0) {
Address.functionDelegateCall(newImplementation, data);
} else {
_checkNonPayable();
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
*/// solhint-disable-next-line private-vars-leading-underscorebytes32internalconstant ADMIN_SLOT =0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Returns the current admin.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using
* the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
*/functiongetAdmin() internalviewreturns (address) {
return StorageSlot.getAddressSlot(ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 admin slot.
*/function_setAdmin(address newAdmin) private{
if (newAdmin ==address(0)) {
revert ERC1967InvalidAdmin(address(0));
}
StorageSlot.getAddressSlot(ADMIN_SLOT).value= newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {IERC1967-AdminChanged} event.
*/functionchangeAdmin(address newAdmin) internal{
emit AdminChanged(getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1.
*/// solhint-disable-next-line private-vars-leading-underscorebytes32internalconstant BEACON_SLOT =0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Returns the current beacon.
*/functiongetBeacon() internalviewreturns (address) {
return StorageSlot.getAddressSlot(BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the EIP1967 beacon slot.
*/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);
}
}
/**
* @dev Change the beacon and trigger a setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-BeaconUpgraded} event.
*
* CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since
* it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for
* efficiency.
*/functionupgradeBeaconToAndCall(address newBeacon, bytesmemory data) internal{
_setBeacon(newBeacon);
emit BeaconUpgraded(newBeacon);
if (data.length>0) {
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
} else {
_checkNonPayable();
}
}
/**
* @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract
* if an upgrade doesn't perform an initialization call.
*/function_checkNonPayable() private{
if (msg.value>0) {
revert ERC1967NonPayable();
}
}
}
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol)pragmasolidity ^0.8.20;/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/interfaceIBeacon{
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {UpgradeableBeacon} will check that this address is a contract.
*/functionimplementation() externalviewreturns (address);
}
Contract Source Code
File 12 of 27: IControlCenter.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.20;import"./IEventEmitter.sol";
/// @dev Interface of the ControlCenter contractinterfaceIControlCenterisIEventEmitter{
/* solhint-disable func-name-mixedcase */functionVERSION() externalviewreturns (stringmemory);
/**
* @notice update Admin access
* @dev only Owner can call
* @param admin Address of the admin
* @param isAdmin toggle admin access
*/functionsetAdmin(address admin, bool isAdmin) external;
/**
* @notice Check control center is official or not supported
* @param controlCenterAddress Address of the contract
* @return bool True if the control center is official
*/functionisOfficialControlCenter(address controlCenterAddress) externalviewreturns (bool);
/**
* @notice Add a new official control center contract
* @dev only Owner can call
* @dev version format: [AppName]_[MajorVer.].[MinorVer.]: e.g. CC_1.1
* @param controlCenterAddress Address of the control center contract
* @param version Version of the control center contract , format:( [Name]_[MajorVer.].[MinorVer.]: e.g. CC_1.1 )
*/functionaddOfficialControlCenter(address controlCenterAddress, bytes32 version) external;
/**
* @notice remove unsupported control center contract
* @dev only Owner can call
* @param controlCenterAddress Address of the control center contract
*/functionremoveOfficialControlCenter(address controlCenterAddress) external;
/**
* @notice Check implementation is official or not supported
* @param implementationAddress Address of the implementation contract
* @return bool True if the implementation is official
*/functionisOfficialImplementation(address implementationAddress) externalviewreturns (bool);
/**
* @notice Add a new official implementation contract
* @dev only Owner can call
* @dev version format: [AppName]_[MajorVer.].[MinorVer.]: e.g. ERC20_1.1
* @param implementationAddress Address of the implementation contract
* @param version Version of the implementation contract , format:( [Name]_[MajorVer.].[MinorVer.]: e.g. master_1.1 )
*/functionaddOfficialImplementation(address implementationAddress, bytes32 version) external;
/**
* @notice remove unsupported implementation contract
* @dev only Owner can call
* @param implementationAddress Address of the implementation contract
*/functionremoveOfficialImplementation(address implementationAddress) external;
/**
* @notice Check analyser is official or not supported
* @param analyserAddress Address of the analyser contract
* @return bool True if the analyser is official
*/functionisOfficialAnalyser(address analyserAddress) externalviewreturns (bool);
/**
* @notice Add a new official analyser contract
* @dev only Admin can call
* @dev version format: [AppName]_[MajorVer.].[MinorVer.]: e.g. ERC20_1.1
* @param analyserAddress Address of the analyser contract
* @param version Version of the analyser contract , format:( [AppName]_[MajorVer.].[MinorVer.]: e.g. ERC20_1.1 )
*/functionaddOfficialAnalyser(address analyserAddress, bytes32 version) external;
/**
* @notice remove unsupported analyser contract
* @dev only Admin can call
* @param analyserAddress Address of the analyser contract
*/functionremoveOfficialAnalyser(address analyserAddress) external;
/**
* @notice get available policy count for KnightSafe
* @param knightSafeAddress Address of the analyser contract
*/functiongetMaxPolicyAllowed(address knightSafeAddress) externalviewreturns (uint256);
/**
* @notice set available policy count
* @dev only Admin can call
* @param knightSafeAddress Address of the analyser contract
* @param maxPolicyAllowed Maximum policy count
*/functionsetMaxPolicyAllowed(address knightSafeAddress, uint256 maxPolicyAllowed) external;
/**
* @notice set global minimum policy count
* @dev only Owner can call
*/functionsetGlobalMinPolicyAllowed(uint256 minPolicyAllowed) external;
/**
* @notice get admin event access list
*/functiongetAdminEventAccess() externalviewreturns (bytes4[] memory);
/**
* @notice get admin event access count
*/functiongetAdminEventAccessCount() externalviewreturns (uint256);
/**
* @notice get admin event access by id
* @param id Event id
*/functiongetAdminEventAccessById(uint8 id) externalviewreturns (bytes4);
/**
* @notice Check policy spending limit is enabled or not
* @param knightSafeAddress Address of the analyser contract
* @return bool True if the spending limit is enabled
*/functionisSpendingLimitEnabled(address knightSafeAddress) externalviewreturns (bool);
/**
* @notice set spending limit
* @dev only Admin can call
* @param knightSafeAddress Address of the analyser contract
* @param isEnabled True if the spending limit is enabled
*/functionsetSpendingLimitEnabled(address knightSafeAddress, bool isEnabled) external;
/**
* @notice get price feed address
* @return Price feed address
*/functiongetPriceFeed() externalviewreturns (address);
/**
* @notice get price feed address
* @dev only owner can call
* @param priceFeed Price feed address
*/functionsetPriceFeed(address priceFeed) external;
/**
* @notice set global volume limit
* @dev only Owner can call
* @param volume global limit with 30 decimals
*/functionsetBaseVolume(uint256 volume) external;
/**
* @notice get daily transaction volume limit
* @param knightSafeAddress knight safe account
* @return Limit transaction volume limit as 30 decimals
*/functiongetDailyVolume(address knightSafeAddress) externalviewreturns (uint256);
/**
* @notice set daily limit
* @dev only Admin can call
* @dev daily Limit must cast to 30 decimals
* @param knightSafeAddress knight safe account
* @param volume daily limit with 30 decimals
*/functionsetDailyVolume(address knightSafeAddress, uint256 volume) external;
/**
* @notice set daily limit date due to
* @dev only Admin can call
* @param knightSafeAddress knight safe account
* @param expiryDate Expiration date of the limit
*/functionsetDailyVolumeExpiryDate(address knightSafeAddress, uint256 expiryDate) external;
/**
* @notice get total transaction volume limit
* @param knightSafeAddress knight safe account
* @return Limit transaction volume limit with 30 decimals
*/functiongetMaxTradingVolume(address knightSafeAddress) externalviewreturns (uint256);
/**
* @notice get volume limit expiration date
* @dev will return 0 for unset value
* @param knightSafeAddress knight safe account
* @return timestamp Expiration date of the limit
*/functiongetMaxVolumeExpiryDate(address knightSafeAddress) externalviewreturns (uint256);
/**
* @notice set account volume limit
* @dev only Admin can call
* @dev volume Limit must cast to 30 decimals
* @param knightSafeAddress knight safe account
* @param volume transaction volume limit with 30 decimals
*/functionsetMaxTradingVolume(address knightSafeAddress, uint256 volume) external;
/**
* @notice set account volume limit date due to
* @dev only Admin can call
* @param knightSafeAddress knight safe account
* @param expiryDate Expiration date of the limit
*/functionsetMaxTradingVolumeExpiryDate(address knightSafeAddress, uint256 expiryDate) external;
}
Contract Source Code
File 13 of 27: IERC1155Receiver.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/IERC1155Receiver.sol)pragmasolidity ^0.8.20;import {IERC165} from"../../utils/introspection/IERC165.sol";
/**
* @dev Interface that must be implemented by smart contracts in order to receive
* ERC-1155 token transfers.
*/interfaceIERC1155ReceiverisIERC165{
/**
* @dev Handles the receipt of a single ERC1155 token type. This function is
* called at the end of a `safeTransferFrom` after the balance has been updated.
*
* NOTE: To accept the transfer, this must return
* `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
* (i.e. 0xf23a6e61, or its own function selector).
*
* @param operator The address which initiated the transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param id The ID of the token being transferred
* @param value The amount of tokens being transferred
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
*/functiononERC1155Received(address operator,
addressfrom,
uint256 id,
uint256 value,
bytescalldata data
) externalreturns (bytes4);
/**
* @dev Handles the receipt of a multiple ERC1155 token types. This function
* is called at the end of a `safeBatchTransferFrom` after the balances have
* been updated.
*
* NOTE: To accept the transfer(s), this must return
* `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
* (i.e. 0xbc197c81, or its own function selector).
*
* @param operator The address which initiated the batch transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param ids An array containing ids of each token being transferred (order and length must match values array)
* @param values An array containing amounts of each token being transferred (order and length must match ids array)
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
*/functiononERC1155BatchReceived(address operator,
addressfrom,
uint256[] calldata ids,
uint256[] calldata values,
bytescalldata data
) externalreturns (bytes4);
}
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC777Recipient.sol)pragmasolidity ^0.8.20;/**
* @dev Interface of the ERC777TokensRecipient standard as defined in the EIP.
*
* Accounts can be notified of {IERC777} tokens being sent to them by having a
* contract implement this interface (contract holders can be their own
* implementer) and registering it on the
* https://eips.ethereum.org/EIPS/eip-1820[ERC1820 global registry].
*
* See {IERC1820Registry} and {IERC1820Implementer}.
*/interfaceIERC777Recipient{
/**
* @dev Called by an {IERC777} token contract whenever tokens are being
* moved or created into a registered account (`to`). The type of operation
* is conveyed by `from` being the zero address or not.
*
* This call occurs _after_ the token contract's state is updated, so
* {IERC777-balanceOf}, etc., can be used to query the post-operation state.
*
* This function may revert to prevent the operation from being executed.
*/functiontokensReceived(address operator,
addressfrom,
address to,
uint256 amount,
bytescalldata userData,
bytescalldata operatorData
) external;
}
Contract Source Code
File 17 of 27: IEventEmitter.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.20;import"../event/EventUtils.sol";
import"../transaction/Transaction.sol";
import"../setting/SettingUtils.sol";
/// @notice EventEmitter interface/// All KnightSafe event will emit through this interfaceinterfaceIEventEmitter{
eventTransactionEventLog(address msgSender, string eventName, stringindexed eventNameHash, bytes32indexed profile, uint256 reqId
);
eventSettingEventLog(address msgSender, string eventName, stringindexed eventNameHash, bytes32indexed profile, uint256 reqId
);
eventEventLog(address msgSender, string eventName, stringindexed eventNameHash, EventUtils.EventLogData eventData
);
eventEventLog1(address msgSender,
string eventName,
stringindexed eventNameHash,
bytes32indexed profile,
EventUtils.EventLogData eventData
);
eventEventLog2(address msgSender,
string eventName,
stringindexed eventNameHash,
bytes32indexed profile,
bytes32indexed topic2,
EventUtils.EventLogData eventData
);
/// @notice check if sender is factoryfunctionisFactory(address sender) externalviewreturns (bool);
/// @notice set sender as factoryfunctionsetFactory(address factory) external;
/// @notice disable factoryfunctiondisableFactory(address factory) external;
/// @notice check if sender is available to send eventfunctionisActiveAccount(address sender) externalviewreturns (bool);
/// @notice set sender as active accountfunctionsetActiveAccount(address sender) external;
/// @notice disable active accountfunctiondisableActiveAccount(address sender) external;
/**
* @notice emit event log
* @param eventName event name, Topic 0
* @param eventData event data, data
*/functionemitEventLog(stringmemory eventName, EventUtils.EventLogData memory eventData) external;
/**
* @notice emit event log with 1 topic
* @param eventName event name, Topic 0
* @param profile profile address, Topic 1
* @param eventData event data, data
*/functionemitEventLog1(stringmemory eventName, bytes32 profile, EventUtils.EventLogData memory eventData)
external;
/**
* @notice emit event log with 2 topic
* @param eventName event name, Topic 0
* @param profile profile address, Topic 1
* @param topic2 second topic information , Topic 2
* @param eventData event data, data
*/functionemitEventLog2(stringmemory eventName,
bytes32 profile,
bytes32 topic2,
EventUtils.EventLogData memory eventData
) external;
/**
* @notice emit transaction event log
* @dev this will trigger on every transaction request
* @param eventName event name
* @param profile profile address
* @param reqId request id
*/functionemitTransactionEventLog(stringmemory eventName, bytes32 profile, uint256 reqId) external;
/**
* @notice emit setting event log
* @dev this will trigger on every setting request
* @param eventName event name
* @param profile profile address
* @param reqId request id
*/functionemitSettingEventLog(stringmemory eventName, bytes32 profile, uint256 reqId) external;
}
Contract Source Code
File 18 of 27: IKnightSafeAnalyser.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.20;interfaceIKnightSafeAnalyser{
/**
* @dev this function is used to extract addresses and values from transaction data
* @param to address of the contract
* @param data transaction data
*/functionextractAddressesWithValue(address to, bytesmemory data)
externalviewreturns (address[] memory, uint256[] memory);
}
Contract Source Code
File 19 of 27: IOwnerManager.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.20;interfaceIOwnerManager{
/// @notice get owner of the contractfunctiongetOwner() externalviewreturns (address);
/**
* @notice set new backup owner to recovery contract
* @dev only owner can call
* @param backupOwner new owner address
* @param takeoverDelayIsSecond delay time for takeover in seconds
*/functionsetBackupOwner(address backupOwner, uint256 takeoverDelayIsSecond) external;
/// @notice get recovery is startedfunctiongetIsTakeoverInProgress() externalviewreturns (bool);
/// @notice get recovery process timestampfunctiongetTakeoverTimestamp() externalviewreturns (uint256);
/// @notice get backup progress statusfunctiongetTakeoverStatus() externalviewreturns (address, bool, uint256, uint256);
/**
* @notice request recovery process
* @dev only backup owner can call
*/functionrequestTakeover() external;
/**
* @notice confirm recovery process
* @dev if owner confirm, takeover will be done instantly;
* @dev backup owner can confirm takeover after delay time
*/functionconfirmTakeover() external;
/**
* @notice instantly takeover
* @dev if takeover delay set to 0, backup owner can confirm takeover instantly after requestTakeover()
*/functioninstantTakeover() external;
/**
* @notice revoke takeover request
* @dev owner and backup owner can revoke takeover request
*/functionrevokeTakeover() external;
/// @notice get admin listfunctiongetAdmins() externalviewreturns (address[] memory);
/// @notice check address is adminfunctionisAdmin(address admin) externalviewreturns (bool);
/// @notice set new adminfunctionaddAdmin(address admin) external;
/// @notice disable adminfunctionremoveAdmin(address admin) external;
}
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)pragmasolidity ^0.8.20;import {Context} from"../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/abstractcontractOwnableisContext{
addressprivate _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/errorOwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/errorOwnableInvalidOwner(address owner);
eventOwnershipTransferred(addressindexed previousOwner, addressindexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/constructor(address initialOwner) {
if (initialOwner ==address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/modifieronlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/functionowner() publicviewvirtualreturns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/function_checkOwner() internalviewvirtual{
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/functionrenounceOwnership() publicvirtualonlyOwner{
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/functiontransferOwnership(address newOwner) publicvirtualonlyOwner{
if (newOwner ==address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/function_transferOwnership(address newOwner) internalvirtual{
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
Contract Source Code
File 22 of 27: Ownable2Step.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable2Step.sol)pragmasolidity ^0.8.20;import {Ownable} from"./Ownable.sol";
/**
* @dev Contract module which provides access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is specified at deployment time in the constructor for `Ownable`. This
* can later be changed with {transferOwnership} and {acceptOwnership}.
*
* This module is used through inheritance. It will make available all functions
* from parent (Ownable).
*/abstractcontractOwnable2StepisOwnable{
addressprivate _pendingOwner;
eventOwnershipTransferStarted(addressindexed previousOwner, addressindexed newOwner);
/**
* @dev Returns the address of the pending owner.
*/functionpendingOwner() publicviewvirtualreturns (address) {
return _pendingOwner;
}
/**
* @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
* Can only be called by the current owner.
*/functiontransferOwnership(address newOwner) publicvirtualoverrideonlyOwner{
_pendingOwner = newOwner;
emit OwnershipTransferStarted(owner(), newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
* Internal function without access restriction.
*/function_transferOwnership(address newOwner) internalvirtualoverride{
delete _pendingOwner;
super._transferOwnership(newOwner);
}
/**
* @dev The new owner accepts the ownership transfer.
*/functionacceptOwnership() publicvirtual{
address sender = _msgSender();
if (pendingOwner() != sender) {
revert OwnableUnauthorizedAccount(sender);
}
_transferOwnership(sender);
}
}
Contract Source Code
File 23 of 27: Proxy.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v5.0.0) (proxy/Proxy.sol)pragmasolidity ^0.8.20;/**
* @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
* instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
* be specified by overriding the virtual {_implementation} function.
*
* Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
* different contract through the {_delegate} function.
*
* The success and return data of the delegated call will be returned back to the caller of the proxy.
*/abstractcontractProxy{
/**
* @dev Delegates the current call to `implementation`.
*
* This function does not return to its internal call site, it will return directly to the external caller.
*/function_delegate(address implementation) internalvirtual{
assembly {
// Copy msg.data. We take full control of memory in this inline assembly// block because it will not return to Solidity code. We overwrite the// Solidity scratch pad at memory position 0.calldatacopy(0, 0, calldatasize())
// Call the implementation.// out and outsize are 0 because we don't know the size yet.let result :=delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
// Copy the returned data.returndatacopy(0, 0, returndatasize())
switch result
// delegatecall returns 0 on error.case0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
/**
* @dev This is a virtual function that should be overridden so it returns the address to which the fallback
* function and {_fallback} should delegate.
*/function_implementation() internalviewvirtualreturns (address);
/**
* @dev Delegates the current call to the address returned by `_implementation()`.
*
* This function does not return to its internal call site, it will return directly to the external caller.
*/function_fallback() internalvirtual{
_delegate(_implementation());
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
* function in the contract matches the call data.
*/fallback() externalpayablevirtual{
_fallback();
}
}