From c3d599d9976144f0c20d25a14126741fdd2edea2 Mon Sep 17 00:00:00 2001 From: Michael De Luca <35537333+deluca-mike@users.noreply.github.com> Date: Fri, 24 Dec 2021 17:25:24 -0500 Subject: [PATCH] chore: Natspec, whitespace, checksum (#11) --- .circleci/config.yml | 40 +++++++++++++++++++-------------------- .gitignore | 5 ++++- src/ERC20.sol | 10 +++++++--- src/interfaces/IERC20.sol | 24 +++++++++++------------ src/test/ERC20.t.sol | 4 ++-- 5 files changed, 45 insertions(+), 38 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ba2dd91..45969f4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,24 +1,24 @@ version: 2.1 jobs: - dapp_test: - docker: - - image: bakii0499/dapptools:0.48.0-solc-0.8.7 - steps: - - run: - name: Checkout erc20 - command: | - GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git clone git@github.com:maple-labs/erc20.git . - git checkout $CIRCLE_BRANCH - - run: - name: Build and test contracts - command: | - GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git submodule update --init --recursive - ./test.sh -c ./config/ci.json - no_output_timeout: 60m + dapp_test: + docker: + - image: bakii0499/dapptools:0.48.0-solc-0.8.7 + steps: + - run: + name: Checkout erc20 + command: | + GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git clone git@github.com:maple-labs/erc20.git . + git checkout $CIRCLE_BRANCH + - run: + name: Build and test contracts + command: | + GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git submodule update --init --recursive + ./test.sh -c ./config/ci.json + no_output_timeout: 60m workflows: - version: 2 - test_all: - jobs: - - dapp_test: - context: seth + version: 2 + test_all: + jobs: + - dapp_test: + context: seth diff --git a/.gitignore b/.gitignore index b9af7e1..5d90bfc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ -/out +out/* hevm* .vscode/* +artifacts/* +docs/* +metadata.json diff --git a/src/ERC20.sol b/src/ERC20.sol index 6e3e8c8..78cd35e 100644 --- a/src/ERC20.sol +++ b/src/ERC20.sol @@ -5,7 +5,6 @@ import { IERC20 } from "./interfaces/IERC20.sol"; /** * @title Modern and gas efficient ERC-20 implementation. - * @dev Code taken from https://github.com/maple-labs/erc20 * @dev Acknowledgements to Solmate, OpenZeppelin, and DSS for inspiring this code. */ contract ERC20 is IERC20 { @@ -21,6 +20,11 @@ contract ERC20 is IERC20 { mapping(address => mapping(address => uint256)) public override allowance; + /** + * @param name_ The name of the token. + * @param symbol_ The symbol of the token. + * @param decimals_ The decimal precision used by the token. + */ constructor(string memory name_, string memory symbol_, uint8 decimals_) { name = name_; symbol = symbol_; @@ -36,8 +40,8 @@ contract ERC20 is IERC20 { return true; } - function transfer(address to_, uint256 amount_) external override returns (bool success_) { - _transfer(msg.sender, to_, amount_); + function transfer(address recipient_, uint256 amount_) external override returns (bool success_) { + _transfer(msg.sender, recipient_, amount_); return true; } diff --git a/src/interfaces/IERC20.sol b/src/interfaces/IERC20.sol index 6aca03d..39ba12e 100644 --- a/src/interfaces/IERC20.sol +++ b/src/interfaces/IERC20.sol @@ -6,19 +6,19 @@ interface IERC20 { /** * @dev Emits an event indicating that tokens have moved from one account to another. - * @param from Account that tokens have moved from. - * @param to Account that tokens have moved to. - * @param amount Amount of tokens that have been transferred. + * @param owner_ Account that tokens have moved from. + * @param recipient_ Account that tokens have moved to. + * @param amount_ Amount of tokens that have been transferred. */ - event Transfer(address indexed from, address indexed to, uint256 amount); + event Transfer(address indexed owner_, address indexed recipient_, uint256 amount_); /** * @dev Emits an event indicating that one account has set the allowance of another account over their tokens. - * @param owner Account that tokens are approved from. - * @param spender Account that tokens are approved for. - * @param amount Amount of tokens that have been approved. + * @param owner_ Account that tokens are approved from. + * @param spender_ Account that tokens are approved for. + * @param amount_ Amount of tokens that have been approved. */ - event Approval(address indexed owner, address indexed spender, uint256 amount); + event Approval(address indexed owner_, address indexed spender_, uint256 amount_); /** * @dev Returns the name of the token. @@ -55,7 +55,7 @@ interface IERC20 { /** * @dev Function that allows one account to set the allowance of another account over their tokens. - * @dev Emits an {Approval} event. + * Emits an {Approval} event. * @param spender_ Account that tokens are approved for. * @param amount_ Amount of tokens that have been approved. * @return success_ Boolean indicating whether the operation succeeded. @@ -64,7 +64,7 @@ interface IERC20 { /** * @dev Moves an amount of tokens from `msg.sender` to a specified account. - * @dev Emits a {Transfer} event. + * Emits a {Transfer} event. * @param recipient_ Account that receives tokens. * @param amount_ Amount of tokens that are transferred. * @return success_ Boolean indicating whether the operation succeeded. @@ -73,8 +73,8 @@ interface IERC20 { /** * @dev Moves a pre-approved amount of tokens from a sender to a specified account. - * @dev Emits a {Transfer} event. - * @dev Emits an {Approval} event. + * Emits a {Transfer} event. + * Emits an {Approval} event. * @param owner_ Account that tokens are moving from. * @param recipient_ Account that receives tokens. * @param amount_ Amount of tokens that are transferred. diff --git a/src/test/ERC20.t.sol b/src/test/ERC20.t.sol index 3b85343..5ca1639 100644 --- a/src/test/ERC20.t.sol +++ b/src/test/ERC20.t.sol @@ -39,7 +39,7 @@ contract ERC20Test is DSTest { } function prove_burn(address account, uint256 amount0, uint256 amount1) public { - if (amount1 > amount0) return; // Mint amount must exceed burn amount + if (amount1 > amount0) return; // Mint amount must exceed burn amount. token.mint(account, amount0); token.burn(account, amount1); @@ -70,7 +70,7 @@ contract ERC20Test is DSTest { } function prove_transferFrom(address to, uint256 approval, uint256 amount) public { - if (amount > approval) return; // Owner must approve for more than amount + if (amount > approval) return; // Owner must approve for more than amount. ERC20User owner = new ERC20User();