import { FeedConfig, Report } from "./ocr";
import { Coin } from "../../../cosmos/base/v1beta1/coin";
import * as _m0 from "protobufjs/minimal";
import { Long } from "../../../helpers";
function createBaseMsgCreateFeed() {
  return {
    sender: "",
    config: undefined
  };
}
export const MsgCreateFeed = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.sender !== "") {
      writer.uint32(10).string(message.sender);
    }
    if (message.config !== undefined) {
      FeedConfig.encode(message.config, 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 = createBaseMsgCreateFeed();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.sender = reader.string();
          break;
        case 2:
          message.config = FeedConfig.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$sender;
    const message = createBaseMsgCreateFeed();
    message.sender = (_object$sender = object.sender) !== null && _object$sender !== void 0 ? _object$sender : "";
    message.config = object.config !== undefined && object.config !== null ? FeedConfig.fromPartial(object.config) : undefined;
    return message;
  }
};
function createBaseMsgCreateFeedResponse() {
  return {};
}
export const MsgCreateFeedResponse = {
  encode(_, writer = _m0.Writer.create()) {
    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 = createBaseMsgCreateFeedResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(_) {
    const message = createBaseMsgCreateFeedResponse();
    return message;
  }
};
function createBaseMsgUpdateFeed() {
  return {
    sender: "",
    feedId: "",
    signers: [],
    transmitters: [],
    linkPerObservation: undefined,
    linkPerTransmission: undefined,
    linkDenom: "",
    feedAdmin: "",
    billingAdmin: ""
  };
}
export const MsgUpdateFeed = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.sender !== "") {
      writer.uint32(10).string(message.sender);
    }
    if (message.feedId !== "") {
      writer.uint32(18).string(message.feedId);
    }
    for (const v of message.signers) {
      writer.uint32(26).string(v);
    }
    for (const v of message.transmitters) {
      writer.uint32(34).string(v);
    }
    if (message.linkPerObservation !== undefined) {
      writer.uint32(42).string(message.linkPerObservation);
    }
    if (message.linkPerTransmission !== undefined) {
      writer.uint32(50).string(message.linkPerTransmission);
    }
    if (message.linkDenom !== "") {
      writer.uint32(58).string(message.linkDenom);
    }
    if (message.feedAdmin !== "") {
      writer.uint32(66).string(message.feedAdmin);
    }
    if (message.billingAdmin !== "") {
      writer.uint32(74).string(message.billingAdmin);
    }
    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 = createBaseMsgUpdateFeed();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.sender = reader.string();
          break;
        case 2:
          message.feedId = reader.string();
          break;
        case 3:
          message.signers.push(reader.string());
          break;
        case 4:
          message.transmitters.push(reader.string());
          break;
        case 5:
          message.linkPerObservation = reader.string();
          break;
        case 6:
          message.linkPerTransmission = reader.string();
          break;
        case 7:
          message.linkDenom = reader.string();
          break;
        case 8:
          message.feedAdmin = reader.string();
          break;
        case 9:
          message.billingAdmin = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$sender2, _object$feedId, _object$signers, _object$transmitters, _object$linkPerObserv, _object$linkPerTransm, _object$linkDenom, _object$feedAdmin, _object$billingAdmin;
    const message = createBaseMsgUpdateFeed();
    message.sender = (_object$sender2 = object.sender) !== null && _object$sender2 !== void 0 ? _object$sender2 : "";
    message.feedId = (_object$feedId = object.feedId) !== null && _object$feedId !== void 0 ? _object$feedId : "";
    message.signers = ((_object$signers = object.signers) === null || _object$signers === void 0 ? void 0 : _object$signers.map(e => e)) || [];
    message.transmitters = ((_object$transmitters = object.transmitters) === null || _object$transmitters === void 0 ? void 0 : _object$transmitters.map(e => e)) || [];
    message.linkPerObservation = (_object$linkPerObserv = object.linkPerObservation) !== null && _object$linkPerObserv !== void 0 ? _object$linkPerObserv : undefined;
    message.linkPerTransmission = (_object$linkPerTransm = object.linkPerTransmission) !== null && _object$linkPerTransm !== void 0 ? _object$linkPerTransm : undefined;
    message.linkDenom = (_object$linkDenom = object.linkDenom) !== null && _object$linkDenom !== void 0 ? _object$linkDenom : "";
    message.feedAdmin = (_object$feedAdmin = object.feedAdmin) !== null && _object$feedAdmin !== void 0 ? _object$feedAdmin : "";
    message.billingAdmin = (_object$billingAdmin = object.billingAdmin) !== null && _object$billingAdmin !== void 0 ? _object$billingAdmin : "";
    return message;
  }
};
function createBaseMsgUpdateFeedResponse() {
  return {};
}
export const MsgUpdateFeedResponse = {
  encode(_, writer = _m0.Writer.create()) {
    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 = createBaseMsgUpdateFeedResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(_) {
    const message = createBaseMsgUpdateFeedResponse();
    return message;
  }
};
function createBaseMsgTransmit() {
  return {
    transmitter: "",
    configDigest: new Uint8Array(),
    feedId: "",
    epoch: Long.UZERO,
    round: Long.UZERO,
    extraHash: new Uint8Array(),
    report: undefined,
    signatures: []
  };
}
export const MsgTransmit = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.transmitter !== "") {
      writer.uint32(10).string(message.transmitter);
    }
    if (message.configDigest.length !== 0) {
      writer.uint32(18).bytes(message.configDigest);
    }
    if (message.feedId !== "") {
      writer.uint32(26).string(message.feedId);
    }
    if (!message.epoch.isZero()) {
      writer.uint32(32).uint64(message.epoch);
    }
    if (!message.round.isZero()) {
      writer.uint32(40).uint64(message.round);
    }
    if (message.extraHash.length !== 0) {
      writer.uint32(50).bytes(message.extraHash);
    }
    if (message.report !== undefined) {
      Report.encode(message.report, writer.uint32(58).fork()).ldelim();
    }
    for (const v of message.signatures) {
      writer.uint32(66).bytes(v);
    }
    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 = createBaseMsgTransmit();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.transmitter = reader.string();
          break;
        case 2:
          message.configDigest = reader.bytes();
          break;
        case 3:
          message.feedId = reader.string();
          break;
        case 4:
          message.epoch = reader.uint64();
          break;
        case 5:
          message.round = reader.uint64();
          break;
        case 6:
          message.extraHash = reader.bytes();
          break;
        case 7:
          message.report = Report.decode(reader, reader.uint32());
          break;
        case 8:
          message.signatures.push(reader.bytes());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$transmitter, _object$configDigest, _object$feedId2, _object$extraHash, _object$signatures;
    const message = createBaseMsgTransmit();
    message.transmitter = (_object$transmitter = object.transmitter) !== null && _object$transmitter !== void 0 ? _object$transmitter : "";
    message.configDigest = (_object$configDigest = object.configDigest) !== null && _object$configDigest !== void 0 ? _object$configDigest : new Uint8Array();
    message.feedId = (_object$feedId2 = object.feedId) !== null && _object$feedId2 !== void 0 ? _object$feedId2 : "";
    message.epoch = object.epoch !== undefined && object.epoch !== null ? Long.fromValue(object.epoch) : Long.UZERO;
    message.round = object.round !== undefined && object.round !== null ? Long.fromValue(object.round) : Long.UZERO;
    message.extraHash = (_object$extraHash = object.extraHash) !== null && _object$extraHash !== void 0 ? _object$extraHash : new Uint8Array();
    message.report = object.report !== undefined && object.report !== null ? Report.fromPartial(object.report) : undefined;
    message.signatures = ((_object$signatures = object.signatures) === null || _object$signatures === void 0 ? void 0 : _object$signatures.map(e => e)) || [];
    return message;
  }
};
function createBaseMsgTransmitResponse() {
  return {};
}
export const MsgTransmitResponse = {
  encode(_, writer = _m0.Writer.create()) {
    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 = createBaseMsgTransmitResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(_) {
    const message = createBaseMsgTransmitResponse();
    return message;
  }
};
function createBaseMsgFundFeedRewardPool() {
  return {
    sender: "",
    feedId: "",
    amount: undefined
  };
}
export const MsgFundFeedRewardPool = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.sender !== "") {
      writer.uint32(10).string(message.sender);
    }
    if (message.feedId !== "") {
      writer.uint32(18).string(message.feedId);
    }
    if (message.amount !== undefined) {
      Coin.encode(message.amount, writer.uint32(26).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 = createBaseMsgFundFeedRewardPool();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.sender = reader.string();
          break;
        case 2:
          message.feedId = reader.string();
          break;
        case 3:
          message.amount = Coin.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$sender3, _object$feedId3;
    const message = createBaseMsgFundFeedRewardPool();
    message.sender = (_object$sender3 = object.sender) !== null && _object$sender3 !== void 0 ? _object$sender3 : "";
    message.feedId = (_object$feedId3 = object.feedId) !== null && _object$feedId3 !== void 0 ? _object$feedId3 : "";
    message.amount = object.amount !== undefined && object.amount !== null ? Coin.fromPartial(object.amount) : undefined;
    return message;
  }
};
function createBaseMsgFundFeedRewardPoolResponse() {
  return {};
}
export const MsgFundFeedRewardPoolResponse = {
  encode(_, writer = _m0.Writer.create()) {
    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 = createBaseMsgFundFeedRewardPoolResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(_) {
    const message = createBaseMsgFundFeedRewardPoolResponse();
    return message;
  }
};
function createBaseMsgWithdrawFeedRewardPool() {
  return {
    sender: "",
    feedId: "",
    amount: undefined
  };
}
export const MsgWithdrawFeedRewardPool = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.sender !== "") {
      writer.uint32(10).string(message.sender);
    }
    if (message.feedId !== "") {
      writer.uint32(18).string(message.feedId);
    }
    if (message.amount !== undefined) {
      Coin.encode(message.amount, writer.uint32(26).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 = createBaseMsgWithdrawFeedRewardPool();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.sender = reader.string();
          break;
        case 2:
          message.feedId = reader.string();
          break;
        case 3:
          message.amount = Coin.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$sender4, _object$feedId4;
    const message = createBaseMsgWithdrawFeedRewardPool();
    message.sender = (_object$sender4 = object.sender) !== null && _object$sender4 !== void 0 ? _object$sender4 : "";
    message.feedId = (_object$feedId4 = object.feedId) !== null && _object$feedId4 !== void 0 ? _object$feedId4 : "";
    message.amount = object.amount !== undefined && object.amount !== null ? Coin.fromPartial(object.amount) : undefined;
    return message;
  }
};
function createBaseMsgWithdrawFeedRewardPoolResponse() {
  return {};
}
export const MsgWithdrawFeedRewardPoolResponse = {
  encode(_, writer = _m0.Writer.create()) {
    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 = createBaseMsgWithdrawFeedRewardPoolResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(_) {
    const message = createBaseMsgWithdrawFeedRewardPoolResponse();
    return message;
  }
};
function createBaseMsgSetPayees() {
  return {
    sender: "",
    feedId: "",
    transmitters: [],
    payees: []
  };
}
export const MsgSetPayees = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.sender !== "") {
      writer.uint32(10).string(message.sender);
    }
    if (message.feedId !== "") {
      writer.uint32(18).string(message.feedId);
    }
    for (const v of message.transmitters) {
      writer.uint32(26).string(v);
    }
    for (const v of message.payees) {
      writer.uint32(34).string(v);
    }
    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 = createBaseMsgSetPayees();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.sender = reader.string();
          break;
        case 2:
          message.feedId = reader.string();
          break;
        case 3:
          message.transmitters.push(reader.string());
          break;
        case 4:
          message.payees.push(reader.string());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$sender5, _object$feedId5, _object$transmitters2, _object$payees;
    const message = createBaseMsgSetPayees();
    message.sender = (_object$sender5 = object.sender) !== null && _object$sender5 !== void 0 ? _object$sender5 : "";
    message.feedId = (_object$feedId5 = object.feedId) !== null && _object$feedId5 !== void 0 ? _object$feedId5 : "";
    message.transmitters = ((_object$transmitters2 = object.transmitters) === null || _object$transmitters2 === void 0 ? void 0 : _object$transmitters2.map(e => e)) || [];
    message.payees = ((_object$payees = object.payees) === null || _object$payees === void 0 ? void 0 : _object$payees.map(e => e)) || [];
    return message;
  }
};
function createBaseMsgSetPayeesResponse() {
  return {};
}
export const MsgSetPayeesResponse = {
  encode(_, writer = _m0.Writer.create()) {
    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 = createBaseMsgSetPayeesResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(_) {
    const message = createBaseMsgSetPayeesResponse();
    return message;
  }
};
function createBaseMsgTransferPayeeship() {
  return {
    sender: "",
    transmitter: "",
    feedId: "",
    proposed: ""
  };
}
export const MsgTransferPayeeship = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.sender !== "") {
      writer.uint32(10).string(message.sender);
    }
    if (message.transmitter !== "") {
      writer.uint32(18).string(message.transmitter);
    }
    if (message.feedId !== "") {
      writer.uint32(26).string(message.feedId);
    }
    if (message.proposed !== "") {
      writer.uint32(34).string(message.proposed);
    }
    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 = createBaseMsgTransferPayeeship();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.sender = reader.string();
          break;
        case 2:
          message.transmitter = reader.string();
          break;
        case 3:
          message.feedId = reader.string();
          break;
        case 4:
          message.proposed = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$sender6, _object$transmitter2, _object$feedId6, _object$proposed;
    const message = createBaseMsgTransferPayeeship();
    message.sender = (_object$sender6 = object.sender) !== null && _object$sender6 !== void 0 ? _object$sender6 : "";
    message.transmitter = (_object$transmitter2 = object.transmitter) !== null && _object$transmitter2 !== void 0 ? _object$transmitter2 : "";
    message.feedId = (_object$feedId6 = object.feedId) !== null && _object$feedId6 !== void 0 ? _object$feedId6 : "";
    message.proposed = (_object$proposed = object.proposed) !== null && _object$proposed !== void 0 ? _object$proposed : "";
    return message;
  }
};
function createBaseMsgTransferPayeeshipResponse() {
  return {};
}
export const MsgTransferPayeeshipResponse = {
  encode(_, writer = _m0.Writer.create()) {
    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 = createBaseMsgTransferPayeeshipResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(_) {
    const message = createBaseMsgTransferPayeeshipResponse();
    return message;
  }
};
function createBaseMsgAcceptPayeeship() {
  return {
    payee: "",
    transmitter: "",
    feedId: ""
  };
}
export const MsgAcceptPayeeship = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.payee !== "") {
      writer.uint32(10).string(message.payee);
    }
    if (message.transmitter !== "") {
      writer.uint32(18).string(message.transmitter);
    }
    if (message.feedId !== "") {
      writer.uint32(26).string(message.feedId);
    }
    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 = createBaseMsgAcceptPayeeship();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.payee = reader.string();
          break;
        case 2:
          message.transmitter = reader.string();
          break;
        case 3:
          message.feedId = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$payee, _object$transmitter3, _object$feedId7;
    const message = createBaseMsgAcceptPayeeship();
    message.payee = (_object$payee = object.payee) !== null && _object$payee !== void 0 ? _object$payee : "";
    message.transmitter = (_object$transmitter3 = object.transmitter) !== null && _object$transmitter3 !== void 0 ? _object$transmitter3 : "";
    message.feedId = (_object$feedId7 = object.feedId) !== null && _object$feedId7 !== void 0 ? _object$feedId7 : "";
    return message;
  }
};
function createBaseMsgAcceptPayeeshipResponse() {
  return {};
}
export const MsgAcceptPayeeshipResponse = {
  encode(_, writer = _m0.Writer.create()) {
    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 = createBaseMsgAcceptPayeeshipResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(_) {
    const message = createBaseMsgAcceptPayeeshipResponse();
    return message;
  }
};