@super-protocol/sdk-js 0.15.0 → 0.15.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/TIIGenerator.js +129 -239
- package/build/connectors/BaseConnector.js +17 -47
- package/build/connectors/BlockchainConnector.js +222 -348
- package/build/connectors/BlockchainEventsListener.js +38 -92
- package/build/contracts/app.json +466 -35
- package/build/crypto/Crypto.js +63 -135
- package/build/crypto/index.js +1 -1
- package/build/crypto/nodejs/AES.js +62 -119
- package/build/crypto/nodejs/ARIA.js +61 -118
- package/build/crypto/nodejs/ECIES.js +51 -87
- package/build/crypto/nodejs/NativeCrypto.js +64 -118
- package/build/crypto/nodejs/RSA-Hybrid.js +54 -113
- package/build/index.d.ts +5 -0
- package/build/index.js +14 -2
- package/build/logger.d.ts +3 -1
- package/build/logger.js +2 -2
- package/build/models/EtlModel.js +65 -114
- package/build/models/Offer.js +227 -462
- package/build/models/Order.d.ts +4 -0
- package/build/models/Order.js +326 -559
- package/build/models/Provider.d.ts +2 -0
- package/build/models/Provider.js +74 -153
- package/build/models/TCB.js +67 -171
- package/build/models/TeeOffer.d.ts +1 -0
- package/build/models/TeeOffer.js +389 -731
- package/build/proto/Compression.js +20 -21
- package/build/proto/TRI.js +46 -50
- package/build/proto/TeeProperties.js +60 -66
- package/build/providers/storage/ChunksDownloadDecorator.js +125 -235
- package/build/providers/storage/S3StorageProvider.js +173 -298
- package/build/providers/storage/StorageAdapter.d.ts +60 -0
- package/build/providers/storage/StorageAdapter.js +317 -0
- package/build/providers/storage/StorageContentWriter.d.ts +39 -0
- package/build/providers/storage/StorageContentWriter.js +181 -0
- package/build/providers/storage/StorageKeyValueAdapter.d.ts +20 -0
- package/build/providers/storage/StorageKeyValueAdapter.js +152 -0
- package/build/providers/storage/StorageMetadataReader.d.ts +19 -0
- package/build/providers/storage/StorageMetadataReader.js +65 -0
- package/build/providers/storage/StorjAdapter.d.ts +19 -0
- package/build/providers/storage/StorjAdapter.js +62 -0
- package/build/providers/storage/StorjStorageProvider.js +138 -315
- package/build/providers/storage/getStorageProvider.js +7 -7
- package/build/providers/storage/types.d.ts +7 -0
- package/build/providers/storage/types.js +2 -0
- package/build/staticModels/ActiveOffers.js +32 -100
- package/build/staticModels/ActiveOrders.js +42 -120
- package/build/staticModels/BaseStaticModel.js +7 -10
- package/build/staticModels/Consensus.d.ts +4 -1
- package/build/staticModels/Consensus.js +164 -220
- package/build/staticModels/Deposits.js +109 -201
- package/build/staticModels/Marks.js +21 -82
- package/build/staticModels/ModelPackager.js +34 -84
- package/build/staticModels/Offers.js +140 -266
- package/build/staticModels/Orders.d.ts +1 -0
- package/build/staticModels/Orders.js +286 -429
- package/build/staticModels/ProviderRegistry.js +114 -225
- package/build/staticModels/Superpro.js +17 -63
- package/build/staticModels/SuperproToken.js +90 -169
- package/build/staticModels/TeeOffers.js +220 -416
- package/build/store.js +2 -2
- package/build/types/HardwareInfo.js +2 -2
- package/build/types/Order.js +4 -4
- package/build/types/Provider.js +1 -1
- package/build/types/TeeOfferInfo.js +1 -1
- package/build/types/TeeOfferOption.js +2 -2
- package/build/types/TeeOfferSlot.js +2 -2
- package/build/types/ValueOfferSlot.js +3 -3
- package/build/utils/Monitoring.js +24 -28
- package/build/utils/NonceTracker.js +56 -121
- package/build/utils/PubSub.d.ts +9 -0
- package/build/utils/PubSub.js +36 -0
- package/build/utils/TxManager.js +121 -215
- package/build/utils/compressors/GzipCompressor.js +13 -50
- package/build/utils/compressors/UncompressedCompressor.js +10 -13
- package/build/utils/helpers/tryWithInterval.js +34 -78
- package/build/utils/resourceLoaders/BaseResourceLoader.js +26 -78
- package/build/utils/resourceLoaders/StorageProviderLoader.js +33 -97
- package/build/utils/resourceLoaders/UrlResourceLoader.js +29 -93
- package/build/utils/resourceLoaders/getResourceLoader.js +6 -6
- package/build/utils.js +60 -105
- package/package.json +4 -1
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -23,99 +8,60 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
23
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
9
|
});
|
|
25
10
|
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
-
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;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
54
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
55
13
|
};
|
|
56
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
15
|
+
const BaseConnector_1 = require("./BaseConnector");
|
|
16
|
+
const web3_1 = __importDefault(require("web3"));
|
|
17
|
+
const app_json_1 = __importDefault(require("../contracts/app.json"));
|
|
60
18
|
// TODO: remove this dependencies
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return _super.call(this) || this;
|
|
19
|
+
const store_1 = __importDefault(require("../store"));
|
|
20
|
+
const Superpro_1 = __importDefault(require("../staticModels/Superpro"));
|
|
21
|
+
const SuperproToken_1 = __importDefault(require("../staticModels/SuperproToken"));
|
|
22
|
+
class BlockchainEventsListener extends BaseConnector_1.BaseConnector {
|
|
23
|
+
constructor() {
|
|
24
|
+
super();
|
|
68
25
|
}
|
|
69
|
-
|
|
26
|
+
static getInstance() {
|
|
70
27
|
if (!BlockchainEventsListener.instance) {
|
|
71
28
|
BlockchainEventsListener.instance = new BlockchainEventsListener();
|
|
72
29
|
}
|
|
73
30
|
return BlockchainEventsListener.instance;
|
|
74
|
-
}
|
|
75
|
-
|
|
31
|
+
}
|
|
32
|
+
getProvider() {
|
|
76
33
|
return this.provider;
|
|
77
|
-
}
|
|
34
|
+
}
|
|
78
35
|
/**
|
|
79
36
|
* Function for connecting to blockchain using web socket
|
|
80
37
|
* Needs to run this function before using events
|
|
81
38
|
*/
|
|
82
|
-
|
|
83
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
onTimeout: false,
|
|
97
|
-
}, config.reconnect);
|
|
98
|
-
this.provider = new web3_1.default.providers.WebsocketProvider(config.blockchainUrl, {
|
|
99
|
-
reconnect: reconnectOptions,
|
|
100
|
-
});
|
|
101
|
-
store_1.default.web3Wss = new web3_1.default(this.provider);
|
|
102
|
-
this.contract = new store_1.default.web3Wss.eth.Contract(app_json_1.default.abi, config.contractAddress);
|
|
103
|
-
Superpro_1.default.address = config.contractAddress;
|
|
104
|
-
_a = SuperproToken_1.default;
|
|
105
|
-
return [4 /*yield*/, Superpro_1.default.getTokenAddress(this.contract)];
|
|
106
|
-
case 1:
|
|
107
|
-
_a.addressWss = _b.sent();
|
|
108
|
-
this.initialized = true;
|
|
109
|
-
this.logger.trace("Initialized");
|
|
110
|
-
return [2 /*return*/];
|
|
111
|
-
}
|
|
39
|
+
initialize(config) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
this.logger.trace(config, "Initializing");
|
|
42
|
+
if (this.provider) {
|
|
43
|
+
this.provider.reset();
|
|
44
|
+
}
|
|
45
|
+
const reconnectOptions = Object.assign({
|
|
46
|
+
auto: true,
|
|
47
|
+
delay: 5000,
|
|
48
|
+
maxAttempts: 5,
|
|
49
|
+
onTimeout: false,
|
|
50
|
+
}, config.reconnect);
|
|
51
|
+
this.provider = new web3_1.default.providers.WebsocketProvider(config.blockchainUrl, {
|
|
52
|
+
reconnect: reconnectOptions,
|
|
112
53
|
});
|
|
54
|
+
store_1.default.web3Wss = new web3_1.default(this.provider);
|
|
55
|
+
this.contract = new store_1.default.web3Wss.eth.Contract(app_json_1.default.abi, config.contractAddress);
|
|
56
|
+
Superpro_1.default.address = config.contractAddress;
|
|
57
|
+
SuperproToken_1.default.addressWss = yield Superpro_1.default.getTokenAddress(this.contract);
|
|
58
|
+
this.initialized = true;
|
|
59
|
+
this.logger.trace("Initialized");
|
|
113
60
|
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
61
|
+
}
|
|
62
|
+
shutdown() {
|
|
63
|
+
super.shutdown();
|
|
117
64
|
store_1.default.web3Wss = undefined;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
}(BaseConnector_1.BaseConnector));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
121
67
|
exports.default = BlockchainEventsListener;
|