forked from MyBitFoundation/MyBit-Network.tech
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHashFunctions.sol
More file actions
179 lines (146 loc) · 3.77 KB
/
HashFunctions.sol
File metadata and controls
179 lines (146 loc) · 3.77 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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
pragma solidity ^0.4.24;
contract HashFunctions {
function toBytes(uint x)
external
pure
returns (bytes b) {
b = new bytes(32);
assembly { mstore(add(b, 32), x) }
}
function getMethodID(string _functionString)
public
pure
returns (bytes4) {
return bytes4(keccak256(abi.encodePacked(_functionString)));
}
function getAssetID(string _assetURI, uint _amountToRaise, bytes32 _operatorID)
public
view
returns(bytes32) {
return keccak256(abi.encodePacked(msg.sender, _amountToRaise, _operatorID, _assetURI));
}
function getOrderID(bytes _assetID, address _user, uint _amount, uint _price, bool _buyOrder)
external
pure
returns(bytes32) {
return keccak256(abi.encodePacked(_assetID, _user, _amount, _price, _buyOrder));
}
function getFunctionInitiatorHash(address _param1, address _param2, bytes32 _param3)
external
pure
returns(bytes32) {
return keccak256(abi.encodePacked(_param1, _param2, "destroy", _param3));
}
function uintHash(uint _param)
external
pure
returns (bytes32) {
return keccak256(abi.encodePacked(_param));
}
function getStakingID(address _staker, uint256 _blockNumber, uint256 _amount)
external
pure
returns (bytes32) {
return keccak256(abi.encodePacked(_staker, _blockNumber, _amount));
}
function stringHash(string _name)
external
pure
returns (bytes32){
return keccak256(abi.encodePacked(_name));
}
function addressHash(address _param)
external
pure
returns (bytes32) {
return keccak256(abi.encodePacked(_param));
}
function contractHash(string _name)
external
pure
returns (bytes32) {
return keccak256(abi.encodePacked("contract", _name));
}
function stringAddress(string _param, address _paramTwo)
external
pure
returns (bytes32) {
return keccak256(abi.encodePacked(_param, _paramTwo));
}
function stringString(string _param, string _paramTwo)
external
pure
returns (bytes32) {
return (keccak256(abi.encodePacked(_param, _paramTwo)));
}
function stringBytes(string _param, bytes32 _paramTwo)
external
pure
returns (bytes32) {
return keccak256(abi.encodePacked(_param, _paramTwo));
}
function stringUint(string _param, uint _paramTwo)
external
pure
returns (bytes32) {
return keccak256(abi.encodePacked(_param, _paramTwo));
}
function stringAddressAddress(string _param, address _paramTwo, address _paramThree)
external
pure
returns (bytes32) {
return keccak256(abi.encodePacked(_param, _paramTwo, _paramThree));
}
function stringBytesAddress(string _param, bytes32 _paramTwo, address _paramThree)
external
pure
returns (bytes32) {
return keccak256(abi.encodePacked(_param, _paramTwo, _paramThree));
}
function addressUintUint(address _param, uint _paramTwo, uint _paramThree)
external
pure
returns (bytes32) {
return keccak256(abi.encodePacked(_param, _paramTwo, _paramThree));
}
function getAuthorizeHash(address _contractAddress, address _owner, string _fnName, bytes32 _recipient)
external
pure
returns (bytes32) {
return keccak256(abi.encodePacked(_contractAddress, _owner, _fnName, _recipient));
}
function uintUint(uint _paramOne, uint _paramTwo)
external
pure
returns (bytes32) {
return keccak256(abi.encodePacked(_paramOne, _paramTwo));
}
function uintUintUint(uint _paramOne, uint _paramTwo, uint _paramThree)
external
pure
returns (bytes32) {
return keccak256(abi.encodePacked(_paramOne, _paramTwo, _paramThree));
}
function currentTime()
external
view
returns (uint) {
return now;
}
function nullBytes()
external
pure
returns (bytes32) {
return bytes32(0);
}
function nullAddress()
external
pure
returns (address) {
return address(0);
}
function ()
public {
revert();
}
}