@super-protocol/sdk-js 0.6.5-beta.0 → 0.7.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.
- package/build/BlockchainConnector.d.ts +7 -1
- package/build/BlockchainConnector.js +44 -0
- package/build/constants.d.ts +1 -0
- package/build/constants.js +2 -1
- package/build/contracts/app.json +8671 -0
- package/build/index.d.ts +1 -8
- package/build/index.js +2 -12
- package/build/models/Ballot.js +2 -5
- package/build/models/Offer.d.ts +12 -0
- package/build/models/Offer.js +47 -3
- package/build/models/Order.js +4 -4
- package/build/models/Provider.d.ts +3 -1
- package/build/models/Provider.js +29 -7
- package/build/models/TCB.d.ts +36 -50
- package/build/models/TCB.js +105 -148
- package/build/models/TeeOffer.js +3 -3
- package/build/staticModels/ActiveOffers.js +3 -3
- package/build/staticModels/ActiveOrders.js +3 -3
- package/build/staticModels/Consensus.d.ts +13 -44
- package/build/staticModels/Consensus.js +87 -255
- package/build/staticModels/Marks.js +3 -3
- package/build/staticModels/OffersFactory.js +3 -3
- package/build/staticModels/OrdersFactory.js +3 -3
- package/build/staticModels/ProviderRegistry.d.ts +1 -0
- package/build/staticModels/ProviderRegistry.js +17 -6
- package/build/staticModels/Staking.js +3 -3
- package/build/staticModels/Superpro.js +2 -2
- package/build/staticModels/SuperproToken.d.ts +4 -0
- package/build/staticModels/SuperproToken.js +22 -4
- package/build/staticModels/TeeOffersFactory.js +3 -3
- package/build/staticModels/Voting.js +3 -3
- package/build/types/Consensus.d.ts +55 -0
- package/build/types/Consensus.js +38 -0
- package/build/types/Web3.d.ts +5 -0
- package/build/utils.d.ts +1 -1
- package/build/utils.js +1 -1
- package/package.json +5 -4
- package/build/contracts/ActiveOffersList.json +0 -131
- package/build/contracts/ActiveOrdersList.json +0 -169
- package/build/contracts/Marks.json +0 -79
- package/build/contracts/Offers.json +0 -1018
- package/build/contracts/Orders.json +0 -984
- package/build/contracts/Providers.json +0 -421
- package/build/contracts/ProvidersOffers.json +0 -254
- package/build/contracts/Staking.json +0 -323
- package/build/contracts/Superpro.json +0 -197
- package/build/contracts/SuperproToken.json +0 -356
- package/build/staticModels/Epochs.d.ts +0 -23
- package/build/staticModels/Epochs.js +0 -97
- package/build/staticModels/LastBlocks.d.ts +0 -25
- package/build/staticModels/LastBlocks.js +0 -96
- package/build/staticModels/Suspicious.d.ts +0 -26
- package/build/staticModels/Suspicious.js +0 -99
- package/build/types/Epoch.d.ts +0 -21
- package/build/types/Epoch.js +0 -18
- package/build/types/TcbData.d.ts +0 -26
- package/build/types/TcbData.js +0 -21
|
@@ -41,14 +41,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
var store_1 = __importDefault(require("../store"));
|
|
43
43
|
var logger_1 = __importDefault(require("../logger"));
|
|
44
|
-
|
|
45
|
-
var Offers_json_1 = __importDefault(require("../contracts/Offers.json"));
|
|
44
|
+
var app_json_1 = __importDefault(require("../contracts/app.json"));
|
|
46
45
|
var TCB_1 = __importDefault(require("../models/TCB"));
|
|
47
|
-
var LastBlocks_1 = __importDefault(require("./LastBlocks"));
|
|
48
|
-
var Suspicious_1 = __importDefault(require("./Suspicious"));
|
|
49
46
|
var utils_1 = require("../utils");
|
|
50
47
|
var constants_1 = require("../constants");
|
|
51
|
-
var TcbData_1 = require("../types/TcbData");
|
|
52
48
|
var Superpro_1 = __importDefault(require("./Superpro"));
|
|
53
49
|
var TxManager_1 = __importDefault(require("../utils/TxManager"));
|
|
54
50
|
var Consensus = /** @class */ (function () {
|
|
@@ -60,314 +56,150 @@ var Consensus = /** @class */ (function () {
|
|
|
60
56
|
Consensus.checkInit = function (transactionOptions) {
|
|
61
57
|
if (transactionOptions === null || transactionOptions === void 0 ? void 0 : transactionOptions.web3) {
|
|
62
58
|
(0, utils_1.checkIfInitialized)();
|
|
63
|
-
|
|
64
|
-
// TODO: stub
|
|
65
|
-
return new transactionOptions.web3.eth.Contract(Offers_json_1.default.abi, Superpro_1.default.address);
|
|
59
|
+
return new transactionOptions.web3.eth.Contract(app_json_1.default.abi, this.address);
|
|
66
60
|
}
|
|
67
61
|
if (this.contract)
|
|
68
62
|
return this.contract;
|
|
69
63
|
(0, utils_1.checkIfInitialized)();
|
|
70
64
|
this.logger = logger_1.default.child({ className: "Consensus" });
|
|
71
|
-
|
|
72
|
-
// TODO: stub
|
|
73
|
-
this.contract = new store_1.default.web3.eth.Contract(Offers_json_1.default.abi, Superpro_1.default.address);
|
|
74
|
-
return this.contract;
|
|
65
|
+
return (this.contract = new store_1.default.web3.eth.Contract(app_json_1.default.abi, Superpro_1.default.address));
|
|
75
66
|
};
|
|
76
|
-
Consensus.
|
|
67
|
+
Consensus.initializeTcb = function (teeOfferId, transactionOptions) {
|
|
77
68
|
return __awaiter(this, void 0, void 0, function () {
|
|
78
|
-
var tcbId;
|
|
79
|
-
return __generator(this, function (_b) {
|
|
80
|
-
switch (_b.label) {
|
|
81
|
-
case 0: return [4 /*yield*/, TxManager_1.default.execute(this.contract.methods.initTcb, [teeOfferId], transactionOptions)];
|
|
82
|
-
case 1:
|
|
83
|
-
_b.sent();
|
|
84
|
-
return [4 /*yield*/, this.getInitedTcb(teeOfferId)];
|
|
85
|
-
case 2:
|
|
86
|
-
tcbId = _b.sent();
|
|
87
|
-
return [2 /*return*/, new TCB_1.default(tcbId)];
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
Consensus.addToSupply = function (tcbId, transactionOptions) {
|
|
93
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
94
|
-
return __generator(this, function (_b) {
|
|
95
|
-
switch (_b.label) {
|
|
96
|
-
case 0: return [4 /*yield*/, TxManager_1.default.execute(this.contract.methods.addToSupply, [tcbId], transactionOptions)];
|
|
97
|
-
case 1:
|
|
98
|
-
_b.sent();
|
|
99
|
-
return [2 /*return*/];
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
};
|
|
104
|
-
Consensus.addMarks = function (L1Marks, L2Marks, tcb, transactionOptions) {
|
|
105
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
106
|
-
var logger, needAddMarks, addAdjustedMarks, l1MarksDiff, l2MarksDiff;
|
|
107
|
-
var _this = this;
|
|
108
|
-
return __generator(this, function (_b) {
|
|
109
|
-
switch (_b.label) {
|
|
110
|
-
case 0:
|
|
111
|
-
logger = this.logger.child({ method: "addTcbMarks" });
|
|
112
|
-
needAddMarks = function (lType) { return __awaiter(_this, void 0, void 0, function () {
|
|
113
|
-
var _b, _c, _d;
|
|
114
|
-
return __generator(this, function (_e) {
|
|
115
|
-
switch (_e.label) {
|
|
116
|
-
case 0:
|
|
117
|
-
if (!(lType == TcbData_1.LType.L1)) return [3 /*break*/, 3];
|
|
118
|
-
return [4 /*yield*/, tcb.getL1()];
|
|
119
|
-
case 1:
|
|
120
|
-
_c = (_e.sent()).length;
|
|
121
|
-
return [4 /*yield*/, tcb.getL1Marks()];
|
|
122
|
-
case 2:
|
|
123
|
-
_b = _c - (_e.sent()).length;
|
|
124
|
-
return [3 /*break*/, 6];
|
|
125
|
-
case 3: return [4 /*yield*/, tcb.getL2()];
|
|
126
|
-
case 4:
|
|
127
|
-
_d = (_e.sent()).length;
|
|
128
|
-
return [4 /*yield*/, tcb.getL2Marks()];
|
|
129
|
-
case 5:
|
|
130
|
-
_b = _d - (_e.sent()).length;
|
|
131
|
-
_e.label = 6;
|
|
132
|
-
case 6: return [2 /*return*/, _b];
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
}); };
|
|
136
|
-
addAdjustedMarks = function (diff, marks, lType) { return __awaiter(_this, void 0, void 0, function () {
|
|
137
|
-
var adjustedMarks;
|
|
138
|
-
return __generator(this, function (_b) {
|
|
139
|
-
switch (_b.label) {
|
|
140
|
-
case 0:
|
|
141
|
-
if (diff > marks.length) {
|
|
142
|
-
logger.error("Invalid L marks count");
|
|
143
|
-
return [2 /*return*/];
|
|
144
|
-
}
|
|
145
|
-
if (!(diff > 0)) return [3 /*break*/, 2];
|
|
146
|
-
adjustedMarks = marks.slice(diff * -1);
|
|
147
|
-
return [4 /*yield*/, tcb.addMarks(lType, adjustedMarks, transactionOptions)];
|
|
148
|
-
case 1:
|
|
149
|
-
_b.sent();
|
|
150
|
-
_b.label = 2;
|
|
151
|
-
case 2: return [2 /*return*/];
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
}); };
|
|
155
|
-
return [4 /*yield*/, needAddMarks(TcbData_1.LType.L1)];
|
|
156
|
-
case 1:
|
|
157
|
-
l1MarksDiff = _b.sent();
|
|
158
|
-
return [4 /*yield*/, needAddMarks(TcbData_1.LType.L2)];
|
|
159
|
-
case 2:
|
|
160
|
-
l2MarksDiff = _b.sent();
|
|
161
|
-
return [4 /*yield*/, addAdjustedMarks(l1MarksDiff, L1Marks, TcbData_1.LType.L1)];
|
|
162
|
-
case 3:
|
|
163
|
-
_b.sent();
|
|
164
|
-
return [4 /*yield*/, addAdjustedMarks(l2MarksDiff, L2Marks, TcbData_1.LType.L2)];
|
|
165
|
-
case 4:
|
|
166
|
-
_b.sent();
|
|
167
|
-
return [2 /*return*/];
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
};
|
|
172
|
-
/**
|
|
173
|
-
* Function initialize TCB and returns two lists of anothers' TCB ids for their checking
|
|
174
|
-
* @param teeOfferId
|
|
175
|
-
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
176
|
-
* @returns two lists of anothers' TCB ids for their checking
|
|
177
|
-
*/
|
|
178
|
-
Consensus.getListsForVerification = function (teeOfferId, transactionOptions) {
|
|
179
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
180
|
-
var alreadyInited, tcbTimeInited, timestamp, tcb, _b, numberOfMissingL2, L1, L2;
|
|
69
|
+
var tcbId, tcb, timeInitialized, _a, _b;
|
|
181
70
|
return __generator(this, function (_c) {
|
|
182
71
|
switch (_c.label) {
|
|
183
|
-
case 0:
|
|
184
|
-
this.checkInit();
|
|
185
|
-
(0, utils_1.checkIfActionAccountInitialized)();
|
|
186
|
-
return [4 /*yield*/, this.getInitedTcb(teeOfferId)];
|
|
72
|
+
case 0: return [4 /*yield*/, this.getInitializedTcbId(teeOfferId)];
|
|
187
73
|
case 1:
|
|
188
|
-
|
|
189
|
-
|
|
74
|
+
tcbId = _c.sent();
|
|
75
|
+
tcb = new TCB_1.default(tcbId);
|
|
76
|
+
return [4 /*yield*/, tcb.get()];
|
|
190
77
|
case 2:
|
|
191
|
-
|
|
78
|
+
timeInitialized = (_c.sent()).timeInitialized;
|
|
79
|
+
_a = timeInitialized == 0;
|
|
80
|
+
if (_a) return [3 /*break*/, 4];
|
|
81
|
+
_b = timeInitialized;
|
|
192
82
|
return [4 /*yield*/, (0, utils_1.getTimestamp)()];
|
|
193
83
|
case 3:
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
return [3 /*break*/,
|
|
198
|
-
|
|
84
|
+
_a = _b > +(_c.sent()) + constants_1.ONE_DAY;
|
|
85
|
+
_c.label = 4;
|
|
86
|
+
case 4:
|
|
87
|
+
if (!_a) return [3 /*break*/, 9];
|
|
88
|
+
return [4 /*yield*/, TxManager_1.default.execute(this.contract.methods.initializeTcb, [teeOfferId], transactionOptions)];
|
|
199
89
|
case 5:
|
|
200
|
-
|
|
201
|
-
|
|
90
|
+
_c.sent();
|
|
91
|
+
return [4 /*yield*/, this.getInitializedTcbId(teeOfferId)];
|
|
202
92
|
case 6:
|
|
203
|
-
|
|
204
|
-
|
|
93
|
+
tcbId = _c.sent();
|
|
94
|
+
tcb = new TCB_1.default(tcbId);
|
|
95
|
+
return [4 /*yield*/, tcb.assignLastBlocksToCheck(transactionOptions)];
|
|
205
96
|
case 7:
|
|
206
|
-
if (!!(_c.sent())) return [3 /*break*/, 11];
|
|
207
|
-
return [4 /*yield*/, tcb.needL2toCompleted()];
|
|
208
|
-
case 8:
|
|
209
|
-
numberOfMissingL2 = +(_c.sent());
|
|
210
|
-
return [4 /*yield*/, LastBlocks_1.default.getRandomL1(tcb.id, transactionOptions)];
|
|
211
|
-
case 9:
|
|
212
97
|
_c.sent();
|
|
213
|
-
return [4 /*yield*/,
|
|
214
|
-
case
|
|
98
|
+
return [4 /*yield*/, tcb.assignSuspiciousBlocksToCheck(transactionOptions)];
|
|
99
|
+
case 8:
|
|
215
100
|
_c.sent();
|
|
216
|
-
_c.label =
|
|
217
|
-
case
|
|
218
|
-
case 12:
|
|
219
|
-
L1 = _c.sent();
|
|
220
|
-
return [4 /*yield*/, tcb.getL2()];
|
|
221
|
-
case 13:
|
|
222
|
-
L2 = _c.sent();
|
|
223
|
-
return [2 /*return*/, {
|
|
224
|
-
L1: L1,
|
|
225
|
-
L2: L2,
|
|
226
|
-
}];
|
|
101
|
+
_c.label = 9;
|
|
102
|
+
case 9: return [2 /*return*/, tcb];
|
|
227
103
|
}
|
|
228
104
|
});
|
|
229
105
|
});
|
|
230
106
|
};
|
|
231
107
|
/**
|
|
232
|
-
*
|
|
233
|
-
* @param teeOfferId -
|
|
234
|
-
* @param L1Marks - marks of LastBlocks
|
|
235
|
-
* @param L2Marks - marks of SuspiciousBlocks
|
|
236
|
-
* @param tcbData - TEE generated
|
|
108
|
+
* Function initialize TCB and returns list of anothers' TCB for their checking
|
|
109
|
+
* @param teeOfferId - id of TEE offer
|
|
237
110
|
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
111
|
+
* @returns tcbId and lists of anothers' TCB for their checking
|
|
238
112
|
*/
|
|
239
|
-
Consensus.
|
|
113
|
+
Consensus.getListsForVerification = function (teeOfferId, transactionOptions) {
|
|
240
114
|
return __awaiter(this, void 0, void 0, function () {
|
|
241
|
-
var
|
|
242
|
-
return __generator(this, function (
|
|
243
|
-
switch (
|
|
115
|
+
var tcb, blocksIds, checkingTcbData, blockIndex, tcb_1, tcbInfo;
|
|
116
|
+
return __generator(this, function (_a) {
|
|
117
|
+
switch (_a.label) {
|
|
244
118
|
case 0:
|
|
245
119
|
this.checkInit();
|
|
246
120
|
(0, utils_1.checkIfActionAccountInitialized)();
|
|
247
|
-
|
|
248
|
-
_b = TCB_1.default.bind;
|
|
249
|
-
return [4 /*yield*/, this.getInitedTcb(teeOfferId)];
|
|
121
|
+
return [4 /*yield*/, this.initializeTcb(teeOfferId, transactionOptions)];
|
|
250
122
|
case 1:
|
|
251
|
-
tcb =
|
|
252
|
-
return [4 /*yield*/,
|
|
123
|
+
tcb = _a.sent();
|
|
124
|
+
return [4 /*yield*/, tcb.getCheckingBlocksMarks()];
|
|
253
125
|
case 2:
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
126
|
+
blocksIds = (_a.sent()).blocksIds;
|
|
127
|
+
checkingTcbData = [];
|
|
128
|
+
blockIndex = 0;
|
|
129
|
+
_a.label = 3;
|
|
258
130
|
case 3:
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
return [4 /*yield*/,
|
|
131
|
+
if (!(blockIndex < blocksIds.length)) return [3 /*break*/, 6];
|
|
132
|
+
tcb_1 = new TCB_1.default(blocksIds[blockIndex]);
|
|
133
|
+
return [4 /*yield*/, tcb_1.get()];
|
|
262
134
|
case 4:
|
|
263
|
-
|
|
264
|
-
|
|
135
|
+
tcbInfo = _a.sent();
|
|
136
|
+
checkingTcbData.push({
|
|
137
|
+
deviceID: tcbInfo.publicData.deviceId,
|
|
138
|
+
properties: tcbInfo.publicData.properties,
|
|
139
|
+
benchmark: tcbInfo.publicData.benchmark,
|
|
140
|
+
tcbQuote: tcbInfo.quote,
|
|
141
|
+
tcbMarks: tcbInfo.utilData.checkingBlockMarks,
|
|
142
|
+
});
|
|
143
|
+
_a.label = 5;
|
|
265
144
|
case 5:
|
|
266
|
-
|
|
267
|
-
return [
|
|
145
|
+
blockIndex++;
|
|
146
|
+
return [3 /*break*/, 3];
|
|
147
|
+
case 6: return [2 /*return*/, {
|
|
148
|
+
tcbId: tcb.tcbId,
|
|
149
|
+
checkingTcbData: checkingTcbData,
|
|
150
|
+
}];
|
|
268
151
|
}
|
|
269
152
|
});
|
|
270
153
|
});
|
|
271
154
|
};
|
|
272
155
|
/**
|
|
273
|
-
* Function
|
|
274
|
-
* @param
|
|
275
|
-
*
|
|
276
|
-
|
|
277
|
-
Consensus.claimRewards = function (tcbId, transactionOptions) {
|
|
156
|
+
* Function return last inited TCB of TEE offer
|
|
157
|
+
* @param teeOfferId - id of TEE offer
|
|
158
|
+
* */
|
|
159
|
+
Consensus.getInitializedTcbId = function (teeOfferId) {
|
|
278
160
|
return __awaiter(this, void 0, void 0, function () {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
case 0:
|
|
283
|
-
contract = this.checkInit(transactionOptions);
|
|
284
|
-
(0, utils_1.checkIfActionAccountInitialized)();
|
|
285
|
-
return [4 /*yield*/, TxManager_1.default.execute(contract.methods.claimRewards, [tcbId], transactionOptions)];
|
|
286
|
-
case 1:
|
|
287
|
-
_b.sent();
|
|
288
|
-
return [2 /*return*/];
|
|
289
|
-
}
|
|
161
|
+
return __generator(this, function (_a) {
|
|
162
|
+
this.checkInit();
|
|
163
|
+
return [2 /*return*/, this.contract.methods.getInitializedTcbId(teeOfferId).call()];
|
|
290
164
|
});
|
|
291
165
|
});
|
|
292
166
|
};
|
|
293
|
-
|
|
294
|
-
* Function unlock previously locked TCB rewards (by claimRewards)
|
|
295
|
-
* @param tcbId - TCB id
|
|
296
|
-
* @param unlockAmount - amount of tokens to unlock, max available amount = TeeOffer.getLockInfo(tcbId)
|
|
297
|
-
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
298
|
-
*/
|
|
299
|
-
Consensus.unlockRewards = function (tcbId, unlockAmount, transactionOptions) {
|
|
167
|
+
Consensus.getEpochIndex = function () {
|
|
300
168
|
return __awaiter(this, void 0, void 0, function () {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
switch (_b.label) {
|
|
169
|
+
return __generator(this, function (_a) {
|
|
170
|
+
switch (_a.label) {
|
|
304
171
|
case 0:
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
case 1:
|
|
309
|
-
_b.sent();
|
|
310
|
-
return [2 /*return*/];
|
|
172
|
+
this.checkInit();
|
|
173
|
+
return [4 /*yield*/, this.contract.methods.getEpochIndex().call()];
|
|
174
|
+
case 1: return [2 /*return*/, +(_a.sent())];
|
|
311
175
|
}
|
|
312
176
|
});
|
|
313
177
|
});
|
|
314
178
|
};
|
|
315
|
-
|
|
316
|
-
* Function return last inited TCB of TEE offer
|
|
317
|
-
* @param teeOfferId
|
|
318
|
-
* */
|
|
319
|
-
Consensus.getInitedTcb = function (teeOfferId) {
|
|
179
|
+
Consensus.getActualTcbId = function (teeOfferId) {
|
|
320
180
|
return __awaiter(this, void 0, void 0, function () {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
case 0:
|
|
325
|
-
this.checkInit();
|
|
326
|
-
return [4 /*yield*/, this.contract.methods.getInitedTcb(teeOfferId).call()];
|
|
327
|
-
case 1:
|
|
328
|
-
tcbId = _b.sent();
|
|
329
|
-
return [2 /*return*/, tcbId];
|
|
330
|
-
}
|
|
181
|
+
return __generator(this, function (_a) {
|
|
182
|
+
this.checkInit();
|
|
183
|
+
return [2 /*return*/, this.contract.methods.getActualTcbId(teeOfferId).call()];
|
|
331
184
|
});
|
|
332
185
|
});
|
|
333
186
|
};
|
|
334
|
-
|
|
335
|
-
* Function return last inited TCB of TEE offer
|
|
336
|
-
* @param teeOfferId
|
|
337
|
-
* */
|
|
338
|
-
Consensus.getTimeInited = function (teeOfferId) {
|
|
187
|
+
Consensus.getSuspiciousBlockTable = function () {
|
|
339
188
|
return __awaiter(this, void 0, void 0, function () {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
case 0:
|
|
344
|
-
this.checkInit();
|
|
345
|
-
return [4 /*yield*/, this.contract.methods.getTimeInited(teeOfferId).call()];
|
|
346
|
-
case 1:
|
|
347
|
-
tcbTimeInited = +(_b.sent());
|
|
348
|
-
return [2 /*return*/, tcbTimeInited];
|
|
349
|
-
}
|
|
189
|
+
return __generator(this, function (_a) {
|
|
190
|
+
this.checkInit();
|
|
191
|
+
return [2 /*return*/, this.contract.methods.getSuspiciousBlockTable().call()];
|
|
350
192
|
});
|
|
351
193
|
});
|
|
352
194
|
};
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
case 0: return [4 /*yield*/, tcb.needL1toCompleted()];
|
|
360
|
-
case 1:
|
|
361
|
-
_b = +(_c.sent()) === 0;
|
|
362
|
-
if (!_b) return [3 /*break*/, 3];
|
|
363
|
-
return [4 /*yield*/, tcb.needL2toCompleted()];
|
|
364
|
-
case 2:
|
|
365
|
-
_b = +(_c.sent()) === 0;
|
|
366
|
-
_c.label = 3;
|
|
367
|
-
case 3: return [2 /*return*/, _b];
|
|
368
|
-
}
|
|
195
|
+
Consensus.getLastBlockTable = function () {
|
|
196
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
197
|
+
return __generator(this, function (_a) {
|
|
198
|
+
this.checkInit();
|
|
199
|
+
return [2 /*return*/, this.contract.methods.getLastBlockTable().call()];
|
|
200
|
+
});
|
|
369
201
|
});
|
|
370
|
-
}
|
|
202
|
+
};
|
|
371
203
|
return Consensus;
|
|
372
204
|
}());
|
|
373
205
|
exports.default = Consensus;
|
|
@@ -42,7 +42,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
42
42
|
var store_1 = __importDefault(require("../store"));
|
|
43
43
|
var utils_1 = require("../utils");
|
|
44
44
|
var Superpro_1 = __importDefault(require("./Superpro"));
|
|
45
|
-
var
|
|
45
|
+
var app_json_1 = __importDefault(require("../contracts/app.json"));
|
|
46
46
|
var Marks = /** @class */ (function () {
|
|
47
47
|
function Marks() {
|
|
48
48
|
}
|
|
@@ -59,12 +59,12 @@ var Marks = /** @class */ (function () {
|
|
|
59
59
|
Marks.checkInit = function (transactionOptions) {
|
|
60
60
|
if (transactionOptions === null || transactionOptions === void 0 ? void 0 : transactionOptions.web3) {
|
|
61
61
|
(0, utils_1.checkIfInitialized)();
|
|
62
|
-
return new transactionOptions.web3.eth.Contract(
|
|
62
|
+
return new transactionOptions.web3.eth.Contract(app_json_1.default.abi, Superpro_1.default.address);
|
|
63
63
|
}
|
|
64
64
|
if (this.contract)
|
|
65
65
|
return this.contract;
|
|
66
66
|
(0, utils_1.checkIfInitialized)();
|
|
67
|
-
return this.contract = new store_1.default.web3.eth.Contract(
|
|
67
|
+
return this.contract = new store_1.default.web3.eth.Contract(app_json_1.default.abi, Superpro_1.default.address);
|
|
68
68
|
};
|
|
69
69
|
Marks.getProviderMarks = function (providerAddress) {
|
|
70
70
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -41,7 +41,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
var store_1 = __importDefault(require("../store"));
|
|
43
43
|
var logger_1 = __importDefault(require("../logger"));
|
|
44
|
-
var
|
|
44
|
+
var app_json_1 = __importDefault(require("../contracts/app.json"));
|
|
45
45
|
var utils_1 = require("../utils");
|
|
46
46
|
var Offer_1 = require("../types/Offer");
|
|
47
47
|
var utils_2 = require("ethers/lib/utils");
|
|
@@ -63,13 +63,13 @@ var OffersFactory = /** @class */ (function () {
|
|
|
63
63
|
OffersFactory.checkInit = function (transactionOptions) {
|
|
64
64
|
if (transactionOptions === null || transactionOptions === void 0 ? void 0 : transactionOptions.web3) {
|
|
65
65
|
(0, utils_1.checkIfInitialized)();
|
|
66
|
-
return new transactionOptions.web3.eth.Contract(
|
|
66
|
+
return new transactionOptions.web3.eth.Contract(app_json_1.default.abi, Superpro_1.default.address);
|
|
67
67
|
}
|
|
68
68
|
if (this.contract)
|
|
69
69
|
return this.contract;
|
|
70
70
|
(0, utils_1.checkIfInitialized)();
|
|
71
71
|
this.logger = logger_1.default.child({ className: "OffersFactory" });
|
|
72
|
-
return (this.contract = new store_1.default.web3.eth.Contract(
|
|
72
|
+
return (this.contract = new store_1.default.web3.eth.Contract(app_json_1.default.abi, Superpro_1.default.address));
|
|
73
73
|
};
|
|
74
74
|
/**
|
|
75
75
|
* Function for fetching list of all offers ids
|
|
@@ -41,7 +41,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
var store_1 = __importDefault(require("../store"));
|
|
43
43
|
var logger_1 = __importDefault(require("../logger"));
|
|
44
|
-
var
|
|
44
|
+
var app_json_1 = __importDefault(require("../contracts/app.json"));
|
|
45
45
|
var utils_1 = require("../utils");
|
|
46
46
|
var Order_1 = require("../types/Order");
|
|
47
47
|
var utils_2 = require("ethers/lib/utils");
|
|
@@ -63,7 +63,7 @@ var OrdersFactory = /** @class */ (function () {
|
|
|
63
63
|
OrdersFactory.checkInit = function (transactionOptions) {
|
|
64
64
|
if (transactionOptions === null || transactionOptions === void 0 ? void 0 : transactionOptions.web3) {
|
|
65
65
|
(0, utils_1.checkIfInitialized)();
|
|
66
|
-
return new transactionOptions.web3.eth.Contract(
|
|
66
|
+
return new transactionOptions.web3.eth.Contract(app_json_1.default.abi, Superpro_1.default.address);
|
|
67
67
|
}
|
|
68
68
|
if (this.contract)
|
|
69
69
|
return this.contract;
|
|
@@ -72,7 +72,7 @@ var OrdersFactory = /** @class */ (function () {
|
|
|
72
72
|
className: "OrdersFactory",
|
|
73
73
|
address: Superpro_1.default.address,
|
|
74
74
|
});
|
|
75
|
-
return (this.contract = new store_1.default.web3.eth.Contract(
|
|
75
|
+
return (this.contract = new store_1.default.web3.eth.Contract(app_json_1.default.abi, Superpro_1.default.address));
|
|
76
76
|
};
|
|
77
77
|
/**
|
|
78
78
|
* Function for fetching list of all orders ids
|
|
@@ -22,6 +22,7 @@ declare class ProviderRegistry {
|
|
|
22
22
|
* Fetch provider security deposit by provider authority account
|
|
23
23
|
*/
|
|
24
24
|
static getSecurityDeposit(providerAuthority: string): Promise<string>;
|
|
25
|
+
static isProviderRegistered(providerAuthority: string): Promise<boolean>;
|
|
25
26
|
/**
|
|
26
27
|
* Reg new provider
|
|
27
28
|
* @param providerInfo - data of new provider
|
|
@@ -41,8 +41,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
var store_1 = __importDefault(require("../store"));
|
|
43
43
|
var logger_1 = __importDefault(require("../logger"));
|
|
44
|
-
var
|
|
45
|
-
var ProvidersOffers_json_1 = __importDefault(require("../contracts/ProvidersOffers.json"));
|
|
44
|
+
var app_json_1 = __importDefault(require("../contracts/app.json"));
|
|
46
45
|
var utils_1 = require("../utils");
|
|
47
46
|
var Provider_1 = require("../types/Provider");
|
|
48
47
|
var Superpro_1 = __importDefault(require("./Superpro"));
|
|
@@ -56,24 +55,24 @@ var ProviderRegistry = /** @class */ (function () {
|
|
|
56
55
|
ProviderRegistry.checkInitProviders = function (transactionOptions) {
|
|
57
56
|
if (transactionOptions === null || transactionOptions === void 0 ? void 0 : transactionOptions.web3) {
|
|
58
57
|
(0, utils_1.checkIfInitialized)();
|
|
59
|
-
return new transactionOptions.web3.eth.Contract(
|
|
58
|
+
return new transactionOptions.web3.eth.Contract(app_json_1.default.abi, Superpro_1.default.address);
|
|
60
59
|
}
|
|
61
60
|
if (this.contract)
|
|
62
61
|
return this.contract;
|
|
63
62
|
(0, utils_1.checkIfInitialized)();
|
|
64
63
|
this.logger = logger_1.default.child({ className: "Providers" });
|
|
65
|
-
return (this.contract = new store_1.default.web3.eth.Contract(
|
|
64
|
+
return (this.contract = new store_1.default.web3.eth.Contract(app_json_1.default.abi, Superpro_1.default.address));
|
|
66
65
|
};
|
|
67
66
|
ProviderRegistry.checkInitProvidersOffers = function (transactionOptions) {
|
|
68
67
|
if (transactionOptions === null || transactionOptions === void 0 ? void 0 : transactionOptions.web3) {
|
|
69
68
|
(0, utils_1.checkIfInitialized)();
|
|
70
|
-
return new transactionOptions.web3.eth.Contract(
|
|
69
|
+
return new transactionOptions.web3.eth.Contract(app_json_1.default.abi, Superpro_1.default.address);
|
|
71
70
|
}
|
|
72
71
|
if (this.contract)
|
|
73
72
|
return this.contract;
|
|
74
73
|
(0, utils_1.checkIfInitialized)();
|
|
75
74
|
this.logger = logger_1.default.child({ className: "ProvidersOffers" });
|
|
76
|
-
return (this.contract = new store_1.default.web3.eth.Contract(
|
|
75
|
+
return (this.contract = new store_1.default.web3.eth.Contract(app_json_1.default.abi, Superpro_1.default.address));
|
|
77
76
|
};
|
|
78
77
|
/**
|
|
79
78
|
* Function for fetching list of all providers addresses
|
|
@@ -119,6 +118,18 @@ var ProviderRegistry = /** @class */ (function () {
|
|
|
119
118
|
});
|
|
120
119
|
});
|
|
121
120
|
};
|
|
121
|
+
ProviderRegistry.isProviderRegistered = function (providerAuthority) {
|
|
122
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
123
|
+
return __generator(this, function (_a) {
|
|
124
|
+
switch (_a.label) {
|
|
125
|
+
case 0:
|
|
126
|
+
this.checkInitProviders();
|
|
127
|
+
return [4 /*yield*/, this.contract.methods.isProviderRegistered(providerAuthority).call()];
|
|
128
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
};
|
|
122
133
|
/**
|
|
123
134
|
* Reg new provider
|
|
124
135
|
* @param providerInfo - data of new provider
|
|
@@ -40,7 +40,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
var logger_1 = __importDefault(require("../logger"));
|
|
43
|
-
var
|
|
43
|
+
var app_json_1 = __importDefault(require("../contracts/app.json"));
|
|
44
44
|
var store_1 = __importDefault(require("../store"));
|
|
45
45
|
var utils_1 = require("../utils");
|
|
46
46
|
var Staking_1 = require("../types/Staking");
|
|
@@ -62,13 +62,13 @@ var Staking = /** @class */ (function () {
|
|
|
62
62
|
Staking.checkInit = function (transactionOptions) {
|
|
63
63
|
if (transactionOptions === null || transactionOptions === void 0 ? void 0 : transactionOptions.web3) {
|
|
64
64
|
(0, utils_1.checkIfInitialized)();
|
|
65
|
-
return new transactionOptions.web3.eth.Contract(
|
|
65
|
+
return new transactionOptions.web3.eth.Contract(app_json_1.default.abi, Superpro_1.default.address);
|
|
66
66
|
}
|
|
67
67
|
if (this.contract)
|
|
68
68
|
return this.contract;
|
|
69
69
|
(0, utils_1.checkIfInitialized)();
|
|
70
70
|
this.logger = logger_1.default.child({ className: "Staking" });
|
|
71
|
-
return this.contract = new store_1.default.web3.eth.Contract(
|
|
71
|
+
return this.contract = new store_1.default.web3.eth.Contract(app_json_1.default.abi, Superpro_1.default.address);
|
|
72
72
|
};
|
|
73
73
|
/**
|
|
74
74
|
* Fetching stake info by owner address from blockchain
|
|
@@ -40,7 +40,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
var logger_1 = __importDefault(require("../logger"));
|
|
43
|
-
var
|
|
43
|
+
var app_json_1 = __importDefault(require("../contracts/app.json"));
|
|
44
44
|
var store_1 = __importDefault(require("../store"));
|
|
45
45
|
var Superpro = /** @class */ (function () {
|
|
46
46
|
function Superpro() {
|
|
@@ -53,7 +53,7 @@ var Superpro = /** @class */ (function () {
|
|
|
53
53
|
return;
|
|
54
54
|
if (!this.address || !store_1.default.web3)
|
|
55
55
|
throw new Error("BlockchainConnector is not initialized, needs to run 'await BlockchainConnector.init(CONFIG)' first");
|
|
56
|
-
this.contract = new store_1.default.web3.eth.Contract(
|
|
56
|
+
this.contract = new store_1.default.web3.eth.Contract(app_json_1.default.abi, this.address);
|
|
57
57
|
this.logger = logger_1.default.child({ className: "Superpro", address: this.address });
|
|
58
58
|
};
|
|
59
59
|
/**
|
|
@@ -12,6 +12,10 @@ declare class SuperproToken {
|
|
|
12
12
|
* Fetching balance of SuperProtocol tokens on address
|
|
13
13
|
*/
|
|
14
14
|
static balanceOf(address: string): Promise<string>;
|
|
15
|
+
/**
|
|
16
|
+
* Fetching allowance of SuperProtocol tokens on address
|
|
17
|
+
*/
|
|
18
|
+
static allowance(from: string, to: string): Promise<string>;
|
|
15
19
|
/**
|
|
16
20
|
* Transfers specific amount of SP tokens to specific address
|
|
17
21
|
* @param to - address to revive tokens
|