import * as _m0 from "protobufjs/minimal";
function createBaseValidatorPreference() {
  return {
    valOperAddress: "",
    weight: ""
  };
}
export const ValidatorPreference = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.valOperAddress !== "") {
      writer.uint32(10).string(message.valOperAddress);
    }
    if (message.weight !== "") {
      writer.uint32(18).string(message.weight);
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseValidatorPreference();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.valOperAddress = reader.string();
          break;
        case 2:
          message.weight = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$valOperAddres, _object$weight;
    const message = createBaseValidatorPreference();
    message.valOperAddress = (_object$valOperAddres = object.valOperAddress) !== null && _object$valOperAddres !== void 0 ? _object$valOperAddres : "";
    message.weight = (_object$weight = object.weight) !== null && _object$weight !== void 0 ? _object$weight : "";
    return message;
  }
};
function createBaseValidatorSetPreferences() {
  return {
    preferences: []
  };
}
export const ValidatorSetPreferences = {
  encode(message, writer = _m0.Writer.create()) {
    for (const v of message.preferences) {
      ValidatorPreference.encode(v, writer.uint32(18).fork()).ldelim();
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseValidatorSetPreferences();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 2:
          message.preferences.push(ValidatorPreference.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$preferences;
    const message = createBaseValidatorSetPreferences();
    message.preferences = ((_object$preferences = object.preferences) === null || _object$preferences === void 0 ? void 0 : _object$preferences.map(e => ValidatorPreference.fromPartial(e))) || [];
    return message;
  }
};