deth
Version:
Ethereum node focused on Developer Experience
20 lines (19 loc) • 645 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const common_1 = require("./common");
const ethereumjs_util_1 = require("ethereumjs-util");
function makeHash(value) {
if (!common_1.HEX_REGEX.test(value) || value.length !== 66) {
throw new TypeError(`Value "${value}" is not a valid hash`);
}
return value.toLowerCase();
}
exports.makeHash = makeHash;
function bufferToHash(buffer) {
return makeHash(ethereumjs_util_1.bufferToHex(buffer));
}
exports.bufferToHash = bufferToHash;
function hashToBuffer(hash) {
return ethereumjs_util_1.toBuffer(hash);
}
exports.hashToBuffer = hashToBuffer;