@super-protocol/sdk-js 0.11.9-beta.9 → 0.11.10-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/models/Provider.js
CHANGED
|
@@ -47,6 +47,7 @@ var Origins_1 = require("../types/Origins");
|
|
|
47
47
|
var Superpro_1 = __importDefault(require("../staticModels/Superpro"));
|
|
48
48
|
var BlockchainConnector_1 = __importDefault(require("../connectors/BlockchainConnector"));
|
|
49
49
|
var TxManager_1 = __importDefault(require("../utils/TxManager"));
|
|
50
|
+
var Consensus_1 = __importDefault(require("../staticModels/Consensus"));
|
|
50
51
|
var Provider = /** @class */ (function () {
|
|
51
52
|
function Provider(providerId) {
|
|
52
53
|
this.providerId = providerId;
|
|
@@ -182,6 +183,22 @@ var Provider = /** @class */ (function () {
|
|
|
182
183
|
});
|
|
183
184
|
});
|
|
184
185
|
};
|
|
186
|
+
Provider.prototype.isProviderBanned = function () {
|
|
187
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
188
|
+
var violationRate, CONSENSUS_MAX_PENALTIES;
|
|
189
|
+
return __generator(this, function (_a) {
|
|
190
|
+
switch (_a.label) {
|
|
191
|
+
case 0: return [4 /*yield*/, this.getViolationRate()];
|
|
192
|
+
case 1:
|
|
193
|
+
violationRate = _a.sent();
|
|
194
|
+
return [4 /*yield*/, Consensus_1.default.getConstants()];
|
|
195
|
+
case 2:
|
|
196
|
+
CONSENSUS_MAX_PENALTIES = (_a.sent()).CONSENSUS_MAX_PENALTIES;
|
|
197
|
+
return [2 /*return*/, violationRate >= CONSENSUS_MAX_PENALTIES];
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
};
|
|
185
202
|
return Provider;
|
|
186
203
|
}());
|
|
187
204
|
exports.default = Provider;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EpochInfo } from "../types/Consensus";
|
|
2
2
|
import { GetTcbRequest } from "@super-protocol/dto-js";
|
|
3
3
|
import { TransactionOptions } from "../types/Web3";
|
|
4
|
+
import { ConsensusConstants } from "../types/Consensus";
|
|
4
5
|
declare class Consensus {
|
|
5
6
|
static get address(): string;
|
|
6
7
|
private static initializeTcbAndAssignBlocks;
|
|
@@ -29,5 +30,6 @@ declare class Consensus {
|
|
|
29
30
|
static getSuspiciousBlockTableSize(): Promise<string[]>;
|
|
30
31
|
static getLastBlockTable(): Promise<string[]>;
|
|
31
32
|
static getLastBlockTableSize(): Promise<string[]>;
|
|
33
|
+
static getConstants(): Promise<ConsensusConstants>;
|
|
32
34
|
}
|
|
33
35
|
export default Consensus;
|
|
@@ -44,6 +44,7 @@ var utils_1 = require("../utils");
|
|
|
44
44
|
var Superpro_1 = __importDefault(require("./Superpro"));
|
|
45
45
|
var BlockchainConnector_1 = __importDefault(require("../connectors/BlockchainConnector"));
|
|
46
46
|
var TxManager_1 = __importDefault(require("../utils/TxManager"));
|
|
47
|
+
var Consensus_1 = require("../types/Consensus");
|
|
47
48
|
var Consensus = /** @class */ (function () {
|
|
48
49
|
function Consensus() {
|
|
49
50
|
}
|
|
@@ -97,11 +98,16 @@ var Consensus = /** @class */ (function () {
|
|
|
97
98
|
return __awaiter(this, void 0, void 0, function () {
|
|
98
99
|
var contract, _a, offerNotBlocked, newEpochStarted, halfEpochPassed, benchmarkVerified;
|
|
99
100
|
return __generator(this, function (_b) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
switch (_b.label) {
|
|
102
|
+
case 0:
|
|
103
|
+
contract = BlockchainConnector_1.default.getInstance().getContract();
|
|
104
|
+
return [4 /*yield*/, contract.methods
|
|
105
|
+
.isTcbCreationAvailable(teeOfferId)
|
|
106
|
+
.call()];
|
|
107
|
+
case 1:
|
|
108
|
+
_a = _b.sent(), offerNotBlocked = _a[0], newEpochStarted = _a[1], halfEpochPassed = _a[2], benchmarkVerified = _a[3];
|
|
109
|
+
return [2 /*return*/, offerNotBlocked && newEpochStarted && halfEpochPassed && benchmarkVerified];
|
|
110
|
+
}
|
|
105
111
|
});
|
|
106
112
|
});
|
|
107
113
|
};
|
|
@@ -244,6 +250,21 @@ var Consensus = /** @class */ (function () {
|
|
|
244
250
|
});
|
|
245
251
|
});
|
|
246
252
|
};
|
|
253
|
+
Consensus.getConstants = function () {
|
|
254
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
255
|
+
var contract, response;
|
|
256
|
+
return __generator(this, function (_a) {
|
|
257
|
+
switch (_a.label) {
|
|
258
|
+
case 0:
|
|
259
|
+
contract = BlockchainConnector_1.default.getInstance().getContract();
|
|
260
|
+
return [4 /*yield*/, contract.methods.getConsensusConstants().call()];
|
|
261
|
+
case 1:
|
|
262
|
+
response = _a.sent();
|
|
263
|
+
return [2 /*return*/, (0, utils_1.tupleToObject)(response, Consensus_1.ConsensusConstantsStructure)];
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
};
|
|
247
268
|
return Consensus;
|
|
248
269
|
}());
|
|
249
270
|
exports.default = Consensus;
|
|
@@ -99,3 +99,19 @@ export declare type EpochInfo = {
|
|
|
99
99
|
benchmark: number;
|
|
100
100
|
penaltyBenchmark: number;
|
|
101
101
|
};
|
|
102
|
+
export declare type ConsensusConstants = {
|
|
103
|
+
CONSENSUS_L1: number;
|
|
104
|
+
CONSENSUS_L2: number;
|
|
105
|
+
CONSENSUS_K: number;
|
|
106
|
+
CONSENSUS_MAX_PENALTIES: number;
|
|
107
|
+
MAX_BECHMARK_OVERRUN_PERCENT: number;
|
|
108
|
+
CONSENSUS_EPOCH_DURATION: number;
|
|
109
|
+
};
|
|
110
|
+
export declare const ConsensusConstantsStructure: {
|
|
111
|
+
CONSENSUS_L1: NumberConstructor;
|
|
112
|
+
CONSENSUS_L2: NumberConstructor;
|
|
113
|
+
CONSENSUS_K: NumberConstructor;
|
|
114
|
+
CONSENSUS_MAX_PENALTIES: NumberConstructor;
|
|
115
|
+
MAX_BECHMARK_OVERRUN_PERCENT: NumberConstructor;
|
|
116
|
+
CONSENSUS_EPOCH_DURATION: NumberConstructor;
|
|
117
|
+
};
|
package/build/types/Consensus.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TcbStructure = exports.TcbStatus = exports.EpochStructure = exports.UtilityDataStructure = exports.PublicDataStructure = exports.TcbVerifiedStatus = void 0;
|
|
3
|
+
exports.ConsensusConstantsStructure = exports.TcbStructure = exports.TcbStatus = exports.EpochStructure = exports.UtilityDataStructure = exports.PublicDataStructure = exports.TcbVerifiedStatus = void 0;
|
|
4
4
|
var TcbVerifiedStatus;
|
|
5
5
|
(function (TcbVerifiedStatus) {
|
|
6
6
|
TcbVerifiedStatus[TcbVerifiedStatus["Valid"] = 0] = "Valid";
|
|
@@ -51,3 +51,11 @@ exports.TcbStructure = {
|
|
|
51
51
|
utilData: exports.UtilityDataStructure,
|
|
52
52
|
status: TcbStatus,
|
|
53
53
|
};
|
|
54
|
+
exports.ConsensusConstantsStructure = {
|
|
55
|
+
CONSENSUS_L1: Number,
|
|
56
|
+
CONSENSUS_L2: Number,
|
|
57
|
+
CONSENSUS_K: Number,
|
|
58
|
+
CONSENSUS_MAX_PENALTIES: Number,
|
|
59
|
+
MAX_BECHMARK_OVERRUN_PERCENT: Number,
|
|
60
|
+
CONSENSUS_EPOCH_DURATION: Number,
|
|
61
|
+
};
|