Skip to content

Commit

Permalink
[Documentation] Add comments to mock tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
ayodeko committed Jul 9, 2024
1 parent ec1963b commit 3ddb8ce
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
16 changes: 16 additions & 0 deletions contracts/mocks/ERC20MockToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@ pragma solidity 0.8.25;
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

/// @title ERC20MockToken
/// @notice A mock ERC20 token for testing purposes, with minting and burning capabilities controlled by the owner.
/// @dev Extends the OpenZeppelin ERC20 and Ownable contracts.
contract ERC20MockToken is ERC20, Ownable {
/// @dev Custom decimal places for the mock token.
uint8 private immutable _decimals;

/// @notice Constructor to initialize the mock token with a name, symbol, and decimals.
/// @param name The name of the token.
/// @param symbol The symbol of the token.
/// @param decimals_ The number of decimal places for the token.
constructor(
string memory name,
string memory symbol,
Expand All @@ -15,14 +23,22 @@ contract ERC20MockToken is ERC20, Ownable {
_decimals = decimals_;
}

/// @notice Mints new tokens to the specified account.
/// @param account The address of the account to mint tokens to.
/// @param amount The amount of tokens to mint.
function mint(address account, uint256 amount) external onlyOwner {
_mint(account, amount);
}

/// @notice Burns tokens from the specified account.
/// @param account The address of the account to burn tokens from.
/// @param amount The amount of tokens to burn.
function burn(address account, uint256 amount) external onlyOwner {
_burn(account, amount);
}

/// @notice Returns the number of decimals used to get its user representation.
/// @return The number of decimals.
function decimals() public view override returns (uint8) {
return _decimals;
}
Expand Down
9 changes: 9 additions & 0 deletions contracts/mocks/ERC721MockToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@ pragma solidity 0.8.25;
import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

/// @title ERC721MockToken
/// @notice A mock ERC721 token for testing purposes, with minting capabilities controlled by the owner.
/// @dev Extends the OpenZeppelin ERC721 and Ownable contracts.
contract ERC721MockToken is ERC721, Ownable {
/// @dev Counter for tracking the next token ID to be minted.
uint256 private _nextTokenId;

/// @notice Constructor to initialize the mock token with a name and symbol.
/// @param name The name of the token.
/// @param symbol The symbol of the token.
constructor(
string memory name,
string memory symbol
) ERC721(name, symbol) Ownable(msg.sender) {}

/// @notice Mints a new token to the specified address.
/// @param to The address to mint the token to.
function safeMint(address to) public onlyOwner {
uint256 tokenId = _nextTokenId++;
_safeMint(to, tokenId);
Expand Down

0 comments on commit 3ddb8ce

Please sign in to comment.