"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Metadata = void 0;
const binary_1 = require("../../../../binary");
function createBaseMetadata() {
    return {
        version: "",
        controllerConnectionId: "",
        hostConnectionId: "",
        address: "",
        encoding: "",
        txType: ""
    };
}
/**
 * Metadata defines a set of protocol specific data encoded into the ICS27 channel version bytestring
 * See ICS004: https://github.com/cosmos/ibc/tree/master/spec/core/ics-004-channel-and-packet-semantics#Versioning
 * @name Metadata
 * @package ibc.applications.interchain_accounts.v1
 * @see proto type: ibc.applications.interchain_accounts.v1.Metadata
 */
exports.Metadata = {
    typeUrl: "/ibc.applications.interchain_accounts.v1.Metadata",
    aminoType: "cosmos-sdk/Metadata",
    is(o) {
        return o && (o.$typeUrl === exports.Metadata.typeUrl || typeof o.version === "string" && typeof o.controllerConnectionId === "string" && typeof o.hostConnectionId === "string" && typeof o.address === "string" && typeof o.encoding === "string" && typeof o.txType === "string");
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.Metadata.typeUrl || typeof o.version === "string" && typeof o.controller_connection_id === "string" && typeof o.host_connection_id === "string" && typeof o.address === "string" && typeof o.encoding === "string" && typeof o.tx_type === "string");
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.version !== "") {
            writer.uint32(10).string(message.version);
        }
        if (message.controllerConnectionId !== "") {
            writer.uint32(18).string(message.controllerConnectionId);
        }
        if (message.hostConnectionId !== "") {
            writer.uint32(26).string(message.hostConnectionId);
        }
        if (message.address !== "") {
            writer.uint32(34).string(message.address);
        }
        if (message.encoding !== "") {
            writer.uint32(42).string(message.encoding);
        }
        if (message.txType !== "") {
            writer.uint32(50).string(message.txType);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof binary_1.BinaryReader ? input : new binary_1.BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseMetadata();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.version = reader.string();
                    break;
                case 2:
                    message.controllerConnectionId = reader.string();
                    break;
                case 3:
                    message.hostConnectionId = reader.string();
                    break;
                case 4:
                    message.address = reader.string();
                    break;
                case 5:
                    message.encoding = reader.string();
                    break;
                case 6:
                    message.txType = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseMetadata();
        message.version = object.version ?? "";
        message.controllerConnectionId = object.controllerConnectionId ?? "";
        message.hostConnectionId = object.hostConnectionId ?? "";
        message.address = object.address ?? "";
        message.encoding = object.encoding ?? "";
        message.txType = object.txType ?? "";
        return message;
    },
    fromAmino(object) {
        const message = createBaseMetadata();
        if (object.version !== undefined && object.version !== null) {
            message.version = object.version;
        }
        if (object.controller_connection_id !== undefined && object.controller_connection_id !== null) {
            message.controllerConnectionId = object.controller_connection_id;
        }
        if (object.host_connection_id !== undefined && object.host_connection_id !== null) {
            message.hostConnectionId = object.host_connection_id;
        }
        if (object.address !== undefined && object.address !== null) {
            message.address = object.address;
        }
        if (object.encoding !== undefined && object.encoding !== null) {
            message.encoding = object.encoding;
        }
        if (object.tx_type !== undefined && object.tx_type !== null) {
            message.txType = object.tx_type;
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.version = message.version === "" ? undefined : message.version;
        obj.controller_connection_id = message.controllerConnectionId === "" ? undefined : message.controllerConnectionId;
        obj.host_connection_id = message.hostConnectionId === "" ? undefined : message.hostConnectionId;
        obj.address = message.address === "" ? undefined : message.address;
        obj.encoding = message.encoding === "" ? undefined : message.encoding;
        obj.tx_type = message.txType === "" ? undefined : message.txType;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.Metadata.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/Metadata",
            value: exports.Metadata.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.Metadata.decode(message.value);
    },
    toProto(message) {
        return exports.Metadata.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.applications.interchain_accounts.v1.Metadata",
            value: exports.Metadata.encode(message).finish()
        };
    },
    registerTypeUrl() { }
};
