@streamflow/stream 3.0.18 → 3.0.19

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 (52) hide show
  1. package/dist/Stream.d.ts +87 -0
  2. package/dist/Stream.js +503 -0
  3. package/dist/StreamClient.d.ts +146 -0
  4. package/dist/{solana/StreamClient.js → StreamClient.js} +397 -301
  5. package/dist/__tests__/test_dependencies/airdrop/airdrop-request.d.ts +3 -0
  6. package/dist/__tests__/test_dependencies/airdrop/airdrop-request.js +67 -0
  7. package/dist/__tests__/test_dependencies/airdrop/airdrop.d.ts +6 -0
  8. package/dist/__tests__/test_dependencies/airdrop/airdrop.js +215 -0
  9. package/dist/__tests__/test_dependencies/constants/index.d.ts +122 -0
  10. package/dist/__tests__/test_dependencies/constants/index.js +158 -0
  11. package/dist/__tests__/test_dependencies/idl/airdrop.d.ts +27 -0
  12. package/dist/__tests__/test_dependencies/idl/airdrop.js +171 -0
  13. package/dist/{solana/constants.d.ts → constants.d.ts} +1 -1
  14. package/dist/{solana/constants.js → constants.js} +5 -5
  15. package/dist/{solana/timelockIDL.d.ts → idl/timelock.d.ts} +0 -0
  16. package/dist/{solana/timelockIDL.js → idl/timelock.js} +0 -0
  17. package/dist/index.d.ts +6 -5
  18. package/dist/index.js +10 -19
  19. package/dist/{solana/instructions.d.ts → instructions.d.ts} +2 -8
  20. package/dist/{solana/instructions.js → instructions.js} +38 -55
  21. package/dist/layout.d.ts +22 -0
  22. package/dist/{solana/layout.js → layout.js} +3 -65
  23. package/dist/{solana/types.d.ts → types.d.ts} +34 -37
  24. package/dist/{solana/types.js → types.js} +20 -3
  25. package/dist/{common/utils.d.ts → utils.d.ts} +4 -0
  26. package/dist/utils.js +126 -0
  27. package/package.json +1 -1
  28. package/dist/__tests__/aptos/streamClient.spec.d.ts +0 -1
  29. package/dist/__tests__/aptos/streamClient.spec.js +0 -160
  30. package/dist/aptos/StreamClient.d.ts +0 -49
  31. package/dist/aptos/StreamClient.js +0 -362
  32. package/dist/aptos/constants.d.ts +0 -2
  33. package/dist/aptos/constants.js +0 -12
  34. package/dist/aptos/index.d.ts +0 -2
  35. package/dist/aptos/index.js +0 -24
  36. package/dist/aptos/types.d.ts +0 -145
  37. package/dist/aptos/types.js +0 -65
  38. package/dist/common/BaseStreamClient.d.ts +0 -11
  39. package/dist/common/BaseStreamClient.js +0 -9
  40. package/dist/common/GenericStreamClient.d.ts +0 -60
  41. package/dist/common/GenericStreamClient.js +0 -137
  42. package/dist/common/types.d.ts +0 -71
  43. package/dist/common/types.js +0 -28
  44. package/dist/common/utils.js +0 -31
  45. package/dist/solana/StreamClient.d.ts +0 -71
  46. package/dist/solana/index.d.ts +0 -7
  47. package/dist/solana/index.js +0 -43
  48. package/dist/solana/instructionTypes.d.ts +0 -86
  49. package/dist/solana/instructionTypes.js +0 -2
  50. package/dist/solana/layout.d.ts +0 -27
  51. package/dist/solana/utils.d.ts +0 -42
  52. package/dist/solana/utils.js +0 -271
