generated from hrkrshnn/tstore-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
MockTERC20.sol
72 lines (58 loc) · 2.17 KB
/
MockTERC20.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import {TERC20} from "src/TERC20.sol";
/// @dev WARNING! This mock is strictly intended for testing purposes only.
/// Do NOT copy anything here into production code unless you really know what you are doing.
contract MockTERC20 is TERC20 {
string internal _name;
string internal _symbol;
uint8 internal _decimals;
bytes32 internal immutable _nameHash;
constructor(string memory name_, string memory symbol_, uint8 decimals_) {
_name = name_;
_symbol = symbol_;
_decimals = decimals_;
_nameHash = keccak256(bytes(name_));
}
function _constantNameHash() internal view virtual override returns (bytes32) {
return _nameHash;
}
function name() public view virtual override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function decimals() public view virtual override returns (uint8) {
return _decimals;
}
function mint(address to, uint256 value) public virtual {
_mint(_brutalized(to), value);
}
function burn(address from, uint256 value) public virtual {
_burn(_brutalized(from), value);
}
function directTransfer(address from, address to, uint256 amount) public virtual {
_transfer(_brutalized(from), _brutalized(to), amount);
}
function directSpendAllowance(address owner, address spender, uint256 amount) public virtual {
_spendAllowance(_brutalized(owner), _brutalized(spender), amount);
}
function transfer(address to, uint256 amount) public virtual override returns (bool) {
return super.transfer(_brutalized(to), amount);
}
function transferFrom(address from, address to, uint256 amount)
public
virtual
override
returns (bool)
{
return super.transferFrom(_brutalized(from), _brutalized(to), amount);
}
function _brutalized(address a) internal view returns (address result) {
/// @solidity memory-safe-assembly
assembly {
result := or(a, shl(160, gas()))
}
}
}