@super-protocol/sdk-js 0.15.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 +466 -35
- 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.d.ts +4 -0
- package/build/models/Order.js +326 -559
- package/build/models/Provider.d.ts +2 -0
- package/build/models/Provider.js +74 -153
- package/build/models/TCB.js +67 -171
- package/build/models/TeeOffer.d.ts +1 -0
- package/build/models/TeeOffer.js +389 -731
- 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 +4 -1
- package/build/staticModels/Consensus.js +164 -220
- 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.d.ts +1 -0
- package/build/staticModels/Orders.js +286 -429
- 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.js +4 -4
- 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,98 +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
|
-
|
|
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;
|
|
69
33
|
}
|
|
70
|
-
Object.defineProperty(Orders, "address", {
|
|
71
|
-
get: function () {
|
|
72
|
-
return Superpro_1.default.address;
|
|
73
|
-
},
|
|
74
|
-
enumerable: false,
|
|
75
|
-
configurable: true
|
|
76
|
-
});
|
|
77
34
|
/**
|
|
78
35
|
* Function for fetching list of all orders ids
|
|
79
36
|
* @returns list of orders ids
|
|
80
37
|
*/
|
|
81
|
-
|
|
38
|
+
static getAll() {
|
|
82
39
|
var _a;
|
|
83
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
ordersCount = _b.sent();
|
|
94
|
-
for (orderId = ordersSet.size + 1; orderId <= ordersCount; orderId++) {
|
|
95
|
-
ordersSet.add(orderId.toString());
|
|
96
|
-
}
|
|
97
|
-
this.orders = Array.from(ordersSet);
|
|
98
|
-
return [2 /*return*/, this.orders];
|
|
99
|
-
}
|
|
100
|
-
});
|
|
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;
|
|
101
50
|
});
|
|
102
|
-
}
|
|
51
|
+
}
|
|
103
52
|
/**
|
|
104
53
|
* Function for fetching orders count
|
|
105
54
|
*/
|
|
106
|
-
|
|
107
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
108
|
-
|
|
109
|
-
return
|
|
110
|
-
switch (_b.label) {
|
|
111
|
-
case 0:
|
|
112
|
-
contract = BlockchainConnector_1.default.getInstance().getContract();
|
|
113
|
-
_a = Number;
|
|
114
|
-
return [4 /*yield*/, contract.methods.getOrdersCount().call()];
|
|
115
|
-
case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent()])];
|
|
116
|
-
}
|
|
117
|
-
});
|
|
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());
|
|
118
59
|
});
|
|
119
|
-
}
|
|
60
|
+
}
|
|
120
61
|
/**
|
|
121
62
|
* Function for creating orders
|
|
122
63
|
* @param orderInfo - order info for new order
|
|
@@ -124,61 +65,37 @@ var Orders = /** @class */ (function () {
|
|
|
124
65
|
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
125
66
|
* @returns {Promise<void>} - Does not return id of created order!
|
|
126
67
|
*/
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
(0, utils_2.checkIfActionAccountInitialized)(transactionOptions);
|
|
138
|
-
preparedInfo = __assign(__assign({}, orderInfo), { externalId: (0, utils_1.formatBytes32String)(orderInfo.externalId) });
|
|
139
|
-
orderInfoArguments = (0, utils_2.objectToTuple)(preparedInfo, Order_1.OrderInfoStructure);
|
|
140
|
-
if (!checkTxBeforeSend) return [3 /*break*/, 2];
|
|
141
|
-
return [4 /*yield*/, TxManager_1.default.dryRun(contract.methods.createOrder, [orderInfoArguments, deposit, suspended], transactionOptions)];
|
|
142
|
-
case 1:
|
|
143
|
-
_a.sent();
|
|
144
|
-
_a.label = 2;
|
|
145
|
-
case 2: return [4 /*yield*/, TxManager_1.default.execute(contract.methods.createOrder, [orderInfoArguments, deposit, suspended], transactionOptions)];
|
|
146
|
-
case 3:
|
|
147
|
-
_a.sent();
|
|
148
|
-
return [2 /*return*/];
|
|
149
|
-
}
|
|
150
|
-
});
|
|
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);
|
|
151
78
|
});
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
options.toBlock = toBlock;
|
|
171
|
-
return [4 /*yield*/, contract.getPastEvents("OrderCreated", options)];
|
|
172
|
-
case 1:
|
|
173
|
-
foundIds = _a.sent();
|
|
174
|
-
notFound = __assign(__assign({}, filter), { offerId: "-1", parentOrderId: "-1", orderId: "-1" });
|
|
175
|
-
response = foundIds.length > 0 ? foundIds[0].returnValues : notFound;
|
|
176
|
-
response.externalId = (0, utils_1.parseBytes32String)(response.externalId);
|
|
177
|
-
return [2 /*return*/, response];
|
|
178
|
-
}
|
|
179
|
-
});
|
|
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;
|
|
180
97
|
});
|
|
181
|
-
}
|
|
98
|
+
}
|
|
182
99
|
/**
|
|
183
100
|
* Function for create workflow
|
|
184
101
|
* @param parentOrderInfo - order info for new order
|
|
@@ -187,187 +104,156 @@ var Orders = /** @class */ (function () {
|
|
|
187
104
|
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
188
105
|
* @returns {Promise<void>} - Does not return id of created order!
|
|
189
106
|
*/
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
preparedSubOrdersInfo = subOrdersInfo.map(function (o) { return (__assign(__assign({}, o), { externalId: (0, utils_1.formatBytes32String)(o.externalId) })); });
|
|
203
|
-
subOrdersInfoArgs = (0, utils_2.objectToTuple)(preparedSubOrdersInfo, Order_1.OrderInfoStructureArray);
|
|
204
|
-
if (!checkTxBeforeSend) return [3 /*break*/, 2];
|
|
205
|
-
return [4 /*yield*/, TxManager_1.default.dryRun(contract.methods.createWorkflow, [parentOrderInfoArgs, workflowDeposit, subOrdersInfoArgs], transactionOptions)];
|
|
206
|
-
case 1:
|
|
207
|
-
_a.sent();
|
|
208
|
-
_a.label = 2;
|
|
209
|
-
case 2: return [4 /*yield*/, TxManager_1.default.execute(contract.methods.createWorkflow, [parentOrderInfoArgs, workflowDeposit, subOrdersInfoArgs], transactionOptions)];
|
|
210
|
-
case 3:
|
|
211
|
-
_a.sent();
|
|
212
|
-
return [2 /*return*/];
|
|
213
|
-
}
|
|
214
|
-
});
|
|
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);
|
|
215
119
|
});
|
|
216
|
-
}
|
|
120
|
+
}
|
|
217
121
|
/**
|
|
218
122
|
* Function for cancel workflow
|
|
219
123
|
* @param parentOrderId - Parent order id
|
|
220
124
|
* @returns {Promise<void>} - Does not return id of created order!
|
|
221
125
|
*/
|
|
222
|
-
|
|
223
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
case 0:
|
|
228
|
-
contract = BlockchainConnector_1.default.getInstance().getContract(transactionOptions);
|
|
229
|
-
(0, utils_2.checkIfActionAccountInitialized)(transactionOptions);
|
|
230
|
-
return [4 /*yield*/, TxManager_1.default.execute(contract.methods.cancelWorkflow, [perentOrderId], transactionOptions)];
|
|
231
|
-
case 1:
|
|
232
|
-
_a.sent();
|
|
233
|
-
return [2 /*return*/];
|
|
234
|
-
}
|
|
235
|
-
});
|
|
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);
|
|
236
131
|
});
|
|
237
|
-
}
|
|
132
|
+
}
|
|
238
133
|
/**
|
|
239
134
|
* Function for withdraw workflow change
|
|
240
135
|
* @param parentOrderId - Parent order id
|
|
241
136
|
* @returns {Promise<void>} - Does not return id of created order!
|
|
242
137
|
*/
|
|
243
|
-
|
|
244
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
case 0:
|
|
249
|
-
contract = BlockchainConnector_1.default.getInstance().getContract(transactionOptions);
|
|
250
|
-
(0, utils_2.checkIfActionAccountInitialized)(transactionOptions);
|
|
251
|
-
return [4 /*yield*/, TxManager_1.default.execute(contract.methods.withdrawWorkflowChange, [parentOrderId], transactionOptions)];
|
|
252
|
-
case 1:
|
|
253
|
-
_a.sent();
|
|
254
|
-
return [2 /*return*/];
|
|
255
|
-
}
|
|
256
|
-
});
|
|
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);
|
|
257
143
|
});
|
|
258
|
-
}
|
|
144
|
+
}
|
|
259
145
|
/**
|
|
260
146
|
* Function for refilling order deposit
|
|
261
147
|
* @param orderId - order id
|
|
262
148
|
* @param amount - amount of tokens to refilling
|
|
263
149
|
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
264
150
|
*/
|
|
265
|
-
|
|
266
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
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);
|
|
156
|
+
});
|
|
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();
|
|
277
175
|
}
|
|
278
|
-
}
|
|
176
|
+
}
|
|
279
177
|
});
|
|
280
|
-
}
|
|
178
|
+
}
|
|
281
179
|
/**
|
|
282
180
|
* Function for adding event listeners on order created event in orders factory contract
|
|
283
181
|
* @param callback - function for processing created order
|
|
284
182
|
* @returns unsubscribe - unsubscribe function from event
|
|
285
183
|
*/
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
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
|
|
291
188
|
.OrderCreated()
|
|
292
|
-
.on("data",
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
hash: event.blockHash,
|
|
298
|
-
});
|
|
299
|
-
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,
|
|
300
194
|
});
|
|
301
|
-
})
|
|
302
|
-
.on("error",
|
|
195
|
+
}))
|
|
196
|
+
.on("error", (error, receipt) => {
|
|
303
197
|
if (receipt)
|
|
304
198
|
return; // Used to avoid logging of transaction rejected
|
|
305
199
|
logger.warn(error);
|
|
306
200
|
});
|
|
307
|
-
return
|
|
308
|
-
}
|
|
201
|
+
return () => subscription.unsubscribe();
|
|
202
|
+
}
|
|
309
203
|
/**
|
|
310
204
|
* Function for adding event listeners on order started event in orders contract
|
|
311
205
|
* @param callback - function for processing suborder filled event
|
|
312
206
|
* @param orderId - order id
|
|
313
207
|
* @returns unsubscribe - unsubscribe function from event
|
|
314
208
|
*/
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
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
|
|
320
213
|
.OrderStarted()
|
|
321
|
-
.on("data",
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
hash: event.blockHash,
|
|
329
|
-
});
|
|
330
|
-
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,
|
|
331
221
|
});
|
|
332
|
-
})
|
|
333
|
-
.on("error",
|
|
222
|
+
}))
|
|
223
|
+
.on("error", (error, receipt) => {
|
|
334
224
|
if (receipt)
|
|
335
225
|
return; // Used to avoid logging of transaction rejected
|
|
336
226
|
logger.warn(error);
|
|
337
227
|
});
|
|
338
|
-
return
|
|
339
|
-
}
|
|
228
|
+
return () => subscription.unsubscribe();
|
|
229
|
+
}
|
|
340
230
|
/**
|
|
341
231
|
* Function for adding event listeners on order updated status event in orders contract
|
|
342
232
|
* @param callback - function for processing order updated status event
|
|
343
233
|
* @param orderId - order id
|
|
344
234
|
* @returns unsubscribe - unsubscribe function from event
|
|
345
235
|
*/
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
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
|
|
351
240
|
.OrderStatusUpdated()
|
|
352
|
-
.on("data",
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
hash: event.blockHash,
|
|
360
|
-
});
|
|
361
|
-
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,
|
|
362
248
|
});
|
|
363
|
-
})
|
|
364
|
-
.on("error",
|
|
249
|
+
}))
|
|
250
|
+
.on("error", (error, receipt) => {
|
|
365
251
|
if (receipt)
|
|
366
252
|
return; // Used to avoid logging of transaction rejected
|
|
367
253
|
logger.warn(error);
|
|
368
254
|
});
|
|
369
|
-
return
|
|
370
|
-
}
|
|
255
|
+
return () => subscription.unsubscribe();
|
|
256
|
+
}
|
|
371
257
|
/**
|
|
372
258
|
* Function for adding event listeners on order refilled event in orders contract
|
|
373
259
|
* @param callback - function for processing order refilled event
|
|
@@ -375,65 +261,57 @@ var Orders = /** @class */ (function () {
|
|
|
375
261
|
* @param orderId - order id
|
|
376
262
|
* @returns unsubscribe - unsubscribe function from event
|
|
377
263
|
*/
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
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
|
|
383
268
|
.OrderDepositRefilled()
|
|
384
|
-
.on("data",
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
hash: event.blockHash,
|
|
395
|
-
});
|
|
396
|
-
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,
|
|
397
279
|
});
|
|
398
|
-
})
|
|
399
|
-
.on("error",
|
|
280
|
+
}))
|
|
281
|
+
.on("error", (error, receipt) => {
|
|
400
282
|
if (receipt)
|
|
401
283
|
return; // Used to avoid logging of transaction rejected
|
|
402
284
|
logger.warn(error);
|
|
403
285
|
});
|
|
404
|
-
return
|
|
405
|
-
}
|
|
286
|
+
return () => subscription.unsubscribe();
|
|
287
|
+
}
|
|
406
288
|
/**
|
|
407
289
|
* Function for adding event listeners on order changed withdrawn event in orders contract
|
|
408
290
|
* @param callback - function for processing order changed withdrawn event
|
|
409
291
|
* @param orderId - order id
|
|
410
292
|
* @returns unsubscribe - unsubscribe function from event
|
|
411
293
|
*/
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
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
|
|
417
298
|
.OrderChangedWithdrawn()
|
|
418
|
-
.on("data",
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
hash: event.blockHash,
|
|
426
|
-
});
|
|
427
|
-
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,
|
|
428
306
|
});
|
|
429
|
-
})
|
|
430
|
-
.on("error",
|
|
307
|
+
}))
|
|
308
|
+
.on("error", (error, receipt) => {
|
|
431
309
|
if (receipt)
|
|
432
310
|
return; // Used to avoid logging of transaction rejected
|
|
433
311
|
logger.warn(error);
|
|
434
312
|
});
|
|
435
|
-
return
|
|
436
|
-
}
|
|
313
|
+
return () => subscription.unsubscribe();
|
|
314
|
+
}
|
|
437
315
|
/**
|
|
438
316
|
* Function for adding event listeners on order changed refunded event in orders contract
|
|
439
317
|
* @param callback - function for processing order changed refunded event
|
|
@@ -441,34 +319,30 @@ var Orders = /** @class */ (function () {
|
|
|
441
319
|
* @param orderId - order id
|
|
442
320
|
* @returns unsubscribe - unsubscribe function from event
|
|
443
321
|
*/
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
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
|
|
449
326
|
.OrderProfitWithdrawn()
|
|
450
|
-
.on("data",
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
hash: event.blockHash,
|
|
461
|
-
});
|
|
462
|
-
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,
|
|
463
337
|
});
|
|
464
|
-
})
|
|
465
|
-
.on("error",
|
|
338
|
+
}))
|
|
339
|
+
.on("error", (error, receipt) => {
|
|
466
340
|
if (receipt)
|
|
467
341
|
return; // Used to avoid logging of transaction rejected
|
|
468
342
|
logger.warn(error);
|
|
469
343
|
});
|
|
470
|
-
return
|
|
471
|
-
}
|
|
344
|
+
return () => subscription.unsubscribe();
|
|
345
|
+
}
|
|
472
346
|
/**
|
|
473
347
|
* Function for adding event listeners on order awaiting payment event in orders contract
|
|
474
348
|
* @param callback - function for processing order awaiting payment event
|
|
@@ -476,34 +350,30 @@ var Orders = /** @class */ (function () {
|
|
|
476
350
|
* @param orderId - order id
|
|
477
351
|
* @returns unsubscribe - unsubscribe function from event
|
|
478
352
|
*/
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
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
|
|
484
357
|
.OrderAwaitingPaymentChanged()
|
|
485
|
-
.on("data",
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
hash: event.blockHash,
|
|
496
|
-
});
|
|
497
|
-
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,
|
|
498
368
|
});
|
|
499
|
-
})
|
|
500
|
-
.on("error",
|
|
369
|
+
}))
|
|
370
|
+
.on("error", (error, receipt) => {
|
|
501
371
|
if (receipt)
|
|
502
372
|
return; // Used to avoid logging of transaction rejected
|
|
503
373
|
logger.warn(error);
|
|
504
374
|
});
|
|
505
|
-
return
|
|
506
|
-
}
|
|
375
|
+
return () => subscription.unsubscribe();
|
|
376
|
+
}
|
|
507
377
|
/**
|
|
508
378
|
* Function for adding event listeners on order encrypted result updated event in orders contract
|
|
509
379
|
* @param callback - function for processing order encrypted result updated event
|
|
@@ -511,34 +381,30 @@ var Orders = /** @class */ (function () {
|
|
|
511
381
|
* @param orderId - order id
|
|
512
382
|
* @returns unsubscribe - unsubscribe function from event
|
|
513
383
|
*/
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
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
|
|
519
388
|
.OrderEncryptedResultUpdated()
|
|
520
|
-
.on("data",
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
hash: event.blockHash,
|
|
531
|
-
});
|
|
532
|
-
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,
|
|
533
399
|
});
|
|
534
|
-
})
|
|
535
|
-
.on("error",
|
|
400
|
+
}))
|
|
401
|
+
.on("error", (error, receipt) => {
|
|
536
402
|
if (receipt)
|
|
537
403
|
return; // Used to avoid logging of transaction rejected
|
|
538
404
|
logger.warn(error);
|
|
539
405
|
});
|
|
540
|
-
return
|
|
541
|
-
}
|
|
406
|
+
return () => subscription.unsubscribe();
|
|
407
|
+
}
|
|
542
408
|
/**
|
|
543
409
|
* Function for adding event listeners on OrderOptionsDepositSpentChanged event in orders contract
|
|
544
410
|
* @param callback - function for processing order encrypted result updated event
|
|
@@ -546,34 +412,30 @@ var Orders = /** @class */ (function () {
|
|
|
546
412
|
* @param orderId - order id
|
|
547
413
|
* @returns unsubscribe - unsubscribe function from event
|
|
548
414
|
*/
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
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
|
|
554
419
|
.OrderOptionsDepositSpentChanged()
|
|
555
|
-
.on("data",
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
hash: event.blockHash,
|
|
566
|
-
});
|
|
567
|
-
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,
|
|
568
430
|
});
|
|
569
|
-
})
|
|
570
|
-
.on("error",
|
|
431
|
+
}))
|
|
432
|
+
.on("error", (error, receipt) => {
|
|
571
433
|
if (receipt)
|
|
572
434
|
return; // Used to avoid logging of transaction rejected
|
|
573
435
|
logger.warn(error);
|
|
574
436
|
});
|
|
575
|
-
return
|
|
576
|
-
}
|
|
437
|
+
return () => subscription.unsubscribe();
|
|
438
|
+
}
|
|
577
439
|
/**
|
|
578
440
|
* Function for adding event listeners on onOrderProfitUnlocked event in orders contract
|
|
579
441
|
* @param callback - function for processing order encrypted result updated event
|
|
@@ -581,44 +443,39 @@ var Orders = /** @class */ (function () {
|
|
|
581
443
|
* @param orderId - order id
|
|
582
444
|
* @returns unsubscribe - unsubscribe function from event
|
|
583
445
|
*/
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
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
|
|
589
450
|
.OrderProfitUnlocked()
|
|
590
|
-
.on("data",
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
hash: event.blockHash,
|
|
601
|
-
});
|
|
602
|
-
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,
|
|
603
461
|
});
|
|
604
|
-
})
|
|
605
|
-
.on("error",
|
|
462
|
+
}))
|
|
463
|
+
.on("error", (error, receipt) => {
|
|
606
464
|
if (receipt)
|
|
607
465
|
return; // Used to avoid logging of transaction rejected
|
|
608
466
|
logger.warn(error);
|
|
609
467
|
});
|
|
610
|
-
return
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
}());
|
|
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);
|
|
624
481
|
exports.default = Orders;
|