@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.
Files changed (81) hide show
  1. package/build/TIIGenerator.js +129 -239
  2. package/build/connectors/BaseConnector.js +17 -47
  3. package/build/connectors/BlockchainConnector.js +222 -348
  4. package/build/connectors/BlockchainEventsListener.js +38 -92
  5. package/build/contracts/app.json +466 -35
  6. package/build/crypto/Crypto.js +63 -135
  7. package/build/crypto/index.js +1 -1
  8. package/build/crypto/nodejs/AES.js +62 -119
  9. package/build/crypto/nodejs/ARIA.js +61 -118
  10. package/build/crypto/nodejs/ECIES.js +51 -87
  11. package/build/crypto/nodejs/NativeCrypto.js +64 -118
  12. package/build/crypto/nodejs/RSA-Hybrid.js +54 -113
  13. package/build/index.d.ts +5 -0
  14. package/build/index.js +14 -2
  15. package/build/logger.d.ts +3 -1
  16. package/build/logger.js +2 -2
  17. package/build/models/EtlModel.js +65 -114
  18. package/build/models/Offer.js +227 -462
  19. package/build/models/Order.d.ts +4 -0
  20. package/build/models/Order.js +326 -559
  21. package/build/models/Provider.d.ts +2 -0
  22. package/build/models/Provider.js +74 -153
  23. package/build/models/TCB.js +67 -171
  24. package/build/models/TeeOffer.d.ts +1 -0
  25. package/build/models/TeeOffer.js +389 -731
  26. package/build/proto/Compression.js +20 -21
  27. package/build/proto/TRI.js +46 -50
  28. package/build/proto/TeeProperties.js +60 -66
  29. package/build/providers/storage/ChunksDownloadDecorator.js +125 -235
  30. package/build/providers/storage/S3StorageProvider.js +173 -298
  31. package/build/providers/storage/StorageAdapter.d.ts +60 -0
  32. package/build/providers/storage/StorageAdapter.js +317 -0
  33. package/build/providers/storage/StorageContentWriter.d.ts +39 -0
  34. package/build/providers/storage/StorageContentWriter.js +181 -0
  35. package/build/providers/storage/StorageKeyValueAdapter.d.ts +20 -0
  36. package/build/providers/storage/StorageKeyValueAdapter.js +152 -0
  37. package/build/providers/storage/StorageMetadataReader.d.ts +19 -0
  38. package/build/providers/storage/StorageMetadataReader.js +65 -0
  39. package/build/providers/storage/StorjAdapter.d.ts +19 -0
  40. package/build/providers/storage/StorjAdapter.js +62 -0
  41. package/build/providers/storage/StorjStorageProvider.js +138 -315
  42. package/build/providers/storage/getStorageProvider.js +7 -7
  43. package/build/providers/storage/types.d.ts +7 -0
  44. package/build/providers/storage/types.js +2 -0
  45. package/build/staticModels/ActiveOffers.js +32 -100
  46. package/build/staticModels/ActiveOrders.js +42 -120
  47. package/build/staticModels/BaseStaticModel.js +7 -10
  48. package/build/staticModels/Consensus.d.ts +4 -1
  49. package/build/staticModels/Consensus.js +164 -220
  50. package/build/staticModels/Deposits.js +109 -201
  51. package/build/staticModels/Marks.js +21 -82
  52. package/build/staticModels/ModelPackager.js +34 -84
  53. package/build/staticModels/Offers.js +140 -266
  54. package/build/staticModels/Orders.d.ts +1 -0
  55. package/build/staticModels/Orders.js +286 -429
  56. package/build/staticModels/ProviderRegistry.js +114 -225
  57. package/build/staticModels/Superpro.js +17 -63
  58. package/build/staticModels/SuperproToken.js +90 -169
  59. package/build/staticModels/TeeOffers.js +220 -416
  60. package/build/store.js +2 -2
  61. package/build/types/HardwareInfo.js +2 -2
  62. package/build/types/Order.js +4 -4
  63. package/build/types/Provider.js +1 -1
  64. package/build/types/TeeOfferInfo.js +1 -1
  65. package/build/types/TeeOfferOption.js +2 -2
  66. package/build/types/TeeOfferSlot.js +2 -2
  67. package/build/types/ValueOfferSlot.js +3 -3
  68. package/build/utils/Monitoring.js +24 -28
  69. package/build/utils/NonceTracker.js +56 -121
  70. package/build/utils/PubSub.d.ts +9 -0
  71. package/build/utils/PubSub.js +36 -0
  72. package/build/utils/TxManager.js +121 -215
  73. package/build/utils/compressors/GzipCompressor.js +13 -50
  74. package/build/utils/compressors/UncompressedCompressor.js +10 -13
  75. package/build/utils/helpers/tryWithInterval.js +34 -78
  76. package/build/utils/resourceLoaders/BaseResourceLoader.js +26 -78
  77. package/build/utils/resourceLoaders/StorageProviderLoader.js +33 -97
  78. package/build/utils/resourceLoaders/UrlResourceLoader.js +29 -93
  79. package/build/utils/resourceLoaders/getResourceLoader.js +6 -6
  80. package/build/utils.js +60 -105
  81. 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
- var BaseConnector_1 = require("./BaseConnector");
58
- var web3_1 = __importDefault(require("web3"));
59
- var app_json_1 = __importDefault(require("../contracts/app.json"));
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
- var store_1 = __importDefault(require("../store"));
62
- var Superpro_1 = __importDefault(require("../staticModels/Superpro"));
63
- var SuperproToken_1 = __importDefault(require("../staticModels/SuperproToken"));
64
- var BlockchainEventsListener = /** @class */ (function (_super) {
65
- __extends(BlockchainEventsListener, _super);
66
- function BlockchainEventsListener() {
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
- BlockchainEventsListener.getInstance = function () {
26
+ static getInstance() {
70
27
  if (!BlockchainEventsListener.instance) {
71
28
  BlockchainEventsListener.instance = new BlockchainEventsListener();
72
29
  }
73
30
  return BlockchainEventsListener.instance;
74
- };
75
- BlockchainEventsListener.prototype.getProvider = function () {
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
- BlockchainEventsListener.prototype.initialize = function (config) {
83
- return __awaiter(this, void 0, void 0, function () {
84
- var reconnectOptions, _a;
85
- return __generator(this, function (_b) {
86
- switch (_b.label) {
87
- case 0:
88
- this.logger.trace(config, "Initializing");
89
- if (this.provider) {
90
- this.provider.reset();
91
- }
92
- reconnectOptions = Object.assign({
93
- auto: true,
94
- delay: 5000,
95
- maxAttempts: 5,
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
- BlockchainEventsListener.prototype.shutdown = function () {
116
- _super.prototype.shutdown.call(this);
61
+ }
62
+ shutdown() {
63
+ super.shutdown();
117
64
  store_1.default.web3Wss = undefined;
118
- };
119
- return BlockchainEventsListener;
120
- }(BaseConnector_1.BaseConnector));
65
+ }
66
+ }
121
67
  exports.default = BlockchainEventsListener;