Verified contractPartialMIT
GeneralView
Address0x9ebc20f0415b7fe50f3f77d8158bc6b2d8d6b14a
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.24
- Same code
Only this contract
Details
- Compiler
- solc 0.8.24+commit.e11b9ed9
- Language
- solidity
- Optimization
- Yes, 1,000 runs
- EVM version
- cancun
- License
- MIT
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 25,990,065
- Creation transaction
- 0x3d3c6198cd…f05edf7c0c
GeneralView.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.8.24;
interface IDSProxy {
function execute(bytes memory _code, bytes memory _data)
external
payable
returns (address, bytes32);
function execute(address _target, bytes memory _data) external payable returns (bytes32);
function setCache(address _cacheAddr) external payable returns (bool);
function owner() external view returns (address);
function guard() external view returns (address);
}
interface IDSProxyFactory {
function isProxy(address _proxy) external view returns (bool);
function build(address owner) external returns (IDSProxy proxy);
function build() external returns (IDSProxy proxy);
}
contract MainnetDSAProxyFactoryAddresses {
address internal constant DSA_LIST_ADDR = 0x4c8a1BEb8a87765788946D6B19C6C6355194AbEb;
}
contract DSAProxyFactoryHelper is MainnetDSAProxyFactoryAddresses { }
contract MainnetProxyFactoryAddresses {
address internal constant PROXY_FACTORY_ADDR = 0xA26e15C895EFc0616177B7c1e7270A4C7D51C997;
}
contract DSProxyFactoryHelper is MainnetProxyFactoryAddresses { }
contract MainnetSFProxyFactoryAddresses {
address internal constant SF_PROXY_FACTORY_ADDR = 0xF7B75183A2829843dB06266c114297dfbFaeE2b6;
address internal constant SF_PROXY_GUARD = 0xCe91349d2A4577BBd0fC91Fe6019600e047f2847;
bytes32 internal constant SF_PROXY_CODEHASH =
0x15b0c1a13812f0fce8291b8e7786ece58e0daab08d489cdfe2899fdac4f66045;
}
contract SFProxyFactoryHelper is MainnetSFProxyFactoryAddresses { }
interface IInstaList {
struct AccountLink {
address first;
address last;
uint64 count;
}
struct AccountList {
address prev;
address next;
}
struct UserLink {
uint64 first;
uint64 last;
uint64 count;
}
struct UserList {
uint64 prev;
uint64 next;
}
function accountAddr(uint64 _id) external view returns (address);
function accountID(address _addr) external view returns (uint64);
function accountLink(uint64 _id) external view returns (AccountLink memory);
function accountList(uint64 _id, address _user) external view returns (AccountList memory);
function userLink(address _user) external view returns (UserLink memory);
function userList(address _user, uint64 _id) external view returns (UserList memory);
}
interface ISafe {
enum Operation {
Call,
DelegateCall
}
function setup(
address[] calldata _owners,
uint256 _threshold,
address to,
bytes calldata data,
address fallbackHandler,
address paymentToken,
uint256 payment,
address payable paymentReceiver
) external;
function execTransaction(
address to,
uint256 value,
bytes calldata data,
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,
Operation operation
) external returns (bool success);
function checkSignatures(bytes32 dataHash, bytes memory data, bytes memory signatures)
external
view;
function checkNSignatures(
address executor,
bytes32 dataHash,
bytes memory, /* data */
bytes memory signatures,
uint256 requiredSignatures
) external view;
function approveHash(bytes32 hashToApprove) external;
function domainSeparator() external view returns (bytes32);
function getTransactionHash(
address to,
uint256 value,
bytes calldata data,
Operation operation,
uint256 safeTxGas,
uint256 baseGas,
uint256 gasPrice,
address gasToken,
address refundReceiver,
uint256 _nonce
) external view returns (bytes32);
function nonce() external view returns (uint256);
function setFallbackHandler(address handler) external;
function getOwners() external view returns (address[] memory);
function isOwner(address owner) external view returns (bool);
function getThreshold() external view returns (uint256);
function enableModule(address module) external;
function isModuleEnabled(address module) external view returns (bool);
function disableModule(address prevModule, address module) external;
function getModulesPaginated(address start, uint256 pageSize)
external
view
returns (address[] memory array, address next);
}
enum WalletType {
DSPROXY,
SAFE,
DSAPROXY,
SFPROXY
}
contract SmartWalletUtils is DSProxyFactoryHelper, DSAProxyFactoryHelper, SFProxyFactoryHelper {
/// @notice Determine the type of wallet an address represents
function _getWalletType(address _wallet) internal view returns (WalletType) {
if (_isDSProxy(_wallet)) {
return WalletType.DSPROXY;
}
if (_isDSAProxy(_wallet)) {
return WalletType.DSAPROXY;
}
if (_isSFProxy(_wallet)) {
return WalletType.SFPROXY;
}
// Otherwise, we assume we are in context of Safe
return WalletType.SAFE;
}
/// @notice Check if the wallet is a DSProxy
function _isDSProxy(address _wallet) internal view returns (bool) {
return IDSProxyFactory(PROXY_FACTORY_ADDR).isProxy(_wallet);
}
/// @notice Check if the wallet is a DSA Proxy Account
function _isDSAProxy(address _wallet) internal view returns (bool) {
return IInstaList(DSA_LIST_ADDR).accountID(_wallet) != 0;
}
/// @notice Check if the wallet is a Summerfi account
function _isSFProxy(address _wallet) internal view returns (bool) {
return _wallet.codehash == SF_PROXY_CODEHASH;
}
/// @notice Fetch the owner of the smart wallet or the wallet itself
/// @dev For 1/1 Safe it returns the owner, otherwise it returns the wallet itself
/// @dev Only supports Safe and DSProxy wallets because SFProxy and DSAProxy are not part of automation
/// @param _wallet Address of the smart wallet
/// @return Address of the owner or wallet
function _fetchOwnerOrWallet(address _wallet) internal view returns (address) {
if (_isDSProxy(_wallet)) return IDSProxy(_wallet).owner();
// Otherwise, we assume we are in context of Safe
address[] memory owners = ISafe(_wallet).getOwners();
return owners.length == 1 ? owners[0] : _wallet;
}
}
interface IAccountImplementation {
function execute(address _target, bytes memory _data)
external
payable
returns (bytes32 response);
function send(address _target, bytes memory _data) external payable;
function owner() external view returns (address owner);
function guard() external view returns (address);
}
contract GeneralView is SmartWalletUtils {
error NotSmartWallet();
/// @notice Retrieves information about a smart wallet and handles the reverts with custom NotSmartWallet error
/// @param _smartWalletAddress Address of the smart wallet
/// @return smartWalletType Type of the smart wallet
/// @return owner Address of the owner of the smart wallet
function getSmartWalletInfoWithCatch(address _smartWalletAddress)
public
view
returns (WalletType smartWalletType, address owner)
{
try this.getSmartWalletInfo(_smartWalletAddress) returns (
WalletType _smartWalletType, address _owner
) {
return (_smartWalletType, _owner);
} catch {
revert NotSmartWallet();
}
}
/// @notice Retrieves information about a smart wallet
/// @param _smartWalletAddress Address of the smart wallet
/// @return smartWalletType Type of the smart wallet
/// @return owner Address of the owner of the smart wallet
function getSmartWalletInfo(address _smartWalletAddress)
public
view
returns (WalletType smartWalletType, address owner)
{
smartWalletType = _getWalletType(_smartWalletAddress);
// DSA Proxy accounts are intentionally handled separately from '_fetchOwnerOrWallet'
if (smartWalletType == WalletType.DSAPROXY) {
owner = _fetchDSAProxyOwner(_smartWalletAddress);
} else if (smartWalletType == WalletType.SFPROXY) {
owner = _fetchSFProxyOwner(_smartWalletAddress);
} else {
owner = _fetchOwnerOrWallet(_smartWalletAddress);
}
}
function _fetchDSAProxyOwner(address _dsaProxy) internal view returns (address) {
uint64 dsaId = IInstaList(DSA_LIST_ADDR).accountID(_dsaProxy);
return IInstaList(DSA_LIST_ADDR).accountLink(dsaId).first;
}
function _fetchSFProxyOwner(address _sfProxy) internal view returns (address) {
return IAccountImplementation(_sfProxy).owner();
}
}Compiler settingsShow
{
"libraries": {},
"optimizer": {
"runs": 1000,
"enabled": true
},
"evmVersion": "cancun"
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.