-
Notifications
You must be signed in to change notification settings - Fork 38
/
ex15.sol
46 lines (33 loc) · 1.19 KB
/
ex15.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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import "../exerciceTemplate.sol";
import "./Iex14Solution.sol";
/*
Exercice 14: Completing all the workshop in a single transaction!
In this exercice you should:
- Implement a contract that complies with interface Iex14Solution
- Call the appropriate function here to trigger collecting points
*/
contract ex15 is exerciceTemplate {
constructor(ERC20TD _TDERC20)
exerciceTemplate(_TDERC20)
{
}
function askForPoints()
public
{
// Checking that solution has no token yet
uint256 initialBalance = TDERC20.balanceOf(msg.sender);
require(initialBalance == 0, "Solution should start with 0 points");
// Calling the solution so that it solves the workshop
Iex14Solution callerSolution = Iex14Solution(msg.sender);
callerSolution.completeWorkshop();
// Checking that at least 10 exercices where validated
uint256 finalBalance = TDERC20.balanceOf(msg.sender);
uint256 decimals = TDERC20.decimals();
require(finalBalance >= 10**decimals *26, "Solution should end with at least than 26 points");
// Validating exercice
creditStudent(2, msg.sender);
validateExercice(msg.sender);
}
}