Skip to content

Commit

Permalink
Add training management with events and mappings to Controller contract
Browse files Browse the repository at this point in the history
  • Loading branch information
schcriher committed Aug 24, 2024
1 parent 083a170 commit 3974511
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/hardhat/contracts/Controller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,21 @@ contract Controller is Ownable {

event Deposit(address indexed sender, uint256 amount);
event Withdrawal(address indexed receiver, uint256 amount);
event NewTraining(uint256 id, string name);

//--------------------------------------------------------------

mapping(address => bool) public members;

struct Training {
uint256 id;
string name;
}
Training[] public trainings;
uint256 private lastTrainingID = 0;

mapping(address => uint256[]) public performed;

//--------------------------------------------------------------

constructor() Ownable() {}
Expand All @@ -40,6 +52,13 @@ contract Controller is Ownable {

//--------------------------------------------------------------

function addTraining(string calldata name) external {
trainings.push(Training({ id: ++lastTrainingID, name: name }));
emit NewTraining(lastTrainingID, name);
}

//--------------------------------------------------------------

function withdraw(uint256 _amount) external {
require(address(this).balance >= _amount, "Insufficient balance");

Expand Down

0 comments on commit 3974511

Please sign in to comment.