//@ts-nocheck
import { Coin } from '../../../cosmos/base/v1beta1/coin.js';
import { BinaryReader, BinaryWriter } from '../../../binary.js';
import { isSet } from '../../../helpers.js';
import {} from '../../../json-safe.js';
function createBaseRoute() {
    return {
        poolId: BigInt(0),
        denomTo: '',
    };
}
export const Route = {
    typeUrl: '/noble.swap.v1.Route',
    encode(message, writer = BinaryWriter.create()) {
        if (message.poolId !== BigInt(0)) {
            writer.uint32(8).uint64(message.poolId);
        }
        if (message.denomTo !== '') {
            writer.uint32(18).string(message.denomTo);
        }
        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 = createBaseRoute();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.poolId = reader.uint64();
                    break;
                case 2:
                    message.denomTo = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        return {
            poolId: isSet(object.poolId)
                ? BigInt(object.poolId.toString())
                : BigInt(0),
            denomTo: isSet(object.denomTo) ? String(object.denomTo) : '',
        };
    },
    toJSON(message) {
        const obj = {};
        message.poolId !== undefined &&
            (obj.poolId = (message.poolId || BigInt(0)).toString());
        message.denomTo !== undefined && (obj.denomTo = message.denomTo);
        return obj;
    },
    fromPartial(object) {
        const message = createBaseRoute();
        message.poolId =
            object.poolId !== undefined && object.poolId !== null
                ? BigInt(object.poolId.toString())
                : BigInt(0);
        message.denomTo = object.denomTo ?? '';
        return message;
    },
    fromProtoMsg(message) {
        return Route.decode(message.value);
    },
    toProto(message) {
        return Route.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: '/noble.swap.v1.Route',
            value: Route.encode(message).finish(),
        };
    },
};
function createBaseSwap() {
    return {
        poolId: BigInt(0),
        in: Coin.fromPartial({}),
        out: Coin.fromPartial({}),
        fees: [],
    };
}
export const Swap = {
    typeUrl: '/noble.swap.v1.Swap',
    encode(message, writer = BinaryWriter.create()) {
        if (message.poolId !== BigInt(0)) {
            writer.uint32(8).uint64(message.poolId);
        }
        if (message.in !== undefined) {
            Coin.encode(message.in, writer.uint32(18).fork()).ldelim();
        }
        if (message.out !== undefined) {
            Coin.encode(message.out, writer.uint32(26).fork()).ldelim();
        }
        for (const v of message.fees) {
            Coin.encode(v, 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 = createBaseSwap();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.poolId = reader.uint64();
                    break;
                case 2:
                    message.in = Coin.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.out = Coin.decode(reader, reader.uint32());
                    break;
                case 4:
                    message.fees.push(Coin.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        return {
            poolId: isSet(object.poolId)
                ? BigInt(object.poolId.toString())
                : BigInt(0),
            in: isSet(object.in) ? Coin.fromJSON(object.in) : undefined,
            out: isSet(object.out) ? Coin.fromJSON(object.out) : undefined,
            fees: Array.isArray(object?.fees)
                ? object.fees.map((e) => Coin.fromJSON(e))
                : [],
        };
    },
    toJSON(message) {
        const obj = {};
        message.poolId !== undefined &&
            (obj.poolId = (message.poolId || BigInt(0)).toString());
        message.in !== undefined &&
            (obj.in = message.in ? Coin.toJSON(message.in) : undefined);
        message.out !== undefined &&
            (obj.out = message.out ? Coin.toJSON(message.out) : undefined);
        if (message.fees) {
            obj.fees = message.fees.map(e => (e ? Coin.toJSON(e) : undefined));
        }
        else {
            obj.fees = [];
        }
        return obj;
    },
    fromPartial(object) {
        const message = createBaseSwap();
        message.poolId =
            object.poolId !== undefined && object.poolId !== null
                ? BigInt(object.poolId.toString())
                : BigInt(0);
        message.in =
            object.in !== undefined && object.in !== null
                ? Coin.fromPartial(object.in)
                : undefined;
        message.out =
            object.out !== undefined && object.out !== null
                ? Coin.fromPartial(object.out)
                : undefined;
        message.fees = object.fees?.map(e => Coin.fromPartial(e)) || [];
        return message;
    },
    fromProtoMsg(message) {
        return Swap.decode(message.value);
    },
    toProto(message) {
        return Swap.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: '/noble.swap.v1.Swap',
            value: Swap.encode(message).finish(),
        };
    },
};
//# sourceMappingURL=swap.js.map