import { RewardPool } from "./pool";
import { BinaryWriter } from "../binary";
import { isSet } from "../helpers";
/** Params defines the parameters for the module. */

/** Params defines the parameters for the module. */

/** Params defines the parameters for the module. */

function createBaseParams() {
  return {
    evaluatorAddress: "",
    rewardSeries: []
  };
}
export const Params = {
  typeUrl: "/gitopia.gitopia.rewards.Params",
  encode(message, writer = BinaryWriter.create()) {
    if (message.evaluatorAddress !== "") {
      writer.uint32(10).string(message.evaluatorAddress);
    }
    for (const v of message.rewardSeries) {
      RewardPool.encode(v, writer.uint32(18).fork()).ldelim();
    }
    return writer;
  },
  fromJSON(object) {
    return {
      evaluatorAddress: isSet(object.evaluatorAddress) ? String(object.evaluatorAddress) : "",
      rewardSeries: Array.isArray(object === null || object === void 0 ? void 0 : object.rewardSeries) ? object.rewardSeries.map(e => RewardPool.fromJSON(e)) : []
    };
  },
  fromPartial(object) {
    var _object$evaluatorAddr, _object$rewardSeries;
    const message = createBaseParams();
    message.evaluatorAddress = (_object$evaluatorAddr = object.evaluatorAddress) !== null && _object$evaluatorAddr !== void 0 ? _object$evaluatorAddr : "";
    message.rewardSeries = ((_object$rewardSeries = object.rewardSeries) === null || _object$rewardSeries === void 0 ? void 0 : _object$rewardSeries.map(e => RewardPool.fromPartial(e))) || [];
    return message;
  },
  fromAmino(object) {
    var _object$reward_series;
    const message = createBaseParams();
    if (object.evaluator_address !== undefined && object.evaluator_address !== null) {
      message.evaluatorAddress = object.evaluator_address;
    }
    message.rewardSeries = ((_object$reward_series = object.reward_series) === null || _object$reward_series === void 0 ? void 0 : _object$reward_series.map(e => RewardPool.fromAmino(e))) || [];
    return message;
  },
  toAmino(message) {
    const obj = {};
    obj.evaluator_address = message.evaluatorAddress === "" ? undefined : message.evaluatorAddress;
    if (message.rewardSeries) {
      obj.reward_series = message.rewardSeries.map(e => e ? RewardPool.toAmino(e) : undefined);
    } else {
      obj.reward_series = message.rewardSeries;
    }
    return obj;
  },
  fromAminoMsg(object) {
    return Params.fromAmino(object.value);
  },
  fromProtoMsg(message) {
    return Params.decode(message.value);
  },
  toProto(message) {
    return Params.encode(message).finish();
  },
  toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.rewards.Params",
      value: Params.encode(message).finish()
    };
  }
};