@super-protocol/sdk-js 0.10.1-beta.0 → 0.10.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.
package/build/models/Order.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
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
|
+
};
|
|
2
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -411,14 +422,14 @@ var Order = /** @class */ (function () {
|
|
|
411
422
|
Order.prototype.createSubOrder = function (subOrderInfo, blocking, holdSum, transactionOptions) {
|
|
412
423
|
if (holdSum === void 0) { holdSum = '0'; }
|
|
413
424
|
return __awaiter(this, void 0, void 0, function () {
|
|
414
|
-
var tupleSubOrder, params;
|
|
425
|
+
var preparedInfo, tupleSubOrder, params;
|
|
415
426
|
return __generator(this, function (_a) {
|
|
416
427
|
switch (_a.label) {
|
|
417
428
|
case 0:
|
|
418
429
|
transactionOptions !== null && transactionOptions !== void 0 ? transactionOptions : this.checkInitOrder(transactionOptions);
|
|
419
430
|
(0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
|
|
420
|
-
|
|
421
|
-
tupleSubOrder = (0, utils_1.objectToTuple)(
|
|
431
|
+
preparedInfo = __assign(__assign({}, subOrderInfo), { externalId: (0, utils_2.formatBytes32String)(subOrderInfo.externalId) });
|
|
432
|
+
tupleSubOrder = (0, utils_1.objectToTuple)(preparedInfo, Order_1.OrderInfoStructure);
|
|
422
433
|
params = {
|
|
423
434
|
blockParentOrder: blocking,
|
|
424
435
|
holdSum: holdSum,
|
|
@@ -449,8 +460,8 @@ var Order = /** @class */ (function () {
|
|
|
449
460
|
batch = new transactionOptions.web3.BatchRequest();
|
|
450
461
|
promises = subOrdersInfo.map(function (subOrderInfo) {
|
|
451
462
|
return new Promise(function (res, rej) {
|
|
452
|
-
|
|
453
|
-
var tupleSubOrder = (0, utils_1.objectToTuple)(
|
|
463
|
+
var preparedInfo = __assign(__assign({}, subOrderInfo), { externalId: (0, utils_2.formatBytes32String)(subOrderInfo.externalId) });
|
|
464
|
+
var tupleSubOrder = (0, utils_1.objectToTuple)(preparedInfo, Order_1.OrderInfoStructure);
|
|
454
465
|
var params = {
|
|
455
466
|
blockParentOrder: subOrderInfo.blocking,
|
|
456
467
|
holdSum: subOrderInfo.holdSum,
|
|
@@ -36,7 +36,19 @@ declare class OrdersFactory {
|
|
|
36
36
|
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
37
37
|
* @returns {Promise<void>} - Does not return id of created order!
|
|
38
38
|
*/
|
|
39
|
-
static createWorkflow(
|
|
39
|
+
static createWorkflow(parentOrderInfo: OrderInfo, subOrdersInfo: OrderInfo[], holdDeposit?: string, transactionOptions?: TransactionOptions): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Function for cancel workflow
|
|
42
|
+
* @param parentOrderId - Parent order id
|
|
43
|
+
* @returns {Promise<void>} - Does not return id of created order!
|
|
44
|
+
*/
|
|
45
|
+
static cancelWorkflow(perentOrderId: string, transactionOptions?: TransactionOptions): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Function for withdraw workflow change
|
|
48
|
+
* @param parentOrderId - Parent order id
|
|
49
|
+
* @returns {Promise<void>} - Does not return id of created order!
|
|
50
|
+
*/
|
|
51
|
+
static withdrawWorkflowChange(parentOrderId: string, transactionOptions?: TransactionOptions): Promise<void>;
|
|
40
52
|
/**
|
|
41
53
|
* Function for refilling order deposit
|
|
42
54
|
* @param orderId - order id
|
|
@@ -1,4 +1,15 @@
|
|
|
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
|
+
};
|
|
2
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -127,14 +138,14 @@ var OrdersFactory = /** @class */ (function () {
|
|
|
127
138
|
if (holdDeposit === void 0) { holdDeposit = "0"; }
|
|
128
139
|
if (suspended === void 0) { suspended = false; }
|
|
129
140
|
return __awaiter(this, void 0, void 0, function () {
|
|
130
|
-
var contract, orderInfoArguments;
|
|
141
|
+
var contract, preparedInfo, orderInfoArguments;
|
|
131
142
|
return __generator(this, function (_a) {
|
|
132
143
|
switch (_a.label) {
|
|
133
144
|
case 0:
|
|
134
145
|
contract = BlockchainConnector_1.default.getContractInstance(transactionOptions);
|
|
135
146
|
(0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
|
|
136
|
-
|
|
137
|
-
orderInfoArguments = (0, utils_1.objectToTuple)(
|
|
147
|
+
preparedInfo = __assign(__assign({}, orderInfo), { externalId: (0, utils_2.formatBytes32String)(orderInfo.externalId) });
|
|
148
|
+
orderInfoArguments = (0, utils_1.objectToTuple)(preparedInfo, Order_1.OrderInfoStructure);
|
|
138
149
|
return [4 /*yield*/, TxManager_1.default.execute(contract.methods.createOrder, [orderInfoArguments, holdDeposit, suspended], transactionOptions)];
|
|
139
150
|
case 1:
|
|
140
151
|
_a.sent();
|
|
@@ -177,20 +188,63 @@ var OrdersFactory = /** @class */ (function () {
|
|
|
177
188
|
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
178
189
|
* @returns {Promise<void>} - Does not return id of created order!
|
|
179
190
|
*/
|
|
180
|
-
OrdersFactory.createWorkflow = function (
|
|
191
|
+
OrdersFactory.createWorkflow = function (parentOrderInfo, subOrdersInfo, holdDeposit, transactionOptions) {
|
|
181
192
|
if (holdDeposit === void 0) { holdDeposit = "0"; }
|
|
182
193
|
return __awaiter(this, void 0, void 0, function () {
|
|
183
|
-
var contract,
|
|
194
|
+
var contract, preparedInfo, parentOrderInfoArgs, preparedSubOrdersInfo, subOrdersInfoArgs;
|
|
195
|
+
return __generator(this, function (_a) {
|
|
196
|
+
switch (_a.label) {
|
|
197
|
+
case 0:
|
|
198
|
+
contract = BlockchainConnector_1.default.getContractInstance(transactionOptions);
|
|
199
|
+
(0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
|
|
200
|
+
preparedInfo = __assign(__assign({}, parentOrderInfo), { externalId: (0, utils_2.formatBytes32String)(parentOrderInfo.externalId) });
|
|
201
|
+
parentOrderInfoArgs = (0, utils_1.objectToTuple)(preparedInfo, Order_1.OrderInfoStructure);
|
|
202
|
+
subOrdersInfo.forEach(function (o) { return (o.externalId = (0, utils_2.formatBytes32String)(o.externalId)); });
|
|
203
|
+
preparedSubOrdersInfo = subOrdersInfo.map(function (o) { return (__assign(__assign({}, o), { externalId: (0, utils_2.formatBytes32String)(o.externalId) })); });
|
|
204
|
+
subOrdersInfoArgs = (0, utils_1.objectToTuple)(preparedSubOrdersInfo, Order_1.OrderInfoStructureArray);
|
|
205
|
+
return [4 /*yield*/, TxManager_1.default.execute(contract.methods.createWorkflow, [parentOrderInfoArgs, holdDeposit, subOrdersInfoArgs], transactionOptions)];
|
|
206
|
+
case 1:
|
|
207
|
+
_a.sent();
|
|
208
|
+
return [2 /*return*/];
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* Function for cancel workflow
|
|
215
|
+
* @param parentOrderId - Parent order id
|
|
216
|
+
* @returns {Promise<void>} - Does not return id of created order!
|
|
217
|
+
*/
|
|
218
|
+
OrdersFactory.cancelWorkflow = function (perentOrderId, transactionOptions) {
|
|
219
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
220
|
+
var contract;
|
|
221
|
+
return __generator(this, function (_a) {
|
|
222
|
+
switch (_a.label) {
|
|
223
|
+
case 0:
|
|
224
|
+
contract = BlockchainConnector_1.default.getContractInstance(transactionOptions);
|
|
225
|
+
(0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
|
|
226
|
+
return [4 /*yield*/, TxManager_1.default.execute(contract.methods.cancelWorkflow, [perentOrderId], transactionOptions)];
|
|
227
|
+
case 1:
|
|
228
|
+
_a.sent();
|
|
229
|
+
return [2 /*return*/];
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
};
|
|
234
|
+
/**
|
|
235
|
+
* Function for withdraw workflow change
|
|
236
|
+
* @param parentOrderId - Parent order id
|
|
237
|
+
* @returns {Promise<void>} - Does not return id of created order!
|
|
238
|
+
*/
|
|
239
|
+
OrdersFactory.withdrawWorkflowChange = function (parentOrderId, transactionOptions) {
|
|
240
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
241
|
+
var contract;
|
|
184
242
|
return __generator(this, function (_a) {
|
|
185
243
|
switch (_a.label) {
|
|
186
244
|
case 0:
|
|
187
245
|
contract = BlockchainConnector_1.default.getContractInstance(transactionOptions);
|
|
188
246
|
(0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
|
|
189
|
-
|
|
190
|
-
perentOrderInfoArgs = (0, utils_1.objectToTuple)(perentOrderInfo, Order_1.OrderInfoStructure);
|
|
191
|
-
subOrdersInfo.forEach(function (o) { return o.externalId = (0, utils_2.formatBytes32String)(o.externalId); });
|
|
192
|
-
subOrdersInfoArgs = (0, utils_1.objectToTuple)(subOrdersInfo, Order_1.OrderInfoStructureArray);
|
|
193
|
-
return [4 /*yield*/, TxManager_1.default.execute(contract.methods.createWorkflow, [perentOrderInfoArgs, holdDeposit, subOrdersInfoArgs], transactionOptions)];
|
|
247
|
+
return [4 /*yield*/, TxManager_1.default.execute(contract.methods.withdrawWorkflowChange, [parentOrderId], transactionOptions)];
|
|
194
248
|
case 1:
|
|
195
249
|
_a.sent();
|
|
196
250
|
return [2 /*return*/];
|