@streamflow/stream 2.0.2-beta.24 → 2.1.1
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/README.md +47 -34
- package/dist/constants.d.ts +0 -2
- package/dist/constants.js +1 -3
- package/dist/index.d.ts +1 -2
- package/dist/index.js +3 -4
- package/dist/sdk.d.ts +28 -26
- package/dist/sdk.js +194 -251
- package/dist/types.d.ts +54 -40
- package/dist/utils.d.ts +6 -6
- package/dist/utils.js +74 -32
- package/package.json +1 -1
- package/dist/instructions.d.ts +0 -97
- package/dist/instructions.js +0 -210
- package/dist/layout.d.ts +0 -18
- package/dist/layout.js +0 -73
package/dist/instructions.js
DELETED
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.topupStreamInstruction = exports.transferStreamInstruction = exports.cancelStreamInstruction = exports.withdrawStreamInstruction = exports.createStreamInstruction = void 0;
|
|
23
|
-
var buffer_1 = require("buffer");
|
|
24
|
-
var web3_js_1 = require("@solana/web3.js");
|
|
25
|
-
var js_sha256_1 = require("js-sha256");
|
|
26
|
-
var Layout = __importStar(require("./layout"));
|
|
27
|
-
var createStreamInstruction = function (data, programId, accounts) {
|
|
28
|
-
var keys = [
|
|
29
|
-
{ pubkey: accounts.sender, isSigner: true, isWritable: true },
|
|
30
|
-
{ pubkey: accounts.senderTokens, isSigner: false, isWritable: true },
|
|
31
|
-
{ pubkey: accounts.recipient, isSigner: false, isWritable: true },
|
|
32
|
-
{ pubkey: accounts.metadata, isSigner: true, isWritable: true },
|
|
33
|
-
{ pubkey: accounts.escrowTokens, isSigner: false, isWritable: true },
|
|
34
|
-
{ pubkey: accounts.recipientTokens, isSigner: false, isWritable: true },
|
|
35
|
-
{
|
|
36
|
-
pubkey: accounts.streamflowTreasury,
|
|
37
|
-
isSigner: false,
|
|
38
|
-
isWritable: true,
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
pubkey: accounts.streamflowTreasuryTokens,
|
|
42
|
-
isSigner: false,
|
|
43
|
-
isWritable: true,
|
|
44
|
-
},
|
|
45
|
-
{ pubkey: accounts.withdrawor, isSigner: false, isWritable: true },
|
|
46
|
-
{ pubkey: accounts.partner, isSigner: false, isWritable: true },
|
|
47
|
-
{ pubkey: accounts.partnerTokens, isSigner: false, isWritable: true },
|
|
48
|
-
{ pubkey: accounts.mint, isSigner: false, isWritable: false },
|
|
49
|
-
{ pubkey: accounts.feeOracle, isSigner: false, isWritable: false },
|
|
50
|
-
{ pubkey: accounts.rent, isSigner: false, isWritable: false },
|
|
51
|
-
{ pubkey: accounts.timelockProgram, isSigner: false, isWritable: false },
|
|
52
|
-
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
|
53
|
-
{
|
|
54
|
-
pubkey: accounts.associatedTokenProgram,
|
|
55
|
-
isSigner: false,
|
|
56
|
-
isWritable: false,
|
|
57
|
-
},
|
|
58
|
-
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
|
|
59
|
-
];
|
|
60
|
-
var bufferData = buffer_1.Buffer.alloc(Layout.createStreamLayout.span);
|
|
61
|
-
var encodedUIntArray = new TextEncoder().encode(data.name);
|
|
62
|
-
var streamNameBuffer = buffer_1.Buffer.alloc(64).fill(encodedUIntArray, 0, encodedUIntArray.byteLength);
|
|
63
|
-
var decodedData = {
|
|
64
|
-
start_time: data.start.toBuffer(),
|
|
65
|
-
net_amount_deposited: data.depositedAmount.toBuffer(),
|
|
66
|
-
period: data.period.toBuffer(),
|
|
67
|
-
amount_per_period: data.amountPerPeriod.toBuffer(),
|
|
68
|
-
cliff: data.cliff.toBuffer(),
|
|
69
|
-
cliff_amount: data.cliffAmount.toBuffer(),
|
|
70
|
-
cancelable_by_sender: data.cancelableBySender,
|
|
71
|
-
cancelable_by_recipient: data.cancelableByRecipient,
|
|
72
|
-
automatic_withdrawal: data.automaticWithdrawal,
|
|
73
|
-
transferable_by_sender: data.transferableBySender,
|
|
74
|
-
transferable_by_recipient: data.transferableByRecipient,
|
|
75
|
-
can_topup: data.canTopup,
|
|
76
|
-
stream_name: streamNameBuffer,
|
|
77
|
-
withdraw_frequency: data.withdrawFrequency.toBuffer(),
|
|
78
|
-
};
|
|
79
|
-
var encodeLength = Layout.createStreamLayout.encode(decodedData, bufferData);
|
|
80
|
-
bufferData = bufferData.slice(0, encodeLength);
|
|
81
|
-
bufferData = buffer_1.Buffer.concat([
|
|
82
|
-
buffer_1.Buffer.from(js_sha256_1.sha256.digest("global:create")).slice(0, 8),
|
|
83
|
-
bufferData,
|
|
84
|
-
]);
|
|
85
|
-
return new web3_js_1.TransactionInstruction({
|
|
86
|
-
keys: keys,
|
|
87
|
-
programId: programId,
|
|
88
|
-
data: bufferData,
|
|
89
|
-
});
|
|
90
|
-
};
|
|
91
|
-
exports.createStreamInstruction = createStreamInstruction;
|
|
92
|
-
var withdrawStreamInstruction = function (amount, programId, _a) {
|
|
93
|
-
var authority = _a.authority, recipient = _a.recipient, recipientTokens = _a.recipientTokens, metadata = _a.metadata, escrowTokens = _a.escrowTokens, streamflowTreasury = _a.streamflowTreasury, streamflowTreasuryTokens = _a.streamflowTreasuryTokens, partner = _a.partner, partnerTokens = _a.partnerTokens, mint = _a.mint, tokenProgram = _a.tokenProgram;
|
|
94
|
-
var keys = [
|
|
95
|
-
{ pubkey: authority, isSigner: true, isWritable: true },
|
|
96
|
-
{ pubkey: recipient, isSigner: false, isWritable: true },
|
|
97
|
-
{ pubkey: recipientTokens, isSigner: false, isWritable: true },
|
|
98
|
-
{ pubkey: metadata, isSigner: false, isWritable: true },
|
|
99
|
-
{ pubkey: escrowTokens, isSigner: false, isWritable: true },
|
|
100
|
-
{
|
|
101
|
-
pubkey: streamflowTreasury,
|
|
102
|
-
isSigner: false,
|
|
103
|
-
isWritable: true,
|
|
104
|
-
},
|
|
105
|
-
{ pubkey: streamflowTreasuryTokens, isSigner: false, isWritable: true },
|
|
106
|
-
{ pubkey: partner, isSigner: false, isWritable: true },
|
|
107
|
-
{ pubkey: partnerTokens, isSigner: false, isWritable: true },
|
|
108
|
-
{ pubkey: mint, isSigner: false, isWritable: false },
|
|
109
|
-
{ pubkey: tokenProgram, isSigner: false, isWritable: false },
|
|
110
|
-
];
|
|
111
|
-
var data = buffer_1.Buffer.alloc(Layout.withdrawStreamLayout.span);
|
|
112
|
-
var decodedData = { amount: amount.toBuffer() };
|
|
113
|
-
var encodeLength = Layout.withdrawStreamLayout.encode(decodedData, data);
|
|
114
|
-
data = data.slice(0, encodeLength);
|
|
115
|
-
data = buffer_1.Buffer.concat([
|
|
116
|
-
buffer_1.Buffer.from(js_sha256_1.sha256.digest("global:withdraw")).slice(0, 8),
|
|
117
|
-
data,
|
|
118
|
-
]);
|
|
119
|
-
return new web3_js_1.TransactionInstruction({
|
|
120
|
-
keys: keys,
|
|
121
|
-
programId: programId,
|
|
122
|
-
data: data,
|
|
123
|
-
});
|
|
124
|
-
};
|
|
125
|
-
exports.withdrawStreamInstruction = withdrawStreamInstruction;
|
|
126
|
-
var cancelStreamInstruction = function (programId, _a) {
|
|
127
|
-
var authority = _a.authority, sender = _a.sender, senderTokens = _a.senderTokens, recipient = _a.recipient, recipientTokens = _a.recipientTokens, metadata = _a.metadata, escrowTokens = _a.escrowTokens, streamflowTreasury = _a.streamflowTreasury, streamflowTreasuryTokens = _a.streamflowTreasuryTokens, partner = _a.partner, partnerTokens = _a.partnerTokens, mint = _a.mint, tokenProgram = _a.tokenProgram;
|
|
128
|
-
var keys = [
|
|
129
|
-
{ pubkey: authority, isSigner: true, isWritable: false },
|
|
130
|
-
{ pubkey: sender, isSigner: false, isWritable: true },
|
|
131
|
-
{ pubkey: senderTokens, isSigner: false, isWritable: true },
|
|
132
|
-
{ pubkey: recipient, isSigner: false, isWritable: true },
|
|
133
|
-
{ pubkey: recipientTokens, isSigner: false, isWritable: true },
|
|
134
|
-
{ pubkey: metadata, isSigner: false, isWritable: true },
|
|
135
|
-
{ pubkey: escrowTokens, isSigner: false, isWritable: true },
|
|
136
|
-
{
|
|
137
|
-
pubkey: streamflowTreasury,
|
|
138
|
-
isSigner: false,
|
|
139
|
-
isWritable: true,
|
|
140
|
-
},
|
|
141
|
-
{ pubkey: streamflowTreasuryTokens, isSigner: false, isWritable: true },
|
|
142
|
-
{ pubkey: partner, isSigner: false, isWritable: true },
|
|
143
|
-
{ pubkey: partnerTokens, isSigner: false, isWritable: true },
|
|
144
|
-
{ pubkey: mint, isSigner: false, isWritable: false },
|
|
145
|
-
{ pubkey: tokenProgram, isSigner: false, isWritable: false },
|
|
146
|
-
];
|
|
147
|
-
var data = buffer_1.Buffer.from(js_sha256_1.sha256.digest("global:cancel")).slice(0, 8);
|
|
148
|
-
return new web3_js_1.TransactionInstruction({
|
|
149
|
-
keys: keys,
|
|
150
|
-
programId: programId,
|
|
151
|
-
data: data,
|
|
152
|
-
});
|
|
153
|
-
};
|
|
154
|
-
exports.cancelStreamInstruction = cancelStreamInstruction;
|
|
155
|
-
var transferStreamInstruction = function (programId, _a) {
|
|
156
|
-
var authority = _a.authority, newRecipient = _a.newRecipient, newRecipientTokens = _a.newRecipientTokens, metadata = _a.metadata, mint = _a.mint, rent = _a.rent, tokenProgram = _a.tokenProgram, associatedTokenProgram = _a.associatedTokenProgram, systemProgram = _a.systemProgram;
|
|
157
|
-
var keys = [
|
|
158
|
-
{ pubkey: authority, isSigner: true, isWritable: true },
|
|
159
|
-
{ pubkey: newRecipient, isSigner: false, isWritable: true },
|
|
160
|
-
{ pubkey: newRecipientTokens, isSigner: false, isWritable: true },
|
|
161
|
-
{ pubkey: metadata, isSigner: false, isWritable: true },
|
|
162
|
-
{ pubkey: mint, isSigner: false, isWritable: false },
|
|
163
|
-
{ pubkey: rent, isSigner: false, isWritable: false },
|
|
164
|
-
{ pubkey: tokenProgram, isSigner: false, isWritable: false },
|
|
165
|
-
{ pubkey: associatedTokenProgram, isSigner: false, isWritable: false },
|
|
166
|
-
{ pubkey: systemProgram, isSigner: false, isWritable: false },
|
|
167
|
-
];
|
|
168
|
-
var data = buffer_1.Buffer.from(js_sha256_1.sha256.digest("global:transfer_recipient")).slice(0, 8);
|
|
169
|
-
return new web3_js_1.TransactionInstruction({
|
|
170
|
-
keys: keys,
|
|
171
|
-
programId: programId,
|
|
172
|
-
data: data,
|
|
173
|
-
});
|
|
174
|
-
};
|
|
175
|
-
exports.transferStreamInstruction = transferStreamInstruction;
|
|
176
|
-
var topupStreamInstruction = function (amount, programId, _a) {
|
|
177
|
-
var sender = _a.sender, senderTokens = _a.senderTokens, metadata = _a.metadata, escrowTokens = _a.escrowTokens, streamflowTreasury = _a.streamflowTreasury, streamflowTreasuryTokens = _a.streamflowTreasuryTokens, partner = _a.partner, partnerTokens = _a.partnerTokens, mint = _a.mint, tokenProgram = _a.tokenProgram, withdrawor = _a.withdrawor, systemProgram = _a.systemProgram;
|
|
178
|
-
var keys = [
|
|
179
|
-
{ pubkey: sender, isSigner: true, isWritable: true },
|
|
180
|
-
{ pubkey: senderTokens, isSigner: false, isWritable: true },
|
|
181
|
-
{ pubkey: metadata, isSigner: false, isWritable: true },
|
|
182
|
-
{ pubkey: escrowTokens, isSigner: false, isWritable: true },
|
|
183
|
-
{
|
|
184
|
-
pubkey: streamflowTreasury,
|
|
185
|
-
isSigner: false,
|
|
186
|
-
isWritable: true,
|
|
187
|
-
},
|
|
188
|
-
{ pubkey: streamflowTreasuryTokens, isSigner: false, isWritable: true },
|
|
189
|
-
{ pubkey: withdrawor, isSigner: false, isWritable: true },
|
|
190
|
-
{ pubkey: partner, isSigner: false, isWritable: true },
|
|
191
|
-
{ pubkey: partnerTokens, isSigner: false, isWritable: true },
|
|
192
|
-
{ pubkey: mint, isSigner: false, isWritable: false },
|
|
193
|
-
{ pubkey: tokenProgram, isSigner: false, isWritable: false },
|
|
194
|
-
{ pubkey: systemProgram, isSigner: false, isWritable: false },
|
|
195
|
-
];
|
|
196
|
-
var data = buffer_1.Buffer.alloc(Layout.topupStreamLayout.span);
|
|
197
|
-
var decodedData = { amount: amount.toBuffer() };
|
|
198
|
-
var encodeLength = Layout.topupStreamLayout.encode(decodedData, data);
|
|
199
|
-
data = data.slice(0, encodeLength);
|
|
200
|
-
data = buffer_1.Buffer.concat([
|
|
201
|
-
buffer_1.Buffer.from(js_sha256_1.sha256.digest("global:topup")).slice(0, 8),
|
|
202
|
-
data,
|
|
203
|
-
]);
|
|
204
|
-
return new web3_js_1.TransactionInstruction({
|
|
205
|
-
keys: keys,
|
|
206
|
-
programId: programId,
|
|
207
|
-
data: data,
|
|
208
|
-
});
|
|
209
|
-
};
|
|
210
|
-
exports.topupStreamInstruction = topupStreamInstruction;
|
package/dist/layout.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
declare const BufferLayout: any;
|
|
2
|
-
/**
|
|
3
|
-
* Stream layout
|
|
4
|
-
*/
|
|
5
|
-
export declare const streamLayout: typeof BufferLayout.Structure;
|
|
6
|
-
/**
|
|
7
|
-
* Create stream instruction layout
|
|
8
|
-
*/
|
|
9
|
-
export declare const createStreamLayout: typeof BufferLayout.Structure;
|
|
10
|
-
/**
|
|
11
|
-
* Withdraw stream instruction layout
|
|
12
|
-
*/
|
|
13
|
-
export declare const withdrawStreamLayout: typeof BufferLayout.Structure;
|
|
14
|
-
/**
|
|
15
|
-
* Topup stream instruction layout
|
|
16
|
-
*/
|
|
17
|
-
export declare const topupStreamLayout: typeof BufferLayout.Structure;
|
|
18
|
-
export {};
|
package/dist/layout.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.topupStreamLayout = exports.withdrawStreamLayout = exports.createStreamLayout = exports.streamLayout = void 0;
|
|
4
|
-
var BufferLayout = require("buffer-layout");
|
|
5
|
-
/**
|
|
6
|
-
* Stream layout
|
|
7
|
-
*/
|
|
8
|
-
exports.streamLayout = BufferLayout.struct([
|
|
9
|
-
BufferLayout.blob(8, "magic"),
|
|
10
|
-
BufferLayout.blob(1, "version"),
|
|
11
|
-
BufferLayout.blob(8, "created_at"),
|
|
12
|
-
BufferLayout.blob(8, "withdrawn_amount"),
|
|
13
|
-
BufferLayout.blob(8, "canceled_at"),
|
|
14
|
-
BufferLayout.blob(8, "end_time"),
|
|
15
|
-
BufferLayout.blob(8, "last_withdrawn_at"),
|
|
16
|
-
BufferLayout.blob(32, "sender"),
|
|
17
|
-
BufferLayout.blob(32, "sender_tokens"),
|
|
18
|
-
BufferLayout.blob(32, "recipient"),
|
|
19
|
-
BufferLayout.blob(32, "recipient_tokens"),
|
|
20
|
-
BufferLayout.blob(32, "mint"),
|
|
21
|
-
BufferLayout.blob(32, "escrow_tokens"),
|
|
22
|
-
BufferLayout.blob(32, "streamflow_treasury"),
|
|
23
|
-
BufferLayout.blob(32, "streamflow_treasury_tokens"),
|
|
24
|
-
BufferLayout.blob(8, "streamflow_fee_total"),
|
|
25
|
-
BufferLayout.blob(8, "streamflow_fee_withdrawn"),
|
|
26
|
-
BufferLayout.f32("streamflow_fee_percent"),
|
|
27
|
-
BufferLayout.blob(32, "partner"),
|
|
28
|
-
BufferLayout.blob(32, "partner_tokens"),
|
|
29
|
-
BufferLayout.blob(8, "partner_fee_total"),
|
|
30
|
-
BufferLayout.blob(8, "partner_fee_withdrawn"),
|
|
31
|
-
BufferLayout.f32("partner_fee_percent"),
|
|
32
|
-
BufferLayout.blob(8, "start_time"),
|
|
33
|
-
BufferLayout.blob(8, "net_amount_deposited"),
|
|
34
|
-
BufferLayout.blob(8, "period"),
|
|
35
|
-
BufferLayout.blob(8, "amount_per_period"),
|
|
36
|
-
BufferLayout.blob(8, "cliff"),
|
|
37
|
-
BufferLayout.blob(8, "cliff_amount"),
|
|
38
|
-
BufferLayout.u8("cancelable_by_sender"),
|
|
39
|
-
BufferLayout.u8("cancelable_by_recipient"),
|
|
40
|
-
BufferLayout.u8("automatic_withdrawal"),
|
|
41
|
-
BufferLayout.u8("transferable_by_sender"),
|
|
42
|
-
BufferLayout.u8("transferable_by_recipient"),
|
|
43
|
-
BufferLayout.u8("can_topup"),
|
|
44
|
-
BufferLayout.blob(64, "stream_name"),
|
|
45
|
-
BufferLayout.blob(8, "withdraw_frequency"),
|
|
46
|
-
]);
|
|
47
|
-
/**
|
|
48
|
-
* Create stream instruction layout
|
|
49
|
-
*/
|
|
50
|
-
exports.createStreamLayout = BufferLayout.struct([
|
|
51
|
-
BufferLayout.blob(8, "start_time"),
|
|
52
|
-
BufferLayout.blob(8, "net_amount_deposited"),
|
|
53
|
-
BufferLayout.blob(8, "period"),
|
|
54
|
-
BufferLayout.blob(8, "amount_per_period"),
|
|
55
|
-
BufferLayout.blob(8, "cliff"),
|
|
56
|
-
BufferLayout.blob(8, "cliff_amount"),
|
|
57
|
-
BufferLayout.u8("cancelable_by_sender"),
|
|
58
|
-
BufferLayout.u8("cancelable_by_recipient"),
|
|
59
|
-
BufferLayout.u8("automatic_withdrawal"),
|
|
60
|
-
BufferLayout.u8("transferable_by_sender"),
|
|
61
|
-
BufferLayout.u8("transferable_by_recipient"),
|
|
62
|
-
BufferLayout.u8("can_topup"),
|
|
63
|
-
BufferLayout.blob(64, "stream_name"),
|
|
64
|
-
BufferLayout.blob(8, "withdraw_frequency"),
|
|
65
|
-
]);
|
|
66
|
-
/**
|
|
67
|
-
* Withdraw stream instruction layout
|
|
68
|
-
*/
|
|
69
|
-
exports.withdrawStreamLayout = BufferLayout.struct([BufferLayout.blob(8, "amount")]);
|
|
70
|
-
/**
|
|
71
|
-
* Topup stream instruction layout
|
|
72
|
-
*/
|
|
73
|
-
exports.topupStreamLayout = BufferLayout.struct([BufferLayout.blob(8, "amount")]);
|