libp2p 0.35.8 → 0.36.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.
Files changed (107) hide show
  1. package/dist/index.min.js +55 -0
  2. package/dist/src/circuit/auto-relay.d.ts +8 -10
  3. package/dist/src/circuit/auto-relay.d.ts.map +1 -1
  4. package/dist/src/config.d.ts +2 -0
  5. package/dist/src/config.d.ts.map +1 -1
  6. package/dist/src/connection-manager/auto-dialler.d.ts +1 -1
  7. package/dist/src/connection-manager/auto-dialler.d.ts.map +1 -1
  8. package/dist/src/connection-manager/index.d.ts +1 -2
  9. package/dist/src/connection-manager/index.d.ts.map +1 -1
  10. package/dist/src/content-routing/utils.d.ts +3 -3
  11. package/dist/src/content-routing/utils.d.ts.map +1 -1
  12. package/dist/src/dialer/dial-request.d.ts.map +1 -1
  13. package/dist/src/dialer/index.d.ts +12 -7
  14. package/dist/src/dialer/index.d.ts.map +1 -1
  15. package/dist/src/errors.d.ts +2 -0
  16. package/dist/src/fetch/constants.d.ts +2 -0
  17. package/dist/src/fetch/constants.d.ts.map +1 -0
  18. package/dist/src/fetch/index.d.ts +76 -0
  19. package/dist/src/fetch/index.d.ts.map +1 -0
  20. package/dist/src/fetch/proto.d.ts +134 -0
  21. package/dist/src/identify/index.d.ts +4 -4
  22. package/dist/src/identify/index.d.ts.map +1 -1
  23. package/dist/src/index.d.ts +116 -7
  24. package/dist/src/index.d.ts.map +1 -1
  25. package/dist/src/metrics/index.d.ts +9 -4
  26. package/dist/src/metrics/index.d.ts.map +1 -1
  27. package/dist/src/metrics/tracked-map.d.ts +6 -1
  28. package/dist/src/metrics/tracked-map.d.ts.map +1 -1
  29. package/dist/src/peer-routing.d.ts +1 -1
  30. package/dist/src/peer-routing.d.ts.map +1 -1
  31. package/dist/src/peer-store/address-book.d.ts +30 -84
  32. package/dist/src/peer-store/address-book.d.ts.map +1 -1
  33. package/dist/src/peer-store/index.d.ts +28 -94
  34. package/dist/src/peer-store/index.d.ts.map +1 -1
  35. package/dist/src/peer-store/key-book.d.ts +31 -15
  36. package/dist/src/peer-store/key-book.d.ts.map +1 -1
  37. package/dist/src/peer-store/metadata-book.d.ts +33 -29
  38. package/dist/src/peer-store/metadata-book.d.ts.map +1 -1
  39. package/dist/src/peer-store/pb/peer.d.ts +222 -0
  40. package/dist/src/peer-store/proto-book.d.ts +27 -28
  41. package/dist/src/peer-store/proto-book.d.ts.map +1 -1
  42. package/dist/src/peer-store/store.d.ts +73 -0
  43. package/dist/src/peer-store/store.d.ts.map +1 -0
  44. package/dist/src/peer-store/types.d.ts +202 -0
  45. package/dist/src/peer-store/types.d.ts.map +1 -0
  46. package/dist/src/ping/index.d.ts.map +1 -1
  47. package/dist/src/record/peer-record/index.d.ts +2 -2
  48. package/dist/src/record/peer-record/index.d.ts.map +1 -1
  49. package/dist/src/registrar.d.ts +5 -5
  50. package/dist/src/registrar.d.ts.map +1 -1
  51. package/dist/src/types.d.ts +90 -0
  52. package/dist/src/types.d.ts.map +1 -0
  53. package/dist/src/upgrader.d.ts +8 -2
  54. package/dist/src/upgrader.d.ts.map +1 -1
  55. package/package.json +23 -26
  56. package/src/circuit/auto-relay.js +52 -38
  57. package/src/config.js +2 -0
  58. package/src/connection-manager/auto-dialler.js +20 -8
  59. package/src/connection-manager/index.js +42 -22
  60. package/src/content-routing/utils.js +4 -4
  61. package/src/dialer/dial-request.js +4 -1
  62. package/src/dialer/index.js +38 -8
  63. package/src/errors.js +2 -0
  64. package/src/fetch/README.md +36 -0
  65. package/src/fetch/constants.js +6 -0
  66. package/src/fetch/index.js +159 -0
  67. package/src/fetch/proto.d.ts +134 -0
  68. package/src/fetch/proto.js +333 -0
  69. package/src/fetch/proto.proto +15 -0
  70. package/src/identify/index.js +47 -38
  71. package/src/index.js +72 -27
  72. package/src/metrics/index.js +15 -8
  73. package/src/metrics/tracked-map.js +40 -14
  74. package/src/peer-routing.js +4 -1
  75. package/src/peer-store/address-book.js +254 -226
  76. package/src/peer-store/index.js +79 -110
  77. package/src/peer-store/key-book.js +99 -54
  78. package/src/peer-store/metadata-book.js +171 -101
  79. package/src/peer-store/pb/peer.d.ts +222 -0
  80. package/src/peer-store/pb/peer.js +643 -0
  81. package/src/peer-store/pb/peer.proto +31 -0
  82. package/src/peer-store/proto-book.js +171 -105
  83. package/src/peer-store/store.js +263 -0
  84. package/src/peer-store/types.ts +245 -0
  85. package/src/ping/index.js +6 -0
  86. package/src/record/peer-record/index.js +1 -1
  87. package/src/record/utils.js +1 -1
  88. package/src/registrar.js +4 -4
  89. package/src/types.ts +98 -0
  90. package/src/upgrader.js +32 -2
  91. package/dist/src/peer-store/book.d.ts +0 -81
  92. package/dist/src/peer-store/book.d.ts.map +0 -1
  93. package/dist/src/peer-store/persistent/consts.d.ts +0 -6
  94. package/dist/src/peer-store/persistent/consts.d.ts.map +0 -1
  95. package/dist/src/peer-store/persistent/index.d.ts +0 -129
  96. package/dist/src/peer-store/persistent/index.d.ts.map +0 -1
  97. package/dist/src/peer-store/persistent/pb/address-book.d.ts +0 -198
  98. package/dist/src/peer-store/persistent/pb/proto-book.d.ts +0 -59
  99. package/src/peer-store/book.js +0 -124
  100. package/src/peer-store/persistent/consts.js +0 -15
  101. package/src/peer-store/persistent/index.js +0 -408
  102. package/src/peer-store/persistent/pb/address-book.d.ts +0 -198
  103. package/src/peer-store/persistent/pb/address-book.js +0 -522
  104. package/src/peer-store/persistent/pb/address-book.proto +0 -27
  105. package/src/peer-store/persistent/pb/proto-book.d.ts +0 -59
  106. package/src/peer-store/persistent/pb/proto-book.js +0 -157
  107. package/src/peer-store/persistent/pb/proto-book.proto +0 -5
