"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Params = exports.ContinuousFund = void 0;
const timestamp_1 = require("../../../google/protobuf/timestamp");
const binary_1 = require("../../../binary");
const math_1 = require("@interchainjs/math");
const helpers_1 = require("../../../helpers");
function createBaseContinuousFund() {
    return {
        recipient: "",
        percentage: "",
        expiry: undefined
    };
}
/**
 * ContinuousFund defines the fields of continuous fund proposal.
 * @name ContinuousFund
 * @package cosmos.protocolpool.v1
 * @see proto type: cosmos.protocolpool.v1.ContinuousFund
 */
exports.ContinuousFund = {
    typeUrl: "/cosmos.protocolpool.v1.ContinuousFund",
    aminoType: "cosmos-sdk/ContinuousFund",
    is(o) {
        return o && (o.$typeUrl === exports.ContinuousFund.typeUrl || typeof o.recipient === "string" && typeof o.percentage === "string");
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.ContinuousFund.typeUrl || typeof o.recipient === "string" && typeof o.percentage === "string");
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.recipient !== "") {
            writer.uint32(10).string(message.recipient);
        }
        if (message.percentage !== "") {
            writer.uint32(18).string(math_1.Decimal.fromUserInput(message.percentage, 18).atomics);
        }
        if (message.expiry !== undefined) {
            timestamp_1.Timestamp.encode((0, helpers_1.toTimestamp)(message.expiry), 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 = createBaseContinuousFund();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.recipient = reader.string();
                    break;
                case 2:
                    message.percentage = math_1.Decimal.fromAtomics(reader.string(), 18).toString();
                    break;
                case 3:
                    message.expiry = (0, helpers_1.fromTimestamp)(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseContinuousFund();
        message.recipient = object.recipient ?? "";
        message.percentage = object.percentage ?? "";
        message.expiry = object.expiry ?? undefined;
        return message;
    },
    fromAmino(object) {
        const message = createBaseContinuousFund();
        if (object.recipient !== undefined && object.recipient !== null) {
            message.recipient = object.recipient;
        }
        if (object.percentage !== undefined && object.percentage !== null) {
            message.percentage = object.percentage;
        }
        if (object.expiry !== undefined && object.expiry !== null) {
            message.expiry = (0, helpers_1.fromTimestamp)(timestamp_1.Timestamp.fromAmino(object.expiry));
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.recipient = message.recipient === "" ? undefined : message.recipient;
        obj.percentage = message.percentage === "" ? undefined : math_1.Decimal.fromUserInput(message.percentage, 18).atomics;
        obj.expiry = message.expiry ? timestamp_1.Timestamp.toAmino((0, helpers_1.toTimestamp)(message.expiry)) : undefined;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.ContinuousFund.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/ContinuousFund",
            value: exports.ContinuousFund.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.ContinuousFund.decode(message.value);
    },
    toProto(message) {
        return exports.ContinuousFund.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmos.protocolpool.v1.ContinuousFund",
            value: exports.ContinuousFund.encode(message).finish()
        };
    },
    registerTypeUrl() { }
};
function createBaseParams() {
    return {
        enabledDistributionDenoms: [],
        distributionFrequency: BigInt(0)
    };
}
/**
 * Params defines the parameters for the protocolpool module.
 * @name Params
 * @package cosmos.protocolpool.v1
 * @see proto type: cosmos.protocolpool.v1.Params
 */
exports.Params = {
    typeUrl: "/cosmos.protocolpool.v1.Params",
    aminoType: "cosmos-sdk/Params",
    is(o) {
        return o && (o.$typeUrl === exports.Params.typeUrl || Array.isArray(o.enabledDistributionDenoms) && (!o.enabledDistributionDenoms.length || typeof o.enabledDistributionDenoms[0] === "string") && typeof o.distributionFrequency === "bigint");
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.Params.typeUrl || Array.isArray(o.enabled_distribution_denoms) && (!o.enabled_distribution_denoms.length || typeof o.enabled_distribution_denoms[0] === "string") && typeof o.distribution_frequency === "bigint");
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        for (const v of message.enabledDistributionDenoms) {
            writer.uint32(10).string(v);
        }
        if (message.distributionFrequency !== BigInt(0)) {
            writer.uint32(16).uint64(message.distributionFrequency);
        }
        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.enabledDistributionDenoms.push(reader.string());
                    break;
                case 2:
                    message.distributionFrequency = reader.uint64();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseParams();
        message.enabledDistributionDenoms = object.enabledDistributionDenoms?.map(e => e) || [];
        message.distributionFrequency = object.distributionFrequency !== undefined && object.distributionFrequency !== null ? BigInt(object.distributionFrequency.toString()) : BigInt(0);
        return message;
    },
    fromAmino(object) {
        const message = createBaseParams();
        message.enabledDistributionDenoms = object.enabled_distribution_denoms?.map(e => e) || [];
        if (object.distribution_frequency !== undefined && object.distribution_frequency !== null) {
            message.distributionFrequency = BigInt(object.distribution_frequency);
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        if (message.enabledDistributionDenoms) {
            obj.enabled_distribution_denoms = message.enabledDistributionDenoms.map(e => e);
        }
        else {
            obj.enabled_distribution_denoms = message.enabledDistributionDenoms;
        }
        obj.distribution_frequency = message.distributionFrequency !== BigInt(0) ? message.distributionFrequency?.toString() : undefined;
        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: "/cosmos.protocolpool.v1.Params",
            value: exports.Params.encode(message).finish()
        };
    },
    registerTypeUrl() { }
};
