"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Hop = exports.Denom = exports.Token = void 0;
const binary_1 = require("../../../../binary");
const registry_1 = require("../../../../registry");
function createBaseToken() {
    return {
        denom: exports.Denom.fromPartial({}),
        amount: ""
    };
}
/**
 * Token defines a struct which represents a token to be transferred.
 * @name Token
 * @package ibc.applications.transfer.v1
 * @see proto type: ibc.applications.transfer.v1.Token
 */
exports.Token = {
    typeUrl: "/ibc.applications.transfer.v1.Token",
    aminoType: "cosmos-sdk/Token",
    is(o) {
        return o && (o.$typeUrl === exports.Token.typeUrl || exports.Denom.is(o.denom) && typeof o.amount === "string");
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.Token.typeUrl || exports.Denom.isAmino(o.denom) && typeof o.amount === "string");
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.denom !== undefined) {
            exports.Denom.encode(message.denom, writer.uint32(10).fork()).ldelim();
        }
        if (message.amount !== "") {
            writer.uint32(18).string(message.amount);
        }
        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 = createBaseToken();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.denom = exports.Denom.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.amount = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseToken();
        message.denom = object.denom !== undefined && object.denom !== null ? exports.Denom.fromPartial(object.denom) : undefined;
        message.amount = object.amount ?? "";
        return message;
    },
    fromAmino(object) {
        const message = createBaseToken();
        if (object.denom !== undefined && object.denom !== null) {
            message.denom = exports.Denom.fromAmino(object.denom);
        }
        if (object.amount !== undefined && object.amount !== null) {
            message.amount = object.amount;
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.denom = message.denom ? exports.Denom.toAmino(message.denom) : undefined;
        obj.amount = message.amount === "" ? undefined : message.amount;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.Token.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/Token",
            value: exports.Token.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.Token.decode(message.value);
    },
    toProto(message) {
        return exports.Token.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.applications.transfer.v1.Token",
            value: exports.Token.encode(message).finish()
        };
    },
    registerTypeUrl() {
        if (!registry_1.GlobalDecoderRegistry.registerExistingTypeUrl(exports.Token.typeUrl)) {
            return;
        }
        exports.Denom.registerTypeUrl();
    }
};
function createBaseDenom() {
    return {
        base: "",
        trace: []
    };
}
/**
 * Denom holds the base denom of a Token and a trace of the chains it was sent through.
 * @name Denom
 * @package ibc.applications.transfer.v1
 * @see proto type: ibc.applications.transfer.v1.Denom
 */
exports.Denom = {
    typeUrl: "/ibc.applications.transfer.v1.Denom",
    aminoType: "cosmos-sdk/Denom",
    is(o) {
        return o && (o.$typeUrl === exports.Denom.typeUrl || typeof o.base === "string" && Array.isArray(o.trace) && (!o.trace.length || exports.Hop.is(o.trace[0])));
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.Denom.typeUrl || typeof o.base === "string" && Array.isArray(o.trace) && (!o.trace.length || exports.Hop.isAmino(o.trace[0])));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.base !== "") {
            writer.uint32(10).string(message.base);
        }
        for (const v of message.trace) {
            exports.Hop.encode(v, writer.uint32(26).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 = createBaseDenom();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.base = reader.string();
                    break;
                case 3:
                    message.trace.push(exports.Hop.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseDenom();
        message.base = object.base ?? "";
        message.trace = object.trace?.map(e => exports.Hop.fromPartial(e)) || [];
        return message;
    },
    fromAmino(object) {
        const message = createBaseDenom();
        if (object.base !== undefined && object.base !== null) {
            message.base = object.base;
        }
        message.trace = object.trace?.map(e => exports.Hop.fromAmino(e)) || [];
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.base = message.base === "" ? undefined : message.base;
        if (message.trace) {
            obj.trace = message.trace.map(e => e ? exports.Hop.toAmino(e) : undefined);
        }
        else {
            obj.trace = message.trace;
        }
        return obj;
    },
    fromAminoMsg(object) {
        return exports.Denom.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/Denom",
            value: exports.Denom.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.Denom.decode(message.value);
    },
    toProto(message) {
        return exports.Denom.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.applications.transfer.v1.Denom",
            value: exports.Denom.encode(message).finish()
        };
    },
    registerTypeUrl() {
        if (!registry_1.GlobalDecoderRegistry.registerExistingTypeUrl(exports.Denom.typeUrl)) {
            return;
        }
        exports.Hop.registerTypeUrl();
    }
};
function createBaseHop() {
    return {
        portId: "",
        channelId: ""
    };
}
/**
 * Hop defines a port ID, channel ID pair specifying a unique "hop" in a trace
 * @name Hop
 * @package ibc.applications.transfer.v1
 * @see proto type: ibc.applications.transfer.v1.Hop
 */
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()
        };
    },
    registerTypeUrl() { }
};
