@super-protocol/sdk-js 0.13.0-beta.4 → 0.13.0-beta.6

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.
@@ -4213,9 +4213,9 @@
4213
4213
  "type": "uint256[]"
4214
4214
  },
4215
4215
  {
4216
- "internalType": "uint256[]",
4217
- "name": "outputOffers",
4218
- "type": "uint256[]"
4216
+ "internalType": "uint256",
4217
+ "name": "outputOffer",
4218
+ "type": "uint256"
4219
4219
  }
4220
4220
  ],
4221
4221
  "internalType": "struct OrderArgs",
@@ -4316,9 +4316,9 @@
4316
4316
  "type": "uint256[]"
4317
4317
  },
4318
4318
  {
4319
- "internalType": "uint256[]",
4320
- "name": "outputOffers",
4321
- "type": "uint256[]"
4319
+ "internalType": "uint256",
4320
+ "name": "outputOffer",
4321
+ "type": "uint256"
4322
4322
  }
4323
4323
  ],
4324
4324
  "internalType": "struct OrderArgs",
@@ -4419,9 +4419,9 @@
4419
4419
  "type": "uint256[]"
4420
4420
  },
4421
4421
  {
4422
- "internalType": "uint256[]",
4423
- "name": "outputOffers",
4424
- "type": "uint256[]"
4422
+ "internalType": "uint256",
4423
+ "name": "outputOffer",
4424
+ "type": "uint256"
4425
4425
  }
4426
4426
  ],
4427
4427
  "internalType": "struct OrderArgs",
@@ -4534,9 +4534,9 @@
4534
4534
  "type": "uint256[]"
4535
4535
  },
4536
4536
  {
4537
- "internalType": "uint256[]",
4538
- "name": "outputOffers",
4539
- "type": "uint256[]"
4537
+ "internalType": "uint256",
4538
+ "name": "outputOffer",
4539
+ "type": "uint256"
4540
4540
  }
4541
4541
  ],
4542
4542
  "internalType": "struct OrderArgs",
@@ -5246,9 +5246,9 @@
5246
5246
  "type": "uint256[]"
5247
5247
  },
5248
5248
  {
5249
- "internalType": "uint256[]",
5250
- "name": "outputOffers",
5251
- "type": "uint256[]"
5249
+ "internalType": "uint256",
5250
+ "name": "outputOffer",
5251
+ "type": "uint256"
5252
5252
  }
5253
5253
  ],
5254
5254
  "internalType": "struct OrderArgs",
@@ -7135,9 +7135,28 @@
7135
7135
  "stateMutability": "view",
7136
7136
  "type": "function"
7137
7137
  },
