Got it working

master
Dan Finlay 8 years ago
parent e66c9aa850
commit 850de97fac
No known key found for this signature in database
GPG Key ID: 931102F24B36007A

@ -11,41 +11,17 @@ module.exports = function namehash (inputName) {
name = normalize(inputName)
if (name) {
const labels = name.split('.')
console.dir({ labels })
for(var i = labels.length - 1; i >= 0; i--) {
console.log("BEFORE")
console.dir({ node, label:labels[i] })
const labelSha = sha3(labels[i])
console.dir({ node, label:labels[i], labelSha })
node = sha3(node + labelSha)
console.log("AFTER")
console.dir({ node })
}
/*
const label = labels.shift()
const remainder = labels.join('.')
const remainderHash = namehash(remainder).substr(2)
const labelHash = sha3(label)
if (remainderHash.match(/^0+$/)) {
return '0x' + labelHash
node = sha3(new Buffer(node + labelSha, 'hex'))
}
return '0x' + sha3(remainderHash + remainderHash)
*/
}
return `0x${node}`
}
function concat (buffA, buffB) {
}
function normalize(name) {
return name ? uts46.toUnicode(name, {useStd3ASCII: true, transitional: false}) : name
}

@ -19,23 +19,6 @@ test('empty param', (t) => {
t.equal(output, expected)
})
/*
test('TLD eth', (t) => {
t.plan(1)
const input = 'eth'
const expected = '0x4f5b812789fc606be1b3b16908db13fc7a9adf7ca72641f84d75b47069d3d7f0'
const output = namehash(input)
t.equal(output, expected)
})
*/
/*
* Commented out because it turns out the EIP has incorrect specs:
* https://github.com/ethereum/EIPs/issues/137#issuecomment-284918147
*
* The correct specs are here, but too sparse to use:
* http://docs.ens.domains/en/latest/introduction.html#namehash
*/
test('TLD eth', (t) => {
t.plan(1)
const input = 'eth'
@ -51,3 +34,4 @@ test('foo.eth', (t) => {
const output = namehash(input)
t.equal(output, expected)
})

Loading…
Cancel
Save