@ottochain/sdk 1.7.0-beta.1 → 1.7.0-beta.2

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.
Files changed (42) hide show
  1. package/dist/cjs/apps/identity/constants.js +28 -14
  2. package/dist/cjs/apps/identity/index.js +40 -17
  3. package/dist/cjs/generated/google/protobuf/struct.js +1 -1
  4. package/dist/cjs/generated/google/protobuf/timestamp.js +1 -1
  5. package/dist/cjs/generated/index.js +19 -22
  6. package/dist/cjs/generated/ottochain/apps/contracts/v1/contract.js +1 -1
  7. package/dist/cjs/generated/ottochain/apps/corporate/v1/corporate.js +1 -1
  8. package/dist/cjs/generated/ottochain/apps/governance/v1/governance.js +1 -1
  9. package/dist/cjs/generated/ottochain/apps/identity/v1/attestation.js +12 -12
  10. package/dist/cjs/generated/ottochain/apps/identity/v1/identity.js +1689 -0
  11. package/dist/cjs/generated/ottochain/apps/markets/v1/market.js +1 -1
  12. package/dist/cjs/generated/ottochain/v1/common.js +1 -1
  13. package/dist/cjs/generated/ottochain/v1/fiber.js +1 -1
  14. package/dist/cjs/generated/ottochain/v1/messages.js +1 -1
  15. package/dist/cjs/generated/ottochain/v1/records.js +1 -1
  16. package/dist/esm/apps/identity/constants.js +27 -13
  17. package/dist/esm/apps/identity/index.js +19 -8
  18. package/dist/esm/generated/google/protobuf/struct.js +1 -1
  19. package/dist/esm/generated/google/protobuf/timestamp.js +1 -1
  20. package/dist/esm/generated/index.js +2 -3
  21. package/dist/esm/generated/ottochain/apps/contracts/v1/contract.js +1 -1
  22. package/dist/esm/generated/ottochain/apps/corporate/v1/corporate.js +1 -1
  23. package/dist/esm/generated/ottochain/apps/governance/v1/governance.js +1 -1
  24. package/dist/esm/generated/ottochain/apps/identity/v1/attestation.js +2 -2
  25. package/dist/esm/generated/ottochain/apps/identity/v1/identity.js +1677 -0
  26. package/dist/esm/generated/ottochain/apps/markets/v1/market.js +1 -1
  27. package/dist/esm/generated/ottochain/v1/common.js +1 -1
  28. package/dist/esm/generated/ottochain/v1/fiber.js +1 -1
  29. package/dist/esm/generated/ottochain/v1/messages.js +1 -1
  30. package/dist/esm/generated/ottochain/v1/records.js +1 -1
  31. package/dist/types/apps/identity/constants.d.ts +10 -5
  32. package/dist/types/apps/identity/index.d.ts +21 -10
  33. package/dist/types/generated/index.d.ts +1 -2
  34. package/dist/types/generated/ottochain/apps/identity/v1/attestation.d.ts +1 -1
  35. package/dist/types/generated/ottochain/apps/identity/v1/identity.d.ts +208 -0
  36. package/package.json +1 -1
  37. package/dist/cjs/generated/ottochain/apps/identity/v1/agent.js +0 -619
  38. package/dist/cjs/generated/ottochain/apps/oracles/v1/oracle.js +0 -1223
  39. package/dist/esm/generated/ottochain/apps/identity/v1/agent.js +0 -610
  40. package/dist/esm/generated/ottochain/apps/oracles/v1/oracle.js +0 -1217
  41. package/dist/types/generated/ottochain/apps/identity/v1/agent.d.ts +0 -94
  42. package/dist/types/generated/ottochain/apps/oracles/v1/oracle.d.ts +0 -150
