mirror of
https://github.com/tornadocash/tornado-core.git
synced 2025-01-29 13:23:20 -05:00
relay code style
This commit is contained in:
parent
a60d539a2c
commit
ca9724bcf9
@ -1,44 +1,41 @@
|
|||||||
let bigInt = require('snarkjs/src/bigint');
|
let bigInt = require('snarkjs/src/bigint')
|
||||||
|
|
||||||
require('dotenv').config();
|
const express = require('express')
|
||||||
const { AMOUNT, MERKLE_TREE_HEIGHT, EMPTY_ELEMENT } = process.env;
|
const app = express()
|
||||||
|
app.use(express.json())
|
||||||
|
|
||||||
const express = require('express');
|
const Web3 = require('web3')
|
||||||
const app = express();
|
const web3 = new Web3('http://localhost:8545', null, {transactionConfirmationBlocks: 1})
|
||||||
app.use(express.json());
|
const contractJson = require('../build/contracts/Mixer.json')
|
||||||
|
let netId = 42
|
||||||
const Web3 = require('web3');
|
const mixer = new web3.eth.Contract(contractJson.abi, contractJson.networks[netId].address)
|
||||||
web3 = new Web3('http://localhost:8545', null, {transactionConfirmationBlocks: 1});
|
|
||||||
contractJson = require('../build/contracts/Mixer.json');
|
|
||||||
let netId = 42;
|
|
||||||
mixer = new web3.eth.Contract(contractJson.abi, contractJson.networks[netId].address);
|
|
||||||
|
|
||||||
function getMinimumFee() {
|
function getMinimumFee() {
|
||||||
// todo calc acceptable fee
|
// todo calc acceptable fee
|
||||||
return 1e16;
|
return 1e16
|
||||||
}
|
}
|
||||||
|
|
||||||
app.post('/deposit', async (req, resp) => {
|
app.post('/deposit', async (req, resp) => {
|
||||||
let proof = req.body;
|
let proof = req.body
|
||||||
if (!(proof.pi_a && proof.pi_b && proof.pi_c && proof.publicSignals)) { // check that it's kinda well formed
|
if (!(proof.pi_a && proof.pi_b && proof.pi_c && proof.publicSignals)) { // check that it's kinda well formed
|
||||||
resp.status(400).end();
|
resp.status(400).end()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bigInt(proof.publicSignals[3]) < getMinimumFee()) {
|
if (bigInt(proof.publicSignals[3]) < getMinimumFee()) {
|
||||||
resp.status(403).send("Fee is too low");
|
resp.status(403).send('Fee is too low')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!utils.snarkVerify(proof)) {
|
if (!utils.snarkVerify(proof)) {
|
||||||
resp.status(403).send("Invalid snark proof");
|
resp.status(403).send('Invalid snark proof')
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let receipt = await mixer.withdraw(proof.pi_a, proof.pi_b, proof.pi_b, proof.publicSignals);
|
let receipt = await mixer.withdraw(proof.pi_a, proof.pi_b, proof.pi_b, proof.publicSignals)
|
||||||
console.log(receipt);
|
console.log(receipt)
|
||||||
resp.send({transaction: receipt.transactionHash})
|
resp.send({ transaction: receipt.transactionHash })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e)
|
||||||
resp.status(400).send("Transaction was reverted");
|
resp.status(400).send('Transaction was reverted')
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
app.listen(3000);
|
app.listen(3000)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user