import { Coin } from "../cosmos/base/v1beta1/coin";
import { seriesFromJSON } from "./pool";
import { Params } from "./params";
import { BinaryWriter } from "../binary";
import { isSet } from "../helpers";

/** this line is used by starport scaffolding # proto/tx/message */

/** this line is used by starport scaffolding # proto/tx/message */

/** this line is used by starport scaffolding # proto/tx/message */

function createBaseMsgCreateReward() {
  return {
    creator: "",
    recipient: "",
    amount: Coin.fromPartial({}),
    series: 0
  };
}
export const MsgCreateReward = {
  typeUrl: "/gitopia.gitopia.rewards.MsgCreateReward",
  encode(message, writer = BinaryWriter.create()) {
    if (message.creator !== "") {
      writer.uint32(10).string(message.creator);
    }
    if (message.recipient !== "") {
      writer.uint32(18).string(message.recipient);
    }
    if (message.amount !== undefined) {
      Coin.encode(message.amount, writer.uint32(26).fork()).ldelim();
    }
    if (message.series !== 0) {
      writer.uint32(32).int32(message.series);
    }
    return writer;
  },
  fromJSON(object) {
    return {
      creator: isSet(object.creator) ? String(object.creator) : "",
      recipient: isSet(object.recipient) ? String(object.recipient) : "",
      amount: isSet(object.amount) ? Coin.fromJSON(object.amount) : undefined,
      series: isSet(object.series) ? seriesFromJSON(object.series) : -1
    };
  },
  fromPartial(object) {
    var _object$creator, _object$recipient, _object$series;
    const message = createBaseMsgCreateReward();
    message.creator = (_object$creator = object.creator) !== null && _object$creator !== void 0 ? _object$creator : "";
    message.recipient = (_object$recipient = object.recipient) !== null && _object$recipient !== void 0 ? _object$recipient : "";
    message.amount = object.amount !== undefined && object.amount !== null ? Coin.fromPartial(object.amount) : undefined;
    message.series = (_object$series = object.series) !== null && _object$series !== void 0 ? _object$series : 0;
    return message;
  },
  fromAmino(object) {
    const message = createBaseMsgCreateReward();
    if (object.creator !== undefined && object.creator !== null) {
      message.creator = object.creator;
    }
    if (object.recipient !== undefined && object.recipient !== null) {
      message.recipient = object.recipient;
    }
    if (object.amount !== undefined && object.amount !== null) {
      message.amount = Coin.fromAmino(object.amount);
    }
    if (object.series !== undefined && object.series !== null) {
      message.series = object.series;
    }
    return message;
  },
  toAmino(message) {
    const obj = {};
    obj.creator = message.creator === "" ? undefined : message.creator;
    obj.recipient = message.recipient === "" ? undefined : message.recipient;
    obj.amount = message.amount ? Coin.toAmino(message.amount) : undefined;
    obj.series = message.series === 0 ? undefined : message.series;
    return obj;
  },
  fromAminoMsg(object) {
    return MsgCreateReward.fromAmino(object.value);
  },
  fromProtoMsg(message) {
    return MsgCreateReward.decode(message.value);
  },
  toProto(message) {
    return MsgCreateReward.encode(message).finish();
  },
  toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.rewards.MsgCreateReward",
      value: MsgCreateReward.encode(message).finish()
    };
  }
};
function createBaseMsgCreateRewardResponse() {
  return {
    amount: Coin.fromPartial({})
  };
}
export const MsgCreateRewardResponse = {
  typeUrl: "/gitopia.gitopia.rewards.MsgCreateRewardResponse",
  encode(message, writer = BinaryWriter.create()) {
    if (message.amount !== undefined) {
      Coin.encode(message.amount, writer.uint32(10).fork()).ldelim();
    }
    return writer;
  },
  fromJSON(object) {
    return {
      amount: isSet(object.amount) ? Coin.fromJSON(object.amount) : undefined
    };
  },
  fromPartial(object) {
    const message = createBaseMsgCreateRewardResponse();
    message.amount = object.amount !== undefined && object.amount !== null ? Coin.fromPartial(object.amount) : undefined;
    return message;
  },
  fromAmino(object) {
    const message = createBaseMsgCreateRewardResponse();
    if (object.amount !== undefined && object.amount !== null) {
      message.amount = Coin.fromAmino(object.amount);
    }
    return message;
  },
  toAmino(message) {
    const obj = {};
    obj.amount = message.amount ? Coin.toAmino(message.amount) : undefined;
    return obj;
  },
  fromAminoMsg(object) {
    return MsgCreateRewardResponse.fromAmino(object.value);
  },
  fromProtoMsg(message) {
    return MsgCreateRewardResponse.decode(message.value);
  },
  toProto(message) {
    return MsgCreateRewardResponse.encode(message).finish();
  },
  toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.rewards.MsgCreateRewardResponse",
      value: MsgCreateRewardResponse.encode(message).finish()
    };
  }
};
function createBaseMsgClaim() {
  return {
    creator: ""
  };
}
export const MsgClaim = {
  typeUrl: "/gitopia.gitopia.rewards.MsgClaim",
  encode(message, writer = BinaryWriter.create()) {
    if (message.creator !== "") {
      writer.uint32(10).string(message.creator);
    }
    return writer;
  },
  fromJSON(object) {
    return {
      creator: isSet(object.creator) ? String(object.creator) : ""
    };
  },
  fromPartial(object) {
    var _object$creator2;
    const message = createBaseMsgClaim();
    message.creator = (_object$creator2 = object.creator) !== null && _object$creator2 !== void 0 ? _object$creator2 : "";
    return message;
  },
  fromAmino(object) {
    const message = createBaseMsgClaim();
    if (object.creator !== undefined && object.creator !== null) {
      message.creator = object.creator;
    }
    return message;
  },
  toAmino(message) {
    const obj = {};
    obj.creator = message.creator === "" ? undefined : message.creator;
    return obj;
  },
  fromAminoMsg(object) {
    return MsgClaim.fromAmino(object.value);
  },
  fromProtoMsg(message) {
    return MsgClaim.decode(message.value);
  },
  toProto(message) {
    return MsgClaim.encode(message).finish();
  },
  toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.rewards.MsgClaim",
      value: MsgClaim.encode(message).finish()
    };
  }
};
function createBaseClaimResponseReward() {
  return {
    series: 0,
    amount: Coin.fromPartial({})
  };
}
export const ClaimResponseReward = {
  typeUrl: "/gitopia.gitopia.rewards.ClaimResponseReward",
  encode(message, writer = BinaryWriter.create()) {
    if (message.series !== 0) {
      writer.uint32(8).int32(message.series);
    }
    if (message.amount !== undefined) {
      Coin.encode(message.amount, writer.uint32(18).fork()).ldelim();
    }
    return writer;
  },
  fromJSON(object) {
    return {
      series: isSet(object.series) ? seriesFromJSON(object.series) : -1,
      amount: isSet(object.amount) ? Coin.fromJSON(object.amount) : undefined
    };
  },
  fromPartial(object) {
    var _object$series2;
    const message = createBaseClaimResponseReward();
    message.series = (_object$series2 = object.series) !== null && _object$series2 !== void 0 ? _object$series2 : 0;
    message.amount = object.amount !== undefined && object.amount !== null ? Coin.fromPartial(object.amount) : undefined;
    return message;
  },
  fromAmino(object) {
    const message = createBaseClaimResponseReward();
    if (object.series !== undefined && object.series !== null) {
      message.series = object.series;
    }
    if (object.amount !== undefined && object.amount !== null) {
      message.amount = Coin.fromAmino(object.amount);
    }
    return message;
  },
  toAmino(message) {
    const obj = {};
    obj.series = message.series === 0 ? undefined : message.series;
    obj.amount = message.amount ? Coin.toAmino(message.amount) : undefined;
    return obj;
  },
  fromAminoMsg(object) {
    return ClaimResponseReward.fromAmino(object.value);
  },
  fromProtoMsg(message) {
    return ClaimResponseReward.decode(message.value);
  },
  toProto(message) {
    return ClaimResponseReward.encode(message).finish();
  },
  toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.rewards.ClaimResponseReward",
      value: ClaimResponseReward.encode(message).finish()
    };
  }
};
function createBaseMsgClaimResponse() {
  return {
    claimedRewards: [],
    expiredRewards: [],
    allClaimedRewards: []
  };
}
export const MsgClaimResponse = {
  typeUrl: "/gitopia.gitopia.rewards.MsgClaimResponse",
  encode(message, writer = BinaryWriter.create()) {
    for (const v of message.claimedRewards) {
      ClaimResponseReward.encode(v, writer.uint32(10).fork()).ldelim();
    }
    for (const v of message.expiredRewards) {
      ClaimResponseReward.encode(v, writer.uint32(18).fork()).ldelim();
    }
    for (const v of message.allClaimedRewards) {
      ClaimResponseReward.encode(v, writer.uint32(26).fork()).ldelim();
    }
    return writer;
  },
  fromJSON(object) {
    return {
      claimedRewards: Array.isArray(object === null || object === void 0 ? void 0 : object.claimedRewards) ? object.claimedRewards.map(e => ClaimResponseReward.fromJSON(e)) : [],
      expiredRewards: Array.isArray(object === null || object === void 0 ? void 0 : object.expiredRewards) ? object.expiredRewards.map(e => ClaimResponseReward.fromJSON(e)) : [],
      allClaimedRewards: Array.isArray(object === null || object === void 0 ? void 0 : object.allClaimedRewards) ? object.allClaimedRewards.map(e => ClaimResponseReward.fromJSON(e)) : []
    };
  },
  fromPartial(object) {
    var _object$claimedReward, _object$expiredReward, _object$allClaimedRew;
    const message = createBaseMsgClaimResponse();
    message.claimedRewards = ((_object$claimedReward = object.claimedRewards) === null || _object$claimedReward === void 0 ? void 0 : _object$claimedReward.map(e => ClaimResponseReward.fromPartial(e))) || [];
    message.expiredRewards = ((_object$expiredReward = object.expiredRewards) === null || _object$expiredReward === void 0 ? void 0 : _object$expiredReward.map(e => ClaimResponseReward.fromPartial(e))) || [];
    message.allClaimedRewards = ((_object$allClaimedRew = object.allClaimedRewards) === null || _object$allClaimedRew === void 0 ? void 0 : _object$allClaimedRew.map(e => ClaimResponseReward.fromPartial(e))) || [];
    return message;
  },
  fromAmino(object) {
    var _object$claimed_rewar, _object$expired_rewar, _object$all_claimed_r;
    const message = createBaseMsgClaimResponse();
    message.claimedRewards = ((_object$claimed_rewar = object.claimed_rewards) === null || _object$claimed_rewar === void 0 ? void 0 : _object$claimed_rewar.map(e => ClaimResponseReward.fromAmino(e))) || [];
    message.expiredRewards = ((_object$expired_rewar = object.expired_rewards) === null || _object$expired_rewar === void 0 ? void 0 : _object$expired_rewar.map(e => ClaimResponseReward.fromAmino(e))) || [];
    message.allClaimedRewards = ((_object$all_claimed_r = object.all_claimed_rewards) === null || _object$all_claimed_r === void 0 ? void 0 : _object$all_claimed_r.map(e => ClaimResponseReward.fromAmino(e))) || [];
    return message;
  },
  toAmino(message) {
    const obj = {};
    if (message.claimedRewards) {
      obj.claimed_rewards = message.claimedRewards.map(e => e ? ClaimResponseReward.toAmino(e) : undefined);
    } else {
      obj.claimed_rewards = message.claimedRewards;
    }
    if (message.expiredRewards) {
      obj.expired_rewards = message.expiredRewards.map(e => e ? ClaimResponseReward.toAmino(e) : undefined);
    } else {
      obj.expired_rewards = message.expiredRewards;
    }
    if (message.allClaimedRewards) {
      obj.all_claimed_rewards = message.allClaimedRewards.map(e => e ? ClaimResponseReward.toAmino(e) : undefined);
    } else {
      obj.all_claimed_rewards = message.allClaimedRewards;
    }
    return obj;
  },
  fromAminoMsg(object) {
    return MsgClaimResponse.fromAmino(object.value);
  },
  fromProtoMsg(message) {
    return MsgClaimResponse.decode(message.value);
  },
  toProto(message) {
    return MsgClaimResponse.encode(message).finish();
  },
  toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.rewards.MsgClaimResponse",
      value: MsgClaimResponse.encode(message).finish()
    };
  }
};
function createBaseMsgUpdateParams() {
  return {
    authority: "",
    params: Params.fromPartial({})
  };
}
export const MsgUpdateParams = {
  typeUrl: "/gitopia.gitopia.rewards.MsgUpdateParams",
  encode(message, writer = BinaryWriter.create()) {
    if (message.authority !== "") {
      writer.uint32(10).string(message.authority);
    }
    if (message.params !== undefined) {
      Params.encode(message.params, writer.uint32(18).fork()).ldelim();
    }
    return writer;
  },
  fromJSON(object) {
    return {
      authority: isSet(object.authority) ? String(object.authority) : "",
      params: isSet(object.params) ? Params.fromJSON(object.params) : undefined
    };
  },
  fromPartial(object) {
    var _object$authority;
    const message = createBaseMsgUpdateParams();
    message.authority = (_object$authority = object.authority) !== null && _object$authority !== void 0 ? _object$authority : "";
    message.params = object.params !== undefined && object.params !== null ? Params.fromPartial(object.params) : undefined;
    return message;
  },
  fromAmino(object) {
    const message = createBaseMsgUpdateParams();
    if (object.authority !== undefined && object.authority !== null) {
      message.authority = object.authority;
    }
    if (object.params !== undefined && object.params !== null) {
      message.params = Params.fromAmino(object.params);
    }
    return message;
  },
  toAmino(message) {
    const obj = {};
    obj.authority = message.authority === "" ? undefined : message.authority;
    obj.params = message.params ? Params.toAmino(message.params) : undefined;
    return obj;
  },
  fromAminoMsg(object) {
    return MsgUpdateParams.fromAmino(object.value);
  },
  fromProtoMsg(message) {
    return MsgUpdateParams.decode(message.value);
  },
  toProto(message) {
    return MsgUpdateParams.encode(message).finish();
  },
  toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.rewards.MsgUpdateParams",
      value: MsgUpdateParams.encode(message).finish()
    };
  }
};
function createBaseMsgUpdateParamsResponse() {
  return {};
}
export const MsgUpdateParamsResponse = {
  typeUrl: "/gitopia.gitopia.rewards.MsgUpdateParamsResponse",
  encode(_, writer = BinaryWriter.create()) {
    return writer;
  },
  fromJSON(_) {
    return {};
  },
  fromPartial(_) {
    const message = createBaseMsgUpdateParamsResponse();
    return message;
  },
  fromAmino(_) {
    const message = createBaseMsgUpdateParamsResponse();
    return message;
  },
  toAmino(_) {
    const obj = {};
    return obj;
  },
  fromAminoMsg(object) {
    return MsgUpdateParamsResponse.fromAmino(object.value);
  },
  fromProtoMsg(message) {
    return MsgUpdateParamsResponse.decode(message.value);
  },
  toProto(message) {
    return MsgUpdateParamsResponse.encode(message).finish();
  },
  toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.rewards.MsgUpdateParamsResponse",
      value: MsgUpdateParamsResponse.encode(message).finish()
    };
  }
};