@streamflow/stream 7.5.3 → 8.0.0-alpha.p287.5172056

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 (154) hide show
  1. package/dist/cjs/BaseStreamClient-CQOC8m8V.d.cts +542 -0
  2. package/dist/cjs/aptos/index.cjs +456 -0
  3. package/dist/cjs/aptos/index.cjs.map +1 -0
  4. package/dist/cjs/aptos/index.d.cts +14 -0
  5. package/dist/cjs/evm/index.cjs +1915 -0
  6. package/dist/cjs/evm/index.cjs.map +1 -0
  7. package/dist/cjs/evm/index.d.cts +13 -0
  8. package/dist/cjs/index-CYu6i--S.d.cts +136 -0
  9. package/dist/cjs/index-DUVcpIhD.d.cts +203 -0
  10. package/dist/cjs/index-b7Qo5mCj.d.cts +664 -0
  11. package/dist/cjs/index-fNLnPKzv.d.cts +213 -0
  12. package/dist/cjs/index.cjs +7189 -0
  13. package/dist/cjs/index.cjs.map +1 -0
  14. package/dist/cjs/index.d.cts +192 -0
  15. package/dist/cjs/solana/descriptor/streamflow_aligned_unlocks.cjs +4 -0
  16. package/dist/cjs/solana/descriptor/streamflow_aligned_unlocks.cjs.map +1 -0
  17. package/dist/cjs/solana/descriptor/streamflow_aligned_unlocks.d.cts +1234 -0
  18. package/dist/cjs/solana/index.cjs +3749 -0
  19. package/dist/cjs/solana/index.cjs.map +1 -0
  20. package/dist/cjs/solana/index.d.cts +17 -0
  21. package/dist/cjs/sui/index.cjs +1021 -0
  22. package/dist/cjs/sui/index.cjs.map +1 -0
  23. package/dist/cjs/sui/index.d.cts +13 -0
  24. package/dist/esm/BaseStreamClient-CQOC8m8V.d.ts +542 -0
  25. package/dist/esm/aptos/index.d.ts +14 -4
  26. package/dist/esm/aptos/index.js +443 -4
  27. package/dist/esm/aptos/index.js.map +1 -0
  28. package/dist/esm/evm/index.d.ts +13 -5
  29. package/dist/esm/evm/index.js +1902 -5
  30. package/dist/esm/evm/index.js.map +1 -0
  31. package/dist/esm/index-BEo0O2IG.d.ts +664 -0
  32. package/dist/esm/index-CWmb3-x9.d.ts +136 -0
  33. package/dist/esm/index-Cgv37xlG.d.ts +213 -0
  34. package/dist/esm/index-D6QYg8hn.d.ts +203 -0
  35. package/dist/esm/index.d.ts +192 -10
  36. package/dist/esm/index.js +7096 -10
  37. package/dist/esm/index.js.map +1 -0
  38. package/dist/esm/solana/descriptor/idl/streamflow_aligned_unlocks.json +917 -1368
  39. package/dist/esm/solana/descriptor/streamflow_aligned_unlocks.d.ts +3 -1
  40. package/dist/esm/solana/descriptor/streamflow_aligned_unlocks.js +3 -1
  41. package/dist/esm/solana/descriptor/streamflow_aligned_unlocks.js.map +1 -0
  42. package/dist/esm/solana/index.d.ts +17 -7
  43. package/dist/esm/solana/index.js +3693 -7
  44. package/dist/esm/solana/index.js.map +1 -0
  45. package/dist/esm/sui/index.d.ts +13 -4
  46. package/dist/esm/sui/index.js +1011 -4
  47. package/dist/esm/sui/index.js.map +1 -0
  48. package/package.json +57 -27
  49. package/dist/cjs/__tests__/aptos/streamClient.spec.js +0 -111
  50. package/dist/cjs/__tests__/common/GenericStreamClient.spec.js +0 -45
  51. package/dist/cjs/aptos/StreamClient.js +0 -226
  52. package/dist/cjs/aptos/constants.js +0 -27
  53. package/dist/cjs/aptos/index.js +0 -38
  54. package/dist/cjs/aptos/types.js +0 -69
  55. package/dist/cjs/aptos/utils.js +0 -34
  56. package/dist/cjs/aptos/wallet.js +0 -34
  57. package/dist/cjs/common/BaseStreamClient.js +0 -23
  58. package/dist/cjs/common/GenericStreamClient.js +0 -102
  59. package/dist/cjs/common/constants.js +0 -10
  60. package/dist/cjs/common/contractUtils.js +0 -77
  61. package/dist/cjs/common/types.js +0 -141
  62. package/dist/cjs/common/utils.js +0 -69
  63. package/dist/cjs/evm/StreamClient.js +0 -238
  64. package/dist/cjs/evm/abi.js +0 -1257
  65. package/dist/cjs/evm/constants.js +0 -38
  66. package/dist/cjs/evm/ercAbi.js +0 -224
  67. package/dist/cjs/evm/index.js +0 -40
  68. package/dist/cjs/evm/types.js +0 -66
  69. package/dist/cjs/evm/utils.js +0 -11
  70. package/dist/cjs/index.js +0 -43
  71. package/dist/cjs/solana/StreamClient.js +0 -1042
  72. package/dist/cjs/solana/constants.js +0 -95
  73. package/dist/cjs/solana/descriptor/idl/streamflow_aligned_unlocks.json +0 -1437
  74. package/dist/cjs/solana/descriptor/streamflow_aligned_unlocks.js +0 -2
  75. package/dist/cjs/solana/index.js +0 -40
  76. package/dist/cjs/solana/instructionTypes.js +0 -2
  77. package/dist/cjs/solana/instructions.js +0 -298
  78. package/dist/cjs/solana/layout.js +0 -182
  79. package/dist/cjs/solana/lib/derive-accounts.js +0 -17
  80. package/dist/cjs/solana/lib/utils.js +0 -127
  81. package/dist/cjs/solana/timelockIDL.js +0 -422
  82. package/dist/cjs/solana/types.js +0 -93
  83. package/dist/cjs/sui/StreamClient.js +0 -416
  84. package/dist/cjs/sui/constants.js +0 -42
  85. package/dist/cjs/sui/index.js +0 -37
  86. package/dist/cjs/sui/types.js +0 -68
  87. package/dist/cjs/sui/utils.js +0 -46
  88. package/dist/cjs/sui/wallet.js +0 -40
  89. package/dist/esm/__tests__/aptos/streamClient.spec.d.ts +0 -1
  90. package/dist/esm/__tests__/aptos/streamClient.spec.js +0 -106
  91. package/dist/esm/__tests__/common/GenericStreamClient.spec.d.ts +0 -1
  92. package/dist/esm/__tests__/common/GenericStreamClient.spec.js +0 -40
  93. package/dist/esm/aptos/StreamClient.d.ts +0 -53
  94. package/dist/esm/aptos/StreamClient.js +0 -226
  95. package/dist/esm/aptos/constants.d.ts +0 -8
  96. package/dist/esm/aptos/constants.js +0 -24
  97. package/dist/esm/aptos/types.d.ts +0 -109
  98. package/dist/esm/aptos/types.js +0 -105
  99. package/dist/esm/aptos/utils.d.ts +0 -7
  100. package/dist/esm/aptos/utils.js +0 -30
  101. package/dist/esm/aptos/wallet.d.ts +0 -9
  102. package/dist/esm/aptos/wallet.js +0 -33
  103. package/dist/esm/common/BaseStreamClient.d.ts +0 -22
  104. package/dist/esm/common/BaseStreamClient.js +0 -19
  105. package/dist/esm/common/GenericStreamClient.d.ts +0 -72
  106. package/dist/esm/common/GenericStreamClient.js +0 -101
  107. package/dist/esm/common/constants.d.ts +0 -4
  108. package/dist/esm/common/constants.js +0 -4
  109. package/dist/esm/common/contractUtils.d.ts +0 -63
  110. package/dist/esm/common/contractUtils.js +0 -61
  111. package/dist/esm/common/types.d.ts +0 -353
  112. package/dist/esm/common/types.js +0 -135
  113. package/dist/esm/common/utils.d.ts +0 -32
  114. package/dist/esm/common/utils.js +0 -59
  115. package/dist/esm/evm/StreamClient.d.ts +0 -32
  116. package/dist/esm/evm/StreamClient.js +0 -237
  117. package/dist/esm/evm/abi.d.ts +0 -111
  118. package/dist/esm/evm/abi.js +0 -1255
  119. package/dist/esm/evm/constants.d.ts +0 -20
  120. package/dist/esm/evm/constants.js +0 -35
  121. package/dist/esm/evm/ercAbi.d.ts +0 -39
  122. package/dist/esm/evm/ercAbi.js +0 -222
  123. package/dist/esm/evm/types.d.ts +0 -98
  124. package/dist/esm/evm/types.js +0 -102
  125. package/dist/esm/evm/utils.d.ts +0 -1
  126. package/dist/esm/evm/utils.js +0 -8
  127. package/dist/esm/solana/StreamClient.d.ts +0 -150
  128. package/dist/esm/solana/StreamClient.js +0 -1017
  129. package/dist/esm/solana/constants.d.ts +0 -70
  130. package/dist/esm/solana/constants.js +0 -92
  131. package/dist/esm/solana/instructionTypes.d.ts +0 -101
  132. package/dist/esm/solana/instructionTypes.js +0 -1
  133. package/dist/esm/solana/instructions.d.ts +0 -142
  134. package/dist/esm/solana/instructions.js +0 -265
  135. package/dist/esm/solana/layout.d.ts +0 -27
  136. package/dist/esm/solana/layout.js +0 -155
  137. package/dist/esm/solana/lib/derive-accounts.d.ts +0 -4
  138. package/dist/esm/solana/lib/derive-accounts.js +0 -11
  139. package/dist/esm/solana/lib/utils.d.ts +0 -22
  140. package/dist/esm/solana/lib/utils.js +0 -117
  141. package/dist/esm/solana/timelockIDL.d.ts +0 -22
  142. package/dist/esm/solana/timelockIDL.js +0 -420
  143. package/dist/esm/solana/types.d.ts +0 -180
  144. package/dist/esm/solana/types.js +0 -142
  145. package/dist/esm/sui/StreamClient.d.ts +0 -82
  146. package/dist/esm/sui/StreamClient.js +0 -417
  147. package/dist/esm/sui/constants.d.ts +0 -10
  148. package/dist/esm/sui/constants.js +0 -39
  149. package/dist/esm/sui/types.d.ts +0 -167
  150. package/dist/esm/sui/types.js +0 -104
  151. package/dist/esm/sui/utils.d.ts +0 -11
  152. package/dist/esm/sui/utils.js +0 -39
  153. package/dist/esm/sui/wallet.d.ts +0 -17
  154. package/dist/esm/sui/wallet.js +0 -38
