-
Notifications
You must be signed in to change notification settings - Fork 23
/
ERC20SnapshotModule.sol
80 lines (72 loc) · 2.74 KB
/
ERC20SnapshotModule.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
//SPDX-License-Identifier: MPL-2.0
pragma solidity ^0.8.20;
import "../../security/AuthorizationModule.sol";
import "../../internal/ERC20SnapshotModuleInternal.sol";
/**
* @title Snapshot module
* @dev
*
* Useful to take a snapshot of token holder balance and total supply at a specific time
*/
abstract contract ERC20SnapshotModule is
ERC20SnapshotModuleInternal,
AuthorizationModule
{
/* ============ State Variables ============ */
bytes32 public constant SNAPSHOOTER_ROLE = keccak256("SNAPSHOOTER_ROLE");
/* ============ Initializer Function ============ */
function __ERC20SnasphotModule_init_unchained() internal onlyInitializing {
// no variable to initialize
}
/*//////////////////////////////////////////////////////////////
PUBLIC/EXTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/
/**
* @notice
* Schedule a snapshot at the given time specified as a number of seconds since epoch.
* The time cannot be before the time of the latest scheduled, but not yet created snapshot.
*/
function scheduleSnapshot(uint256 time) public onlyRole(SNAPSHOOTER_ROLE) {
_scheduleSnapshot(time);
}
/**
* @notice
* Schedule a snapshot at the given time specified as a number of seconds since epoch.
* The time cannot be before the time of the latest scheduled, but not yet created snapshot.
*/
function scheduleSnapshotNotOptimized(
uint256 time
) public onlyRole(SNAPSHOOTER_ROLE) {
_scheduleSnapshotNotOptimized(time);
}
/**
* @notice
* Reschedule the scheduled snapshot, but not yet created snapshot with the given oldTime to be created at the given newTime specified as a number of seconds since epoch.
* The newTime cannot be before the time of the previous scheduled, but not yet created snapshot, or after the time fo the next scheduled snapshot.
*/
function rescheduleSnapshot(
uint256 oldTime,
uint256 newTime
) public onlyRole(SNAPSHOOTER_ROLE) {
_rescheduleSnapshot(oldTime, newTime);
}
/**
* @notice
* Cancel creation of the scheduled snapshot, but not yet created snapshot with the given time.
* There should not be any other snapshots scheduled after this one.
*/
function unscheduleLastSnapshot(
uint256 time
) public onlyRole(SNAPSHOOTER_ROLE) {
_unscheduleLastSnapshot(time);
}
/**
* @notice
* Cancel creation of the scheduled snapshot, but not yet created snapshot with the given time.
*/
function unscheduleSnapshotNotOptimized(
uint256 time
) public onlyRole(SNAPSHOOTER_ROLE) {
_unscheduleSnapshotNotOptimized(time);
}
}