UNPKG

exonum-client

Version:

Light Client for Exonum Blockchain

1,036 lines (964 loc) 280 kB
/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/ (function(global, factory) { /* global define, require, module */ /* AMD */ if (typeof define === 'function' && define.amd) define(["protobufjs/minimal"], factory); /* CommonJS */ else if (typeof require === 'function' && typeof module === 'object' && module && module.exports) module.exports = factory(require("protobufjs/minimal")); })(this, function($protobuf) { "use strict"; // Common aliases var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util; // Exported root namespace var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {}); $root.exonum = (function() { /** * Namespace exonum. * @exports exonum * @namespace */ var exonum = {}; exonum.AdditionalHeaders = (function() { /** * Properties of an AdditionalHeaders. * @memberof exonum * @interface IAdditionalHeaders * @property {exonum.IKeyValueSequence|null} [headers] AdditionalHeaders headers */ /** * Constructs a new AdditionalHeaders. * @memberof exonum * @classdesc Represents an AdditionalHeaders. * @implements IAdditionalHeaders * @constructor * @param {exonum.IAdditionalHeaders=} [properties] Properties to set */ function AdditionalHeaders(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]]; } /** * AdditionalHeaders headers. * @member {exonum.IKeyValueSequence|null|undefined} headers * @memberof exonum.AdditionalHeaders * @instance */ AdditionalHeaders.prototype.headers = null; /** * Creates a new AdditionalHeaders instance using the specified properties. * @function create * @memberof exonum.AdditionalHeaders * @static * @param {exonum.IAdditionalHeaders=} [properties] Properties to set * @returns {exonum.AdditionalHeaders} AdditionalHeaders instance */ AdditionalHeaders.create = function create(properties) { return new AdditionalHeaders(properties); }; /** * Encodes the specified AdditionalHeaders message. Does not implicitly {@link exonum.AdditionalHeaders.verify|verify} messages. * @function encode * @memberof exonum.AdditionalHeaders * @static * @param {exonum.IAdditionalHeaders} message AdditionalHeaders message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ AdditionalHeaders.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.headers != null && message.hasOwnProperty("headers")) $root.exonum.KeyValueSequence.encode(message.headers, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); return writer; }; /** * Encodes the specified AdditionalHeaders message, length delimited. Does not implicitly {@link exonum.AdditionalHeaders.verify|verify} messages. * @function encodeDelimited * @memberof exonum.AdditionalHeaders * @static * @param {exonum.IAdditionalHeaders} message AdditionalHeaders message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ AdditionalHeaders.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes an AdditionalHeaders message from the specified reader or buffer. * @function decode * @memberof exonum.AdditionalHeaders * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {exonum.AdditionalHeaders} AdditionalHeaders * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ AdditionalHeaders.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.exonum.AdditionalHeaders(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: message.headers = $root.exonum.KeyValueSequence.decode(reader, reader.uint32()); break; default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes an AdditionalHeaders message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof exonum.AdditionalHeaders * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {exonum.AdditionalHeaders} AdditionalHeaders * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ AdditionalHeaders.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies an AdditionalHeaders message. * @function verify * @memberof exonum.AdditionalHeaders * @static * @param {Object.<string,*>} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ AdditionalHeaders.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.headers != null && message.hasOwnProperty("headers")) { var error = $root.exonum.KeyValueSequence.verify(message.headers); if (error) return "headers." + error; } return null; }; /** * Creates an AdditionalHeaders message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof exonum.AdditionalHeaders * @static * @param {Object.<string,*>} object Plain object * @returns {exonum.AdditionalHeaders} AdditionalHeaders */ AdditionalHeaders.fromObject = function fromObject(object) { if (object instanceof $root.exonum.AdditionalHeaders) return object; var message = new $root.exonum.AdditionalHeaders(); if (object.headers != null) { if (typeof object.headers !== "object") throw TypeError(".exonum.AdditionalHeaders.headers: object expected"); message.headers = $root.exonum.KeyValueSequence.fromObject(object.headers); } return message; }; /** * Creates a plain object from an AdditionalHeaders message. Also converts values to other types if specified. * @function toObject * @memberof exonum.AdditionalHeaders * @static * @param {exonum.AdditionalHeaders} message AdditionalHeaders * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.<string,*>} Plain object */ AdditionalHeaders.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) object.headers = null; if (message.headers != null && message.hasOwnProperty("headers")) object.headers = $root.exonum.KeyValueSequence.toObject(message.headers, options); return object; }; /** * Converts this AdditionalHeaders to JSON. * @function toJSON * @memberof exonum.AdditionalHeaders * @instance * @returns {Object.<string,*>} JSON object */ AdditionalHeaders.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; return AdditionalHeaders; })(); exonum.Block = (function() { /** * Properties of a Block. * @memberof exonum * @interface IBlock * @property {number|null} [proposer_id] Block proposer_id * @property {number|Long|null} [height] Block height * @property {number|null} [tx_count] Block tx_count * @property {exonum.crypto.IHash|null} [prev_hash] Block prev_hash * @property {exonum.crypto.IHash|null} [tx_hash] Block tx_hash * @property {exonum.crypto.IHash|null} [state_hash] Block state_hash * @property {exonum.crypto.IHash|null} [error_hash] Block error_hash * @property {exonum.IAdditionalHeaders|null} [additional_headers] Block additional_headers */ /** * Constructs a new Block. * @memberof exonum * @classdesc Represents a Block. * @implements IBlock * @constructor * @param {exonum.IBlock=} [properties] Properties to set */ function Block(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]]; } /** * Block proposer_id. * @member {number} proposer_id * @memberof exonum.Block * @instance */ Block.prototype.proposer_id = 0; /** * Block height. * @member {number|Long} height * @memberof exonum.Block * @instance */ Block.prototype.height = $util.Long ? $util.Long.fromBits(0,0,true) : 0; /** * Block tx_count. * @member {number} tx_count * @memberof exonum.Block * @instance */ Block.prototype.tx_count = 0; /** * Block prev_hash. * @member {exonum.crypto.IHash|null|undefined} prev_hash * @memberof exonum.Block * @instance */ Block.prototype.prev_hash = null; /** * Block tx_hash. * @member {exonum.crypto.IHash|null|undefined} tx_hash * @memberof exonum.Block * @instance */ Block.prototype.tx_hash = null; /** * Block state_hash. * @member {exonum.crypto.IHash|null|undefined} state_hash * @memberof exonum.Block * @instance */ Block.prototype.state_hash = null; /** * Block error_hash. * @member {exonum.crypto.IHash|null|undefined} error_hash * @memberof exonum.Block * @instance */ Block.prototype.error_hash = null; /** * Block additional_headers. * @member {exonum.IAdditionalHeaders|null|undefined} additional_headers * @memberof exonum.Block * @instance */ Block.prototype.additional_headers = null; /** * Creates a new Block instance using the specified properties. * @function create * @memberof exonum.Block * @static * @param {exonum.IBlock=} [properties] Properties to set * @returns {exonum.Block} Block instance */ Block.create = function create(properties) { return new Block(properties); }; /** * Encodes the specified Block message. Does not implicitly {@link exonum.Block.verify|verify} messages. * @function encode * @memberof exonum.Block * @static * @param {exonum.IBlock} message Block message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ Block.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.proposer_id != null && message.hasOwnProperty("proposer_id")) writer.uint32(/* id 1, wireType 0 =*/8).uint32(message.proposer_id); if (message.height != null && message.hasOwnProperty("height")) writer.uint32(/* id 2, wireType 0 =*/16).uint64(message.height); if (message.tx_count != null && message.hasOwnProperty("tx_count")) writer.uint32(/* id 3, wireType 0 =*/24).uint32(message.tx_count); if (message.prev_hash != null && message.hasOwnProperty("prev_hash")) $root.exonum.crypto.Hash.encode(message.prev_hash, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); if (message.tx_hash != null && message.hasOwnProperty("tx_hash")) $root.exonum.crypto.Hash.encode(message.tx_hash, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); if (message.state_hash != null && message.hasOwnProperty("state_hash")) $root.exonum.crypto.Hash.encode(message.state_hash, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); if (message.error_hash != null && message.hasOwnProperty("error_hash")) $root.exonum.crypto.Hash.encode(message.error_hash, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); if (message.additional_headers != null && message.hasOwnProperty("additional_headers")) $root.exonum.AdditionalHeaders.encode(message.additional_headers, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); return writer; }; /** * Encodes the specified Block message, length delimited. Does not implicitly {@link exonum.Block.verify|verify} messages. * @function encodeDelimited * @memberof exonum.Block * @static * @param {exonum.IBlock} message Block message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ Block.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes a Block message from the specified reader or buffer. * @function decode * @memberof exonum.Block * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {exonum.Block} Block * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ Block.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.exonum.Block(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: message.proposer_id = reader.uint32(); break; case 2: message.height = reader.uint64(); break; case 3: message.tx_count = reader.uint32(); break; case 4: message.prev_hash = $root.exonum.crypto.Hash.decode(reader, reader.uint32()); break; case 5: message.tx_hash = $root.exonum.crypto.Hash.decode(reader, reader.uint32()); break; case 6: message.state_hash = $root.exonum.crypto.Hash.decode(reader, reader.uint32()); break; case 7: message.error_hash = $root.exonum.crypto.Hash.decode(reader, reader.uint32()); break; case 8: message.additional_headers = $root.exonum.AdditionalHeaders.decode(reader, reader.uint32()); break; default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes a Block message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof exonum.Block * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {exonum.Block} Block * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ Block.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies a Block message. * @function verify * @memberof exonum.Block * @static * @param {Object.<string,*>} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ Block.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.proposer_id != null && message.hasOwnProperty("proposer_id")) if (!$util.isInteger(message.proposer_id)) return "proposer_id: integer expected"; if (message.height != null && message.hasOwnProperty("height")) if (!$util.isInteger(message.height) && !(message.height && $util.isInteger(message.height.low) && $util.isInteger(message.height.high))) return "height: integer|Long expected"; if (message.tx_count != null && message.hasOwnProperty("tx_count")) if (!$util.isInteger(message.tx_count)) return "tx_count: integer expected"; if (message.prev_hash != null && message.hasOwnProperty("prev_hash")) { var error = $root.exonum.crypto.Hash.verify(message.prev_hash); if (error) return "prev_hash." + error; } if (message.tx_hash != null && message.hasOwnProperty("tx_hash")) { var error = $root.exonum.crypto.Hash.verify(message.tx_hash); if (error) return "tx_hash." + error; } if (message.state_hash != null && message.hasOwnProperty("state_hash")) { var error = $root.exonum.crypto.Hash.verify(message.state_hash); if (error) return "state_hash." + error; } if (message.error_hash != null && message.hasOwnProperty("error_hash")) { var error = $root.exonum.crypto.Hash.verify(message.error_hash); if (error) return "error_hash." + error; } if (message.additional_headers != null && message.hasOwnProperty("additional_headers")) { var error = $root.exonum.AdditionalHeaders.verify(message.additional_headers); if (error) return "additional_headers." + error; } return null; }; /** * Creates a Block message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof exonum.Block * @static * @param {Object.<string,*>} object Plain object * @returns {exonum.Block} Block */ Block.fromObject = function fromObject(object) { if (object instanceof $root.exonum.Block) return object; var message = new $root.exonum.Block(); if (object.proposer_id != null) message.proposer_id = object.proposer_id >>> 0; if (object.height != null) if ($util.Long) (message.height = $util.Long.fromValue(object.height)).unsigned = true; else if (typeof object.height === "string") message.height = parseInt(object.height, 10); else if (typeof object.height === "number") message.height = object.height; else if (typeof object.height === "object") message.height = new $util.LongBits(object.height.low >>> 0, object.height.high >>> 0).toNumber(true); if (object.tx_count != null) message.tx_count = object.tx_count >>> 0; if (object.prev_hash != null) { if (typeof object.prev_hash !== "object") throw TypeError(".exonum.Block.prev_hash: object expected"); message.prev_hash = $root.exonum.crypto.Hash.fromObject(object.prev_hash); } if (object.tx_hash != null) { if (typeof object.tx_hash !== "object") throw TypeError(".exonum.Block.tx_hash: object expected"); message.tx_hash = $root.exonum.crypto.Hash.fromObject(object.tx_hash); } if (object.state_hash != null) { if (typeof object.state_hash !== "object") throw TypeError(".exonum.Block.state_hash: object expected"); message.state_hash = $root.exonum.crypto.Hash.fromObject(object.state_hash); } if (object.error_hash != null) { if (typeof object.error_hash !== "object") throw TypeError(".exonum.Block.error_hash: object expected"); message.error_hash = $root.exonum.crypto.Hash.fromObject(object.error_hash); } if (object.additional_headers != null) { if (typeof object.additional_headers !== "object") throw TypeError(".exonum.Block.additional_headers: object expected"); message.additional_headers = $root.exonum.AdditionalHeaders.fromObject(object.additional_headers); } return message; }; /** * Creates a plain object from a Block message. Also converts values to other types if specified. * @function toObject * @memberof exonum.Block * @static * @param {exonum.Block} message Block * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.<string,*>} Plain object */ Block.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { object.proposer_id = 0; if ($util.Long) { var long = new $util.Long(0, 0, true); object.height = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; } else object.height = options.longs === String ? "0" : 0; object.tx_count = 0; object.prev_hash = null; object.tx_hash = null; object.state_hash = null; object.error_hash = null; object.additional_headers = null; } if (message.proposer_id != null && message.hasOwnProperty("proposer_id")) object.proposer_id = message.proposer_id; if (message.height != null && message.hasOwnProperty("height")) if (typeof message.height === "number") object.height = options.longs === String ? String(message.height) : message.height; else object.height = options.longs === String ? $util.Long.prototype.toString.call(message.height) : options.longs === Number ? new $util.LongBits(message.height.low >>> 0, message.height.high >>> 0).toNumber(true) : message.height; if (message.tx_count != null && message.hasOwnProperty("tx_count")) object.tx_count = message.tx_count; if (message.prev_hash != null && message.hasOwnProperty("prev_hash")) object.prev_hash = $root.exonum.crypto.Hash.toObject(message.prev_hash, options); if (message.tx_hash != null && message.hasOwnProperty("tx_hash")) object.tx_hash = $root.exonum.crypto.Hash.toObject(message.tx_hash, options); if (message.state_hash != null && message.hasOwnProperty("state_hash")) object.state_hash = $root.exonum.crypto.Hash.toObject(message.state_hash, options); if (message.error_hash != null && message.hasOwnProperty("error_hash")) object.error_hash = $root.exonum.crypto.Hash.toObject(message.error_hash, options); if (message.additional_headers != null && message.hasOwnProperty("additional_headers")) object.additional_headers = $root.exonum.AdditionalHeaders.toObject(message.additional_headers, options); return object; }; /** * Converts this Block to JSON. * @function toJSON * @memberof exonum.Block * @instance * @returns {Object.<string,*>} JSON object */ Block.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; return Block; })(); exonum.TxLocation = (function() { /** * Properties of a TxLocation. * @memberof exonum * @interface ITxLocation * @property {number|Long|null} [block_height] TxLocation block_height * @property {number|null} [position_in_block] TxLocation position_in_block */ /** * Constructs a new TxLocation. * @memberof exonum * @classdesc Represents a TxLocation. * @implements ITxLocation * @constructor * @param {exonum.ITxLocation=} [properties] Properties to set */ function TxLocation(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]]; } /** * TxLocation block_height. * @member {number|Long} block_height * @memberof exonum.TxLocation * @instance */ TxLocation.prototype.block_height = $util.Long ? $util.Long.fromBits(0,0,true) : 0; /** * TxLocation position_in_block. * @member {number} position_in_block * @memberof exonum.TxLocation * @instance */ TxLocation.prototype.position_in_block = 0; /** * Creates a new TxLocation instance using the specified properties. * @function create * @memberof exonum.TxLocation * @static * @param {exonum.ITxLocation=} [properties] Properties to set * @returns {exonum.TxLocation} TxLocation instance */ TxLocation.create = function create(properties) { return new TxLocation(properties); }; /** * Encodes the specified TxLocation message. Does not implicitly {@link exonum.TxLocation.verify|verify} messages. * @function encode * @memberof exonum.TxLocation * @static * @param {exonum.ITxLocation} message TxLocation message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ TxLocation.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.block_height != null && message.hasOwnProperty("block_height")) writer.uint32(/* id 1, wireType 0 =*/8).uint64(message.block_height); if (message.position_in_block != null && message.hasOwnProperty("position_in_block")) writer.uint32(/* id 2, wireType 0 =*/16).uint32(message.position_in_block); return writer; }; /** * Encodes the specified TxLocation message, length delimited. Does not implicitly {@link exonum.TxLocation.verify|verify} messages. * @function encodeDelimited * @memberof exonum.TxLocation * @static * @param {exonum.ITxLocation} message TxLocation message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ TxLocation.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes a TxLocation message from the specified reader or buffer. * @function decode * @memberof exonum.TxLocation * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {exonum.TxLocation} TxLocation * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ TxLocation.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.exonum.TxLocation(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: message.block_height = reader.uint64(); break; case 2: message.position_in_block = reader.uint32(); break; default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes a TxLocation message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof exonum.TxLocation * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {exonum.TxLocation} TxLocation * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ TxLocation.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies a TxLocation message. * @function verify * @memberof exonum.TxLocation * @static * @param {Object.<string,*>} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ TxLocation.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.block_height != null && message.hasOwnProperty("block_height")) if (!$util.isInteger(message.block_height) && !(message.block_height && $util.isInteger(message.block_height.low) && $util.isInteger(message.block_height.high))) return "block_height: integer|Long expected"; if (message.position_in_block != null && message.hasOwnProperty("position_in_block")) if (!$util.isInteger(message.position_in_block)) return "position_in_block: integer expected"; return null; }; /** * Creates a TxLocation message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof exonum.TxLocation * @static * @param {Object.<string,*>} object Plain object * @returns {exonum.TxLocation} TxLocation */ TxLocation.fromObject = function fromObject(object) { if (object instanceof $root.exonum.TxLocation) return object; var message = new $root.exonum.TxLocation(); if (object.block_height != null) if ($util.Long) (message.block_height = $util.Long.fromValue(object.block_height)).unsigned = true; else if (typeof object.block_height === "string") message.block_height = parseInt(object.block_height, 10); else if (typeof object.block_height === "number") message.block_height = object.block_height; else if (typeof object.block_height === "object") message.block_height = new $util.LongBits(object.block_height.low >>> 0, object.block_height.high >>> 0).toNumber(true); if (object.position_in_block != null) message.position_in_block = object.position_in_block >>> 0; return message; }; /** * Creates a plain object from a TxLocation message. Also converts values to other types if specified. * @function toObject * @memberof exonum.TxLocation * @static * @param {exonum.TxLocation} message TxLocation * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.<string,*>} Plain object */ TxLocation.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.block_height = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; } else object.block_height = options.longs === String ? "0" : 0; object.position_in_block = 0; } if (message.block_height != null && message.hasOwnProperty("block_height")) if (typeof message.block_height === "number") object.block_height = options.longs === String ? String(message.block_height) : message.block_height; else object.block_height = options.longs === String ? $util.Long.prototype.toString.call(message.block_height) : options.longs === Number ? new $util.LongBits(message.block_height.low >>> 0, message.block_height.high >>> 0).toNumber(true) : message.block_height; if (message.position_in_block != null && message.hasOwnProperty("position_in_block")) object.position_in_block = message.position_in_block; return object; }; /** * Converts this TxLocation to JSON. * @function toJSON * @memberof exonum.TxLocation * @instance * @returns {Object.<string,*>} JSON object */ TxLocation.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; return TxLocation; })(); exonum.CallInBlock = (function() { /** * Properties of a CallInBlock. * @memberof exonum * @interface ICallInBlock * @property {number|null} [transaction] CallInBlock transaction * @property {number|null} [before_transactions] CallInBlock before_transactions * @property {number|null} [after_transactions] CallInBlock after_transactions */ /** * Constructs a new CallInBlock. * @memberof exonum * @classdesc Represents a CallInBlock. * @implements ICallInBlock * @constructor * @param {exonum.ICallInBlock=} [properties] Properties to set */ function CallInBlock(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]]; } /** * CallInBlock transaction. * @member {number} transaction * @memberof exonum.CallInBlock * @instance */ CallInBlock.prototype.transaction = 0; /** * CallInBlock before_transactions. * @member {number} before_transactions * @memberof exonum.CallInBlock * @instance */ CallInBlock.prototype.before_transactions = 0; /** * CallInBlock after_transactions. * @member {number} after_transactions * @memberof exonum.CallInBlock * @instance */ CallInBlock.prototype.after_transactions = 0; // OneOf field names bound to virtual getters and setters var $oneOfFields; /** * CallInBlock call. * @member {"transaction"|"before_transactions"|"after_transactions"|undefined} call * @memberof exonum.CallInBlock * @instance */ Object.defineProperty(CallInBlock.prototype, "call", { get: $util.oneOfGetter($oneOfFields = ["transaction", "before_transactions", "after_transactions"]), set: $util.oneOfSetter($oneOfFields) }); /** * Creates a new CallInBlock instance using the specified properties. * @function create * @memberof exonum.CallInBlock * @static * @param {exonum.ICallInBlock=} [properties] Properties to set * @returns {exonum.CallInBlock} CallInBlock instance */ CallInBlock.create = function create(properties) { return new CallInBlock(properties); }; /** * Encodes the specified CallInBlock message. Does not implicitly {@link exonum.CallInBlock.verify|verify} messages. * @function encode * @memberof exonum.CallInBlock * @static * @param {exonum.ICallInBlock} message CallInBlock message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ CallInBlock.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.transaction != null && message.hasOwnProperty("transaction")) writer.uint32(/* id 1, wireType 0 =*/8).uint32(message.transaction); if (message.before_transactions != null && message.hasOwnProperty("before_transactions")) writer.uint32(/* id 2, wireType 0 =*/16).uint32(message.before_transactions); if (message.after_transactions != null && message.hasOwnProperty("after_transactions")) writer.uint32(/* id 3, wireType 0 =*/24).uint32(message.after_transactions); return writer; }; /** * Encodes the specified CallInBlock message, length delimited. Does not implicitly {@link exonum.CallInBlock.verify|verify} messages. * @function encodeDelimited * @memberof exonum.CallInBlock * @static * @param {exonum.ICallInBlock} message CallInBlock message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ CallInBlock.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes a CallInBlock message from the specified reader or buffer. * @function decode * @memberof exonum.CallInBlock * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {exonum.CallInBlock} CallInBlock * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ CallInBlock.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.exonum.CallInBlock(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: message.transaction = reader.uint32(); break; case 2: message.before_transactions = reader.uint32(); break; case 3: message.after_transactions = reader.uint32(); break; default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes a CallInBlock message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof exonum.CallInBlock * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {exonum.CallInBlock} CallInBlock * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ CallInBlock.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies a CallInBlock message. * @function verify * @memberof exonum.CallInBlock * @static * @param {Object.<string,*>} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ CallInBlock.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; var properties = {}; if (message.transaction != null && message.hasOwnProperty("transaction")) { properties.call = 1; if (!$util.isInteger(message.transaction)) return "transaction: integer expected"; } if (message.before_transactions != null && message.hasOwnProperty("before_transactions")) { if (properties.call === 1) return "call: multiple values"; properties.call = 1; if (!$util.isInteger(message.before_transactions)) return "before_transactions: integer expected"; } if (message.after_transactions != null && message.hasOwnProperty("after_transactions")) { if (properties.call === 1) return "call: multiple values"; properties.call = 1; if (!$util.isInteger(message.after_transactions)) return "after_transactions: integer expected"; } return null; }; /** * Creates a CallInBlock message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof exonum.CallInBlock * @static * @param {Object.<string,*>} object Plain object * @returns {exonum.CallInBlock} CallInBlock */ CallInBlock.fromObject = function fromObject(object) { if (object instanceof $root.exonum.CallInBlock) return object; var message = new $root.exonum.CallInBlock(); if (object.transaction != null) message.transaction = object.transaction >>> 0; if (object.before_transactions != null) message.before_transactions = object.before_transactions >>> 0; if (object.after_transacti