@@ -1,353 +0,0 @@
1
- import { Address } from "@coral-xyz/anchor";
2
- import { Commitment, ConnectionConfig, PublicKey, TransactionInstruction } from "@solana/web3.js";
3
- import { IChain, ICluster } from "@streamflow/common";
4
- import { Types } from "aptos";
5
- import BN from "bn.js";
6
- import type { Signer } from "ethers";
7
- import type { default as PQueue } from "p-queue";
8
- import { ISuiIdParameters } from "../sui/index.js";
9
- export { ContractError, IChain, ICluster } from "@streamflow/common";
10
- export interface IRecipient {
11
- recipient: string;
12
- amount: BN;
13
- name: string;
14
- cliffAmount: BN;
15
- amountPerPeriod: BN;
16
- }
17
- export interface IBaseStreamConfig {
18
- period: number;
19
- start: number;
20
- cliff: number;
21
- cancelableBySender: boolean;
22
- cancelableByRecipient: boolean;
23
- transferableBySender: boolean;
24
- transferableByRecipient: boolean;
25
- canTopup: boolean;
26
- automaticWithdrawal?: boolean;
27
- withdrawalFrequency?: number;
28
- tokenId: string;
29
- canPause?: boolean;
30
- canUpdateRate?: boolean;
31
- partner?: string;
32
- tokenProgramId?: string | PublicKey;
33
- }
34
- export type IAlignedStreamConfig = {
35
- minPrice: number | BN;
36
- maxPrice: number | BN;
37
- minPercentage: number | BN;
38
- maxPercentage: number | BN;
39
- oracleType?: OracleTypeName;
40
- priceOracle?: Address;
41
- skipInitial?: boolean;
42
- tickSize?: number;
43
- };
44
- export type ICreateLinearStreamData = IBaseStreamConfig & IRecipient;
45
- export type ICreateAlignedStreamData = ICreateLinearStreamData & IAlignedStreamConfig;
46
- export type ICreateStreamData = ICreateLinearStreamData | ICreateAlignedStreamData;
47
- export type ICreateMultipleLinearStreamData = IBaseStreamConfig & {
48
- recipients: IRecipient[];
49
- };
50
- export type ICreateMultipleAlignedStreamData = ICreateMultipleLinearStreamData & IAlignedStreamConfig;
51
- export type ICreateMultipleStreamData = ICreateMultipleLinearStreamData | ICreateMultipleAlignedStreamData;
52
- export interface IInteractData {
53
- id: string;
54
- }
55
- export interface IWithdrawData extends IInteractData {
56
- amount?: BN;
57
- }
58
- export interface IUpdateData extends IInteractData {
59
- enableAutomaticWithdrawal?: boolean;
60
- withdrawFrequency?: BN;
61
- amountPerPeriod?: BN;
62
- }
63
- export type ICancelData = IInteractData;
64
- export interface ITransferData extends IInteractData {
65
- newRecipient: string;
66
- }
67
- export interface ITopUpData extends IInteractData {
68
- amount: BN;
69
- }
70
- export type IGetOneData = IInteractData;
71
- export interface IGetFeesData {
72
- address: string;
73
- }
74
- export interface IGetAllData {
75
- address: string;
76
- type?: StreamType;
77
- direction?: StreamDirection;
78
- }
79
- export interface ICreateMultiError {
80
- recipient: string;
81
- error: string;
82
- contractErrorCode?: string;
83
- }
84
- type MetadataId = string;
85
- export interface ITransactionResult {
86
- ixs: (TransactionInstruction | Types.TransactionPayload)[];
87
- txId: string;
88
- }
89
- export interface IFees {
90
- streamflowFee: number;
91
- partnerFee: number;
92
- }
93
- export interface ICreateResult extends ITransactionResult {
94
- metadataId: MetadataId;
95
- }
96
- export interface IMultiTransactionResult {
97
- txs: string[];
98
- metadatas: MetadataId[];
99
- metadataToRecipient: Record<MetadataId, IRecipient>;
100
- errors: ICreateMultiError[];
101
- }
102
- export type OracleTypeName = "none" | "pyth" | "switchboard" | "test";
103
- export declare enum StreamDirection {
104
- Outgoing = "outgoing",
105
- Incoming = "incoming",
106
- All = "all"
107
- }
108
- export declare enum StreamType {
109
- All = "all",
110
- Payment = "payment",
111
- Vesting = "vesting",
112
- Lock = "lock"
113
- }
114
- /**
115
- * Error codes raised by all protocols except for Solana
116
- */
117
- export declare enum ContractErrorCode {
118
- /** Contract does not exist */
119
- ECONTRACT_NOT_INIT = "ECONTRACT_NOT_INIT",
120
- /** Invalid total amount */
121
- EBAD_AMOUNT = "EBAD_AMOUNT",
122
- /** No permissions to perform an operation */
123
- ENO_PERMISSIONS = "ENO_PERMISSIONS",
124
- /** Invalid input parameters on create/update */
125
- EBADINPUT = "EBADINPUT",
126
- /** Contract is already ended */
127
- ECLOSED = "ECLOSED",
128
- /** Invalid amount per period input */
129
- EBAD_INPUT_AMOUNT_PER_PERIOD = "EBAD_INPUT_AMOUNT_PER_PERIOD",
130
- /** Pause feature is not supported */
131
- EBAD_INPUT_PAUSABLE = "EBAD_INPUT_PAUSABLE",
132
- /** Not used currently */
133
- EBAD_INPUT_UPDATE_RATE = "EBAD_INPUT_UPDATE_RATE",
134
- /** Invalid cliff amount input */
135
- EBAD_INPUT_CLIFF_AMOUNT = "EBAD_INPUT_CLIFF_AMOUNT",
136
- /** Invalid period input */
137
- EBAD_INPUT_PERIOD = "EBAD_INPUT_PERIOD",
138
- /** Invalid start time of the contract */
139
- EBAD_INPUT_START = "EBAD_INPUT_START",
140
- /** EVM: token allowance is not enough to create a Contract */
141
- EBAD_INSUFFICIENT_TOKEN_ALLOWANCE = "EBAD_INSUFFICIENT_TOKEN_ALLOWANCE",
142
- /** EVM: not enough coins were passed for withdrawal fees */
143
- EBAD_INSUFFICIENT_WITHDRAWAL_FEES = "EBAD_INSUFFICIENT_WITHDRAWAL_FEES",
144
- /** Sui: Insufficient amount of tokens passed */
145
- EBAD_INSUFFICIENT_AMOUNT = "EBAD_INSUFFICIENT_AMOUNT",
146
- /** Contract is already paused */
147
- EPAUSED = "EPAUSED",
148
- /** Contract is not paused */
149
- ENOTPAUSED = "ENOTPAUSED",
150
- /** Aptos: user opt out from direct coin transfers feature and has not coin wallet registered */
151
- ENO_RECIPIENT_COIN_ADDRESS = "ENO_RECIPIENT_COIN_ADDRESS"
152
- }
153
- export interface LinearStream {
154
- magic: number;
155
- version: number;
156
- createdAt: number;
157
- withdrawnAmount: BN;
158
- canceledAt: number;
159
- end: number;
160
- lastWithdrawnAt: number;
161
- sender: string;
162
- senderTokens: string;
163
- recipient: string;
164
- recipientTokens: string;
165
- mint: string;
166
- escrowTokens: string;
167
- streamflowTreasury: string;
168
- streamflowTreasuryTokens: string;
169
- streamflowFeeTotal: BN;
170
- streamflowFeeWithdrawn: BN;
171
- streamflowFeePercent: number;
172
- partnerFeeTotal: BN;
173
- partnerFeeWithdrawn: BN;
174
- partnerFeePercent: number;
175
- partner: string;
176
- partnerTokens: string;
177
- start: number;
178
- depositedAmount: BN;
179
- period: number;
180
- amountPerPeriod: BN;
181
- cliff: number;
182
- cliffAmount: BN;
183
- cancelableBySender: boolean;
184
- cancelableByRecipient: boolean;
185
- automaticWithdrawal: boolean;
186
- transferableBySender: boolean;
187
- transferableByRecipient: boolean;
188
- canTopup: boolean;
189
- name: string;
190
- withdrawalFrequency: number;
191
- closed: boolean;
192
- currentPauseStart: number;
193
- pauseCumulative: BN;
194
- lastRateChangeTime: number;
195
- fundsUnlockedAtLastRateChange: BN;
196
- type: StreamType;
197
- unlocked(currentTimestamp: number): BN;
198
- remaining(decimals: number): number;
199
- }
200
- export type AlignedStreamData = {
201
- minPrice: number;
202
- maxPrice: number;
203
- minPercentage: number;
204
- maxPercentage: number;
205
- oracleType: OracleTypeName;
206
- priceOracle: string | undefined;
207
- tickSize: number;
208
- initialAmountPerPeriod: BN;
209
- initialPrice: number;
210
- lastPrice: number;
211
- lastAmountUpdateTime: number;
212
- initialNetAmount: BN;
213
- };
214
- export type AlignedStream = LinearStream & AlignedStreamData;
215
- export type Stream = LinearStream | AlignedStream;
216
- /**
217
- * Error codes raised by Solana protocol specifically
218
- */
219
- export declare enum SolanaContractErrorCode {
220
- /** Accounts not writable */
221
- AccountsNotWritable = "AccountsNotWritable",
222
- /** Invalid Metadata */
223
- InvalidMetadata = "InvalidMetadata",
224
- /** Invalid metadata account */
225
- InvalidMetadataAccount = "InvalidMetadataAccount",
226
- /** Provided accounts don't match the ones in contract */
227
- MetadataAccountMismatch = "MetadataAccountMismatch",
228
- /** Invalid escrow account */
229
- InvalidEscrowAccount = "InvalidEscrowAccount",
230
- /** Provided account(s) is/are not valid associated token accounts */
231
- NotAssociated = "NotAssociated",
232
- /** Sender mint does not match accounts mint */
233
- MintMismatch = "MintMismatch",
234
- /** Recipient not transferable for account */
235
- TransferNotAllowed = "TransferNotAllowed",
236
- /** Contract closed */
237
- ContractClosed = "ContractClosed",
238
- /** Invalid Streamflow Treasury accounts supplied */
239
- InvalidTreasury = "InvalidTreasury",
240
- /** Given timestamps are invalid */
241
- InvalidTimestamps = "InvalidTimestamps",
242
- /** Invalid deposit configuration */
243
- InvalidDepositConfiguration = "InvalidDepositConfiguration",
244
- /** Amount cannot be zero */
245
- AmountIsZero = "AmountIsZero",
246
- /** Amount requested is larger than available */
247
- AmountMoreThanAvailable = "AmountMoreThanAvailable",
248
- /** Amount currently available is zero */
249
- AmountAvailableIsZero = "AmountAvailableIsZero",
250
- /** Arithmetic error */
251
- ArithmeticError = "ArithmeticError",
252
- /** Metadata account data must be 1104 bytes long */
253
- InvalidMetadataSize = "InvalidMetadataSize",
254
- /** Metadata state account must be initialized */
255
- UninitializedMetadata = "UninitializedMetadata",
256
- /** Authority does not have permission for this action */
257
- Unauthorized = "Unauthorized",
258
- /** Contract is not transferable to the original recipient */
259
- SelfTransfer = "SelfTransfer",
260
- /** Contract is already paused */
261
- AlreadyPaused = "AlreadyPaused",
262
- /** Contract is not paused */
263
- NotPaused = "NotPaused",
264
- /** Meta account is not rent exempt */
265
- MetadataNotRentExempt = "MetadataNotRentExempt"
266
- }
267
- export declare enum SolanaAlignedProxyErrorCode {
268
- /** Authority does not have permission for this action */
269
- Unauthorized = "Unauthorized",
270
- /** Arithmetic error */
271
- ArithmeticError = "ArithmeticError",
272
- /** Mint has unsupported Token Extensions */
273
- UnsupportedTokenExtensions = "UnsupportedTokenExtensions",
274
- /** Provided period is too short, should be equal or more than 30 seconds */
275
- PeriodTooShort = "PeriodTooShort",
276
- /** Provided percentage tick size is invalid */
277
- InvalidTickSize = "InvalidTickSize",
278
- /** Provided percentage bounds are invalid */
279
- InvalidPercentageBoundaries = "InvalidPercentageBoundaries",
280
- /** Provided price bounds are invalid */
281
- InvalidPriceBoundaries = "InvalidPriceBoundaries",
282
- /** Unsupported price oracle */
283
- UnsupportedOracle = "UnsupportedOracle",
284
- /** Invalid oracle account */
285
- InvalidOracleAccount = "InvalidOracleAccount",
286
- /** Invalid oracle price */
287
- InvalidOraclePrice = "InvalidOraclePrice",
288
- /** Invalid Stream Metadata */
289
- InvalidStreamMetadata = "InvalidStreamMetadata",
290
- /** Release amount has already been updated in this period */
291
- AmountAlreadyUpdated = "AmountAlreadyUpdated",
292
- /** All funds are already unlocked */
293
- AllFundsUnlocked = "AllFundsUnlocked"
294
- }
295
- /**
296
- * @interface
297
- */
298
- export interface SolanaTransactionSchedulingOptions {
299
- /**
300
- * concurrency rate for scheduling
301
- */
302
- sendRate: number;
303
- /**
304
- * time interval between consecutive sends
305
- */
306
- sendInterval?: number;
307
- /**
308
- * time interval before confirming the transaction
309
- */
310
- waitBeforeConfirming?: number;
311
- }
312
- /**
313
- * @interface
314
- */
315
- export interface SolanaStreamClientOptions {
316
- chain: IChain.Solana;
317
- clusterUrl: string;
318
- cluster?: ICluster;
319
- programId?: string;
320
- commitment?: Commitment | ConnectionConfig;
321
- sendRate?: number;
322
- sendThrottler?: PQueue;
323
- sendScheduler?: PQueue | SolanaTransactionSchedulingOptions;
324
- }
325
- /**
326
- * @interface
327
- */
328
- export interface AptosStreamClientOptions {
329
- chain: IChain.Aptos;
330
- clusterUrl: string;
331
- cluster?: ICluster;
332
- programId?: string;
333
- maxGas?: string;
334
- }
335
- /**
336
- * @interface
337
- */
338
- export interface EvmStreamClientOptions {
339
- chain: IChain.Ethereum | IChain.BNB | IChain.Polygon;
340
- clusterUrl: string;
341
- signer: Signer;
342
- cluster?: ICluster;
343
- programId?: string;
344
- }
345
- /**
346
- * @interface
347
- */
348
- export interface SuiStreamClientOptions {
349
- chain: IChain.Sui;
350
- clusterUrl: string;
351
- cluster?: ICluster;
352
- ids?: ISuiIdParameters;
353
- }
@@ -1,135 +0,0 @@
1
- export { ContractError, IChain, ICluster } from "@streamflow/common";
2
- export var StreamDirection;
3
- (function (StreamDirection) {
4
- StreamDirection["Outgoing"] = "outgoing";
5
- StreamDirection["Incoming"] = "incoming";
6
- StreamDirection["All"] = "all";
7
- })(StreamDirection || (StreamDirection = {}));
8
- export var StreamType;
9
- (function (StreamType) {
10
- StreamType["All"] = "all";
11
- StreamType["Payment"] = "payment";
12
- StreamType["Vesting"] = "vesting";
13
- StreamType["Lock"] = "lock";
14
- })(StreamType || (StreamType = {}));
15
- /**
16
- * Error codes raised by all protocols except for Solana
17
- */
18
- export var ContractErrorCode;
19
- (function (ContractErrorCode) {
20
- /** Contract does not exist */
21
- ContractErrorCode["ECONTRACT_NOT_INIT"] = "ECONTRACT_NOT_INIT";
22
- /** Invalid total amount */
23
- ContractErrorCode["EBAD_AMOUNT"] = "EBAD_AMOUNT";
24
- /** No permissions to perform an operation */
25
- ContractErrorCode["ENO_PERMISSIONS"] = "ENO_PERMISSIONS";
26
- /** Invalid input parameters on create/update */
27
- ContractErrorCode["EBADINPUT"] = "EBADINPUT";
28
- /** Contract is already ended */
29
- ContractErrorCode["ECLOSED"] = "ECLOSED";
30
- /** Invalid amount per period input */
31
- ContractErrorCode["EBAD_INPUT_AMOUNT_PER_PERIOD"] = "EBAD_INPUT_AMOUNT_PER_PERIOD";
32
- /** Pause feature is not supported */
33
- ContractErrorCode["EBAD_INPUT_PAUSABLE"] = "EBAD_INPUT_PAUSABLE";
34
- /** Not used currently */
35
- ContractErrorCode["EBAD_INPUT_UPDATE_RATE"] = "EBAD_INPUT_UPDATE_RATE";
36
- /** Invalid cliff amount input */
37
- ContractErrorCode["EBAD_INPUT_CLIFF_AMOUNT"] = "EBAD_INPUT_CLIFF_AMOUNT";
38
- /** Invalid period input */
39
- ContractErrorCode["EBAD_INPUT_PERIOD"] = "EBAD_INPUT_PERIOD";
40
- /** Invalid start time of the contract */
41
- ContractErrorCode["EBAD_INPUT_START"] = "EBAD_INPUT_START";
42
- /** EVM: token allowance is not enough to create a Contract */
43
- ContractErrorCode["EBAD_INSUFFICIENT_TOKEN_ALLOWANCE"] = "EBAD_INSUFFICIENT_TOKEN_ALLOWANCE";
44
- /** EVM: not enough coins were passed for withdrawal fees */
45
- ContractErrorCode["EBAD_INSUFFICIENT_WITHDRAWAL_FEES"] = "EBAD_INSUFFICIENT_WITHDRAWAL_FEES";
46
- /** Sui: Insufficient amount of tokens passed */
47
- ContractErrorCode["EBAD_INSUFFICIENT_AMOUNT"] = "EBAD_INSUFFICIENT_AMOUNT";
48
- /** Contract is already paused */
49
- ContractErrorCode["EPAUSED"] = "EPAUSED";
50
- /** Contract is not paused */
51
- ContractErrorCode["ENOTPAUSED"] = "ENOTPAUSED";
52
- /** Aptos: user opt out from direct coin transfers feature and has not coin wallet registered */
53
- ContractErrorCode["ENO_RECIPIENT_COIN_ADDRESS"] = "ENO_RECIPIENT_COIN_ADDRESS";
54
- })(ContractErrorCode || (ContractErrorCode = {}));
55
- /**
56
- * Error codes raised by Solana protocol specifically
57
- */
58
- export var SolanaContractErrorCode;
59
- (function (SolanaContractErrorCode) {
60
- /** Accounts not writable */
61
- SolanaContractErrorCode["AccountsNotWritable"] = "AccountsNotWritable";
62
- /** Invalid Metadata */
63
- SolanaContractErrorCode["InvalidMetadata"] = "InvalidMetadata";
64
- /** Invalid metadata account */
65
- SolanaContractErrorCode["InvalidMetadataAccount"] = "InvalidMetadataAccount";
66
- /** Provided accounts don't match the ones in contract */
67
- SolanaContractErrorCode["MetadataAccountMismatch"] = "MetadataAccountMismatch";
68
- /** Invalid escrow account */
69
- SolanaContractErrorCode["InvalidEscrowAccount"] = "InvalidEscrowAccount";
70
- /** Provided account(s) is/are not valid associated token accounts */
71
- SolanaContractErrorCode["NotAssociated"] = "NotAssociated";
72
- /** Sender mint does not match accounts mint */
73
- SolanaContractErrorCode["MintMismatch"] = "MintMismatch";
74
- /** Recipient not transferable for account */
75
- SolanaContractErrorCode["TransferNotAllowed"] = "TransferNotAllowed";
76
- /** Contract closed */
77
- SolanaContractErrorCode["ContractClosed"] = "ContractClosed";
78
- /** Invalid Streamflow Treasury accounts supplied */
79
- SolanaContractErrorCode["InvalidTreasury"] = "InvalidTreasury";
80
- /** Given timestamps are invalid */
81
- SolanaContractErrorCode["InvalidTimestamps"] = "InvalidTimestamps";
82
- /** Invalid deposit configuration */
83
- SolanaContractErrorCode["InvalidDepositConfiguration"] = "InvalidDepositConfiguration";
84
- /** Amount cannot be zero */
85
- SolanaContractErrorCode["AmountIsZero"] = "AmountIsZero";
86
- /** Amount requested is larger than available */
87
- SolanaContractErrorCode["AmountMoreThanAvailable"] = "AmountMoreThanAvailable";
88
- /** Amount currently available is zero */
89
- SolanaContractErrorCode["AmountAvailableIsZero"] = "AmountAvailableIsZero";
90
- /** Arithmetic error */
91
- SolanaContractErrorCode["ArithmeticError"] = "ArithmeticError";
92
- /** Metadata account data must be 1104 bytes long */
93
- SolanaContractErrorCode["InvalidMetadataSize"] = "InvalidMetadataSize";
94
- /** Metadata state account must be initialized */
95
- SolanaContractErrorCode["UninitializedMetadata"] = "UninitializedMetadata";
96
- /** Authority does not have permission for this action */
97
- SolanaContractErrorCode["Unauthorized"] = "Unauthorized";
98
- /** Contract is not transferable to the original recipient */
99
- SolanaContractErrorCode["SelfTransfer"] = "SelfTransfer";
100
- /** Contract is already paused */
101
- SolanaContractErrorCode["AlreadyPaused"] = "AlreadyPaused";
102
- /** Contract is not paused */
103
- SolanaContractErrorCode["NotPaused"] = "NotPaused";
104
- /** Meta account is not rent exempt */
105
- SolanaContractErrorCode["MetadataNotRentExempt"] = "MetadataNotRentExempt";
106
- })(SolanaContractErrorCode || (SolanaContractErrorCode = {}));
107
- export var SolanaAlignedProxyErrorCode;
108
- (function (SolanaAlignedProxyErrorCode) {
109
- /** Authority does not have permission for this action */
110
- SolanaAlignedProxyErrorCode["Unauthorized"] = "Unauthorized";
111
- /** Arithmetic error */
112
- SolanaAlignedProxyErrorCode["ArithmeticError"] = "ArithmeticError";
113
- /** Mint has unsupported Token Extensions */
114
- SolanaAlignedProxyErrorCode["UnsupportedTokenExtensions"] = "UnsupportedTokenExtensions";
115
- /** Provided period is too short, should be equal or more than 30 seconds */
116
- SolanaAlignedProxyErrorCode["PeriodTooShort"] = "PeriodTooShort";
117
- /** Provided percentage tick size is invalid */
118
- SolanaAlignedProxyErrorCode["InvalidTickSize"] = "InvalidTickSize";
119
- /** Provided percentage bounds are invalid */
120
- SolanaAlignedProxyErrorCode["InvalidPercentageBoundaries"] = "InvalidPercentageBoundaries";
121
- /** Provided price bounds are invalid */
122
- SolanaAlignedProxyErrorCode["InvalidPriceBoundaries"] = "InvalidPriceBoundaries";
123
- /** Unsupported price oracle */
124
- SolanaAlignedProxyErrorCode["UnsupportedOracle"] = "UnsupportedOracle";
125
- /** Invalid oracle account */
126
- SolanaAlignedProxyErrorCode["InvalidOracleAccount"] = "InvalidOracleAccount";
127
- /** Invalid oracle price */
128
- SolanaAlignedProxyErrorCode["InvalidOraclePrice"] = "InvalidOraclePrice";
129
- /** Invalid Stream Metadata */
130
- SolanaAlignedProxyErrorCode["InvalidStreamMetadata"] = "InvalidStreamMetadata";
131
- /** Release amount has already been updated in this period */
132
- SolanaAlignedProxyErrorCode["AmountAlreadyUpdated"] = "AmountAlreadyUpdated";
133
- /** All funds are already unlocked */
134
- SolanaAlignedProxyErrorCode["AllFundsUnlocked"] = "AllFundsUnlocked";
135
- })(SolanaAlignedProxyErrorCode || (SolanaAlignedProxyErrorCode = {}));
@@ -1,32 +0,0 @@
1
- import BN from "bn.js";
2
- /**
3
- * Used for conversion of token amounts to their Big Number representation.
4
- * Get Big Number representation in the smallest units from the same value in the highest units.
5
- * @param {number} value - Number of tokens you want to convert to its BN representation.
6
- * @param {number} decimals - Number of decimals the token has.
7
- */
8
- export declare const getBN: (value: number, decimals: number) => BN;
9
- /**
10
- * Used for token amounts conversion from their Big Number representation to number.
11
- * Get value in the highest units from BN representation of the same value in the smallest units.
12
- * @param {BN} value - Big Number representation of value in the smallest units.
13
- * @param {number} decimals - Number of decimals the token has.
14
- */
15
- export declare const getNumberFromBN: (value: BN, decimals: number) => number;
16
- /**
17
- * Calculate total amount of a Contract including all fees.
18
- * - first we convert fee floating to a BN with up to 4 decimals precision
19
- * - then we reverse the fee with `FEE_MULTIPLIER` to safely multiply it by depositedAmount
20
- * to receive a total number and not percentage of depositedAmount
21
- * @param depositedAmount deposited raw tokens
22
- * @param totalFee sum of all fees in percentage as floating number, e.g. 0.99% should be supplied as 0.99
23
- * @returns total tokens amount that Contract will retrieve from the Sender
24
- */
25
- export declare const calculateTotalAmountToDeposit: (depositedAmount: BN, totalFee: number) => BN;
26
- /**
27
- * Used to make on chain calls to the contract and wrap raised errors if any
28
- * @param func function that interacts with the contract
29
- * @param callback callback that may be used to extract error code
30
- * @returns {T}
31
- */
32
- export declare function handleContractError<T>(func: () => Promise<T>, callback?: (err: Error) => string | null): Promise<T>;
@@ -1,59 +0,0 @@
1
- import BN from "bn.js";
2
- import { ContractError } from "./types.js";
3
- const FEE_PRECISION = 4;
4
- const FEE_NORMALIZER = 10 ** FEE_PRECISION;
5
- const FEE_MULTIPLIER = new BN(10 ** 6);
6
- /**
7
- * Used for conversion of token amounts to their Big Number representation.
8
- * Get Big Number representation in the smallest units from the same value in the highest units.
9
- * @param {number} value - Number of tokens you want to convert to its BN representation.
10
- * @param {number} decimals - Number of decimals the token has.
11
- */
12
- export const getBN = (value, decimals) => {
13
- const decimalPart = value - Math.trunc(value);
14
- const integerPart = new BN(Math.trunc(value));
15
- const decimalE = new BN(decimalPart * 1e9);
16
- const sum = integerPart.mul(new BN(1e9)).add(decimalE);
17
- const resultE = sum.mul(new BN(10).pow(new BN(decimals)));
18
- return resultE.div(new BN(1e9));
19
- };
20
- /**
21
- * Used for token amounts conversion from their Big Number representation to number.
22
- * Get value in the highest units from BN representation of the same value in the smallest units.
23
- * @param {BN} value - Big Number representation of value in the smallest units.
24
- * @param {number} decimals - Number of decimals the token has.
25
- */
26
- export const getNumberFromBN = (value, decimals) => value.gt(new BN(2 ** 53 - 1)) ? value.div(new BN(10 ** decimals)).toNumber() : value.toNumber() / 10 ** decimals;
27
- /**
28
- * Calculate total amount of a Contract including all fees.
29
- * - first we convert fee floating to a BN with up to 4 decimals precision
30
- * - then we reverse the fee with `FEE_MULTIPLIER` to safely multiply it by depositedAmount
31
- * to receive a total number and not percentage of depositedAmount
32
- * @param depositedAmount deposited raw tokens
33
- * @param totalFee sum of all fees in percentage as floating number, e.g. 0.99% should be supplied as 0.99
34
- * @returns total tokens amount that Contract will retrieve from the Sender
35
- */
36
- export const calculateTotalAmountToDeposit = (depositedAmount, totalFee) => {
37
- const totalFeeNormalized = new BN(totalFee * FEE_NORMALIZER);
38
- return depositedAmount.mul(totalFeeNormalized.add(FEE_MULTIPLIER)).div(FEE_MULTIPLIER);
39
- };
40
- /**
41
- * Used to make on chain calls to the contract and wrap raised errors if any
42
- * @param func function that interacts with the contract
43
- * @param callback callback that may be used to extract error code
44
- * @returns {T}
45
- */
46
- export async function handleContractError(func, callback) {
47
- try {
48
- return await func();
49
- }
50
- catch (err) {
51
- if (err instanceof Error) {
52
- if (callback) {
53
- throw new ContractError(err, callback(err));
54
- }
55
- throw new ContractError(err);
56
- }
57
- throw err;
58
- }
59
- }
@@ -1,32 +0,0 @@
1
- import { ethers } from "ethers";
2
- import BN from "bn.js";
3
- import { BaseStreamClient } from "../common/BaseStreamClient.js";
4
- import { ICancelData, IChain, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetFeesData, IGetAllData, IGetOneData, IFees, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData, Stream } from "../common/types.js";
5
- export default class EvmStreamClient extends BaseStreamClient {
6
- private programId;
7
- private provider;
8
- private signer;
9
- private readContract;
10
- private writeContract;
11
- constructor(clusterUrl: string, chain: IChain, signer: ethers.Signer, cluster?: ICluster, programId?: string);
12
- create(streamData: ICreateStreamData): Promise<ICreateResult>;
13
- createMultiple(multipleStreamData: ICreateMultipleStreamData): Promise<IMultiTransactionResult>;
14
- withdraw({ id, amount }: IWithdrawData): Promise<ITransactionResult>;
15
- cancel(cancelData: ICancelData): Promise<ITransactionResult>;
16
- transfer(transferData: ITransferData): Promise<ITransactionResult>;
17
- topup(topupData: ITopUpData): Promise<ITransactionResult>;
18
- update(updateData: IUpdateData): Promise<ITransactionResult>;
19
- getOne({ id }: IGetOneData): Promise<Stream>;
20
- get({ address, direction, }: IGetAllData): Promise<[string, Stream][]>;
21
- extractErrorCode(err: Error): string | null;
22
- getFees({ address }: IGetFeesData): Promise<IFees | null>;
23
- getDefaultStreamflowFee(): Promise<number>;
24
- /**
25
- * Returns StreamClient protocol program ID.
26
- */
27
- getProgramId(): string;
28
- approveTokens(tokenId: string, amount: BN): Promise<void>;
29
- private generateMultiPayloads;
30
- private getFeeParams;
31
- private formatMetadataId;
32
- }