7138
+ {
7139
+ "inputs": [
7140
+ {
7141
+ "internalType": "uint256",
7142
+ "name": "teeOfferId",
7143
+ "type": "uint256"
7144
+ }
7145
+ ],
7146
+ "name": "getTeeOfferSlotsCount",
7147
+ "outputs": [
7148
+ {
7149
+ "internalType": "uint256",
7150
+ "name": "",
7151
+ "type": "uint256"
7152
+ }
7153
+ ],
7154
+ "stateMutability": "view",
7155
+ "type": "function"
7156
+ },
7138
7157
  {
7139
7158
  "inputs": [],
7140
- "name": "getTeeOffersSlotsCount",
7159
+ "name": "getTeeOffersSlotsCountTotal",
7141
7160
  "outputs": [
7142
7161
  {
7143
7162
  "internalType": "uint256",
@@ -7916,9 +7935,28 @@
7916
7935
  "stateMutability": "view",
7917
7936
  "type": "function"
7918
7937
  },
7938
+ {
7939
+ "inputs": [
7940
+ {
7941
+ "internalType": "uint256",
7942
+ "name": "offerId",
7943
+ "type": "uint256"
7944
+ }
7945
+ ],
7946
+ "name": "getValueOfferSlotsCount",
7947
+ "outputs": [
7948
+ {
7949
+ "internalType": "uint256",
7950
+ "name": "",
7951
+ "type": "uint256"
7952
+ }
7953
+ ],
7954
+ "stateMutability": "view",
7955
+ "type": "function"
7956
+ },
7919
7957
  {
7920
7958
  "inputs": [],
7921
- "name": "getValueOffersSlotsCount",
7959
+ "name": "getValueOffersSlotsCountTotal",
7922
7960
  "outputs": [
7923
7961
  {
7924
7962
  "internalType": "uint256",
@@ -8129,9 +8167,9 @@
8129
8167
  "type": "uint256[]"
8130
8168
  },
8131
8169
  {
8132
- "internalType": "uint256[]",
8133
- "name": "outputOffers",
8134
- "type": "uint256[]"
8170
+ "internalType": "uint256",
8171
+ "name": "outputOffer",
8172
+ "type": "uint256"
8135
8173
  }
8136
8174
  ],
8137
8175
  "internalType": "struct OrderArgs",
@@ -8208,9 +8246,9 @@
8208
8246
  "type": "uint256[]"
8209
8247
  },
8210
8248
  {
8211
- "internalType": "uint256[]",
8212
- "name": "outputOffers",
8213
- "type": "uint256[]"
8249
+ "internalType": "uint256",
8250
+ "name": "outputOffer",
8251
+ "type": "uint256"
8214
8252
  }
8215
8253
  ],
8216
8254
  "internalType": "struct OrderArgs",
@@ -10108,9 +10146,9 @@
10108
10146
  "type": "uint256[]"
10109
10147
  },
10110
10148
  {
10111
- "internalType": "uint256[]",
10112
- "name": "outputOffers",
10113
- "type": "uint256[]"
10149
+ "internalType": "uint256",
10150
+ "name": "outputOffer",
10151
+ "type": "uint256"
10114
10152
  }
10115
10153
  ],
10116
10154
  "internalType": "struct OrderArgs",
@@ -10216,9 +10254,9 @@
10216
10254
  "type": "uint256[]"
10217
10255
  },
10218
10256
  {
10219
- "internalType": "uint256[]",
10220
- "name": "outputOffers",
10221
- "type": "uint256[]"
10257
+ "internalType": "uint256",
10258
+ "name": "outputOffer",
10259
+ "type": "uint256"
10222
10260
  }
10223
10261
  ],
10224
10262
  "internalType": "struct OrderArgs",
@@ -10334,9 +10372,9 @@
10334
10372
  "type": "uint256[]"
10335
10373
  },
10336
10374
  {
10337
- "internalType": "uint256[]",
10338
- "name": "outputOffers",
10339
- "type": "uint256[]"
10375
+ "internalType": "uint256",
10376
+ "name": "outputOffer",
10377
+ "type": "uint256"
10340
10378
  }
10341
10379
  ],
10342
10380
  "internalType": "struct OrderArgs",
@@ -10583,9 +10621,9 @@
10583
10621
  "type": "uint256[]"
10584
10622
  },
10585
10623
  {
10586
- "internalType": "uint256[]",
10587
- "name": "outputOffers",
10588
- "type": "uint256[]"
10624
+ "internalType": "uint256",
10625
+ "name": "outputOffer",
10626
+ "type": "uint256"
10589
10627
  }
10590
10628
  ],
10591
10629
  "internalType": "struct OrderArgs",
