-
Notifications
You must be signed in to change notification settings - Fork 747
/
Copy pathSystem.sol
104 lines (82 loc) · 3.49 KB
/
System.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
pragma solidity 0.6.4;
import "./interface/ISystemReward.sol";
import "./interface/IRelayerHub.sol";
import "./interface/ILightClient.sol";
contract System {
bool public alreadyInit;
uint32 public constant CODE_OK = 0;
uint32 public constant ERROR_FAIL_DECODE = 100;
uint8 constant public BIND_CHANNELID = 0x01;
uint8 constant public TRANSFER_IN_CHANNELID = 0x02;
uint8 constant public TRANSFER_OUT_CHANNELID = 0x03;
uint8 constant public STAKING_CHANNELID = 0x08;
uint8 constant public GOV_CHANNELID = 0x09;
uint8 constant public SLASH_CHANNELID = 0x0b;
uint8 constant public CROSS_STAKE_CHANNELID = 0x10;
uint16 constant public bscChainID = 0x0060;
address public constant VALIDATOR_CONTRACT_ADDR = 0x0000000000000000000000000000000000001000;
address public constant SLASH_CONTRACT_ADDR = 0x0000000000000000000000000000000000001001;
address public constant SYSTEM_REWARD_ADDR = 0x0000000000000000000000000000000000001002;
address public constant LIGHT_CLIENT_ADDR = 0x0000000000000000000000000000000000001003;
address public constant TOKEN_HUB_ADDR = 0x0000000000000000000000000000000000001004;
address public constant INCENTIVIZE_ADDR=0x0000000000000000000000000000000000001005;
address public constant RELAYERHUB_CONTRACT_ADDR = 0x0000000000000000000000000000000000001006;
address public constant GOV_HUB_ADDR = 0x0000000000000000000000000000000000001007;
address public constant TOKEN_MANAGER_ADDR = 0x0000000000000000000000000000000000001008;
address public constant CROSS_CHAIN_CONTRACT_ADDR = 0x0000000000000000000000000000000000002000;
address public constant STAKING_CONTRACT_ADDR = 0x0000000000000000000000000000000000002001;
modifier onlyCoinbase() {
require(msg.sender == block.coinbase, "the message sender must be the block producer");
_;
}
modifier onlyNotInit() {
require(!alreadyInit, "the contract already init");
_;
}
modifier onlyInit() {
require(alreadyInit, "the contract not init yet");
_;
}
modifier onlySlash() {
require(msg.sender == SLASH_CONTRACT_ADDR, "the message sender must be slash contract");
_;
}
modifier onlyTokenHub() {
require(msg.sender == TOKEN_HUB_ADDR, "the message sender must be token hub contract");
_;
}
modifier onlyGov() {
require(msg.sender == GOV_HUB_ADDR, "the message sender must be governance contract");
_;
}
modifier onlyValidatorContract() {
require(msg.sender == VALIDATOR_CONTRACT_ADDR, "the message sender must be validatorSet contract");
_;
}
modifier onlyCrossChainContract() {
require(msg.sender == CROSS_CHAIN_CONTRACT_ADDR, "the message sender must be cross chain contract");
_;
}
modifier onlyRelayerIncentivize() {
require(msg.sender == INCENTIVIZE_ADDR, "the message sender must be incentivize contract");
_;
}
modifier onlyRelayer() {
require(IRelayerHub(RELAYERHUB_CONTRACT_ADDR).isRelayer(msg.sender), "the msg sender is not a relayer");
_;
}
modifier onlyWhiteLableRelayer() {
require(msg.sender == 0xb005741528b86F5952469d80A8614591E3c5B632 || msg.sender == 0x446AA6E0DC65690403dF3F127750da1322941F3e, "the msg sender is not a whitelabel relayer");
_;
}
modifier onlyTokenManager() {
require(msg.sender == TOKEN_MANAGER_ADDR, "the msg sender must be tokenManager");
_;
}
// Not reliable, do not use when need strong verify
function isContract(address addr) internal view returns (bool) {
uint size;
assembly { size := extcodesize(addr) }
return size > 0;
}
}