"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.convertStreamMessageToMessage = void 0;
const protocol_1 = require("@streamr/protocol");
function signatureTypeToString(signatureType) {
    switch (signatureType) {
        case protocol_1.SignatureType.LEGACY_SECP256K1:
            return 'LEGACY_SECP256K1';
        case protocol_1.SignatureType.SECP256K1:
            return 'SECP256K1';
        case protocol_1.SignatureType.ERC_1271:
            return 'ERC_1271';
        default:
            throw new Error(`Unknown signature type: ${signatureType}`);
    }
}
const convertStreamMessageToMessage = (msg) => {
    return {
        content: msg.getParsedContent(),
        streamId: msg.getStreamId(),
        streamPartition: msg.getStreamPartition(),
        timestamp: msg.getTimestamp(),
        sequenceNumber: msg.getSequenceNumber(),
        signature: msg.signature,
        signatureType: signatureTypeToString(msg.signatureType),
        publisherId: msg.getPublisherId(),
        msgChainId: msg.getMsgChainId(),
        groupKeyId: msg.groupKeyId,
        streamMessage: msg
        // TODO add other relevant fields (could update some test assertions to
        // use those keys instead of getting the fields via from streamMessage property)
    };
};
exports.convertStreamMessageToMessage = convertStreamMessageToMessage;
//# sourceMappingURL=Message.js.map