From a889e29baedd6a656d82185144b7b34d5c6f1e7a Mon Sep 17 00:00:00 2001 From: Alexey Date: Tue, 17 Nov 2020 18:39:39 +0300 Subject: [PATCH] fix erc20 tornadoWithdraw --- src/worker.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/worker.js b/src/worker.js index 6ad4c37..e6e60c5 100644 --- a/src/worker.js +++ b/src/worker.js @@ -7,6 +7,7 @@ const { GasPriceOracle } = require('gas-price-oracle') const { Utils } = require('tornado-cash-anonymity-mining') const tornadoProxyABI = require('../abis/tornadoProxyABI.json') +const tornadoABI = require('../abis/tornadoABI.json') const miningABI = require('../abis/mining.abi.json') const swapABI = require('../abis/swap.abi.json') const { queue } = require('./queue') @@ -172,12 +173,18 @@ async function checkMiningFee({ args }) { async function getTxObject({ data }) { if (data.type === jobType.TORNADO_WITHDRAW) { - const tornadoProxyAddress = await resolver.resolve(torn.tornadoProxy.address) - const contract = new web3.eth.Contract(tornadoProxyABI, tornadoProxyAddress) - const calldata = contract.methods.withdraw(data.contract, data.proof, ...data.args).encodeABI() + let contract, calldata + if (getInstance(data.contract).currency === 'eth') { + const tornadoProxyAddress = await resolver.resolve(torn.tornadoProxy.address) + contract = new web3.eth.Contract(tornadoProxyABI, tornadoProxyAddress) + calldata = contract.methods.withdraw(data.contract, data.proof, ...data.args).encodeABI() + } else { + contract = new web3.eth.Contract(tornadoABI, data.contract) + calldata = contract.methods.withdraw(data.proof, ...data.args).encodeABI() + } return { value: data.args[5], - to: tornadoProxyAddress, + to: contract._address, data: calldata, } } else {