forked from CMTA/CMTAT
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathValidationModuleAllowlist.sol
More file actions
50 lines (47 loc) · 1.65 KB
/
ValidationModuleAllowlist.sol
File metadata and controls
50 lines (47 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//SPDX-License-Identifier: MPL-2.0
pragma solidity ^0.8.20;
/* ==== Module === */
import {ValidationModule} from "./ValidationModule.sol";
import {AllowlistModule} from "../options/AllowlistModule.sol";
/**
* @title ValidationModule - Allowlist
* @dev Validation module with allowlist.
*
* Useful for to restrict and validate transfers
*/
abstract contract ValidationModuleAllowlist is
AllowlistModule, ValidationModule
{
/*//////////////////////////////////////////////////////////////
INTERNAL/PRIVATE FUNCTIONS
//////////////////////////////////////////////////////////////*/
/* ============ View functions ============ */
/**
* @dev Use forcedTransfer (or forcedBurn) to burn tokens from an non-allowlist address
*/
function _canMintBurnByModule(
address target
) internal view virtual override(ValidationModule) returns (bool) {
if(_isAllowlistEnabled() && !isAllowlisted(target)){
return false;
} else {
return ValidationModule._canMintBurnByModule(target);
}
}
/**
* @dev Add allowlist check for standard transfer
*/
function _canTransferStandardByModule(
address spender,
address from,
address to
) internal view virtual override(ValidationModule) returns (bool) {
if(_isAllowlistEnabled()){
bool spenderCheck = spender != address(0) && !isAllowlisted(spender);
if (spenderCheck || !isAllowlisted(from) || !isAllowlisted(to)){
return false;
}
}
return ValidationModule._canTransferStandardByModule(spender, from, to);
}
}