@browseth/utils
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -276,2 +276,15 @@ 'use strict'; | ||
function namehash(name) { | ||
var labels = name.split('.'); | ||
if (labels[labels.length - 1] === '') { | ||
labels.pop(); | ||
} | ||
if (labels[0] === '') { | ||
labels.shift(); | ||
} | ||
return labels.reverse().reduce(function (a, v) { | ||
return toHex(keccak256(Buffer.from(a.replace('0x', '') + toHex(keccak256(fromUtf8(v))).replace('0x', ''), 'hex'))); | ||
}, '0x' + '0'.repeat(64)); | ||
} | ||
var mipherUuid = new uuid.UUID(); | ||
@@ -287,3 +300,4 @@ function uuid$1() { | ||
keccak256: keccak256, | ||
uuid: uuid$1 | ||
uuid: uuid$1, | ||
namehash: namehash | ||
}); | ||
@@ -806,3 +820,3 @@ | ||
} | ||
clearInterval(interval); | ||
clearInterval(_this.interval); | ||
if (receipt.status === 0) { | ||
@@ -809,0 +823,0 @@ reject('Transaction not found'); |
@@ -270,2 +270,15 @@ import _getIterator from 'babel-runtime/core-js/get-iterator'; | ||
function namehash(name) { | ||
var labels = name.split('.'); | ||
if (labels[labels.length - 1] === '') { | ||
labels.pop(); | ||
} | ||
if (labels[0] === '') { | ||
labels.shift(); | ||
} | ||
return labels.reverse().reduce(function (a, v) { | ||
return toHex(keccak256(Buffer.from(a.replace('0x', '') + toHex(keccak256(fromUtf8(v))).replace('0x', ''), 'hex'))); | ||
}, '0x' + '0'.repeat(64)); | ||
} | ||
var mipherUuid = new UUID(); | ||
@@ -281,3 +294,4 @@ function uuid() { | ||
keccak256: keccak256, | ||
uuid: uuid | ||
uuid: uuid, | ||
namehash: namehash | ||
}); | ||
@@ -800,3 +814,3 @@ | ||
} | ||
clearInterval(interval); | ||
clearInterval(_this.interval); | ||
if (receipt.status === 0) { | ||
@@ -803,0 +817,0 @@ reject('Transaction not found'); |
@@ -41,2 +41,3 @@ export = Utils | ||
keccak256(value: string | ArrayBuffer | ArrayBufferView): ArrayBuffer | ||
namehash(value: string): string | ||
} | ||
@@ -43,0 +44,0 @@ const interval: { |
import { Keccak } from 'mipher/dist/sha3' | ||
import { UUID } from 'mipher/dist/uuid' | ||
import { fromBytes, fromUtf8, bytesRegex } from './ab' | ||
export { keccak256, uuid } | ||
import { fromBytes, fromUtf8, bytesRegex, toHex } from './ab' | ||
export { keccak256, uuid, namehash } | ||
@@ -11,2 +11,26 @@ const mipherKeccak256 = new Keccak(256, 1) | ||
function namehash(name) { | ||
const labels = name.split('.') | ||
if (labels[labels.length - 1] === '') { | ||
labels.pop() | ||
} | ||
if (labels[0] === '') { | ||
labels.shift() | ||
} | ||
return labels.reverse().reduce( | ||
(a, v) => | ||
toHex( | ||
keccak256( | ||
Buffer.from( | ||
a.replace('0x', '') + | ||
toHex(keccak256(fromUtf8(v))).replace('0x', ''), | ||
'hex', | ||
), | ||
), | ||
), | ||
`0x${'0'.repeat(64)}`, | ||
) | ||
} | ||
const mipherUuid = new UUID() | ||
@@ -13,0 +37,0 @@ function uuid() { |
@@ -18,3 +18,3 @@ import { setUnrefedInterval, setUnrefedTimeout } from './interval' | ||
} | ||
clearInterval(interval) | ||
clearInterval(this.interval) | ||
if (receipt.status === 0) { | ||
@@ -21,0 +21,0 @@ reject('Transaction not found') |
{ | ||
"name": "@browseth/utils", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"license": "MIT", | ||
@@ -25,3 +25,3 @@ "browser": "build/browser.js", | ||
}, | ||
"gitHead": "b0773524c099b89c52af08f341509281aaafb158" | ||
"gitHead": "54c14d8930a4eb94c70edfc426d64593212f4894" | ||
} |
Sorry, the diff of this file is too big to display
859660
11259