@@ -67,7 +67,7 @@ declare class Offer {
67
67
  /**
68
68
  * Function for fetching offer hold deposit
69
69
  */
70
- getMinDeposit(slotId: number, slotCount: number, optionsIds: number[], optionsCount: number[]): Promise<string>;
70
+ getMinDeposit(slotId: string): Promise<string>;
71
71
  /**
72
72
  * Function for fetching cheapest value offer from blockchain
73
73
  */
@@ -83,13 +83,17 @@ declare class Offer {
83
83
  * @param slotId - Slot ID
84
84
  */
85
85
  getSlotById(slotId: string): Promise<ValueOfferSlot>;
86
+ /**
87
+ * @returns this TEE offer slots count
88
+ */
89
+ getSlotsCount(): Promise<string>;
86
90
  /**
87
91
  * Function for fetching offer slots info from blockchain
88
92
  * @param begin - The first element of range.
89
93
  * @param end - One past the final element in the range.
90
94
  * @returns {Promise<ValueOfferSlot[]>}
91
95
  */
92
- getSlots(begin: number, end: number): Promise<ValueOfferSlot[]>;
96
+ getSlots(begin?: number, end?: number): Promise<ValueOfferSlot[]>;
93
97
  /**
94
98
  * Function for add slot usage to the value offer
95
99
  * @param slotInfo - slot info
@@ -254,16 +254,14 @@ var Offer = /** @class */ (function () {
254
254
  /**
255
255
  * Function for fetching offer hold deposit
256
256
  */
257
- Offer.prototype.getMinDeposit = function (slotId, slotCount, optionsIds, optionsCount) {
257
+ Offer.prototype.getMinDeposit = function (slotId) {
258
258
  return __awaiter(this, void 0, void 0, function () {
259
259
  var _a;
260
260
  return __generator(this, function (_b) {
261
261
  switch (_b.label) {
262
262
  case 0:
263
263
  _a = this;
264
- return [4 /*yield*/, Offer.contract.methods
265
- .getOfferMinDeposit(this.id, slotId, slotCount, optionsIds, optionsCount)
266
- .call()];
264
+ return [4 /*yield*/, Offer.contract.methods.getOfferMinDeposit(this.id, slotId, "0", [], []).call()];
267
265
  case 1:
268
266
  _a.minDeposit = _b.sent();
269
267
  return [2 /*return*/, this.minDeposit];
@@ -332,6 +330,19 @@ var Offer = /** @class */ (function () {
332
330
  });
333
331
  });
334
332
  };
333
+ /**
334
+ * @returns this TEE offer slots count
335
+ */
336
+ Offer.prototype.getSlotsCount = function () {
337
+ return __awaiter(this, void 0, void 0, function () {
338
+ return __generator(this, function (_a) {
339
+ switch (_a.label) {
340
+ case 0: return [4 /*yield*/, Offer.contract.methods.getValueOfferSlotsCount().call()];
341
+ case 1: return [2 /*return*/, _a.sent()];
342
+ }
343
+ });
344
+ });
345
+ };
335
346
  /**
336
347
  * Function for fetching offer slots info from blockchain
337
348
  * @param begin - The first element of range.
@@ -339,6 +350,8 @@ var Offer = /** @class */ (function () {
339
350
  * @returns {Promise<ValueOfferSlot[]>}
340
351
  */
341
352
  Offer.prototype.getSlots = function (begin, end) {
353
+ if (begin === void 0) { begin = 0; }
354
+ if (end === void 0) { end = 999999; }
342
355
  return __awaiter(this, void 0, void 0, function () {
343
356
  var slots, _i, slots_1, slot, _a, _b, _c;
344
357
  return __generator(this, function (_d) {
@@ -26,11 +26,20 @@ declare class TeeOffer {
26
26
  origins?: Origins;
27
27
  isCancelable?: boolean;
28
28
  cpuDenominator?: number;
29
+ minDeposit?: string;
29
30
  constructor(offerId: string);
30
31
  /**
31
32
  * Function for fetching offer status from the blockchain
32
33
  */
33
34
  isEnabled(): Promise<boolean>;
35
+ /**
36
+ * Function for fetching offer hold deposit
37
+ */
38
+ getMinDeposit(slotId: string, slotCount: string, optionsIds: string[], optionsCount: string[]): Promise<string>;
39
+ /**
40
+ * @returns this TEE offer slots count
41
+ */
42
+ getSlotsCount(): Promise<string>;
34
43
  /**
35
44
  * @returns True if offer is cancelable.
36
45
  */
@@ -53,7 +62,7 @@ declare class TeeOffer {
53
62
  * @param end - One past the final element in the range.
54
63
  * @returns {Promise<TeeOfferOption[]>}
55
64
  */
56
- getOptions(begin: number, end: number): Promise<TeeOfferOption[]>;
65
+ getOptions(begin?: number, end?: number): Promise<TeeOfferOption[]>;
57
66
  /**
58
67
  * Function for fetching tee offer slot by id
59
68
  * @param optionId - Slot ID
@@ -102,7 +111,7 @@ declare class TeeOffer {
102
111
  * @param end - One past the final element in the range.
103
112
  * @returns {Promise<TeeOfferSlot[]>}
104
113
  */
105
- getSlots(begin: number, end: number): Promise<TeeOfferSlot[]>;
114
+ getSlots(begin?: number, end?: number): Promise<TeeOfferSlot[]>;
106
115
  /**
107
116
  * Function for add slot usage to the tee offer
108
117
  * @param info - New option info
@@ -79,6 +79,39 @@ var TeeOffer = /** @class */ (function () {
79
79
  });
80
80
  });
81
81
  };
82
+ /**
83
+ * Function for fetching offer hold deposit
84
+ */
85
+ TeeOffer.prototype.getMinDeposit = function (slotId, slotCount, optionsIds, optionsCount) {
86
+ return __awaiter(this, void 0, void 0, function () {
87
+ var _a;
88
+ return __generator(this, function (_b) {
89
+ switch (_b.label) {
90
+ case 0:
91
+ _a = this;
92
+ return [4 /*yield*/, TeeOffer.contract.methods
93
+ .getOfferMinDeposit(this.id, slotId, slotCount, optionsIds, optionsCount)
94
+ .call()];
95
+ case 1:
96
+ _a.minDeposit = _b.sent();
97
+ return [2 /*return*/, this.minDeposit];
98
+ }
99
+ });
100
+ });
101
+ };
102
+ /**
103
+ * @returns this TEE offer slots count
104
+ */
105
+ TeeOffer.prototype.getSlotsCount = function () {
106
+ return __awaiter(this, void 0, void 0, function () {
107
+ return __generator(this, function (_a) {
108
+ switch (_a.label) {
109
+ case 0: return [4 /*yield*/, TeeOffer.contract.methods.getTeeOfferSlotsCount().call()];
110
+ case 1: return [2 /*return*/, _a.sent()];
111
+ }
112
+ });
113
+ });
114
+ };
82
115
  /**
83
116
  * @returns True if offer is cancelable.
84
117
  */
@@ -151,6 +184,8 @@ var TeeOffer = /** @class */ (function () {
151
184
  * @returns {Promise<TeeOfferOption[]>}
152
185
  */
153
186
  TeeOffer.prototype.getOptions = function (begin, end) {
187
+ if (begin === void 0) { begin = 0; }
188
+ if (end === void 0) { end = 999999; }
154
189
  return __awaiter(this, void 0, void 0, function () {
155
190
  var teeOfferOption;
156
191
  return __generator(this, function (_a) {
@@ -172,7 +207,7 @@ var TeeOffer = /** @class */ (function () {
172
207
  var teeOfferOption;
173
208
  return __generator(this, function (_a) {
174
209
  switch (_a.label) {
175
- case 0: return [4 /*yield*/, TeeOffer.contract.methods.getTeeOfferSlotById(this.id, optionId).call()];
210
+ case 0: return [4 /*yield*/, TeeOffer.contract.methods.getOptionById(optionId).call()];
176
211
  case 1:
177
212
  teeOfferOption = _a.sent();
178
213
  return [2 /*return*/, (0, utils_1.tupleToObject)(teeOfferOption, TeeOfferOption_1.TeeOfferOptionStructure)];
@@ -312,6 +347,8 @@ var TeeOffer = /** @class */ (function () {
312
347
  * @returns {Promise<TeeOfferSlot[]>}
313
348
  */
314
349
  TeeOffer.prototype.getSlots = function (begin, end) {
350
+ if (begin === void 0) { begin = 0; }
351
+ if (end === void 0) { end = 999999; }
315
352
  return __awaiter(this, void 0, void 0, function () {
316
353
  var slots, _i, slots_1, slot, _a, _b, _c;
317
354
  return __generator(this, function (_d) {
@@ -414,7 +451,7 @@ var TeeOffer = /** @class */ (function () {
414
451
  case 0:
415
452
  contract = BlockchainConnector_1.default.getInstance().getContract(transactionOptions);
416
453
  (0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
417
- return [4 /*yield*/, TxManager_1.default.execute(contract.methods.updateTeeOfferSlot, [this.id, slotId], transactionOptions)];
454
+ return [4 /*yield*/, TxManager_1.default.execute(contract.methods.deleteTeeOfferSlot, [this.id, slotId], transactionOptions)];
418
455
  case 1:
419
456
  _a.sent();
420
457
  return [2 /*return*/];
@@ -746,6 +783,9 @@ var TeeOffer = /** @class */ (function () {
746
783
  __decorate([
747
784
  (0, utils_1.incrementMethodCall)()
748
785
  ], TeeOffer.prototype, "isEnabled", null);
786
+ __decorate([
787
+ (0, utils_1.incrementMethodCall)()
788
+ ], TeeOffer.prototype, "getMinDeposit", null);
749
789
  __decorate([
750
790
  (0, utils_1.incrementMethodCall)()
751
791
  ], TeeOffer.prototype, "isOfferCancelable", null);
@@ -11,7 +11,7 @@ declare class Consensus {
11
11
  * Function for fetching list of all tcb ids
12
12
  * @returns list of tcb ids
13
13
  */
14
- static getAll(): Promise<string[]>;
14
+ static getAllTcbs(): Promise<string[]>;
15
15
  static initializeTcb(teeOfferId: string, transactionOptions?: TransactionOptions): Promise<void>;
16
16
  static isTcbCreationAvailable(teeOfferId: string): Promise<boolean>;
17
17
  /**
@@ -84,7 +84,7 @@ var Consensus = /** @class */ (function () {
84
84
  * Function for fetching list of all tcb ids
85
85
  * @returns list of tcb ids
86
86
  */
87
- Consensus.getAll = function () {
87
+ Consensus.getAllTcbs = function () {
88
88
  var _a;
89
89
  return __awaiter(this, void 0, void 0, function () {
90
90
  var contract, tcbSet, tcbsCount, tcbId;
@@ -22,7 +22,7 @@ declare class Orders {
22
22
  * @returns {Promise<void>} - Does not return id of created order!
23
23
  */
24
24
  static createOrder(orderInfo: OrderInfo, deposit?: string, suspended?: boolean, transactionOptions?: TransactionOptions): Promise<void>;
25
- static getOrder(consumer?: string, externalId?: string, fromBlock?: number | string, toBlock?: number | string): Promise<OrderCreatedEvent>;
25
+ static getByExternalId(consumer: string, externalId: string): Promise<OrderCreatedEvent>;
26
26
  /**
27
27
  * Function for create workflow
28
28
  * @param parentOrderInfo - order info for new order
@@ -144,11 +144,9 @@ var Orders = /** @class */ (function () {
144
144
  });
145
145
  });
146
146
  };
147
- Orders.getOrder = function (consumer, externalId, fromBlock, toBlock) {
148
- if (consumer === void 0) { consumer = ""; }
149
- if (externalId === void 0) { externalId = ""; }
147
+ Orders.getByExternalId = function (consumer, externalId) {
150
148
  return __awaiter(this, void 0, void 0, function () {
151
- var contract, filter, options, foundIds, notFound, response;
149
+ var contract, filter, foundIds, notFound, response;
152
150
  return __generator(this, function (_a) {
153
151
  switch (_a.label) {
154
152
  case 0:
@@ -157,17 +155,17 @@ var Orders = /** @class */ (function () {
157
155
  consumer: consumer,
158
156
  externalId: (0, utils_1.formatBytes32String)(externalId),
159
157
  };
160
- options = { filter: filter };
161
- if (fromBlock)
162
- options.fromBlock = fromBlock;
163
- if (toBlock)
164
- options.toBlock = toBlock;
165
- return [4 /*yield*/, contract.getPastEvents("OrderCreated", options)];
158
+ return [4 /*yield*/, contract.getPastEvents("OrderCreated", { filter: filter })];
166
159
  case 1:
167
160
  foundIds = _a.sent();
168
- notFound = __assign(__assign({}, filter), { offerId: "-1", parentOrderId: "-1", orderId: "-1" });
161
+ notFound = {
162
+ consumer: consumer,
163
+ externalId: externalId,
164
+ offerId: "-1",
165
+ parentOrderId: "-1",
166
+ orderId: "-1",
167
+ };
169
168
  response = foundIds.length > 0 ? foundIds[0].returnValues : notFound;
170
- response.externalId = (0, utils_1.parseBytes32String)(response.externalId);
171
169
  return [2 /*return*/, response];
172
170
  }
173
171
  });
@@ -603,7 +601,7 @@ var Orders = /** @class */ (function () {
603
601
  ], Orders, "createOrder", null);
604
602
  __decorate([
605
603
  (0, utils_2.incrementMethodCall)()
606
- ], Orders, "getOrder", null);
604
+ ], Orders, "getByExternalId", null);
607
605
  __decorate([
608
606
  (0, utils_2.incrementMethodCall)()
609
607
  ], Orders, "createWorkflow", null);
@@ -11,11 +11,11 @@ export declare enum OrderStatus {
11
11
  }
12
12
  export declare const OrderArgsStructure: {
13
13
  inputOffers: StringConstructor[];
14
- outputOffers: StringConstructor[];
14
+ outputOffer: StringConstructor;
15
15
  };
16
16
  export type OrderArgs = {
17
17
  inputOffers: string[];
18
- outputOffers: string[];
18
+ outputOffer: string;
19
19
  };
20
20
  export declare const OrderInfoStructure: {
21
21
  offerId: StringConstructor;
@@ -25,7 +25,7 @@ export declare const OrderInfoStructure: {
25
25
  status: typeof OrderStatus;
26
26
  args: {
27
27
  inputOffers: StringConstructor[];
28
- outputOffers: StringConstructor[];
28
+ outputOffer: StringConstructor;
29
29
  };
30
30
  externalId: typeof parseBytes32String;
31
31
  slotId: StringConstructor;
@@ -41,7 +41,7 @@ export declare const OrderInfoStructureArray: {
41
41
  status: typeof OrderStatus;
42
42
  args: {
43
43
  inputOffers: StringConstructor[];
44
- outputOffers: StringConstructor[];
44
+ outputOffer: StringConstructor;
45
45
  };
46
46
  externalId: typeof parseBytes32String;
47
47
  slotId: StringConstructor;
@@ -16,7 +16,7 @@ var OrderStatus;
16
16
  // Order of keys and type conversion functions for this object in blockchain contract
17
17
  exports.OrderArgsStructure = {
18
18
  inputOffers: [String],
19
- outputOffers: [String],
19
+ outputOffer: String,
20
20
  };
21
21
  // Order of keys and type conversion functions for this object in blockchain contract
22
22
  exports.OrderInfoStructure = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@super-protocol/sdk-js",
3
- "version": "0.13.0-beta.4",
3
+ "version": "0.13.0-beta.6",
4
4
  "main": "build/index.js",
5
5
  "license": "MIT",
6
6
  "files": [