@super-protocol/sdk-js 0.14.2-beta.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/TIIGenerator.js +129 -239
- package/build/connectors/BaseConnector.js +17 -47
- package/build/connectors/BlockchainConnector.js +222 -348
- package/build/connectors/BlockchainEventsListener.js +38 -92
- package/build/contracts/app.json +0 -110
- package/build/crypto/Crypto.js +63 -135
- package/build/crypto/index.js +1 -1
- package/build/crypto/nodejs/AES.js +62 -119
- package/build/crypto/nodejs/ARIA.js +61 -118
- package/build/crypto/nodejs/ECIES.js +51 -87
- package/build/crypto/nodejs/NativeCrypto.js +64 -118
- package/build/crypto/nodejs/RSA-Hybrid.js +54 -113
- package/build/index.d.ts +5 -0
- package/build/index.js +14 -2
- package/build/logger.d.ts +3 -1
- package/build/logger.js +2 -2
- package/build/models/EtlModel.js +65 -114
- package/build/models/Offer.js +227 -462
- package/build/models/Order.js +324 -573
- package/build/models/Provider.js +72 -165
- package/build/models/TCB.js +67 -171
- package/build/models/TeeOffer.d.ts +1 -7
- package/build/models/TeeOffer.js +389 -758
- package/build/proto/Compression.js +20 -21
- package/build/proto/TRI.js +46 -50
- package/build/proto/TeeProperties.js +60 -66
- package/build/providers/storage/ChunksDownloadDecorator.js +125 -235
- package/build/providers/storage/S3StorageProvider.js +173 -298
- package/build/providers/storage/StorageAdapter.d.ts +60 -0
- package/build/providers/storage/StorageAdapter.js +317 -0
- package/build/providers/storage/StorageContentWriter.d.ts +39 -0
- package/build/providers/storage/StorageContentWriter.js +181 -0
- package/build/providers/storage/StorageKeyValueAdapter.d.ts +20 -0
- package/build/providers/storage/StorageKeyValueAdapter.js +152 -0
- package/build/providers/storage/StorageMetadataReader.d.ts +19 -0
- package/build/providers/storage/StorageMetadataReader.js +65 -0
- package/build/providers/storage/StorjAdapter.d.ts +19 -0
- package/build/providers/storage/StorjAdapter.js +62 -0
- package/build/providers/storage/StorjStorageProvider.js +138 -315
- package/build/providers/storage/getStorageProvider.js +7 -7
- package/build/providers/storage/types.d.ts +7 -0
- package/build/providers/storage/types.js +2 -0
- package/build/staticModels/ActiveOffers.js +32 -100
- package/build/staticModels/ActiveOrders.js +42 -120
- package/build/staticModels/BaseStaticModel.js +7 -10
- package/build/staticModels/Consensus.d.ts +2 -2
- package/build/staticModels/Consensus.js +157 -280
- package/build/staticModels/Deposits.js +109 -201
- package/build/staticModels/Marks.js +21 -82
- package/build/staticModels/ModelPackager.js +34 -84
- package/build/staticModels/Offers.js +140 -266
- package/build/staticModels/Orders.js +285 -472
- package/build/staticModels/ProviderRegistry.js +114 -225
- package/build/staticModels/Superpro.js +17 -63
- package/build/staticModels/SuperproToken.js +90 -169
- package/build/staticModels/TeeOffers.js +220 -416
- package/build/store.js +2 -2
- package/build/types/HardwareInfo.js +2 -2
- package/build/types/Order.d.ts +0 -6
- package/build/types/Order.js +4 -6
- package/build/types/Provider.js +1 -1
- package/build/types/TeeOfferInfo.js +1 -1
- package/build/types/TeeOfferOption.js +2 -2
- package/build/types/TeeOfferSlot.js +2 -2
- package/build/types/ValueOfferSlot.js +3 -3
- package/build/utils/Monitoring.js +24 -28
- package/build/utils/NonceTracker.js +56 -121
- package/build/utils/PubSub.d.ts +9 -0
- package/build/utils/PubSub.js +36 -0
- package/build/utils/TxManager.js +121 -215
- package/build/utils/compressors/GzipCompressor.js +13 -50
- package/build/utils/compressors/UncompressedCompressor.js +10 -13
- package/build/utils/helpers/tryWithInterval.js +34 -78
- package/build/utils/resourceLoaders/BaseResourceLoader.js +26 -78
- package/build/utils/resourceLoaders/StorageProviderLoader.js +33 -97
- package/build/utils/resourceLoaders/UrlResourceLoader.js +29 -93
- package/build/utils/resourceLoaders/getResourceLoader.js +6 -6
- package/build/utils.js +60 -105
- 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,99 +14,50 @@ 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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
21
|
+
const utils_1 = require("ethers/lib/utils");
|
|
22
|
+
const logger_1 = __importDefault(require("../logger"));
|
|
23
|
+
const utils_2 = require("../utils");
|
|
24
|
+
const Order_1 = require("../types/Order");
|
|
25
|
+
const Superpro_1 = __importDefault(require("./Superpro"));
|
|
26
|
+
const TxManager_1 = __importDefault(require("../utils/TxManager"));
|
|
27
|
+
const BlockchainConnector_1 = __importDefault(require("../connectors/BlockchainConnector"));
|
|
28
|
+
const BlockchainEventsListener_1 = __importDefault(require("../connectors/BlockchainEventsListener"));
|
|
29
|
+
const Order_2 = __importDefault(require("../models/Order"));
|
|
30
|
+
class Orders {
|
|
31
|
+
static get address() {
|
|
32
|
+
return Superpro_1.default.address;
|
|
70
33
|
}
|
|
71
|
-
Object.defineProperty(Orders, "address", {
|
|
72
|
-
get: function () {
|
|
73
|
-
return Superpro_1.default.address;
|
|
74
|
-
},
|
|
75
|
-
enumerable: false,
|
|
76
|
-
configurable: true
|
|
77
|
-
});
|
|
78
34
|
/**
|
|
79
35
|
* Function for fetching list of all orders ids
|
|
80
36
|
* @returns list of orders ids
|
|
81
37
|
*/
|
|
82
|
-
|
|
38
|
+
static getAll() {
|
|
83
39
|
var _a;
|
|
84
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
ordersCount = _b.sent();
|
|
95
|
-
for (orderId = ordersSet.size + 1; orderId <= ordersCount; orderId++) {
|
|
96
|
-
ordersSet.add(orderId.toString());
|
|
97
|
-
}
|
|
98
|
-
this.orders = Array.from(ordersSet);
|
|
99
|
-
return [2 /*return*/, this.orders];
|
|
100
|
-
}
|
|
101
|
-
});
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
const contract = BlockchainConnector_1.default.getInstance().getContract();
|
|
42
|
+
this.orders = (_a = this.orders) !== null && _a !== void 0 ? _a : [];
|
|
43
|
+
const ordersSet = new Set(this.orders);
|
|
44
|
+
const ordersCount = yield contract.methods.getOrdersCount().call();
|
|
45
|
+
for (let orderId = ordersSet.size + 1; orderId <= ordersCount; orderId++) {
|
|
46
|
+
ordersSet.add(orderId.toString());
|
|
47
|
+
}
|
|
48
|
+
this.orders = Array.from(ordersSet);
|
|
49
|
+
return this.orders;
|
|
102
50
|
});
|
|
103
|
-
}
|
|
51
|
+
}
|
|
104
52
|
/**
|
|
105
53
|
* Function for fetching orders count
|
|
106
54
|
*/
|
|
107
|
-
|
|
108
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
109
|
-
|
|
110
|
-
return
|
|
111
|
-
switch (_b.label) {
|
|
112
|
-
case 0:
|
|
113
|
-
contract = BlockchainConnector_1.default.getInstance().getContract();
|
|
114
|
-
_a = Number;
|
|
115
|
-
return [4 /*yield*/, contract.methods.getOrdersCount().call()];
|
|
116
|
-
case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent()])];
|
|
117
|
-
}
|
|
118
|
-
});
|
|
55
|
+
static getCount() {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
const contract = BlockchainConnector_1.default.getInstance().getContract();
|
|
58
|
+
return Number(yield contract.methods.getOrdersCount().call());
|
|
119
59
|
});
|
|
120
|
-
}
|
|
60
|
+
}
|
|
121
61
|
/**
|
|
122
62
|
* Function for creating orders
|
|
123
63
|
* @param orderInfo - order info for new order
|
|
@@ -125,61 +65,37 @@ var Orders = /** @class */ (function () {
|
|
|
125
65
|
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
126
66
|
* @returns {Promise<void>} - Does not return id of created order!
|
|
127
67
|
*/
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
(0, utils_2.checkIfActionAccountInitialized)(transactionOptions);
|
|
139
|
-
preparedInfo = __assign(__assign({}, orderInfo), { externalId: (0, utils_1.formatBytes32String)(orderInfo.externalId) });
|
|
140
|
-
orderInfoArguments = (0, utils_2.objectToTuple)(preparedInfo, Order_1.OrderInfoStructure);
|
|
141
|
-
if (!checkTxBeforeSend) return [3 /*break*/, 2];
|
|
142
|
-
return [4 /*yield*/, TxManager_1.default.dryRun(contract.methods.createOrder, [orderInfoArguments, deposit, suspended], transactionOptions)];
|
|
143
|
-
case 1:
|
|
144
|
-
_a.sent();
|
|
145
|
-
_a.label = 2;
|
|
146
|
-
case 2: return [4 /*yield*/, TxManager_1.default.execute(contract.methods.createOrder, [orderInfoArguments, deposit, suspended], transactionOptions)];
|
|
147
|
-
case 3:
|
|
148
|
-
_a.sent();
|
|
149
|
-
return [2 /*return*/];
|
|
150
|
-
}
|
|
151
|
-
});
|
|
68
|
+
static createOrder(orderInfo, deposit = "0", suspended = false, transactionOptions, checkTxBeforeSend = false) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
const contract = BlockchainConnector_1.default.getInstance().getContract(transactionOptions);
|
|
71
|
+
(0, utils_2.checkIfActionAccountInitialized)(transactionOptions);
|
|
72
|
+
const preparedInfo = Object.assign(Object.assign({}, orderInfo), { externalId: (0, utils_1.formatBytes32String)(orderInfo.externalId) });
|
|
73
|
+
const orderInfoArguments = (0, utils_2.objectToTuple)(preparedInfo, Order_1.OrderInfoStructure);
|
|
74
|
+
if (checkTxBeforeSend) {
|
|
75
|
+
yield TxManager_1.default.dryRun(contract.methods.createOrder, [orderInfoArguments, deposit, suspended], transactionOptions);
|
|
76
|
+
}
|
|
77
|
+
yield TxManager_1.default.execute(contract.methods.createOrder, [orderInfoArguments, deposit, suspended], transactionOptions);
|
|
152
78
|
});
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
options.toBlock = toBlock;
|
|
172
|
-
return [4 /*yield*/, contract.getPastEvents("OrderCreated", options)];
|
|
173
|
-
case 1:
|
|
174
|
-
foundIds = _a.sent();
|
|
175
|
-
notFound = __assign(__assign({}, filter), { offerId: "-1", parentOrderId: "-1", orderId: "-1" });
|
|
176
|
-
response = foundIds.length > 0 ? foundIds[0].returnValues : notFound;
|
|
177
|
-
response.externalId = (0, utils_1.parseBytes32String)(response.externalId);
|
|
178
|
-
return [2 /*return*/, response];
|
|
179
|
-
}
|
|
180
|
-
});
|
|
79
|
+
}
|
|
80
|
+
static getByExternalId(consumer = "", externalId = "", fromBlock, toBlock) {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
const contract = BlockchainConnector_1.default.getInstance().getContract();
|
|
83
|
+
const filter = {
|
|
84
|
+
consumer,
|
|
85
|
+
externalId: (0, utils_1.formatBytes32String)(externalId),
|
|
86
|
+
};
|
|
87
|
+
const options = { filter };
|
|
88
|
+
if (fromBlock)
|
|
89
|
+
options.fromBlock = fromBlock;
|
|
90
|
+
if (toBlock)
|
|
91
|
+
options.toBlock = toBlock;
|
|
92
|
+
const foundIds = yield contract.getPastEvents("OrderCreated", options);
|
|
93
|
+
const notFound = Object.assign(Object.assign({}, filter), { offerId: "-1", parentOrderId: "-1", orderId: "-1" });
|
|
94
|
+
const response = foundIds.length > 0 ? foundIds[0].returnValues : notFound;
|
|
95
|
+
response.externalId = (0, utils_1.parseBytes32String)(response.externalId);
|
|
96
|
+
return response;
|
|
181
97
|
});
|
|
182
|
-
}
|
|
98
|
+
}
|
|
183
99
|
/**
|
|
184
100
|
* Function for create workflow
|
|
185
101
|
* @param parentOrderInfo - order info for new order
|
|
@@ -188,230 +104,156 @@ var Orders = /** @class */ (function () {
|
|
|
188
104
|
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
189
105
|
* @returns {Promise<void>} - Does not return id of created order!
|
|
190
106
|
*/
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
preparedSubOrdersInfo = subOrdersInfo.map(function (o) { return (__assign(__assign({}, o), { externalId: (0, utils_1.formatBytes32String)(o.externalId) })); });
|
|
204
|
-
subOrdersInfoArgs = (0, utils_2.objectToTuple)(preparedSubOrdersInfo, Order_1.OrderInfoStructureArray);
|
|
205
|
-
if (!checkTxBeforeSend) return [3 /*break*/, 2];
|
|
206
|
-
return [4 /*yield*/, TxManager_1.default.dryRun(contract.methods.createWorkflow, [parentOrderInfoArgs, workflowDeposit, subOrdersInfoArgs], transactionOptions)];
|
|
207
|
-
case 1:
|
|
208
|
-
_a.sent();
|
|
209
|
-
_a.label = 2;
|
|
210
|
-
case 2: return [4 /*yield*/, TxManager_1.default.execute(contract.methods.createWorkflow, [parentOrderInfoArgs, workflowDeposit, subOrdersInfoArgs], transactionOptions)];
|
|
211
|
-
case 3:
|
|
212
|
-
_a.sent();
|
|
213
|
-
return [2 /*return*/];
|
|
214
|
-
}
|
|
215
|
-
});
|
|
107
|
+
static createWorkflow(parentOrderInfo, subOrdersInfo, workflowDeposit = "0", transactionOptions, checkTxBeforeSend = false) {
|
|
108
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
const contract = BlockchainConnector_1.default.getInstance().getContract(transactionOptions);
|
|
110
|
+
(0, utils_2.checkIfActionAccountInitialized)(transactionOptions);
|
|
111
|
+
const preparedInfo = Object.assign(Object.assign({}, parentOrderInfo), { externalId: (0, utils_1.formatBytes32String)(parentOrderInfo.externalId) });
|
|
112
|
+
const parentOrderInfoArgs = (0, utils_2.objectToTuple)(preparedInfo, Order_1.OrderInfoStructure);
|
|
113
|
+
const preparedSubOrdersInfo = subOrdersInfo.map((o) => (Object.assign(Object.assign({}, o), { externalId: (0, utils_1.formatBytes32String)(o.externalId) })));
|
|
114
|
+
const subOrdersInfoArgs = (0, utils_2.objectToTuple)(preparedSubOrdersInfo, Order_1.OrderInfoStructureArray);
|
|
115
|
+
if (checkTxBeforeSend) {
|
|
116
|
+
yield TxManager_1.default.dryRun(contract.methods.createWorkflow, [parentOrderInfoArgs, workflowDeposit, subOrdersInfoArgs], transactionOptions);
|
|
117
|
+
}
|
|
118
|
+
yield TxManager_1.default.execute(contract.methods.createWorkflow, [parentOrderInfoArgs, workflowDeposit, subOrdersInfoArgs], transactionOptions);
|
|
216
119
|
});
|
|
217
|
-
}
|
|
120
|
+
}
|
|
218
121
|
/**
|
|
219
122
|
* Function for cancel workflow
|
|
220
123
|
* @param parentOrderId - Parent order id
|
|
221
124
|
* @returns {Promise<void>} - Does not return id of created order!
|
|
222
125
|
*/
|
|
223
|
-
|
|
224
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
case 0:
|
|
229
|
-
contract = BlockchainConnector_1.default.getInstance().getContract(transactionOptions);
|
|
230
|
-
(0, utils_2.checkIfActionAccountInitialized)(transactionOptions);
|
|
231
|
-
return [4 /*yield*/, TxManager_1.default.execute(contract.methods.cancelWorkflow, [perentOrderId], transactionOptions)];
|
|
232
|
-
case 1:
|
|
233
|
-
_a.sent();
|
|
234
|
-
return [2 /*return*/];
|
|
235
|
-
}
|
|
236
|
-
});
|
|
126
|
+
static cancelWorkflow(perentOrderId, transactionOptions) {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
const contract = BlockchainConnector_1.default.getInstance().getContract(transactionOptions);
|
|
129
|
+
(0, utils_2.checkIfActionAccountInitialized)(transactionOptions);
|
|
130
|
+
yield TxManager_1.default.execute(contract.methods.cancelWorkflow, [perentOrderId], transactionOptions);
|
|
237
131
|
});
|
|
238
|
-
}
|
|
132
|
+
}
|
|
239
133
|
/**
|
|
240
134
|
* Function for withdraw workflow change
|
|
241
135
|
* @param parentOrderId - Parent order id
|
|
242
136
|
* @returns {Promise<void>} - Does not return id of created order!
|
|
243
137
|
*/
|
|
244
|
-
|
|
245
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
case 0:
|
|
250
|
-
contract = BlockchainConnector_1.default.getInstance().getContract(transactionOptions);
|
|
251
|
-
(0, utils_2.checkIfActionAccountInitialized)(transactionOptions);
|
|
252
|
-
return [4 /*yield*/, TxManager_1.default.execute(contract.methods.withdrawWorkflowChange, [parentOrderId], transactionOptions)];
|
|
253
|
-
case 1:
|
|
254
|
-
_a.sent();
|
|
255
|
-
return [2 /*return*/];
|
|
256
|
-
}
|
|
257
|
-
});
|
|
138
|
+
static withdrawWorkflowChange(parentOrderId, transactionOptions) {
|
|
139
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
140
|
+
const contract = BlockchainConnector_1.default.getInstance().getContract(transactionOptions);
|
|
141
|
+
(0, utils_2.checkIfActionAccountInitialized)(transactionOptions);
|
|
142
|
+
yield TxManager_1.default.execute(contract.methods.withdrawWorkflowChange, [parentOrderId], transactionOptions);
|
|
258
143
|
});
|
|
259
|
-
}
|
|
144
|
+
}
|
|
260
145
|
/**
|
|
261
146
|
* Function for refilling order deposit
|
|
262
147
|
* @param orderId - order id
|
|
263
148
|
* @param amount - amount of tokens to refilling
|
|
264
149
|
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
265
150
|
*/
|
|
266
|
-
|
|
267
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
case 0:
|
|
272
|
-
contract = BlockchainConnector_1.default.getInstance().getContract(transactionOptions);
|
|
273
|
-
(0, utils_2.checkIfActionAccountInitialized)(transactionOptions);
|
|
274
|
-
return [4 /*yield*/, TxManager_1.default.execute(contract.methods.refillOrder, [orderId, amount], transactionOptions)];
|
|
275
|
-
case 1:
|
|
276
|
-
_a.sent();
|
|
277
|
-
return [2 /*return*/];
|
|
278
|
-
}
|
|
279
|
-
});
|
|
151
|
+
static refillOrderDeposit(orderId, amount, transactionOptions) {
|
|
152
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
153
|
+
const contract = BlockchainConnector_1.default.getInstance().getContract(transactionOptions);
|
|
154
|
+
(0, utils_2.checkIfActionAccountInitialized)(transactionOptions);
|
|
155
|
+
yield TxManager_1.default.execute(contract.methods.refillOrder, [orderId, amount], transactionOptions);
|
|
280
156
|
});
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
executedCount = 0;
|
|
300
|
-
return [3 /*break*/, 4];
|
|
301
|
-
case 4:
|
|
302
|
-
if (!(executedCount === orderIds.length)) return [3 /*break*/, 6];
|
|
303
|
-
return [4 /*yield*/, TxManager_1.default.execute(contract.methods.unlockProfitByList, [orderIds], transactionOptions)];
|
|
304
|
-
case 5:
|
|
305
|
-
_a.sent();
|
|
306
|
-
return [3 /*break*/, 10];
|
|
307
|
-
case 6:
|
|
308
|
-
_i = 0, orderIds_1 = orderIds;
|
|
309
|
-
_a.label = 7;
|
|
310
|
-
case 7:
|
|
311
|
-
if (!(_i < orderIds_1.length)) return [3 /*break*/, 10];
|
|
312
|
-
orderId = orderIds_1[_i];
|
|
313
|
-
return [4 /*yield*/, new Order_2.default(orderId).unlockProfit()];
|
|
314
|
-
case 8:
|
|
315
|
-
_a.sent();
|
|
316
|
-
_a.label = 9;
|
|
317
|
-
case 9:
|
|
318
|
-
_i++;
|
|
319
|
-
return [3 /*break*/, 7];
|
|
320
|
-
case 10: return [2 /*return*/];
|
|
157
|
+
}
|
|
158
|
+
static unlockProfitByOrderList(orderIds, transactionOptions) {
|
|
159
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
+
const contract = BlockchainConnector_1.default.getInstance().getContract(transactionOptions);
|
|
161
|
+
(0, utils_2.checkIfActionAccountInitialized)(transactionOptions);
|
|
162
|
+
let executedCount;
|
|
163
|
+
try {
|
|
164
|
+
executedCount = +(yield TxManager_1.default.dryRun(contract.methods.unlockProfitByList, [orderIds], transactionOptions));
|
|
165
|
+
}
|
|
166
|
+
catch (e) {
|
|
167
|
+
executedCount = 0;
|
|
168
|
+
}
|
|
169
|
+
if (executedCount === orderIds.length) {
|
|
170
|
+
yield TxManager_1.default.execute(contract.methods.unlockProfitByList, [orderIds], transactionOptions);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
for (const orderId of orderIds) {
|
|
174
|
+
yield new Order_2.default(orderId).unlockProfit();
|
|
321
175
|
}
|
|
322
|
-
}
|
|
176
|
+
}
|
|
323
177
|
});
|
|
324
|
-
}
|
|
178
|
+
}
|
|
325
179
|
/**
|
|
326
180
|
* Function for adding event listeners on order created event in orders factory contract
|
|
327
181
|
* @param callback - function for processing created order
|
|
328
182
|
* @returns unsubscribe - unsubscribe function from event
|
|
329
183
|
*/
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
var subscription = contract.events
|
|
184
|
+
static onCreated(callback) {
|
|
185
|
+
const contract = BlockchainEventsListener_1.default.getInstance().getContract();
|
|
186
|
+
const logger = this.logger.child({ method: "onOrderCreated" });
|
|
187
|
+
const subscription = contract.events
|
|
335
188
|
.OrderCreated()
|
|
336
|
-
.on("data",
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
hash: event.blockHash,
|
|
342
|
-
});
|
|
343
|
-
return [2 /*return*/];
|
|
189
|
+
.on("data", (event) => __awaiter(this, void 0, void 0, function* () {
|
|
190
|
+
//consumer: string, externalId: string, offerId: string, orderId: string
|
|
191
|
+
callback(event.returnValues.consumer, (0, utils_1.parseBytes32String)(event.returnValues.externalId), event.returnValues.offerId, event.returnValues.parentOrderId, event.returnValues.orderId, {
|
|
192
|
+
index: event.blockNumber,
|
|
193
|
+
hash: event.blockHash,
|
|
344
194
|
});
|
|
345
|
-
})
|
|
346
|
-
.on("error",
|
|
195
|
+
}))
|
|
196
|
+
.on("error", (error, receipt) => {
|
|
347
197
|
if (receipt)
|
|
348
198
|
return; // Used to avoid logging of transaction rejected
|
|
349
199
|
logger.warn(error);
|
|
350
200
|
});
|
|
351
|
-
return
|
|
352
|
-
}
|
|
201
|
+
return () => subscription.unsubscribe();
|
|
202
|
+
}
|
|
353
203
|
/**
|
|
354
204
|
* Function for adding event listeners on order started event in orders contract
|
|
355
205
|
* @param callback - function for processing suborder filled event
|
|
356
206
|
* @param orderId - order id
|
|
357
207
|
* @returns unsubscribe - unsubscribe function from event
|
|
358
208
|
*/
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
var subscription = contract.events
|
|
209
|
+
static onStarted(callback, orderId) {
|
|
210
|
+
const contract = BlockchainEventsListener_1.default.getInstance().getContract();
|
|
211
|
+
const logger = this.logger.child({ method: "onOrderStarted" });
|
|
212
|
+
const subscription = contract.events
|
|
364
213
|
.OrderStarted()
|
|
365
|
-
.on("data",
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
hash: event.blockHash,
|
|
373
|
-
});
|
|
374
|
-
return [2 /*return*/];
|
|
214
|
+
.on("data", (event) => __awaiter(this, void 0, void 0, function* () {
|
|
215
|
+
if (orderId && event.returnValues.orderId != orderId) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
callback(event.returnValues.orderId, event.returnValues.consumer, {
|
|
219
|
+
index: event.blockNumber,
|
|
220
|
+
hash: event.blockHash,
|
|
375
221
|
});
|
|
376
|
-
})
|
|
377
|
-
.on("error",
|
|
222
|
+
}))
|
|
223
|
+
.on("error", (error, receipt) => {
|
|
378
224
|
if (receipt)
|
|
379
225
|
return; // Used to avoid logging of transaction rejected
|
|
380
226
|
logger.warn(error);
|
|
381
227
|
});
|
|
382
|
-
return
|
|
383
|
-
}
|
|
228
|
+
return () => subscription.unsubscribe();
|
|
229
|
+
}
|
|
384
230
|
/**
|
|
385
231
|
* Function for adding event listeners on order updated status event in orders contract
|
|
386
232
|
* @param callback - function for processing order updated status event
|
|
387
233
|
* @param orderId - order id
|
|
388
234
|
* @returns unsubscribe - unsubscribe function from event
|
|
389
235
|
*/
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
var subscription = contract.events
|
|
236
|
+
static onStatusUpdated(callback, orderId) {
|
|
237
|
+
const contract = BlockchainEventsListener_1.default.getInstance().getContract();
|
|
238
|
+
const logger = this.logger.child({ method: "onOrdersStatusUpdated" });
|
|
239
|
+
const subscription = contract.events
|
|
395
240
|
.OrderStatusUpdated()
|
|
396
|
-
.on("data",
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
hash: event.blockHash,
|
|
404
|
-
});
|
|
405
|
-
return [2 /*return*/];
|
|
241
|
+
.on("data", (event) => __awaiter(this, void 0, void 0, function* () {
|
|
242
|
+
if (orderId && event.returnValues.orderId != orderId) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
callback(event.returnValues.orderId, event.returnValues.status, {
|
|
246
|
+
index: event.blockNumber,
|
|
247
|
+
hash: event.blockHash,
|
|
406
248
|
});
|
|
407
|
-
})
|
|
408
|
-
.on("error",
|
|
249
|
+
}))
|
|
250
|
+
.on("error", (error, receipt) => {
|
|
409
251
|
if (receipt)
|
|
410
252
|
return; // Used to avoid logging of transaction rejected
|
|
411
253
|
logger.warn(error);
|
|
412
254
|
});
|
|
413
|
-
return
|
|
414
|
-
}
|
|
255
|
+
return () => subscription.unsubscribe();
|
|
256
|
+
}
|
|
415
257
|
/**
|
|
416
258
|
* Function for adding event listeners on order refilled event in orders contract
|
|
417
259
|
* @param callback - function for processing order refilled event
|
|
@@ -419,65 +261,57 @@ var Orders = /** @class */ (function () {
|
|
|
419
261
|
* @param orderId - order id
|
|
420
262
|
* @returns unsubscribe - unsubscribe function from event
|
|
421
263
|
*/
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
var subscription = contract.events
|
|
264
|
+
static onDepositRefilled(callback, consumer, orderId) {
|
|
265
|
+
const contract = BlockchainEventsListener_1.default.getInstance().getContract();
|
|
266
|
+
const logger = this.logger.child({ method: "onOrderDepositRefilled" });
|
|
267
|
+
const subscription = contract.events
|
|
427
268
|
.OrderDepositRefilled()
|
|
428
|
-
.on("data",
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
hash: event.blockHash,
|
|
439
|
-
});
|
|
440
|
-
return [2 /*return*/];
|
|
269
|
+
.on("data", (event) => __awaiter(this, void 0, void 0, function* () {
|
|
270
|
+
if (orderId && event.returnValues.orderId != orderId) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
if (consumer && event.returnValues.consumer != consumer) {
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
callback(event.returnValues.orderId, event.returnValues.consumer, event.returnValues.amount, {
|
|
277
|
+
index: event.blockNumber,
|
|
278
|
+
hash: event.blockHash,
|
|
441
279
|
});
|
|
442
|
-
})
|
|
443
|
-
.on("error",
|
|
280
|
+
}))
|
|
281
|
+
.on("error", (error, receipt) => {
|
|
444
282
|
if (receipt)
|
|
445
283
|
return; // Used to avoid logging of transaction rejected
|
|
446
284
|
logger.warn(error);
|
|
447
285
|
});
|
|
448
|
-
return
|
|
449
|
-
}
|
|
286
|
+
return () => subscription.unsubscribe();
|
|
287
|
+
}
|
|
450
288
|
/**
|
|
451
289
|
* Function for adding event listeners on order changed withdrawn event in orders contract
|
|
452
290
|
* @param callback - function for processing order changed withdrawn event
|
|
453
291
|
* @param orderId - order id
|
|
454
292
|
* @returns unsubscribe - unsubscribe function from event
|
|
455
293
|
*/
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
var subscription = contract.events
|
|
294
|
+
static onChangedWithdrawn(callback, orderId) {
|
|
295
|
+
const contract = BlockchainEventsListener_1.default.getInstance().getContract();
|
|
296
|
+
const logger = this.logger.child({ method: "onOrderChangedWithdrawn" });
|
|
297
|
+
const subscription = contract.events
|
|
461
298
|
.OrderChangedWithdrawn()
|
|
462
|
-
.on("data",
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
hash: event.blockHash,
|
|
470
|
-
});
|
|
471
|
-
return [2 /*return*/];
|
|
299
|
+
.on("data", (event) => __awaiter(this, void 0, void 0, function* () {
|
|
300
|
+
if (orderId && event.returnValues.orderId != orderId) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
callback(event.returnValues.orderId, event.returnValues.consumer, event.returnValues.change, {
|
|
304
|
+
index: event.blockNumber,
|
|
305
|
+
hash: event.blockHash,
|
|
472
306
|
});
|
|
473
|
-
})
|
|
474
|
-
.on("error",
|
|
307
|
+
}))
|
|
308
|
+
.on("error", (error, receipt) => {
|
|
475
309
|
if (receipt)
|
|
476
310
|
return; // Used to avoid logging of transaction rejected
|
|
477
311
|
logger.warn(error);
|
|
478
312
|
});
|
|
479
|
-
return
|
|
480
|
-
}
|
|
313
|
+
return () => subscription.unsubscribe();
|
|
314
|
+
}
|
|
481
315
|
/**
|
|
482
316
|
* Function for adding event listeners on order changed refunded event in orders contract
|
|
483
317
|
* @param callback - function for processing order changed refunded event
|
|
@@ -485,34 +319,30 @@ var Orders = /** @class */ (function () {
|
|
|
485
319
|
* @param orderId - order id
|
|
486
320
|
* @returns unsubscribe - unsubscribe function from event
|
|
487
321
|
*/
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
var subscription = contract.events
|
|
322
|
+
static onProfitWithdrawn(callback, orderId, tokenReceiver) {
|
|
323
|
+
const contract = BlockchainEventsListener_1.default.getInstance().getContract();
|
|
324
|
+
const logger = this.logger.child({ method: "onOrderProfitWithdrawn" });
|
|
325
|
+
const subscription = contract.events
|
|
493
326
|
.OrderProfitWithdrawn()
|
|
494
|
-
.on("data",
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
hash: event.blockHash,
|
|
505
|
-
});
|
|
506
|
-
return [2 /*return*/];
|
|
327
|
+
.on("data", (event) => __awaiter(this, void 0, void 0, function* () {
|
|
328
|
+
if (orderId && event.returnValues.orderId != orderId) {
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
if (tokenReceiver && event.returnValues.tokenReceiver != tokenReceiver) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
callback(event.returnValues.orderId, event.returnValues.tokenReceiver, event.returnValues.profit, {
|
|
335
|
+
index: event.blockNumber,
|
|
336
|
+
hash: event.blockHash,
|
|
507
337
|
});
|
|
508
|
-
})
|
|
509
|
-
.on("error",
|
|
338
|
+
}))
|
|
339
|
+
.on("error", (error, receipt) => {
|
|
510
340
|
if (receipt)
|
|
511
341
|
return; // Used to avoid logging of transaction rejected
|
|
512
342
|
logger.warn(error);
|
|
513
343
|
});
|
|
514
|
-
return
|
|
515
|
-
}
|
|
344
|
+
return () => subscription.unsubscribe();
|
|
345
|
+
}
|
|
516
346
|
/**
|
|
517
347
|
* Function for adding event listeners on order awaiting payment event in orders contract
|
|
518
348
|
* @param callback - function for processing order awaiting payment event
|
|
@@ -520,34 +350,30 @@ var Orders = /** @class */ (function () {
|
|
|
520
350
|
* @param orderId - order id
|
|
521
351
|
* @returns unsubscribe - unsubscribe function from event
|
|
522
352
|
*/
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
var subscription = contract.events
|
|
353
|
+
static onAwaitingPaymentChanged(callback, consumer, orderId) {
|
|
354
|
+
const contract = BlockchainEventsListener_1.default.getInstance().getContract();
|
|
355
|
+
const logger = this.logger.child({ method: "onOrderAwaitingPaymentChanged" });
|
|
356
|
+
const subscription = contract.events
|
|
528
357
|
.OrderAwaitingPaymentChanged()
|
|
529
|
-
.on("data",
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
hash: event.blockHash,
|
|
540
|
-
});
|
|
541
|
-
return [2 /*return*/];
|
|
358
|
+
.on("data", (event) => __awaiter(this, void 0, void 0, function* () {
|
|
359
|
+
if (orderId && event.returnValues.orderId != orderId) {
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
if (consumer && event.returnValues.consumer != consumer) {
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
callback(event.returnValues.orderId, event.returnValues.consumer, event.returnValues.awaitingPayment, {
|
|
366
|
+
index: event.blockNumber,
|
|
367
|
+
hash: event.blockHash,
|
|
542
368
|
});
|
|
543
|
-
})
|
|
544
|
-
.on("error",
|
|
369
|
+
}))
|
|
370
|
+
.on("error", (error, receipt) => {
|
|
545
371
|
if (receipt)
|
|
546
372
|
return; // Used to avoid logging of transaction rejected
|
|
547
373
|
logger.warn(error);
|
|
548
374
|
});
|
|
549
|
-
return
|
|
550
|
-
}
|
|
375
|
+
return () => subscription.unsubscribe();
|
|
376
|
+
}
|
|
551
377
|
/**
|
|
552
378
|
* Function for adding event listeners on order encrypted result updated event in orders contract
|
|
553
379
|
* @param callback - function for processing order encrypted result updated event
|
|
@@ -555,34 +381,30 @@ var Orders = /** @class */ (function () {
|
|
|
555
381
|
* @param orderId - order id
|
|
556
382
|
* @returns unsubscribe - unsubscribe function from event
|
|
557
383
|
*/
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
var subscription = contract.events
|
|
384
|
+
static onEncryptedResultUpdated(callback, consumer, orderId) {
|
|
385
|
+
const contract = BlockchainEventsListener_1.default.getInstance().getContract();
|
|
386
|
+
const logger = this.logger.child({ method: "onOrderEncryptedResultUpdated" });
|
|
387
|
+
const subscription = contract.events
|
|
563
388
|
.OrderEncryptedResultUpdated()
|
|
564
|
-
.on("data",
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
hash: event.blockHash,
|
|
575
|
-
});
|
|
576
|
-
return [2 /*return*/];
|
|
389
|
+
.on("data", (event) => __awaiter(this, void 0, void 0, function* () {
|
|
390
|
+
if (orderId && event.returnValues.orderId != orderId) {
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
if (consumer && event.returnValues.consumer != consumer) {
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
callback(event.returnValues.orderId, event.returnValues.consumer, event.returnValues.encryptedResult, {
|
|
397
|
+
index: event.blockNumber,
|
|
398
|
+
hash: event.blockHash,
|
|
577
399
|
});
|
|
578
|
-
})
|
|
579
|
-
.on("error",
|
|
400
|
+
}))
|
|
401
|
+
.on("error", (error, receipt) => {
|
|
580
402
|
if (receipt)
|
|
581
403
|
return; // Used to avoid logging of transaction rejected
|
|
582
404
|
logger.warn(error);
|
|
583
405
|
});
|
|
584
|
-
return
|
|
585
|
-
}
|
|
406
|
+
return () => subscription.unsubscribe();
|
|
407
|
+
}
|
|
586
408
|
/**
|
|
587
409
|
* Function for adding event listeners on OrderOptionsDepositSpentChanged event in orders contract
|
|
588
410
|
* @param callback - function for processing order encrypted result updated event
|
|
@@ -590,34 +412,30 @@ var Orders = /** @class */ (function () {
|
|
|
590
412
|
* @param orderId - order id
|
|
591
413
|
* @returns unsubscribe - unsubscribe function from event
|
|
592
414
|
*/
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
var subscription = contract.events
|
|
415
|
+
static onOptionsDepositSpentChanged(callback, consumer, orderId) {
|
|
416
|
+
const contract = BlockchainEventsListener_1.default.getInstance().getContract();
|
|
417
|
+
const logger = this.logger.child({ method: "onOrderOptionsDepositSpentChanged" });
|
|
418
|
+
const subscription = contract.events
|
|
598
419
|
.OrderOptionsDepositSpentChanged()
|
|
599
|
-
.on("data",
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
hash: event.blockHash,
|
|
610
|
-
});
|
|
611
|
-
return [2 /*return*/];
|
|
420
|
+
.on("data", (event) => __awaiter(this, void 0, void 0, function* () {
|
|
421
|
+
if (orderId && event.returnValues.orderId != orderId) {
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
if (consumer && event.returnValues.consumer != consumer) {
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
callback(event.returnValues.consumer, event.returnValues.orderId, event.returnValues.value, {
|
|
428
|
+
index: event.blockNumber,
|
|
429
|
+
hash: event.blockHash,
|
|
612
430
|
});
|
|
613
|
-
})
|
|
614
|
-
.on("error",
|
|
431
|
+
}))
|
|
432
|
+
.on("error", (error, receipt) => {
|
|
615
433
|
if (receipt)
|
|
616
434
|
return; // Used to avoid logging of transaction rejected
|
|
617
435
|
logger.warn(error);
|
|
618
436
|
});
|
|
619
|
-
return
|
|
620
|
-
}
|
|
437
|
+
return () => subscription.unsubscribe();
|
|
438
|
+
}
|
|
621
439
|
/**
|
|
622
440
|
* Function for adding event listeners on onOrderProfitUnlocked event in orders contract
|
|
623
441
|
* @param callback - function for processing order encrypted result updated event
|
|
@@ -625,44 +443,39 @@ var Orders = /** @class */ (function () {
|
|
|
625
443
|
* @param orderId - order id
|
|
626
444
|
* @returns unsubscribe - unsubscribe function from event
|
|
627
445
|
*/
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
var subscription = contract.events
|
|
446
|
+
static onOProfitUnlocked(callback, tokenReceiver, orderId) {
|
|
447
|
+
const contract = BlockchainEventsListener_1.default.getInstance().getContract();
|
|
448
|
+
const logger = this.logger.child({ method: "onOrderProfitUnlocked" });
|
|
449
|
+
const subscription = contract.events
|
|
633
450
|
.OrderProfitUnlocked()
|
|
634
|
-
.on("data",
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
hash: event.blockHash,
|
|
645
|
-
});
|
|
646
|
-
return [2 /*return*/];
|
|
451
|
+
.on("data", (event) => __awaiter(this, void 0, void 0, function* () {
|
|
452
|
+
if (orderId && event.returnValues.orderId != orderId) {
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
if (tokenReceiver && event.returnValues.tokenReceiver != tokenReceiver) {
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
callback(event.returnValues.tokenReceiver, event.returnValues.orderId, event.returnValues.profit, {
|
|
459
|
+
index: event.blockNumber,
|
|
460
|
+
hash: event.blockHash,
|
|
647
461
|
});
|
|
648
|
-
})
|
|
649
|
-
.on("error",
|
|
462
|
+
}))
|
|
463
|
+
.on("error", (error, receipt) => {
|
|
650
464
|
if (receipt)
|
|
651
465
|
return; // Used to avoid logging of transaction rejected
|
|
652
466
|
logger.warn(error);
|
|
653
467
|
});
|
|
654
|
-
return
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
}());
|
|
468
|
+
return () => subscription.unsubscribe();
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
Orders.logger = logger_1.default.child({ className: "Orders" });
|
|
472
|
+
__decorate([
|
|
473
|
+
(0, utils_2.incrementMethodCall)()
|
|
474
|
+
], Orders, "createOrder", null);
|
|
475
|
+
__decorate([
|
|
476
|
+
(0, utils_2.incrementMethodCall)()
|
|
477
|
+
], Orders, "getByExternalId", null);
|
|
478
|
+
__decorate([
|
|
479
|
+
(0, utils_2.incrementMethodCall)()
|
|
480
|
+
], Orders, "createWorkflow", null);
|
|
668
481
|
exports.default = Orders;
|