_updateInstance updates

This commit is contained in:
Alexey 2021-03-12 16:09:05 +04:00 committed by Alexey Pertsev
parent 44e9d7d645
commit b9570ea3c3

View File

@ -90,7 +90,6 @@ contract TornadoProxy {
function updateInstance(Tornado calldata _tornado) external onlyGovernance { function updateInstance(Tornado calldata _tornado) external onlyGovernance {
_updateInstance(_tornado); _updateInstance(_tornado);
emit InstanceStateUpdate(_tornado.addr, _tornado.instance.state);
} }
function setTornadoTreesContract(address _tornadoTrees) external onlyGovernance { function setTornadoTreesContract(address _tornadoTrees) external onlyGovernance {
@ -124,7 +123,14 @@ contract TornadoProxy {
if (_tornado.instance.isERC20) { if (_tornado.instance.isERC20) {
IERC20 token = IERC20(_tornado.addr.token()); IERC20 token = IERC20(_tornado.addr.token());
require(token == _tornado.instance.token, "Incorrect token"); require(token == _tornado.instance.token, "Incorrect token");
uint256 allowance = token.allowance(address(this), address(_tornado.addr));
if (_tornado.instance.state != InstanceState.Disabled && allowance == 0) {
token.safeApprove(address(_tornado.addr), uint256(-1)); token.safeApprove(address(_tornado.addr), uint256(-1));
} else if (_tornado.instance.state == InstanceState.Disabled && allowance != 0) {
token.safeApprove(address(_tornado.addr), 0);
} }
} }
emit InstanceStateUpdate(_tornado.addr, _tornado.instance.state);
}
} }