"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Hop = exports.Forwarding = exports.Params = void 0;
const binary_1 = require("../../../../binary");
const registry_1 = require("../../../../registry");
function createBaseParams() {
    return {
        sendEnabled: false,
        receiveEnabled: false
    };
}
exports.Params = {
    typeUrl: "/ibc.applications.transfer.v1.Params",
    aminoType: "cosmos-sdk/Params",
    is(o) {
        return o && (o.$typeUrl === exports.Params.typeUrl || typeof o.sendEnabled === "boolean" && typeof o.receiveEnabled === "boolean");
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.Params.typeUrl || typeof o.send_enabled === "boolean" && typeof o.receive_enabled === "boolean");
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.sendEnabled === true) {
            writer.uint32(8).bool(message.sendEnabled);
        }
        if (message.receiveEnabled === true) {
            writer.uint32(16).bool(message.receiveEnabled);
        }
        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 = createBaseParams();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.sendEnabled = reader.bool();
                    break;
                case 2:
                    message.receiveEnabled = reader.bool();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseParams();
        message.sendEnabled = object.sendEnabled ?? false;
        message.receiveEnabled = object.receiveEnabled ?? false;
        return message;
    },
    fromAmino(object) {
        const message = createBaseParams();
        if (object.send_enabled !== undefined && object.send_enabled !== null) {
            message.sendEnabled = object.send_enabled;
        }
        if (object.receive_enabled !== undefined && object.receive_enabled !== null) {
            message.receiveEnabled = object.receive_enabled;
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.send_enabled = message.sendEnabled === false ? undefined : message.sendEnabled;
        obj.receive_enabled = message.receiveEnabled === false ? undefined : message.receiveEnabled;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.Params.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/Params",
            value: exports.Params.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.Params.decode(message.value);
    },
    toProto(message) {
        return exports.Params.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.applications.transfer.v1.Params",
            value: exports.Params.encode(message).finish()
        };
    }
};
registry_1.GlobalDecoderRegistry.register(exports.Params.typeUrl, exports.Params);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.Params.aminoType, exports.Params.typeUrl);
function createBaseForwarding() {
    return {
        unwind: false,
        hops: []
    };
}
exports.Forwarding = {
    typeUrl: "/ibc.applications.transfer.v1.Forwarding",
    aminoType: "cosmos-sdk/Forwarding",
    is(o) {
        return o && (o.$typeUrl === exports.Forwarding.typeUrl || typeof o.unwind === "boolean" && Array.isArray(o.hops) && (!o.hops.length || exports.Hop.is(o.hops[0])));
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.Forwarding.typeUrl || typeof o.unwind === "boolean" && Array.isArray(o.hops) && (!o.hops.length || exports.Hop.isAmino(o.hops[0])));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.unwind === true) {
            writer.uint32(8).bool(message.unwind);
        }
        for (const v of message.hops) {
            exports.Hop.encode(v, 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 = createBaseForwarding();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.unwind = reader.bool();
                    break;
                case 2:
                    message.hops.push(exports.Hop.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseForwarding();
        message.unwind = object.unwind ?? false;
        message.hops = object.hops?.map(e => exports.Hop.fromPartial(e)) || [];
        return message;
    },
    fromAmino(object) {
        const message = createBaseForwarding();
        if (object.unwind !== undefined && object.unwind !== null) {
            message.unwind = object.unwind;
        }
        message.hops = object.hops?.map(e => exports.Hop.fromAmino(e)) || [];
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.unwind = message.unwind === false ? undefined : message.unwind;
        if (message.hops) {
            obj.hops = message.hops.map(e => e ? exports.Hop.toAmino(e) : undefined);
        }
        else {
            obj.hops = message.hops;
        }
        return obj;
    },
    fromAminoMsg(object) {
        return exports.Forwarding.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/Forwarding",
            value: exports.Forwarding.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.Forwarding.decode(message.value);
    },
    toProto(message) {
        return exports.Forwarding.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.applications.transfer.v1.Forwarding",
            value: exports.Forwarding.encode(message).finish()
        };
    }
};
registry_1.GlobalDecoderRegistry.register(exports.Forwarding.typeUrl, exports.Forwarding);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.Forwarding.aminoType, exports.Forwarding.typeUrl);
function createBaseHop() {
    return {
        portId: "",
        channelId: ""
    };
}
exports.Hop = {
    typeUrl: "/ibc.applications.transfer.v1.Hop",
    aminoType: "cosmos-sdk/Hop",
    is(o) {
        return o && (o.$typeUrl === exports.Hop.typeUrl || typeof o.portId === "string" && typeof o.channelId === "string");
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.Hop.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 = createBaseHop();
        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 = createBaseHop();
        message.portId = object.portId ?? "";
        message.channelId = object.channelId ?? "";
        return message;
    },
    fromAmino(object) {
        const message = createBaseHop();
        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.Hop.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/Hop",
            value: exports.Hop.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.Hop.decode(message.value);
    },
    toProto(message) {
        return exports.Hop.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.applications.transfer.v1.Hop",
            value: exports.Hop.encode(message).finish()
        };
    }
};
registry_1.GlobalDecoderRegistry.register(exports.Hop.typeUrl, exports.Hop);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.Hop.aminoType, exports.Hop.typeUrl);
