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

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 (78) hide show
  1. package/README.md +70 -67
  2. package/dist/cjs/__tests__/aptos/streamClient.spec.js +83 -134
  3. package/dist/cjs/__tests__/common/GenericStreamClient.spec.js +9 -9
  4. package/dist/cjs/aptos/StreamClient.js +162 -367
  5. package/dist/cjs/aptos/constants.js +7 -8
  6. package/dist/cjs/aptos/index.js +3 -3
  7. package/dist/cjs/aptos/types.js +28 -37
  8. package/dist/cjs/aptos/utils.js +4 -4
  9. package/dist/cjs/aptos/wallet.js +20 -75
  10. package/dist/cjs/common/BaseStreamClient.js +11 -59
  11. package/dist/cjs/common/GenericStreamClient.js +46 -72
  12. package/dist/cjs/common/constants.js +4 -3
  13. package/dist/cjs/common/contractUtils.js +33 -18
  14. package/dist/cjs/common/types.js +30 -1
  15. package/dist/cjs/common/utils.js +38 -80
  16. package/dist/cjs/evm/StreamClient.js +198 -456
  17. package/dist/cjs/evm/constants.js +19 -20
  18. package/dist/cjs/evm/types.js +25 -34
  19. package/dist/cjs/evm/utils.js +2 -2
  20. package/dist/cjs/index.js +10 -10
  21. package/dist/cjs/solana/StreamClient.js +759 -1090
  22. package/dist/cjs/solana/constants.js +44 -11
  23. package/dist/cjs/solana/descriptor/idl/streamflow_aligned_unlocks.json +1471 -0
  24. package/dist/cjs/solana/descriptor/streamflow_aligned_unlocks.js +2 -0
  25. package/dist/cjs/solana/index.js +2 -1
  26. package/dist/cjs/solana/instructions.js +75 -81
  27. package/dist/cjs/solana/layout.js +7 -8
  28. package/dist/cjs/solana/lib/derive-accounts.js +17 -0
  29. package/dist/cjs/solana/lib/utils.js +127 -0
  30. package/dist/cjs/solana/types.js +40 -27
  31. package/dist/cjs/sui/StreamClient.js +325 -571
  32. package/dist/cjs/sui/constants.js +19 -20
  33. package/dist/cjs/sui/types.js +28 -62
  34. package/dist/cjs/sui/utils.js +7 -7
  35. package/dist/cjs/sui/wallet.js +13 -63
  36. package/dist/esm/__tests__/aptos/streamClient.spec.js +4 -4
  37. package/dist/esm/aptos/index.d.ts +3 -3
  38. package/dist/esm/aptos/index.js +3 -3
  39. package/dist/esm/aptos/types.d.ts +14 -14
  40. package/dist/esm/aptos/types.js +13 -13
  41. package/dist/esm/common/GenericStreamClient.d.ts +4 -4
  42. package/dist/esm/common/GenericStreamClient.js +4 -4
  43. package/dist/esm/common/constants.d.ts +3 -2
  44. package/dist/esm/common/constants.js +3 -2
  45. package/dist/esm/common/contractUtils.d.ts +18 -15
  46. package/dist/esm/common/contractUtils.js +19 -6
  47. package/dist/esm/common/types.d.ts +112 -57
  48. package/dist/esm/common/types.js +29 -0
  49. package/dist/esm/common/utils.d.ts +11 -11
  50. package/dist/esm/common/utils.js +19 -16
  51. package/dist/esm/evm/StreamClient.d.ts +2 -2
  52. package/dist/esm/evm/StreamClient.js +7 -7
  53. package/dist/esm/evm/types.d.ts +14 -14
  54. package/dist/esm/evm/types.js +13 -13
  55. package/dist/esm/index.d.ts +9 -9
  56. package/dist/esm/index.js +9 -9
  57. package/dist/esm/solana/StreamClient.d.ts +24 -16
  58. package/dist/esm/solana/StreamClient.js +324 -156
  59. package/dist/esm/solana/constants.d.ts +17 -0
  60. package/dist/esm/solana/constants.js +35 -1
  61. package/dist/esm/solana/descriptor/idl/streamflow_aligned_unlocks.json +1471 -0
  62. package/dist/esm/solana/descriptor/streamflow_aligned_unlocks.d.ts +1272 -0
  63. package/dist/esm/solana/descriptor/streamflow_aligned_unlocks.js +1 -0
  64. package/dist/esm/solana/index.d.ts +2 -1
  65. package/dist/esm/solana/index.js +2 -1
  66. package/dist/esm/solana/instructions.d.ts +17 -17
  67. package/dist/esm/solana/instructions.js +18 -19
  68. package/dist/esm/solana/lib/derive-accounts.d.ts +4 -0
  69. package/dist/esm/solana/lib/derive-accounts.js +11 -0
  70. package/dist/esm/solana/{utils.d.ts → lib/utils.d.ts} +1 -3
  71. package/dist/esm/solana/{utils.js → lib/utils.js} +28 -34
  72. package/dist/esm/solana/types.d.ts +72 -39
  73. package/dist/esm/solana/types.js +32 -4
  74. package/dist/esm/sui/StreamClient.js +1 -1
  75. package/dist/esm/sui/types.d.ts +14 -14
  76. package/dist/esm/sui/types.js +13 -13
  77. package/package.json +12 -10
  78. package/dist/cjs/solana/utils.js +0 -222
