@super-protocol/sdk-js 0.13.6-beta.7 → 0.13.7-beta.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.
@@ -91,12 +91,15 @@ var BlockchainEventsListener = /** @class */ (function (_super) {
91
91
  }
92
92
  reconnectOptions = Object.assign({
93
93
  auto: true,
94
- delay: 5000,
95
- maxAttempts: 5,
94
+ delay: 20000,
95
+ maxAttempts: 5000,
96
96
  onTimeout: false,
97
97
  }, config.reconnect);
98
+ this.logger.info("Initializing events listener with reconnect options: ".concat(JSON.stringify(reconnectOptions)));
98
99
  this.provider = new web3_1.default.providers.WebsocketProvider(config.blockchainUrl, {
99
100
  reconnect: reconnectOptions,
101
+ timeout: 100000,
102
+ reconnectDelay: 20000
100
103
  });
101
104
  store_1.default.web3Wss = new web3_1.default(this.provider);
102
105
  this.contract = new store_1.default.web3Wss.eth.Contract(app_json_1.default.abi, config.contractAddress);
@@ -6,5 +6,3 @@ export declare const defaultGasLimitMultiplier = 1.2;
6
6
  export declare const ONE_DAY: number;
7
7
  export declare const BLOCK_SIZE_TO_FETCH_TRANSACTION = 500;
8
8
  export declare const POLYGON_MATIC_EVENT_PATH = "0x0000000000000000000000000000000000001010";
9
- export declare const BLOCKCHAIN_CALL_RETRY_ATTEMPTS = 10;
10
- export declare const BLOCKCHAIN_CALL_RETRY_INTERVAL = 3000;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BLOCKCHAIN_CALL_RETRY_INTERVAL = exports.BLOCKCHAIN_CALL_RETRY_ATTEMPTS = exports.POLYGON_MATIC_EVENT_PATH = exports.BLOCK_SIZE_TO_FETCH_TRANSACTION = exports.ONE_DAY = exports.defaultGasLimitMultiplier = exports.defaultGasPriceMultiplier = exports.defaultGasPrice = exports.defaultGasLimit = exports.defaultBlockchainUrl = void 0;
3
+ exports.POLYGON_MATIC_EVENT_PATH = exports.BLOCK_SIZE_TO_FETCH_TRANSACTION = exports.ONE_DAY = exports.defaultGasLimitMultiplier = exports.defaultGasPriceMultiplier = exports.defaultGasPrice = exports.defaultGasLimit = exports.defaultBlockchainUrl = void 0;
4
4
  exports.defaultBlockchainUrl = "http://127.0.0.1:8545";
5
5
  exports.defaultGasLimit = 7000000;
6
6
  exports.defaultGasPrice = "3000000000";
@@ -9,5 +9,3 @@ exports.defaultGasLimitMultiplier = 1.2;
9
9
  exports.ONE_DAY = 24 * 60 * 60;
10
10
  exports.BLOCK_SIZE_TO_FETCH_TRANSACTION = 500;
11
11
  exports.POLYGON_MATIC_EVENT_PATH = "0x0000000000000000000000000000000000001010";
12
- exports.BLOCKCHAIN_CALL_RETRY_ATTEMPTS = 10;
13
- exports.BLOCKCHAIN_CALL_RETRY_INTERVAL = 3000;
@@ -73,7 +73,6 @@ declare class Offer {
73
73
  */
74
74
  getCheapestPrice(): Promise<string>;
75
75
  isOfferExists(): Promise<boolean>;
76
- private checkIfOfferExistsWithInterval;
77
76
  /**
78
77
  * Function for fetching whether offer slot exists or not
79
78
  * @param slotId - Slot ID
@@ -59,8 +59,6 @@ var OptionInfo_1 = require("../types/OptionInfo");
59
59
  var SlotUsage_1 = require("../types/SlotUsage");
60
60
  var utils_2 = require("ethers/lib/utils");
61
61
  var TeeOffers_1 = __importDefault(require("../staticModels/TeeOffers"));
62
- var helpers_1 = require("../utils/helpers");
63
- var constants_1 = require("../constants");
64
62
  var Offer = /** @class */ (function () {
65
63
  function Offer(offerId) {
66
64
  this.id = offerId;
@@ -169,13 +167,8 @@ var Offer = /** @class */ (function () {
169
167
  var _a, offerInfoParams;
170
168
  return __generator(this, function (_b) {
171
169
  switch (_b.label) {
172
- case 0: return [4 /*yield*/, this.checkIfOfferExistsWithInterval()];
170
+ case 0: return [4 /*yield*/, Offer.contract.methods.getValueOffer(this.id).call()];
173
171
  case 1:
174
- if (!(_b.sent())) {
175
- throw Error("Offer ".concat(this.id, " does not exist"));
176
- }
177
- return [4 /*yield*/, Offer.contract.methods.getValueOffer(this.id).call()];
178
- case 2:
179
172
  _a = _b.sent(), offerInfoParams = _a[2];
180
173
  this.offerInfo = (0, utils_1.tupleToObject)(offerInfoParams, Offer_1.OfferInfoStructure);
181
174
  return [2 /*return*/, this.offerInfo];
@@ -299,29 +292,6 @@ var Offer = /** @class */ (function () {
299
292
  });
300
293
  });
301
294
  };
302
- Offer.prototype.checkIfOfferExistsWithInterval = function () {
303
- return __awaiter(this, void 0, void 0, function () {
304
- var offerExists;
305
- var _this = this;
306
- return __generator(this, function (_a) {
307
- switch (_a.label) {
308
- case 0: return [4 /*yield*/, (0, helpers_1.tryWithInterval)({
309
- handler: function () { return _this.isOfferExists(); },
310
- checkResult: function (exists) {
311
- if (!exists)
312
- _this.logger.debug("Offer ".concat(_this.id, " exists: ").concat(exists));
313
- return { isResultOk: exists };
314
- },
315
- retryInterval: constants_1.BLOCKCHAIN_CALL_RETRY_INTERVAL,
316
- retryMax: constants_1.BLOCKCHAIN_CALL_RETRY_ATTEMPTS,
317
- })];
318
- case 1:
319
- offerExists = _a.sent();
320
- return [2 /*return*/, offerExists];
321
- }
322
- });
323
- });
324
- };
325
295
  /**
326
296
  * Function for fetching whether offer slot exists or not
327
297
  * @param slotId - Slot ID
@@ -38,7 +38,6 @@ declare class Order {
38
38
  * Function for fetching order info from blockchain
39
39
  */
40
40
  getOrderInfo(): Promise<OrderInfo>;
41
- private checkIfOrderExistsWithInterval;
42
41
  getConsumer(): Promise<string>;
43
42
  /**
44
43
  * Function for fetching order result from blockchain
@@ -135,7 +134,7 @@ declare class Order {
135
134
  * @param transactionOptions - object what contains alternative action account or gas limit (optional)
136
135
  * @returns Promise<void> - Does not return id of created sub order!
137
136
  */
138
- createSubOrder(subOrderInfo: OrderInfo, blockParentOrder: boolean, deposit?: string, transactionOptions?: TransactionOptions): Promise<void>;
137
+ createSubOrder(subOrderInfo: OrderInfo, blockParentOrder: boolean, deposit?: string, transactionOptions?: TransactionOptions, checkTxBeforeSend?: boolean): Promise<void>;
139
138
  /**
140
139
  * Function for creating pack of sub orders (wokflow) for current order
141
140
  * @param subOrdersInfo - orders info for new subOrders
@@ -68,8 +68,6 @@ var Superpro_1 = __importDefault(require("../staticModels/Superpro"));
68
68
  var TxManager_1 = __importDefault(require("../utils/TxManager"));
69
69
  var BlockchainEventsListener_1 = __importDefault(require("../connectors/BlockchainEventsListener"));
70
70
  var TeeOffers_1 = __importDefault(require("../staticModels/TeeOffers"));
71
- var helpers_1 = require("../utils/helpers");
72
- var constants_1 = require("../constants");
73
71
  var Order = /** @class */ (function () {
74
72
  function Order(orderId) {
75
73
  this.id = orderId;
@@ -149,7 +147,7 @@ var Order = /** @class */ (function () {
149
147
  var orderInfoParams;
150
148
  return __generator(this, function (_a) {
151
149
  switch (_a.label) {
152
- case 0: return [4 /*yield*/, this.checkIfOrderExistsWithInterval()];
150
+ case 0: return [4 /*yield*/, this.isExist()];
153
151
  case 1:
154
152
  if (!(_a.sent())) {
155
153
  throw Error("Order ".concat(this.id, " does not exist"));
@@ -162,29 +160,6 @@ var Order = /** @class */ (function () {
162
160
  });
163
161
  });
164
162
  };
165
- Order.prototype.checkIfOrderExistsWithInterval = function () {
166
- return __awaiter(this, void 0, void 0, function () {
167
- var offerExists;
168
- var _this = this;
169
- return __generator(this, function (_a) {
170
- switch (_a.label) {
171
- case 0: return [4 /*yield*/, (0, helpers_1.tryWithInterval)({
172
- handler: function () { return _this.isExist(); },
173
- checkResult: function (exists) {
174
- if (!exists)
175
- _this.logger.debug("Order ".concat(_this.id, " exists: ").concat(exists));
176
- return { isResultOk: exists };
177
- },
178
- retryInterval: constants_1.BLOCKCHAIN_CALL_RETRY_INTERVAL,
179
- retryMax: constants_1.BLOCKCHAIN_CALL_RETRY_ATTEMPTS,
180
- })];
181
- case 1:
182
- offerExists = _a.sent();
183
- return [2 /*return*/, offerExists];
184
- }
185
- });
186
- });
187
- };
188
163
  Order.prototype.getConsumer = function () {
189
164
  return __awaiter(this, void 0, void 0, function () {
190
165
  var orderInfoParams;
@@ -554,8 +529,9 @@ var Order = /** @class */ (function () {
554
529
  * @param transactionOptions - object what contains alternative action account or gas limit (optional)
555
530
  * @returns Promise<void> - Does not return id of created sub order!
556
531
  */
557
- Order.prototype.createSubOrder = function (subOrderInfo, blockParentOrder, deposit, transactionOptions) {
532
+ Order.prototype.createSubOrder = function (subOrderInfo, blockParentOrder, deposit, transactionOptions, checkTxBeforeSend) {
558
533
  if (deposit === void 0) { deposit = "0"; }
534
+ if (checkTxBeforeSend === void 0) { checkTxBeforeSend = false; }
559
535
  return __awaiter(this, void 0, void 0, function () {
560
536
  var preparedInfo, tupleSubOrder, params;
561
537
  return __generator(this, function (_a) {
@@ -569,8 +545,13 @@ var Order = /** @class */ (function () {
569
545
  blockParentOrder: blockParentOrder,
570
546
  deposit: deposit,
571
547
  };
572
- return [4 /*yield*/, TxManager_1.default.execute(Order.contract.methods.createSubOrder, [this.id, tupleSubOrder, params], transactionOptions)];
548
+ if (!checkTxBeforeSend) return [3 /*break*/, 2];
549
+ return [4 /*yield*/, TxManager_1.default.dryRun(Order.contract.methods.createSubOrder, [this.id, tupleSubOrder, params], transactionOptions)];
573
550
  case 1:
551
+ _a.sent();
552
+ _a.label = 2;
553
+ case 2: return [4 /*yield*/, TxManager_1.default.execute(Order.contract.methods.createSubOrder, [this.id, tupleSubOrder, params], transactionOptions)];
554
+ case 3:
574
555
  _a.sent();
575
556
  return [2 /*return*/];
576
557
  }
@@ -11,8 +11,7 @@ export default class StorJStorageProvider implements IStorageProvider {
11
11
  private _access?;
12
12
  private _project?;
13
13
  private _storj?;
14
- private maximumConcurrent?;
15
- constructor(credentials: any, maximumConcurrent?: number);
14
+ constructor(credentials: any);
16
15
  uploadFile(inputStream: stream.Readable, remotePath: string, contentLength: number, progressListener?: (total: number, current: number) => void): Promise<void>;
17
16
  downloadFile(remotePath: string, config: DownloadConfig, progressListener?: (total: number, current: number) => void): Promise<stream.Readable>;
18
17
  deleteObject(remotePath: string): Promise<void>;
@@ -63,7 +63,7 @@ var utils_1 = require("../../utils");
63
63
  var stream_1 = __importDefault(require("stream"));
64
64
  var logger_1 = __importDefault(require("../../logger"));
65
65
  var StorJStorageProvider = /** @class */ (function () {
66
- function StorJStorageProvider(credentials, maximumConcurrent) {
66
+ function StorJStorageProvider(credentials) {
67
67
  this.logger = logger_1.default.child({ className: "StorJStorageProvider" });
68
68
  if (!(0, utils_1.isNodeJS)()) {
69
69
  throw Error("StorageProvider: StorJ is supported only in the node.js execution environment");
@@ -79,7 +79,6 @@ var StorJStorageProvider = /** @class */ (function () {
79
79
  this.bucket = credentials.storageId;
80
80
  }
81
81
  this.accessToken = credentials.token;
82
- this.maximumConcurrent = maximumConcurrent;
83
82
  }
84
83
  StorJStorageProvider.prototype.uploadFile = function (inputStream, remotePath, contentLength, progressListener) {
85
84
  var _a, inputStream_1, inputStream_1_1;
@@ -368,7 +367,7 @@ var StorJStorageProvider = /** @class */ (function () {
368
367
  case 1:
369
368
  access = _b.sent();
370
369
  _a = this;
371
- return [4 /*yield*/, access.openProject(this.maximumConcurrent)];
370
+ return [4 /*yield*/, access.openProject()];
372
371
  case 2:
373
372
  _a._project = _b.sent();
374
373
  _b.label = 3;
@@ -5,14 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  var dto_js_1 = require("@super-protocol/dto-js");
7
7
  var StorjStorageProvider_1 = __importDefault(require("./StorjStorageProvider"));
8
- var S3StorageProvider_1 = require("./S3StorageProvider");
9
8
  exports.default = (function (storageAccess) {
10
9
  var key = storageAccess.storageType;
11
10
  switch (key) {
12
11
  case dto_js_1.StorageType.StorJ:
13
- return new StorjStorageProvider_1.default(storageAccess.credentials, storageAccess.maximumConcurrent);
14
- case dto_js_1.StorageType.S3:
15
- return new S3StorageProvider_1.S3StorageProvider(storageAccess.credentials);
12
+ return new StorjStorageProvider_1.default(storageAccess.credentials);
16
13
  default:
17
14
  throw Error("Unsupported storageType ".concat(key));
18
15
  }
@@ -21,7 +21,7 @@ declare class Orders {
21
21
  * @param transactionOptions - object what contains alternative action account or gas limit (optional)
22
22
  * @returns {Promise<void>} - Does not return id of created order!
23
23
  */
24
- static createOrder(orderInfo: OrderInfo, deposit?: string, suspended?: boolean, transactionOptions?: TransactionOptions): Promise<void>;
24
+ static createOrder(orderInfo: OrderInfo, deposit?: string, suspended?: boolean, transactionOptions?: TransactionOptions, checkTxBeforeSend?: boolean): Promise<void>;
25
25
  static getByExternalId(consumer?: string, externalId?: string, fromBlock?: number | string, toBlock?: number | string): Promise<OrderCreatedEvent>;
26
26
  /**
27
27
  * Function for create workflow
@@ -31,7 +31,7 @@ declare class Orders {
31
31
  * @param transactionOptions - object what contains alternative action account or gas limit (optional)
32
32
  * @returns {Promise<void>} - Does not return id of created order!
33
33
  */
34
- static createWorkflow(parentOrderInfo: OrderInfo, subOrdersInfo: OrderInfo[], workflowDeposit?: string, transactionOptions?: TransactionOptions): Promise<void>;
34
+ static createWorkflow(parentOrderInfo: OrderInfo, subOrdersInfo: OrderInfo[], workflowDeposit?: string, transactionOptions?: TransactionOptions, checkTxBeforeSend?: boolean): Promise<void>;
35
35
  /**
36
36
  * Function for cancel workflow
37
37
  * @param parentOrderId - Parent order id
@@ -124,9 +124,10 @@ var Orders = /** @class */ (function () {
124
124
  * @param transactionOptions - object what contains alternative action account or gas limit (optional)
125
125
  * @returns {Promise<void>} - Does not return id of created order!
126
126
  */
127
- Orders.createOrder = function (orderInfo, deposit, suspended, transactionOptions) {
127
+ Orders.createOrder = function (orderInfo, deposit, suspended, transactionOptions, checkTxBeforeSend) {
128
128
  if (deposit === void 0) { deposit = "0"; }
129
129
  if (suspended === void 0) { suspended = false; }
130
+ if (checkTxBeforeSend === void 0) { checkTxBeforeSend = false; }
130
131
  return __awaiter(this, void 0, void 0, function () {
131
132
  var contract, preparedInfo, orderInfoArguments;
132
133
  return __generator(this, function (_a) {
@@ -136,8 +137,13 @@ var Orders = /** @class */ (function () {
136
137
  (0, utils_2.checkIfActionAccountInitialized)(transactionOptions);
137
138
  preparedInfo = __assign(__assign({}, orderInfo), { externalId: (0, utils_1.formatBytes32String)(orderInfo.externalId) });
138
139
  orderInfoArguments = (0, utils_2.objectToTuple)(preparedInfo, Order_1.OrderInfoStructure);
139
- return [4 /*yield*/, TxManager_1.default.execute(contract.methods.createOrder, [orderInfoArguments, deposit, suspended], transactionOptions)];
140
+ if (!checkTxBeforeSend) return [3 /*break*/, 2];
141
+ return [4 /*yield*/, TxManager_1.default.dryRun(contract.methods.createOrder, [orderInfoArguments, deposit, suspended], transactionOptions)];
140
142
  case 1:
143
+ _a.sent();
144
+ _a.label = 2;
145
+ case 2: return [4 /*yield*/, TxManager_1.default.execute(contract.methods.createOrder, [orderInfoArguments, deposit, suspended], transactionOptions)];
146
+ case 3:
141
147
  _a.sent();
142
148
  return [2 /*return*/];
143
149
  }
@@ -181,8 +187,9 @@ var Orders = /** @class */ (function () {
181
187
  * @param transactionOptions - object what contains alternative action account or gas limit (optional)
182
188
  * @returns {Promise<void>} - Does not return id of created order!
183
189
  */
184
- Orders.createWorkflow = function (parentOrderInfo, subOrdersInfo, workflowDeposit, transactionOptions) {
190
+ Orders.createWorkflow = function (parentOrderInfo, subOrdersInfo, workflowDeposit, transactionOptions, checkTxBeforeSend) {
185
191
  if (workflowDeposit === void 0) { workflowDeposit = "0"; }
192
+ if (checkTxBeforeSend === void 0) { checkTxBeforeSend = false; }
186
193
  return __awaiter(this, void 0, void 0, function () {
187
194
  var contract, preparedInfo, parentOrderInfoArgs, preparedSubOrdersInfo, subOrdersInfoArgs;
188
195
  return __generator(this, function (_a) {
@@ -194,8 +201,13 @@ var Orders = /** @class */ (function () {
194
201
  parentOrderInfoArgs = (0, utils_2.objectToTuple)(preparedInfo, Order_1.OrderInfoStructure);
195
202
  preparedSubOrdersInfo = subOrdersInfo.map(function (o) { return (__assign(__assign({}, o), { externalId: (0, utils_1.formatBytes32String)(o.externalId) })); });
196
203
  subOrdersInfoArgs = (0, utils_2.objectToTuple)(preparedSubOrdersInfo, Order_1.OrderInfoStructureArray);
197
- return [4 /*yield*/, TxManager_1.default.execute(contract.methods.createWorkflow, [parentOrderInfoArgs, workflowDeposit, subOrdersInfoArgs], transactionOptions)];
204
+ if (!checkTxBeforeSend) return [3 /*break*/, 2];
205
+ return [4 /*yield*/, TxManager_1.default.dryRun(contract.methods.createWorkflow, [parentOrderInfoArgs, workflowDeposit, subOrdersInfoArgs], transactionOptions)];
198
206
  case 1:
207
+ _a.sent();
208
+ _a.label = 2;
209
+ case 2: return [4 /*yield*/, TxManager_1.default.execute(contract.methods.createWorkflow, [parentOrderInfoArgs, workflowDeposit, subOrdersInfoArgs], transactionOptions)];
210
+ case 3:
199
211
  _a.sent();
200
212
  return [2 /*return*/];
201
213
  }
@@ -32,14 +32,14 @@ declare class SuperproToken {
32
32
  * @param amount - amount of tokens to transfer
33
33
  * @param transactionOptions - object what contains alternative action account or gas limit (optional)
34
34
  */
35
- static transfer(to: string, amount: string, transactionOptions?: TransactionOptions): Promise<Transaction>;
35
+ static transfer(to: string, amount: string, transactionOptions?: TransactionOptions, checkTxBeforeSend?: boolean): Promise<Transaction>;
36
36
  /**
37
37
  * Approve tokens for specific address
38
38
  * @param address - address for approval
39
39
  * @param amount - number of tokens to be approved
40
40
  * @param transactionOptions - object what contains alternative action account or gas limit (optional)
41
41
  */
42
- static approve(address: string, amount: string, transactionOptions?: TransactionOptions): Promise<void>;
42
+ static approve(address: string, amount: string, transactionOptions?: TransactionOptions, checkTxBeforeSend?: boolean): Promise<void>;
43
43
  static onTokenApprove(callback: onTokenApproveCallback, owner?: string, spender?: string): () => void;
44
44
  static onTokenTransfer(callback: onTokenTransferCallback, from?: string, to?: string): () => void;
45
45
  }
@@ -120,7 +120,8 @@ var SuperproToken = /** @class */ (function () {
120
120
  * @param amount - amount of tokens to transfer
121
121
  * @param transactionOptions - object what contains alternative action account or gas limit (optional)
122
122
  */
123
- SuperproToken.transfer = function (to, amount, transactionOptions) {
123
+ SuperproToken.transfer = function (to, amount, transactionOptions, checkTxBeforeSend) {
124
+ if (checkTxBeforeSend === void 0) { checkTxBeforeSend = false; }
124
125
  return __awaiter(this, void 0, void 0, function () {
125
126
  var contract, receipt;
126
127
  return __generator(this, function (_a) {
@@ -128,6 +129,9 @@ var SuperproToken = /** @class */ (function () {
128
129
  case 0:
129
130
  contract = this.checkInit(transactionOptions);
130
131
  (0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
132
+ if (checkTxBeforeSend) {
133
+ TxManager_1.default.dryRun(contract.methods.transfer, [to, amount], transactionOptions);
134
+ }
131
135
  return [4 /*yield*/, TxManager_1.default.execute(contract.methods.transfer, [to, amount], transactionOptions, SuperproToken.addressHttps)];
132
136
  case 1:
133
137
  receipt = _a.sent();
@@ -142,7 +146,8 @@ var SuperproToken = /** @class */ (function () {
142
146
  * @param amount - number of tokens to be approved
143
147
  * @param transactionOptions - object what contains alternative action account or gas limit (optional)
144
148
  */
145
- SuperproToken.approve = function (address, amount, transactionOptions) {
149
+ SuperproToken.approve = function (address, amount, transactionOptions, checkTxBeforeSend) {
150
+ if (checkTxBeforeSend === void 0) { checkTxBeforeSend = false; }
146
151
  return __awaiter(this, void 0, void 0, function () {
147
152
  var contract;
148
153
  return __generator(this, function (_a) {
@@ -150,8 +155,13 @@ var SuperproToken = /** @class */ (function () {
150
155
  case 0:
151
156
  contract = this.checkInit(transactionOptions);
152
157
  (0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
153
- return [4 /*yield*/, TxManager_1.default.execute(contract.methods.approve, [address, amount], transactionOptions, SuperproToken.addressHttps)];
158
+ if (!checkTxBeforeSend) return [3 /*break*/, 2];
159
+ return [4 /*yield*/, TxManager_1.default.dryRun(contract.methods.approve, [address, amount], transactionOptions)];
154
160
  case 1:
161
+ _a.sent();
162
+ _a.label = 2;
163
+ case 2: return [4 /*yield*/, TxManager_1.default.execute(contract.methods.approve, [address, amount], transactionOptions, SuperproToken.addressHttps)];
164
+ case 3:
155
165
  _a.sent();
156
166
  return [2 /*return*/];
157
167
  }
@@ -36,3 +36,6 @@ export type Transaction = {
36
36
  input: string;
37
37
  timestamp: number;
38
38
  };
39
+ export type DryRunError = Error & {
40
+ txErrorMsg: string | null;
41
+ };
@@ -2,6 +2,5 @@ import { StorageType } from "@super-protocol/dto-js";
2
2
  type StorageAccess = {
3
3
  storageType: StorageType;
4
4
  credentials: any;
5
- maximumConcurrent?: number;
6
5
  };
7
6
  export default StorageAccess;
@@ -1,8 +1,8 @@
1
1
  type StorageObject = {
2
2
  name: string;
3
3
  size: number;
4
- isFolder?: boolean;
5
- childrenCount?: number;
4
+ isFolder: boolean;
5
+ childrenCount: number;
6
6
  createdAt: Date;
7
7
  };
8
8
  export default StorageObject;
@@ -16,6 +16,7 @@ declare class TxManager {
16
16
  private static checkIfInitialized;
17
17
  static initAccount(address: string): Promise<void>;
18
18
  static execute(method: (...args: ArgumentsType) => MethodReturnType, args: ArgumentsType, transactionOptions?: TransactionOptions, to?: string): Promise<TransactionReceipt>;
19
+ static dryRun(method: (...args: ArgumentsType) => MethodReturnType, args: ArgumentsType, transactionOptions?: TransactionOptions): Promise<any>;
19
20
  static publishTransaction(txData: Record<string, any>, transactionOptions?: TransactionOptions, transactionCall?: MethodReturnType): Promise<TransactionReceipt>;
20
21
  }
21
22
  export default TxManager;
@@ -89,18 +89,47 @@ var TxManager = /** @class */ (function () {
89
89
  return __awaiter(this, void 0, void 0, function () {
90
90
  var transaction, txData;
91
91
  return __generator(this, function (_a) {
92
- transaction = method.apply(void 0, args);
93
- txData = {
94
- to: to,
95
- data: transaction.encodeABI(),
96
- };
97
- return [2 /*return*/, TxManager.publishTransaction(txData, transactionOptions, transaction)];
92
+ switch (_a.label) {
93
+ case 0:
94
+ transaction = method.apply(void 0, args);
95
+ txData = {
96
+ to: to,
97
+ data: transaction.encodeABI(),
98
+ };
99
+ return [4 /*yield*/, TxManager.publishTransaction(txData, transactionOptions, transaction)];
100
+ case 1: return [2 /*return*/, _a.sent()];
101
+ }
102
+ });
103
+ });
104
+ };
105
+ TxManager.dryRun = function (method, args, transactionOptions) {
106
+ var _a;
107
+ return __awaiter(this, void 0, void 0, function () {
108
+ var transaction, from, result, e_1;
109
+ return __generator(this, function (_b) {
110
+ switch (_b.label) {
111
+ case 0:
112
+ transaction = method.apply(void 0, args);
113
+ from = (_a = transactionOptions === null || transactionOptions === void 0 ? void 0 : transactionOptions.from) !== null && _a !== void 0 ? _a : store_1.default.actionAccount;
114
+ _b.label = 1;
115
+ case 1:
116
+ _b.trys.push([1, 3, , 4]);
117
+ return [4 /*yield*/, transaction.call({ from: from })];
118
+ case 2:
119
+ result = _b.sent();
120
+ return [2 /*return*/, result];
121
+ case 3:
122
+ e_1 = _b.sent();
123
+ e_1.txErrorMsg = e_1.data.message || "Error text is undefined";
124
+ throw e_1;
125
+ case 4: return [2 /*return*/];
126
+ }
98
127
  });
99
128
  });
100
129
  };
101
130
  TxManager.publishTransaction = function (txData, transactionOptions, transactionCall) {
102
131
  return __awaiter(this, void 0, void 0, function () {
103
- var web3, options, estimatedGas, e_1, nonceTracker, signingKey, transactionResultData, signed, e_2;
132
+ var web3, options, estimatedGas, e_2, nonceTracker, signingKey, transactionResultData, signed, e_3;
104
133
  return __generator(this, function (_a) {
105
134
  switch (_a.label) {
106
135
  case 0:
@@ -124,8 +153,8 @@ var TxManager = /** @class */ (function () {
124
153
  estimatedGas = _a.sent();
125
154
  return [3 /*break*/, 5];
126
155
  case 4:
127
- e_1 = _a.sent();
128
- TxManager.logger.debug({ error: e_1 }, "Fail to calculate estimated gas");
156
+ e_2 = _a.sent();
157
+ TxManager.logger.debug({ error: e_2 }, "Fail to calculate estimated gas");
129
158
  estimatedGas = constants_1.defaultGasLimit;
130
159
  return [3 /*break*/, 5];
131
160
  case 5:
@@ -191,14 +220,14 @@ var TxManager = /** @class */ (function () {
191
220
  nonceTracker.onTransactionPublished();
192
221
  return [2 /*return*/, transactionResultData];
193
222
  case 15:
194
- e_2 = _a.sent();
195
- TxManager.logger.error(e_2, "Error during transaction execution");
223
+ e_3 = _a.sent();
224
+ TxManager.logger.error(e_3, "Error during transaction execution");
196
225
  if (!nonceTracker) return [3 /*break*/, 17];
197
226
  return [4 /*yield*/, nonceTracker.onTransactionError()];
198
227
  case 16:
199
228
  _a.sent();
200
229
  _a.label = 17;
201
- case 17: throw e_2;
230
+ case 17: throw e_3;
202
231
  case 18: return [2 /*return*/];
203
232
  }
204
233
  });
@@ -6,7 +6,6 @@ export interface TryWithIntervalParams<T> {
6
6
  checkError?: (err: unknown) => {
7
7
  retryable: boolean;
8
8
  };
9
- startDelay?: number;
10
9
  retryInterval: number;
11
10
  retryMax: number;
12
11
  }
@@ -38,12 +38,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.tryWithInterval = void 0;
40
40
  var tryWithInterval = function (params) { return __awaiter(void 0, void 0, void 0, function () {
41
- var checkedTimes, handler, checkResult, checkError, _a, startDelay, retryInterval, retryMax;
42
- return __generator(this, function (_b) {
43
- switch (_b.label) {
41
+ var checkedTimes, handler, checkResult, checkError, retryInterval, retryMax;
42
+ return __generator(this, function (_a) {
43
+ switch (_a.label) {
44
44
  case 0:
45
45
  checkedTimes = 0;
46
- handler = params.handler, checkResult = params.checkResult, checkError = params.checkError, _a = params.startDelay, startDelay = _a === void 0 ? 0 : _a, retryInterval = params.retryInterval, retryMax = params.retryMax;
46
+ handler = params.handler, checkResult = params.checkResult, checkError = params.checkError, retryInterval = params.retryInterval, retryMax = params.retryMax;
47
47
  return [4 /*yield*/, new Promise(function (resolve, reject) {
48
48
  var checkTimes = function () {
49
49
  checkedTimes += 1;
@@ -83,9 +83,9 @@ var tryWithInterval = function (params) { return __awaiter(void 0, void 0, void
83
83
  }
84
84
  });
85
85
  }); };
86
- setTimeout(timeoutFn, startDelay);
86
+ setTimeout(timeoutFn, retryInterval);
87
87
  })];
88
- case 1: return [2 /*return*/, _b.sent()];
88
+ case 1: return [2 /*return*/, _a.sent()];
89
89
  }
90
90
  });
91
91
  }); };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@super-protocol/sdk-js",
3
- "version": "0.13.6-beta.7",
3
+ "version": "0.13.7-beta.0",
4
4
  "main": "build/index.js",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -52,10 +52,9 @@
52
52
  "typescript": "^4.4.4"
53
53
  },
54
54
  "dependencies": {
55
- "@super-protocol/dto-js": "0.0.28",
55
+ "@super-protocol/dto-js": "0.0.24",
56
56
  "@super-protocol/tee-lib": "^0.1.2",
57
- "@super-protocol/uplink-nodejs": "1.2.16",
58
- "aws-sdk": "^2.1418.0",
57
+ "@super-protocol/uplink-nodejs": "1.2.12",
59
58
  "ethers": "^5.5.3",
60
59
  "hybrid-crypto-js": "^0.2.4",
61
60
  "lodash": "^4.17.21",
@@ -65,8 +64,5 @@
65
64
  "web3": "^1.7.1",
66
65
  "web3-parse-receipt-events": "^1.0.2"
67
66
  },
68
- "repository": "git://github.com/Super-Protocol/sdk-js.git",
69
- "resolutions": {
70
- "wrap-ansi": "7.0.0"
71
- }
67
+ "repository": "git://github.com/Super-Protocol/sdk-js.git"
72
68
  }
@@ -1,24 +0,0 @@
1
- /// <reference types="node" />
2
- import IStorageProvider, { DownloadConfig } from "./IStorageProvider";
3
- import { Readable } from "stream";
4
- import StorageObject from "../../types/storage/StorageObject";
5
- export type S3ClientConfig = {
6
- accessKeyId: string;
7
- secretAccessKey: string;
8
- endpoint: string;
9
- bucket: string;
10
- };
11
- export declare class S3StorageProvider implements IStorageProvider {
12
- private readonly s3Client;
13
- private readonly bucket;
14
- private readonly multipartChunkSizeInBytes;
15
- constructor(storageAccess: S3ClientConfig);
16
- uploadFile(inputStream: Readable, remotePath: string, contentLength: number, progressListener?: ((total: number, current: number) => void) | undefined): Promise<void>;
17
- private multipartUpload;
18
- deleteObject(remotePath: string): Promise<void>;
19
- downloadFile(remotePath: string, config: DownloadConfig, progressListener?: ((total: number, current: number) => void) | undefined): Promise<Readable>;
20
- listObjects(remotePath: string): Promise<StorageObject[]>;
21
- private getMetadata;
22
- getObjectSize(remotePath: string): Promise<number>;
23
- getLastModified(remotePath: string): Promise<Date>;
24
- }
@@ -1,357 +0,0 @@
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 (g && (g = 0, op[0] && (_ = 0)), _) 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 __asyncValues = (this && this.__asyncValues) || function (o) {
39
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
40
- var m = o[Symbol.asyncIterator], i;
41
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
42
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
43
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
44
- };
45
- Object.defineProperty(exports, "__esModule", { value: true });
46
- exports.S3StorageProvider = void 0;
47
- var aws_sdk_1 = require("aws-sdk");
48
- var S3StorageProvider = /** @class */ (function () {
49
- function S3StorageProvider(storageAccess) {
50
- this.multipartChunkSizeInBytes = 64 * 1024 * 1024; // 64MB
51
- var accessKeyId = storageAccess.accessKeyId, secretAccessKey = storageAccess.secretAccessKey, endpoint = storageAccess.endpoint, bucket = storageAccess.bucket;
52
- if (!accessKeyId)
53
- throw new Error("Access key id is undefined");
54
- if (!secretAccessKey)
55
- throw new Error("Secret access is undefined");
56
- if (!endpoint)
57
- throw new Error("Endpoint is undefined");
58
- if (!bucket)
59
- throw new Error("Bucket is undefined");
60
- this.bucket = bucket;
61
- this.s3Client = new aws_sdk_1.S3({
62
- credentials: {
63
- accessKeyId: accessKeyId,
64
- secretAccessKey: secretAccessKey,
65
- },
66
- endpoint: endpoint,
67
- s3ForcePathStyle: true,
68
- signatureVersion: "v4",
69
- httpOptions: { timeout: 0 },
70
- });
71
- }
72
- S3StorageProvider.prototype.uploadFile = function (inputStream, remotePath, contentLength, progressListener) {
73
- return __awaiter(this, void 0, void 0, function () {
74
- var result;
75
- return __generator(this, function (_a) {
76
- switch (_a.label) {
77
- case 0:
78
- // For performance & cost optimization
79
- // https://docs.storj.io/dcs/api-reference/s3-compatible-gateway/multipart-upload/multipart-part-size
80
- if (inputStream.readableHighWaterMark >= this.multipartChunkSizeInBytes) {
81
- return [2 /*return*/, this.multipartUpload(inputStream, remotePath, contentLength, progressListener)];
82
- }
83
- return [4 /*yield*/, this.s3Client
84
- .putObject({
85
- Body: inputStream,
86
- Bucket: this.bucket,
87
- Key: remotePath,
88
- ContentLength: contentLength,
89
- })
90
- .on("httpUploadProgress", function (_a) {
91
- var total = _a.total, loaded = _a.loaded;
92
- return progressListener === null || progressListener === void 0 ? void 0 : progressListener(total, loaded);
93
- })
94
- .promise()];
95
- case 1:
96
- result = _a.sent();
97
- if (result.$response.error) {
98
- throw result.$response.error;
99
- }
100
- return [2 /*return*/];
101
- }
102
- });
103
- });
104
- };
105
- S3StorageProvider.prototype.multipartUpload = function (inputStream, remotePath, contentLength, progressListener) {
106
- var _a, inputStream_1, inputStream_1_1;
107
- var _b, e_1, _c, _d;
108
- return __awaiter(this, void 0, void 0, function () {
109
- var multipart, totalWritten, partNumber, uploadId, parts, buffer, response, e_1_1, doneParams, uploadingError_1;
110
- return __generator(this, function (_e) {
111
- switch (_e.label) {
112
- case 0: return [4 /*yield*/, this.s3Client
113
- .createMultipartUpload({
114
- Bucket: this.bucket,
115
- Key: remotePath,
116
- })
117
- .promise()];
118
- case 1:
119
- multipart = _e.sent();
120
- if (!multipart.UploadId) {
121
- throw new Error("UploadId property is empty");
122
- }
123
- _e.label = 2;
124
- case 2:
125
- _e.trys.push([2, 19, , 21]);
126
- totalWritten = 0;
127
- partNumber = 0;
128
- uploadId = multipart.UploadId;
129
- parts = [];
130
- _e.label = 3;
131
- case 3:
132
- _e.trys.push([3, 11, 12, 17]);
133
- _a = true, inputStream_1 = __asyncValues(inputStream);
134
- _e.label = 4;
135
- case 4: return [4 /*yield*/, inputStream_1.next()];
136
- case 5:
137
- if (!(inputStream_1_1 = _e.sent(), _b = inputStream_1_1.done, !_b)) return [3 /*break*/, 10];
138
- _d = inputStream_1_1.value;
139
- _a = false;
140
- _e.label = 6;
141
- case 6:
142
- _e.trys.push([6, , 8, 9]);
143
- buffer = _d;
144
- partNumber++;
145
- return [4 /*yield*/, this.s3Client
146
- .uploadPart({
147
- Body: buffer,
148
- Bucket: this.bucket,
149
- Key: remotePath,
150
- UploadId: uploadId,
151
- PartNumber: partNumber,
152
- })
153
- .promise()];
154
- case 7:
155
- response = _e.sent();
156
- parts.push({
157
- ETag: response.ETag,
158
- PartNumber: partNumber,
159
- });
160
- totalWritten += buffer.length;
161
- if (!!progressListener) {
162
- progressListener(contentLength, totalWritten);
163
- }
164
- return [3 /*break*/, 9];
165
- case 8:
166
- _a = true;
167
- return [7 /*endfinally*/];
168
- case 9: return [3 /*break*/, 4];
169
- case 10: return [3 /*break*/, 17];
170
- case 11:
171
- e_1_1 = _e.sent();
172
- e_1 = { error: e_1_1 };
173
- return [3 /*break*/, 17];
174
- case 12:
175
- _e.trys.push([12, , 15, 16]);
176
- if (!(!_a && !_b && (_c = inputStream_1.return))) return [3 /*break*/, 14];
177
- return [4 /*yield*/, _c.call(inputStream_1)];
178
- case 13:
179
- _e.sent();
180
- _e.label = 14;
181
- case 14: return [3 /*break*/, 16];
182
- case 15:
183
- if (e_1) throw e_1.error;
184
- return [7 /*endfinally*/];
185
- case 16: return [7 /*endfinally*/];
186
- case 17:
187
- doneParams = {
188
- Bucket: this.bucket,
189
- Key: remotePath,
190
- UploadId: multipart.UploadId,
191
- MultipartUpload: { Parts: parts },
192
- };
193
- return [4 /*yield*/, this.s3Client.completeMultipartUpload(doneParams).promise()];
194
- case 18:
195
- _e.sent();
196
- return [3 /*break*/, 21];
197
- case 19:
198
- uploadingError_1 = _e.sent();
199
- return [4 /*yield*/, this.s3Client
200
- .abortMultipartUpload({
201
- Bucket: this.bucket,
202
- Key: remotePath,
203
- UploadId: multipart.UploadId,
204
- })
205
- .promise()];
206
- case 20:
207
- _e.sent();
208
- throw uploadingError_1;
209
- case 21: return [2 /*return*/];
210
- }
211
- });
212
- });
213
- };
214
- S3StorageProvider.prototype.deleteObject = function (remotePath) {
215
- return __awaiter(this, void 0, void 0, function () {
216
- var deleteResult;
217
- return __generator(this, function (_a) {
218
- switch (_a.label) {
219
- case 0: return [4 /*yield*/, this.s3Client
220
- .deleteObject({
221
- Bucket: this.bucket,
222
- Key: remotePath,
223
- })
224
- .promise()];
225
- case 1:
226
- deleteResult = _a.sent();
227
- if (deleteResult.$response.error) {
228
- throw deleteResult.$response.error;
229
- }
230
- return [2 /*return*/];
231
- }
232
- });
233
- });
234
- };
235
- S3StorageProvider.prototype.downloadFile = function (remotePath, config, progressListener) {
236
- return __awaiter(this, void 0, void 0, function () {
237
- var getObjectParams, start, end, downloadStream, current, fileBytesSize_1, _a;
238
- return __generator(this, function (_b) {
239
- switch (_b.label) {
240
- case 0:
241
- getObjectParams = {
242
- Bucket: this.bucket,
243
- Key: remotePath,
244
- };
245
- if (config) {
246
- start = config.offset || 0;
247
- end = start + (config.length || 0);
248
- getObjectParams.Range = "bytes=".concat(start, "-").concat(end || "");
249
- }
250
- downloadStream = this.s3Client.getObject(getObjectParams).createReadStream();
251
- current = 0;
252
- if (!progressListener) return [3 /*break*/, 3];
253
- _a = config.length;
254
- if (_a) return [3 /*break*/, 2];
255
- return [4 /*yield*/, this.getObjectSize(remotePath)];
256
- case 1:
257
- _a = (_b.sent());
258
- _b.label = 2;
259
- case 2:
260
- fileBytesSize_1 = _a;
261
- downloadStream.on("data", function (chunk) {
262
- current += chunk.length;
263
- progressListener(fileBytesSize_1, current);
264
- });
265
- _b.label = 3;
266
- case 3: return [2 /*return*/, downloadStream];
267
- }
268
- });
269
- });
270
- };
271
- S3StorageProvider.prototype.listObjects = function (remotePath) {
272
- return __awaiter(this, void 0, void 0, function () {
273
- var prefix, listObjects, result;
274
- return __generator(this, function (_a) {
275
- switch (_a.label) {
276
- case 0:
277
- prefix = remotePath.endsWith("/") ? remotePath : "".concat(remotePath, "/");
278
- return [4 /*yield*/, this.s3Client
279
- .listObjectsV2({
280
- Bucket: this.bucket,
281
- Prefix: prefix,
282
- })
283
- .promise()];
284
- case 1:
285
- listObjects = _a.sent();
286
- if (listObjects.$response.error) {
287
- throw listObjects.$response.error;
288
- }
289
- result = [];
290
- if (listObjects.Contents) {
291
- result = listObjects.Contents.map(function (object) { return ({
292
- name: object.Key || "",
293
- createdAt: object.LastModified || new Date(),
294
- size: object.Size || 0,
295
- }); });
296
- }
297
- return [2 /*return*/, result];
298
- }
299
- });
300
- });
301
- };
302
- S3StorageProvider.prototype.getMetadata = function (remotePath) {
303
- return __awaiter(this, void 0, void 0, function () {
304
- var getObjectParams, metadata;
305
- return __generator(this, function (_a) {
306
- switch (_a.label) {
307
- case 0:
308
- getObjectParams = {
309
- Bucket: this.bucket,
310
- Key: remotePath,
311
- };
312
- return [4 /*yield*/, this.s3Client.headObject(getObjectParams).promise()];
313
- case 1:
314
- metadata = _a.sent();
315
- if (metadata.$response.error) {
316
- throw metadata.$response.error;
317
- }
318
- return [2 /*return*/, metadata];
319
- }
320
- });
321
- });
322
- };
323
- S3StorageProvider.prototype.getObjectSize = function (remotePath) {
324
- return __awaiter(this, void 0, void 0, function () {
325
- var metadata;
326
- return __generator(this, function (_a) {
327
- switch (_a.label) {
328
- case 0: return [4 /*yield*/, this.getMetadata(remotePath)];
329
- case 1:
330
- metadata = _a.sent();
331
- if (metadata.ContentLength === undefined) {
332
- throw new Error("ContentLength property is empty");
333
- }
334
- return [2 /*return*/, metadata.ContentLength || 0];
335
- }
336
- });
337
- });
338
- };
339
- S3StorageProvider.prototype.getLastModified = function (remotePath) {
340
- return __awaiter(this, void 0, void 0, function () {
341
- var metadata;
342
- return __generator(this, function (_a) {
343
- switch (_a.label) {
344
- case 0: return [4 /*yield*/, this.getMetadata(remotePath)];
345
- case 1:
346
- metadata = _a.sent();
347
- if (!metadata.LastModified) {
348
- throw new Error("LastModified property is empty");
349
- }
350
- return [2 /*return*/, metadata.LastModified];
351
- }
352
- });
353
- });
354
- };
355
- return S3StorageProvider;
356
- }());
357
- exports.S3StorageProvider = S3StorageProvider;