@super-protocol/sdk-js 0.12.8-beta.2 → 0.12.9-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.
|
@@ -32,7 +32,7 @@ declare class OrdersFactory {
|
|
|
32
32
|
* @returns {Promise<void>} - Does not return id of created order!
|
|
33
33
|
*/
|
|
34
34
|
static createOrder(orderInfo: OrderInfo, holdDeposit?: string, suspended?: boolean, transactionOptions?: TransactionOptions): Promise<void>;
|
|
35
|
-
static getOrder(consumer
|
|
35
|
+
static getOrder(consumer?: string, externalId?: string, fromBlock?: number | string, toBlock?: number | string): Promise<OrderCreatedEvent>;
|
|
36
36
|
/**
|
|
37
37
|
* Function for create workflow
|
|
38
38
|
* @param parentOrderInfo - order info for new order
|
|
@@ -56,10 +56,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
56
56
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
57
57
|
};
|
|
58
58
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
59
|
+
var utils_1 = require("ethers/lib/utils");
|
|
59
60
|
var logger_1 = __importDefault(require("../logger"));
|
|
60
|
-
var
|
|
61
|
+
var utils_2 = require("../utils");
|
|
61
62
|
var Order_1 = require("../types/Order");
|
|
62
|
-
var utils_2 = require("ethers/lib/utils");
|
|
63
63
|
var Superpro_1 = __importDefault(require("./Superpro"));
|
|
64
64
|
var TxManager_1 = __importDefault(require("../utils/TxManager"));
|
|
65
65
|
var BlockchainConnector_1 = __importDefault(require("../connectors/BlockchainConnector"));
|
|
@@ -167,9 +167,9 @@ var OrdersFactory = /** @class */ (function () {
|
|
|
167
167
|
switch (_a.label) {
|
|
168
168
|
case 0:
|
|
169
169
|
contract = BlockchainConnector_1.default.getInstance().getContract(transactionOptions);
|
|
170
|
-
(0,
|
|
171
|
-
preparedInfo = __assign(__assign({}, orderInfo), { externalId: (0,
|
|
172
|
-
orderInfoArguments = (0,
|
|
170
|
+
(0, utils_2.checkIfActionAccountInitialized)(transactionOptions);
|
|
171
|
+
preparedInfo = __assign(__assign({}, orderInfo), { externalId: (0, utils_1.formatBytes32String)(orderInfo.externalId) });
|
|
172
|
+
orderInfoArguments = (0, utils_2.objectToTuple)(preparedInfo, Order_1.OrderInfoStructure);
|
|
173
173
|
return [4 /*yield*/, TxManager_1.default.execute(contract.methods.createOrder, [orderInfoArguments, holdDeposit, suspended], transactionOptions)];
|
|
174
174
|
case 1:
|
|
175
175
|
_a.sent();
|
|
@@ -178,26 +178,28 @@ var OrdersFactory = /** @class */ (function () {
|
|
|
178
178
|
});
|
|
179
179
|
});
|
|
180
180
|
};
|
|
181
|
-
OrdersFactory.getOrder = function (consumer, externalId) {
|
|
181
|
+
OrdersFactory.getOrder = function (consumer, externalId, fromBlock, toBlock) {
|
|
182
|
+
if (consumer === void 0) { consumer = ""; }
|
|
183
|
+
if (externalId === void 0) { externalId = ""; }
|
|
182
184
|
return __awaiter(this, void 0, void 0, function () {
|
|
183
|
-
var contract, filter, foundIds, notFound, response;
|
|
185
|
+
var contract, filter, options, foundIds, notFound, response;
|
|
184
186
|
return __generator(this, function (_a) {
|
|
185
187
|
switch (_a.label) {
|
|
186
188
|
case 0:
|
|
187
189
|
contract = BlockchainConnector_1.default.getInstance().getContract();
|
|
188
190
|
filter = {
|
|
189
191
|
consumer: consumer,
|
|
190
|
-
externalId: (0,
|
|
192
|
+
externalId: (0, utils_1.formatBytes32String)(externalId),
|
|
191
193
|
};
|
|
192
|
-
|
|
194
|
+
options = { filter: filter };
|
|
195
|
+
if (fromBlock)
|
|
196
|
+
options.fromBlock = fromBlock;
|
|
197
|
+
if (toBlock)
|
|
198
|
+
options.toBlock = toBlock;
|
|
199
|
+
return [4 /*yield*/, contract.getPastEvents("OrderCreated", options)];
|
|
193
200
|
case 1:
|
|
194
201
|
foundIds = _a.sent();
|
|
195
|
-
notFound = {
|
|
196
|
-
consumer: consumer,
|
|
197
|
-
externalId: externalId,
|
|
198
|
-
offerId: "-1",
|
|
199
|
-
orderId: "-1",
|
|
200
|
-
};
|
|
202
|
+
notFound = __assign(__assign({}, filter), { offerId: "-1", orderId: "-1" });
|
|
201
203
|
response = foundIds.length > 0 ? foundIds[0].returnValues : notFound;
|
|
202
204
|
return [2 /*return*/, response];
|
|
203
205
|
}
|
|
@@ -220,11 +222,11 @@ var OrdersFactory = /** @class */ (function () {
|
|
|
220
222
|
switch (_a.label) {
|
|
221
223
|
case 0:
|
|
222
224
|
contract = BlockchainConnector_1.default.getInstance().getContract(transactionOptions);
|
|
223
|
-
(0,
|
|
224
|
-
preparedInfo = __assign(__assign({}, parentOrderInfo), { externalId: (0,
|
|
225
|
-
parentOrderInfoArgs = (0,
|
|
226
|
-
preparedSubOrdersInfo = subOrdersInfo.map(function (o) { return (__assign(__assign({}, o), { externalId: (0,
|
|
227
|
-
subOrdersInfoArgs = (0,
|
|
225
|
+
(0, utils_2.checkIfActionAccountInitialized)(transactionOptions);
|
|
226
|
+
preparedInfo = __assign(__assign({}, parentOrderInfo), { externalId: (0, utils_1.formatBytes32String)(parentOrderInfo.externalId) });
|
|
227
|
+
parentOrderInfoArgs = (0, utils_2.objectToTuple)(preparedInfo, Order_1.OrderInfoStructure);
|
|
228
|
+
preparedSubOrdersInfo = subOrdersInfo.map(function (o) { return (__assign(__assign({}, o), { externalId: (0, utils_1.formatBytes32String)(o.externalId) })); });
|
|
229
|
+
subOrdersInfoArgs = (0, utils_2.objectToTuple)(preparedSubOrdersInfo, Order_1.OrderInfoStructureArray);
|
|
228
230
|
return [4 /*yield*/, TxManager_1.default.execute(contract.methods.createWorkflow, [parentOrderInfoArgs, holdDeposit, subOrdersInfoArgs], transactionOptions)];
|
|
229
231
|
case 1:
|
|
230
232
|
_a.sent();
|
|
@@ -245,7 +247,7 @@ var OrdersFactory = /** @class */ (function () {
|
|
|
245
247
|
switch (_a.label) {
|
|
246
248
|
case 0:
|
|
247
249
|
contract = BlockchainConnector_1.default.getInstance().getContract(transactionOptions);
|
|
248
|
-
(0,
|
|
250
|
+
(0, utils_2.checkIfActionAccountInitialized)(transactionOptions);
|
|
249
251
|
return [4 /*yield*/, TxManager_1.default.execute(contract.methods.cancelWorkflow, [perentOrderId], transactionOptions)];
|
|
250
252
|
case 1:
|
|
251
253
|
_a.sent();
|
|
@@ -266,7 +268,7 @@ var OrdersFactory = /** @class */ (function () {
|
|
|
266
268
|
switch (_a.label) {
|
|
267
269
|
case 0:
|
|
268
270
|
contract = BlockchainConnector_1.default.getInstance().getContract(transactionOptions);
|
|
269
|
-
(0,
|
|
271
|
+
(0, utils_2.checkIfActionAccountInitialized)(transactionOptions);
|
|
270
272
|
return [4 /*yield*/, TxManager_1.default.execute(contract.methods.withdrawWorkflowChange, [parentOrderId], transactionOptions)];
|
|
271
273
|
case 1:
|
|
272
274
|
_a.sent();
|
|
@@ -288,7 +290,7 @@ var OrdersFactory = /** @class */ (function () {
|
|
|
288
290
|
switch (_a.label) {
|
|
289
291
|
case 0:
|
|
290
292
|
contract = BlockchainConnector_1.default.getInstance().getContract(transactionOptions);
|
|
291
|
-
(0,
|
|
293
|
+
(0, utils_2.checkIfActionAccountInitialized)(transactionOptions);
|
|
292
294
|
return [4 /*yield*/, TxManager_1.default.execute(contract.methods.refillOrder, [orderId, amount], transactionOptions)];
|
|
293
295
|
case 1:
|
|
294
296
|
_a.sent();
|
|
@@ -311,7 +313,7 @@ var OrdersFactory = /** @class */ (function () {
|
|
|
311
313
|
.on("data", function (event) { return __awaiter(_this, void 0, void 0, function () {
|
|
312
314
|
return __generator(this, function (_a) {
|
|
313
315
|
//consumer: string, externalId: string, offerId: string, orderId: string
|
|
314
|
-
callback(event.returnValues.consumer, (0,
|
|
316
|
+
callback(event.returnValues.consumer, (0, utils_1.parseBytes32String)(event.returnValues.externalId), event.returnValues.offerId, event.returnValues.orderId, {
|
|
315
317
|
index: event.blockNumber,
|
|
316
318
|
hash: event.blockHash,
|
|
317
319
|
});
|
|
@@ -339,7 +341,7 @@ var OrdersFactory = /** @class */ (function () {
|
|
|
339
341
|
.on("data", function (event) { return __awaiter(_this, void 0, void 0, function () {
|
|
340
342
|
return __generator(this, function (_a) {
|
|
341
343
|
//consumer: string, externalId: string, offerId: string, orderId: string
|
|
342
|
-
callback(event.returnValues.consumer, (0,
|
|
344
|
+
callback(event.returnValues.consumer, (0, utils_1.parseBytes32String)(event.returnValues.externalId), event.returnValues.offerId, event.returnValues.orderId, {
|
|
343
345
|
index: event.blockNumber,
|
|
344
346
|
hash: event.blockHash,
|
|
345
347
|
});
|
|
@@ -685,13 +687,13 @@ var OrdersFactory = /** @class */ (function () {
|
|
|
685
687
|
};
|
|
686
688
|
OrdersFactory.logger = logger_1.default.child({ className: "OrdersFactory" });
|
|
687
689
|
__decorate([
|
|
688
|
-
(0,
|
|
690
|
+
(0, utils_2.incrementMethodCall)()
|
|
689
691
|
], OrdersFactory, "createOrder", null);
|
|
690
692
|
__decorate([
|
|
691
|
-
(0,
|
|
693
|
+
(0, utils_2.incrementMethodCall)()
|
|
692
694
|
], OrdersFactory, "getOrder", null);
|
|
693
695
|
__decorate([
|
|
694
|
-
(0,
|
|
696
|
+
(0, utils_2.incrementMethodCall)()
|
|
695
697
|
], OrdersFactory, "createWorkflow", null);
|
|
696
698
|
return OrdersFactory;
|
|
697
699
|
}());
|