"use strict";

var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.TokenMetadataProperties = exports.QueryTokenMetadataResponse = exports.QueryTokenMetadataRequest = exports.QueryTokenListResponse = exports.QueryTokenListRequest = exports.QueryTokenDocResponse = exports.QueryTokenDocRequest = exports.QueryParamsResponse = exports.QueryParamsRequest = void 0;
var _pagination = require("../../../cosmos/base/query/v1beta1/pagination");
var _token = require("./token");
var _m0 = _interopRequireWildcard(require("protobufjs/minimal"));
var _helpers = require("../../../helpers");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, 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 o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } //@ts-nocheck
function createBaseQueryParamsRequest() {
  return {};
}
var QueryParamsRequest = exports.QueryParamsRequest = {
  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 = createBaseQueryParamsRequest();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(_) {
    return {};
  },
  toJSON: function toJSON(_) {
    var obj = {};
    return obj;
  },
  fromPartial: function fromPartial(_) {
    var message = createBaseQueryParamsRequest();
    return message;
  }
};
function createBaseQueryParamsResponse() {
  return {
    params: undefined
  };
}
var QueryParamsResponse = exports.QueryParamsResponse = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.params !== undefined) {
      _token.Params.encode(message.params, writer.uint32(10).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 = createBaseQueryParamsResponse();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.params = _token.Params.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      params: (0, _helpers.isSet)(object.params) ? _token.Params.fromJSON(object.params) : undefined
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.params !== undefined && (obj.params = message.params ? _token.Params.toJSON(message.params) : undefined);
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var message = createBaseQueryParamsResponse();
    message.params = object.params !== undefined && object.params !== null ? _token.Params.fromPartial(object.params) : undefined;
    return message;
  }
};
function createBaseQueryTokenListRequest() {
  return {
    pagination: undefined,
    minter: ""
  };
}
var QueryTokenListRequest = exports.QueryTokenListRequest = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.pagination !== undefined) {
      _pagination.PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim();
    }
    if (message.minter !== "") {
      writer.uint32(18).string(message.minter);
    }
    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 = createBaseQueryTokenListRequest();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.pagination = _pagination.PageRequest.decode(reader, reader.uint32());
          break;
        case 2:
          message.minter = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      pagination: (0, _helpers.isSet)(object.pagination) ? _pagination.PageRequest.fromJSON(object.pagination) : undefined,
      minter: (0, _helpers.isSet)(object.minter) ? String(object.minter) : ""
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.pagination !== undefined && (obj.pagination = message.pagination ? _pagination.PageRequest.toJSON(message.pagination) : undefined);
    message.minter !== undefined && (obj.minter = message.minter);
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$minter;
    var message = createBaseQueryTokenListRequest();
    message.pagination = object.pagination !== undefined && object.pagination !== null ? _pagination.PageRequest.fromPartial(object.pagination) : undefined;
    message.minter = (_object$minter = object.minter) !== null && _object$minter !== void 0 ? _object$minter : "";
    return message;
  }
};
function createBaseQueryTokenListResponse() {
  return {
    pagination: undefined,
    tokenDocs: []
  };
}
var QueryTokenListResponse = exports.QueryTokenListResponse = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.pagination !== undefined) {
      _pagination.PageResponse.encode(message.pagination, writer.uint32(10).fork()).ldelim();
    }
    var _iterator = _createForOfIteratorHelper(message.tokenDocs),
      _step;
    try {
      for (_iterator.s(); !(_step = _iterator.n()).done;) {
        var v = _step.value;
        _token.Token.encode(v, writer.uint32(18).fork()).ldelim();
      }
    } 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 = createBaseQueryTokenListResponse();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.pagination = _pagination.PageResponse.decode(reader, reader.uint32());
          break;
        case 2:
          message.tokenDocs.push(_token.Token.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      pagination: (0, _helpers.isSet)(object.pagination) ? _pagination.PageResponse.fromJSON(object.pagination) : undefined,
      tokenDocs: Array.isArray(object === null || object === void 0 ? void 0 : object.tokenDocs) ? object.tokenDocs.map(function (e) {
        return _token.Token.fromJSON(e);
      }) : []
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.pagination !== undefined && (obj.pagination = message.pagination ? _pagination.PageResponse.toJSON(message.pagination) : undefined);
    if (message.tokenDocs) {
      obj.tokenDocs = message.tokenDocs.map(function (e) {
        return e ? _token.Token.toJSON(e) : undefined;
      });
    } else {
      obj.tokenDocs = [];
    }
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$tokenDocs;
    var message = createBaseQueryTokenListResponse();
    message.pagination = object.pagination !== undefined && object.pagination !== null ? _pagination.PageResponse.fromPartial(object.pagination) : undefined;
    message.tokenDocs = ((_object$tokenDocs = object.tokenDocs) === null || _object$tokenDocs === void 0 ? void 0 : _object$tokenDocs.map(function (e) {
      return _token.Token.fromPartial(e);
    })) || [];
    return message;
  }
};
function createBaseQueryTokenDocRequest() {
  return {
    minter: "",
    contractAddress: ""
  };
}
var QueryTokenDocRequest = exports.QueryTokenDocRequest = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.minter !== "") {
      writer.uint32(10).string(message.minter);
    }
    if (message.contractAddress !== "") {
      writer.uint32(18).string(message.contractAddress);
    }
    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 = createBaseQueryTokenDocRequest();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.minter = reader.string();
          break;
        case 2:
          message.contractAddress = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      minter: (0, _helpers.isSet)(object.minter) ? String(object.minter) : "",
      contractAddress: (0, _helpers.isSet)(object.contractAddress) ? String(object.contractAddress) : ""
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.minter !== undefined && (obj.minter = message.minter);
    message.contractAddress !== undefined && (obj.contractAddress = message.contractAddress);
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$minter2, _object$contractAddre;
    var message = createBaseQueryTokenDocRequest();
    message.minter = (_object$minter2 = object.minter) !== null && _object$minter2 !== void 0 ? _object$minter2 : "";
    message.contractAddress = (_object$contractAddre = object.contractAddress) !== null && _object$contractAddre !== void 0 ? _object$contractAddre : "";
    return message;
  }
};
function createBaseQueryTokenDocResponse() {
  return {
    tokenDoc: undefined
  };
}
var QueryTokenDocResponse = exports.QueryTokenDocResponse = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.tokenDoc !== undefined) {
      _token.Token.encode(message.tokenDoc, writer.uint32(10).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 = createBaseQueryTokenDocResponse();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.tokenDoc = _token.Token.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      tokenDoc: (0, _helpers.isSet)(object.tokenDoc) ? _token.Token.fromJSON(object.tokenDoc) : undefined
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.tokenDoc !== undefined && (obj.tokenDoc = message.tokenDoc ? _token.Token.toJSON(message.tokenDoc) : undefined);
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var message = createBaseQueryTokenDocResponse();
    message.tokenDoc = object.tokenDoc !== undefined && object.tokenDoc !== null ? _token.Token.fromPartial(object.tokenDoc) : undefined;
    return message;
  }
};
function createBaseQueryTokenMetadataRequest() {
  return {
    id: ""
  };
}
var QueryTokenMetadataRequest = exports.QueryTokenMetadataRequest = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.id !== "") {
      writer.uint32(10).string(message.id);
    }
    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 = createBaseQueryTokenMetadataRequest();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.id = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      id: (0, _helpers.isSet)(object.id) ? String(object.id) : ""
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.id !== undefined && (obj.id = message.id);
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$id;
    var message = createBaseQueryTokenMetadataRequest();
    message.id = (_object$id = object.id) !== null && _object$id !== void 0 ? _object$id : "";
    return message;
  }
};
function createBaseQueryTokenMetadataResponse() {
  return {
    name: "",
    description: "",
    decimals: "",
    image: "",
    index: "",
    properties: undefined
  };
}
var QueryTokenMetadataResponse = exports.QueryTokenMetadataResponse = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.name !== "") {
      writer.uint32(10).string(message.name);
    }
    if (message.description !== "") {
      writer.uint32(18).string(message.description);
    }
    if (message.decimals !== "") {
      writer.uint32(26).string(message.decimals);
    }
    if (message.image !== "") {
      writer.uint32(34).string(message.image);
    }
    if (message.index !== "") {
      writer.uint32(42).string(message.index);
    }
    if (message.properties !== undefined) {
      TokenMetadataProperties.encode(message.properties, writer.uint32(50).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 = createBaseQueryTokenMetadataResponse();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.name = reader.string();
          break;
        case 2:
          message.description = reader.string();
          break;
        case 3:
          message.decimals = reader.string();
          break;
        case 4:
          message.image = reader.string();
          break;
        case 5:
          message.index = reader.string();
          break;
        case 6:
          message.properties = TokenMetadataProperties.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      name: (0, _helpers.isSet)(object.name) ? String(object.name) : "",
      description: (0, _helpers.isSet)(object.description) ? String(object.description) : "",
      decimals: (0, _helpers.isSet)(object.decimals) ? String(object.decimals) : "",
      image: (0, _helpers.isSet)(object.image) ? String(object.image) : "",
      index: (0, _helpers.isSet)(object.index) ? String(object.index) : "",
      properties: (0, _helpers.isSet)(object.properties) ? TokenMetadataProperties.fromJSON(object.properties) : undefined
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.name !== undefined && (obj.name = message.name);
    message.description !== undefined && (obj.description = message.description);
    message.decimals !== undefined && (obj.decimals = message.decimals);
    message.image !== undefined && (obj.image = message.image);
    message.index !== undefined && (obj.index = message.index);
    message.properties !== undefined && (obj.properties = message.properties ? TokenMetadataProperties.toJSON(message.properties) : undefined);
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$name, _object$description, _object$decimals, _object$image, _object$index;
    var message = createBaseQueryTokenMetadataResponse();
    message.name = (_object$name = object.name) !== null && _object$name !== void 0 ? _object$name : "";
    message.description = (_object$description = object.description) !== null && _object$description !== void 0 ? _object$description : "";
    message.decimals = (_object$decimals = object.decimals) !== null && _object$decimals !== void 0 ? _object$decimals : "";
    message.image = (_object$image = object.image) !== null && _object$image !== void 0 ? _object$image : "";
    message.index = (_object$index = object.index) !== null && _object$index !== void 0 ? _object$index : "";
    message.properties = object.properties !== undefined && object.properties !== null ? TokenMetadataProperties.fromPartial(object.properties) : undefined;
    return message;
  }
};
function createBaseTokenMetadataProperties() {
  return {
    "class": "",
    collection: "",
    cap: "",
    linkedResources: []
  };
}
var TokenMetadataProperties = exports.TokenMetadataProperties = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message["class"] !== "") {
      writer.uint32(10).string(message["class"]);
    }
    if (message.collection !== "") {
      writer.uint32(18).string(message.collection);
    }
    if (message.cap !== "") {
      writer.uint32(26).string(message.cap);
    }
    var _iterator2 = _createForOfIteratorHelper(message.linkedResources),
      _step2;
    try {
      for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
        var v = _step2.value;
        _token.TokenData.encode(v, writer.uint32(34).fork()).ldelim();
      }
    } 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 = createBaseTokenMetadataProperties();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message["class"] = reader.string();
          break;
        case 2:
          message.collection = reader.string();
          break;
        case 3:
          message.cap = reader.string();
          break;
        case 4:
          message.linkedResources.push(_token.TokenData.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      "class": (0, _helpers.isSet)(object["class"]) ? String(object["class"]) : "",
      collection: (0, _helpers.isSet)(object.collection) ? String(object.collection) : "",
      cap: (0, _helpers.isSet)(object.cap) ? String(object.cap) : "",
      linkedResources: Array.isArray(object === null || object === void 0 ? void 0 : object.linkedResources) ? object.linkedResources.map(function (e) {
        return _token.TokenData.fromJSON(e);
      }) : []
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message["class"] !== undefined && (obj["class"] = message["class"]);
    message.collection !== undefined && (obj.collection = message.collection);
    message.cap !== undefined && (obj.cap = message.cap);
    if (message.linkedResources) {
      obj.linkedResources = message.linkedResources.map(function (e) {
        return e ? _token.TokenData.toJSON(e) : undefined;
      });
    } else {
      obj.linkedResources = [];
    }
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$class, _object$collection, _object$cap, _object$linkedResourc;
    var message = createBaseTokenMetadataProperties();
    message["class"] = (_object$class = object["class"]) !== null && _object$class !== void 0 ? _object$class : "";
    message.collection = (_object$collection = object.collection) !== null && _object$collection !== void 0 ? _object$collection : "";
    message.cap = (_object$cap = object.cap) !== null && _object$cap !== void 0 ? _object$cap : "";
    message.linkedResources = ((_object$linkedResourc = object.linkedResources) === null || _object$linkedResourc === void 0 ? void 0 : _object$linkedResourc.map(function (e) {
      return _token.TokenData.fromPartial(e);
    })) || [];
    return message;
  }
};