@super-protocol/sdk-js 0.15.0 → 0.15.2-beta.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 (83) hide show
  1. package/build/TIIGenerator.js +129 -239
  2. package/build/connectors/BaseConnector.js +17 -47
  3. package/build/connectors/BlockchainConnector.js +222 -348
  4. package/build/connectors/BlockchainEventsListener.js +38 -92
  5. package/build/contracts/app.json +466 -35
  6. package/build/crypto/Crypto.js +63 -135
  7. package/build/crypto/index.js +1 -1
  8. package/build/crypto/nodejs/AES.js +62 -119
  9. package/build/crypto/nodejs/ARIA.js +61 -118
  10. package/build/crypto/nodejs/ECIES.js +51 -87
  11. package/build/crypto/nodejs/NativeCrypto.js +64 -118
  12. package/build/crypto/nodejs/RSA-Hybrid.js +54 -113
  13. package/build/index.d.ts +5 -0
  14. package/build/index.js +14 -2
  15. package/build/logger.d.ts +3 -1
  16. package/build/logger.js +2 -2
  17. package/build/models/EtlModel.js +65 -114
  18. package/build/models/Offer.js +227 -462
  19. package/build/models/Order.d.ts +4 -0
  20. package/build/models/Order.js +326 -559
  21. package/build/models/Provider.d.ts +2 -0
  22. package/build/models/Provider.js +74 -153
  23. package/build/models/TCB.js +67 -171
  24. package/build/models/TeeOffer.d.ts +1 -0
  25. package/build/models/TeeOffer.js +389 -731
  26. package/build/proto/Compression.js +20 -21
  27. package/build/proto/TRI.js +46 -50
  28. package/build/proto/TeeProperties.js +60 -66
  29. package/build/providers/storage/ChunksDownloadDecorator.d.ts +1 -1
  30. package/build/providers/storage/ChunksDownloadDecorator.js +125 -235
  31. package/build/providers/storage/IStorageProvider.d.ts +1 -1
  32. package/build/providers/storage/S3StorageProvider.js +173 -298
  33. package/build/providers/storage/StorageAdapter.d.ts +60 -0
  34. package/build/providers/storage/StorageAdapter.js +322 -0
  35. package/build/providers/storage/StorageContentWriter.d.ts +46 -0
  36. package/build/providers/storage/StorageContentWriter.js +182 -0
  37. package/build/providers/storage/StorageKeyValueAdapter.d.ts +23 -0
  38. package/build/providers/storage/StorageKeyValueAdapter.js +157 -0
  39. package/build/providers/storage/StorageMetadataReader.d.ts +20 -0
  40. package/build/providers/storage/StorageMetadataReader.js +67 -0
  41. package/build/providers/storage/StorjAdapter.d.ts +19 -0
  42. package/build/providers/storage/StorjAdapter.js +73 -0
  43. package/build/providers/storage/StorjStorageProvider.js +138 -315
  44. package/build/providers/storage/getStorageProvider.js +7 -7
  45. package/build/providers/storage/types.d.ts +7 -0
  46. package/build/providers/storage/types.js +2 -0
  47. package/build/staticModels/ActiveOffers.js +32 -100
  48. package/build/staticModels/ActiveOrders.js +42 -120
  49. package/build/staticModels/BaseStaticModel.js +7 -10
  50. package/build/staticModels/Consensus.d.ts +4 -1
  51. package/build/staticModels/Consensus.js +164 -220
  52. package/build/staticModels/Deposits.js +109 -201
  53. package/build/staticModels/Marks.js +21 -82
  54. package/build/staticModels/ModelPackager.js +34 -84
  55. package/build/staticModels/Offers.js +140 -266
  56. package/build/staticModels/Orders.d.ts +1 -0
  57. package/build/staticModels/Orders.js +286 -429
  58. package/build/staticModels/ProviderRegistry.js +114 -225
  59. package/build/staticModels/Superpro.js +17 -63
  60. package/build/staticModels/SuperproToken.js +90 -169
  61. package/build/staticModels/TeeOffers.js +220 -416
  62. package/build/store.js +2 -2
  63. package/build/types/HardwareInfo.js +2 -2
  64. package/build/types/Order.js +4 -4
  65. package/build/types/Provider.js +1 -1
  66. package/build/types/TeeOfferInfo.js +1 -1
  67. package/build/types/TeeOfferOption.js +2 -2
  68. package/build/types/TeeOfferSlot.js +2 -2
  69. package/build/types/ValueOfferSlot.js +3 -3
  70. package/build/utils/Monitoring.js +24 -28
  71. package/build/utils/NonceTracker.js +56 -121
  72. package/build/utils/PubSub.d.ts +9 -0
  73. package/build/utils/PubSub.js +36 -0
  74. package/build/utils/TxManager.js +121 -215
  75. package/build/utils/compressors/GzipCompressor.js +13 -50
  76. package/build/utils/compressors/UncompressedCompressor.js +10 -13
  77. package/build/utils/helpers/tryWithInterval.js +34 -78
  78. package/build/utils/resourceLoaders/BaseResourceLoader.js +26 -78
  79. package/build/utils/resourceLoaders/StorageProviderLoader.js +33 -97
  80. package/build/utils/resourceLoaders/UrlResourceLoader.js +29 -93
  81. package/build/utils/resourceLoaders/getResourceLoader.js +6 -6
  82. package/build/utils.js +60 -105
  83. package/package.json +4 -1
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
14
3
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
15
4
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -25,53 +14,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
25
14
  step((generator = generator.apply(thisArg, _arguments || [])).next());
26
15
  });
27
16
  };
28
- var __generator = (this && this.__generator) || function (thisArg, body) {
29
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
30
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
31
- function verb(n) { return function (v) { return step([n, v]); }; }
32
- function step(op) {
33
- if (f) throw new TypeError("Generator is already executing.");
34
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
35
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
36
- if (y = 0, t) op = [op[0] & 2, t.value];
37
- switch (op[0]) {
38
- case 0: case 1: t = op; break;
39
- case 4: _.label++; return { value: op[1], done: false };
40
- case 5: _.label++; y = op[1]; op = [0]; continue;
41
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
42
- default:
43
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
44
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
45
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
46
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
47
- if (t[2]) _.ops.pop();
48
- _.trys.pop(); continue;
49
- }
50
- op = body.call(thisArg, _);
51
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
52
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
53
- }
54
- };
55
17
  var __importDefault = (this && this.__importDefault) || function (mod) {
56
18
  return (mod && mod.__esModule) ? mod : { "default": mod };
57
19
  };
58
20
  Object.defineProperty(exports, "__esModule", { value: true });
