LimiterTokenRegistry.sol (1308B)
1 pragma solidity ^0.8.0; 2 3 // Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 4 // SPDX-License-Identifier: AGPL-3.0-or-later 5 // File-Version: 1 6 // Description: Registry of allowed ERC20 balance limits per-token and per-holder. 7 8 interface Limiter { 9 function limitOf(address,address) external view returns(uint256); 10 function setLimit(address,uint256) external; 11 function setLimitFor(address,address,uint256) external; 12 } 13 14 contract LimiterTokenRegistry { 15 Limiter limiter; 16 address holder; 17 18 constructor(address _holder, Limiter _limiter) { 19 holder = _holder; 20 limiter = _limiter; 21 } 22 23 function limitOf(address _token, address _holder) public view returns (uint256) { 24 return limiter.limitOf(_token, _holder); 25 } 26 27 function setLimit(address _token, uint256 _value) public { 28 setLimitFor(_token, msg.sender, _value); 29 } 30 31 function setLimitFor(address _token, address _holder, uint256 _value) public { 32 limiter.setLimitFor(_token, _holder, _value); 33 } 34 35 function have(address _token) public view returns(bool) { 36 return limiter.limitOf(_token, holder) > 0; 37 } 38 39 function supportsInterface(bytes4 _sum) public pure returns (bool) { 40 if (_sum == 0x01ffc9a7) { // ERC165 41 return true; 42 } 43 if (_sum == 0xb7bca625) { // AccountsIndex 44 return true; 45 } 46 return false; 47 } 48 }