@super-protocol/sdk-js 0.8.1-beta.2 → 0.9.0-beta.1
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 +5 -0
- package/build/BlockchainConnector.js +42 -5
- package/build/contracts/app.json +943 -293
- package/build/models/Ballot.js +2 -4
- package/build/models/Offer.d.ts +5 -0
- package/build/models/Offer.js +20 -2
- package/build/models/Order.d.ts +12 -0
- package/build/models/Order.js +32 -1
- package/build/models/Provider.js +2 -2
- package/build/models/TCB.js +3 -3
- package/build/models/TeeOffer.js +2 -2
- package/build/staticModels/ActiveOffers.d.ts +0 -5
- package/build/staticModels/ActiveOffers.js +14 -28
- package/build/staticModels/ActiveOrders.d.ts +0 -5
- package/build/staticModels/ActiveOrders.js +8 -27
- package/build/staticModels/Consensus.d.ts +7 -9
- package/build/staticModels/Consensus.js +92 -53
- package/build/staticModels/Marks.d.ts +0 -5
- package/build/staticModels/Marks.js +10 -22
- package/build/staticModels/OffersFactory.d.ts +0 -5
- package/build/staticModels/OffersFactory.js +13 -29
- package/build/staticModels/OrdersFactory.d.ts +0 -6
- package/build/staticModels/OrdersFactory.js +38 -56
- package/build/staticModels/ProviderRegistry.d.ts +0 -6
- package/build/staticModels/ProviderRegistry.js +23 -49
- package/build/staticModels/Staking.d.ts +0 -5
- package/build/staticModels/Staking.js +8 -24
- package/build/staticModels/Superpro.d.ts +0 -5
- package/build/staticModels/Superpro.js +7 -19
- package/build/staticModels/SuperproToken.d.ts +3 -1
- package/build/staticModels/SuperproToken.js +14 -11
- package/build/staticModels/TeeOffersFactory.d.ts +0 -5
- package/build/staticModels/TeeOffersFactory.js +13 -29
- package/build/staticModels/Voting.d.ts +0 -5
- package/build/staticModels/Voting.js +0 -20
- package/build/types/Consensus.d.ts +7 -0
- package/package.json +1 -1
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { TransactionOptions, EventData, BlockInfo } from "./types/Web3";
|
|
2
2
|
import BlockchainTransaction from "./types/blockchainConnector/StorageAccess";
|
|
3
3
|
import { TransactionReceipt } from "web3-core";
|
|
4
|
+
import { Contract } from "web3-eth-contract";
|
|
4
5
|
declare class BlockchainConnector {
|
|
5
6
|
private static logger;
|
|
7
|
+
private static contract;
|
|
6
8
|
private static provider?;
|
|
7
9
|
static defaultActionAccount?: string;
|
|
10
|
+
private static initContracts;
|
|
11
|
+
static getContractInstance(transactionOptions?: TransactionOptions): Contract;
|
|
8
12
|
/**
|
|
9
13
|
* Function for connecting to blockchain
|
|
10
14
|
* Used to setting up settings for blockchain connector
|
|
@@ -20,6 +24,7 @@ declare class BlockchainConnector {
|
|
|
20
24
|
* Returns balance of blockchain platform tokens in wei
|
|
21
25
|
*/
|
|
22
26
|
static getBalance(address: string): Promise<string>;
|
|
27
|
+
static getTimestamp(): Promise<number | string>;
|
|
23
28
|
/**
|
|
24
29
|
* Returns transactions events info
|
|
25
30
|
* @param txHash - transaction hash
|
|
@@ -63,6 +63,21 @@ var ethers_1 = require("ethers");
|
|
|
63
63
|
var BlockchainConnector = /** @class */ (function () {
|
|
64
64
|
function BlockchainConnector() {
|
|
65
65
|
}
|
|
66
|
+
BlockchainConnector.initContracts = function () {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
68
|
+
return __generator(this, function (_a) {
|
|
69
|
+
BlockchainConnector.contract = new store_1.default.web3.eth.Contract(app_json_1.default.abi, Superpro_1.default.address);
|
|
70
|
+
return [2 /*return*/];
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
BlockchainConnector.getContractInstance = function (transactionOptions) {
|
|
75
|
+
(0, utils_1.checkIfInitialized)();
|
|
76
|
+
if (transactionOptions === null || transactionOptions === void 0 ? void 0 : transactionOptions.web3) {
|
|
77
|
+
return new transactionOptions.web3.eth.Contract(app_json_1.default.abi, Superpro_1.default.address);
|
|
78
|
+
}
|
|
79
|
+
return BlockchainConnector.contract;
|
|
80
|
+
};
|
|
66
81
|
/**
|
|
67
82
|
* Function for connecting to blockchain
|
|
68
83
|
* Used to setting up settings for blockchain connector
|
|
@@ -74,9 +89,12 @@ var BlockchainConnector = /** @class */ (function () {
|
|
|
74
89
|
return __generator(this, function (_b) {
|
|
75
90
|
switch (_b.label) {
|
|
76
91
|
case 0:
|
|
77
|
-
if (store_1.default.isInitialized)
|
|
78
|
-
return [2 /*return*/];
|
|
79
92
|
url = (config === null || config === void 0 ? void 0 : config.blockchainUrl) || constants_1.defaultBlockchainUrl;
|
|
93
|
+
if (this.provider) {
|
|
94
|
+
if (this.provider instanceof web3_1.default.providers.WebsocketProvider) {
|
|
95
|
+
this.provider.reset();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
80
98
|
if (/^(ws)|(wss)/.test(url)) {
|
|
81
99
|
this.provider = new web3_1.default.providers.WebsocketProvider(url, {
|
|
82
100
|
reconnect: {
|
|
@@ -99,12 +117,15 @@ var BlockchainConnector = /** @class */ (function () {
|
|
|
99
117
|
if (config === null || config === void 0 ? void 0 : config.gasLimitMultiplier)
|
|
100
118
|
store_1.default.gasLimitMultiplier = config.gasLimitMultiplier;
|
|
101
119
|
Superpro_1.default.address = config.contractAddress;
|
|
102
|
-
|
|
103
|
-
return [4 /*yield*/, Superpro_1.default.getTokenAddress()];
|
|
120
|
+
return [4 /*yield*/, this.initContracts()];
|
|
104
121
|
case 1:
|
|
105
|
-
|
|
122
|
+
_b.sent();
|
|
106
123
|
TxManager_1.default.init(store_1.default.web3);
|
|
107
124
|
store_1.default.isInitialized = true;
|
|
125
|
+
_a = SuperproToken_1.default;
|
|
126
|
+
return [4 /*yield*/, Superpro_1.default.getTokenAddress()];
|
|
127
|
+
case 2:
|
|
128
|
+
_a.address = _b.sent();
|
|
108
129
|
return [2 /*return*/];
|
|
109
130
|
}
|
|
110
131
|
});
|
|
@@ -150,6 +171,22 @@ var BlockchainConnector = /** @class */ (function () {
|
|
|
150
171
|
});
|
|
151
172
|
});
|
|
152
173
|
};
|
|
174
|
+
BlockchainConnector.getTimestamp = function () {
|
|
175
|
+
var _a;
|
|
176
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
177
|
+
var block;
|
|
178
|
+
return __generator(this, function (_b) {
|
|
179
|
+
switch (_b.label) {
|
|
180
|
+
case 0:
|
|
181
|
+
(0, utils_1.checkIfInitialized)();
|
|
182
|
+
return [4 /*yield*/, ((_a = store_1.default.web3) === null || _a === void 0 ? void 0 : _a.eth.getBlock("latest"))];
|
|
183
|
+
case 1:
|
|
184
|
+
block = _b.sent();
|
|
185
|
+
return [2 /*return*/, block.timestamp];
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
};
|
|
153
190
|
/**
|
|
154
191
|
* Returns transactions events info
|
|
155
192
|
* @param txHash - transaction hash
|