snapshot
This commit is contained in:
38
contracts/lib/ConstFeeRateModel.sol
Normal file
38
contracts/lib/ConstFeeRateModel.sol
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
|
||||
Copyright 2020 DODO ZOO.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity 0.6.9;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import {IFeeRateModel} from "../intf/IFeeRateModel.sol";
|
||||
import {Ownable} from "../lib/Ownable.sol";
|
||||
import {InitializableOwnable} from "../lib/InitializableOwnable.sol";
|
||||
|
||||
interface IConstFeeRateModel {
|
||||
function init(address owner, uint256 feeRate) external;
|
||||
|
||||
function setFeeRate(uint256 newFeeRate) external;
|
||||
|
||||
function getFeeRate(address, uint256) external view returns (uint256);
|
||||
}
|
||||
|
||||
contract ConstFeeRateModel is InitializableOwnable, IFeeRateModel {
|
||||
uint256 public _FEE_RATE_;
|
||||
|
||||
function init(address owner, uint256 feeRate) external {
|
||||
initOwner(owner);
|
||||
_FEE_RATE_ = feeRate;
|
||||
}
|
||||
|
||||
function setFeeRate(uint256 newFeeRate) external {
|
||||
_FEE_RATE_ = newFeeRate;
|
||||
}
|
||||
|
||||
function getFeeRate(address, uint256) external override view returns (uint256) {
|
||||
return _FEE_RATE_;
|
||||
}
|
||||
}
|
||||
36
contracts/lib/OperatorSystem.sol
Normal file
36
contracts/lib/OperatorSystem.sol
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
|
||||
Copyright 2020 DODO ZOO.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity 0.6.9;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import {InitializableOwnable} from "./InitializableOwnable.sol";
|
||||
|
||||
contract OperatorSystem is InitializableOwnable {
|
||||
mapping(address => bool) internal _global_operator_;
|
||||
mapping(address => mapping(address => bool)) internal _operator_; // user=>operator=>isValid
|
||||
|
||||
function isValidOperator(address user, address operator) external view returns (bool) {
|
||||
return user == operator || _global_operator_[operator] || _operator_[user][operator];
|
||||
}
|
||||
|
||||
function addGlobalOperator(address operator) external onlyOwner {
|
||||
_global_operator_[operator] = true;
|
||||
}
|
||||
|
||||
function removeGlobalOperator(address operator) external onlyOwner {
|
||||
_global_operator_[operator] = false;
|
||||
}
|
||||
|
||||
function addOperator(address operator) external {
|
||||
_operator_[msg.sender][operator] = true;
|
||||
}
|
||||
|
||||
function removeOperator(address operator) external {
|
||||
_operator_[msg.sender][operator] = false;
|
||||
}
|
||||
}
|
||||
@@ -10,44 +10,47 @@ pragma experimental ABIEncoderV2;
|
||||
|
||||
import {InitializableOwnable} from "./InitializableOwnable.sol";
|
||||
|
||||
interface IPermissionManager {
|
||||
function initOwner(address) external;
|
||||
|
||||
function isAllowed(address) external returns (bool);
|
||||
}
|
||||
|
||||
contract PermissionManager is InitializableOwnable {
|
||||
bool public _BLACKLIST_MODE_ON_;
|
||||
|
||||
bool public _BLACKLIST_MODE_ON_;
|
||||
mapping(address => bool) internal _whitelist_;
|
||||
mapping(address => bool) internal _blacklist_;
|
||||
|
||||
mapping(address => bool) internal _whitelist_;
|
||||
mapping(address => bool) internal _blacklist_;
|
||||
|
||||
function isAllowed(address account) external view returns(bool){
|
||||
if (_BLACKLIST_MODE_ON_) {
|
||||
return !_blacklist_[account];
|
||||
} else {
|
||||
return _whitelist_[account];
|
||||
function isAllowed(address account) external view returns (bool) {
|
||||
if (_BLACKLIST_MODE_ON_) {
|
||||
return !_blacklist_[account];
|
||||
} else {
|
||||
return _whitelist_[account];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function openBlacklist() external onlyOwner {
|
||||
_BLACKLIST_MODE_ON_ = true;
|
||||
}
|
||||
function openBlacklist() external onlyOwner {
|
||||
_BLACKLIST_MODE_ON_ = true;
|
||||
}
|
||||
|
||||
function openWhitelist() external onlyOwner {
|
||||
_BLACKLIST_MODE_ON_ = true;
|
||||
function openWhitelist() external onlyOwner {
|
||||
_BLACKLIST_MODE_ON_ = true;
|
||||
}
|
||||
|
||||
}
|
||||
function addToWhitelist(address account) external onlyOwner {
|
||||
_whitelist_[account] = true;
|
||||
}
|
||||
|
||||
function addToWhitelist(address account) external onlyOwner{
|
||||
_whitelist_[account] = true;
|
||||
}
|
||||
function removeFromWhitelist(address account) external onlyOwner {
|
||||
_whitelist_[account] = false;
|
||||
}
|
||||
|
||||
function removeFromWhitelist(address account) external onlyOwner{
|
||||
_whitelist_[account] = false;
|
||||
}
|
||||
function addToBlacklist(address account) external onlyOwner {
|
||||
_blacklist_[account] = true;
|
||||
}
|
||||
|
||||
function addToBlacklist(address account) external onlyOwner{
|
||||
_blacklist_[account] = true;
|
||||
}
|
||||
|
||||
function removeFromBlacklist(address account) external onlyOwner{
|
||||
_blacklist_[account] = false;
|
||||
}
|
||||
|
||||
}
|
||||
function removeFromBlacklist(address account) external onlyOwner {
|
||||
_blacklist_[account] = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user