From cd7cfd834a90e72b3b2ddb9204d503bf90890f9e Mon Sep 17 00:00:00 2001 From: Ayanami Date: Fri, 11 Mar 2022 13:35:53 +0900 Subject: [PATCH] Fix withdrawal using relayer + Fixed number turnication error + Fixed netId detection --- cli.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cli.js b/cli.js index c78b8be..117f7f4 100755 --- a/cli.js +++ b/cli.js @@ -424,10 +424,13 @@ async function withdraw({ deposit, currency, amount, recipient, relayerURL, refu if (torPort) { options = { httpsAgent: new SocksProxyAgent('socks5h://127.0.0.1:' + torPort), headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0' } } } - const relayerStatus = await axios.get(relayerURL + '/status', options); + const [ relayerStatus, globalNetId ] = await Promise.all([ + axios.get(relayerURL + '/status', options), + web3.eth.net.getId() + ]); - const { rewardAccount, relayerNetId, ethPrices, tornadoServiceFee } = relayerStatus.data - assert(relayerNetId === netId || relayerNetId === '*', 'This relay is for different network'); + const { rewardAccount, netId, ethPrices, tornadoServiceFee } = relayerStatus.data + assert(netId === globalNetId || netId === '*', 'This relay is for different network'); console.log('Relay address:', rewardAccount); const gasPrice = await fetchGasPrice(); @@ -781,7 +784,7 @@ function calculateFee({ currency, gasPrice, amount, refund, ethPrices, relayerSe Math.floor(relayerServiceFee) === Number(relayerServiceFee) ? 0 : relayerServiceFee.toString().split('.')[1].length; const roundDecimal = 10 ** decimalsPoint; const total = toBN(fromDecimals({ amount, decimals })); - const feePercent = total.mul(toBN(relayerServiceFee * roundDecimal)).div(toBN(roundDecimal * 100)); + const feePercent = total.mul(toBN(Math.floor(relayerServiceFee * roundDecimal))).div(toBN(roundDecimal * 100)); const expense = toBN(gasPrice).mul(toBN(5e5)); let desiredFee; switch (currency) {