import { Coin } from "../../../cosmos/base/v1beta1/coin";
import * as _m0 from "protobufjs/minimal";
import { Long } from "../../../helpers";
export let OracleType;
(function (OracleType) {
  OracleType[OracleType["Unspecified"] = 0] = "Unspecified";
  OracleType[OracleType["Band"] = 1] = "Band";
  OracleType[OracleType["PriceFeed"] = 2] = "PriceFeed";
  OracleType[OracleType["Coinbase"] = 3] = "Coinbase";
  OracleType[OracleType["Chainlink"] = 4] = "Chainlink";
  OracleType[OracleType["Razor"] = 5] = "Razor";
  OracleType[OracleType["Dia"] = 6] = "Dia";
  OracleType[OracleType["API3"] = 7] = "API3";
  OracleType[OracleType["Uma"] = 8] = "Uma";
  OracleType[OracleType["Pyth"] = 9] = "Pyth";
  OracleType[OracleType["BandIBC"] = 10] = "BandIBC";
  OracleType[OracleType["Provider"] = 11] = "Provider";
  OracleType[OracleType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(OracleType || (OracleType = {}));
export const OracleTypeSDKType = OracleType;
export function oracleTypeFromJSON(object) {
  switch (object) {
    case 0:
    case "Unspecified":
      return OracleType.Unspecified;
    case 1:
    case "Band":
      return OracleType.Band;
    case 2:
    case "PriceFeed":
      return OracleType.PriceFeed;
    case 3:
    case "Coinbase":
      return OracleType.Coinbase;
    case 4:
    case "Chainlink":
      return OracleType.Chainlink;
    case 5:
    case "Razor":
      return OracleType.Razor;
    case 6:
    case "Dia":
      return OracleType.Dia;
    case 7:
    case "API3":
      return OracleType.API3;
    case 8:
    case "Uma":
      return OracleType.Uma;
    case 9:
    case "Pyth":
      return OracleType.Pyth;
    case 10:
    case "BandIBC":
      return OracleType.BandIBC;
    case 11:
    case "Provider":
      return OracleType.Provider;
    case -1:
    case "UNRECOGNIZED":
    default:
      return OracleType.UNRECOGNIZED;
  }
}
export function oracleTypeToJSON(object) {
  switch (object) {
    case OracleType.Unspecified:
      return "Unspecified";
    case OracleType.Band:
      return "Band";
    case OracleType.PriceFeed:
      return "PriceFeed";
    case OracleType.Coinbase:
      return "Coinbase";
    case OracleType.Chainlink:
      return "Chainlink";
    case OracleType.Razor:
      return "Razor";
    case OracleType.Dia:
      return "Dia";
    case OracleType.API3:
      return "API3";
    case OracleType.Uma:
      return "Uma";
    case OracleType.Pyth:
      return "Pyth";
    case OracleType.BandIBC:
      return "BandIBC";
    case OracleType.Provider:
      return "Provider";
    case OracleType.UNRECOGNIZED:
    default:
      return "UNRECOGNIZED";
  }
}
function createBaseParams() {
  return {};
}
export const Params = {
  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 = createBaseParams();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(_) {
    const message = createBaseParams();
    return message;
  }
};
function createBaseOracleInfo() {
  return {
    symbol: "",
    oracleType: 0,
    scaleFactor: 0
  };
}
export const OracleInfo = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.symbol !== "") {
      writer.uint32(10).string(message.symbol);
    }
    if (message.oracleType !== 0) {
      writer.uint32(16).int32(message.oracleType);
    }
    if (message.scaleFactor !== 0) {
      writer.uint32(24).uint32(message.scaleFactor);
    }
    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 = createBaseOracleInfo();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.symbol = reader.string();
          break;
        case 2:
          message.oracleType = reader.int32();
          break;
        case 3:
          message.scaleFactor = reader.uint32();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$symbol, _object$oracleType, _object$scaleFactor;
    const message = createBaseOracleInfo();
    message.symbol = (_object$symbol = object.symbol) !== null && _object$symbol !== void 0 ? _object$symbol : "";
    message.oracleType = (_object$oracleType = object.oracleType) !== null && _object$oracleType !== void 0 ? _object$oracleType : 0;
    message.scaleFactor = (_object$scaleFactor = object.scaleFactor) !== null && _object$scaleFactor !== void 0 ? _object$scaleFactor : 0;
    return message;
  }
};
function createBaseChainlinkPriceState() {
  return {
    feedId: "",
    answer: "",
    timestamp: Long.UZERO,
    priceState: undefined
  };
}
export const ChainlinkPriceState = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.feedId !== "") {
      writer.uint32(10).string(message.feedId);
    }
    if (message.answer !== "") {
      writer.uint32(18).string(message.answer);
    }
    if (!message.timestamp.isZero()) {
      writer.uint32(24).uint64(message.timestamp);
    }
    if (message.priceState !== undefined) {
      PriceState.encode(message.priceState, writer.uint32(34).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 = createBaseChainlinkPriceState();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.feedId = reader.string();
          break;
        case 2:
          message.answer = reader.string();
          break;
        case 3:
          message.timestamp = reader.uint64();
          break;
        case 4:
          message.priceState = PriceState.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$feedId, _object$answer;
    const message = createBaseChainlinkPriceState();
    message.feedId = (_object$feedId = object.feedId) !== null && _object$feedId !== void 0 ? _object$feedId : "";
    message.answer = (_object$answer = object.answer) !== null && _object$answer !== void 0 ? _object$answer : "";
    message.timestamp = object.timestamp !== undefined && object.timestamp !== null ? Long.fromValue(object.timestamp) : Long.UZERO;
    message.priceState = object.priceState !== undefined && object.priceState !== null ? PriceState.fromPartial(object.priceState) : undefined;
    return message;
  }
};
function createBaseBandPriceState() {
  return {
    symbol: "",
    rate: "",
    resolveTime: Long.UZERO,
    request_ID: Long.UZERO,
    priceState: undefined
  };
}
export const BandPriceState = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.symbol !== "") {
      writer.uint32(10).string(message.symbol);
    }
    if (message.rate !== "") {
      writer.uint32(18).string(message.rate);
    }
    if (!message.resolveTime.isZero()) {
      writer.uint32(24).uint64(message.resolveTime);
    }
    if (!message.request_ID.isZero()) {
      writer.uint32(32).uint64(message.request_ID);
    }
    if (message.priceState !== undefined) {
      PriceState.encode(message.priceState, writer.uint32(42).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 = createBaseBandPriceState();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.symbol = reader.string();
          break;
        case 2:
          message.rate = reader.string();
          break;
        case 3:
          message.resolveTime = reader.uint64();
          break;
        case 4:
          message.request_ID = reader.uint64();
          break;
        case 5:
          message.priceState = PriceState.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$symbol2, _object$rate;
    const message = createBaseBandPriceState();
    message.symbol = (_object$symbol2 = object.symbol) !== null && _object$symbol2 !== void 0 ? _object$symbol2 : "";
    message.rate = (_object$rate = object.rate) !== null && _object$rate !== void 0 ? _object$rate : "";
    message.resolveTime = object.resolveTime !== undefined && object.resolveTime !== null ? Long.fromValue(object.resolveTime) : Long.UZERO;
    message.request_ID = object.request_ID !== undefined && object.request_ID !== null ? Long.fromValue(object.request_ID) : Long.UZERO;
    message.priceState = object.priceState !== undefined && object.priceState !== null ? PriceState.fromPartial(object.priceState) : undefined;
    return message;
  }
};
function createBasePriceFeedState() {
  return {
    base: "",
    quote: "",
    priceState: undefined,
    relayers: []
  };
}
export const PriceFeedState = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.base !== "") {
      writer.uint32(10).string(message.base);
    }
    if (message.quote !== "") {
      writer.uint32(18).string(message.quote);
    }
    if (message.priceState !== undefined) {
      PriceState.encode(message.priceState, writer.uint32(26).fork()).ldelim();
    }
    for (const v of message.relayers) {
      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 = createBasePriceFeedState();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.base = reader.string();
          break;
        case 2:
          message.quote = reader.string();
          break;
        case 3:
          message.priceState = PriceState.decode(reader, reader.uint32());
          break;
        case 4:
          message.relayers.push(reader.string());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$base, _object$quote, _object$relayers;
    const message = createBasePriceFeedState();
    message.base = (_object$base = object.base) !== null && _object$base !== void 0 ? _object$base : "";
    message.quote = (_object$quote = object.quote) !== null && _object$quote !== void 0 ? _object$quote : "";
    message.priceState = object.priceState !== undefined && object.priceState !== null ? PriceState.fromPartial(object.priceState) : undefined;
    message.relayers = ((_object$relayers = object.relayers) === null || _object$relayers === void 0 ? void 0 : _object$relayers.map(e => e)) || [];
    return message;
  }
};
function createBaseProviderInfo() {
  return {
    provider: "",
    relayers: []
  };
}
export const ProviderInfo = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.provider !== "") {
      writer.uint32(10).string(message.provider);
    }
    for (const v of message.relayers) {
      writer.uint32(18).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 = createBaseProviderInfo();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.provider = reader.string();
          break;
        case 2:
          message.relayers.push(reader.string());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$provider, _object$relayers2;
    const message = createBaseProviderInfo();
    message.provider = (_object$provider = object.provider) !== null && _object$provider !== void 0 ? _object$provider : "";
    message.relayers = ((_object$relayers2 = object.relayers) === null || _object$relayers2 === void 0 ? void 0 : _object$relayers2.map(e => e)) || [];
    return message;
  }
};
function createBaseProviderState() {
  return {
    providerInfo: undefined,
    providerPriceStates: []
  };
}
export const ProviderState = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.providerInfo !== undefined) {
      ProviderInfo.encode(message.providerInfo, writer.uint32(10).fork()).ldelim();
    }
    for (const v of message.providerPriceStates) {
      ProviderPriceState.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 = createBaseProviderState();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.providerInfo = ProviderInfo.decode(reader, reader.uint32());
          break;
        case 2:
          message.providerPriceStates.push(ProviderPriceState.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$providerPrice;
    const message = createBaseProviderState();
    message.providerInfo = object.providerInfo !== undefined && object.providerInfo !== null ? ProviderInfo.fromPartial(object.providerInfo) : undefined;
    message.providerPriceStates = ((_object$providerPrice = object.providerPriceStates) === null || _object$providerPrice === void 0 ? void 0 : _object$providerPrice.map(e => ProviderPriceState.fromPartial(e))) || [];
    return message;
  }
};
function createBaseProviderPriceState() {
  return {
    symbol: "",
    state: undefined
  };
}
export const ProviderPriceState = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.symbol !== "") {
      writer.uint32(10).string(message.symbol);
    }
    if (message.state !== undefined) {
      PriceState.encode(message.state, 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 = createBaseProviderPriceState();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.symbol = reader.string();
          break;
        case 2:
          message.state = PriceState.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$symbol3;
    const message = createBaseProviderPriceState();
    message.symbol = (_object$symbol3 = object.symbol) !== null && _object$symbol3 !== void 0 ? _object$symbol3 : "";
    message.state = object.state !== undefined && object.state !== null ? PriceState.fromPartial(object.state) : undefined;
    return message;
  }
};
function createBasePriceFeedInfo() {
  return {
    base: "",
    quote: ""
  };
}
export const PriceFeedInfo = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.base !== "") {
      writer.uint32(10).string(message.base);
    }
    if (message.quote !== "") {
      writer.uint32(18).string(message.quote);
    }
    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 = createBasePriceFeedInfo();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.base = reader.string();
          break;
        case 2:
          message.quote = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$base2, _object$quote2;
    const message = createBasePriceFeedInfo();
    message.base = (_object$base2 = object.base) !== null && _object$base2 !== void 0 ? _object$base2 : "";
    message.quote = (_object$quote2 = object.quote) !== null && _object$quote2 !== void 0 ? _object$quote2 : "";
    return message;
  }
};
function createBasePriceFeedPrice() {
  return {
    price: ""
  };
}
export const PriceFeedPrice = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.price !== "") {
      writer.uint32(10).string(message.price);
    }
    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 = createBasePriceFeedPrice();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.price = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$price;
    const message = createBasePriceFeedPrice();
    message.price = (_object$price = object.price) !== null && _object$price !== void 0 ? _object$price : "";
    return message;
  }
};
function createBaseCoinbasePriceState() {
  return {
    kind: "",
    timestamp: Long.UZERO,
    key: "",
    value: Long.UZERO,
    priceState: undefined
  };
}
export const CoinbasePriceState = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.kind !== "") {
      writer.uint32(10).string(message.kind);
    }
    if (!message.timestamp.isZero()) {
      writer.uint32(16).uint64(message.timestamp);
    }
    if (message.key !== "") {
      writer.uint32(26).string(message.key);
    }
    if (!message.value.isZero()) {
      writer.uint32(32).uint64(message.value);
    }
    if (message.priceState !== undefined) {
      PriceState.encode(message.priceState, writer.uint32(42).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 = createBaseCoinbasePriceState();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.kind = reader.string();
          break;
        case 2:
          message.timestamp = reader.uint64();
          break;
        case 3:
          message.key = reader.string();
          break;
        case 4:
          message.value = reader.uint64();
          break;
        case 5:
          message.priceState = PriceState.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$kind, _object$key;
    const message = createBaseCoinbasePriceState();
    message.kind = (_object$kind = object.kind) !== null && _object$kind !== void 0 ? _object$kind : "";
    message.timestamp = object.timestamp !== undefined && object.timestamp !== null ? Long.fromValue(object.timestamp) : Long.UZERO;
    message.key = (_object$key = object.key) !== null && _object$key !== void 0 ? _object$key : "";
    message.value = object.value !== undefined && object.value !== null ? Long.fromValue(object.value) : Long.UZERO;
    message.priceState = object.priceState !== undefined && object.priceState !== null ? PriceState.fromPartial(object.priceState) : undefined;
    return message;
  }
};
function createBasePriceState() {
  return {
    price: "",
    cumulativePrice: "",
    timestamp: Long.ZERO
  };
}
export const PriceState = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.price !== "") {
      writer.uint32(10).string(message.price);
    }
    if (message.cumulativePrice !== "") {
      writer.uint32(18).string(message.cumulativePrice);
    }
    if (!message.timestamp.isZero()) {
      writer.uint32(24).int64(message.timestamp);
    }
    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 = createBasePriceState();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.price = reader.string();
          break;
        case 2:
          message.cumulativePrice = reader.string();
          break;
        case 3:
          message.timestamp = reader.int64();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$price2, _object$cumulativePri;
    const message = createBasePriceState();
    message.price = (_object$price2 = object.price) !== null && _object$price2 !== void 0 ? _object$price2 : "";
    message.cumulativePrice = (_object$cumulativePri = object.cumulativePrice) !== null && _object$cumulativePri !== void 0 ? _object$cumulativePri : "";
    message.timestamp = object.timestamp !== undefined && object.timestamp !== null ? Long.fromValue(object.timestamp) : Long.ZERO;
    return message;
  }
};
function createBaseBandOracleRequest() {
  return {
    requestId: Long.UZERO,
    oracleScriptId: Long.ZERO,
    symbols: [],
    askCount: Long.UZERO,
    minCount: Long.UZERO,
    feeLimit: [],
    prepareGas: Long.UZERO,
    executeGas: Long.UZERO
  };
}
export const BandOracleRequest = {
  encode(message, writer = _m0.Writer.create()) {
    if (!message.requestId.isZero()) {
      writer.uint32(8).uint64(message.requestId);
    }
    if (!message.oracleScriptId.isZero()) {
      writer.uint32(16).int64(message.oracleScriptId);
    }
    for (const v of message.symbols) {
      writer.uint32(26).string(v);
    }
    if (!message.askCount.isZero()) {
      writer.uint32(32).uint64(message.askCount);
    }
    if (!message.minCount.isZero()) {
      writer.uint32(40).uint64(message.minCount);
    }
    for (const v of message.feeLimit) {
      Coin.encode(v, writer.uint32(50).fork()).ldelim();
    }
    if (!message.prepareGas.isZero()) {
      writer.uint32(56).uint64(message.prepareGas);
    }
    if (!message.executeGas.isZero()) {
      writer.uint32(64).uint64(message.executeGas);
    }
    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 = createBaseBandOracleRequest();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.requestId = reader.uint64();
          break;
        case 2:
          message.oracleScriptId = reader.int64();
          break;
        case 3:
          message.symbols.push(reader.string());
          break;
        case 4:
          message.askCount = reader.uint64();
          break;
        case 5:
          message.minCount = reader.uint64();
          break;
        case 6:
          message.feeLimit.push(Coin.decode(reader, reader.uint32()));
          break;
        case 7:
          message.prepareGas = reader.uint64();
          break;
        case 8:
          message.executeGas = reader.uint64();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$symbols, _object$feeLimit;
    const message = createBaseBandOracleRequest();
    message.requestId = object.requestId !== undefined && object.requestId !== null ? Long.fromValue(object.requestId) : Long.UZERO;
    message.oracleScriptId = object.oracleScriptId !== undefined && object.oracleScriptId !== null ? Long.fromValue(object.oracleScriptId) : Long.ZERO;
    message.symbols = ((_object$symbols = object.symbols) === null || _object$symbols === void 0 ? void 0 : _object$symbols.map(e => e)) || [];
    message.askCount = object.askCount !== undefined && object.askCount !== null ? Long.fromValue(object.askCount) : Long.UZERO;
    message.minCount = object.minCount !== undefined && object.minCount !== null ? Long.fromValue(object.minCount) : Long.UZERO;
    message.feeLimit = ((_object$feeLimit = object.feeLimit) === null || _object$feeLimit === void 0 ? void 0 : _object$feeLimit.map(e => Coin.fromPartial(e))) || [];
    message.prepareGas = object.prepareGas !== undefined && object.prepareGas !== null ? Long.fromValue(object.prepareGas) : Long.UZERO;
    message.executeGas = object.executeGas !== undefined && object.executeGas !== null ? Long.fromValue(object.executeGas) : Long.UZERO;
    return message;
  }
};
function createBaseBandIBCParams() {
  return {
    bandIbcEnabled: false,
    ibcRequestInterval: Long.ZERO,
    ibcSourceChannel: "",
    ibcVersion: "",
    ibcPortId: ""
  };
}
export const BandIBCParams = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.bandIbcEnabled === true) {
      writer.uint32(8).bool(message.bandIbcEnabled);
    }
    if (!message.ibcRequestInterval.isZero()) {
      writer.uint32(16).int64(message.ibcRequestInterval);
    }
    if (message.ibcSourceChannel !== "") {
      writer.uint32(26).string(message.ibcSourceChannel);
    }
    if (message.ibcVersion !== "") {
      writer.uint32(34).string(message.ibcVersion);
    }
    if (message.ibcPortId !== "") {
      writer.uint32(42).string(message.ibcPortId);
    }
    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 = createBaseBandIBCParams();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.bandIbcEnabled = reader.bool();
          break;
        case 2:
          message.ibcRequestInterval = reader.int64();
          break;
        case 3:
          message.ibcSourceChannel = reader.string();
          break;
        case 4:
          message.ibcVersion = reader.string();
          break;
        case 5:
          message.ibcPortId = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$bandIbcEnable, _object$ibcSourceChan, _object$ibcVersion, _object$ibcPortId;
    const message = createBaseBandIBCParams();
    message.bandIbcEnabled = (_object$bandIbcEnable = object.bandIbcEnabled) !== null && _object$bandIbcEnable !== void 0 ? _object$bandIbcEnable : false;
    message.ibcRequestInterval = object.ibcRequestInterval !== undefined && object.ibcRequestInterval !== null ? Long.fromValue(object.ibcRequestInterval) : Long.ZERO;
    message.ibcSourceChannel = (_object$ibcSourceChan = object.ibcSourceChannel) !== null && _object$ibcSourceChan !== void 0 ? _object$ibcSourceChan : "";
    message.ibcVersion = (_object$ibcVersion = object.ibcVersion) !== null && _object$ibcVersion !== void 0 ? _object$ibcVersion : "";
    message.ibcPortId = (_object$ibcPortId = object.ibcPortId) !== null && _object$ibcPortId !== void 0 ? _object$ibcPortId : "";
    return message;
  }
};
function createBaseSymbolPriceTimestamp() {
  return {
    oracle: 0,
    symbolId: "",
    timestamp: Long.ZERO
  };
}
export const SymbolPriceTimestamp = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.oracle !== 0) {
      writer.uint32(8).int32(message.oracle);
    }
    if (message.symbolId !== "") {
      writer.uint32(18).string(message.symbolId);
    }
    if (!message.timestamp.isZero()) {
      writer.uint32(24).int64(message.timestamp);
    }
    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 = createBaseSymbolPriceTimestamp();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.oracle = reader.int32();
          break;
        case 2:
          message.symbolId = reader.string();
          break;
        case 3:
          message.timestamp = reader.int64();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$oracle, _object$symbolId;
    const message = createBaseSymbolPriceTimestamp();
    message.oracle = (_object$oracle = object.oracle) !== null && _object$oracle !== void 0 ? _object$oracle : 0;
    message.symbolId = (_object$symbolId = object.symbolId) !== null && _object$symbolId !== void 0 ? _object$symbolId : "";
    message.timestamp = object.timestamp !== undefined && object.timestamp !== null ? Long.fromValue(object.timestamp) : Long.ZERO;
    return message;
  }
};
function createBaseLastPriceTimestamps() {
  return {
    lastPriceTimestamps: []
  };
}
export const LastPriceTimestamps = {
  encode(message, writer = _m0.Writer.create()) {
    for (const v of message.lastPriceTimestamps) {
      SymbolPriceTimestamp.encode(v, writer.uint32(10).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 = createBaseLastPriceTimestamps();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.lastPriceTimestamps.push(SymbolPriceTimestamp.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$lastPriceTime;
    const message = createBaseLastPriceTimestamps();
    message.lastPriceTimestamps = ((_object$lastPriceTime = object.lastPriceTimestamps) === null || _object$lastPriceTime === void 0 ? void 0 : _object$lastPriceTime.map(e => SymbolPriceTimestamp.fromPartial(e))) || [];
    return message;
  }
};
function createBasePriceRecords() {
  return {
    oracle: 0,
    symbolId: "",
    latestPriceRecords: []
  };
}
export const PriceRecords = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.oracle !== 0) {
      writer.uint32(8).int32(message.oracle);
    }
    if (message.symbolId !== "") {
      writer.uint32(18).string(message.symbolId);
    }
    for (const v of message.latestPriceRecords) {
      PriceRecord.encode(v, 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 = createBasePriceRecords();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.oracle = reader.int32();
          break;
        case 2:
          message.symbolId = reader.string();
          break;
        case 3:
          message.latestPriceRecords.push(PriceRecord.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$oracle2, _object$symbolId2, _object$latestPriceRe;
    const message = createBasePriceRecords();
    message.oracle = (_object$oracle2 = object.oracle) !== null && _object$oracle2 !== void 0 ? _object$oracle2 : 0;
    message.symbolId = (_object$symbolId2 = object.symbolId) !== null && _object$symbolId2 !== void 0 ? _object$symbolId2 : "";
    message.latestPriceRecords = ((_object$latestPriceRe = object.latestPriceRecords) === null || _object$latestPriceRe === void 0 ? void 0 : _object$latestPriceRe.map(e => PriceRecord.fromPartial(e))) || [];
    return message;
  }
};
function createBasePriceRecord() {
  return {
    timestamp: Long.ZERO,
    price: ""
  };
}
export const PriceRecord = {
  encode(message, writer = _m0.Writer.create()) {
    if (!message.timestamp.isZero()) {
      writer.uint32(8).int64(message.timestamp);
    }
    if (message.price !== "") {
      writer.uint32(18).string(message.price);
    }
    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 = createBasePriceRecord();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.timestamp = reader.int64();
          break;
        case 2:
          message.price = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$price3;
    const message = createBasePriceRecord();
    message.timestamp = object.timestamp !== undefined && object.timestamp !== null ? Long.fromValue(object.timestamp) : Long.ZERO;
    message.price = (_object$price3 = object.price) !== null && _object$price3 !== void 0 ? _object$price3 : "";
    return message;
  }
};
function createBaseMetadataStatistics() {
  return {
    groupCount: 0,
    recordsSampleSize: 0,
    mean: "",
    twap: "",
    firstTimestamp: Long.ZERO,
    lastTimestamp: Long.ZERO,
    minPrice: "",
    maxPrice: "",
    medianPrice: ""
  };
}
export const MetadataStatistics = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.groupCount !== 0) {
      writer.uint32(8).uint32(message.groupCount);
    }
    if (message.recordsSampleSize !== 0) {
      writer.uint32(16).uint32(message.recordsSampleSize);
    }
    if (message.mean !== "") {
      writer.uint32(26).string(message.mean);
    }
    if (message.twap !== "") {
      writer.uint32(34).string(message.twap);
    }
    if (!message.firstTimestamp.isZero()) {
      writer.uint32(40).int64(message.firstTimestamp);
    }
    if (!message.lastTimestamp.isZero()) {
      writer.uint32(48).int64(message.lastTimestamp);
    }
    if (message.minPrice !== "") {
      writer.uint32(58).string(message.minPrice);
    }
    if (message.maxPrice !== "") {
      writer.uint32(66).string(message.maxPrice);
    }
    if (message.medianPrice !== "") {
      writer.uint32(74).string(message.medianPrice);
    }
    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 = createBaseMetadataStatistics();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.groupCount = reader.uint32();
          break;
        case 2:
          message.recordsSampleSize = reader.uint32();
          break;
        case 3:
          message.mean = reader.string();
          break;
        case 4:
          message.twap = reader.string();
          break;
        case 5:
          message.firstTimestamp = reader.int64();
          break;
        case 6:
          message.lastTimestamp = reader.int64();
          break;
        case 7:
          message.minPrice = reader.string();
          break;
        case 8:
          message.maxPrice = reader.string();
          break;
        case 9:
          message.medianPrice = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$groupCount, _object$recordsSample, _object$mean, _object$twap, _object$minPrice, _object$maxPrice, _object$medianPrice;
    const message = createBaseMetadataStatistics();
    message.groupCount = (_object$groupCount = object.groupCount) !== null && _object$groupCount !== void 0 ? _object$groupCount : 0;
    message.recordsSampleSize = (_object$recordsSample = object.recordsSampleSize) !== null && _object$recordsSample !== void 0 ? _object$recordsSample : 0;
    message.mean = (_object$mean = object.mean) !== null && _object$mean !== void 0 ? _object$mean : "";
    message.twap = (_object$twap = object.twap) !== null && _object$twap !== void 0 ? _object$twap : "";
    message.firstTimestamp = object.firstTimestamp !== undefined && object.firstTimestamp !== null ? Long.fromValue(object.firstTimestamp) : Long.ZERO;
    message.lastTimestamp = object.lastTimestamp !== undefined && object.lastTimestamp !== null ? Long.fromValue(object.lastTimestamp) : Long.ZERO;
    message.minPrice = (_object$minPrice = object.minPrice) !== null && _object$minPrice !== void 0 ? _object$minPrice : "";
    message.maxPrice = (_object$maxPrice = object.maxPrice) !== null && _object$maxPrice !== void 0 ? _object$maxPrice : "";
    message.medianPrice = (_object$medianPrice = object.medianPrice) !== null && _object$medianPrice !== void 0 ? _object$medianPrice : "";
    return message;
  }
};