import { Params, BandPriceState, PriceFeedState, CoinbasePriceState, BandOracleRequest, BandIBCParams, ChainlinkPriceState, PriceRecords, ProviderState } from "./oracle";
import { Long } from "../../../helpers";
import * as _m0 from "protobufjs/minimal";
/** GenesisState defines the oracle module's genesis state. */

function createBaseGenesisState() {
  return {
    params: undefined,
    bandRelayers: [],
    bandPriceStates: [],
    priceFeedPriceStates: [],
    coinbasePriceStates: [],
    bandIbcPriceStates: [],
    bandIbcOracleRequests: [],
    bandIbcParams: undefined,
    bandIbcLatestClientId: Long.UZERO,
    calldataRecords: [],
    bandIbcLatestRequestId: Long.UZERO,
    chainlinkPriceStates: [],
    historicalPriceRecords: [],
    providerStates: []
  };
}
export const GenesisState = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.params !== undefined) {
      Params.encode(message.params, writer.uint32(10).fork()).ldelim();
    }
    for (const v of message.bandRelayers) {
      writer.uint32(18).string(v);
    }
    for (const v of message.bandPriceStates) {
      BandPriceState.encode(v, writer.uint32(26).fork()).ldelim();
    }
    for (const v of message.priceFeedPriceStates) {
      PriceFeedState.encode(v, writer.uint32(34).fork()).ldelim();
    }
    for (const v of message.coinbasePriceStates) {
      CoinbasePriceState.encode(v, writer.uint32(42).fork()).ldelim();
    }
    for (const v of message.bandIbcPriceStates) {
      BandPriceState.encode(v, writer.uint32(50).fork()).ldelim();
    }
    for (const v of message.bandIbcOracleRequests) {
      BandOracleRequest.encode(v, writer.uint32(58).fork()).ldelim();
    }
    if (message.bandIbcParams !== undefined) {
      BandIBCParams.encode(message.bandIbcParams, writer.uint32(66).fork()).ldelim();
    }
    if (!message.bandIbcLatestClientId.isZero()) {
      writer.uint32(72).uint64(message.bandIbcLatestClientId);
    }
    for (const v of message.calldataRecords) {
      CalldataRecord.encode(v, writer.uint32(82).fork()).ldelim();
    }
    if (!message.bandIbcLatestRequestId.isZero()) {
      writer.uint32(88).uint64(message.bandIbcLatestRequestId);
    }
    for (const v of message.chainlinkPriceStates) {
      ChainlinkPriceState.encode(v, writer.uint32(98).fork()).ldelim();
    }
    for (const v of message.historicalPriceRecords) {
      PriceRecords.encode(v, writer.uint32(106).fork()).ldelim();
    }
    for (const v of message.providerStates) {
      ProviderState.encode(v, writer.uint32(114).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 = createBaseGenesisState();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.params = Params.decode(reader, reader.uint32());
          break;
        case 2:
          message.bandRelayers.push(reader.string());
          break;
        case 3:
          message.bandPriceStates.push(BandPriceState.decode(reader, reader.uint32()));
          break;
        case 4:
          message.priceFeedPriceStates.push(PriceFeedState.decode(reader, reader.uint32()));
          break;
        case 5:
          message.coinbasePriceStates.push(CoinbasePriceState.decode(reader, reader.uint32()));
          break;
        case 6:
          message.bandIbcPriceStates.push(BandPriceState.decode(reader, reader.uint32()));
          break;
        case 7:
          message.bandIbcOracleRequests.push(BandOracleRequest.decode(reader, reader.uint32()));
          break;
        case 8:
          message.bandIbcParams = BandIBCParams.decode(reader, reader.uint32());
          break;
        case 9:
          message.bandIbcLatestClientId = reader.uint64();
          break;
        case 10:
          message.calldataRecords.push(CalldataRecord.decode(reader, reader.uint32()));
          break;
        case 11:
          message.bandIbcLatestRequestId = reader.uint64();
          break;
        case 12:
          message.chainlinkPriceStates.push(ChainlinkPriceState.decode(reader, reader.uint32()));
          break;
        case 13:
          message.historicalPriceRecords.push(PriceRecords.decode(reader, reader.uint32()));
          break;
        case 14:
          message.providerStates.push(ProviderState.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$bandRelayers, _object$bandPriceStat, _object$priceFeedPric, _object$coinbasePrice, _object$bandIbcPriceS, _object$bandIbcOracle, _object$calldataRecor, _object$chainlinkPric, _object$historicalPri, _object$providerState;
    const message = createBaseGenesisState();
    message.params = object.params !== undefined && object.params !== null ? Params.fromPartial(object.params) : undefined;
    message.bandRelayers = ((_object$bandRelayers = object.bandRelayers) === null || _object$bandRelayers === void 0 ? void 0 : _object$bandRelayers.map(e => e)) || [];
    message.bandPriceStates = ((_object$bandPriceStat = object.bandPriceStates) === null || _object$bandPriceStat === void 0 ? void 0 : _object$bandPriceStat.map(e => BandPriceState.fromPartial(e))) || [];
    message.priceFeedPriceStates = ((_object$priceFeedPric = object.priceFeedPriceStates) === null || _object$priceFeedPric === void 0 ? void 0 : _object$priceFeedPric.map(e => PriceFeedState.fromPartial(e))) || [];
    message.coinbasePriceStates = ((_object$coinbasePrice = object.coinbasePriceStates) === null || _object$coinbasePrice === void 0 ? void 0 : _object$coinbasePrice.map(e => CoinbasePriceState.fromPartial(e))) || [];
    message.bandIbcPriceStates = ((_object$bandIbcPriceS = object.bandIbcPriceStates) === null || _object$bandIbcPriceS === void 0 ? void 0 : _object$bandIbcPriceS.map(e => BandPriceState.fromPartial(e))) || [];
    message.bandIbcOracleRequests = ((_object$bandIbcOracle = object.bandIbcOracleRequests) === null || _object$bandIbcOracle === void 0 ? void 0 : _object$bandIbcOracle.map(e => BandOracleRequest.fromPartial(e))) || [];
    message.bandIbcParams = object.bandIbcParams !== undefined && object.bandIbcParams !== null ? BandIBCParams.fromPartial(object.bandIbcParams) : undefined;
    message.bandIbcLatestClientId = object.bandIbcLatestClientId !== undefined && object.bandIbcLatestClientId !== null ? Long.fromValue(object.bandIbcLatestClientId) : Long.UZERO;
    message.calldataRecords = ((_object$calldataRecor = object.calldataRecords) === null || _object$calldataRecor === void 0 ? void 0 : _object$calldataRecor.map(e => CalldataRecord.fromPartial(e))) || [];
    message.bandIbcLatestRequestId = object.bandIbcLatestRequestId !== undefined && object.bandIbcLatestRequestId !== null ? Long.fromValue(object.bandIbcLatestRequestId) : Long.UZERO;
    message.chainlinkPriceStates = ((_object$chainlinkPric = object.chainlinkPriceStates) === null || _object$chainlinkPric === void 0 ? void 0 : _object$chainlinkPric.map(e => ChainlinkPriceState.fromPartial(e))) || [];
    message.historicalPriceRecords = ((_object$historicalPri = object.historicalPriceRecords) === null || _object$historicalPri === void 0 ? void 0 : _object$historicalPri.map(e => PriceRecords.fromPartial(e))) || [];
    message.providerStates = ((_object$providerState = object.providerStates) === null || _object$providerState === void 0 ? void 0 : _object$providerState.map(e => ProviderState.fromPartial(e))) || [];
    return message;
  }
};
function createBaseCalldataRecord() {
  return {
    clientId: Long.UZERO,
    calldata: new Uint8Array()
  };
}
export const CalldataRecord = {
  encode(message, writer = _m0.Writer.create()) {
    if (!message.clientId.isZero()) {
      writer.uint32(8).uint64(message.clientId);
    }
    if (message.calldata.length !== 0) {
      writer.uint32(18).bytes(message.calldata);
    }
    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 = createBaseCalldataRecord();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.clientId = reader.uint64();
          break;
        case 2:
          message.calldata = reader.bytes();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$calldata;
    const message = createBaseCalldataRecord();
    message.clientId = object.clientId !== undefined && object.clientId !== null ? Long.fromValue(object.clientId) : Long.UZERO;
    message.calldata = (_object$calldata = object.calldata) !== null && _object$calldata !== void 0 ? _object$calldata : new Uint8Array();
    return message;
  }
};