generated from FinTechIntro/HW-Template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4977ba9
commit b6e353f
Showing
31 changed files
with
1,253 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[submodule "hw/lib/forge-std"] | ||
path = hw/lib/forge-std | ||
url = https://github.com/foundry-rs/forge-std | ||
[submodule "hw/lib/openzeppelin-contracts"] | ||
path = hw/lib/openzeppelin-contracts | ||
url = https://github.com/OpenZeppelin/openzeppelin-contracts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"solidity.compileUsingRemoteVersion": "v0.8.9+commit.e5eed63a" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1 @@ | ||
# HW-Template | ||
|
||
Assignment Template for GitHub Classroom | ||
|
||
## Introduction | ||
|
||
This tutorial will guide you through creating your assignment locally and configuring it on GitHub Classroom. Follow the step-by-step instructions carefully to ensure each step is completed correctly. | ||
|
||
## Create An Assignment on GitHub | ||
1. Create a new repository by clicking the `Use this template` button. | ||
2. Rename the repository using the format `2024-Fall-HW*`. | ||
3. Choose repository visibility; `Public` is recommended. | ||
4. Design your assignment in the `src/` and `test/` folders. | ||
- Grading should be based on whether the Foundry tests pass or fail. | ||
- Do not support analyzing output content for grading. | ||
- If you install external libraries, run `forge remappings` to link them. | ||
5. Update the autograding configuration in `.github/workflows/test.yml`. | ||
- Copy the `Problem Template` and adjust the `name`, `id`, `test-name`, `command`, `timeout`, and `max-score`. | ||
- Add a new entry in `Autograding Reporter` (at the end of the YAML configuration). | ||
6. Commit the changes and push them to GitHub. | ||
7. Check the GitHub Actions and open the `Autograding Tests` workflow to ensure the auto-grading succeeds. | ||
|
||
![auto-grading-result](./images/auto-grading-result.png) | ||
|
||
## Create An Assignemnt on GitHub Classroom | ||
|
||
1. Go to the relevant GitHub Classroom page. | ||
2. Click the green `+ New Assignment` button. | ||
3. Set up the `Assignment basics` section. | ||
- Enter the assignment title using the format `2024-Fall-HW*``. | ||
- Select deadline, and select `This is a cutoff date`[1]. | ||
- Select individual / group assignment | ||
4. Setup `Starter code and environment` section | ||
- Select the repo for this assignment in the `Find a GitHub repository section`. | ||
- Choose repo visibility, recommend `Private`[2] access. | ||
5. Setup `Grading and feedback` section | ||
- Leave the `Add autograding tests` section empty, as grading rules are already configured. | ||
- Enter protected file path, recommend adding `.github/**/*` since grading rules should not be altered[3]. | ||
- Select `Enable feedback pull requests` to create PR on each assignment. | ||
6. Finish assignment creation, send the invitation code to the students and starting coding! | ||
|
||
|
||
NOTE: | ||
[1] Once the cutoff date option is selected, student will lose write access to their repository after deadline. | ||
[2] `Private` access means students will create private repositories when receiving the invitation link. | ||
[3] For CTF problems, the `src/` folder should be locked. If students need to fill in blanks in the source contract, consider locking the corresponding test files. | ||
|
||
## Check the Assignment Status on GitHub Classroom | ||
|
||
1. Check the students' repositories by clicking the `Repository` button on the right side. | ||
2. Provide feedback by clicking the `Feedback` button on the right side and leave comments on the PR. | ||
3. Verify whether students have submitted the assignment and review grading results. | ||
4. Check if students have altered any protected files or folders. | ||
|
||
There are several examples: | ||
|
||
- Students not submit the assignment. | ||
![hw-status-not-submitted](./images/hw-status-not-submitted.png) | ||
- Students complete the assignment | ||
![hw-status-submitted](./images/hw-status-submitted.png) | ||
- Student change the protected files and folders | ||
![hw-status-modify-files](./images/hw-status-modify-files.png) | ||
# 2024-Fall-DeFi-2024 |
Submodule openzeppelin-contracts
added at
eb4e86
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/ | ||
ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/ | ||
erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/ | ||
forge-std/=lib/openzeppelin-contracts/lib/forge-std/src/ | ||
openzeppelin-contracts/=lib/openzeppelin-contracts/ |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
interface IERC20 { | ||
event Transfer(address indexed from, address indexed to, uint256 value); | ||
event Approval(address indexed owner, address indexed spender, uint256 value); | ||
|
||
function totalSupply() external view returns (uint256); | ||
function balanceOf(address account) external view returns (uint256); | ||
function transfer(address to, uint256 amount) external returns (bool); | ||
function allowance(address owner, address spender) external view returns (uint256); | ||
function approve(address spender, uint256 amount) external returns (bool); | ||
function transferFrom(address from, address to, uint256 amount) external returns (bool); | ||
} | ||
|
||
contract GPUToken is IERC20 { | ||
string public name; | ||
string public symbol; | ||
uint8 public decimals = 18; | ||
uint256 private _totalSupply; | ||
address internal admin; | ||
|
||
mapping(address => uint256) private _balances; | ||
mapping(address => mapping(address => uint256)) private _allowances; | ||
|
||
constructor(string memory _name, string memory _symbol) { | ||
name = _name; | ||
symbol = _symbol; | ||
admin = msg.sender; | ||
} | ||
|
||
function totalSupply() external view override returns (uint256) { | ||
return _totalSupply; | ||
} | ||
|
||
function balanceOf(address account) external view override returns (uint256) { | ||
return _balances[account]; | ||
} | ||
|
||
function transfer(address to, uint256 amount) external override returns (bool) { | ||
_transfer(msg.sender, to, amount); | ||
return true; | ||
} | ||
|
||
function allowance(address owner, address spender) external view override returns (uint256) { | ||
return _allowances[owner][spender]; | ||
} | ||
|
||
function approve(address spender, uint256 amount) external override returns (bool) { | ||
_approve(msg.sender, spender, amount); | ||
return true; | ||
} | ||
|
||
function transferFrom(address from, address to, uint256 amount) external override returns (bool) { | ||
_approve(from, msg.sender, _allowances[from][msg.sender] - amount); | ||
_transfer(from, to, amount); | ||
return true; | ||
} | ||
|
||
function _transfer(address from, address to, uint256 amount) internal { | ||
require(from != address(0), "ERC20: transfer from the zero address"); | ||
require(to != address(0), "ERC20: transfer to the zero address"); | ||
require(_balances[from] >= amount, "ERC20: transfer amount exceeds balance"); | ||
|
||
uint256 value = _balances[from]; | ||
uint256 fromBalance = value - amount; | ||
uint256 toBalance = value + amount; | ||
|
||
_balances[from] = fromBalance; | ||
_balances[to] = toBalance; | ||
emit Transfer(from, to, amount); | ||
} | ||
|
||
function mint(address account, uint256 amount) public { | ||
require(admin == msg.sender, "caller not admin"); | ||
require(account != address(0), "ERC20: mint to the zero address"); | ||
|
||
_totalSupply += amount; | ||
_balances[account] += amount; | ||
emit Transfer(address(0), account, amount); | ||
} | ||
|
||
function _approve(address owner, address spender, uint256 amount) internal { | ||
require(owner != address(0), "ERC20: approve from the zero address"); | ||
require(spender != address(0), "ERC20: approve to the zero address"); | ||
|
||
_allowances[owner][spender] = amount; | ||
emit Approval(owner, spender, amount); | ||
} | ||
} |
Oops, something went wrong.