Files

34 lines
939 B
Solidity
Raw Permalink 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;
2021-11-09 10:53:38 +08:00
import {InitializableOwnable} from "../lib/InitializableOwnable.sol";
2021-04-20 21:02:43 +08:00
2021-06-11 14:23:43 +08:00
interface IQuota {
function getUserQuota(address user) external view returns (int);
}
2021-11-09 10:53:38 +08:00
contract UserQuota is InitializableOwnable, 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];
2022-02-18 21:12:18 +08:00
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
}