@streamflow/stream 7.0.0-alpha.2 → 7.0.0-alpha.5

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 (38) hide show
  1. package/dist/cjs/__tests__/aptos/streamClient.spec.js +83 -134
  2. package/dist/cjs/__tests__/common/GenericStreamClient.spec.js +9 -9
  3. package/dist/cjs/aptos/StreamClient.js +162 -367
  4. package/dist/cjs/aptos/constants.js +7 -8
  5. package/dist/cjs/aptos/index.js +3 -3
  6. package/dist/cjs/aptos/types.js +17 -26
  7. package/dist/cjs/aptos/utils.js +4 -4
  8. package/dist/cjs/aptos/wallet.js +20 -75
  9. package/dist/cjs/common/BaseStreamClient.js +11 -59
  10. package/dist/cjs/common/GenericStreamClient.js +46 -72
  11. package/dist/cjs/common/constants.js +1 -1
  12. package/dist/cjs/common/contractUtils.js +12 -13
  13. package/dist/cjs/common/utils.js +21 -66
  14. package/dist/cjs/evm/StreamClient.js +198 -456
  15. package/dist/cjs/evm/constants.js +19 -20
  16. package/dist/cjs/evm/types.js +14 -23
  17. package/dist/cjs/evm/utils.js +2 -2
  18. package/dist/cjs/index.js +10 -10
  19. package/dist/cjs/solana/StreamClient.js +592 -1090
  20. package/dist/cjs/solana/constants.js +9 -10
  21. package/dist/cjs/solana/instructions.js +60 -65
  22. package/dist/cjs/solana/layout.js +7 -8
  23. package/dist/cjs/solana/types.js +14 -24
  24. package/dist/cjs/solana/utils.js +48 -136
  25. package/dist/cjs/sui/StreamClient.js +325 -571
  26. package/dist/cjs/sui/constants.js +19 -20
  27. package/dist/cjs/sui/types.js +17 -51
  28. package/dist/cjs/sui/utils.js +7 -7
  29. package/dist/cjs/sui/wallet.js +13 -63
  30. package/dist/esm/__tests__/aptos/streamClient.spec.js +1 -1
  31. package/dist/esm/aptos/index.d.ts +3 -3
  32. package/dist/esm/aptos/index.js +3 -3
  33. package/dist/esm/common/GenericStreamClient.d.ts +4 -4
  34. package/dist/esm/common/GenericStreamClient.js +4 -4
  35. package/dist/esm/common/types.d.ts +1 -1
  36. package/dist/esm/index.d.ts +9 -9
  37. package/dist/esm/index.js +9 -9
  38. package/package.json +4 -4
@@ -1,27 +1,16 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
4
  };
16
5
  Object.defineProperty(exports, "__esModule", { value: true });
17
6
  exports.Contract = void 0;
