Skip to content

Commit

Permalink
chore: cleanup (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
deluca-mike authored Dec 10, 2021
1 parent de7fc2c commit 3e5f4f1
Show file tree
Hide file tree
Showing 11 changed files with 170 additions and 166 deletions.
50 changes: 25 additions & 25 deletions config/ci.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
{
"language": "Solidity",
"sources": {
"src/ERC20.sol": {
"urls": ["src/ERC20.sol"]
"language": "Solidity",
"sources": {
"src/ERC20.sol": {
"urls": ["src/ERC20.sol"]
},
"src/test/ERC20.t.sol": {
"urls": ["src/test/ERC20.t.sol"]
}
},
"src/test/ERC20.t.sol": {
"urls": ["src/test/ERC20.t.sol"]
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"abi",
"evm.bytecode",
"evm.deployedBytecode"
],
"": [
"ast"
]
}
}
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"abi",
"evm.bytecode",
"evm.deployedBytecode"
],
"": [
"ast"
]
}
}
}
}
48 changes: 24 additions & 24 deletions config/dev.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
{
"language": "Solidity",
"sources": {
"src/ERC20.sol": {
"urls": ["src/ERC20.sol"]
"language": "Solidity",
"sources": {
"src/ERC20.sol": {
"urls": ["src/ERC20.sol"]
},
"src/test/ERC20.t.sol": {
"urls": ["src/test/ERC20.t.sol"]
}
},
"src/test/ERC20.t.sol": {
"urls": ["src/test/ERC20.t.sol"]
"settings": {
"optimizer": {
"enabled": false
},
"outputSelection": {
"*": {
"*": [
"abi",
"metadata",
"evm.bytecode",
"evm.deployedBytecode",
"evm.gasEstimates"
],
"": ["ast"]
}
}
}
},
"settings": {
"optimizer": {
"enabled": false
},
"outputSelection": {
"*": {
"*": [
"abi",
"metadata",
"evm.bytecode",
"evm.deployedBytecode",
"evm.gasEstimates"
],
"": ["ast"]
}
}
}
}
58 changes: 29 additions & 29 deletions config/prod.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
{
"language": "Solidity",
"sources": {
"src/ERC20.sol": {
"urls": ["src/ERC20.sol"]
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"abi",
"devdoc",
"userdoc",
"metadata",
"evm.bytecode",
"evm.deployedBytecode",
"evm.gasEstimates"
],
"": [
"ast"
]
}
"language": "Solidity",
"sources": {
"src/ERC20.sol": {
"urls": ["src/ERC20.sol"]
}
},
"metadata": {
"bytecodeHash": "none"
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"abi",
"devdoc",
"userdoc",
"metadata",
"evm.bytecode",
"evm.deployedBytecode",
"evm.gasEstimates"
],
"": [
"ast"
]
}
},
"metadata": {
"bytecodeHash": "none"
}
}
}
}
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ source: src
packages:
- path: src/ERC20.sol
contractName: ERC20
customChecksum: 0x98d4afd18b750d8da28fe9c2baff010a76336cd20c085c15457a9f599de21aec
customChecksum: 0xc98bdfa894c6adc0616f92279032e0230473ab4077f221f8c3539c5a807cb147
customDescription: ERC-20 Artifacts and ABIs
56 changes: 28 additions & 28 deletions src/ERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.7;
import { IERC20 } from "./interfaces/IERC20.sol";

