You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.1 KiB
39 lines
1.1 KiB
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.8.19;
|
|
|
|
import {ERC20} from "../../token/ERC20/ERC20.sol";
|
|
import {Address} from "../../utils/Address.sol";
|
|
|
|
contract ERC20Reentrant is ERC20("TEST", "TST") {
|
|
enum Type {
|
|
No,
|
|
Before,
|
|
After
|
|
}
|
|
|
|
Type private _reenterType;
|
|
address private _reenterTarget;
|
|
bytes private _reenterData;
|
|
|
|
function scheduleReenter(Type when, address target, bytes calldata data) external {
|
|
_reenterType = when;
|
|
_reenterTarget = target;
|
|
_reenterData = data;
|
|
}
|
|
|
|
function functionCall(address target, bytes memory data) public returns (bytes memory) {
|
|
return Address.functionCall(target, data);
|
|
}
|
|
|
|
function _update(address from, address to, uint256 amount) internal override {
|
|
if (_reenterType == Type.Before) {
|
|
_reenterType = Type.No;
|
|
functionCall(_reenterTarget, _reenterData);
|
|
}
|
|
super._update(from, to, amount);
|
|
if (_reenterType == Type.After) {
|
|
_reenterType = Type.No;
|
|
functionCall(_reenterTarget, _reenterData);
|
|
}
|
|
}
|
|
}
|
|
|