Files
dodo-contractV2/contracts/DODOFee/UserQuota.sol

34 lines
900 B
Solidity
Raw Normal View History

2021-04-20 21:02:43 +08:00
/*
Copyright 2020 DODO ZOO.
SPDX-License-Identifier: Apache-2.0
*/
pragma solidity 0.6.9;
import {Ownable} from "../lib/Ownable.sol";
2021-06-11 14:23:43 +08:00
interface IQuota {
function getUserQuota(address user) external view returns (int);
}
contract UserQuota is Ownable, IQuota {
2021-04-20 21:02:43 +08:00
mapping(address => uint256) public userQuota;
2021-05-06 14:58:53 +08:00
event SetQuota(address user, uint256 amount);
2021-04-20 21:02:43 +08:00
2021-05-06 14:58:53 +08:00
function setUserQuota(address[] memory users, uint256[] memory quotas) external onlyOwner {
require(users.length == quotas.length, "PARAMS_LENGTH_NOT_MATCH");
2021-04-20 21:02:43 +08:00
for(uint256 i = 0; i< users.length; i++) {
require(users[i] != address(0), "USER_INVALID");
2021-05-06 14:58:53 +08:00
userQuota[users[i]] = quotas[i];
emit SetQuota(users[i],quotas[i]);
2021-04-20 21:02:43 +08:00
}
}
2021-06-11 14:23:43 +08:00
function getUserQuota(address user) override external view returns (int) {
return int(userQuota[user]);
2021-04-20 21:02:43 +08:00
}
2021-05-06 14:58:53 +08:00
}