"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Subspace = exports.QuerySubspacesResponse = exports.QuerySubspacesRequest = exports.QueryParamsResponse = exports.QueryParamsRequest = void 0;
var _params = require("./params");
var _binary = require("../../../binary");
var _helpers = require("../../../helpers");
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; }
/** QueryParamsRequest is request type for the Query/Params RPC method. */

/** QueryParamsRequest is request type for the Query/Params RPC method. */

/** QueryParamsRequest is request type for the Query/Params RPC method. */

/** QueryParamsResponse is response type for the Query/Params RPC method. */

/** QueryParamsResponse is response type for the Query/Params RPC method. */

/** QueryParamsResponse is response type for the Query/Params RPC method. */

/**
 * QuerySubspacesRequest defines a request type for querying for all registered
 * subspaces and all keys for a subspace.
 * 
 * Since: cosmos-sdk 0.46
 */

/**
 * QuerySubspacesRequest defines a request type for querying for all registered
 * subspaces and all keys for a subspace.
 * 
 * Since: cosmos-sdk 0.46
 */

/**
 * QuerySubspacesRequest defines a request type for querying for all registered
 * subspaces and all keys for a subspace.
 * 
 * Since: cosmos-sdk 0.46
 */

/**
 * QuerySubspacesResponse defines the response types for querying for all
 * registered subspaces and all keys for a subspace.
 * 
 * Since: cosmos-sdk 0.46
 */

/**
 * QuerySubspacesResponse defines the response types for querying for all
 * registered subspaces and all keys for a subspace.
 * 
 * Since: cosmos-sdk 0.46
 */

/**
 * QuerySubspacesResponse defines the response types for querying for all
 * registered subspaces and all keys for a subspace.
 * 
 * Since: cosmos-sdk 0.46
 */

/**
 * Subspace defines a parameter subspace name and all the keys that exist for
 * the subspace.
 * 
 * Since: cosmos-sdk 0.46
 */

/**
 * Subspace defines a parameter subspace name and all the keys that exist for
 * the subspace.
 * 
 * Since: cosmos-sdk 0.46
 */

/**
 * Subspace defines a parameter subspace name and all the keys that exist for
 * the subspace.
 * 
 * Since: cosmos-sdk 0.46
 */

