diff --git a/packages/dapi-grpc/build.rs b/packages/dapi-grpc/build.rs index 0abcf5c99c2..45609eb10b1 100644 --- a/packages/dapi-grpc/build.rs +++ b/packages/dapi-grpc/build.rs @@ -84,10 +84,11 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig { // Derive features for versioned messages // // "GetConsensusParamsRequest" is excluded as this message does not support proofs - const VERSIONED_REQUESTS: [&str; 56] = [ + const VERSIONED_REQUESTS: [&str; 57] = [ "GetDataContractHistoryRequest", "GetDataContractRequest", "GetDataContractsRequest", + "GetDocumentHistoryRequest", "GetDocumentsRequest", "GetIdentitiesByPublicKeyHashesRequest", "GetIdentitiesRequest", @@ -161,10 +162,11 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig { // - "GetIdentityByNonUniquePublicKeyHashResponse" // // "GetEvonodesProposedEpochBlocksResponse" is used for 2 Requests - const VERSIONED_RESPONSES: [&str; 54] = [ + const VERSIONED_RESPONSES: [&str; 55] = [ "GetDataContractHistoryResponse", "GetDataContractResponse", "GetDataContractsResponse", + "GetDocumentHistoryResponse", "GetDocumentsResponse", "GetIdentitiesByPublicKeyHashesResponse", "GetIdentitiesResponse", diff --git a/packages/dapi-grpc/clients/drive/v0/nodejs/drive_pbjs.js b/packages/dapi-grpc/clients/drive/v0/nodejs/drive_pbjs.js index 5899464a2db..363f1a21de7 100644 --- a/packages/dapi-grpc/clients/drive/v0/nodejs/drive_pbjs.js +++ b/packages/dapi-grpc/clients/drive/v0/nodejs/drive_pbjs.js @@ -1056,6 +1056,39 @@ $root.org = (function() { * @variation 2 */ + /** + * Callback as used by {@link org.dash.platform.dapi.v0.Platform#getDocumentHistory}. + * @memberof org.dash.platform.dapi.v0.Platform + * @typedef getDocumentHistoryCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse} [response] GetDocumentHistoryResponse + */ + + /** + * Calls getDocumentHistory. + * @function getDocumentHistory + * @memberof org.dash.platform.dapi.v0.Platform + * @instance + * @param {org.dash.platform.dapi.v0.IGetDocumentHistoryRequest} request GetDocumentHistoryRequest message or plain object + * @param {org.dash.platform.dapi.v0.Platform.getDocumentHistoryCallback} callback Node-style callback called with the error, if any, and GetDocumentHistoryResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Platform.prototype.getDocumentHistory = function getDocumentHistory(request, callback) { + return this.rpcCall(getDocumentHistory, $root.org.dash.platform.dapi.v0.GetDocumentHistoryRequest, $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse, request, callback); + }, "name", { value: "getDocumentHistory" }); + + /** + * Calls getDocumentHistory. + * @function getDocumentHistory + * @memberof org.dash.platform.dapi.v0.Platform + * @instance + * @param {org.dash.platform.dapi.v0.IGetDocumentHistoryRequest} request GetDocumentHistoryRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + /** * Callback as used by {@link org.dash.platform.dapi.v0.Platform#getDocuments}. * @memberof org.dash.platform.dapi.v0.Platform @@ -27401,6 +27434,1504 @@ $root.org = (function() { return GetDocumentsResponse; })(); + v0.GetDocumentHistoryRequest = (function() { + + /** + * Properties of a GetDocumentHistoryRequest. + * @memberof org.dash.platform.dapi.v0 + * @interface IGetDocumentHistoryRequest + * @property {org.dash.platform.dapi.v0.GetDocumentHistoryRequest.IGetDocumentHistoryRequestV0|null} [v0] GetDocumentHistoryRequest v0 + */ + + /** + * Constructs a new GetDocumentHistoryRequest. + * @memberof org.dash.platform.dapi.v0 + * @classdesc Represents a GetDocumentHistoryRequest. + * @implements IGetDocumentHistoryRequest + * @constructor + * @param {org.dash.platform.dapi.v0.IGetDocumentHistoryRequest=} [properties] Properties to set + */ + function GetDocumentHistoryRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetDocumentHistoryRequest v0. + * @member {org.dash.platform.dapi.v0.GetDocumentHistoryRequest.IGetDocumentHistoryRequestV0|null|undefined} v0 + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest + * @instance + */ + GetDocumentHistoryRequest.prototype.v0 = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * GetDocumentHistoryRequest version. + * @member {"v0"|undefined} version + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest + * @instance + */ + Object.defineProperty(GetDocumentHistoryRequest.prototype, "version", { + get: $util.oneOfGetter($oneOfFields = ["v0"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new GetDocumentHistoryRequest instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest + * @static + * @param {org.dash.platform.dapi.v0.IGetDocumentHistoryRequest=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryRequest} GetDocumentHistoryRequest instance + */ + GetDocumentHistoryRequest.create = function create(properties) { + return new GetDocumentHistoryRequest(properties); + }; + + /** + * Encodes the specified GetDocumentHistoryRequest message. Does not implicitly {@link org.dash.platform.dapi.v0.GetDocumentHistoryRequest.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest + * @static + * @param {org.dash.platform.dapi.v0.IGetDocumentHistoryRequest} message GetDocumentHistoryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDocumentHistoryRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.v0 != null && Object.hasOwnProperty.call(message, "v0")) + $root.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.encode(message.v0, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified GetDocumentHistoryRequest message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetDocumentHistoryRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest + * @static + * @param {org.dash.platform.dapi.v0.IGetDocumentHistoryRequest} message GetDocumentHistoryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDocumentHistoryRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetDocumentHistoryRequest message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryRequest} GetDocumentHistoryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDocumentHistoryRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetDocumentHistoryRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.v0 = $root.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetDocumentHistoryRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryRequest} GetDocumentHistoryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDocumentHistoryRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetDocumentHistoryRequest message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetDocumentHistoryRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.v0 != null && message.hasOwnProperty("v0")) { + properties.version = 1; + { + var error = $root.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.verify(message.v0); + if (error) + return "v0." + error; + } + } + return null; + }; + + /** + * Creates a GetDocumentHistoryRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryRequest} GetDocumentHistoryRequest + */ + GetDocumentHistoryRequest.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetDocumentHistoryRequest) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetDocumentHistoryRequest(); + if (object.v0 != null) { + if (typeof object.v0 !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetDocumentHistoryRequest.v0: object expected"); + message.v0 = $root.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.fromObject(object.v0); + } + return message; + }; + + /** + * Creates a plain object from a GetDocumentHistoryRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryRequest} message GetDocumentHistoryRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetDocumentHistoryRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.v0 != null && message.hasOwnProperty("v0")) { + object.v0 = $root.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.toObject(message.v0, options); + if (options.oneofs) + object.version = "v0"; + } + return object; + }; + + /** + * Converts this GetDocumentHistoryRequest to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest + * @instance + * @returns {Object.} JSON object + */ + GetDocumentHistoryRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 = (function() { + + /** + * Properties of a GetDocumentHistoryRequestV0. + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest + * @interface IGetDocumentHistoryRequestV0 + * @property {Uint8Array|null} [dataContractId] GetDocumentHistoryRequestV0 dataContractId + * @property {string|null} [documentTypeName] GetDocumentHistoryRequestV0 documentTypeName + * @property {Uint8Array|null} [documentId] GetDocumentHistoryRequestV0 documentId + * @property {google.protobuf.IUInt32Value|null} [limit] GetDocumentHistoryRequestV0 limit + * @property {google.protobuf.IUInt32Value|null} [offset] GetDocumentHistoryRequestV0 offset + * @property {number|Long|null} [startAtMs] GetDocumentHistoryRequestV0 startAtMs + * @property {boolean|null} [prove] GetDocumentHistoryRequestV0 prove + */ + + /** + * Constructs a new GetDocumentHistoryRequestV0. + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest + * @classdesc Represents a GetDocumentHistoryRequestV0. + * @implements IGetDocumentHistoryRequestV0 + * @constructor + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryRequest.IGetDocumentHistoryRequestV0=} [properties] Properties to set + */ + function GetDocumentHistoryRequestV0(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetDocumentHistoryRequestV0 dataContractId. + * @member {Uint8Array} dataContractId + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @instance + */ + GetDocumentHistoryRequestV0.prototype.dataContractId = $util.newBuffer([]); + + /** + * GetDocumentHistoryRequestV0 documentTypeName. + * @member {string} documentTypeName + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @instance + */ + GetDocumentHistoryRequestV0.prototype.documentTypeName = ""; + + /** + * GetDocumentHistoryRequestV0 documentId. + * @member {Uint8Array} documentId + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @instance + */ + GetDocumentHistoryRequestV0.prototype.documentId = $util.newBuffer([]); + + /** + * GetDocumentHistoryRequestV0 limit. + * @member {google.protobuf.IUInt32Value|null|undefined} limit + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @instance + */ + GetDocumentHistoryRequestV0.prototype.limit = null; + + /** + * GetDocumentHistoryRequestV0 offset. + * @member {google.protobuf.IUInt32Value|null|undefined} offset + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @instance + */ + GetDocumentHistoryRequestV0.prototype.offset = null; + + /** + * GetDocumentHistoryRequestV0 startAtMs. + * @member {number|Long} startAtMs + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @instance + */ + GetDocumentHistoryRequestV0.prototype.startAtMs = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * GetDocumentHistoryRequestV0 prove. + * @member {boolean} prove + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @instance + */ + GetDocumentHistoryRequestV0.prototype.prove = false; + + /** + * Creates a new GetDocumentHistoryRequestV0 instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryRequest.IGetDocumentHistoryRequestV0=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} GetDocumentHistoryRequestV0 instance + */ + GetDocumentHistoryRequestV0.create = function create(properties) { + return new GetDocumentHistoryRequestV0(properties); + }; + + /** + * Encodes the specified GetDocumentHistoryRequestV0 message. Does not implicitly {@link org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryRequest.IGetDocumentHistoryRequestV0} message GetDocumentHistoryRequestV0 message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDocumentHistoryRequestV0.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.dataContractId != null && Object.hasOwnProperty.call(message, "dataContractId")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.dataContractId); + if (message.documentTypeName != null && Object.hasOwnProperty.call(message, "documentTypeName")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.documentTypeName); + if (message.documentId != null && Object.hasOwnProperty.call(message, "documentId")) + writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.documentId); + if (message.limit != null && Object.hasOwnProperty.call(message, "limit")) + $root.google.protobuf.UInt32Value.encode(message.limit, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.offset != null && Object.hasOwnProperty.call(message, "offset")) + $root.google.protobuf.UInt32Value.encode(message.offset, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.startAtMs != null && Object.hasOwnProperty.call(message, "startAtMs")) + writer.uint32(/* id 6, wireType 0 =*/48).uint64(message.startAtMs); + if (message.prove != null && Object.hasOwnProperty.call(message, "prove")) + writer.uint32(/* id 7, wireType 0 =*/56).bool(message.prove); + return writer; + }; + + /** + * Encodes the specified GetDocumentHistoryRequestV0 message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryRequest.IGetDocumentHistoryRequestV0} message GetDocumentHistoryRequestV0 message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDocumentHistoryRequestV0.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetDocumentHistoryRequestV0 message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} GetDocumentHistoryRequestV0 + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDocumentHistoryRequestV0.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.dataContractId = reader.bytes(); + break; + case 2: + message.documentTypeName = reader.string(); + break; + case 3: + message.documentId = reader.bytes(); + break; + case 4: + message.limit = $root.google.protobuf.UInt32Value.decode(reader, reader.uint32()); + break; + case 5: + message.offset = $root.google.protobuf.UInt32Value.decode(reader, reader.uint32()); + break; + case 6: + message.startAtMs = reader.uint64(); + break; + case 7: + message.prove = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetDocumentHistoryRequestV0 message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} GetDocumentHistoryRequestV0 + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDocumentHistoryRequestV0.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetDocumentHistoryRequestV0 message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetDocumentHistoryRequestV0.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.dataContractId != null && message.hasOwnProperty("dataContractId")) + if (!(message.dataContractId && typeof message.dataContractId.length === "number" || $util.isString(message.dataContractId))) + return "dataContractId: buffer expected"; + if (message.documentTypeName != null && message.hasOwnProperty("documentTypeName")) + if (!$util.isString(message.documentTypeName)) + return "documentTypeName: string expected"; + if (message.documentId != null && message.hasOwnProperty("documentId")) + if (!(message.documentId && typeof message.documentId.length === "number" || $util.isString(message.documentId))) + return "documentId: buffer expected"; + if (message.limit != null && message.hasOwnProperty("limit")) { + var error = $root.google.protobuf.UInt32Value.verify(message.limit); + if (error) + return "limit." + error; + } + if (message.offset != null && message.hasOwnProperty("offset")) { + var error = $root.google.protobuf.UInt32Value.verify(message.offset); + if (error) + return "offset." + error; + } + if (message.startAtMs != null && message.hasOwnProperty("startAtMs")) + if (!$util.isInteger(message.startAtMs) && !(message.startAtMs && $util.isInteger(message.startAtMs.low) && $util.isInteger(message.startAtMs.high))) + return "startAtMs: integer|Long expected"; + if (message.prove != null && message.hasOwnProperty("prove")) + if (typeof message.prove !== "boolean") + return "prove: boolean expected"; + return null; + }; + + /** + * Creates a GetDocumentHistoryRequestV0 message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} GetDocumentHistoryRequestV0 + */ + GetDocumentHistoryRequestV0.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0(); + if (object.dataContractId != null) + if (typeof object.dataContractId === "string") + $util.base64.decode(object.dataContractId, message.dataContractId = $util.newBuffer($util.base64.length(object.dataContractId)), 0); + else if (object.dataContractId.length >= 0) + message.dataContractId = object.dataContractId; + if (object.documentTypeName != null) + message.documentTypeName = String(object.documentTypeName); + if (object.documentId != null) + if (typeof object.documentId === "string") + $util.base64.decode(object.documentId, message.documentId = $util.newBuffer($util.base64.length(object.documentId)), 0); + else if (object.documentId.length >= 0) + message.documentId = object.documentId; + if (object.limit != null) { + if (typeof object.limit !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.limit: object expected"); + message.limit = $root.google.protobuf.UInt32Value.fromObject(object.limit); + } + if (object.offset != null) { + if (typeof object.offset !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.offset: object expected"); + message.offset = $root.google.protobuf.UInt32Value.fromObject(object.offset); + } + if (object.startAtMs != null) + if ($util.Long) + (message.startAtMs = $util.Long.fromValue(object.startAtMs)).unsigned = true; + else if (typeof object.startAtMs === "string") + message.startAtMs = parseInt(object.startAtMs, 10); + else if (typeof object.startAtMs === "number") + message.startAtMs = object.startAtMs; + else if (typeof object.startAtMs === "object") + message.startAtMs = new $util.LongBits(object.startAtMs.low >>> 0, object.startAtMs.high >>> 0).toNumber(true); + if (object.prove != null) + message.prove = Boolean(object.prove); + return message; + }; + + /** + * Creates a plain object from a GetDocumentHistoryRequestV0 message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} message GetDocumentHistoryRequestV0 + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetDocumentHistoryRequestV0.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if (options.bytes === String) + object.dataContractId = ""; + else { + object.dataContractId = []; + if (options.bytes !== Array) + object.dataContractId = $util.newBuffer(object.dataContractId); + } + object.documentTypeName = ""; + if (options.bytes === String) + object.documentId = ""; + else { + object.documentId = []; + if (options.bytes !== Array) + object.documentId = $util.newBuffer(object.documentId); + } + object.limit = null; + object.offset = null; + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.startAtMs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.startAtMs = options.longs === String ? "0" : 0; + object.prove = false; + } + if (message.dataContractId != null && message.hasOwnProperty("dataContractId")) + object.dataContractId = options.bytes === String ? $util.base64.encode(message.dataContractId, 0, message.dataContractId.length) : options.bytes === Array ? Array.prototype.slice.call(message.dataContractId) : message.dataContractId; + if (message.documentTypeName != null && message.hasOwnProperty("documentTypeName")) + object.documentTypeName = message.documentTypeName; + if (message.documentId != null && message.hasOwnProperty("documentId")) + object.documentId = options.bytes === String ? $util.base64.encode(message.documentId, 0, message.documentId.length) : options.bytes === Array ? Array.prototype.slice.call(message.documentId) : message.documentId; + if (message.limit != null && message.hasOwnProperty("limit")) + object.limit = $root.google.protobuf.UInt32Value.toObject(message.limit, options); + if (message.offset != null && message.hasOwnProperty("offset")) + object.offset = $root.google.protobuf.UInt32Value.toObject(message.offset, options); + if (message.startAtMs != null && message.hasOwnProperty("startAtMs")) + if (typeof message.startAtMs === "number") + object.startAtMs = options.longs === String ? String(message.startAtMs) : message.startAtMs; + else + object.startAtMs = options.longs === String ? $util.Long.prototype.toString.call(message.startAtMs) : options.longs === Number ? new $util.LongBits(message.startAtMs.low >>> 0, message.startAtMs.high >>> 0).toNumber(true) : message.startAtMs; + if (message.prove != null && message.hasOwnProperty("prove")) + object.prove = message.prove; + return object; + }; + + /** + * Converts this GetDocumentHistoryRequestV0 to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @instance + * @returns {Object.} JSON object + */ + GetDocumentHistoryRequestV0.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return GetDocumentHistoryRequestV0; + })(); + + return GetDocumentHistoryRequest; + })(); + + v0.GetDocumentHistoryResponse = (function() { + + /** + * Properties of a GetDocumentHistoryResponse. + * @memberof org.dash.platform.dapi.v0 + * @interface IGetDocumentHistoryResponse + * @property {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.IGetDocumentHistoryResponseV0|null} [v0] GetDocumentHistoryResponse v0 + */ + + /** + * Constructs a new GetDocumentHistoryResponse. + * @memberof org.dash.platform.dapi.v0 + * @classdesc Represents a GetDocumentHistoryResponse. + * @implements IGetDocumentHistoryResponse + * @constructor + * @param {org.dash.platform.dapi.v0.IGetDocumentHistoryResponse=} [properties] Properties to set + */ + function GetDocumentHistoryResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetDocumentHistoryResponse v0. + * @member {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.IGetDocumentHistoryResponseV0|null|undefined} v0 + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse + * @instance + */ + GetDocumentHistoryResponse.prototype.v0 = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * GetDocumentHistoryResponse version. + * @member {"v0"|undefined} version + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse + * @instance + */ + Object.defineProperty(GetDocumentHistoryResponse.prototype, "version", { + get: $util.oneOfGetter($oneOfFields = ["v0"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new GetDocumentHistoryResponse instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse + * @static + * @param {org.dash.platform.dapi.v0.IGetDocumentHistoryResponse=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse} GetDocumentHistoryResponse instance + */ + GetDocumentHistoryResponse.create = function create(properties) { + return new GetDocumentHistoryResponse(properties); + }; + + /** + * Encodes the specified GetDocumentHistoryResponse message. Does not implicitly {@link org.dash.platform.dapi.v0.GetDocumentHistoryResponse.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse + * @static + * @param {org.dash.platform.dapi.v0.IGetDocumentHistoryResponse} message GetDocumentHistoryResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDocumentHistoryResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.v0 != null && Object.hasOwnProperty.call(message, "v0")) + $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.encode(message.v0, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified GetDocumentHistoryResponse message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetDocumentHistoryResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse + * @static + * @param {org.dash.platform.dapi.v0.IGetDocumentHistoryResponse} message GetDocumentHistoryResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDocumentHistoryResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetDocumentHistoryResponse message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse} GetDocumentHistoryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDocumentHistoryResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.v0 = $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetDocumentHistoryResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse} GetDocumentHistoryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDocumentHistoryResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetDocumentHistoryResponse message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetDocumentHistoryResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.v0 != null && message.hasOwnProperty("v0")) { + properties.version = 1; + { + var error = $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.verify(message.v0); + if (error) + return "v0." + error; + } + } + return null; + }; + + /** + * Creates a GetDocumentHistoryResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse} GetDocumentHistoryResponse + */ + GetDocumentHistoryResponse.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse(); + if (object.v0 != null) { + if (typeof object.v0 !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetDocumentHistoryResponse.v0: object expected"); + message.v0 = $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.fromObject(object.v0); + } + return message; + }; + + /** + * Creates a plain object from a GetDocumentHistoryResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse} message GetDocumentHistoryResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetDocumentHistoryResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.v0 != null && message.hasOwnProperty("v0")) { + object.v0 = $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.toObject(message.v0, options); + if (options.oneofs) + object.version = "v0"; + } + return object; + }; + + /** + * Converts this GetDocumentHistoryResponse to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse + * @instance + * @returns {Object.} JSON object + */ + GetDocumentHistoryResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 = (function() { + + /** + * Properties of a GetDocumentHistoryResponseV0. + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse + * @interface IGetDocumentHistoryResponseV0 + * @property {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.IDocumentHistory|null} [documentHistory] GetDocumentHistoryResponseV0 documentHistory + * @property {org.dash.platform.dapi.v0.IProof|null} [proof] GetDocumentHistoryResponseV0 proof + * @property {org.dash.platform.dapi.v0.IResponseMetadata|null} [metadata] GetDocumentHistoryResponseV0 metadata + */ + + /** + * Constructs a new GetDocumentHistoryResponseV0. + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse + * @classdesc Represents a GetDocumentHistoryResponseV0. + * @implements IGetDocumentHistoryResponseV0 + * @constructor + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.IGetDocumentHistoryResponseV0=} [properties] Properties to set + */ + function GetDocumentHistoryResponseV0(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetDocumentHistoryResponseV0 documentHistory. + * @member {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.IDocumentHistory|null|undefined} documentHistory + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @instance + */ + GetDocumentHistoryResponseV0.prototype.documentHistory = null; + + /** + * GetDocumentHistoryResponseV0 proof. + * @member {org.dash.platform.dapi.v0.IProof|null|undefined} proof + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @instance + */ + GetDocumentHistoryResponseV0.prototype.proof = null; + + /** + * GetDocumentHistoryResponseV0 metadata. + * @member {org.dash.platform.dapi.v0.IResponseMetadata|null|undefined} metadata + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @instance + */ + GetDocumentHistoryResponseV0.prototype.metadata = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * GetDocumentHistoryResponseV0 result. + * @member {"documentHistory"|"proof"|undefined} result + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @instance + */ + Object.defineProperty(GetDocumentHistoryResponseV0.prototype, "result", { + get: $util.oneOfGetter($oneOfFields = ["documentHistory", "proof"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new GetDocumentHistoryResponseV0 instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.IGetDocumentHistoryResponseV0=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} GetDocumentHistoryResponseV0 instance + */ + GetDocumentHistoryResponseV0.create = function create(properties) { + return new GetDocumentHistoryResponseV0(properties); + }; + + /** + * Encodes the specified GetDocumentHistoryResponseV0 message. Does not implicitly {@link org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.IGetDocumentHistoryResponseV0} message GetDocumentHistoryResponseV0 message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDocumentHistoryResponseV0.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.documentHistory != null && Object.hasOwnProperty.call(message, "documentHistory")) + $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.encode(message.documentHistory, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.proof != null && Object.hasOwnProperty.call(message, "proof")) + $root.org.dash.platform.dapi.v0.Proof.encode(message.proof, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.metadata != null && Object.hasOwnProperty.call(message, "metadata")) + $root.org.dash.platform.dapi.v0.ResponseMetadata.encode(message.metadata, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified GetDocumentHistoryResponseV0 message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.IGetDocumentHistoryResponseV0} message GetDocumentHistoryResponseV0 message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDocumentHistoryResponseV0.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetDocumentHistoryResponseV0 message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} GetDocumentHistoryResponseV0 + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDocumentHistoryResponseV0.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.documentHistory = $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.decode(reader, reader.uint32()); + break; + case 2: + message.proof = $root.org.dash.platform.dapi.v0.Proof.decode(reader, reader.uint32()); + break; + case 3: + message.metadata = $root.org.dash.platform.dapi.v0.ResponseMetadata.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetDocumentHistoryResponseV0 message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} GetDocumentHistoryResponseV0 + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDocumentHistoryResponseV0.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetDocumentHistoryResponseV0 message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetDocumentHistoryResponseV0.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.documentHistory != null && message.hasOwnProperty("documentHistory")) { + properties.result = 1; + { + var error = $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.verify(message.documentHistory); + if (error) + return "documentHistory." + error; + } + } + if (message.proof != null && message.hasOwnProperty("proof")) { + if (properties.result === 1) + return "result: multiple values"; + properties.result = 1; + { + var error = $root.org.dash.platform.dapi.v0.Proof.verify(message.proof); + if (error) + return "proof." + error; + } + } + if (message.metadata != null && message.hasOwnProperty("metadata")) { + var error = $root.org.dash.platform.dapi.v0.ResponseMetadata.verify(message.metadata); + if (error) + return "metadata." + error; + } + return null; + }; + + /** + * Creates a GetDocumentHistoryResponseV0 message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} GetDocumentHistoryResponseV0 + */ + GetDocumentHistoryResponseV0.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0(); + if (object.documentHistory != null) { + if (typeof object.documentHistory !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.documentHistory: object expected"); + message.documentHistory = $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.fromObject(object.documentHistory); + } + if (object.proof != null) { + if (typeof object.proof !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.proof: object expected"); + message.proof = $root.org.dash.platform.dapi.v0.Proof.fromObject(object.proof); + } + if (object.metadata != null) { + if (typeof object.metadata !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.metadata: object expected"); + message.metadata = $root.org.dash.platform.dapi.v0.ResponseMetadata.fromObject(object.metadata); + } + return message; + }; + + /** + * Creates a plain object from a GetDocumentHistoryResponseV0 message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} message GetDocumentHistoryResponseV0 + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetDocumentHistoryResponseV0.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.metadata = null; + if (message.documentHistory != null && message.hasOwnProperty("documentHistory")) { + object.documentHistory = $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.toObject(message.documentHistory, options); + if (options.oneofs) + object.result = "documentHistory"; + } + if (message.proof != null && message.hasOwnProperty("proof")) { + object.proof = $root.org.dash.platform.dapi.v0.Proof.toObject(message.proof, options); + if (options.oneofs) + object.result = "proof"; + } + if (message.metadata != null && message.hasOwnProperty("metadata")) + object.metadata = $root.org.dash.platform.dapi.v0.ResponseMetadata.toObject(message.metadata, options); + return object; + }; + + /** + * Converts this GetDocumentHistoryResponseV0 to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @instance + * @returns {Object.} JSON object + */ + GetDocumentHistoryResponseV0.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + GetDocumentHistoryResponseV0.DocumentHistoryEntry = (function() { + + /** + * Properties of a DocumentHistoryEntry. + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @interface IDocumentHistoryEntry + * @property {number|Long|null} [date] DocumentHistoryEntry date + * @property {Uint8Array|null} [value] DocumentHistoryEntry value + */ + + /** + * Constructs a new DocumentHistoryEntry. + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @classdesc Represents a DocumentHistoryEntry. + * @implements IDocumentHistoryEntry + * @constructor + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.IDocumentHistoryEntry=} [properties] Properties to set + */ + function DocumentHistoryEntry(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DocumentHistoryEntry date. + * @member {number|Long} date + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry + * @instance + */ + DocumentHistoryEntry.prototype.date = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * DocumentHistoryEntry value. + * @member {Uint8Array} value + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry + * @instance + */ + DocumentHistoryEntry.prototype.value = $util.newBuffer([]); + + /** + * Creates a new DocumentHistoryEntry instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.IDocumentHistoryEntry=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry} DocumentHistoryEntry instance + */ + DocumentHistoryEntry.create = function create(properties) { + return new DocumentHistoryEntry(properties); + }; + + /** + * Encodes the specified DocumentHistoryEntry message. Does not implicitly {@link org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.IDocumentHistoryEntry} message DocumentHistoryEntry message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DocumentHistoryEntry.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.date != null && Object.hasOwnProperty.call(message, "date")) + writer.uint32(/* id 1, wireType 0 =*/8).uint64(message.date); + if (message.value != null && Object.hasOwnProperty.call(message, "value")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.value); + return writer; + }; + + /** + * Encodes the specified DocumentHistoryEntry message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.IDocumentHistoryEntry} message DocumentHistoryEntry message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DocumentHistoryEntry.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DocumentHistoryEntry message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry} DocumentHistoryEntry + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DocumentHistoryEntry.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.date = reader.uint64(); + break; + case 2: + message.value = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DocumentHistoryEntry message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry} DocumentHistoryEntry + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DocumentHistoryEntry.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DocumentHistoryEntry message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DocumentHistoryEntry.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.date != null && message.hasOwnProperty("date")) + if (!$util.isInteger(message.date) && !(message.date && $util.isInteger(message.date.low) && $util.isInteger(message.date.high))) + return "date: integer|Long expected"; + if (message.value != null && message.hasOwnProperty("value")) + if (!(message.value && typeof message.value.length === "number" || $util.isString(message.value))) + return "value: buffer expected"; + return null; + }; + + /** + * Creates a DocumentHistoryEntry message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry} DocumentHistoryEntry + */ + DocumentHistoryEntry.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry(); + if (object.date != null) + if ($util.Long) + (message.date = $util.Long.fromValue(object.date)).unsigned = true; + else if (typeof object.date === "string") + message.date = parseInt(object.date, 10); + else if (typeof object.date === "number") + message.date = object.date; + else if (typeof object.date === "object") + message.date = new $util.LongBits(object.date.low >>> 0, object.date.high >>> 0).toNumber(true); + if (object.value != null) + if (typeof object.value === "string") + $util.base64.decode(object.value, message.value = $util.newBuffer($util.base64.length(object.value)), 0); + else if (object.value.length >= 0) + message.value = object.value; + return message; + }; + + /** + * Creates a plain object from a DocumentHistoryEntry message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry} message DocumentHistoryEntry + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DocumentHistoryEntry.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.date = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.date = options.longs === String ? "0" : 0; + if (options.bytes === String) + object.value = ""; + else { + object.value = []; + if (options.bytes !== Array) + object.value = $util.newBuffer(object.value); + } + } + if (message.date != null && message.hasOwnProperty("date")) + if (typeof message.date === "number") + object.date = options.longs === String ? String(message.date) : message.date; + else + object.date = options.longs === String ? $util.Long.prototype.toString.call(message.date) : options.longs === Number ? new $util.LongBits(message.date.low >>> 0, message.date.high >>> 0).toNumber(true) : message.date; + if (message.value != null && message.hasOwnProperty("value")) + object.value = options.bytes === String ? $util.base64.encode(message.value, 0, message.value.length) : options.bytes === Array ? Array.prototype.slice.call(message.value) : message.value; + return object; + }; + + /** + * Converts this DocumentHistoryEntry to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry + * @instance + * @returns {Object.} JSON object + */ + DocumentHistoryEntry.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DocumentHistoryEntry; + })(); + + GetDocumentHistoryResponseV0.DocumentHistory = (function() { + + /** + * Properties of a DocumentHistory. + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @interface IDocumentHistory + * @property {Array.|null} [documentEntries] DocumentHistory documentEntries + */ + + /** + * Constructs a new DocumentHistory. + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @classdesc Represents a DocumentHistory. + * @implements IDocumentHistory + * @constructor + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.IDocumentHistory=} [properties] Properties to set + */ + function DocumentHistory(properties) { + this.documentEntries = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DocumentHistory documentEntries. + * @member {Array.} documentEntries + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory + * @instance + */ + DocumentHistory.prototype.documentEntries = $util.emptyArray; + + /** + * Creates a new DocumentHistory instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.IDocumentHistory=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory} DocumentHistory instance + */ + DocumentHistory.create = function create(properties) { + return new DocumentHistory(properties); + }; + + /** + * Encodes the specified DocumentHistory message. Does not implicitly {@link org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.IDocumentHistory} message DocumentHistory message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DocumentHistory.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.documentEntries != null && message.documentEntries.length) + for (var i = 0; i < message.documentEntries.length; ++i) + $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.encode(message.documentEntries[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified DocumentHistory message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.IDocumentHistory} message DocumentHistory message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DocumentHistory.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DocumentHistory message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory} DocumentHistory + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DocumentHistory.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.documentEntries && message.documentEntries.length)) + message.documentEntries = []; + message.documentEntries.push($root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DocumentHistory message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory} DocumentHistory + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DocumentHistory.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DocumentHistory message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DocumentHistory.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.documentEntries != null && message.hasOwnProperty("documentEntries")) { + if (!Array.isArray(message.documentEntries)) + return "documentEntries: array expected"; + for (var i = 0; i < message.documentEntries.length; ++i) { + var error = $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.verify(message.documentEntries[i]); + if (error) + return "documentEntries." + error; + } + } + return null; + }; + + /** + * Creates a DocumentHistory message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory} DocumentHistory + */ + DocumentHistory.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory(); + if (object.documentEntries) { + if (!Array.isArray(object.documentEntries)) + throw TypeError(".org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.documentEntries: array expected"); + message.documentEntries = []; + for (var i = 0; i < object.documentEntries.length; ++i) { + if (typeof object.documentEntries[i] !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.documentEntries: object expected"); + message.documentEntries[i] = $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.fromObject(object.documentEntries[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a DocumentHistory message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory} message DocumentHistory + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DocumentHistory.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.documentEntries = []; + if (message.documentEntries && message.documentEntries.length) { + object.documentEntries = []; + for (var j = 0; j < message.documentEntries.length; ++j) + object.documentEntries[j] = $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.toObject(message.documentEntries[j], options); + } + return object; + }; + + /** + * Converts this DocumentHistory to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory + * @instance + * @returns {Object.} JSON object + */ + DocumentHistory.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DocumentHistory; + })(); + + return GetDocumentHistoryResponseV0; + })(); + + return GetDocumentHistoryResponse; + })(); + v0.GetIdentityByPublicKeyHashRequest = (function() { /** diff --git a/packages/dapi-grpc/clients/platform/v0/nodejs/PlatformPromiseClient.js b/packages/dapi-grpc/clients/platform/v0/nodejs/PlatformPromiseClient.js index 8a11e009c82..f2008547c8d 100644 --- a/packages/dapi-grpc/clients/platform/v0/nodejs/PlatformPromiseClient.js +++ b/packages/dapi-grpc/clients/platform/v0/nodejs/PlatformPromiseClient.js @@ -34,6 +34,8 @@ const { GetDataContractResponse: PBJSGetDataContractResponse, GetDataContractHistoryRequest: PBJSGetDataContractHistoryRequest, GetDataContractHistoryResponse: PBJSGetDataContractHistoryResponse, + GetDocumentHistoryRequest: PBJSGetDocumentHistoryRequest, + GetDocumentHistoryResponse: PBJSGetDocumentHistoryResponse, GetDocumentsRequest: PBJSGetDocumentsRequest, GetDocumentsResponse: PBJSGetDocumentsResponse, GetIdentityByPublicKeyHashRequest: PBJSGetIdentityByPublicKeyHashRequest, @@ -75,6 +77,7 @@ const { GetIdentitiesContractKeysResponse: ProtocGetIdentitiesContractKeysResponse, GetDataContractResponse: ProtocGetDataContractResponse, GetDataContractHistoryResponse: ProtocGetDataContractHistoryResponse, + GetDocumentHistoryResponse: ProtocGetDocumentHistoryResponse, GetDocumentsResponse: ProtocGetDocumentsResponse, GetIdentityByPublicKeyHashResponse: ProtocGetIdentityByPublicKeyHashResponse, WaitForStateTransitionResultResponse: ProtocWaitForStateTransitionResultResponse, @@ -134,6 +137,10 @@ class PlatformPromiseClient { this.client.getDataContractHistory.bind(this.client), ); + this.client.getDocumentHistory = promisify( + this.client.getDocumentHistory.bind(this.client), + ); + this.client.getDocuments = promisify( this.client.getDocuments.bind(this.client), ); @@ -349,6 +356,38 @@ class PlatformPromiseClient { ); } + /** + * + * @param {!GetDocumentHistoryRequest} getDocumentHistoryRequest + * @param {?Object} metadata + * @param {CallOptions} [options={}] + * @returns {Promise} + */ + getDocumentHistory(getDocumentHistoryRequest, metadata = {}, options = {}) { + if (!isObject(metadata)) { + throw new Error('metadata must be an object'); + } + + return this.client.getDocumentHistory( + getDocumentHistoryRequest, + convertObjectToMetadata(metadata), + { + interceptors: [ + jsonToProtobufInterceptorFactory( + jsonToProtobufFactory( + ProtocGetDocumentHistoryResponse, + PBJSGetDocumentHistoryResponse, + ), + protobufToJsonFactory( + PBJSGetDocumentHistoryRequest, + ), + ), + ], + ...options, + }, + ); + } + /** * * @param {!GetDocumentsRequest} getDocumentsRequest diff --git a/packages/dapi-grpc/clients/platform/v0/nodejs/platform_pbjs.js b/packages/dapi-grpc/clients/platform/v0/nodejs/platform_pbjs.js index 48de1155b4e..a64c7e588ee 100644 --- a/packages/dapi-grpc/clients/platform/v0/nodejs/platform_pbjs.js +++ b/packages/dapi-grpc/clients/platform/v0/nodejs/platform_pbjs.js @@ -548,6 +548,39 @@ $root.org = (function() { * @variation 2 */ + /** + * Callback as used by {@link org.dash.platform.dapi.v0.Platform#getDocumentHistory}. + * @memberof org.dash.platform.dapi.v0.Platform + * @typedef getDocumentHistoryCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse} [response] GetDocumentHistoryResponse + */ + + /** + * Calls getDocumentHistory. + * @function getDocumentHistory + * @memberof org.dash.platform.dapi.v0.Platform + * @instance + * @param {org.dash.platform.dapi.v0.IGetDocumentHistoryRequest} request GetDocumentHistoryRequest message or plain object + * @param {org.dash.platform.dapi.v0.Platform.getDocumentHistoryCallback} callback Node-style callback called with the error, if any, and GetDocumentHistoryResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Platform.prototype.getDocumentHistory = function getDocumentHistory(request, callback) { + return this.rpcCall(getDocumentHistory, $root.org.dash.platform.dapi.v0.GetDocumentHistoryRequest, $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse, request, callback); + }, "name", { value: "getDocumentHistory" }); + + /** + * Calls getDocumentHistory. + * @function getDocumentHistory + * @memberof org.dash.platform.dapi.v0.Platform + * @instance + * @param {org.dash.platform.dapi.v0.IGetDocumentHistoryRequest} request GetDocumentHistoryRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + /** * Callback as used by {@link org.dash.platform.dapi.v0.Platform#getDocuments}. * @memberof org.dash.platform.dapi.v0.Platform @@ -26893,6 +26926,1504 @@ $root.org = (function() { return GetDocumentsResponse; })(); + v0.GetDocumentHistoryRequest = (function() { + + /** + * Properties of a GetDocumentHistoryRequest. + * @memberof org.dash.platform.dapi.v0 + * @interface IGetDocumentHistoryRequest + * @property {org.dash.platform.dapi.v0.GetDocumentHistoryRequest.IGetDocumentHistoryRequestV0|null} [v0] GetDocumentHistoryRequest v0 + */ + + /** + * Constructs a new GetDocumentHistoryRequest. + * @memberof org.dash.platform.dapi.v0 + * @classdesc Represents a GetDocumentHistoryRequest. + * @implements IGetDocumentHistoryRequest + * @constructor + * @param {org.dash.platform.dapi.v0.IGetDocumentHistoryRequest=} [properties] Properties to set + */ + function GetDocumentHistoryRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetDocumentHistoryRequest v0. + * @member {org.dash.platform.dapi.v0.GetDocumentHistoryRequest.IGetDocumentHistoryRequestV0|null|undefined} v0 + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest + * @instance + */ + GetDocumentHistoryRequest.prototype.v0 = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * GetDocumentHistoryRequest version. + * @member {"v0"|undefined} version + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest + * @instance + */ + Object.defineProperty(GetDocumentHistoryRequest.prototype, "version", { + get: $util.oneOfGetter($oneOfFields = ["v0"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new GetDocumentHistoryRequest instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest + * @static + * @param {org.dash.platform.dapi.v0.IGetDocumentHistoryRequest=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryRequest} GetDocumentHistoryRequest instance + */ + GetDocumentHistoryRequest.create = function create(properties) { + return new GetDocumentHistoryRequest(properties); + }; + + /** + * Encodes the specified GetDocumentHistoryRequest message. Does not implicitly {@link org.dash.platform.dapi.v0.GetDocumentHistoryRequest.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest + * @static + * @param {org.dash.platform.dapi.v0.IGetDocumentHistoryRequest} message GetDocumentHistoryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDocumentHistoryRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.v0 != null && Object.hasOwnProperty.call(message, "v0")) + $root.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.encode(message.v0, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified GetDocumentHistoryRequest message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetDocumentHistoryRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest + * @static + * @param {org.dash.platform.dapi.v0.IGetDocumentHistoryRequest} message GetDocumentHistoryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDocumentHistoryRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetDocumentHistoryRequest message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryRequest} GetDocumentHistoryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDocumentHistoryRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetDocumentHistoryRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.v0 = $root.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetDocumentHistoryRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryRequest} GetDocumentHistoryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDocumentHistoryRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetDocumentHistoryRequest message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetDocumentHistoryRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.v0 != null && message.hasOwnProperty("v0")) { + properties.version = 1; + { + var error = $root.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.verify(message.v0); + if (error) + return "v0." + error; + } + } + return null; + }; + + /** + * Creates a GetDocumentHistoryRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryRequest} GetDocumentHistoryRequest + */ + GetDocumentHistoryRequest.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetDocumentHistoryRequest) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetDocumentHistoryRequest(); + if (object.v0 != null) { + if (typeof object.v0 !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetDocumentHistoryRequest.v0: object expected"); + message.v0 = $root.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.fromObject(object.v0); + } + return message; + }; + + /** + * Creates a plain object from a GetDocumentHistoryRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryRequest} message GetDocumentHistoryRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetDocumentHistoryRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.v0 != null && message.hasOwnProperty("v0")) { + object.v0 = $root.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.toObject(message.v0, options); + if (options.oneofs) + object.version = "v0"; + } + return object; + }; + + /** + * Converts this GetDocumentHistoryRequest to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest + * @instance + * @returns {Object.} JSON object + */ + GetDocumentHistoryRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 = (function() { + + /** + * Properties of a GetDocumentHistoryRequestV0. + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest + * @interface IGetDocumentHistoryRequestV0 + * @property {Uint8Array|null} [dataContractId] GetDocumentHistoryRequestV0 dataContractId + * @property {string|null} [documentTypeName] GetDocumentHistoryRequestV0 documentTypeName + * @property {Uint8Array|null} [documentId] GetDocumentHistoryRequestV0 documentId + * @property {google.protobuf.IUInt32Value|null} [limit] GetDocumentHistoryRequestV0 limit + * @property {google.protobuf.IUInt32Value|null} [offset] GetDocumentHistoryRequestV0 offset + * @property {number|Long|null} [startAtMs] GetDocumentHistoryRequestV0 startAtMs + * @property {boolean|null} [prove] GetDocumentHistoryRequestV0 prove + */ + + /** + * Constructs a new GetDocumentHistoryRequestV0. + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest + * @classdesc Represents a GetDocumentHistoryRequestV0. + * @implements IGetDocumentHistoryRequestV0 + * @constructor + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryRequest.IGetDocumentHistoryRequestV0=} [properties] Properties to set + */ + function GetDocumentHistoryRequestV0(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetDocumentHistoryRequestV0 dataContractId. + * @member {Uint8Array} dataContractId + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @instance + */ + GetDocumentHistoryRequestV0.prototype.dataContractId = $util.newBuffer([]); + + /** + * GetDocumentHistoryRequestV0 documentTypeName. + * @member {string} documentTypeName + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @instance + */ + GetDocumentHistoryRequestV0.prototype.documentTypeName = ""; + + /** + * GetDocumentHistoryRequestV0 documentId. + * @member {Uint8Array} documentId + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @instance + */ + GetDocumentHistoryRequestV0.prototype.documentId = $util.newBuffer([]); + + /** + * GetDocumentHistoryRequestV0 limit. + * @member {google.protobuf.IUInt32Value|null|undefined} limit + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @instance + */ + GetDocumentHistoryRequestV0.prototype.limit = null; + + /** + * GetDocumentHistoryRequestV0 offset. + * @member {google.protobuf.IUInt32Value|null|undefined} offset + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @instance + */ + GetDocumentHistoryRequestV0.prototype.offset = null; + + /** + * GetDocumentHistoryRequestV0 startAtMs. + * @member {number|Long} startAtMs + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @instance + */ + GetDocumentHistoryRequestV0.prototype.startAtMs = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * GetDocumentHistoryRequestV0 prove. + * @member {boolean} prove + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @instance + */ + GetDocumentHistoryRequestV0.prototype.prove = false; + + /** + * Creates a new GetDocumentHistoryRequestV0 instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryRequest.IGetDocumentHistoryRequestV0=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} GetDocumentHistoryRequestV0 instance + */ + GetDocumentHistoryRequestV0.create = function create(properties) { + return new GetDocumentHistoryRequestV0(properties); + }; + + /** + * Encodes the specified GetDocumentHistoryRequestV0 message. Does not implicitly {@link org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryRequest.IGetDocumentHistoryRequestV0} message GetDocumentHistoryRequestV0 message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDocumentHistoryRequestV0.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.dataContractId != null && Object.hasOwnProperty.call(message, "dataContractId")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.dataContractId); + if (message.documentTypeName != null && Object.hasOwnProperty.call(message, "documentTypeName")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.documentTypeName); + if (message.documentId != null && Object.hasOwnProperty.call(message, "documentId")) + writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.documentId); + if (message.limit != null && Object.hasOwnProperty.call(message, "limit")) + $root.google.protobuf.UInt32Value.encode(message.limit, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.offset != null && Object.hasOwnProperty.call(message, "offset")) + $root.google.protobuf.UInt32Value.encode(message.offset, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.startAtMs != null && Object.hasOwnProperty.call(message, "startAtMs")) + writer.uint32(/* id 6, wireType 0 =*/48).uint64(message.startAtMs); + if (message.prove != null && Object.hasOwnProperty.call(message, "prove")) + writer.uint32(/* id 7, wireType 0 =*/56).bool(message.prove); + return writer; + }; + + /** + * Encodes the specified GetDocumentHistoryRequestV0 message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryRequest.IGetDocumentHistoryRequestV0} message GetDocumentHistoryRequestV0 message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDocumentHistoryRequestV0.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetDocumentHistoryRequestV0 message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} GetDocumentHistoryRequestV0 + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDocumentHistoryRequestV0.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.dataContractId = reader.bytes(); + break; + case 2: + message.documentTypeName = reader.string(); + break; + case 3: + message.documentId = reader.bytes(); + break; + case 4: + message.limit = $root.google.protobuf.UInt32Value.decode(reader, reader.uint32()); + break; + case 5: + message.offset = $root.google.protobuf.UInt32Value.decode(reader, reader.uint32()); + break; + case 6: + message.startAtMs = reader.uint64(); + break; + case 7: + message.prove = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetDocumentHistoryRequestV0 message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} GetDocumentHistoryRequestV0 + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDocumentHistoryRequestV0.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetDocumentHistoryRequestV0 message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetDocumentHistoryRequestV0.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.dataContractId != null && message.hasOwnProperty("dataContractId")) + if (!(message.dataContractId && typeof message.dataContractId.length === "number" || $util.isString(message.dataContractId))) + return "dataContractId: buffer expected"; + if (message.documentTypeName != null && message.hasOwnProperty("documentTypeName")) + if (!$util.isString(message.documentTypeName)) + return "documentTypeName: string expected"; + if (message.documentId != null && message.hasOwnProperty("documentId")) + if (!(message.documentId && typeof message.documentId.length === "number" || $util.isString(message.documentId))) + return "documentId: buffer expected"; + if (message.limit != null && message.hasOwnProperty("limit")) { + var error = $root.google.protobuf.UInt32Value.verify(message.limit); + if (error) + return "limit." + error; + } + if (message.offset != null && message.hasOwnProperty("offset")) { + var error = $root.google.protobuf.UInt32Value.verify(message.offset); + if (error) + return "offset." + error; + } + if (message.startAtMs != null && message.hasOwnProperty("startAtMs")) + if (!$util.isInteger(message.startAtMs) && !(message.startAtMs && $util.isInteger(message.startAtMs.low) && $util.isInteger(message.startAtMs.high))) + return "startAtMs: integer|Long expected"; + if (message.prove != null && message.hasOwnProperty("prove")) + if (typeof message.prove !== "boolean") + return "prove: boolean expected"; + return null; + }; + + /** + * Creates a GetDocumentHistoryRequestV0 message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} GetDocumentHistoryRequestV0 + */ + GetDocumentHistoryRequestV0.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0(); + if (object.dataContractId != null) + if (typeof object.dataContractId === "string") + $util.base64.decode(object.dataContractId, message.dataContractId = $util.newBuffer($util.base64.length(object.dataContractId)), 0); + else if (object.dataContractId.length >= 0) + message.dataContractId = object.dataContractId; + if (object.documentTypeName != null) + message.documentTypeName = String(object.documentTypeName); + if (object.documentId != null) + if (typeof object.documentId === "string") + $util.base64.decode(object.documentId, message.documentId = $util.newBuffer($util.base64.length(object.documentId)), 0); + else if (object.documentId.length >= 0) + message.documentId = object.documentId; + if (object.limit != null) { + if (typeof object.limit !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.limit: object expected"); + message.limit = $root.google.protobuf.UInt32Value.fromObject(object.limit); + } + if (object.offset != null) { + if (typeof object.offset !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.offset: object expected"); + message.offset = $root.google.protobuf.UInt32Value.fromObject(object.offset); + } + if (object.startAtMs != null) + if ($util.Long) + (message.startAtMs = $util.Long.fromValue(object.startAtMs)).unsigned = true; + else if (typeof object.startAtMs === "string") + message.startAtMs = parseInt(object.startAtMs, 10); + else if (typeof object.startAtMs === "number") + message.startAtMs = object.startAtMs; + else if (typeof object.startAtMs === "object") + message.startAtMs = new $util.LongBits(object.startAtMs.low >>> 0, object.startAtMs.high >>> 0).toNumber(true); + if (object.prove != null) + message.prove = Boolean(object.prove); + return message; + }; + + /** + * Creates a plain object from a GetDocumentHistoryRequestV0 message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} message GetDocumentHistoryRequestV0 + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetDocumentHistoryRequestV0.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if (options.bytes === String) + object.dataContractId = ""; + else { + object.dataContractId = []; + if (options.bytes !== Array) + object.dataContractId = $util.newBuffer(object.dataContractId); + } + object.documentTypeName = ""; + if (options.bytes === String) + object.documentId = ""; + else { + object.documentId = []; + if (options.bytes !== Array) + object.documentId = $util.newBuffer(object.documentId); + } + object.limit = null; + object.offset = null; + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.startAtMs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.startAtMs = options.longs === String ? "0" : 0; + object.prove = false; + } + if (message.dataContractId != null && message.hasOwnProperty("dataContractId")) + object.dataContractId = options.bytes === String ? $util.base64.encode(message.dataContractId, 0, message.dataContractId.length) : options.bytes === Array ? Array.prototype.slice.call(message.dataContractId) : message.dataContractId; + if (message.documentTypeName != null && message.hasOwnProperty("documentTypeName")) + object.documentTypeName = message.documentTypeName; + if (message.documentId != null && message.hasOwnProperty("documentId")) + object.documentId = options.bytes === String ? $util.base64.encode(message.documentId, 0, message.documentId.length) : options.bytes === Array ? Array.prototype.slice.call(message.documentId) : message.documentId; + if (message.limit != null && message.hasOwnProperty("limit")) + object.limit = $root.google.protobuf.UInt32Value.toObject(message.limit, options); + if (message.offset != null && message.hasOwnProperty("offset")) + object.offset = $root.google.protobuf.UInt32Value.toObject(message.offset, options); + if (message.startAtMs != null && message.hasOwnProperty("startAtMs")) + if (typeof message.startAtMs === "number") + object.startAtMs = options.longs === String ? String(message.startAtMs) : message.startAtMs; + else + object.startAtMs = options.longs === String ? $util.Long.prototype.toString.call(message.startAtMs) : options.longs === Number ? new $util.LongBits(message.startAtMs.low >>> 0, message.startAtMs.high >>> 0).toNumber(true) : message.startAtMs; + if (message.prove != null && message.hasOwnProperty("prove")) + object.prove = message.prove; + return object; + }; + + /** + * Converts this GetDocumentHistoryRequestV0 to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 + * @instance + * @returns {Object.} JSON object + */ + GetDocumentHistoryRequestV0.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return GetDocumentHistoryRequestV0; + })(); + + return GetDocumentHistoryRequest; + })(); + + v0.GetDocumentHistoryResponse = (function() { + + /** + * Properties of a GetDocumentHistoryResponse. + * @memberof org.dash.platform.dapi.v0 + * @interface IGetDocumentHistoryResponse + * @property {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.IGetDocumentHistoryResponseV0|null} [v0] GetDocumentHistoryResponse v0 + */ + + /** + * Constructs a new GetDocumentHistoryResponse. + * @memberof org.dash.platform.dapi.v0 + * @classdesc Represents a GetDocumentHistoryResponse. + * @implements IGetDocumentHistoryResponse + * @constructor + * @param {org.dash.platform.dapi.v0.IGetDocumentHistoryResponse=} [properties] Properties to set + */ + function GetDocumentHistoryResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetDocumentHistoryResponse v0. + * @member {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.IGetDocumentHistoryResponseV0|null|undefined} v0 + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse + * @instance + */ + GetDocumentHistoryResponse.prototype.v0 = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * GetDocumentHistoryResponse version. + * @member {"v0"|undefined} version + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse + * @instance + */ + Object.defineProperty(GetDocumentHistoryResponse.prototype, "version", { + get: $util.oneOfGetter($oneOfFields = ["v0"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new GetDocumentHistoryResponse instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse + * @static + * @param {org.dash.platform.dapi.v0.IGetDocumentHistoryResponse=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse} GetDocumentHistoryResponse instance + */ + GetDocumentHistoryResponse.create = function create(properties) { + return new GetDocumentHistoryResponse(properties); + }; + + /** + * Encodes the specified GetDocumentHistoryResponse message. Does not implicitly {@link org.dash.platform.dapi.v0.GetDocumentHistoryResponse.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse + * @static + * @param {org.dash.platform.dapi.v0.IGetDocumentHistoryResponse} message GetDocumentHistoryResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDocumentHistoryResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.v0 != null && Object.hasOwnProperty.call(message, "v0")) + $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.encode(message.v0, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified GetDocumentHistoryResponse message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetDocumentHistoryResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse + * @static + * @param {org.dash.platform.dapi.v0.IGetDocumentHistoryResponse} message GetDocumentHistoryResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDocumentHistoryResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetDocumentHistoryResponse message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse} GetDocumentHistoryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDocumentHistoryResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.v0 = $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetDocumentHistoryResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse} GetDocumentHistoryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDocumentHistoryResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetDocumentHistoryResponse message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetDocumentHistoryResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.v0 != null && message.hasOwnProperty("v0")) { + properties.version = 1; + { + var error = $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.verify(message.v0); + if (error) + return "v0." + error; + } + } + return null; + }; + + /** + * Creates a GetDocumentHistoryResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse} GetDocumentHistoryResponse + */ + GetDocumentHistoryResponse.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse(); + if (object.v0 != null) { + if (typeof object.v0 !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetDocumentHistoryResponse.v0: object expected"); + message.v0 = $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.fromObject(object.v0); + } + return message; + }; + + /** + * Creates a plain object from a GetDocumentHistoryResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse} message GetDocumentHistoryResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetDocumentHistoryResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.v0 != null && message.hasOwnProperty("v0")) { + object.v0 = $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.toObject(message.v0, options); + if (options.oneofs) + object.version = "v0"; + } + return object; + }; + + /** + * Converts this GetDocumentHistoryResponse to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse + * @instance + * @returns {Object.} JSON object + */ + GetDocumentHistoryResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 = (function() { + + /** + * Properties of a GetDocumentHistoryResponseV0. + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse + * @interface IGetDocumentHistoryResponseV0 + * @property {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.IDocumentHistory|null} [documentHistory] GetDocumentHistoryResponseV0 documentHistory + * @property {org.dash.platform.dapi.v0.IProof|null} [proof] GetDocumentHistoryResponseV0 proof + * @property {org.dash.platform.dapi.v0.IResponseMetadata|null} [metadata] GetDocumentHistoryResponseV0 metadata + */ + + /** + * Constructs a new GetDocumentHistoryResponseV0. + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse + * @classdesc Represents a GetDocumentHistoryResponseV0. + * @implements IGetDocumentHistoryResponseV0 + * @constructor + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.IGetDocumentHistoryResponseV0=} [properties] Properties to set + */ + function GetDocumentHistoryResponseV0(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetDocumentHistoryResponseV0 documentHistory. + * @member {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.IDocumentHistory|null|undefined} documentHistory + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @instance + */ + GetDocumentHistoryResponseV0.prototype.documentHistory = null; + + /** + * GetDocumentHistoryResponseV0 proof. + * @member {org.dash.platform.dapi.v0.IProof|null|undefined} proof + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @instance + */ + GetDocumentHistoryResponseV0.prototype.proof = null; + + /** + * GetDocumentHistoryResponseV0 metadata. + * @member {org.dash.platform.dapi.v0.IResponseMetadata|null|undefined} metadata + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @instance + */ + GetDocumentHistoryResponseV0.prototype.metadata = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * GetDocumentHistoryResponseV0 result. + * @member {"documentHistory"|"proof"|undefined} result + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @instance + */ + Object.defineProperty(GetDocumentHistoryResponseV0.prototype, "result", { + get: $util.oneOfGetter($oneOfFields = ["documentHistory", "proof"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new GetDocumentHistoryResponseV0 instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.IGetDocumentHistoryResponseV0=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} GetDocumentHistoryResponseV0 instance + */ + GetDocumentHistoryResponseV0.create = function create(properties) { + return new GetDocumentHistoryResponseV0(properties); + }; + + /** + * Encodes the specified GetDocumentHistoryResponseV0 message. Does not implicitly {@link org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.IGetDocumentHistoryResponseV0} message GetDocumentHistoryResponseV0 message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDocumentHistoryResponseV0.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.documentHistory != null && Object.hasOwnProperty.call(message, "documentHistory")) + $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.encode(message.documentHistory, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.proof != null && Object.hasOwnProperty.call(message, "proof")) + $root.org.dash.platform.dapi.v0.Proof.encode(message.proof, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.metadata != null && Object.hasOwnProperty.call(message, "metadata")) + $root.org.dash.platform.dapi.v0.ResponseMetadata.encode(message.metadata, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified GetDocumentHistoryResponseV0 message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.IGetDocumentHistoryResponseV0} message GetDocumentHistoryResponseV0 message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDocumentHistoryResponseV0.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetDocumentHistoryResponseV0 message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} GetDocumentHistoryResponseV0 + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDocumentHistoryResponseV0.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.documentHistory = $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.decode(reader, reader.uint32()); + break; + case 2: + message.proof = $root.org.dash.platform.dapi.v0.Proof.decode(reader, reader.uint32()); + break; + case 3: + message.metadata = $root.org.dash.platform.dapi.v0.ResponseMetadata.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetDocumentHistoryResponseV0 message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} GetDocumentHistoryResponseV0 + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDocumentHistoryResponseV0.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetDocumentHistoryResponseV0 message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetDocumentHistoryResponseV0.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.documentHistory != null && message.hasOwnProperty("documentHistory")) { + properties.result = 1; + { + var error = $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.verify(message.documentHistory); + if (error) + return "documentHistory." + error; + } + } + if (message.proof != null && message.hasOwnProperty("proof")) { + if (properties.result === 1) + return "result: multiple values"; + properties.result = 1; + { + var error = $root.org.dash.platform.dapi.v0.Proof.verify(message.proof); + if (error) + return "proof." + error; + } + } + if (message.metadata != null && message.hasOwnProperty("metadata")) { + var error = $root.org.dash.platform.dapi.v0.ResponseMetadata.verify(message.metadata); + if (error) + return "metadata." + error; + } + return null; + }; + + /** + * Creates a GetDocumentHistoryResponseV0 message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} GetDocumentHistoryResponseV0 + */ + GetDocumentHistoryResponseV0.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0(); + if (object.documentHistory != null) { + if (typeof object.documentHistory !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.documentHistory: object expected"); + message.documentHistory = $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.fromObject(object.documentHistory); + } + if (object.proof != null) { + if (typeof object.proof !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.proof: object expected"); + message.proof = $root.org.dash.platform.dapi.v0.Proof.fromObject(object.proof); + } + if (object.metadata != null) { + if (typeof object.metadata !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.metadata: object expected"); + message.metadata = $root.org.dash.platform.dapi.v0.ResponseMetadata.fromObject(object.metadata); + } + return message; + }; + + /** + * Creates a plain object from a GetDocumentHistoryResponseV0 message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} message GetDocumentHistoryResponseV0 + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetDocumentHistoryResponseV0.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.metadata = null; + if (message.documentHistory != null && message.hasOwnProperty("documentHistory")) { + object.documentHistory = $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.toObject(message.documentHistory, options); + if (options.oneofs) + object.result = "documentHistory"; + } + if (message.proof != null && message.hasOwnProperty("proof")) { + object.proof = $root.org.dash.platform.dapi.v0.Proof.toObject(message.proof, options); + if (options.oneofs) + object.result = "proof"; + } + if (message.metadata != null && message.hasOwnProperty("metadata")) + object.metadata = $root.org.dash.platform.dapi.v0.ResponseMetadata.toObject(message.metadata, options); + return object; + }; + + /** + * Converts this GetDocumentHistoryResponseV0 to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @instance + * @returns {Object.} JSON object + */ + GetDocumentHistoryResponseV0.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + GetDocumentHistoryResponseV0.DocumentHistoryEntry = (function() { + + /** + * Properties of a DocumentHistoryEntry. + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @interface IDocumentHistoryEntry + * @property {number|Long|null} [date] DocumentHistoryEntry date + * @property {Uint8Array|null} [value] DocumentHistoryEntry value + */ + + /** + * Constructs a new DocumentHistoryEntry. + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @classdesc Represents a DocumentHistoryEntry. + * @implements IDocumentHistoryEntry + * @constructor + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.IDocumentHistoryEntry=} [properties] Properties to set + */ + function DocumentHistoryEntry(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DocumentHistoryEntry date. + * @member {number|Long} date + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry + * @instance + */ + DocumentHistoryEntry.prototype.date = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * DocumentHistoryEntry value. + * @member {Uint8Array} value + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry + * @instance + */ + DocumentHistoryEntry.prototype.value = $util.newBuffer([]); + + /** + * Creates a new DocumentHistoryEntry instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.IDocumentHistoryEntry=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry} DocumentHistoryEntry instance + */ + DocumentHistoryEntry.create = function create(properties) { + return new DocumentHistoryEntry(properties); + }; + + /** + * Encodes the specified DocumentHistoryEntry message. Does not implicitly {@link org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.IDocumentHistoryEntry} message DocumentHistoryEntry message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DocumentHistoryEntry.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.date != null && Object.hasOwnProperty.call(message, "date")) + writer.uint32(/* id 1, wireType 0 =*/8).uint64(message.date); + if (message.value != null && Object.hasOwnProperty.call(message, "value")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.value); + return writer; + }; + + /** + * Encodes the specified DocumentHistoryEntry message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.IDocumentHistoryEntry} message DocumentHistoryEntry message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DocumentHistoryEntry.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DocumentHistoryEntry message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry} DocumentHistoryEntry + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DocumentHistoryEntry.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.date = reader.uint64(); + break; + case 2: + message.value = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DocumentHistoryEntry message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry} DocumentHistoryEntry + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DocumentHistoryEntry.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DocumentHistoryEntry message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DocumentHistoryEntry.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.date != null && message.hasOwnProperty("date")) + if (!$util.isInteger(message.date) && !(message.date && $util.isInteger(message.date.low) && $util.isInteger(message.date.high))) + return "date: integer|Long expected"; + if (message.value != null && message.hasOwnProperty("value")) + if (!(message.value && typeof message.value.length === "number" || $util.isString(message.value))) + return "value: buffer expected"; + return null; + }; + + /** + * Creates a DocumentHistoryEntry message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry} DocumentHistoryEntry + */ + DocumentHistoryEntry.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry(); + if (object.date != null) + if ($util.Long) + (message.date = $util.Long.fromValue(object.date)).unsigned = true; + else if (typeof object.date === "string") + message.date = parseInt(object.date, 10); + else if (typeof object.date === "number") + message.date = object.date; + else if (typeof object.date === "object") + message.date = new $util.LongBits(object.date.low >>> 0, object.date.high >>> 0).toNumber(true); + if (object.value != null) + if (typeof object.value === "string") + $util.base64.decode(object.value, message.value = $util.newBuffer($util.base64.length(object.value)), 0); + else if (object.value.length >= 0) + message.value = object.value; + return message; + }; + + /** + * Creates a plain object from a DocumentHistoryEntry message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry} message DocumentHistoryEntry + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DocumentHistoryEntry.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.date = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.date = options.longs === String ? "0" : 0; + if (options.bytes === String) + object.value = ""; + else { + object.value = []; + if (options.bytes !== Array) + object.value = $util.newBuffer(object.value); + } + } + if (message.date != null && message.hasOwnProperty("date")) + if (typeof message.date === "number") + object.date = options.longs === String ? String(message.date) : message.date; + else + object.date = options.longs === String ? $util.Long.prototype.toString.call(message.date) : options.longs === Number ? new $util.LongBits(message.date.low >>> 0, message.date.high >>> 0).toNumber(true) : message.date; + if (message.value != null && message.hasOwnProperty("value")) + object.value = options.bytes === String ? $util.base64.encode(message.value, 0, message.value.length) : options.bytes === Array ? Array.prototype.slice.call(message.value) : message.value; + return object; + }; + + /** + * Converts this DocumentHistoryEntry to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry + * @instance + * @returns {Object.} JSON object + */ + DocumentHistoryEntry.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DocumentHistoryEntry; + })(); + + GetDocumentHistoryResponseV0.DocumentHistory = (function() { + + /** + * Properties of a DocumentHistory. + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @interface IDocumentHistory + * @property {Array.|null} [documentEntries] DocumentHistory documentEntries + */ + + /** + * Constructs a new DocumentHistory. + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 + * @classdesc Represents a DocumentHistory. + * @implements IDocumentHistory + * @constructor + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.IDocumentHistory=} [properties] Properties to set + */ + function DocumentHistory(properties) { + this.documentEntries = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DocumentHistory documentEntries. + * @member {Array.} documentEntries + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory + * @instance + */ + DocumentHistory.prototype.documentEntries = $util.emptyArray; + + /** + * Creates a new DocumentHistory instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.IDocumentHistory=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory} DocumentHistory instance + */ + DocumentHistory.create = function create(properties) { + return new DocumentHistory(properties); + }; + + /** + * Encodes the specified DocumentHistory message. Does not implicitly {@link org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.IDocumentHistory} message DocumentHistory message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DocumentHistory.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.documentEntries != null && message.documentEntries.length) + for (var i = 0; i < message.documentEntries.length; ++i) + $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.encode(message.documentEntries[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified DocumentHistory message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.IDocumentHistory} message DocumentHistory message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DocumentHistory.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DocumentHistory message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory} DocumentHistory + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DocumentHistory.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.documentEntries && message.documentEntries.length)) + message.documentEntries = []; + message.documentEntries.push($root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DocumentHistory message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory} DocumentHistory + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DocumentHistory.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DocumentHistory message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DocumentHistory.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.documentEntries != null && message.hasOwnProperty("documentEntries")) { + if (!Array.isArray(message.documentEntries)) + return "documentEntries: array expected"; + for (var i = 0; i < message.documentEntries.length; ++i) { + var error = $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.verify(message.documentEntries[i]); + if (error) + return "documentEntries." + error; + } + } + return null; + }; + + /** + * Creates a DocumentHistory message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory} DocumentHistory + */ + DocumentHistory.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory(); + if (object.documentEntries) { + if (!Array.isArray(object.documentEntries)) + throw TypeError(".org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.documentEntries: array expected"); + message.documentEntries = []; + for (var i = 0; i < object.documentEntries.length; ++i) { + if (typeof object.documentEntries[i] !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.documentEntries: object expected"); + message.documentEntries[i] = $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.fromObject(object.documentEntries[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a DocumentHistory message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory + * @static + * @param {org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory} message DocumentHistory + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DocumentHistory.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.documentEntries = []; + if (message.documentEntries && message.documentEntries.length) { + object.documentEntries = []; + for (var j = 0; j < message.documentEntries.length; ++j) + object.documentEntries[j] = $root.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.toObject(message.documentEntries[j], options); + } + return object; + }; + + /** + * Converts this DocumentHistory to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory + * @instance + * @returns {Object.} JSON object + */ + DocumentHistory.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DocumentHistory; + })(); + + return GetDocumentHistoryResponseV0; + })(); + + return GetDocumentHistoryResponse; + })(); + v0.GetIdentityByPublicKeyHashRequest = (function() { /** diff --git a/packages/dapi-grpc/clients/platform/v0/nodejs/platform_protoc.js b/packages/dapi-grpc/clients/platform/v0/nodejs/platform_protoc.js index 2553cd1a237..ed0d58a5e75 100644 --- a/packages/dapi-grpc/clients/platform/v0/nodejs/platform_protoc.js +++ b/packages/dapi-grpc/clients/platform/v0/nodejs/platform_protoc.js @@ -150,6 +150,15 @@ goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDataContractsResponse.Data goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0', null, { proto }); goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.ResultCase', null, { proto }); goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDataContractsResponse.VersionCase', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.VersionCase', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.ResultCase', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.VersionCase', null, { proto }); goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDocumentsRequest', null, { proto }); goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDocumentsRequest.DocumentFieldValue', null, { proto }); goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDocumentsRequest.DocumentFieldValue.ValueList', null, { proto }); @@ -2733,6 +2742,132 @@ if (goog.DEBUG && !COMPILED) { */ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.ResultData.displayName = 'proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.ResultData'; } +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.oneofGroups_); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.displayName = 'proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.displayName = 'proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.oneofGroups_); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.displayName = 'proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.oneofGroups_); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.displayName = 'proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.displayName = 'proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.repeatedFields_, null); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.displayName = 'proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory'; +} /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a @@ -31557,6 +31692,1381 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.hasV1 = function( +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.oneofGroups_ = [[1]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.VersionCase} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest; + return proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.deserializeBinaryFromReader); + msg.setV0(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getV0(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.serializeBinaryToWriter + ); + } +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.toObject = function(includeInstance, msg) { + var f, obj = { + dataContractId: msg.getDataContractId_asB64(), + documentTypeName: jspb.Message.getFieldWithDefault(msg, 2, ""), + documentId: msg.getDocumentId_asB64(), + limit: (f = msg.getLimit()) && google_protobuf_wrappers_pb.UInt32Value.toObject(includeInstance, f), + offset: (f = msg.getOffset()) && google_protobuf_wrappers_pb.UInt32Value.toObject(includeInstance, f), + startAtMs: jspb.Message.getFieldWithDefault(msg, 6, "0"), + prove: jspb.Message.getBooleanFieldWithDefault(msg, 7, false) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0; + return proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setDataContractId(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setDocumentTypeName(value); + break; + case 3: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setDocumentId(value); + break; + case 4: + var value = new google_protobuf_wrappers_pb.UInt32Value; + reader.readMessage(value,google_protobuf_wrappers_pb.UInt32Value.deserializeBinaryFromReader); + msg.setLimit(value); + break; + case 5: + var value = new google_protobuf_wrappers_pb.UInt32Value; + reader.readMessage(value,google_protobuf_wrappers_pb.UInt32Value.deserializeBinaryFromReader); + msg.setOffset(value); + break; + case 6: + var value = /** @type {string} */ (reader.readUint64String()); + msg.setStartAtMs(value); + break; + case 7: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getDataContractId_asU8(); + if (f.length > 0) { + writer.writeBytes( + 1, + f + ); + } + f = message.getDocumentTypeName(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getDocumentId_asU8(); + if (f.length > 0) { + writer.writeBytes( + 3, + f + ); + } + f = message.getLimit(); + if (f != null) { + writer.writeMessage( + 4, + f, + google_protobuf_wrappers_pb.UInt32Value.serializeBinaryToWriter + ); + } + f = message.getOffset(); + if (f != null) { + writer.writeMessage( + 5, + f, + google_protobuf_wrappers_pb.UInt32Value.serializeBinaryToWriter + ); + } + f = message.getStartAtMs(); + if (parseInt(f, 10) !== 0) { + writer.writeUint64String( + 6, + f + ); + } + f = message.getProve(); + if (f) { + writer.writeBool( + 7, + f + ); + } +}; + + +/** + * optional bytes data_contract_id = 1; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.getDataContractId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * optional bytes data_contract_id = 1; + * This is a type-conversion wrapper around `getDataContractId()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.getDataContractId_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getDataContractId())); +}; + + +/** + * optional bytes data_contract_id = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getDataContractId()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.getDataContractId_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getDataContractId())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.setDataContractId = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); +}; + + +/** + * optional string document_type_name = 2; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.getDocumentTypeName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.setDocumentTypeName = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * optional bytes document_id = 3; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.getDocumentId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * optional bytes document_id = 3; + * This is a type-conversion wrapper around `getDocumentId()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.getDocumentId_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getDocumentId())); +}; + + +/** + * optional bytes document_id = 3; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getDocumentId()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.getDocumentId_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getDocumentId())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.setDocumentId = function(value) { + return jspb.Message.setProto3BytesField(this, 3, value); +}; + + +/** + * optional google.protobuf.UInt32Value limit = 4; + * @return {?proto.google.protobuf.UInt32Value} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.getLimit = function() { + return /** @type{?proto.google.protobuf.UInt32Value} */ ( + jspb.Message.getWrapperField(this, google_protobuf_wrappers_pb.UInt32Value, 4)); +}; + + +/** + * @param {?proto.google.protobuf.UInt32Value|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.setLimit = function(value) { + return jspb.Message.setWrapperField(this, 4, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.clearLimit = function() { + return this.setLimit(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.hasLimit = function() { + return jspb.Message.getField(this, 4) != null; +}; + + +/** + * optional google.protobuf.UInt32Value offset = 5; + * @return {?proto.google.protobuf.UInt32Value} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.getOffset = function() { + return /** @type{?proto.google.protobuf.UInt32Value} */ ( + jspb.Message.getWrapperField(this, google_protobuf_wrappers_pb.UInt32Value, 5)); +}; + + +/** + * @param {?proto.google.protobuf.UInt32Value|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.setOffset = function(value) { + return jspb.Message.setWrapperField(this, 5, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.clearOffset = function() { + return this.setOffset(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.hasOffset = function() { + return jspb.Message.getField(this, 5) != null; +}; + + +/** + * optional uint64 start_at_ms = 6; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.getStartAtMs = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 6, "0")); +}; + + +/** + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.setStartAtMs = function(value) { + return jspb.Message.setProto3StringIntField(this, 6, value); +}; + + +/** + * optional bool prove = 7; + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 7, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 7, value); +}; + + +/** + * optional GetDocumentHistoryRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.prototype.clearV0 = function() { + return this.setV0(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.oneofGroups_ = [[1]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.VersionCase} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse; + return proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.deserializeBinaryFromReader); + msg.setV0(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getV0(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.serializeBinaryToWriter + ); + } +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.oneofGroups_ = [[1,2]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.ResultCase = { + RESULT_NOT_SET: 0, + DOCUMENT_HISTORY: 1, + PROOF: 2 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.ResultCase} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.toObject = function(includeInstance, msg) { + var f, obj = { + documentHistory: (f = msg.getDocumentHistory()) && proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.toObject(includeInstance, f), + proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), + metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0; + return proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.deserializeBinaryFromReader); + msg.setDocumentHistory(value); + break; + case 2: + var value = new proto.org.dash.platform.dapi.v0.Proof; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); + msg.setProof(value); + break; + case 3: + var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); + msg.setMetadata(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getDocumentHistory(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.serializeBinaryToWriter + ); + } + f = message.getProof(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter + ); + } + f = message.getMetadata(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter + ); + } +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.toObject = function(includeInstance, msg) { + var f, obj = { + date: jspb.Message.getFieldWithDefault(msg, 1, "0"), + value: msg.getValue_asB64() + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry; + return proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readUint64String()); + msg.setDate(value); + break; + case 2: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setValue(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getDate(); + if (parseInt(f, 10) !== 0) { + writer.writeUint64String( + 1, + f + ); + } + f = message.getValue_asU8(); + if (f.length > 0) { + writer.writeBytes( + 2, + f + ); + } +}; + + +/** + * optional uint64 date = 1; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.prototype.getDate = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "0")); +}; + + +/** + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.prototype.setDate = function(value) { + return jspb.Message.setProto3StringIntField(this, 1, value); +}; + + +/** + * optional bytes value = 2; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.prototype.getValue = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * optional bytes value = 2; + * This is a type-conversion wrapper around `getValue()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.prototype.getValue_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getValue())); +}; + + +/** + * optional bytes value = 2; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getValue()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.prototype.getValue_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getValue())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.prototype.setValue = function(value) { + return jspb.Message.setProto3BytesField(this, 2, value); +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.repeatedFields_ = [1]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.toObject = function(includeInstance, msg) { + var f, obj = { + documentEntriesList: jspb.Message.toObjectList(msg.getDocumentEntriesList(), + proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.toObject, includeInstance) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory; + return proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.deserializeBinaryFromReader); + msg.addDocumentEntries(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getDocumentEntriesList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.serializeBinaryToWriter + ); + } +}; + + +/** + * repeated DocumentHistoryEntry document_entries = 1; + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.prototype.getDocumentEntriesList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry, 1)); +}; + + +/** + * @param {!Array} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.prototype.setDocumentEntriesList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 1, value); +}; + + +/** + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry=} opt_value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.prototype.addDocumentEntries = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.prototype.clearDocumentEntriesList = function() { + return this.setDocumentEntriesList([]); +}; + + +/** + * optional DocumentHistory document_history = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.prototype.getDocumentHistory = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.prototype.setDocumentHistory = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.prototype.clearDocumentHistory = function() { + return this.setDocumentHistory(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.prototype.hasDocumentHistory = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional Proof proof = 2; + * @return {?proto.org.dash.platform.dapi.v0.Proof} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.prototype.getProof = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.prototype.clearProof = function() { + return this.setProof(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.prototype.hasProof = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional ResponseMetadata metadata = 3; + * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.prototype.getMetadata = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.prototype.setMetadata = function(value) { + return jspb.Message.setWrapperField(this, 3, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.prototype.clearMetadata = function() { + return this.setMetadata(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.prototype.hasMetadata = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * optional GetDocumentHistoryResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.prototype.clearV0 = function() { + return this.setV0(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + /** * Oneof group definitions for this message. Each group defines the field * numbers belonging to that group. When of these fields' value is set, all diff --git a/packages/dapi-grpc/clients/platform/v0/web/PlatformPromiseClient.js b/packages/dapi-grpc/clients/platform/v0/web/PlatformPromiseClient.js index 13be28a2d50..dd51dec9bb9 100644 --- a/packages/dapi-grpc/clients/platform/v0/web/PlatformPromiseClient.js +++ b/packages/dapi-grpc/clients/platform/v0/web/PlatformPromiseClient.js @@ -85,6 +85,21 @@ class PlatformPromiseClient { ); } + /** + * + * @param {!GetDocumentHistoryRequest} getDocumentHistoryRequest + * @param {?Object} metadata + * @returns {Promise} + */ + getDocumentHistory(getDocumentHistoryRequest, metadata = {}) { + return promisify( + this.client.getDocumentHistory.bind(this.client), + )( + getDocumentHistoryRequest, + metadata, + ); + } + /** * * @param {!GetDocumentsRequest} getDocumentsRequest diff --git a/packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts b/packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts index fc2e6a5d0da..40fcfe775d9 100644 --- a/packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts +++ b/packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts @@ -3307,6 +3307,203 @@ export namespace GetDocumentsResponse { } } +export class GetDocumentHistoryRequest extends jspb.Message { + hasV0(): boolean; + clearV0(): void; + getV0(): GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 | undefined; + setV0(value?: GetDocumentHistoryRequest.GetDocumentHistoryRequestV0): void; + + getVersionCase(): GetDocumentHistoryRequest.VersionCase; + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetDocumentHistoryRequest.AsObject; + static toObject(includeInstance: boolean, msg: GetDocumentHistoryRequest): GetDocumentHistoryRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetDocumentHistoryRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetDocumentHistoryRequest; + static deserializeBinaryFromReader(message: GetDocumentHistoryRequest, reader: jspb.BinaryReader): GetDocumentHistoryRequest; +} + +export namespace GetDocumentHistoryRequest { + export type AsObject = { + v0?: GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.AsObject, + } + + export class GetDocumentHistoryRequestV0 extends jspb.Message { + getDataContractId(): Uint8Array | string; + getDataContractId_asU8(): Uint8Array; + getDataContractId_asB64(): string; + setDataContractId(value: Uint8Array | string): void; + + getDocumentTypeName(): string; + setDocumentTypeName(value: string): void; + + getDocumentId(): Uint8Array | string; + getDocumentId_asU8(): Uint8Array; + getDocumentId_asB64(): string; + setDocumentId(value: Uint8Array | string): void; + + hasLimit(): boolean; + clearLimit(): void; + getLimit(): google_protobuf_wrappers_pb.UInt32Value | undefined; + setLimit(value?: google_protobuf_wrappers_pb.UInt32Value): void; + + hasOffset(): boolean; + clearOffset(): void; + getOffset(): google_protobuf_wrappers_pb.UInt32Value | undefined; + setOffset(value?: google_protobuf_wrappers_pb.UInt32Value): void; + + getStartAtMs(): string; + setStartAtMs(value: string): void; + + getProve(): boolean; + setProve(value: boolean): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetDocumentHistoryRequestV0.AsObject; + static toObject(includeInstance: boolean, msg: GetDocumentHistoryRequestV0): GetDocumentHistoryRequestV0.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetDocumentHistoryRequestV0, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetDocumentHistoryRequestV0; + static deserializeBinaryFromReader(message: GetDocumentHistoryRequestV0, reader: jspb.BinaryReader): GetDocumentHistoryRequestV0; + } + + export namespace GetDocumentHistoryRequestV0 { + export type AsObject = { + dataContractId: Uint8Array | string, + documentTypeName: string, + documentId: Uint8Array | string, + limit?: google_protobuf_wrappers_pb.UInt32Value.AsObject, + offset?: google_protobuf_wrappers_pb.UInt32Value.AsObject, + startAtMs: string, + prove: boolean, + } + } + + export enum VersionCase { + VERSION_NOT_SET = 0, + V0 = 1, + } +} + +export class GetDocumentHistoryResponse extends jspb.Message { + hasV0(): boolean; + clearV0(): void; + getV0(): GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 | undefined; + setV0(value?: GetDocumentHistoryResponse.GetDocumentHistoryResponseV0): void; + + getVersionCase(): GetDocumentHistoryResponse.VersionCase; + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetDocumentHistoryResponse.AsObject; + static toObject(includeInstance: boolean, msg: GetDocumentHistoryResponse): GetDocumentHistoryResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetDocumentHistoryResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetDocumentHistoryResponse; + static deserializeBinaryFromReader(message: GetDocumentHistoryResponse, reader: jspb.BinaryReader): GetDocumentHistoryResponse; +} + +export namespace GetDocumentHistoryResponse { + export type AsObject = { + v0?: GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.AsObject, + } + + export class GetDocumentHistoryResponseV0 extends jspb.Message { + hasDocumentHistory(): boolean; + clearDocumentHistory(): void; + getDocumentHistory(): GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory | undefined; + setDocumentHistory(value?: GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory): void; + + hasProof(): boolean; + clearProof(): void; + getProof(): Proof | undefined; + setProof(value?: Proof): void; + + hasMetadata(): boolean; + clearMetadata(): void; + getMetadata(): ResponseMetadata | undefined; + setMetadata(value?: ResponseMetadata): void; + + getResultCase(): GetDocumentHistoryResponseV0.ResultCase; + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetDocumentHistoryResponseV0.AsObject; + static toObject(includeInstance: boolean, msg: GetDocumentHistoryResponseV0): GetDocumentHistoryResponseV0.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetDocumentHistoryResponseV0, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetDocumentHistoryResponseV0; + static deserializeBinaryFromReader(message: GetDocumentHistoryResponseV0, reader: jspb.BinaryReader): GetDocumentHistoryResponseV0; + } + + export namespace GetDocumentHistoryResponseV0 { + export type AsObject = { + documentHistory?: GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.AsObject, + proof?: Proof.AsObject, + metadata?: ResponseMetadata.AsObject, + } + + export class DocumentHistoryEntry extends jspb.Message { + getDate(): string; + setDate(value: string): void; + + getValue(): Uint8Array | string; + getValue_asU8(): Uint8Array; + getValue_asB64(): string; + setValue(value: Uint8Array | string): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): DocumentHistoryEntry.AsObject; + static toObject(includeInstance: boolean, msg: DocumentHistoryEntry): DocumentHistoryEntry.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: DocumentHistoryEntry, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): DocumentHistoryEntry; + static deserializeBinaryFromReader(message: DocumentHistoryEntry, reader: jspb.BinaryReader): DocumentHistoryEntry; + } + + export namespace DocumentHistoryEntry { + export type AsObject = { + date: string, + value: Uint8Array | string, + } + } + + export class DocumentHistory extends jspb.Message { + clearDocumentEntriesList(): void; + getDocumentEntriesList(): Array; + setDocumentEntriesList(value: Array): void; + addDocumentEntries(value?: GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry, index?: number): GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): DocumentHistory.AsObject; + static toObject(includeInstance: boolean, msg: DocumentHistory): DocumentHistory.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: DocumentHistory, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): DocumentHistory; + static deserializeBinaryFromReader(message: DocumentHistory, reader: jspb.BinaryReader): DocumentHistory; + } + + export namespace DocumentHistory { + export type AsObject = { + documentEntriesList: Array, + } + } + + export enum ResultCase { + RESULT_NOT_SET = 0, + DOCUMENT_HISTORY = 1, + PROOF = 2, + } + } + + export enum VersionCase { + VERSION_NOT_SET = 0, + V0 = 1, + } +} + export class GetIdentityByPublicKeyHashRequest extends jspb.Message { hasV0(): boolean; clearV0(): void; diff --git a/packages/dapi-grpc/clients/platform/v0/web/platform_pb.js b/packages/dapi-grpc/clients/platform/v0/web/platform_pb.js index 2553cd1a237..ed0d58a5e75 100644 --- a/packages/dapi-grpc/clients/platform/v0/web/platform_pb.js +++ b/packages/dapi-grpc/clients/platform/v0/web/platform_pb.js @@ -150,6 +150,15 @@ goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDataContractsResponse.Data goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0', null, { proto }); goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.ResultCase', null, { proto }); goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDataContractsResponse.VersionCase', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.VersionCase', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.ResultCase', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.VersionCase', null, { proto }); goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDocumentsRequest', null, { proto }); goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDocumentsRequest.DocumentFieldValue', null, { proto }); goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDocumentsRequest.DocumentFieldValue.ValueList', null, { proto }); @@ -2733,6 +2742,132 @@ if (goog.DEBUG && !COMPILED) { */ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.ResultData.displayName = 'proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV1.ResultData'; } +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.oneofGroups_); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.displayName = 'proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0 = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.displayName = 'proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.oneofGroups_); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.displayName = 'proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0 = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.oneofGroups_); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.displayName = 'proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.displayName = 'proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.repeatedFields_, null); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.displayName = 'proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory'; +} /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a @@ -31557,6 +31692,1381 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.hasV1 = function( +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.oneofGroups_ = [[1]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.VersionCase} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest; + return proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.deserializeBinaryFromReader); + msg.setV0(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getV0(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.serializeBinaryToWriter + ); + } +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.toObject = function(includeInstance, msg) { + var f, obj = { + dataContractId: msg.getDataContractId_asB64(), + documentTypeName: jspb.Message.getFieldWithDefault(msg, 2, ""), + documentId: msg.getDocumentId_asB64(), + limit: (f = msg.getLimit()) && google_protobuf_wrappers_pb.UInt32Value.toObject(includeInstance, f), + offset: (f = msg.getOffset()) && google_protobuf_wrappers_pb.UInt32Value.toObject(includeInstance, f), + startAtMs: jspb.Message.getFieldWithDefault(msg, 6, "0"), + prove: jspb.Message.getBooleanFieldWithDefault(msg, 7, false) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0; + return proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setDataContractId(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setDocumentTypeName(value); + break; + case 3: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setDocumentId(value); + break; + case 4: + var value = new google_protobuf_wrappers_pb.UInt32Value; + reader.readMessage(value,google_protobuf_wrappers_pb.UInt32Value.deserializeBinaryFromReader); + msg.setLimit(value); + break; + case 5: + var value = new google_protobuf_wrappers_pb.UInt32Value; + reader.readMessage(value,google_protobuf_wrappers_pb.UInt32Value.deserializeBinaryFromReader); + msg.setOffset(value); + break; + case 6: + var value = /** @type {string} */ (reader.readUint64String()); + msg.setStartAtMs(value); + break; + case 7: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getDataContractId_asU8(); + if (f.length > 0) { + writer.writeBytes( + 1, + f + ); + } + f = message.getDocumentTypeName(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getDocumentId_asU8(); + if (f.length > 0) { + writer.writeBytes( + 3, + f + ); + } + f = message.getLimit(); + if (f != null) { + writer.writeMessage( + 4, + f, + google_protobuf_wrappers_pb.UInt32Value.serializeBinaryToWriter + ); + } + f = message.getOffset(); + if (f != null) { + writer.writeMessage( + 5, + f, + google_protobuf_wrappers_pb.UInt32Value.serializeBinaryToWriter + ); + } + f = message.getStartAtMs(); + if (parseInt(f, 10) !== 0) { + writer.writeUint64String( + 6, + f + ); + } + f = message.getProve(); + if (f) { + writer.writeBool( + 7, + f + ); + } +}; + + +/** + * optional bytes data_contract_id = 1; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.getDataContractId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * optional bytes data_contract_id = 1; + * This is a type-conversion wrapper around `getDataContractId()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.getDataContractId_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getDataContractId())); +}; + + +/** + * optional bytes data_contract_id = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getDataContractId()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.getDataContractId_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getDataContractId())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.setDataContractId = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); +}; + + +/** + * optional string document_type_name = 2; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.getDocumentTypeName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.setDocumentTypeName = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * optional bytes document_id = 3; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.getDocumentId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * optional bytes document_id = 3; + * This is a type-conversion wrapper around `getDocumentId()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.getDocumentId_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getDocumentId())); +}; + + +/** + * optional bytes document_id = 3; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getDocumentId()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.getDocumentId_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getDocumentId())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.setDocumentId = function(value) { + return jspb.Message.setProto3BytesField(this, 3, value); +}; + + +/** + * optional google.protobuf.UInt32Value limit = 4; + * @return {?proto.google.protobuf.UInt32Value} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.getLimit = function() { + return /** @type{?proto.google.protobuf.UInt32Value} */ ( + jspb.Message.getWrapperField(this, google_protobuf_wrappers_pb.UInt32Value, 4)); +}; + + +/** + * @param {?proto.google.protobuf.UInt32Value|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.setLimit = function(value) { + return jspb.Message.setWrapperField(this, 4, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.clearLimit = function() { + return this.setLimit(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.hasLimit = function() { + return jspb.Message.getField(this, 4) != null; +}; + + +/** + * optional google.protobuf.UInt32Value offset = 5; + * @return {?proto.google.protobuf.UInt32Value} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.getOffset = function() { + return /** @type{?proto.google.protobuf.UInt32Value} */ ( + jspb.Message.getWrapperField(this, google_protobuf_wrappers_pb.UInt32Value, 5)); +}; + + +/** + * @param {?proto.google.protobuf.UInt32Value|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.setOffset = function(value) { + return jspb.Message.setWrapperField(this, 5, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.clearOffset = function() { + return this.setOffset(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.hasOffset = function() { + return jspb.Message.getField(this, 5) != null; +}; + + +/** + * optional uint64 start_at_ms = 6; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.getStartAtMs = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 6, "0")); +}; + + +/** + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.setStartAtMs = function(value) { + return jspb.Message.setProto3StringIntField(this, 6, value); +}; + + +/** + * optional bool prove = 7; + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 7, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 7, value); +}; + + +/** + * optional GetDocumentHistoryRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.GetDocumentHistoryRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.prototype.clearV0 = function() { + return this.setV0(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryRequest.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.oneofGroups_ = [[1]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.VersionCase} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse; + return proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.deserializeBinaryFromReader); + msg.setV0(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getV0(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.serializeBinaryToWriter + ); + } +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.oneofGroups_ = [[1,2]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.ResultCase = { + RESULT_NOT_SET: 0, + DOCUMENT_HISTORY: 1, + PROOF: 2 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.ResultCase} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.toObject = function(includeInstance, msg) { + var f, obj = { + documentHistory: (f = msg.getDocumentHistory()) && proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.toObject(includeInstance, f), + proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), + metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0; + return proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.deserializeBinaryFromReader); + msg.setDocumentHistory(value); + break; + case 2: + var value = new proto.org.dash.platform.dapi.v0.Proof; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); + msg.setProof(value); + break; + case 3: + var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); + msg.setMetadata(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getDocumentHistory(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.serializeBinaryToWriter + ); + } + f = message.getProof(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter + ); + } + f = message.getMetadata(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter + ); + } +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.toObject = function(includeInstance, msg) { + var f, obj = { + date: jspb.Message.getFieldWithDefault(msg, 1, "0"), + value: msg.getValue_asB64() + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry; + return proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readUint64String()); + msg.setDate(value); + break; + case 2: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setValue(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getDate(); + if (parseInt(f, 10) !== 0) { + writer.writeUint64String( + 1, + f + ); + } + f = message.getValue_asU8(); + if (f.length > 0) { + writer.writeBytes( + 2, + f + ); + } +}; + + +/** + * optional uint64 date = 1; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.prototype.getDate = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "0")); +}; + + +/** + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.prototype.setDate = function(value) { + return jspb.Message.setProto3StringIntField(this, 1, value); +}; + + +/** + * optional bytes value = 2; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.prototype.getValue = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * optional bytes value = 2; + * This is a type-conversion wrapper around `getValue()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.prototype.getValue_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getValue())); +}; + + +/** + * optional bytes value = 2; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getValue()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.prototype.getValue_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getValue())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.prototype.setValue = function(value) { + return jspb.Message.setProto3BytesField(this, 2, value); +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.repeatedFields_ = [1]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.toObject = function(includeInstance, msg) { + var f, obj = { + documentEntriesList: jspb.Message.toObjectList(msg.getDocumentEntriesList(), + proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.toObject, includeInstance) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory; + return proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.deserializeBinaryFromReader); + msg.addDocumentEntries(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getDocumentEntriesList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry.serializeBinaryToWriter + ); + } +}; + + +/** + * repeated DocumentHistoryEntry document_entries = 1; + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.prototype.getDocumentEntriesList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry, 1)); +}; + + +/** + * @param {!Array} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.prototype.setDocumentEntriesList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 1, value); +}; + + +/** + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry=} opt_value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.prototype.addDocumentEntries = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistoryEntry, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory.prototype.clearDocumentEntriesList = function() { + return this.setDocumentEntriesList([]); +}; + + +/** + * optional DocumentHistory document_history = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.prototype.getDocumentHistory = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.DocumentHistory|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.prototype.setDocumentHistory = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.prototype.clearDocumentHistory = function() { + return this.setDocumentHistory(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.prototype.hasDocumentHistory = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional Proof proof = 2; + * @return {?proto.org.dash.platform.dapi.v0.Proof} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.prototype.getProof = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.prototype.clearProof = function() { + return this.setProof(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.prototype.hasProof = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional ResponseMetadata metadata = 3; + * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.prototype.getMetadata = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.prototype.setMetadata = function(value) { + return jspb.Message.setWrapperField(this, 3, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.prototype.clearMetadata = function() { + return this.setMetadata(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0.prototype.hasMetadata = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * optional GetDocumentHistoryResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.GetDocumentHistoryResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.prototype.clearV0 = function() { + return this.setV0(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetDocumentHistoryResponse.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + /** * Oneof group definitions for this message. Each group defines the field * numbers belonging to that group. When of these fields' value is set, all diff --git a/packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.d.ts b/packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.d.ts index 589095161be..58418b14e96 100644 --- a/packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.d.ts +++ b/packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.d.ts @@ -130,6 +130,15 @@ type PlatformgetDataContracts = { readonly responseType: typeof platform_pb.GetDataContractsResponse; }; +type PlatformgetDocumentHistory = { + readonly methodName: string; + readonly service: typeof Platform; + readonly requestStream: false; + readonly responseStream: false; + readonly requestType: typeof platform_pb.GetDocumentHistoryRequest; + readonly responseType: typeof platform_pb.GetDocumentHistoryResponse; +}; + type PlatformgetDocuments = { readonly methodName: string; readonly service: typeof Platform; @@ -578,6 +587,7 @@ export class Platform { static readonly getDataContract: PlatformgetDataContract; static readonly getDataContractHistory: PlatformgetDataContractHistory; static readonly getDataContracts: PlatformgetDataContracts; + static readonly getDocumentHistory: PlatformgetDocumentHistory; static readonly getDocuments: PlatformgetDocuments; static readonly getIdentityByPublicKeyHash: PlatformgetIdentityByPublicKeyHash; static readonly getIdentityByNonUniquePublicKeyHash: PlatformgetIdentityByNonUniquePublicKeyHash; @@ -786,6 +796,15 @@ export class PlatformClient { requestMessage: platform_pb.GetDataContractsRequest, callback: (error: ServiceError|null, responseMessage: platform_pb.GetDataContractsResponse|null) => void ): UnaryResponse; + getDocumentHistory( + requestMessage: platform_pb.GetDocumentHistoryRequest, + metadata: grpc.Metadata, + callback: (error: ServiceError|null, responseMessage: platform_pb.GetDocumentHistoryResponse|null) => void + ): UnaryResponse; + getDocumentHistory( + requestMessage: platform_pb.GetDocumentHistoryRequest, + callback: (error: ServiceError|null, responseMessage: platform_pb.GetDocumentHistoryResponse|null) => void + ): UnaryResponse; getDocuments( requestMessage: platform_pb.GetDocumentsRequest, metadata: grpc.Metadata, diff --git a/packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.js b/packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.js index e7d245b66a6..d02bf1cd66e 100644 --- a/packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.js +++ b/packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.js @@ -136,6 +136,15 @@ Platform.getDataContracts = { responseType: platform_pb.GetDataContractsResponse }; +Platform.getDocumentHistory = { + methodName: "getDocumentHistory", + service: Platform, + requestStream: false, + responseStream: false, + requestType: platform_pb.GetDocumentHistoryRequest, + responseType: platform_pb.GetDocumentHistoryResponse +}; + Platform.getDocuments = { methodName: "getDocuments", service: Platform, @@ -1009,6 +1018,37 @@ PlatformClient.prototype.getDataContracts = function getDataContracts(requestMes }; }; +PlatformClient.prototype.getDocumentHistory = function getDocumentHistory(requestMessage, metadata, callback) { + if (arguments.length === 2) { + callback = arguments[1]; + } + var client = grpc.unary(Platform.getDocumentHistory, { + request: requestMessage, + host: this.serviceHost, + metadata: metadata, + transport: this.options.transport, + debug: this.options.debug, + onEnd: function (response) { + if (callback) { + if (response.status !== grpc.Code.OK) { + var err = new Error(response.statusMessage); + err.code = response.status; + err.metadata = response.trailers; + callback(err, null); + } else { + callback(null, response.message); + } + } + } + }); + return { + cancel: function () { + callback = null; + client.close(); + } + }; +}; + PlatformClient.prototype.getDocuments = function getDocuments(requestMessage, metadata, callback) { if (arguments.length === 2) { callback = arguments[1]; diff --git a/packages/dapi-grpc/protos/platform/v0/platform.proto b/packages/dapi-grpc/protos/platform/v0/platform.proto index 506db668e52..3756cc7c309 100644 --- a/packages/dapi-grpc/protos/platform/v0/platform.proto +++ b/packages/dapi-grpc/protos/platform/v0/platform.proto @@ -35,6 +35,8 @@ service Platform { returns (GetDataContractHistoryResponse); rpc getDataContracts(GetDataContractsRequest) returns (GetDataContractsResponse); + rpc getDocumentHistory(GetDocumentHistoryRequest) + returns (GetDocumentHistoryResponse); rpc getDocuments(GetDocumentsRequest) returns (GetDocumentsResponse); rpc getIdentityByPublicKeyHash(GetIdentityByPublicKeyHashRequest) returns (GetIdentityByPublicKeyHashResponse); @@ -1300,6 +1302,49 @@ message GetDocumentsResponse { } } +message GetDocumentHistoryRequest { + message GetDocumentHistoryRequestV0 { + bytes data_contract_id = 1; // The ID of the data contract + string document_type_name = 2; // The document type name + bytes document_id = 3; // The document ID + google.protobuf.UInt32Value limit = + 4; // The maximum number of history entries to return + google.protobuf.UInt32Value offset = + 5; // The offset for pagination through the document history + uint64 start_at_ms = 6 [ + jstype = JS_STRING + ]; // Only return results after this time in milliseconds + bool prove = 7; // Flag to request a proof as the response + } + oneof version { GetDocumentHistoryRequestV0 v0 = 1; } +} + +message GetDocumentHistoryResponse { + message GetDocumentHistoryResponseV0 { + // Represents a single entry in a document's history + message DocumentHistoryEntry { + uint64 date = 1 [ jstype = JS_STRING ]; // The date of the history entry + bytes value = 2; // The value of the document at this point in history + } + + // Collection of document history entries + message DocumentHistory { + repeated DocumentHistoryEntry document_entries = + 1; // List of history entries + } + + oneof result { + DocumentHistory document_history = + 1; // The actual history of the document + Proof proof = + 2; // Cryptographic proof of the document history, if requested + } + + ResponseMetadata metadata = 3; // Metadata about the blockchain state + } + oneof version { GetDocumentHistoryResponseV0 v0 = 1; } +} + message GetIdentityByPublicKeyHashRequest { message GetIdentityByPublicKeyHashRequestV0 { bytes public_key_hash = diff --git a/packages/js-evo-sdk/src/documents/facade.ts b/packages/js-evo-sdk/src/documents/facade.ts index 3c3acc66dda..c97e1ac4bd5 100644 --- a/packages/js-evo-sdk/src/documents/facade.ts +++ b/packages/js-evo-sdk/src/documents/facade.ts @@ -23,6 +23,18 @@ export class DocumentsFacade { return w.getDocumentsWithProofInfo(query); } + async history(query: wasm.DocumentHistoryQuery): Promise> { + const w = await this.sdk.getWasmSdkConnected(); + return w.getDocumentHistory(query); + } + + async historyWithProof( + query: wasm.DocumentHistoryQuery, + ): Promise>> { + const w = await this.sdk.getWasmSdkConnected(); + return w.getDocumentHistoryWithProofInfo(query); + } + async get(contractId: wasm.IdentifierLike, type: string, documentId: wasm.IdentifierLike): Promise { const w = await this.sdk.getWasmSdkConnected(); diff --git a/packages/js-evo-sdk/tests/unit/facades/documents.spec.ts b/packages/js-evo-sdk/tests/unit/facades/documents.spec.ts index 3e776ffa403..a2928bc6083 100644 --- a/packages/js-evo-sdk/tests/unit/facades/documents.spec.ts +++ b/packages/js-evo-sdk/tests/unit/facades/documents.spec.ts @@ -19,6 +19,8 @@ describe('DocumentsFacade', () => { // Stub references for type-safe assertions let getDocumentsStub: SinonStub; let getDocumentsWithProofInfoStub: SinonStub; + let getDocumentHistoryStub: SinonStub; + let getDocumentHistoryWithProofInfoStub: SinonStub; let getDocumentStub: SinonStub; let getDocumentWithProofInfoStub: SinonStub; let documentCreateStub: SinonStub; @@ -46,6 +48,15 @@ describe('DocumentsFacade', () => { proof: {}, metadata: {}, }); + getDocumentHistoryStub = this.sinon.stub(wasmSdk, 'getDocumentHistory').resolves(new Map()); + getDocumentHistoryWithProofInfoStub = this.sinon.stub( + wasmSdk, + 'getDocumentHistoryWithProofInfo', + ).resolves({ + data: new Map(), + proof: {}, + metadata: {}, + }); getDocumentStub = this.sinon.stub(wasmSdk, 'getDocument').resolves(document); getDocumentWithProofInfoStub = this.sinon.stub(wasmSdk, 'getDocumentWithProofInfo').resolves({ data: document, @@ -91,6 +102,37 @@ describe('DocumentsFacade', () => { }); }); + describe('history()', () => { + it('should fetch document history', async () => { + const query = { + dataContractId: 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec', + documentTypeName: 'note', + documentId: '4mZmxva49PBb7BE7srw9o3gixvDfj1dAx1K6z4A7P9Ah', + startAtMs: 1000, + limit: 10, + offset: 1, + }; + + await client.documents.history(query); + + expect(getDocumentHistoryStub).to.be.calledOnceWithExactly(query); + }); + }); + + describe('historyWithProof()', () => { + it('should fetch document history with proof metadata', async () => { + const query = { + dataContractId: 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec', + documentTypeName: 'note', + documentId: '4mZmxva49PBb7BE7srw9o3gixvDfj1dAx1K6z4A7P9Ah', + }; + + await client.documents.historyWithProof(query); + + expect(getDocumentHistoryWithProofInfoStub).to.be.calledOnceWithExactly(query); + }); + }); + describe('get()', () => { it('should fetch a single document by ID', async () => { const contractId = 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec'; diff --git a/packages/rs-dapi-client/src/transport/grpc.rs b/packages/rs-dapi-client/src/transport/grpc.rs index 3b9aa9eed5b..07de1348657 100644 --- a/packages/rs-dapi-client/src/transport/grpc.rs +++ b/packages/rs-dapi-client/src/transport/grpc.rs @@ -229,6 +229,14 @@ impl_transport_request_grpc!( get_data_contract_history ); +impl_transport_request_grpc!( + platform_proto::GetDocumentHistoryRequest, + platform_proto::GetDocumentHistoryResponse, + PlatformGrpcClient, + RequestSettings::default(), + get_document_history +); + impl_transport_request_grpc!( platform_proto::BroadcastStateTransitionRequest, platform_proto::BroadcastStateTransitionResponse, diff --git a/packages/rs-dapi/src/services/platform_service/mod.rs b/packages/rs-dapi/src/services/platform_service/mod.rs index 1fa71606a43..074dad5d38c 100644 --- a/packages/rs-dapi/src/services/platform_service/mod.rs +++ b/packages/rs-dapi/src/services/platform_service/mod.rs @@ -344,6 +344,12 @@ impl Platform for PlatformServiceImpl { dapi_grpc::platform::v0::GetDocumentsResponse ); + drive_method!( + get_document_history, + dapi_grpc::platform::v0::GetDocumentHistoryRequest, + dapi_grpc::platform::v0::GetDocumentHistoryResponse + ); + // System methods drive_method!( get_consensus_params, diff --git a/packages/rs-drive-abci/src/query/document_history/mod.rs b/packages/rs-drive-abci/src/query/document_history/mod.rs new file mode 100644 index 00000000000..bccdcfa9fae --- /dev/null +++ b/packages/rs-drive-abci/src/query/document_history/mod.rs @@ -0,0 +1,55 @@ +use crate::error::query::QueryError; +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::platform_types::platform_state::PlatformState; +use crate::query::QueryValidationResult; +use dapi_grpc::platform::v0::get_document_history_request::Version as RequestVersion; +use dapi_grpc::platform::v0::get_document_history_response::Version as ResponseVersion; +use dapi_grpc::platform::v0::{GetDocumentHistoryRequest, GetDocumentHistoryResponse}; +use dpp::version::PlatformVersion; + +mod v0; + +impl Platform { + /// Querying of a document history. + pub fn query_document_history( + &self, + GetDocumentHistoryRequest { version }: GetDocumentHistoryRequest, + platform_state: &PlatformState, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let Some(version) = version else { + return Ok(QueryValidationResult::new_with_error( + QueryError::DecodingError("could not decode document history query".to_string()), + )); + }; + + let feature_version_bounds = &platform_version.drive_abci.query.document_history; + + let feature_version = match &version { + RequestVersion::V0(_) => 0, + }; + if !feature_version_bounds.check_version(feature_version) { + return Ok(QueryValidationResult::new_with_error( + QueryError::UnsupportedQueryVersion( + "document_history".to_string(), + feature_version_bounds.min_version, + feature_version_bounds.max_version, + platform_version.protocol_version, + feature_version, + ), + )); + } + + match version { + RequestVersion::V0(request_v0) => { + let result = + self.query_document_history_v0(request_v0, platform_state, platform_version)?; + + Ok(result.map(|response_v0| GetDocumentHistoryResponse { + version: Some(ResponseVersion::V0(response_v0)), + })) + } + } + } +} diff --git a/packages/rs-drive-abci/src/query/document_history/v0/mod.rs b/packages/rs-drive-abci/src/query/document_history/v0/mod.rs new file mode 100644 index 00000000000..2e1d638891f --- /dev/null +++ b/packages/rs-drive-abci/src/query/document_history/v0/mod.rs @@ -0,0 +1,253 @@ +use crate::error::query::QueryError; +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::platform_types::platform_state::PlatformState; +use crate::query::response_metadata::CheckpointUsed; +use crate::query::QueryValidationResult; +use dapi_grpc::platform::v0::get_document_history_request::GetDocumentHistoryRequestV0; +use dapi_grpc::platform::v0::get_document_history_response::get_document_history_response_v0::DocumentHistoryEntry; +use dapi_grpc::platform::v0::get_document_history_response::{ + get_document_history_response_v0, GetDocumentHistoryResponseV0, +}; +use dpp::check_validation_result_with_data; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; +use dpp::identifier::Identifier; +use dpp::validation::ValidationResult; +use dpp::version::PlatformVersion; +use drive::drive::document::MAX_DOCUMENT_HISTORY_FETCH_LIMIT; +use drive::util::grove_operations::GroveDBToUse; + +impl Platform { + pub(super) fn query_document_history_v0( + &self, + GetDocumentHistoryRequestV0 { + data_contract_id, + document_type_name, + document_id, + limit, + offset, + start_at_ms, + prove, + }: GetDocumentHistoryRequestV0, + platform_state: &PlatformState, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let contract_id: Identifier = + check_validation_result_with_data!(data_contract_id.try_into().map_err(|_| { + QueryError::InvalidArgument( + "data_contract_id must be a valid identifier (32 bytes long)".to_string(), + ) + })); + let document_id: Identifier = + check_validation_result_with_data!(document_id.try_into().map_err(|_| { + QueryError::InvalidArgument( + "document_id must be a valid identifier (32 bytes long)".to_string(), + ) + })); + + let limit = check_validation_result_with_data!(limit + .map(|limit| { + let limit = u16::try_from(limit) + .map_err(|_| QueryError::InvalidArgument("limit out of bounds".to_string()))?; + + if !(1..=MAX_DOCUMENT_HISTORY_FETCH_LIMIT).contains(&limit) { + return Err(QueryError::InvalidArgument(format!( + "limit {} out of bounds of [1, {}]", + limit, MAX_DOCUMENT_HISTORY_FETCH_LIMIT, + ))); + } + + Ok(limit) + }) + .transpose()); + + let offset = check_validation_result_with_data!(offset + .map(|offset| { + u16::try_from(offset) + .map_err(|_| QueryError::InvalidArgument("offset out of bounds".to_string())) + }) + .transpose()); + + let maybe_contract_fetch_info = self + .drive + .fetch_contract(contract_id.to_buffer(), None, None, None, platform_version) + .unwrap()?; + let contract_fetch_info = check_validation_result_with_data!(maybe_contract_fetch_info + .ok_or_else(|| { + QueryError::NotFound(format!("data contract {} not found", contract_id)) + })); + let contract = &contract_fetch_info.contract; + let document_type = check_validation_result_with_data!(contract + .document_type_for_name(&document_type_name) + .map_err(|_| QueryError::NotFound(format!( + "document type {} not found in data contract {}", + document_type_name, contract_id + )))); + + let response = if prove { + let proof = self.drive.prove_document_history( + contract_id.to_buffer(), + &document_type_name, + document_id.to_buffer(), + None, + start_at_ms, + limit, + offset, + platform_version, + )?; + + GetDocumentHistoryResponseV0 { + result: Some(get_document_history_response_v0::Result::Proof( + self.response_proof_v0(platform_state, proof, GroveDBToUse::Current) + .map(|(_, proof)| proof)?, + )), + metadata: Some(self.response_metadata_v0(platform_state, CheckpointUsed::Current)), + } + } else { + let documents = self.drive.fetch_document_history( + contract_id.to_buffer(), + &document_type_name, + document_type, + document_id.to_buffer(), + None, + start_at_ms, + limit, + offset, + platform_version, + )?; + + let document_entries = documents + .into_iter() + .map(|(date, document)| { + Ok(DocumentHistoryEntry { + date, + value: document + .serialize(document_type, contract, platform_version) + .map_err(Error::Protocol)?, + }) + }) + .collect::, Error>>()?; + + GetDocumentHistoryResponseV0 { + result: Some(get_document_history_response_v0::Result::DocumentHistory( + get_document_history_response_v0::DocumentHistory { document_entries }, + )), + metadata: Some(self.response_metadata_v0(platform_state, CheckpointUsed::Current)), + } + }; + + Ok(QueryValidationResult::new_with_data(response)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::query::tests::setup_platform; + use dpp::block::block_info::BlockInfo; + use dpp::dashcore::Network; + use dpp::data_contract::accessors::v0::DataContractV0Getters; + use dpp::document::DocumentV0Getters; + use dpp::tests::json_document::{json_document_to_contract, json_document_to_document}; + use dpp::tests::utils::generate_random_identifier_struct; + use drive::util::object_size_info::DocumentInfo::DocumentRefInfo; + use drive::util::object_size_info::{DocumentAndContractInfo, OwnedDocumentInfo}; + use drive::util::storage_flags::StorageFlags; + + const DOCUMENT_TYPE_NAME: &str = "profile"; + + #[test] + fn should_return_empty_document_history_page_without_error() { + let (platform, state, version) = setup_platform(None, Network::Testnet, None); + let contract = json_document_to_contract( + concat!( + env!("CARGO_MANIFEST_DIR"), + "/../rs-drive/tests/supporting_files/contract/dashpay/dashpay-contract-with-profile-history.json" + ), + false, + version, + ) + .expect("expected contract"); + + platform + .drive + .apply_contract( + &contract, + BlockInfo::default(), + true, + StorageFlags::optional_default_as_cow(), + None, + version, + ) + .expect("apply contract"); + + let document_type = contract + .document_type_for_name(DOCUMENT_TYPE_NAME) + .expect("profile document type"); + let document = json_document_to_document( + concat!( + env!("CARGO_MANIFEST_DIR"), + "/../rs-drive/tests/supporting_files/contract/dashpay/profile0.json" + ), + Some(generate_random_identifier_struct()), + document_type, + version, + ) + .expect("expected document"); + + platform + .drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentRefInfo(( + &document, + StorageFlags::optional_default_as_cow(), + )), + owner_id: None, + }, + contract: &contract, + document_type, + }, + true, + BlockInfo::default_with_time(1000), + true, + None, + version, + None, + ) + .expect("put document"); + + let request = GetDocumentHistoryRequestV0 { + data_contract_id: contract.id().to_vec(), + document_type_name: DOCUMENT_TYPE_NAME.to_string(), + document_id: document.id().to_vec(), + limit: Some(10), + offset: None, + start_at_ms: 1000, + prove: false, + }; + + let result = platform + .query_document_history_v0(request, &state, version) + .expect("query document history"); + + assert!( + result.errors.is_empty(), + "expected empty history page to be successful" + ); + + let response = result.data.expect("expected data"); + let GetDocumentHistoryResponseV0 { + result: + Some(get_document_history_response_v0::Result::DocumentHistory(document_history)), + metadata: Some(_), + } = response + else { + panic!("expected document history response"); + }; + + assert!(document_history.document_entries.is_empty()); + } +} diff --git a/packages/rs-drive-abci/src/query/mod.rs b/packages/rs-drive-abci/src/query/mod.rs index e3cc7911f1f..9e1dab2b082 100644 --- a/packages/rs-drive-abci/src/query/mod.rs +++ b/packages/rs-drive-abci/src/query/mod.rs @@ -1,5 +1,6 @@ mod address_funds; mod data_contract_based_queries; +mod document_history; mod document_query; mod group_queries; mod identity_based_queries; diff --git a/packages/rs-drive-abci/src/query/service.rs b/packages/rs-drive-abci/src/query/service.rs index 5bf6259fa6d..bdc04142bcb 100644 --- a/packages/rs-drive-abci/src/query/service.rs +++ b/packages/rs-drive-abci/src/query/service.rs @@ -22,13 +22,14 @@ use dapi_grpc::platform::v0::{ GetContestedResourcesRequest, GetContestedResourcesResponse, GetCurrentQuorumsInfoRequest, GetCurrentQuorumsInfoResponse, GetDataContractHistoryRequest, GetDataContractHistoryResponse, GetDataContractRequest, GetDataContractResponse, GetDataContractsRequest, - GetDataContractsResponse, GetDocumentsRequest, GetDocumentsResponse, GetEpochsInfoRequest, - GetEpochsInfoResponse, GetEvonodesProposedEpochBlocksByIdsRequest, - GetEvonodesProposedEpochBlocksByRangeRequest, GetEvonodesProposedEpochBlocksResponse, - GetFinalizedEpochInfosRequest, GetFinalizedEpochInfosResponse, GetGroupActionSignersRequest, - GetGroupActionSignersResponse, GetGroupActionsRequest, GetGroupActionsResponse, - GetGroupInfoRequest, GetGroupInfoResponse, GetGroupInfosRequest, GetGroupInfosResponse, - GetIdentitiesBalancesRequest, GetIdentitiesBalancesResponse, GetIdentitiesContractKeysRequest, + GetDataContractsResponse, GetDocumentHistoryRequest, GetDocumentHistoryResponse, + GetDocumentsRequest, GetDocumentsResponse, GetEpochsInfoRequest, GetEpochsInfoResponse, + GetEvonodesProposedEpochBlocksByIdsRequest, GetEvonodesProposedEpochBlocksByRangeRequest, + GetEvonodesProposedEpochBlocksResponse, GetFinalizedEpochInfosRequest, + GetFinalizedEpochInfosResponse, GetGroupActionSignersRequest, GetGroupActionSignersResponse, + GetGroupActionsRequest, GetGroupActionsResponse, GetGroupInfoRequest, GetGroupInfoResponse, + GetGroupInfosRequest, GetGroupInfosResponse, GetIdentitiesBalancesRequest, + GetIdentitiesBalancesResponse, GetIdentitiesContractKeysRequest, GetIdentitiesContractKeysResponse, GetIdentitiesTokenBalancesRequest, GetIdentitiesTokenBalancesResponse, GetIdentitiesTokenInfosRequest, GetIdentitiesTokenInfosResponse, GetIdentityBalanceAndRevisionRequest, @@ -393,6 +394,18 @@ impl PlatformService for QueryService { .await } + async fn get_document_history( + &self, + request: Request, + ) -> Result, Status> { + self.handle_blocking_query( + request, + Platform::::query_document_history, + "get_document_history", + ) + .await + } + async fn get_documents( &self, request: Request, diff --git a/packages/rs-drive-proof-verifier/Cargo.toml b/packages/rs-drive-proof-verifier/Cargo.toml index f05fd5d1846..5ef2372aee3 100644 --- a/packages/rs-drive-proof-verifier/Cargo.toml +++ b/packages/rs-drive-proof-verifier/Cargo.toml @@ -42,3 +42,8 @@ serde = { version = "1.0.219", default-features = false, optional = true } hex = { version = "0.4.3" } indexmap = { version = "2.6.0" } derive_more = { version = "1.0", features = ["from"] } + +[dev-dependencies] +dpp = { path = "../rs-dpp", features = [ + "fixtures-and-mocks", +], default-features = false } diff --git a/packages/rs-drive-proof-verifier/src/proof.rs b/packages/rs-drive-proof-verifier/src/proof.rs index 55b4b037267..e37ea29946b 100644 --- a/packages/rs-drive-proof-verifier/src/proof.rs +++ b/packages/rs-drive-proof-verifier/src/proof.rs @@ -39,7 +39,7 @@ use dapi_grpc::platform::v0::get_protocol_version_upgrade_vote_status_request::{ use dapi_grpc::platform::v0::security_level_map::KeyKindRequestType as GrpcKeyKind; use dapi_grpc::platform::v0::{ get_address_info_request, get_addresses_infos_request, - get_contested_resource_identity_votes_request, get_data_contract_history_request, get_data_contract_request, get_data_contracts_request, get_epochs_info_request, get_evonodes_proposed_epoch_blocks_by_ids_request, get_evonodes_proposed_epoch_blocks_by_range_request, get_finalized_epoch_infos_request, get_identities_balances_request, get_identities_contract_keys_request, get_identity_balance_and_revision_request, get_identity_balance_request, get_identity_by_non_unique_public_key_hash_request, + get_contested_resource_identity_votes_request, get_data_contract_history_request, get_data_contract_request, get_data_contracts_request, get_document_history_request, get_epochs_info_request, get_evonodes_proposed_epoch_blocks_by_ids_request, get_evonodes_proposed_epoch_blocks_by_range_request, get_finalized_epoch_infos_request, get_identities_balances_request, get_identities_contract_keys_request, get_identity_balance_and_revision_request, get_identity_balance_request, get_identity_by_non_unique_public_key_hash_request, get_identity_by_public_key_hash_request, get_identity_contract_nonce_request, get_identity_keys_request, get_identity_nonce_request, get_identity_request, get_path_elements_request, get_prefunded_specialized_balance_request, GetContestedResourceVotersForIdentityRequest, GetContestedResourceVotersForIdentityResponse, GetPathElementsRequest, GetPathElementsResponse, GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeStateResponse, GetProtocolVersionUpgradeVoteStatusRequest, GetProtocolVersionUpgradeVoteStatusResponse, Proof, ResponseMetadata }; use dapi_grpc::platform::{ @@ -51,6 +51,7 @@ use dpp::block::block_info::BlockInfo; use dpp::block::epoch::EpochIndex; use dpp::block::extended_epoch_info::ExtendedEpochInfo; use dpp::core_subsidy::NetworkCoreSubsidy; +use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::dashcore::hashes::Hash; use dpp::dashcore::{Network, ProTxHash}; use dpp::document::{Document, DocumentV0Getters}; @@ -1428,6 +1429,85 @@ impl FromProof for DataContractHistory } } +impl FromProof for DocumentHistory { + type Request = platform::GetDocumentHistoryRequest; + type Response = platform::GetDocumentHistoryResponse; + + fn maybe_from_proof_with_metadata<'a, I: Into, O: Into>( + request: I, + response: O, + _network: Network, + platform_version: &PlatformVersion, + provider: &'a dyn ContextProvider, + ) -> Result<(Option, ResponseMetadata, Proof), Error> + where + Self: Sized + 'a, + { + let request: Self::Request = request.into(); + let response: Self::Response = response.into(); + + let proof = response.proof().or(Err(Error::NoProofInResult))?; + let mtd = response.metadata().or(Err(Error::EmptyResponseMetadata))?; + + let (contract_id, document_type_name, document_id, limit, offset, start_at_ms) = + match request.version.ok_or(Error::EmptyVersion)? { + get_document_history_request::Version::V0(v0) => { + let contract_id = + Identifier::from_bytes(&v0.data_contract_id).map_err(|e| { + Error::ProtocolError { + error: e.to_string(), + } + })?; + let document_id = Identifier::from_bytes(&v0.document_id).map_err(|e| { + Error::ProtocolError { + error: e.to_string(), + } + })?; + let limit = u32_to_u16_opt(v0.limit.unwrap_or_default())?; + let offset = u32_to_u16_opt(v0.offset.unwrap_or_default())?; + ( + contract_id, + v0.document_type_name, + document_id, + limit, + offset, + v0.start_at_ms, + ) + } + }; + + let data_contract = provider + .get_data_contract(&contract_id, platform_version)? + .ok_or(Error::NotFound)?; + let document_type = data_contract + .document_type_for_name(&document_type_name) + .map_err(|e| Error::ProtocolError { + error: e.to_string(), + })?; + + let (root_hash, maybe_history) = Drive::verify_document_history( + &proof.grovedb_proof, + contract_id.into_buffer(), + &document_type_name, + document_type, + document_id.into_buffer(), + start_at_ms, + limit, + offset, + platform_version, + ) + .map_drive_error(proof, mtd)?; + + verify_tenderdash_proof(proof, mtd, &root_hash, provider)?; + + Ok(( + maybe_history.and_then(|history| IndexMap::from_iter(history).into_option()), + mtd.clone(), + proof.clone(), + )) + } +} + impl FromProof for StateTransitionProofResult { type Request = platform::BroadcastStateTransitionRequest; type Response = platform::WaitForStateTransitionResultResponse; @@ -2847,6 +2927,7 @@ macro_rules! define_length { define_length!(DataContract); define_length!(DataContractHistory, |d: &DataContractHistory| d.len()); +define_length!(DocumentHistory, |d: &DocumentHistory| d.len()); define_length!(Document); define_length!(Identity); define_length!(IdentityBalance); @@ -3219,6 +3300,90 @@ mod tests { PlatformVersion::latest() } + struct NoDataContractProvider; + + impl dash_context_provider::ContextProvider for NoDataContractProvider { + fn get_data_contract( + &self, + _id: &dpp::prelude::Identifier, + _platform_version: &PlatformVersion, + ) -> Result>, dash_context_provider::ContextProviderError> + { + Ok(None) + } + + fn get_token_configuration( + &self, + _token_id: &dpp::prelude::Identifier, + ) -> Result< + Option, + dash_context_provider::ContextProviderError, + > { + panic!("token configuration should not be requested") + } + + fn get_quorum_public_key( + &self, + _quorum_type: u32, + _quorum_hash: [u8; 32], + _core_chain_locked_height: u32, + ) -> Result<[u8; 48], dash_context_provider::ContextProviderError> { + panic!("quorum public key should not be requested") + } + + fn get_platform_activation_height( + &self, + ) -> Result + { + panic!("platform activation height should not be requested") + } + } + + struct StaticDataContractProvider { + data_contract: std::sync::Arc, + } + + impl dash_context_provider::ContextProvider for StaticDataContractProvider { + fn get_data_contract( + &self, + id: &dpp::prelude::Identifier, + _platform_version: &PlatformVersion, + ) -> Result>, dash_context_provider::ContextProviderError> + { + if self.data_contract.id() == *id { + Ok(Some(self.data_contract.clone())) + } else { + Ok(None) + } + } + + fn get_token_configuration( + &self, + _token_id: &dpp::prelude::Identifier, + ) -> Result< + Option, + dash_context_provider::ContextProviderError, + > { + panic!("token configuration should not be requested") + } + + fn get_quorum_public_key( + &self, + _quorum_type: u32, + _quorum_hash: [u8; 32], + _core_chain_locked_height: u32, + ) -> Result<[u8; 48], dash_context_provider::ContextProviderError> { + panic!("quorum public key should not be requested") + } + + fn get_platform_activation_height( + &self, + ) -> Result + { + panic!("platform activation height should not be requested") + } + } + /// Build a fully-populated `GetIdentityResponse` shell so that /// `response.proof()` and `response.metadata()` both succeed. The /// enclosed proof is empty, so any real verification would fail — but @@ -3235,6 +3400,56 @@ mod tests { } } + fn document_history_response_with_proof_and_metadata() -> platform::GetDocumentHistoryResponse { + use platform::get_document_history_response::{ + get_document_history_response_v0::Result as V0Result, GetDocumentHistoryResponseV0, + Version, + }; + platform::GetDocumentHistoryResponse { + version: Some(Version::V0(GetDocumentHistoryResponseV0 { + result: Some(V0Result::Proof(Proof::default())), + metadata: Some(ResponseMetadata::default()), + })), + } + } + + fn document_history_request( + data_contract_id: Vec, + document_type_name: &str, + document_id: Vec, + limit: Option, + offset: Option, + ) -> platform::GetDocumentHistoryRequest { + use dapi_grpc::platform::v0::get_document_history_request::GetDocumentHistoryRequestV0; + GetDocumentHistoryRequestV0 { + data_contract_id, + document_type_name: document_type_name.to_string(), + document_id, + limit, + offset, + start_at_ms: 0, + prove: true, + } + .into() + } + + fn document_history_error( + request: platform::GetDocumentHistoryRequest, + response: platform::GetDocumentHistoryResponse, + provider: &dyn ContextProvider, + ) -> Error { + >::maybe_from_proof_with_metadata( + request, + response, + Network::Testnet, + default_platform_version(), + provider, + ) + .unwrap_err() + } + #[test] fn identity_from_proof_no_proof_when_response_empty() { // Default response has `version: None` -> response.proof() errors @@ -4668,6 +4883,122 @@ mod tests { assert!(matches!(err, Error::RequestError { .. }), "got: {err:?}"); } + #[test] + fn document_history_no_proof_when_response_empty() { + let request = platform::GetDocumentHistoryRequest::default(); + let response = platform::GetDocumentHistoryResponse::default(); + let provider = unreachable_provider(); + + let err = document_history_error(request, response, &provider); + + assert!(matches!(err, Error::NoProofInResult), "got: {err:?}"); + } + + #[test] + fn document_history_empty_response_metadata() { + use platform::get_document_history_response::{ + get_document_history_response_v0::Result as V0Result, GetDocumentHistoryResponseV0, + Version, + }; + let request = platform::GetDocumentHistoryRequest::default(); + let response = platform::GetDocumentHistoryResponse { + version: Some(Version::V0(GetDocumentHistoryResponseV0 { + result: Some(V0Result::Proof(Proof::default())), + metadata: None, + })), + }; + let provider = unreachable_provider(); + + let err = document_history_error(request, response, &provider); + + assert!(matches!(err, Error::EmptyResponseMetadata), "got: {err:?}"); + } + + #[test] + fn document_history_empty_version() { + let request = platform::GetDocumentHistoryRequest { version: None }; + let response = document_history_response_with_proof_and_metadata(); + let provider = unreachable_provider(); + + let err = document_history_error(request, response, &provider); + + assert!(matches!(err, Error::EmptyVersion), "got: {err:?}"); + } + + #[test] + fn document_history_rejects_bad_contract_id_length() { + let request = + document_history_request(vec![0u8; 5], "niceDocument", vec![1u8; 32], None, None); + let response = document_history_response_with_proof_and_metadata(); + let provider = unreachable_provider(); + + let err = document_history_error(request, response, &provider); + + assert!(matches!(err, Error::ProtocolError { .. }), "got: {err:?}"); + } + + #[test] + fn document_history_rejects_bad_document_id_length() { + let request = + document_history_request(vec![0u8; 32], "niceDocument", vec![1u8; 5], None, None); + let response = document_history_response_with_proof_and_metadata(); + let provider = unreachable_provider(); + + let err = document_history_error(request, response, &provider); + + assert!(matches!(err, Error::ProtocolError { .. }), "got: {err:?}"); + } + + #[test] + fn document_history_rejects_overflowing_limit() { + let request = document_history_request( + vec![0u8; 32], + "niceDocument", + vec![1u8; 32], + Some(100_000), + None, + ); + let response = document_history_response_with_proof_and_metadata(); + let provider = unreachable_provider(); + + let err = document_history_error(request, response, &provider); + + assert!(matches!(err, Error::RequestError { .. }), "got: {err:?}"); + } + + #[test] + fn document_history_returns_not_found_when_contract_provider_misses() { + let request = + document_history_request(vec![0u8; 32], "niceDocument", vec![1u8; 32], None, None); + let response = document_history_response_with_proof_and_metadata(); + let provider = NoDataContractProvider; + + let err = document_history_error(request, response, &provider); + + assert!(matches!(err, Error::NotFound), "got: {err:?}"); + } + + #[test] + fn document_history_rejects_unknown_document_type() { + let data_contract = dpp::tests::fixtures::get_data_contract_fixture( + None, + 0, + default_platform_version().protocol_version, + ) + .data_contract_owned(); + let contract_id = data_contract.id().to_vec(); + let provider = StaticDataContractProvider { + data_contract: std::sync::Arc::new(data_contract), + }; + let request = + document_history_request(contract_id, "missingDocument", vec![1u8; 32], None, None); + let response = document_history_response_with_proof_and_metadata(); + + let err = document_history_error(request, response, &provider); + + assert!(matches!(err, Error::ProtocolError { .. }), "got: {err:?}"); + } + #[test] fn address_info_rejects_bad_address_bytes() { // PlatformAddress::from_bytes fails for invalid lengths. diff --git a/packages/rs-drive-proof-verifier/src/types.rs b/packages/rs-drive-proof-verifier/src/types.rs index f8e740de208..19ae4385f64 100644 --- a/packages/rs-drive-proof-verifier/src/types.rs +++ b/packages/rs-drive-proof-verifier/src/types.rs @@ -106,6 +106,10 @@ pub type RetrievedValues = IndexMap; /// /// Contains a map of data contract revisions to data contracts. pub type DataContractHistory = RetrievedValues; +/// History of a document. +/// +/// Contains a map of revision timestamps to documents. +pub type DocumentHistory = RetrievedValues; /// Multiple data contracts. /// /// Mapping between data contract IDs and data contracts. diff --git a/packages/rs-drive/src/drive/document/get_fetch/fetch_document_history/mod.rs b/packages/rs-drive/src/drive/document/get_fetch/fetch_document_history/mod.rs new file mode 100644 index 00000000000..e5886dd8948 --- /dev/null +++ b/packages/rs-drive/src/drive/document/get_fetch/fetch_document_history/mod.rs @@ -0,0 +1,273 @@ +mod v0; + +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use dpp::data_contract::document_type::DocumentTypeRef; +use dpp::document::Document; +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; +use std::collections::BTreeMap; + +impl Drive { + /// Fetches the historical revisions of a document that keeps history. + #[allow(clippy::too_many_arguments)] + pub fn fetch_document_history( + &self, + contract_id: [u8; 32], + document_type_name: &str, + document_type: DocumentTypeRef, + document_id: [u8; 32], + transaction: TransactionArg, + start_at_ms: u64, + limit: Option, + offset: Option, + platform_version: &PlatformVersion, + ) -> Result, Error> { + match platform_version + .drive + .methods + .document + .query + .fetch_document_history + { + 0 => self.fetch_document_history_v0( + contract_id, + document_type_name, + document_type, + document_id, + transaction, + start_at_ms, + limit, + offset, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "fetch_document_history".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::util::object_size_info::DocumentInfo::DocumentRefInfo; + use crate::util::object_size_info::{DocumentAndContractInfo, OwnedDocumentInfo}; + use crate::util::storage_flags::StorageFlags; + use crate::util::test_helpers::setup::setup_drive_with_initial_state_structure; + use dpp::block::block_info::BlockInfo; + use dpp::data_contract::accessors::v0::DataContractV0Getters; + use dpp::document::{DocumentV0Getters, DocumentV0Setters}; + use dpp::tests::json_document::{json_document_to_contract, json_document_to_document}; + use dpp::tests::utils::generate_random_identifier_struct; + + const DOCUMENT_TYPE_NAME: &str = "profile"; + + fn setup_history_document() -> (Drive, dpp::prelude::DataContract, dpp::document::Document) { + let drive = setup_drive_with_initial_state_structure(None); + let platform_version = PlatformVersion::latest(); + let contract = json_document_to_contract( + "tests/supporting_files/contract/dashpay/dashpay-contract-with-profile-history.json", + false, + platform_version, + ) + .expect("expected contract"); + drive + .apply_contract( + &contract, + BlockInfo::default(), + true, + StorageFlags::optional_default_as_cow(), + None, + platform_version, + ) + .expect("apply contract"); + + let document_type = contract + .document_type_for_name(DOCUMENT_TYPE_NAME) + .expect("profile document type"); + let document = json_document_to_document( + "tests/supporting_files/contract/dashpay/profile0.json", + Some(generate_random_identifier_struct()), + document_type, + platform_version, + ) + .expect("expected document"); + + (drive, contract, document) + } + + fn put_document( + drive: &Drive, + contract: &dpp::prelude::DataContract, + document: &dpp::document::Document, + time_ms: u64, + ) { + let platform_version = PlatformVersion::latest(); + let document_type = contract + .document_type_for_name(DOCUMENT_TYPE_NAME) + .expect("profile document type"); + drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentRefInfo(( + document, + StorageFlags::optional_default_as_cow(), + )), + owner_id: None, + }, + contract, + document_type, + }, + true, + BlockInfo::default_with_time(time_ms), + true, + None, + platform_version, + None, + ) + .expect("put document"); + } + + #[test] + fn should_fetch_document_history_in_time_order_with_pagination() { + let (drive, contract, mut document) = setup_history_document(); + let platform_version = PlatformVersion::latest(); + let contract_id = contract.id().to_buffer(); + let document_id = document.id().to_buffer(); + let document_type = contract + .document_type_for_name(DOCUMENT_TYPE_NAME) + .expect("profile document type"); + + put_document(&drive, &contract, &document, 1000); + document.set("displayName", "Alice 2".into()); + put_document(&drive, &contract, &document, 2000); + document.set("displayName", "Alice 3".into()); + put_document(&drive, &contract, &document, 3000); + + let history = drive + .fetch_document_history( + contract_id, + DOCUMENT_TYPE_NAME, + document_type, + document_id, + None, + 0, + None, + None, + platform_version, + ) + .expect("fetch history"); + assert_eq!( + history.keys().copied().collect::>(), + vec![1000, 2000, 3000] + ); + + let page = drive + .fetch_document_history( + contract_id, + DOCUMENT_TYPE_NAME, + document_type, + document_id, + None, + 1000, + Some(1), + None, + platform_version, + ) + .expect("fetch page"); + assert_eq!(page.keys().copied().collect::>(), vec![2000]); + + let empty_page = drive + .fetch_document_history( + contract_id, + DOCUMENT_TYPE_NAME, + document_type, + document_id, + None, + 3000, + Some(10), + None, + platform_version, + ) + .expect("fetch empty page"); + assert!(empty_page.is_empty()); + } + + #[test] + fn should_prove_and_verify_document_history() { + let (drive, contract, mut document) = setup_history_document(); + let platform_version = PlatformVersion::latest(); + let contract_id = contract.id().to_buffer(); + let document_id = document.id().to_buffer(); + let document_type = contract + .document_type_for_name(DOCUMENT_TYPE_NAME) + .expect("profile document type"); + + put_document(&drive, &contract, &document, 1000); + document.set("displayName", "Alice 2".into()); + put_document(&drive, &contract, &document, 2000); + + let proof = drive + .prove_document_history( + contract_id, + DOCUMENT_TYPE_NAME, + document_id, + None, + 0, + Some(10), + None, + platform_version, + ) + .expect("prove history"); + let (_root_hash, history) = Drive::verify_document_history( + &proof, + contract_id, + DOCUMENT_TYPE_NAME, + document_type, + document_id, + 0, + Some(10), + None, + platform_version, + ) + .expect("verify history"); + + let history = history.expect("history exists"); + assert_eq!( + history.keys().copied().collect::>(), + vec![1000, 2000] + ); + + let empty_page_proof = drive + .prove_document_history( + contract_id, + DOCUMENT_TYPE_NAME, + document_id, + None, + 2000, + Some(10), + None, + platform_version, + ) + .expect("prove empty page"); + let (_root_hash, empty_history) = Drive::verify_document_history( + &empty_page_proof, + contract_id, + DOCUMENT_TYPE_NAME, + document_type, + document_id, + 2000, + Some(10), + None, + platform_version, + ) + .expect("verify empty history page"); + + assert!(empty_history.expect("empty history page exists").is_empty()); + } +} diff --git a/packages/rs-drive/src/drive/document/get_fetch/fetch_document_history/v0/mod.rs b/packages/rs-drive/src/drive/document/get_fetch/fetch_document_history/v0/mod.rs new file mode 100644 index 00000000000..bb8e67f0eb5 --- /dev/null +++ b/packages/rs-drive/src/drive/document/get_fetch/fetch_document_history/v0/mod.rs @@ -0,0 +1,74 @@ +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use dpp::data_contract::document_type::DocumentPropertyType; +use dpp::data_contract::document_type::DocumentTypeRef; +use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; +use dpp::document::Document; +use dpp::version::PlatformVersion; +use grovedb::query_result_type::{QueryResultElement, QueryResultType}; +use grovedb::{Element, TransactionArg}; +use std::collections::BTreeMap; + +impl Drive { + #[allow(clippy::too_many_arguments)] + pub(super) fn fetch_document_history_v0( + &self, + contract_id: [u8; 32], + document_type_name: &str, + document_type: DocumentTypeRef, + document_id: [u8; 32], + transaction: TransactionArg, + start_at_ms: u64, + limit: Option, + offset: Option, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let mut ops = Vec::new(); + let path_query = Self::fetch_document_history_query( + contract_id, + document_type_name, + document_id, + start_at_ms, + limit, + offset, + platform_version, + )?; + + let (results, _cost) = self.grove_get_path_query( + &path_query, + transaction, + QueryResultType::QueryKeyElementPairResultType, + &mut ops, + &platform_version.drive, + )?; + + results + .elements + .iter() + .map(|el| match el { + QueryResultElement::KeyElementPairResultItem((key, value)) => { + let document_time = DocumentPropertyType::decode_date_timestamp(key).ok_or( + Error::Drive(DriveError::CorruptedDocumentPath( + "document history key is not a valid timestamp", + )), + )?; + match value { + Element::Item(item, _flags) => { + let document = + Document::from_bytes(item, document_type, platform_version) + .map_err(Error::from)?; + Ok((document_time, document)) + } + _ => Err(Error::Drive(DriveError::CorruptedDocumentPath( + "document history path did not refer to a document item", + ))), + } + } + _ => Err(Error::Drive(DriveError::CorruptedDocumentPath( + "document history path did not refer to a key element pair", + ))), + }) + .collect() + } +} diff --git a/packages/rs-drive/src/drive/document/get_fetch/mod.rs b/packages/rs-drive/src/drive/document/get_fetch/mod.rs new file mode 100644 index 00000000000..03f868c5c7d --- /dev/null +++ b/packages/rs-drive/src/drive/document/get_fetch/mod.rs @@ -0,0 +1 @@ +mod fetch_document_history; diff --git a/packages/rs-drive/src/drive/document/mod.rs b/packages/rs-drive/src/drive/document/mod.rs index cd36a7dd5d7..05477e15812 100644 --- a/packages/rs-drive/src/drive/document/mod.rs +++ b/packages/rs-drive/src/drive/document/mod.rs @@ -25,6 +25,8 @@ use grovedb::Element; mod delete; #[cfg(feature = "server")] mod estimation_costs; +#[cfg(any(feature = "server", feature = "fixtures-and-mocks"))] +mod get_fetch; #[cfg(feature = "server")] mod index_uniqueness; #[cfg(any(feature = "server", feature = "fixtures-and-mocks"))] @@ -35,6 +37,12 @@ mod insert_contested; pub mod query; #[cfg(any(feature = "server", feature = "fixtures-and-mocks"))] mod update; +#[cfg(all( + feature = "verify", + not(any(feature = "server", feature = "fixtures-and-mocks")) +))] +#[path = "query/fetch_document_history_query/mod.rs"] +mod verify_fetch_document_history_query; /// paths #[cfg(any(feature = "server", feature = "verify"))] @@ -43,6 +51,12 @@ pub mod paths; /// Primary key tree type resolution #[cfg(feature = "server")] pub mod primary_key_tree_type; +#[cfg(feature = "server")] +pub(crate) mod prove; + +/// How many document history entries to fetch at once. This mirrors contract history +/// and prevents unbounded history reads. +pub const MAX_DOCUMENT_HISTORY_FETCH_LIMIT: u16 = 10; #[cfg(feature = "server")] /// Creates a reference to a document. diff --git a/packages/rs-drive/src/drive/document/prove/mod.rs b/packages/rs-drive/src/drive/document/prove/mod.rs new file mode 100644 index 00000000000..4edb48359ff --- /dev/null +++ b/packages/rs-drive/src/drive/document/prove/mod.rs @@ -0,0 +1,2 @@ +/// The `prove_document_history` module provides functionality for getting document historical proofs. +mod prove_document_history; diff --git a/packages/rs-drive/src/drive/document/prove/prove_document_history/mod.rs b/packages/rs-drive/src/drive/document/prove/prove_document_history/mod.rs new file mode 100644 index 00000000000..c6214e01563 --- /dev/null +++ b/packages/rs-drive/src/drive/document/prove/prove_document_history/mod.rs @@ -0,0 +1,47 @@ +mod v0; + +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; + +impl Drive { + /// Proves the existence or absence of the specified document's history. + #[allow(clippy::too_many_arguments)] + pub fn prove_document_history( + &self, + contract_id: [u8; 32], + document_type_name: &str, + document_id: [u8; 32], + transaction: TransactionArg, + start_at_ms: u64, + limit: Option, + offset: Option, + platform_version: &PlatformVersion, + ) -> Result, Error> { + match platform_version + .drive + .methods + .document + .query + .prove_document_history + { + 0 => self.prove_document_history_v0( + contract_id, + document_type_name, + document_id, + transaction, + start_at_ms, + limit, + offset, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "prove_document_history".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/document/prove/prove_document_history/v0/mod.rs b/packages/rs-drive/src/drive/document/prove/prove_document_history/v0/mod.rs new file mode 100644 index 00000000000..bf7777c788a --- /dev/null +++ b/packages/rs-drive/src/drive/document/prove/prove_document_history/v0/mod.rs @@ -0,0 +1,36 @@ +use crate::drive::Drive; +use crate::error::Error; +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; + +impl Drive { + #[allow(clippy::too_many_arguments)] + pub(super) fn prove_document_history_v0( + &self, + contract_id: [u8; 32], + document_type_name: &str, + document_id: [u8; 32], + transaction: TransactionArg, + start_at_ms: u64, + limit: Option, + offset: Option, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let history_query = Self::fetch_document_history_query( + contract_id, + document_type_name, + document_id, + start_at_ms, + limit, + offset, + platform_version, + )?; + + self.grove_get_proved_path_query( + &history_query, + transaction, + &mut vec![], + &platform_version.drive, + ) + } +} diff --git a/packages/rs-drive/src/drive/document/query/fetch_document_history_query/mod.rs b/packages/rs-drive/src/drive/document/query/fetch_document_history_query/mod.rs new file mode 100644 index 00000000000..d8da80e66f7 --- /dev/null +++ b/packages/rs-drive/src/drive/document/query/fetch_document_history_query/mod.rs @@ -0,0 +1,55 @@ +mod v0; + +use crate::drive::document::MAX_DOCUMENT_HISTORY_FETCH_LIMIT; +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use dpp::version::PlatformVersion; +use grovedb::PathQuery; + +impl Drive { + /// Creates a path query for historical entries of a specified document. + #[allow(clippy::too_many_arguments)] + pub fn fetch_document_history_query( + contract_id: [u8; 32], + document_type_name: &str, + document_id: [u8; 32], + start_at_ms: u64, + limit: Option, + offset: Option, + platform_version: &PlatformVersion, + ) -> Result { + match platform_version + .drive + .methods + .document + .query + .fetch_document_history_query + { + 0 => Self::fetch_document_history_query_v0( + contract_id, + document_type_name, + document_id, + start_at_ms, + limit, + offset, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "fetch_document_history_query".to_string(), + known_versions: vec![0], + received: version, + })), + } + } + + pub(crate) fn validate_document_history_limit(limit: Option) -> Result { + let limit = limit.unwrap_or(MAX_DOCUMENT_HISTORY_FETCH_LIMIT); + if !(1..=MAX_DOCUMENT_HISTORY_FETCH_LIMIT).contains(&limit) { + return Err(Error::Drive(DriveError::InvalidDocumentHistoryFetchLimit( + limit, + ))); + } + + Ok(limit) + } +} diff --git a/packages/rs-drive/src/drive/document/query/fetch_document_history_query/v0/mod.rs b/packages/rs-drive/src/drive/document/query/fetch_document_history_query/v0/mod.rs new file mode 100644 index 00000000000..f43a5ca78f8 --- /dev/null +++ b/packages/rs-drive/src/drive/document/query/fetch_document_history_query/v0/mod.rs @@ -0,0 +1,39 @@ +use crate::drive::document::paths::contract_documents_keeping_history_primary_key_path_for_document_id; +use crate::drive::Drive; +use crate::error::Error; +use dpp::data_contract::document_type::DocumentPropertyType; +use grovedb::{PathQuery, Query, QueryItem, SizedQuery}; + +impl Drive { + #[allow(clippy::too_many_arguments)] + pub(super) fn fetch_document_history_query_v0( + contract_id: [u8; 32], + document_type_name: &str, + document_id: [u8; 32], + start_at_ms: u64, + limit: Option, + offset: Option, + ) -> Result { + let limit = Self::validate_document_history_limit(limit)?; + let encoded_start = DocumentPropertyType::encode_date_timestamp(start_at_ms); + let query = Query::new_single_query_item_with_direction( + QueryItem::RangeAfter(std::ops::RangeFrom { + start: encoded_start, + }), + true, + ); + let path = contract_documents_keeping_history_primary_key_path_for_document_id( + contract_id.as_slice(), + document_type_name, + document_id.as_slice(), + ) + .into_iter() + .map(|segment| segment.to_vec()) + .collect(); + + Ok(PathQuery::new( + path, + SizedQuery::new(query, Some(limit), offset), + )) + } +} diff --git a/packages/rs-drive/src/drive/document/query/mod.rs b/packages/rs-drive/src/drive/document/query/mod.rs index 87b5d8fb72c..1b56d8dc286 100644 --- a/packages/rs-drive/src/drive/document/query/mod.rs +++ b/packages/rs-drive/src/drive/document/query/mod.rs @@ -3,6 +3,7 @@ //! Defines and implements in Drive functions relevant to querying. //! +mod fetch_document_history_query; /// query of the vote state pub mod query_contested_documents_vote_state; mod query_documents; diff --git a/packages/rs-drive/src/error/drive.rs b/packages/rs-drive/src/error/drive.rs index d23ff65a508..3412c9df1aa 100644 --- a/packages/rs-drive/src/error/drive.rs +++ b/packages/rs-drive/src/error/drive.rs @@ -1,4 +1,5 @@ use crate::drive::contract::MAX_CONTRACT_HISTORY_FETCH_LIMIT; +use crate::drive::document::MAX_DOCUMENT_HISTORY_FETCH_LIMIT; use dpp::fee::Credits; use dpp::identifier::Identifier; use dpp::version::FeatureVersion; @@ -178,6 +179,10 @@ pub enum DriveError { #[error("invalid contract history fetch limit: {0}. The limit must be between 1 and {MAX_CONTRACT_HISTORY_FETCH_LIMIT}")] InvalidContractHistoryFetchLimit(u16), + /// Error + #[error("invalid document history fetch limit: {0}. The limit must be between 1 and {MAX_DOCUMENT_HISTORY_FETCH_LIMIT}")] + InvalidDocumentHistoryFetchLimit(u16), + /// Error #[error("prefunded specialized balance does not exist: {0}")] PrefundedSpecializedBalanceDoesNotExist(String), diff --git a/packages/rs-drive/src/verify/document/mod.rs b/packages/rs-drive/src/verify/document/mod.rs index e2a4d7897f2..e38cf29e5f7 100644 --- a/packages/rs-drive/src/verify/document/mod.rs +++ b/packages/rs-drive/src/verify/document/mod.rs @@ -1,3 +1,4 @@ +mod verify_document_history; mod verify_proof; mod verify_proof_keep_serialized; mod verify_start_at_document_in_proof; diff --git a/packages/rs-drive/src/verify/document/verify_document_history/mod.rs b/packages/rs-drive/src/verify/document/verify_document_history/mod.rs new file mode 100644 index 00000000000..fb625cfa545 --- /dev/null +++ b/packages/rs-drive/src/verify/document/verify_document_history/mod.rs @@ -0,0 +1,51 @@ +mod v0; + +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use crate::verify::RootHash; +use dpp::data_contract::document_type::DocumentTypeRef; +use dpp::document::Document; +use dpp::version::PlatformVersion; +use std::collections::BTreeMap; + +impl Drive { + /// Verifies that the document's history is included in the proof. + #[allow(clippy::too_many_arguments)] + pub fn verify_document_history( + proof: &[u8], + contract_id: [u8; 32], + document_type_name: &str, + document_type: DocumentTypeRef, + document_id: [u8; 32], + start_at_ms: u64, + limit: Option, + offset: Option, + platform_version: &PlatformVersion, + ) -> Result<(RootHash, Option>), Error> { + match platform_version + .drive + .methods + .verify + .document + .verify_document_history + { + 0 => Drive::verify_document_history_v0( + proof, + contract_id, + document_type_name, + document_type, + document_id, + start_at_ms, + limit, + offset, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "verify_document_history".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/verify/document/verify_document_history/v0/mod.rs b/packages/rs-drive/src/verify/document/verify_document_history/v0/mod.rs new file mode 100644 index 00000000000..abb0eb6b676 --- /dev/null +++ b/packages/rs-drive/src/verify/document/verify_document_history/v0/mod.rs @@ -0,0 +1,85 @@ +use crate::drive::document::paths::contract_documents_keeping_history_primary_key_path_for_document_id; +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::proof::ProofError; +use crate::error::Error; +use crate::verify::RootHash; +use dpp::data_contract::document_type::DocumentPropertyType; +use dpp::data_contract::document_type::DocumentTypeRef; +use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; +use dpp::document::Document; +use dpp::version::PlatformVersion; +use grovedb::GroveDb; +use std::collections::BTreeMap; + +impl Drive { + #[allow(clippy::too_many_arguments)] + pub(super) fn verify_document_history_v0( + proof: &[u8], + contract_id: [u8; 32], + document_type_name: &str, + document_type: DocumentTypeRef, + document_id: [u8; 32], + start_at_ms: u64, + limit: Option, + offset: Option, + platform_version: &PlatformVersion, + ) -> Result<(RootHash, Option>), Error> { + let path_query = Self::fetch_document_history_query( + contract_id, + document_type_name, + document_id, + start_at_ms, + limit, + offset, + platform_version, + )?; + let expected_path = contract_documents_keeping_history_primary_key_path_for_document_id( + contract_id.as_slice(), + document_type_name, + document_id.as_slice(), + ) + .into_iter() + .map(|segment| segment.to_vec()) + .collect::>(); + + let (root_hash, mut proved_key_values) = + GroveDb::verify_query(proof, &path_query, &platform_version.drive.grove_version)?; + + let mut documents: BTreeMap = BTreeMap::new(); + for (path, key, maybe_element) in proved_key_values.drain(..) { + if path != expected_path { + return Err(Error::Proof(ProofError::CorruptedProof( + "we did not get back an element for the correct path for the historical document" + .to_string(), + ))); + } + + let date = DocumentPropertyType::decode_date_timestamp(&key).ok_or(Error::Drive( + DriveError::CorruptedDocumentPath("document history key is not a valid timestamp"), + ))?; + + let maybe_document = maybe_element + .map(|element| { + element + .into_item_bytes() + .map_err(Error::from) + .and_then(|bytes| { + Document::from_bytes(&bytes, document_type, platform_version) + .map_err(Error::from) + }) + }) + .transpose()?; + + if let Some(document) = maybe_document { + documents.insert(date, document); + } else { + return Err(Error::Drive(DriveError::CorruptedDocumentPath( + "expected a document at this path", + ))); + } + } + + Ok((root_hash, Some(documents))) + } +} diff --git a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_query_versions/mod.rs b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_query_versions/mod.rs index 2a3245aee80..1b0c5f1e4f1 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_query_versions/mod.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_query_versions/mod.rs @@ -9,6 +9,7 @@ pub struct DriveAbciQueryVersions { pub response_metadata: FeatureVersion, pub proofs_query: FeatureVersion, pub document_query: FeatureVersionBounds, + pub document_history: FeatureVersionBounds, /// Per-helper version slots for internal v1-document-query /// routing helpers. Separate from `document_query` (which /// versions the wire surface) because the helper output is diff --git a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_query_versions/v0.rs b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_query_versions/v0.rs index bb933d9cbf5..646e03ad127 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_query_versions/v0.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_query_versions/v0.rs @@ -22,6 +22,11 @@ pub const DRIVE_ABCI_QUERY_VERSIONS_V0: DriveAbciQueryVersions = DriveAbciQueryV max_version: 0, default_current_version: 0, }, + document_history: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, document_query_helpers: DriveAbciDocumentQueryHelperVersions { compute_aggregate_mode_and_check_limit: 0, }, diff --git a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_query_versions/v1.rs b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_query_versions/v1.rs index 126efeb4cd1..a600d7a9728 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_query_versions/v1.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_query_versions/v1.rs @@ -24,6 +24,11 @@ pub const DRIVE_ABCI_QUERY_VERSIONS_V1: DriveAbciQueryVersions = DriveAbciQueryV max_version: 1, default_current_version: 1, }, + document_history: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, document_query_helpers: DriveAbciDocumentQueryHelperVersions { compute_aggregate_mode_and_check_limit: 0, }, diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/mod.rs b/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/mod.rs index ef0440b3f08..69cf66441e2 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/mod.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/mod.rs @@ -22,6 +22,9 @@ pub struct DriveDocumentQueryMethodVersions { pub query_contested_documents: FeatureVersion, pub query_contested_documents_vote_state: FeatureVersion, pub query_documents_with_flags: FeatureVersion, + pub fetch_document_history_query: FeatureVersion, + pub fetch_document_history: FeatureVersion, + pub prove_document_history: FeatureVersion, /// Mode-detection routing table for `SELECT COUNT` queries. /// Versioned because the routing table is consensus-relevant on /// the query surface — a future protocol version that changes diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v1.rs b/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v1.rs index d385bcc67b2..19e3cf45860 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v1.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v1.rs @@ -12,6 +12,9 @@ pub const DRIVE_DOCUMENT_METHOD_VERSIONS_V1: DriveDocumentMethodVersions = query_contested_documents: 0, query_contested_documents_vote_state: 0, query_documents_with_flags: 0, + fetch_document_history_query: 0, + fetch_document_history: 0, + prove_document_history: 0, detect_count_mode: 0, detect_sum_mode: 0, }, diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v2.rs b/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v2.rs index b576b67f11e..77bec9a9ee8 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v2.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v2.rs @@ -14,6 +14,9 @@ pub const DRIVE_DOCUMENT_METHOD_VERSIONS_V2: DriveDocumentMethodVersions = query_contested_documents: 0, query_contested_documents_vote_state: 0, query_documents_with_flags: 0, + fetch_document_history_query: 0, + fetch_document_history: 0, + prove_document_history: 0, detect_count_mode: 0, detect_sum_mode: 0, }, diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v3.rs b/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v3.rs index 6534037e9a3..67092185126 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v3.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_document_method_versions/v3.rs @@ -24,6 +24,9 @@ pub const DRIVE_DOCUMENT_METHOD_VERSIONS_V3: DriveDocumentMethodVersions = query_contested_documents: 0, query_contested_documents_vote_state: 0, query_documents_with_flags: 0, + fetch_document_history_query: 0, + fetch_document_history: 0, + prove_document_history: 0, detect_count_mode: 0, detect_sum_mode: 0, }, diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/mod.rs b/packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/mod.rs index 93772544b8d..5110b796581 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/mod.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/mod.rs @@ -43,6 +43,7 @@ pub struct DriveVerifyContractMethodVersions { pub struct DriveVerifyDocumentMethodVersions { pub verify_proof: FeatureVersion, pub verify_proof_keep_serialized: FeatureVersion, + pub verify_document_history: FeatureVersion, pub verify_start_at_document_in_proof: FeatureVersion, } diff --git a/packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/v1.rs b/packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/v1.rs index 0395a5237e6..68913eeff95 100644 --- a/packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/v1.rs +++ b/packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/v1.rs @@ -17,6 +17,7 @@ pub const DRIVE_VERIFY_METHOD_VERSIONS_V1: DriveVerifyMethodVersions = DriveVeri document: DriveVerifyDocumentMethodVersions { verify_proof: 0, verify_proof_keep_serialized: 0, + verify_document_history: 0, verify_start_at_document_in_proof: 0, }, document_count: DriveVerifyDocumentCountMethodVersions { diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 30487fff051..98527e8f2a4 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -176,6 +176,11 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { max_version: 0, default_current_version: 0, }, + document_history: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, document_query_helpers: DriveAbciDocumentQueryHelperVersions { compute_aggregate_mode_and_check_limit: 0, }, diff --git a/packages/rs-sdk/src/mock/sdk.rs b/packages/rs-sdk/src/mock/sdk.rs index f1c74b10e37..b9147e3bb48 100644 --- a/packages/rs-sdk/src/mock/sdk.rs +++ b/packages/rs-sdk/src/mock/sdk.rs @@ -159,6 +159,9 @@ impl MockDashPlatformSdk { "GetDataContractHistoryRequest" => { load_expectation::(&mut dapi, filename)? } + "GetDocumentHistoryRequest" => { + load_expectation::(&mut dapi, filename)? + } "IdentityRequest" => load_expectation::(&mut dapi, filename)?, "GetIdentityRequest" => { load_expectation::(&mut dapi, filename)? diff --git a/packages/rs-sdk/src/platform.rs b/packages/rs-sdk/src/platform.rs index 006cab205c2..9e2cbdf89af 100644 --- a/packages/rs-sdk/src/platform.rs +++ b/packages/rs-sdk/src/platform.rs @@ -30,6 +30,7 @@ pub use dapi_grpc::platform::v0 as proto; pub use dash_context_provider::ContextProvider; #[cfg(feature = "mocks")] pub use dash_context_provider::MockContextProvider; +pub use documents::document_history_query::DocumentHistoryQuery; pub use documents::document_query::DocumentQuery; pub use dpp::{ self as dpp, diff --git a/packages/rs-sdk/src/platform/documents/document_history_query.rs b/packages/rs-sdk/src/platform/documents/document_history_query.rs new file mode 100644 index 00000000000..1e5fa27dc70 --- /dev/null +++ b/packages/rs-sdk/src/platform/documents/document_history_query.rs @@ -0,0 +1,21 @@ +//! Query type for retrieving document history. + +use dpp::prelude::Identifier; + +/// Query parameters for a document's historical revisions. +#[derive(Debug, Clone, PartialEq, Eq, dash_platform_macros::Mockable)] +#[cfg_attr(feature = "mocks", derive(serde::Serialize, serde::Deserialize))] +pub struct DocumentHistoryQuery { + /// Data contract ID. + pub data_contract_id: Identifier, + /// Document type name within the data contract. + pub document_type_name: String, + /// Document ID. + pub document_id: Identifier, + /// Exclusive lower-bound timestamp in milliseconds. + pub start_at_ms: u64, + /// Maximum number of history entries to return. + pub limit: Option, + /// Offset within the history query result. + pub offset: Option, +} diff --git a/packages/rs-sdk/src/platform/documents/mod.rs b/packages/rs-sdk/src/platform/documents/mod.rs index 2b9cf2ecb66..6463f20c658 100644 --- a/packages/rs-sdk/src/platform/documents/mod.rs +++ b/packages/rs-sdk/src/platform/documents/mod.rs @@ -4,6 +4,7 @@ pub(super) mod count_proof_helpers; /// `(count, sum)`; client divides. pub mod document_average; pub mod document_count; +pub mod document_history_query; pub mod document_query; /// `Fetch` impl for the average-side per-entry result. Mirrors /// `document_split_sums`. diff --git a/packages/rs-sdk/src/platform/fetch.rs b/packages/rs-sdk/src/platform/fetch.rs index f153936096a..8ef758d486f 100644 --- a/packages/rs-sdk/src/platform/fetch.rs +++ b/packages/rs-sdk/src/platform/fetch.rs @@ -336,6 +336,11 @@ impl Fetch for drive_proof_verifier::types::DataContractHistory { type Request = platform_proto::GetDataContractHistoryRequest; } +impl Fetch for drive_proof_verifier::types::DocumentHistory { + type Query = platform_proto::GetDocumentHistoryRequest; + type Request = platform_proto::GetDocumentHistoryRequest; +} + impl Fetch for ExtendedEpochInfo { type Query = platform_proto::GetEpochsInfoRequest; type Request = platform_proto::GetEpochsInfoRequest; diff --git a/packages/rs-sdk/src/platform/query.rs b/packages/rs-sdk/src/platform/query.rs index 3a99993e111..bb7d7ff80c8 100644 --- a/packages/rs-sdk/src/platform/query.rs +++ b/packages/rs-sdk/src/platform/query.rs @@ -4,6 +4,7 @@ use super::types::epoch::EpochQuery; use super::types::evonode::EvoNode; use crate::error::Error; +use crate::platform::documents::document_history_query::DocumentHistoryQuery; use crate::platform::documents::document_query::DocumentQuery; use dapi_grpc::mock::Mockable; use dapi_grpc::platform::v0::get_contested_resource_identity_votes_request::GetContestedResourceIdentityVotesRequestV0; @@ -185,6 +186,32 @@ impl Query for LimitQuery<(Identifier, u64 } } +impl Query for DocumentHistoryQuery { + fn query( + &self, + settings: &crate::platform::QuerySettings<'_>, + ) -> Result { + let prove = settings.prove; + if !prove { + unimplemented!("queries without proofs are not supported yet"); + } + + Ok(proto::GetDocumentHistoryRequest { + version: Some(proto::get_document_history_request::Version::V0( + proto::get_document_history_request::GetDocumentHistoryRequestV0 { + data_contract_id: self.data_contract_id.to_vec(), + document_type_name: self.document_type_name.clone(), + document_id: self.document_id.to_vec(), + limit: self.limit, + offset: self.offset, + start_at_ms: self.start_at_ms, + prove, + }, + )), + }) + } +} + impl Query for Identifier { /// Get all keys for an identity with provided identifier. fn query( diff --git a/packages/wasm-sdk/src/queries/document.rs b/packages/wasm-sdk/src/queries/document.rs index 754cb933639..55f4c06f92e 100644 --- a/packages/wasm-sdk/src/queries/document.rs +++ b/packages/wasm-sdk/src/queries/document.rs @@ -7,12 +7,14 @@ use dash_sdk::dpp::document::Document; use dash_sdk::dpp::platform_value::Value; use dash_sdk::dpp::prelude::Identifier; use dash_sdk::drive::query::SelectProjection; +use dash_sdk::platform::documents::document_history_query::DocumentHistoryQuery; use dash_sdk::platform::documents::document_query::DocumentQuery; use dash_sdk::platform::Fetch; use dash_sdk::platform::FetchMany; use drive::query::{OrderClause, WhereClause, WhereOperator}; +use drive_proof_verifier::types::DocumentHistory; use drive_proof_verifier::{DocumentSplitAverages, DocumentSplitCounts, DocumentSplitSums}; -use js_sys::Map; +use js_sys::{BigInt, Map}; use serde::Deserialize; use serde_json::Value as JsonValue; use wasm_bindgen::prelude::wasm_bindgen; @@ -118,12 +120,53 @@ export interface DocumentsQuery { */ groupBy?: string[]; } + +/** + * Query parameters for retrieving document history. + */ +export interface DocumentHistoryQuery { + /** + * Data contract identifier. + */ + dataContractId: IdentifierLike + + /** + * Document type name. + */ + documentTypeName: string; + + /** + * Document identifier. + */ + documentId: IdentifierLike + + /** + * Millisecond timestamp (exclusive) to start after. + * @default 0 + */ + startAtMs?: number; + + /** + * Maximum number of entries to return. + * @default undefined + */ + limit?: number; + + /** + * Offset for pagination through the document history. + * @default undefined + */ + offset?: number; +} "#; #[wasm_bindgen] extern "C" { #[wasm_bindgen(typescript_type = "DocumentsQuery")] pub type DocumentsQueryJs; + + #[wasm_bindgen(typescript_type = "DocumentHistoryQuery")] + pub type DocumentHistoryQueryJs; } #[derive(Deserialize)] @@ -154,6 +197,36 @@ struct DocumentsQueryInput { // separate `orderByAscending` knob. } +#[derive(Deserialize)] +#[serde(rename_all = "camelCase")] +struct DocumentHistoryQueryInput { + data_contract_id: IdentifierWasm, + document_type_name: String, + document_id: IdentifierWasm, + #[serde(default)] + start_at_ms: Option, + #[serde(default)] + limit: Option, + #[serde(default)] + offset: Option, +} + +fn parse_document_history_query( + query: DocumentHistoryQueryJs, +) -> Result { + let input: DocumentHistoryQueryInput = + deserialize_required_query(query, "Query object is required", "document history query")?; + + Ok(DocumentHistoryQuery { + data_contract_id: input.data_contract_id.into(), + document_type_name: input.document_type_name, + document_id: input.document_id.into(), + start_at_ms: input.start_at_ms.unwrap_or(0), + limit: input.limit, + offset: input.offset, + }) +} + async fn build_documents_query( sdk: &WasmSdk, input: DocumentsQueryInput, @@ -451,6 +524,85 @@ fn json_to_platform_value(json_val: &JsonValue) -> Result { #[wasm_bindgen] impl WasmSdk { + #[wasm_bindgen( + js_name = "getDocumentHistory", + unchecked_return_type = "Map" + )] + pub async fn get_document_history( + &self, + query: DocumentHistoryQueryJs, + ) -> Result { + let query = parse_document_history_query(query)?; + let contract_id = query.data_contract_id; + let document_type_name = query.document_type_name.clone(); + + let data_contract = self.get_or_fetch_contract(contract_id).await?; + data_contract + .document_type_for_name(&document_type_name) + .map_err(|e| WasmSdkError::not_found(format!("Document type not found: {}", e)))?; + + let history_result = DocumentHistory::fetch(self.as_ref(), query).await?; + let history_map = Map::new(); + + if let Some(history) = history_result { + for (block_time_ms, document) in history { + let document_js = JsValue::from(DocumentWasm::new( + document, + contract_id, + document_type_name.clone(), + None, + )); + let key = JsValue::from(BigInt::from(block_time_ms)); + + history_map.set(&key, &document_js); + } + } + + Ok(history_map) + } + + #[wasm_bindgen( + js_name = "getDocumentHistoryWithProofInfo", + unchecked_return_type = "ProofMetadataResponseTyped>" + )] + pub async fn get_document_history_with_proof_info( + &self, + query: DocumentHistoryQueryJs, + ) -> Result { + let query = parse_document_history_query(query)?; + let contract_id = query.data_contract_id; + let document_type_name = query.document_type_name.clone(); + + let data_contract = self.get_or_fetch_contract(contract_id).await?; + data_contract + .document_type_for_name(&document_type_name) + .map_err(|e| WasmSdkError::not_found(format!("Document type not found: {}", e)))?; + + let (history_result, metadata, proof) = + DocumentHistory::fetch_with_metadata_and_proof(self.as_ref(), query, None).await?; + let history_map = Map::new(); + + if let Some(history) = history_result { + for (block_time_ms, document) in history { + let document_js = JsValue::from(DocumentWasm::new( + document, + contract_id, + document_type_name.clone(), + None, + )); + let key = JsValue::from(BigInt::from(block_time_ms)); + + history_map.set(&key, &document_js); + } + } + + Ok(ProofMetadataResponseWasm::from_sdk_parts( + history_map, + metadata, + proof, + )) + } + #[wasm_bindgen( js_name = "getDocuments", unchecked_return_type = "Map"