@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,20 +0,0 @@
1
- import { ContractErrorCode, ICluster } from "../common/types.js";
2
- export declare const ETHEREUM_PROGRAM_IDS: Record<ICluster, string>;
3
- export declare const BNB_PROGRAM_IDS: Record<ICluster, string>;
4
- export declare const POLYGON_PROGRAM_IDS: Record<ICluster, string>;
5
- export declare const EVM_ERROR_MATCH_REGEX: RegExp;
6
- export declare const EVM_ERROR_MAP: {
7
- ECONTRACT_NOT_INIT: ContractErrorCode;
8
- EBAD_AMOUNT: ContractErrorCode;
9
- ENO_PERMISSIONS: ContractErrorCode;
10
- EBADINPUT: ContractErrorCode;
11
- ECLOSED: ContractErrorCode;
12
- EBAD_INPUT_AMOUNT_PER_PERIOD: ContractErrorCode;
13
- EBAD_INPUT_PAUSABLE: ContractErrorCode;
14
- EBAD_INPUT_UPDATE_RATE: ContractErrorCode;
15
- EBAD_INPUT_CLIFF_AMOUNT: ContractErrorCode;
16
- EBAD_INPUT_PERIOD: ContractErrorCode;
17
- EBAD_INPUT_START: ContractErrorCode;
18
- EBAD_INSUFFICIENT_TOKEN_ALLOWANCE: ContractErrorCode;
19
- EBAD_INSUFFICIENT_WITHDRAWAL_FEES: ContractErrorCode;
20
- };
@@ -1,35 +0,0 @@
1
- import { ContractErrorCode, ICluster } from "../common/types.js";
2
- export const ETHEREUM_PROGRAM_IDS = {
3
- [ICluster.Mainnet]: "0x94d4646Bd307Bf91CB1893BC64d976BF9E60D9B2",
4
- [ICluster.Devnet]: "0x5Db7a43D20De64E3a3BC765334a477026FD13E7d",
5
- [ICluster.Testnet]: "0x5Db7a43D20De64E3a3BC765334a477026FD13E7d",
6
- [ICluster.Local]: "0x5Db7a43D20De64E3a3BC765334a477026FD13E7d",
7
- };
8
- export const BNB_PROGRAM_IDS = {
9
- [ICluster.Mainnet]: "0x94d4646Bd307Bf91CB1893BC64d976BF9E60D9B2",
10
- [ICluster.Devnet]: "0x5Db7a43D20De64E3a3BC765334a477026FD13E7d",
11
- [ICluster.Testnet]: "0x5Db7a43D20De64E3a3BC765334a477026FD13E7d",
12
- [ICluster.Local]: "0x5Db7a43D20De64E3a3BC765334a477026FD13E7d",
13
- };
14
- export const POLYGON_PROGRAM_IDS = {
15
- [ICluster.Mainnet]: "0x94d4646Bd307Bf91CB1893BC64d976BF9E60D9B2",
16
- [ICluster.Devnet]: "0x5Db7a43D20De64E3a3BC765334a477026FD13E7d",
17
- [ICluster.Testnet]: "0x5Db7a43D20De64E3a3BC765334a477026FD13E7d",
18
- [ICluster.Local]: "0x5Db7a43D20De64E3a3BC765334a477026FD13E7d",
19
- };
20
- export const EVM_ERROR_MATCH_REGEX = /execution reverted: ([A-Z_]+)/;
21
- export const EVM_ERROR_MAP = {
22
- ECONTRACT_NOT_INIT: ContractErrorCode.ECONTRACT_NOT_INIT,
23
- EBAD_AMOUNT: ContractErrorCode.EBAD_AMOUNT,
24
- ENO_PERMISSIONS: ContractErrorCode.ENO_PERMISSIONS,
25
- EBADINPUT: ContractErrorCode.EBADINPUT,
26
- ECLOSED: ContractErrorCode.ECLOSED,
27
- EBAD_INPUT_AMOUNT_PER_PERIOD: ContractErrorCode.EBAD_INPUT_AMOUNT_PER_PERIOD,
28
- EBAD_INPUT_PAUSABLE: ContractErrorCode.EBAD_INPUT_PAUSABLE,
29
- EBAD_INPUT_UPDATE_RATE: ContractErrorCode.EBAD_INPUT_UPDATE_RATE,
30
- EBAD_INPUT_CLIFF_AMOUNT: ContractErrorCode.EBAD_INPUT_CLIFF_AMOUNT,
31
- EBAD_INPUT_PERIOD: ContractErrorCode.EBAD_INPUT_PERIOD,
32
- EBAD_INPUT_START: ContractErrorCode.EBAD_INPUT_START,
33
- EBAD_INSUFFICIENT_TOKEN_ALLOWANCE: ContractErrorCode.EBAD_INSUFFICIENT_TOKEN_ALLOWANCE,
34
- EBAD_INSUFFICIENT_WITHDRAWAL_FEES: ContractErrorCode.EBAD_INSUFFICIENT_WITHDRAWAL_FEES,
35
- };
@@ -1,39 +0,0 @@
1
- declare const _default: ({
2
- constant: boolean;
3
- inputs: {
4
- name: string;
5
- type: string;
6
- }[];
7
- name: string;
8
- outputs: {
9
- name: string;
10
- type: string;
11
- }[];
12
- payable: boolean;
13
- stateMutability: string;
14
- type: string;
15
- anonymous?: undefined;
16
- } | {
17
- payable: boolean;
18
- stateMutability: string;
19
- type: string;
20
- constant?: undefined;
21
- inputs?: undefined;
22
- name?: undefined;
23
- outputs?: undefined;
24
- anonymous?: undefined;
25
- } | {
26
- anonymous: boolean;
27
- inputs: {
28
- indexed: boolean;
29
- name: string;
30
- type: string;
31
- }[];
32
- name: string;
33
- type: string;
34
- constant?: undefined;
35
- outputs?: undefined;
36
- payable?: undefined;
37
- stateMutability?: undefined;
38
- })[];
39
- export default _default;
@@ -1,222 +0,0 @@
1
- export default [
2
- {
3
- constant: true,
4
- inputs: [],
5
- name: "name",
6
- outputs: [
7
- {
8
- name: "",
9
- type: "string",
10
- },
11
- ],
12
- payable: false,
13
- stateMutability: "view",
14
- type: "function",
15
- },
16
- {
17
- constant: false,
18
- inputs: [
19
- {
20
- name: "_spender",
21
- type: "address",
22
- },
23
- {
24
- name: "_value",
25
- type: "uint256",
26
- },
27
- ],
28
- name: "approve",
29
- outputs: [
30
- {
31
- name: "",
32
- type: "bool",
33
- },
34
- ],
35
- payable: false,
36
- stateMutability: "nonpayable",
37
- type: "function",
38
- },
39
- {
40
- constant: true,
41
- inputs: [],
42
- name: "totalSupply",
43
- outputs: [
44
- {
45
- name: "",
46
- type: "uint256",
47
- },
48
- ],
49
- payable: false,
50
- stateMutability: "view",
51
- type: "function",
52
- },
53
- {
54
- constant: false,
55
- inputs: [
56
- {
57
- name: "_from",
58
- type: "address",
59
- },
60
- {
61
- name: "_to",
62
- type: "address",
63
- },
64
- {
65
- name: "_value",
66
- type: "uint256",
67
- },
68
- ],
69
- name: "transferFrom",
70
- outputs: [
71
- {
72
- name: "",
73
- type: "bool",
74
- },
75
- ],
76
- payable: false,
77
- stateMutability: "nonpayable",
78
- type: "function",
79
- },
80
- {
81
- constant: true,
82
- inputs: [],
83
- name: "decimals",
84
- outputs: [
85
- {
86
- name: "",
87
- type: "uint8",
88
- },
89
- ],
90
- payable: false,
91
- stateMutability: "view",
92
- type: "function",
93
- },
94
- {
95
- constant: true,
96
- inputs: [
97
- {
98
- name: "_owner",
99
- type: "address",
100
- },
101
- ],
102
- name: "balanceOf",
103
- outputs: [
104
- {
105
- name: "balance",
106
- type: "uint256",
107
- },
108
- ],
109
- payable: false,
110
- stateMutability: "view",
111
- type: "function",
112
- },
113
- {
114
- constant: true,
115
- inputs: [],
116
- name: "symbol",
117
- outputs: [
118
- {
119
- name: "",
120
- type: "string",
121
- },
122
- ],
123
- payable: false,
124
- stateMutability: "view",
125
- type: "function",
126
- },
127
- {
128
- constant: false,
129
- inputs: [
130
- {
131
- name: "_to",
132
- type: "address",
133
- },
134
- {
135
- name: "_value",
136
- type: "uint256",
137
- },
138
- ],
139
- name: "transfer",
140
- outputs: [
141
- {
142
- name: "",
143
- type: "bool",
144
- },
145
- ],
146
- payable: false,
147
- stateMutability: "nonpayable",
148
- type: "function",
149
- },
150
- {
151
- constant: true,
152
- inputs: [
153
- {
154
- name: "_owner",
155
- type: "address",
156
- },
157
- {
158
- name: "_spender",
159
- type: "address",
160
- },
161
- ],
162
- name: "allowance",
163
- outputs: [
164
- {
165
- name: "",
166
- type: "uint256",
167
- },
168
- ],
169
- payable: false,
170
- stateMutability: "view",
171
- type: "function",
172
- },
173
- {
174
- payable: true,
175
- stateMutability: "payable",
176
- type: "fallback",
177
- },
178
- {
179
- anonymous: false,
180
- inputs: [
181
- {
182
- indexed: true,
183
- name: "owner",
184
- type: "address",
185
- },
186
- {
187
- indexed: true,
188
- name: "spender",
189
- type: "address",
190
- },
191
- {
192
- indexed: false,
193
- name: "value",
194
- type: "uint256",
195
- },
196
- ],
197
- name: "Approval",
198
- type: "event",
199
- },
200
- {
201
- anonymous: false,
202
- inputs: [
203
- {
204
- indexed: true,
205
- name: "from",
206
- type: "address",
207
- },
208
- {
209
- indexed: true,
210
- name: "to",
211
- type: "address",
212
- },
213
- {
214
- indexed: false,
215
- name: "value",
216
- type: "uint256",
217
- },
218
- ],
219
- name: "Transfer",
220
- type: "event",
221
- },
222
- ];
@@ -1,98 +0,0 @@
1
- import BN from "bn.js";
2
- import { BigNumber as BigNumberEvm } from "ethers";
3
- import { LinearStream, StreamType } from "../common/types.js";
4
- export interface StreamAbiResult {
5
- amount: BigNumberEvm;
6
- amount_per_period: BigNumberEvm;
7
- canceled_at: BigNumberEvm;
8
- cliff_amount: BigNumberEvm;
9
- closed: boolean;
10
- created: BigNumberEvm;
11
- current_pause_start: BigNumberEvm;
12
- end: BigNumberEvm;
13
- fees: {
14
- streamflow_fee_percentage: BigNumberEvm;
15
- streamflow_fee: BigNumberEvm;
16
- streamflow_fee_withdrawn: BigNumberEvm;
17
- partner_fee_percentage: BigNumberEvm;
18
- partner_fee: BigNumberEvm;
19
- partner_fee_withdrawn: BigNumberEvm;
20
- tx_fee: BigNumberEvm;
21
- };
22
- funds_unlocked_at_last_rate_change: BigNumberEvm;
23
- last_rate_change_time: BigNumberEvm;
24
- last_withdrawn_at: BigNumberEvm;
25
- meta: {
26
- automatic_withdrawal: boolean;
27
- can_topup: boolean;
28
- can_update_rate: boolean;
29
- cancelable_by_recipient: boolean;
30
- cancelable_by_sender: boolean;
31
- contract_name: string;
32
- pausable: boolean;
33
- transferable_by_recipient: boolean;
34
- transferable_by_sender: boolean;
35
- withdrawal_frequency: BigNumberEvm;
36
- };
37
- pause_cumulative: BigNumberEvm;
38
- period: BigNumberEvm;
39
- recipient: string;
40
- sender: string;
41
- partner: string;
42
- start: BigNumberEvm;
43
- token: string;
44
- withdrawn: BigNumberEvm;
45
- }
46
- export interface FeesAbiResult {
47
- exists: boolean;
48
- streamflow_fee: BigNumberEvm;
49
- partner_fee: BigNumberEvm;
50
- }
51
- export declare class EvmContract implements LinearStream {
52
- magic: number;
53
- version: number;
54
- createdAt: number;
55
- withdrawnAmount: BN;
56
- canceledAt: number;
57
- end: number;
58
- lastWithdrawnAt: number;
59
- sender: string;
60
- senderTokens: string;
61
- recipient: string;
62
- recipientTokens: string;
63
- mint: string;
64
- escrowTokens: string;
65
- streamflowTreasury: string;
66
- streamflowTreasuryTokens: string;
67
- streamflowFeeTotal: BN;
68
- streamflowFeeWithdrawn: BN;
69
- streamflowFeePercent: number;
70
- partnerFeeTotal: BN;
71
- partnerFeeWithdrawn: BN;
72
- partnerFeePercent: number;
73
- partner: string;
74
- partnerTokens: string;
75
- start: number;
76
- depositedAmount: BN;
77
- period: number;
78
- amountPerPeriod: BN;
79
- cliff: number;
80
- cliffAmount: BN;
81
- cancelableBySender: boolean;
82
- cancelableByRecipient: boolean;
83
- automaticWithdrawal: boolean;
84
- transferableBySender: boolean;
85
- transferableByRecipient: boolean;
86
- canTopup: boolean;
87
- name: string;
88
- withdrawalFrequency: number;
89
- closed: boolean;
90
- currentPauseStart: number;
91
- pauseCumulative: BN;
92
- lastRateChangeTime: number;
93
- fundsUnlockedAtLastRateChange: BN;
94
- type: StreamType;
95
- constructor(stream: StreamAbiResult);
96
- unlocked(currentTimestamp: number): BN;
97
- remaining(decimals: number): number;
98
- }
@@ -1,102 +0,0 @@
1
- import BN from "bn.js";
2
- import { buildStreamType, calculateUnlockedAmount } from "../common/contractUtils.js";
3
- import { getNumberFromBN } from "../common/utils.js";
4
- export class EvmContract {
5
- magic;
6
- version;
7
- createdAt;
8
- withdrawnAmount;
9
- canceledAt;
10
- end;
11
- lastWithdrawnAt;
12
- sender;
13
- senderTokens;
14
- recipient;
15
- recipientTokens;
16
- mint;
17
- escrowTokens;
18
- streamflowTreasury;
19
- streamflowTreasuryTokens;
20
- streamflowFeeTotal;
21
- streamflowFeeWithdrawn;
22
- streamflowFeePercent;
23
- partnerFeeTotal;
24
- partnerFeeWithdrawn;
25
- partnerFeePercent;
26
- partner;
27
- partnerTokens;
28
- start;
29
- depositedAmount;
30
- period;
31
- amountPerPeriod;
32
- cliff;
33
- cliffAmount;
34
- cancelableBySender;
35
- cancelableByRecipient;
36
- automaticWithdrawal;
37
- transferableBySender;
38
- transferableByRecipient;
39
- canTopup;
40
- name;
41
- withdrawalFrequency;
42
- closed;
43
- currentPauseStart;
44
- pauseCumulative;
45
- lastRateChangeTime;
46
- fundsUnlockedAtLastRateChange;
47
- type;
48
- constructor(stream) {
49
- this.magic = 0;
50
- this.version = 0;
51
- this.createdAt = stream.created.toNumber();
52
- this.withdrawnAmount = new BN(stream.withdrawn.toString());
53
- this.canceledAt = stream.canceled_at.toNumber();
54
- this.end = stream.end.toNumber();
55
- this.lastWithdrawnAt = stream.last_withdrawn_at.toNumber();
56
- this.sender = stream.sender;
57
- this.senderTokens = stream.sender;
58
- this.recipient = stream.recipient;
59
- this.recipientTokens = stream.recipient;
60
- this.mint = stream.token.toLowerCase();
61
- this.escrowTokens = "";
62
- this.streamflowTreasury = "";
63
- this.streamflowTreasuryTokens = "";
64
- this.streamflowFeeTotal = new BN(stream.fees.streamflow_fee.toString());
65
- this.streamflowFeeWithdrawn = new BN(stream.fees.streamflow_fee_withdrawn.toString());
66
- this.streamflowFeePercent = stream.fees.streamflow_fee_percentage.toNumber() / 10000;
67
- this.partnerFeeTotal = new BN(0);
68
- this.partnerFeeWithdrawn = new BN(0);
69
- this.partnerFeePercent = 0;
70
- this.partner = "";
71
- this.partnerTokens = "";
72
- this.start = stream.start.toNumber();
73
- this.depositedAmount = new BN(stream.amount.toString());
74
- this.period = stream.period.toNumber();
75
- this.amountPerPeriod = new BN(stream.amount_per_period.toString());
76
- this.cliff = stream.start.toNumber();
77
- this.cliffAmount = new BN(stream.cliff_amount.toString());
78
- this.cancelableBySender = stream.meta.cancelable_by_sender;
79
- this.cancelableByRecipient = stream.meta.cancelable_by_recipient;
80
- this.automaticWithdrawal = stream.meta.automatic_withdrawal;
81
- this.transferableBySender = stream.meta.transferable_by_sender;
82
- this.transferableByRecipient = stream.meta.transferable_by_recipient;
83
- this.canTopup = stream.meta.can_topup;
84
- this.name = stream.meta.contract_name;
85
- this.withdrawalFrequency = stream.meta.withdrawal_frequency.toNumber();
86
- this.closed = stream.closed;
87
- this.currentPauseStart = stream.current_pause_start.toNumber();
88
- this.pauseCumulative = new BN(stream.pause_cumulative.toString());
89
- this.lastRateChangeTime = stream.last_rate_change_time.toNumber();
90
- this.fundsUnlockedAtLastRateChange = new BN(stream.funds_unlocked_at_last_rate_change.toString());
91
- this.type = buildStreamType(this);
92
- }
93
- unlocked(currentTimestamp) {
94
- return calculateUnlockedAmount({
95
- ...this,
96
- currentTimestamp,
97
- });
98
- }
99
- remaining(decimals) {
100
- return getNumberFromBN(this.depositedAmount.sub(this.withdrawnAmount), decimals);
101
- }
102
- }
@@ -1 +0,0 @@
1
- export declare function extractEvmErrorCode(errorText: string): string | null;
@@ -1,8 +0,0 @@
1
- import { EVM_ERROR_MATCH_REGEX } from "./constants.js";
2
- export function extractEvmErrorCode(errorText) {
3
- const match = EVM_ERROR_MATCH_REGEX.exec(errorText);
4
- if (!match) {
5
- return null;
6
- }
7
- return match[1];
8
- }
@@ -1,150 +0,0 @@
1
- import PQueue from "p-queue";
2
- import { Connection, Keypair, PublicKey, TransactionInstruction, Commitment, ConnectionConfig } from "@solana/web3.js";
3
- import { IProgramAccount } from "@streamflow/common/solana";
4
- import { Program } from "@coral-xyz/anchor";
5
- import { ICreateStreamSolanaExt, IInteractStreamSolanaExt, ITopUpStreamSolanaExt, ISearchStreams, ICreateStreamInstructions } from "./types.js";
6
- import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetAllData, IGetFeesData, IGetOneData, IFees, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData, Stream, ICreateAlignedStreamData, SolanaStreamClientOptions } from "../common/types.js";
7
- import { BaseStreamClient } from "../common/BaseStreamClient.js";
8
- import { StreamflowAlignedUnlocks as AlignedUnlocksProgramType } from "./descriptor/streamflow_aligned_unlocks.js";
9
- /**
10
- * Solana Client creation options
11
- * @property cluster {@link ICluster} cluster type
12
- * @property clusterUrl cluster url
13
- * @interface ClientCreationOptions
14
- */
15
- export type ClientCreationOptions = Omit<SolanaStreamClientOptions, "chain" | "sendRate" | "sendThrottler">;
16
- export declare class SolanaStreamClient extends BaseStreamClient {
17
- private readonly connection;
18
- private readonly programId;
19
- private readonly commitment;
20
- readonly alignedProxyProgram: Program<AlignedUnlocksProgramType>;
21
- private readonly schedulingParams;
22
- /**
23
- * Create Stream instance with flat arguments
24
- */
25
- constructor(clusterUrl: string, cluster?: ICluster, commitment?: Commitment | ConnectionConfig, programId?: string, sendRate?: number, sendThrottler?: PQueue);
26
- /**
27
- * Create Stream instance with options
28
- */
29
- constructor(options: ClientCreationOptions);
30
- getConnection(): Connection;
31
- getCommitment(): Commitment | undefined;
32
- getProgramId(): string;
33
- /**
34
- * Creates a new stream/vesting contract.
35
- * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
36
- */
37
- create(data: ICreateStreamData, extParams: ICreateStreamSolanaExt): Promise<ICreateResult>;
38
- prepareCreateInstructions(streamParams: ICreateStreamData, extParams: ICreateStreamSolanaExt): Promise<ICreateStreamInstructions>;
39
- prepareCreateAlignedUnlockInstructions(streamParams: ICreateAlignedStreamData, extParams: ICreateStreamSolanaExt): Promise<ICreateStreamInstructions>;
40
- /**
41
- * Creates a new stream/vesting contract.
42
- * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
43
- */
44
- prepareCreateStreamInstructions({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canPause, canUpdateRate, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, tokenProgramId: streamTokenProgramId, }: ICreateStreamData, { sender, metadataPubKeys, isNative, computePrice, computeLimit }: ICreateStreamSolanaExt): Promise<ICreateStreamInstructions>;
45
- /**
46
- * Creates a new stream/vesting contract using unchecked instruction.
47
- *
48
- * Unchecked instruction differs from the regular in:
49
- * - does not check for initialized associated token account (wallets with no control over their ATA should not be used
50
- * as sender/recipient/partner or there are risks of funds being locked in the contract)
51
- * - initialized contract PDA off chain
52
- *
53
- * If you are not sure if you should use create or create_unchecked, go for create to be safer.
54
- */
55
- createUnchecked(data: ICreateStreamData, extParams: ICreateStreamSolanaExt): Promise<ICreateResult>;
56
- /**
57
- * Create Transaction instructions for `createUnchecked`
58
- */
59
- prepareCreateUncheckedInstructions({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, canUpdateRate, canPause, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, }: ICreateStreamData, { sender, metadataPubKeys, isNative, computePrice, computeLimit }: ICreateStreamSolanaExt): Promise<{
60
- ixs: TransactionInstruction[];
61
- metadata: Keypair | undefined;
62
- metadataPubKey: PublicKey;
63
- }>;
64
- /**
65
- * Creates multiple stream/vesting contracts.
66
- * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
67
- */
68
- createMultiple(data: ICreateMultipleStreamData, extParams: ICreateStreamSolanaExt): Promise<IMultiTransactionResult>;
69
- /**
70
- * Creates multiple stream/vesting contracts, and send all transactions sequentially.
71
- * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
72
- * In most cases, createMultiple should be used instead.
73
- */
74
- createMultipleSequential(data: ICreateMultipleStreamData, extParams: ICreateStreamSolanaExt): Promise<IMultiTransactionResult>;
75
- /**
76
- * Attempts withdrawing from the specified stream.
77
- */
78
- withdraw({ id, amount }: IWithdrawData, extParams: IInteractStreamSolanaExt): Promise<ITransactionResult>;
79
- /**
80
- * Creates Transaction Instructions for withdrawal
81
- */
82
- prepareWithdrawInstructions({ id, amount }: IWithdrawData, { invoker, checkTokenAccounts, computePrice, computeLimit }: IInteractStreamSolanaExt): Promise<TransactionInstruction[]>;
83
- /**
84
- * Attempts canceling the specified stream.
85
- */
86
- cancel(cancelData: ICancelData, extParams: IInteractStreamSolanaExt): Promise<ITransactionResult>;
87
- prepareCancelInstructions(cancelData: ICancelData, extParams: IInteractStreamSolanaExt): Promise<TransactionInstruction[]>;
88
- prepareCancelAlignedUnlockInstructions({ id }: ICancelData, { invoker, checkTokenAccounts, computePrice, computeLimit }: IInteractStreamSolanaExt): Promise<TransactionInstruction[]>;
89
- /**
90
- * Creates Transaction Instructions for cancel
91
- */
92
- prepareCancelStreamInstructions({ id }: ICancelData, { invoker, checkTokenAccounts, computePrice, computeLimit }: IInteractStreamSolanaExt): Promise<TransactionInstruction[]>;
93
- /**
94
- * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
95
- * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
96
- */
97
- transfer({ id, newRecipient }: ITransferData, extParams: IInteractStreamSolanaExt): Promise<ITransactionResult>;
98
- /**
99
- * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
100
- * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
101
- */
102
- prepareTransferInstructions({ id, newRecipient }: ITransferData, { invoker, computePrice, computeLimit }: IInteractStreamSolanaExt): Promise<TransactionInstruction[]>;
103
- /**
104
- * Tops up stream account with specified amount.
105
- */
106
- topup({ id, amount }: ITopUpData, extParams: ITopUpStreamSolanaExt): Promise<ITransactionResult>;
107
- /**
108
- * Create Transaction instructions for topup
109
- */
110
- prepareTopupInstructions({ id, amount }: ITopUpData, { invoker, isNative, computePrice, computeLimit }: ITopUpStreamSolanaExt): Promise<TransactionInstruction[]>;
111
- /**
112
- * Fetch stream data by its id (address).
113
- */
114
- getOne({ id }: IGetOneData): Promise<Stream>;
115
- /**
116
- * Fetch all aligned outgoing streams/contracts by the provided public key.
117
- */
118
- private getOutgoingAlignedStreams;
119
- private getIncomingAlignedStreams;
120
- /**
121
- * Fetch streams/contracts by providing direction.
122
- * Streams are sorted by start time in ascending order.
123
- */
124
- get({ address, type, direction, }: IGetAllData): Promise<[string, Stream][]>;
125
- searchStreams(data: ISearchStreams): Promise<IProgramAccount<Stream>[]>;
126
- /**
127
- * Attempts updating the stream auto withdrawal params and amount per period
128
- */
129
- update(data: IUpdateData, extParams: IInteractStreamSolanaExt): Promise<ITransactionResult>;
130
- /**
131
- * Create Transaction instructions for update
132
- */
133
- prepareUpdateInstructions(data: IUpdateData, { invoker, computePrice, computeLimit }: IInteractStreamSolanaExt): Promise<TransactionInstruction[]>;
134
- getFees({ address }: IGetFeesData): Promise<IFees | null>;
135
- getDefaultStreamflowFee(): Promise<number>;
136
- extractErrorCode(err: Error): string | null;
137
- /**
138
- * Utility function to generate metadata for a Contract or return existing Pubkey
139
- */
140
- private getOrCreateStreamMetadata;
141
- /**
142
- * Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
143
- */
144
- private isAlignedUnlock;
145
- /**
146
- * Returns insrtuctions for creating associated token accounts for the provided owners
147
- */
148
- private getCreateATAInstructions;
149
- private applyCustomAfterInstructions;
150
- }