59
- var Order_1 = require("../types/Order");
60
- var logger_1 = __importDefault(require("../logger"));
61
- var app_json_1 = __importDefault(require("../contracts/app.json"));
62
- var store_1 = __importDefault(require("../store"));
63
- var utils_1 = require("../utils");
64
- var Origins_1 = require("../types/Origins");
65
- var utils_2 = require("ethers/lib/utils");
66
- var BlockchainConnector_1 = __importDefault(require("../connectors/BlockchainConnector"));
67
- var Superpro_1 = __importDefault(require("../staticModels/Superpro"));
68
- var TxManager_1 = __importDefault(require("../utils/TxManager"));
69
- var BlockchainEventsListener_1 = __importDefault(require("../connectors/BlockchainEventsListener"));
70
- var TeeOffers_1 = __importDefault(require("../staticModels/TeeOffers"));
71
- var helpers_1 = require("../utils/helpers");
72
- var constants_1 = require("../constants");
73
- var Order = /** @class */ (function () {
74
- function Order(orderId) {
21
+ const Order_1 = require("../types/Order");
22
+ const logger_1 = __importDefault(require("../logger"));
23
+ const app_json_1 = __importDefault(require("../contracts/app.json"));
24
+ const store_1 = __importDefault(require("../store"));
25
+ const utils_1 = require("../utils");
26
+ const Origins_1 = require("../types/Origins");
27
+ const utils_2 = require("ethers/lib/utils");
28
+ const BlockchainConnector_1 = __importDefault(require("../connectors/BlockchainConnector"));
29
+ const Superpro_1 = __importDefault(require("../staticModels/Superpro"));
30
+ const TxManager_1 = __importDefault(require("../utils/TxManager"));
31
+ const BlockchainEventsListener_1 = __importDefault(require("../connectors/BlockchainEventsListener"));
32
+ const TeeOffers_1 = __importDefault(require("../staticModels/TeeOffers"));
33
+ const helpers_1 = require("../utils/helpers");
34
+ const constants_1 = require("../constants");
35
+ class Order {
36
+ constructor(orderId) {
75
37
  this.id = orderId;
76
38
  if (!Order.contract) {
77
39
  Order.contract = BlockchainConnector_1.default.getInstance().getContract();
@@ -81,456 +43,288 @@ var Order = /** @class */ (function () {
81
43
  /**
82
44
  * Checks if contract has been initialized, if not - initialize contract
83
45
  */
84
- Order.prototype.checkInitOrder = function (transactionOptions) {
46
+ checkInitOrder(transactionOptions) {
85
47
  if (transactionOptions === null || transactionOptions === void 0 ? void 0 : transactionOptions.web3) {
86
48
  return new transactionOptions.web3.eth.Contract(app_json_1.default.abi, Superpro_1.default.address);
87
49
  }
88
- };
50
+ }
89
51
  /**
90
52
  * Check if order exist
91
53
  */
92
- Order.prototype.isExist = function () {
93
- return __awaiter(this, void 0, void 0, function () {
94
- return __generator(this, function (_a) {
95
- switch (_a.label) {
96
- case 0: return [4 /*yield*/, Order.contract.methods.isOrderValid(this.id).call()];
97
- case 1: return [2 /*return*/, _a.sent()];
98
- }
99
- });
54
+ isExist() {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ return yield Order.contract.methods.isOrderValid(this.id).call();
100
57
  });
101
- };
58
+ }
102
59
  /**
103
60
  * Check if order is in `processing` state
104
61
  */
105
- Order.prototype.isOrderProcessing = function () {
106
- return __awaiter(this, void 0, void 0, function () {
107
- return __generator(this, function (_a) {
108
- switch (_a.label) {
109
- case 0: return [4 /*yield*/, Order.contract.methods.isOrderProcessing(this.id).call()];
110
- case 1: return [2 /*return*/, _a.sent()];
111
- }
112
- });
62
+ isOrderProcessing() {
63
+ return __awaiter(this, void 0, void 0, function* () {
64
+ return yield Order.contract.methods.isOrderProcessing(this.id).call();
113
65
  });
114
- };
66
+ }
67
+ /**
68
+ * Function for fetching avaliable for unlock order profit.
69
+ */
70
+ isOrderProfitAvailable() {
71
+ return __awaiter(this, void 0, void 0, function* () {
72
+ const [, profit] = yield Order.contract.methods.isOrderProfitAvailable(this.id).call();
73
+ return profit;
74
+ });
75
+ }
115
76
  /**
116
77
  * Function for fetching order price
117
78
  */
118
- Order.prototype.calculateCurrentPrice = function () {
119
- return __awaiter(this, void 0, void 0, function () {
120
- return __generator(this, function (_a) {
121
- switch (_a.label) {
122
- case 0: return [4 /*yield*/, Order.contract.methods.calculateOrderCurrentPrice(this.id).call()];
123
- case 1: return [2 /*return*/, _a.sent()];
124
- }
125
- });
79
+ calculateCurrentPrice() {
80
+ return __awaiter(this, void 0, void 0, function* () {
81
+ return yield Order.contract.methods.calculateOrderCurrentPrice(this.id).call();
126
82
  });
127
- };
83
+ }
128
84
  /**
129
85
  * Function for fetching order info from blockchain
130
86
  */
131
- Order.prototype.getOrderInfo = function () {
132
- return __awaiter(this, void 0, void 0, function () {
133
- var orderInfoParams;
134
- return __generator(this, function (_a) {
135
- switch (_a.label) {
136
- case 0: return [4 /*yield*/, this.checkIfOrderExistsWithInterval()];
137
- case 1:
138
- if (!(_a.sent())) {
139
- throw Error("Order ".concat(this.id, " does not exist"));
140
- }
141
- return [4 /*yield*/, Order.contract.methods.getOrder(this.id).call()];
142
- case 2:
143
- orderInfoParams = _a.sent();
144
- return [2 /*return*/, (this.orderInfo = (0, utils_1.tupleToObject)(orderInfoParams[1], Order_1.OrderInfoStructure))];
145
- }
146
- });
87
+ getOrderInfo() {
88
+ return __awaiter(this, void 0, void 0, function* () {
89
+ if (!(yield this.checkIfOrderExistsWithInterval())) {
90
+ throw Error(`Order ${this.id} does not exist`);
91
+ }
92
+ const orderInfoParams = yield Order.contract.methods.getOrder(this.id).call();
93
+ return (this.orderInfo = (0, utils_1.tupleToObject)(orderInfoParams[1], Order_1.OrderInfoStructure));
147
94
  });
148
- };
149
- Order.prototype.checkIfOrderExistsWithInterval = function () {
150
- return __awaiter(this, void 0, void 0, function () {
151
- var offerExists;
152
- var _this = this;
153
- return __generator(this, function (_a) {
154
- switch (_a.label) {
155
- case 0: return [4 /*yield*/, (0, helpers_1.tryWithInterval)({
156
- handler: function () { return _this.isExist(); },
157
- checkResult: function (exists) {
158
- if (!exists)
159
- _this.logger.debug("Order ".concat(_this.id, " exists: ").concat(exists));
160
- return { isResultOk: exists };
161
- },
162
- retryInterval: constants_1.BLOCKCHAIN_CALL_RETRY_INTERVAL,
163
- retryMax: constants_1.BLOCKCHAIN_CALL_RETRY_ATTEMPTS,
164
- })];
165
- case 1:
166
- offerExists = _a.sent();
167
- return [2 /*return*/, offerExists];
168
- }
95
+ }
96
+ checkIfOrderExistsWithInterval() {
97
+ return __awaiter(this, void 0, void 0, function* () {
98
+ const offerExists = yield (0, helpers_1.tryWithInterval)({
99
+ handler: () => this.isExist(),
100
+ checkResult: (exists) => {
101
+ if (!exists)
102
+ this.logger.debug(`Order ${this.id} exists: ${exists}`);
103
+ return { isResultOk: exists };
104
+ },
105
+ retryInterval: constants_1.BLOCKCHAIN_CALL_RETRY_INTERVAL,
106
+ retryMax: constants_1.BLOCKCHAIN_CALL_RETRY_ATTEMPTS,
169
107
  });
108
+ return offerExists;
170
109
  });
171
- };
172
- Order.prototype.getConsumer = function () {
173
- return __awaiter(this, void 0, void 0, function () {
174
- var orderInfoParams;
175
- return __generator(this, function (_a) {
176
- switch (_a.label) {
177
- case 0: return [4 /*yield*/, Order.contract.methods.getOrder(this.id).call()];
178
- case 1:
179
- orderInfoParams = _a.sent();
180
- this.consumer = orderInfoParams[0];
181
- return [2 /*return*/, this.consumer];
182
- }
183
- });
110
+ }
111
+ getConsumer() {
112
+ return __awaiter(this, void 0, void 0, function* () {
113
+ const orderInfoParams = yield Order.contract.methods.getOrder(this.id).call();
114
+ this.consumer = orderInfoParams[0];
115
+ return this.consumer;
184
116
  });
185
- };
117
+ }
186
118
  /**
187
119
  * Function for fetching order result from blockchain
188
120
  */
189
- Order.prototype.getOrderResult = function () {
190
- return __awaiter(this, void 0, void 0, function () {
191
- var orderInfoParams;
192
- return __generator(this, function (_a) {
193
- switch (_a.label) {
194
- case 0: return [4 /*yield*/, Order.contract.methods.getOrder(this.id).call()];
195
- case 1:
196
- orderInfoParams = _a.sent();
197
- return [2 /*return*/, (this.orderResult = (0, utils_1.tupleToObject)([orderInfoParams[2][0], orderInfoParams[2][1]], Order_1.OrderResultStructure))];
198
- }
199
- });
121
+ getOrderResult() {
122
+ return __awaiter(this, void 0, void 0, function* () {
123
+ const orderInfoParams = yield Order.contract.methods.getOrder(this.id).call();
124
+ return (this.orderResult = (0, utils_1.tupleToObject)([orderInfoParams[2][0], orderInfoParams[2][1]], Order_1.OrderResultStructure));
200
125
  });
201
- };
126
+ }
202
127
  /**
203
128
  * Function for fetching sub orders from blockchain
204
129
  */
205
- Order.prototype.getSubOrders = function () {
206
- return __awaiter(this, void 0, void 0, function () {
207
- var _a;
208
- return __generator(this, function (_b) {
209
- switch (_b.label) {
210
- case 0:
211
- _a = this;
212
- return [4 /*yield*/, Order.contract.methods.getOrderSubOrders(this.id).call()];
213
- case 1:
214
- _a.subOrders = _b.sent();
215
- return [2 /*return*/, this.subOrders];
216
- }
217
- });
130
+ getSubOrders() {
131
+ return __awaiter(this, void 0, void 0, function* () {
132
+ this.subOrders = yield Order.contract.methods.getOrderSubOrders(this.id).call();
133
+ return this.subOrders;
218
134
  });
219
- };
135
+ }
220
136
  /**
221
137
  * Function for fetching parent order from blockchain
222
138
  */
223
- Order.prototype.getParentOrder = function () {
224
- return __awaiter(this, void 0, void 0, function () {
225
- var _a;
226
- return __generator(this, function (_b) {
227
- switch (_b.label) {
228
- case 0:
229
- _a = this;
230
- return [4 /*yield*/, Order.contract.methods.getOrderParentOrder(this.id).call()];
231
- case 1:
232
- _a.parentOrder = _b.sent();
233
- return [2 /*return*/, this.parentOrder];
234
- }
235
- });
139
+ getParentOrder() {
140
+ return __awaiter(this, void 0, void 0, function* () {
141
+ this.parentOrder = yield Order.contract.methods.getOrderParentOrder(this.id).call();
142
+ return this.parentOrder;
236
143
  });
237
- };
144
+ }
238
145
  /**
239
146
  * Function for fetching order options deposit spent from blockchain
240
147
  */
241
- Order.prototype.getOptionsDepositSpent = function () {
242
- return __awaiter(this, void 0, void 0, function () {
243
- return __generator(this, function (_a) {
244
- return [2 /*return*/, Order.contract.methods.getOptionsDepositSpent(this.id).call()];
245
- });
148
+ getOptionsDepositSpent() {
149
+ return __awaiter(this, void 0, void 0, function* () {
150
+ return Order.contract.methods.getOptionsDepositSpent(this.id).call();
246
151
  });
247
- };
152
+ }
248
153
  /**
249
154
  * Function for fetching order deposit spent from blockchain
250
155
  */
251
- Order.prototype.getSelectedUsage = function () {
252
- return __awaiter(this, void 0, void 0, function () {
253
- var _a, _b, _c, _d, _e;
254
- return __generator(this, function (_f) {
255
- switch (_f.label) {
256
- case 0:
257
- _a = this;
258
- _b = utils_1.tupleToObject;
259
- return [4 /*yield*/, Order.contract.methods.getOrderSelectedUsage(this.id).call()];
260
- case 1:
261
- _a.selectedUsage = _b.apply(void 0, [_f.sent(), Order_1.OrderUsageStructure]);
262
- this.selectedUsage.optionsCount = this.selectedUsage.optionsCount.map(function (item) { return +item; });
263
- _c = this.selectedUsage;
264
- _d = utils_1.unpackSlotInfo;
265
- _e = [this.selectedUsage.slotInfo];
266
- return [4 /*yield*/, TeeOffers_1.default.getDenominator()];
267
- case 2:
268
- _c.slotInfo = _d.apply(void 0, _e.concat([_f.sent()]));
269
- return [2 /*return*/, this.selectedUsage];
270
- }
271
- });
156
+ getSelectedUsage() {
157
+ return __awaiter(this, void 0, void 0, function* () {
158
+ this.selectedUsage = (0, utils_1.tupleToObject)(yield Order.contract.methods.getOrderSelectedUsage(this.id).call(), Order_1.OrderUsageStructure);
159
+ this.selectedUsage.optionsCount = this.selectedUsage.optionsCount.map((item) => +item);
160
+ this.selectedUsage.slotInfo = (0, utils_1.unpackSlotInfo)(this.selectedUsage.slotInfo, yield TeeOffers_1.default.getDenominator());
161
+ return this.selectedUsage;
272
162
  });
273
- };
163
+ }
274
164
  /**
275
165
  * Function for fetching hold deposits sum of the order and its suborders
276
166
  */
277
- Order.prototype.calculateTotalOrderDeposit = function () {
278
- return __awaiter(this, void 0, void 0, function () {
279
- return __generator(this, function (_a) {
280
- return [2 /*return*/, Order.contract.methods.calculateTotalOrderDeposit(this.id).call()];
281
- });
167
+ calculateTotalOrderDeposit() {
168
+ return __awaiter(this, void 0, void 0, function* () {
169
+ return Order.contract.methods.calculateTotalOrderDeposit(this.id).call();
282
170
  });
283
- };
171
+ }
284
172
  /**
285
173
  * Function for fetching reserve for output order
286
174
  */
287
- Order.prototype.calculateOrderOutputReserve = function () {
288
- return __awaiter(this, void 0, void 0, function () {
289
- return __generator(this, function (_a) {
290
- return [2 /*return*/, Order.contract.methods.calculateOrderOutputReserve(this.id).call()];
291
- });
175
+ calculateOrderOutputReserve() {
176
+ return __awaiter(this, void 0, void 0, function* () {
177
+ return Order.contract.methods.calculateOrderOutputReserve(this.id).call();
292
178
  });
293
- };
179
+ }
294
180
  /**
295
181
  * Function for fetching spent deposits sum of the order and its suborders
296
182
  */
297
- Order.prototype.calculateTotalDepositSpent = function () {
298
- return __awaiter(this, void 0, void 0, function () {
299
- return __generator(this, function (_a) {
300
- return [2 /*return*/, Order.contract.methods.calculateTotalDepositSpent(this.id).call()];
301
- });
183
+ calculateTotalDepositSpent() {
184
+ return __awaiter(this, void 0, void 0, function* () {
185
+ return Order.contract.methods.calculateTotalDepositSpent(this.id).call();
302
186
  });
303
- };
187
+ }
304
188
  /**
305
189
  * Function for fetching unspent deposits sum of the order and its suborders
306
190
  */
307
- Order.prototype.calculateTotalDepositUnspent = function () {
308
- return __awaiter(this, void 0, void 0, function () {
309
- return __generator(this, function (_a) {
310
- return [2 /*return*/, Order.contract.methods.calculateTotalDepositUnspent(this.id).call()];
311
- });
191
+ calculateTotalDepositUnspent() {
192
+ return __awaiter(this, void 0, void 0, function* () {
193
+ return Order.contract.methods.calculateTotalDepositUnspent(this.id).call();
312
194
  });
313
- };
195
+ }
314
196
  /**
315
197
  * Fetch new Origins (createdDate, createdBy, modifiedDate and modifiedBy)
316
198
  */
317
- Order.prototype.getOrigins = function () {
318
- return __awaiter(this, void 0, void 0, function () {
319
- var origins;
320
- return __generator(this, function (_a) {
321
- switch (_a.label) {
322
- case 0: return [4 /*yield*/, Order.contract.methods.getOrderOrigins(this.id).call()];
323
- case 1:
324
- origins = _a.sent();
325
- // Converts blockchain array into object
326
- origins = (0, utils_1.tupleToObject)(origins, Origins_1.OriginsStructure);
327
- // Convert blockchain time seconds to js time milliseconds
328
- origins.createdDate = +origins.createdDate * 1000;
329
- origins.modifiedDate = +origins.modifiedDate * 1000;
330
- return [2 /*return*/, (this.origins = origins)];
331
- }
332
- });
199
+ getOrigins() {
200
+ return __awaiter(this, void 0, void 0, function* () {
201
+ let origins = yield Order.contract.methods.getOrderOrigins(this.id).call();
202
+ // Converts blockchain array into object
203
+ origins = (0, utils_1.tupleToObject)(origins, Origins_1.OriginsStructure);
204
+ // Convert blockchain time seconds to js time milliseconds
205
+ origins.createdDate = +origins.createdDate * 1000;
206
+ origins.modifiedDate = +origins.modifiedDate * 1000;
207
+ return (this.origins = origins);
333
208
  });
334
- };
209
+ }
335
210
  /**
336
211
  * Function for fetching parent order from blockchain
337
212
  */
338
- Order.prototype.getAwaitingPayment = function () {
339
- return __awaiter(this, void 0, void 0, function () {
340
- return __generator(this, function (_a) {
341
- return [2 /*return*/, Order.contract.methods.getAwaitingPayment(this.id).call()];
342
- });
213
+ getAwaitingPayment() {
214
+ return __awaiter(this, void 0, void 0, function* () {
215
+ return Order.contract.methods.getAwaitingPayment(this.id).call();
343
216
  });
344
- };
217
+ }
345
218
  /**
346
219
  * Function for fetching deposit of order from blockchain
347
220
  */
348
- Order.prototype.getDeposit = function () {
349
- return __awaiter(this, void 0, void 0, function () {
350
- return __generator(this, function (_a) {
351
- return [2 /*return*/, Order.contract.methods.getOrderDeposit(this.id).call()];
352
- });
221
+ getDeposit() {
222
+ return __awaiter(this, void 0, void 0, function* () {
223
+ return Order.contract.methods.getOrderDeposit(this.id).call();
353
224
  });
354
- };
225
+ }
355
226
  /**
356
227
  * Function for fetching start of processing date
357
228
  */
358
- Order.prototype.getStartDate = function () {
359
- return __awaiter(this, void 0, void 0, function () {
360
- return __generator(this, function (_a) {
361
- return [2 /*return*/, Order.contract.methods.getStartDate(this.id).call()];
362
- });
229
+ getStartDate() {
230
+ return __awaiter(this, void 0, void 0, function* () {
231
+ return Order.contract.methods.getStartDate(this.id).call();
363
232
  });
364
- };
233
+ }
365
234
  /**
366
235
  * Function for fetching parent order from blockchain
367
236
  */
368
- Order.prototype.setAwaitingPayment = function (value, transactionOptions) {
369
- return __awaiter(this, void 0, void 0, function () {
370
- return __generator(this, function (_a) {
371
- switch (_a.label) {
372
- case 0:
373
- transactionOptions !== null && transactionOptions !== void 0 ? transactionOptions : this.checkInitOrder(transactionOptions);
374
- (0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
375
- return [4 /*yield*/, TxManager_1.default.execute(Order.contract.methods.setAwaitingPayment, [this.id, value], transactionOptions)];
376
- case 1:
377
- _a.sent();
378
- return [2 /*return*/];
379
- }
380
- });
237
+ setAwaitingPayment(value, transactionOptions) {
238
+ return __awaiter(this, void 0, void 0, function* () {
239
+ transactionOptions !== null && transactionOptions !== void 0 ? transactionOptions : this.checkInitOrder(transactionOptions);
240
+ (0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
241
+ yield TxManager_1.default.execute(Order.contract.methods.setAwaitingPayment, [this.id, value], transactionOptions);
381
242
  });
382
- };
243
+ }
383
244
  /**
384
245
  * Updates order price
385
246
  */
386
- Order.prototype.updateOrderPrice = function (price, transactionOptions) {
387
- return __awaiter(this, void 0, void 0, function () {
388
- return __generator(this, function (_a) {
389
- switch (_a.label) {
390
- case 0:
391
- transactionOptions !== null && transactionOptions !== void 0 ? transactionOptions : this.checkInitOrder(transactionOptions);
392
- (0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
393
- return [4 /*yield*/, TxManager_1.default.execute(Order.contract.methods.updateOrderPrice, [this.id, price], transactionOptions)];
394
- case 1:
395
- _a.sent();
396
- return [2 /*return*/];
397
- }
398
- });
247
+ updateOrderPrice(price, transactionOptions) {
248
+ return __awaiter(this, void 0, void 0, function* () {
249
+ transactionOptions !== null && transactionOptions !== void 0 ? transactionOptions : this.checkInitOrder(transactionOptions);
250
+ (0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
251
+ yield TxManager_1.default.execute(Order.contract.methods.updateOrderPrice, [this.id, price], transactionOptions);
399
252
  });
400
- };
253
+ }
401
254
  /**
402
255
  * Sets options deposit spent
403
256
  */
404
- Order.prototype.setOptionsDepositSpent = function (value, transactionOptions) {
405
- return __awaiter(this, void 0, void 0, function () {
406
- return __generator(this, function (_a) {
407
- switch (_a.label) {
408
- case 0:
409
- transactionOptions !== null && transactionOptions !== void 0 ? transactionOptions : this.checkInitOrder(transactionOptions);
410
- (0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
411
- return [4 /*yield*/, TxManager_1.default.execute(Order.contract.methods.setOptionsDepositSpent, [this.id, value], transactionOptions)];
412
- case 1:
413
- _a.sent();
414
- return [2 /*return*/];
415
- }
416
- });
257
+ setOptionsDepositSpent(value, transactionOptions) {
258
+ return __awaiter(this, void 0, void 0, function* () {
259
+ transactionOptions !== null && transactionOptions !== void 0 ? transactionOptions : this.checkInitOrder(transactionOptions);
260
+ (0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
261
+ yield TxManager_1.default.execute(Order.contract.methods.setOptionsDepositSpent, [this.id, value], transactionOptions);
417
262
  });
418
- };
263
+ }
419
264
  /**
420
265
  * Function for updating status of contract
421
266
  */
422
- Order.prototype.updateStatus = function (status, transactionOptions) {
423
- return __awaiter(this, void 0, void 0, function () {
424
- return __generator(this, function (_a) {
425
- switch (_a.label) {
426
- case 0:
427
- transactionOptions !== null && transactionOptions !== void 0 ? transactionOptions : this.checkInitOrder(transactionOptions);
428
- (0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
429
- if (!(status === Order_1.OrderStatus.Processing)) return [3 /*break*/, 2];
430
- return [4 /*yield*/, TxManager_1.default.execute(Order.contract.methods.processOrder, [this.id], transactionOptions)];
431
- case 1:
432
- _a.sent();
433
- _a.label = 2;
434
- case 2:
435
- if (this.orderInfo)
436
- this.orderInfo.status = status;
437
- return [2 /*return*/];
438
- }
439
- });
267
+ updateStatus(status, transactionOptions) {
268
+ return __awaiter(this, void 0, void 0, function* () {
269
+ transactionOptions !== null && transactionOptions !== void 0 ? transactionOptions : this.checkInitOrder(transactionOptions);
270
+ (0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
271
+ if (status === Order_1.OrderStatus.Processing) {
272
+ yield TxManager_1.default.execute(Order.contract.methods.processOrder, [this.id], transactionOptions);
273
+ }
274
+ if (this.orderInfo)
275
+ this.orderInfo.status = status;
440
276
  });
441
- };
277
+ }
442
278
  /**
443
279
  * Function for updating status of contract
444
280
  */
445
- Order.prototype.cancelOrder = function (transactionOptions) {
446
- return __awaiter(this, void 0, void 0, function () {
447
- return __generator(this, function (_a) {
448
- switch (_a.label) {
449
- case 0:
450
- transactionOptions !== null && transactionOptions !== void 0 ? transactionOptions : this.checkInitOrder(transactionOptions);
451
- (0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
452
- return [4 /*yield*/, TxManager_1.default.execute(Order.contract.methods.cancelOrder, [this.id], transactionOptions)];
453
- case 1:
454
- _a.sent();
455
- return [2 /*return*/];
456
- }
457
- });
281
+ cancelOrder(transactionOptions) {
282
+ return __awaiter(this, void 0, void 0, function* () {
283
+ transactionOptions !== null && transactionOptions !== void 0 ? transactionOptions : this.checkInitOrder(transactionOptions);
284
+ (0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
285
+ yield TxManager_1.default.execute(Order.contract.methods.cancelOrder, [this.id], transactionOptions);
458
286
  });
459
- };
287
+ }
460
288
  /**
461
289
  * Starts suspended order
462
290
  */
463
- Order.prototype.start = function (transactionOptions) {
464
- return __awaiter(this, void 0, void 0, function () {
465
- return __generator(this, function (_a) {
466
- switch (_a.label) {
467
- case 0:
468
- transactionOptions !== null && transactionOptions !== void 0 ? transactionOptions : this.checkInitOrder(transactionOptions);
469
- (0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
470
- return [4 /*yield*/, TxManager_1.default.execute(Order.contract.methods.startOrder, [this.id], transactionOptions)];
471
- case 1:
472
- _a.sent();
473
- return [2 /*return*/];
474
- }
475
- });
291
+ start(transactionOptions) {
292
+ return __awaiter(this, void 0, void 0, function* () {
293
+ transactionOptions !== null && transactionOptions !== void 0 ? transactionOptions : this.checkInitOrder(transactionOptions);
294
+ (0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
295
+ yield TxManager_1.default.execute(Order.contract.methods.startOrder, [this.id], transactionOptions);
476
296
  });
477
- };
297
+ }
478
298
  /**
479
299
  * Updates order result
480
300
  */
481
- Order.prototype.updateOrderResult = function (encryptedResult, transactionOptions) {
482
- if (encryptedResult === void 0) { encryptedResult = ""; }
483
- return __awaiter(this, void 0, void 0, function () {
484
- return __generator(this, function (_a) {
485
- switch (_a.label) {
486
- case 0:
487
- transactionOptions !== null && transactionOptions !== void 0 ? transactionOptions : this.checkInitOrder(transactionOptions);
488
- (0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
489
- return [4 /*yield*/, TxManager_1.default.execute(Order.contract.methods.updateOrderResult, [this.id, encryptedResult], transactionOptions)];
490
- case 1:
491
- _a.sent();
492
- return [2 /*return*/];
493
- }
494
- });
301
+ updateOrderResult(encryptedResult = "", transactionOptions) {
302
+ return __awaiter(this, void 0, void 0, function* () {
303
+ transactionOptions !== null && transactionOptions !== void 0 ? transactionOptions : this.checkInitOrder(transactionOptions);
304
+ (0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
305
+ yield TxManager_1.default.execute(Order.contract.methods.updateOrderResult, [this.id, encryptedResult], transactionOptions);
495
306
  });
496
- };
307
+ }
497
308
  /**
498
309
  * Completes order
499
310
  */
500
- Order.prototype.complete = function (status, encryptedResult, transactionOptions) {
501
- if (encryptedResult === void 0) { encryptedResult = ""; }
502
- return __awaiter(this, void 0, void 0, function () {
503
- return __generator(this, function (_a) {
504
- switch (_a.label) {
505
- case 0:
506
- transactionOptions !== null && transactionOptions !== void 0 ? transactionOptions : this.checkInitOrder(transactionOptions);
507
- (0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
508
- return [4 /*yield*/, TxManager_1.default.execute(Order.contract.methods.completeOrder, [this.id, status, encryptedResult], transactionOptions)];
509
- case 1:
510
- _a.sent();
511
- return [2 /*return*/];
512
- }
513
- });
311
+ complete(status, encryptedResult = "", transactionOptions) {
312
+ return __awaiter(this, void 0, void 0, function* () {
313
+ transactionOptions !== null && transactionOptions !== void 0 ? transactionOptions : this.checkInitOrder(transactionOptions);
314
+ (0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
315
+ yield TxManager_1.default.execute(Order.contract.methods.completeOrder, [this.id, status, encryptedResult], transactionOptions);
514
316
  });
515
- };
317
+ }
516
318
  /**
517
319
  * Unlocks profit
518
320
  */
519
- Order.prototype.unlockProfit = function (transactionOptions) {
520
- return __awaiter(this, void 0, void 0, function () {
521
- return __generator(this, function (_a) {
522
- switch (_a.label) {
523
- case 0:
524
- transactionOptions !== null && transactionOptions !== void 0 ? transactionOptions : this.checkInitOrder(transactionOptions);
525
- (0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
526
- return [4 /*yield*/, TxManager_1.default.execute(Order.contract.methods.unlockProfit, [this.id], transactionOptions)];
527
- case 1:
528
- _a.sent();
529
- return [2 /*return*/];
530
- }
531
- });
321
+ unlockProfit(transactionOptions) {
322
+ return __awaiter(this, void 0, void 0, function* () {
323
+ transactionOptions !== null && transactionOptions !== void 0 ? transactionOptions : this.checkInitOrder(transactionOptions);
324
+ (0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
325
+ yield TxManager_1.default.execute(Order.contract.methods.unlockProfit, [this.id], transactionOptions);
532
326
  });
533
- };
327
+ }
534
328
  /**
535
329
  * Function for creating sub orders for current order
536
330
  * @param subOrderInfo - order info for new subOrder
@@ -538,189 +332,162 @@ var Order = /** @class */ (function () {
538
332
  * @param transactionOptions - object what contains alternative action account or gas limit (optional)
539
333
  * @returns Promise<void> - Does not return id of created sub order!
540
334
  */
541
- Order.prototype.createSubOrder = function (subOrderInfo, blockParentOrder, deposit, transactionOptions, checkTxBeforeSend) {
542
- if (deposit === void 0) { deposit = "0"; }
543
- if (checkTxBeforeSend === void 0) { checkTxBeforeSend = false; }
544
- return __awaiter(this, void 0, void 0, function () {
545
- var preparedInfo, tupleSubOrder, params;
546
- return __generator(this, function (_a) {
547
- switch (_a.label) {
548
- case 0:
549
- transactionOptions !== null && transactionOptions !== void 0 ? transactionOptions : this.checkInitOrder(transactionOptions);
550
- (0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
551
- preparedInfo = __assign(__assign({}, subOrderInfo), { externalId: (0, utils_2.formatBytes32String)(subOrderInfo.externalId) });
552
- tupleSubOrder = (0, utils_1.objectToTuple)(preparedInfo, Order_1.OrderInfoStructure);
553
- params = {
554
- blockParentOrder: blockParentOrder,
555
- deposit: deposit,
556
- };
557
- if (!checkTxBeforeSend) return [3 /*break*/, 2];
558
- return [4 /*yield*/, TxManager_1.default.dryRun(Order.contract.methods.createSubOrder, [this.id, tupleSubOrder, params], transactionOptions)];
559
- case 1:
560
- _a.sent();
561
- _a.label = 2;
562
- case 2: return [4 /*yield*/, TxManager_1.default.execute(Order.contract.methods.createSubOrder, [this.id, tupleSubOrder, params], transactionOptions)];
563
- case 3:
564
- _a.sent();
565
- return [2 /*return*/];
566
- }
567
- });
335
+ createSubOrder(subOrderInfo, blockParentOrder, deposit = "0", transactionOptions, checkTxBeforeSend = false) {
336
+ return __awaiter(this, void 0, void 0, function* () {
337
+ transactionOptions !== null && transactionOptions !== void 0 ? transactionOptions : this.checkInitOrder(transactionOptions);
338
+ (0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
339
+ const preparedInfo = Object.assign(Object.assign({}, subOrderInfo), { externalId: (0, utils_2.formatBytes32String)(subOrderInfo.externalId) });
340
+ const tupleSubOrder = (0, utils_1.objectToTuple)(preparedInfo, Order_1.OrderInfoStructure);
341
+ const params = {
342
+ blockParentOrder,
343
+ deposit,
344
+ };
345
+ if (checkTxBeforeSend) {
346
+ yield TxManager_1.default.dryRun(Order.contract.methods.createSubOrder, [this.id, tupleSubOrder, params], transactionOptions);
347
+ }
348
+ yield TxManager_1.default.execute(Order.contract.methods.createSubOrder, [this.id, tupleSubOrder, params], transactionOptions);
568
349
  });
569
- };
350
+ }
570
351
  /**
571
352
  * Function for creating pack of sub orders (wokflow) for current order
572
353
  * @param subOrdersInfo - orders info for new subOrders
573
354
  * @param transactionOptions - object what contains action account and web3 instance
574
355
  * @returns {Promise<string[]>} - tx hashes
575
356
  */
576
- Order.prototype.createSubOrders = function (subOrdersInfo, transactionOptions) {
577
- return __awaiter(this, void 0, void 0, function () {
578
- var batch, promises, txs;
579
- var _this = this;
580
- return __generator(this, function (_a) {
581
- switch (_a.label) {
582
- case 0:
583
- this.checkInitOrder(transactionOptions);
584
- (0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
585
- batch = new transactionOptions.web3.BatchRequest();
586
- promises = subOrdersInfo.map(function (subOrderInfo) {
587
- return new Promise(function (res, rej) {
588
- var preparedInfo = __assign(__assign({}, subOrderInfo), { externalId: (0, utils_2.formatBytes32String)(subOrderInfo.externalId) });
589
- var tupleSubOrder = (0, utils_1.objectToTuple)(preparedInfo, Order_1.OrderInfoStructure);
590
- var params = {
591
- blockParentOrder: subOrderInfo.blocking,
592
- deposit: subOrderInfo.deposit,
593
- };
594
- var request = Order.contract.methods.createSubOrder(_this.id, tupleSubOrder, params).send.request({
595
- from: transactionOptions.from,
596
- gasPrice: store_1.default.gasPrice,
597
- gas: store_1.default.gasLimit,
598
- }, function (err, data) {
599
- if (data)
600
- res(data);
601
- if (err)
602
- rej(err);
603
- });
604
- batch.add(request);
605
- });
606
- });
607
- batch.execute();
608
- return [4 /*yield*/, Promise.all(promises)];
609
- case 1:
610
- txs = _a.sent();
611
- return [2 /*return*/, txs.reduce(function (a, b) { return a.concat(b); }, [])];
612
- }
357
+ createSubOrders(subOrdersInfo, transactionOptions) {
358
+ return __awaiter(this, void 0, void 0, function* () {
359
+ this.checkInitOrder(transactionOptions);
360
+ (0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
361
+ const batch = new transactionOptions.web3.BatchRequest();
362
+ const promises = subOrdersInfo.map((subOrderInfo) => {
363
+ return new Promise((res, rej) => {
364
+ const preparedInfo = Object.assign(Object.assign({}, subOrderInfo), { externalId: (0, utils_2.formatBytes32String)(subOrderInfo.externalId) });
365
+ const tupleSubOrder = (0, utils_1.objectToTuple)(preparedInfo, Order_1.OrderInfoStructure);
366
+ const params = {
367
+ blockParentOrder: subOrderInfo.blocking,
368
+ deposit: subOrderInfo.deposit,
369
+ };
370
+ const request = Order.contract.methods.createSubOrder(this.id, tupleSubOrder, params).send.request({
371
+ from: transactionOptions.from,
372
+ gasPrice: store_1.default.gasPrice,
373
+ gas: store_1.default.gasLimit,
374
+ }, (err, data) => {
375
+ if (data)
376
+ res(data);
377
+ if (err)
378
+ rej(err);
379
+ });
380
+ batch.add(request);
381
+ });
613
382
  });
383
+ batch.execute();
384
+ const txs = yield Promise.all(promises);
385
+ return txs.reduce((a, b) => a.concat(b), []);
614
386
  });
615
- };
387
+ }
616
388
  /**
617
389
  * Function for adding event listeners to contract events
618
390
  * @param callback - function for processing each order related with event
619
391
  * @returns unsubscribe - function unsubscribing from event
620
392
  */
621
- Order.prototype.onStatusUpdated = function (callback) {
622
- var _this = this;
623
- var logger = this.logger.child({ method: "onOrderStatusUpdated" });
393
+ onStatusUpdated(callback) {
394
+ const logger = this.logger.child({ method: "onOrderStatusUpdated" });
624
395
  // TODO: add ability to use this event without https provider initialization
625
- var contractWss = BlockchainEventsListener_1.default.getInstance().getContract();
626
- var subscription = contractWss.events
396
+ const contractWss = BlockchainEventsListener_1.default.getInstance().getContract();
397
+ const subscription = contractWss.events
627
398
  .OrderStatusUpdated()
628
- .on("data", function (event) { return __awaiter(_this, void 0, void 0, function () {
629
- return __generator(this, function (_a) {
630
- if (event.returnValues.orderId != this.id) {
631
- return [2 /*return*/];
632
- }
633
- if (this.orderInfo)
634
- this.orderInfo.status = event.returnValues.status;
635
- callback(event.returnValues.status);
636
- return [2 /*return*/];
637
- });
638
- }); })
639
- .on("error", function (error, receipt) {
399
+ .on("data", (event) => __awaiter(this, void 0, void 0, function* () {
400
+ if (event.returnValues.orderId != this.id) {
401
+ return;
402
+ }
403
+ if (this.orderInfo)
404
+ this.orderInfo.status = event.returnValues.status;
405
+ callback(event.returnValues.status);
406
+ }))
407
+ .on("error", (error, receipt) => {
640
408
  if (receipt)
641
409
  return; // Used to avoid logging of transaction rejected
642
410
  logger.warn(error);
643
411
  });
644
- return function () { return subscription.unsubscribe(); };
645
- };
646
- __decorate([
647
- (0, utils_1.incrementMethodCall)()
648
- ], Order.prototype, "getOrderInfo", null);
649
- __decorate([
650
- (0, utils_1.incrementMethodCall)()
651
- ], Order.prototype, "getConsumer", null);
652
- __decorate([
653
- (0, utils_1.incrementMethodCall)()
654
- ], Order.prototype, "getOrderResult", null);
655
- __decorate([
656
- (0, utils_1.incrementMethodCall)()
657
- ], Order.prototype, "getSubOrders", null);
658
- __decorate([
659
- (0, utils_1.incrementMethodCall)()
660
- ], Order.prototype, "getParentOrder", null);
661
- __decorate([
662
- (0, utils_1.incrementMethodCall)()
663
- ], Order.prototype, "getOptionsDepositSpent", null);
664
- __decorate([
665
- (0, utils_1.incrementMethodCall)()
666
- ], Order.prototype, "getSelectedUsage", null);
667
- __decorate([
668
- (0, utils_1.incrementMethodCall)()
669
- ], Order.prototype, "calculateTotalOrderDeposit", null);
670
- __decorate([
671
- (0, utils_1.incrementMethodCall)()
672
- ], Order.prototype, "calculateOrderOutputReserve", null);
673
- __decorate([
674
- (0, utils_1.incrementMethodCall)()
675
- ], Order.prototype, "calculateTotalDepositSpent", null);
676
- __decorate([
677
- (0, utils_1.incrementMethodCall)()
678
- ], Order.prototype, "calculateTotalDepositUnspent", null);
679
- __decorate([
680
- (0, utils_1.incrementMethodCall)()
681
- ], Order.prototype, "getOrigins", null);
682
- __decorate([
683
- (0, utils_1.incrementMethodCall)()
684
- ], Order.prototype, "getAwaitingPayment", null);
685
- __decorate([
686
- (0, utils_1.incrementMethodCall)()
687
- ], Order.prototype, "getDeposit", null);
688
- __decorate([
689
- (0, utils_1.incrementMethodCall)()
690
- ], Order.prototype, "getStartDate", null);
691
- __decorate([
692
- (0, utils_1.incrementMethodCall)()
693
- ], Order.prototype, "setAwaitingPayment", null);
694
- __decorate([
695
- (0, utils_1.incrementMethodCall)()
696
- ], Order.prototype, "updateOrderPrice", null);
697
- __decorate([
698
- (0, utils_1.incrementMethodCall)()
699
- ], Order.prototype, "setOptionsDepositSpent", null);
700
- __decorate([
701
- (0, utils_1.incrementMethodCall)()
702
- ], Order.prototype, "updateStatus", null);
703
- __decorate([
704
- (0, utils_1.incrementMethodCall)()
705
- ], Order.prototype, "cancelOrder", null);
706
- __decorate([
707
- (0, utils_1.incrementMethodCall)()
708
- ], Order.prototype, "start", null);
709
- __decorate([
710
- (0, utils_1.incrementMethodCall)()
711
- ], Order.prototype, "updateOrderResult", null);
712
- __decorate([
713
- (0, utils_1.incrementMethodCall)()
714
- ], Order.prototype, "complete", null);
715
- __decorate([
716
- (0, utils_1.incrementMethodCall)()
717
- ], Order.prototype, "unlockProfit", null);
718
- __decorate([
719
- (0, utils_1.incrementMethodCall)()
720
- ], Order.prototype, "createSubOrder", null);
721
- __decorate([
722
- (0, utils_1.incrementMethodCall)()
723
- ], Order.prototype, "createSubOrders", null);
724
- return Order;
725
- }());
412
+ return () => subscription.unsubscribe();
413
+ }
414
+ }
415
+ __decorate([
416
+ (0, utils_1.incrementMethodCall)()
417
+ ], Order.prototype, "getOrderInfo", null);
418
+ __decorate([
419
+ (0, utils_1.incrementMethodCall)()
420
+ ], Order.prototype, "getConsumer", null);
421
+ __decorate([
422
+ (0, utils_1.incrementMethodCall)()
423
+ ], Order.prototype, "getOrderResult", null);
424
+ __decorate([
425
+ (0, utils_1.incrementMethodCall)()
426
+ ], Order.prototype, "getSubOrders", null);
427
+ __decorate([
428
+ (0, utils_1.incrementMethodCall)()
429
+ ], Order.prototype, "getParentOrder", null);
430
+ __decorate([
431
+ (0, utils_1.incrementMethodCall)()
432
+ ], Order.prototype, "getOptionsDepositSpent", null);
433
+ __decorate([
434
+ (0, utils_1.incrementMethodCall)()
435
+ ], Order.prototype, "getSelectedUsage", null);
436
+ __decorate([
437
+ (0, utils_1.incrementMethodCall)()
438
+ ], Order.prototype, "calculateTotalOrderDeposit", null);
439
+ __decorate([
440
+ (0, utils_1.incrementMethodCall)()
441
+ ], Order.prototype, "calculateOrderOutputReserve", null);
442
+ __decorate([
443
+ (0, utils_1.incrementMethodCall)()
444
+ ], Order.prototype, "calculateTotalDepositSpent", null);
445
+ __decorate([
446
+ (0, utils_1.incrementMethodCall)()
447
+ ], Order.prototype, "calculateTotalDepositUnspent", null);
448
+ __decorate([
449
+ (0, utils_1.incrementMethodCall)()
450
+ ], Order.prototype, "getOrigins", null);
451
+ __decorate([
452
+ (0, utils_1.incrementMethodCall)()
453
+ ], Order.prototype, "getAwaitingPayment", null);
454
+ __decorate([
455
+ (0, utils_1.incrementMethodCall)()
456
+ ], Order.prototype, "getDeposit", null);
457
+ __decorate([
458
+ (0, utils_1.incrementMethodCall)()
459
+ ], Order.prototype, "getStartDate", null);
460
+ __decorate([
461
+ (0, utils_1.incrementMethodCall)()
462
+ ], Order.prototype, "setAwaitingPayment", null);
463
+ __decorate([
464
+ (0, utils_1.incrementMethodCall)()
465
+ ], Order.prototype, "updateOrderPrice", null);
466
+ __decorate([
467
+ (0, utils_1.incrementMethodCall)()
468
+ ], Order.prototype, "setOptionsDepositSpent", null);
469
+ __decorate([
470
+ (0, utils_1.incrementMethodCall)()
471
+ ], Order.prototype, "updateStatus", null);
472
+ __decorate([
473
+ (0, utils_1.incrementMethodCall)()
474
+ ], Order.prototype, "cancelOrder", null);
475
+ __decorate([
476
+ (0, utils_1.incrementMethodCall)()
477
+ ], Order.prototype, "start", null);
478
+ __decorate([
479
+ (0, utils_1.incrementMethodCall)()
480
+ ], Order.prototype, "updateOrderResult", null);
481
+ __decorate([
482
+ (0, utils_1.incrementMethodCall)()
483
+ ], Order.prototype, "complete", null);
484
+ __decorate([
485
+ (0, utils_1.incrementMethodCall)()
486
+ ], Order.prototype, "unlockProfit", null);
487
+ __decorate([
488
+ (0, utils_1.incrementMethodCall)()
489
+ ], Order.prototype, "createSubOrder", null);
490
+ __decorate([
491
+ (0, utils_1.incrementMethodCall)()
492
+ ], Order.prototype, "createSubOrders", null);
726
493
  exports.default = Order;