@bitgo/abstract-cosmos 11.16.0 → 11.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1090 @@
1
+ /*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/
2
+ 'use strict';
3
+
4
+ var $protobuf = require('protobufjs/minimal');
5
+
6
+ // Common aliases
7
+ var $Reader = $protobuf.Reader,
8
+ $Writer = $protobuf.Writer,
9
+ $util = $protobuf.util;
10
+
11
+ // Exported root namespace
12
+ var $root = $protobuf.roots['default'] || ($protobuf.roots['default'] = {});
13
+
14
+ $root.cosmos = (function () {
15
+ /**
16
+ * Namespace cosmos.
17
+ * @exports cosmos
18
+ * @namespace
19
+ */
20
+ var cosmos = {};
21
+
22
+ cosmos.group = (function () {
23
+ /**
24
+ * Namespace group.
25
+ * @memberof cosmos
26
+ * @namespace
27
+ */
28
+ var group = {};
29
+
30
+ group.v1 = (function () {
31
+ /**
32
+ * Namespace v1.
33
+ * @memberof cosmos.group
34
+ * @namespace
35
+ */
36
+ var v1 = {};
37
+
38
+ v1.MsgSubmitProposal = (function () {
39
+ /**
40
+ * Properties of a MsgSubmitProposal.
41
+ * @memberof cosmos.group.v1
42
+ * @interface IMsgSubmitProposal
43
+ * @property {string|null} [groupPolicyAddress] MsgSubmitProposal groupPolicyAddress
44
+ * @property {Array.<string>|null} [proposers] MsgSubmitProposal proposers
45
+ * @property {string|null} [metadata] MsgSubmitProposal metadata
46
+ * @property {Array.<google.protobuf.IAny>|null} [messages] MsgSubmitProposal messages
47
+ * @property {cosmos.group.v1.Exec|null} [exec] MsgSubmitProposal exec
48
+ * @property {string|null} [title] MsgSubmitProposal title
49
+ * @property {string|null} [summary] MsgSubmitProposal summary
50
+ */
51
+
52
+ /**
53
+ * Constructs a new MsgSubmitProposal.
54
+ * @memberof cosmos.group.v1
55
+ * @classdesc Represents a MsgSubmitProposal.
56
+ * @implements IMsgSubmitProposal
57
+ * @constructor
58
+ * @param {cosmos.group.v1.IMsgSubmitProposal=} [properties] Properties to set
59
+ */
60
+ function MsgSubmitProposal(properties) {
61
+ this.proposers = [];
62
+ this.messages = [];
63
+ if (properties)
64
+ for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
65
+ if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]];
66
+ }
67
+
68
+ /**
69
+ * MsgSubmitProposal groupPolicyAddress.
70
+ * @member {string} groupPolicyAddress
71
+ * @memberof cosmos.group.v1.MsgSubmitProposal
72
+ * @instance
73
+ */
74
+ MsgSubmitProposal.prototype.groupPolicyAddress = '';
75
+
76
+ /**
77
+ * MsgSubmitProposal proposers.
78
+ * @member {Array.<string>} proposers
79
+ * @memberof cosmos.group.v1.MsgSubmitProposal
80
+ * @instance
81
+ */
82
+ MsgSubmitProposal.prototype.proposers = $util.emptyArray;
83
+
84
+ /**
85
+ * MsgSubmitProposal metadata.
86
+ * @member {string} metadata
87
+ * @memberof cosmos.group.v1.MsgSubmitProposal
88
+ * @instance
89
+ */
90
+ MsgSubmitProposal.prototype.metadata = '';
91
+
92
+ /**
93
+ * MsgSubmitProposal messages.
94
+ * @member {Array.<google.protobuf.IAny>} messages
95
+ * @memberof cosmos.group.v1.MsgSubmitProposal
96
+ * @instance
97
+ */
98
+ MsgSubmitProposal.prototype.messages = $util.emptyArray;
99
+
100
+ /**
101
+ * MsgSubmitProposal exec.
102
+ * @member {cosmos.group.v1.Exec} exec
103
+ * @memberof cosmos.group.v1.MsgSubmitProposal
104
+ * @instance
105
+ */
106
+ MsgSubmitProposal.prototype.exec = 0;
107
+
108
+ /**
109
+ * MsgSubmitProposal title.
110
+ * @member {string} title
111
+ * @memberof cosmos.group.v1.MsgSubmitProposal
112
+ * @instance
113
+ */
114
+ MsgSubmitProposal.prototype.title = '';
115
+
116
+ /**
117
+ * MsgSubmitProposal summary.
118
+ * @member {string} summary
119
+ * @memberof cosmos.group.v1.MsgSubmitProposal
120
+ * @instance
121
+ */
122
+ MsgSubmitProposal.prototype.summary = '';
123
+
124
+ /**
125
+ * Creates a new MsgSubmitProposal instance using the specified properties.
126
+ * @function create
127
+ * @memberof cosmos.group.v1.MsgSubmitProposal
128
+ * @static
129
+ * @param {cosmos.group.v1.IMsgSubmitProposal=} [properties] Properties to set
130
+ * @returns {cosmos.group.v1.MsgSubmitProposal} MsgSubmitProposal instance
131
+ */
132
+ MsgSubmitProposal.create = function create(properties) {
133
+ return new MsgSubmitProposal(properties);
134
+ };
135
+
136
+ /**
137
+ * Encodes the specified MsgSubmitProposal message. Does not implicitly {@link cosmos.group.v1.MsgSubmitProposal.verify|verify} messages.
138
+ * @function encode
139
+ * @memberof cosmos.group.v1.MsgSubmitProposal
140
+ * @static
141
+ * @param {cosmos.group.v1.IMsgSubmitProposal} message MsgSubmitProposal message or plain object to encode
142
+ * @param {$protobuf.Writer} [writer] Writer to encode to
143
+ * @returns {$protobuf.Writer} Writer
144
+ */
145
+ MsgSubmitProposal.encode = function encode(message, writer) {
146
+ if (!writer) writer = $Writer.create();
147
+ if (message.groupPolicyAddress != null && Object.hasOwnProperty.call(message, 'groupPolicyAddress'))
148
+ writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.groupPolicyAddress);
149
+ if (message.proposers != null && message.proposers.length)
150
+ for (var i = 0; i < message.proposers.length; ++i)
151
+ writer.uint32(/* id 2, wireType 2 =*/ 18).string(message.proposers[i]);
152
+ if (message.metadata != null && Object.hasOwnProperty.call(message, 'metadata'))
153
+ writer.uint32(/* id 3, wireType 2 =*/ 26).string(message.metadata);
154
+ if (message.messages != null && message.messages.length)
155
+ for (var i = 0; i < message.messages.length; ++i)
156
+ $root.google.protobuf.Any.encode(
157
+ message.messages[i],
158
+ writer.uint32(/* id 4, wireType 2 =*/ 34).fork()
159
+ ).ldelim();
160
+ if (message.exec != null && Object.hasOwnProperty.call(message, 'exec'))
161
+ writer.uint32(/* id 5, wireType 0 =*/ 40).int32(message.exec);
162
+ if (message.title != null && Object.hasOwnProperty.call(message, 'title'))
163
+ writer.uint32(/* id 6, wireType 2 =*/ 50).string(message.title);
164
+ if (message.summary != null && Object.hasOwnProperty.call(message, 'summary'))
165
+ writer.uint32(/* id 7, wireType 2 =*/ 58).string(message.summary);
166
+ return writer;
167
+ };
168
+
169
+ /**
170
+ * Encodes the specified MsgSubmitProposal message, length delimited. Does not implicitly {@link cosmos.group.v1.MsgSubmitProposal.verify|verify} messages.
171
+ * @function encodeDelimited
172
+ * @memberof cosmos.group.v1.MsgSubmitProposal
173
+ * @static
174
+ * @param {cosmos.group.v1.IMsgSubmitProposal} message MsgSubmitProposal message or plain object to encode
175
+ * @param {$protobuf.Writer} [writer] Writer to encode to
176
+ * @returns {$protobuf.Writer} Writer
177
+ */
178
+ MsgSubmitProposal.encodeDelimited = function encodeDelimited(message, writer) {
179
+ return this.encode(message, writer).ldelim();
180
+ };
181
+
182
+ /**
183
+ * Decodes a MsgSubmitProposal message from the specified reader or buffer.
184
+ * @function decode
185
+ * @memberof cosmos.group.v1.MsgSubmitProposal
186
+ * @static
187
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
188
+ * @param {number} [length] Message length if known beforehand
189
+ * @returns {cosmos.group.v1.MsgSubmitProposal} MsgSubmitProposal
190
+ * @throws {Error} If the payload is not a reader or valid buffer
191
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
192
+ */
193
+ MsgSubmitProposal.decode = function decode(reader, length, error) {
194
+ if (!(reader instanceof $Reader)) reader = $Reader.create(reader);
195
+ var end = length === undefined ? reader.len : reader.pos + length,
196
+ message = new $root.cosmos.group.v1.MsgSubmitProposal();
197
+ while (reader.pos < end) {
198
+ var tag = reader.uint32();
199
+ if (tag === error) break;
200
+ switch (tag >>> 3) {
201
+ case 1: {
202
+ message.groupPolicyAddress = reader.string();
203
+ break;
204
+ }
205
+ case 2: {
206
+ if (!(message.proposers && message.proposers.length)) message.proposers = [];
207
+ message.proposers.push(reader.string());
208
+ break;
209
+ }
210
+ case 3: {
211
+ message.metadata = reader.string();
212
+ break;
213
+ }
214
+ case 4: {
215
+ if (!(message.messages && message.messages.length)) message.messages = [];
216
+ message.messages.push($root.google.protobuf.Any.decode(reader, reader.uint32()));
217
+ break;
218
+ }
219
+ case 5: {
220
+ message.exec = reader.int32();
221
+ break;
222
+ }
223
+ case 6: {
224
+ message.title = reader.string();
225
+ break;
226
+ }
227
+ case 7: {
228
+ message.summary = reader.string();
229
+ break;
230
+ }
231
+ default:
232
+ reader.skipType(tag & 7);
233
+ break;
234
+ }
235
+ }
236
+ return message;
237
+ };
238
+
239
+ /**
240
+ * Decodes a MsgSubmitProposal message from the specified reader or buffer, length delimited.
241
+ * @function decodeDelimited
242
+ * @memberof cosmos.group.v1.MsgSubmitProposal
243
+ * @static
244
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
245
+ * @returns {cosmos.group.v1.MsgSubmitProposal} MsgSubmitProposal
246
+ * @throws {Error} If the payload is not a reader or valid buffer
247
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
248
+ */
249
+ MsgSubmitProposal.decodeDelimited = function decodeDelimited(reader) {
250
+ if (!(reader instanceof $Reader)) reader = new $Reader(reader);
251
+ return this.decode(reader, reader.uint32());
252
+ };
253
+
254
+ /**
255
+ * Verifies a MsgSubmitProposal message.
256
+ * @function verify
257
+ * @memberof cosmos.group.v1.MsgSubmitProposal
258
+ * @static
259
+ * @param {Object.<string,*>} message Plain object to verify
260
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
261
+ */
262
+ MsgSubmitProposal.verify = function verify(message) {
263
+ if (typeof message !== 'object' || message === null) return 'object expected';
264
+ if (message.groupPolicyAddress != null && message.hasOwnProperty('groupPolicyAddress'))
265
+ if (!$util.isString(message.groupPolicyAddress)) return 'groupPolicyAddress: string expected';
266
+ if (message.proposers != null && message.hasOwnProperty('proposers')) {
267
+ if (!Array.isArray(message.proposers)) return 'proposers: array expected';
268
+ for (var i = 0; i < message.proposers.length; ++i)
269
+ if (!$util.isString(message.proposers[i])) return 'proposers: string[] expected';
270
+ }
271
+ if (message.metadata != null && message.hasOwnProperty('metadata'))
272
+ if (!$util.isString(message.metadata)) return 'metadata: string expected';
273
+ if (message.messages != null && message.hasOwnProperty('messages')) {
274
+ if (!Array.isArray(message.messages)) return 'messages: array expected';
275
+ for (var i = 0; i < message.messages.length; ++i) {
276
+ var error = $root.google.protobuf.Any.verify(message.messages[i]);
277
+ if (error) return 'messages.' + error;
278
+ }
279
+ }
280
+ if (message.exec != null && message.hasOwnProperty('exec'))
281
+ switch (message.exec) {
282
+ default:
283
+ return 'exec: enum value expected';
284
+ case 0:
285
+ case 1:
286
+ break;
287
+ }
288
+ if (message.title != null && message.hasOwnProperty('title'))
289
+ if (!$util.isString(message.title)) return 'title: string expected';
290
+ if (message.summary != null && message.hasOwnProperty('summary'))
291
+ if (!$util.isString(message.summary)) return 'summary: string expected';
292
+ return null;
293
+ };
294
+
295
+ /**
296
+ * Creates a MsgSubmitProposal message from a plain object. Also converts values to their respective internal types.
297
+ * @function fromObject
298
+ * @memberof cosmos.group.v1.MsgSubmitProposal
299
+ * @static
300
+ * @param {Object.<string,*>} object Plain object
301
+ * @returns {cosmos.group.v1.MsgSubmitProposal} MsgSubmitProposal
302
+ */
303
+ MsgSubmitProposal.fromObject = function fromObject(object) {
304
+ if (object instanceof $root.cosmos.group.v1.MsgSubmitProposal) return object;
305
+ var message = new $root.cosmos.group.v1.MsgSubmitProposal();
306
+ if (object.groupPolicyAddress != null) message.groupPolicyAddress = String(object.groupPolicyAddress);
307
+ if (object.proposers) {
308
+ if (!Array.isArray(object.proposers))
309
+ throw TypeError('.cosmos.group.v1.MsgSubmitProposal.proposers: array expected');
310
+ message.proposers = [];
311
+ for (var i = 0; i < object.proposers.length; ++i) message.proposers[i] = String(object.proposers[i]);
312
+ }
313
+ if (object.metadata != null) message.metadata = String(object.metadata);
314
+ if (object.messages) {
315
+ if (!Array.isArray(object.messages))
316
+ throw TypeError('.cosmos.group.v1.MsgSubmitProposal.messages: array expected');
317
+ message.messages = [];
318
+ for (var i = 0; i < object.messages.length; ++i) {
319
+ if (typeof object.messages[i] !== 'object')
320
+ throw TypeError('.cosmos.group.v1.MsgSubmitProposal.messages: object expected');
321
+ message.messages[i] = $root.google.protobuf.Any.fromObject(object.messages[i]);
322
+ }
323
+ }
324
+ switch (object.exec) {
325
+ default:
326
+ if (typeof object.exec === 'number') {
327
+ message.exec = object.exec;
328
+ break;
329
+ }
330
+ break;
331
+ case 'EXEC_UNSPECIFIED':
332
+ case 0:
333
+ message.exec = 0;
334
+ break;
335
+ case 'EXEC_TRY':
336
+ case 1:
337
+ message.exec = 1;
338
+ break;
339
+ }
340
+ if (object.title != null) message.title = String(object.title);
341
+ if (object.summary != null) message.summary = String(object.summary);
342
+ return message;
343
+ };
344
+
345
+ /**
346
+ * Creates a plain object from a MsgSubmitProposal message. Also converts values to other types if specified.
347
+ * @function toObject
348
+ * @memberof cosmos.group.v1.MsgSubmitProposal
349
+ * @static
350
+ * @param {cosmos.group.v1.MsgSubmitProposal} message MsgSubmitProposal
351
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
352
+ * @returns {Object.<string,*>} Plain object
353
+ */
354
+ MsgSubmitProposal.toObject = function toObject(message, options) {
355
+ if (!options) options = {};
356
+ var object = {};
357
+ if (options.arrays || options.defaults) {
358
+ object.proposers = [];
359
+ object.messages = [];
360
+ }
361
+ if (options.defaults) {
362
+ object.groupPolicyAddress = '';
363
+ object.metadata = '';
364
+ object.exec = options.enums === String ? 'EXEC_UNSPECIFIED' : 0;
365
+ object.title = '';
366
+ object.summary = '';
367
+ }
368
+ if (message.groupPolicyAddress != null && message.hasOwnProperty('groupPolicyAddress'))
369
+ object.groupPolicyAddress = message.groupPolicyAddress;
370
+ if (message.proposers && message.proposers.length) {
371
+ object.proposers = [];
372
+ for (var j = 0; j < message.proposers.length; ++j) object.proposers[j] = message.proposers[j];
373
+ }
374
+ if (message.metadata != null && message.hasOwnProperty('metadata')) object.metadata = message.metadata;
375
+ if (message.messages && message.messages.length) {
376
+ object.messages = [];
377
+ for (var j = 0; j < message.messages.length; ++j)
378
+ object.messages[j] = $root.google.protobuf.Any.toObject(message.messages[j], options);
379
+ }
380
+ if (message.exec != null && message.hasOwnProperty('exec'))
381
+ object.exec =
382
+ options.enums === String
383
+ ? $root.cosmos.group.v1.Exec[message.exec] === undefined
384
+ ? message.exec
385
+ : $root.cosmos.group.v1.Exec[message.exec]
386
+ : message.exec;
387
+ if (message.title != null && message.hasOwnProperty('title')) object.title = message.title;
388
+ if (message.summary != null && message.hasOwnProperty('summary')) object.summary = message.summary;
389
+ return object;
390
+ };
391
+
392
+ /**
393
+ * Converts this MsgSubmitProposal to JSON.
394
+ * @function toJSON
395
+ * @memberof cosmos.group.v1.MsgSubmitProposal
396
+ * @instance
397
+ * @returns {Object.<string,*>} JSON object
398
+ */
399
+ MsgSubmitProposal.prototype.toJSON = function toJSON() {
400
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
401
+ };
402
+
403
+ /**
404
+ * Gets the default type url for MsgSubmitProposal
405
+ * @function getTypeUrl
406
+ * @memberof cosmos.group.v1.MsgSubmitProposal
407
+ * @static
408
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
409
+ * @returns {string} The default type url
410
+ */
411
+ MsgSubmitProposal.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
412
+ if (typeUrlPrefix === undefined) {
413
+ typeUrlPrefix = 'type.googleapis.com';
414
+ }
415
+ return typeUrlPrefix + '/cosmos.group.v1.MsgSubmitProposal';
416
+ };
417
+
418
+ return MsgSubmitProposal;
419
+ })();
420
+
421
+ /**
422
+ * Exec enum.
423
+ * @name cosmos.group.v1.Exec
424
+ * @enum {number}
425
+ * @property {number} EXEC_UNSPECIFIED=0 EXEC_UNSPECIFIED value
426
+ * @property {number} EXEC_TRY=1 EXEC_TRY value
427
+ */
428
+ v1.Exec = (function () {
429
+ var valuesById = {},
430
+ values = Object.create(valuesById);
431
+ values[(valuesById[0] = 'EXEC_UNSPECIFIED')] = 0;
432
+ values[(valuesById[1] = 'EXEC_TRY')] = 1;
433
+ return values;
434
+ })();
435
+
436
+ /**
437
+ * VoteOption enum.
438
+ * @name cosmos.group.v1.VoteOption
439
+ * @enum {number}
440
+ * @property {number} VOTE_OPTION_UNSPECIFIED=0 VOTE_OPTION_UNSPECIFIED value
441
+ * @property {number} VOTE_OPTION_YES=1 VOTE_OPTION_YES value
442
+ * @property {number} VOTE_OPTION_ABSTAIN=2 VOTE_OPTION_ABSTAIN value
443
+ * @property {number} VOTE_OPTION_NO=3 VOTE_OPTION_NO value
444
+ * @property {number} VOTE_OPTION_NO_WITH_VETO=4 VOTE_OPTION_NO_WITH_VETO value
445
+ */
446
+ v1.VoteOption = (function () {
447
+ var valuesById = {},
448
+ values = Object.create(valuesById);
449
+ values[(valuesById[0] = 'VOTE_OPTION_UNSPECIFIED')] = 0;
450
+ values[(valuesById[1] = 'VOTE_OPTION_YES')] = 1;
451
+ values[(valuesById[2] = 'VOTE_OPTION_ABSTAIN')] = 2;
452
+ values[(valuesById[3] = 'VOTE_OPTION_NO')] = 3;
453
+ values[(valuesById[4] = 'VOTE_OPTION_NO_WITH_VETO')] = 4;
454
+ return values;
455
+ })();
456
+
457
+ v1.MsgVote = (function () {
458
+ /**
459
+ * Properties of a MsgVote.
460
+ * @memberof cosmos.group.v1
461
+ * @interface IMsgVote
462
+ * @property {number|Long|null} [proposalId] MsgVote proposalId
463
+ * @property {string|null} [voter] MsgVote voter
464
+ * @property {cosmos.group.v1.VoteOption|null} [option] MsgVote option
465
+ * @property {string|null} [metadata] MsgVote metadata
466
+ * @property {cosmos.group.v1.Exec|null} [exec] MsgVote exec
467
+ */
468
+
469
+ /**
470
+ * Constructs a new MsgVote.
471
+ * @memberof cosmos.group.v1
472
+ * @classdesc Represents a MsgVote.
473
+ * @implements IMsgVote
474
+ * @constructor
475
+ * @param {cosmos.group.v1.IMsgVote=} [properties] Properties to set
476
+ */
477
+ function MsgVote(properties) {
478
+ if (properties)
479
+ for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
480
+ if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]];
481
+ }
482
+
483
+ /**
484
+ * MsgVote proposalId.
485
+ * @member {number|Long} proposalId
486
+ * @memberof cosmos.group.v1.MsgVote
487
+ * @instance
488
+ */
489
+ MsgVote.prototype.proposalId = $util.Long ? $util.Long.fromBits(0, 0, true) : 0;
490
+
491
+ /**
492
+ * MsgVote voter.
493
+ * @member {string} voter
494
+ * @memberof cosmos.group.v1.MsgVote
495
+ * @instance
496
+ */
497
+ MsgVote.prototype.voter = '';
498
+
499
+ /**
500
+ * MsgVote option.
501
+ * @member {cosmos.group.v1.VoteOption} option
502
+ * @memberof cosmos.group.v1.MsgVote
503
+ * @instance
504
+ */
505
+ MsgVote.prototype.option = 0;
506
+
507
+ /**
508
+ * MsgVote metadata.
509
+ * @member {string} metadata
510
+ * @memberof cosmos.group.v1.MsgVote
511
+ * @instance
512
+ */
513
+ MsgVote.prototype.metadata = '';
514
+
515
+ /**
516
+ * MsgVote exec.
517
+ * @member {cosmos.group.v1.Exec} exec
518
+ * @memberof cosmos.group.v1.MsgVote
519
+ * @instance
520
+ */
521
+ MsgVote.prototype.exec = 0;
522
+
523
+ /**
524
+ * Creates a new MsgVote instance using the specified properties.
525
+ * @function create
526
+ * @memberof cosmos.group.v1.MsgVote
527
+ * @static
528
+ * @param {cosmos.group.v1.IMsgVote=} [properties] Properties to set
529
+ * @returns {cosmos.group.v1.MsgVote} MsgVote instance
530
+ */
531
+ MsgVote.create = function create(properties) {
532
+ return new MsgVote(properties);
533
+ };
534
+
535
+ /**
536
+ * Encodes the specified MsgVote message. Does not implicitly {@link cosmos.group.v1.MsgVote.verify|verify} messages.
537
+ * @function encode
538
+ * @memberof cosmos.group.v1.MsgVote
539
+ * @static
540
+ * @param {cosmos.group.v1.IMsgVote} message MsgVote message or plain object to encode
541
+ * @param {$protobuf.Writer} [writer] Writer to encode to
542
+ * @returns {$protobuf.Writer} Writer
543
+ */
544
+ MsgVote.encode = function encode(message, writer) {
545
+ if (!writer) writer = $Writer.create();
546
+ if (message.proposalId != null && Object.hasOwnProperty.call(message, 'proposalId'))
547
+ writer.uint32(/* id 1, wireType 0 =*/ 8).uint64(message.proposalId);
548
+ if (message.voter != null && Object.hasOwnProperty.call(message, 'voter'))
549
+ writer.uint32(/* id 2, wireType 2 =*/ 18).string(message.voter);
550
+ if (message.option != null && Object.hasOwnProperty.call(message, 'option'))
551
+ writer.uint32(/* id 3, wireType 0 =*/ 24).int32(message.option);
552
+ if (message.metadata != null && Object.hasOwnProperty.call(message, 'metadata'))
553
+ writer.uint32(/* id 4, wireType 2 =*/ 34).string(message.metadata);
554
+ if (message.exec != null && Object.hasOwnProperty.call(message, 'exec'))
555
+ writer.uint32(/* id 5, wireType 0 =*/ 40).int32(message.exec);
556
+ return writer;
557
+ };
558
+
559
+ /**
560
+ * Encodes the specified MsgVote message, length delimited. Does not implicitly {@link cosmos.group.v1.MsgVote.verify|verify} messages.
561
+ * @function encodeDelimited
562
+ * @memberof cosmos.group.v1.MsgVote
563
+ * @static
564
+ * @param {cosmos.group.v1.IMsgVote} message MsgVote message or plain object to encode
565
+ * @param {$protobuf.Writer} [writer] Writer to encode to
566
+ * @returns {$protobuf.Writer} Writer
567
+ */
568
+ MsgVote.encodeDelimited = function encodeDelimited(message, writer) {
569
+ return this.encode(message, writer).ldelim();
570
+ };
571
+
572
+ /**
573
+ * Decodes a MsgVote message from the specified reader or buffer.
574
+ * @function decode
575
+ * @memberof cosmos.group.v1.MsgVote
576
+ * @static
577
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
578
+ * @param {number} [length] Message length if known beforehand
579
+ * @returns {cosmos.group.v1.MsgVote} MsgVote
580
+ * @throws {Error} If the payload is not a reader or valid buffer
581
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
582
+ */
583
+ MsgVote.decode = function decode(reader, length, error) {
584
+ if (!(reader instanceof $Reader)) reader = $Reader.create(reader);
585
+ var end = length === undefined ? reader.len : reader.pos + length,
586
+ message = new $root.cosmos.group.v1.MsgVote();
587
+ while (reader.pos < end) {
588
+ var tag = reader.uint32();
589
+ if (tag === error) break;
590
+ switch (tag >>> 3) {
591
+ case 1: {
592
+ message.proposalId = reader.uint64();
593
+ break;
594
+ }
595
+ case 2: {
596
+ message.voter = reader.string();
597
+ break;
598
+ }
599
+ case 3: {
600
+ message.option = reader.int32();
601
+ break;
602
+ }
603
+ case 4: {
604
+ message.metadata = reader.string();
605
+ break;
606
+ }
607
+ case 5: {
608
+ message.exec = reader.int32();
609
+ break;
610
+ }
611
+ default:
612
+ reader.skipType(tag & 7);
613
+ break;
614
+ }
615
+ }
616
+ return message;
617
+ };
618
+
619
+ /**
620
+ * Decodes a MsgVote message from the specified reader or buffer, length delimited.
621
+ * @function decodeDelimited
622
+ * @memberof cosmos.group.v1.MsgVote
623
+ * @static
624
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
625
+ * @returns {cosmos.group.v1.MsgVote} MsgVote
626
+ * @throws {Error} If the payload is not a reader or valid buffer
627
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
628
+ */
629
+ MsgVote.decodeDelimited = function decodeDelimited(reader) {
630
+ if (!(reader instanceof $Reader)) reader = new $Reader(reader);
631
+ return this.decode(reader, reader.uint32());
632
+ };
633
+
634
+ /**
635
+ * Verifies a MsgVote message.
636
+ * @function verify
637
+ * @memberof cosmos.group.v1.MsgVote
638
+ * @static
639
+ * @param {Object.<string,*>} message Plain object to verify
640
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
641
+ */
642
+ MsgVote.verify = function verify(message) {
643
+ if (typeof message !== 'object' || message === null) return 'object expected';
644
+ if (message.proposalId != null && message.hasOwnProperty('proposalId'))
645
+ if (
646
+ !$util.isInteger(message.proposalId) &&
647
+ !(
648
+ message.proposalId &&
649
+ $util.isInteger(message.proposalId.low) &&
650
+ $util.isInteger(message.proposalId.high)
651
+ )
652
+ )
653
+ return 'proposalId: integer|Long expected';
654
+ if (message.voter != null && message.hasOwnProperty('voter'))
655
+ if (!$util.isString(message.voter)) return 'voter: string expected';
656
+ if (message.option != null && message.hasOwnProperty('option'))
657
+ switch (message.option) {
658
+ default:
659
+ return 'option: enum value expected';
660
+ case 0:
661
+ case 1:
662
+ case 2:
663
+ case 3:
664
+ case 4:
665
+ break;
666
+ }
667
+ if (message.metadata != null && message.hasOwnProperty('metadata'))
668
+ if (!$util.isString(message.metadata)) return 'metadata: string expected';
669
+ if (message.exec != null && message.hasOwnProperty('exec'))
670
+ switch (message.exec) {
671
+ default:
672
+ return 'exec: enum value expected';
673
+ case 0:
674
+ case 1:
675
+ break;
676
+ }
677
+ return null;
678
+ };
679
+
680
+ /**
681
+ * Creates a MsgVote message from a plain object. Also converts values to their respective internal types.
682
+ * @function fromObject
683
+ * @memberof cosmos.group.v1.MsgVote
684
+ * @static
685
+ * @param {Object.<string,*>} object Plain object
686
+ * @returns {cosmos.group.v1.MsgVote} MsgVote
687
+ */
688
+ MsgVote.fromObject = function fromObject(object) {
689
+ if (object instanceof $root.cosmos.group.v1.MsgVote) return object;
690
+ var message = new $root.cosmos.group.v1.MsgVote();
691
+ if (object.proposalId != null)
692
+ if ($util.Long) (message.proposalId = $util.Long.fromValue(object.proposalId)).unsigned = true;
693
+ else if (typeof object.proposalId === 'string') message.proposalId = parseInt(object.proposalId, 10);
694
+ else if (typeof object.proposalId === 'number') message.proposalId = object.proposalId;
695
+ else if (typeof object.proposalId === 'object')
696
+ message.proposalId = new $util.LongBits(
697
+ object.proposalId.low >>> 0,
698
+ object.proposalId.high >>> 0
699
+ ).toNumber(true);
700
+ if (object.voter != null) message.voter = String(object.voter);
701
+ switch (object.option) {
702
+ default:
703
+ if (typeof object.option === 'number') {
704
+ message.option = object.option;
705
+ break;
706
+ }
707
+ break;
708
+ case 'VOTE_OPTION_UNSPECIFIED':
709
+ case 0:
710
+ message.option = 0;
711
+ break;
712
+ case 'VOTE_OPTION_YES':
713
+ case 1:
714
+ message.option = 1;
715
+ break;
716
+ case 'VOTE_OPTION_ABSTAIN':
717
+ case 2:
718
+ message.option = 2;
719
+ break;
720
+ case 'VOTE_OPTION_NO':
721
+ case 3:
722
+ message.option = 3;
723
+ break;
724
+ case 'VOTE_OPTION_NO_WITH_VETO':
725
+ case 4:
726
+ message.option = 4;
727
+ break;
728
+ }
729
+ if (object.metadata != null) message.metadata = String(object.metadata);
730
+ switch (object.exec) {
731
+ default:
732
+ if (typeof object.exec === 'number') {
733
+ message.exec = object.exec;
734
+ break;
735
+ }
736
+ break;
737
+ case 'EXEC_UNSPECIFIED':
738
+ case 0:
739
+ message.exec = 0;
740
+ break;
741
+ case 'EXEC_TRY':
742
+ case 1:
743
+ message.exec = 1;
744
+ break;
745
+ }
746
+ return message;
747
+ };
748
+
749
+ /**
750
+ * Creates a plain object from a MsgVote message. Also converts values to other types if specified.
751
+ * @function toObject
752
+ * @memberof cosmos.group.v1.MsgVote
753
+ * @static
754
+ * @param {cosmos.group.v1.MsgVote} message MsgVote
755
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
756
+ * @returns {Object.<string,*>} Plain object
757
+ */
758
+ MsgVote.toObject = function toObject(message, options) {
759
+ if (!options) options = {};
760
+ var object = {};
761
+ if (options.defaults) {
762
+ if ($util.Long) {
763
+ var long = new $util.Long(0, 0, true);
764
+ object.proposalId =
765
+ options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
766
+ } else object.proposalId = options.longs === String ? '0' : 0;
767
+ object.voter = '';
768
+ object.option = options.enums === String ? 'VOTE_OPTION_UNSPECIFIED' : 0;
769
+ object.metadata = '';
770
+ object.exec = options.enums === String ? 'EXEC_UNSPECIFIED' : 0;
771
+ }
772
+ if (message.proposalId != null && message.hasOwnProperty('proposalId'))
773
+ if (typeof message.proposalId === 'number')
774
+ object.proposalId = options.longs === String ? String(message.proposalId) : message.proposalId;
775
+ else
776
+ object.proposalId =
777
+ options.longs === String
778
+ ? $util.Long.prototype.toString.call(message.proposalId)
779
+ : options.longs === Number
780
+ ? new $util.LongBits(message.proposalId.low >>> 0, message.proposalId.high >>> 0).toNumber(true)
781
+ : message.proposalId;
782
+ if (message.voter != null && message.hasOwnProperty('voter')) object.voter = message.voter;
783
+ if (message.option != null && message.hasOwnProperty('option'))
784
+ object.option =
785
+ options.enums === String
786
+ ? $root.cosmos.group.v1.VoteOption[message.option] === undefined
787
+ ? message.option
788
+ : $root.cosmos.group.v1.VoteOption[message.option]
789
+ : message.option;
790
+ if (message.metadata != null && message.hasOwnProperty('metadata')) object.metadata = message.metadata;
791
+ if (message.exec != null && message.hasOwnProperty('exec'))
792
+ object.exec =
793
+ options.enums === String
794
+ ? $root.cosmos.group.v1.Exec[message.exec] === undefined
795
+ ? message.exec
796
+ : $root.cosmos.group.v1.Exec[message.exec]
797
+ : message.exec;
798
+ return object;
799
+ };
800
+
801
+ /**
802
+ * Converts this MsgVote to JSON.
803
+ * @function toJSON
804
+ * @memberof cosmos.group.v1.MsgVote
805
+ * @instance
806
+ * @returns {Object.<string,*>} JSON object
807
+ */
808
+ MsgVote.prototype.toJSON = function toJSON() {
809
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
810
+ };
811
+
812
+ /**
813
+ * Gets the default type url for MsgVote
814
+ * @function getTypeUrl
815
+ * @memberof cosmos.group.v1.MsgVote
816
+ * @static
817
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
818
+ * @returns {string} The default type url
819
+ */
820
+ MsgVote.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
821
+ if (typeUrlPrefix === undefined) {
822
+ typeUrlPrefix = 'type.googleapis.com';
823
+ }
824
+ return typeUrlPrefix + '/cosmos.group.v1.MsgVote';
825
+ };
826
+
827
+ return MsgVote;
828
+ })();
829
+
830
+ return v1;
831
+ })();
832
+
833
+ return group;
834
+ })();
835
+
836
+ return cosmos;
837
+ })();
838
+
839
+ $root.google = (function () {
840
+ /**
841
+ * Namespace google.
842
+ * @exports google
843
+ * @namespace
844
+ */
845
+ var google = {};
846
+
847
+ google.protobuf = (function () {
848
+ /**
849
+ * Namespace protobuf.
850
+ * @memberof google
851
+ * @namespace
852
+ */
853
+ var protobuf = {};
854
+
855
+ protobuf.Any = (function () {
856
+ /**
857
+ * Properties of an Any.
858
+ * @memberof google.protobuf
859
+ * @interface IAny
860
+ * @property {string|null} [type_url] Any type_url
861
+ * @property {Uint8Array|null} [value] Any value
862
+ */
863
+
864
+ /**
865
+ * Constructs a new Any.
866
+ * @memberof google.protobuf
867
+ * @classdesc Represents an Any.
868
+ * @implements IAny
869
+ * @constructor
870
+ * @param {google.protobuf.IAny=} [properties] Properties to set
871
+ */
872
+ function Any(properties) {
873
+ if (properties)
874
+ for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
875
+ if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]];
876
+ }
877
+
878
+ /**
879
+ * Any type_url.
880
+ * @member {string} type_url
881
+ * @memberof google.protobuf.Any
882
+ * @instance
883
+ */
884
+ Any.prototype.type_url = '';
885
+
886
+ /**
887
+ * Any value.
888
+ * @member {Uint8Array} value
889
+ * @memberof google.protobuf.Any
890
+ * @instance
891
+ */
892
+ Any.prototype.value = $util.newBuffer([]);
893
+
894
+ /**
895
+ * Creates a new Any instance using the specified properties.
896
+ * @function create
897
+ * @memberof google.protobuf.Any
898
+ * @static
899
+ * @param {google.protobuf.IAny=} [properties] Properties to set
900
+ * @returns {google.protobuf.Any} Any instance
901
+ */
902
+ Any.create = function create(properties) {
903
+ return new Any(properties);
904
+ };
905
+
906
+ /**
907
+ * Encodes the specified Any message. Does not implicitly {@link google.protobuf.Any.verify|verify} messages.
908
+ * @function encode
909
+ * @memberof google.protobuf.Any
910
+ * @static
911
+ * @param {google.protobuf.IAny} message Any message or plain object to encode
912
+ * @param {$protobuf.Writer} [writer] Writer to encode to
913
+ * @returns {$protobuf.Writer} Writer
914
+ */
915
+ Any.encode = function encode(message, writer) {
916
+ if (!writer) writer = $Writer.create();
917
+ if (message.type_url != null && Object.hasOwnProperty.call(message, 'type_url'))
918
+ writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.type_url);
919
+ if (message.value != null && Object.hasOwnProperty.call(message, 'value'))
920
+ writer.uint32(/* id 2, wireType 2 =*/ 18).bytes(message.value);
921
+ return writer;
922
+ };
923
+
924
+ /**
925
+ * Encodes the specified Any message, length delimited. Does not implicitly {@link google.protobuf.Any.verify|verify} messages.
926
+ * @function encodeDelimited
927
+ * @memberof google.protobuf.Any
928
+ * @static
929
+ * @param {google.protobuf.IAny} message Any message or plain object to encode
930
+ * @param {$protobuf.Writer} [writer] Writer to encode to
931
+ * @returns {$protobuf.Writer} Writer
932
+ */
933
+ Any.encodeDelimited = function encodeDelimited(message, writer) {
934
+ return this.encode(message, writer).ldelim();
935
+ };
936
+
937
+ /**
938
+ * Decodes an Any message from the specified reader or buffer.
939
+ * @function decode
940
+ * @memberof google.protobuf.Any
941
+ * @static
942
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
943
+ * @param {number} [length] Message length if known beforehand
944
+ * @returns {google.protobuf.Any} Any
945
+ * @throws {Error} If the payload is not a reader or valid buffer
946
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
947
+ */
948
+ Any.decode = function decode(reader, length, error) {
949
+ if (!(reader instanceof $Reader)) reader = $Reader.create(reader);
950
+ var end = length === undefined ? reader.len : reader.pos + length,
951
+ message = new $root.google.protobuf.Any();
952
+ while (reader.pos < end) {
953
+ var tag = reader.uint32();
954
+ if (tag === error) break;
955
+ switch (tag >>> 3) {
956
+ case 1: {
957
+ message.type_url = reader.string();
958
+ break;
959
+ }
960
+ case 2: {
961
+ message.value = reader.bytes();
962
+ break;
963
+ }
964
+ default:
965
+ reader.skipType(tag & 7);
966
+ break;
967
+ }
968
+ }
969
+ return message;
970
+ };
971
+
972
+ /**
973
+ * Decodes an Any message from the specified reader or buffer, length delimited.
974
+ * @function decodeDelimited
975
+ * @memberof google.protobuf.Any
976
+ * @static
977
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
978
+ * @returns {google.protobuf.Any} Any
979
+ * @throws {Error} If the payload is not a reader or valid buffer
980
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
981
+ */
982
+ Any.decodeDelimited = function decodeDelimited(reader) {
983
+ if (!(reader instanceof $Reader)) reader = new $Reader(reader);
984
+ return this.decode(reader, reader.uint32());
985
+ };
986
+
987
+ /**
988
+ * Verifies an Any message.
989
+ * @function verify
990
+ * @memberof google.protobuf.Any
991
+ * @static
992
+ * @param {Object.<string,*>} message Plain object to verify
993
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
994
+ */
995
+ Any.verify = function verify(message) {
996
+ if (typeof message !== 'object' || message === null) return 'object expected';
997
+ if (message.type_url != null && message.hasOwnProperty('type_url'))
998
+ if (!$util.isString(message.type_url)) return 'type_url: string expected';
999
+ if (message.value != null && message.hasOwnProperty('value'))
1000
+ if (!((message.value && typeof message.value.length === 'number') || $util.isString(message.value)))
1001
+ return 'value: buffer expected';
1002
+ return null;
1003
+ };
1004
+
1005
+ /**
1006
+ * Creates an Any message from a plain object. Also converts values to their respective internal types.
1007
+ * @function fromObject
1008
+ * @memberof google.protobuf.Any
1009
+ * @static
1010
+ * @param {Object.<string,*>} object Plain object
1011
+ * @returns {google.protobuf.Any} Any
1012
+ */
1013
+ Any.fromObject = function fromObject(object) {
1014
+ if (object instanceof $root.google.protobuf.Any) return object;
1015
+ var message = new $root.google.protobuf.Any();
1016
+ if (object.type_url != null) message.type_url = String(object.type_url);
1017
+ if (object.value != null)
1018
+ if (typeof object.value === 'string')
1019
+ $util.base64.decode(object.value, (message.value = $util.newBuffer($util.base64.length(object.value))), 0);
1020
+ else if (object.value.length >= 0) message.value = object.value;
1021
+ return message;
1022
+ };
1023
+
1024
+ /**
1025
+ * Creates a plain object from an Any message. Also converts values to other types if specified.
1026
+ * @function toObject
1027
+ * @memberof google.protobuf.Any
1028
+ * @static
1029
+ * @param {google.protobuf.Any} message Any
1030
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
1031
+ * @returns {Object.<string,*>} Plain object
1032
+ */
1033
+ Any.toObject = function toObject(message, options) {
1034
+ if (!options) options = {};
1035
+ var object = {};
1036
+ if (options.defaults) {
1037
+ object.type_url = '';
1038
+ if (options.bytes === String) object.value = '';
1039
+ else {
1040
+ object.value = [];
1041
+ if (options.bytes !== Array) object.value = $util.newBuffer(object.value);
1042
+ }
1043
+ }
1044
+ if (message.type_url != null && message.hasOwnProperty('type_url')) object.type_url = message.type_url;
1045
+ if (message.value != null && message.hasOwnProperty('value'))
1046
+ object.value =
1047
+ options.bytes === String
1048
+ ? $util.base64.encode(message.value, 0, message.value.length)
1049
+ : options.bytes === Array
1050
+ ? Array.prototype.slice.call(message.value)
1051
+ : message.value;
1052
+ return object;
1053
+ };
1054
+
1055
+ /**
1056
+ * Converts this Any to JSON.
1057
+ * @function toJSON
1058
+ * @memberof google.protobuf.Any
1059
+ * @instance
1060
+ * @returns {Object.<string,*>} JSON object
1061
+ */
1062
+ Any.prototype.toJSON = function toJSON() {
1063
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
1064
+ };
1065
+
1066
+ /**
1067
+ * Gets the default type url for Any
1068
+ * @function getTypeUrl
1069
+ * @memberof google.protobuf.Any
1070
+ * @static
1071
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
1072
+ * @returns {string} The default type url
1073
+ */
1074
+ Any.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
1075
+ if (typeUrlPrefix === undefined) {
1076
+ typeUrlPrefix = 'type.googleapis.com';
1077
+ }
1078
+ return typeUrlPrefix + '/google.protobuf.Any';
1079
+ };
1080
+
1081
+ return Any;
1082
+ })();
1083
+
1084
+ return protobuf;
1085
+ })();
1086
+
1087
+ return google;
1088
+ })();
1089
+
1090
+ module.exports = $root;