trac-msb 0.2.26 → 0.3.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 (136) hide show
  1. package/SECURITY.md +2 -2
  2. package/cli/commandHandler.js +317 -20
  3. package/cli/handlers.js +9 -1
  4. package/cli/interactive.js +4 -3
  5. package/cli/tokenSupplyAudit.js +90 -0
  6. package/msb.mjs +1 -0
  7. package/package.json +15 -6
  8. package/rpc/create_server.js +12 -3
  9. package/rpc/handlers.js +121 -0
  10. package/rpc/routes/v1.js +12 -0
  11. package/src/codecs/apply/applyOperationCodec.js +334 -0
  12. package/src/codecs/apply/applyOperations.generated.cjs +6380 -0
  13. package/src/codecs/consensus/v1/consensusV1.generated.cjs +3508 -0
  14. package/src/codecs/consensus/v1/consensusV1OperationCodec.js +161 -0
  15. package/src/codecs/consensus/v1/vdfConfigCodec.js +83 -0
  16. package/src/{utils/protobuf → codecs/network/v1}/networkV1.generated.cjs +664 -393
  17. package/src/codecs/network/v1/networkV1OperationCodec.js +25 -0
  18. package/src/codecs/protobufRuntime.cjs +95 -0
  19. package/src/codecs/state/escrowEntryCodec.js +45 -0
  20. package/src/codecs/state/state.generated.cjs +659 -0
  21. package/src/config/args.js +0 -1
  22. package/src/config/config.js +41 -7
  23. package/src/config/env.js +33 -9
  24. package/src/core/consensus/epochAppenderSelection/EpochAppenderSelectionError.js +55 -0
  25. package/src/core/consensus/epochAppenderSelection/EpochAppenderSelectionOperations.js +118 -0
  26. package/src/core/consensus/epochAppenderSelection/EpochAppenderSelector.js +1042 -0
  27. package/src/core/consensus/epochAppenderSelection/createEpochAppenderSelector.js +23 -0
  28. package/src/core/consensus/epochAppenderSelection/epochAppenderSelectionLedgerReader.js +274 -0
  29. package/src/core/consensus/epochAppenderSelection/epochAppenderSelectionState.js +488 -0
  30. package/src/core/consensus/epochAppenderSelection/epochAppenderSelectionStorage.js +93 -0
  31. package/src/core/consensus/quorum.js +11 -0
  32. package/src/core/consensus/services/EpochCoordinationRound.js +839 -0
  33. package/src/core/consensus/services/EpochCoordinatorOperations.js +211 -0
  34. package/src/core/consensus/services/EpochCoordinatorService.js +335 -0
  35. package/src/core/consensus/services/EpochRoundListeners.js +116 -0
  36. package/src/core/consensus/services/EpochStateMachine.js +141 -0
  37. package/src/core/consensus/services/VDFBare.js +291 -0
  38. package/src/core/consensus/services/VDFNode.js +111 -0
  39. package/src/core/consensus/services/VDFProgressWatchdog.js +79 -0
  40. package/src/core/consensus/services/VDFService.js +87 -0
  41. package/src/core/consensus/services/VDFServiceManager.js +147 -0
  42. package/src/core/consensus/services/createVDFService.js +16 -0
  43. package/src/core/consensus/services/vdf-guardian.js +32 -0
  44. package/src/core/consensus/services/vdf-worker.js +90 -0
  45. package/src/core/network/Network.js +327 -238
  46. package/src/core/network/protocols/consensus/IndexerMessages.js +72 -0
  47. package/src/core/network/protocols/consensus/v1/ConsensusV1ConnectionPolicy.js +57 -0
  48. package/src/core/network/protocols/consensus/v1/ConsensusV1MessageRouter.js +147 -0
  49. package/src/core/network/protocols/consensus/v1/ConsensusV1Protocol.js +72 -0
  50. package/src/core/network/protocols/consensus/v1/IndexerPendingRequestService.js +108 -0
  51. package/src/core/network/protocols/consensus/v1/V1ConsensusProtocolError.js +29 -0
  52. package/src/core/network/protocols/consensus/v1/handlers/V1EpochAppendOperationHandler.js +68 -0
  53. package/src/core/network/protocols/consensus/v1/handlers/V1EpochProofProposalOperationHandler.js +226 -0
  54. package/src/core/network/protocols/consensus/v1/validators/ConsensusValidationSchema.js +192 -0
  55. package/src/core/network/protocols/consensus/v1/validators/V1BaseConsensusOperation.js +428 -0
  56. package/src/core/network/protocols/consensus/v1/validators/V1EpochAppendReply.js +47 -0
  57. package/src/core/network/protocols/consensus/v1/validators/V1EpochAppendRequest.js +17 -0
  58. package/src/core/network/protocols/consensus/v1/validators/V1EpochProofProposalApproval.js +116 -0
  59. package/src/core/network/protocols/consensus/v1/validators/V1EpochProofProposalRequest.js +152 -0
  60. package/src/core/network/protocols/consensus/v1/validators/consensusValidationSchemaHelpers.js +145 -0
  61. package/src/core/network/protocols/shared/ConnectionOperationHandler.js +27 -0
  62. package/src/core/network/protocols/{NetworkMessages.js → validators/ValidatorMessages.js} +24 -14
  63. package/src/core/network/protocols/{ProtocolSession.js → validators/ValidatorProtocolSession.js} +22 -25
  64. package/src/core/network/protocols/{legacy/NetworkMessageRouter.js → validators/legacy/ValidatorLegacyMessageRouter.js} +6 -6
  65. package/src/core/network/protocols/{LegacyProtocol.js → validators/legacy/ValidatorLegacyProtocol.js} +9 -7
  66. package/src/core/network/protocols/{legacy → validators/legacy}/handlers/BaseStateOperationHandler.js +1 -1
  67. package/src/core/network/protocols/{legacy → validators/legacy}/handlers/LegacyGetRequestHandler.js +5 -5
  68. package/src/core/network/protocols/{legacy → validators/legacy}/handlers/LegacyRoleOperationHandler.js +5 -5
  69. package/src/core/network/protocols/{legacy → validators/legacy}/handlers/LegacySubnetworkOperationHandler.js +5 -5
  70. package/src/core/network/protocols/{legacy → validators/legacy}/handlers/LegacyTransferOperationHandler.js +5 -5
  71. package/src/core/network/protocols/{ProtocolInterface.js → validators/shared/ValidatorProtocolInterface.js} +5 -5
  72. package/src/core/network/protocols/{shared → validators/shared}/validators/PartialBootstrapDeploymentValidator.js +1 -1
  73. package/src/core/network/protocols/validators/shared/validators/PartialHtlcValidator.js +325 -0
  74. package/src/core/network/protocols/{shared → validators/shared}/validators/PartialOperationValidator.js +44 -21
  75. package/src/core/network/protocols/{shared → validators/shared}/validators/PartialRoleAccessValidator.js +3 -3
  76. package/src/core/network/protocols/{shared → validators/shared}/validators/PartialTransactionValidator.js +3 -3
  77. package/src/core/network/protocols/{shared → validators/shared}/validators/PartialTransferValidator.js +4 -4
  78. package/src/core/network/protocols/{v1 → validators/v1}/V1ProtocolError.js +1 -1
  79. package/src/core/network/{services/PendingRequestService.js → protocols/validators/v1/ValidatorPendingRequestService.js} +19 -82
  80. package/src/core/network/protocols/{v1/NetworkMessageRouter.js → validators/v1/ValidatorV1MessageRouter.js} +9 -9
  81. package/src/core/network/protocols/{V1Protocol.js → validators/v1/ValidatorV1Protocol.js} +10 -8
  82. package/src/core/network/protocols/{connectionPolicies.js → validators/v1/connectionPolicies.js} +1 -1
  83. package/src/core/network/protocols/{v1 → validators/v1}/handlers/V1BaseOperationHandler.js +6 -23
  84. package/src/core/network/protocols/{v1 → validators/v1}/handlers/V1BroadcastTransactionOperationHandler.js +14 -9
  85. package/src/core/network/protocols/{v1 → validators/v1}/handlers/V1LivenessOperationHandler.js +5 -4
  86. package/src/core/network/protocols/{v1 → validators/v1}/handlers/broadcastTransaction/BroadcastTransactionErrorMapper.js +3 -3
  87. package/src/core/network/protocols/{v1 → validators/v1}/handlers/broadcastTransaction/BroadcastTransactionOperationStrategies.js +44 -1
  88. package/src/core/network/protocols/{v1 → validators/v1}/handlers/broadcastTransaction/BroadcastTransactionPayloadUtils.js +1 -1
  89. package/src/core/network/protocols/{v1 → validators/v1}/validators/V1BaseOperation.js +19 -15
  90. package/src/core/network/protocols/{v1 → validators/v1}/validators/V1BroadcastTransactionRequest.js +2 -2
  91. package/src/core/network/protocols/{v1 → validators/v1}/validators/V1BroadcastTransactionResponse.js +34 -18
  92. package/src/core/network/protocols/{v1 → validators/v1}/validators/V1ValidationSchema.js +3 -3
  93. package/src/core/network/services/IndexerConnectionManager.js +88 -0
  94. package/src/core/network/services/TransactionPoolService.js +11 -18
  95. package/src/core/network/services/TransactionRateLimiterService.js +1 -1
  96. package/src/core/network/services/ValidatorConnectionManager.js +163 -0
  97. package/src/core/network/services/{MessageOrchestrator.js → ValidatorMessageOrchestrator.js} +34 -42
  98. package/src/core/network/services/ValidatorObserverService.js +21 -36
  99. package/src/core/network/shared/BasePendingRequestService.js +67 -0
  100. package/src/core/network/shared/PeerConnectionManager.js +185 -0
  101. package/src/core/state/State.js +1803 -159
  102. package/src/core/state/StateEventQueue.js +69 -0
  103. package/src/core/state/utils/address.js +10 -6
  104. package/src/core/state/utils/epochProof.js +109 -0
  105. package/src/core/state/utils/escrowEntry.js +178 -0
  106. package/src/core/state/validators/StateValidationSchema.js +757 -0
  107. package/src/core/state/validators/stateValidationRules.js +312 -0
  108. package/src/index.js +280 -67
  109. package/src/messages/consensus/v1/ConsensusMessageBuilder.js +368 -0
  110. package/src/messages/consensus/v1/ConsensusMessageDirector.js +142 -0
  111. package/src/messages/consensus/v1/consensusMessageFactory.js +12 -0
  112. package/src/messages/consensus/v1/epochAppendMessage.js +58 -0
  113. package/src/messages/network/v1/NetworkMessageBuilder.js +15 -7
  114. package/src/messages/state/ApplyStateMessageBuilder.js +499 -13
  115. package/src/messages/state/ApplyStateMessageDirector.js +261 -2
  116. package/src/utils/StateMachine.js +125 -0
  117. package/src/utils/applyOperations.js +45 -2
  118. package/src/utils/buffer.js +239 -59
  119. package/src/utils/consensusConfig.js +76 -0
  120. package/src/utils/constants.js +174 -73
  121. package/src/utils/helpers.js +0 -25
  122. package/src/utils/htlcLock.js +122 -0
  123. package/src/utils/logger.js +10 -4
  124. package/src/utils/migrationUtils.js +2 -1
  125. package/src/utils/normalizers.js +113 -0
  126. package/src/utils/scheduler/SchedulableService.js +107 -0
  127. package/src/utils/{Scheduler.js → scheduler/Scheduler.js} +56 -17
  128. package/src/core/network/services/ConnectionManager.js +0 -406
  129. package/src/utils/check.js +0 -525
  130. package/src/utils/protobuf/applyOperations.cjs +0 -1373
  131. package/src/utils/protobuf/operationHelpers.js +0 -81
  132. /package/src/core/network/protocols/{legacy → validators/legacy}/handlers/LegacyResponseHandler.js +0 -0
  133. /package/src/core/network/protocols/{legacy → validators/legacy}/validators/ValidatorResponse.js +0 -0
  134. /package/src/core/network/protocols/{legacy → validators/legacy}/validators/base/BaseResponse.js +0 -0
  135. /package/src/core/network/protocols/{v1 → validators/v1}/validators/V1LivenessRequest.js +0 -0
  136. /package/src/core/network/protocols/{v1 → validators/v1}/validators/V1LivenessResponse.js +0 -0
