"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ForwardRelayerAddress = exports.RegisteredCounterpartyPayee = exports.RegisteredPayee = exports.FeeEnabledChannel = exports.GenesisState = void 0;
const fee_1 = require("./fee");
const channel_1 = require("../../../core/channel/v1/channel");
const binary_1 = require("../../../../binary");
const registry_1 = require("../../../../registry");
function createBaseGenesisState() {
    return {
        identifiedFees: [],
        feeEnabledChannels: [],
        registeredPayees: [],
        registeredCounterpartyPayees: [],
        forwardRelayers: []
    };
}
exports.GenesisState = {
    typeUrl: "/ibc.applications.fee.v1.GenesisState",
    aminoType: "cosmos-sdk/GenesisState",
    is(o) {
        return o && (o.$typeUrl === exports.GenesisState.typeUrl || Array.isArray(o.identifiedFees) && (!o.identifiedFees.length || fee_1.IdentifiedPacketFees.is(o.identifiedFees[0])) && Array.isArray(o.feeEnabledChannels) && (!o.feeEnabledChannels.length || exports.FeeEnabledChannel.is(o.feeEnabledChannels[0])) && Array.isArray(o.registeredPayees) && (!o.registeredPayees.length || exports.RegisteredPayee.is(o.registeredPayees[0])) && Array.isArray(o.registeredCounterpartyPayees) && (!o.registeredCounterpartyPayees.length || exports.RegisteredCounterpartyPayee.is(o.registeredCounterpartyPayees[0])) && Array.isArray(o.forwardRelayers) && (!o.forwardRelayers.length || exports.ForwardRelayerAddress.is(o.forwardRelayers[0])));
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.GenesisState.typeUrl || Array.isArray(o.identified_fees) && (!o.identified_fees.length || fee_1.IdentifiedPacketFees.isAmino(o.identified_fees[0])) && Array.isArray(o.fee_enabled_channels) && (!o.fee_enabled_channels.length || exports.FeeEnabledChannel.isAmino(o.fee_enabled_channels[0])) && Array.isArray(o.registered_payees) && (!o.registered_payees.length || exports.RegisteredPayee.isAmino(o.registered_payees[0])) && Array.isArray(o.registered_counterparty_payees) && (!o.registered_counterparty_payees.length || exports.RegisteredCounterpartyPayee.isAmino(o.registered_counterparty_payees[0])) && Array.isArray(o.forward_relayers) && (!o.forward_relayers.length || exports.ForwardRelayerAddress.isAmino(o.forward_relayers[0])));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        for (const v of message.identifiedFees) {
            fee_1.IdentifiedPacketFees.encode(v, writer.uint32(10).fork()).ldelim();
        }
        for (const v of message.feeEnabledChannels) {
            exports.FeeEnabledChannel.encode(v, writer.uint32(18).fork()).ldelim();
        }
        for (const v of message.registeredPayees) {
            exports.RegisteredPayee.encode(v, writer.uint32(26).fork()).ldelim();
        }
        for (const v of message.registeredCounterpartyPayees) {
            exports.RegisteredCounterpartyPayee.encode(v, writer.uint32(34).fork()).ldelim();
        }
        for (const v of message.forwardRelayers) {
            exports.ForwardRelayerAddress.encode(v, writer.uint32(42).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.identifiedFees.push(fee_1.IdentifiedPacketFees.decode(reader, reader.uint32()));
                    break;
                case 2:
                    message.feeEnabledChannels.push(exports.FeeEnabledChannel.decode(reader, reader.uint32()));
                    break;
                case 3:
                    message.registeredPayees.push(exports.RegisteredPayee.decode(reader, reader.uint32()));
                    break;
                case 4:
                    message.registeredCounterpartyPayees.push(exports.RegisteredCounterpartyPayee.decode(reader, reader.uint32()));
                    break;
                case 5:
                    message.forwardRelayers.push(exports.ForwardRelayerAddress.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseGenesisState();
        message.identifiedFees = object.identifiedFees?.map(e => fee_1.IdentifiedPacketFees.fromPartial(e)) || [];
        message.feeEnabledChannels = object.feeEnabledChannels?.map(e => exports.FeeEnabledChannel.fromPartial(e)) || [];
        message.registeredPayees = object.registeredPayees?.map(e => exports.RegisteredPayee.fromPartial(e)) || [];
        message.registeredCounterpartyPayees = object.registeredCounterpartyPayees?.map(e => exports.RegisteredCounterpartyPayee.fromPartial(e)) || [];
        message.forwardRelayers = object.forwardRelayers?.map(e => exports.ForwardRelayerAddress.fromPartial(e)) || [];
        return message;
    },
    fromAmino(object) {
        const message = createBaseGenesisState();
        message.identifiedFees = object.identified_fees?.map(e => fee_1.IdentifiedPacketFees.fromAmino(e)) || [];
        message.feeEnabledChannels = object.fee_enabled_channels?.map(e => exports.FeeEnabledChannel.fromAmino(e)) || [];
        message.registeredPayees = object.registered_payees?.map(e => exports.RegisteredPayee.fromAmino(e)) || [];
        message.registeredCounterpartyPayees = object.registered_counterparty_payees?.map(e => exports.RegisteredCounterpartyPayee.fromAmino(e)) || [];
        message.forwardRelayers = object.forward_relayers?.map(e => exports.ForwardRelayerAddress.fromAmino(e)) || [];
        return message;
    },
    toAmino(message) {
        const obj = {};
        if (message.identifiedFees) {
            obj.identified_fees = message.identifiedFees.map(e => e ? fee_1.IdentifiedPacketFees.toAmino(e) : undefined);
        }
        else {
            obj.identified_fees = message.identifiedFees;
        }
        if (message.feeEnabledChannels) {
            obj.fee_enabled_channels = message.feeEnabledChannels.map(e => e ? exports.FeeEnabledChannel.toAmino(e) : undefined);
        }
        else {
            obj.fee_enabled_channels = message.feeEnabledChannels;
        }
        if (message.registeredPayees) {
            obj.registered_payees = message.registeredPayees.map(e => e ? exports.RegisteredPayee.toAmino(e) : undefined);
        }
        else {
            obj.registered_payees = message.registeredPayees;
        }
        if (message.registeredCounterpartyPayees) {
            obj.registered_counterparty_payees = message.registeredCounterpartyPayees.map(e => e ? exports.RegisteredCounterpartyPayee.toAmino(e) : undefined);
        }
        else {
            obj.registered_counterparty_payees = message.registeredCounterpartyPayees;
        }
        if (message.forwardRelayers) {
            obj.forward_relayers = message.forwardRelayers.map(e => e ? exports.ForwardRelayerAddress.toAmino(e) : undefined);
        }
        else {
            obj.forward_relayers = message.forwardRelayers;
        }
        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.fee.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 createBaseFeeEnabledChannel() {
    return {
        portId: "",
        channelId: ""
    };
}
exports.FeeEnabledChannel = {
    typeUrl: "/ibc.applications.fee.v1.FeeEnabledChannel",
    aminoType: "cosmos-sdk/FeeEnabledChannel",
    is(o) {
        return o && (o.$typeUrl === exports.FeeEnabledChannel.typeUrl || typeof o.portId === "string" && typeof o.channelId === "string");
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.FeeEnabledChannel.typeUrl || typeof o.port_id === "string" && typeof o.channel_id === "string");
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.portId !== "") {
            writer.uint32(10).string(message.portId);
        }
        if (message.channelId !== "") {
            writer.uint32(18).string(message.channelId);
        }
        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 = createBaseFeeEnabledChannel();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.portId = reader.string();
                    break;
                case 2:
                    message.channelId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseFeeEnabledChannel();
        message.portId = object.portId ?? "";
        message.channelId = object.channelId ?? "";
        return message;
    },
    fromAmino(object) {
        const message = createBaseFeeEnabledChannel();
        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;
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.port_id = message.portId === "" ? undefined : message.portId;
        obj.channel_id = message.channelId === "" ? undefined : message.channelId;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.FeeEnabledChannel.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/FeeEnabledChannel",
            value: exports.FeeEnabledChannel.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.FeeEnabledChannel.decode(message.value);
    },
    toProto(message) {
        return exports.FeeEnabledChannel.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.applications.fee.v1.FeeEnabledChannel",
            value: exports.FeeEnabledChannel.encode(message).finish()
        };
    }
};
registry_1.GlobalDecoderRegistry.register(exports.FeeEnabledChannel.typeUrl, exports.FeeEnabledChannel);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.FeeEnabledChannel.aminoType, exports.FeeEnabledChannel.typeUrl);
function createBaseRegisteredPayee() {
    return {
        channelId: "",
        relayer: "",
        payee: ""
    };
}
exports.RegisteredPayee = {
    typeUrl: "/ibc.applications.fee.v1.RegisteredPayee",
    aminoType: "cosmos-sdk/RegisteredPayee",
    is(o) {
        return o && (o.$typeUrl === exports.RegisteredPayee.typeUrl || typeof o.channelId === "string" && typeof o.relayer === "string" && typeof o.payee === "string");
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.RegisteredPayee.typeUrl || typeof o.channel_id === "string" && typeof o.relayer === "string" && typeof o.payee === "string");
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.channelId !== "") {
            writer.uint32(10).string(message.channelId);
        }
        if (message.relayer !== "") {
            writer.uint32(18).string(message.relayer);
        }
        if (message.payee !== "") {
            writer.uint32(26).string(message.payee);
        }
        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 = createBaseRegisteredPayee();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.channelId = reader.string();
                    break;
                case 2:
                    message.relayer = reader.string();
                    break;
                case 3:
                    message.payee = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseRegisteredPayee();
        message.channelId = object.channelId ?? "";
        message.relayer = object.relayer ?? "";
        message.payee = object.payee ?? "";
        return message;
    },
    fromAmino(object) {
        const message = createBaseRegisteredPayee();
        if (object.channel_id !== undefined && object.channel_id !== null) {
            message.channelId = object.channel_id;
        }
        if (object.relayer !== undefined && object.relayer !== null) {
            message.relayer = object.relayer;
        }
        if (object.payee !== undefined && object.payee !== null) {
            message.payee = object.payee;
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.channel_id = message.channelId === "" ? undefined : message.channelId;
        obj.relayer = message.relayer === "" ? undefined : message.relayer;
        obj.payee = message.payee === "" ? undefined : message.payee;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.RegisteredPayee.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/RegisteredPayee",
            value: exports.RegisteredPayee.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.RegisteredPayee.decode(message.value);
    },
    toProto(message) {
        return exports.RegisteredPayee.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.applications.fee.v1.RegisteredPayee",
            value: exports.RegisteredPayee.encode(message).finish()
        };
    }
};
registry_1.GlobalDecoderRegistry.register(exports.RegisteredPayee.typeUrl, exports.RegisteredPayee);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.RegisteredPayee.aminoType, exports.RegisteredPayee.typeUrl);
function createBaseRegisteredCounterpartyPayee() {
    return {
        channelId: "",
        relayer: "",
        counterpartyPayee: ""
    };
}
exports.RegisteredCounterpartyPayee = {
    typeUrl: "/ibc.applications.fee.v1.RegisteredCounterpartyPayee",
    aminoType: "cosmos-sdk/RegisteredCounterpartyPayee",
    is(o) {
        return o && (o.$typeUrl === exports.RegisteredCounterpartyPayee.typeUrl || typeof o.channelId === "string" && typeof o.relayer === "string" && typeof o.counterpartyPayee === "string");
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.RegisteredCounterpartyPayee.typeUrl || typeof o.channel_id === "string" && typeof o.relayer === "string" && typeof o.counterparty_payee === "string");
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.channelId !== "") {
            writer.uint32(10).string(message.channelId);
        }
        if (message.relayer !== "") {
            writer.uint32(18).string(message.relayer);
        }
        if (message.counterpartyPayee !== "") {
            writer.uint32(26).string(message.counterpartyPayee);
        }
        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 = createBaseRegisteredCounterpartyPayee();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.channelId = reader.string();
                    break;
                case 2:
                    message.relayer = reader.string();
                    break;
                case 3:
                    message.counterpartyPayee = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseRegisteredCounterpartyPayee();
        message.channelId = object.channelId ?? "";
        message.relayer = object.relayer ?? "";
        message.counterpartyPayee = object.counterpartyPayee ?? "";
        return message;
    },
    fromAmino(object) {
        const message = createBaseRegisteredCounterpartyPayee();
        if (object.channel_id !== undefined && object.channel_id !== null) {
            message.channelId = object.channel_id;
        }
        if (object.relayer !== undefined && object.relayer !== null) {
            message.relayer = object.relayer;
        }
        if (object.counterparty_payee !== undefined && object.counterparty_payee !== null) {
            message.counterpartyPayee = object.counterparty_payee;
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.channel_id = message.channelId === "" ? undefined : message.channelId;
        obj.relayer = message.relayer === "" ? undefined : message.relayer;
        obj.counterparty_payee = message.counterpartyPayee === "" ? undefined : message.counterpartyPayee;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.RegisteredCounterpartyPayee.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/RegisteredCounterpartyPayee",
            value: exports.RegisteredCounterpartyPayee.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.RegisteredCounterpartyPayee.decode(message.value);
    },
    toProto(message) {
        return exports.RegisteredCounterpartyPayee.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.applications.fee.v1.RegisteredCounterpartyPayee",
            value: exports.RegisteredCounterpartyPayee.encode(message).finish()
        };
    }
};
registry_1.GlobalDecoderRegistry.register(exports.RegisteredCounterpartyPayee.typeUrl, exports.RegisteredCounterpartyPayee);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.RegisteredCounterpartyPayee.aminoType, exports.RegisteredCounterpartyPayee.typeUrl);
function createBaseForwardRelayerAddress() {
    return {
        address: "",
        packetId: channel_1.PacketId.fromPartial({})
    };
}
exports.ForwardRelayerAddress = {
    typeUrl: "/ibc.applications.fee.v1.ForwardRelayerAddress",
    aminoType: "cosmos-sdk/ForwardRelayerAddress",
    is(o) {
        return o && (o.$typeUrl === exports.ForwardRelayerAddress.typeUrl || typeof o.address === "string" && channel_1.PacketId.is(o.packetId));
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.ForwardRelayerAddress.typeUrl || typeof o.address === "string" && channel_1.PacketId.isAmino(o.packet_id));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.address !== "") {
            writer.uint32(10).string(message.address);
        }
        if (message.packetId !== undefined) {
            channel_1.PacketId.encode(message.packetId, 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 = createBaseForwardRelayerAddress();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.address = reader.string();
                    break;
                case 2:
                    message.packetId = channel_1.PacketId.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseForwardRelayerAddress();
        message.address = object.address ?? "";
        message.packetId = object.packetId !== undefined && object.packetId !== null ? channel_1.PacketId.fromPartial(object.packetId) : undefined;
        return message;
    },
    fromAmino(object) {
        const message = createBaseForwardRelayerAddress();
        if (object.address !== undefined && object.address !== null) {
            message.address = object.address;
        }
        if (object.packet_id !== undefined && object.packet_id !== null) {
            message.packetId = channel_1.PacketId.fromAmino(object.packet_id);
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.address = message.address === "" ? undefined : message.address;
        obj.packet_id = message.packetId ? channel_1.PacketId.toAmino(message.packetId) : undefined;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.ForwardRelayerAddress.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/ForwardRelayerAddress",
            value: exports.ForwardRelayerAddress.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.ForwardRelayerAddress.decode(message.value);
    },
    toProto(message) {
        return exports.ForwardRelayerAddress.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.applications.fee.v1.ForwardRelayerAddress",
            value: exports.ForwardRelayerAddress.encode(message).finish()
        };
    }
};
registry_1.GlobalDecoderRegistry.register(exports.ForwardRelayerAddress.typeUrl, exports.ForwardRelayerAddress);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.ForwardRelayerAddress.aminoType, exports.ForwardRelayerAddress.typeUrl);
