fix deposit

This commit is contained in:
Alexey 2020-04-09 21:58:01 +03:00
parent 709bde4705
commit a772d76829

View File

@ -24,7 +24,7 @@ const toHex = (number, length = 32) => '0x' + (number instanceof Buffer ? number
function merklePathIndicesToBigint(indexArray) {
let result = 0
for(let item of indexArray) {
for(let item of indexArray.slice().reverse()) {
result = (result << 1) + item
}
return result
@ -98,16 +98,7 @@ async function insertOutput(tree, output) {
output.merklePathElements = path_elements
}
async function main() {
web3 = new Web3(new Web3.providers.HttpProvider(RPC_URL, { timeout: 5 * 60 * 1000 }), null, { transactionConfirmationBlocks: 1 })
circuit = require('../build/circuits/transaction.json')
proving_key = fs.readFileSync('../build/circuits/transaction_proving_key.bin').buffer
groth16 = await buildGroth16()
netId = await web3.eth.net.getId()
const contractData = require('../build/contracts/TornadoPool.json')
contract = new web3.eth.Contract(contractData.abi, contractData.networks[netId].address)
web3.eth.defaultAccount = (await web3.eth.getAccounts())[0]
async function deposit() {
const amount = 1e6;
const tree = await buildMerkleTree()
const oldRoot = await tree.root()
@ -164,6 +155,19 @@ async function main() {
console.log('Sending deposit transaction...')
const receipt = await contract.methods.transaction(proof, ...args).send({ value: amount, from: web3.eth.defaultAccount, gas: 1e6 })
console.log(`Receipt ${receipt.transactionHash}`)
}
async function main() {
web3 = new Web3(new Web3.providers.HttpProvider(RPC_URL, { timeout: 5 * 60 * 1000 }), null, { transactionConfirmationBlocks: 1 })
circuit = require('../build/circuits/transaction.json')
proving_key = fs.readFileSync('../build/circuits/transaction_proving_key.bin').buffer
groth16 = await buildGroth16()
netId = await web3.eth.net.getId()
const contractData = require('../build/contracts/TornadoPool.json')
contract = new web3.eth.Contract(contractData.abi, contractData.networks[netId].address)
web3.eth.defaultAccount = (await web3.eth.getAccounts())[0]
await deposit()
}