function createBaseQueryParamsRequest() {
  return {
    subspace: "",
    key: ""
  };
}
var QueryParamsRequest = exports.QueryParamsRequest = {
  typeUrl: "/cosmos.params.v1beta1.QueryParamsRequest",
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _binary.BinaryWriter.create();
    if (message.subspace !== "") {
      writer.uint32(10).string(message.subspace);
    }
    if (message.key !== "") {
      writer.uint32(18).string(message.key);
    }
    return writer;
  },
  fromJSON: function fromJSON(object) {
    return {
      subspace: (0, _helpers.isSet)(object.subspace) ? String(object.subspace) : "",
      key: (0, _helpers.isSet)(object.key) ? String(object.key) : ""
    };
  },
  fromPartial: function fromPartial(object) {
    var _object$subspace, _object$key;
    var message = createBaseQueryParamsRequest();
    message.subspace = (_object$subspace = object.subspace) !== null && _object$subspace !== void 0 ? _object$subspace : "";
    message.key = (_object$key = object.key) !== null && _object$key !== void 0 ? _object$key : "";
    return message;
  },
  fromAmino: function fromAmino(object) {
    var message = createBaseQueryParamsRequest();
    if (object.subspace !== undefined && object.subspace !== null) {
      message.subspace = object.subspace;
    }
    if (object.key !== undefined && object.key !== null) {
      message.key = object.key;
    }
    return message;
  },
  toAmino: function toAmino(message) {
    var obj = {};
    obj.subspace = message.subspace === "" ? undefined : message.subspace;
    obj.key = message.key === "" ? undefined : message.key;
    return obj;
  },
  fromAminoMsg: function fromAminoMsg(object) {
    return QueryParamsRequest.fromAmino(object.value);
  },
  toAminoMsg: function toAminoMsg(message) {
    return {
      type: "cosmos-sdk/QueryParamsRequest",
      value: QueryParamsRequest.toAmino(message)
    };
  },
  fromProtoMsg: function fromProtoMsg(message) {
    return QueryParamsRequest.decode(message.value);
  },
  toProto: function toProto(message) {
    return QueryParamsRequest.encode(message).finish();
  },
  toProtoMsg: function toProtoMsg(message) {
    return {
      typeUrl: "/cosmos.params.v1beta1.QueryParamsRequest",
      value: QueryParamsRequest.encode(message).finish()
    };
  }
};
function createBaseQueryParamsResponse() {
  return {
    param: _params.ParamChange.fromPartial({})
  };
}
var QueryParamsResponse = exports.QueryParamsResponse = {
  typeUrl: "/cosmos.params.v1beta1.QueryParamsResponse",
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _binary.BinaryWriter.create();
    if (message.param !== undefined) {
      _params.ParamChange.encode(message.param, writer.uint32(10).fork()).ldelim();
    }
    return writer;
  },
  fromJSON: function fromJSON(object) {
    return {
      param: (0, _helpers.isSet)(object.param) ? _params.ParamChange.fromJSON(object.param) : undefined
    };
  },
  fromPartial: function fromPartial(object) {
    var message = createBaseQueryParamsResponse();
    message.param = object.param !== undefined && object.param !== null ? _params.ParamChange.fromPartial(object.param) : undefined;
    return message;
  },
  fromAmino: function fromAmino(object) {
    var message = createBaseQueryParamsResponse();
    if (object.param !== undefined && object.param !== null) {
      message.param = _params.ParamChange.fromAmino(object.param);
    }
    return message;
  },
  toAmino: function toAmino(message) {
    var obj = {};
    obj.param = message.param ? _params.ParamChange.toAmino(message.param) : undefined;
    return obj;
  },
  fromAminoMsg: function fromAminoMsg(object) {
    return QueryParamsResponse.fromAmino(object.value);
  },
  toAminoMsg: function toAminoMsg(message) {
    return {
      type: "cosmos-sdk/QueryParamsResponse",
      value: QueryParamsResponse.toAmino(message)
    };
  },
  fromProtoMsg: function fromProtoMsg(message) {
    return QueryParamsResponse.decode(message.value);
  },
  toProto: function toProto(message) {
    return QueryParamsResponse.encode(message).finish();
  },
  toProtoMsg: function toProtoMsg(message) {
    return {
      typeUrl: "/cosmos.params.v1beta1.QueryParamsResponse",
      value: QueryParamsResponse.encode(message).finish()
    };
  }
};
function createBaseQuerySubspacesRequest() {
  return {};
}
var QuerySubspacesRequest = exports.QuerySubspacesRequest = {
  typeUrl: "/cosmos.params.v1beta1.QuerySubspacesRequest",
  encode: function encode(_) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _binary.BinaryWriter.create();
    return writer;
  },
  fromJSON: function fromJSON(_) {
    return {};
  },
  fromPartial: function fromPartial(_) {
    var message = createBaseQuerySubspacesRequest();
    return message;
  },
  fromAmino: function fromAmino(_) {
    var message = createBaseQuerySubspacesRequest();
    return message;
  },
  toAmino: function toAmino(_) {
    var obj = {};
    return obj;
  },
  fromAminoMsg: function fromAminoMsg(object) {
    return QuerySubspacesRequest.fromAmino(object.value);
  },
  toAminoMsg: function toAminoMsg(message) {
    return {
      type: "cosmos-sdk/QuerySubspacesRequest",
      value: QuerySubspacesRequest.toAmino(message)
    };
  },
  fromProtoMsg: function fromProtoMsg(message) {
    return QuerySubspacesRequest.decode(message.value);
  },
  toProto: function toProto(message) {
    return QuerySubspacesRequest.encode(message).finish();
  },
  toProtoMsg: function toProtoMsg(message) {
    return {
      typeUrl: "/cosmos.params.v1beta1.QuerySubspacesRequest",
      value: QuerySubspacesRequest.encode(message).finish()
    };
  }
};
function createBaseQuerySubspacesResponse() {
  return {
    subspaces: []
  };
}
var QuerySubspacesResponse = exports.QuerySubspacesResponse = {
  typeUrl: "/cosmos.params.v1beta1.QuerySubspacesResponse",
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _binary.BinaryWriter.create();
    var _iterator = _createForOfIteratorHelper(message.subspaces),
      _step;
    try {
      for (_iterator.s(); !(_step = _iterator.n()).done;) {
        var v = _step.value;
        Subspace.encode(v, writer.uint32(10).fork()).ldelim();
      }
    } catch (err) {
      _iterator.e(err);
    } finally {
      _iterator.f();
    }
    return writer;
  },
  fromJSON: function fromJSON(object) {
    return {
      subspaces: Array.isArray(object === null || object === void 0 ? void 0 : object.subspaces) ? object.subspaces.map(function (e) {
        return Subspace.fromJSON(e);
      }) : []
    };
  },
  fromPartial: function fromPartial(object) {
    var _object$subspaces;
    var message = createBaseQuerySubspacesResponse();
    message.subspaces = ((_object$subspaces = object.subspaces) === null || _object$subspaces === void 0 ? void 0 : _object$subspaces.map(function (e) {
      return Subspace.fromPartial(e);
    })) || [];
    return message;
  },
  fromAmino: function fromAmino(object) {
    var _object$subspaces2;
    var message = createBaseQuerySubspacesResponse();
    message.subspaces = ((_object$subspaces2 = object.subspaces) === null || _object$subspaces2 === void 0 ? void 0 : _object$subspaces2.map(function (e) {
      return Subspace.fromAmino(e);
    })) || [];
    return message;
  },
  toAmino: function toAmino(message) {
    var obj = {};
    if (message.subspaces) {
      obj.subspaces = message.subspaces.map(function (e) {
        return e ? Subspace.toAmino(e) : undefined;
      });
    } else {
      obj.subspaces = message.subspaces;
    }
    return obj;
  },
  fromAminoMsg: function fromAminoMsg(object) {
    return QuerySubspacesResponse.fromAmino(object.value);
  },
  toAminoMsg: function toAminoMsg(message) {
    return {
      type: "cosmos-sdk/QuerySubspacesResponse",
      value: QuerySubspacesResponse.toAmino(message)
    };
  },
  fromProtoMsg: function fromProtoMsg(message) {
    return QuerySubspacesResponse.decode(message.value);
  },
  toProto: function toProto(message) {
    return QuerySubspacesResponse.encode(message).finish();
  },
  toProtoMsg: function toProtoMsg(message) {
    return {
      typeUrl: "/cosmos.params.v1beta1.QuerySubspacesResponse",
      value: QuerySubspacesResponse.encode(message).finish()
    };
  }
};
function createBaseSubspace() {
  return {
    subspace: "",
    keys: []
  };
}
var Subspace = exports.Subspace = {
  typeUrl: "/cosmos.params.v1beta1.Subspace",
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _binary.BinaryWriter.create();
    if (message.subspace !== "") {
      writer.uint32(10).string(message.subspace);
    }
    var _iterator2 = _createForOfIteratorHelper(message.keys),
      _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;
  },
  fromJSON: function fromJSON(object) {
    return {
      subspace: (0, _helpers.isSet)(object.subspace) ? String(object.subspace) : "",
      keys: Array.isArray(object === null || object === void 0 ? void 0 : object.keys) ? object.keys.map(function (e) {
        return String(e);
      }) : []
    };
  },
  fromPartial: function fromPartial(object) {
    var _object$subspace2, _object$keys;
    var message = createBaseSubspace();
    message.subspace = (_object$subspace2 = object.subspace) !== null && _object$subspace2 !== void 0 ? _object$subspace2 : "";
    message.keys = ((_object$keys = object.keys) === null || _object$keys === void 0 ? void 0 : _object$keys.map(function (e) {
      return e;
    })) || [];
    return message;
  },
  fromAmino: function fromAmino(object) {
    var _object$keys2;
    var message = createBaseSubspace();
    if (object.subspace !== undefined && object.subspace !== null) {
      message.subspace = object.subspace;
    }
    message.keys = ((_object$keys2 = object.keys) === null || _object$keys2 === void 0 ? void 0 : _object$keys2.map(function (e) {
      return e;
    })) || [];
    return message;
  },
  toAmino: function toAmino(message) {
    var obj = {};
    obj.subspace = message.subspace === "" ? undefined : message.subspace;
    if (message.keys) {
      obj.keys = message.keys.map(function (e) {
        return e;
      });
    } else {
      obj.keys = message.keys;
    }
    return obj;
  },
  fromAminoMsg: function fromAminoMsg(object) {
    return Subspace.fromAmino(object.value);
  },
  toAminoMsg: function toAminoMsg(message) {
    return {
      type: "cosmos-sdk/Subspace",
      value: Subspace.toAmino(message)
    };
  },
  fromProtoMsg: function fromProtoMsg(message) {
    return Subspace.decode(message.value);
  },
  toProto: function toProto(message) {
    return Subspace.encode(message).finish();
  },
  toProtoMsg: function toProtoMsg(message) {
    return {
      typeUrl: "/cosmos.params.v1beta1.Subspace",
      value: Subspace.encode(message).finish()
    };
  }
};