@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,125 @@
|
|
|
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
|
+
var SuperproToken_json_1 = __importDefault(require("../contracts/SuperproToken.json"));
|
|
44
|
+
var store_1 = __importDefault(require("../store"));
|
|
45
|
+
var utils_1 = require("../utils");
|
|
46
|
+
var TxManager_1 = __importDefault(require("../utils/TxManager"));
|
|
47
|
+
var SuperproToken = /** @class */ (function () {
|
|
48
|
+
function SuperproToken() {
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Checks if contract has been initialized, if not - initialize contract
|
|
52
|
+
*/
|
|
53
|
+
SuperproToken.checkInit = function (transactionOptions) {
|
|
54
|
+
if (transactionOptions === null || transactionOptions === void 0 ? void 0 : transactionOptions.web3) {
|
|
55
|
+
(0, utils_1.checkIfInitialized)();
|
|
56
|
+
return new transactionOptions.web3.eth.Contract(SuperproToken_json_1.default.abi, this.address);
|
|
57
|
+
}
|
|
58
|
+
if (this.contract)
|
|
59
|
+
return this.contract;
|
|
60
|
+
(0, utils_1.checkIfInitialized)();
|
|
61
|
+
this.logger = logger_1.default.child({ className: "SuperproToken", address: this.address });
|
|
62
|
+
return this.contract = new store_1.default.web3.eth.Contract(SuperproToken_json_1.default.abi, this.address);
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Fetching balance of SuperProtocol tokens on address
|
|
66
|
+
*/
|
|
67
|
+
SuperproToken.balanceOf = function (address) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
69
|
+
return __generator(this, function (_a) {
|
|
70
|
+
switch (_a.label) {
|
|
71
|
+
case 0:
|
|
72
|
+
this.checkInit();
|
|
73
|
+
return [4 /*yield*/, this.contract.methods.balanceOf(address).call()];
|
|
74
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Transfers specific amount of SP tokens to specific address
|
|
81
|
+
* @param to - address to revive tokens
|
|
82
|
+
* @param amount - amount of tokens to transfer
|
|
83
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
84
|
+
*/
|
|
85
|
+
SuperproToken.transfer = function (to, amount, transactionOptions) {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
+
var contract, receipt;
|
|
88
|
+
return __generator(this, function (_a) {
|
|
89
|
+
switch (_a.label) {
|
|
90
|
+
case 0:
|
|
91
|
+
contract = this.checkInit(transactionOptions);
|
|
92
|
+
(0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
|
|
93
|
+
return [4 /*yield*/, TxManager_1.default.execute(contract.methods.transfer, [to, amount], transactionOptions, SuperproToken.address)];
|
|
94
|
+
case 1:
|
|
95
|
+
receipt = _a.sent();
|
|
96
|
+
return [2 /*return*/, store_1.default.web3.eth.getTransaction(receipt.transactionHash)];
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Approve tokens for specific address
|
|
103
|
+
* @param address - address for approval
|
|
104
|
+
* @param amount - number of tokens to be approved
|
|
105
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
106
|
+
*/
|
|
107
|
+
SuperproToken.approve = function (address, amount, transactionOptions) {
|
|
108
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
109
|
+
var contract;
|
|
110
|
+
return __generator(this, function (_a) {
|
|
111
|
+
switch (_a.label) {
|
|
112
|
+
case 0:
|
|
113
|
+
contract = this.checkInit(transactionOptions);
|
|
114
|
+
(0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
|
|
115
|
+
return [4 /*yield*/, TxManager_1.default.execute(contract.methods.approve, [address, amount], transactionOptions, SuperproToken.address)];
|
|
116
|
+
case 1:
|
|
117
|
+
_a.sent();
|
|
118
|
+
return [2 /*return*/];
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
return SuperproToken;
|
|
124
|
+
}());
|
|
125
|
+
exports.default = SuperproToken;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { TransactionOptions } from "../types/Web3";
|
|
2
|
+
declare class Suspicious {
|
|
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 generates a list of blocks to be checked in a random way
|
|
12
|
+
* @param tcbAddress - TCB into which other TCBs are recruited from tables for verification
|
|
13
|
+
* @param max - limit for getting blocks (like a batch size)
|
|
14
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
15
|
+
*/
|
|
16
|
+
static getRandomL2(tcbAddress: string, max: number, transactionOptions?: TransactionOptions): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Function for fetching TCB suspect list
|
|
19
|
+
*/
|
|
20
|
+
static listAll(): Promise<string[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Function for fetching TCB suspect list size
|
|
23
|
+
*/
|
|
24
|
+
static count(): Promise<string[]>;
|
|
25
|
+
}
|
|
26
|
+
export default Suspicious;
|
|
@@ -0,0 +1,99 @@
|
|
|
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
|
+
var utils_1 = require("../utils");
|
|
44
|
+
var Suspicious = /** @class */ (function () {
|
|
45
|
+
function Suspicious() {
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Checks if contract has been initialized, if not - initialize contract
|
|
49
|
+
*/
|
|
50
|
+
Suspicious.checkInit = function (transactionOptions) {
|
|
51
|
+
if (transactionOptions === null || transactionOptions === void 0 ? void 0 : transactionOptions.web3) {
|
|
52
|
+
(0, utils_1.checkIfInitialized)();
|
|
53
|
+
// return new transactionOptions.web3.eth.Contract(<AbiItem[]>SuspiciousJSON.abi, this.address);
|
|
54
|
+
}
|
|
55
|
+
if (this.contract)
|
|
56
|
+
return this.contract;
|
|
57
|
+
(0, utils_1.checkIfInitialized)();
|
|
58
|
+
this.logger = logger_1.default.child({ className: "Suspicious" });
|
|
59
|
+
// return this.contract = new store.web3!.eth.Contract(<AbiItem[]>SuspiciousJSON.abi, this.address);
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Function generates a list of blocks to be checked in a random way
|
|
63
|
+
* @param tcbAddress - TCB into which other TCBs are recruited from tables for verification
|
|
64
|
+
* @param max - limit for getting blocks (like a batch size)
|
|
65
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
66
|
+
*/
|
|
67
|
+
Suspicious.getRandomL2 = function (tcbAddress, max, transactionOptions) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
69
|
+
return __generator(this, function (_a) {
|
|
70
|
+
return [2 /*return*/];
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Function for fetching TCB suspect list
|
|
76
|
+
*/
|
|
77
|
+
Suspicious.listAll = function () {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
79
|
+
return __generator(this, function (_a) {
|
|
80
|
+
// TODO: stub
|
|
81
|
+
return [2 /*return*/, []];
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Function for fetching TCB suspect list size
|
|
87
|
+
*/
|
|
88
|
+
// TODO: stub
|
|
89
|
+
Suspicious.count = function () {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
91
|
+
return __generator(this, function (_a) {
|
|
92
|
+
// TODO: stub
|
|
93
|
+
return [2 /*return*/, []];
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
return Suspicious;
|
|
98
|
+
}());
|
|
99
|
+
exports.default = Suspicious;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { TransactionOptions } from "../types/Web3";
|
|
2
|
+
import { TeeOfferInfo } from "../types/TeeOffer";
|
|
3
|
+
import { OfferType } from "../types/Offer";
|
|
4
|
+
import { OfferCreatedEvent } from "../types/Events";
|
|
5
|
+
declare class TeeOffersFactory {
|
|
6
|
+
private static contract;
|
|
7
|
+
private static logger;
|
|
8
|
+
static teeOffers?: string[];
|
|
9
|
+
static get address(): string;
|
|
10
|
+
/**
|
|
11
|
+
* Checks if contract has been initialized, if not - initialize contract
|
|
12
|
+
*/
|
|
13
|
+
private static checkInit;
|
|
14
|
+
/**
|
|
15
|
+
* Function for fetching list of all TEE offers addresses
|
|
16
|
+
*/
|
|
17
|
+
static getAllTeeOffers(): Promise<string[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Creates new TEE offer
|
|
20
|
+
* @param providerAuthorityAccount - address of authority account of provider
|
|
21
|
+
* @param teeOfferInfo - data of new TEE offer
|
|
22
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
23
|
+
*/
|
|
24
|
+
static createTeeOffer(providerAuthorityAccount: string, teeOfferInfo: TeeOfferInfo, externalId?: string, transactionOptions?: TransactionOptions): Promise<void>;
|
|
25
|
+
static getOffer(creator: string, externalId: string): Promise<OfferCreatedEvent>;
|
|
26
|
+
/**
|
|
27
|
+
* Function for adding event listeners on TEE offer created event in TEE offers factory contract
|
|
28
|
+
* @param callback - function for processing created TEE offer
|
|
29
|
+
* @return unsubscribe - unsubscribe function from event
|
|
30
|
+
*/
|
|
31
|
+
static onTeeOfferCreated(callback: onTeeOfferCreatedCallback): () => void;
|
|
32
|
+
static onTeeOfferViolationRateChanged(callback: onTeeOfferViolationRateChangedCallback): () => void;
|
|
33
|
+
}
|
|
34
|
+
export declare type onTeeOfferCreatedCallback = (address: string, providerAuth: string, offerType: OfferType) => void;
|
|
35
|
+
export declare type onTeeOfferViolationRateChangedCallback = (address: string, providerAuth: string, violationRate: number) => void;
|
|
36
|
+
export default TeeOffersFactory;
|
|
@@ -0,0 +1,206 @@
|
|
|
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 Offers_json_1 = __importDefault(require("../contracts/Offers.json"));
|
|
45
|
+
var utils_1 = require("../utils");
|
|
46
|
+
var utils_2 = require("ethers/lib/utils");
|
|
47
|
+
var TeeOffer_1 = require("../types/TeeOffer");
|
|
48
|
+
var Offer_1 = require("../types/Offer");
|
|
49
|
+
var Superpro_1 = __importDefault(require("./Superpro"));
|
|
50
|
+
var TxManager_1 = __importDefault(require("../utils/TxManager"));
|
|
51
|
+
var TeeOffersFactory = /** @class */ (function () {
|
|
52
|
+
function TeeOffersFactory() {
|
|
53
|
+
}
|
|
54
|
+
Object.defineProperty(TeeOffersFactory, "address", {
|
|
55
|
+
get: function () {
|
|
56
|
+
return Superpro_1.default.address;
|
|
57
|
+
},
|
|
58
|
+
enumerable: false,
|
|
59
|
+
configurable: true
|
|
60
|
+
});
|
|
61
|
+
/**
|
|
62
|
+
* Checks if contract has been initialized, if not - initialize contract
|
|
63
|
+
*/
|
|
64
|
+
TeeOffersFactory.checkInit = function (transactionOptions) {
|
|
65
|
+
if (transactionOptions === null || transactionOptions === void 0 ? void 0 : transactionOptions.web3) {
|
|
66
|
+
(0, utils_1.checkIfInitialized)();
|
|
67
|
+
return new transactionOptions.web3.eth.Contract(Offers_json_1.default.abi, Superpro_1.default.address);
|
|
68
|
+
}
|
|
69
|
+
if (this.contract)
|
|
70
|
+
return this.contract;
|
|
71
|
+
(0, utils_1.checkIfInitialized)();
|
|
72
|
+
this.logger = logger_1.default.child({ className: "TeeOffersFactory" });
|
|
73
|
+
return (this.contract = new store_1.default.web3.eth.Contract(Offers_json_1.default.abi, Superpro_1.default.address));
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Function for fetching list of all TEE offers addresses
|
|
77
|
+
*/
|
|
78
|
+
TeeOffersFactory.getAllTeeOffers = function () {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
80
|
+
var count, teeOfffersSet, offerId, offerType;
|
|
81
|
+
return __generator(this, function (_a) {
|
|
82
|
+
switch (_a.label) {
|
|
83
|
+
case 0:
|
|
84
|
+
this.checkInit();
|
|
85
|
+
return [4 /*yield*/, this.contract.methods.getOffersTotalCount().call()];
|
|
86
|
+
case 1:
|
|
87
|
+
count = _a.sent();
|
|
88
|
+
this.teeOffers = this.teeOffers || [];
|
|
89
|
+
teeOfffersSet = new Set(this.teeOffers);
|
|
90
|
+
offerId = teeOfffersSet.size + 1;
|
|
91
|
+
_a.label = 2;
|
|
92
|
+
case 2:
|
|
93
|
+
if (!(offerId <= count)) return [3 /*break*/, 5];
|
|
94
|
+
return [4 /*yield*/, this.contract.methods.getOfferType(offerId).call()];
|
|
95
|
+
case 3:
|
|
96
|
+
offerType = (_a.sent());
|
|
97
|
+
if (offerType === Offer_1.OfferType.TeeOffer) {
|
|
98
|
+
teeOfffersSet.add(offerId.toString());
|
|
99
|
+
}
|
|
100
|
+
_a.label = 4;
|
|
101
|
+
case 4:
|
|
102
|
+
++offerId;
|
|
103
|
+
return [3 /*break*/, 2];
|
|
104
|
+
case 5:
|
|
105
|
+
this.teeOffers = Array.from(teeOfffersSet);
|
|
106
|
+
return [2 /*return*/, this.teeOffers];
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Creates new TEE offer
|
|
113
|
+
* @param providerAuthorityAccount - address of authority account of provider
|
|
114
|
+
* @param teeOfferInfo - data of new TEE offer
|
|
115
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
116
|
+
*/
|
|
117
|
+
TeeOffersFactory.createTeeOffer = function (providerAuthorityAccount, teeOfferInfo, externalId, transactionOptions) {
|
|
118
|
+
if (externalId === void 0) { externalId = "default"; }
|
|
119
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
120
|
+
var contract, teeOfferInfoParams, formattedExternalId;
|
|
121
|
+
return __generator(this, function (_a) {
|
|
122
|
+
switch (_a.label) {
|
|
123
|
+
case 0:
|
|
124
|
+
contract = this.checkInit(transactionOptions);
|
|
125
|
+
(0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
|
|
126
|
+
teeOfferInfoParams = (0, utils_1.objectToTuple)(teeOfferInfo, TeeOffer_1.TeeOfferInfoStructure);
|
|
127
|
+
formattedExternalId = (0, utils_2.formatBytes32String)(externalId);
|
|
128
|
+
return [4 /*yield*/, TxManager_1.default.execute(contract.methods.createTeeOffer, [providerAuthorityAccount, teeOfferInfoParams, formattedExternalId], transactionOptions)];
|
|
129
|
+
case 1:
|
|
130
|
+
_a.sent();
|
|
131
|
+
return [2 /*return*/];
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
TeeOffersFactory.getOffer = function (creator, externalId) {
|
|
137
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
138
|
+
var contract, filter, foundIds, notFound, response;
|
|
139
|
+
return __generator(this, function (_a) {
|
|
140
|
+
switch (_a.label) {
|
|
141
|
+
case 0:
|
|
142
|
+
contract = this.checkInit();
|
|
143
|
+
filter = {
|
|
144
|
+
creator: creator,
|
|
145
|
+
externalId: (0, utils_2.formatBytes32String)(externalId),
|
|
146
|
+
};
|
|
147
|
+
return [4 /*yield*/, contract.getPastEvents("TeeOfferCreated", { filter: filter })];
|
|
148
|
+
case 1:
|
|
149
|
+
foundIds = _a.sent();
|
|
150
|
+
notFound = {
|
|
151
|
+
creator: creator,
|
|
152
|
+
externalId: externalId,
|
|
153
|
+
offerId: '-1',
|
|
154
|
+
};
|
|
155
|
+
response = foundIds.length > 0 ? foundIds[0].returnValues : notFound;
|
|
156
|
+
return [2 /*return*/, response];
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Function for adding event listeners on TEE offer created event in TEE offers factory contract
|
|
163
|
+
* @param callback - function for processing created TEE offer
|
|
164
|
+
* @return unsubscribe - unsubscribe function from event
|
|
165
|
+
*/
|
|
166
|
+
TeeOffersFactory.onTeeOfferCreated = function (callback) {
|
|
167
|
+
var _this = this;
|
|
168
|
+
this.checkInit();
|
|
169
|
+
var logger = this.logger.child({ method: "onTeeOfferCreated" });
|
|
170
|
+
var subscription = this.contract.events
|
|
171
|
+
.OfferCreated()
|
|
172
|
+
.on("data", function (event) { return __awaiter(_this, void 0, void 0, function () {
|
|
173
|
+
return __generator(this, function (_a) {
|
|
174
|
+
callback(event.returnValues.offerId, event.returnValues.providerAuth, event.returnValues.offerType);
|
|
175
|
+
return [2 /*return*/];
|
|
176
|
+
});
|
|
177
|
+
}); })
|
|
178
|
+
.on("error", function (error, receipt) {
|
|
179
|
+
if (receipt)
|
|
180
|
+
return; // Used to avoid logging of transaction rejected
|
|
181
|
+
logger.warn(error);
|
|
182
|
+
});
|
|
183
|
+
return function () { return subscription.unsubscribe(); };
|
|
184
|
+
};
|
|
185
|
+
TeeOffersFactory.onTeeOfferViolationRateChanged = function (callback) {
|
|
186
|
+
var _this = this;
|
|
187
|
+
this.checkInit();
|
|
188
|
+
var logger = this.logger.child({ method: "onTeeOfferViolationRateChanged" });
|
|
189
|
+
var subscription = this.contract.events
|
|
190
|
+
.OfferCreated()
|
|
191
|
+
.on("data", function (event) { return __awaiter(_this, void 0, void 0, function () {
|
|
192
|
+
return __generator(this, function (_a) {
|
|
193
|
+
callback(event.returnValues.offerId, event.returnValues.providerAuth, event.returnValues.violationRate);
|
|
194
|
+
return [2 /*return*/];
|
|
195
|
+
});
|
|
196
|
+
}); })
|
|
197
|
+
.on("error", function (error, receipt) {
|
|
198
|
+
if (receipt)
|
|
199
|
+
return; // Used to avoid logging of transaction rejected
|
|
200
|
+
logger.warn(error);
|
|
201
|
+
});
|
|
202
|
+
return function () { return subscription.unsubscribe(); };
|
|
203
|
+
};
|
|
204
|
+
return TeeOffersFactory;
|
|
205
|
+
}());
|
|
206
|
+
exports.default = TeeOffersFactory;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ContractName, ParamName } from "../types/Superpro";
|
|
2
|
+
import { TransactionOptions } from "../types/Web3";
|
|
3
|
+
declare class Voting {
|
|
4
|
+
private static contract;
|
|
5
|
+
private static logger;
|
|
6
|
+
static ballots?: string[];
|
|
7
|
+
/**
|
|
8
|
+
* Checks if contract has been initialized, if not - initialize contract
|
|
9
|
+
*/
|
|
10
|
+
private static checkInit;
|
|
11
|
+
/**
|
|
12
|
+
* Creates ballot for replacing contract (updating address of contract in main config contract)
|
|
13
|
+
* @param contractName - name of contract to replace
|
|
14
|
+
* @param newAddress - address of new contract
|
|
15
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
16
|
+
*/
|
|
17
|
+
static createBallotForAddressUpdate(contractName: ContractName, newAddress: string, transactionOptions?: TransactionOptions): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Creates ballot for updating params value (in main config contract)
|
|
20
|
+
* @param paramName - data of new provider
|
|
21
|
+
* @param newValue - data of new provider
|
|
22
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
23
|
+
*/
|
|
24
|
+
static createBallotForParamUpdate(paramName: ParamName, newValue: number, transactionOptions?: TransactionOptions): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Function for fetching list of all ballots addresses
|
|
27
|
+
*/
|
|
28
|
+
static getAllBallots(): Promise<string[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Function for fetching list of all ballots for specific user addresses
|
|
31
|
+
* @param userAddress - address of user fpr fetching ballots
|
|
32
|
+
*/
|
|
33
|
+
static getUserBallots(userAddress: string): Promise<string[]>;
|
|
34
|
+
}
|
|
35
|
+
export default Voting;
|
|
@@ -0,0 +1,111 @@
|
|
|
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 VotingJSON from "../contracts/Voting.json";
|
|
44
|
+
var utils_1 = require("../utils");
|
|
45
|
+
var Voting = /** @class */ (function () {
|
|
46
|
+
function Voting() {
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Checks if contract has been initialized, if not - initialize contract
|
|
50
|
+
*/
|
|
51
|
+
Voting.checkInit = function (transactionOptions) {
|
|
52
|
+
if (transactionOptions === null || transactionOptions === void 0 ? void 0 : transactionOptions.web3) {
|
|
53
|
+
(0, utils_1.checkIfInitialized)();
|
|
54
|
+
// return new transactionOptions.web3.eth.Contract(<AbiItem[]>VotingJSON.abi, this.address);
|
|
55
|
+
}
|
|
56
|
+
if (this.contract)
|
|
57
|
+
return this.contract;
|
|
58
|
+
(0, utils_1.checkIfInitialized)();
|
|
59
|
+
this.logger = logger_1.default.child({ className: "Voting" });
|
|
60
|
+
// return this.contract = new store.web3!.eth.Contract(<AbiItem[]>VotingJSON.abi, this.address);
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Creates ballot for replacing contract (updating address of contract in main config contract)
|
|
64
|
+
* @param contractName - name of contract to replace
|
|
65
|
+
* @param newAddress - address of new contract
|
|
66
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
67
|
+
*/
|
|
68
|
+
Voting.createBallotForAddressUpdate = function (contractName, newAddress, transactionOptions) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
70
|
+
return __generator(this, function (_a) {
|
|
71
|
+
return [2 /*return*/];
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Creates ballot for updating params value (in main config contract)
|
|
77
|
+
* @param paramName - data of new provider
|
|
78
|
+
* @param newValue - data of new provider
|
|
79
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
80
|
+
*/
|
|
81
|
+
Voting.createBallotForParamUpdate = function (paramName, newValue, transactionOptions) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
83
|
+
return __generator(this, function (_a) {
|
|
84
|
+
return [2 /*return*/];
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Function for fetching list of all ballots addresses
|
|
90
|
+
*/
|
|
91
|
+
Voting.getAllBallots = function () {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
93
|
+
return __generator(this, function (_a) {
|
|
94
|
+
return [2 /*return*/, []];
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Function for fetching list of all ballots for specific user addresses
|
|
100
|
+
* @param userAddress - address of user fpr fetching ballots
|
|
101
|
+
*/
|
|
102
|
+
Voting.getUserBallots = function (userAddress) {
|
|
103
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
104
|
+
return __generator(this, function (_a) {
|
|
105
|
+
return [2 /*return*/, []];
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
return Voting;
|
|
110
|
+
}());
|
|
111
|
+
exports.default = Voting;
|
package/build/store.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Web3 from "web3";
|
|
2
|
+
export declare type Store = {
|
|
3
|
+
isInitialized: boolean;
|
|
4
|
+
web3?: Web3;
|
|
5
|
+
actionAccount?: string;
|
|
6
|
+
gasLimit: number;
|
|
7
|
+
gasLimitMultiplier: number;
|
|
8
|
+
gasPrice?: string;
|
|
9
|
+
keys: Record<string, string>;
|
|
10
|
+
};
|
|
11
|
+
declare const store: Store;
|
|
12
|
+
export default store;
|
package/build/store.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var constants_1 = require("./constants");
|
|
4
|
+
var store = {
|
|
5
|
+
isInitialized: false,
|
|
6
|
+
web3: undefined,
|
|
7
|
+
actionAccount: undefined,
|
|
8
|
+
gasLimit: constants_1.defaultGasLimit,
|
|
9
|
+
gasLimitMultiplier: constants_1.defaultGasLimitMultiplier,
|
|
10
|
+
gasPrice: undefined,
|
|
11
|
+
keys: {},
|
|
12
|
+
};
|
|
13
|
+
exports.default = store;
|