"use strict";

var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.SymbolPriceTimestamp = exports.ProviderState = exports.ProviderPriceState = exports.ProviderInfo = exports.PriceState = exports.PriceRecords = exports.PriceRecord = exports.PriceFeedState = exports.PriceFeedPrice = exports.PriceFeedInfo = exports.Params = exports.OracleTypeSDKType = exports.OracleType = exports.OracleInfo = exports.MetadataStatistics = exports.LastPriceTimestamps = exports.CoinbasePriceState = exports.ChainlinkPriceState = exports.BandPriceState = exports.BandOracleRequest = exports.BandIBCParams = void 0;
exports.oracleTypeFromJSON = oracleTypeFromJSON;
exports.oracleTypeToJSON = oracleTypeToJSON;
var _coin = require("../../../cosmos/base/v1beta1/coin");
var _m0 = _interopRequireWildcard(require("protobufjs/minimal"));
var _helpers = require("../../../helpers");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
var OracleType;
exports.OracleType = 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 || (exports.OracleType = OracleType = {}));
var OracleTypeSDKType = OracleType;
exports.OracleTypeSDKType = OracleTypeSDKType;
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;
  }
}
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 {};
}
var Params = {
  encode: function encode(_) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseParams();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial: function fromPartial(_) {
    var message = createBaseParams();
    return message;
  }
};
exports.Params = Params;
function createBaseOracleInfo() {
  return {
    symbol: "",
    oracleType: 0,
    scaleFactor: 0
  };
}
var OracleInfo = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _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: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseOracleInfo();
    while (reader.pos < end) {
      var 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: function fromPartial(object) {
    var _object$symbol, _object$oracleType, _object$scaleFactor;
    var 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;
  }
};
exports.OracleInfo = OracleInfo;
function createBaseChainlinkPriceState() {
  return {
    feedId: "",
    answer: "",
    timestamp: _helpers.Long.UZERO,
    priceState: undefined
  };
}
var ChainlinkPriceState = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _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: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseChainlinkPriceState();
    while (reader.pos < end) {
      var 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: function fromPartial(object) {
    var _object$feedId, _object$answer;
    var 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 ? _helpers.Long.fromValue(object.timestamp) : _helpers.Long.UZERO;
    message.priceState = object.priceState !== undefined && object.priceState !== null ? PriceState.fromPartial(object.priceState) : undefined;
    return message;
  }
};
exports.ChainlinkPriceState = ChainlinkPriceState;
function createBaseBandPriceState() {
  return {
    symbol: "",
    rate: "",
    resolveTime: _helpers.Long.UZERO,
    request_ID: _helpers.Long.UZERO,
    priceState: undefined
  };
}
var BandPriceState = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _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: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseBandPriceState();
    while (reader.pos < end) {
      var 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: function fromPartial(object) {
    var _object$symbol2, _object$rate;
    var 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 ? _helpers.Long.fromValue(object.resolveTime) : _helpers.Long.UZERO;
    message.request_ID = object.request_ID !== undefined && object.request_ID !== null ? _helpers.Long.fromValue(object.request_ID) : _helpers.Long.UZERO;
    message.priceState = object.priceState !== undefined && object.priceState !== null ? PriceState.fromPartial(object.priceState) : undefined;
    return message;
  }
};
exports.BandPriceState = BandPriceState;
function createBasePriceFeedState() {
  return {
    base: "",
    quote: "",
    priceState: undefined,
    relayers: []
  };
}
var PriceFeedState = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _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();
    }
    var _iterator = _createForOfIteratorHelper(message.relayers),
      _step;
    try {
      for (_iterator.s(); !(_step = _iterator.n()).done;) {
        var v = _step.value;
        writer.uint32(34).string(v);
      }
    } catch (err) {
      _iterator.e(err);
    } finally {
      _iterator.f();
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBasePriceFeedState();
    while (reader.pos < end) {
      var 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: function fromPartial(object) {
    var _object$base, _object$quote, _object$relayers;
    var 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(function (e) {
      return e;
    })) || [];
    return message;
  }
};
exports.PriceFeedState = PriceFeedState;
function createBaseProviderInfo() {
  return {
    provider: "",
    relayers: []
  };
}
var ProviderInfo = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.provider !== "") {
      writer.uint32(10).string(message.provider);
    }
    var _iterator2 = _createForOfIteratorHelper(message.relayers),
      _step2;
    try {
      for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
        var v = _step2.value;
        writer.uint32(18).string(v);
      }
    } catch (err) {
      _iterator2.e(err);
    } finally {
      _iterator2.f();
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseProviderInfo();
    while (reader.pos < end) {
      var 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: function fromPartial(object) {
    var _object$provider, _object$relayers2;
    var 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(function (e) {
      return e;
    })) || [];
    return message;
  }
};
exports.ProviderInfo = ProviderInfo;
function createBaseProviderState() {
  return {
    providerInfo: undefined,
    providerPriceStates: []
  };
}
var ProviderState = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.providerInfo !== undefined) {
      ProviderInfo.encode(message.providerInfo, writer.uint32(10).fork()).ldelim();
    }
    var _iterator3 = _createForOfIteratorHelper(message.providerPriceStates),
      _step3;
    try {
      for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
        var v = _step3.value;
        ProviderPriceState.encode(v, writer.uint32(18).fork()).ldelim();
      }
    } catch (err) {
      _iterator3.e(err);
    } finally {
      _iterator3.f();
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseProviderState();
    while (reader.pos < end) {
      var 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: function fromPartial(object) {
    var _object$providerPrice;
    var 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(function (e) {
      return ProviderPriceState.fromPartial(e);
    })) || [];
    return message;
  }
};
exports.ProviderState = ProviderState;
function createBaseProviderPriceState() {
  return {
    symbol: "",
    state: undefined
  };
}
var ProviderPriceState = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _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: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseProviderPriceState();
    while (reader.pos < end) {
      var 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: function fromPartial(object) {
    var _object$symbol3;
    var 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;
  }
};
exports.ProviderPriceState = ProviderPriceState;
function createBasePriceFeedInfo() {
  return {
    base: "",
    quote: ""
  };
}
var PriceFeedInfo = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.base !== "") {
      writer.uint32(10).string(message.base);
    }
    if (message.quote !== "") {
      writer.uint32(18).string(message.quote);
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBasePriceFeedInfo();
    while (reader.pos < end) {
      var 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: function fromPartial(object) {
    var _object$base2, _object$quote2;
    var 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;
  }
};
exports.PriceFeedInfo = PriceFeedInfo;
function createBasePriceFeedPrice() {
  return {
    price: ""
  };
}
var PriceFeedPrice = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.price !== "") {
      writer.uint32(10).string(message.price);
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBasePriceFeedPrice();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.price = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial: function fromPartial(object) {
    var _object$price;
    var message = createBasePriceFeedPrice();
    message.price = (_object$price = object.price) !== null && _object$price !== void 0 ? _object$price : "";
    return message;
  }
};
exports.PriceFeedPrice = PriceFeedPrice;
function createBaseCoinbasePriceState() {
  return {
    kind: "",
    timestamp: _helpers.Long.UZERO,
    key: "",
    value: _helpers.Long.UZERO,
    priceState: undefined
  };
}
var CoinbasePriceState = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _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: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseCoinbasePriceState();
    while (reader.pos < end) {
      var 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: function fromPartial(object) {
    var _object$kind, _object$key;
    var message = createBaseCoinbasePriceState();
    message.kind = (_object$kind = object.kind) !== null && _object$kind !== void 0 ? _object$kind : "";
    message.timestamp = object.timestamp !== undefined && object.timestamp !== null ? _helpers.Long.fromValue(object.timestamp) : _helpers.Long.UZERO;
    message.key = (_object$key = object.key) !== null && _object$key !== void 0 ? _object$key : "";
    message.value = object.value !== undefined && object.value !== null ? _helpers.Long.fromValue(object.value) : _helpers.Long.UZERO;
    message.priceState = object.priceState !== undefined && object.priceState !== null ? PriceState.fromPartial(object.priceState) : undefined;
    return message;
  }
};
exports.CoinbasePriceState = CoinbasePriceState;
function createBasePriceState() {
  return {
    price: "",
    cumulativePrice: "",
    timestamp: _helpers.Long.ZERO
  };
}
var PriceState = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _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: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBasePriceState();
    while (reader.pos < end) {
      var 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: function fromPartial(object) {
    var _object$price2, _object$cumulativePri;
    var 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 ? _helpers.Long.fromValue(object.timestamp) : _helpers.Long.ZERO;
    return message;
  }
};
exports.PriceState = PriceState;
function createBaseBandOracleRequest() {
  return {
    requestId: _helpers.Long.UZERO,
    oracleScriptId: _helpers.Long.ZERO,
    symbols: [],
    askCount: _helpers.Long.UZERO,
    minCount: _helpers.Long.UZERO,
    feeLimit: [],
    prepareGas: _helpers.Long.UZERO,
    executeGas: _helpers.Long.UZERO
  };
}
var BandOracleRequest = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (!message.requestId.isZero()) {
      writer.uint32(8).uint64(message.requestId);
    }
    if (!message.oracleScriptId.isZero()) {
      writer.uint32(16).int64(message.oracleScriptId);
    }
    var _iterator4 = _createForOfIteratorHelper(message.symbols),
      _step4;
    try {
      for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
        var v = _step4.value;
        writer.uint32(26).string(v);
      }
    } catch (err) {
      _iterator4.e(err);
    } finally {
      _iterator4.f();
    }
    if (!message.askCount.isZero()) {
      writer.uint32(32).uint64(message.askCount);
    }
    if (!message.minCount.isZero()) {
      writer.uint32(40).uint64(message.minCount);
    }
    var _iterator5 = _createForOfIteratorHelper(message.feeLimit),
      _step5;
    try {
      for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
        var _v = _step5.value;
        _coin.Coin.encode(_v, writer.uint32(50).fork()).ldelim();
      }
    } catch (err) {
      _iterator5.e(err);
    } finally {
      _iterator5.f();
    }
    if (!message.prepareGas.isZero()) {
      writer.uint32(56).uint64(message.prepareGas);
    }
    if (!message.executeGas.isZero()) {
      writer.uint32(64).uint64(message.executeGas);
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseBandOracleRequest();
    while (reader.pos < end) {
      var 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.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: function fromPartial(object) {
    var _object$symbols, _object$feeLimit;
    var message = createBaseBandOracleRequest();
    message.requestId = object.requestId !== undefined && object.requestId !== null ? _helpers.Long.fromValue(object.requestId) : _helpers.Long.UZERO;
    message.oracleScriptId = object.oracleScriptId !== undefined && object.oracleScriptId !== null ? _helpers.Long.fromValue(object.oracleScriptId) : _helpers.Long.ZERO;
    message.symbols = ((_object$symbols = object.symbols) === null || _object$symbols === void 0 ? void 0 : _object$symbols.map(function (e) {
      return e;
    })) || [];
    message.askCount = object.askCount !== undefined && object.askCount !== null ? _helpers.Long.fromValue(object.askCount) : _helpers.Long.UZERO;
    message.minCount = object.minCount !== undefined && object.minCount !== null ? _helpers.Long.fromValue(object.minCount) : _helpers.Long.UZERO;
    message.feeLimit = ((_object$feeLimit = object.feeLimit) === null || _object$feeLimit === void 0 ? void 0 : _object$feeLimit.map(function (e) {
      return _coin.Coin.fromPartial(e);
    })) || [];
    message.prepareGas = object.prepareGas !== undefined && object.prepareGas !== null ? _helpers.Long.fromValue(object.prepareGas) : _helpers.Long.UZERO;
    message.executeGas = object.executeGas !== undefined && object.executeGas !== null ? _helpers.Long.fromValue(object.executeGas) : _helpers.Long.UZERO;
    return message;
  }
};
exports.BandOracleRequest = BandOracleRequest;
function createBaseBandIBCParams() {
  return {
    bandIbcEnabled: false,
    ibcRequestInterval: _helpers.Long.ZERO,
    ibcSourceChannel: "",
    ibcVersion: "",
    ibcPortId: ""
  };
}
var BandIBCParams = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _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: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseBandIBCParams();
    while (reader.pos < end) {
      var 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: function fromPartial(object) {
    var _object$bandIbcEnable, _object$ibcSourceChan, _object$ibcVersion, _object$ibcPortId;
    var message = createBaseBandIBCParams();
    message.bandIbcEnabled = (_object$bandIbcEnable = object.bandIbcEnabled) !== null && _object$bandIbcEnable !== void 0 ? _object$bandIbcEnable : false;
    message.ibcRequestInterval = object.ibcRequestInterval !== undefined && object.ibcRequestInterval !== null ? _helpers.Long.fromValue(object.ibcRequestInterval) : _helpers.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;
  }
};
exports.BandIBCParams = BandIBCParams;
function createBaseSymbolPriceTimestamp() {
  return {
    oracle: 0,
    symbolId: "",
    timestamp: _helpers.Long.ZERO
  };
}
var SymbolPriceTimestamp = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _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: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseSymbolPriceTimestamp();
    while (reader.pos < end) {
      var 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: function fromPartial(object) {
    var _object$oracle, _object$symbolId;
    var 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 ? _helpers.Long.fromValue(object.timestamp) : _helpers.Long.ZERO;
    return message;
  }
};
exports.SymbolPriceTimestamp = SymbolPriceTimestamp;
function createBaseLastPriceTimestamps() {
  return {
    lastPriceTimestamps: []
  };
}
var LastPriceTimestamps = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    var _iterator6 = _createForOfIteratorHelper(message.lastPriceTimestamps),
      _step6;
    try {
      for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
        var v = _step6.value;
        SymbolPriceTimestamp.encode(v, writer.uint32(10).fork()).ldelim();
      }
    } catch (err) {
      _iterator6.e(err);
    } finally {
      _iterator6.f();
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseLastPriceTimestamps();
    while (reader.pos < end) {
      var 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: function fromPartial(object) {
    var _object$lastPriceTime;
    var message = createBaseLastPriceTimestamps();
    message.lastPriceTimestamps = ((_object$lastPriceTime = object.lastPriceTimestamps) === null || _object$lastPriceTime === void 0 ? void 0 : _object$lastPriceTime.map(function (e) {
      return SymbolPriceTimestamp.fromPartial(e);
    })) || [];
    return message;
  }
};
exports.LastPriceTimestamps = LastPriceTimestamps;
function createBasePriceRecords() {
  return {
    oracle: 0,
    symbolId: "",
    latestPriceRecords: []
  };
}
var PriceRecords = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.oracle !== 0) {
      writer.uint32(8).int32(message.oracle);
    }
    if (message.symbolId !== "") {
      writer.uint32(18).string(message.symbolId);
    }
    var _iterator7 = _createForOfIteratorHelper(message.latestPriceRecords),
      _step7;
    try {
      for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
        var v = _step7.value;
        PriceRecord.encode(v, writer.uint32(26).fork()).ldelim();
      }
    } catch (err) {
      _iterator7.e(err);
    } finally {
      _iterator7.f();
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBasePriceRecords();
    while (reader.pos < end) {
      var 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: function fromPartial(object) {
    var _object$oracle2, _object$symbolId2, _object$latestPriceRe;
    var 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(function (e) {
      return PriceRecord.fromPartial(e);
    })) || [];
    return message;
  }
};
exports.PriceRecords = PriceRecords;
function createBasePriceRecord() {
  return {
    timestamp: _helpers.Long.ZERO,
    price: ""
  };
}
var PriceRecord = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _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: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBasePriceRecord();
    while (reader.pos < end) {
      var 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: function fromPartial(object) {
    var _object$price3;
    var message = createBasePriceRecord();
    message.timestamp = object.timestamp !== undefined && object.timestamp !== null ? _helpers.Long.fromValue(object.timestamp) : _helpers.Long.ZERO;
    message.price = (_object$price3 = object.price) !== null && _object$price3 !== void 0 ? _object$price3 : "";
    return message;
  }
};
exports.PriceRecord = PriceRecord;
function createBaseMetadataStatistics() {
  return {
    groupCount: 0,
    recordsSampleSize: 0,
    mean: "",
    twap: "",
    firstTimestamp: _helpers.Long.ZERO,
    lastTimestamp: _helpers.Long.ZERO,
    minPrice: "",
    maxPrice: "",
    medianPrice: ""
  };
}
var MetadataStatistics = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _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: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseMetadataStatistics();
    while (reader.pos < end) {
      var 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: function fromPartial(object) {
    var _object$groupCount, _object$recordsSample, _object$mean, _object$twap, _object$minPrice, _object$maxPrice, _object$medianPrice;
    var 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 ? _helpers.Long.fromValue(object.firstTimestamp) : _helpers.Long.ZERO;
    message.lastTimestamp = object.lastTimestamp !== undefined && object.lastTimestamp !== null ? _helpers.Long.fromValue(object.lastTimestamp) : _helpers.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;
  }
};
exports.MetadataStatistics = MetadataStatistics;