import { getBlockRootFromBeaconAttestationSerialized, getBlockRootFromSignedAggregateAndProofSerialized, getSlotFromBeaconAttestationSerialized, getSlotFromBlobSidecarSerialized, getSlotFromDataColumnSidecarSerialized, getSlotFromSignedAggregateAndProofSerialized, getSlotFromSignedBeaconBlockSerialized, } from "../../util/sszBytes.js";
import { GossipType } from "../gossip/index.js";
/**
 * Extract the slot and block root of a gossip message form serialized data.
 * Only applicable for beacon_attestation and beacon_aggregate_and_proof topics.
 */
export function createExtractBlockSlotRootFns() {
    return {
        [GossipType.beacon_attestation]: (data, fork) => {
            const slot = getSlotFromBeaconAttestationSerialized(fork, data);
            const root = getBlockRootFromBeaconAttestationSerialized(fork, data);
            if (slot === null || root === null) {
                return null;
            }
            return { slot, root };
        },
        [GossipType.beacon_aggregate_and_proof]: (data) => {
            const slot = getSlotFromSignedAggregateAndProofSerialized(data);
            const root = getBlockRootFromSignedAggregateAndProofSerialized(data);
            if (slot === null || root === null) {
                return null;
            }
            return { slot, root };
        },
        [GossipType.beacon_block]: (data) => {
            const slot = getSlotFromSignedBeaconBlockSerialized(data);
            if (slot === null) {
                return null;
            }
            return { slot };
        },
        [GossipType.blob_sidecar]: (data) => {
            const slot = getSlotFromBlobSidecarSerialized(data);
            if (slot === null) {
                return null;
            }
            return { slot };
        },
        [GossipType.data_column_sidecar]: (data) => {
            const slot = getSlotFromDataColumnSidecarSerialized(data);
            if (slot === null) {
                return null;
            }
            return { slot };
        },
    };
}
//# sourceMappingURL=extractSlotRootFns.js.map