mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 13:16:42 +00:00
Create no no
This commit is contained in:
parent
891bbad9ce
commit
1894470c11
1 changed files with 60 additions and 0 deletions
60
no no
Normal file
60
no no
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity ^0.8.17;
|
||||
|
||||
contract EmployeeStorage {
|
||||
uint16 private shares;
|
||||
uint32 private salary;
|
||||
uint256 public idNumber;
|
||||
string public name;
|
||||
|
||||
constructor(uint16 _shares, string memory _name, uint32 _salary, uint _idNumber) {
|
||||
shares = _shares;
|
||||
name = _name;
|
||||
salary = _salary;
|
||||
idNumber = _idNumber;
|
||||
}
|
||||
|
||||
function viewShares() public view returns (uint16) {
|
||||
return shares;
|
||||
}
|
||||
|
||||
function viewSalary() public view returns (uint32) {
|
||||
return salary;
|
||||
}
|
||||
|
||||
error TooManyShares(uint16 _shares);
|
||||
function grantShares(uint16 _newShares) public {
|
||||
if (_newShares > 5000) {
|
||||
revert("Too many shares");
|
||||
} else if (shares + _newShares > 5000) {
|
||||
revert TooManyShares(shares + _newShares);
|
||||
}
|
||||
shares += _newShares;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not modify this function. It is used to enable the unit test for this pin
|
||||
* to check whether or not you have configured your storage variables to make
|
||||
* use of packing.
|
||||
*
|
||||
* If you wish to cheat, simply modify this function to always return `0`
|
||||
* I'm not your boss ¯\_(ツ)_/¯
|
||||
*
|
||||
* Fair warning though, if you do cheat, it will be on the blockchain having been
|
||||
* deployed by you wallet....FOREVER!
|
||||
*/
|
||||
function checkForPacking(uint _slot) public view returns (uint r) {
|
||||
assembly {
|
||||
r := sload (_slot)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Warning: Anyone can use this function at any time!
|
||||
*/
|
||||
function debugResetShares() public {
|
||||
shares = 1000;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in a new issue