@streamflow/stream 10.0.0-alpha.p313.3ce4d29 → 10.0.0-alpha.p313.4470e29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -99,7 +99,7 @@ const solanaInteractParams = {
99
99
 
100
100
  ## Create a Vesting Stream
101
101
 
102
- Vesting Streams are a type of Stream used to linearly unlock a given amount of tokens over a period of time. You can specify the amount, cliff, start time and releasePeriod along with other configuration that controls who can transfer or cancel the contract. For a Stream to be considered Vesting in the Streamflow App it has to match the criteria from the `isVesting` helper function (or `buildStreamType` returns `StreamType.Vesting`). The stream must not allow top-ups, the cliff amount must not be too close to the total amount and it must not be a Dynamic token lock.
102
+ Vesting Streams are a type of Stream used to linearly unlock a given amount of tokens over a period of time. You can specify the amount, cliff, start time and releasePeriod along with other configuration that controls who can transfer or cancel the contract. For a Stream to be considered Vesting in the Streamflow App it has to match the criteria from the `isVesting` helper function (or `buildStreamType` returns `StreamType.Vesting`). The cliff amount must not be too close to the total amount and it must not be a Dynamic token lock.
103
103
 
104
104
  For more details creating a Stream with arbitrary configuration see [General Stream creation](#general-stream-creation).
105
105
  For creating multiple Streams at once see [Create Multiple Streams](#create-multiple-streams-at-once).
@@ -426,7 +426,7 @@ console.log(remaining);
426
426
  ```javascript
427
427
  const data: IGetAllData = {
428
428
  address: "99h00075bKjVg000000tLdk4w42NyG3Mv0000dc0M99",
429
- type: StreamType.All, // StreamType.Vesting, StreamType.Lock, StreamType.Payment
429
+ type: StreamType.All, // StreamType.Vesting, StreamType.Lock
430
430
  direction: StreamDirection.All, // StreamDirection.Outgoing, StreamDirection.Incoming
431
431
  };
432
432
 
@@ -59,11 +59,8 @@ var calculateUnlockedAmount = ({
59
59
  var isCliffCloseToDepositedAmount = (streamData) => {
60
60
  return streamData.cliffAmount.gte(streamData.depositedAmount.sub(new BN3__default.default(1)));
61
61
  };
62
- var isPayment = (streamData) => {
63
- return streamData.canTopup;
64
- };
65
62
  var isVesting = (streamData) => {
66
- return !streamData.canTopup && !isCliffCloseToDepositedAmount(streamData) && !isDynamicLock(streamData.minPrice, streamData.maxPrice, streamData.minPercentage, streamData.maxPercentage);
63
+ return !isCliffCloseToDepositedAmount(streamData) && !isDynamicLock(streamData.minPrice, streamData.maxPrice, streamData.minPercentage, streamData.maxPercentage);
67
64
  };
68
65
  var isAligned = (stream) => {
69
66
  return "minPrice" in stream && "maxPrice" in stream && "minPercentage" in stream && "maxPercentage" in stream;
@@ -78,13 +75,10 @@ var isTokenLock = (streamData) => {
78
75
  return !streamData.canTopup && !streamData.automaticWithdrawal && !streamData.cancelableBySender && !streamData.cancelableByRecipient && !streamData.transferableBySender && (isCliffCloseToDepositedAmount(streamData) || isDynamicLock(streamData.minPrice, streamData.maxPrice, streamData.minPercentage, streamData.maxPercentage));
79
76
  };
80
77
  var buildStreamType = (streamData) => {
81
- if (isVesting(streamData)) {
82
- return "vesting" /* Vesting */;
83
- }
84
78
  if (isTokenLock(streamData)) {
85
79
  return "lock" /* Lock */;
86
80
  }
87
- return "payment" /* Payment */;
81
+ return "vesting" /* Vesting */;
88
82
  };
89
83
  var decodeEndTime = (endTime) => {
90
84
  if (endTime.gt(new BN3__default.default(MAX_SAFE_UNIX_TIME_VALUE))) {
@@ -101,7 +95,6 @@ var StreamDirection = /* @__PURE__ */ ((StreamDirection2) => {
101
95
  })(StreamDirection || {});
102
96
  var StreamType = /* @__PURE__ */ ((StreamType2) => {
103
97
  StreamType2["All"] = "all";
104
- StreamType2["Payment"] = "payment";
105
98
  StreamType2["Vesting"] = "vesting";
106
99
  StreamType2["Lock"] = "lock";
107
100
  return StreamType2;
@@ -3598,10 +3591,20 @@ var SolanaStreamClient = class {
3598
3591
  const accounts = await this.connection.getProgramAccounts(this.programId, {
3599
3592
  filters
3600
3593
  });
3601
- return accounts.map(({ pubkey, account }) => ({
3602
- publicKey: pubkey,
3603
- account: new Contract(decodeStream(account.data))
3604
- }));
3594
+ const mapped = await Promise.all(
3595
+ accounts.map(async ({ pubkey, account }) => {
3596
+ const stream = decodeStream(account.data);
3597
+ if (this.isAlignedUnlock(pubkey, stream.sender)) {
3598
+ const alignedProxy = await this.alignedProxyProgram.account.contract.fetch(
3599
+ deriveContractPDA(this.alignedProxyProgram.programId, pubkey)
3600
+ );
3601
+ common.invariant(alignedProxy, "Couldn't get aligned proxy account info");
3602
+ return { publicKey: pubkey, account: new AlignedContract(stream, alignedProxy) };
3603
+ }
3604
+ return { publicKey: pubkey, account: new Contract(stream) };
3605
+ })
3606
+ );
3607
+ return mapped;
3605
3608
  }
3606
3609
  /**
3607
3610
  * Attempts updating the stream auto withdrawal params and amount per period
@@ -4247,7 +4250,6 @@ exports.isAligned = isAligned;
4247
4250
  exports.isCliffCloseToDepositedAmount = isCliffCloseToDepositedAmount;
4248
4251
  exports.isCreateAlignedStreamData = isCreateAlignedStreamData;
4249
4252
  exports.isDynamicLock = isDynamicLock;
4250
- exports.isPayment = isPayment;
4251
4253
  exports.isTokenLock = isTokenLock;
4252
4254
  exports.isVesting = isVesting;
4253
4255
  exports.sendAndConfirmStreamRawTransaction = sendAndConfirmStreamRawTransaction;