-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmployeeStorage.sol
More file actions
54 lines (43 loc) · 1.14 KB
/
EmployeeStorage.sol
File metadata and controls
54 lines (43 loc) · 1.14 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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract EmployeeStorage {
string public name;
uint16 private shares;
uint24 private salary;
uint256 public idNumber;
constructor(
string memory _name,
uint16 _shares,
uint24 _salary,
uint256 _idNumber
) {
name = _name;
shares = _shares;
salary = _salary;
idNumber = _idNumber;
}
function viewSalary() public view returns (uint24) {
return salary;
}
function viewShares() public view returns (uint16) {
return shares;
}
function grantShares(uint16 _newShares) public {
uint16 totalShares = shares + _newShares;
if (_newShares > 5000) {
revert("Too many shares");
}
if (totalShares > 5000) {
revert(string(abi.encodePacked("TooManyShares: ", totalShares)));
}
shares += _newShares;
}
function checkForPacking(uint256 _slot) public view returns (uint256 r) {
assembly {
r := sload(_slot)
}
}
function debugResetShares() public {
shares = 1000;
}
}