@streamflow/stream 5.2.0 → 5.2.2

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.
@@ -12,16 +12,33 @@ interface ICalculateUnlockedAmount {
12
12
  fundsUnlockedAtLastRateChange: BN;
13
13
  }
14
14
  export declare const calculateUnlockedAmount: ({ depositedAmount, cliff, cliffAmount, end, currentTimestamp, lastRateChangeTime, period, amountPerPeriod, fundsUnlockedAtLastRateChange, }: ICalculateUnlockedAmount) => BN;
15
+ export declare const isCliffCloseToDepositedAmount: (streamData: {
16
+ depositedAmount: BN;
17
+ cliffAmount: BN;
18
+ }) => boolean;
15
19
  export declare const isPayment: (streamData: {
16
20
  canTopup: boolean;
17
21
  }) => boolean;
22
+ export declare const isVesting: (streamData: {
23
+ canTopup: boolean;
24
+ }) => boolean;
18
25
  export declare const isTokenLock: (streamData: {
19
26
  canTopup: boolean;
27
+ automaticWithdrawal: boolean;
28
+ cancelableBySender: boolean;
29
+ cancelableByRecipient: boolean;
30
+ transferableBySender: boolean;
31
+ transferableByRecipient: boolean;
20
32
  depositedAmount: BN;
21
33
  cliffAmount: BN;
22
34
  }) => boolean;
23
35
  export declare const buildStreamType: (streamData: {
24
36
  canTopup: boolean;
37
+ automaticWithdrawal: boolean;
38
+ cancelableBySender: boolean;
39
+ cancelableByRecipient: boolean;
40
+ transferableBySender: boolean;
41
+ transferableByRecipient: boolean;
25
42
  depositedAmount: BN;
26
43
  cliffAmount: BN;
27
44
  }) => StreamType;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.buildStreamType = exports.isTokenLock = exports.isPayment = exports.calculateUnlockedAmount = void 0;
6
+ exports.buildStreamType = exports.isTokenLock = exports.isVesting = exports.isPayment = exports.isCliffCloseToDepositedAmount = exports.calculateUnlockedAmount = void 0;
7
7
  var bn_js_1 = __importDefault(require("bn.js"));
8
8
  var types_1 = require("./types");
