mirror of
https://github.com/tornadocash/tornado-relayer.git
synced 2025-08-15 09:35:59 -04:00
upgrade config structure
This commit is contained in:
parent
fd458d4b19
commit
ced0b6a738
6 changed files with 78 additions and 27 deletions
30
src/utils.js
30
src/utils.js
|
@ -1,5 +1,5 @@
|
|||
const { isHexStrict, toBN, toWei } = require('web3-utils')
|
||||
const { mixers, relayerServiceFee } = require('../config')
|
||||
const { netId, mixers, relayerServiceFee } = require('../config')
|
||||
|
||||
function isValidProof(proof) {
|
||||
// validator expects `websnarkUtils.toSolidityInput(proof)` output
|
||||
|
@ -44,9 +44,12 @@ function isValidArgs(args) {
|
|||
}
|
||||
|
||||
function isKnownContract(contract) {
|
||||
for (let i = 0; i < mixers.length; i++) {
|
||||
if (mixers[i].address === contract) {
|
||||
return { valid: true, currency: mixers[i].currency, amount: mixers[i].amount }
|
||||
const mixers = getMixers()
|
||||
for (let currency of Object.keys(mixers)) {
|
||||
for (let amount of Object.keys(mixers[currency].mixerAddress)) {
|
||||
if (mixers[currency].mixerAddress[amount] === contract) {
|
||||
return { valid: true, currency, amount }
|
||||
}
|
||||
}
|
||||
}
|
||||
return { valid: false }
|
||||
|
@ -82,4 +85,21 @@ function isEnoughFee({ gas, gasPrices, currency, amount, refund, ethPrices, fee
|
|||
return { isEnough: true }
|
||||
}
|
||||
|
||||
module.exports = { isValidProof, isValidArgs, sleep, isKnownContract, isEnoughFee }
|
||||
function getMainnetTokens() {
|
||||
const tokens = mixers['netId1']
|
||||
const tokenAddresses = []
|
||||
const currencyLookup = {}
|
||||
Object.entries(tokens).map(([currency, data]) => {
|
||||
if (currency !== 'eth') {
|
||||
tokenAddresses.push(data.tokenAddress)
|
||||
currencyLookup[data.tokenAddress] = currency
|
||||
}
|
||||
})
|
||||
return { tokenAddresses, currencyLookup }
|
||||
}
|
||||
|
||||
function getMixers() {
|
||||
return mixers[`netId${netId}`]
|
||||
}
|
||||
|
||||
module.exports = { isValidProof, isValidArgs, sleep, isKnownContract, isEnoughFee, getMixers, getMainnetTokens }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue