mirror of
https://github.com/tornadocash/tornado-anonymity-mining.git
synced 2024-11-25 03:11:51 +01:00
updates
This commit is contained in:
parent
01ca620e7c
commit
5a82105f24
@ -17,8 +17,9 @@ contract TornadoProxy {
|
|||||||
|
|
||||||
enum InstanceState { Disabled, Enabled, Mineable }
|
enum InstanceState { Disabled, Enabled, Mineable }
|
||||||
struct Instance {
|
struct Instance {
|
||||||
address instance;
|
ITornadoInstance instance;
|
||||||
InstanceState state;
|
InstanceState state;
|
||||||
|
bool isERC20;
|
||||||
}
|
}
|
||||||
|
|
||||||
ITornadoTrees public tornadoTrees;
|
ITornadoTrees public tornadoTrees;
|
||||||
@ -39,7 +40,7 @@ contract TornadoProxy {
|
|||||||
governance = _governance;
|
governance = _governance;
|
||||||
|
|
||||||
for (uint256 i = 0; i < _instances.length; i++) {
|
for (uint256 i = 0; i < _instances.length; i++) {
|
||||||
instances[ITornadoInstance(_instances[i].instance)] = _instances[i].state;
|
_updateInstance(_instances[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +51,9 @@ contract TornadoProxy {
|
|||||||
) external payable {
|
) external payable {
|
||||||
require(instances[_tornado] != InstanceState.Disabled, "The instance is not supported");
|
require(instances[_tornado] != InstanceState.Disabled, "The instance is not supported");
|
||||||
|
|
||||||
|
IERC20(_tornado.token()).safeTransferFrom(msg.sender, address(this), _tornado.denomination());
|
||||||
_tornado.deposit{ value: msg.value }(_commitment);
|
_tornado.deposit{ value: msg.value }(_commitment);
|
||||||
|
|
||||||
if (instances[_tornado] == InstanceState.Mineable) {
|
if (instances[_tornado] == InstanceState.Mineable) {
|
||||||
tornadoTrees.registerDeposit(address(_tornado), _commitment);
|
tornadoTrees.registerDeposit(address(_tornado), _commitment);
|
||||||
}
|
}
|
||||||
@ -75,13 +78,13 @@ contract TornadoProxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateInstance(ITornadoInstance _instance, InstanceState _state) external onlyGovernance {
|
function updateInstance(Instance calldata _instance) external onlyGovernance {
|
||||||
instances[_instance] = _state;
|
_updateInstance(_instance);
|
||||||
emit InstanceStateUpdate(address(_instance), _state);
|
emit InstanceStateUpdate(address(_instance), _state);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setTornadoTreesContract(address _instance) external onlyGovernance {
|
function setTornadoTreesContract(address _tornadoTrees) external onlyGovernance {
|
||||||
tornadoTrees = ITornadoTrees(_instance);
|
tornadoTrees = ITornadoTrees(_tornadoTrees);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Method to claim junk and accidentally sent tokens
|
/// @dev Method to claim junk and accidentally sent tokens
|
||||||
@ -105,4 +108,12 @@ contract TornadoProxy {
|
|||||||
_token.safeTransfer(_to, balance);
|
_token.safeTransfer(_to, balance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _updateInstance(Instance memory _tornado) internal {
|
||||||
|
instances[_tornado.instance] = _tornado.state;
|
||||||
|
if (_tornado.isERC20) {
|
||||||
|
IERC20 token = IERC20(_tornado.instance.token());
|
||||||
|
token.safeApprove(address(_tornado.instance), uint256(-1));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,10 @@
|
|||||||
pragma solidity ^0.6.0;
|
pragma solidity ^0.6.0;
|
||||||
|
|
||||||
interface ITornadoInstance {
|
interface ITornadoInstance {
|
||||||
|
function token() external returns (address);
|
||||||
|
|
||||||
|
function denomination() external returns (uint256);
|
||||||
|
|
||||||
function deposit(bytes32 commitment) external payable;
|
function deposit(bytes32 commitment) external payable;
|
||||||
|
|
||||||
function withdraw(
|
function withdraw(
|
||||||
|
Loading…
Reference in New Issue
Block a user