This repository has been archived by the owner on Dec 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
VerifyTier.sol
57 lines (52 loc) · 2.05 KB
/
VerifyTier.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
// SPDX-License-Identifier: CAL
pragma solidity =0.8.10;
import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
import "./ReadOnlyTier.sol";
import "../verify/libraries/VerifyConstants.sol";
import {State, Verify} from "../verify/Verify.sol";
import "./libraries/TierReport.sol";
/// @title VerifyTier
///
/// @dev A contract that is `VerifyTier` expects to derive tiers from the time
/// the account was approved by the underlying `Verify` contract. The approval
/// block numbers defer to `State.since` returned from `Verify.state`.
contract VerifyTier is ReadOnlyTier, Initializable {
/// Result of initializing.
event Initialize(
/// `msg.sender` that initialized the contract.
address sender,
/// The `Verify` contract checked for reports.ww
address verify
);
/// The contract to check to produce reports.
Verify private verify;
/// Sets the `verify` contract.
/// @param verify_ The contract to check to produce reports.
function initialize(address verify_) external initializer {
require(verify_ != address(0), "0_ADDRESS");
verify = Verify(verify_);
emit Initialize(msg.sender, verify_);
}
/// Every tier will be the `State.since` block if `account_` is approved
/// otherwise every tier will be uninitialized.
/// @inheritdoc ITier
function report(address account_) public view override returns (uint256) {
State memory state_ = verify.state(account_);
if (
// This is comparing an enum variant so it must be equal.
// slither-disable-next-line incorrect-equality
verify.statusAtBlock(state_, block.number) ==
VerifyConstants.STATUS_APPROVED
) {
return
TierReport.updateBlocksForTierRange(
TierConstants.NEVER_REPORT,
TierConstants.TIER_ZERO,
TierConstants.TIER_EIGHT,
state_.approvedSince
);
} else {
return TierConstants.NEVER_REPORT;
}
}
}