mirror of
https://github.com/tornadocash/tornado-relayer
synced 2024-02-02 15:04:06 +01:00
init check, add Governance contract
This commit is contained in:
parent
1f900843de
commit
2f79125dd1
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "relay",
|
||||
"version": "4.1.1",
|
||||
"version": "4.1.2",
|
||||
"description": "Relayer for Tornado.cash privacy solution. https://tornado.cash",
|
||||
"scripts": {
|
||||
"server": "node src/server.js",
|
||||
@ -29,7 +29,7 @@
|
||||
"gas-price-oracle": "^0.3.5",
|
||||
"ioredis": "^4.14.1",
|
||||
"node-fetch": "^2.6.7",
|
||||
"torn-token": "1.0.4",
|
||||
"torn-token": "1.0.6",
|
||||
"tornado-anonymity-mining": "^2.1.2",
|
||||
"tx-manager": "^0.4.1",
|
||||
"uuid": "^8.3.0",
|
||||
|
@ -18,6 +18,7 @@ module.exports = {
|
||||
tornadoServiceFee: Number(process.env.REGULAR_TORNADO_WITHDRAW_FEE),
|
||||
miningServiceFee: Number(process.env.MINING_SERVICE_FEE),
|
||||
rewardAccount: process.env.REWARD_ACCOUNT,
|
||||
governanceAddress: '0x5efda50f22d34F262c29268506C5Fa42cB56A1Ce',
|
||||
tornadoGoerliProxy: '0x454d870a72e29d5E5697f635128D18077BD04C60',
|
||||
gasLimits: {
|
||||
[jobType.TORNADO_WITHDRAW]: 390000,
|
||||
|
@ -10,6 +10,7 @@ const swapABI = require('../abis/swap.abi.json')
|
||||
const miningABI = require('../abis/mining.abi.json')
|
||||
const tornadoABI = require('../abis/tornadoABI.json')
|
||||
const tornadoProxyABI = require('../abis/tornadoProxyABI.json')
|
||||
const aggregatorAbi = require('../abis/Aggregator.abi.json')
|
||||
const { queue } = require('./queue')
|
||||
const { poseidonHash2, getInstance, fromDecimals, sleep } = require('./utils')
|
||||
const { jobType, status } = require('./constants')
|
||||
@ -26,6 +27,8 @@ const {
|
||||
miningServiceFee,
|
||||
tornadoServiceFee,
|
||||
tornadoGoerliProxy,
|
||||
governanceAddress,
|
||||
aggregatorAddress,
|
||||
} = require('./config')
|
||||
const ENSResolver = require('./resolver')
|
||||
const resolver = new ENSResolver()
|
||||
@ -195,15 +198,30 @@ async function checkMiningFee({ args }) {
|
||||
}
|
||||
}
|
||||
|
||||
async function isLatestProposalExecuted() {
|
||||
const PROPOSAL_EXECUTED_STATUS = 5
|
||||
const expectedProposalId = 10
|
||||
try {
|
||||
const aggregator = new web3.eth.Contract(aggregatorAbi, aggregatorAddress)
|
||||
const proposals = await aggregator.methods.getAllProposals(governanceAddress).call()
|
||||
const expectedProposal = proposals[expectedProposalId - 1]
|
||||
return expectedProposal && Number(expectedProposal['state']) === PROPOSAL_EXECUTED_STATUS
|
||||
} catch (e) {
|
||||
console.error(e.message)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getProxyContract() {
|
||||
let proxyAddress
|
||||
|
||||
if (netId === 5) {
|
||||
proxyAddress = tornadoGoerliProxy
|
||||
} else {
|
||||
proxyAddress = await resolver.resolve(torn.tornadoProxy.address)
|
||||
const latestProposalExecuted = await isLatestProposalExecuted()
|
||||
proxyAddress = latestProposalExecuted
|
||||
? await resolver.resolve(torn.tornadoRouter.address)
|
||||
: await resolver.resolve(torn.tornadoProxy.address)
|
||||
}
|
||||
|
||||
const contract = new web3.eth.Contract(tornadoProxyABI, proxyAddress)
|
||||
|
||||
return {
|
||||
|
@ -4887,10 +4887,10 @@ toidentifier@1.0.0:
|
||||
resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553"
|
||||
integrity sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==
|
||||
|
||||
torn-token@1.0.4:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.npmjs.org/torn-token/-/torn-token-1.0.4.tgz#c638b6899f3e899a3bdb1d7a04194b500f100c71"
|
||||
integrity sha512-3377n2Wi9TO9JfTzPBKi4j+gdyJ35NCNkELT+3nXZn56j6z6o/Fh9tuAlEaP9E24jhx4gewRSrhsdim8v9/hjg==
|
||||
torn-token@1.0.6:
|
||||
version "1.0.6"
|
||||
resolved "https://registry.yarnpkg.com/torn-token/-/torn-token-1.0.6.tgz#66cde5f85b611033918c807b4a8d9d4e5bb3fcfc"
|
||||
integrity sha512-ilCS7fN+JM2O8l1Iw5cEWXyiQQg8GxEeYYvqALJcn5cO6qSpD+xJb3Dji4EHXa1Yu1OBd/19ktWNvUkWNvuAaQ==
|
||||
dependencies:
|
||||
"@openzeppelin/contracts" "^3.1.0"
|
||||
eth-sig-util "^2.5.3"
|
||||
|
Loading…
Reference in New Issue
Block a user