@@ -1,619 +0,0 @@
1
- "use strict";
2
- // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
3
- // versions:
4
- // protoc-gen-ts_proto v2.11.2
5
- // protoc unknown
6
- // source: ottochain/apps/identity/v1/agent.proto
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.AgentIdentityDefinition = exports.AgentIdentity = exports.PlatformLink = exports.platformToNumber = exports.platformToJSON = exports.platformFromJSON = exports.Platform = exports.agentStateToNumber = exports.agentStateToJSON = exports.agentStateFromJSON = exports.AgentState = exports.protobufPackage = void 0;
9
- /* eslint-disable */
10
- const wire_1 = require("@bufbuild/protobuf/wire");
11
- const timestamp_js_1 = require("../../../../google/protobuf/timestamp.js");
12
- exports.protobufPackage = "ottochain.apps.identity.v1";
13
- /** Agent lifecycle states in the identity state machine */
14
- var AgentState;
15
- (function (AgentState) {
16
- AgentState["AGENT_STATE_UNSPECIFIED"] = "AGENT_STATE_UNSPECIFIED";
17
- /** AGENT_STATE_REGISTERED - Initial state after registration */
18
- AgentState["AGENT_STATE_REGISTERED"] = "AGENT_STATE_REGISTERED";
19
- /** AGENT_STATE_ACTIVE - Activated and participating */
20
- AgentState["AGENT_STATE_ACTIVE"] = "AGENT_STATE_ACTIVE";
21
- /** AGENT_STATE_CHALLENGED - Under dispute/challenge */
22
- AgentState["AGENT_STATE_CHALLENGED"] = "AGENT_STATE_CHALLENGED";
23
- /** AGENT_STATE_SUSPENDED - Challenge upheld, temporarily suspended */
24
- AgentState["AGENT_STATE_SUSPENDED"] = "AGENT_STATE_SUSPENDED";
25
- /** AGENT_STATE_PROBATION - Recovering from suspension */
26
- AgentState["AGENT_STATE_PROBATION"] = "AGENT_STATE_PROBATION";
27
- /** AGENT_STATE_WITHDRAWN - Voluntarily exited (terminal) */
28
- AgentState["AGENT_STATE_WITHDRAWN"] = "AGENT_STATE_WITHDRAWN";
29
- AgentState["UNRECOGNIZED"] = "UNRECOGNIZED";
30
- })(AgentState || (exports.AgentState = AgentState = {}));
31
- function agentStateFromJSON(object) {
32
- switch (object) {
33
- case 0:
34
- case "AGENT_STATE_UNSPECIFIED":
35
- return AgentState.AGENT_STATE_UNSPECIFIED;
36
- case 1:
37
- case "AGENT_STATE_REGISTERED":
38
- return AgentState.AGENT_STATE_REGISTERED;
39
- case 2:
40
- case "AGENT_STATE_ACTIVE":
41
- return AgentState.AGENT_STATE_ACTIVE;
42
- case 3:
43
- case "AGENT_STATE_CHALLENGED":
44
- return AgentState.AGENT_STATE_CHALLENGED;
45
- case 4:
46
- case "AGENT_STATE_SUSPENDED":
47
- return AgentState.AGENT_STATE_SUSPENDED;
48
- case 5:
49
- case "AGENT_STATE_PROBATION":
50
- return AgentState.AGENT_STATE_PROBATION;
51
- case 6:
52
- case "AGENT_STATE_WITHDRAWN":
53
- return AgentState.AGENT_STATE_WITHDRAWN;
54
- case -1:
55
- case "UNRECOGNIZED":
56
- default:
57
- return AgentState.UNRECOGNIZED;
58
- }
59
- }
60
- exports.agentStateFromJSON = agentStateFromJSON;
61
- function agentStateToJSON(object) {
62
- switch (object) {
63
- case AgentState.AGENT_STATE_UNSPECIFIED:
64
- return "AGENT_STATE_UNSPECIFIED";
65
- case AgentState.AGENT_STATE_REGISTERED:
66
- return "AGENT_STATE_REGISTERED";
67
- case AgentState.AGENT_STATE_ACTIVE:
68
- return "AGENT_STATE_ACTIVE";
69
- case AgentState.AGENT_STATE_CHALLENGED:
70
- return "AGENT_STATE_CHALLENGED";
71
- case AgentState.AGENT_STATE_SUSPENDED:
72
- return "AGENT_STATE_SUSPENDED";
73
- case AgentState.AGENT_STATE_PROBATION:
74
- return "AGENT_STATE_PROBATION";
75
- case AgentState.AGENT_STATE_WITHDRAWN:
76
- return "AGENT_STATE_WITHDRAWN";
77
- case AgentState.UNRECOGNIZED:
78
- default:
79
- return "UNRECOGNIZED";
80
- }
81
- }
82
- exports.agentStateToJSON = agentStateToJSON;
83
- function agentStateToNumber(object) {
84
- switch (object) {
85
- case AgentState.AGENT_STATE_UNSPECIFIED:
86
- return 0;
87
- case AgentState.AGENT_STATE_REGISTERED:
88
- return 1;
89
- case AgentState.AGENT_STATE_ACTIVE:
90
- return 2;
91
- case AgentState.AGENT_STATE_CHALLENGED:
92
- return 3;
93
- case AgentState.AGENT_STATE_SUSPENDED:
94
- return 4;
95
- case AgentState.AGENT_STATE_PROBATION:
96
- return 5;
97
- case AgentState.AGENT_STATE_WITHDRAWN:
98
- return 6;
99
- case AgentState.UNRECOGNIZED:
100
- default:
101
- return -1;
102
- }
103
- }
104
- exports.agentStateToNumber = agentStateToNumber;
105
- /** Platform where agent identity is linked */
106
- var Platform;
107
- (function (Platform) {
108
- Platform["PLATFORM_UNSPECIFIED"] = "PLATFORM_UNSPECIFIED";
109
- Platform["PLATFORM_DISCORD"] = "PLATFORM_DISCORD";
110
- Platform["PLATFORM_TELEGRAM"] = "PLATFORM_TELEGRAM";
111
- Platform["PLATFORM_TWITTER"] = "PLATFORM_TWITTER";
112
- Platform["PLATFORM_GITHUB"] = "PLATFORM_GITHUB";
113
- Platform["PLATFORM_CUSTOM"] = "PLATFORM_CUSTOM";
114
- Platform["UNRECOGNIZED"] = "UNRECOGNIZED";
115
- })(Platform || (exports.Platform = Platform = {}));
116
- function platformFromJSON(object) {
117
- switch (object) {
118
- case 0:
119
- case "PLATFORM_UNSPECIFIED":
120
- return Platform.PLATFORM_UNSPECIFIED;
121
- case 1:
122
- case "PLATFORM_DISCORD":
123
- return Platform.PLATFORM_DISCORD;
124
- case 2:
125
- case "PLATFORM_TELEGRAM":
126
- return Platform.PLATFORM_TELEGRAM;
127
- case 3:
128
- case "PLATFORM_TWITTER":
129
- return Platform.PLATFORM_TWITTER;
130
- case 4:
131
- case "PLATFORM_GITHUB":
132
- return Platform.PLATFORM_GITHUB;
133
- case 5:
134
- case "PLATFORM_CUSTOM":
135
- return Platform.PLATFORM_CUSTOM;
136
- case -1:
137
- case "UNRECOGNIZED":
138
- default:
139
- return Platform.UNRECOGNIZED;
140
- }
141
- }
142
- exports.platformFromJSON = platformFromJSON;
143
- function platformToJSON(object) {
144
- switch (object) {
145
- case Platform.PLATFORM_UNSPECIFIED:
146
- return "PLATFORM_UNSPECIFIED";
147
- case Platform.PLATFORM_DISCORD:
148
- return "PLATFORM_DISCORD";
149
- case Platform.PLATFORM_TELEGRAM:
150
- return "PLATFORM_TELEGRAM";
151
- case Platform.PLATFORM_TWITTER:
152
- return "PLATFORM_TWITTER";
153
- case Platform.PLATFORM_GITHUB:
154
- return "PLATFORM_GITHUB";
155
- case Platform.PLATFORM_CUSTOM:
156
- return "PLATFORM_CUSTOM";
157
- case Platform.UNRECOGNIZED:
158
- default:
159
- return "UNRECOGNIZED";
160
- }
161
- }
162
- exports.platformToJSON = platformToJSON;
163
- function platformToNumber(object) {
164
- switch (object) {
165
- case Platform.PLATFORM_UNSPECIFIED:
166
- return 0;
167
- case Platform.PLATFORM_DISCORD:
168
- return 1;
169
- case Platform.PLATFORM_TELEGRAM:
170
- return 2;
171
- case Platform.PLATFORM_TWITTER:
172
- return 3;
173
- case Platform.PLATFORM_GITHUB:
174
- return 4;
175
- case Platform.PLATFORM_CUSTOM:
176
- return 5;
177
- case Platform.UNRECOGNIZED:
178
- default:
179
- return -1;
180
- }
181
- }
182
- exports.platformToNumber = platformToNumber;
183
- function createBasePlatformLink() {
184
- return {
185
- platform: Platform.PLATFORM_UNSPECIFIED,
186
- platformUserId: "",
187
- platformUsername: "",
188
- linkedAt: undefined,
189
- verified: false,
190
- };
191
- }
192
- exports.PlatformLink = {
193
- encode(message, writer = new wire_1.BinaryWriter()) {
194
- if (message.platform !== Platform.PLATFORM_UNSPECIFIED) {
195
- writer.uint32(8).int32(platformToNumber(message.platform));
196
- }
197
- if (message.platformUserId !== "") {
198
- writer.uint32(18).string(message.platformUserId);
199
- }
200
- if (message.platformUsername !== "") {
201
- writer.uint32(26).string(message.platformUsername);
202
- }
203
- if (message.linkedAt !== undefined) {
204
- timestamp_js_1.Timestamp.encode(toTimestamp(message.linkedAt), writer.uint32(34).fork()).join();
205
- }
206
- if (message.verified !== false) {
207
- writer.uint32(40).bool(message.verified);
208
- }
209
- return writer;
210
- },
211
- decode(input, length) {
212
- const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
213
- const end = length === undefined ? reader.len : reader.pos + length;
214
- const message = createBasePlatformLink();
215
- while (reader.pos < end) {
216
- const tag = reader.uint32();
217
- switch (tag >>> 3) {
218
- case 1: {
219
- if (tag !== 8) {
220
- break;
221
- }
222
- message.platform = platformFromJSON(reader.int32());
223
- continue;
224
- }
225
- case 2: {
226
- if (tag !== 18) {
227
- break;
228
- }
229
- message.platformUserId = reader.string();
230
- continue;
231
- }
232
- case 3: {
233
- if (tag !== 26) {
234
- break;
235
- }
236
- message.platformUsername = reader.string();
237
- continue;
238
- }
239
- case 4: {
240
- if (tag !== 34) {
241
- break;
242
- }
243
- message.linkedAt = fromTimestamp(timestamp_js_1.Timestamp.decode(reader, reader.uint32()));
244
- continue;
245
- }
246
- case 5: {
247
- if (tag !== 40) {
248
- break;
249
- }
250
- message.verified = reader.bool();
251
- continue;
252
- }
253
- }
254
- if ((tag & 7) === 4 || tag === 0) {
255
- break;
256
- }
257
- reader.skip(tag & 7);
258
- }
259
- return message;
260
- },
261
- fromJSON(object) {
262
- return {
263
- platform: isSet(object.platform) ? platformFromJSON(object.platform) : Platform.PLATFORM_UNSPECIFIED,
264
- platformUserId: isSet(object.platformUserId)
265
- ? globalThis.String(object.platformUserId)
266
- : isSet(object.platform_user_id)
267
- ? globalThis.String(object.platform_user_id)
268
- : "",
269
- platformUsername: isSet(object.platformUsername)
270
- ? globalThis.String(object.platformUsername)
271
- : isSet(object.platform_username)
272
- ? globalThis.String(object.platform_username)
273
- : "",
274
- linkedAt: isSet(object.linkedAt)
275
- ? fromJsonTimestamp(object.linkedAt)
276
- : isSet(object.linked_at)
277
- ? fromJsonTimestamp(object.linked_at)
278
- : undefined,
279
- verified: isSet(object.verified) ? globalThis.Boolean(object.verified) : false,
280
- };
281
- },
282
- toJSON(message) {
283
- const obj = {};
284
- if (message.platform !== Platform.PLATFORM_UNSPECIFIED) {
285
- obj.platform = platformToJSON(message.platform);
286
- }
287
- if (message.platformUserId !== "") {
288
- obj.platformUserId = message.platformUserId;
289
- }
290
- if (message.platformUsername !== "") {
291
- obj.platformUsername = message.platformUsername;
292
- }
293
- if (message.linkedAt !== undefined) {
294
- obj.linkedAt = message.linkedAt.toISOString();
295
- }
296
- if (message.verified !== false) {
297
- obj.verified = message.verified;
298
- }
299
- return obj;
300
- },
301
- create(base) {
302
- return exports.PlatformLink.fromPartial(base ?? {});
303
- },
304
- fromPartial(object) {
305
- const message = createBasePlatformLink();
306
- message.platform = object.platform ?? Platform.PLATFORM_UNSPECIFIED;
307
- message.platformUserId = object.platformUserId ?? "";
308
- message.platformUsername = object.platformUsername ?? "";
309
- message.linkedAt = object.linkedAt ?? undefined;
310
- message.verified = object.verified ?? false;
311
- return message;
312
- },
313
- };
314
- function createBaseAgentIdentity() {
315
- return {
316
- address: "",
317
- publicKey: "",
318
- displayName: "",
319
- reputation: 0,
320
- state: AgentState.AGENT_STATE_UNSPECIFIED,
321
- platformLinks: [],
322
- createdAt: undefined,
323
- updatedAt: undefined,
324
- };
325
- }
326
- exports.AgentIdentity = {
327
- encode(message, writer = new wire_1.BinaryWriter()) {
328
- if (message.address !== "") {
329
- writer.uint32(10).string(message.address);
330
- }
331
- if (message.publicKey !== "") {
332
- writer.uint32(18).string(message.publicKey);
333
- }
334
- if (message.displayName !== "") {
335
- writer.uint32(26).string(message.displayName);
336
- }
337
- if (message.reputation !== 0) {
338
- writer.uint32(32).int32(message.reputation);
339
- }
340
- if (message.state !== AgentState.AGENT_STATE_UNSPECIFIED) {
341
- writer.uint32(40).int32(agentStateToNumber(message.state));
342
- }
343
- for (const v of message.platformLinks) {
344
- exports.PlatformLink.encode(v, writer.uint32(50).fork()).join();
345
- }
346
- if (message.createdAt !== undefined) {
347
- timestamp_js_1.Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(58).fork()).join();
348
- }
349
- if (message.updatedAt !== undefined) {
350
- timestamp_js_1.Timestamp.encode(toTimestamp(message.updatedAt), writer.uint32(66).fork()).join();
351
- }
352
- return writer;
353
- },
354
- decode(input, length) {
355
- const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
356
- const end = length === undefined ? reader.len : reader.pos + length;
357
- const message = createBaseAgentIdentity();
358
- while (reader.pos < end) {
359
- const tag = reader.uint32();
360
- switch (tag >>> 3) {
361
- case 1: {
362
- if (tag !== 10) {
363
- break;
364
- }
365
- message.address = reader.string();
366
- continue;
367
- }
368
- case 2: {
369
- if (tag !== 18) {
370
- break;
371
- }
372
- message.publicKey = reader.string();
373
- continue;
374
- }
375
- case 3: {
376
- if (tag !== 26) {
377
- break;
378
- }
379
- message.displayName = reader.string();
380
- continue;
381
- }
382
- case 4: {
383
- if (tag !== 32) {
384
- break;
385
- }
386
- message.reputation = reader.int32();
387
- continue;
388
- }
389
- case 5: {
390
- if (tag !== 40) {
391
- break;
392
- }
393
- message.state = agentStateFromJSON(reader.int32());
394
- continue;
395
- }
396
- case 6: {
397
- if (tag !== 50) {
398
- break;
399
- }
400
- message.platformLinks.push(exports.PlatformLink.decode(reader, reader.uint32()));
401
- continue;
402
- }
403
- case 7: {
404
- if (tag !== 58) {
405
- break;
406
- }
407
- message.createdAt = fromTimestamp(timestamp_js_1.Timestamp.decode(reader, reader.uint32()));
408
- continue;
409
- }
410
- case 8: {
411
- if (tag !== 66) {
412
- break;
413
- }
414
- message.updatedAt = fromTimestamp(timestamp_js_1.Timestamp.decode(reader, reader.uint32()));
415
- continue;
416
- }
417
- }
418
- if ((tag & 7) === 4 || tag === 0) {
419
- break;
420
- }
421
- reader.skip(tag & 7);
422
- }
423
- return message;
424
- },
425
- fromJSON(object) {
426
- return {
427
- address: isSet(object.address) ? globalThis.String(object.address) : "",
428
- publicKey: isSet(object.publicKey)
429
- ? globalThis.String(object.publicKey)
430
- : isSet(object.public_key)
431
- ? globalThis.String(object.public_key)
432
- : "",
433
- displayName: isSet(object.displayName)
434
- ? globalThis.String(object.displayName)
435
- : isSet(object.display_name)
436
- ? globalThis.String(object.display_name)
437
- : "",
438
- reputation: isSet(object.reputation) ? globalThis.Number(object.reputation) : 0,
439
- state: isSet(object.state) ? agentStateFromJSON(object.state) : AgentState.AGENT_STATE_UNSPECIFIED,
440
- platformLinks: globalThis.Array.isArray(object?.platformLinks)
441
- ? object.platformLinks.map((e) => exports.PlatformLink.fromJSON(e))
442
- : globalThis.Array.isArray(object?.platform_links)
443
- ? object.platform_links.map((e) => exports.PlatformLink.fromJSON(e))
444
- : [],
445
- createdAt: isSet(object.createdAt)
446
- ? fromJsonTimestamp(object.createdAt)
447
- : isSet(object.created_at)
448
- ? fromJsonTimestamp(object.created_at)
449
- : undefined,
450
- updatedAt: isSet(object.updatedAt)
451
- ? fromJsonTimestamp(object.updatedAt)
452
- : isSet(object.updated_at)
453
- ? fromJsonTimestamp(object.updated_at)
454
- : undefined,
455
- };
456
- },
457
- toJSON(message) {
458
- const obj = {};
459
- if (message.address !== "") {
460
- obj.address = message.address;
461
- }
462
- if (message.publicKey !== "") {
463
- obj.publicKey = message.publicKey;
464
- }
465
- if (message.displayName !== "") {
466
- obj.displayName = message.displayName;
467
- }
468
- if (message.reputation !== 0) {
469
- obj.reputation = Math.round(message.reputation);
470
- }
471
- if (message.state !== AgentState.AGENT_STATE_UNSPECIFIED) {
472
- obj.state = agentStateToJSON(message.state);
473
- }
474
- if (message.platformLinks?.length) {
475
- obj.platformLinks = message.platformLinks.map((e) => exports.PlatformLink.toJSON(e));
476
- }
477
- if (message.createdAt !== undefined) {
478
- obj.createdAt = message.createdAt.toISOString();
479
- }
480
- if (message.updatedAt !== undefined) {
481
- obj.updatedAt = message.updatedAt.toISOString();
482
- }
483
- return obj;
484
- },
485
- create(base) {
486
- return exports.AgentIdentity.fromPartial(base ?? {});
487
- },
488
- fromPartial(object) {
489
- const message = createBaseAgentIdentity();
490
- message.address = object.address ?? "";
491
- message.publicKey = object.publicKey ?? "";
492
- message.displayName = object.displayName ?? "";
493
- message.reputation = object.reputation ?? 0;
494
- message.state = object.state ?? AgentState.AGENT_STATE_UNSPECIFIED;
495
- message.platformLinks = object.platformLinks?.map((e) => exports.PlatformLink.fromPartial(e)) || [];
496
- message.createdAt = object.createdAt ?? undefined;
497
- message.updatedAt = object.updatedAt ?? undefined;
498
- return message;
499
- },
500
- };
501
- function createBaseAgentIdentityDefinition() {
502
- return { initialReputation: 0, activationThreshold: 0, suspensionDurationEpochs: 0 };
503
- }
504
- exports.AgentIdentityDefinition = {
505
- encode(message, writer = new wire_1.BinaryWriter()) {
506
- if (message.initialReputation !== 0) {
507
- writer.uint32(8).int32(message.initialReputation);
508
- }
509
- if (message.activationThreshold !== 0) {
510
- writer.uint32(16).int32(message.activationThreshold);
511
- }
512
- if (message.suspensionDurationEpochs !== 0) {
513
- writer.uint32(24).int32(message.suspensionDurationEpochs);
514
- }
515
- return writer;
516
- },
517
- decode(input, length) {
518
- const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
519
- const end = length === undefined ? reader.len : reader.pos + length;
520
- const message = createBaseAgentIdentityDefinition();
521
- while (reader.pos < end) {
522
- const tag = reader.uint32();
523
- switch (tag >>> 3) {
524
- case 1: {
525
- if (tag !== 8) {
526
- break;
527
- }
528
- message.initialReputation = reader.int32();
529
- continue;
530
- }
531
- case 2: {
532
- if (tag !== 16) {
533
- break;
534
- }
535
- message.activationThreshold = reader.int32();
536
- continue;
537
- }
538
- case 3: {
539
- if (tag !== 24) {
540
- break;
541
- }
542
- message.suspensionDurationEpochs = reader.int32();
543
- continue;
544
- }
545
- }
546
- if ((tag & 7) === 4 || tag === 0) {
547
- break;
548
- }
549
- reader.skip(tag & 7);
550
- }
551
- return message;
552
- },
553
- fromJSON(object) {
554
- return {
555
- initialReputation: isSet(object.initialReputation)
556
- ? globalThis.Number(object.initialReputation)
557
- : isSet(object.initial_reputation)
558
- ? globalThis.Number(object.initial_reputation)
559
- : 0,
560
- activationThreshold: isSet(object.activationThreshold)
561
- ? globalThis.Number(object.activationThreshold)
562
- : isSet(object.activation_threshold)
563
- ? globalThis.Number(object.activation_threshold)
564
- : 0,
565
- suspensionDurationEpochs: isSet(object.suspensionDurationEpochs)
566
- ? globalThis.Number(object.suspensionDurationEpochs)
567
- : isSet(object.suspension_duration_epochs)
568
- ? globalThis.Number(object.suspension_duration_epochs)
569
- : 0,
570
- };
571
- },
572
- toJSON(message) {
573
- const obj = {};
574
- if (message.initialReputation !== 0) {
575
- obj.initialReputation = Math.round(message.initialReputation);
576
- }
577
- if (message.activationThreshold !== 0) {
578
- obj.activationThreshold = Math.round(message.activationThreshold);
579
- }
580
- if (message.suspensionDurationEpochs !== 0) {
581
- obj.suspensionDurationEpochs = Math.round(message.suspensionDurationEpochs);
582
- }
583
- return obj;
584
- },
585
- create(base) {
586
- return exports.AgentIdentityDefinition.fromPartial(base ?? {});
587
- },
588
- fromPartial(object) {
589
- const message = createBaseAgentIdentityDefinition();
590
- message.initialReputation = object.initialReputation ?? 0;
591
- message.activationThreshold = object.activationThreshold ?? 0;
592
- message.suspensionDurationEpochs = object.suspensionDurationEpochs ?? 0;
593
- return message;
594
- },
595
- };
596
- function toTimestamp(date) {
597
- const seconds = Math.trunc(date.getTime() / 1000);
598
- const nanos = (date.getTime() % 1000) * 1000000;
599
- return { seconds, nanos };
600
- }
601
- function fromTimestamp(t) {
602
- let millis = (t.seconds || 0) * 1000;
603
- millis += (t.nanos || 0) / 1000000;
604
- return new globalThis.Date(millis);
605
- }
606
- function fromJsonTimestamp(o) {
607
- if (o instanceof globalThis.Date) {
608
- return o;
609
- }
610
- else if (typeof o === "string") {
611
- return new globalThis.Date(o);
612
- }
613
- else {
614
- return fromTimestamp(timestamp_js_1.Timestamp.fromJSON(o));
615
- }
616
- }
617
- function isSet(value) {
618
- return value !== null && value !== undefined;
619
- }