// SPDX-License-Identifier: Apache-2.0
import { GenesisNetworkDataWrapper } from './genesis-network-data-wrapper.js';
import { ipv4ToBase64, isIPv4Address } from '../helpers.js';
export class GenesisNetworkNodeDataWrapper extends GenesisNetworkDataWrapper {
    nodeId;
    adminKey;
    description;
    accountId;
    serviceEndpoint = [];
    grpcCertificateHash;
    deleted = false;
    constructor(nodeId, adminKey, description) {
        super(nodeId);
        this.nodeId = nodeId;
        this.adminKey = adminKey;
        this.description = description;
    }
    /**
     * @param address - a fully qualified domain name or an IPv4 address
     * @param port
     */
    addServiceEndpoint(address, port) {
        const isIpV4Address = isIPv4Address(address);
        this.serviceEndpoint.push({
            domainName: isIpV4Address ? '' : address,
            port,
            ipAddressV4: isIpV4Address ? ipv4ToBase64(address) : undefined,
        });
    }
    toObject() {
        return {
            nodeId: this.nodeId,
            accountId: {
                realmNum: `${this.accountId.realm}`,
                shardNum: `${this.accountId.shard}`,
                accountNum: `${this.accountId.num}`,
            },
            description: this.description,
            gossipEndpoint: this.gossipEndpoint,
            serviceEndpoint: this.serviceEndpoint,
            gossipCaCertificate: this.gossipCaCertificate,
            grpcCertificateHash: this.grpcCertificateHash,
            weight: this.weight,
            deleted: this.deleted,
            adminKey: this.adminKey,
        };
    }
}
//
//# sourceMappingURL=genesis-network-node-data-wrapper.js.map