@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,436 @@
|
|
|
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 Offers_json_1 = __importDefault(require("../contracts/Offers.json"));
|
|
44
|
+
var store_1 = __importDefault(require("../store"));
|
|
45
|
+
var utils_1 = require("../utils");
|
|
46
|
+
var TeeOffer_1 = require("../types/TeeOffer");
|
|
47
|
+
var Origins_1 = require("../types/Origins");
|
|
48
|
+
var Superpro_1 = __importDefault(require("../staticModels/Superpro"));
|
|
49
|
+
var TxManager_1 = __importDefault(require("../utils/TxManager"));
|
|
50
|
+
var TeeOffer = /** @class */ (function () {
|
|
51
|
+
function TeeOffer(offerId) {
|
|
52
|
+
(0, utils_1.checkIfInitialized)();
|
|
53
|
+
this.id = offerId;
|
|
54
|
+
if (!TeeOffer.contract) {
|
|
55
|
+
TeeOffer.contract = new store_1.default.web3.eth.Contract(Offers_json_1.default.abi, Superpro_1.default.address);
|
|
56
|
+
}
|
|
57
|
+
this.logger = logger_1.default.child({ className: "TeeOffer" });
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* @returns True if offer is cancelable.
|
|
61
|
+
*/
|
|
62
|
+
TeeOffer.prototype.isOfferCancelable = function () {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
64
|
+
var _a;
|
|
65
|
+
return __generator(this, function (_b) {
|
|
66
|
+
switch (_b.label) {
|
|
67
|
+
case 0:
|
|
68
|
+
_a = this;
|
|
69
|
+
return [4 /*yield*/, TeeOffer.contract.methods.isOfferCancelable(this.id).call()];
|
|
70
|
+
case 1:
|
|
71
|
+
_a.isCancelable = _b.sent();
|
|
72
|
+
return [2 /*return*/, this.isCancelable];
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Checks if contract has been initialized, if not - initialize contract
|
|
79
|
+
*/
|
|
80
|
+
TeeOffer.prototype.checkInitTeeOffer = function (transactionOptions) {
|
|
81
|
+
if (transactionOptions === null || transactionOptions === void 0 ? void 0 : transactionOptions.web3) {
|
|
82
|
+
(0, utils_1.checkIfInitialized)();
|
|
83
|
+
return new transactionOptions.web3.eth.Contract(Offers_json_1.default.abi, Superpro_1.default.address);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Function for fetching TEE offer info from blockchain
|
|
88
|
+
*/
|
|
89
|
+
TeeOffer.prototype.getInfo = function () {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
91
|
+
var _a, teeOfferInfoParams;
|
|
92
|
+
return __generator(this, function (_b) {
|
|
93
|
+
switch (_b.label) {
|
|
94
|
+
case 0: return [4 /*yield*/, TeeOffer.contract.methods.getTeeOffer(this.id).call()];
|
|
95
|
+
case 1:
|
|
96
|
+
_a = _b.sent(), teeOfferInfoParams = _a[2];
|
|
97
|
+
return [2 /*return*/, (this.offerInfo = (0, utils_1.tupleToObject)(teeOfferInfoParams, TeeOffer_1.TeeOfferInfoStructure))];
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Function for fetching TEE offer provider from blockchain
|
|
104
|
+
*/
|
|
105
|
+
TeeOffer.prototype.getProvider = function () {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
107
|
+
var _a;
|
|
108
|
+
return __generator(this, function (_b) {
|
|
109
|
+
switch (_b.label) {
|
|
110
|
+
case 0:
|
|
111
|
+
_a = this;
|
|
112
|
+
return [4 /*yield*/, TeeOffer.contract.methods.getOfferProviderAuthority(this.id).call()];
|
|
113
|
+
case 1:
|
|
114
|
+
_a.providerAuthority = _b.sent();
|
|
115
|
+
return [2 /*return*/, this.providerAuthority];
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Function for fetching TEE offer provider authority account from blockchain
|
|
122
|
+
*/
|
|
123
|
+
TeeOffer.prototype.getProviderAuthority = function () {
|
|
124
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
125
|
+
var _a;
|
|
126
|
+
return __generator(this, function (_b) {
|
|
127
|
+
switch (_b.label) {
|
|
128
|
+
case 0:
|
|
129
|
+
_a = this;
|
|
130
|
+
return [4 /*yield*/, TeeOffer.contract.methods.getOfferProviderAuthority(this.id).call()];
|
|
131
|
+
case 1:
|
|
132
|
+
_a.providerAuthority = _b.sent();
|
|
133
|
+
return [2 /*return*/, this.providerAuthority];
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Fetch offer type from blockchain (works for TEE and Value offers)
|
|
140
|
+
*/
|
|
141
|
+
TeeOffer.prototype.getOfferType = function () {
|
|
142
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
143
|
+
var _a;
|
|
144
|
+
return __generator(this, function (_b) {
|
|
145
|
+
switch (_b.label) {
|
|
146
|
+
case 0:
|
|
147
|
+
_a = this;
|
|
148
|
+
return [4 /*yield*/, TeeOffer.contract.methods.getOfferType(this.id).call()];
|
|
149
|
+
case 1:
|
|
150
|
+
_a.type = _b.sent();
|
|
151
|
+
return [2 /*return*/, this.type];
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Function for fetching offer provider from blockchain
|
|
158
|
+
*/
|
|
159
|
+
TeeOffer.prototype.getDisabledAfter = function () {
|
|
160
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
161
|
+
var _a;
|
|
162
|
+
return __generator(this, function (_b) {
|
|
163
|
+
switch (_b.label) {
|
|
164
|
+
case 0:
|
|
165
|
+
_a = this;
|
|
166
|
+
return [4 /*yield*/, TeeOffer.contract.methods.getOfferDisabledAfter(this.id).call()];
|
|
167
|
+
case 1:
|
|
168
|
+
_a.disabledAfter = +(_b.sent());
|
|
169
|
+
return [2 /*return*/, this.disabledAfter];
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* Function for fetching tcb provider from blockchain
|
|
176
|
+
*/
|
|
177
|
+
TeeOffer.prototype.getTcb = function () {
|
|
178
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
179
|
+
var offerInfo;
|
|
180
|
+
return __generator(this, function (_a) {
|
|
181
|
+
switch (_a.label) {
|
|
182
|
+
case 0: return [4 /*yield*/, this.getInfo()];
|
|
183
|
+
case 1:
|
|
184
|
+
offerInfo = _a.sent();
|
|
185
|
+
return [2 /*return*/, offerInfo.tcb];
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* Function for fetching TLB provider from blockchain
|
|
192
|
+
*/
|
|
193
|
+
TeeOffer.prototype.getTlb = function () {
|
|
194
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
195
|
+
var offerInfo;
|
|
196
|
+
return __generator(this, function (_a) {
|
|
197
|
+
switch (_a.label) {
|
|
198
|
+
case 0: return [4 /*yield*/, this.getInfo()];
|
|
199
|
+
case 1:
|
|
200
|
+
offerInfo = _a.sent();
|
|
201
|
+
return [2 /*return*/, offerInfo.tlb];
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
* Function for offer closing price calculation
|
|
208
|
+
*/
|
|
209
|
+
TeeOffer.prototype.getClosingPrice = function (startDate) {
|
|
210
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
211
|
+
var _a;
|
|
212
|
+
return __generator(this, function (_b) {
|
|
213
|
+
switch (_b.label) {
|
|
214
|
+
case 0:
|
|
215
|
+
_a = this;
|
|
216
|
+
return [4 /*yield*/, TeeOffer.contract.methods.getOfferClosingPrice(this.id, startDate, 0).call()];
|
|
217
|
+
case 1:
|
|
218
|
+
_a.closingPrice = _b.sent();
|
|
219
|
+
return [2 /*return*/, this.closingPrice];
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* Function for fetching last TLB addition time for this TEE offer
|
|
226
|
+
*/
|
|
227
|
+
TeeOffer.prototype.getLastTlbAddedTime = function () {
|
|
228
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
229
|
+
var _a;
|
|
230
|
+
return __generator(this, function (_b) {
|
|
231
|
+
switch (_b.label) {
|
|
232
|
+
case 0:
|
|
233
|
+
_a = this;
|
|
234
|
+
return [4 /*yield*/, TeeOffer.contract.methods.getTeeOfferLastTlbAddedTime().call()];
|
|
235
|
+
case 1:
|
|
236
|
+
_a.tlbAddedTime = _b.sent();
|
|
237
|
+
return [2 /*return*/, this.tlbAddedTime];
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* Function for fetching last TCB addition time for this TEE offer
|
|
244
|
+
*/
|
|
245
|
+
TeeOffer.prototype.getLastTcbAddedTime = function () {
|
|
246
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
247
|
+
return __generator(this, function (_a) {
|
|
248
|
+
// this.tcbAddedTime = await TeeOffer.contract.methods.getLastTcbAddedTime().call();
|
|
249
|
+
// return this.tcbAddedTime!;
|
|
250
|
+
// TODO: stub
|
|
251
|
+
return [2 /*return*/, 0];
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* Function for fetching violationRate for this TEE offer
|
|
257
|
+
*/
|
|
258
|
+
TeeOffer.prototype.getViolationRate = function () {
|
|
259
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
260
|
+
var _a;
|
|
261
|
+
return __generator(this, function (_b) {
|
|
262
|
+
switch (_b.label) {
|
|
263
|
+
case 0:
|
|
264
|
+
_a = this;
|
|
265
|
+
return [4 /*yield*/, TeeOffer.contract.methods.getTeeOfferViolationRate(this.id).call()];
|
|
266
|
+
case 1:
|
|
267
|
+
_a.violationRate = _b.sent();
|
|
268
|
+
return [2 /*return*/, this.violationRate];
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
};
|
|
273
|
+
/**
|
|
274
|
+
* Function for fetching amount of total locked tokens
|
|
275
|
+
*/
|
|
276
|
+
TeeOffer.prototype.getTotalLocked = function () {
|
|
277
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
278
|
+
return __generator(this, function (_a) {
|
|
279
|
+
// this.totalLocked = await TeeOffer.contract.methods.getTotalLocked().call();
|
|
280
|
+
// return this.totalLocked!;
|
|
281
|
+
// TODO: stub
|
|
282
|
+
return [2 /*return*/, 0];
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
};
|
|
286
|
+
/**
|
|
287
|
+
* Fetch new Origins (createdDate, createdBy, modifiedDate and modifiedBy)
|
|
288
|
+
*/
|
|
289
|
+
TeeOffer.prototype.getOrigins = function () {
|
|
290
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
291
|
+
var origins;
|
|
292
|
+
return __generator(this, function (_a) {
|
|
293
|
+
switch (_a.label) {
|
|
294
|
+
case 0: return [4 /*yield*/, TeeOffer.contract.methods.getOfferOrigins(this.id).call()];
|
|
295
|
+
case 1:
|
|
296
|
+
origins = _a.sent();
|
|
297
|
+
// Converts blockchain array into object
|
|
298
|
+
origins = (0, utils_1.tupleToObject)(origins, Origins_1.OriginsStructure);
|
|
299
|
+
// Convert blockchain time seconds to js time milliseconds
|
|
300
|
+
origins.createdDate = +origins.createdDate * 1000;
|
|
301
|
+
origins.modifiedDate = +origins.modifiedDate * 1000;
|
|
302
|
+
return [2 /*return*/, (this.origins = origins)];
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
};
|
|
307
|
+
/**
|
|
308
|
+
* Updates TLB in order info
|
|
309
|
+
* @param tlb - new TLB
|
|
310
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
311
|
+
*/
|
|
312
|
+
TeeOffer.prototype.addTlb = function (tlb, transactionOptions) {
|
|
313
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
314
|
+
return __generator(this, function (_a) {
|
|
315
|
+
switch (_a.label) {
|
|
316
|
+
case 0:
|
|
317
|
+
transactionOptions !== null && transactionOptions !== void 0 ? transactionOptions : this.checkInitTeeOffer(transactionOptions);
|
|
318
|
+
(0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
|
|
319
|
+
return [4 /*yield*/, TxManager_1.default.execute(TeeOffer.contract.methods.setTeeOfferTlb, [this.id, tlb], transactionOptions)];
|
|
320
|
+
case 1:
|
|
321
|
+
_a.sent();
|
|
322
|
+
if (this.offerInfo)
|
|
323
|
+
this.offerInfo.tlb = tlb;
|
|
324
|
+
return [2 /*return*/];
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
};
|
|
329
|
+
/**
|
|
330
|
+
* Updates name in order info
|
|
331
|
+
* @param name - new name
|
|
332
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
333
|
+
*/
|
|
334
|
+
TeeOffer.prototype.setName = function (name, transactionOptions) {
|
|
335
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
336
|
+
return __generator(this, function (_a) {
|
|
337
|
+
switch (_a.label) {
|
|
338
|
+
case 0:
|
|
339
|
+
transactionOptions !== null && transactionOptions !== void 0 ? transactionOptions : this.checkInitTeeOffer(transactionOptions);
|
|
340
|
+
(0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
|
|
341
|
+
return [4 /*yield*/, TxManager_1.default.execute(TeeOffer.contract.methods.setOfferName, [this.id, name], transactionOptions)];
|
|
342
|
+
case 1:
|
|
343
|
+
_a.sent();
|
|
344
|
+
if (this.offerInfo)
|
|
345
|
+
this.offerInfo.name = name;
|
|
346
|
+
return [2 /*return*/];
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
};
|
|
351
|
+
/**
|
|
352
|
+
* Updates description in order info
|
|
353
|
+
* @param description - new description
|
|
354
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
355
|
+
*/
|
|
356
|
+
TeeOffer.prototype.setDescription = function (description, transactionOptions) {
|
|
357
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
358
|
+
return __generator(this, function (_a) {
|
|
359
|
+
switch (_a.label) {
|
|
360
|
+
case 0:
|
|
361
|
+
transactionOptions !== null && transactionOptions !== void 0 ? transactionOptions : this.checkInitTeeOffer(transactionOptions);
|
|
362
|
+
(0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
|
|
363
|
+
return [4 /*yield*/, TxManager_1.default.execute(TeeOffer.contract.methods.setOfferDescription, [this.id, description], transactionOptions)];
|
|
364
|
+
case 1:
|
|
365
|
+
_a.sent();
|
|
366
|
+
if (this.offerInfo)
|
|
367
|
+
this.offerInfo.description = description;
|
|
368
|
+
return [2 /*return*/];
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
});
|
|
372
|
+
};
|
|
373
|
+
/**
|
|
374
|
+
* Updates argsPublicKey and argsPublicKeyAlgo in order info
|
|
375
|
+
* @param argsPublicKey - new argsPublicKey
|
|
376
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
377
|
+
*/
|
|
378
|
+
TeeOffer.prototype.setKeys = function (argsPublicKey, transactionOptions) {
|
|
379
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
380
|
+
return __generator(this, function (_a) {
|
|
381
|
+
switch (_a.label) {
|
|
382
|
+
case 0:
|
|
383
|
+
transactionOptions !== null && transactionOptions !== void 0 ? transactionOptions : this.checkInitTeeOffer(transactionOptions);
|
|
384
|
+
(0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
|
|
385
|
+
return [4 /*yield*/, TxManager_1.default.execute(TeeOffer.contract.methods.setOfferPublicKey, [this.id, argsPublicKey], transactionOptions)];
|
|
386
|
+
case 1:
|
|
387
|
+
_a.sent();
|
|
388
|
+
if (this.offerInfo) {
|
|
389
|
+
this.offerInfo.argsPublicKey = argsPublicKey;
|
|
390
|
+
}
|
|
391
|
+
return [2 /*return*/];
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
});
|
|
395
|
+
};
|
|
396
|
+
/**
|
|
397
|
+
* Function for disabling TEE offer
|
|
398
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
399
|
+
*/
|
|
400
|
+
TeeOffer.prototype.disable = function (transactionOptions) {
|
|
401
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
402
|
+
return __generator(this, function (_a) {
|
|
403
|
+
switch (_a.label) {
|
|
404
|
+
case 0:
|
|
405
|
+
transactionOptions !== null && transactionOptions !== void 0 ? transactionOptions : this.checkInitTeeOffer(transactionOptions);
|
|
406
|
+
(0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
|
|
407
|
+
return [4 /*yield*/, TxManager_1.default.execute(TeeOffer.contract.methods.disableOffer, [this.id], transactionOptions)];
|
|
408
|
+
case 1:
|
|
409
|
+
_a.sent();
|
|
410
|
+
return [2 /*return*/];
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
});
|
|
414
|
+
};
|
|
415
|
+
/**
|
|
416
|
+
* Function for enabling TEE offer
|
|
417
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
418
|
+
*/
|
|
419
|
+
TeeOffer.prototype.enable = function (transactionOptions) {
|
|
420
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
421
|
+
return __generator(this, function (_a) {
|
|
422
|
+
switch (_a.label) {
|
|
423
|
+
case 0:
|
|
424
|
+
transactionOptions !== null && transactionOptions !== void 0 ? transactionOptions : this.checkInitTeeOffer(transactionOptions);
|
|
425
|
+
(0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
|
|
426
|
+
return [4 /*yield*/, TxManager_1.default.execute(TeeOffer.contract.methods.enableOffer, [this.id], transactionOptions)];
|
|
427
|
+
case 1:
|
|
428
|
+
_a.sent();
|
|
429
|
+
return [2 /*return*/];
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
});
|
|
433
|
+
};
|
|
434
|
+
return TeeOffer;
|
|
435
|
+
}());
|
|
436
|
+
exports.default = TeeOffer;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as _m0 from "protobufjs/minimal";
|
|
2
|
+
export declare const protobufPackage = "";
|
|
3
|
+
export interface Compression {
|
|
4
|
+
type: Compression_TYPE;
|
|
5
|
+
data: Uint8Array;
|
|
6
|
+
}
|
|
7
|
+
export declare enum Compression_TYPE {
|
|
8
|
+
GZIP = 0
|
|
9
|
+
}
|
|
10
|
+
export declare function compression_TYPEFromJSON(object: any): Compression_TYPE;
|
|
11
|
+
export declare function compression_TYPEToJSON(object: Compression_TYPE): string;
|
|
12
|
+
export declare const Compression: {
|
|
13
|
+
encode(message: Compression, writer?: _m0.Writer): _m0.Writer;
|
|
14
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): Compression;
|
|
15
|
+
fromJSON(object: any): Compression;
|
|
16
|
+
toJSON(message: Compression): unknown;
|
|
17
|
+
fromPartial<I extends {
|
|
18
|
+
type?: Compression_TYPE | undefined;
|
|
19
|
+
data?: Uint8Array | undefined;
|
|
20
|
+
} & {
|
|
21
|
+
type?: Compression_TYPE | undefined;
|
|
22
|
+
data?: Uint8Array | undefined;
|
|
23
|
+
} & Record<Exclude<keyof I, keyof Compression>, never>>(object: I): Compression;
|
|
24
|
+
};
|
|
25
|
+
declare type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
26
|
+
export declare type DeepPartial<T> = T extends Builtin ? T : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|
|
27
|
+
[K in keyof T]?: DeepPartial<T[K]>;
|
|
28
|
+
} : Partial<T>;
|
|
29
|
+
declare type KeysOfUnion<T> = T extends T ? keyof T : never;
|
|
30
|
+
export declare type Exact<P, I extends P> = P extends Builtin ? P : P & {
|
|
31
|
+
[K in keyof P]: Exact<P[K], I[K]>;
|
|
32
|
+
} & Record<Exclude<keyof I, KeysOfUnion<P>>, never>;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.Compression = exports.compression_TYPEToJSON = exports.compression_TYPEFromJSON = exports.Compression_TYPE = exports.protobufPackage = void 0;
|
|
30
|
+
/* eslint-disable */
|
|
31
|
+
var long_1 = __importDefault(require("long"));
|
|
32
|
+
var _m0 = __importStar(require("protobufjs/minimal"));
|
|
33
|
+
exports.protobufPackage = "";
|
|
34
|
+
var Compression_TYPE;
|
|
35
|
+
(function (Compression_TYPE) {
|
|
36
|
+
Compression_TYPE[Compression_TYPE["GZIP"] = 0] = "GZIP";
|
|
37
|
+
})(Compression_TYPE = exports.Compression_TYPE || (exports.Compression_TYPE = {}));
|
|
38
|
+
function compression_TYPEFromJSON(object) {
|
|
39
|
+
switch (object) {
|
|
40
|
+
case 0:
|
|
41
|
+
case "GZIP":
|
|
42
|
+
return Compression_TYPE.GZIP;
|
|
43
|
+
default:
|
|
44
|
+
throw new globalThis.Error("Unrecognized enum value " + object + " for enum Compression_TYPE");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.compression_TYPEFromJSON = compression_TYPEFromJSON;
|
|
48
|
+
function compression_TYPEToJSON(object) {
|
|
49
|
+
switch (object) {
|
|
50
|
+
case Compression_TYPE.GZIP:
|
|
51
|
+
return "GZIP";
|
|
52
|
+
default:
|
|
53
|
+
throw new globalThis.Error("Unrecognized enum value " + object + " for enum Compression_TYPE");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.compression_TYPEToJSON = compression_TYPEToJSON;
|
|
57
|
+
function createBaseCompression() {
|
|
58
|
+
return { type: 0, data: new Uint8Array() };
|
|
59
|
+
}
|
|
60
|
+
exports.Compression = {
|
|
61
|
+
encode: function (message, writer) {
|
|
62
|
+
if (writer === void 0) { writer = _m0.Writer.create(); }
|
|
63
|
+
if (message.type !== 0) {
|
|
64
|
+
writer.uint32(8).int32(message.type);
|
|
65
|
+
}
|
|
66
|
+
if (message.data.length !== 0) {
|
|
67
|
+
writer.uint32(18).bytes(message.data);
|
|
68
|
+
}
|
|
69
|
+
return writer;
|
|
70
|
+
},
|
|
71
|
+
decode: function (input, length) {
|
|
72
|
+
var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
|
73
|
+
var end = length === undefined ? reader.len : reader.pos + length;
|
|
74
|
+
var message = createBaseCompression();
|
|
75
|
+
while (reader.pos < end) {
|
|
76
|
+
var tag = reader.uint32();
|
|
77
|
+
switch (tag >>> 3) {
|
|
78
|
+
case 1:
|
|
79
|
+
message.type = reader.int32();
|
|
80
|
+
break;
|
|
81
|
+
case 2:
|
|
82
|
+
message.data = reader.bytes();
|
|
83
|
+
break;
|
|
84
|
+
default:
|
|
85
|
+
reader.skipType(tag & 7);
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return message;
|
|
90
|
+
},
|
|
91
|
+
fromJSON: function (object) {
|
|
92
|
+
return {
|
|
93
|
+
type: isSet(object.type) ? compression_TYPEFromJSON(object.type) : 0,
|
|
94
|
+
data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(),
|
|
95
|
+
};
|
|
96
|
+
},
|
|
97
|
+
toJSON: function (message) {
|
|
98
|
+
var obj = {};
|
|
99
|
+
message.type !== undefined && (obj.type = compression_TYPEToJSON(message.type));
|
|
100
|
+
message.data !== undefined &&
|
|
101
|
+
(obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array()));
|
|
102
|
+
return obj;
|
|
103
|
+
},
|
|
104
|
+
fromPartial: function (object) {
|
|
105
|
+
var _a, _b;
|
|
106
|
+
var message = createBaseCompression();
|
|
107
|
+
message.type = (_a = object.type) !== null && _a !== void 0 ? _a : 0;
|
|
108
|
+
message.data = (_b = object.data) !== null && _b !== void 0 ? _b : new Uint8Array();
|
|
109
|
+
return message;
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
var globalThis = (function () {
|
|
113
|
+
if (typeof globalThis !== "undefined")
|
|
114
|
+
return globalThis;
|
|
115
|
+
if (typeof self !== "undefined")
|
|
116
|
+
return self;
|
|
117
|
+
if (typeof window !== "undefined")
|
|
118
|
+
return window;
|
|
119
|
+
if (typeof global !== "undefined")
|
|
120
|
+
return global;
|
|
121
|
+
throw "Unable to locate global object";
|
|
122
|
+
})();
|
|
123
|
+
var atob = globalThis.atob || (function (b64) { return globalThis.Buffer.from(b64, "base64").toString("binary"); });
|
|
124
|
+
function bytesFromBase64(b64) {
|
|
125
|
+
var bin = atob(b64);
|
|
126
|
+
var arr = new Uint8Array(bin.length);
|
|
127
|
+
for (var i = 0; i < bin.length; ++i) {
|
|
128
|
+
arr[i] = bin.charCodeAt(i);
|
|
129
|
+
}
|
|
130
|
+
return arr;
|
|
131
|
+
}
|
|
132
|
+
var btoa = globalThis.btoa || (function (bin) { return globalThis.Buffer.from(bin, "binary").toString("base64"); });
|
|
133
|
+
function base64FromBytes(arr) {
|
|
134
|
+
var bin = [];
|
|
135
|
+
arr.forEach(function (byte) {
|
|
136
|
+
bin.push(String.fromCharCode(byte));
|
|
137
|
+
});
|
|
138
|
+
return btoa(bin.join(""));
|
|
139
|
+
}
|
|
140
|
+
if (_m0.util.Long !== long_1.default) {
|
|
141
|
+
_m0.util.Long = long_1.default;
|
|
142
|
+
_m0.configure();
|
|
143
|
+
}
|
|
144
|
+
function isSet(value) {
|
|
145
|
+
return value !== null && value !== undefined;
|
|
146
|
+
}
|