@@ -1,180 +1,250 @@
1
1
  'use strict'
2
2
 
3
3
  const debug = require('debug')
4
- const log = Object.assign(debug('libp2p:peer-store:proto-book'), {
5
- error: debug('libp2p:peer-store:proto-book:err')
6
- })
7
4
  const errcode = require('err-code')
8
- const { equals: uint8ArrayEquals } = require('uint8arrays/equals')
9
-
5
+ const { codes } = require('../errors')
10
6
  const PeerId = require('peer-id')
7
+ const { equals: uint8ArrayEquals } = require('uint8arrays/equals')
11
8
 
12
- const Book = require('./book')
13
-
14
- const {
15
- codes: { ERR_INVALID_PARAMETERS }
16
- } = require('../errors')
9
+ const log = Object.assign(debug('libp2p:peer-store:metadata-book'), {
10
+ error: debug('libp2p:peer-store:metadata-book:err')
11
+ })
17
12
 
18
13
  /**
19
- * @typedef {import('./')} PeerStore
14
+ * @typedef {import('./types').PeerStore} PeerStore
15
+ * @typedef {import('./types').MetadataBook} MetadataBook
20
16
  */
21
17
 
18
+ const EVENT_NAME = 'change:metadata'
19
+
22
20
  /**
23
- * @extends {Book}
24
- *
25
- * @fires MetadataBook#change:metadata
21
+ * @implements {MetadataBook}
26
22
  */
