@super-protocol/sdk-js 0.6.0 → 0.6.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.
@@ -73,27 +73,27 @@ var Consensus = /** @class */ (function () {
73
73
  this.contract = new store_1.default.web3.eth.Contract(Offers_json_1.default.abi, Superpro_1.default.address);
74
74
  return this.contract;
75
75
  };
76
- Consensus.initTcb = function (teeOfferAddress, transactionOptions) {
76
+ Consensus.initTcb = function (teeOfferId, transactionOptions) {
77
77
  return __awaiter(this, void 0, void 0, function () {
78
- var tcbAddress;
78
+ var tcbId;
79
79
  return __generator(this, function (_b) {
80
80
  switch (_b.label) {
81
- case 0: return [4 /*yield*/, TxManager_1.default.execute(this.contract.methods.initTcb, [teeOfferAddress], transactionOptions)];
81
+ case 0: return [4 /*yield*/, TxManager_1.default.execute(this.contract.methods.initTcb, [teeOfferId], transactionOptions)];
82
82
  case 1:
83
83
  _b.sent();
84
- return [4 /*yield*/, this.getInitedTcb(teeOfferAddress)];
84
+ return [4 /*yield*/, this.getInitedTcb(teeOfferId)];
85
85
  case 2:
86
- tcbAddress = _b.sent();
87
- return [2 /*return*/, new TCB_1.default(tcbAddress)];
86
+ tcbId = _b.sent();
87
+ return [2 /*return*/, new TCB_1.default(tcbId)];
88
88
  }
89
89
  });
90
90
  });
91
91
  };
92
- Consensus.addToSupply = function (tcbAddress, transactionOptions) {
92
+ Consensus.addToSupply = function (tcbId, transactionOptions) {
93
93
  return __awaiter(this, void 0, void 0, function () {
94
94
  return __generator(this, function (_b) {
95
95
  switch (_b.label) {
96
- case 0: return [4 /*yield*/, TxManager_1.default.execute(this.contract.methods.addToSupply, [tcbAddress], transactionOptions)];
96
+ case 0: return [4 /*yield*/, TxManager_1.default.execute(this.contract.methods.addToSupply, [tcbId], transactionOptions)];
97
97
  case 1:
98
98
  _b.sent();
99
99
  return [2 /*return*/];
@@ -170,12 +170,12 @@ var Consensus = /** @class */ (function () {
170
170
  });
171
171
  };
172
172
  /**
173
- * Function initialize TCB and returns two lists of anothers' TCB addresses for their checking
174
- * @param teeOfferAddress
173
+ * Function initialize TCB and returns two lists of anothers' TCB ids for their checking
174
+ * @param teeOfferId
175
175
  * @param transactionOptions - object what contains alternative action account or gas limit (optional)
176
- * @returns two lists of anothers' TCB addresses for their checking
176
+ * @returns two lists of anothers' TCB ids for their checking
177
177
  */
178
- Consensus.getListsForVerification = function (teeOfferAddress, transactionOptions) {
178
+ Consensus.getListsForVerification = function (teeOfferId, transactionOptions) {
179
179
  return __awaiter(this, void 0, void 0, function () {
180
180
  var alreadyInited, tcbTimeInited, timestamp, tcb, _b, numberOfMissingL2, L1, L2;
181
181
  return __generator(this, function (_c) {
@@ -183,10 +183,10 @@ var Consensus = /** @class */ (function () {
183
183
  case 0:
184
184
  this.checkInit();
185
185
  (0, utils_1.checkIfActionAccountInitialized)();
186
- return [4 /*yield*/, this.getInitedTcb(teeOfferAddress)];
186
+ return [4 /*yield*/, this.getInitedTcb(teeOfferId)];
187
187
  case 1:
188
188
  alreadyInited = _c.sent();
189
- return [4 /*yield*/, this.getTimeInited(teeOfferAddress)];
189
+ return [4 /*yield*/, this.getTimeInited(teeOfferId)];
190
190
  case 2:
191
191
  tcbTimeInited = _c.sent();
192
192
  return [4 /*yield*/, (0, utils_1.getTimestamp)()];
@@ -195,7 +195,7 @@ var Consensus = /** @class */ (function () {
195
195
  if (!(tcbTimeInited !== 0 && tcbTimeInited + constants_1.ONE_DAY > timestamp)) return [3 /*break*/, 4];
196
196
  _b = new TCB_1.default(alreadyInited);
197
197
  return [3 /*break*/, 6];
198
- case 4: return [4 /*yield*/, this.initTcb(teeOfferAddress, transactionOptions)];
198
+ case 4: return [4 /*yield*/, this.initTcb(teeOfferId, transactionOptions)];
199
199
  case 5:
200
200
  _b = _c.sent();
201
201
  _c.label = 6;
@@ -207,10 +207,10 @@ var Consensus = /** @class */ (function () {
207
207
  return [4 /*yield*/, tcb.needL2toCompleted()];
208
208
  case 8:
209
209
  numberOfMissingL2 = +(_c.sent());
210
- return [4 /*yield*/, LastBlocks_1.default.getRandomL1(tcb.address, transactionOptions)];
210
+ return [4 /*yield*/, LastBlocks_1.default.getRandomL1(tcb.id, transactionOptions)];
211
211
  case 9:
212
212
  _c.sent();
213
- return [4 /*yield*/, Suspicious_1.default.getRandomL2(tcb.address, numberOfMissingL2, transactionOptions)];
213
+ return [4 /*yield*/, Suspicious_1.default.getRandomL2(tcb.id, numberOfMissingL2, transactionOptions)];
214
214
  case 10:
215
215
  _c.sent();
216
216
  _c.label = 11;
@@ -230,13 +230,13 @@ var Consensus = /** @class */ (function () {
230
230
  };
231
231
  /**
232
232
  * Add data to TeeConfirmationBlock and push it to Consensus
233
- * @param teeOfferAddress - TCB's device offer, as key
233
+ * @param teeOfferId - TCB's device offer, as key
234
234
  * @param L1Marks - marks of LastBlocks
235
235
  * @param L2Marks - marks of SuspiciousBlocks
236
236
  * @param tcbData - TEE generated
237
237
  * @param transactionOptions - object what contains alternative action account or gas limit (optional)
238
238
  */
239
- Consensus.addTCB = function (teeOfferAddress, L1Marks, L2Marks, tcbData, transactionOptions) {
239
+ Consensus.addTCB = function (teeOfferId, L1Marks, L2Marks, tcbData, transactionOptions) {
240
240
  return __awaiter(this, void 0, void 0, function () {
241
241
  var logger, tcb, _b;
242
242
  return __generator(this, function (_c) {
@@ -246,7 +246,7 @@ var Consensus = /** @class */ (function () {
246
246
  (0, utils_1.checkIfActionAccountInitialized)();
247
247
  logger = this.logger.child({ method: "addTCB" });
248
248
  _b = TCB_1.default.bind;
249
- return [4 /*yield*/, this.getInitedTcb(teeOfferAddress)];
249
+ return [4 /*yield*/, this.getInitedTcb(teeOfferId)];
250
250
  case 1:
251
251
  tcb = new (_b.apply(TCB_1.default, [void 0, _c.sent()]))();
252
252
  return [4 /*yield*/, this.LEnough(tcb)];
@@ -261,7 +261,7 @@ var Consensus = /** @class */ (function () {
261
261
  return [4 /*yield*/, this.addMarks(L1Marks, L2Marks, tcb, transactionOptions)];
262
262
  case 4:
263
263
  _c.sent();
264
- return [4 /*yield*/, this.addToSupply(tcb.address, transactionOptions)];
264
+ return [4 /*yield*/, this.addToSupply(tcb.id, transactionOptions)];
265
265
  case 5:
266
266
  _c.sent();
267
267
  return [2 /*return*/];
@@ -271,10 +271,10 @@ var Consensus = /** @class */ (function () {
271
271
  };
272
272
  /**
273
273
  * Function stake and lock TCB's reward
274
- * @param tcbAddress - TEE Offer's completed and valid TCB contract
274
+ * @param tcbId - TEE Offer's completed and valid TCB contract
275
275
  * @param transactionOptions - object what contains alternative action account or gas limit (optional)
276
276
  */
277
- Consensus.claimRewards = function (tcbAddress, transactionOptions) {
277
+ Consensus.claimRewards = function (tcbId, transactionOptions) {
278
278
  return __awaiter(this, void 0, void 0, function () {
279
279
  var contract;
280
280
  return __generator(this, function (_b) {
@@ -282,7 +282,7 @@ var Consensus = /** @class */ (function () {
282
282
  case 0:
283
283
  contract = this.checkInit(transactionOptions);
284
284
  (0, utils_1.checkIfActionAccountInitialized)();
285
- return [4 /*yield*/, TxManager_1.default.execute(contract.methods.claimRewards, [tcbAddress], transactionOptions)];
285
+ return [4 /*yield*/, TxManager_1.default.execute(contract.methods.claimRewards, [tcbId], transactionOptions)];
286
286
  case 1:
287
287
  _b.sent();
288
288
  return [2 /*return*/];
@@ -292,11 +292,11 @@ var Consensus = /** @class */ (function () {
292
292
  };
293
293
  /**
294
294
  * Function unlock previously locked TCB rewards (by claimRewards)
295
- * @param tcbAddress - TCB contract address
296
- * @param unlockAmount - amount of tokens to unlock, max available amount = TeeOffer.getLockInfo(tcbAddress)
295
+ * @param tcbId - TCB id
296
+ * @param unlockAmount - amount of tokens to unlock, max available amount = TeeOffer.getLockInfo(tcbId)
297
297
  * @param transactionOptions - object what contains alternative action account or gas limit (optional)
298
298
  */
299
- Consensus.unlockRewards = function (tcbAddress, unlockAmount, transactionOptions) {
299
+ Consensus.unlockRewards = function (tcbId, unlockAmount, transactionOptions) {
300
300
  return __awaiter(this, void 0, void 0, function () {
301
301
  var contract;
302
302
  return __generator(this, function (_b) {
@@ -304,7 +304,7 @@ var Consensus = /** @class */ (function () {
304
304
  case 0:
305
305
  contract = this.checkInit(transactionOptions);
306
306
  (0, utils_1.checkIfActionAccountInitialized)();
307
- return [4 /*yield*/, TxManager_1.default.execute(contract.methods.unlockRewards, [tcbAddress, unlockAmount], transactionOptions)];
307
+ return [4 /*yield*/, TxManager_1.default.execute(contract.methods.unlockRewards, [tcbId, unlockAmount], transactionOptions)];
308
308
  case 1:
309
309
  _b.sent();
310
310
  return [2 /*return*/];
@@ -314,35 +314,35 @@ var Consensus = /** @class */ (function () {
314
314
  };
315
315
  /**
316
316
  * Function return last inited TCB of TEE offer
317
- * @param teeOfferAddress
317
+ * @param teeOfferId
318
318
  * */
319
- Consensus.getInitedTcb = function (teeOfferAddress) {
319
+ Consensus.getInitedTcb = function (teeOfferId) {
320
320
  return __awaiter(this, void 0, void 0, function () {
321
- var tcbAddress;
321
+ var tcbId;
322
322
  return __generator(this, function (_b) {
323
323
  switch (_b.label) {
324
324
  case 0:
325
325
  this.checkInit();
326
- return [4 /*yield*/, this.contract.methods.getInitedTcb(teeOfferAddress).call()];
326
+ return [4 /*yield*/, this.contract.methods.getInitedTcb(teeOfferId).call()];
327
327
  case 1:
328
- tcbAddress = _b.sent();
329
- return [2 /*return*/, tcbAddress];
328
+ tcbId = _b.sent();
329
+ return [2 /*return*/, tcbId];
330
330
  }
331
331
  });
332
332
  });
333
333
  };
334
334
  /**
335
335
  * Function return last inited TCB of TEE offer
336
- * @param teeOfferAddress
336
+ * @param teeOfferId
337
337
  * */
338
- Consensus.getTimeInited = function (teeOfferAddress) {
338
+ Consensus.getTimeInited = function (teeOfferId) {
339
339
  return __awaiter(this, void 0, void 0, function () {
340
340
  var tcbTimeInited;
341
341
  return __generator(this, function (_b) {
342
342
  switch (_b.label) {
343
343
  case 0:
344
344
  this.checkInit();
345
- return [4 /*yield*/, this.contract.methods.getTimeInited(teeOfferAddress).call()];
345
+ return [4 /*yield*/, this.contract.methods.getTimeInited(teeOfferId).call()];
346
346
  case 1:
347
347
  tcbTimeInited = +(_b.sent());
348
348
  return [2 /*return*/, tcbTimeInited];
@@ -11,7 +11,7 @@ declare class OffersFactory {
11
11
  */
12
12
  private static checkInit;
13
13
  /**
14
- * Function for fetching list of all offers addresses
14
+ * Function for fetching list of all offers ids
15
15
  */
16
16
  static getAllOffers(): Promise<string[]>;
17
17
  /**
@@ -31,7 +31,7 @@ declare class OffersFactory {
31
31
  static onOfferEnabled(callback: onOfferEnabledCallback): () => void;
32
32
  static onOfferDisabled(callback: onOfferDisbledCallback): () => void;
33
33
  }
34
- export declare type onOfferCreatedCallback = (address: string, creator: string, externalId: string) => void;
35
- export declare type onOfferEnabledCallback = (providerAuth: string, address: string, offerType: OfferType) => void;
36
- export declare type onOfferDisbledCallback = (providerAuth: string, address: string, offerType: OfferType) => void;
34
+ export declare type onOfferCreatedCallback = (id: string, creator: string, externalId: string) => void;
35
+ export declare type onOfferEnabledCallback = (providerAuth: string, id: string, offerType: OfferType) => void;
36
+ export declare type onOfferDisbledCallback = (providerAuth: string, id: string, offerType: OfferType) => void;
37
37
  export default OffersFactory;
@@ -72,7 +72,7 @@ var OffersFactory = /** @class */ (function () {
72
72
  return (this.contract = new store_1.default.web3.eth.Contract(Offers_json_1.default.abi, Superpro_1.default.address));
73
73
  };
74
74
  /**
75
- * Function for fetching list of all offers addresses
75
+ * Function for fetching list of all offers ids
76
76
  */
77
77
  OffersFactory.getAllOffers = function () {
78
78
  return __awaiter(this, void 0, void 0, function () {
@@ -12,8 +12,8 @@ declare class OrdersFactory {
12
12
  */
13
13
  private static checkInit;
14
14
  /**
15
- * Function for fetching list of all orders addresses
16
- * @returns list of orders addresses
15
+ * Function for fetching list of all orders ids
16
+ * @returns list of orders ids
17
17
  */
18
18
  static getAllOrders(): Promise<string[]>;
19
19
  /**
@@ -22,25 +22,25 @@ declare class OrdersFactory {
22
22
  static getOrdersCount(): Promise<number>;
23
23
  /**
24
24
  * Function for fetching order hold deposit for specific order
25
- * @param orderAddress - address of order for fetching hold deposit
25
+ * @param orderId - order for fetching hold deposit
26
26
  */
27
- static getOrderHoldDeposit(orderAddress: string): Promise<string>;
27
+ static getOrderHoldDeposit(orderId: string): Promise<string>;
28
28
  /**
29
29
  * Function for creating orders
30
30
  * @param orderInfo - order info for new order
31
31
  * @param suspended - is orders suspended
32
32
  * @param transactionOptions - object what contains alternative action account or gas limit (optional)
33
- * @returns {Promise<void>} - Does not return address of created contract!
33
+ * @returns {Promise<void>} - Does not return id of created order!
34
34
  */
35
35
  static createOrder(orderInfo: OrderInfo, holdDeposit?: string, suspended?: boolean, externalId?: string, transactionOptions?: TransactionOptions): Promise<void>;
36
36
  static getOrder(consumer: string, externalId: string): Promise<OrderCreatedEvent>;
37
37
  /**
38
38
  * Function for refilling order deposit
39
- * @param orderAddress - address of order
39
+ * @param orderId - order id
40
40
  * @param amount - amount of tokens to refilling
41
41
  * @param transactionOptions - object what contains alternative action account or gas limit (optional)
42
42
  */
43
- static refillOrderDeposit(orderAddress: string, amount: string, transactionOptions?: TransactionOptions): Promise<void>;
43
+ static refillOrderDeposit(orderId: string, amount: string, transactionOptions?: TransactionOptions): Promise<void>;
44
44
  /**
45
45
  * Function for adding event listeners on order created event in orders factory contract
46
46
  * @param callback - function for processing created order
@@ -75,8 +75,8 @@ var OrdersFactory = /** @class */ (function () {
75
75
  return (this.contract = new store_1.default.web3.eth.Contract(Orders_json_1.default.abi, Superpro_1.default.address));
76
76
  };
77
77
  /**
78
- * Function for fetching list of all orders addresses
79
- * @returns list of orders addresses
78
+ * Function for fetching list of all orders ids
79
+ * @returns list of orders ids
80
80
  */
81
81
  OrdersFactory.getAllOrders = function () {
82
82
  var _a;
@@ -119,15 +119,15 @@ var OrdersFactory = /** @class */ (function () {
119
119
  };
120
120
  /**
121
121
  * Function for fetching order hold deposit for specific order
122
- * @param orderAddress - address of order for fetching hold deposit
122
+ * @param orderId - order for fetching hold deposit
123
123
  */
124
- OrdersFactory.getOrderHoldDeposit = function (orderAddress) {
124
+ OrdersFactory.getOrderHoldDeposit = function (orderId) {
125
125
  return __awaiter(this, void 0, void 0, function () {
126
126
  return __generator(this, function (_a) {
127
127
  switch (_a.label) {
128
128
  case 0:
129
129
  this.checkInit();
130
- return [4 /*yield*/, this.contract.methods.getOrderHoldDeposit(orderAddress).call()];
130
+ return [4 /*yield*/, this.contract.methods.getOrderHoldDeposit(orderId).call()];
131
131
  case 1: return [2 /*return*/, _a.sent()];
132
132
  }
133
133
  });
@@ -138,7 +138,7 @@ var OrdersFactory = /** @class */ (function () {
138
138
  * @param orderInfo - order info for new order
139
139
  * @param suspended - is orders suspended
140
140
  * @param transactionOptions - object what contains alternative action account or gas limit (optional)
141
- * @returns {Promise<void>} - Does not return address of created contract!
141
+ * @returns {Promise<void>} - Does not return id of created order!
142
142
  */
143
143
  OrdersFactory.createOrder = function (orderInfo, holdDeposit, suspended, externalId, transactionOptions) {
144
144
  if (holdDeposit === void 0) { holdDeposit = '0'; }
@@ -189,11 +189,11 @@ var OrdersFactory = /** @class */ (function () {
189
189
  };
190
190
  /**
191
191
  * Function for refilling order deposit
192
- * @param orderAddress - address of order
192
+ * @param orderId - order id
193
193
  * @param amount - amount of tokens to refilling
194
194
  * @param transactionOptions - object what contains alternative action account or gas limit (optional)
195
195
  */
196
- OrdersFactory.refillOrderDeposit = function (orderAddress, amount, transactionOptions) {
196
+ OrdersFactory.refillOrderDeposit = function (orderId, amount, transactionOptions) {
197
197
  return __awaiter(this, void 0, void 0, function () {
198
198
  var contract;
199
199
  return __generator(this, function (_a) {
@@ -201,7 +201,7 @@ var OrdersFactory = /** @class */ (function () {
201
201
  case 0:
202
202
  contract = this.checkInit(transactionOptions);
203
203
  (0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
204
- return [4 /*yield*/, TxManager_1.default.execute(contract.methods.refillOrder, [orderAddress, amount], transactionOptions)];
204
+ return [4 /*yield*/, TxManager_1.default.execute(contract.methods.refillOrder, [orderId, amount], transactionOptions)];
205
205
  case 1:
206
206
  _a.sent();
207
207
  return [2 /*return*/];
@@ -31,6 +31,6 @@ declare class TeeOffersFactory {
31
31
  static onTeeOfferCreated(callback: onTeeOfferCreatedCallback): () => void;
32
32
  static onTeeOfferViolationRateChanged(callback: onTeeOfferViolationRateChangedCallback): () => void;
33
33
  }
34
- export declare type onTeeOfferCreatedCallback = (address: string, providerAuth: string, offerType: OfferType) => void;
35
- export declare type onTeeOfferViolationRateChangedCallback = (address: string, providerAuth: string, violationRate: number) => void;
34
+ export declare type onTeeOfferCreatedCallback = (offerId: string, providerAuth: string, offerType: OfferType) => void;
35
+ export declare type onTeeOfferViolationRateChangedCallback = (offerId: string, providerAuth: string, violationRate: number) => void;
36
36
  export default TeeOffersFactory;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@super-protocol/sdk-js",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "main": "build/index.js",
5
5
  "license": "MIT",
6
6
  "files": [