@libp2p/peer-store 1.0.6 → 1.0.9
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.
- package/dist/src/pb/peer.d.ts +25 -216
- package/dist/src/pb/peer.d.ts.map +1 -0
- package/dist/src/pb/peer.js +52 -641
- package/dist/src/pb/peer.js.map +1 -0
- package/dist/src/store.d.ts.map +1 -1
- package/dist/src/store.js +16 -7
- package/dist/src/store.js.map +1 -1
- package/package.json +15 -17
- package/src/address-book.ts +3 -3
- package/src/pb/peer.ts +76 -0
- package/src/store.ts +20 -8
- package/src/pb/peer.d.ts +0 -222
- package/src/pb/peer.js +0 -641
package/src/pb/peer.js
DELETED
|
@@ -1,641 +0,0 @@
|
|
|
1
|
-
/*eslint-disable*/
|
|
2
|
-
import $protobuf from "protobufjs/minimal.js";
|
|
3
|
-
|
|
4
|
-
// Common aliases
|
|
5
|
-
const $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;
|
|
6
|
-
|
|
7
|
-
// Exported root namespace
|
|
8
|
-
const $root = $protobuf.roots["libp2p-peer-store"] || ($protobuf.roots["libp2p-peer-store"] = {});
|
|
9
|
-
|
|
10
|
-
export const Peer = $root.Peer = (() => {
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Properties of a Peer.
|
|
14
|
-
* @exports IPeer
|
|
15
|
-
* @interface IPeer
|
|
16
|
-
* @property {Array.<IAddress>|null} [addresses] Peer addresses
|
|
17
|
-
* @property {Array.<string>|null} [protocols] Peer protocols
|
|
18
|
-
* @property {Array.<IMetadata>|null} [metadata] Peer metadata
|
|
19
|
-
* @property {Uint8Array|null} [pubKey] Peer pubKey
|
|
20
|
-
* @property {Uint8Array|null} [peerRecordEnvelope] Peer peerRecordEnvelope
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Constructs a new Peer.
|
|
25
|
-
* @exports Peer
|
|
26
|
-
* @classdesc Represents a Peer.
|
|
27
|
-
* @implements IPeer
|
|
28
|
-
* @constructor
|
|
29
|
-
* @param {IPeer=} [p] Properties to set
|
|
30
|
-
*/
|
|
31
|
-
function Peer(p) {
|
|
32
|
-
this.addresses = [];
|
|
33
|
-
this.protocols = [];
|
|
34
|
-
this.metadata = [];
|
|
35
|
-
if (p)
|
|
36
|
-
for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
|
|
37
|
-
if (p[ks[i]] != null)
|
|
38
|
-
this[ks[i]] = p[ks[i]];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Peer addresses.
|
|
43
|
-
* @member {Array.<IAddress>} addresses
|
|
44
|
-
* @memberof Peer
|
|
45
|
-
* @instance
|
|
46
|
-
*/
|
|
47
|
-
Peer.prototype.addresses = $util.emptyArray;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Peer protocols.
|
|
51
|
-
* @member {Array.<string>} protocols
|
|
52
|
-
* @memberof Peer
|
|
53
|
-
* @instance
|
|
54
|
-
*/
|
|
55
|
-
Peer.prototype.protocols = $util.emptyArray;
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Peer metadata.
|
|
59
|
-
* @member {Array.<IMetadata>} metadata
|
|
60
|
-
* @memberof Peer
|
|
61
|
-
* @instance
|
|
62
|
-
*/
|
|
63
|
-
Peer.prototype.metadata = $util.emptyArray;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Peer pubKey.
|
|
67
|
-
* @member {Uint8Array|null|undefined} pubKey
|
|
68
|
-
* @memberof Peer
|
|
69
|
-
* @instance
|
|
70
|
-
*/
|
|
71
|
-
Peer.prototype.pubKey = null;
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Peer peerRecordEnvelope.
|
|
75
|
-
* @member {Uint8Array|null|undefined} peerRecordEnvelope
|
|
76
|
-
* @memberof Peer
|
|
77
|
-
* @instance
|
|
78
|
-
*/
|
|
79
|
-
Peer.prototype.peerRecordEnvelope = null;
|
|
80
|
-
|
|
81
|
-
// OneOf field names bound to virtual getters and setters
|
|
82
|
-
let $oneOfFields;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Peer _pubKey.
|
|
86
|
-
* @member {"pubKey"|undefined} _pubKey
|
|
87
|
-
* @memberof Peer
|
|
88
|
-
* @instance
|
|
89
|
-
*/
|
|
90
|
-
Object.defineProperty(Peer.prototype, "_pubKey", {
|
|
91
|
-
get: $util.oneOfGetter($oneOfFields = ["pubKey"]),
|
|
92
|
-
set: $util.oneOfSetter($oneOfFields)
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Peer _peerRecordEnvelope.
|
|
97
|
-
* @member {"peerRecordEnvelope"|undefined} _peerRecordEnvelope
|
|
98
|
-
* @memberof Peer
|
|
99
|
-
* @instance
|
|
100
|
-
*/
|
|
101
|
-
Object.defineProperty(Peer.prototype, "_peerRecordEnvelope", {
|
|
102
|
-
get: $util.oneOfGetter($oneOfFields = ["peerRecordEnvelope"]),
|
|
103
|
-
set: $util.oneOfSetter($oneOfFields)
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Encodes the specified Peer message. Does not implicitly {@link Peer.verify|verify} messages.
|
|
108
|
-
* @function encode
|
|
109
|
-
* @memberof Peer
|
|
110
|
-
* @static
|
|
111
|
-
* @param {IPeer} m Peer message or plain object to encode
|
|
112
|
-
* @param {$protobuf.Writer} [w] Writer to encode to
|
|
113
|
-
* @returns {$protobuf.Writer} Writer
|
|
114
|
-
*/
|
|
115
|
-
Peer.encode = function encode(m, w) {
|
|
116
|
-
if (!w)
|
|
117
|
-
w = $Writer.create();
|
|
118
|
-
if (m.addresses != null && m.addresses.length) {
|
|
119
|
-
for (var i = 0; i < m.addresses.length; ++i)
|
|
120
|
-
$root.Address.encode(m.addresses[i], w.uint32(10).fork()).ldelim();
|
|
121
|
-
}
|
|
122
|
-
if (m.protocols != null && m.protocols.length) {
|
|
123
|
-
for (var i = 0; i < m.protocols.length; ++i)
|
|
124
|
-
w.uint32(18).string(m.protocols[i]);
|
|
125
|
-
}
|
|
126
|
-
if (m.metadata != null && m.metadata.length) {
|
|
127
|
-
for (var i = 0; i < m.metadata.length; ++i)
|
|
128
|
-
$root.Metadata.encode(m.metadata[i], w.uint32(26).fork()).ldelim();
|
|
129
|
-
}
|
|
130
|
-
if (m.pubKey != null && Object.hasOwnProperty.call(m, "pubKey"))
|
|
131
|
-
w.uint32(34).bytes(m.pubKey);
|
|
132
|
-
if (m.peerRecordEnvelope != null && Object.hasOwnProperty.call(m, "peerRecordEnvelope"))
|
|
133
|
-
w.uint32(42).bytes(m.peerRecordEnvelope);
|
|
134
|
-
return w;
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Decodes a Peer message from the specified reader or buffer.
|
|
139
|
-
* @function decode
|
|
140
|
-
* @memberof Peer
|
|
141
|
-
* @static
|
|
142
|
-
* @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from
|
|
143
|
-
* @param {number} [l] Message length if known beforehand
|
|
144
|
-
* @returns {Peer} Peer
|
|
145
|
-
* @throws {Error} If the payload is not a reader or valid buffer
|
|
146
|
-
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
147
|
-
*/
|
|
148
|
-
Peer.decode = function decode(r, l) {
|
|
149
|
-
if (!(r instanceof $Reader))
|
|
150
|
-
r = $Reader.create(r);
|
|
151
|
-
var c = l === undefined ? r.len : r.pos + l, m = new $root.Peer();
|
|
152
|
-
while (r.pos < c) {
|
|
153
|
-
var t = r.uint32();
|
|
154
|
-
switch (t >>> 3) {
|
|
155
|
-
case 1:
|
|
156
|
-
if (!(m.addresses && m.addresses.length))
|
|
157
|
-
m.addresses = [];
|
|
158
|
-
m.addresses.push($root.Address.decode(r, r.uint32()));
|
|
159
|
-
break;
|
|
160
|
-
case 2:
|
|
161
|
-
if (!(m.protocols && m.protocols.length))
|
|
162
|
-
m.protocols = [];
|
|
163
|
-
m.protocols.push(r.string());
|
|
164
|
-
break;
|
|
165
|
-
case 3:
|
|
166
|
-
if (!(m.metadata && m.metadata.length))
|
|
167
|
-
m.metadata = [];
|
|
168
|
-
m.metadata.push($root.Metadata.decode(r, r.uint32()));
|
|
169
|
-
break;
|
|
170
|
-
case 4:
|
|
171
|
-
m.pubKey = r.bytes();
|
|
172
|
-
break;
|
|
173
|
-
case 5:
|
|
174
|
-
m.peerRecordEnvelope = r.bytes();
|
|
175
|
-
break;
|
|
176
|
-
default:
|
|
177
|
-
r.skipType(t & 7);
|
|
178
|
-
break;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
return m;
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Creates a Peer message from a plain object. Also converts values to their respective internal types.
|
|
186
|
-
* @function fromObject
|
|
187
|
-
* @memberof Peer
|
|
188
|
-
* @static
|
|
189
|
-
* @param {Object.<string,*>} d Plain object
|
|
190
|
-
* @returns {Peer} Peer
|
|
191
|
-
*/
|
|
192
|
-
Peer.fromObject = function fromObject(d) {
|
|
193
|
-
if (d instanceof $root.Peer)
|
|
194
|
-
return d;
|
|
195
|
-
var m = new $root.Peer();
|
|
196
|
-
if (d.addresses) {
|
|
197
|
-
if (!Array.isArray(d.addresses))
|
|
198
|
-
throw TypeError(".Peer.addresses: array expected");
|
|
199
|
-
m.addresses = [];
|
|
200
|
-
for (var i = 0; i < d.addresses.length; ++i) {
|
|
201
|
-
if (typeof d.addresses[i] !== "object")
|
|
202
|
-
throw TypeError(".Peer.addresses: object expected");
|
|
203
|
-
m.addresses[i] = $root.Address.fromObject(d.addresses[i]);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
if (d.protocols) {
|
|
207
|
-
if (!Array.isArray(d.protocols))
|
|
208
|
-
throw TypeError(".Peer.protocols: array expected");
|
|
209
|
-
m.protocols = [];
|
|
210
|
-
for (var i = 0; i < d.protocols.length; ++i) {
|
|
211
|
-
m.protocols[i] = String(d.protocols[i]);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
if (d.metadata) {
|
|
215
|
-
if (!Array.isArray(d.metadata))
|
|
216
|
-
throw TypeError(".Peer.metadata: array expected");
|
|
217
|
-
m.metadata = [];
|
|
218
|
-
for (var i = 0; i < d.metadata.length; ++i) {
|
|
219
|
-
if (typeof d.metadata[i] !== "object")
|
|
220
|
-
throw TypeError(".Peer.metadata: object expected");
|
|
221
|
-
m.metadata[i] = $root.Metadata.fromObject(d.metadata[i]);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
if (d.pubKey != null) {
|
|
225
|
-
if (typeof d.pubKey === "string")
|
|
226
|
-
$util.base64.decode(d.pubKey, m.pubKey = $util.newBuffer($util.base64.length(d.pubKey)), 0);
|
|
227
|
-
else if (d.pubKey.length)
|
|
228
|
-
m.pubKey = d.pubKey;
|
|
229
|
-
}
|
|
230
|
-
if (d.peerRecordEnvelope != null) {
|
|
231
|
-
if (typeof d.peerRecordEnvelope === "string")
|
|
232
|
-
$util.base64.decode(d.peerRecordEnvelope, m.peerRecordEnvelope = $util.newBuffer($util.base64.length(d.peerRecordEnvelope)), 0);
|
|
233
|
-
else if (d.peerRecordEnvelope.length)
|
|
234
|
-
m.peerRecordEnvelope = d.peerRecordEnvelope;
|
|
235
|
-
}
|
|
236
|
-
return m;
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* Creates a plain object from a Peer message. Also converts values to other types if specified.
|
|
241
|
-
* @function toObject
|
|
242
|
-
* @memberof Peer
|
|
243
|
-
* @static
|
|
244
|
-
* @param {Peer} m Peer
|
|
245
|
-
* @param {$protobuf.IConversionOptions} [o] Conversion options
|
|
246
|
-
* @returns {Object.<string,*>} Plain object
|
|
247
|
-
*/
|
|
248
|
-
Peer.toObject = function toObject(m, o) {
|
|
249
|
-
if (!o)
|
|
250
|
-
o = {};
|
|
251
|
-
var d = {};
|
|
252
|
-
if (o.arrays || o.defaults) {
|
|
253
|
-
d.addresses = [];
|
|
254
|
-
d.protocols = [];
|
|
255
|
-
d.metadata = [];
|
|
256
|
-
}
|
|
257
|
-
if (m.addresses && m.addresses.length) {
|
|
258
|
-
d.addresses = [];
|
|
259
|
-
for (var j = 0; j < m.addresses.length; ++j) {
|
|
260
|
-
d.addresses[j] = $root.Address.toObject(m.addresses[j], o);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
if (m.protocols && m.protocols.length) {
|
|
264
|
-
d.protocols = [];
|
|
265
|
-
for (var j = 0; j < m.protocols.length; ++j) {
|
|
266
|
-
d.protocols[j] = m.protocols[j];
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
if (m.metadata && m.metadata.length) {
|
|
270
|
-
d.metadata = [];
|
|
271
|
-
for (var j = 0; j < m.metadata.length; ++j) {
|
|
272
|
-
d.metadata[j] = $root.Metadata.toObject(m.metadata[j], o);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
if (m.pubKey != null && m.hasOwnProperty("pubKey")) {
|
|
276
|
-
d.pubKey = o.bytes === String ? $util.base64.encode(m.pubKey, 0, m.pubKey.length) : o.bytes === Array ? Array.prototype.slice.call(m.pubKey) : m.pubKey;
|
|
277
|
-
if (o.oneofs)
|
|
278
|
-
d._pubKey = "pubKey";
|
|
279
|
-
}
|
|
280
|
-
if (m.peerRecordEnvelope != null && m.hasOwnProperty("peerRecordEnvelope")) {
|
|
281
|
-
d.peerRecordEnvelope = o.bytes === String ? $util.base64.encode(m.peerRecordEnvelope, 0, m.peerRecordEnvelope.length) : o.bytes === Array ? Array.prototype.slice.call(m.peerRecordEnvelope) : m.peerRecordEnvelope;
|
|
282
|
-
if (o.oneofs)
|
|
283
|
-
d._peerRecordEnvelope = "peerRecordEnvelope";
|
|
284
|
-
}
|
|
285
|
-
return d;
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* Converts this Peer to JSON.
|
|
290
|
-
* @function toJSON
|
|
291
|
-
* @memberof Peer
|
|
292
|
-
* @instance
|
|
293
|
-
* @returns {Object.<string,*>} JSON object
|
|
294
|
-
*/
|
|
295
|
-
Peer.prototype.toJSON = function toJSON() {
|
|
296
|
-
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
return Peer;
|
|
300
|
-
})();
|
|
301
|
-
|
|
302
|
-
export const Address = $root.Address = (() => {
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* Properties of an Address.
|
|
306
|
-
* @exports IAddress
|
|
307
|
-
* @interface IAddress
|
|
308
|
-
* @property {Uint8Array|null} [multiaddr] Address multiaddr
|
|
309
|
-
* @property {boolean|null} [isCertified] Address isCertified
|
|
310
|
-
*/
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* Constructs a new Address.
|
|
314
|
-
* @exports Address
|
|
315
|
-
* @classdesc Represents an Address.
|
|
316
|
-
* @implements IAddress
|
|
317
|
-
* @constructor
|
|
318
|
-
* @param {IAddress=} [p] Properties to set
|
|
319
|
-
*/
|
|
320
|
-
function Address(p) {
|
|
321
|
-
if (p)
|
|
322
|
-
for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
|
|
323
|
-
if (p[ks[i]] != null)
|
|
324
|
-
this[ks[i]] = p[ks[i]];
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* Address multiaddr.
|
|
329
|
-
* @member {Uint8Array} multiaddr
|
|
330
|
-
* @memberof Address
|
|
331
|
-
* @instance
|
|
332
|
-
*/
|
|
333
|
-
Address.prototype.multiaddr = $util.newBuffer([]);
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* Address isCertified.
|
|
337
|
-
* @member {boolean|null|undefined} isCertified
|
|
338
|
-
* @memberof Address
|
|
339
|
-
* @instance
|
|
340
|
-
*/
|
|
341
|
-
Address.prototype.isCertified = null;
|
|
342
|
-
|
|
343
|
-
// OneOf field names bound to virtual getters and setters
|
|
344
|
-
let $oneOfFields;
|
|
345
|
-
|
|
346
|
-
/**
|
|
347
|
-
* Address _isCertified.
|
|
348
|
-
* @member {"isCertified"|undefined} _isCertified
|
|
349
|
-
* @memberof Address
|
|
350
|
-
* @instance
|
|
351
|
-
*/
|
|
352
|
-
Object.defineProperty(Address.prototype, "_isCertified", {
|
|
353
|
-
get: $util.oneOfGetter($oneOfFields = ["isCertified"]),
|
|
354
|
-
set: $util.oneOfSetter($oneOfFields)
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* Encodes the specified Address message. Does not implicitly {@link Address.verify|verify} messages.
|
|
359
|
-
* @function encode
|
|
360
|
-
* @memberof Address
|
|
361
|
-
* @static
|
|
362
|
-
* @param {IAddress} m Address message or plain object to encode
|
|
363
|
-
* @param {$protobuf.Writer} [w] Writer to encode to
|
|
364
|
-
* @returns {$protobuf.Writer} Writer
|
|
365
|
-
*/
|
|
366
|
-
Address.encode = function encode(m, w) {
|
|
367
|
-
if (!w)
|
|
368
|
-
w = $Writer.create();
|
|
369
|
-
if (m.multiaddr != null && Object.hasOwnProperty.call(m, "multiaddr"))
|
|
370
|
-
w.uint32(10).bytes(m.multiaddr);
|
|
371
|
-
if (m.isCertified != null && Object.hasOwnProperty.call(m, "isCertified"))
|
|
372
|
-
w.uint32(16).bool(m.isCertified);
|
|
373
|
-
return w;
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
* Decodes an Address message from the specified reader or buffer.
|
|
378
|
-
* @function decode
|
|
379
|
-
* @memberof Address
|
|
380
|
-
* @static
|
|
381
|
-
* @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from
|
|
382
|
-
* @param {number} [l] Message length if known beforehand
|
|
383
|
-
* @returns {Address} Address
|
|
384
|
-
* @throws {Error} If the payload is not a reader or valid buffer
|
|
385
|
-
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
386
|
-
*/
|
|
387
|
-
Address.decode = function decode(r, l) {
|
|
388
|
-
if (!(r instanceof $Reader))
|
|
389
|
-
r = $Reader.create(r);
|
|
390
|
-
var c = l === undefined ? r.len : r.pos + l, m = new $root.Address();
|
|
391
|
-
while (r.pos < c) {
|
|
392
|
-
var t = r.uint32();
|
|
393
|
-
switch (t >>> 3) {
|
|
394
|
-
case 1:
|
|
395
|
-
m.multiaddr = r.bytes();
|
|
396
|
-
break;
|
|
397
|
-
case 2:
|
|
398
|
-
m.isCertified = r.bool();
|
|
399
|
-
break;
|
|
400
|
-
default:
|
|
401
|
-
r.skipType(t & 7);
|
|
402
|
-
break;
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
return m;
|
|
406
|
-
};
|
|
407
|
-
|
|
408
|
-
/**
|
|
409
|
-
* Creates an Address message from a plain object. Also converts values to their respective internal types.
|
|
410
|
-
* @function fromObject
|
|
411
|
-
* @memberof Address
|
|
412
|
-
* @static
|
|
413
|
-
* @param {Object.<string,*>} d Plain object
|
|
414
|
-
* @returns {Address} Address
|
|
415
|
-
*/
|
|
416
|
-
Address.fromObject = function fromObject(d) {
|
|
417
|
-
if (d instanceof $root.Address)
|
|
418
|
-
return d;
|
|
419
|
-
var m = new $root.Address();
|
|
420
|
-
if (d.multiaddr != null) {
|
|
421
|
-
if (typeof d.multiaddr === "string")
|
|
422
|
-
$util.base64.decode(d.multiaddr, m.multiaddr = $util.newBuffer($util.base64.length(d.multiaddr)), 0);
|
|
423
|
-
else if (d.multiaddr.length)
|
|
424
|
-
m.multiaddr = d.multiaddr;
|
|
425
|
-
}
|
|
426
|
-
if (d.isCertified != null) {
|
|
427
|
-
m.isCertified = Boolean(d.isCertified);
|
|
428
|
-
}
|
|
429
|
-
return m;
|
|
430
|
-
};
|
|
431
|
-
|
|
432
|
-
/**
|
|
433
|
-
* Creates a plain object from an Address message. Also converts values to other types if specified.
|
|
434
|
-
* @function toObject
|
|
435
|
-
* @memberof Address
|
|
436
|
-
* @static
|
|
437
|
-
* @param {Address} m Address
|
|
438
|
-
* @param {$protobuf.IConversionOptions} [o] Conversion options
|
|
439
|
-
* @returns {Object.<string,*>} Plain object
|
|
440
|
-
*/
|
|
441
|
-
Address.toObject = function toObject(m, o) {
|
|
442
|
-
if (!o)
|
|
443
|
-
o = {};
|
|
444
|
-
var d = {};
|
|
445
|
-
if (o.defaults) {
|
|
446
|
-
if (o.bytes === String)
|
|
447
|
-
d.multiaddr = "";
|
|
448
|
-
else {
|
|
449
|
-
d.multiaddr = [];
|
|
450
|
-
if (o.bytes !== Array)
|
|
451
|
-
d.multiaddr = $util.newBuffer(d.multiaddr);
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
if (m.multiaddr != null && m.hasOwnProperty("multiaddr")) {
|
|
455
|
-
d.multiaddr = o.bytes === String ? $util.base64.encode(m.multiaddr, 0, m.multiaddr.length) : o.bytes === Array ? Array.prototype.slice.call(m.multiaddr) : m.multiaddr;
|
|
456
|
-
}
|
|
457
|
-
if (m.isCertified != null && m.hasOwnProperty("isCertified")) {
|
|
458
|
-
d.isCertified = m.isCertified;
|
|
459
|
-
if (o.oneofs)
|
|
460
|
-
d._isCertified = "isCertified";
|
|
461
|
-
}
|
|
462
|
-
return d;
|
|
463
|
-
};
|
|
464
|
-
|
|
465
|
-
/**
|
|
466
|
-
* Converts this Address to JSON.
|
|
467
|
-
* @function toJSON
|
|
468
|
-
* @memberof Address
|
|
469
|
-
* @instance
|
|
470
|
-
* @returns {Object.<string,*>} JSON object
|
|
471
|
-
*/
|
|
472
|
-
Address.prototype.toJSON = function toJSON() {
|
|
473
|
-
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
|
474
|
-
};
|
|
475
|
-
|
|
476
|
-
return Address;
|
|
477
|
-
})();
|
|
478
|
-
|
|
479
|
-
export const Metadata = $root.Metadata = (() => {
|
|
480
|
-
|
|
481
|
-
/**
|
|
482
|
-
* Properties of a Metadata.
|
|
483
|
-
* @exports IMetadata
|
|
484
|
-
* @interface IMetadata
|
|
485
|
-
* @property {string|null} [key] Metadata key
|
|
486
|
-
* @property {Uint8Array|null} [value] Metadata value
|
|
487
|
-
*/
|
|
488
|
-
|
|
489
|
-
/**
|
|
490
|
-
* Constructs a new Metadata.
|
|
491
|
-
* @exports Metadata
|
|
492
|
-
* @classdesc Represents a Metadata.
|
|
493
|
-
* @implements IMetadata
|
|
494
|
-
* @constructor
|
|
495
|
-
* @param {IMetadata=} [p] Properties to set
|
|
496
|
-
*/
|
|
497
|
-
function Metadata(p) {
|
|
498
|
-
if (p)
|
|
499
|
-
for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
|
|
500
|
-
if (p[ks[i]] != null)
|
|
501
|
-
this[ks[i]] = p[ks[i]];
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
/**
|
|
505
|
-
* Metadata key.
|
|
506
|
-
* @member {string} key
|
|
507
|
-
* @memberof Metadata
|
|
508
|
-
* @instance
|
|
509
|
-
*/
|
|
510
|
-
Metadata.prototype.key = "";
|
|
511
|
-
|
|
512
|
-
/**
|
|
513
|
-
* Metadata value.
|
|
514
|
-
* @member {Uint8Array} value
|
|
515
|
-
* @memberof Metadata
|
|
516
|
-
* @instance
|
|
517
|
-
*/
|
|
518
|
-
Metadata.prototype.value = $util.newBuffer([]);
|
|
519
|
-
|
|
520
|
-
/**
|
|
521
|
-
* Encodes the specified Metadata message. Does not implicitly {@link Metadata.verify|verify} messages.
|
|
522
|
-
* @function encode
|
|
523
|
-
* @memberof Metadata
|
|
524
|
-
* @static
|
|
525
|
-
* @param {IMetadata} m Metadata message or plain object to encode
|
|
526
|
-
* @param {$protobuf.Writer} [w] Writer to encode to
|
|
527
|
-
* @returns {$protobuf.Writer} Writer
|
|
528
|
-
*/
|
|
529
|
-
Metadata.encode = function encode(m, w) {
|
|
530
|
-
if (!w)
|
|
531
|
-
w = $Writer.create();
|
|
532
|
-
if (m.key != null && Object.hasOwnProperty.call(m, "key"))
|
|
533
|
-
w.uint32(10).string(m.key);
|
|
534
|
-
if (m.value != null && Object.hasOwnProperty.call(m, "value"))
|
|
535
|
-
w.uint32(18).bytes(m.value);
|
|
536
|
-
return w;
|
|
537
|
-
};
|
|
538
|
-
|
|
539
|
-
/**
|
|
540
|
-
* Decodes a Metadata message from the specified reader or buffer.
|
|
541
|
-
* @function decode
|
|
542
|
-
* @memberof Metadata
|
|
543
|
-
* @static
|
|
544
|
-
* @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from
|
|
545
|
-
* @param {number} [l] Message length if known beforehand
|
|
546
|
-
* @returns {Metadata} Metadata
|
|
547
|
-
* @throws {Error} If the payload is not a reader or valid buffer
|
|
548
|
-
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
549
|
-
*/
|
|
550
|
-
Metadata.decode = function decode(r, l) {
|
|
551
|
-
if (!(r instanceof $Reader))
|
|
552
|
-
r = $Reader.create(r);
|
|
553
|
-
var c = l === undefined ? r.len : r.pos + l, m = new $root.Metadata();
|
|
554
|
-
while (r.pos < c) {
|
|
555
|
-
var t = r.uint32();
|
|
556
|
-
switch (t >>> 3) {
|
|
557
|
-
case 1:
|
|
558
|
-
m.key = r.string();
|
|
559
|
-
break;
|
|
560
|
-
case 2:
|
|
561
|
-
m.value = r.bytes();
|
|
562
|
-
break;
|
|
563
|
-
default:
|
|
564
|
-
r.skipType(t & 7);
|
|
565
|
-
break;
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
return m;
|
|
569
|
-
};
|
|
570
|
-
|
|
571
|
-
/**
|
|
572
|
-
* Creates a Metadata message from a plain object. Also converts values to their respective internal types.
|
|
573
|
-
* @function fromObject
|
|
574
|
-
* @memberof Metadata
|
|
575
|
-
* @static
|
|
576
|
-
* @param {Object.<string,*>} d Plain object
|
|
577
|
-
* @returns {Metadata} Metadata
|
|
578
|
-
*/
|
|
579
|
-
Metadata.fromObject = function fromObject(d) {
|
|
580
|
-
if (d instanceof $root.Metadata)
|
|
581
|
-
return d;
|
|
582
|
-
var m = new $root.Metadata();
|
|
583
|
-
if (d.key != null) {
|
|
584
|
-
m.key = String(d.key);
|
|
585
|
-
}
|
|
586
|
-
if (d.value != null) {
|
|
587
|
-
if (typeof d.value === "string")
|
|
588
|
-
$util.base64.decode(d.value, m.value = $util.newBuffer($util.base64.length(d.value)), 0);
|
|
589
|
-
else if (d.value.length)
|
|
590
|
-
m.value = d.value;
|
|
591
|
-
}
|
|
592
|
-
return m;
|
|
593
|
-
};
|
|
594
|
-
|
|
595
|
-
/**
|
|
596
|
-
* Creates a plain object from a Metadata message. Also converts values to other types if specified.
|
|
597
|
-
* @function toObject
|
|
598
|
-
* @memberof Metadata
|
|
599
|
-
* @static
|
|
600
|
-
* @param {Metadata} m Metadata
|
|
601
|
-
* @param {$protobuf.IConversionOptions} [o] Conversion options
|
|
602
|
-
* @returns {Object.<string,*>} Plain object
|
|
603
|
-
*/
|
|
604
|
-
Metadata.toObject = function toObject(m, o) {
|
|
605
|
-
if (!o)
|
|
606
|
-
o = {};
|
|
607
|
-
var d = {};
|
|
608
|
-
if (o.defaults) {
|
|
609
|
-
d.key = "";
|
|
610
|
-
if (o.bytes === String)
|
|
611
|
-
d.value = "";
|
|
612
|
-
else {
|
|
613
|
-
d.value = [];
|
|
614
|
-
if (o.bytes !== Array)
|
|
615
|
-
d.value = $util.newBuffer(d.value);
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
if (m.key != null && m.hasOwnProperty("key")) {
|
|
619
|
-
d.key = m.key;
|
|
620
|
-
}
|
|
621
|
-
if (m.value != null && m.hasOwnProperty("value")) {
|
|
622
|
-
d.value = o.bytes === String ? $util.base64.encode(m.value, 0, m.value.length) : o.bytes === Array ? Array.prototype.slice.call(m.value) : m.value;
|
|
623
|
-
}
|
|
624
|
-
return d;
|
|
625
|
-
};
|
|
626
|
-
|
|
627
|
-
/**
|
|
628
|
-
* Converts this Metadata to JSON.
|
|
629
|
-
* @function toJSON
|
|
630
|
-
* @memberof Metadata
|
|
631
|
-
* @instance
|
|
632
|
-
* @returns {Object.<string,*>} JSON object
|
|
633
|
-
*/
|
|
634
|
-
Metadata.prototype.toJSON = function toJSON() {
|
|
635
|
-
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
|
636
|
-
};
|
|
637
|
-
|
|
638
|
-
return Metadata;
|
|
639
|
-
})();
|
|
640
|
-
|
|
641
|
-
export { $root as default };
|