// SPDX-License-Identifier: MIT pragma solidity ^0.8.6; interface IKYCContract { function level(address addr) external view returns (uint);} /** * @title FilterContract * @notice Graphite system contract that interacts with the KYC contract to manage user-specific filter levels * and verify permissions based on KYC levels. */contract FilterContract { /** * @notice Mapping to store the filter level of each user. * @dev This determines the minimum KYC level required by others to interact with the user. */ mapping(address => uint) filterLevel; // External KYC contract used for checking KYC levels. IKYCContract public kycContract; /** * @notice Emitted when a user's filter level is updated. * @param user The address of the user whose filter level was updated. * @param level The new filter level for the user. */ event FilterLevelChanged(address indexed user, uint indexed level); /** * @notice Updates the caller's filter level. * @dev This allows a user to set the minimum KYC level required by others to interact with them. * @param _level The new filter level to set for the caller. */ function setFilterLevel(uint _level) external { filterLevel[msg.sender] = _level; emit FilterLevelChanged(msg.sender, _level); } /** * @notice Retrieves the caller's current filter level. * @dev Useful for users to query their own filter settings. * returns The filter level of the caller. */ function viewFilterLevel() external view returns(uint){ return(filterLevel[msg.sender]); } /** * @notice Checks if the KYC level of the sender meets the filter level of the destination address. * @dev This function compares the sender's KYC level with the required filter level of the destination. * @param _sender The address of the user initiating the interaction. * @param _destination The address of the user receiving the interaction. * @return `true` if the `_sender`'s KYC level is greater than or equal to `_destination`'s filter level, otherwise `false`. */ function filter(address _sender, address _destination) external view returns(bool) { return(kycContract.level(_sender) >= filterLevel[_destination]); }}
[{"name": "FilterLevelChanged", "type": "event", "inputs": [{"name": "user", "type": "address", "indexed": true, "internalType": "address"}, {"name": "level", "type": "uint256", "indexed": true, "internalType": "uint256"}], "anonymous": false}, {"name": "filter", "type": "function", "inputs": [{"name": "_sender", "type": "address", "internalType": "address"}, {"name": "_destination", "type": "address", "internalType": "address"}], "outputs": [{"name": "", "type": "bool", "internalType": "bool"}], "stateMutability": "view"}, {"name": "kycContract", "type": "function", "inputs": [], "outputs": [{"name": "", "type": "address", "internalType": "contract IKYCContract"}], "stateMutability": "view"}, {"name": "setFilterLevel", "type": "function", "inputs": [{"name": "_level", "type": "uint256", "internalType": "uint256"}], "outputs": [], "stateMutability": "nonpayable"}, {"name": "viewFilterLevel", "type": "function", "inputs": [], "outputs": [{"name": "", "type": "uint256", "internalType": "uint256"}], "stateMutability": "view"}]
0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80632cea8391146100515780636d3123eb14610074578063d1a23b901461009f578063e1917fda146100b4575b600080fd5b336000908152602081905260409020546040519081526020015b60405180910390f35b600154610087906001600160a01b031681565b6040516001600160a01b03909116815260200161006b565b6100b26100ad3660046101a0565b6100d7565b005b6100c76100c23660046101d5565b610114565b604051901515815260200161006b565b33600081815260208190526040808220849055518392917f2ac7de9de5ad40921e24320f86f2fcb6f4c55726e82e2a173f9cee5dc62342f791a350565b6001600160a01b03818116600090815260208190526040808220546001549151636a0db6db60e11b815286851660048201529293909291169063d41b6db690602401602060405180830381865afa158015610173573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101979190610208565b10159392505050565b6000602082840312156101b257600080fd5b5035919050565b80356001600160a01b03811681146101d057600080fd5b919050565b600080604083850312156101e857600080fd5b6101f1836101b9565b91506101ff602084016101b9565b90509250929050565b60006020828403121561021a57600080fd5b505191905056fea2646970667358221220db37876039486f4fddd046c6f6c3b861c3d08c71e893564b7e838013ae2f4fab64736f6c63430008130033