/**
* @title Modern and gas efficient ERC-20 implementation.
* @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.
*/
Expand All @@ -21,59 +21,59 @@ contract ERC20 is IERC20 {

mapping(address => mapping(address => uint256)) public override allowance;

constructor(string memory _name, string memory _symbol, uint8 _decimals) {
name = _name;
symbol = _symbol;
decimals = _decimals;
constructor(string memory name_, string memory symbol_, uint8 decimals_) {
name = name_;
symbol = symbol_;
decimals = decimals_;
}

/**************************/
/*** External Functions ***/
/**************************/
function approve(address spender, uint256 amount) external override returns (bool) {
_approve(msg.sender, spender, amount);

function approve(address spender_, uint256 amount_) external override returns (bool success_) {
_approve(msg.sender, spender_, amount_);
return true;
}

function transfer(address to, uint256 amount) external override returns (bool) {
_transfer(msg.sender, to, amount);
function transfer(address to_, uint256 amount_) external override returns (bool success_) {
_transfer(msg.sender, to_, amount_);
return true;
}

function transferFrom(address owner, address recipient, uint256 amount) external override returns (bool) {
_approve(owner, msg.sender, allowance[owner][msg.sender] - amount);
_transfer(owner, recipient, amount);
function transferFrom(address owner_, address recipient_, uint256 amount_) external override returns (bool success_) {
_approve(owner_, msg.sender, allowance[owner_][msg.sender] - amount_);
_transfer(owner_, recipient_, amount_);
return true;
}

/**************************/
/*** Internal Functions ***/
/**************************/
function _approve(address owner, address spender, uint256 amount) internal {
emit Approval(owner, spender, allowance[owner][spender] = amount);

function _approve(address owner_, address spender_, uint256 amount_) internal {
emit Approval(owner_, spender_, allowance[owner_][spender_] = amount_);
}

function _transfer(address owner, address recipient, uint256 amount) internal {
balanceOf[owner] -= amount;
balanceOf[recipient] += amount;
function _transfer(address owner_, address recipient_, uint256 amount_) internal {
balanceOf[owner_] -= amount_;
balanceOf[recipient_] += amount_;

emit Transfer(owner, recipient, amount);
emit Transfer(owner_, recipient_, amount_);
}

function _mint(address recipient, uint256 amount) internal {
totalSupply += amount;
balanceOf[recipient] += amount;
function _mint(address recipient_, uint256 amount_) internal {
totalSupply += amount_;
balanceOf[recipient_] += amount_;

emit Transfer(address(0), recipient, amount);
emit Transfer(address(0), recipient_, amount_);
}

function _burn(address owner, uint256 amount) internal {
balanceOf[owner] -= amount;
totalSupply -= amount;
function _burn(address owner_, uint256 amount_) internal {
balanceOf[owner_] -= amount_;
totalSupply -= amount_;

emit Transfer(owner, address(0), amount);
emit Transfer(owner_, address(0), amount_);
}

}
64 changes: 33 additions & 31 deletions src/interfaces/IERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ pragma solidity ^0.8.7;
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.
* @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.
*/
event Transfer(address indexed from, address indexed to, uint256 amount);

/**
* @dev Emits an event indicating that one account has set the allowance of another account over their tokens.
* @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.
Expand All @@ -23,61 +23,63 @@ interface IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
function name() external view returns (string memory name_);

/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
function symbol() external view returns (string memory symbol_);

/**
* @dev Returns the decimal precision used by the token.
*/
function decimals() external view returns (uint8);
function decimals() external view returns (uint8 decimals_);

/**
* @dev Returns the total amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
function totalSupply() external view returns (uint256 totalSupply_);

/**
* @dev Returns the amount of tokens owned by a given account.
* @param account Account that owns the tokens.
* @param account_ Account that owns the tokens.
*/
function balanceOf(address account) external view returns (uint256);
function balanceOf(address account_) external view returns (uint256 balance_);

/**
* @dev Function that returns the allowance that one account has given another over their tokens.
* @param owner Account that tokens are approved from.
* @param spender Account that tokens are approved for.
* @param owner_ Account that tokens are approved from.
* @param spender_ Account that tokens are approved for.
*/
function allowance(address owner, address spender) external view returns (uint256);
function allowance(address owner_, address spender_) external view returns (uint256 allowance_);

/**
* @dev Function that allows one account to set the allowance of another account over their tokens.
* @dev Emits an {Approval} event.
* @param spender Account that tokens are approved for.
* @param amount Amount of tokens that have been approved.
* @dev Function that allows one account to set the allowance of another account over their tokens.
* @dev 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.
*/
function approve(address spender, uint256 amount) external returns (bool);
function approve(address spender_, uint256 amount_) external returns (bool success_);

/**
* @dev Moves an amount of tokens from `msg.sender` to a specified account.
* @dev Emits a {Transfer} event.
* @param recipient Account that recieves tokens.
* @param amount Amount of tokens that are transferred.
* @return Boolean amount indicating whether the operation succeeded.
* @dev Moves an amount of tokens from `msg.sender` to a specified account.
* @dev 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.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
function transfer(address recipient_, uint256 amount_) external returns (bool success_);

/**
* @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.
* @param owner Account that tokens are moving from.
* @param recipient Account that recieves tokens.
* @param amount Amount of tokens that are transferred.
* @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.
* @param owner_ Account that tokens are moving from.
* @param recipient_ Account that receives tokens.
* @param amount_ Amount of tokens that are transferred.
* @return success_ Boolean indicating whether the operation succeeded.
*/
function transferFrom(address owner, address recipient, uint256 amount) external returns (bool);
function transferFrom(address owner_, address recipient_, uint256 amount_) external returns (bool success_);

}
2 changes: 1 addition & 1 deletion src/test/ERC20.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { MockERC20 } from "./mocks/MockERC20.sol";
import { InvariantTest } from "./utils/InvariantTest.sol";

contract ERC20Test is DSTest {

MockERC20 token;

address internal immutable self = address(this);
Expand Down
Loading

0 comments on commit 3e5f4f1

Please sign in to comment.