@@ -1,13 +1,15 @@
1
1
  import PQueue from "p-queue";
2
2
  import { Connection, Keypair, PublicKey, TransactionInstruction, Commitment, ConnectionConfig } from "@solana/web3.js";
3
- import { ICreateStreamSolanaExt, IInteractStreamSolanaExt, ITopUpStreamSolanaExt } from "./types.js";
4
- import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetAllData, IGetFeesData, IGetOneData, IFees, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData, Stream } from "../common/types.js";
3
+ import { IProgramAccount } from "@streamflow/common/solana";
4
+ import { ICreateStreamSolanaExt, IInteractStreamSolanaExt, ITopUpStreamSolanaExt, ISearchStreams, ICreateStreamInstructions } from "./types.js";
5
+ import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetAllData, IGetFeesData, IGetOneData, IFees, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData, Stream, ICreateAlignedStreamData } from "../common/types.js";
5
6
  import { BaseStreamClient } from "../common/BaseStreamClient.js";
6
7
  export declare class SolanaStreamClient extends BaseStreamClient {
7
8
  private connection;
8
9
  private programId;
9
10
  private commitment;
10
11
  private sendThrottler;
12
+ private alignedProxyProgram;
11
13
  /**
12
14
  * Create Stream instance
13
15
  */
@@ -20,15 +22,13 @@ export declare class SolanaStreamClient extends BaseStreamClient {
20
22
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
21
23
  */
22
24
  create(data: ICreateStreamData, extParams: ICreateStreamSolanaExt): Promise<ICreateResult>;
25
+ prepareCreateInstructions(streamParams: ICreateStreamData, extParams: ICreateStreamSolanaExt): Promise<ICreateStreamInstructions>;
26
+ prepareCreateAlignedUnlockInstructions(streamParams: ICreateAlignedStreamData, extParams: ICreateStreamSolanaExt): Promise<ICreateStreamInstructions>;
23
27
  /**
24
28
  * Creates a new stream/vesting contract.
25
29
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
26
30
  */
27
- prepareCreateInstructions({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canPause, canUpdateRate, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, }: ICreateStreamData, { sender, metadataPubKeys, isNative, computePrice, computeLimit }: ICreateStreamSolanaExt): Promise<{
28
- ixs: TransactionInstruction[];
29
- metadata: Keypair | undefined;
30
- metadataPubKey: PublicKey;
31
- }>;
31
+ prepareCreateStreamInstructions({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canPause, canUpdateRate, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, }: ICreateStreamData, { sender, metadataPubKeys, isNative, computePrice, computeLimit }: ICreateStreamSolanaExt): Promise<ICreateStreamInstructions>;
32
32
  /**
33
33
  * Creates a new stream/vesting contract using unchecked instruction.
34
34
  *
@@ -52,7 +52,7 @@ export declare class SolanaStreamClient extends BaseStreamClient {
52
52
  * Creates multiple stream/vesting contracts.
53
53
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
54
54
  */
55
- createMultiple(data: ICreateMultipleStreamData, { sender, metadataPubKeys, isNative, computePrice, computeLimit }: ICreateStreamSolanaExt): Promise<IMultiTransactionResult>;
55
+ createMultiple(data: ICreateMultipleStreamData, extParams: ICreateStreamSolanaExt): Promise<IMultiTransactionResult>;
56
56
  /**
57
57
  * Attempts withdrawing from the specified stream.
58
58
  */
@@ -64,11 +64,13 @@ export declare class SolanaStreamClient extends BaseStreamClient {
64
64
  /**
65
65
  * Attempts canceling the specified stream.
66
66
  */
67
- cancel({ id }: ICancelData, extParams: IInteractStreamSolanaExt): Promise<ITransactionResult>;
67
+ cancel(cancelData: ICancelData, extParams: IInteractStreamSolanaExt): Promise<ITransactionResult>;
68
+ prepareCancelInstructions(cancelData: ICancelData, extParams: IInteractStreamSolanaExt): Promise<TransactionInstruction[]>;
69
+ prepareCancelAlignedUnlockInstructions({ id }: ICancelData, { invoker, checkTokenAccounts, computePrice, computeLimit }: IInteractStreamSolanaExt): Promise<TransactionInstruction[]>;
68
70
  /**
69
71
  * Creates Transaction Instructions for cancel
70
72
  */
71
- prepareCancelInstructions({ id }: ICancelData, { invoker, checkTokenAccounts, computePrice, computeLimit }: IInteractStreamSolanaExt): Promise<TransactionInstruction[]>;
73
+ prepareCancelStreamInstructions({ id }: ICancelData, { invoker, checkTokenAccounts, computePrice, computeLimit }: IInteractStreamSolanaExt): Promise<TransactionInstruction[]>;
72
74
  /**
73
75
  * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
74
76
  * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
@@ -91,11 +93,17 @@ export declare class SolanaStreamClient extends BaseStreamClient {
91
93
  * Fetch stream data by its id (address).
92
94
  */
93
95
  getOne({ id }: IGetOneData): Promise<Stream>;
96
+ /**
97
+ * Fetch all aligned outgoing streams/contracts by the provided public key.
98
+ */
99
+ private getOutgoingAlignedStreams;
100
+ private getIncomingAlignedStreams;
94
101
  /**
95
102
  * Fetch streams/contracts by providing direction.
96
103
  * Streams are sorted by start time in ascending order.
97
104
  */
98
105
  get({ address, type, direction, }: IGetAllData): Promise<[string, Stream][]>;
106
+ searchStreams(data: ISearchStreams): Promise<IProgramAccount<Stream>[]>;
99
107
  /**
100
108
  * Attempts updating the stream auto withdrawal params and amount per period
101
109
  */
@@ -107,16 +115,16 @@ export declare class SolanaStreamClient extends BaseStreamClient {
107
115
  getFees({ address }: IGetFeesData): Promise<IFees | null>;
108
116
  getDefaultStreamflowFee(): Promise<number>;
109
117
  extractErrorCode(err: Error): string | null;
110
- /**
111
- * Forms instructions from params, creates a raw transaction and fetch recent blockhash.
112
- */
113
- private prepareStreamInstructions;
114
118
  /**
115
119
  * Utility function to generate metadata for a Contract or return existing Pubkey
116
120
  */
117
121
  private getOrCreateStreamMetadata;
118
122
  /**
119
- * Utility function that checks whether associated token accounts still exist and adds instructions to add them if not
123
+ * Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
124
+ */
125
+ private isAlignedUnlock;
126
+ /**
127
+ * Returns insrtuctions for creating associated token accounts for the provided owners
120
128
  */
121
- private checkAssociatedTokenAccounts;
129
+ private getCreateATAInstructions;
122
130
  }