@streamflow/stream 3.0.16-dev → 4.0.0-Alpha.0
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.d.ts +3 -4
- package/dist/StreamClient.js +35 -21
- package/dist/__tests__/aptos/streamClient.spec.d.ts +1 -0
- package/dist/__tests__/aptos/streamClient.spec.js +160 -0
- package/dist/__tests__/test_dependencies/airdrop/airdrop-request.d.ts +0 -1
- package/dist/aptos/StreamClient.d.ts +19 -0
- package/dist/aptos/StreamClient.js +296 -0
- package/dist/aptos/constants.d.ts +2 -0
- package/dist/aptos/constants.js +12 -0
- package/dist/aptos/index.d.ts +2 -0
- package/dist/aptos/index.js +23 -0
- package/dist/aptos/types.d.ts +10 -0
- package/dist/aptos/types.js +2 -0
- package/dist/common/types.d.ts +70 -0
- package/dist/common/types.js +29 -0
- package/dist/common/utils.d.ts +15 -0
- package/dist/common/utils.js +31 -0
- package/dist/index.d.ts +4 -6
- package/dist/index.js +17 -13
- package/dist/instructionTypes.d.ts +81 -0
- package/dist/instructionTypes.js +2 -0
- package/dist/instructions.d.ts +0 -2
- package/dist/instructions.js +18 -29
- package/dist/layout.d.ts +7 -7
- package/dist/layout.js +78 -75
- package/dist/solana/StreamClient.d.ts +145 -0
- package/dist/solana/StreamClient.js +952 -0
- package/dist/solana/constants.d.ts +18 -0
- package/dist/solana/constants.js +23 -0
- package/dist/solana/index.d.ts +5 -0
- package/dist/solana/index.js +27 -0
- package/dist/solana/instructionTypes.d.ts +81 -0
- package/dist/solana/instructionTypes.js +2 -0
- package/dist/solana/instructions.d.ts +131 -0
- package/dist/solana/instructions.js +375 -0
- package/dist/solana/layout.d.ts +22 -0
- package/dist/solana/layout.js +96 -0
- package/dist/solana/timelockIDL.d.ts +22 -0
- package/dist/solana/timelockIDL.js +422 -0
- package/dist/solana/types.d.ts +321 -0
- package/dist/solana/types.js +74 -0
- package/dist/solana/utils.d.ts +42 -0
- package/dist/solana/utils.js +269 -0
- package/dist/types.d.ts +12 -13
- package/package.json +23 -10
package/dist/instructions.js
CHANGED
|
@@ -87,12 +87,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
87
87
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
88
88
|
};
|
|
89
89
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
90
|
-
exports.prepareWrappedAccount = exports.
|
|
90
|
+
exports.prepareWrappedAccount = exports.topupStreamInstruction = exports.transferStreamInstruction = exports.cancelStreamInstruction = exports.withdrawStreamInstruction = exports.createUncheckedStreamInstruction = exports.createStreamInstruction = void 0;
|
|
91
91
|
var buffer_1 = require("buffer");
|
|
92
92
|
var web3_js_1 = require("@solana/web3.js");
|
|
93
93
|
var bn_js_1 = __importDefault(require("bn.js"));
|
|
94
94
|
var js_sha256_1 = require("js-sha256");
|
|
95
|
-
var buffer_layout_1 = require("@solana/buffer-layout");
|
|
96
95
|
var Layout = __importStar(require("./layout"));
|
|
97
96
|
var spl_token_1 = require("@solana/spl-token");
|
|
98
97
|
var constants_1 = require("./constants");
|
|
@@ -139,12 +138,12 @@ var createStreamInstruction = function (data, programId, accounts) {
|
|
|
139
138
|
amount_per_period: data.amountPerPeriod.toArrayLike(buffer_1.Buffer, "le", 8),
|
|
140
139
|
cliff: data.cliff.toArrayLike(buffer_1.Buffer, "le", 8),
|
|
141
140
|
cliff_amount: data.cliffAmount.toArrayLike(buffer_1.Buffer, "le", 8),
|
|
142
|
-
cancelable_by_sender: data.cancelableBySender,
|
|
143
|
-
cancelable_by_recipient: data.cancelableByRecipient,
|
|
144
|
-
automatic_withdrawal: data.automaticWithdrawal,
|
|
145
|
-
transferable_by_sender: data.transferableBySender,
|
|
146
|
-
transferable_by_recipient: data.transferableByRecipient,
|
|
147
|
-
can_topup: data.canTopup,
|
|
141
|
+
cancelable_by_sender: Number(data.cancelableBySender),
|
|
142
|
+
cancelable_by_recipient: Number(data.cancelableByRecipient),
|
|
143
|
+
automatic_withdrawal: Number(data.automaticWithdrawal),
|
|
144
|
+
transferable_by_sender: Number(data.transferableBySender),
|
|
145
|
+
transferable_by_recipient: Number(data.transferableByRecipient),
|
|
146
|
+
can_topup: Number(data.canTopup),
|
|
148
147
|
stream_name: streamNameBuffer,
|
|
149
148
|
withdraw_frequency: data.withdrawFrequency.toArrayLike(buffer_1.Buffer, "le", 8),
|
|
150
149
|
};
|
|
@@ -193,18 +192,18 @@ var createUncheckedStreamInstruction = function (data, programId, accounts) {
|
|
|
193
192
|
amount_per_period: data.amountPerPeriod.toArrayLike(buffer_1.Buffer, "le", 8),
|
|
194
193
|
cliff: data.cliff.toArrayLike(buffer_1.Buffer, "le", 8),
|
|
195
194
|
cliff_amount: data.cliffAmount.toArrayLike(buffer_1.Buffer, "le", 8),
|
|
196
|
-
cancelable_by_sender: data.cancelableBySender,
|
|
197
|
-
cancelable_by_recipient: data.cancelableByRecipient,
|
|
198
|
-
automatic_withdrawal: data.automaticWithdrawal,
|
|
199
|
-
transferable_by_sender: data.transferableBySender,
|
|
200
|
-
transferable_by_recipient: data.transferableByRecipient,
|
|
201
|
-
can_topup: data.canTopup,
|
|
195
|
+
cancelable_by_sender: Number(data.cancelableBySender),
|
|
196
|
+
cancelable_by_recipient: Number(data.cancelableByRecipient),
|
|
197
|
+
automatic_withdrawal: Number(data.automaticWithdrawal),
|
|
198
|
+
transferable_by_sender: Number(data.transferableBySender),
|
|
199
|
+
transferable_by_recipient: Number(data.transferableByRecipient),
|
|
200
|
+
can_topup: Number(data.canTopup),
|
|
202
201
|
stream_name: streamNameBuffer,
|
|
203
202
|
withdraw_frequency: data.withdrawFrequency.toArrayLike(buffer_1.Buffer, "le", 8),
|
|
204
203
|
recipient: data.recipient.toBuffer(),
|
|
205
204
|
partner: data.partner.toBuffer(),
|
|
206
|
-
pausable:
|
|
207
|
-
can_update_rate:
|
|
205
|
+
pausable: 1,
|
|
206
|
+
can_update_rate: 1,
|
|
208
207
|
};
|
|
209
208
|
var encodeLength = Layout.createUncheckedStreamLayout.encode(decodedData, bufferData);
|
|
210
209
|
bufferData = bufferData.slice(0, encodeLength);
|
|
@@ -350,22 +349,12 @@ var topupStreamInstruction = function (amount, programId, _a) {
|
|
|
350
349
|
});
|
|
351
350
|
};
|
|
352
351
|
exports.topupStreamInstruction = topupStreamInstruction;
|
|
353
|
-
// TODO: Use native createSyncNativeInstruction after migrating to newer @solana/spl-token
|
|
354
|
-
var SyncNativeIndex = 17;
|
|
355
|
-
exports.syncNativeInstructionData = (0, buffer_layout_1.struct)([(0, buffer_layout_1.u8)('instruction')]);
|
|
356
|
-
var createSyncNativeInstruction = function (account) {
|
|
357
|
-
var keys = [{ pubkey: account, isSigner: false, isWritable: true }];
|
|
358
|
-
var data = buffer_1.Buffer.alloc(exports.syncNativeInstructionData.span);
|
|
359
|
-
exports.syncNativeInstructionData.encode({ instruction: SyncNativeIndex }, data);
|
|
360
|
-
return new web3_js_1.TransactionInstruction({ keys: keys, programId: spl_token_1.TOKEN_PROGRAM_ID, data: data });
|
|
361
|
-
};
|
|
362
|
-
exports.createSyncNativeInstruction = createSyncNativeInstruction;
|
|
363
352
|
var prepareWrappedAccount = function (connection, senderAddress, amount) { return __awaiter(void 0, void 0, void 0, function () {
|
|
364
353
|
var tokenAccount, accInfo, instructions;
|
|
365
354
|
var _a, _b;
|
|
366
355
|
return __generator(this, function (_c) {
|
|
367
356
|
switch (_c.label) {
|
|
368
|
-
case 0: return [4 /*yield*/,
|
|
357
|
+
case 0: return [4 /*yield*/, (0, spl_token_1.getAssociatedTokenAddress)(spl_token_1.NATIVE_MINT, senderAddress, true)];
|
|
369
358
|
case 1:
|
|
370
359
|
tokenAccount = _c.sent();
|
|
371
360
|
return [4 /*yield*/, connection.getParsedAccountInfo(tokenAccount)];
|
|
@@ -374,7 +363,7 @@ var prepareWrappedAccount = function (connection, senderAddress, amount) { retur
|
|
|
374
363
|
instructions = ((_b = (_a = accInfo.value) === null || _a === void 0 ? void 0 : _a.lamports) !== null && _b !== void 0 ? _b : 0) > 0
|
|
375
364
|
? []
|
|
376
365
|
: [
|
|
377
|
-
|
|
366
|
+
(0, spl_token_1.createAssociatedTokenAccountInstruction)(senderAddress, tokenAccount, senderAddress, spl_token_1.NATIVE_MINT),
|
|
378
367
|
];
|
|
379
368
|
return [2 /*return*/, __spreadArray(__spreadArray([], __read(instructions), false), [
|
|
380
369
|
web3_js_1.SystemProgram.transfer({
|
|
@@ -382,7 +371,7 @@ var prepareWrappedAccount = function (connection, senderAddress, amount) { retur
|
|
|
382
371
|
toPubkey: tokenAccount,
|
|
383
372
|
lamports: amount.mul(new bn_js_1.default(constants_1.BASE_FEE)).div(new bn_js_1.default(1000000)).toNumber(),
|
|
384
373
|
}),
|
|
385
|
-
(0,
|
|
374
|
+
(0, spl_token_1.createSyncNativeInstruction)(tokenAccount),
|
|
386
375
|
], false)];
|
|
387
376
|
}
|
|
388
377
|
});
|
package/dist/layout.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
import { Structure } from "@solana/buffer-layout";
|
|
2
|
+
import { ICreateStreamLayout, ICreateUncheckedStreamLayout, IStreamLayout, ITopupStreamLayout, IWithdrawStreamLayout } from "./instructionTypes";
|
|
2
3
|
/**
|
|
3
4
|
* Stream layout
|
|
4
5
|
*/
|
|
5
|
-
export declare const streamLayout:
|
|
6
|
+
export declare const streamLayout: Structure<IStreamLayout>;
|
|
6
7
|
/**
|
|
7
8
|
* Create stream instruction layout
|
|
8
9
|
*/
|
|
9
|
-
export declare const createStreamLayout:
|
|
10
|
+
export declare const createStreamLayout: Structure<ICreateStreamLayout>;
|
|
10
11
|
/**
|
|
11
12
|
* Create unchecked stream instruction layout
|
|
12
13
|
*/
|
|
13
|
-
export declare const createUncheckedStreamLayout:
|
|
14
|
+
export declare const createUncheckedStreamLayout: Structure<ICreateUncheckedStreamLayout>;
|
|
14
15
|
/**
|
|
15
16
|
* Withdraw stream instruction layout
|
|
16
17
|
*/
|
|
17
|
-
export declare const withdrawStreamLayout:
|
|
18
|
+
export declare const withdrawStreamLayout: Structure<IWithdrawStreamLayout>;
|
|
18
19
|
/**
|
|
19
20
|
* Topup stream instruction layout
|
|
20
21
|
*/
|
|
21
|
-
export declare const topupStreamLayout:
|
|
22
|
-
export {};
|
|
22
|
+
export declare const topupStreamLayout: Structure<ITopupStreamLayout>;
|
package/dist/layout.js
CHANGED
|
@@ -1,96 +1,99 @@
|
|
|
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
6
|
exports.topupStreamLayout = exports.withdrawStreamLayout = exports.createUncheckedStreamLayout = exports.createStreamLayout = exports.streamLayout = void 0;
|
|
4
|
-
var
|
|
7
|
+
var buffer_layout_1 = __importDefault(require("@solana/buffer-layout"));
|
|
5
8
|
/**
|
|
6
9
|
* Stream layout
|
|
7
10
|
*/
|
|
8
|
-
exports.streamLayout =
|
|
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
|
-
|
|
11
|
+
exports.streamLayout = buffer_layout_1.default.struct([
|
|
12
|
+
buffer_layout_1.default.blob(8, "magic"),
|
|
13
|
+
buffer_layout_1.default.blob(1, "version"),
|
|
14
|
+
buffer_layout_1.default.blob(8, "created_at"),
|
|
15
|
+
buffer_layout_1.default.blob(8, "withdrawn_amount"),
|
|
16
|
+
buffer_layout_1.default.blob(8, "canceled_at"),
|
|
17
|
+
buffer_layout_1.default.blob(8, "end_time"),
|
|
18
|
+
buffer_layout_1.default.blob(8, "last_withdrawn_at"),
|
|
19
|
+
buffer_layout_1.default.blob(32, "sender"),
|
|
20
|
+
buffer_layout_1.default.blob(32, "sender_tokens"),
|
|
21
|
+
buffer_layout_1.default.blob(32, "recipient"),
|
|
22
|
+
buffer_layout_1.default.blob(32, "recipient_tokens"),
|
|
23
|
+
buffer_layout_1.default.blob(32, "mint"),
|
|
24
|
+
buffer_layout_1.default.blob(32, "escrow_tokens"),
|
|
25
|
+
buffer_layout_1.default.blob(32, "streamflow_treasury"),
|
|
26
|
+
buffer_layout_1.default.blob(32, "streamflow_treasury_tokens"),
|
|
27
|
+
buffer_layout_1.default.blob(8, "streamflow_fee_total"),
|
|
28
|
+
buffer_layout_1.default.blob(8, "streamflow_fee_withdrawn"),
|
|
29
|
+
buffer_layout_1.default.f32("streamflow_fee_percent"),
|
|
30
|
+
buffer_layout_1.default.blob(32, "partner"),
|
|
31
|
+
buffer_layout_1.default.blob(32, "partner_tokens"),
|
|
32
|
+
buffer_layout_1.default.blob(8, "partner_fee_total"),
|
|
33
|
+
buffer_layout_1.default.blob(8, "partner_fee_withdrawn"),
|
|
34
|
+
buffer_layout_1.default.f32("partner_fee_percent"),
|
|
35
|
+
buffer_layout_1.default.blob(8, "start_time"),
|
|
36
|
+
buffer_layout_1.default.blob(8, "net_amount_deposited"),
|
|
37
|
+
buffer_layout_1.default.blob(8, "period"),
|
|
38
|
+
buffer_layout_1.default.blob(8, "amount_per_period"),
|
|
39
|
+
buffer_layout_1.default.blob(8, "cliff"),
|
|
40
|
+
buffer_layout_1.default.blob(8, "cliff_amount"),
|
|
41
|
+
buffer_layout_1.default.u8("cancelable_by_sender"),
|
|
42
|
+
buffer_layout_1.default.u8("cancelable_by_recipient"),
|
|
43
|
+
buffer_layout_1.default.u8("automatic_withdrawal"),
|
|
44
|
+
buffer_layout_1.default.u8("transferable_by_sender"),
|
|
45
|
+
buffer_layout_1.default.u8("transferable_by_recipient"),
|
|
46
|
+
buffer_layout_1.default.u8("can_topup"),
|
|
47
|
+
buffer_layout_1.default.blob(64, "stream_name"),
|
|
48
|
+
buffer_layout_1.default.blob(8, "withdraw_frequency"),
|
|
46
49
|
]);
|
|
47
50
|
/**
|
|
48
51
|
* Create stream instruction layout
|
|
49
52
|
*/
|
|
50
|
-
exports.createStreamLayout =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
53
|
+
exports.createStreamLayout = buffer_layout_1.default.struct([
|
|
54
|
+
buffer_layout_1.default.blob(8, "start_time"),
|
|
55
|
+
buffer_layout_1.default.blob(8, "net_amount_deposited"),
|
|
56
|
+
buffer_layout_1.default.blob(8, "period"),
|
|
57
|
+
buffer_layout_1.default.blob(8, "amount_per_period"),
|
|
58
|
+
buffer_layout_1.default.blob(8, "cliff"),
|
|
59
|
+
buffer_layout_1.default.blob(8, "cliff_amount"),
|
|
60
|
+
buffer_layout_1.default.u8("cancelable_by_sender"),
|
|
61
|
+
buffer_layout_1.default.u8("cancelable_by_recipient"),
|
|
62
|
+
buffer_layout_1.default.u8("automatic_withdrawal"),
|
|
63
|
+
buffer_layout_1.default.u8("transferable_by_sender"),
|
|
64
|
+
buffer_layout_1.default.u8("transferable_by_recipient"),
|
|
65
|
+
buffer_layout_1.default.u8("can_topup"),
|
|
66
|
+
buffer_layout_1.default.blob(64, "stream_name"),
|
|
67
|
+
buffer_layout_1.default.blob(8, "withdraw_frequency"),
|
|
65
68
|
]);
|
|
66
69
|
/**
|
|
67
70
|
* Create unchecked stream instruction layout
|
|
68
71
|
*/
|
|
69
|
-
exports.createUncheckedStreamLayout =
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
72
|
+
exports.createUncheckedStreamLayout = buffer_layout_1.default.struct([
|
|
73
|
+
buffer_layout_1.default.blob(8, "start_time"),
|
|
74
|
+
buffer_layout_1.default.blob(8, "net_amount_deposited"),
|
|
75
|
+
buffer_layout_1.default.blob(8, "period"),
|
|
76
|
+
buffer_layout_1.default.blob(8, "amount_per_period"),
|
|
77
|
+
buffer_layout_1.default.blob(8, "cliff"),
|
|
78
|
+
buffer_layout_1.default.blob(8, "cliff_amount"),
|
|
79
|
+
buffer_layout_1.default.u8("cancelable_by_sender"),
|
|
80
|
+
buffer_layout_1.default.u8("cancelable_by_recipient"),
|
|
81
|
+
buffer_layout_1.default.u8("automatic_withdrawal"),
|
|
82
|
+
buffer_layout_1.default.u8("transferable_by_sender"),
|
|
83
|
+
buffer_layout_1.default.u8("transferable_by_recipient"),
|
|
84
|
+
buffer_layout_1.default.u8("can_topup"),
|
|
85
|
+
buffer_layout_1.default.blob(64, "stream_name"),
|
|
86
|
+
buffer_layout_1.default.blob(8, "withdraw_frequency"),
|
|
87
|
+
buffer_layout_1.default.blob(32, "recipient"),
|
|
88
|
+
buffer_layout_1.default.blob(32, "partner"),
|
|
89
|
+
buffer_layout_1.default.u8("pausable"),
|
|
90
|
+
buffer_layout_1.default.u8("can_update_rate"),
|
|
88
91
|
]);
|
|
89
92
|
/**
|
|
90
93
|
* Withdraw stream instruction layout
|
|
91
94
|
*/
|
|
92
|
-
exports.withdrawStreamLayout =
|
|
95
|
+
exports.withdrawStreamLayout = buffer_layout_1.default.struct([buffer_layout_1.default.blob(8, "amount")]);
|
|
93
96
|
/**
|
|
94
97
|
* Topup stream instruction layout
|
|
95
98
|
*/
|
|
96
|
-
exports.topupStreamLayout =
|
|
99
|
+
exports.topupStreamLayout = buffer_layout_1.default.struct([buffer_layout_1.default.blob(8, "amount")]);
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { Connection, Commitment, ConnectionConfig } from "@solana/web3.js";
|
|
2
|
+
import { Stream as StreamData, GetAllParams, CreateResponse, CreateMultiResponse, TxResponse, ICreateStreamSolanaExt, IInteractStreamSolanaExt, ITopUpStreamSolanaExt } from "./types";
|
|
3
|
+
import { GenericStreamClient, ICancelData, ICluster, ICreateMultipleStreamData, ICreateStreamData, IGetOneData, ITopUpData, ITransferData, IWithdrawData } from "../common/types";
|
|
4
|
+
export default class SolanaStreamClient extends GenericStreamClient {
|
|
5
|
+
private connection;
|
|
6
|
+
private programId;
|
|
7
|
+
private commitment;
|
|
8
|
+
/**
|
|
9
|
+
* Create Stream instance
|
|
10
|
+
*/
|
|
11
|
+
constructor(clusterUrl: string, cluster?: ICluster, commitment?: Commitment | ConnectionConfig, programId?: string);
|
|
12
|
+
getConnection(): Connection;
|
|
13
|
+
getProgramId(): string;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new stream/vesting contract.
|
|
16
|
+
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
17
|
+
* @param {CreateParams} data
|
|
18
|
+
* @param {WalletAdapter | Keypair} data.sender - Wallet signing the transaction. Its address should match the authorized wallet (sender) or transaction will fail.
|
|
19
|
+
* @param {string} data.recipient - Solana address of the recipient. Associated token account will be derived using this address and token mint address.
|
|
20
|
+
* @param {string} data.mint - SPL Token mint.
|
|
21
|
+
* @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
|
|
22
|
+
* @param {BN} data.depositedAmount - Initially deposited amount of tokens (in the smallest units).
|
|
23
|
+
* @param {number} data.period - Time step (period) in seconds per which the unlocking occurs.
|
|
24
|
+
* @param {number} data.cliff - Vesting contract "cliff" timestamp in seconds.
|
|
25
|
+
* @param {BN} data.cliffAmount - Amount unlocked at the "cliff".
|
|
26
|
+
* @param {BN} data.amountPerPeriod - Amount unlocked per each period.
|
|
27
|
+
* @param {string} data.name - Stream name/subject.
|
|
28
|
+
* @param {boolean} data.canTopup - TRUE for streams, FALSE for vesting contracts.
|
|
29
|
+
* @param {boolean} data.cancelableBySender - Whether or not sender can cancel the stream.
|
|
30
|
+
* @param {boolean} data.cancelableByRecipient - Whether or not recipient can cancel the stream.
|
|
31
|
+
* @param {boolean} data.transferableBySender - Whether or not sender can transfer the stream.
|
|
32
|
+
* @param {boolean} data.transferableByRecipient - Whether or not recipient can transfer the stream.
|
|
33
|
+
* @param {boolean} data.automaticWithdrawal - Whether or not a 3rd party can initiate withdraw in the name of recipient.
|
|
34
|
+
* @param {number} [data.withdrawalFrequency = 0] - Relevant when automatic withdrawal is enabled. If greater than 0 our withdrawor will take care of withdrawals. If equal to 0 our withdrawor will skip, but everyone else can initiate withdrawals.
|
|
35
|
+
* @param {boolean} [data.isNative = false] - When true Automatically wraps SOLs to WrappedSOL and creates wSOL stream
|
|
36
|
+
* @param {string | null} [data.partner = null] - Partner's wallet address (optional).
|
|
37
|
+
*/
|
|
38
|
+
create({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, }: ICreateStreamData, { sender, partner, isNative }: ICreateStreamSolanaExt): Promise<CreateResponse>;
|
|
39
|
+
/**
|
|
40
|
+
* Creates a new stream/vesting contract using unchecked instruction.
|
|
41
|
+
*
|
|
42
|
+
* Unchecked instruction differes from the regular in:
|
|
43
|
+
* - does not check for initialized associated token account (wallets with no control over their ATA should not be used
|
|
44
|
+
* as sender/recipient/partner or there are risks of funds being locked in the contract)
|
|
45
|
+
* - initialized contract PDA off chain
|
|
46
|
+
*
|
|
47
|
+
* If you are not sure if you should use create or create_unchecked, go for create to be safer.
|
|
48
|
+
*
|
|
49
|
+
* @param {CreateParams} data
|
|
50
|
+
* @param {Wallet | Keypair} data.sender - Wallet signing the transaction. Its address should match the authorized wallet (sender) or transaction will fail.
|
|
51
|
+
* @param {string} data.recipient - Solana address of the recipient. Associated token account will be derived using this address and token mint address.
|
|
52
|
+
* @param {string} data.mint - SPL Token mint.
|
|
53
|
+
* @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
|
|
54
|
+
* @param {BN} data.depositedAmount - Initially deposited amount of tokens (in the smallest units).
|
|
55
|
+
* @param {number} data.period - Time step (period) in seconds per which the unlocking occurs.
|
|
56
|
+
* @param {number} data.cliff - Vesting contract "cliff" timestamp in seconds.
|
|
57
|
+
* @param {BN} data.cliffAmount - Amount unlocked at the "cliff".
|
|
58
|
+
* @param {BN} data.amountPerPeriod - Amount unlocked per each period.
|
|
59
|
+
* @param {string} data.name - Stream name/subject.
|
|
60
|
+
* @param {boolean} data.canTopup - TRUE for streams, FALSE for vesting contracts.
|
|
61
|
+
* @param {boolean} data.cancelableBySender - Whether or not sender can cancel the stream.
|
|
62
|
+
* @param {boolean} data.cancelableByRecipient - Whether or not recipient can cancel the stream.
|
|
63
|
+
* @param {boolean} data.transferableBySender - Whether or not sender can transfer the stream.
|
|
64
|
+
* @param {boolean} data.transferableByRecipient - Whether or not recipient can transfer the stream.
|
|
65
|
+
* @param {boolean} data.automaticWithdrawal - Whether or not a 3rd party can initiate withdraw in the name of recipient.
|
|
66
|
+
* @param {number} [data.withdrawalFrequency = 0] - Relevant when automatic withdrawal is enabled. If greater than 0 our withdrawor will take care of withdrawals. If equal to 0 our withdrawor will skip, but everyone else can initiate withdrawals.
|
|
67
|
+
* @param {boolean} [data.isNative = false] - When true Automatically wraps SOLs to WrappedSOL and creates wSOL stream
|
|
68
|
+
* @param {string | null} [data.partner = null] - Partner's wallet address (optional).
|
|
69
|
+
*/
|
|
70
|
+
createUnchecked({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, }: ICreateStreamData, { sender, partner, isNative }: ICreateStreamSolanaExt): Promise<CreateResponse>;
|
|
71
|
+
/**
|
|
72
|
+
* Creates a new stream/vesting contract.
|
|
73
|
+
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
74
|
+
* @param {CreateMultiParams} data
|
|
75
|
+
* @param {Wallet | Keypair} data.sender - Wallet signing the transaction. Its address should match the authorized wallet (sender) or transaction will fail.
|
|
76
|
+
* @param {MultiRecipient[]} data.recipientsData
|
|
77
|
+
* @param {string} data.mint - SPL Token mint.
|
|
78
|
+
* @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
|
|
79
|
+
* @param {number} data.period - Time step (period) in seconds per which the unlocking occurs.
|
|
80
|
+
* @param {number} data.cliff - Vesting contract "cliff" timestamp in seconds.
|
|
81
|
+
* @param {boolean} data.canTopup - TRUE for streams, FALSE for vesting contracts.
|
|
82
|
+
* @param {boolean} data.cancelableBySender - Whether or not sender can cancel the stream.
|
|
83
|
+
* @param {boolean} data.cancelableByRecipient - Whether or not recipient can cancel the stream.
|
|
84
|
+
* @param {boolean} data.transferableBySender - Whether or not sender can transfer the stream.
|
|
85
|
+
* @param {boolean} data.transferableByRecipient - Whether or not recipient can transfer the stream.
|
|
86
|
+
* @param {boolean} data.automaticWithdrawal - Whether or not a 3rd party can initiate withdraw in the name of recipient.
|
|
87
|
+
* @param {number} [data.withdrawalFrequency = 0] - Relevant when automatic withdrawal is enabled. If greater than 0 our withdrawor will take care of withdrawals. If equal to 0 our withdrawor will skip, but everyone else can initiate withdrawals.
|
|
88
|
+
* @param {boolean} [data.isNative = false] - When true Automatically wraps SOLs to WrappedSOL and creates wSOL stream
|
|
89
|
+
* @param {string | null} [data.partner = null] - Partner's wallet address (optional).
|
|
90
|
+
*/
|
|
91
|
+
createMultiple(data: ICreateMultipleStreamData, { sender, partner, isNative }: ICreateStreamSolanaExt): Promise<CreateMultiResponse>;
|
|
92
|
+
/**
|
|
93
|
+
* Attempts withdrawal from the specified stream.
|
|
94
|
+
* @param {WithdrawParams} data
|
|
95
|
+
* @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (recipient) or transaction will fail.
|
|
96
|
+
* @param {string} data.id - Identifier of a stream (escrow account with metadata) to be withdrawn from.
|
|
97
|
+
* @param {BN} data.amount - Requested amount (in the smallest units) to withdraw (while streaming). If stream is completed, the whole amount will be withdrawn.
|
|
98
|
+
*/
|
|
99
|
+
withdraw({ id, amount }: IWithdrawData, { invoker }: IInteractStreamSolanaExt): Promise<TxResponse>;
|
|
100
|
+
/**
|
|
101
|
+
* Attempts canceling the specified stream.
|
|
102
|
+
* @param {CancelParams} data
|
|
103
|
+
* @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (sender or recipient) or transaction will fail.
|
|
104
|
+
* @param {string} data.id - Identifier of a stream (escrow account with metadata) to be canceled.
|
|
105
|
+
*/
|
|
106
|
+
cancel({ id }: ICancelData, { invoker }: IInteractStreamSolanaExt): Promise<TxResponse>;
|
|
107
|
+
/**
|
|
108
|
+
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
109
|
+
* Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
|
|
110
|
+
* @param {TransferParams} data
|
|
111
|
+
* @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (sender or recipient) or transaction will fail.
|
|
112
|
+
* @param {string} data.id - Identifier of a stream (escrow account with metadata) to be transferred.
|
|
113
|
+
* @param {string} data.recipientId - Address of a new recipient.
|
|
114
|
+
*/
|
|
115
|
+
transfer({ id, newRecipient: newRecipientString }: ITransferData, { invoker }: IInteractStreamSolanaExt): Promise<TxResponse>;
|
|
116
|
+
/**
|
|
117
|
+
* Tops up stream account deposited amount.
|
|
118
|
+
* @param {TopupParams} data
|
|
119
|
+
* @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match current stream sender or transaction will fail.
|
|
120
|
+
* @param {string} data.id - Identifier of a stream (escrow account with metadata) to be topped up.
|
|
121
|
+
* @param {BN} data.amount - Specified amount (in the smallest units) to topup (increases deposited amount).
|
|
122
|
+
*/
|
|
123
|
+
topup({ id, amount }: ITopUpData, { invoker, isNative }: ITopUpStreamSolanaExt): Promise<TxResponse>;
|
|
124
|
+
/**
|
|
125
|
+
* Fetch stream data by its id (address).
|
|
126
|
+
* @param {string} id - Identifier of a stream that is fetched.
|
|
127
|
+
*/
|
|
128
|
+
getOne({ id }: IGetOneData): Promise<StreamData>;
|
|
129
|
+
/**
|
|
130
|
+
* Fetch streams/contracts by providing direction.
|
|
131
|
+
* Streams are sorted by start time in ascending order.
|
|
132
|
+
* @param {GetAllParams} data
|
|
133
|
+
* @param {PublicKey} data.wallet - PublicKey of the wallet for which the streams/contracts are fetched.
|
|
134
|
+
* @param {StreamType} [data.type = StreamType.All] - It can be one of: stream, vesting, all.
|
|
135
|
+
* @param {StreamDirection} [data.direction = StreamDirection.All] - It can be one of: incoming, outgoing, all.
|
|
136
|
+
*/
|
|
137
|
+
get({ wallet, type, direction, }: GetAllParams): Promise<[string, StreamData][]>;
|
|
138
|
+
private sign;
|
|
139
|
+
/**
|
|
140
|
+
* Forms instructions from params, creates a raw transaction and fetch recent blockhash.
|
|
141
|
+
* @param {MultiRecipient} recipient - Wallet sending stream to
|
|
142
|
+
* @param {CreateMultiParams} streamParams - Parameters of stream user wants to create.
|
|
143
|
+
*/
|
|
144
|
+
private prepareStreamTransaction;
|
|
145
|
+
}
|