27
- class MetadataBook extends Book {
23
+ class PeerStoreMetadataBook {
28
24
  /**
29
25
  * The MetadataBook is responsible for keeping the known supported
30
- * protocols of a peer.
26
+ * protocols of a peer
31
27
  *
32
- * @class
33
- * @param {PeerStore} peerStore
28
+ * @param {PeerStore["emit"]} emit
29
+ * @param {import('./types').Store} store
34
30
  */
35
- constructor (peerStore) {
36
- /**
37
- * PeerStore Event emitter, used by the MetadataBook to emit:
38
- * "change:metadata" - emitted when the known metadata of a peer change.
39
- */
40
- super({
41
- peerStore,
42
- eventName: 'change:metadata',
43
- eventProperty: 'metadata'
44
- })
45
-
46
- /**
47
- * Map known peers to their known protocols.
48
- *
49
- * @type {Map<string, Map<string, Uint8Array>>}
50
- */
51
- this.data = new Map()
31
+ constructor (emit, store) {
32
+ this._emit = emit
33
+ this._store = store
52
34
  }
53
35
 
54
36
  /**
55
- * Set metadata key and value of a provided peer.
37
+ * Get the known data of a provided peer
56
38
  *
57
- * @override
58
39
  * @param {PeerId} peerId
59
- * @param {string} key - metadata key
60
- * @param {Uint8Array} value - metadata value
61
- * @returns {MetadataBook}
62
40
  */
63
- // @ts-ignore override with more then the parameters expected in Book
64
- set (peerId, key, value) {
41
+ async get (peerId) {
65
42
  if (!PeerId.isPeerId(peerId)) {
66
43
  log.error('peerId must be an instance of peer-id to store data')
67
- throw errcode(new Error('peerId must be an instance of peer-id'), ERR_INVALID_PARAMETERS)
44
+ throw errcode(new Error('peerId must be an instance of peer-id'), codes.ERR_INVALID_PARAMETERS)
68
45
  }
69
46
 
70
- if (typeof key !== 'string' || !(value instanceof Uint8Array)) {
71
- log.error('valid key and value must be provided to store data')
72
- throw errcode(new Error('valid key and value must be provided'), ERR_INVALID_PARAMETERS)
47
+ log('get await read lock')
48
+ const release = await this._store.lock.readLock()
49
+ log('get got read lock')
50
+
51
+ try {
52
+ const peer = await this._store.load(peerId)
53
+
54
+ return peer.metadata
55
+ } catch (/** @type {any} */ err) {
56
+ if (err.code !== codes.ERR_NOT_FOUND) {
57
+ throw err
58
+ }
59
+ } finally {
60
+ log('get release read lock')
61
+ release()
73
62
  }
74
63
 
75
- this._setValue(peerId, key, value)
76
-
77
- return this
64
+ return new Map()
78
65
  }
79
66
 
80
67
  /**
81
- * Set data into the datastructure
68
+ * Get specific metadata value, if it exists
82
69
  *
83
70
  * @param {PeerId} peerId
84
71
  * @param {string} key
85
- * @param {Uint8Array} value
86
- * @param {object} [opts]
87
- * @param {boolean} [opts.emit]
88
72
  */
89
- _setValue (peerId, key, value, { emit = true } = {}) {
90
- const id = peerId.toB58String()
91
- const rec = this.data.get(id) || new Map()
92
- const recMap = rec.get(key)
93
-
94
- // Already exists and is equal
95
- if (recMap && uint8ArrayEquals(value, recMap)) {
96
- log(`the metadata provided to store is equal to the already stored for ${id} on ${key}`)
97
- return
73
+ async getValue (peerId, key) {
74
+ if (!PeerId.isPeerId(peerId)) {
75
+ log.error('peerId must be an instance of peer-id to store data')
76
+ throw errcode(new Error('peerId must be an instance of peer-id'), codes.ERR_INVALID_PARAMETERS)
98
77
  }
99
78
 
100
- rec.set(key, value)
101
- this.data.set(id, rec)
102
-
103
- emit && this._emit(peerId, key)
79
+ log('getValue await read lock')
80
+ const release = await this._store.lock.readLock()
81
+ log('getValue got read lock')
82
+
83
+ try {
84
+ const peer = await this._store.load(peerId)
85
+
86
+ return peer.metadata.get(key)
87
+ } catch (/** @type {any} */ err) {
88
+ if (err.code !== codes.ERR_NOT_FOUND) {
89
+ throw err
90
+ }
91
+ } finally {
92
+ log('getValue release write lock')
93
+ release()
94
+ }
104
95
  }
105
96
 
106
97
  /**
107
- * Get the known data of a provided peer.
108
- *
109
98
  * @param {PeerId} peerId
110
- * @returns {Map<string, Uint8Array>|undefined}
99
+ * @param {Map<string, Uint8Array>} metadata
111
100
  */
112
- get (peerId) {
101
+ async set (peerId, metadata) {
113
102
  if (!PeerId.isPeerId(peerId)) {
114
- throw errcode(new Error('peerId must be an instance of peer-id'), ERR_INVALID_PARAMETERS)
103
+ log.error('peerId must be an instance of peer-id to store data')
104
+ throw errcode(new Error('peerId must be an instance of peer-id'), codes.ERR_INVALID_PARAMETERS)
105
+ }
106
+
107
+ if (!metadata || !(metadata instanceof Map)) {
108
+ log.error('valid metadata must be provided to store data')
109
+ throw errcode(new Error('valid metadata must be provided'), codes.ERR_INVALID_PARAMETERS)
115
110
  }
116
111
 
117
- return this.data.get(peerId.toB58String())
112
+ log('set await write lock')
113
+ const release = await this._store.lock.writeLock()
114
+ log('set got write lock')
115
+
116
+ try {
117
+ await this._store.mergeOrCreate(peerId, {
118
+ metadata
119
+ })
120
+ } finally {
121
+ log('set release write lock')
122
+ release()
123
+ }
124
+
125
+ this._emit(EVENT_NAME, { peerId, metadata })
118
126
  }
119
127
 
120
128
  /**
121
- * Get specific metadata value, if it exists
129
+ * Set metadata key and value of a provided peer
122
130
  *
123
131
  * @param {PeerId} peerId
124
- * @param {string} key
125
- * @returns {Uint8Array | undefined}
132
+ * @param {string} key - metadata key
133
+ * @param {Uint8Array} value - metadata value
126
134
  */
127
- getValue (peerId, key) {
135
+ async setValue (peerId, key, value) {
128
136
  if (!PeerId.isPeerId(peerId)) {
129
- throw errcode(new Error('peerId must be an instance of peer-id'), ERR_INVALID_PARAMETERS)
137
+ log.error('peerId must be an instance of peer-id to store data')
138
+ throw errcode(new Error('peerId must be an instance of peer-id'), codes.ERR_INVALID_PARAMETERS)
139
+ }
140
+
141
+ if (typeof key !== 'string' || !(value instanceof Uint8Array)) {
142
+ log.error('valid key and value must be provided to store data')
143
+ throw errcode(new Error('valid key and value must be provided'), codes.ERR_INVALID_PARAMETERS)
144
+ }
145
+
146
+ log('setValue await write lock')
147
+ const release = await this._store.lock.writeLock()
148
+ log('setValue got write lock')
149
+
150
+ let updatedPeer
151
+
152
+ try {
153
+ try {
154
+ const existingPeer = await this._store.load(peerId)
155
+ const existingValue = existingPeer.metadata.get(key)
156
+
157
+ if (existingValue != null && uint8ArrayEquals(value, existingValue)) {
158
+ return
159
+ }
160
+ } catch (/** @type {any} */ err) {
161
+ if (err.code !== codes.ERR_NOT_FOUND) {
162
+ throw err
163
+ }
164
+ }
165
+
166
+ updatedPeer = await this._store.mergeOrCreate(peerId, {
167
+ metadata: new Map([[key, value]])
168
+ })
169
+ } finally {
170
+ log('setValue release write lock')
171
+ release()
130
172
  }
131
173
 
132
- const rec = this.data.get(peerId.toB58String())
133
- return rec && rec.get(key)
174
+ this._emit(EVENT_NAME, { peerId, metadata: updatedPeer.metadata })
134
175
  }
135
176
 
136
177
  /**
137
- * Deletes the provided peer from the book.
138
- *
139
178
  * @param {PeerId} peerId
140
- * @returns {boolean}
141
179
  */
142
- delete (peerId) {
180
+ async delete (peerId) {
143
181
  if (!PeerId.isPeerId(peerId)) {
144
- throw errcode(new Error('peerId must be an instance of peer-id'), ERR_INVALID_PARAMETERS)
182
+ log.error('peerId must be an instance of peer-id to store data')
183
+ throw errcode(new Error('peerId must be an instance of peer-id'), codes.ERR_INVALID_PARAMETERS)
145
184
  }
146
185
 
147
- if (!this.data.delete(peerId.toB58String())) {
148
- return false
149
- }
186
+ log('delete await write lock')
187
+ const release = await this._store.lock.writeLock()
188
+ log('delete got write lock')
189
+
190
+ let has
191
+
192
+ try {
193
+ has = await this._store.has(peerId)
150
194
 
151
- this._emit(peerId)
195
+ if (has) {
196
+ await this._store.patch(peerId, {
197
+ metadata: new Map()
198
+ })
199
+ }
200
+ } finally {
201
+ log('delete release write lock')
202
+ release()
203
+ }
152
204
 
153
- return true
205
+ if (has) {
206
+ this._emit(EVENT_NAME, { peerId, metadata: new Map() })
207
+ }
154
208
  }
155
209
 
156
210
  /**
157
- * Deletes the provided peer metadata key from the book.
158
- *
159
211
  * @param {PeerId} peerId
160
212
  * @param {string} key
161
- * @returns {boolean}
162
213
  */
163
- deleteValue (peerId, key) {
214
+ async deleteValue (peerId, key) {
164
215
  if (!PeerId.isPeerId(peerId)) {
165
- throw errcode(new Error('peerId must be an instance of peer-id'), ERR_INVALID_PARAMETERS)
216
+ log.error('peerId must be an instance of peer-id to store data')
217
+ throw errcode(new Error('peerId must be an instance of peer-id'), codes.ERR_INVALID_PARAMETERS)
166
218
  }
167
219
 
168
- const rec = this.data.get(peerId.toB58String())
220
+ log('deleteValue await write lock')
221
+ const release = await this._store.lock.writeLock()
222
+ log('deleteValue got write lock')
169
223
 
170
- if (!rec || !rec.delete(key)) {
171
- return false
172
- }
224
+ let metadata
225
+
226
+ try {
227
+ const peer = await this._store.load(peerId)
228
+ metadata = peer.metadata
173
229
 
174
- this._emit(peerId, key)
230
+ metadata.delete(key)
175
231
 
176
- return true
232
+ await this._store.patch(peerId, {
233
+ metadata
234
+ })
235
+ } catch (/** @type {any} **/ err) {
236
+ if (err.code !== codes.ERR_NOT_FOUND) {
237
+ throw err
238
+ }
239
+ } finally {
240
+ log('deleteValue release write lock')
241
+ release()
242
+ }
243
+
244
+ if (metadata) {
245
+ this._emit(EVENT_NAME, { peerId, metadata })
246
+ }
177
247
  }
178
248
  }
179
249
 
180
- module.exports = MetadataBook
250
+ module.exports = PeerStoreMetadataBook
@@ -0,0 +1,222 @@
1
+ import * as $protobuf from "protobufjs";
2
+ /** Properties of a Peer. */
3
+ export interface IPeer {
4
+
5
+ /** Peer addresses */
6
+ addresses?: (IAddress[]|null);
7
+
8
+ /** Peer protocols */
9
+ protocols?: (string[]|null);
10
+
11
+ /** Peer metadata */
12
+ metadata?: (IMetadata[]|null);
13
+
14
+ /** Peer pubKey */
15
+ pubKey?: (Uint8Array|null);
16
+
17
+ /** Peer peerRecordEnvelope */
18
+ peerRecordEnvelope?: (Uint8Array|null);
19
+ }
20
+
21
+ /** Represents a Peer. */
22
+ export class Peer implements IPeer {
23
+
24
+ /**
25
+ * Constructs a new Peer.
26
+ * @param [p] Properties to set
27
+ */
28
+ constructor(p?: IPeer);
29
+
30
+ /** Peer addresses. */
31
+ public addresses: IAddress[];
32
+
33
+ /** Peer protocols. */
34
+ public protocols: string[];
35
+
36
+ /** Peer metadata. */
37
+ public metadata: IMetadata[];
38
+
39
+ /** Peer pubKey. */
40
+ public pubKey?: (Uint8Array|null);
41
+
42
+ /** Peer peerRecordEnvelope. */
43
+ public peerRecordEnvelope?: (Uint8Array|null);
44
+
45
+ /** Peer _pubKey. */
46
+ public _pubKey?: "pubKey";
47
+
48
+ /** Peer _peerRecordEnvelope. */
49
+ public _peerRecordEnvelope?: "peerRecordEnvelope";
50
+
51
+ /**
52
+ * Encodes the specified Peer message. Does not implicitly {@link Peer.verify|verify} messages.
53
+ * @param m Peer message or plain object to encode
54
+ * @param [w] Writer to encode to
55
+ * @returns Writer
56
+ */
57
+ public static encode(m: IPeer, w?: $protobuf.Writer): $protobuf.Writer;
58
+
59
+ /**
60
+ * Decodes a Peer message from the specified reader or buffer.
61
+ * @param r Reader or buffer to decode from
62
+ * @param [l] Message length if known beforehand
63
+ * @returns Peer
64
+ * @throws {Error} If the payload is not a reader or valid buffer
65
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
66
+ */
67
+ public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): Peer;
68
+
69
+ /**
70
+ * Creates a Peer message from a plain object. Also converts values to their respective internal types.
71
+ * @param d Plain object
72
+ * @returns Peer
73
+ */
74
+ public static fromObject(d: { [k: string]: any }): Peer;
75
+
76
+ /**
77
+ * Creates a plain object from a Peer message. Also converts values to other types if specified.
78
+ * @param m Peer
79
+ * @param [o] Conversion options
80
+ * @returns Plain object
81
+ */
82
+ public static toObject(m: Peer, o?: $protobuf.IConversionOptions): { [k: string]: any };
83
+
84
+ /**
85
+ * Converts this Peer to JSON.
86
+ * @returns JSON object
87
+ */
88
+ public toJSON(): { [k: string]: any };
89
+ }
90
+
91
+ /** Properties of an Address. */
92
+ export interface IAddress {
93
+
94
+ /** Address multiaddr */
95
+ multiaddr?: (Uint8Array|null);
96
+
97
+ /** Address isCertified */
98
+ isCertified?: (boolean|null);
99
+ }
100
+
101
+ /** Represents an Address. */
102
+ export class Address implements IAddress {
103
+
104
+ /**
105
+ * Constructs a new Address.
106
+ * @param [p] Properties to set
107
+ */
108
+ constructor(p?: IAddress);
109
+
110
+ /** Address multiaddr. */
111
+ public multiaddr: Uint8Array;
112
+
113
+ /** Address isCertified. */
114
+ public isCertified?: (boolean|null);
115
+
116
+ /** Address _isCertified. */
117
+ public _isCertified?: "isCertified";
118
+
119
+ /**
120
+ * Encodes the specified Address message. Does not implicitly {@link Address.verify|verify} messages.
121
+ * @param m Address message or plain object to encode
122
+ * @param [w] Writer to encode to
123
+ * @returns Writer
124
+ */
125
+ public static encode(m: IAddress, w?: $protobuf.Writer): $protobuf.Writer;
126
+
127
+ /**
128
+ * Decodes an Address message from the specified reader or buffer.
129
+ * @param r Reader or buffer to decode from
130
+ * @param [l] Message length if known beforehand
131
+ * @returns Address
132
+ * @throws {Error} If the payload is not a reader or valid buffer
133
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
134
+ */
135
+ public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): Address;
136
+
137
+ /**
138
+ * Creates an Address message from a plain object. Also converts values to their respective internal types.
139
+ * @param d Plain object
140
+ * @returns Address
141
+ */
142
+ public static fromObject(d: { [k: string]: any }): Address;
143
+
144
+ /**
145
+ * Creates a plain object from an Address message. Also converts values to other types if specified.
146
+ * @param m Address
147
+ * @param [o] Conversion options
148
+ * @returns Plain object
149
+ */
150
+ public static toObject(m: Address, o?: $protobuf.IConversionOptions): { [k: string]: any };
151
+
152
+ /**
153
+ * Converts this Address to JSON.
154
+ * @returns JSON object
155
+ */
156
+ public toJSON(): { [k: string]: any };
157
+ }
158
+
159
+ /** Properties of a Metadata. */
160
+ export interface IMetadata {
161
+
162
+ /** Metadata key */
163
+ key?: (string|null);
164
+
165
+ /** Metadata value */
166
+ value?: (Uint8Array|null);
167
+ }
168
+
169
+ /** Represents a Metadata. */
170
+ export class Metadata implements IMetadata {
171
+
172
+ /**
173
+ * Constructs a new Metadata.
174
+ * @param [p] Properties to set
175
+ */
176
+ constructor(p?: IMetadata);
177
+
178
+ /** Metadata key. */
179
+ public key: string;
180
+
181
+ /** Metadata value. */
182
+ public value: Uint8Array;
183
+
184
+ /**
185
+ * Encodes the specified Metadata message. Does not implicitly {@link Metadata.verify|verify} messages.
186
+ * @param m Metadata message or plain object to encode
187
+ * @param [w] Writer to encode to
188
+ * @returns Writer
189
+ */
190
+ public static encode(m: IMetadata, w?: $protobuf.Writer): $protobuf.Writer;
191
+
192
+ /**
193
+ * Decodes a Metadata message from the specified reader or buffer.
194
+ * @param r Reader or buffer to decode from
195
+ * @param [l] Message length if known beforehand
196
+ * @returns Metadata
197
+ * @throws {Error} If the payload is not a reader or valid buffer
198
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
199
+ */
200
+ public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): Metadata;
201
+
202
+ /**
203
+ * Creates a Metadata message from a plain object. Also converts values to their respective internal types.
204
+ * @param d Plain object
205
+ * @returns Metadata
206
+ */
207
+ public static fromObject(d: { [k: string]: any }): Metadata;
208
+
209
+ /**
210
+ * Creates a plain object from a Metadata message. Also converts values to other types if specified.
211
+ * @param m Metadata
212
+ * @param [o] Conversion options
213
+ * @returns Plain object
214
+ */
215
+ public static toObject(m: Metadata, o?: $protobuf.IConversionOptions): { [k: string]: any };
216
+
217
+ /**
218
+ * Converts this Metadata to JSON.
219
+ * @returns JSON object
220
+ */
221
+ public toJSON(): { [k: string]: any };
222
+ }