This commit is contained in:
Roman Storm 2019-11-23 01:20:08 -08:00
parent b5609c30c5
commit db6a47f4fb
2 changed files with 6 additions and 4 deletions

View File

@ -8,7 +8,6 @@ const { web3, fetcher } = require('./instances')
async function relay (req, resp) {
const { proof, args, contract } = req.body
console.log(proof, args, contract)
const gasPrices = fetcher.gasPrices
let { valid , reason } = isValidProof(proof)
if (!valid) {
@ -37,7 +36,7 @@ async function relay (req, resp) {
toBN(args[4]),
toBN(args[5])
]
console.log('root, nullifierHash, recipient, relayer, fee, refund', fee.toString(), refund)
console.log('fee, refund', fee.toString(), refund.toString())
if (currency === 'eth' && !refund.isZero()) {
return resp.status(400).json({ error: 'Cannot send refund for eth currency.' })
}

View File

@ -65,11 +65,14 @@ function isEnoughFee({ gas, gasPrices, currency, refund, ethPrices, fee }) {
break
}
case 'dai': {
desiredFee = expense.add(refund).mul(toBN(ethPrices.dai)).div(toBN(10 ** 18))
desiredFee =
expense.add(refund)
.mul(toBN(10 ** 18))
.div(toBN(ethPrices.dai))
break
}
}
console.log('desired fee', desiredFee)
console.log('desired fee', desiredFee.toString())
if (fee.lt(desiredFee)) {
return { isEnough: false, reason: 'Not enough fee' }
}