-
Notifications
You must be signed in to change notification settings - Fork 11.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add IERC20Metadata with name, symbol and decimals (#2561)
Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
- Loading branch information
Showing
4 changed files
with
37 additions
and
4 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 |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
pragma solidity ^0.8.0; | ||
|
||
import "./IERC20.sol"; | ||
import "./extensions/IERC20Metadata.sol"; | ||
import "../../utils/Context.sol"; | ||
|
||
/** | ||
|
@@ -29,7 +30,7 @@ import "../../utils/Context.sol"; | |
* functions have been added to mitigate the well-known issues around setting | ||
* allowances. See {IERC20-approve}. | ||
*/ | ||
contract ERC20 is Context, IERC20 { | ||
contract ERC20 is Context, IERC20, IERC20Metadata { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
frangio
Author
Contributor
|
||
mapping (address => uint256) private _balances; | ||
|
||
mapping (address => mapping (address => uint256)) private _allowances; | ||
|
@@ -56,15 +57,15 @@ contract ERC20 is Context, IERC20 { | |
/** | ||
* @dev Returns the name of the token. | ||
*/ | ||
function name() public view virtual returns (string memory) { | ||
function name() public view virtual override returns (string memory) { | ||
return _name; | ||
} | ||
|
||
/** | ||
* @dev Returns the symbol of the token, usually a shorter version of the | ||
* name. | ||
*/ | ||
function symbol() public view virtual returns (string memory) { | ||
function symbol() public view virtual override returns (string memory) { | ||
return _symbol; | ||
} | ||
|
||
|
@@ -81,7 +82,7 @@ contract ERC20 is Context, IERC20 { | |
* no way affects any of the arithmetic of the contract, including | ||
* {IERC20-balanceOf} and {IERC20-transfer}. | ||
*/ | ||
function decimals() public view virtual returns (uint8) { | ||
function decimals() public view virtual override returns (uint8) { | ||
return 18; | ||
} | ||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import "../IERC20.sol"; | ||
|
||
/** | ||
* @dev Interface for the optional metadata functions from the ERC20 standard. | ||
*/ | ||
interface IERC20Metadata is IERC20 { | ||
/** | ||
* @dev Returns the name of the token. | ||
*/ | ||
function name() external view returns (string memory); | ||
|
||
/** | ||
* @dev Returns the symbol of the token. | ||
*/ | ||
function symbol() external view returns (string memory); | ||
|
||
/** | ||
* @dev Returns the decimals places of the token. | ||
*/ | ||
function decimals() external view returns (uint8); | ||
} |
Isn't the
IERC20
interface implementation obsolete since it's already a parent ofIERC20Metadata
interface?