UNPKG

rchain-toolkit

Version:

Node JS utils and methods to interact with rchain's rnode api and proto interfaces

1,143 lines (1,056 loc) 2.16 MB
/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/ "use strict"; var $protobuf = require("protobufjs/minimal"); // Common aliases var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util; // Exported root namespace var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {}); $root.casper = (function() { /** * Namespace casper. * @exports casper * @namespace */ var casper = {}; casper.HasBlockRequestProto = (function() { /** * Properties of a HasBlockRequestProto. * @memberof casper * @interface IHasBlockRequestProto * @property {Uint8Array|null} [hash] HasBlockRequestProto hash */ /** * Constructs a new HasBlockRequestProto. * @memberof casper * @classdesc Represents a HasBlockRequestProto. * @implements IHasBlockRequestProto * @constructor * @param {casper.IHasBlockRequestProto=} [properties] Properties to set */ function HasBlockRequestProto(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]]; } /** * HasBlockRequestProto hash. * @member {Uint8Array} hash * @memberof casper.HasBlockRequestProto * @instance */ HasBlockRequestProto.prototype.hash = $util.newBuffer([]); /** * Creates a new HasBlockRequestProto instance using the specified properties. * @function create * @memberof casper.HasBlockRequestProto * @static * @param {casper.IHasBlockRequestProto=} [properties] Properties to set * @returns {casper.HasBlockRequestProto} HasBlockRequestProto instance */ HasBlockRequestProto.create = function create(properties) { return new HasBlockRequestProto(properties); }; /** * Encodes the specified HasBlockRequestProto message. Does not implicitly {@link casper.HasBlockRequestProto.verify|verify} messages. * @function encode * @memberof casper.HasBlockRequestProto * @static * @param {casper.IHasBlockRequestProto} message HasBlockRequestProto message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ HasBlockRequestProto.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.hash != null && message.hasOwnProperty("hash")) writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.hash); return writer; }; /** * Encodes the specified HasBlockRequestProto message, length delimited. Does not implicitly {@link casper.HasBlockRequestProto.verify|verify} messages. * @function encodeDelimited * @memberof casper.HasBlockRequestProto * @static * @param {casper.IHasBlockRequestProto} message HasBlockRequestProto message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ HasBlockRequestProto.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes a HasBlockRequestProto message from the specified reader or buffer. * @function decode * @memberof casper.HasBlockRequestProto * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {casper.HasBlockRequestProto} HasBlockRequestProto * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ HasBlockRequestProto.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.casper.HasBlockRequestProto(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: message.hash = reader.bytes(); break; default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes a HasBlockRequestProto message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof casper.HasBlockRequestProto * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {casper.HasBlockRequestProto} HasBlockRequestProto * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ HasBlockRequestProto.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies a HasBlockRequestProto message. * @function verify * @memberof casper.HasBlockRequestProto * @static * @param {Object.<string,*>} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ HasBlockRequestProto.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.hash != null && message.hasOwnProperty("hash")) if (!(message.hash && typeof message.hash.length === "number" || $util.isString(message.hash))) return "hash: buffer expected"; return null; }; /** * Creates a HasBlockRequestProto message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof casper.HasBlockRequestProto * @static * @param {Object.<string,*>} object Plain object * @returns {casper.HasBlockRequestProto} HasBlockRequestProto */ HasBlockRequestProto.fromObject = function fromObject(object) { if (object instanceof $root.casper.HasBlockRequestProto) return object; var message = new $root.casper.HasBlockRequestProto(); if (object.hash != null) if (typeof object.hash === "string") $util.base64.decode(object.hash, message.hash = $util.newBuffer($util.base64.length(object.hash)), 0); else if (object.hash.length) message.hash = object.hash; return message; }; /** * Creates a plain object from a HasBlockRequestProto message. Also converts values to other types if specified. * @function toObject * @memberof casper.HasBlockRequestProto * @static * @param {casper.HasBlockRequestProto} message HasBlockRequestProto * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.<string,*>} Plain object */ HasBlockRequestProto.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) if (options.bytes === String) object.hash = ""; else { object.hash = []; if (options.bytes !== Array) object.hash = $util.newBuffer(object.hash); } if (message.hash != null && message.hasOwnProperty("hash")) object.hash = options.bytes === String ? $util.base64.encode(message.hash, 0, message.hash.length) : options.bytes === Array ? Array.prototype.slice.call(message.hash) : message.hash; return object; }; /** * Converts this HasBlockRequestProto to JSON. * @function toJSON * @memberof casper.HasBlockRequestProto * @instance * @returns {Object.<string,*>} JSON object */ HasBlockRequestProto.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; return HasBlockRequestProto; })(); casper.HasBlockProto = (function() { /** * Properties of a HasBlockProto. * @memberof casper * @interface IHasBlockProto * @property {Uint8Array|null} [hash] HasBlockProto hash */ /** * Constructs a new HasBlockProto. * @memberof casper * @classdesc Represents a HasBlockProto. * @implements IHasBlockProto * @constructor * @param {casper.IHasBlockProto=} [properties] Properties to set */ function HasBlockProto(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]]; } /** * HasBlockProto hash. * @member {Uint8Array} hash * @memberof casper.HasBlockProto * @instance */ HasBlockProto.prototype.hash = $util.newBuffer([]); /** * Creates a new HasBlockProto instance using the specified properties. * @function create * @memberof casper.HasBlockProto * @static * @param {casper.IHasBlockProto=} [properties] Properties to set * @returns {casper.HasBlockProto} HasBlockProto instance */ HasBlockProto.create = function create(properties) { return new HasBlockProto(properties); }; /** * Encodes the specified HasBlockProto message. Does not implicitly {@link casper.HasBlockProto.verify|verify} messages. * @function encode * @memberof casper.HasBlockProto * @static * @param {casper.IHasBlockProto} message HasBlockProto message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ HasBlockProto.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.hash != null && message.hasOwnProperty("hash")) writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.hash); return writer; }; /** * Encodes the specified HasBlockProto message, length delimited. Does not implicitly {@link casper.HasBlockProto.verify|verify} messages. * @function encodeDelimited * @memberof casper.HasBlockProto * @static * @param {casper.IHasBlockProto} message HasBlockProto message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ HasBlockProto.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes a HasBlockProto message from the specified reader or buffer. * @function decode * @memberof casper.HasBlockProto * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {casper.HasBlockProto} HasBlockProto * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ HasBlockProto.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.casper.HasBlockProto(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: message.hash = reader.bytes(); break; default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes a HasBlockProto message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof casper.HasBlockProto * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {casper.HasBlockProto} HasBlockProto * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ HasBlockProto.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies a HasBlockProto message. * @function verify * @memberof casper.HasBlockProto * @static * @param {Object.<string,*>} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ HasBlockProto.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.hash != null && message.hasOwnProperty("hash")) if (!(message.hash && typeof message.hash.length === "number" || $util.isString(message.hash))) return "hash: buffer expected"; return null; }; /** * Creates a HasBlockProto message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof casper.HasBlockProto * @static * @param {Object.<string,*>} object Plain object * @returns {casper.HasBlockProto} HasBlockProto */ HasBlockProto.fromObject = function fromObject(object) { if (object instanceof $root.casper.HasBlockProto) return object; var message = new $root.casper.HasBlockProto(); if (object.hash != null) if (typeof object.hash === "string") $util.base64.decode(object.hash, message.hash = $util.newBuffer($util.base64.length(object.hash)), 0); else if (object.hash.length) message.hash = object.hash; return message; }; /** * Creates a plain object from a HasBlockProto message. Also converts values to other types if specified. * @function toObject * @memberof casper.HasBlockProto * @static * @param {casper.HasBlockProto} message HasBlockProto * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.<string,*>} Plain object */ HasBlockProto.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) if (options.bytes === String) object.hash = ""; else { object.hash = []; if (options.bytes !== Array) object.hash = $util.newBuffer(object.hash); } if (message.hash != null && message.hasOwnProperty("hash")) object.hash = options.bytes === String ? $util.base64.encode(message.hash, 0, message.hash.length) : options.bytes === Array ? Array.prototype.slice.call(message.hash) : message.hash; return object; }; /** * Converts this HasBlockProto to JSON. * @function toJSON * @memberof casper.HasBlockProto * @instance * @returns {Object.<string,*>} JSON object */ HasBlockProto.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; return HasBlockProto; })(); casper.BlockRequestProto = (function() { /** * Properties of a BlockRequestProto. * @memberof casper * @interface IBlockRequestProto * @property {Uint8Array|null} [hash] BlockRequestProto hash */ /** * Constructs a new BlockRequestProto. * @memberof casper * @classdesc Represents a BlockRequestProto. * @implements IBlockRequestProto * @constructor * @param {casper.IBlockRequestProto=} [properties] Properties to set */ function BlockRequestProto(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]]; } /** * BlockRequestProto hash. * @member {Uint8Array} hash * @memberof casper.BlockRequestProto * @instance */ BlockRequestProto.prototype.hash = $util.newBuffer([]); /** * Creates a new BlockRequestProto instance using the specified properties. * @function create * @memberof casper.BlockRequestProto * @static * @param {casper.IBlockRequestProto=} [properties] Properties to set * @returns {casper.BlockRequestProto} BlockRequestProto instance */ BlockRequestProto.create = function create(properties) { return new BlockRequestProto(properties); }; /** * Encodes the specified BlockRequestProto message. Does not implicitly {@link casper.BlockRequestProto.verify|verify} messages. * @function encode * @memberof casper.BlockRequestProto * @static * @param {casper.IBlockRequestProto} message BlockRequestProto message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ BlockRequestProto.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.hash != null && message.hasOwnProperty("hash")) writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.hash); return writer; }; /** * Encodes the specified BlockRequestProto message, length delimited. Does not implicitly {@link casper.BlockRequestProto.verify|verify} messages. * @function encodeDelimited * @memberof casper.BlockRequestProto * @static * @param {casper.IBlockRequestProto} message BlockRequestProto message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ BlockRequestProto.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes a BlockRequestProto message from the specified reader or buffer. * @function decode * @memberof casper.BlockRequestProto * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {casper.BlockRequestProto} BlockRequestProto * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ BlockRequestProto.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.casper.BlockRequestProto(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: message.hash = reader.bytes(); break; default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes a BlockRequestProto message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof casper.BlockRequestProto * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {casper.BlockRequestProto} BlockRequestProto * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ BlockRequestProto.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies a BlockRequestProto message. * @function verify * @memberof casper.BlockRequestProto * @static * @param {Object.<string,*>} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ BlockRequestProto.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.hash != null && message.hasOwnProperty("hash")) if (!(message.hash && typeof message.hash.length === "number" || $util.isString(message.hash))) return "hash: buffer expected"; return null; }; /** * Creates a BlockRequestProto message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof casper.BlockRequestProto * @static * @param {Object.<string,*>} object Plain object * @returns {casper.BlockRequestProto} BlockRequestProto */ BlockRequestProto.fromObject = function fromObject(object) { if (object instanceof $root.casper.BlockRequestProto) return object; var message = new $root.casper.BlockRequestProto(); if (object.hash != null) if (typeof object.hash === "string") $util.base64.decode(object.hash, message.hash = $util.newBuffer($util.base64.length(object.hash)), 0); else if (object.hash.length) message.hash = object.hash; return message; }; /** * Creates a plain object from a BlockRequestProto message. Also converts values to other types if specified. * @function toObject * @memberof casper.BlockRequestProto * @static * @param {casper.BlockRequestProto} message BlockRequestProto * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.<string,*>} Plain object */ BlockRequestProto.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) if (options.bytes === String) object.hash = ""; else { object.hash = []; if (options.bytes !== Array) object.hash = $util.newBuffer(object.hash); } if (message.hash != null && message.hasOwnProperty("hash")) object.hash = options.bytes === String ? $util.base64.encode(message.hash, 0, message.hash.length) : options.bytes === Array ? Array.prototype.slice.call(message.hash) : message.hash; return object; }; /** * Converts this BlockRequestProto to JSON. * @function toJSON * @memberof casper.BlockRequestProto * @instance * @returns {Object.<string,*>} JSON object */ BlockRequestProto.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; return BlockRequestProto; })(); casper.ForkChoiceTipRequestProto = (function() { /** * Properties of a ForkChoiceTipRequestProto. * @memberof casper * @interface IForkChoiceTipRequestProto */ /** * Constructs a new ForkChoiceTipRequestProto. * @memberof casper * @classdesc Represents a ForkChoiceTipRequestProto. * @implements IForkChoiceTipRequestProto * @constructor * @param {casper.IForkChoiceTipRequestProto=} [properties] Properties to set */ function ForkChoiceTipRequestProto(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]]; } /** * Creates a new ForkChoiceTipRequestProto instance using the specified properties. * @function create * @memberof casper.ForkChoiceTipRequestProto * @static * @param {casper.IForkChoiceTipRequestProto=} [properties] Properties to set * @returns {casper.ForkChoiceTipRequestProto} ForkChoiceTipRequestProto instance */ ForkChoiceTipRequestProto.create = function create(properties) { return new ForkChoiceTipRequestProto(properties); }; /** * Encodes the specified ForkChoiceTipRequestProto message. Does not implicitly {@link casper.ForkChoiceTipRequestProto.verify|verify} messages. * @function encode * @memberof casper.ForkChoiceTipRequestProto * @static * @param {casper.IForkChoiceTipRequestProto} message ForkChoiceTipRequestProto message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ ForkChoiceTipRequestProto.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); return writer; }; /** * Encodes the specified ForkChoiceTipRequestProto message, length delimited. Does not implicitly {@link casper.ForkChoiceTipRequestProto.verify|verify} messages. * @function encodeDelimited * @memberof casper.ForkChoiceTipRequestProto * @static * @param {casper.IForkChoiceTipRequestProto} message ForkChoiceTipRequestProto message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ ForkChoiceTipRequestProto.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes a ForkChoiceTipRequestProto message from the specified reader or buffer. * @function decode * @memberof casper.ForkChoiceTipRequestProto * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {casper.ForkChoiceTipRequestProto} ForkChoiceTipRequestProto * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ ForkChoiceTipRequestProto.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.casper.ForkChoiceTipRequestProto(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes a ForkChoiceTipRequestProto message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof casper.ForkChoiceTipRequestProto * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {casper.ForkChoiceTipRequestProto} ForkChoiceTipRequestProto * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ ForkChoiceTipRequestProto.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies a ForkChoiceTipRequestProto message. * @function verify * @memberof casper.ForkChoiceTipRequestProto * @static * @param {Object.<string,*>} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ ForkChoiceTipRequestProto.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; return null; }; /** * Creates a ForkChoiceTipRequestProto message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof casper.ForkChoiceTipRequestProto * @static * @param {Object.<string,*>} object Plain object * @returns {casper.ForkChoiceTipRequestProto} ForkChoiceTipRequestProto */ ForkChoiceTipRequestProto.fromObject = function fromObject(object) { if (object instanceof $root.casper.ForkChoiceTipRequestProto) return object; return new $root.casper.ForkChoiceTipRequestProto(); }; /** * Creates a plain object from a ForkChoiceTipRequestProto message. Also converts values to other types if specified. * @function toObject * @memberof casper.ForkChoiceTipRequestProto * @static * @param {casper.ForkChoiceTipRequestProto} message ForkChoiceTipRequestProto * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.<string,*>} Plain object */ ForkChoiceTipRequestProto.toObject = function toObject() { return {}; }; /** * Converts this ForkChoiceTipRequestProto to JSON. * @function toJSON * @memberof casper.ForkChoiceTipRequestProto * @instance * @returns {Object.<string,*>} JSON object */ ForkChoiceTipRequestProto.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; return ForkChoiceTipRequestProto; })(); casper.ApprovedBlockCandidateProto = (function() { /** * Properties of an ApprovedBlockCandidateProto. * @memberof casper * @interface IApprovedBlockCandidateProto * @property {casper.IBlockMessageProto|null} [block] ApprovedBlockCandidateProto block * @property {number|null} [requiredSigs] ApprovedBlockCandidateProto requiredSigs */ /** * Constructs a new ApprovedBlockCandidateProto. * @memberof casper * @classdesc Represents an ApprovedBlockCandidateProto. * @implements IApprovedBlockCandidateProto * @constructor * @param {casper.IApprovedBlockCandidateProto=} [properties] Properties to set */ function ApprovedBlockCandidateProto(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]]; } /** * ApprovedBlockCandidateProto block. * @member {casper.IBlockMessageProto|null|undefined} block * @memberof casper.ApprovedBlockCandidateProto * @instance */ ApprovedBlockCandidateProto.prototype.block = null; /** * ApprovedBlockCandidateProto requiredSigs. * @member {number} requiredSigs * @memberof casper.ApprovedBlockCandidateProto * @instance */ ApprovedBlockCandidateProto.prototype.requiredSigs = 0; /** * Creates a new ApprovedBlockCandidateProto instance using the specified properties. * @function create * @memberof casper.ApprovedBlockCandidateProto * @static * @param {casper.IApprovedBlockCandidateProto=} [properties] Properties to set * @returns {casper.ApprovedBlockCandidateProto} ApprovedBlockCandidateProto instance */ ApprovedBlockCandidateProto.create = function create(properties) { return new ApprovedBlockCandidateProto(properties); }; /** * Encodes the specified ApprovedBlockCandidateProto message. Does not implicitly {@link casper.ApprovedBlockCandidateProto.verify|verify} messages. * @function encode * @memberof casper.ApprovedBlockCandidateProto * @static * @param {casper.IApprovedBlockCandidateProto} message ApprovedBlockCandidateProto message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ ApprovedBlockCandidateProto.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.block != null && message.hasOwnProperty("block")) $root.casper.BlockMessageProto.encode(message.block, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); if (message.requiredSigs != null && message.hasOwnProperty("requiredSigs")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.requiredSigs); return writer; }; /** * Encodes the specified ApprovedBlockCandidateProto message, length delimited. Does not implicitly {@link casper.ApprovedBlockCandidateProto.verify|verify} messages. * @function encodeDelimited * @memberof casper.ApprovedBlockCandidateProto * @static * @param {casper.IApprovedBlockCandidateProto} message ApprovedBlockCandidateProto message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ ApprovedBlockCandidateProto.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes an ApprovedBlockCandidateProto message from the specified reader or buffer. * @function decode * @memberof casper.ApprovedBlockCandidateProto * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {casper.ApprovedBlockCandidateProto} ApprovedBlockCandidateProto * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ ApprovedBlockCandidateProto.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.casper.ApprovedBlockCandidateProto(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: message.block = $root.casper.BlockMessageProto.decode(reader, reader.uint32()); break; case 2: message.requiredSigs = reader.int32(); break; default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes an ApprovedBlockCandidateProto message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof casper.ApprovedBlockCandidateProto * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {casper.ApprovedBlockCandidateProto} ApprovedBlockCandidateProto * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ ApprovedBlockCandidateProto.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies an ApprovedBlockCandidateProto message. * @function verify * @memberof casper.ApprovedBlockCandidateProto * @static * @param {Object.<string,*>} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ ApprovedBlockCandidateProto.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.block != null && message.hasOwnProperty("block")) { var error = $root.casper.BlockMessageProto.verify(message.block); if (error) return "block." + error; } if (message.requiredSigs != null && message.hasOwnProperty("requiredSigs")) if (!$util.isInteger(message.requiredSigs)) return "requiredSigs: integer expected"; return null; }; /** * Creates an ApprovedBlockCandidateProto message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof casper.ApprovedBlockCandidateProto * @static * @param {Object.<string,*>} object Plain object * @returns {casper.ApprovedBlockCandidateProto} ApprovedBlockCandidateProto */ ApprovedBlockCandidateProto.fromObject = function fromObject(object) { if (object instanceof $root.casper.ApprovedBlockCandidateProto) return object; var message = new $root.casper.ApprovedBlockCandidateProto(); if (object.block != null) { if (typeof object.block !== "object") throw TypeError(".casper.ApprovedBlockCandidateProto.block: object expected"); message.block = $root.casper.BlockMessageProto.fromObject(object.block); } if (object.requiredSigs != null) message.requiredSigs = object.requiredSigs | 0; return message; }; /** * Creates a plain object from an ApprovedBlockCandidateProto message. Also converts values to other types if specified. * @function toObject * @memberof casper.ApprovedBlockCandidateProto * @static * @param {casper.ApprovedBlockCandidateProto} message ApprovedBlockCandidateProto * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.<string,*>} Plain object */ ApprovedBlockCandidateProto.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { object.block = null; object.requiredSigs = 0; } if (message.block != null && message.hasOwnProperty("block")) object.block = $root.casper.BlockMessageProto.toObject(message.block, options); if (message.requiredSigs != null && message.hasOwnProperty("requiredSigs")) object.requiredSigs = message.requiredSigs; return object; }; /** * Converts this ApprovedBlockCandidateProto to JSON. * @function toJSON * @memberof casper.ApprovedBlockCandidateProto * @instance * @returns {Object.<string,*>} JSON object */ ApprovedBlockCandidateProto.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; return ApprovedBlockCandidateProto; })(); casper.UnapprovedBlockProto = (function() { /** * Properties of an UnapprovedBlockProto. * @memberof casper * @interface IUnapprovedBlockProto * @property {casper.IApprovedBlockCandidateProto|null} [candidate] UnapprovedBlockProto candidate * @property {number|Long|null} [timestamp] UnapprovedBlockProto timestamp * @property {number|Long|null} [duration] UnapprovedBlockProto duration */ /** * Constructs a new UnapprovedBlockProto. * @memberof casper * @classdesc Represents an UnapprovedBlockProto. * @implements IUnapprovedBlockProto * @constructor * @param {casper.IUnapprovedBlockProto=} [properties] Properties to set */ function UnapprovedBlockProto(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]]; } /** * UnapprovedBlockProto candidate. * @member {casper.IApprovedBlockCandidateProto|null|undefined} candidate * @memberof casper.UnapprovedBlockProto * @instance */ UnapprovedBlockProto.prototype.candidate = null; /** * UnapprovedBlockProto timestamp. * @member {number|Long} timestamp * @memberof casper.UnapprovedBlockProto * @instance */ UnapprovedBlockProto.prototype.timestamp = $util.Long ? $util.Long.fromBits(0,0,false) : 0; /** * UnapprovedBlockProto duration. * @member {number|Long} duration * @memberof casper.UnapprovedBlockProto * @instance */ UnapprovedBlockProto.prototype.duration = $util.Long ? $util.Long.fromBits(0,0,false) : 0; /** * Creates a new UnapprovedBlockProto instance using the specified properties. * @function create * @memberof casper.UnapprovedBlockProto * @static * @param {casper.IUnapprovedBlockProto=} [properties] Properties to set * @returns {casper.UnapprovedBlockProto} UnapprovedBlockProto instance */ UnapprovedBlockProto.create = function create(properties) { return new UnapprovedBlockProto(properties); }; /** * Encodes the specified UnapprovedBlockProto message. Does not implicitly {@link casper.UnapprovedBlockProto.verify|verify} messages. * @function encode * @memberof casper.UnapprovedBlockProto * @static * @param {casper.IUnapprovedBlockProto} message UnapprovedBlockProto message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ UnapprovedBlockProto.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.candidate != null && message.hasOwnProperty("candidate")) $root.casper.ApprovedBlockCandidateProto.encode(message.candidate, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); if (message.timestamp != null && message.hasOwnProperty("timestamp")) writer.uint32(/* id 2, wireType 0 =*/16).int64(message.timestamp); if (message.duration != null && message.hasOwnProperty("duration")) writer.uint32(/* id 3, wireType 0 =*/24).int64(message.duration); return writer; }; /** * Encodes the specified UnapprovedBlockProto message, length delimited. Does not implicitly {@link casper.UnapprovedBlockProto.verify|verify} messages. * @function encodeDelimited * @memberof casper.UnapprovedBlockProto * @static * @param {casper.IUnapprovedBlockProto} message UnapprovedBlockProto message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ UnapprovedBlockProto.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes an UnapprovedBlockProto message from the specified reader or buffer. * @function decode * @memberof casper.UnapprovedBlockProto * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {casper.UnapprovedBlockProto} UnapprovedBlockProto * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ UnapprovedBlockProto.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.casper.UnapprovedBlockProto(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: message.candidate = $root.casper.ApprovedBlockCandidateProto.decode(reader, reader.uint32()); break; case 2: message.timestamp = reader.int64(); break; case 3: message.duration = reader.int64(); break; default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes an UnapprovedBlockProto message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof casper.UnapprovedBlockProto * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {casper.UnapprovedBlockProto} UnapprovedBlockProto * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ UnapprovedBlockProto.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies an UnapprovedBlockProto message. * @function verify * @memberof casper.UnapprovedBlockProto * @static * @param {Object.<string,*>} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ UnapprovedBlockProto.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.candidate != null && message.hasOwnProperty("candidate")) { var error = $root.casper.ApprovedBlockC