-
Notifications
You must be signed in to change notification settings - Fork 1
/
WithSanctionsList.sol
85 lines (76 loc) · 2.44 KB
/
WithSanctionsList.sol
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "../interfaces/ISanctionsList.sol";
import "../access/WithMidasAccessControl.sol";
import "./MidasInitializable.sol";
/**
* @title WithSanctionsList
* @notice Base contract that uses sanctions oracle from
* Chainalysis to check that user is not sanctioned
* @author RedDuck Software
*/
abstract contract WithSanctionsList is WithMidasAccessControl {
/**
* @notice address of Chainalysis sanctions oracle
*/
address public sanctionsList;
/**
* @param caller function caller (msg.sender)
* @param newSanctionsList new address of `sanctionsList`
*/
event SetSanctionsList(
address indexed caller,
address indexed newSanctionsList
);
/**
* @dev checks that a given `user` is not sanctioned
*/
modifier onlyNotSanctioned(address user) {
address _sanctionsList = sanctionsList;
if (_sanctionsList != address(0)) {
require(
!ISanctionsList(_sanctionsList).isSanctioned(user),
"WSL: sanctioned"
);
}
_;
}
/**
* @dev upgradeable pattern contract`s initializer
*/
// solhint-disable func-name-mixedcase
function __WithSanctionsList_init(
address _accesControl,
address _sanctionsList
) internal onlyInitializing {
__WithMidasAccessControl_init(_accesControl);
__WithSanctionsList_init_unchained(_sanctionsList);
}
/**
* @dev upgradeable pattern contract`s initializer unchained
*/
// solhint-disable func-name-mixedcase
function __WithSanctionsList_init_unchained(address _sanctionsList)
internal
onlyInitializing
{
sanctionsList = _sanctionsList;
}
/**
* @notice updates `sanctionsList` address.
* can be called only from permissioned actor that have
* `sanctionsListAdminRole()` role
* @param newSanctionsList new sanctions list address
*/
function setSanctionsList(address newSanctionsList) external {
_onlyRole(sanctionsListAdminRole(), msg.sender);
sanctionsList = newSanctionsList;
emit SetSanctionsList(msg.sender, newSanctionsList);
}
/**
* @notice AC role of sanctions list admin
* @dev address that have this role can use `setSanctionsList`
* @return role bytes32 role
*/
function sanctionsListAdminRole() public view virtual returns (bytes32);
}