@@ -0,0 +1,659 @@
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
+ /** @typedef {ReturnType<typeof import("b4a").alloc>} B4aBuffer */
5
+
6
+ var $protobuf = require("../protobufRuntime.cjs");
7
+
8
+ // Common aliases
9
+ var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;
10
+
11
+ // Exported root namespace
12
+ var $root = $protobuf.roots["state"] || ($protobuf.roots["state"] = {});
13
+
14
+ $root.state = (function() {
15
+
16
+ /**
17
+ * Namespace state.
18
+ * @exports state
19
+ * @namespace
20
+ */
21
+ var state = {};
22
+
23
+ /**
24
+ * EscrowStatus enum.
25
+ * @name state.EscrowStatus
26
+ * @enum {number}
27
+ * @property {number} PENDING=0 PENDING value
28
+ * @property {number} CLAIMED=1 CLAIMED value
29
+ * @property {number} REFUNDED=2 REFUNDED value
30
+ */
31
+ state.EscrowStatus = (function() {
32
+ var valuesById = {}, values = Object.create(valuesById);
33
+ values[valuesById[0] = "PENDING"] = 0;
34
+ values[valuesById[1] = "CLAIMED"] = 1;
35
+ values[valuesById[2] = "REFUNDED"] = 2;
36
+ return values;
37
+ })();
38
+
39
+ state.EscrowEntry = (function() {
40
+
41
+ /**
42
+ * Properties of an EscrowEntry.
43
+ * @memberof state
44
+ * @interface IEscrowEntry
45
+ * @property {number|null} [version] EscrowEntry version
46
+ * @property {state.EscrowStatus|null} [status] EscrowEntry status
47
+ * @property {B4aBuffer|null} [amount] EscrowEntry amount
48
+ * @property {B4aBuffer|null} [additionalFeeAmount] EscrowEntry additionalFeeAmount
49
+ * @property {B4aBuffer|null} [lockerAddress] EscrowEntry lockerAddress
50
+ * @property {B4aBuffer|null} [claimRecipientAddress] EscrowEntry claimRecipientAddress
51
+ * @property {B4aBuffer|null} [refundRecipientAddress] EscrowEntry refundRecipientAddress
52
+ * @property {B4aBuffer|null} [additionalFeeRecipientAddress] EscrowEntry additionalFeeRecipientAddress
53
+ * @property {B4aBuffer|null} [lockId] EscrowEntry lockId
54
+ * @property {B4aBuffer|null} [hashLock] EscrowEntry hashLock
55
+ * @property {B4aBuffer|null} [preimage] EscrowEntry preimage
56
+ * @property {B4aBuffer|null} [metadata] EscrowEntry metadata
57
+ * @property {B4aBuffer|null} [refundEpoch] EscrowEntry refundEpoch
58
+ */
59
+
60
+ /**
61
+ * Constructs a new EscrowEntry.
62
+ * @memberof state
63
+ * @classdesc Represents an EscrowEntry.
64
+ * @implements IEscrowEntry
65
+ * @constructor
66
+ * @param {state.IEscrowEntry=} [properties] Properties to set
67
+ */
68
+ function EscrowEntry(properties) {
69
+ if (properties)
70
+ for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
71
+ if (properties[keys[i]] != null && keys[i] !== "__proto__")
72
+ this[keys[i]] = properties[keys[i]];
73
+ }
74
+
75
+ /**
76
+ * EscrowEntry version.
77
+ * @member {number} version
78
+ * @memberof state.EscrowEntry
79
+ * @instance
80
+ */
81
+ EscrowEntry.prototype.version = 0;
82
+
83
+ /**
84
+ * EscrowEntry status.
85
+ * @member {state.EscrowStatus|null|undefined} status
86
+ * @memberof state.EscrowEntry
87
+ * @instance
88
+ */
89
+ EscrowEntry.prototype.status = null;
90
+
91
+ /**
92
+ * EscrowEntry amount.
93
+ * @member {B4aBuffer} amount
94
+ * @memberof state.EscrowEntry
95
+ * @instance
96
+ */
97
+ EscrowEntry.prototype.amount = $util.newBuffer([]);
98
+
99
+ /**
100
+ * EscrowEntry additionalFeeAmount.
101
+ * @member {B4aBuffer} additionalFeeAmount
102
+ * @memberof state.EscrowEntry
103
+ * @instance
104
+ */
105
+ EscrowEntry.prototype.additionalFeeAmount = $util.newBuffer([]);
106
+
107
+ /**
108
+ * EscrowEntry lockerAddress.
109
+ * @member {B4aBuffer} lockerAddress
110
+ * @memberof state.EscrowEntry
111
+ * @instance
112
+ */
113
+ EscrowEntry.prototype.lockerAddress = $util.newBuffer([]);
114
+
115
+ /**
116
+ * EscrowEntry claimRecipientAddress.
117
+ * @member {B4aBuffer} claimRecipientAddress
118
+ * @memberof state.EscrowEntry
119
+ * @instance
120
+ */
121
+ EscrowEntry.prototype.claimRecipientAddress = $util.newBuffer([]);
122
+
123
+ /**
124
+ * EscrowEntry refundRecipientAddress.
125
+ * @member {B4aBuffer} refundRecipientAddress
126
+ * @memberof state.EscrowEntry
127
+ * @instance
128
+ */
129
+ EscrowEntry.prototype.refundRecipientAddress = $util.newBuffer([]);
130
+
131
+ /**
132
+ * EscrowEntry additionalFeeRecipientAddress.
133
+ * @member {B4aBuffer|null|undefined} additionalFeeRecipientAddress
134
+ * @memberof state.EscrowEntry
135
+ * @instance
136
+ */
137
+ EscrowEntry.prototype.additionalFeeRecipientAddress = null;
138
+
139
+ /**
140
+ * EscrowEntry lockId.
141
+ * @member {B4aBuffer} lockId
142
+ * @memberof state.EscrowEntry
143
+ * @instance
144
+ */
145
+ EscrowEntry.prototype.lockId = $util.newBuffer([]);
146
+
147
+ /**
148
+ * EscrowEntry hashLock.
149
+ * @member {B4aBuffer} hashLock
150
+ * @memberof state.EscrowEntry
151
+ * @instance
152
+ */
153
+ EscrowEntry.prototype.hashLock = $util.newBuffer([]);
154
+
155
+ /**
156
+ * EscrowEntry preimage.
157
+ * @member {B4aBuffer|null|undefined} preimage
158
+ * @memberof state.EscrowEntry
159
+ * @instance
160
+ */
161
+ EscrowEntry.prototype.preimage = null;
162
+
163
+ /**
164
+ * EscrowEntry metadata.
165
+ * @member {B4aBuffer|null|undefined} metadata
166
+ * @memberof state.EscrowEntry
167
+ * @instance
168
+ */
169
+ EscrowEntry.prototype.metadata = null;
170
+
171
+ /**
172
+ * EscrowEntry refundEpoch.
173
+ * @member {B4aBuffer} refundEpoch
174
+ * @memberof state.EscrowEntry
175
+ * @instance
176
+ */
177
+ EscrowEntry.prototype.refundEpoch = $util.newBuffer([]);
178
+
179
+ // OneOf field names bound to virtual getters and setters
180
+ var $oneOfFields;
181
+
182
+ // Virtual OneOf for proto3 optional field
183
+ Object.defineProperty(EscrowEntry.prototype, "_status", {
184
+ get: $util.oneOfGetter($oneOfFields = ["status"]),
185
+ set: $util.oneOfSetter($oneOfFields)
186
+ });
187
+
188
+ // Virtual OneOf for proto3 optional field
189
+ Object.defineProperty(EscrowEntry.prototype, "_additionalFeeRecipientAddress", {
190
+ get: $util.oneOfGetter($oneOfFields = ["additionalFeeRecipientAddress"]),
191
+ set: $util.oneOfSetter($oneOfFields)
192
+ });
193
+
194
+ // Virtual OneOf for proto3 optional field
195
+ Object.defineProperty(EscrowEntry.prototype, "_preimage", {
196
+ get: $util.oneOfGetter($oneOfFields = ["preimage"]),
197
+ set: $util.oneOfSetter($oneOfFields)
198
+ });
199
+
200
+ // Virtual OneOf for proto3 optional field
201
+ Object.defineProperty(EscrowEntry.prototype, "_metadata", {
202
+ get: $util.oneOfGetter($oneOfFields = ["metadata"]),
203
+ set: $util.oneOfSetter($oneOfFields)
204
+ });
205
+
206
+ /**
207
+ * Creates a new EscrowEntry instance using the specified properties.
208
+ * @function create
209
+ * @memberof state.EscrowEntry
210
+ * @static
211
+ * @param {state.IEscrowEntry=} [properties] Properties to set
212
+ * @returns {state.EscrowEntry} EscrowEntry instance
213
+ */
214
+ EscrowEntry.create = function create(properties) {
215
+ return new EscrowEntry(properties);
216
+ };
217
+
218
+ /**
219
+ * Encodes the specified EscrowEntry message. Does not implicitly {@link state.EscrowEntry.verify|verify} messages.
220
+ * @function encode
221
+ * @memberof state.EscrowEntry
222
+ * @static
223
+ * @param {state.IEscrowEntry} message EscrowEntry message or plain object to encode
224
+ * @param {$protobuf.Writer} [writer] Writer to encode to
225
+ * @returns {$protobuf.Writer} Writer
226
+ */
227
+ EscrowEntry.encode = function encode(message, writer, q) {
228
+ writer = $Writer.create(writer);
229
+ if (q === undefined)
230
+ q = 0;
231
+ if (q > $util.recursionLimit)
232
+ throw Error("max depth exceeded");
233
+ if (message.version != null && Object.hasOwnProperty.call(message, "version"))
234
+ writer.uint32(/* id 1, wireType 0 =*/8).uint32(message.version);
235
+ if (message.status != null && Object.hasOwnProperty.call(message, "status"))
236
+ writer.uint32(/* id 2, wireType 0 =*/16).int32(message.status);
237
+ if (message.amount != null && Object.hasOwnProperty.call(message, "amount"))
238
+ writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.amount);
239
+ if (message.additionalFeeAmount != null && Object.hasOwnProperty.call(message, "additionalFeeAmount"))
240
+ writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.additionalFeeAmount);
241
+ if (message.lockerAddress != null && Object.hasOwnProperty.call(message, "lockerAddress"))
242
+ writer.uint32(/* id 5, wireType 2 =*/42).bytes(message.lockerAddress);
243
+ if (message.claimRecipientAddress != null && Object.hasOwnProperty.call(message, "claimRecipientAddress"))
244
+ writer.uint32(/* id 6, wireType 2 =*/50).bytes(message.claimRecipientAddress);
245
+ if (message.refundRecipientAddress != null && Object.hasOwnProperty.call(message, "refundRecipientAddress"))
246
+ writer.uint32(/* id 7, wireType 2 =*/58).bytes(message.refundRecipientAddress);
247
+ if (message.additionalFeeRecipientAddress != null && Object.hasOwnProperty.call(message, "additionalFeeRecipientAddress"))
248
+ writer.uint32(/* id 8, wireType 2 =*/66).bytes(message.additionalFeeRecipientAddress);
249
+ if (message.lockId != null && Object.hasOwnProperty.call(message, "lockId"))
250
+ writer.uint32(/* id 9, wireType 2 =*/74).bytes(message.lockId);
251
+ if (message.hashLock != null && Object.hasOwnProperty.call(message, "hashLock"))
252
+ writer.uint32(/* id 10, wireType 2 =*/82).bytes(message.hashLock);
253
+ if (message.preimage != null && Object.hasOwnProperty.call(message, "preimage"))
254
+ writer.uint32(/* id 11, wireType 2 =*/90).bytes(message.preimage);
255
+ if (message.metadata != null && Object.hasOwnProperty.call(message, "metadata"))
256
+ writer.uint32(/* id 12, wireType 2 =*/98).bytes(message.metadata);
257
+ if (message.refundEpoch != null && Object.hasOwnProperty.call(message, "refundEpoch"))
258
+ writer.uint32(/* id 13, wireType 2 =*/106).bytes(message.refundEpoch);
259
+ return writer;
260
+ };
261
+
262
+ /**
263
+ * Encodes the specified EscrowEntry message, length delimited. Does not implicitly {@link state.EscrowEntry.verify|verify} messages.
264
+ * @function encodeDelimited
265
+ * @memberof state.EscrowEntry
266
+ * @static
267
+ * @param {state.IEscrowEntry} message EscrowEntry message or plain object to encode
268
+ * @param {$protobuf.Writer} [writer] Writer to encode to
269
+ * @returns {$protobuf.Writer} Writer
270
+ */
271
+ EscrowEntry.encodeDelimited = function encodeDelimited(message, writer) {
272
+ return this.encode(message, writer && writer.len ? writer.fork() : writer).ldelim();
273
+ };
274
+
275
+ /**
276
+ * Decodes an EscrowEntry message from the specified reader or buffer.
277
+ * @function decode
278
+ * @memberof state.EscrowEntry
279
+ * @static
280
+ * @param {$protobuf.Reader|B4aBuffer} reader Reader or buffer to decode from
281
+ * @param {number} [length] Message length if known beforehand
282
+ * @returns {state.EscrowEntry} EscrowEntry
283
+ * @throws {Error} If the payload is not a reader or valid buffer
284
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
285
+ */
286
+ EscrowEntry.decode = function decode(reader, length, error, long) {
287
+ reader = $Reader.create(reader);
288
+ if (long === undefined)
289
+ long = 0;
290
+ if (long > $Reader.recursionLimit)
291
+ throw Error("maximum nesting depth exceeded");
292
+ var end = length === undefined ? reader.len : reader.pos + length, message = new $root.state.EscrowEntry();
293
+ while (reader.pos < end) {
294
+ var tag = reader.uint32();
295
+ if (tag === error)
296
+ break;
297
+ switch (tag >>> 3) {
298
+ case 1: {
299
+ message.version = reader.uint32();
300
+ break;
301
+ }
302
+ case 2: {
303
+ message.status = reader.int32();
304
+ break;
305
+ }
306
+ case 3: {
307
+ message.amount = $util.bytesFrom(reader.bytes());
308
+ break;
309
+ }
310
+ case 4: {
311
+ message.additionalFeeAmount = $util.bytesFrom(reader.bytes());
312
+ break;
313
+ }
314
+ case 5: {
315
+ message.lockerAddress = $util.bytesFrom(reader.bytes());
316
+ break;
317
+ }
318
+ case 6: {
319
+ message.claimRecipientAddress = $util.bytesFrom(reader.bytes());
320
+ break;
321
+ }
322
+ case 7: {
323
+ message.refundRecipientAddress = $util.bytesFrom(reader.bytes());
324
+ break;
325
+ }
326
+ case 8: {
327
+ message.additionalFeeRecipientAddress = $util.bytesFrom(reader.bytes());
328
+ break;
329
+ }
330
+ case 9: {
331
+ message.lockId = $util.bytesFrom(reader.bytes());
332
+ break;
333
+ }
334
+ case 10: {
335
+ message.hashLock = $util.bytesFrom(reader.bytes());
336
+ break;
337
+ }
338
+ case 11: {
339
+ message.preimage = $util.bytesFrom(reader.bytes());
340
+ break;
341
+ }
342
+ case 12: {
343
+ message.metadata = $util.bytesFrom(reader.bytes());
344
+ break;
345
+ }
346
+ case 13: {
347
+ message.refundEpoch = $util.bytesFrom(reader.bytes());
348
+ break;
349
+ }
350
+ default:
351
+ reader.skipType(tag & 7, long);
352
+ break;
353
+ }
354
+ }
355
+ return message;
356
+ };
357
+
358
+ /**
359
+ * Decodes an EscrowEntry message from the specified reader or buffer, length delimited.
360
+ * @function decodeDelimited
361
+ * @memberof state.EscrowEntry
362
+ * @static
363
+ * @param {$protobuf.Reader|B4aBuffer} reader Reader or buffer to decode from
364
+ * @returns {state.EscrowEntry} EscrowEntry
365
+ * @throws {Error} If the payload is not a reader or valid buffer
366
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
367
+ */
368
+ EscrowEntry.decodeDelimited = function decodeDelimited(reader) {
369
+ reader = $Reader.create(reader);
370
+ return this.decode(reader, reader.uint32());
371
+ };
372
+
373
+ /**
374
+ * Verifies an EscrowEntry message.
375
+ * @function verify
376
+ * @memberof state.EscrowEntry
377
+ * @static
378
+ * @param {Object.<string,*>} message Plain object to verify
379
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
380
+ */
381
+ EscrowEntry.verify = function verify(message, long) {
382
+ if (typeof message !== "object" || message === null)
383
+ return "object expected";
384
+ if (long === undefined)
385
+ long = 0;
386
+ if (long > $util.recursionLimit)
387
+ return "maximum nesting depth exceeded";
388
+ var properties = {};
389
+ if (message.version != null && Object.hasOwnProperty.call(message, "version"))
390
+ if (!$util.isInteger(message.version))
391
+ return "version: integer expected";
392
+ if (message.status != null && Object.hasOwnProperty.call(message, "status")) {
393
+ properties._status = 1;
394
+ switch (message.status) {
395
+ default:
396
+ return "status: enum value expected";
397
+ case 0:
398
+ case 1:
399
+ case 2:
400
+ break;
401
+ }
402
+ }
403
+ if (message.amount != null && Object.hasOwnProperty.call(message, "amount"))
404
+ if (!$util.isBytes(message.amount))
405
+ return "amount: buffer expected";
406
+ if (message.additionalFeeAmount != null && Object.hasOwnProperty.call(message, "additionalFeeAmount"))
407
+ if (!$util.isBytes(message.additionalFeeAmount))
408
+ return "additionalFeeAmount: buffer expected";
409
+ if (message.lockerAddress != null && Object.hasOwnProperty.call(message, "lockerAddress"))
410
+ if (!$util.isBytes(message.lockerAddress))
411
+ return "lockerAddress: buffer expected";
412
+ if (message.claimRecipientAddress != null && Object.hasOwnProperty.call(message, "claimRecipientAddress"))
413
+ if (!$util.isBytes(message.claimRecipientAddress))
414
+ return "claimRecipientAddress: buffer expected";
415
+ if (message.refundRecipientAddress != null && Object.hasOwnProperty.call(message, "refundRecipientAddress"))
416
+ if (!$util.isBytes(message.refundRecipientAddress))
417
+ return "refundRecipientAddress: buffer expected";
418
+ if (message.additionalFeeRecipientAddress != null && Object.hasOwnProperty.call(message, "additionalFeeRecipientAddress")) {
419
+ properties._additionalFeeRecipientAddress = 1;
420
+ if (!$util.isBytes(message.additionalFeeRecipientAddress))
421
+ return "additionalFeeRecipientAddress: buffer expected";
422
+ }
423
+ if (message.lockId != null && Object.hasOwnProperty.call(message, "lockId"))
424
+ if (!$util.isBytes(message.lockId))
425
+ return "lockId: buffer expected";
426
+ if (message.hashLock != null && Object.hasOwnProperty.call(message, "hashLock"))
427
+ if (!$util.isBytes(message.hashLock))
428
+ return "hashLock: buffer expected";
429
+ if (message.preimage != null && Object.hasOwnProperty.call(message, "preimage")) {
430
+ properties._preimage = 1;
431
+ if (!$util.isBytes(message.preimage))
432
+ return "preimage: buffer expected";
433
+ }
434
+ if (message.metadata != null && Object.hasOwnProperty.call(message, "metadata")) {
435
+ properties._metadata = 1;
436
+ if (!$util.isBytes(message.metadata))
437
+ return "metadata: buffer expected";
438
+ }
439
+ if (message.refundEpoch != null && Object.hasOwnProperty.call(message, "refundEpoch"))
440
+ if (!$util.isBytes(message.refundEpoch))
441
+ return "refundEpoch: buffer expected";
442
+ return null;
443
+ };
444
+
445
+ /**
446
+ * Creates an EscrowEntry message from a plain object. Also converts values to their respective internal types.
447
+ * @function fromObject
448
+ * @memberof state.EscrowEntry
449
+ * @static
450
+ * @param {Object.<string,*>} object Plain object
451
+ * @returns {state.EscrowEntry} EscrowEntry
452
+ */
453
+ EscrowEntry.fromObject = function fromObject(object, long) {
454
+ if (object instanceof $root.state.EscrowEntry)
455
+ object = Object.assign({}, object);
456
+ if (!$util.isObject(object))
457
+ throw TypeError(".state.EscrowEntry: object expected");
458
+ if (long === undefined)
459
+ long = 0;
460
+ if (long > $util.recursionLimit)
461
+ throw Error("maximum nesting depth exceeded");
462
+ var message = new $root.state.EscrowEntry();
463
+ if (object.version != null)
464
+ message.version = object.version >>> 0;
465
+ switch (object.status) {
466
+ default:
467
+ if (typeof object.status === "number") {
468
+ message.status = object.status;
469
+ break;
470
+ }
471
+ break;
472
+ case "PENDING":
473
+ case 0:
474
+ message.status = 0;
475
+ break;
476
+ case "CLAIMED":
477
+ case 1:
478
+ message.status = 1;
479
+ break;
480
+ case "REFUNDED":
481
+ case 2:
482
+ message.status = 2;
483
+ break;
484
+ }
485
+ if (object.amount != null)
486
+ message.amount = $util.bytesFrom(object.amount);
487
+ if (object.additionalFeeAmount != null)
488
+ message.additionalFeeAmount = $util.bytesFrom(object.additionalFeeAmount);
489
+ if (object.lockerAddress != null)
490
+ message.lockerAddress = $util.bytesFrom(object.lockerAddress);
491
+ if (object.claimRecipientAddress != null)
492
+ message.claimRecipientAddress = $util.bytesFrom(object.claimRecipientAddress);
493
+ if (object.refundRecipientAddress != null)
494
+ message.refundRecipientAddress = $util.bytesFrom(object.refundRecipientAddress);
495
+ if (object.additionalFeeRecipientAddress != null)
496
+ message.additionalFeeRecipientAddress = $util.bytesFrom(object.additionalFeeRecipientAddress);
497
+ if (object.lockId != null)
498
+ message.lockId = $util.bytesFrom(object.lockId);
499
+ if (object.hashLock != null)
500
+ message.hashLock = $util.bytesFrom(object.hashLock);
501
+ if (object.preimage != null)
502
+ message.preimage = $util.bytesFrom(object.preimage);
503
+ if (object.metadata != null)
504
+ message.metadata = $util.bytesFrom(object.metadata);
505
+ if (object.refundEpoch != null)
506
+ message.refundEpoch = $util.bytesFrom(object.refundEpoch);
507
+ return message;
508
+ };
509
+
510
+ /**
511
+ * Creates a plain object from an EscrowEntry message. Also converts values to other types if specified.
512
+ * @function toObject
513
+ * @memberof state.EscrowEntry
514
+ * @static
515
+ * @param {state.EscrowEntry} message EscrowEntry
516
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
517
+ * @returns {Object.<string,*>} Plain object
518
+ */
519
+ EscrowEntry.toObject = function toObject(message, options, q) {
520
+ if (!options)
521
+ options = {};
522
+ if (q === undefined)
523
+ q = 0;
524
+ if (q > $util.recursionLimit)
525
+ throw Error("max depth exceeded");
526
+ var object = {};
527
+ if (options.defaults) {
528
+ object.version = 0;
529
+ if (options.bytes === String)
530
+ object.amount = "";
531
+ else {
532
+ object.amount = [];
533
+ if (options.bytes !== Array)
534
+ object.amount = $util.newBuffer(object.amount);
535
+ }
536
+ if (options.bytes === String)
537
+ object.additionalFeeAmount = "";
538
+ else {
539
+ object.additionalFeeAmount = [];
540
+ if (options.bytes !== Array)
541
+ object.additionalFeeAmount = $util.newBuffer(object.additionalFeeAmount);
542
+ }
543
+ if (options.bytes === String)
544
+ object.lockerAddress = "";
545
+ else {
546
+ object.lockerAddress = [];
547
+ if (options.bytes !== Array)
548
+ object.lockerAddress = $util.newBuffer(object.lockerAddress);
549
+ }
550
+ if (options.bytes === String)
551
+ object.claimRecipientAddress = "";
552
+ else {
553
+ object.claimRecipientAddress = [];
554
+ if (options.bytes !== Array)
555
+ object.claimRecipientAddress = $util.newBuffer(object.claimRecipientAddress);
556
+ }
557
+ if (options.bytes === String)
558
+ object.refundRecipientAddress = "";
559
+ else {
560
+ object.refundRecipientAddress = [];
561
+ if (options.bytes !== Array)
562
+ object.refundRecipientAddress = $util.newBuffer(object.refundRecipientAddress);
563
+ }
564
+ if (options.bytes === String)
565
+ object.lockId = "";
566
+ else {
567
+ object.lockId = [];
568
+ if (options.bytes !== Array)
569
+ object.lockId = $util.newBuffer(object.lockId);
570
+ }
571
+ if (options.bytes === String)
572
+ object.hashLock = "";
573
+ else {
574
+ object.hashLock = [];
575
+ if (options.bytes !== Array)
576
+ object.hashLock = $util.newBuffer(object.hashLock);
577
+ }
578
+ if (options.bytes === String)
579
+ object.refundEpoch = "";
580
+ else {
581
+ object.refundEpoch = [];
582
+ if (options.bytes !== Array)
583
+ object.refundEpoch = $util.newBuffer(object.refundEpoch);
584
+ }
585
+ }
586
+ if (message.version != null && Object.hasOwnProperty.call(message, "version"))
587
+ object.version = message.version;
588
+ if (message.status != null && Object.hasOwnProperty.call(message, "status")) {
589
+ object.status = options.enums === String ? $root.state.EscrowStatus[message.status] === undefined ? message.status : $root.state.EscrowStatus[message.status] : message.status;
590
+ if (options.oneofs)
591
+ object._status = "status";
592
+ }
593
+ if (message.amount != null && Object.hasOwnProperty.call(message, "amount"))
594
+ object.amount = $util.bytesTo(message.amount, options);
595
+ if (message.additionalFeeAmount != null && Object.hasOwnProperty.call(message, "additionalFeeAmount"))
596
+ object.additionalFeeAmount = $util.bytesTo(message.additionalFeeAmount, options);
597
+ if (message.lockerAddress != null && Object.hasOwnProperty.call(message, "lockerAddress"))
598
+ object.lockerAddress = $util.bytesTo(message.lockerAddress, options);
599
+ if (message.claimRecipientAddress != null && Object.hasOwnProperty.call(message, "claimRecipientAddress"))
600
+ object.claimRecipientAddress = $util.bytesTo(message.claimRecipientAddress, options);
601
+ if (message.refundRecipientAddress != null && Object.hasOwnProperty.call(message, "refundRecipientAddress"))
602
+ object.refundRecipientAddress = $util.bytesTo(message.refundRecipientAddress, options);
603
+ if (message.additionalFeeRecipientAddress != null && Object.hasOwnProperty.call(message, "additionalFeeRecipientAddress")) {
604
+ object.additionalFeeRecipientAddress = $util.bytesTo(message.additionalFeeRecipientAddress, options);
605
+ if (options.oneofs)
606
+ object._additionalFeeRecipientAddress = "additionalFeeRecipientAddress";
607
+ }
608
+ if (message.lockId != null && Object.hasOwnProperty.call(message, "lockId"))
609
+ object.lockId = $util.bytesTo(message.lockId, options);
610
+ if (message.hashLock != null && Object.hasOwnProperty.call(message, "hashLock"))
611
+ object.hashLock = $util.bytesTo(message.hashLock, options);
612
+ if (message.preimage != null && Object.hasOwnProperty.call(message, "preimage")) {
613
+ object.preimage = $util.bytesTo(message.preimage, options);
614
+ if (options.oneofs)
615
+ object._preimage = "preimage";
616
+ }
617
+ if (message.metadata != null && Object.hasOwnProperty.call(message, "metadata")) {
618
+ object.metadata = $util.bytesTo(message.metadata, options);
619
+ if (options.oneofs)
620
+ object._metadata = "metadata";
621
+ }
622
+ if (message.refundEpoch != null && Object.hasOwnProperty.call(message, "refundEpoch"))
623
+ object.refundEpoch = $util.bytesTo(message.refundEpoch, options);
624
+ return object;
625
+ };
626
+
627
+ /**
628
+ * Converts this EscrowEntry to JSON.
629
+ * @function toJSON
630
+ * @memberof state.EscrowEntry
631
+ * @instance
632
+ * @returns {Object.<string,*>} JSON object
633
+ */
634
+ EscrowEntry.prototype.toJSON = function toJSON() {
635
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
636
+ };
637
+
638
+ /**
639
+ * Gets the default type url for EscrowEntry
640
+ * @function getTypeUrl
641
+ * @memberof state.EscrowEntry
642
+ * @static
643
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
644
+ * @returns {string} The default type url
645
+ */
646
+ EscrowEntry.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
647
+ if (typeUrlPrefix === undefined) {
648
+ typeUrlPrefix = "type.googleapis.com";
649
+ }
650
+ return typeUrlPrefix + "/state.EscrowEntry";
651
+ };
652
+
653
+ return EscrowEntry;
654
+ })();
655
+
656
+ return state;
657
+ })();
658
+
659
+ module.exports = $root;
@@ -88,6 +88,5 @@ export const resolveConfig = () => {
88
88
  };
89
89
 
90
90
  const options = runRpc ? rpc : { storesDirectory };
91
-
92
91
  return createConfig(selectedEnv, options);
93
92
  };