@super-protocol/sdk-js 0.12.8-beta.2 → 0.13.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/build/TIIGenerator.js +16 -14
  2. package/build/connectors/BlockchainConnector.d.ts +1 -1
  3. package/build/connectors/BlockchainConnector.js +6 -4
  4. package/build/contracts/app.json +3581 -1393
  5. package/build/crypto/Crypto.d.ts +3 -3
  6. package/build/crypto/Crypto.js +3 -3
  7. package/build/crypto/nodejs/AES.d.ts +1 -1
  8. package/build/crypto/nodejs/AES.js +1 -1
  9. package/build/crypto/nodejs/ARIA.d.ts +1 -1
  10. package/build/crypto/nodejs/ARIA.js +1 -1
  11. package/build/index.d.ts +15 -15
  12. package/build/index.js +20 -22
  13. package/build/models/Offer.d.ts +47 -4
  14. package/build/models/Offer.js +159 -21
  15. package/build/models/Order.d.ts +29 -17
  16. package/build/models/Order.js +103 -74
  17. package/build/models/Provider.js +4 -2
  18. package/build/models/TeeOffer.d.ts +92 -11
  19. package/build/models/TeeOffer.js +305 -53
  20. package/build/providers/storage/ChunksDownloadDecorator.d.ts +0 -2
  21. package/build/providers/storage/ChunksDownloadDecorator.js +0 -3
  22. package/build/providers/storage/IStorageProvider.d.ts +0 -2
  23. package/build/providers/storage/StorjStorageProvider.d.ts +0 -2
  24. package/build/providers/storage/StorjStorageProvider.js +0 -15
  25. package/build/staticModels/Deposits.d.ts +71 -0
  26. package/build/staticModels/Deposits.js +303 -0
  27. package/build/staticModels/Offers.d.ts +58 -0
  28. package/build/staticModels/{OffersFactory.js → Offers.js} +115 -14
  29. package/build/staticModels/{OrdersFactory.d.ts → Orders.d.ts} +36 -43
  30. package/build/staticModels/{OrdersFactory.js → Orders.js} +103 -125
  31. package/build/staticModels/ProviderRegistry.d.ts +1 -1
  32. package/build/staticModels/ProviderRegistry.js +1 -1
  33. package/build/staticModels/Superpro.d.ts +2 -2
  34. package/build/staticModels/Superpro.js +1 -1
  35. package/build/staticModels/TeeOffers.d.ts +101 -0
  36. package/build/staticModels/TeeOffers.js +455 -0
  37. package/build/types/DepositInfo.d.ts +10 -0
  38. package/build/types/DepositInfo.js +9 -0
  39. package/build/types/Events.d.ts +0 -12
  40. package/build/types/HardwareInfo.d.ts +19 -0
  41. package/build/types/HardwareInfo.js +10 -0
  42. package/build/types/Offer.d.ts +0 -7
  43. package/build/types/Offer.js +0 -3
  44. package/build/types/OptionInfo.d.ts +10 -0
  45. package/build/types/OptionInfo.js +9 -0
  46. package/build/types/Order.d.ts +5 -1
  47. package/build/types/SlotInfo.d.ts +12 -0
  48. package/build/types/SlotInfo.js +10 -0
  49. package/build/types/SlotUsage.d.ts +16 -0
  50. package/build/types/SlotUsage.js +15 -0
  51. package/build/types/Superpro.d.ts +0 -14
  52. package/build/types/Superpro.js +1 -16
  53. package/build/types/TeeOfferInfo.d.ts +31 -0
  54. package/build/types/{TeeOffer.js → TeeOfferInfo.js} +2 -4
  55. package/build/types/TeeOfferOption.d.ts +21 -0
  56. package/build/types/TeeOfferOption.js +11 -0
  57. package/build/types/TeeOfferSlot.d.ts +22 -0
  58. package/build/types/TeeOfferSlot.js +11 -0
  59. package/build/types/ValueOfferSlot.d.ts +29 -0
  60. package/build/types/ValueOfferSlot.js +13 -0
  61. package/build/utils.d.ts +1 -0
  62. package/build/utils.js +5 -1
  63. package/package.json +1 -1
  64. package/build/models/Ballot.d.ts +0 -13
  65. package/build/models/Ballot.js +0 -70
  66. package/build/staticModels/OffersFactory.d.ts +0 -32
  67. package/build/staticModels/Staking.d.ts +0 -20
  68. package/build/staticModels/Staking.js +0 -116
  69. package/build/staticModels/TeeOffersFactory.d.ts +0 -36
  70. package/build/staticModels/TeeOffersFactory.js +0 -211
  71. package/build/staticModels/Voting.d.ts +0 -29
  72. package/build/staticModels/Voting.js +0 -91
  73. package/build/types/Ballot.d.ts +0 -75
  74. package/build/types/Ballot.js +0 -49
  75. package/build/types/Staking.d.ts +0 -27
  76. package/build/types/Staking.js +0 -22
  77. package/build/types/TeeOffer.d.ts +0 -25
@@ -1,7 +1,7 @@
1
1
  import { OrderInfo, OrderStatus } from "../types/Order";
2
2
  import { BlockInfo, TransactionOptions } from "../types/Web3";
3
3
  import { OrderCreatedEvent } from "../types/Events";
