@super-protocol/sdk-js 0.6.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 +48 -0
- package/build/BlockchainConnector.js +259 -0
- package/build/TIIGenerator.d.ts +21 -0
- package/build/TIIGenerator.js +251 -0
- package/build/constants.d.ts +7 -0
- package/build/constants.js +10 -0
- package/build/contracts/ActiveOffersList.json +131 -0
- package/build/contracts/ActiveOrdersList.json +74 -0
- package/build/contracts/Marks.json +79 -0
- package/build/contracts/Offers.json +999 -0
- package/build/contracts/Orders.json +984 -0
- package/build/contracts/Providers.json +440 -0
- package/build/contracts/ProvidersOffers.json +254 -0
- package/build/contracts/Staking.json +323 -0
- package/build/contracts/Superpro.json +197 -0
- package/build/contracts/SuperproToken.json +356 -0
- package/build/crypto/Crypto.d.ts +37 -0
- package/build/crypto/Crypto.js +181 -0
- package/build/crypto/index.d.ts +2 -0
- package/build/crypto/index.js +7 -0
- package/build/crypto/nodejs/AES.d.ts +24 -0
- package/build/crypto/nodejs/AES.js +152 -0
- package/build/crypto/nodejs/ARIA.d.ts +24 -0
- package/build/crypto/nodejs/ARIA.js +151 -0
- package/build/crypto/nodejs/ECIES.d.ts +6 -0
- package/build/crypto/nodejs/ECIES.js +94 -0
- package/build/crypto/nodejs/NativeCrypto.d.ts +54 -0
- package/build/crypto/nodejs/NativeCrypto.js +214 -0
- package/build/crypto/nodejs/RSA-Hybrid.d.ts +15 -0
- package/build/crypto/nodejs/RSA-Hybrid.js +153 -0
- package/build/index.d.ts +65 -0
- package/build/index.js +117 -0
- package/build/logger.d.ts +4 -0
- package/build/logger.js +8 -0
- package/build/models/Ballot.d.ts +13 -0
- package/build/models/Ballot.js +76 -0
- package/build/models/Offer.d.ts +70 -0
- package/build/models/Offer.js +273 -0
- package/build/models/Order.d.ts +125 -0
- package/build/models/Order.js +540 -0
- package/build/models/Provider.d.ts +40 -0
- package/build/models/Provider.js +167 -0
- package/build/models/TCB.d.ts +80 -0
- package/build/models/TCB.js +315 -0
- package/build/models/TeeOffer.d.ts +118 -0
- package/build/models/TeeOffer.js +436 -0
- package/build/proto/Compression.d.ts +33 -0
- package/build/proto/Compression.js +146 -0
- package/build/proto/TRI.d.ts +122 -0
- package/build/proto/TRI.js +316 -0
- package/build/providers/storage/ChunksDownloadDecorator.d.ts +38 -0
- package/build/providers/storage/ChunksDownloadDecorator.js +284 -0
- package/build/providers/storage/IStorageProvider.d.ts +17 -0
- package/build/providers/storage/IStorageProvider.js +2 -0
- package/build/providers/storage/StorjStorageProvider.d.ts +26 -0
- package/build/providers/storage/StorjStorageProvider.js +389 -0
- package/build/providers/storage/getStorageProvider.d.ts +4 -0
- package/build/providers/storage/getStorageProvider.js +16 -0
- package/build/staticModels/ActiveOffers.d.ts +29 -0
- package/build/staticModels/ActiveOffers.js +144 -0
- package/build/staticModels/ActiveOrders.d.ts +21 -0
- package/build/staticModels/ActiveOrders.js +120 -0
- package/build/staticModels/Consensus.d.ts +63 -0
- package/build/staticModels/Consensus.js +373 -0
- package/build/staticModels/Epochs.d.ts +23 -0
- package/build/staticModels/Epochs.js +97 -0
- package/build/staticModels/LastBlocks.d.ts +25 -0
- package/build/staticModels/LastBlocks.js +96 -0
- package/build/staticModels/Marks.d.ts +13 -0
- package/build/staticModels/Marks.js +113 -0
- package/build/staticModels/OffersFactory.d.ts +37 -0
- package/build/staticModels/OffersFactory.js +227 -0
- package/build/staticModels/OrdersFactory.d.ts +137 -0
- package/build/staticModels/OrdersFactory.js +539 -0
- package/build/staticModels/ProviderRegistry.d.ts +81 -0
- package/build/staticModels/ProviderRegistry.js +311 -0
- package/build/staticModels/Staking.d.ts +26 -0
- package/build/staticModels/Staking.js +132 -0
- package/build/staticModels/Superpro.d.ts +20 -0
- package/build/staticModels/Superpro.js +99 -0
- package/build/staticModels/SuperproToken.d.ts +30 -0
- package/build/staticModels/SuperproToken.js +125 -0
- package/build/staticModels/Suspicious.d.ts +26 -0
- package/build/staticModels/Suspicious.js +99 -0
- package/build/staticModels/TeeOffersFactory.d.ts +36 -0
- package/build/staticModels/TeeOffersFactory.js +206 -0
- package/build/staticModels/Voting.d.ts +35 -0
- package/build/staticModels/Voting.js +111 -0
- package/build/store.d.ts +12 -0
- package/build/store.js +13 -0
- package/build/types/Ballot.d.ts +75 -0
- package/build/types/Ballot.js +49 -0
- package/build/types/Epoch.d.ts +21 -0
- package/build/types/Epoch.js +18 -0
- package/build/types/Events.d.ts +18 -0
- package/build/types/Events.js +2 -0
- package/build/types/Marks.d.ts +5 -0
- package/build/types/Marks.js +9 -0
- package/build/types/Offer.d.ts +63 -0
- package/build/types/Offer.js +41 -0
- package/build/types/Order.d.ts +61 -0
- package/build/types/Order.js +36 -0
- package/build/types/Origins.d.ts +12 -0
- package/build/types/Origins.js +10 -0
- package/build/types/Provider.d.ts +25 -0
- package/build/types/Provider.js +19 -0
- package/build/types/Staking.d.ts +27 -0
- package/build/types/Staking.js +22 -0
- package/build/types/Superpro.d.ts +24 -0
- package/build/types/Superpro.js +29 -0
- package/build/types/TcbData.d.ts +26 -0
- package/build/types/TcbData.js +21 -0
- package/build/types/TeeOffer.d.ts +22 -0
- package/build/types/TeeOffer.js +15 -0
- package/build/types/Web3.d.ts +26 -0
- package/build/types/Web3.js +2 -0
- package/build/types/blockchainConnector/StorageAccess.d.ts +8 -0
- package/build/types/blockchainConnector/StorageAccess.js +2 -0
- package/build/types/storage/StorageAccess.d.ts +6 -0
- package/build/types/storage/StorageAccess.js +2 -0
- package/build/types/storage/StorageFileAccess.d.ts +5 -0
- package/build/types/storage/StorageFileAccess.js +2 -0
- package/build/types/storage/StorageObject.d.ts +8 -0
- package/build/types/storage/StorageObject.js +2 -0
- package/build/utils/NonceTracker.d.ts +12 -0
- package/build/utils/NonceTracker.js +84 -0
- package/build/utils/TxManager.d.ts +21 -0
- package/build/utils/TxManager.js +159 -0
- package/build/utils.d.ts +38 -0
- package/build/utils.js +195 -0
- package/package.json +68 -0
- package/readme.md +40 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
var store_1 = __importDefault(require("../store"));
|
|
43
|
+
var logger_1 = __importDefault(require("../logger"));
|
|
44
|
+
var ActiveOrdersList_json_1 = __importDefault(require("../contracts/ActiveOrdersList.json"));
|
|
45
|
+
var utils_1 = require("../utils");
|
|
46
|
+
var Superpro_1 = __importDefault(require("./Superpro"));
|
|
47
|
+
var ActiveOrders = /** @class */ (function () {
|
|
48
|
+
function ActiveOrders() {
|
|
49
|
+
}
|
|
50
|
+
Object.defineProperty(ActiveOrders, "address", {
|
|
51
|
+
get: function () {
|
|
52
|
+
return Superpro_1.default.address;
|
|
53
|
+
},
|
|
54
|
+
enumerable: false,
|
|
55
|
+
configurable: true
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* Checks if contract has been initialized, if not - initialize contract
|
|
59
|
+
*/
|
|
60
|
+
ActiveOrders.checkInit = function (transactionOptions) {
|
|
61
|
+
if (transactionOptions === null || transactionOptions === void 0 ? void 0 : transactionOptions.web3) {
|
|
62
|
+
(0, utils_1.checkIfInitialized)();
|
|
63
|
+
return new transactionOptions.web3.eth.Contract(ActiveOrdersList_json_1.default.abi, Superpro_1.default.address);
|
|
64
|
+
}
|
|
65
|
+
if (this.contract)
|
|
66
|
+
return this.contract;
|
|
67
|
+
(0, utils_1.checkIfInitialized)();
|
|
68
|
+
this.logger = logger_1.default.child({
|
|
69
|
+
className: "ActiveOrder",
|
|
70
|
+
address: Superpro_1.default.address,
|
|
71
|
+
});
|
|
72
|
+
return (this.contract = new store_1.default.web3.eth.Contract(ActiveOrdersList_json_1.default.abi, Superpro_1.default.address));
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Function returns amount of active orders
|
|
76
|
+
* @returns {Promise<BigNumber>}
|
|
77
|
+
*/
|
|
78
|
+
ActiveOrders.getListOfActiveOrdersSize = function () {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
80
|
+
return __generator(this, function (_a) {
|
|
81
|
+
switch (_a.label) {
|
|
82
|
+
case 0:
|
|
83
|
+
this.checkInit();
|
|
84
|
+
return [4 /*yield*/, this.contract.methods.getListOfActiveOrdersSize().call()];
|
|
85
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Function returns ids of active orders
|
|
92
|
+
* @returns {Promise<string[]>}
|
|
93
|
+
*/
|
|
94
|
+
ActiveOrders.getListOfActiveOrdersRange = function (begin, end) {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
96
|
+
var logger, _a;
|
|
97
|
+
return __generator(this, function (_b) {
|
|
98
|
+
switch (_b.label) {
|
|
99
|
+
case 0:
|
|
100
|
+
this.checkInit();
|
|
101
|
+
logger = this.logger.child({ method: "getListOfActiveOrdersRange" });
|
|
102
|
+
begin = begin !== null && begin !== void 0 ? begin : 0;
|
|
103
|
+
if (!(end !== null && end !== void 0)) return [3 /*break*/, 1];
|
|
104
|
+
_a = end;
|
|
105
|
+
return [3 /*break*/, 3];
|
|
106
|
+
case 1: return [4 /*yield*/, this.contract.methods.getListOfActiveOrdersSize().call()];
|
|
107
|
+
case 2:
|
|
108
|
+
_a = (_b.sent());
|
|
109
|
+
_b.label = 3;
|
|
110
|
+
case 3:
|
|
111
|
+
end = _a;
|
|
112
|
+
return [4 /*yield*/, this.contract.methods.getListOfActiveOrdersRange(begin, end).call()];
|
|
113
|
+
case 4: return [2 /*return*/, _b.sent()];
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
return ActiveOrders;
|
|
119
|
+
}());
|
|
120
|
+
exports.default = ActiveOrders;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import TCB from "../models/TCB";
|
|
2
|
+
import { PublicData } from "../types/TcbData";
|
|
3
|
+
import { TransactionOptions } from "../types/Web3";
|
|
4
|
+
declare class Consensus {
|
|
5
|
+
static address: string;
|
|
6
|
+
private static contract;
|
|
7
|
+
private static logger;
|
|
8
|
+
static LEnough: (tcb: TCB) => Promise<boolean>;
|
|
9
|
+
static offers?: string[];
|
|
10
|
+
/**
|
|
11
|
+
* Checks if contract has been initialized, if not - initialize contract
|
|
12
|
+
*/
|
|
13
|
+
private static checkInit;
|
|
14
|
+
private static initTcb;
|
|
15
|
+
private static addToSupply;
|
|
16
|
+
private static addMarks;
|
|
17
|
+
/**
|
|
18
|
+
* Function initialize TCB and returns two lists of anothers' TCB addresses for their checking
|
|
19
|
+
* @param teeOfferAddress
|
|
20
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
21
|
+
* @returns two lists of anothers' TCB addresses for their checking
|
|
22
|
+
*/
|
|
23
|
+
static getListsForVerification(teeOfferAddress: string, transactionOptions?: TransactionOptions): Promise<{
|
|
24
|
+
L1: string[];
|
|
25
|
+
L2: string[];
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Add data to TeeConfirmationBlock and push it to Consensus
|
|
29
|
+
* @param teeOfferAddress - TCB's device offer, as key
|
|
30
|
+
* @param L1Marks - marks of LastBlocks
|
|
31
|
+
* @param L2Marks - marks of SuspiciousBlocks
|
|
32
|
+
* @param tcbData - TEE generated
|
|
33
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
34
|
+
*/
|
|
35
|
+
static addTCB(teeOfferAddress: string, L1Marks: number[], L2Marks: number[], tcbData: {
|
|
36
|
+
publicData: PublicData;
|
|
37
|
+
quote: string;
|
|
38
|
+
}, transactionOptions?: TransactionOptions): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Function stake and lock TCB's reward
|
|
41
|
+
* @param tcbAddress - TEE Offer's completed and valid TCB contract
|
|
42
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
43
|
+
*/
|
|
44
|
+
static claimRewards(tcbAddress: string, transactionOptions?: TransactionOptions): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Function unlock previously locked TCB rewards (by claimRewards)
|
|
47
|
+
* @param tcbAddress - TCB contract address
|
|
48
|
+
* @param unlockAmount - amount of tokens to unlock, max available amount = TeeOffer.getLockInfo(tcbAddress)
|
|
49
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
50
|
+
*/
|
|
51
|
+
static unlockRewards(tcbAddress: string, unlockAmount: number, transactionOptions?: TransactionOptions): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Function return last inited TCB of TEE offer
|
|
54
|
+
* @param teeOfferAddress
|
|
55
|
+
* */
|
|
56
|
+
static getInitedTcb(teeOfferAddress: string): Promise<string>;
|
|
57
|
+
/**
|
|
58
|
+
* Function return last inited TCB of TEE offer
|
|
59
|
+
* @param teeOfferAddress
|
|
60
|
+
* */
|
|
61
|
+
static getTimeInited(teeOfferAddress: string): Promise<number>;
|
|
62
|
+
}
|
|
63
|
+
export default Consensus;
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
var store_1 = __importDefault(require("../store"));
|
|
43
|
+
var logger_1 = __importDefault(require("../logger"));
|
|
44
|
+
// import ConsensusJSON from "../contracts/Consensus.json";
|
|
45
|
+
var Offers_json_1 = __importDefault(require("../contracts/Offers.json"));
|
|
46
|
+
var TCB_1 = __importDefault(require("../models/TCB"));
|
|
47
|
+
var LastBlocks_1 = __importDefault(require("./LastBlocks"));
|
|
48
|
+
var Suspicious_1 = __importDefault(require("./Suspicious"));
|
|
49
|
+
var utils_1 = require("../utils");
|
|
50
|
+
var constants_1 = require("../constants");
|
|
51
|
+
var TcbData_1 = require("../types/TcbData");
|
|
52
|
+
var Superpro_1 = __importDefault(require("./Superpro"));
|
|
53
|
+
var TxManager_1 = __importDefault(require("../utils/TxManager"));
|
|
54
|
+
var Consensus = /** @class */ (function () {
|
|
55
|
+
function Consensus() {
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Checks if contract has been initialized, if not - initialize contract
|
|
59
|
+
*/
|
|
60
|
+
Consensus.checkInit = function (transactionOptions) {
|
|
61
|
+
if (transactionOptions === null || transactionOptions === void 0 ? void 0 : transactionOptions.web3) {
|
|
62
|
+
(0, utils_1.checkIfInitialized)();
|
|
63
|
+
// return new transactionOptions.web3.eth.Contract(<AbiItem[]>ConsensusJSON.abi, this.address);
|
|
64
|
+
// TODO: stub
|
|
65
|
+
return new transactionOptions.web3.eth.Contract(Offers_json_1.default.abi, Superpro_1.default.address);
|
|
66
|
+
}
|
|
67
|
+
if (this.contract)
|
|
68
|
+
return this.contract;
|
|
69
|
+
(0, utils_1.checkIfInitialized)();
|
|
70
|
+
this.logger = logger_1.default.child({ className: "Consensus" });
|
|
71
|
+
// return this.contract = new store.web3!.eth.Contract(<AbiItem[]>ConsensusJSON.abi, this.address);
|
|
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;
|
|
75
|
+
};
|
|
76
|
+
Consensus.initTcb = function (teeOfferAddress, transactionOptions) {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
78
|
+
var tcbAddress;
|
|
79
|
+
return __generator(this, function (_b) {
|
|
80
|
+
switch (_b.label) {
|
|
81
|
+
case 0: return [4 /*yield*/, TxManager_1.default.execute(this.contract.methods.initTcb, [teeOfferAddress], transactionOptions)];
|
|
82
|
+
case 1:
|
|
83
|
+
_b.sent();
|
|
84
|
+
return [4 /*yield*/, this.getInitedTcb(teeOfferAddress)];
|
|
85
|
+
case 2:
|
|
86
|
+
tcbAddress = _b.sent();
|
|
87
|
+
return [2 /*return*/, new TCB_1.default(tcbAddress)];
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
Consensus.addToSupply = function (tcbAddress, 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, [tcbAddress], 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 addresses for their checking
|
|
174
|
+
* @param teeOfferAddress
|
|
175
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
176
|
+
* @returns two lists of anothers' TCB addresses for their checking
|
|
177
|
+
*/
|
|
178
|
+
Consensus.getListsForVerification = function (teeOfferAddress, transactionOptions) {
|
|
179
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
180
|
+
var alreadyInited, tcbTimeInited, timestamp, tcb, _b, numberOfMissingL2, L1, L2;
|
|
181
|
+
return __generator(this, function (_c) {
|
|
182
|
+
switch (_c.label) {
|
|
183
|
+
case 0:
|
|
184
|
+
this.checkInit();
|
|
185
|
+
(0, utils_1.checkIfActionAccountInitialized)();
|
|
186
|
+
return [4 /*yield*/, this.getInitedTcb(teeOfferAddress)];
|
|
187
|
+
case 1:
|
|
188
|
+
alreadyInited = _c.sent();
|
|
189
|
+
return [4 /*yield*/, this.getTimeInited(teeOfferAddress)];
|
|
190
|
+
case 2:
|
|
191
|
+
tcbTimeInited = _c.sent();
|
|
192
|
+
return [4 /*yield*/, (0, utils_1.getTimestamp)()];
|
|
193
|
+
case 3:
|
|
194
|
+
timestamp = _c.sent();
|
|
195
|
+
if (!(tcbTimeInited !== 0 && tcbTimeInited + constants_1.ONE_DAY > timestamp)) return [3 /*break*/, 4];
|
|
196
|
+
_b = new TCB_1.default(alreadyInited);
|
|
197
|
+
return [3 /*break*/, 6];
|
|
198
|
+
case 4: return [4 /*yield*/, this.initTcb(teeOfferAddress, transactionOptions)];
|
|
199
|
+
case 5:
|
|
200
|
+
_b = _c.sent();
|
|
201
|
+
_c.label = 6;
|
|
202
|
+
case 6:
|
|
203
|
+
tcb = _b;
|
|
204
|
+
return [4 /*yield*/, this.LEnough(tcb)];
|
|
205
|
+
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.address, transactionOptions)];
|
|
211
|
+
case 9:
|
|
212
|
+
_c.sent();
|
|
213
|
+
return [4 /*yield*/, Suspicious_1.default.getRandomL2(tcb.address, numberOfMissingL2, transactionOptions)];
|
|
214
|
+
case 10:
|
|
215
|
+
_c.sent();
|
|
216
|
+
_c.label = 11;
|
|
217
|
+
case 11: return [4 /*yield*/, tcb.getL1()];
|
|
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
|
+
}];
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* Add data to TeeConfirmationBlock and push it to Consensus
|
|
233
|
+
* @param teeOfferAddress - TCB's device offer, as key
|
|
234
|
+
* @param L1Marks - marks of LastBlocks
|
|
235
|
+
* @param L2Marks - marks of SuspiciousBlocks
|
|
236
|
+
* @param tcbData - TEE generated
|
|
237
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
238
|
+
*/
|
|
239
|
+
Consensus.addTCB = function (teeOfferAddress, L1Marks, L2Marks, tcbData, transactionOptions) {
|
|
240
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
241
|
+
var logger, tcb, _b;
|
|
242
|
+
return __generator(this, function (_c) {
|
|
243
|
+
switch (_c.label) {
|
|
244
|
+
case 0:
|
|
245
|
+
this.checkInit();
|
|
246
|
+
(0, utils_1.checkIfActionAccountInitialized)();
|
|
247
|
+
logger = this.logger.child({ method: "addTCB" });
|
|
248
|
+
_b = TCB_1.default.bind;
|
|
249
|
+
return [4 /*yield*/, this.getInitedTcb(teeOfferAddress)];
|
|
250
|
+
case 1:
|
|
251
|
+
tcb = new (_b.apply(TCB_1.default, [void 0, _c.sent()]))();
|
|
252
|
+
return [4 /*yield*/, this.LEnough(tcb)];
|
|
253
|
+
case 2:
|
|
254
|
+
if (!(_c.sent()))
|
|
255
|
+
logger.error("L is not enough to complite TCB");
|
|
256
|
+
// Can be upgraded to completion of TCB
|
|
257
|
+
return [4 /*yield*/, tcb.addData(tcbData.publicData, tcbData.quote, transactionOptions)];
|
|
258
|
+
case 3:
|
|
259
|
+
// Can be upgraded to completion of TCB
|
|
260
|
+
_c.sent();
|
|
261
|
+
return [4 /*yield*/, this.addMarks(L1Marks, L2Marks, tcb, transactionOptions)];
|
|
262
|
+
case 4:
|
|
263
|
+
_c.sent();
|
|
264
|
+
return [4 /*yield*/, this.addToSupply(tcb.address, transactionOptions)];
|
|
265
|
+
case 5:
|
|
266
|
+
_c.sent();
|
|
267
|
+
return [2 /*return*/];
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
};
|
|
272
|
+
/**
|
|
273
|
+
* Function stake and lock TCB's reward
|
|
274
|
+
* @param tcbAddress - TEE Offer's completed and valid TCB contract
|
|
275
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
276
|
+
*/
|
|
277
|
+
Consensus.claimRewards = function (tcbAddress, transactionOptions) {
|
|
278
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
279
|
+
var contract;
|
|
280
|
+
return __generator(this, function (_b) {
|
|
281
|
+
switch (_b.label) {
|
|
282
|
+
case 0:
|
|
283
|
+
contract = this.checkInit(transactionOptions);
|
|
284
|
+
(0, utils_1.checkIfActionAccountInitialized)();
|
|
285
|
+
return [4 /*yield*/, TxManager_1.default.execute(contract.methods.claimRewards, [tcbAddress], transactionOptions)];
|
|
286
|
+
case 1:
|
|
287
|
+
_b.sent();
|
|
288
|
+
return [2 /*return*/];
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
};
|
|
293
|
+
/**
|
|
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)
|
|
297
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
298
|
+
*/
|
|
299
|
+
Consensus.unlockRewards = function (tcbAddress, unlockAmount, transactionOptions) {
|
|
300
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
301
|
+
var contract;
|
|
302
|
+
return __generator(this, function (_b) {
|
|
303
|
+
switch (_b.label) {
|
|
304
|
+
case 0:
|
|
305
|
+
contract = this.checkInit(transactionOptions);
|
|
306
|
+
(0, utils_1.checkIfActionAccountInitialized)();
|
|
307
|
+
return [4 /*yield*/, TxManager_1.default.execute(contract.methods.unlockRewards, [tcbAddress, unlockAmount], transactionOptions)];
|
|
308
|
+
case 1:
|
|
309
|
+
_b.sent();
|
|
310
|
+
return [2 /*return*/];
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
});
|
|
314
|
+
};
|
|
315
|
+
/**
|
|
316
|
+
* Function return last inited TCB of TEE offer
|
|
317
|
+
* @param teeOfferAddress
|
|
318
|
+
* */
|
|
319
|
+
Consensus.getInitedTcb = function (teeOfferAddress) {
|
|
320
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
321
|
+
var tcbAddress;
|
|
322
|
+
return __generator(this, function (_b) {
|
|
323
|
+
switch (_b.label) {
|
|
324
|
+
case 0:
|
|
325
|
+
this.checkInit();
|
|
326
|
+
return [4 /*yield*/, this.contract.methods.getInitedTcb(teeOfferAddress).call()];
|
|
327
|
+
case 1:
|
|
328
|
+
tcbAddress = _b.sent();
|
|
329
|
+
return [2 /*return*/, tcbAddress];
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
};
|
|
334
|
+
/**
|
|
335
|
+
* Function return last inited TCB of TEE offer
|
|
336
|
+
* @param teeOfferAddress
|
|
337
|
+
* */
|
|
338
|
+
Consensus.getTimeInited = function (teeOfferAddress) {
|
|
339
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
340
|
+
var tcbTimeInited;
|
|
341
|
+
return __generator(this, function (_b) {
|
|
342
|
+
switch (_b.label) {
|
|
343
|
+
case 0:
|
|
344
|
+
this.checkInit();
|
|
345
|
+
return [4 /*yield*/, this.contract.methods.getTimeInited(teeOfferAddress).call()];
|
|
346
|
+
case 1:
|
|
347
|
+
tcbTimeInited = +(_b.sent());
|
|
348
|
+
return [2 /*return*/, tcbTimeInited];
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
};
|
|
353
|
+
var _a;
|
|
354
|
+
_a = Consensus;
|
|
355
|
+
Consensus.LEnough = function (tcb) { return __awaiter(void 0, void 0, void 0, function () {
|
|
356
|
+
var _b;
|
|
357
|
+
return __generator(_a, function (_c) {
|
|
358
|
+
switch (_c.label) {
|
|
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
|
+
}
|
|
369
|
+
});
|
|
370
|
+
}); };
|
|
371
|
+
return Consensus;
|
|
372
|
+
}());
|
|
373
|
+
exports.default = Consensus;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Epoch } from "../types/Epoch";
|
|
2
|
+
declare class Epochs {
|
|
3
|
+
static address: string;
|
|
4
|
+
private static contract;
|
|
5
|
+
private static logger;
|
|
6
|
+
/**
|
|
7
|
+
* Checks if contract has been initialized, if not - initialize contract
|
|
8
|
+
*/
|
|
9
|
+
private static checkInit;
|
|
10
|
+
/**
|
|
11
|
+
* Function for fetching epoch info by index
|
|
12
|
+
*/
|
|
13
|
+
static getEpoch(index: number): Promise<Epoch>;
|
|
14
|
+
/**
|
|
15
|
+
* Function for fetching TCB reward by epoch
|
|
16
|
+
*/
|
|
17
|
+
static getReward(tcbAddress: string): Promise<number>;
|
|
18
|
+
/**
|
|
19
|
+
* Function for fetching TCB last blocks list size
|
|
20
|
+
*/
|
|
21
|
+
static count(): Promise<number>;
|
|
22
|
+
}
|
|
23
|
+
export default Epochs;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
var logger_1 = __importDefault(require("../logger"));
|
|
43
|
+
// import EpochsJSON from "../contracts/Epochs.json";
|
|
44
|
+
var utils_1 = require("../utils");
|
|
45
|
+
var Epochs = /** @class */ (function () {
|
|
46
|
+
function Epochs() {
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Checks if contract has been initialized, if not - initialize contract
|
|
50
|
+
*/
|
|
51
|
+
Epochs.checkInit = function () {
|
|
52
|
+
if (this.contract)
|
|
53
|
+
return;
|
|
54
|
+
(0, utils_1.checkIfInitialized)();
|
|
55
|
+
// this.contract = new store.web3!.eth.Contract(<AbiItem[]>EpochsJSON.abi, this.address);
|
|
56
|
+
this.logger = logger_1.default.child({ className: "Epochs" });
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Function for fetching epoch info by index
|
|
60
|
+
*/
|
|
61
|
+
Epochs.getEpoch = function (index) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
63
|
+
return __generator(this, function (_a) {
|
|
64
|
+
return [2 /*return*/, {
|
|
65
|
+
startDate: 0,
|
|
66
|
+
endDate: 0,
|
|
67
|
+
reward: 0,
|
|
68
|
+
benchmark: 0,
|
|
69
|
+
reparation: 0,
|
|
70
|
+
reparationBenchmark: 0,
|
|
71
|
+
}];
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Function for fetching TCB reward by epoch
|
|
77
|
+
*/
|
|
78
|
+
Epochs.getReward = function (tcbAddress) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
80
|
+
return __generator(this, function (_a) {
|
|
81
|
+
return [2 /*return*/, 0];
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Function for fetching TCB last blocks list size
|
|
87
|
+
*/
|
|
88
|
+
Epochs.count = function () {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
90
|
+
return __generator(this, function (_a) {
|
|
91
|
+
return [2 /*return*/, 0];
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
return Epochs;
|
|
96
|
+
}());
|
|
97
|
+
exports.default = Epochs;
|