@streamflow/stream 3.0.10 → 3.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/StreamClient.js +1 -1
- package/dist/__tests__/streams.spec.d.ts +0 -15
- package/dist/__tests__/streams.spec.js +165 -249
- package/package.json +5 -1
package/dist/StreamClient.js
CHANGED
|
@@ -925,7 +925,7 @@ function ata(mint, account) {
|
|
|
925
925
|
return __awaiter(this, void 0, void 0, function () {
|
|
926
926
|
return __generator(this, function (_a) {
|
|
927
927
|
switch (_a.label) {
|
|
928
|
-
case 0: return [4 /*yield*/, spl_token_1.Token.getAssociatedTokenAddress(spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, spl_token_1.TOKEN_PROGRAM_ID, mint, account)];
|
|
928
|
+
case 0: return [4 /*yield*/, spl_token_1.Token.getAssociatedTokenAddress(spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, spl_token_1.TOKEN_PROGRAM_ID, mint, account, true)];
|
|
929
929
|
case 1: return [2 /*return*/, _a.sent()];
|
|
930
930
|
}
|
|
931
931
|
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare const DATE_FORMAT = "yyyy-MM-dd";
|
|
2
|
-
export declare const TIME_FORMAT = "HH:mm";
|
|
3
|
-
export declare const PERIOD: {
|
|
4
|
-
SECOND: number;
|
|
5
|
-
MINUTE: number;
|
|
6
|
-
HOUR: number;
|
|
7
|
-
DAY: number;
|
|
8
|
-
WEEK: number;
|
|
9
|
-
MONTH: number;
|
|
10
|
-
YEAR: number;
|
|
11
|
-
};
|
|
12
|
-
export declare const timePeriodOptions: {
|
|
13
|
-
value: number;
|
|
14
|
-
label: string;
|
|
15
|
-
}[];
|
|
@@ -1,250 +1,166 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
})
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
amountPerPeriod: (0, utils_1.getBN)(releaseAmount, 9),
|
|
168
|
-
cliffAmount: new bn_js_1.BN(0),
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
var data = {
|
|
172
|
-
sender: sender,
|
|
173
|
-
recipientsData: recipientsFormatted,
|
|
174
|
-
mint: constants_1.AIRDROP_TEST_TOKEN,
|
|
175
|
-
start: start,
|
|
176
|
-
period: releaseFrequencyCounter * releaseFrequencyPeriod,
|
|
177
|
-
cliff: start,
|
|
178
|
-
cancelableBySender: whoCanCancel === types_1.TransferCancelOptions.Sender ||
|
|
179
|
-
whoCanCancel === types_1.TransferCancelOptions.Both,
|
|
180
|
-
cancelableByRecipient: whoCanCancel === types_1.TransferCancelOptions.Recipient ||
|
|
181
|
-
whoCanCancel === types_1.TransferCancelOptions.Both,
|
|
182
|
-
transferableBySender: whoCanTransfer === types_1.TransferCancelOptions.Sender ||
|
|
183
|
-
whoCanTransfer === types_1.TransferCancelOptions.Both,
|
|
184
|
-
transferableByRecipient: whoCanTransfer === types_1.TransferCancelOptions.Recipient ||
|
|
185
|
-
whoCanTransfer === types_1.TransferCancelOptions.Both,
|
|
186
|
-
automaticWithdrawal: false,
|
|
187
|
-
withdrawalFrequency: 0,
|
|
188
|
-
canTopup: true,
|
|
189
|
-
partner: referral,
|
|
190
|
-
};
|
|
191
|
-
return data;
|
|
192
|
-
};
|
|
193
|
-
exports.DATE_FORMAT = "yyyy-MM-dd";
|
|
194
|
-
exports.TIME_FORMAT = "HH:mm";
|
|
195
|
-
exports.PERIOD = {
|
|
196
|
-
SECOND: 1,
|
|
197
|
-
MINUTE: 60,
|
|
198
|
-
HOUR: 3600,
|
|
199
|
-
DAY: 24 * 3600,
|
|
200
|
-
WEEK: 7 * 24 * 3600,
|
|
201
|
-
MONTH: Math.floor(30.4167 * 24 * 3600),
|
|
202
|
-
YEAR: 365 * 24 * 3600, // 365 days
|
|
203
|
-
};
|
|
204
|
-
exports.timePeriodOptions = [
|
|
205
|
-
{ value: exports.PERIOD.SECOND, label: "second" },
|
|
206
|
-
{ value: exports.PERIOD.MINUTE, label: "minute" },
|
|
207
|
-
{ value: exports.PERIOD.HOUR, label: "hour" },
|
|
208
|
-
{ value: exports.PERIOD.DAY, label: "day" },
|
|
209
|
-
{ value: exports.PERIOD.WEEK, label: "week" },
|
|
210
|
-
{ value: exports.PERIOD.MONTH, label: "month" },
|
|
211
|
-
{ value: exports.PERIOD.YEAR, label: "year" },
|
|
212
|
-
];
|
|
213
|
-
test("Can create multiple stremas", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
214
|
-
var now, recipientsPayload, values, data, response, errors;
|
|
215
|
-
return __generator(this, function (_a) {
|
|
216
|
-
switch (_a.label) {
|
|
217
|
-
case 0:
|
|
218
|
-
now = new Date();
|
|
219
|
-
recipientsPayload = recipients.map(function (recipient, i) { return ({
|
|
220
|
-
recipient: recipient.publicKey.toBase58(),
|
|
221
|
-
recipientEmail: "",
|
|
222
|
-
name: "Recipient " + i,
|
|
223
|
-
depositedAmount: 0.0001,
|
|
224
|
-
}); });
|
|
225
|
-
values = {
|
|
226
|
-
releaseAmount: 0.00001,
|
|
227
|
-
tokenSymbol: "",
|
|
228
|
-
startDate: (0, date_fns_1.format)(now, exports.DATE_FORMAT),
|
|
229
|
-
startTime: (0, date_fns_1.format)((0, date_fns_1.add)(now, { minutes: 5 }), exports.TIME_FORMAT),
|
|
230
|
-
releaseFrequencyCounter: 1,
|
|
231
|
-
releaseFrequencyPeriod: exports.timePeriodOptions[0].value,
|
|
232
|
-
whoCanTransfer: types_1.TransferCancelOptions.Recipient,
|
|
233
|
-
whoCanCancel: types_1.TransferCancelOptions.Sender,
|
|
234
|
-
automaticWithdrawal: false,
|
|
235
|
-
withdrawalFrequencyCounter: 1,
|
|
236
|
-
withdrawalFrequencyPeriod: exports.timePeriodOptions[1].value,
|
|
237
|
-
referral: "",
|
|
238
|
-
email: "",
|
|
239
|
-
recipients: recipientsPayload,
|
|
240
|
-
};
|
|
241
|
-
data = newCreateMultipleStreamsPayload(values, sender);
|
|
242
|
-
return [4 /*yield*/, (streamInstance === null || streamInstance === void 0 ? void 0 : streamInstance.createMultiple(data))];
|
|
243
|
-
case 1:
|
|
244
|
-
response = _a.sent();
|
|
245
|
-
errors = response === null || response === void 0 ? void 0 : response.errors;
|
|
246
|
-
console.log(errors);
|
|
247
|
-
return [2 /*return*/, response];
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
}); }, 600000);
|
|
2
|
+
// import StreamClient from "../StreamClient";
|
|
3
|
+
// import {
|
|
4
|
+
// Cluster,
|
|
5
|
+
// CreateMultiParams,
|
|
6
|
+
// CreateMultipleStreamsValues,
|
|
7
|
+
// LocalCluster,
|
|
8
|
+
// TransferCancelOptions,
|
|
9
|
+
// } from "../types";
|
|
10
|
+
// import * as web3 from "@solana/web3.js";
|
|
11
|
+
// import { getBN } from "../utils";
|
|
12
|
+
// import { requestAirdrop } from "./test_dependencies/airdrop/airdrop-request";
|
|
13
|
+
// import { Wallet } from "@project-serum/anchor";
|
|
14
|
+
// import { AIRDROP_TEST_TOKEN } from "../constants";
|
|
15
|
+
// import { BN } from "bn.js";
|
|
16
|
+
// let streamInstance: StreamClient | null = null;
|
|
17
|
+
// let sender: Wallet;
|
|
18
|
+
// let recipient: Wallet;
|
|
19
|
+
// let recipients: Wallet[] = [];
|
|
20
|
+
// let connection: web3.Connection | null = null;
|
|
21
|
+
// import { add, addMinutes, format, getUnixTime } from "date-fns";
|
|
22
|
+
// const CLUSTER_LOCAL = "local";
|
|
23
|
+
//
|
|
24
|
+
// const clusterUrls: { [s: string]: () => string } = {
|
|
25
|
+
// [CLUSTER_LOCAL]: () => "http://localhost:8899", // http://127.0.0.1:8899",
|
|
26
|
+
// [Cluster.Devnet]: () => "https://api.devnet.solana.com",
|
|
27
|
+
// [Cluster.Mainnet]: () => "https://api.mainnet-beta.solana.com",
|
|
28
|
+
// };
|
|
29
|
+
// beforeAll(async () => {
|
|
30
|
+
// streamInstance = new StreamClient(
|
|
31
|
+
// clusterUrls[Cluster.Devnet](),
|
|
32
|
+
// Cluster.Devnet,
|
|
33
|
+
// {
|
|
34
|
+
// commitment: "confirmed",
|
|
35
|
+
// disableRetryOnRateLimit: true,
|
|
36
|
+
// }
|
|
37
|
+
// );
|
|
38
|
+
// connection = new web3.Connection(web3.clusterApiUrl(), "confirmed");
|
|
39
|
+
//
|
|
40
|
+
// sender = new Wallet(web3.Keypair.generate());
|
|
41
|
+
// recipient = new Wallet(web3.Keypair.generate());
|
|
42
|
+
// recipients = [...new Array(10)].map(
|
|
43
|
+
// () => new Wallet(web3.Keypair.generate())
|
|
44
|
+
// );
|
|
45
|
+
// await requestAirdrop(sender, connection);
|
|
46
|
+
// }, 100000);
|
|
47
|
+
//
|
|
48
|
+
// test("Sender wallet airdropped funds", async () => {
|
|
49
|
+
// expect(await connection?.getBalance(sender.publicKey)).toBeGreaterThan(0);
|
|
50
|
+
// }, 100000);
|
|
51
|
+
//
|
|
52
|
+
// test("Stream client connects to cluster", async () => {
|
|
53
|
+
// expect(streamInstance).toBeTruthy();
|
|
54
|
+
// const streamInstanceConnection = await streamInstance?.getConnection();
|
|
55
|
+
// expect(streamInstanceConnection).toBeTruthy();
|
|
56
|
+
// });
|
|
57
|
+
//
|
|
58
|
+
// const newCreateMultipleStreamsPayload = (
|
|
59
|
+
// values: CreateMultipleStreamsValues,
|
|
60
|
+
// sender: Wallet
|
|
61
|
+
// ) => {
|
|
62
|
+
// const {
|
|
63
|
+
// recipients,
|
|
64
|
+
// releaseAmount,
|
|
65
|
+
// startDate,
|
|
66
|
+
// startTime,
|
|
67
|
+
// releaseFrequencyCounter,
|
|
68
|
+
// releaseFrequencyPeriod,
|
|
69
|
+
// whoCanTransfer,
|
|
70
|
+
// whoCanCancel,
|
|
71
|
+
// referral,
|
|
72
|
+
// } = values;
|
|
73
|
+
//
|
|
74
|
+
// const start = getUnixTime(new Date(startDate + "T" + startTime));
|
|
75
|
+
//
|
|
76
|
+
// const recipientsFormatted = recipients.map(
|
|
77
|
+
// ({ depositedAmount, recipient, name }) => ({
|
|
78
|
+
// recipient,
|
|
79
|
+
// name,
|
|
80
|
+
// depositedAmount: getBN(depositedAmount, 9),
|
|
81
|
+
// amountPerPeriod: getBN(releaseAmount, 9),
|
|
82
|
+
// cliffAmount: new BN(0),
|
|
83
|
+
// })
|
|
84
|
+
// );
|
|
85
|
+
// const data: CreateMultiParams = {
|
|
86
|
+
// sender,
|
|
87
|
+
// recipientsData: recipientsFormatted,
|
|
88
|
+
// mint: AIRDROP_TEST_TOKEN,
|
|
89
|
+
// start,
|
|
90
|
+
// period: releaseFrequencyCounter * releaseFrequencyPeriod,
|
|
91
|
+
// cliff: start,
|
|
92
|
+
// cancelableBySender:
|
|
93
|
+
// whoCanCancel === TransferCancelOptions.Sender ||
|
|
94
|
+
// whoCanCancel === TransferCancelOptions.Both,
|
|
95
|
+
// cancelableByRecipient:
|
|
96
|
+
// whoCanCancel === TransferCancelOptions.Recipient ||
|
|
97
|
+
// whoCanCancel === TransferCancelOptions.Both,
|
|
98
|
+
// transferableBySender:
|
|
99
|
+
// whoCanTransfer === TransferCancelOptions.Sender ||
|
|
100
|
+
// whoCanTransfer === TransferCancelOptions.Both,
|
|
101
|
+
// transferableByRecipient:
|
|
102
|
+
// whoCanTransfer === TransferCancelOptions.Recipient ||
|
|
103
|
+
// whoCanTransfer === TransferCancelOptions.Both,
|
|
104
|
+
// automaticWithdrawal: false,
|
|
105
|
+
// withdrawalFrequency: 0,
|
|
106
|
+
// canTopup: true,
|
|
107
|
+
// partner: referral,
|
|
108
|
+
// };
|
|
109
|
+
//
|
|
110
|
+
// return data;
|
|
111
|
+
// };
|
|
112
|
+
//
|
|
113
|
+
// export const DATE_FORMAT = "yyyy-MM-dd";
|
|
114
|
+
// export const TIME_FORMAT = "HH:mm";
|
|
115
|
+
//
|
|
116
|
+
// export const PERIOD = {
|
|
117
|
+
// SECOND: 1,
|
|
118
|
+
// MINUTE: 60,
|
|
119
|
+
// HOUR: 3600,
|
|
120
|
+
// DAY: 24 * 3600,
|
|
121
|
+
// WEEK: 7 * 24 * 3600,
|
|
122
|
+
// MONTH: Math.floor(30.4167 * 24 * 3600), //30.4167 days
|
|
123
|
+
// YEAR: 365 * 24 * 3600, // 365 days
|
|
124
|
+
// };
|
|
125
|
+
//
|
|
126
|
+
// export const timePeriodOptions = [
|
|
127
|
+
// { value: PERIOD.SECOND, label: "second" },
|
|
128
|
+
// { value: PERIOD.MINUTE, label: "minute" },
|
|
129
|
+
// { value: PERIOD.HOUR, label: "hour" },
|
|
130
|
+
// { value: PERIOD.DAY, label: "day" },
|
|
131
|
+
// { value: PERIOD.WEEK, label: "week" },
|
|
132
|
+
// { value: PERIOD.MONTH, label: "month" },
|
|
133
|
+
// { value: PERIOD.YEAR, label: "year" },
|
|
134
|
+
// ];
|
|
135
|
+
//
|
|
136
|
+
// test("Can create multiple stremas", async () => {
|
|
137
|
+
// const now = new Date();
|
|
138
|
+
// const recipientsPayload = recipients.map((recipient, i) => ({
|
|
139
|
+
// recipient: recipient.publicKey.toBase58(),
|
|
140
|
+
// recipientEmail: "",
|
|
141
|
+
// name: "Recipient " + i,
|
|
142
|
+
// depositedAmount: 0.0001,
|
|
143
|
+
// }));
|
|
144
|
+
//
|
|
145
|
+
// const values: CreateMultipleStreamsValues = {
|
|
146
|
+
// releaseAmount: 0.00001,
|
|
147
|
+
// tokenSymbol: "",
|
|
148
|
+
// startDate: format(now, DATE_FORMAT),
|
|
149
|
+
// startTime: format(add(now, { minutes: 5 }), TIME_FORMAT),
|
|
150
|
+
// releaseFrequencyCounter: 1,
|
|
151
|
+
// releaseFrequencyPeriod: timePeriodOptions[0].value,
|
|
152
|
+
// whoCanTransfer: TransferCancelOptions.Recipient,
|
|
153
|
+
// whoCanCancel: TransferCancelOptions.Sender,
|
|
154
|
+
// automaticWithdrawal: false,
|
|
155
|
+
// withdrawalFrequencyCounter: 1,
|
|
156
|
+
// withdrawalFrequencyPeriod: timePeriodOptions[1].value,
|
|
157
|
+
// referral: "",
|
|
158
|
+
// email: "",
|
|
159
|
+
// recipients: recipientsPayload,
|
|
160
|
+
// };
|
|
161
|
+
// const data = newCreateMultipleStreamsPayload(values, sender);
|
|
162
|
+
// const response = await streamInstance?.createMultiple(data);
|
|
163
|
+
// const errors = response?.errors;
|
|
164
|
+
// console.log(errors);
|
|
165
|
+
// return response;
|
|
166
|
+
// }, 600000);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamflow/stream",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.11",
|
|
4
4
|
"description": "JavaScript SDK to interact with Streamflow protocol.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"homepage": "https://github.com/streamflow-finance/js-sdk/",
|
|
@@ -12,7 +12,11 @@
|
|
|
12
12
|
"gitHead": "a37306eba0e762af096db642fa22f07194014cfd",
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"@types/bn.js": "^5.1.0",
|
|
15
|
+
"@types/jest": "^28.1.4",
|
|
16
|
+
"@types/mocha": "^9.1.1",
|
|
15
17
|
"date-fns": "^2.28.0",
|
|
18
|
+
"jest": "^28.1.2",
|
|
19
|
+
"mocha": "^10.0.0",
|
|
16
20
|
"typescript": "^4.6.4"
|
|
17
21
|
},
|
|
18
22
|
"dependencies": {
|