@super-protocol/sdk-js 0.14.0-beta.0 → 0.14.1-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.
@@ -58,6 +58,7 @@ var crypto_1 = __importDefault(require("./crypto"));
58
58
  var Offer_1 = __importDefault(require("./models/Offer"));
59
59
  var Order_1 = __importDefault(require("./models/Order"));
60
60
  var TeeOffer_1 = __importDefault(require("./models/TeeOffer"));
61
+ var TCB_1 = __importDefault(require("./models/TCB"));
61
62
  var dto_js_1 = require("@super-protocol/dto-js");
62
63
  var tee_lib_1 = require("@super-protocol/tee-lib");
63
64
  var TIIGenerator = /** @class */ (function () {
@@ -65,7 +66,7 @@ var TIIGenerator = /** @class */ (function () {
65
66
  }
66
67
  TIIGenerator.generateByOffer = function (offerId, solutionHashes, linkageString, resource, args, encryption) {
67
68
  return __awaiter(this, void 0, void 0, function () {
68
- var teeOffer, teeOfferInfo, linkage, tlb, mac, rawTri, tri, compressedTri, _a, _b, _c, _d;
69
+ var teeOffer, teeOfferInfo, tcbId, tcb, linkage, tlb, mac, rawTri, tri, compressedTri, _a, _b, _c, _d;
69
70
  var _e, _f;
70
71
  return __generator(this, function (_g) {
71
72
  switch (_g.label) {
@@ -74,13 +75,22 @@ var TIIGenerator = /** @class */ (function () {
74
75
  return [4 /*yield*/, teeOffer.getInfo()];
75
76
  case 1:
76
77
  teeOfferInfo = _g.sent();
78
+ return [4 /*yield*/, teeOffer.getActualTcbId()];
79
+ case 2:
80
+ tcbId = _g.sent();
81
+ if (tcbId === "0") {
82
+ throw Error("Tee offer isn't avaliable before added TCB");
83
+ }
84
+ return [4 /*yield*/, new TCB_1.default(tcbId).get()];
85
+ case 3:
86
+ tcb = _g.sent();
77
87
  linkage = linkageString
78
88
  ? JSON.parse(linkageString)
79
89
  : {
80
90
  encoding: dto_js_1.Encoding.base64,
81
91
  mrenclave: "",
82
92
  };
83
- tlb = new tee_lib_1.TLBlockSerializerV1().unserializeTlb(Buffer.from(teeOfferInfo.tlb, "base64"));
93
+ tlb = new tee_lib_1.TLBlockSerializerV1().unserializeTlb(Buffer.from(tcb.quote, "base64"));
84
94
  mac = encryption.authTag || encryption.mac;
85
95
  rawTri = {
86
96
  solutionHashes: solutionHashes.map(function (hash) { return ({
@@ -97,21 +107,21 @@ var TIIGenerator = /** @class */ (function () {
97
107
  _b = (_a = Compression_1.Compression).encode;
98
108
  _e = {};
99
109
  return [4 /*yield*/, (0, node_gzip_1.gzip)(tri)];
100
- case 2:
110
+ case 4:
101
111
  compressedTri = _b.apply(_a, [(_e.data = _g.sent(),
102
112
  _e.type = Compression_1.Compression_TYPE.GZIP,
103
113
  _e)]).finish();
104
114
  _d = (_c = JSON).stringify;
105
115
  _f = {};
106
116
  return [4 /*yield*/, crypto_1.default.encrypt(JSON.stringify(resource), JSON.parse(teeOfferInfo.argsPublicKey))];
107
- case 3:
117
+ case 5:
108
118
  _f.encryptedResource = _g.sent();
109
119
  return [4 /*yield*/, crypto_1.default.encrypt(Buffer.from(compressedTri).toString(dto_js_1.Encoding.base64), {
110
120
  algo: dto_js_1.CryptoAlgorithm.ECIES,
111
121
  key: Buffer.from(tlb.data.teePubKeyData).toString("base64"),
112
122
  encoding: dto_js_1.Encoding.base64,
113
123
  })];
114
- case 4: return [2 /*return*/, _d.apply(_c, [(_f.tri = _g.sent(),
124
+ case 6: return [2 /*return*/, _d.apply(_c, [(_f.tri = _g.sent(),
115
125
  _f)])];
116
126
  }
117
127
  });
@@ -8,6 +8,7 @@ import { TeeOfferSlot } from "../types/TeeOfferSlot";
8
8
  import { OptionInfo } from "../types/OptionInfo";
9
9
  import { SlotUsage } from "../types/SlotUsage";
10
10
  import { SlotInfo } from "../types/SlotInfo";
11
+ import { GetTcbRequest } from "@super-protocol/dto-js";
11
12
  declare class TeeOffer {
12
13
  private static contract;
13
14
  private logger;
@@ -95,6 +96,15 @@ declare class TeeOffer {
95
96
  * @param transactionOptions - object what contains alternative action account or gas limit (optional)
96
97
  */
97
98
  deleteOption(optionId: string, transactionOptions?: TransactionOptions): Promise<void>;
99
+ initializeTcb(transactionOptions?: TransactionOptions): Promise<void>;
100
+ private initializeTcbAndAssignBlocks;
101
+ /**
102
+ * Function initialize TCB and returns list of anothers' TCB for their checking
103
+ * @param teeOfferId - id of TEE offer
104
+ * @param transactionOptions - object what contains alternative action account or gas limit (optional)
105
+ * @returns tcbId and lists of anothers' TCB for their checking
106
+ */
107
+ getListsForVerification(transactionOptions?: TransactionOptions): Promise<GetTcbRequest>;
98
108
  /**
99
109
  * Function for fetching whether tee offer slot exists or not
100
110
  * @param slotId - Slot ID
@@ -133,6 +143,17 @@ declare class TeeOffer {
133
143
  * @param transactionOptions - object what contains alternative action account or gas limit (optional)
134
144
  */
135
145
  deleteSlot(slotId: string, transactionOptions?: TransactionOptions): Promise<void>;
146
+ /**
147
+ * @param teeOfferId - TEE offer ID
148
+ * @returns {Promise<string>} - Actual TCB ID
149
+ */
150
+ getActualTcbId(): Promise<string>;
151
+ /**
152
+ * Function return last inited TCB of TEE offer
153
+ * @param teeOfferId - id of TEE offer
154
+ * */
155
+ getInitializedTcbId(): Promise<string>;
156
+ isTcbCreationAvailable(): Promise<boolean>;
136
157
  /**
137
158
  * Function for fetching TEE offer provider authority account from blockchain
138
159
  */
@@ -146,22 +167,10 @@ declare class TeeOffer {
146
167
  * Function for fetching TLB provider from blockchain
147
168
  */
148
169
  getTlb(): Promise<string>;
149
- /**
150
- * Function for fetching last TLB addition time for this TEE offer
151
- */
152
- getLastTlbAddedTime(): Promise<number>;
153
- /**
154
- * Function for fetching last TCB addition time for this TEE offer
155
- */
156
- getLastTcbAddedTime(): Promise<number>;
157
170
  /**
158
171
  * Function for fetching violationRate for this TEE offer
159
172
  */
160
173
  getViolationRate(): Promise<number>;
161
- /**
162
- * Function for fetching amount of total locked tokens
163
- */
164
- getTotalLocked(): Promise<number>;
165
174
  /**
166
175
  * Fetch new Origins (createdDate, createdBy, modifiedDate and modifiedBy)
167
176
  */
@@ -61,6 +61,7 @@ var SlotUsage_1 = require("../types/SlotUsage");
61
61
  var utils_2 = require("ethers/lib/utils");
62
62
  var SlotInfo_1 = require("../types/SlotInfo");
63
63
  var TeeOffers_1 = __importDefault(require("../staticModels/TeeOffers"));
64
+ var TCB_1 = __importDefault(require("../models/TCB"));
64
65
  var TeeOffer = /** @class */ (function () {
65
66
  function TeeOffer(offerId) {
66
67
  this.id = offerId;
@@ -308,6 +309,94 @@ var TeeOffer = /** @class */ (function () {
308
309
  });
309
310
  });
310
311
  };
312
+ TeeOffer.prototype.initializeTcb = function (transactionOptions) {
313
+ return __awaiter(this, void 0, void 0, function () {
314
+ var contract;
315
+ return __generator(this, function (_a) {
316
+ switch (_a.label) {
317
+ case 0:
318
+ contract = BlockchainConnector_1.default.getInstance().getContract();
319
+ (0, utils_1.checkIfActionAccountInitialized)();
320
+ return [4 /*yield*/, TxManager_1.default.execute(contract.methods.initializeTcb, [this.id], transactionOptions)];
321
+ case 1:
322
+ _a.sent();
323
+ return [2 /*return*/];
324
+ }
325
+ });
326
+ });
327
+ };
328
+ TeeOffer.prototype.initializeTcbAndAssignBlocks = function (transactionOptions) {
329
+ return __awaiter(this, void 0, void 0, function () {
330
+ var tcbId, tcb;
331
+ return __generator(this, function (_a) {
332
+ switch (_a.label) {
333
+ case 0: return [4 /*yield*/, this.initializeTcb(transactionOptions)];
334
+ case 1:
335
+ _a.sent();
336
+ return [4 /*yield*/, this.getInitializedTcbId()];
337
+ case 2:
338
+ tcbId = _a.sent();
339
+ tcb = new TCB_1.default(tcbId);
340
+ return [4 /*yield*/, tcb.assignLastBlocksToCheck(transactionOptions)];
341
+ case 3:
342
+ _a.sent();
343
+ return [4 /*yield*/, tcb.assignSuspiciousBlocksToCheck(transactionOptions)];
344
+ case 4:
345
+ _a.sent();
346
+ return [2 /*return*/, tcb];
347
+ }
348
+ });
349
+ });
350
+ };
351
+ /**
352
+ * Function initialize TCB and returns list of anothers' TCB for their checking
353
+ * @param teeOfferId - id of TEE offer
354
+ * @param transactionOptions - object what contains alternative action account or gas limit (optional)
355
+ * @returns tcbId and lists of anothers' TCB for their checking
356
+ */
357
+ TeeOffer.prototype.getListsForVerification = function (transactionOptions) {
358
+ return __awaiter(this, void 0, void 0, function () {
359
+ var tcb, blocksIds, tcbsForVerification, blockIndex, tcb_1, tcbInfo;
360
+ return __generator(this, function (_a) {
361
+ switch (_a.label) {
362
+ case 0:
363
+ (0, utils_1.checkIfActionAccountInitialized)();
364
+ return [4 /*yield*/, this.initializeTcbAndAssignBlocks(transactionOptions)];
365
+ case 1:
366
+ tcb = _a.sent();
367
+ return [4 /*yield*/, tcb.getCheckingBlocksMarks()];
368
+ case 2:
369
+ blocksIds = (_a.sent()).blocksIds;
370
+ tcbsForVerification = [];
371
+ blockIndex = 0;
372
+ _a.label = 3;
373
+ case 3:
374
+ if (!(blockIndex < blocksIds.length)) return [3 /*break*/, 6];
375
+ tcb_1 = new TCB_1.default(blocksIds[blockIndex]);
376
+ return [4 /*yield*/, tcb_1.get()];
377
+ case 4:
378
+ tcbInfo = _a.sent();
379
+ tcbsForVerification.push({
380
+ tcbId: blocksIds[blockIndex].toString(),
381
+ deviceId: tcbInfo.publicData.deviceID,
382
+ properties: tcbInfo.publicData.properties,
383
+ benchmark: tcbInfo.publicData.benchmark,
384
+ quote: tcbInfo.quote,
385
+ marks: tcbInfo.utilData.checkingBlockMarks,
386
+ checkingBlocks: tcbInfo.utilData.checkingBlocks,
387
+ });
388
+ _a.label = 5;
389
+ case 5:
390
+ blockIndex++;
391
+ return [3 /*break*/, 3];
392
+ case 6: return [2 /*return*/, {
393
+ tcbId: tcb.tcbId,
394
+ tcbsForVerification: tcbsForVerification,
395
+ }];
396
+ }
397
+ });
398
+ });
399
+ };
311
400
  /**
312
401
  * Function for fetching whether tee offer slot exists or not
313
402
  * @param slotId - Slot ID
@@ -471,6 +560,43 @@ var TeeOffer = /** @class */ (function () {
471
560
  });
472
561
  });
473
562
  };
563
+ /**
564
+ * @param teeOfferId - TEE offer ID
565
+ * @returns {Promise<string>} - Actual TCB ID
566
+ */
567
+ TeeOffer.prototype.getActualTcbId = function () {
568
+ return __awaiter(this, void 0, void 0, function () {
569
+ return __generator(this, function (_a) {
570
+ return [2 /*return*/, TeeOffer.contract.methods.getActualTcbId(this.id).call()];
571
+ });
572
+ });
573
+ };
574
+ /**
575
+ * Function return last inited TCB of TEE offer
576
+ * @param teeOfferId - id of TEE offer
577
+ * */
578
+ TeeOffer.prototype.getInitializedTcbId = function () {
579
+ return __awaiter(this, void 0, void 0, function () {
580
+ return __generator(this, function (_a) {
581
+ return [2 /*return*/, TeeOffer.contract.methods.getInitializedTcbId(this.id).call()];
582
+ });
583
+ });
584
+ };
585
+ TeeOffer.prototype.isTcbCreationAvailable = function () {
586
+ return __awaiter(this, void 0, void 0, function () {
587
+ var _a, offerNotBlocked, newEpochStarted, halfEpochPassed, benchmarkVerified;
588
+ return __generator(this, function (_b) {
589
+ switch (_b.label) {
590
+ case 0: return [4 /*yield*/, TeeOffer.contract.methods
591
+ .isTcbCreationAvailable(this.id)
592
+ .call()];
593
+ case 1:
594
+ _a = _b.sent(), offerNotBlocked = _a[0], newEpochStarted = _a[1], halfEpochPassed = _a[2], benchmarkVerified = _a[3];
595
+ return [2 /*return*/, offerNotBlocked && newEpochStarted && halfEpochPassed && benchmarkVerified];
596
+ }
597
+ });
598
+ });
599
+ };
474
600
  /**
475
601
  * Function for fetching TEE offer provider authority account from blockchain
476
602
  */
@@ -533,37 +659,6 @@ var TeeOffer = /** @class */ (function () {
533
659
  });
534
660
  });
535
661
  };
536
- /**
537
- * Function for fetching last TLB addition time for this TEE offer
538
- */
539
- TeeOffer.prototype.getLastTlbAddedTime = function () {
540
- return __awaiter(this, void 0, void 0, function () {
541
- var _a;
542
- return __generator(this, function (_b) {
543
- switch (_b.label) {
544
- case 0:
545
- _a = this;
546
- return [4 /*yield*/, TeeOffer.contract.methods.getTeeOfferLastTlbAddedTime().call()];
547
- case 1:
548
- _a.tlbAddedTime = _b.sent();
549
- return [2 /*return*/, this.tlbAddedTime];
550
- }
551
- });
552
- });
553
- };
554
- /**
555
- * Function for fetching last TCB addition time for this TEE offer
556
- */
557
- TeeOffer.prototype.getLastTcbAddedTime = function () {
558
- return __awaiter(this, void 0, void 0, function () {
559
- return __generator(this, function (_a) {
560
- // this.tcbAddedTime = await TeeOffer.contract.methods.getLastTcbAddedTime().call();
561
- // return this.tcbAddedTime!;
562
- // TODO: stub
563
- return [2 /*return*/, 0];
564
- });
565
- });
566
- };
567
662
  /**
568
663
  * Function for fetching violationRate for this TEE offer
569
664
  */
@@ -582,19 +677,6 @@ var TeeOffer = /** @class */ (function () {
582
677
  });
583
678
  });
584
679
  };
585
- /**
586
- * Function for fetching amount of total locked tokens
587
- */
588
- TeeOffer.prototype.getTotalLocked = function () {
589
- return __awaiter(this, void 0, void 0, function () {
590
- return __generator(this, function (_a) {
591
- // this.totalLocked = await TeeOffer.contract.methods.getTotalLocked().call();
592
- // return this.totalLocked!;
593
- // TODO: stub
594
- return [2 /*return*/, 0];
595
- });
596
- });
597
- };
598
680
  /**
599
681
  * Fetch new Origins (createdDate, createdBy, modifiedDate and modifiedBy)
600
682
  */
@@ -819,6 +901,15 @@ var TeeOffer = /** @class */ (function () {
819
901
  __decorate([
820
902
  (0, utils_1.incrementMethodCall)()
821
903
  ], TeeOffer.prototype, "deleteOption", null);
904
+ __decorate([
905
+ (0, utils_1.incrementMethodCall)()
906
+ ], TeeOffer.prototype, "initializeTcb", null);
907
+ __decorate([
908
+ (0, utils_1.incrementMethodCall)()
909
+ ], TeeOffer.prototype, "initializeTcbAndAssignBlocks", null);
910
+ __decorate([
911
+ (0, utils_1.incrementMethodCall)()
912
+ ], TeeOffer.prototype, "getListsForVerification", null);
822
913
  __decorate([
823
914
  (0, utils_1.incrementMethodCall)()
824
915
  ], TeeOffer.prototype, "addSlot", null);
@@ -11,7 +11,8 @@ export default class StorJStorageProvider implements IStorageProvider {
11
11
  private _access?;
12
12
  private _project?;
13
13
  private _storj?;
14
- constructor(credentials: any);
14
+ private maximumConcurrent?;
15
+ constructor(credentials: any, maximumConcurrent?: number);
15
16
  uploadFile(inputStream: stream.Readable, remotePath: string, contentLength: number, progressListener?: (total: number, current: number) => void): Promise<void>;
16
17
  downloadFile(remotePath: string, config: DownloadConfig, progressListener?: (total: number, current: number) => void): Promise<stream.Readable>;
17
18
  deleteObject(remotePath: string): Promise<void>;
@@ -63,7 +63,7 @@ var utils_1 = require("../../utils");
63
63
  var stream_1 = __importDefault(require("stream"));
64
64
  var logger_1 = __importDefault(require("../../logger"));
65
65
  var StorJStorageProvider = /** @class */ (function () {
66
- function StorJStorageProvider(credentials) {
66
+ function StorJStorageProvider(credentials, maximumConcurrent) {
67
67
  this.logger = logger_1.default.child({ className: "StorJStorageProvider" });
68
68
  if (!(0, utils_1.isNodeJS)()) {
69
69
  throw Error("StorageProvider: StorJ is supported only in the node.js execution environment");
@@ -79,6 +79,7 @@ var StorJStorageProvider = /** @class */ (function () {
79
79
  this.bucket = credentials.storageId;
80
80
  }
81
81
  this.accessToken = credentials.token;
82
+ this.maximumConcurrent = maximumConcurrent;
82
83
  }
83
84
  StorJStorageProvider.prototype.uploadFile = function (inputStream, remotePath, contentLength, progressListener) {
84
85
  var _a, inputStream_1, inputStream_1_1;
@@ -367,7 +368,7 @@ var StorJStorageProvider = /** @class */ (function () {
367
368
  case 1:
368
369
  access = _b.sent();
369
370
  _a = this;
370
- return [4 /*yield*/, access.openProject()];
371
+ return [4 /*yield*/, access.openProject(this.maximumConcurrent)];
371
372
  case 2:
372
373
  _a._project = _b.sent();
373
374
  _b.label = 3;
@@ -9,7 +9,7 @@ exports.default = (function (storageAccess) {
9
9
  var key = storageAccess.storageType;
10
10
  switch (key) {
11
11
  case dto_js_1.StorageType.StorJ:
12
- return new StorjStorageProvider_1.default(storageAccess.credentials);
12
+ return new StorjStorageProvider_1.default(storageAccess.credentials, storageAccess.maximumConcurrent);
13
13
  default:
14
14
  throw Error("Unsupported storageType ".concat(key));
15
15
  }
@@ -1,39 +1,22 @@
1
1
  import { EpochInfo } from "../types/Consensus";
2
- import { GetTcbRequest } from "@super-protocol/dto-js";
3
2
  import { TransactionOptions, BlockInfo } from "../types/Web3";
4
3
  import { ConsensusConstants } from "../types/Consensus";
5
4
  declare class Consensus {
6
5
  private static readonly logger;
7
6
  private static tcbIds?;
8
7
  static get address(): string;
9
- private static initializeTcbAndAssignBlocks;
10
8
  /**
11
9
  * Function for fetching list of all tcb ids
12
10
  * @returns list of tcb ids
13
11
  */
14
12
  static getAllTcbs(): Promise<string[]>;
15
- static initializeTcb(teeOfferId: string, transactionOptions?: TransactionOptions): Promise<void>;
16
13
  static unlockProfitByTcbList(tcbIds: string[], transactionOptions?: TransactionOptions): Promise<void>;
17
- static isTcbCreationAvailable(teeOfferId: string): Promise<boolean>;
18
- /**
19
- * Function initialize TCB and returns list of anothers' TCB for their checking
20
- * @param teeOfferId - id of TEE offer
21
- * @param transactionOptions - object what contains alternative action account or gas limit (optional)
22
- * @returns tcbId and lists of anothers' TCB for their checking
23
- */
24
- static getListsForVerification(teeOfferId: string, transactionOptions?: TransactionOptions): Promise<GetTcbRequest>;
25
- /**
26
- * Function return last inited TCB of TEE offer
27
- * @param teeOfferId - id of TEE offer
28
- * */
29
- static getInitializedTcbId(teeOfferId: string): Promise<string>;
30
14
  static getEpochTime(time: number): Promise<{
31
15
  epochStart: number;
32
16
  epochEnd: number;
33
17
  epochIndex: number;
34
18
  }>;
35
19
  static getEpoch(epochIndex: number): Promise<EpochInfo>;
36
- static getActualTcbId(teeOfferId: string): Promise<string>;
37
20
  static getSuspiciousBlockTable(): Promise<string[]>;
38
21
  static getSuspiciousBlockTableSize(): Promise<string[]>;
39
22
  static getLastBlockTable(): Promise<string[]>;
@@ -57,29 +57,6 @@ var Consensus = /** @class */ (function () {
57
57
  enumerable: false,
58
58
  configurable: true
59
59
  });
60
- Consensus.initializeTcbAndAssignBlocks = function (teeOfferId, transactionOptions) {
61
- return __awaiter(this, void 0, void 0, function () {
62
- var tcbId, tcb;
63
- return __generator(this, function (_a) {
64
- switch (_a.label) {
65
- case 0: return [4 /*yield*/, this.initializeTcb(teeOfferId, transactionOptions)];
66
- case 1:
67
- _a.sent();
68
- return [4 /*yield*/, this.getInitializedTcbId(teeOfferId)];
69
- case 2:
70
- tcbId = _a.sent();
71
- tcb = new TCB_1.default(tcbId);
72
- return [4 /*yield*/, tcb.assignLastBlocksToCheck(transactionOptions)];
73
- case 3:
74
- _a.sent();
75
- return [4 /*yield*/, tcb.assignSuspiciousBlocksToCheck(transactionOptions)];
76
- case 4:
77
- _a.sent();
78
- return [2 /*return*/, tcb];
79
- }
80
- });
81
- });
82
- };
83
60
  /**
84
61
  * Function for fetching list of all tcb ids
85
62
  * @returns list of tcb ids
@@ -105,22 +82,6 @@ var Consensus = /** @class */ (function () {
105
82
  });
106
83
  });
107
84
  };
108
- Consensus.initializeTcb = function (teeOfferId, transactionOptions) {
109
- return __awaiter(this, void 0, void 0, function () {
110
- var contract;
111
- return __generator(this, function (_a) {
112
- switch (_a.label) {
113
- case 0:
114
- contract = BlockchainConnector_1.default.getInstance().getContract();
115
- (0, utils_1.checkIfActionAccountInitialized)();
116
- return [4 /*yield*/, TxManager_1.default.execute(contract.methods.initializeTcb, [teeOfferId], transactionOptions)];
117
- case 1:
118
- _a.sent();
119
- return [2 /*return*/];
120
- }
121
- });
122
- });
123
- };
124
85
  Consensus.unlockProfitByTcbList = function (tcbIds, transactionOptions) {
125
86
  return __awaiter(this, void 0, void 0, function () {
126
87
  var contract, executedCount, e_1, _i, tcbIds_1, tcbId;
@@ -164,85 +125,6 @@ var Consensus = /** @class */ (function () {
164
125
  });
165
126
  });
166
127
  };
167
- Consensus.isTcbCreationAvailable = function (teeOfferId) {
168
- return __awaiter(this, void 0, void 0, function () {
169
- var contract, _a, offerNotBlocked, newEpochStarted, halfEpochPassed, benchmarkVerified;
170
- return __generator(this, function (_b) {
171
- switch (_b.label) {
172
- case 0:
173
- contract = BlockchainConnector_1.default.getInstance().getContract();
174
- return [4 /*yield*/, contract.methods
175
- .isTcbCreationAvailable(teeOfferId)
176
- .call()];
177
- case 1:
178
- _a = _b.sent(), offerNotBlocked = _a[0], newEpochStarted = _a[1], halfEpochPassed = _a[2], benchmarkVerified = _a[3];
179
- return [2 /*return*/, offerNotBlocked && newEpochStarted && halfEpochPassed && benchmarkVerified];
180
- }
181
- });
182
- });
183
- };
184
- /**
185
- * Function initialize TCB and returns list of anothers' TCB for their checking
186
- * @param teeOfferId - id of TEE offer
187
- * @param transactionOptions - object what contains alternative action account or gas limit (optional)
188
- * @returns tcbId and lists of anothers' TCB for their checking
189
- */
190
- Consensus.getListsForVerification = function (teeOfferId, transactionOptions) {
191
- return __awaiter(this, void 0, void 0, function () {
192
- var tcb, blocksIds, tcbsForVerification, blockIndex, tcb_1, tcbInfo;
193
- return __generator(this, function (_a) {
194
- switch (_a.label) {
195
- case 0:
196
- (0, utils_1.checkIfActionAccountInitialized)();
197
- return [4 /*yield*/, this.initializeTcbAndAssignBlocks(teeOfferId, transactionOptions)];
198
- case 1:
199
- tcb = _a.sent();
200
- return [4 /*yield*/, tcb.getCheckingBlocksMarks()];
201
- case 2:
202
- blocksIds = (_a.sent()).blocksIds;
203
- tcbsForVerification = [];
204
- blockIndex = 0;
205
- _a.label = 3;
206
- case 3:
207
- if (!(blockIndex < blocksIds.length)) return [3 /*break*/, 6];
208
- tcb_1 = new TCB_1.default(blocksIds[blockIndex]);
209
- return [4 /*yield*/, tcb_1.get()];
210
- case 4:
211
- tcbInfo = _a.sent();
212
- tcbsForVerification.push({
213
- tcbId: blocksIds[blockIndex].toString(),
214
- deviceId: tcbInfo.publicData.deviceID,
215
- properties: tcbInfo.publicData.properties,
216
- benchmark: tcbInfo.publicData.benchmark,
217
- quote: tcbInfo.quote,
218
- marks: tcbInfo.utilData.checkingBlockMarks,
219
- checkingBlocks: tcbInfo.utilData.checkingBlocks,
220
- });
221
- _a.label = 5;
222
- case 5:
223
- blockIndex++;
224
- return [3 /*break*/, 3];
225
- case 6: return [2 /*return*/, {
226
- tcbId: tcb.tcbId,
227
- tcbsForVerification: tcbsForVerification,
228
- }];
229
- }
230
- });
231
- });
232
- };
233
- /**
234
- * Function return last inited TCB of TEE offer
235
- * @param teeOfferId - id of TEE offer
236
- * */
237
- Consensus.getInitializedTcbId = function (teeOfferId) {
238
- return __awaiter(this, void 0, void 0, function () {
239
- var contract;
240
- return __generator(this, function (_a) {
241
- contract = BlockchainConnector_1.default.getInstance().getContract();
242
- return [2 /*return*/, contract.methods.getInitializedTcbId(teeOfferId).call()];
243
- });
244
- });
245
- };
246
128
  Consensus.getEpochTime = function (time) {
247
129
  return __awaiter(this, void 0, void 0, function () {
248
130
  var contract, _a, epochStart, epochEnd, epochIndex;
@@ -275,15 +157,6 @@ var Consensus = /** @class */ (function () {
275
157
  });
276
158
  });
277
159
  };
278
- Consensus.getActualTcbId = function (teeOfferId) {
279
- return __awaiter(this, void 0, void 0, function () {
280
- var contract;
281
- return __generator(this, function (_a) {
282
- contract = BlockchainConnector_1.default.getInstance().getContract();
283
- return [2 /*return*/, contract.methods.getActualTcbId(teeOfferId).call()];
284
- });
285
- });
286
- };
287
160
  Consensus.getSuspiciousBlockTable = function () {
288
161
  return __awaiter(this, void 0, void 0, function () {
289
162
  var contract;
@@ -2,5 +2,6 @@ import { StorageType } from "@super-protocol/dto-js";
2
2
  type StorageAccess = {
3
3
  storageType: StorageType;
4
4
  credentials: any;
5
+ maximumConcurrent?: number;
5
6
  };
6
7
  export default StorageAccess;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@super-protocol/sdk-js",
3
- "version": "0.14.0-beta.0",
3
+ "version": "0.14.1-beta.0",
4
4
  "main": "build/index.js",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -54,7 +54,7 @@
54
54
  "dependencies": {
55
55
  "@super-protocol/dto-js": "0.0.24",
56
56
  "@super-protocol/tee-lib": "^0.1.2",
57
- "@super-protocol/uplink-nodejs": "1.2.12",
57
+ "@super-protocol/uplink-nodejs": "1.2.16",
58
58
  "ethers": "^5.5.3",
59
59
  "hybrid-crypto-js": "^0.2.4",
60
60
  "lodash": "^4.17.21",
@@ -64,5 +64,8 @@
64
64
  "web3": "^1.7.1",
65
65
  "web3-parse-receipt-events": "^1.0.2"
66
66
  },
67
- "repository": "git://github.com/Super-Protocol/sdk-js.git"
67
+ "repository": "git://github.com/Super-Protocol/sdk-js.git",
68
+ "resolutions": {
69
+ "wrap-ansi": "7.0.0"
70
+ }
68
71
  }