-
Notifications
You must be signed in to change notification settings - Fork 670
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity ^0.8.12; | ||
|
||
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | ||
|
||
contract TestERC20 is ERC20 { | ||
uint8 private immutable __decimals; | ||
|
||
constructor(uint8 _decimals) ERC20("TestERC20", "T20") { | ||
_mint(msg.sender, 1000000000000000000000000); | ||
__decimals = _decimals; | ||
} | ||
|
||
function decimals() public view override returns (uint8) { | ||
return __decimals; | ||
} | ||
|
||
function sudoMint(address _to, uint256 _amount) external { | ||
_mint(_to, _amount); | ||
} | ||
|
||
function sudoTransfer(address _from, address _to) external { | ||
_transfer(_from, _to, balanceOf(_from)); | ||
} | ||
|
||
function sudoApprove(address _from, address _to, uint256 _amount) external { | ||
_approve(_from, _to, _amount); | ||
} | ||
} |
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,22 @@ | ||
import { GasCheckCollector } from './GasChecker' | ||
import { createAddress } from '../test/testutils' | ||
import { ethers } from 'hardhat' | ||
import { TestERC20, TestERC20__factory } from '../typechain' | ||
|
||
// TODO: NOTE: Must be executed separately as otherwise test will reuse SimpleAccount | ||
context.only('ERC-20 Token related', function () { | ||
let token: TestERC20 | ||
|
||
before(async function () { | ||
await GasCheckCollector.init() | ||
GasCheckCollector.inst.createJsonResult = true | ||
token = await new TestERC20__factory(ethers.provider.getSigner()).deploy(18) | ||
}) | ||
|
||
it('simple 1', async function () { | ||
const destEoa = createAddress() | ||
const tx = await token.transfer(destEoa, 100) | ||
const receipt = await ethers.provider.getTransactionReceipt(tx.hash) | ||
console.log(`ERC-20 EOA -> EOA transfer: status = ${receipt.status}; gasUsed = ${receipt.gasUsed.toString()}; txid = ${receipt.transactionHash}`) | ||
}) | ||
}) |