@streamflow/stream 3.0.6 → 3.0.7
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/Stream.js +2 -2
- package/dist/StreamClient.js +55 -44
- package/dist/__tests__/streams.spec.js +4 -2
- package/dist/types.d.ts +47 -4
- package/dist/types.js +64 -1
- package/dist/utils.js +7 -2
- package/package.json +2 -2
package/dist/Stream.js
CHANGED
|
@@ -410,7 +410,7 @@ var Stream = /** @class */ (function () {
|
|
|
410
410
|
if (!(escrow === null || escrow === void 0 ? void 0 : escrow.data)) {
|
|
411
411
|
throw new Error("Couldn't get account info.");
|
|
412
412
|
}
|
|
413
|
-
return [2 /*return*/,
|
|
413
|
+
return [2 /*return*/, new types_1.Contract((0, utils_1.decodeStream)(escrow === null || escrow === void 0 ? void 0 : escrow.data))];
|
|
414
414
|
}
|
|
415
415
|
});
|
|
416
416
|
});
|
|
@@ -454,7 +454,7 @@ var Stream = /** @class */ (function () {
|
|
|
454
454
|
streams = {};
|
|
455
455
|
accounts.forEach(function (account) {
|
|
456
456
|
var _a;
|
|
457
|
-
var decoded =
|
|
457
|
+
var decoded = new types_1.Contract((0, utils_1.decodeStream)(account.account.data));
|
|
458
458
|
streams = __assign(__assign({}, streams), (_a = {}, _a[account.pubkey.toBase58()] = decoded, _a));
|
|
459
459
|
});
|
|
460
460
|
sortedStreams = Object.entries(streams).sort(function (_a, _b) {
|
package/dist/StreamClient.js
CHANGED
|
@@ -97,6 +97,7 @@ var utils_1 = require("./utils");
|
|
|
97
97
|
var constants_1 = require("./constants");
|
|
98
98
|
var instructions_1 = require("./instructions");
|
|
99
99
|
var common_1 = require("@project-serum/common");
|
|
100
|
+
var bs58_1 = require("@project-serum/anchor/dist/cjs/utils/bytes/bs58");
|
|
100
101
|
var StreamClient = /** @class */ (function () {
|
|
101
102
|
/**
|
|
102
103
|
* Create Stream instance
|
|
@@ -247,8 +248,8 @@ var StreamClient = /** @class */ (function () {
|
|
|
247
248
|
*/
|
|
248
249
|
StreamClient.prototype.createMultiple = function (data) {
|
|
249
250
|
return __awaiter(this, void 0, void 0, function () {
|
|
250
|
-
var sender, recipientsData, metadatas, metadataToRecipient, errors, signatures, chunkSize, chunkes,
|
|
251
|
-
var
|
|
251
|
+
var sender, recipientsData, metadatas, metadataToRecipient, errors, signatures, chunkSize, chunkes, batch, recipientsData_1, recipientsData_1_1, recipientData, _a, tx, metadata, metadataPubKey, e_1_1, i, chunk, chunkes_1, chunkes_1_1, chunk, signed_batch, batchTransactionsCalls, responses, successes, failures, e_2_1;
|
|
252
|
+
var e_1, _b, e_2, _c;
|
|
252
253
|
var _this = this;
|
|
253
254
|
return __generator(this, function (_d) {
|
|
254
255
|
switch (_d.label) {
|
|
@@ -258,52 +259,53 @@ var StreamClient = /** @class */ (function () {
|
|
|
258
259
|
metadataToRecipient = {};
|
|
259
260
|
errors = [];
|
|
260
261
|
signatures = [];
|
|
261
|
-
chunkSize =
|
|
262
|
+
chunkSize = 100;
|
|
262
263
|
chunkes = [];
|
|
263
|
-
|
|
264
|
-
chunk = recipientsData.slice(i, i + chunkSize);
|
|
265
|
-
chunkes.push(chunk);
|
|
266
|
-
}
|
|
264
|
+
batch = [];
|
|
267
265
|
_d.label = 1;
|
|
268
266
|
case 1:
|
|
269
|
-
_d.trys.push([1,
|
|
270
|
-
|
|
267
|
+
_d.trys.push([1, 6, 7, 8]);
|
|
268
|
+
recipientsData_1 = __values(recipientsData), recipientsData_1_1 = recipientsData_1.next();
|
|
271
269
|
_d.label = 2;
|
|
272
270
|
case 2:
|
|
273
|
-
if (!!
|
|
274
|
-
|
|
275
|
-
batch = [];
|
|
276
|
-
_d.label = 3;
|
|
277
|
-
case 3:
|
|
278
|
-
_d.trys.push([3, 8, 9, 10]);
|
|
279
|
-
chunk_1 = (e_1 = void 0, __values(chunk)), chunk_1_1 = chunk_1.next();
|
|
280
|
-
_d.label = 4;
|
|
281
|
-
case 4:
|
|
282
|
-
if (!!chunk_1_1.done) return [3 /*break*/, 7];
|
|
283
|
-
recipientData = chunk_1_1.value;
|
|
271
|
+
if (!!recipientsData_1_1.done) return [3 /*break*/, 5];
|
|
272
|
+
recipientData = recipientsData_1_1.value;
|
|
284
273
|
return [4 /*yield*/, this.prepareStreamTransaction(recipientData, data)];
|
|
285
|
-
case
|
|
274
|
+
case 3:
|
|
286
275
|
_a = _d.sent(), tx = _a.tx, metadata = _a.metadata;
|
|
287
276
|
metadataPubKey = metadata.publicKey.toBase58();
|
|
288
277
|
metadataToRecipient[metadataPubKey] = recipientData;
|
|
289
278
|
metadatas.push(metadata);
|
|
290
279
|
batch.push({ tx: tx, recipient: recipientData.recipient });
|
|
291
|
-
_d.label =
|
|
280
|
+
_d.label = 4;
|
|
281
|
+
case 4:
|
|
282
|
+
recipientsData_1_1 = recipientsData_1.next();
|
|
283
|
+
return [3 /*break*/, 2];
|
|
284
|
+
case 5: return [3 /*break*/, 8];
|
|
292
285
|
case 6:
|
|
293
|
-
chunk_1_1 = chunk_1.next();
|
|
294
|
-
return [3 /*break*/, 4];
|
|
295
|
-
case 7: return [3 /*break*/, 10];
|
|
296
|
-
case 8:
|
|
297
286
|
e_1_1 = _d.sent();
|
|
298
287
|
e_1 = { error: e_1_1 };
|
|
299
|
-
return [3 /*break*/,
|
|
300
|
-
case
|
|
288
|
+
return [3 /*break*/, 8];
|
|
289
|
+
case 7:
|
|
301
290
|
try {
|
|
302
|
-
if (
|
|
291
|
+
if (recipientsData_1_1 && !recipientsData_1_1.done && (_b = recipientsData_1.return)) _b.call(recipientsData_1);
|
|
303
292
|
}
|
|
304
293
|
finally { if (e_1) throw e_1.error; }
|
|
305
294
|
return [7 /*endfinally*/];
|
|
306
|
-
case
|
|
295
|
+
case 8:
|
|
296
|
+
for (i = 0; i < batch.length; i += chunkSize) {
|
|
297
|
+
chunk = batch.slice(i, i + chunkSize);
|
|
298
|
+
chunkes.push(chunk);
|
|
299
|
+
}
|
|
300
|
+
_d.label = 9;
|
|
301
|
+
case 9:
|
|
302
|
+
_d.trys.push([9, 16, 17, 18]);
|
|
303
|
+
chunkes_1 = __values(chunkes), chunkes_1_1 = chunkes_1.next();
|
|
304
|
+
_d.label = 10;
|
|
305
|
+
case 10:
|
|
306
|
+
if (!!chunkes_1_1.done) return [3 /*break*/, 15];
|
|
307
|
+
chunk = chunkes_1_1.value;
|
|
308
|
+
return [4 /*yield*/, signAllTransactionWithRecipients(sender, chunk)];
|
|
307
309
|
case 11:
|
|
308
310
|
signed_batch = _d.sent();
|
|
309
311
|
batchTransactionsCalls = signed_batch.map(function (el) {
|
|
@@ -328,7 +330,7 @@ var StreamClient = /** @class */ (function () {
|
|
|
328
330
|
_d.label = 14;
|
|
329
331
|
case 14:
|
|
330
332
|
chunkes_1_1 = chunkes_1.next();
|
|
331
|
-
return [3 /*break*/,
|
|
333
|
+
return [3 /*break*/, 10];
|
|
332
334
|
case 15: return [3 /*break*/, 18];
|
|
333
335
|
case 16:
|
|
334
336
|
e_2_1 = _d.sent();
|
|
@@ -336,7 +338,7 @@ var StreamClient = /** @class */ (function () {
|
|
|
336
338
|
return [3 /*break*/, 18];
|
|
337
339
|
case 17:
|
|
338
340
|
try {
|
|
339
|
-
if (chunkes_1_1 && !chunkes_1_1.done && (
|
|
341
|
+
if (chunkes_1_1 && !chunkes_1_1.done && (_c = chunkes_1.return)) _c.call(chunkes_1);
|
|
340
342
|
}
|
|
341
343
|
finally { if (e_2) throw e_2.error; }
|
|
342
344
|
return [7 /*endfinally*/];
|
|
@@ -603,7 +605,7 @@ var StreamClient = /** @class */ (function () {
|
|
|
603
605
|
if (!(escrow === null || escrow === void 0 ? void 0 : escrow.data)) {
|
|
604
606
|
throw new Error("Couldn't get account info.");
|
|
605
607
|
}
|
|
606
|
-
return [2 /*return*/,
|
|
608
|
+
return [2 /*return*/, new types_1.Contract((0, utils_1.decodeStream)(escrow === null || escrow === void 0 ? void 0 : escrow.data))];
|
|
607
609
|
}
|
|
608
610
|
});
|
|
609
611
|
});
|
|
@@ -645,7 +647,7 @@ var StreamClient = /** @class */ (function () {
|
|
|
645
647
|
streams = {};
|
|
646
648
|
accounts.forEach(function (account) {
|
|
647
649
|
var _a;
|
|
648
|
-
var decoded =
|
|
650
|
+
var decoded = new types_1.Contract((0, utils_1.decodeStream)(account.account.data));
|
|
649
651
|
streams = __assign(__assign({}, streams), (_a = {}, _a[account.pubkey.toBase58()] = decoded, _a));
|
|
650
652
|
});
|
|
651
653
|
sortedStreams = Object.entries(streams).sort(function (_a, _b) {
|
|
@@ -760,12 +762,13 @@ var StreamClient = /** @class */ (function () {
|
|
|
760
762
|
withdrawor: constants_1.WITHDRAWOR_PUBLIC_KEY,
|
|
761
763
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
762
764
|
}));
|
|
763
|
-
return [4 /*yield*/, this.connection.
|
|
765
|
+
return [4 /*yield*/, this.connection.getLatestBlockhash(commitment)];
|
|
764
766
|
case 6:
|
|
765
767
|
hash = _f.sent();
|
|
766
768
|
tx = (_e = new web3_js_1.Transaction({
|
|
767
769
|
feePayer: sender.publicKey,
|
|
768
|
-
|
|
770
|
+
blockhash: hash.blockhash,
|
|
771
|
+
lastValidBlockHeight: hash.lastValidBlockHeight,
|
|
769
772
|
})).add.apply(_e, __spreadArray([], __read(ixs), false));
|
|
770
773
|
tx.partialSign(metadata);
|
|
771
774
|
return [2 /*return*/, { tx: tx, metadata: metadata }];
|
|
@@ -858,18 +861,26 @@ function signAllTransactionWithRecipients(sender, batch) {
|
|
|
858
861
|
}
|
|
859
862
|
function sendAndConfirmStreamRawTransaction(connection, batchItem) {
|
|
860
863
|
return __awaiter(this, void 0, void 0, function () {
|
|
861
|
-
var rawTx, signature, error_1;
|
|
862
|
-
return __generator(this, function (
|
|
863
|
-
switch (
|
|
864
|
+
var rawTx, _a, lastValidBlockHeight, signature, recentBlockhash, confirmationStrategy, completedTxSignature, error_1;
|
|
865
|
+
return __generator(this, function (_b) {
|
|
866
|
+
switch (_b.label) {
|
|
864
867
|
case 0:
|
|
865
|
-
|
|
868
|
+
_b.trys.push([0, 2, , 3]);
|
|
866
869
|
rawTx = batchItem.tx.serialize();
|
|
867
|
-
|
|
870
|
+
_a = batchItem.tx, lastValidBlockHeight = _a.lastValidBlockHeight, signature = _a.signature, recentBlockhash = _a.recentBlockhash;
|
|
871
|
+
if (!lastValidBlockHeight || !signature || !recentBlockhash)
|
|
872
|
+
throw { recipient: batchItem.recipient, error: "no recent blockhash" };
|
|
873
|
+
confirmationStrategy = {
|
|
874
|
+
lastValidBlockHeight: lastValidBlockHeight,
|
|
875
|
+
signature: (0, bs58_1.encode)(signature),
|
|
876
|
+
blockhash: recentBlockhash,
|
|
877
|
+
};
|
|
878
|
+
return [4 /*yield*/, (0, web3_js_1.sendAndConfirmRawTransaction)(connection, rawTx, confirmationStrategy)];
|
|
868
879
|
case 1:
|
|
869
|
-
|
|
870
|
-
return [2 /*return*/, __assign(__assign({}, batchItem), { signature:
|
|
880
|
+
completedTxSignature = _b.sent();
|
|
881
|
+
return [2 /*return*/, __assign(__assign({}, batchItem), { signature: completedTxSignature })];
|
|
871
882
|
case 2:
|
|
872
|
-
error_1 =
|
|
883
|
+
error_1 = _b.sent();
|
|
873
884
|
throw { recipient: batchItem.recipient, error: error_1 };
|
|
874
885
|
case 3: return [2 /*return*/];
|
|
875
886
|
}
|
|
@@ -120,7 +120,7 @@ beforeAll(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
|
120
120
|
connection = new web3.Connection(web3.clusterApiUrl(), "confirmed");
|
|
121
121
|
sender = new anchor_1.Wallet(web3.Keypair.generate());
|
|
122
122
|
recipient = new anchor_1.Wallet(web3.Keypair.generate());
|
|
123
|
-
recipients = __spreadArray([], __read(new Array(
|
|
123
|
+
recipients = __spreadArray([], __read(new Array(10)), false).map(function () { return new anchor_1.Wallet(web3.Keypair.generate()); });
|
|
124
124
|
return [4 /*yield*/, (0, airdrop_request_1.requestAirdrop)(sender, connection)];
|
|
125
125
|
case 1:
|
|
126
126
|
_a.sent();
|
|
@@ -211,7 +211,7 @@ exports.timePeriodOptions = [
|
|
|
211
211
|
{ value: exports.PERIOD.YEAR, label: "year" },
|
|
212
212
|
];
|
|
213
213
|
test("Can create multiple stremas", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
214
|
-
var now, recipientsPayload, values, data, response;
|
|
214
|
+
var now, recipientsPayload, values, data, response, errors;
|
|
215
215
|
return __generator(this, function (_a) {
|
|
216
216
|
switch (_a.label) {
|
|
217
217
|
case 0:
|
|
@@ -242,6 +242,8 @@ test("Can create multiple stremas", function () { return __awaiter(void 0, void
|
|
|
242
242
|
return [4 /*yield*/, (streamInstance === null || streamInstance === void 0 ? void 0 : streamInstance.createMultiple(data))];
|
|
243
243
|
case 1:
|
|
244
244
|
response = _a.sent();
|
|
245
|
+
errors = response === null || response === void 0 ? void 0 : response.errors;
|
|
246
|
+
console.log(errors);
|
|
245
247
|
return [2 /*return*/, response];
|
|
246
248
|
}
|
|
247
249
|
});
|
package/dist/types.d.ts
CHANGED
|
@@ -85,7 +85,7 @@ export interface WithdrawStreamParams extends WithdrawStreamData {
|
|
|
85
85
|
cluster?: ClusterExtended;
|
|
86
86
|
}
|
|
87
87
|
export interface WithdrawParams extends WithdrawStreamData {
|
|
88
|
-
invoker: Wallet;
|
|
88
|
+
invoker: Wallet | Keypair;
|
|
89
89
|
}
|
|
90
90
|
export interface TopupStreamData {
|
|
91
91
|
id: string;
|
|
@@ -97,7 +97,7 @@ export interface TopupStreamParams extends TopupStreamData {
|
|
|
97
97
|
cluster?: ClusterExtended;
|
|
98
98
|
}
|
|
99
99
|
export interface TopupParams extends TopupStreamData {
|
|
100
|
-
invoker: Wallet;
|
|
100
|
+
invoker: Wallet | Keypair;
|
|
101
101
|
}
|
|
102
102
|
export interface CancelStreamData {
|
|
103
103
|
id: string;
|
|
@@ -108,7 +108,7 @@ export interface CancelStreamParams extends CancelStreamData {
|
|
|
108
108
|
cluster?: ClusterExtended;
|
|
109
109
|
}
|
|
110
110
|
export interface CancelParams extends CancelStreamData {
|
|
111
|
-
invoker: Wallet;
|
|
111
|
+
invoker: Wallet | Keypair;
|
|
112
112
|
}
|
|
113
113
|
export interface TransferStreamData {
|
|
114
114
|
id: string;
|
|
@@ -120,7 +120,7 @@ export interface TransferStreamParams extends TransferStreamData {
|
|
|
120
120
|
cluster?: ClusterExtended;
|
|
121
121
|
}
|
|
122
122
|
export interface TransferParams extends TransferStreamData {
|
|
123
|
-
invoker: Wallet;
|
|
123
|
+
invoker: Wallet | Keypair;
|
|
124
124
|
}
|
|
125
125
|
export interface GetStreamParams {
|
|
126
126
|
connection: Connection;
|
|
@@ -176,6 +176,49 @@ export interface Stream {
|
|
|
176
176
|
canTopup: boolean;
|
|
177
177
|
name: string;
|
|
178
178
|
withdrawalFrequency: number;
|
|
179
|
+
unlocked(currentTimestamp: number, decimals: number): number;
|
|
180
|
+
}
|
|
181
|
+
export declare class Contract implements Stream {
|
|
182
|
+
magic: number;
|
|
183
|
+
version: number;
|
|
184
|
+
createdAt: number;
|
|
185
|
+
withdrawnAmount: BN;
|
|
186
|
+
canceledAt: number;
|
|
187
|
+
end: number;
|
|
188
|
+
lastWithdrawnAt: number;
|
|
189
|
+
sender: string;
|
|
190
|
+
senderTokens: string;
|
|
191
|
+
recipient: string;
|
|
192
|
+
recipientTokens: string;
|
|
193
|
+
mint: string;
|
|
194
|
+
escrowTokens: string;
|
|
195
|
+
streamflowTreasury: string;
|
|
196
|
+
streamflowTreasuryTokens: string;
|
|
197
|
+
streamflowFeeTotal: BN;
|
|
198
|
+
streamflowFeeWithdrawn: BN;
|
|
199
|
+
streamflowFeePercent: number;
|
|
200
|
+
partnerFeeTotal: BN;
|
|
201
|
+
partnerFeeWithdrawn: BN;
|
|
202
|
+
partnerFeePercent: number;
|
|
203
|
+
partner: string;
|
|
204
|
+
partnerTokens: string;
|
|
205
|
+
start: number;
|
|
206
|
+
depositedAmount: BN;
|
|
207
|
+
period: number;
|
|
208
|
+
amountPerPeriod: BN;
|
|
209
|
+
cliff: number;
|
|
210
|
+
cliffAmount: BN;
|
|
211
|
+
cancelableBySender: boolean;
|
|
212
|
+
cancelableByRecipient: boolean;
|
|
213
|
+
automaticWithdrawal: boolean;
|
|
214
|
+
transferableBySender: boolean;
|
|
215
|
+
transferableByRecipient: boolean;
|
|
216
|
+
canTopup: boolean;
|
|
217
|
+
name: string;
|
|
218
|
+
withdrawalFrequency: number;
|
|
219
|
+
constructor(stream: DecodedStream);
|
|
220
|
+
unlocked(currentTimestamp: number, decimals: number): number;
|
|
221
|
+
remaining(decimals: number): number;
|
|
179
222
|
}
|
|
180
223
|
export interface DecodedStream {
|
|
181
224
|
magic: BN;
|
package/dist/types.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TransferCancelOptions = exports.LocalCluster = exports.StreamType = exports.StreamDirection = exports.Cluster = void 0;
|
|
6
|
+
exports.TransferCancelOptions = exports.Contract = exports.LocalCluster = exports.StreamType = exports.StreamDirection = exports.Cluster = void 0;
|
|
7
|
+
var bn_js_1 = __importDefault(require("bn.js"));
|
|
8
|
+
var utils_1 = require("./utils");
|
|
4
9
|
var wallet_adapter_base_1 = require("@solana/wallet-adapter-base");
|
|
5
10
|
Object.defineProperty(exports, "Cluster", { enumerable: true, get: function () { return wallet_adapter_base_1.WalletAdapterNetwork; } });
|
|
6
11
|
var StreamDirection;
|
|
@@ -19,6 +24,64 @@ var LocalCluster;
|
|
|
19
24
|
(function (LocalCluster) {
|
|
20
25
|
LocalCluster["Local"] = "local";
|
|
21
26
|
})(LocalCluster = exports.LocalCluster || (exports.LocalCluster = {}));
|
|
27
|
+
var Contract = /** @class */ (function () {
|
|
28
|
+
function Contract(stream) {
|
|
29
|
+
var _a;
|
|
30
|
+
this.magic = stream.magic.toNumber();
|
|
31
|
+
this.version = stream.version.toNumber();
|
|
32
|
+
this.createdAt = stream.createdAt.toNumber();
|
|
33
|
+
this.withdrawnAmount = stream.withdrawnAmount;
|
|
34
|
+
this.canceledAt = stream.canceledAt.toNumber();
|
|
35
|
+
this.end = stream.end.toNumber();
|
|
36
|
+
this.lastWithdrawnAt = stream.lastWithdrawnAt.toNumber();
|
|
37
|
+
this.sender = stream.sender.toBase58();
|
|
38
|
+
this.senderTokens = stream.senderTokens.toBase58();
|
|
39
|
+
this.recipient = stream.recipient.toBase58();
|
|
40
|
+
this.recipientTokens = stream.recipientTokens.toBase58();
|
|
41
|
+
this.mint = stream.mint.toBase58();
|
|
42
|
+
this.escrowTokens = stream.escrowTokens.toBase58();
|
|
43
|
+
this.streamflowTreasury = stream.streamflowTreasury.toBase58();
|
|
44
|
+
this.streamflowTreasuryTokens =
|
|
45
|
+
stream.streamflowTreasuryTokens.toBase58();
|
|
46
|
+
this.streamflowFeeTotal = stream.streamflowFeeTotal;
|
|
47
|
+
this.streamflowFeeWithdrawn = stream.streamflowFeeWithdrawn;
|
|
48
|
+
this.streamflowFeePercent = stream.streamflowFeePercent.toNumber();
|
|
49
|
+
this.partnerFeeTotal = stream.partnerFeeTotal;
|
|
50
|
+
this.partnerFeeWithdrawn = stream.partnerFeeWithdrawn;
|
|
51
|
+
this.partnerFeePercent = stream.partnerFeePercent.toNumber();
|
|
52
|
+
this.partner = stream.partner.toBase58();
|
|
53
|
+
this.partnerTokens = (_a = stream.partnerTokens) === null || _a === void 0 ? void 0 : _a.toBase58();
|
|
54
|
+
this.start = stream.start.toNumber();
|
|
55
|
+
this.depositedAmount = stream.depositedAmount;
|
|
56
|
+
this.period = stream.period.toNumber();
|
|
57
|
+
this.amountPerPeriod = stream.amountPerPeriod;
|
|
58
|
+
this.cliff = stream.cliff.toNumber();
|
|
59
|
+
this.cliffAmount = stream.cliffAmount;
|
|
60
|
+
this.cancelableBySender = stream.cancelableBySender;
|
|
61
|
+
this.cancelableByRecipient = stream.cancelableByRecipient;
|
|
62
|
+
this.automaticWithdrawal = stream.automaticWithdrawal;
|
|
63
|
+
this.transferableBySender = stream.transferableBySender;
|
|
64
|
+
this.transferableByRecipient = stream.transferableByRecipient;
|
|
65
|
+
this.canTopup = stream.canTopup;
|
|
66
|
+
this.name = stream.name;
|
|
67
|
+
this.withdrawalFrequency = stream.withdrawFrequency.toNumber();
|
|
68
|
+
}
|
|
69
|
+
Contract.prototype.unlocked = function (currentTimestamp, decimals) {
|
|
70
|
+
var deposited = (0, utils_1.getNumberFromBN)(this.depositedAmount, decimals);
|
|
71
|
+
if (currentTimestamp < this.cliff)
|
|
72
|
+
return 0;
|
|
73
|
+
if (currentTimestamp > this.end)
|
|
74
|
+
return deposited;
|
|
75
|
+
var streamedBN = this.cliffAmount.add(new bn_js_1.default(Math.floor((currentTimestamp - this.cliff) / this.period)).mul(this.amountPerPeriod));
|
|
76
|
+
var streamed = (0, utils_1.getNumberFromBN)(streamedBN, decimals);
|
|
77
|
+
return streamed < deposited ? streamed : deposited;
|
|
78
|
+
};
|
|
79
|
+
Contract.prototype.remaining = function (decimals) {
|
|
80
|
+
return (0, utils_1.getNumberFromBN)(this.depositedAmount.sub(this.withdrawnAmount), decimals);
|
|
81
|
+
};
|
|
82
|
+
return Contract;
|
|
83
|
+
}());
|
|
84
|
+
exports.Contract = Contract;
|
|
22
85
|
var TransferCancelOptions;
|
|
23
86
|
(function (TransferCancelOptions) {
|
|
24
87
|
TransferCancelOptions["Recipient"] = "recipient";
|
package/dist/utils.js
CHANGED
|
@@ -52,9 +52,11 @@ var decodeStream = function (buf) {
|
|
|
52
52
|
};
|
|
53
53
|
};
|
|
54
54
|
exports.decodeStream = decodeStream;
|
|
55
|
+
// DeprecationWarning: This object will be deprecated starting from the version 4.0.0. Use
|
|
56
|
+
// types/Contract instead
|
|
55
57
|
var formatDecodedStream = function (stream) {
|
|
56
58
|
var _a;
|
|
57
|
-
|
|
59
|
+
var resp = {
|
|
58
60
|
magic: stream.magic.toNumber(),
|
|
59
61
|
version: stream.version.toNumber(),
|
|
60
62
|
createdAt: stream.createdAt.toNumber(),
|
|
@@ -92,7 +94,10 @@ var formatDecodedStream = function (stream) {
|
|
|
92
94
|
canTopup: stream.canTopup,
|
|
93
95
|
name: stream.name,
|
|
94
96
|
withdrawalFrequency: stream.withdrawFrequency.toNumber(),
|
|
95
|
-
|
|
97
|
+
unlocked: function () { return 0; },
|
|
98
|
+
withdrawn: function () { return new bn_js_1.default(0); } //phantom method to preserve partial support of this object
|
|
99
|
+
};
|
|
100
|
+
return resp;
|
|
96
101
|
};
|
|
97
102
|
exports.formatDecodedStream = formatDecodedStream;
|
|
98
103
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamflow/stream",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.7",
|
|
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/",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@project-serum/common": "^0.0.1-beta.3",
|
|
21
21
|
"@solana/spl-token": "^0.1.8",
|
|
22
22
|
"@solana/wallet-adapter-base": "^0.9.2",
|
|
23
|
-
"@solana/web3.js": "^1.
|
|
23
|
+
"@solana/web3.js": "^1.42.0",
|
|
24
24
|
"bn.js": "^5.2.0",
|
|
25
25
|
"buffer-layout": "^1.2.1"
|
|
26
26
|
}
|