@@ -0,0 +1,146 @@
1
+ import { web3 } from "@project-serum/anchor";
2
+ import { Commitment, ConnectionConfig } from "@solana/web3.js";
3
+ import { Stream as StreamData, CreateParams, CreateMultiParams, WithdrawParams, TopupParams, CancelParams, TransferParams, ClusterExtended, GetAllParams, CreateResponse, CreateMultiResponse, TxResponse } from "./types";
4
+ export default class StreamClient {
5
+ private connection;
6
+ private cluster;
7
+ private programId;
8
+ private commitment;
9
+ /**
10
+ * Create Stream instance
11
+ */
12
+ constructor(clusterUrl: string, cluster?: ClusterExtended, commitment?: Commitment | ConnectionConfig, programId?: string);
13
+ getConnection(): web3.Connection;
14
+ getProgramId(): string;
15
+ /**
16
+ * Creates a new stream/vesting contract.
17
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
18
+ * @param {CreateParams} data
19
+ * @param {Wallet | Keypair} data.sender - Wallet signing the transaction. Its address should match the authorized wallet (sender) or transaction will fail.
20
+ * @param {string} data.recipient - Solana address of the recipient. Associated token account will be derived using this address and token mint address.
21
+ * @param {string} data.mint - SPL Token mint.
22
+ * @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
23
+ * @param {BN} data.depositedAmount - Initially deposited amount of tokens (in the smallest units).
24
+ * @param {number} data.period - Time step (period) in seconds per which the unlocking occurs.
25
+ * @param {number} data.cliff - Vesting contract "cliff" timestamp in seconds.
26
+ * @param {BN} data.cliffAmount - Amount unlocked at the "cliff".
27
+ * @param {BN} data.amountPerPeriod - Amount unlocked per each period.
28
+ * @param {string} data.name - Stream name/subject.
29
+ * @param {boolean} data.canTopup - TRUE for streams, FALSE for vesting contracts.
30
+ * @param {boolean} data.cancelableBySender - Whether or not sender can cancel the stream.
31
+ * @param {boolean} data.cancelableByRecipient - Whether or not recipient can cancel the stream.
32
+ * @param {boolean} data.transferableBySender - Whether or not sender can transfer the stream.
33
+ * @param {boolean} data.transferableByRecipient - Whether or not recipient can transfer the stream.
34
+ * @param {boolean} data.automaticWithdrawal - Whether or not a 3rd party can initiate withdraw in the name of recipient.
35
+ * @param {number} [data.withdrawalFrequency = 0] - Relevant when automatic withdrawal is enabled. If greater than 0 our withdrawor will take care of withdrawals. If equal to 0 our withdrawor will skip, but everyone else can initiate withdrawals.
36
+ * @param {boolean} [data.isNative = false] - When true Automatically wraps SOLs to WrappedSOL and creates wSOL stream
37
+ * @param {string | null} [data.partner = null] - Partner's wallet address (optional).
38
+ */
39
+ create({ sender, recipient, mint, start, depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, isNative, }: CreateParams): Promise<CreateResponse>;
40
+ /**
41
+ * Creates a new stream/vesting contract using unchecked instruction.
42
+ *
43
+ * Unchecked instruction differes from the regular in:
44
+ * - does not check for initialized associated token account (wallets with no control over their ATA should not be used
45
+ * as sender/recipient/partner or there are risks of funds being locked in the contract)
46
+ * - initialized contract PDA off chain
47
+ *
48
+ * If you are not sure if you should use create or create_unchecked, go for create to be safer.
49
+ *
50
+ * @param {CreateParams} data
51
+ * @param {Wallet | Keypair} data.sender - Wallet signing the transaction. Its address should match the authorized wallet (sender) or transaction will fail.
52
+ * @param {string} data.recipient - Solana address of the recipient. Associated token account will be derived using this address and token mint address.
53
+ * @param {string} data.mint - SPL Token mint.
54
+ * @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
55
+ * @param {BN} data.depositedAmount - Initially deposited amount of tokens (in the smallest units).
56
+ * @param {number} data.period - Time step (period) in seconds per which the unlocking occurs.
57
+ * @param {number} data.cliff - Vesting contract "cliff" timestamp in seconds.
58
+ * @param {BN} data.cliffAmount - Amount unlocked at the "cliff".
59
+ * @param {BN} data.amountPerPeriod - Amount unlocked per each period.
60
+ * @param {string} data.name - Stream name/subject.
61
+ * @param {boolean} data.canTopup - TRUE for streams, FALSE for vesting contracts.
62
+ * @param {boolean} data.cancelableBySender - Whether or not sender can cancel the stream.
63
+ * @param {boolean} data.cancelableByRecipient - Whether or not recipient can cancel the stream.
64
+ * @param {boolean} data.transferableBySender - Whether or not sender can transfer the stream.
65
+ * @param {boolean} data.transferableByRecipient - Whether or not recipient can transfer the stream.
66
+ * @param {boolean} data.automaticWithdrawal - Whether or not a 3rd party can initiate withdraw in the name of recipient.
67
+ * @param {number} [data.withdrawalFrequency = 0] - Relevant when automatic withdrawal is enabled. If greater than 0 our withdrawor will take care of withdrawals. If equal to 0 our withdrawor will skip, but everyone else can initiate withdrawals.
68
+ * @param {boolean} [data.isNative = false] - When true Automatically wraps SOLs to WrappedSOL and creates wSOL stream
69
+ * @param {string | null} [data.partner = null] - Partner's wallet address (optional).
70
+ */
71
+ createUnchecked({ sender, recipient, mint, start, depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, isNative, }: CreateParams): Promise<CreateResponse>;
72
+ /**
73
+ * Creates a new stream/vesting contract.
74
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
75
+ * @param {CreateMultiParams} data
76
+ * @param {Wallet | Keypair} data.sender - Wallet signing the transaction. Its address should match the authorized wallet (sender) or transaction will fail.
77
+ * @param {MultiRecipient[]} data.recipientsData
78
+ * @param {string} data.mint - SPL Token mint.
79
+ * @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
80
+ * @param {number} data.period - Time step (period) in seconds per which the unlocking occurs.
81
+ * @param {number} data.cliff - Vesting contract "cliff" timestamp in seconds.
82
+ * @param {boolean} data.canTopup - TRUE for streams, FALSE for vesting contracts.
83
+ * @param {boolean} data.cancelableBySender - Whether or not sender can cancel the stream.
84
+ * @param {boolean} data.cancelableByRecipient - Whether or not recipient can cancel the stream.
85
+ * @param {boolean} data.transferableBySender - Whether or not sender can transfer the stream.
86
+ * @param {boolean} data.transferableByRecipient - Whether or not recipient can transfer the stream.
87
+ * @param {boolean} data.automaticWithdrawal - Whether or not a 3rd party can initiate withdraw in the name of recipient.
88
+ * @param {number} [data.withdrawalFrequency = 0] - Relevant when automatic withdrawal is enabled. If greater than 0 our withdrawor will take care of withdrawals. If equal to 0 our withdrawor will skip, but everyone else can initiate withdrawals.
89
+ * @param {boolean} [data.isNative = false] - When true Automatically wraps SOLs to WrappedSOL and creates wSOL stream
90
+ * @param {string | null} [data.partner = null] - Partner's wallet address (optional).
91
+ */
92
+ createMultiple(data: CreateMultiParams): Promise<CreateMultiResponse>;
93
+ /**
94
+ * Attempts withdrawal from the specified stream.
95
+ * @param {WithdrawParams} data
96
+ * @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (recipient) or transaction will fail.
97
+ * @param {string} data.id - Identifier of a stream (escrow account with metadata) to be withdrawn from.
98
+ * @param {BN} data.amount - Requested amount (in the smallest units) to withdraw (while streaming). If stream is completed, the whole amount will be withdrawn.
99
+ */
100
+ withdraw({ invoker, id, amount, }: WithdrawParams): Promise<TxResponse>;
101
+ /**
102
+ * Attempts canceling the specified stream.
103
+ * @param {CancelParams} data
104
+ * @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (sender or recipient) or transaction will fail.
105
+ * @param {string} data.id - Identifier of a stream (escrow account with metadata) to be canceled.
106
+ */
107
+ cancel({ invoker, id }: CancelParams): Promise<TxResponse>;
108
+ /**
109
+ * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
110
+ * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
111
+ * @param {TransferParams} data
112
+ * @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (sender or recipient) or transaction will fail.
113
+ * @param {string} data.id - Identifier of a stream (escrow account with metadata) to be transferred.
114
+ * @param {string} data.recipientId - Address of a new recipient.
115
+ */
116
+ transfer({ invoker, id, recipientId, }: TransferParams): Promise<TxResponse>;
117
+ /**
118
+ * Tops up stream account deposited amount.
119
+ * @param {TopupParams} data
120
+ * @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match current stream sender or transaction will fail.
121
+ * @param {string} data.id - Identifier of a stream (escrow account with metadata) to be topped up.
122
+ * @param {BN} data.amount - Specified amount (in the smallest units) to topup (increases deposited amount).
123
+ */
124
+ topup({ invoker, id, amount, isNative, }: TopupParams): Promise<TxResponse>;
125
+ /**
126
+ * Fetch stream data by its id (address).
127
+ * @param {string} id - Identifier of a stream that is fetched.
128
+ */
129
+ getOne(id: string): Promise<StreamData>;
130
+ /**
131
+ * Fetch streams/contracts by providing direction.
132
+ * Streams are sorted by start time in ascending order.
133
+ * @param {GetAllParams} data
134
+ * @param {PublicKey} data.wallet - PublicKey of the wallet for which the streams/contracts are fetched.
135
+ * @param {StreamType} [data.type = StreamType.All] - It can be one of: stream, vesting, all.
136
+ * @param {StreamDirection} [data.direction = StreamDirection.All] - It can be one of: incoming, outgoing, all.
137
+ */
138
+ get({ wallet, type, direction, }: GetAllParams): Promise<[string, StreamData][]>;
139
+ private sign;
140
+ /**
141
+ * Forms instructions from params, creates a raw transaction and fetch recent blockhash.
142
+ * @param {MultiRecipient} recipient - Wallet sending stream to
143
+ * @param {CreateMultiParams} streamParams - Parameters of stream user wants to create.
144
+ */
145
+ private prepareStreamTransaction;
146
+ }