4
- declare class OrdersFactory {
4
+ declare class Orders {
5
5
  private static readonly logger;
6
6
  static orders?: string[];
7
7
  static get address(): string;
@@ -9,21 +9,11 @@ declare class OrdersFactory {
9
9
  * Function for fetching list of all orders ids
10
10
  * @returns list of orders ids
11
11
  */
12
- static getAllOrders(): Promise<string[]>;
12
+ static getAll(): Promise<string[]>;
13
13
  /**
14
14
  * Function for fetching orders count
15
15
  */
16
- static getOrdersCount(): Promise<number>;
17
- /**
18
- * Function for fetching order hold deposit for specific order
19
- * @param orderId - order for fetching hold deposit
20
- */
21
- static getOrderHoldDeposit(orderId: string): Promise<string>;
22
- /**
23
- * Function for fetching status of order change
24
- * @param orderId - order for fetching hold deposit
25
- */
26
- static getOrderChangeWithdrawn(orderId: string): Promise<boolean>;
16
+ static getCount(): Promise<number>;
27
17
  /**
28
18
  * Function for creating orders
29
19
  * @param orderInfo - order info for new order
@@ -31,8 +21,8 @@ declare class OrdersFactory {
31
21
  * @param transactionOptions - object what contains alternative action account or gas limit (optional)
32
22
  * @returns {Promise<void>} - Does not return id of created order!
33
23
  */
34
- static createOrder(orderInfo: OrderInfo, holdDeposit?: string, suspended?: boolean, transactionOptions?: TransactionOptions): Promise<void>;
35
- static getOrder(consumer: string, externalId: string): Promise<OrderCreatedEvent>;
24
+ static createOrder(orderInfo: OrderInfo, deposit?: string, suspended?: boolean, transactionOptions?: TransactionOptions): Promise<void>;
25
+ static getByExternalId(consumer: string, externalId: string): Promise<OrderCreatedEvent>;
36
26
  /**
37
27
  * Function for create workflow
38
28
  * @param parentOrderInfo - order info for new order
@@ -41,7 +31,7 @@ declare class OrdersFactory {
41
31
  * @param transactionOptions - object what contains alternative action account or gas limit (optional)
42
32
  * @returns {Promise<void>} - Does not return id of created order!
43
33
  */
44
- static createWorkflow(parentOrderInfo: OrderInfo, subOrdersInfo: OrderInfo[], holdDeposit?: string, transactionOptions?: TransactionOptions): Promise<void>;
34
+ static createWorkflow(parentOrderInfo: OrderInfo, subOrdersInfo: OrderInfo[], workflowDeposit?: string, transactionOptions?: TransactionOptions): Promise<void>;
45
35
  /**
46
36
  * Function for cancel workflow
47
37
  * @param parentOrderId - Parent order id
@@ -66,34 +56,21 @@ declare class OrdersFactory {
66
56
  * @param callback - function for processing created order
67
57
  * @returns unsubscribe - unsubscribe function from event
68
58
  */
69
- static onWorkflowCreated(callback: onWorkflowCreatedCallback): () => void;
70
- /**
71
- * Function for adding event listeners on order created event in orders factory contract
72
- * @param callback - function for processing created order
73
- * @returns unsubscribe - unsubscribe function from event
74
- */
75
- static onOrderCreated(callback: onOrderCreatedCallback): () => void;
76
- /**
77
- * Function for adding event listeners on suborder created event in orders contract
78
- * @param callback - function for processing created suborder
79
- * @param parentOrderId - parent order id
80
- * @return unsubscribe - unsubscribe function from event
81
- */
82
- static onSubOrderCreated(callback: onSubOrderCreatedCallback, parentOrderId?: string): () => void;
59
+ static onCreated(callback: onOrderCreatedCallback): () => void;
83
60
  /**
84
61
  * Function for adding event listeners on order started event in orders contract
85
62
  * @param callback - function for processing suborder filled event
86
63
  * @param orderId - order id
87
64
  * @returns unsubscribe - unsubscribe function from event
88
65
  */
89
- static onOrderStarted(callback: onOrderStartedCallback, orderId?: string): () => void;
66
+ static onStarted(callback: onOrderStartedCallback, orderId?: string): () => void;
90
67
  /**
91
68
  * Function for adding event listeners on order updated status event in orders contract
92
69
  * @param callback - function for processing order updated status event
93
70
  * @param orderId - order id
94
71
  * @returns unsubscribe - unsubscribe function from event
95
72
  */
96
- static onOrdersStatusUpdated(callback: onOrdersStatusUpdatedCallback, orderId?: string): () => void;
73
+ static onStatusUpdated(callback: onOrdersStatusUpdatedCallback, orderId?: string): () => void;
97
74
  /**
98
75
  * Function for adding event listeners on order refilled event in orders contract
99
76
  * @param callback - function for processing order refilled event
@@ -101,21 +78,21 @@ declare class OrdersFactory {
101
78
  * @param orderId - order id
102
79
  * @returns unsubscribe - unsubscribe function from event
103
80
  */
104
- static onOrderDepositRefilled(callback: onOrderDepositRefilledCallback, consumer?: string, orderId?: string): () => void;
81
+ static onDepositRefilled(callback: onOrderDepositRefilledCallback, consumer?: string, orderId?: string): () => void;
105
82
  /**
106
83
  * Function for adding event listeners on order price updated event in orders contract
107
84
  * @param callback - function for processing order price updated event
108
85
  * @param orderId - order id
109
86
  * @returns unsubscribe - unsubscribe function from event
110
87
  */
111
- static onOrderPriceUpdated(callback: onOrderPriceUpdatedCallback, orderId?: string): () => void;
88
+ static onPriceUpdated(callback: onOrderPriceUpdatedCallback, orderId?: string): () => void;
112
89
  /**
113
90
  * Function for adding event listeners on order changed withdrawn event in orders contract
114
91
  * @param callback - function for processing order changed withdrawn event
115
92
  * @param orderId - order id
116
93
  * @returns unsubscribe - unsubscribe function from event
117
94
  */
118
- static onOrderChangedWithdrawn(callback: onOrderChangedWithdrawnCallback, orderId?: string): () => void;
95
+ static onChangedWithdrawn(callback: onOrderChangedWithdrawnCallback, orderId?: string): () => void;
119
96
  /**
120
97
  * Function for adding event listeners on order changed refunded event in orders contract
121
98
  * @param callback - function for processing order changed refunded event
@@ -123,7 +100,7 @@ declare class OrdersFactory {
123
100
  * @param orderId - order id
124
101
  * @returns unsubscribe - unsubscribe function from event
125
102
  */
126
- static onOrderProfitWithdrawn(callback: onOrderProfitWithdrawnCallback, orderId?: string, tokenReceiver?: string): () => void;
103
+ static onProfitWithdrawn(callback: onOrderProfitWithdrawnCallback, orderId?: string, tokenReceiver?: string): () => void;
127
104
  /**
128
105
  * Function for adding event listeners on order awaiting payment event in orders contract
129
106
  * @param callback - function for processing order awaiting payment event
@@ -131,7 +108,7 @@ declare class OrdersFactory {
131
108
  * @param orderId - order id
132
109
  * @returns unsubscribe - unsubscribe function from event
133
110
  */
134
- static onOrderAwaitingPaymentChanged(callback: onOrderAwaitingPaymentChangedCallback, consumer?: string, orderId?: string): () => void;
111
+ static onAwaitingPaymentChanged(callback: onOrderAwaitingPaymentChangedCallback, consumer?: string, orderId?: string): () => void;
135
112
  /**
136
113
  * Function for adding event listeners on order deposit spent event in orders contract
137
114
  * @param callback - function for processing order deposit spent event
@@ -139,7 +116,7 @@ declare class OrdersFactory {
139
116
  * @param orderId - order id
140
117
  * @returns unsubscribe - unsubscribe function from event
141
118
  */
142
- static onOrderDepositSpentChanged(callback: onOrderDepositSpentChangedCallback, consumer?: string, orderId?: string): () => void;
119
+ static onDepositSpentChanged(callback: onOrderDepositSpentChangedCallback, consumer?: string, orderId?: string): () => void;
143
120
  /**
144
121
  * Function for adding event listeners on order encrypted result updated event in orders contract
145
122
  * @param callback - function for processing order encrypted result updated event
@@ -147,18 +124,34 @@ declare class OrdersFactory {
147
124
  * @param orderId - order id
148
125
  * @returns unsubscribe - unsubscribe function from event
149
126
  */
150
- static onOrderEncryptedResultUpdated(callback: onOrderEncryptedResultUpdatedCallback, consumer?: string, orderId?: string): () => void;
127
+ static onEncryptedResultUpdated(callback: onOrderEncryptedResultUpdatedCallback, consumer?: string, orderId?: string): () => void;
128
+ /**
129
+ * Function for adding event listeners on OrderOptionsDepositSpentChanged event in orders contract
130
+ * @param callback - function for processing order encrypted result updated event
131
+ * @param consumer - order creator address
132
+ * @param orderId - order id
133
+ * @returns unsubscribe - unsubscribe function from event
134
+ */
135
+ static onOptionsDepositSpentChanged(callback: onOrderOptionsDepositSpentChangedCallback, consumer?: string, orderId?: string): () => void;
136
+ /**
137
+ * Function for adding event listeners on onOrderProfitUnlocked event in orders contract
138
+ * @param callback - function for processing order encrypted result updated event
139
+ * @param tokenReceiver - tokenReceiver
140
+ * @param orderId - order id
141
+ * @returns unsubscribe - unsubscribe function from event
142
+ */
143
+ static onOProfitUnlocked(callback: onOrderProfitUnlockedCallback, tokenReceiver?: string, orderId?: string): () => void;
151
144
  }
152
- export type onSubOrderCreatedCallback = (parentOrderId: string, subOrderId: string, block?: BlockInfo) => void;
153
145
  export type onOrderStartedCallback = (orderId: string, consumer: string, block?: BlockInfo) => void;
154
146
  export type onOrdersStatusUpdatedCallback = (orderId: string, status: OrderStatus, block?: BlockInfo) => void;
155
147
  export type onOrderPriceUpdatedCallback = (orderId: string, price: string, block?: BlockInfo) => void;
156
- export type onOrderCreatedCallback = (consumer: string, externalId: string, offerId: string, orderId: string, block?: BlockInfo) => void;
148
+ export type onOrderCreatedCallback = (consumer: string, externalId: string, offerId: string, parentOrderId: string, orderId: string, block?: BlockInfo) => void;
157
149
  export type onOrderDepositRefilledCallback = (orderId: string, consumer: string, amount: string, block?: BlockInfo) => void;
158
150
  export type onOrderChangedWithdrawnCallback = (orderId: string, consumer: string, change: string, block?: BlockInfo) => void;
159
151
  export type onOrderProfitWithdrawnCallback = (orderId: string, tokenReceiver: string, profit: string, block?: BlockInfo) => void;
160
152
  export type onOrderDepositSpentChangedCallback = (orderId: string, consumer: string, spent: string, block?: BlockInfo) => void;
161
153
  export type onOrderAwaitingPaymentChangedCallback = (orderId: string, consumer: string, awaitingPaymentFlag: boolean, block?: BlockInfo) => void;
162
154
  export type onOrderEncryptedResultUpdatedCallback = (orderId: string, consumer: string, encryptedResult: string, block?: BlockInfo) => void;
163
- export type onWorkflowCreatedCallback = (consumer: string, externalId: string, offerId: string, orderId: string, block?: BlockInfo) => void;
164
- export default OrdersFactory;
155
+ export type onOrderOptionsDepositSpentChangedCallback = (consumer: string, orderId: string, value: string, block?: BlockInfo) => void;
156
+ export type onOrderProfitUnlockedCallback = (tokenReceiver: string, orderId: string, profit: string, block?: BlockInfo) => void;
157
+ export default Orders;
@@ -64,10 +64,10 @@ var Superpro_1 = __importDefault(require("./Superpro"));
64
64
  var TxManager_1 = __importDefault(require("../utils/TxManager"));
65
65
  var BlockchainConnector_1 = __importDefault(require("../connectors/BlockchainConnector"));
66
66
  var BlockchainEventsListener_1 = __importDefault(require("../connectors/BlockchainEventsListener"));
67
- var OrdersFactory = /** @class */ (function () {
68
- function OrdersFactory() {
67
+ var Orders = /** @class */ (function () {
68
+ function Orders() {
69
69
  }
70
- Object.defineProperty(OrdersFactory, "address", {
70
+ Object.defineProperty(Orders, "address", {
71
71
  get: function () {
72
72
  return Superpro_1.default.address;
73
73
  },
@@ -78,7 +78,7 @@ var OrdersFactory = /** @class */ (function () {
78
78
  * Function for fetching list of all orders ids
79
79
  * @returns list of orders ids
80
80
  */
81
- OrdersFactory.getAllOrders = function () {
81
+ Orders.getAll = function () {
82
82
  var _a;
83
83
  return __awaiter(this, void 0, void 0, function () {
84
84
  var contract, ordersSet, ordersCount, orderId;
@@ -103,7 +103,7 @@ var OrdersFactory = /** @class */ (function () {
103
103
  /**
104
104
  * Function for fetching orders count
105
105
  */
106
- OrdersFactory.getOrdersCount = function () {
106
+ Orders.getCount = function () {
107
107
  return __awaiter(this, void 0, void 0, function () {
108
108
  var contract, _a;
109
109
  return __generator(this, function (_b) {
@@ -117,40 +117,6 @@ var OrdersFactory = /** @class */ (function () {
117
117
  });
118
118
  });
119
119
  };
120
- /**
121
- * Function for fetching order hold deposit for specific order
122
- * @param orderId - order for fetching hold deposit
123
- */
124
- OrdersFactory.getOrderHoldDeposit = function (orderId) {
125
- return __awaiter(this, void 0, void 0, function () {
126
- var contract;
127
- return __generator(this, function (_a) {
128
- switch (_a.label) {
129
- case 0:
130
- contract = BlockchainConnector_1.default.getInstance().getContract();
131
- return [4 /*yield*/, contract.methods.getOrderHoldDeposit(orderId).call()];
132
- case 1: return [2 /*return*/, _a.sent()];
133
- }
134
- });
135
- });
136
- };
137
- /**
138
- * Function for fetching status of order change
139
- * @param orderId - order for fetching hold deposit
140
- */
141
- OrdersFactory.getOrderChangeWithdrawn = function (orderId) {
142
- return __awaiter(this, void 0, void 0, function () {
143
- var contract;
144
- return __generator(this, function (_a) {
145
- switch (_a.label) {
146
- case 0:
147
- contract = BlockchainConnector_1.default.getInstance().getContract();
148
- return [4 /*yield*/, contract.methods.getOrderChangeWithdrawn(orderId).call()];
149
- case 1: return [2 /*return*/, _a.sent()];
150
- }
151
- });
152
- });
153
- };
154
120
  /**
155
121
  * Function for creating orders
156
122
  * @param orderInfo - order info for new order
@@ -158,8 +124,8 @@ var OrdersFactory = /** @class */ (function () {
158
124
  * @param transactionOptions - object what contains alternative action account or gas limit (optional)
159
125
  * @returns {Promise<void>} - Does not return id of created order!
160
126
  */
161
- OrdersFactory.createOrder = function (orderInfo, holdDeposit, suspended, transactionOptions) {
162
- if (holdDeposit === void 0) { holdDeposit = "0"; }
127
+ Orders.createOrder = function (orderInfo, deposit, suspended, transactionOptions) {
128
+ if (deposit === void 0) { deposit = "0"; }
163
129
  if (suspended === void 0) { suspended = false; }
164
130
  return __awaiter(this, void 0, void 0, function () {
165
131
  var contract, preparedInfo, orderInfoArguments;
@@ -170,7 +136,7 @@ var OrdersFactory = /** @class */ (function () {
170
136
  (0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
171
137
  preparedInfo = __assign(__assign({}, orderInfo), { externalId: (0, utils_2.formatBytes32String)(orderInfo.externalId) });
172
138
  orderInfoArguments = (0, utils_1.objectToTuple)(preparedInfo, Order_1.OrderInfoStructure);
173
- return [4 /*yield*/, TxManager_1.default.execute(contract.methods.createOrder, [orderInfoArguments, holdDeposit, suspended], transactionOptions)];
139
+ return [4 /*yield*/, TxManager_1.default.execute(contract.methods.createOrder, [orderInfoArguments, deposit, suspended], transactionOptions)];
174
140
  case 1:
175
141
  _a.sent();
176
142
  return [2 /*return*/];
@@ -178,7 +144,7 @@ var OrdersFactory = /** @class */ (function () {
178
144
  });
179
145
  });
180
146
  };
181
- OrdersFactory.getOrder = function (consumer, externalId) {
147
+ Orders.getByExternalId = function (consumer, externalId) {
182
148
  return __awaiter(this, void 0, void 0, function () {
183
149
  var contract, filter, foundIds, notFound, response;
184
150
  return __generator(this, function (_a) {
@@ -196,6 +162,7 @@ var OrdersFactory = /** @class */ (function () {
196
162
  consumer: consumer,
197
163
  externalId: externalId,
198
164
  offerId: "-1",
165
+ parentOrderId: "-1",
199
166
  orderId: "-1",
200
167
  };
201
168
  response = foundIds.length > 0 ? foundIds[0].returnValues : notFound;
@@ -212,8 +179,8 @@ var OrdersFactory = /** @class */ (function () {
212
179
  * @param transactionOptions - object what contains alternative action account or gas limit (optional)
213
180
  * @returns {Promise<void>} - Does not return id of created order!
214
181
  */
215
- OrdersFactory.createWorkflow = function (parentOrderInfo, subOrdersInfo, holdDeposit, transactionOptions) {
216
- if (holdDeposit === void 0) { holdDeposit = "0"; }
182
+ Orders.createWorkflow = function (parentOrderInfo, subOrdersInfo, workflowDeposit, transactionOptions) {
183
+ if (workflowDeposit === void 0) { workflowDeposit = "0"; }
217
184
  return __awaiter(this, void 0, void 0, function () {
218
185
  var contract, preparedInfo, parentOrderInfoArgs, preparedSubOrdersInfo, subOrdersInfoArgs;
219
186
  return __generator(this, function (_a) {
@@ -225,7 +192,7 @@ var OrdersFactory = /** @class */ (function () {
225
192
  parentOrderInfoArgs = (0, utils_1.objectToTuple)(preparedInfo, Order_1.OrderInfoStructure);
226
193
  preparedSubOrdersInfo = subOrdersInfo.map(function (o) { return (__assign(__assign({}, o), { externalId: (0, utils_2.formatBytes32String)(o.externalId) })); });
227
194
  subOrdersInfoArgs = (0, utils_1.objectToTuple)(preparedSubOrdersInfo, Order_1.OrderInfoStructureArray);
228
- return [4 /*yield*/, TxManager_1.default.execute(contract.methods.createWorkflow, [parentOrderInfoArgs, holdDeposit, subOrdersInfoArgs], transactionOptions)];
195
+ return [4 /*yield*/, TxManager_1.default.execute(contract.methods.createWorkflow, [parentOrderInfoArgs, workflowDeposit, subOrdersInfoArgs], transactionOptions)];
229
196
  case 1:
230
197
  _a.sent();
231
198
  return [2 /*return*/];
@@ -238,7 +205,7 @@ var OrdersFactory = /** @class */ (function () {
238
205
  * @param parentOrderId - Parent order id
239
206
  * @returns {Promise<void>} - Does not return id of created order!
240
207
  */
241
- OrdersFactory.cancelWorkflow = function (perentOrderId, transactionOptions) {
208
+ Orders.cancelWorkflow = function (perentOrderId, transactionOptions) {
242
209
  return __awaiter(this, void 0, void 0, function () {
243
210
  var contract;
244
211
  return __generator(this, function (_a) {
@@ -259,7 +226,7 @@ var OrdersFactory = /** @class */ (function () {
259
226
  * @param parentOrderId - Parent order id
260
227
  * @returns {Promise<void>} - Does not return id of created order!
261
228
  */
262
- OrdersFactory.withdrawWorkflowChange = function (parentOrderId, transactionOptions) {
229
+ Orders.withdrawWorkflowChange = function (parentOrderId, transactionOptions) {
263
230
  return __awaiter(this, void 0, void 0, function () {
264
231
  var contract;
265
232
  return __generator(this, function (_a) {
@@ -281,7 +248,7 @@ var OrdersFactory = /** @class */ (function () {
281
248
  * @param amount - amount of tokens to refilling
282
249
  * @param transactionOptions - object what contains alternative action account or gas limit (optional)
283
250
  */
284
- OrdersFactory.refillOrderDeposit = function (orderId, amount, transactionOptions) {
251
+ Orders.refillOrderDeposit = function (orderId, amount, transactionOptions) {
285
252
  return __awaiter(this, void 0, void 0, function () {
286
253
  var contract;
287
254
  return __generator(this, function (_a) {
@@ -302,35 +269,7 @@ var OrdersFactory = /** @class */ (function () {
302
269
  * @param callback - function for processing created order
303
270
  * @returns unsubscribe - unsubscribe function from event
304
271
  */
305
- OrdersFactory.onWorkflowCreated = function (callback) {
306
- var _this = this;
307
- var contract = BlockchainEventsListener_1.default.getInstance().getContract();
308
- var logger = this.logger.child({ method: "onWorkflowCreated" });
309
- var subscription = contract.events
310
- .WorkflowCreated()
311
- .on("data", function (event) { return __awaiter(_this, void 0, void 0, function () {
312
- return __generator(this, function (_a) {
313
- //consumer: string, externalId: string, offerId: string, orderId: string
314
- callback(event.returnValues.consumer, (0, utils_2.parseBytes32String)(event.returnValues.externalId), event.returnValues.offerId, event.returnValues.orderId, {
315
- index: event.blockNumber,
316
- hash: event.blockHash,
317
- });
318
- return [2 /*return*/];
319
- });
320
- }); })
321
- .on("error", function (error, receipt) {
322
- if (receipt)
323
- return; // Used to avoid logging of transaction rejected
324
- logger.warn(error);
325
- });
326
- return function () { return subscription.unsubscribe(); };
327
- };
328
- /**
329
- * Function for adding event listeners on order created event in orders factory contract
330
- * @param callback - function for processing created order
331
- * @returns unsubscribe - unsubscribe function from event
332
- */
333
- OrdersFactory.onOrderCreated = function (callback) {
272
+ Orders.onCreated = function (callback) {
334
273
  var _this = this;
335
274
  var contract = BlockchainEventsListener_1.default.getInstance().getContract();
336
275
  var logger = this.logger.child({ method: "onOrderCreated" });
@@ -339,38 +278,7 @@ var OrdersFactory = /** @class */ (function () {
339
278
  .on("data", function (event) { return __awaiter(_this, void 0, void 0, function () {
340
279
  return __generator(this, function (_a) {
341
280
  //consumer: string, externalId: string, offerId: string, orderId: string
342
- callback(event.returnValues.consumer, (0, utils_2.parseBytes32String)(event.returnValues.externalId), event.returnValues.offerId, event.returnValues.orderId, {
343
- index: event.blockNumber,
344
- hash: event.blockHash,
345
- });
346
- return [2 /*return*/];
347
- });
348
- }); })
349
- .on("error", function (error, receipt) {
350
- if (receipt)
351
- return; // Used to avoid logging of transaction rejected
352
- logger.warn(error);
353
- });
354
- return function () { return subscription.unsubscribe(); };
355
- };
356
- /**
357
- * Function for adding event listeners on suborder created event in orders contract
358
- * @param callback - function for processing created suborder
359
- * @param parentOrderId - parent order id
360
- * @return unsubscribe - unsubscribe function from event
361
- */
362
- OrdersFactory.onSubOrderCreated = function (callback, parentOrderId) {
363
- var _this = this;
364
- var contract = BlockchainEventsListener_1.default.getInstance().getContract();
365
- var logger = this.logger.child({ method: "onSubOrderCreated" });
366
- var subscription = contract.events
367
- .SubOrderCreated()
368
- .on("data", function (event) { return __awaiter(_this, void 0, void 0, function () {
369
- return __generator(this, function (_a) {
370
- if (parentOrderId && event.returnValues.parentOrderId != parentOrderId) {
371
- return [2 /*return*/];
372
- }
373
- callback(event.returnValues.parentOrderId, event.returnValues.subOrderId, {
281
+ callback(event.returnValues.consumer, (0, utils_2.parseBytes32String)(event.returnValues.externalId), event.returnValues.offerId, event.returnValues.parentOrderId, event.returnValues.orderId, {
374
282
  index: event.blockNumber,
375
283
  hash: event.blockHash,
376
284
  });
@@ -390,7 +298,7 @@ var OrdersFactory = /** @class */ (function () {
390
298
  * @param orderId - order id
391
299
  * @returns unsubscribe - unsubscribe function from event
392
300
  */
393
- OrdersFactory.onOrderStarted = function (callback, orderId) {
301
+ Orders.onStarted = function (callback, orderId) {
394
302
  var _this = this;
395
303
  var contract = BlockchainEventsListener_1.default.getInstance().getContract();
396
304
  var logger = this.logger.child({ method: "onOrderStarted" });
@@ -421,7 +329,7 @@ var OrdersFactory = /** @class */ (function () {
421
329
  * @param orderId - order id
422
330
  * @returns unsubscribe - unsubscribe function from event
423
331
  */
424
- OrdersFactory.onOrdersStatusUpdated = function (callback, orderId) {
332
+ Orders.onStatusUpdated = function (callback, orderId) {
425
333
  var _this = this;
426
334
  var contract = BlockchainEventsListener_1.default.getInstance().getContract();
427
335
  var logger = this.logger.child({ method: "onOrdersStatusUpdated" });
@@ -453,7 +361,7 @@ var OrdersFactory = /** @class */ (function () {
453
361
  * @param orderId - order id
454
362
  * @returns unsubscribe - unsubscribe function from event
455
363
  */
456
- OrdersFactory.onOrderDepositRefilled = function (callback, consumer, orderId) {
364
+ Orders.onDepositRefilled = function (callback, consumer, orderId) {
457
365
  var _this = this;
458
366
  var contract = BlockchainEventsListener_1.default.getInstance().getContract();
459
367
  var logger = this.logger.child({ method: "onOrderDepositRefilled" });
@@ -487,7 +395,7 @@ var OrdersFactory = /** @class */ (function () {
487
395
  * @param orderId - order id
488
396
  * @returns unsubscribe - unsubscribe function from event
489
397
  */
490
- OrdersFactory.onOrderPriceUpdated = function (callback, orderId) {
398
+ Orders.onPriceUpdated = function (callback, orderId) {
491
399
  var _this = this;
492
400
  var contract = BlockchainEventsListener_1.default.getInstance().getContract();
493
401
  var logger = this.logger.child({ method: "onOrderPriceUpdated" });
@@ -518,7 +426,7 @@ var OrdersFactory = /** @class */ (function () {
518
426
  * @param orderId - order id
519
427
  * @returns unsubscribe - unsubscribe function from event
520
428
  */
521
- OrdersFactory.onOrderChangedWithdrawn = function (callback, orderId) {
429
+ Orders.onChangedWithdrawn = function (callback, orderId) {
522
430
  var _this = this;
523
431
  var contract = BlockchainEventsListener_1.default.getInstance().getContract();
524
432
  var logger = this.logger.child({ method: "onOrderChangedWithdrawn" });
@@ -550,7 +458,7 @@ var OrdersFactory = /** @class */ (function () {
550
458
  * @param orderId - order id
551
459
  * @returns unsubscribe - unsubscribe function from event
552
460
  */
553
- OrdersFactory.onOrderProfitWithdrawn = function (callback, orderId, tokenReceiver) {
461
+ Orders.onProfitWithdrawn = function (callback, orderId, tokenReceiver) {
554
462
  var _this = this;
555
463
  var contract = BlockchainEventsListener_1.default.getInstance().getContract();
556
464
  var logger = this.logger.child({ method: "onOrderProfitWithdrawn" });
@@ -585,7 +493,7 @@ var OrdersFactory = /** @class */ (function () {
585
493
  * @param orderId - order id
586
494
  * @returns unsubscribe - unsubscribe function from event
587
495
  */
588
- OrdersFactory.onOrderAwaitingPaymentChanged = function (callback, consumer, orderId) {
496
+ Orders.onAwaitingPaymentChanged = function (callback, consumer, orderId) {
589
497
  var _this = this;
590
498
  var contract = BlockchainEventsListener_1.default.getInstance().getContract();
591
499
  var logger = this.logger.child({ method: "onOrderAwaitingPaymentChanged" });
@@ -620,7 +528,7 @@ var OrdersFactory = /** @class */ (function () {
620
528
  * @param orderId - order id
621
529
  * @returns unsubscribe - unsubscribe function from event
622
530
  */
623
- OrdersFactory.onOrderDepositSpentChanged = function (callback, consumer, orderId) {
531
+ Orders.onDepositSpentChanged = function (callback, consumer, orderId) {
624
532
  var _this = this;
625
533
  var contract = BlockchainEventsListener_1.default.getInstance().getContract();
626
534
  var logger = this.logger.child({ method: "onOrderDepositSpentChanged" });
@@ -655,7 +563,7 @@ var OrdersFactory = /** @class */ (function () {
655
563
  * @param orderId - order id
656
564
  * @returns unsubscribe - unsubscribe function from event
657
565
  */
658
- OrdersFactory.onOrderEncryptedResultUpdated = function (callback, consumer, orderId) {
566
+ Orders.onEncryptedResultUpdated = function (callback, consumer, orderId) {
659
567
  var _this = this;
660
568
  var contract = BlockchainEventsListener_1.default.getInstance().getContract();
661
569
  var logger = this.logger.child({ method: "onOrderEncryptedResultUpdated" });
@@ -683,16 +591,86 @@ var OrdersFactory = /** @class */ (function () {
683
591
  });
684
592
  return function () { return subscription.unsubscribe(); };
685
593
  };
686
- OrdersFactory.logger = logger_1.default.child({ className: "OrdersFactory" });
594
+ /**
595
+ * Function for adding event listeners on OrderOptionsDepositSpentChanged event in orders contract
596
+ * @param callback - function for processing order encrypted result updated event
597
+ * @param consumer - order creator address
598
+ * @param orderId - order id
599
+ * @returns unsubscribe - unsubscribe function from event
600
+ */
601
+ Orders.onOptionsDepositSpentChanged = function (callback, consumer, orderId) {
602
+ var _this = this;
603
+ var contract = BlockchainEventsListener_1.default.getInstance().getContract();
604
+ var logger = this.logger.child({ method: "onOrderOptionsDepositSpentChanged" });
605
+ var subscription = contract.events
606
+ .OrderOptionsDepositSpentChanged()
607
+ .on("data", function (event) { return __awaiter(_this, void 0, void 0, function () {
608
+ return __generator(this, function (_a) {
609
+ if (orderId && event.returnValues.orderId != orderId) {
610
+ return [2 /*return*/];
611
+ }
612
+ if (consumer && event.returnValues.consumer != consumer) {
613
+ return [2 /*return*/];
614
+ }
615
+ callback(event.returnValues.consumer, event.returnValues.orderId, event.returnValues.value, {
616
+ index: event.blockNumber,
617
+ hash: event.blockHash,
618
+ });
619
+ return [2 /*return*/];
620
+ });
621
+ }); })
622
+ .on("error", function (error, receipt) {
623
+ if (receipt)
624
+ return; // Used to avoid logging of transaction rejected
625
+ logger.warn(error);
626
+ });
627
+ return function () { return subscription.unsubscribe(); };
628
+ };
629
+ /**
630
+ * Function for adding event listeners on onOrderProfitUnlocked event in orders contract
631
+ * @param callback - function for processing order encrypted result updated event
632
+ * @param tokenReceiver - tokenReceiver
633
+ * @param orderId - order id
634
+ * @returns unsubscribe - unsubscribe function from event
635
+ */
636
+ Orders.onOProfitUnlocked = function (callback, tokenReceiver, orderId) {
637
+ var _this = this;
638
+ var contract = BlockchainEventsListener_1.default.getInstance().getContract();
639
+ var logger = this.logger.child({ method: "onOrderProfitUnlocked" });
640
+ var subscription = contract.events
641
+ .OrderProfitUnlocked()
642
+ .on("data", function (event) { return __awaiter(_this, void 0, void 0, function () {
643
+ return __generator(this, function (_a) {
644
+ if (orderId && event.returnValues.orderId != orderId) {
645
+ return [2 /*return*/];
646
+ }
647
+ if (tokenReceiver && event.returnValues.tokenReceiver != tokenReceiver) {
648
+ return [2 /*return*/];
649
+ }
650
+ callback(event.returnValues.tokenReceiver, event.returnValues.orderId, event.returnValues.profit, {
651
+ index: event.blockNumber,
652
+ hash: event.blockHash,
653
+ });
654
+ return [2 /*return*/];
655
+ });
656
+ }); })
657
+ .on("error", function (error, receipt) {
658
+ if (receipt)
659
+ return; // Used to avoid logging of transaction rejected
660
+ logger.warn(error);
661
+ });
662
+ return function () { return subscription.unsubscribe(); };
663
+ };
664
+ Orders.logger = logger_1.default.child({ className: "Orders" });
687
665
  __decorate([
688
666
  (0, utils_1.incrementMethodCall)()
689
- ], OrdersFactory, "createOrder", null);
667
+ ], Orders, "createOrder", null);
690
668
  __decorate([
691
669
  (0, utils_1.incrementMethodCall)()
692
- ], OrdersFactory, "getOrder", null);
670
+ ], Orders, "getByExternalId", null);
693
671
  __decorate([
694
672
  (0, utils_1.incrementMethodCall)()
695
- ], OrdersFactory, "createWorkflow", null);
696
- return OrdersFactory;
673
+ ], Orders, "createWorkflow", null);
674
+ return Orders;
697
675
  }());
698
- exports.default = OrdersFactory;
676
+ exports.default = Orders;
@@ -40,7 +40,7 @@ declare class ProviderRegistry {
40
40
  /**
41
41
  * Function for adding event listeners on provider registered event in provider registry
42
42
  * @param callback - function for processing new provider
43
- * @return unsubscribe - unsubscribe function from event
43
+ * @returns unsubscribe - unsubscribe function from event
44
44
  */
45
45
  static onProviderRegistered(callback: onProviderRegisteredCallback): () => void;
46
46
  /**
@@ -175,7 +175,7 @@ var ProviderRegistry = /** @class */ (function () {
175
175
  /**
176
176
  * Function for adding event listeners on provider registered event in provider registry
177
177
  * @param callback - function for processing new provider
178
- * @return unsubscribe - unsubscribe function from event
178
+ * @returns unsubscribe - unsubscribe function from event
179
179
  */
180
180
  ProviderRegistry.onProviderRegistered = function (callback) {
181
181
  var _this = this;
@@ -1,11 +1,11 @@
1
- import { ContractName, ParamName } from "../types/Superpro";
1
+ import { ParamName } from "../types/Superpro";
2
2
  import { Contract } from "web3-eth-contract";
3
3
  declare class Superpro {
4
4
  static address: string;
5
5
  /**
6
6
  * Fetching address of contract by name
7
7
  */
8
- static getContractAddress(name: ContractName): Promise<string>;
8
+ static getContractAddress(): Promise<string>;
9
9
  static getTokenAddress(contractInstance?: Contract): Promise<string>;
10
10
  /**
11
11
  * Fetching config parameter value by name
@@ -46,7 +46,7 @@ var Superpro = /** @class */ (function () {
46
46
  /**
47
47
  * Fetching address of contract by name
48
48
  */
49
- Superpro.getContractAddress = function (name) {
49
+ Superpro.getContractAddress = function () {
50
50
  return __awaiter(this, void 0, void 0, function () {
51
51
  return __generator(this, function (_a) {
52
52
  return [2 /*return*/, this.address];