18
- var bignumber_js_1 = __importDefault(require("bignumber.js"));
19
- var buffer_1 = require("buffer");
20
- var contractUtils_js_1 = require("../common/contractUtils.js");
21
- var utils_js_1 = require("./utils.js");
22
- var utils_js_2 = require("../common/utils.js");
23
- var Contract = /** @class */ (function () {
24
- function Contract(stream, tokenId) {
7
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
8
+ const buffer_1 = require("buffer");
9
+ const contractUtils_js_1 = require("../common/contractUtils.js");
10
+ const utils_js_1 = require("./utils.js");
11
+ const utils_js_2 = require("../common/utils.js");
12
+ class Contract {
13
+ constructor(stream, tokenId) {
25
14
  this.magic = 0;
26
15
  this.version = 0;
27
16
  this.createdAt = parseInt(stream.created);
@@ -57,7 +46,7 @@ var Contract = /** @class */ (function () {
57
46
  this.transferableBySender = stream.meta.transferable_by_sender;
58
47
  this.transferableByRecipient = stream.meta.transferable_by_recipient;
59
48
  this.canTopup = stream.meta.can_topup;
60
- var name = stream.meta.contract_name.replace("0x", "");
49
+ const name = stream.meta.contract_name.replace("0x", "");
61
50
  this.name = buffer_1.Buffer.from(name, "hex").toString("utf8");
62
51
  this.withdrawalFrequency = parseInt(stream.meta.withdrawal_frequency);
63
52
  this.closed = stream.closed;
@@ -67,12 +56,14 @@ var Contract = /** @class */ (function () {
67
56
  this.fundsUnlockedAtLastRateChange = (0, bignumber_js_1.default)(stream.funds_unlocked_at_last_rate_change);
68
57
  this.type = (0, contractUtils_js_1.buildStreamType)(this);
69
58
  }
70
- Contract.prototype.unlocked = function (currentTimestamp) {
71
- return (0, contractUtils_js_1.calculateUnlockedAmount)(__assign(__assign({}, this), { currentTimestamp: currentTimestamp }));
72
- };
73
- Contract.prototype.remaining = function (decimals) {
59
+ unlocked(currentTimestamp) {
60
+ return (0, contractUtils_js_1.calculateUnlockedAmount)({
61
+ ...this,
62
+ currentTimestamp,
63
+ });
64
+ }
65
+ remaining(decimals) {
74
66
  return (0, utils_js_2.getNumberFromBigNumber)(this.depositedAmount.minus(this.withdrawnAmount), decimals);
75
- };
76
- return Contract;
77
- }());
67
+ }
68
+ }
78
69
  exports.Contract = Contract;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeAptosAddress = exports.extractAptosErrorCode = void 0;
4
- var constants_js_1 = require("./constants.js");
4
+ const constants_js_1 = require("./constants.js");
5
5
  function extractAptosErrorCode(errorText) {
6
- var match = constants_js_1.APTOS_ERROR_MATCH_REGEX.exec(errorText);
6
+ const match = constants_js_1.APTOS_ERROR_MATCH_REGEX.exec(errorText);
7
7
  if (!match) {
8
8
  return null;
9
9
  }
@@ -25,11 +25,11 @@ function normalizeAptosAddress(address) {
25
25
  if (isAddressSpecial(address)) {
26
26
  return address;
27
27
  }
28
- var length = address.length;
28
+ const length = address.length;
29
29
  if (length === 66 || length < 3) {
30
30
  return address;
31
31
  }
32
- var missingZeros = 66 - length;
32
+ const missingZeros = 66 - length;
33
33
  return address.slice(0, 2) + "0".repeat(missingZeros) + address.slice(2);
34
34
  }
35
35
  exports.normalizeAptosAddress = normalizeAptosAddress;
@@ -1,45 +1,9 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
39
3
  exports.AptosWalletWrapper = void 0;
40
- var aptos_1 = require("aptos");
41
- var AptosWalletWrapper = /** @class */ (function () {
42
- function AptosWalletWrapper(wallet, client) {
4
+ const aptos_1 = require("aptos");
5
+ class AptosWalletWrapper {
6
+ constructor(wallet, client) {
43
7
  this.client = client;
44
8
  this.wallet = wallet;
45
9
  if (wallet instanceof aptos_1.AptosAccount) {
@@ -49,41 +13,22 @@ var AptosWalletWrapper = /** @class */ (function () {
49
13
  this.address = wallet.account.address;
50
14
  }
51
15
  }
52
- AptosWalletWrapper.prototype.signAndSubmitTransaction = function (input) {
53
- return __awaiter(this, void 0, void 0, function () {
54
- var builder, rawTxn, res, signedTx, tx;
55
- return __generator(this, function (_a) {
56
- switch (_a.label) {
57
- case 0:
58
- if (!(this.wallet instanceof aptos_1.AptosAccount)) return [3 /*break*/, 6];
59
- builder = new aptos_1.TransactionBuilderRemoteABI(this.client, {
60
- sender: this.address,
61
- });
62
- return [4 /*yield*/, builder.build(input.function, input.type_arguments, input.arguments)];
63
- case 1:
64
- rawTxn = _a.sent();
65
- return [4 /*yield*/, this.client.simulateTransaction(this.wallet, rawTxn)];
66
- case 2:
67
- res = _a.sent();
68
- if (!res[0].success) {
69
- throw new Error("Transaction Simulation failed: ".concat(JSON.stringify(res)));
70
- }
71
- return [4 /*yield*/, this.client.signTransaction(this.wallet, rawTxn)];
72
- case 3:
73
- signedTx = _a.sent();
74
- return [4 /*yield*/, this.client.submitSignedBCSTransaction(signedTx)];
75
- case 4:
76
- tx = _a.sent();
77
- return [4 /*yield*/, this.client.waitForTransaction(tx.hash)];
78
- case 5:
79
- _a.sent();
80
- return [2 /*return*/, tx.hash];
81
- case 6: return [4 /*yield*/, this.wallet.signAndSubmitTransaction(input)];
82
- case 7: return [2 /*return*/, (_a.sent()).hash];
83
- }
16
+ async signAndSubmitTransaction(input) {
17
+ if (this.wallet instanceof aptos_1.AptosAccount) {
18
+ const builder = new aptos_1.TransactionBuilderRemoteABI(this.client, {
19
+ sender: this.address,
84
20
  });
85
- });
86
- };
87
- return AptosWalletWrapper;
88
- }());
21
+ const rawTxn = await builder.build(input.function, input.type_arguments, input.arguments);
22
+ const res = await this.client.simulateTransaction(this.wallet, rawTxn);
23
+ if (!res[0].success) {
24
+ throw new Error(`Transaction Simulation failed: ${JSON.stringify(res)}`);
25
+ }
26
+ const signedTx = await this.client.signTransaction(this.wallet, rawTxn);
27
+ const tx = await this.client.submitSignedBCSTransaction(signedTx);
28
+ await this.client.waitForTransaction(tx.hash);
29
+ return tx.hash;
30
+ }
31
+ return (await this.wallet.signAndSubmitTransaction(input)).hash;
32
+ }
33
+ }
89
34
  exports.AptosWalletWrapper = AptosWalletWrapper;
@@ -1,71 +1,23 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
39
3
  exports.BaseStreamClient = void 0;
40
- var BaseStreamClient = /** @class */ (function () {
41
- function BaseStreamClient() {
42
- }
4
+ class BaseStreamClient {
43
5
  /**
44
6
  * Returns total fee percent, streamflow fees + partner fees
45
7
  * @param getFeesData structure with address for which we need to derive fee, either sender or partner usually
46
8
  * @param chainSpecificParams additional parameters required by chain client
47
9
  * @returns fee as floating number, so if fee is 0.99%, it will return 0.99
48
10
  */
49
- BaseStreamClient.prototype.getTotalFee = function (getFeesData, chainSpecificParams) {
50
- return __awaiter(this, void 0, void 0, function () {
51
- var fees;
52
- return __generator(this, function (_a) {
53
- switch (_a.label) {
54
- case 0: return [4 /*yield*/, this.getFees(getFeesData, chainSpecificParams)];
55
- case 1:
56
- fees = _a.sent();
57
- if (fees) {
58
- return [2 /*return*/, fees.partnerFee + fees.streamflowFee];
59
- }
60
- return [2 /*return*/, this.getDefaultStreamflowFee(chainSpecificParams)];
61
- }
62
- });
63
- });
64
- };
11
+ async getTotalFee(getFeesData, chainSpecificParams) {
12
+ const fees = await this.getFees(getFeesData, chainSpecificParams);
13
+ if (fees) {
14
+ return fees.partnerFee + fees.streamflowFee;
15
+ }
16
+ return this.getDefaultStreamflowFee(chainSpecificParams);
17
+ }
65
18
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
66
- BaseStreamClient.prototype.extractErrorCode = function (err) {
19
+ extractErrorCode(err) {
67
20
  return null;
68
- };
69
- return BaseStreamClient;
70
- }());
21
+ }
22
+ }
71
23
  exports.BaseStreamClient = BaseStreamClient;
@@ -1,128 +1,102 @@
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
  Object.defineProperty(exports, "__esModule", { value: true });
18
- var BaseStreamClient_js_1 = require("./BaseStreamClient.js");
19
- var types_js_1 = require("./types.js");
20
- var utils_js_1 = require("./utils.js");
21
- var aptos_1 = require("../aptos");
22
- var evm_1 = require("../evm");
23
- var solana_1 = require("../solana");
24
- var sui_1 = require("../sui");
25
- var constants_js_1 = require("./constants.js");
3
+ const BaseStreamClient_js_1 = require("./BaseStreamClient.js");
4
+ const types_js_1 = require("./types.js");
5
+ const utils_js_1 = require("./utils.js");
6
+ const index_js_1 = require("../aptos/index.js");
7
+ const index_js_2 = require("../evm/index.js");
8
+ const index_js_3 = require("../solana/index.js");
9
+ const index_js_4 = require("../sui/index.js");
10
+ const constants_js_1 = require("./constants.js");
26
11
  /** Generic Stream Client implementation that wrap Chain Client methods and enriches error messages if possible
27
12
  * @property {StreamClientType} - Chain Client implementation
28
13
  * @property {chain} - Chain
29
14
  */
30
- var GenericStreamClient = /** @class */ (function (_super) {
31
- __extends(GenericStreamClient, _super);
32
- function GenericStreamClient(options) {
33
- var _this = _super.call(this) || this;
34
- _this.chain = options.chain;
15
+ class GenericStreamClient extends BaseStreamClient_js_1.BaseStreamClient {
16
+ constructor(options) {
17
+ super();
18
+ this.chain = options.chain;
35
19
  switch (options.chain) {
36
20
  case types_js_1.IChain.Solana:
37
- _this.nativeStreamClient = new solana_1.SolanaStreamClient(options.clusterUrl, options.cluster, options.commitment, options.programId, options.sendRate, options.sendThrottler);
21
+ this.nativeStreamClient = new index_js_3.SolanaStreamClient(options.clusterUrl, options.cluster, options.commitment, options.programId, options.sendRate, options.sendThrottler);
38
22
  break;
39
23
  case types_js_1.IChain.Aptos:
40
- _this.nativeStreamClient = new aptos_1.AptosStreamClient(options.clusterUrl, options.cluster, options.maxGas, options.programId);
24
+ this.nativeStreamClient = new index_js_1.AptosStreamClient(options.clusterUrl, options.cluster, options.maxGas, options.programId);
41
25
  break;
42
26
  case types_js_1.IChain.BNB:
43
27
  case types_js_1.IChain.Ethereum:
44
28
  case types_js_1.IChain.Polygon:
45
- _this.nativeStreamClient = new evm_1.EvmStreamClient(options.clusterUrl, options.chain, options.signer, options.cluster, options.programId);
29
+ this.nativeStreamClient = new index_js_2.EvmStreamClient(options.clusterUrl, options.chain, options.signer, options.cluster, options.programId);
46
30
  break;
47
31
  case types_js_1.IChain.Sui:
48
- _this.nativeStreamClient = new sui_1.SuiStreamClient(options.clusterUrl, options.cluster, options.ids);
32
+ this.nativeStreamClient = new index_js_4.SuiStreamClient(options.clusterUrl, options.cluster, options.ids);
49
33
  }
50
- return _this;
51
34
  }
52
35
  /**
53
36
  * Creates a new stream/vesting contract.
54
37
  */
55
- GenericStreamClient.prototype.create = function (streamData, chainSpecificParams) {
56
- var _this = this;
57
- return (0, utils_js_1.handleContractError)(function () { return _this.nativeStreamClient.create(streamData, chainSpecificParams); }, this.nativeStreamClient.extractErrorCode);
58
- };
38
+ create(streamData, chainSpecificParams) {
39
+ return (0, utils_js_1.handleContractError)(() => this.nativeStreamClient.create(streamData, chainSpecificParams), this.nativeStreamClient.extractErrorCode);
40
+ }
59
41
  /**
60
42
  * Creates multiple stream/vesting contracts.
61
43
  */
62
- GenericStreamClient.prototype.createMultiple = function (multipleStreamData, chainSpecificParams) {
63
- var _this = this;
64
- return (0, utils_js_1.handleContractError)(function () { return _this.nativeStreamClient.createMultiple(multipleStreamData, chainSpecificParams); }, this.nativeStreamClient.extractErrorCode);
65
- };
44
+ createMultiple(multipleStreamData, chainSpecificParams) {
45
+ return (0, utils_js_1.handleContractError)(() => this.nativeStreamClient.createMultiple(multipleStreamData, chainSpecificParams), this.nativeStreamClient.extractErrorCode);
46
+ }
66
47
  /**
67
48
  * Attempts withdrawing from the specified stream.
68
49
  */
69
- GenericStreamClient.prototype.withdraw = function (_a, chainSpecificParams) {
70
- var _this = this;
71
- var id = _a.id, _b = _a.amount, amount = _b === void 0 ? constants_js_1.WITHDRAW_AVAILABLE_AMOUNT : _b;
72
- return (0, utils_js_1.handleContractError)(function () { return _this.nativeStreamClient.withdraw({ id: id, amount: amount }, chainSpecificParams); }, this.nativeStreamClient.extractErrorCode);
73
- };
50
+ withdraw({ id, amount = constants_js_1.WITHDRAW_AVAILABLE_AMOUNT }, chainSpecificParams) {
51
+ return (0, utils_js_1.handleContractError)(() => this.nativeStreamClient.withdraw({ id, amount }, chainSpecificParams), this.nativeStreamClient.extractErrorCode);
52
+ }
74
53
  /**
75
54
  * Attempts canceling the specified stream.
76
55
  */
77
- GenericStreamClient.prototype.cancel = function (cancelData, chainSpecificParams) {
78
- var _this = this;
79
- return (0, utils_js_1.handleContractError)(function () { return _this.nativeStreamClient.cancel(cancelData, chainSpecificParams); }, this.nativeStreamClient.extractErrorCode);
80
- };
56
+ cancel(cancelData, chainSpecificParams) {
57
+ return (0, utils_js_1.handleContractError)(() => this.nativeStreamClient.cancel(cancelData, chainSpecificParams), this.nativeStreamClient.extractErrorCode);
58
+ }
81
59
  /**
82
60
  * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
83
61
  */
84
- GenericStreamClient.prototype.transfer = function (transferData, chainSpecificParams) {
85
- var _this = this;
86
- return (0, utils_js_1.handleContractError)(function () { return _this.nativeStreamClient.transfer(transferData, chainSpecificParams); }, this.nativeStreamClient.extractErrorCode);
87
- };
62
+ transfer(transferData, chainSpecificParams) {
63
+ return (0, utils_js_1.handleContractError)(() => this.nativeStreamClient.transfer(transferData, chainSpecificParams), this.nativeStreamClient.extractErrorCode);
64
+ }
88
65
  /**
89
66
  * Tops up stream account with specified amount.
90
67
  */
91
- GenericStreamClient.prototype.topup = function (topupData, chainSpecificParams) {
92
- var _this = this;
93
- return (0, utils_js_1.handleContractError)(function () { return _this.nativeStreamClient.topup(topupData, chainSpecificParams); }, this.nativeStreamClient.extractErrorCode);
94
- };
68
+ topup(topupData, chainSpecificParams) {
69
+ return (0, utils_js_1.handleContractError)(() => this.nativeStreamClient.topup(topupData, chainSpecificParams), this.nativeStreamClient.extractErrorCode);
70
+ }
95
71
  /**
96
72
  * Fetch stream data by its id (address).
97
73
  */
98
- GenericStreamClient.prototype.getOne = function (getOneData) {
74
+ getOne(getOneData) {
99
75
  return this.nativeStreamClient.getOne(getOneData);
100
- };
76
+ }
101
77
  /**
102
78
  * Fetch streams by sender or recipient address.
103
79
  */
104
- GenericStreamClient.prototype.get = function (getAllData) {
80
+ get(getAllData) {
105
81
  return this.nativeStreamClient.get(getAllData);
106
- };
82
+ }
107
83
  /**
108
84
  * Attempts updating the stream auto withdrawal params and amount per period
109
85
  */
110
- GenericStreamClient.prototype.update = function (updateData, chainSpecificParams) {
111
- var _this = this;
112
- return (0, utils_js_1.handleContractError)(function () { return _this.nativeStreamClient.update(updateData, chainSpecificParams); }, this.nativeStreamClient.extractErrorCode);
113
- };
86
+ update(updateData, chainSpecificParams) {
87
+ return (0, utils_js_1.handleContractError)(() => this.nativeStreamClient.update(updateData, chainSpecificParams), this.nativeStreamClient.extractErrorCode);
88
+ }
114
89
  /**
115
90
  * Returns streamflow and partner fees for the specific wallet in %
116
91
  */
117
- GenericStreamClient.prototype.getFees = function (getFeesData) {
92
+ getFees(getFeesData) {
118
93
  return this.nativeStreamClient.getFees(getFeesData);
119
- };
94
+ }
120
95
  /**
121
96
  * Returns default Streamflow Fee in %
122
97
  */
123
- GenericStreamClient.prototype.getDefaultStreamflowFee = function () {
98
+ getDefaultStreamflowFee() {
124
99
  return this.nativeStreamClient.getDefaultStreamflowFee();
125
- };
126
- return GenericStreamClient;
127
- }(BaseStreamClient_js_1.BaseStreamClient));
100
+ }
101
+ }
128
102
  exports.default = GenericStreamClient;
@@ -4,6 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.WITHDRAW_AVAILABLE_AMOUNT = exports.BASE_FEE = void 0;
7
- var bignumber_js_1 = __importDefault(require("bignumber.js"));
7
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
8
8
  exports.BASE_FEE = 1009900; // Buffer to include usual fees when calculating stream amount
9
9
  exports.WITHDRAW_AVAILABLE_AMOUNT = (0, bignumber_js_1.default)("18446744073709551615"); // Magical number to withdraw all available amount from a Contract
@@ -4,36 +4,35 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.buildStreamType = exports.isTokenLock = exports.isVesting = exports.isPayment = exports.isCliffCloseToDepositedAmount = exports.calculateUnlockedAmount = void 0;
7
- var bignumber_js_1 = __importDefault(require("bignumber.js"));
8
- var types_js_1 = require("./types.js");
9
- var calculateUnlockedAmount = function (_a) {
10
- var depositedAmount = _a.depositedAmount, cliff = _a.cliff, cliffAmount = _a.cliffAmount, end = _a.end, currentTimestamp = _a.currentTimestamp, lastRateChangeTime = _a.lastRateChangeTime, period = _a.period, amountPerPeriod = _a.amountPerPeriod, fundsUnlockedAtLastRateChange = _a.fundsUnlockedAtLastRateChange;
11
- var deposited = depositedAmount;
7
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
8
+ const types_js_1 = require("./types.js");
9
+ const calculateUnlockedAmount = ({ depositedAmount, cliff, cliffAmount, end, currentTimestamp, lastRateChangeTime, period, amountPerPeriod, fundsUnlockedAtLastRateChange, }) => {
10
+ const deposited = depositedAmount;
12
11
  if (currentTimestamp < cliff)
13
12
  return (0, bignumber_js_1.default)(0);
14
13
  if (currentTimestamp > end)
15
14
  return deposited;
16
- var savedUnlockedFunds = lastRateChangeTime === 0 ? cliffAmount : fundsUnlockedAtLastRateChange;
17
- var savedUnlockedFundsTime = lastRateChangeTime === 0 ? cliff : lastRateChangeTime;
18
- var streamed = (0, bignumber_js_1.default)(Math.floor((currentTimestamp - savedUnlockedFundsTime) / period))
15
+ const savedUnlockedFunds = lastRateChangeTime === 0 ? cliffAmount : fundsUnlockedAtLastRateChange;
16
+ const savedUnlockedFundsTime = lastRateChangeTime === 0 ? cliff : lastRateChangeTime;
17
+ const streamed = (0, bignumber_js_1.default)(Math.floor((currentTimestamp - savedUnlockedFundsTime) / period))
19
18
  .times(amountPerPeriod)
20
19
  .plus(savedUnlockedFunds);
21
20
  return streamed.lt(deposited) ? streamed : deposited;
22
21
  };
23
22
  exports.calculateUnlockedAmount = calculateUnlockedAmount;
24
- var isCliffCloseToDepositedAmount = function (streamData) {
23
+ const isCliffCloseToDepositedAmount = (streamData) => {
25
24
  return streamData.cliffAmount.gte(streamData.depositedAmount.minus((0, bignumber_js_1.default)(1)));
26
25
  };
27
26
  exports.isCliffCloseToDepositedAmount = isCliffCloseToDepositedAmount;
28
- var isPayment = function (streamData) {
27
+ const isPayment = (streamData) => {
29
28
  return streamData.canTopup;
30
29
  };
31
30
  exports.isPayment = isPayment;
32
- var isVesting = function (streamData) {
31
+ const isVesting = (streamData) => {
33
32
  return !streamData.canTopup && !(0, exports.isCliffCloseToDepositedAmount)(streamData);
34
33
  };
35
34
  exports.isVesting = isVesting;
36
- var isTokenLock = function (streamData) {
35
+ const isTokenLock = (streamData) => {
37
36
  return (!streamData.canTopup &&
38
37
  !streamData.automaticWithdrawal &&
39
38
  !streamData.cancelableBySender &&
@@ -43,7 +42,7 @@ var isTokenLock = function (streamData) {
43
42
  (0, exports.isCliffCloseToDepositedAmount)(streamData));
44
43
  };
45
44
  exports.isTokenLock = isTokenLock;
46
- var buildStreamType = function (streamData) {
45
+ const buildStreamType = (streamData) => {
47
46
  if ((0, exports.isVesting)(streamData)) {
48
47
  return types_js_1.StreamType.Vesting;
49
48
  }