// File: contracts/SmartWalletWhitelist.sol



// SPDX-License-Identifier: MIT

pragma solidity 0.8.17;

interface SmartWalletChecker {
    function check(address) external view returns (bool);
}

contract SmartWalletWhitelist {
    mapping(address => bool) public wallets;
    address public admin;
    address public checker;
    address public future_checker;

    event ApproveWallet(address);
    event RevokeWallet(address);

    constructor(address _admin) {
        require(_admin != address(0), "Zero Address");
        admin = _admin;
    }

    function commitSetChecker(address _checker) external {
        require(msg.sender == admin, "!admin");
        require(_checker != address(0), "Zero Address");
        future_checker = _checker;
    }

    function changeAdmin(address _admin) external {
        require(msg.sender == admin, "!admin");
        require(_admin != address(0), "Zero Address");
        admin = _admin;
    }

    function applySetChecker() external {
        require(msg.sender == admin, "!admin");
        checker = future_checker;
    }

    function approveWallet(address _wallet) public {
        require(msg.sender == admin, "!admin");
        require(address(_wallet) != address(0), "Zero Address");
        wallets[_wallet] = true;

        emit ApproveWallet(_wallet);
    }

    function revokeWallet(address _wallet) external {
        require(msg.sender == admin, "!admin");
        wallets[_wallet] = false;

        emit RevokeWallet(_wallet);
    }

    function check(address _wallet) external view returns (bool) {
        bool _check = wallets[_wallet];
        if (_check) {
            return _check;
        } else {
            if (checker != address(0)) {
                return SmartWalletChecker(checker).check(_wallet);
            }
        }
        return false;
    }
}