9
9
  var calculateUnlockedAmount = function (_a) {
@@ -21,21 +21,35 @@ var calculateUnlockedAmount = function (_a) {
21
21
  return streamed.lt(deposited) ? streamed : deposited;
22
22
  };
23
23
  exports.calculateUnlockedAmount = calculateUnlockedAmount;
24
+ var isCliffCloseToDepositedAmount = function (streamData) {
25
+ return streamData.cliffAmount.gte(streamData.depositedAmount.sub(new bn_js_1.default("1")));
26
+ };
27
+ exports.isCliffCloseToDepositedAmount = isCliffCloseToDepositedAmount;
24
28
  var isPayment = function (streamData) {
25
29
  return streamData.canTopup;
26
30
  };
27
31
  exports.isPayment = isPayment;
32
+ var isVesting = function (streamData) {
33
+ return !streamData.canTopup && !exports.isCliffCloseToDepositedAmount;
34
+ };
35
+ exports.isVesting = isVesting;
28
36
  var isTokenLock = function (streamData) {
29
- return (!streamData.canTopup && streamData.cliffAmount.gte(streamData.depositedAmount.sub(new bn_js_1.default("1"))));
37
+ return (!streamData.canTopup &&
38
+ !streamData.automaticWithdrawal &&
39
+ !streamData.cancelableBySender &&
40
+ !streamData.cancelableByRecipient &&
41
+ !streamData.transferableBySender &&
42
+ !streamData.transferableByRecipient &&
43
+ (0, exports.isCliffCloseToDepositedAmount)(streamData));
30
44
  };
31
45
  exports.isTokenLock = isTokenLock;
32
46
  var buildStreamType = function (streamData) {
33
- if ((0, exports.isPayment)(streamData)) {
34
- return types_1.StreamType.Payment;
47
+ if ((0, exports.isVesting)(streamData)) {
48
+ return types_1.StreamType.Vesting;
35
49
  }
36
50
  if ((0, exports.isTokenLock)(streamData)) {
37
51
  return types_1.StreamType.Lock;
38
52
  }
39
- return types_1.StreamType.Vesting;
53
+ return types_1.StreamType.Payment;
40
54
  };
41
55
  exports.buildStreamType = buildStreamType;
@@ -218,7 +218,7 @@ var SuiStreamClient = /** @class */ (function (_super) {
218
218
  txb.object(withdrawData.id),
219
219
  txb.object(this.configId),
220
220
  txb.object(utils_1.SUI_CLOCK_OBJECT_ID),
221
- txb.pure(withdrawData.amount),
221
+ txb.pure(withdrawData.amount.toString()),
222
222
  ],
223
223
  });
224
224
  return [4 /*yield*/, wallet.signAndExecuteTransactionBlock({
@@ -322,7 +322,7 @@ var SuiStreamClient = /** @class */ (function (_super) {
322
322
  txb.object(this.configId),
323
323
  coinObject,
324
324
  txb.gas,
325
- txb.pure(topupData.amount),
325
+ txb.pure(topupData.amount.toString()),
326
326
  ],
327
327
  });
328
328
  this.returnSplittedCoinObject(txb, tokenId, coins, coinObject);
@@ -398,8 +398,10 @@ var SuiStreamClient = /** @class */ (function (_super) {
398
398
  txb.pure(updateData.enableAutomaticWithdrawal !== undefined
399
399
  ? [updateData.enableAutomaticWithdrawal]
400
400
  : [], "vector<bool>"),
401
- txb.pure(updateData.withdrawFrequency !== undefined ? [updateData.withdrawFrequency] : [], "vector<u64>"),
402
- txb.pure(updateData.amountPerPeriod !== undefined ? [updateData.amountPerPeriod] : [], "vector<u64>"),
401
+ txb.pure(updateData.withdrawFrequency !== undefined
402
+ ? [updateData.withdrawFrequency.toString()]
403
+ : [], "vector<u64>"),
404
+ txb.pure(updateData.amountPerPeriod !== undefined ? [updateData.amountPerPeriod.toString()] : [], "vector<u64>"),
403
405
  ],
404
406
  });
405
407
  return [4 /*yield*/, wallet.signAndExecuteTransactionBlock({
@@ -447,11 +449,11 @@ var SuiStreamClient = /** @class */ (function (_super) {
447
449
  txb.object(utils_1.SUI_CLOCK_OBJECT_ID),
448
450
  coinObject,
449
451
  txb.gas,
450
- txb.pure(recipient.amount),
452
+ txb.pure(recipient.amount.toString()),
451
453
  txb.pure(multipleStreamData.period),
452
- txb.pure(recipient.amountPerPeriod),
454
+ txb.pure(recipient.amountPerPeriod.toString()),
453
455
  txb.pure(multipleStreamData.start),
454
- txb.pure(recipient.cliffAmount),
456
+ txb.pure(recipient.cliffAmount.toString()),
455
457
  txb.pure(multipleStreamData.cancelableBySender),
456
458
  txb.pure(multipleStreamData.cancelableByRecipient),
457
459
  txb.pure(multipleStreamData.cancelableBySender),
@@ -524,7 +526,7 @@ var SuiStreamClient = /** @class */ (function (_super) {
524
526
  txb.mergeCoins(coinObject, coins.slice(1).map(function (item) { return txb.object(item.coinObjectId); }));
525
527
  }
526
528
  var sum = amount.mul(new bn_js_1.default(constants_1.BASE_FEE)).div(new bn_js_1.default(1000000));
527
- return txb.splitCoins(coinObject, [txb.pure(sum)])[0];
529
+ return txb.splitCoins(coinObject, [txb.pure(sum.toString())])[0];
528
530
  };
529
531
  /**
530
532
  * Return previously splitted Coin Object to owner and merge it to to rebate storage fees
package/dist/sui/types.js CHANGED
@@ -119,8 +119,7 @@ var Contract = /** @class */ (function () {
119
119
  this.transferableBySender = meta.transferable_by_sender;
120
120
  this.transferableByRecipient = meta.transferable_by_recipient;
121
121
  this.canTopup = meta.can_topup;
122
- var name = String.fromCharCode.apply(String, __spreadArray([], __read(meta.contract_name), false));
123
- this.name = Buffer.from(name, "hex").toString("utf8");
122
+ this.name = String.fromCharCode.apply(String, __spreadArray([], __read(meta.contract_name), false));
124
123
  this.withdrawalFrequency = parseInt(meta.withdrawal_frequency);
125
124
  this.closed = stream.closed;
126
125
  this.currentPauseStart = parseInt(stream.current_pause_start);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamflow/stream",
3
- "version": "5.2.0",
3
+ "version": "5.2.2",
4
4
  "description": "JavaScript SDK to interact with Streamflow protocol.",
5
5
  "main": "dist/index.js",
6
6
  "homepage": "https://github.com/streamflow-finance/js-sdk/",