"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeTopicFromString = exports.makeTopic = void 0;
const hash_1 = require("../utils/hash");
const bytes_1 = require("../utils/bytes");
const hex_1 = require("../utils/hex");
const types_1 = require("../types");
function makeTopic(topic) {
    if (typeof topic === 'string') {
        return (0, hex_1.makeHexString)(topic, types_1.TOPIC_HEX_LENGTH);
    }
    else if (topic instanceof Uint8Array) {
        (0, bytes_1.assertBytes)(topic, types_1.TOPIC_BYTES_LENGTH);
        return (0, hex_1.bytesToHex)(topic, types_1.TOPIC_HEX_LENGTH);
    }
    throw new TypeError('invalid topic');
}
exports.makeTopic = makeTopic;
function makeTopicFromString(s) {
    if (typeof s !== 'string') {
        throw new TypeError('topic has to be string!');
    }
    return (0, hex_1.bytesToHex)((0, hash_1.keccak256Hash)(s), types_1.TOPIC_HEX_LENGTH);
}
exports.makeTopicFromString = makeTopicFromString;
