example: Fix options
This commit is contained in:
parent
319d3300f6
commit
f6b6c99d20
|
@ -43,14 +43,11 @@ function compute () {
|
||||||
const value = getInputValue()
|
const value = getInputValue()
|
||||||
const leaves = parseInput(value)
|
const leaves = parseInput(value)
|
||||||
const hashFn = getHashFn()
|
const hashFn = getHashFn()
|
||||||
const fillDefaultHash = getDefaultFillHashInput()
|
const options = getOptions()
|
||||||
const _options = Object.assign({}, options, {
|
|
||||||
fillDefaultHash: options.fillDefaultHash ? fillDefaultHash : undefined
|
|
||||||
})
|
|
||||||
console.log('input leaves:', leaves)
|
console.log('input leaves:', leaves)
|
||||||
console.log('hash:', getHashType())
|
console.log('hash:', getHashType())
|
||||||
console.log('options:', _options)
|
console.log('options:', options)
|
||||||
tree = new window.MerkleTree(leaves, hashFn, _options)
|
tree = new window.MerkleTree(leaves, hashFn, options)
|
||||||
const hexRoot = tree.getHexRoot()
|
const hexRoot = tree.getHexRoot()
|
||||||
const hexLeaves = tree.getHexLeaves()
|
const hexLeaves = tree.getHexLeaves()
|
||||||
const hexLayers = tree.getHexLayers()
|
const hexLayers = tree.getHexLayers()
|
||||||
|
@ -66,7 +63,14 @@ function compute () {
|
||||||
setTreeValue(tree.toString())
|
setTreeValue(tree.toString())
|
||||||
updateLeaveOptions(hexLeaves)
|
updateLeaveOptions(hexLeaves)
|
||||||
updateProof(0)
|
updateProof(0)
|
||||||
setVerified('')
|
setVerified('-')
|
||||||
|
}
|
||||||
|
|
||||||
|
function getOptions () {
|
||||||
|
const fillDefaultHash = getDefaultFillHashInput()
|
||||||
|
return Object.assign({}, options, {
|
||||||
|
fillDefaultHash: options.fillDefaultHash ? fillDefaultHash : undefined
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseInput (value) {
|
function parseInput (value) {
|
||||||
|
@ -110,11 +114,12 @@ function setVerified (verified) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function verify () {
|
function verify () {
|
||||||
setVerified('')
|
setVerified('-')
|
||||||
const proof = getVerifyProof()
|
const proof = getVerifyProof()
|
||||||
const leaf = getVerifyLeaf()
|
const leaf = getVerifyLeaf()
|
||||||
const root = getVerifyRoot()
|
const root = getVerifyRoot()
|
||||||
const hashFn = getHashFn()
|
const hashFn = getHashFn()
|
||||||
|
const options = getOptions()
|
||||||
const verified = window.MerkleTree.verify(proof, leaf, root, hashFn, options)
|
const verified = window.MerkleTree.verify(proof, leaf, root, hashFn, options)
|
||||||
setVerified(`${verified}`)
|
setVerified(`${verified}`)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue