43 lines
1.3 KiB
Solidity
43 lines
1.3 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.8.24;
|
|
|
|
/// @notice Minimal ERC-20 for escrow tests.
|
|
contract MockERC20 {
|
|
string public name = "Mock USDC";
|
|
string public symbol = "mUSDC";
|
|
uint8 public decimals = 6;
|
|
|
|
mapping(address => uint256) public balanceOf;
|
|
mapping(address => mapping(address => uint256)) public allowance;
|
|
|
|
function mint(address to, uint256 amount) external {
|
|
balanceOf[to] += amount;
|
|
}
|
|
|
|
function approve(address spender, uint256 amount) external returns (bool) {
|
|
allowance[msg.sender][spender] = amount;
|
|
return true;
|
|
}
|
|
|
|
function transfer(address to, uint256 amount) external returns (bool) {
|
|
_transfer(msg.sender, to, amount);
|
|
return true;
|
|
}
|
|
|
|
function transferFrom(address from, address to, uint256 amount) external returns (bool) {
|
|
uint256 allowed = allowance[from][msg.sender];
|
|
require(allowed >= amount, "ALLOWANCE");
|
|
if (allowed != type(uint256).max) {
|
|
allowance[from][msg.sender] = allowed - amount;
|
|
}
|
|
_transfer(from, to, amount);
|
|
return true;
|
|
}
|
|
|
|
function _transfer(address from, address to, uint256 amount) private {
|
|
require(balanceOf[from] >= amount, "BALANCE");
|
|
balanceOf[from] -= amount;
|
|
balanceOf[to] += amount;
|
|
}
|
|
}
|