"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RegisteredInterchainAccount = exports.ActiveChannel = exports.HostGenesisState = exports.ControllerGenesisState = exports.GenesisState = void 0;
const controller_1 = require("../../controller/v1/controller");
const host_1 = require("../../host/v1/host");
const binary_1 = require("../../../../../binary");
const registry_1 = require("../../../../../registry");
function createBaseGenesisState() {
    return {
        controllerGenesisState: exports.ControllerGenesisState.fromPartial({}),
        hostGenesisState: exports.HostGenesisState.fromPartial({})
    };
}
exports.GenesisState = {
    typeUrl: "/ibc.applications.interchain_accounts.genesis.v1.GenesisState",
    aminoType: "cosmos-sdk/GenesisState",
    is(o) {
        return o && (o.$typeUrl === exports.GenesisState.typeUrl || exports.ControllerGenesisState.is(o.controllerGenesisState) && exports.HostGenesisState.is(o.hostGenesisState));
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.GenesisState.typeUrl || exports.ControllerGenesisState.isAmino(o.controller_genesis_state) && exports.HostGenesisState.isAmino(o.host_genesis_state));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.controllerGenesisState !== undefined) {
            exports.ControllerGenesisState.encode(message.controllerGenesisState, writer.uint32(10).fork()).ldelim();
        }
        if (message.hostGenesisState !== undefined) {
            exports.HostGenesisState.encode(message.hostGenesisState, writer.uint32(18).fork()).ldelim();
        }
        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 = createBaseGenesisState();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.controllerGenesisState = exports.ControllerGenesisState.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.hostGenesisState = exports.HostGenesisState.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseGenesisState();
        message.controllerGenesisState = object.controllerGenesisState !== undefined && object.controllerGenesisState !== null ? exports.ControllerGenesisState.fromPartial(object.controllerGenesisState) : undefined;
        message.hostGenesisState = object.hostGenesisState !== undefined && object.hostGenesisState !== null ? exports.HostGenesisState.fromPartial(object.hostGenesisState) : undefined;
        return message;
    },
    fromAmino(object) {
        const message = createBaseGenesisState();
        if (object.controller_genesis_state !== undefined && object.controller_genesis_state !== null) {
            message.controllerGenesisState = exports.ControllerGenesisState.fromAmino(object.controller_genesis_state);
        }
        if (object.host_genesis_state !== undefined && object.host_genesis_state !== null) {
            message.hostGenesisState = exports.HostGenesisState.fromAmino(object.host_genesis_state);
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.controller_genesis_state = message.controllerGenesisState ? exports.ControllerGenesisState.toAmino(message.controllerGenesisState) : undefined;
        obj.host_genesis_state = message.hostGenesisState ? exports.HostGenesisState.toAmino(message.hostGenesisState) : undefined;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.GenesisState.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/GenesisState",
            value: exports.GenesisState.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.GenesisState.decode(message.value);
    },
    toProto(message) {
        return exports.GenesisState.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.applications.interchain_accounts.genesis.v1.GenesisState",
            value: exports.GenesisState.encode(message).finish()
        };
    }
};
registry_1.GlobalDecoderRegistry.register(exports.GenesisState.typeUrl, exports.GenesisState);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.GenesisState.aminoType, exports.GenesisState.typeUrl);
function createBaseControllerGenesisState() {
    return {
        activeChannels: [],
        interchainAccounts: [],
        ports: [],
        params: controller_1.Params.fromPartial({})
    };
}
exports.ControllerGenesisState = {
    typeUrl: "/ibc.applications.interchain_accounts.genesis.v1.ControllerGenesisState",
    aminoType: "cosmos-sdk/ControllerGenesisState",
    is(o) {
        return o && (o.$typeUrl === exports.ControllerGenesisState.typeUrl || Array.isArray(o.activeChannels) && (!o.activeChannels.length || exports.ActiveChannel.is(o.activeChannels[0])) && Array.isArray(o.interchainAccounts) && (!o.interchainAccounts.length || exports.RegisteredInterchainAccount.is(o.interchainAccounts[0])) && Array.isArray(o.ports) && (!o.ports.length || typeof o.ports[0] === "string") && controller_1.Params.is(o.params));
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.ControllerGenesisState.typeUrl || Array.isArray(o.active_channels) && (!o.active_channels.length || exports.ActiveChannel.isAmino(o.active_channels[0])) && Array.isArray(o.interchain_accounts) && (!o.interchain_accounts.length || exports.RegisteredInterchainAccount.isAmino(o.interchain_accounts[0])) && Array.isArray(o.ports) && (!o.ports.length || typeof o.ports[0] === "string") && controller_1.Params.isAmino(o.params));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        for (const v of message.activeChannels) {
            exports.ActiveChannel.encode(v, writer.uint32(10).fork()).ldelim();
        }
        for (const v of message.interchainAccounts) {
            exports.RegisteredInterchainAccount.encode(v, writer.uint32(18).fork()).ldelim();
        }
        for (const v of message.ports) {
            writer.uint32(26).string(v);
        }
        if (message.params !== undefined) {
            controller_1.Params.encode(message.params, writer.uint32(34).fork()).ldelim();
        }
        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 = createBaseControllerGenesisState();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.activeChannels.push(exports.ActiveChannel.decode(reader, reader.uint32()));
                    break;
                case 2:
                    message.interchainAccounts.push(exports.RegisteredInterchainAccount.decode(reader, reader.uint32()));
                    break;
                case 3:
                    message.ports.push(reader.string());
                    break;
                case 4:
                    message.params = controller_1.Params.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseControllerGenesisState();
        message.activeChannels = object.activeChannels?.map(e => exports.ActiveChannel.fromPartial(e)) || [];
        message.interchainAccounts = object.interchainAccounts?.map(e => exports.RegisteredInterchainAccount.fromPartial(e)) || [];
        message.ports = object.ports?.map(e => e) || [];
        message.params = object.params !== undefined && object.params !== null ? controller_1.Params.fromPartial(object.params) : undefined;
        return message;
    },
    fromAmino(object) {
        const message = createBaseControllerGenesisState();
        message.activeChannels = object.active_channels?.map(e => exports.ActiveChannel.fromAmino(e)) || [];
        message.interchainAccounts = object.interchain_accounts?.map(e => exports.RegisteredInterchainAccount.fromAmino(e)) || [];
        message.ports = object.ports?.map(e => e) || [];
        if (object.params !== undefined && object.params !== null) {
            message.params = controller_1.Params.fromAmino(object.params);
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        if (message.activeChannels) {
            obj.active_channels = message.activeChannels.map(e => e ? exports.ActiveChannel.toAmino(e) : undefined);
        }
        else {
            obj.active_channels = message.activeChannels;
        }
        if (message.interchainAccounts) {
            obj.interchain_accounts = message.interchainAccounts.map(e => e ? exports.RegisteredInterchainAccount.toAmino(e) : undefined);
        }
        else {
            obj.interchain_accounts = message.interchainAccounts;
        }
        if (message.ports) {
            obj.ports = message.ports.map(e => e);
        }
        else {
            obj.ports = message.ports;
        }
        obj.params = message.params ? controller_1.Params.toAmino(message.params) : undefined;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.ControllerGenesisState.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/ControllerGenesisState",
            value: exports.ControllerGenesisState.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.ControllerGenesisState.decode(message.value);
    },
    toProto(message) {
        return exports.ControllerGenesisState.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.applications.interchain_accounts.genesis.v1.ControllerGenesisState",
            value: exports.ControllerGenesisState.encode(message).finish()
        };
    }
};
registry_1.GlobalDecoderRegistry.register(exports.ControllerGenesisState.typeUrl, exports.ControllerGenesisState);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.ControllerGenesisState.aminoType, exports.ControllerGenesisState.typeUrl);
function createBaseHostGenesisState() {
    return {
        activeChannels: [],
        interchainAccounts: [],
        port: "",
        params: host_1.Params.fromPartial({})
    };
}
exports.HostGenesisState = {
    typeUrl: "/ibc.applications.interchain_accounts.genesis.v1.HostGenesisState",
    aminoType: "cosmos-sdk/HostGenesisState",
    is(o) {
        return o && (o.$typeUrl === exports.HostGenesisState.typeUrl || Array.isArray(o.activeChannels) && (!o.activeChannels.length || exports.ActiveChannel.is(o.activeChannels[0])) && Array.isArray(o.interchainAccounts) && (!o.interchainAccounts.length || exports.RegisteredInterchainAccount.is(o.interchainAccounts[0])) && typeof o.port === "string" && host_1.Params.is(o.params));
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.HostGenesisState.typeUrl || Array.isArray(o.active_channels) && (!o.active_channels.length || exports.ActiveChannel.isAmino(o.active_channels[0])) && Array.isArray(o.interchain_accounts) && (!o.interchain_accounts.length || exports.RegisteredInterchainAccount.isAmino(o.interchain_accounts[0])) && typeof o.port === "string" && host_1.Params.isAmino(o.params));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        for (const v of message.activeChannels) {
            exports.ActiveChannel.encode(v, writer.uint32(10).fork()).ldelim();
        }
        for (const v of message.interchainAccounts) {
            exports.RegisteredInterchainAccount.encode(v, writer.uint32(18).fork()).ldelim();
        }
        if (message.port !== "") {
            writer.uint32(26).string(message.port);
        }
        if (message.params !== undefined) {
            host_1.Params.encode(message.params, writer.uint32(34).fork()).ldelim();
        }
        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 = createBaseHostGenesisState();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.activeChannels.push(exports.ActiveChannel.decode(reader, reader.uint32()));
                    break;
                case 2:
                    message.interchainAccounts.push(exports.RegisteredInterchainAccount.decode(reader, reader.uint32()));
                    break;
                case 3:
                    message.port = reader.string();
                    break;
                case 4:
                    message.params = host_1.Params.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseHostGenesisState();
        message.activeChannels = object.activeChannels?.map(e => exports.ActiveChannel.fromPartial(e)) || [];
        message.interchainAccounts = object.interchainAccounts?.map(e => exports.RegisteredInterchainAccount.fromPartial(e)) || [];
        message.port = object.port ?? "";
        message.params = object.params !== undefined && object.params !== null ? host_1.Params.fromPartial(object.params) : undefined;
        return message;
    },
    fromAmino(object) {
        const message = createBaseHostGenesisState();
        message.activeChannels = object.active_channels?.map(e => exports.ActiveChannel.fromAmino(e)) || [];
        message.interchainAccounts = object.interchain_accounts?.map(e => exports.RegisteredInterchainAccount.fromAmino(e)) || [];
        if (object.port !== undefined && object.port !== null) {
            message.port = object.port;
        }
        if (object.params !== undefined && object.params !== null) {
            message.params = host_1.Params.fromAmino(object.params);
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        if (message.activeChannels) {
            obj.active_channels = message.activeChannels.map(e => e ? exports.ActiveChannel.toAmino(e) : undefined);
        }
        else {
            obj.active_channels = message.activeChannels;
        }
        if (message.interchainAccounts) {
            obj.interchain_accounts = message.interchainAccounts.map(e => e ? exports.RegisteredInterchainAccount.toAmino(e) : undefined);
        }
        else {
            obj.interchain_accounts = message.interchainAccounts;
        }
        obj.port = message.port === "" ? undefined : message.port;
        obj.params = message.params ? host_1.Params.toAmino(message.params) : undefined;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.HostGenesisState.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/HostGenesisState",
            value: exports.HostGenesisState.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.HostGenesisState.decode(message.value);
    },
    toProto(message) {
        return exports.HostGenesisState.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.applications.interchain_accounts.genesis.v1.HostGenesisState",
            value: exports.HostGenesisState.encode(message).finish()
        };
    }
};
registry_1.GlobalDecoderRegistry.register(exports.HostGenesisState.typeUrl, exports.HostGenesisState);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.HostGenesisState.aminoType, exports.HostGenesisState.typeUrl);
function createBaseActiveChannel() {
    return {
        connectionId: "",
        portId: "",
        channelId: "",
        isMiddlewareEnabled: false
    };
}
exports.ActiveChannel = {
    typeUrl: "/ibc.applications.interchain_accounts.genesis.v1.ActiveChannel",
    aminoType: "cosmos-sdk/ActiveChannel",
    is(o) {
        return o && (o.$typeUrl === exports.ActiveChannel.typeUrl || typeof o.connectionId === "string" && typeof o.portId === "string" && typeof o.channelId === "string" && typeof o.isMiddlewareEnabled === "boolean");
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.ActiveChannel.typeUrl || typeof o.connection_id === "string" && typeof o.port_id === "string" && typeof o.channel_id === "string" && typeof o.is_middleware_enabled === "boolean");
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.connectionId !== "") {
            writer.uint32(10).string(message.connectionId);
        }
        if (message.portId !== "") {
            writer.uint32(18).string(message.portId);
        }
        if (message.channelId !== "") {
            writer.uint32(26).string(message.channelId);
        }
        if (message.isMiddlewareEnabled === true) {
            writer.uint32(32).bool(message.isMiddlewareEnabled);
        }
        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 = createBaseActiveChannel();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.connectionId = reader.string();
                    break;
                case 2:
                    message.portId = reader.string();
                    break;
                case 3:
                    message.channelId = reader.string();
                    break;
                case 4:
                    message.isMiddlewareEnabled = reader.bool();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseActiveChannel();
        message.connectionId = object.connectionId ?? "";
        message.portId = object.portId ?? "";
        message.channelId = object.channelId ?? "";
        message.isMiddlewareEnabled = object.isMiddlewareEnabled ?? false;
        return message;
    },
    fromAmino(object) {
        const message = createBaseActiveChannel();
        if (object.connection_id !== undefined && object.connection_id !== null) {
            message.connectionId = object.connection_id;
        }
        if (object.port_id !== undefined && object.port_id !== null) {
            message.portId = object.port_id;
        }
        if (object.channel_id !== undefined && object.channel_id !== null) {
            message.channelId = object.channel_id;
        }
        if (object.is_middleware_enabled !== undefined && object.is_middleware_enabled !== null) {
            message.isMiddlewareEnabled = object.is_middleware_enabled;
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.connection_id = message.connectionId === "" ? undefined : message.connectionId;
        obj.port_id = message.portId === "" ? undefined : message.portId;
        obj.channel_id = message.channelId === "" ? undefined : message.channelId;
        obj.is_middleware_enabled = message.isMiddlewareEnabled === false ? undefined : message.isMiddlewareEnabled;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.ActiveChannel.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/ActiveChannel",
            value: exports.ActiveChannel.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.ActiveChannel.decode(message.value);
    },
    toProto(message) {
        return exports.ActiveChannel.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.applications.interchain_accounts.genesis.v1.ActiveChannel",
            value: exports.ActiveChannel.encode(message).finish()
        };
    }
};
registry_1.GlobalDecoderRegistry.register(exports.ActiveChannel.typeUrl, exports.ActiveChannel);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.ActiveChannel.aminoType, exports.ActiveChannel.typeUrl);
function createBaseRegisteredInterchainAccount() {
    return {
        connectionId: "",
        portId: "",
        accountAddress: ""
    };
}
exports.RegisteredInterchainAccount = {
    typeUrl: "/ibc.applications.interchain_accounts.genesis.v1.RegisteredInterchainAccount",
    aminoType: "cosmos-sdk/RegisteredInterchainAccount",
    is(o) {
        return o && (o.$typeUrl === exports.RegisteredInterchainAccount.typeUrl || typeof o.connectionId === "string" && typeof o.portId === "string" && typeof o.accountAddress === "string");
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.RegisteredInterchainAccount.typeUrl || typeof o.connection_id === "string" && typeof o.port_id === "string" && typeof o.account_address === "string");
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.connectionId !== "") {
            writer.uint32(10).string(message.connectionId);
        }
        if (message.portId !== "") {
            writer.uint32(18).string(message.portId);
        }
        if (message.accountAddress !== "") {
            writer.uint32(26).string(message.accountAddress);
        }
        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 = createBaseRegisteredInterchainAccount();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.connectionId = reader.string();
                    break;
                case 2:
                    message.portId = reader.string();
                    break;
                case 3:
                    message.accountAddress = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseRegisteredInterchainAccount();
        message.connectionId = object.connectionId ?? "";
        message.portId = object.portId ?? "";
        message.accountAddress = object.accountAddress ?? "";
        return message;
    },
    fromAmino(object) {
        const message = createBaseRegisteredInterchainAccount();
        if (object.connection_id !== undefined && object.connection_id !== null) {
            message.connectionId = object.connection_id;
        }
        if (object.port_id !== undefined && object.port_id !== null) {
            message.portId = object.port_id;
        }
        if (object.account_address !== undefined && object.account_address !== null) {
            message.accountAddress = object.account_address;
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.connection_id = message.connectionId === "" ? undefined : message.connectionId;
        obj.port_id = message.portId === "" ? undefined : message.portId;
        obj.account_address = message.accountAddress === "" ? undefined : message.accountAddress;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.RegisteredInterchainAccount.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/RegisteredInterchainAccount",
            value: exports.RegisteredInterchainAccount.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.RegisteredInterchainAccount.decode(message.value);
    },
    toProto(message) {
        return exports.RegisteredInterchainAccount.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.applications.interchain_accounts.genesis.v1.RegisteredInterchainAccount",
            value: exports.RegisteredInterchainAccount.encode(message).finish()
        };
    }
};
registry_1.GlobalDecoderRegistry.register(exports.RegisteredInterchainAccount.typeUrl, exports.RegisteredInterchainAccount);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.RegisteredInterchainAccount.aminoType, exports.RegisteredInterchainAccount.typeUrl);
