import { Params as Params1 } from "../../controller/v1/controller";
import { Params as Params2 } from "../../host/v1/host";
import { BinaryReader, BinaryWriter } from "../../../../../binary";
function createBaseGenesisState() {
    return {
        controllerGenesisState: ControllerGenesisState.fromPartial({}),
        hostGenesisState: HostGenesisState.fromPartial({})
    };
}
export const GenesisState = {
    typeUrl: "/ibc.applications.interchain_accounts.genesis.v1.GenesisState",
    aminoType: "cosmos-sdk/GenesisState",
    encode(message, writer = BinaryWriter.create()) {
        if (message.controllerGenesisState !== undefined) {
            ControllerGenesisState.encode(message.controllerGenesisState, writer.uint32(10).fork()).ldelim();
        }
        if (message.hostGenesisState !== undefined) {
            HostGenesisState.encode(message.hostGenesisState, writer.uint32(18).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new 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 = ControllerGenesisState.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.hostGenesisState = 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 ? ControllerGenesisState.fromPartial(object.controllerGenesisState) : undefined;
        message.hostGenesisState = object.hostGenesisState !== undefined && object.hostGenesisState !== null ? HostGenesisState.fromPartial(object.hostGenesisState) : undefined;
        return message;
    },
    fromAmino(object) {
        return {
            controllerGenesisState: object?.controller_genesis_state ? ControllerGenesisState.fromAmino(object.controller_genesis_state) : undefined,
            hostGenesisState: object?.host_genesis_state ? HostGenesisState.fromAmino(object.host_genesis_state) : undefined
        };
    },
    toAmino(message) {
        const obj = {};
        obj.controller_genesis_state = message.controllerGenesisState ? ControllerGenesisState.toAmino(message.controllerGenesisState) : undefined;
        obj.host_genesis_state = message.hostGenesisState ? HostGenesisState.toAmino(message.hostGenesisState) : undefined;
        return obj;
    },
    fromAminoMsg(object) {
        return GenesisState.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/GenesisState",
            value: GenesisState.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return GenesisState.decode(message.value);
    },
    toProto(message) {
        return GenesisState.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.applications.interchain_accounts.genesis.v1.GenesisState",
            value: GenesisState.encode(message).finish()
        };
    }
};
function createBaseControllerGenesisState() {
    return {
        activeChannels: [],
        interchainAccounts: [],
        ports: [],
        params: Params1.fromPartial({})
    };
}
export const ControllerGenesisState = {
    typeUrl: "/ibc.applications.interchain_accounts.genesis.v1.ControllerGenesisState",
    aminoType: "cosmos-sdk/ControllerGenesisState",
    encode(message, writer = BinaryWriter.create()) {
        for (const v of message.activeChannels) {
            ActiveChannel.encode(v, writer.uint32(10).fork()).ldelim();
        }
        for (const v of message.interchainAccounts) {
            RegisteredInterchainAccount.encode(v, writer.uint32(18).fork()).ldelim();
        }
        for (const v of message.ports) {
            writer.uint32(26).string(v);
        }
        if (message.params !== undefined) {
            Params1.encode(message.params, writer.uint32(34).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new 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(ActiveChannel.decode(reader, reader.uint32()));
                    break;
                case 2:
                    message.interchainAccounts.push(RegisteredInterchainAccount.decode(reader, reader.uint32()));
                    break;
                case 3:
                    message.ports.push(reader.string());
                    break;
                case 4:
                    message.params = Params1.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseControllerGenesisState();
        message.activeChannels = object.activeChannels?.map(e => ActiveChannel.fromPartial(e)) || [];
        message.interchainAccounts = object.interchainAccounts?.map(e => RegisteredInterchainAccount.fromPartial(e)) || [];
        message.ports = object.ports?.map(e => e) || [];
        message.params = object.params !== undefined && object.params !== null ? Params1.fromPartial(object.params) : undefined;
        return message;
    },
    fromAmino(object) {
        return {
            activeChannels: Array.isArray(object?.active_channels) ? object.active_channels.map((e) => ActiveChannel.fromAmino(e)) : [],
            interchainAccounts: Array.isArray(object?.interchain_accounts) ? object.interchain_accounts.map((e) => RegisteredInterchainAccount.fromAmino(e)) : [],
            ports: Array.isArray(object?.ports) ? object.ports.map((e) => e) : [],
            params: object?.params ? Params1.fromAmino(object.params) : undefined
        };
    },
    toAmino(message) {
        const obj = {};
        if (message.activeChannels) {
            obj.active_channels = message.activeChannels.map(e => e ? ActiveChannel.toAmino(e) : undefined);
        }
        else {
            obj.active_channels = [];
        }
        if (message.interchainAccounts) {
            obj.interchain_accounts = message.interchainAccounts.map(e => e ? RegisteredInterchainAccount.toAmino(e) : undefined);
        }
        else {
            obj.interchain_accounts = [];
        }
        if (message.ports) {
            obj.ports = message.ports.map(e => e);
        }
        else {
            obj.ports = [];
        }
        obj.params = message.params ? Params1.toAmino(message.params) : undefined;
        return obj;
    },
    fromAminoMsg(object) {
        return ControllerGenesisState.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/ControllerGenesisState",
            value: ControllerGenesisState.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return ControllerGenesisState.decode(message.value);
    },
    toProto(message) {
        return ControllerGenesisState.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.applications.interchain_accounts.genesis.v1.ControllerGenesisState",
            value: ControllerGenesisState.encode(message).finish()
        };
    }
};
function createBaseHostGenesisState() {
    return {
        activeChannels: [],
        interchainAccounts: [],
        port: "",
        params: Params2.fromPartial({})
    };
}
export const HostGenesisState = {
    typeUrl: "/ibc.applications.interchain_accounts.genesis.v1.HostGenesisState",
    aminoType: "cosmos-sdk/HostGenesisState",
    encode(message, writer = BinaryWriter.create()) {
        for (const v of message.activeChannels) {
            ActiveChannel.encode(v, writer.uint32(10).fork()).ldelim();
        }
        for (const v of message.interchainAccounts) {
            RegisteredInterchainAccount.encode(v, writer.uint32(18).fork()).ldelim();
        }
        if (message.port !== "") {
            writer.uint32(26).string(message.port);
        }
        if (message.params !== undefined) {
            Params2.encode(message.params, writer.uint32(34).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new 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(ActiveChannel.decode(reader, reader.uint32()));
                    break;
                case 2:
                    message.interchainAccounts.push(RegisteredInterchainAccount.decode(reader, reader.uint32()));
                    break;
                case 3:
                    message.port = reader.string();
                    break;
                case 4:
                    message.params = Params2.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseHostGenesisState();
        message.activeChannels = object.activeChannels?.map(e => ActiveChannel.fromPartial(e)) || [];
        message.interchainAccounts = object.interchainAccounts?.map(e => RegisteredInterchainAccount.fromPartial(e)) || [];
        message.port = object.port ?? "";
        message.params = object.params !== undefined && object.params !== null ? Params2.fromPartial(object.params) : undefined;
        return message;
    },
    fromAmino(object) {
        return {
            activeChannels: Array.isArray(object?.active_channels) ? object.active_channels.map((e) => ActiveChannel.fromAmino(e)) : [],
            interchainAccounts: Array.isArray(object?.interchain_accounts) ? object.interchain_accounts.map((e) => RegisteredInterchainAccount.fromAmino(e)) : [],
            port: object.port,
            params: object?.params ? Params2.fromAmino(object.params) : undefined
        };
    },
    toAmino(message) {
        const obj = {};
        if (message.activeChannels) {
            obj.active_channels = message.activeChannels.map(e => e ? ActiveChannel.toAmino(e) : undefined);
        }
        else {
            obj.active_channels = [];
        }
        if (message.interchainAccounts) {
            obj.interchain_accounts = message.interchainAccounts.map(e => e ? RegisteredInterchainAccount.toAmino(e) : undefined);
        }
        else {
            obj.interchain_accounts = [];
        }
        obj.port = message.port;
        obj.params = message.params ? Params2.toAmino(message.params) : undefined;
        return obj;
    },
    fromAminoMsg(object) {
        return HostGenesisState.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/HostGenesisState",
            value: HostGenesisState.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return HostGenesisState.decode(message.value);
    },
    toProto(message) {
        return HostGenesisState.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.applications.interchain_accounts.genesis.v1.HostGenesisState",
            value: HostGenesisState.encode(message).finish()
        };
    }
};
function createBaseActiveChannel() {
    return {
        connectionId: "",
        portId: "",
        channelId: "",
        isMiddlewareEnabled: false
    };
}
export const ActiveChannel = {
    typeUrl: "/ibc.applications.interchain_accounts.genesis.v1.ActiveChannel",
    aminoType: "cosmos-sdk/ActiveChannel",
    encode(message, writer = 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 BinaryReader ? input : new 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) {
        return {
            connectionId: object.connection_id,
            portId: object.port_id,
            channelId: object.channel_id,
            isMiddlewareEnabled: object.is_middleware_enabled
        };
    },
    toAmino(message) {
        const obj = {};
        obj.connection_id = message.connectionId;
        obj.port_id = message.portId;
        obj.channel_id = message.channelId;
        obj.is_middleware_enabled = message.isMiddlewareEnabled;
        return obj;
    },
    fromAminoMsg(object) {
        return ActiveChannel.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/ActiveChannel",
            value: ActiveChannel.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return ActiveChannel.decode(message.value);
    },
    toProto(message) {
        return ActiveChannel.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.applications.interchain_accounts.genesis.v1.ActiveChannel",
            value: ActiveChannel.encode(message).finish()
        };
    }
};
function createBaseRegisteredInterchainAccount() {
    return {
        connectionId: "",
        portId: "",
        accountAddress: ""
    };
}
export const RegisteredInterchainAccount = {
    typeUrl: "/ibc.applications.interchain_accounts.genesis.v1.RegisteredInterchainAccount",
    aminoType: "cosmos-sdk/RegisteredInterchainAccount",
    encode(message, writer = 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 BinaryReader ? input : new 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) {
        return {
            connectionId: object.connection_id,
            portId: object.port_id,
            accountAddress: object.account_address
        };
    },
    toAmino(message) {
        const obj = {};
        obj.connection_id = message.connectionId;
        obj.port_id = message.portId;
        obj.account_address = message.accountAddress;
        return obj;
    },
    fromAminoMsg(object) {
        return RegisteredInterchainAccount.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/RegisteredInterchainAccount",
            value: RegisteredInterchainAccount.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return RegisteredInterchainAccount.decode(message.value);
    },
    toProto(message) {
        return RegisteredInterchainAccount.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.applications.interchain_accounts.genesis.v1.RegisteredInterchainAccount",
            value: RegisteredInterchainAccount.encode(message).finish()
        };
    }
};
//# sourceMappingURL=genesis.js.map