mirror of
https://github.com/tornadocash/tornado-core.git
synced 2024-11-22 17:50:19 +01:00
leafs sort fix
This commit is contained in:
parent
46165bafc1
commit
caaedbc959
5
cli.js
5
cli.js
@ -48,8 +48,9 @@ async function withdraw(note, receiver) {
|
|||||||
|
|
||||||
console.log('Getting current state from mixer contract')
|
console.log('Getting current state from mixer contract')
|
||||||
const events = await mixer.getPastEvents('Deposit', { fromBlock: mixer.deployedBlock, toBlock: 'latest' })
|
const events = await mixer.getPastEvents('Deposit', { fromBlock: mixer.deployedBlock, toBlock: 'latest' })
|
||||||
console.log('events', events)
|
const leaves = events
|
||||||
const leaves = events.sort(e => e.returnValues.leafIndex).map(e => e.returnValues.commitment)
|
.sort((a, b) => a.returnValues.leafIndex.sub(b.returnValues.leafIndex))
|
||||||
|
.map(e => e.returnValues.commitment)
|
||||||
const tree = new merkleTree(MERKLE_TREE_HEIGHT, EMPTY_ELEMENT, leaves)
|
const tree = new merkleTree(MERKLE_TREE_HEIGHT, EMPTY_ELEMENT, leaves)
|
||||||
const validRoot = await mixer.methods.isKnownRoot(await tree.root()).call()
|
const validRoot = await mixer.methods.isKnownRoot(await tree.root()).call()
|
||||||
// todo make sure that function input is 32 bytes long
|
// todo make sure that function input is 32 bytes long
|
||||||
|
Loading…
Reference in New Issue
Block a user