@streamflow/stream 7.1.0-alpha.2 → 7.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/dist/cjs/solana/StreamClient.js +14 -10
- package/dist/cjs/solana/constants.js +3 -1
- package/dist/cjs/solana/instructions.js +27 -18
- package/dist/esm/solana/StreamClient.js +14 -10
- package/dist/esm/solana/constants.d.ts +1 -0
- package/dist/esm/solana/constants.js +2 -0
- package/dist/esm/solana/instructions.d.ts +7 -7
- package/dist/esm/solana/instructions.js +27 -18
- package/dist/esm/solana/types.d.ts +1 -0
- package/package.json +4 -4
|
@@ -29,6 +29,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
30
|
exports.SolanaStreamClient = void 0;
|
|
31
31
|
const bn_js_1 = __importDefault(require("bn.js"));
|
|
32
|
+
const bs58_1 = __importDefault(require("bs58"));
|
|
32
33
|
const buffer_1 = require("buffer");
|
|
33
34
|
const spl_token_1 = require("@solana/spl-token");
|
|
34
35
|
const web3_js_1 = require("@solana/web3.js");
|
|
@@ -195,7 +196,7 @@ class SolanaStreamClient extends BaseStreamClient_js_1.BaseStreamClient {
|
|
|
195
196
|
const streamflowTreasuryTokens = await (0, solana_1.ata)(mintPublicKey, constants_js_1.STREAMFLOW_TREASURY_PUBLIC_KEY, tokenProgramId);
|
|
196
197
|
const partnerPublicKey = partner ? new web3_js_1.PublicKey(partner) : constants_js_1.WITHDRAWOR_PUBLIC_KEY;
|
|
197
198
|
const partnerTokens = await (0, solana_1.ata)(mintPublicKey, partnerPublicKey, tokenProgramId);
|
|
198
|
-
ixs.push((0, instructions_js_1.createStreamInstruction)({
|
|
199
|
+
ixs.push(await (0, instructions_js_1.createStreamInstruction)({
|
|
199
200
|
start: new bn_js_1.default(start),
|
|
200
201
|
depositedAmount,
|
|
201
202
|
period: new bn_js_1.default(period),
|
|
@@ -285,7 +286,7 @@ class SolanaStreamClient extends BaseStreamClient_js_1.BaseStreamClient {
|
|
|
285
286
|
const totalAmount = (0, utils_js_2.calculateTotalAmountToDeposit)(depositedAmount, totalFee);
|
|
286
287
|
ixs.push(...(await (0, solana_1.prepareWrappedAccount)(this.connection, sender.publicKey, totalAmount)));
|
|
287
288
|
}
|
|
288
|
-
const createInstruction = (0, instructions_js_1.createUncheckedStreamInstruction)({
|
|
289
|
+
const createInstruction = await (0, instructions_js_1.createUncheckedStreamInstruction)({
|
|
289
290
|
start: new bn_js_1.default(start),
|
|
290
291
|
depositedAmount,
|
|
291
292
|
period: new bn_js_1.default(period),
|
|
@@ -558,7 +559,7 @@ class SolanaStreamClient extends BaseStreamClient_js_1.BaseStreamClient {
|
|
|
558
559
|
const streamflowTreasuryTokens = await (0, solana_1.ata)(mint, constants_js_1.STREAMFLOW_TREASURY_PUBLIC_KEY, tokenProgramId);
|
|
559
560
|
const partnerTokens = await (0, solana_1.ata)(mint, partner, tokenProgramId);
|
|
560
561
|
const ataIx = await this.getCreateATAInstructions([sender, recipient, streamflowTreasury, partner], mint, invoker, checkTokenAccounts, tokenProgramId);
|
|
561
|
-
ixs.push(...ataIx, (0, instructions_js_1.withdrawStreamInstruction)(amount, this.programId, {
|
|
562
|
+
ixs.push(...ataIx, await (0, instructions_js_1.withdrawStreamInstruction)(amount, this.programId, {
|
|
562
563
|
partner,
|
|
563
564
|
partnerTokens,
|
|
564
565
|
mint,
|
|
@@ -655,7 +656,7 @@ class SolanaStreamClient extends BaseStreamClient_js_1.BaseStreamClient {
|
|
|
655
656
|
computeLimit,
|
|
656
657
|
});
|
|
657
658
|
const ixsAta = await this.getCreateATAInstructions([sender, recipient, partner, streamflowTreasury], mint, invoker, checkTokenAccounts, tokenProgramId);
|
|
658
|
-
ixs.push(...ixsAta, (0, instructions_js_1.cancelStreamInstruction)(this.programId, {
|
|
659
|
+
ixs.push(...ixsAta, await (0, instructions_js_1.cancelStreamInstruction)(this.programId, {
|
|
659
660
|
sender,
|
|
660
661
|
senderTokens,
|
|
661
662
|
recipient,
|
|
@@ -707,7 +708,7 @@ class SolanaStreamClient extends BaseStreamClient_js_1.BaseStreamClient {
|
|
|
707
708
|
const { mint } = (0, utils_js_1.decodeStream)(escrow?.data);
|
|
708
709
|
const { tokenProgramId } = await (0, solana_1.getMintAndProgram)(this.connection, mint);
|
|
709
710
|
const newRecipientTokens = await (0, solana_1.ata)(mint, newRecipientPublicKey, tokenProgramId);
|
|
710
|
-
ixs.push((0, instructions_js_1.transferStreamInstruction)(this.programId, {
|
|
711
|
+
ixs.push(await (0, instructions_js_1.transferStreamInstruction)(this.programId, {
|
|
711
712
|
authority: invoker.publicKey,
|
|
712
713
|
newRecipient: newRecipientPublicKey,
|
|
713
714
|
newRecipientTokens,
|
|
@@ -756,7 +757,7 @@ class SolanaStreamClient extends BaseStreamClient_js_1.BaseStreamClient {
|
|
|
756
757
|
if (isNative) {
|
|
757
758
|
ixs.push(...(await (0, solana_1.prepareWrappedAccount)(this.connection, invoker.publicKey, amount)));
|
|
758
759
|
}
|
|
759
|
-
ixs.push((0, instructions_js_1.topupStreamInstruction)(amount, this.programId, {
|
|
760
|
+
ixs.push(await (0, instructions_js_1.topupStreamInstruction)(amount, this.programId, {
|
|
760
761
|
sender: invoker.publicKey,
|
|
761
762
|
senderTokens,
|
|
762
763
|
metadata: streamPublicKey,
|
|
@@ -872,14 +873,17 @@ class SolanaStreamClient extends BaseStreamClient_js_1.BaseStreamClient {
|
|
|
872
873
|
async searchStreams(data) {
|
|
873
874
|
const filters = Object.entries(data)
|
|
874
875
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
875
|
-
.filter(([_, value]) => value) // Only keep entries where the value is truthy
|
|
876
|
+
.filter(([_, value]) => value !== undefined) // Only keep entries where the value is truthy
|
|
876
877
|
.map(([key, value]) => ({
|
|
877
878
|
memcmp: {
|
|
878
879
|
offset: constants_js_1.STREAM_STRUCT_OFFSETS[key],
|
|
879
|
-
bytes: value,
|
|
880
|
+
bytes: typeof value === "boolean" ? bs58_1.default.encode([Number(value)]) : value.toString(),
|
|
880
881
|
},
|
|
881
882
|
}));
|
|
882
|
-
|
|
883
|
+
filters.push({ dataSize: METADATA_ACC_SIZE });
|
|
884
|
+
const accounts = await this.connection.getProgramAccounts(this.programId, {
|
|
885
|
+
filters,
|
|
886
|
+
});
|
|
883
887
|
return accounts.map(({ pubkey, account }) => ({
|
|
884
888
|
publicKey: pubkey,
|
|
885
889
|
account: new types_js_1.Contract((0, utils_js_1.decodeStream)(account.data)),
|
|
@@ -917,7 +921,7 @@ class SolanaStreamClient extends BaseStreamClient_js_1.BaseStreamClient {
|
|
|
917
921
|
computePrice,
|
|
918
922
|
computeLimit,
|
|
919
923
|
});
|
|
920
|
-
ixs.push((0, instructions_js_1.updateStreamInstruction)(data, this.programId, {
|
|
924
|
+
ixs.push(await (0, instructions_js_1.updateStreamInstruction)(data, this.programId, {
|
|
921
925
|
authority: invoker.publicKey,
|
|
922
926
|
metadata: streamPublicKey,
|
|
923
927
|
withdrawor: constants_js_1.WITHDRAWOR_PUBLIC_KEY,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SOLANA_ERROR_MAP = exports.SOLANA_ERROR_MATCH_REGEX = exports.PARTNERS_SCHEMA = exports.PARTNER_SCHEMA = exports.AIRDROP_AMOUNT = exports.DEFAULT_STREAMFLOW_FEE = exports.FEES_METADATA_SEED = exports.AIRDROP_TEST_TOKEN = exports.FEE_ORACLE_PUBLIC_KEY = exports.WITHDRAWOR_PUBLIC_KEY = exports.STREAMFLOW_TREASURY_PUBLIC_KEY = exports.PARTNER_ORACLE_PROGRAM_ID = exports.TEST_ORACLE_SEED = exports.ESCROW_SEED = exports.CONTRACT_SEED = exports.TEST_ORACLE_DISCRIMINATOR = exports.CONTRACT_DISCRIMINATOR = exports.ALIGNED_COMPUTE_LIMIT = exports.ALIGNED_UNLOCKS_PROGRAM_ID = exports.PROGRAM_ID = exports.CREATE_PARAMS_PADDING = exports.STREAM_STRUCT_OFFSETS = exports.ALIGNED_PRECISION_FACTOR_POW = exports.STREAM_STRUCT_OFFSET_MINT = exports.STREAM_STRUCT_OFFSET_RECIPIENT = exports.STREAM_STRUCT_OFFSET_SENDER = exports.ORIGINAL_CONTRACT_SENDER_OFFSET = exports.TX_FINALITY_CONFIRMED = void 0;
|
|
3
|
+
exports.SOLANA_ERROR_MAP = exports.SOLANA_ERROR_MATCH_REGEX = exports.PARTNERS_SCHEMA = exports.PARTNER_SCHEMA = exports.AIRDROP_AMOUNT = exports.DEFAULT_STREAMFLOW_FEE = exports.FEES_METADATA_SEED = exports.AIRDROP_TEST_TOKEN = exports.FEE_ORACLE_PUBLIC_KEY = exports.WITHDRAWOR_PUBLIC_KEY = exports.STREAMFLOW_TREASURY_PUBLIC_KEY = exports.PARTNER_ORACLE_PROGRAM_ID = exports.TEST_ORACLE_SEED = exports.ESCROW_SEED = exports.CONTRACT_SEED = exports.TEST_ORACLE_DISCRIMINATOR = exports.CONTRACT_DISCRIMINATOR = exports.ALIGNED_COMPUTE_LIMIT = exports.ALIGNED_UNLOCKS_PROGRAM_ID = exports.PROGRAM_ID = exports.CREATE_PARAMS_PADDING = exports.STREAM_STRUCT_OFFSETS = exports.ALIGNED_PRECISION_FACTOR_POW = exports.STREAM_STRUCT_OFFSET_CLOSED = exports.STREAM_STRUCT_OFFSET_MINT = exports.STREAM_STRUCT_OFFSET_RECIPIENT = exports.STREAM_STRUCT_OFFSET_SENDER = exports.ORIGINAL_CONTRACT_SENDER_OFFSET = exports.TX_FINALITY_CONFIRMED = void 0;
|
|
4
4
|
const web3_js_1 = require("@solana/web3.js");
|
|
5
5
|
const buffer_1 = require("buffer");
|
|
6
6
|
const types_js_1 = require("../common/types.js");
|
|
@@ -9,11 +9,13 @@ exports.ORIGINAL_CONTRACT_SENDER_OFFSET = 9;
|
|
|
9
9
|
exports.STREAM_STRUCT_OFFSET_SENDER = 49;
|
|
10
10
|
exports.STREAM_STRUCT_OFFSET_RECIPIENT = 113;
|
|
11
11
|
exports.STREAM_STRUCT_OFFSET_MINT = 177;
|
|
12
|
+
exports.STREAM_STRUCT_OFFSET_CLOSED = 671;
|
|
12
13
|
exports.ALIGNED_PRECISION_FACTOR_POW = 9;
|
|
13
14
|
exports.STREAM_STRUCT_OFFSETS = {
|
|
14
15
|
mint: exports.STREAM_STRUCT_OFFSET_MINT,
|
|
15
16
|
recipient: exports.STREAM_STRUCT_OFFSET_RECIPIENT,
|
|
16
17
|
sender: exports.STREAM_STRUCT_OFFSET_SENDER,
|
|
18
|
+
closed: exports.STREAM_STRUCT_OFFSET_CLOSED,
|
|
17
19
|
};
|
|
18
20
|
// Defined: https://github.com/streamflow-finance/protocol/blob/main/programs/protocol/src/state.rs#L25
|
|
19
21
|
exports.CREATE_PARAMS_PADDING = 126;
|
|
@@ -26,13 +26,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.topupStreamInstruction = exports.transferStreamInstruction = exports.cancelStreamInstruction = exports.updateStreamInstruction = exports.withdrawStreamInstruction = exports.createUncheckedStreamInstruction = exports.createStreamInstruction = void 0;
|
|
27
27
|
const buffer_1 = require("buffer");
|
|
28
28
|
const web3_js_1 = require("@solana/web3.js");
|
|
29
|
-
const node_crypto_1 = require("node:crypto");
|
|
30
29
|
const Layout = __importStar(require("./layout.js"));
|
|
31
|
-
const hasher = () => (0, node_crypto_1.createHash)("sha256");
|
|
32
30
|
const sha256 = {
|
|
33
|
-
digest: (data) =>
|
|
31
|
+
digest: async (data) => {
|
|
32
|
+
const dataBuffer = new TextEncoder().encode(data);
|
|
33
|
+
const hashBuffer = await globalThis.crypto.subtle.digest("SHA-256", dataBuffer);
|
|
34
|
+
return new Uint8Array(hashBuffer);
|
|
35
|
+
},
|
|
34
36
|
};
|
|
35
|
-
const createStreamInstruction = (data, programId, accounts) => {
|
|
37
|
+
const createStreamInstruction = async (data, programId, accounts) => {
|
|
36
38
|
const keys = [
|
|
37
39
|
{ pubkey: accounts.sender, isSigner: true, isWritable: true },
|
|
38
40
|
{ pubkey: accounts.senderTokens, isSigner: false, isWritable: true },
|
|
@@ -90,7 +92,11 @@ const createStreamInstruction = (data, programId, accounts) => {
|
|
|
90
92
|
};
|
|
91
93
|
const encodeLength = Layout.createStreamLayout.encode(decodedData, bufferData);
|
|
92
94
|
bufferData = bufferData.slice(0, encodeLength);
|
|
93
|
-
bufferData = buffer_1.Buffer.concat([
|
|
95
|
+
bufferData = buffer_1.Buffer.concat([
|
|
96
|
+
buffer_1.Buffer.from(await sha256.digest("global:create")).slice(0, 8),
|
|
97
|
+
bufferData,
|
|
98
|
+
buffer_1.Buffer.alloc(10),
|
|
99
|
+
]);
|
|
94
100
|
return new web3_js_1.TransactionInstruction({
|
|
95
101
|
keys,
|
|
96
102
|
programId,
|
|
@@ -98,7 +104,7 @@ const createStreamInstruction = (data, programId, accounts) => {
|
|
|
98
104
|
});
|
|
99
105
|
};
|
|
100
106
|
exports.createStreamInstruction = createStreamInstruction;
|
|
101
|
-
const createUncheckedStreamInstruction = (data, programId, accounts) => {
|
|
107
|
+
const createUncheckedStreamInstruction = async (data, programId, accounts) => {
|
|
102
108
|
const keys = [
|
|
103
109
|
{ pubkey: accounts.sender, isSigner: true, isWritable: true },
|
|
104
110
|
{ pubkey: accounts.senderTokens, isSigner: false, isWritable: true },
|
|
@@ -145,8 +151,8 @@ const createUncheckedStreamInstruction = (data, programId, accounts) => {
|
|
|
145
151
|
const encodeLength = Layout.createUncheckedStreamLayout.encode(decodedData, bufferData);
|
|
146
152
|
bufferData = bufferData.slice(0, encodeLength);
|
|
147
153
|
const digest = accounts.payer
|
|
148
|
-
? sha256.digest("global:create_unchecked_with_payer")
|
|
149
|
-
: sha256.digest("global:create_unchecked");
|
|
154
|
+
? await sha256.digest("global:create_unchecked_with_payer")
|
|
155
|
+
: await sha256.digest("global:create_unchecked");
|
|
150
156
|
bufferData = buffer_1.Buffer.concat([buffer_1.Buffer.from(digest).slice(0, 8), bufferData, buffer_1.Buffer.alloc(10)]);
|
|
151
157
|
return new web3_js_1.TransactionInstruction({
|
|
152
158
|
keys,
|
|
@@ -155,7 +161,7 @@ const createUncheckedStreamInstruction = (data, programId, accounts) => {
|
|
|
155
161
|
});
|
|
156
162
|
};
|
|
157
163
|
exports.createUncheckedStreamInstruction = createUncheckedStreamInstruction;
|
|
158
|
-
const withdrawStreamInstruction = (amount, programId, { authority, recipient, recipientTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, }) => {
|
|
164
|
+
const withdrawStreamInstruction = async (amount, programId, { authority, recipient, recipientTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, }) => {
|
|
159
165
|
const keys = [
|
|
160
166
|
{ pubkey: authority, isSigner: true, isWritable: true },
|
|
161
167
|
{ pubkey: recipient, isSigner: false, isWritable: true },
|
|
@@ -177,7 +183,7 @@ const withdrawStreamInstruction = (amount, programId, { authority, recipient, re
|
|
|
177
183
|
const decodedData = { amount: amount.toArrayLike(buffer_1.Buffer, "le", 8) };
|
|
178
184
|
const encodeLength = Layout.withdrawStreamLayout.encode(decodedData, data);
|
|
179
185
|
data = data.slice(0, encodeLength);
|
|
180
|
-
data = buffer_1.Buffer.concat([buffer_1.Buffer.from(sha256.digest("global:withdraw")).slice(0, 8), data, buffer_1.Buffer.alloc(10)]);
|
|
186
|
+
data = buffer_1.Buffer.concat([buffer_1.Buffer.from(await sha256.digest("global:withdraw")).slice(0, 8), data, buffer_1.Buffer.alloc(10)]);
|
|
181
187
|
return new web3_js_1.TransactionInstruction({
|
|
182
188
|
keys,
|
|
183
189
|
programId,
|
|
@@ -185,7 +191,7 @@ const withdrawStreamInstruction = (amount, programId, { authority, recipient, re
|
|
|
185
191
|
});
|
|
186
192
|
};
|
|
187
193
|
exports.withdrawStreamInstruction = withdrawStreamInstruction;
|
|
188
|
-
const updateStreamInstruction = (params, programId, { authority, metadata, withdrawor, systemProgram }) => {
|
|
194
|
+
const updateStreamInstruction = async (params, programId, { authority, metadata, withdrawor, systemProgram }) => {
|
|
189
195
|
const keys = [
|
|
190
196
|
{ pubkey: authority, isSigner: true, isWritable: true },
|
|
191
197
|
{ pubkey: metadata, isSigner: false, isWritable: true },
|
|
@@ -200,7 +206,7 @@ const updateStreamInstruction = (params, programId, { authority, metadata, withd
|
|
|
200
206
|
};
|
|
201
207
|
const encodeLength = Layout.encodeUpdateStream(decodedData, data);
|
|
202
208
|
data = data.slice(0, encodeLength);
|
|
203
|
-
data = buffer_1.Buffer.concat([buffer_1.Buffer.from(sha256.digest("global:update")).slice(0, 8), data, buffer_1.Buffer.alloc(20)]);
|
|
209
|
+
data = buffer_1.Buffer.concat([buffer_1.Buffer.from(await sha256.digest("global:update")).slice(0, 8), data, buffer_1.Buffer.alloc(20)]);
|
|
204
210
|
return new web3_js_1.TransactionInstruction({
|
|
205
211
|
keys: keys,
|
|
206
212
|
programId: programId,
|
|
@@ -208,7 +214,7 @@ const updateStreamInstruction = (params, programId, { authority, metadata, withd
|
|
|
208
214
|
});
|
|
209
215
|
};
|
|
210
216
|
exports.updateStreamInstruction = updateStreamInstruction;
|
|
211
|
-
const cancelStreamInstruction = (programId, { authority, sender, senderTokens, recipient, recipientTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, }) => {
|
|
217
|
+
const cancelStreamInstruction = async (programId, { authority, sender, senderTokens, recipient, recipientTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, }) => {
|
|
212
218
|
const keys = [
|
|
213
219
|
{ pubkey: authority, isSigner: true, isWritable: false },
|
|
214
220
|
{ pubkey: sender, isSigner: false, isWritable: true },
|
|
@@ -228,7 +234,7 @@ const cancelStreamInstruction = (programId, { authority, sender, senderTokens, r
|
|
|
228
234
|
{ pubkey: mint, isSigner: false, isWritable: true },
|
|
229
235
|
{ pubkey: tokenProgram, isSigner: false, isWritable: false },
|
|
230
236
|
];
|
|
231
|
-
const data = buffer_1.Buffer.concat([buffer_1.Buffer.from(sha256.digest("global:cancel")).slice(0, 8), buffer_1.Buffer.alloc(10)]);
|
|
237
|
+
const data = buffer_1.Buffer.concat([buffer_1.Buffer.from(await sha256.digest("global:cancel")).slice(0, 8), buffer_1.Buffer.alloc(10)]);
|
|
232
238
|
return new web3_js_1.TransactionInstruction({
|
|
233
239
|
keys,
|
|
234
240
|
programId,
|
|
@@ -236,7 +242,7 @@ const cancelStreamInstruction = (programId, { authority, sender, senderTokens, r
|
|
|
236
242
|
});
|
|
237
243
|
};
|
|
238
244
|
exports.cancelStreamInstruction = cancelStreamInstruction;
|
|
239
|
-
const transferStreamInstruction = (programId, { authority, newRecipient, newRecipientTokens, metadata, mint, rent, tokenProgram, associatedTokenProgram, systemProgram, }) => {
|
|
245
|
+
const transferStreamInstruction = async (programId, { authority, newRecipient, newRecipientTokens, metadata, mint, rent, tokenProgram, associatedTokenProgram, systemProgram, }) => {
|
|
240
246
|
const keys = [
|
|
241
247
|
{ pubkey: authority, isSigner: true, isWritable: true },
|
|
242
248
|
{ pubkey: newRecipient, isSigner: false, isWritable: true },
|
|
@@ -248,7 +254,10 @@ const transferStreamInstruction = (programId, { authority, newRecipient, newReci
|
|
|
248
254
|
{ pubkey: associatedTokenProgram, isSigner: false, isWritable: false },
|
|
249
255
|
{ pubkey: systemProgram, isSigner: false, isWritable: false },
|
|
250
256
|
];
|
|
251
|
-
const data = buffer_1.Buffer.concat([
|
|
257
|
+
const data = buffer_1.Buffer.concat([
|
|
258
|
+
buffer_1.Buffer.from(await sha256.digest("global:transfer_recipient")).slice(0, 8),
|
|
259
|
+
buffer_1.Buffer.alloc(10),
|
|
260
|
+
]);
|
|
252
261
|
return new web3_js_1.TransactionInstruction({
|
|
253
262
|
keys,
|
|
254
263
|
programId,
|
|
@@ -256,7 +265,7 @@ const transferStreamInstruction = (programId, { authority, newRecipient, newReci
|
|
|
256
265
|
});
|
|
257
266
|
};
|
|
258
267
|
exports.transferStreamInstruction = transferStreamInstruction;
|
|
259
|
-
const topupStreamInstruction = (amount, programId, { sender, senderTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, withdrawor, systemProgram, }) => {
|
|
268
|
+
const topupStreamInstruction = async (amount, programId, { sender, senderTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, withdrawor, systemProgram, }) => {
|
|
260
269
|
const keys = [
|
|
261
270
|
{ pubkey: sender, isSigner: true, isWritable: true },
|
|
262
271
|
{ pubkey: senderTokens, isSigner: false, isWritable: true },
|
|
@@ -279,7 +288,7 @@ const topupStreamInstruction = (amount, programId, { sender, senderTokens, metad
|
|
|
279
288
|
const decodedData = { amount: amount.toArrayLike(buffer_1.Buffer, "le", 8) };
|
|
280
289
|
const encodeLength = Layout.topupStreamLayout.encode(decodedData, data);
|
|
281
290
|
data = data.slice(0, encodeLength);
|
|
282
|
-
data = buffer_1.Buffer.concat([buffer_1.Buffer.from(sha256.digest("global:topup")).slice(0, 8), data, buffer_1.Buffer.alloc(10)]);
|
|
291
|
+
data = buffer_1.Buffer.concat([buffer_1.Buffer.from(await sha256.digest("global:topup")).slice(0, 8), data, buffer_1.Buffer.alloc(10)]);
|
|
283
292
|
return new web3_js_1.TransactionInstruction({
|
|
284
293
|
keys,
|
|
285
294
|
programId,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Latest version of the SDK that does not use Anchor. It supports raw instructions.
|
|
2
2
|
import BN from "bn.js";
|
|
3
|
+
import bs58 from "bs58";
|
|
3
4
|
import { Buffer } from "buffer";
|
|
4
5
|
import { ASSOCIATED_TOKEN_PROGRAM_ID, NATIVE_MINT } from "@solana/spl-token";
|
|
5
6
|
import { Connection, Keypair, PublicKey, SystemProgram, SYSVAR_RENT_PUBKEY, TransactionMessage, VersionedTransaction, } from "@solana/web3.js";
|
|
@@ -171,7 +172,7 @@ export class SolanaStreamClient extends BaseStreamClient {
|
|
|
171
172
|
const streamflowTreasuryTokens = await ata(mintPublicKey, STREAMFLOW_TREASURY_PUBLIC_KEY, tokenProgramId);
|
|
172
173
|
const partnerPublicKey = partner ? new PublicKey(partner) : WITHDRAWOR_PUBLIC_KEY;
|
|
173
174
|
const partnerTokens = await ata(mintPublicKey, partnerPublicKey, tokenProgramId);
|
|
174
|
-
ixs.push(createStreamInstruction({
|
|
175
|
+
ixs.push(await createStreamInstruction({
|
|
175
176
|
start: new BN(start),
|
|
176
177
|
depositedAmount,
|
|
177
178
|
period: new BN(period),
|
|
@@ -261,7 +262,7 @@ export class SolanaStreamClient extends BaseStreamClient {
|
|
|
261
262
|
const totalAmount = calculateTotalAmountToDeposit(depositedAmount, totalFee);
|
|
262
263
|
ixs.push(...(await prepareWrappedAccount(this.connection, sender.publicKey, totalAmount)));
|
|
263
264
|
}
|
|
264
|
-
const createInstruction = createUncheckedStreamInstruction({
|
|
265
|
+
const createInstruction = await createUncheckedStreamInstruction({
|
|
265
266
|
start: new BN(start),
|
|
266
267
|
depositedAmount,
|
|
267
268
|
period: new BN(period),
|
|
@@ -534,7 +535,7 @@ export class SolanaStreamClient extends BaseStreamClient {
|
|
|
534
535
|
const streamflowTreasuryTokens = await ata(mint, STREAMFLOW_TREASURY_PUBLIC_KEY, tokenProgramId);
|
|
535
536
|
const partnerTokens = await ata(mint, partner, tokenProgramId);
|
|
536
537
|
const ataIx = await this.getCreateATAInstructions([sender, recipient, streamflowTreasury, partner], mint, invoker, checkTokenAccounts, tokenProgramId);
|
|
537
|
-
ixs.push(...ataIx, withdrawStreamInstruction(amount, this.programId, {
|
|
538
|
+
ixs.push(...ataIx, await withdrawStreamInstruction(amount, this.programId, {
|
|
538
539
|
partner,
|
|
539
540
|
partnerTokens,
|
|
540
541
|
mint,
|
|
@@ -631,7 +632,7 @@ export class SolanaStreamClient extends BaseStreamClient {
|
|
|
631
632
|
computeLimit,
|
|
632
633
|
});
|
|
633
634
|
const ixsAta = await this.getCreateATAInstructions([sender, recipient, partner, streamflowTreasury], mint, invoker, checkTokenAccounts, tokenProgramId);
|
|
634
|
-
ixs.push(...ixsAta, cancelStreamInstruction(this.programId, {
|
|
635
|
+
ixs.push(...ixsAta, await cancelStreamInstruction(this.programId, {
|
|
635
636
|
sender,
|
|
636
637
|
senderTokens,
|
|
637
638
|
recipient,
|
|
@@ -683,7 +684,7 @@ export class SolanaStreamClient extends BaseStreamClient {
|
|
|
683
684
|
const { mint } = decodeStream(escrow?.data);
|
|
684
685
|
const { tokenProgramId } = await getMintAndProgram(this.connection, mint);
|
|
685
686
|
const newRecipientTokens = await ata(mint, newRecipientPublicKey, tokenProgramId);
|
|
686
|
-
ixs.push(transferStreamInstruction(this.programId, {
|
|
687
|
+
ixs.push(await transferStreamInstruction(this.programId, {
|
|
687
688
|
authority: invoker.publicKey,
|
|
688
689
|
newRecipient: newRecipientPublicKey,
|
|
689
690
|
newRecipientTokens,
|
|
@@ -732,7 +733,7 @@ export class SolanaStreamClient extends BaseStreamClient {
|
|
|
732
733
|
if (isNative) {
|
|
733
734
|
ixs.push(...(await prepareWrappedAccount(this.connection, invoker.publicKey, amount)));
|
|
734
735
|
}
|
|
735
|
-
ixs.push(topupStreamInstruction(amount, this.programId, {
|
|
736
|
+
ixs.push(await topupStreamInstruction(amount, this.programId, {
|
|
736
737
|
sender: invoker.publicKey,
|
|
737
738
|
senderTokens,
|
|
738
739
|
metadata: streamPublicKey,
|
|
@@ -848,14 +849,17 @@ export class SolanaStreamClient extends BaseStreamClient {
|
|
|
848
849
|
async searchStreams(data) {
|
|
849
850
|
const filters = Object.entries(data)
|
|
850
851
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
851
|
-
.filter(([_, value]) => value) // Only keep entries where the value is truthy
|
|
852
|
+
.filter(([_, value]) => value !== undefined) // Only keep entries where the value is truthy
|
|
852
853
|
.map(([key, value]) => ({
|
|
853
854
|
memcmp: {
|
|
854
855
|
offset: STREAM_STRUCT_OFFSETS[key],
|
|
855
|
-
bytes: value,
|
|
856
|
+
bytes: typeof value === "boolean" ? bs58.encode([Number(value)]) : value.toString(),
|
|
856
857
|
},
|
|
857
858
|
}));
|
|
858
|
-
|
|
859
|
+
filters.push({ dataSize: METADATA_ACC_SIZE });
|
|
860
|
+
const accounts = await this.connection.getProgramAccounts(this.programId, {
|
|
861
|
+
filters,
|
|
862
|
+
});
|
|
859
863
|
return accounts.map(({ pubkey, account }) => ({
|
|
860
864
|
publicKey: pubkey,
|
|
861
865
|
account: new Contract(decodeStream(account.data)),
|
|
@@ -893,7 +897,7 @@ export class SolanaStreamClient extends BaseStreamClient {
|
|
|
893
897
|
computePrice,
|
|
894
898
|
computeLimit,
|
|
895
899
|
});
|
|
896
|
-
ixs.push(updateStreamInstruction(data, this.programId, {
|
|
900
|
+
ixs.push(await updateStreamInstruction(data, this.programId, {
|
|
897
901
|
authority: invoker.publicKey,
|
|
898
902
|
metadata: streamPublicKey,
|
|
899
903
|
withdrawor: WITHDRAWOR_PUBLIC_KEY,
|
|
@@ -6,6 +6,7 @@ export declare const ORIGINAL_CONTRACT_SENDER_OFFSET = 9;
|
|
|
6
6
|
export declare const STREAM_STRUCT_OFFSET_SENDER = 49;
|
|
7
7
|
export declare const STREAM_STRUCT_OFFSET_RECIPIENT = 113;
|
|
8
8
|
export declare const STREAM_STRUCT_OFFSET_MINT = 177;
|
|
9
|
+
export declare const STREAM_STRUCT_OFFSET_CLOSED = 671;
|
|
9
10
|
export declare const ALIGNED_PRECISION_FACTOR_POW = 9;
|
|
10
11
|
export declare const STREAM_STRUCT_OFFSETS: Record<keyof ISearchStreams, number>;
|
|
11
12
|
export declare const CREATE_PARAMS_PADDING = 126;
|
|
@@ -6,11 +6,13 @@ export const ORIGINAL_CONTRACT_SENDER_OFFSET = 9;
|
|
|
6
6
|
export const STREAM_STRUCT_OFFSET_SENDER = 49;
|
|
7
7
|
export const STREAM_STRUCT_OFFSET_RECIPIENT = 113;
|
|
8
8
|
export const STREAM_STRUCT_OFFSET_MINT = 177;
|
|
9
|
+
export const STREAM_STRUCT_OFFSET_CLOSED = 671;
|
|
9
10
|
export const ALIGNED_PRECISION_FACTOR_POW = 9;
|
|
10
11
|
export const STREAM_STRUCT_OFFSETS = {
|
|
11
12
|
mint: STREAM_STRUCT_OFFSET_MINT,
|
|
12
13
|
recipient: STREAM_STRUCT_OFFSET_RECIPIENT,
|
|
13
14
|
sender: STREAM_STRUCT_OFFSET_SENDER,
|
|
15
|
+
closed: STREAM_STRUCT_OFFSET_CLOSED,
|
|
14
16
|
};
|
|
15
17
|
// Defined: https://github.com/streamflow-finance/protocol/blob/main/programs/protocol/src/state.rs#L25
|
|
16
18
|
export const CREATE_PARAMS_PADDING = 126;
|
|
@@ -39,7 +39,7 @@ interface CreateStreamAccounts {
|
|
|
39
39
|
withdrawor: PublicKey;
|
|
40
40
|
systemProgram: PublicKey;
|
|
41
41
|
}
|
|
42
|
-
export declare const createStreamInstruction: (data: CreateStreamData, programId: PublicKey, accounts: CreateStreamAccounts) => TransactionInstruction
|
|
42
|
+
export declare const createStreamInstruction: (data: CreateStreamData, programId: PublicKey, accounts: CreateStreamAccounts) => Promise<TransactionInstruction>;
|
|
43
43
|
interface CreateUncheckedStreamData {
|
|
44
44
|
start: BN;
|
|
45
45
|
depositedAmount: BN;
|
|
@@ -74,7 +74,7 @@ interface CreateUncheckedStreamAccounts {
|
|
|
74
74
|
withdrawor: PublicKey;
|
|
75
75
|
systemProgram: PublicKey;
|
|
76
76
|
}
|
|
77
|
-
export declare const createUncheckedStreamInstruction: (data: CreateUncheckedStreamData, programId: PublicKey, accounts: CreateUncheckedStreamAccounts) => TransactionInstruction
|
|
77
|
+
export declare const createUncheckedStreamInstruction: (data: CreateUncheckedStreamData, programId: PublicKey, accounts: CreateUncheckedStreamAccounts) => Promise<TransactionInstruction>;
|
|
78
78
|
interface WithdrawAccounts {
|
|
79
79
|
authority: PublicKey;
|
|
80
80
|
recipient: PublicKey;
|
|
@@ -88,14 +88,14 @@ interface WithdrawAccounts {
|
|
|
88
88
|
mint: PublicKey;
|
|
89
89
|
tokenProgram: PublicKey;
|
|
90
90
|
}
|
|
91
|
-
export declare const withdrawStreamInstruction: (amount: BN, programId: PublicKey, { authority, recipient, recipientTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, }: WithdrawAccounts) => TransactionInstruction
|
|
91
|
+
export declare const withdrawStreamInstruction: (amount: BN, programId: PublicKey, { authority, recipient, recipientTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, }: WithdrawAccounts) => Promise<TransactionInstruction>;
|
|
92
92
|
interface UpdateAccounts {
|
|
93
93
|
authority: PublicKey;
|
|
94
94
|
metadata: PublicKey;
|
|
95
95
|
withdrawor: PublicKey;
|
|
96
96
|
systemProgram: PublicKey;
|
|
97
97
|
}
|
|
98
|
-
export declare const updateStreamInstruction: (params: IUpdateData, programId: PublicKey, { authority, metadata, withdrawor, systemProgram }: UpdateAccounts) => TransactionInstruction
|
|
98
|
+
export declare const updateStreamInstruction: (params: IUpdateData, programId: PublicKey, { authority, metadata, withdrawor, systemProgram }: UpdateAccounts) => Promise<TransactionInstruction>;
|
|
99
99
|
interface CancelAccounts {
|
|
100
100
|
authority: PublicKey;
|
|
101
101
|
sender: PublicKey;
|
|
@@ -111,7 +111,7 @@ interface CancelAccounts {
|
|
|
111
111
|
mint: PublicKey;
|
|
112
112
|
tokenProgram: PublicKey;
|
|
113
113
|
}
|
|
114
|
-
export declare const cancelStreamInstruction: (programId: PublicKey, { authority, sender, senderTokens, recipient, recipientTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, }: CancelAccounts) => TransactionInstruction
|
|
114
|
+
export declare const cancelStreamInstruction: (programId: PublicKey, { authority, sender, senderTokens, recipient, recipientTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, }: CancelAccounts) => Promise<TransactionInstruction>;
|
|
115
115
|
interface TransferAccounts {
|
|
116
116
|
authority: PublicKey;
|
|
117
117
|
newRecipient: PublicKey;
|
|
@@ -123,7 +123,7 @@ interface TransferAccounts {
|
|
|
123
123
|
associatedTokenProgram: PublicKey;
|
|
124
124
|
systemProgram: PublicKey;
|
|
125
125
|
}
|
|
126
|
-
export declare const transferStreamInstruction: (programId: PublicKey, { authority, newRecipient, newRecipientTokens, metadata, mint, rent, tokenProgram, associatedTokenProgram, systemProgram, }: TransferAccounts) => TransactionInstruction
|
|
126
|
+
export declare const transferStreamInstruction: (programId: PublicKey, { authority, newRecipient, newRecipientTokens, metadata, mint, rent, tokenProgram, associatedTokenProgram, systemProgram, }: TransferAccounts) => Promise<TransactionInstruction>;
|
|
127
127
|
interface TopupAccounts {
|
|
128
128
|
sender: PublicKey;
|
|
129
129
|
senderTokens: PublicKey;
|
|
@@ -138,5 +138,5 @@ interface TopupAccounts {
|
|
|
138
138
|
withdrawor: PublicKey;
|
|
139
139
|
systemProgram: PublicKey;
|
|
140
140
|
}
|
|
141
|
-
export declare const topupStreamInstruction: (amount: BN, programId: PublicKey, { sender, senderTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, withdrawor, systemProgram, }: TopupAccounts) => TransactionInstruction
|
|
141
|
+
export declare const topupStreamInstruction: (amount: BN, programId: PublicKey, { sender, senderTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, withdrawor, systemProgram, }: TopupAccounts) => Promise<TransactionInstruction>;
|
|
142
142
|
export {};
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { Buffer } from "buffer";
|
|
2
2
|
import { TransactionInstruction } from "@solana/web3.js";
|
|
3
|
-
import { createHash } from "node:crypto";
|
|
4
3
|
import * as Layout from "./layout.js";
|
|
5
|
-
const hasher = () => createHash("sha256");
|
|
6
4
|
const sha256 = {
|
|
7
|
-
digest: (data) =>
|
|
5
|
+
digest: async (data) => {
|
|
6
|
+
const dataBuffer = new TextEncoder().encode(data);
|
|
7
|
+
const hashBuffer = await globalThis.crypto.subtle.digest("SHA-256", dataBuffer);
|
|
8
|
+
return new Uint8Array(hashBuffer);
|
|
9
|
+
},
|
|
8
10
|
};
|
|
9
|
-
export const createStreamInstruction = (data, programId, accounts) => {
|
|
11
|
+
export const createStreamInstruction = async (data, programId, accounts) => {
|
|
10
12
|
const keys = [
|
|
11
13
|
{ pubkey: accounts.sender, isSigner: true, isWritable: true },
|
|
12
14
|
{ pubkey: accounts.senderTokens, isSigner: false, isWritable: true },
|
|
@@ -64,14 +66,18 @@ export const createStreamInstruction = (data, programId, accounts) => {
|
|
|
64
66
|
};
|
|
65
67
|
const encodeLength = Layout.createStreamLayout.encode(decodedData, bufferData);
|
|
66
68
|
bufferData = bufferData.slice(0, encodeLength);
|
|
67
|
-
bufferData = Buffer.concat([
|
|
69
|
+
bufferData = Buffer.concat([
|
|
70
|
+
Buffer.from(await sha256.digest("global:create")).slice(0, 8),
|
|
71
|
+
bufferData,
|
|
72
|
+
Buffer.alloc(10),
|
|
73
|
+
]);
|
|
68
74
|
return new TransactionInstruction({
|
|
69
75
|
keys,
|
|
70
76
|
programId,
|
|
71
77
|
data: bufferData,
|
|
72
78
|
});
|
|
73
79
|
};
|
|
74
|
-
export const createUncheckedStreamInstruction = (data, programId, accounts) => {
|
|
80
|
+
export const createUncheckedStreamInstruction = async (data, programId, accounts) => {
|
|
75
81
|
const keys = [
|
|
76
82
|
{ pubkey: accounts.sender, isSigner: true, isWritable: true },
|
|
77
83
|
{ pubkey: accounts.senderTokens, isSigner: false, isWritable: true },
|
|
@@ -118,8 +124,8 @@ export const createUncheckedStreamInstruction = (data, programId, accounts) => {
|
|
|
118
124
|
const encodeLength = Layout.createUncheckedStreamLayout.encode(decodedData, bufferData);
|
|
119
125
|
bufferData = bufferData.slice(0, encodeLength);
|
|
120
126
|
const digest = accounts.payer
|
|
121
|
-
? sha256.digest("global:create_unchecked_with_payer")
|
|
122
|
-
: sha256.digest("global:create_unchecked");
|
|
127
|
+
? await sha256.digest("global:create_unchecked_with_payer")
|
|
128
|
+
: await sha256.digest("global:create_unchecked");
|
|
123
129
|
bufferData = Buffer.concat([Buffer.from(digest).slice(0, 8), bufferData, Buffer.alloc(10)]);
|
|
124
130
|
return new TransactionInstruction({
|
|
125
131
|
keys,
|
|
@@ -127,7 +133,7 @@ export const createUncheckedStreamInstruction = (data, programId, accounts) => {
|
|
|
127
133
|
data: bufferData,
|
|
128
134
|
});
|
|
129
135
|
};
|
|
130
|
-
export const withdrawStreamInstruction = (amount, programId, { authority, recipient, recipientTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, }) => {
|
|
136
|
+
export const withdrawStreamInstruction = async (amount, programId, { authority, recipient, recipientTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, }) => {
|
|
131
137
|
const keys = [
|
|
132
138
|
{ pubkey: authority, isSigner: true, isWritable: true },
|
|
133
139
|
{ pubkey: recipient, isSigner: false, isWritable: true },
|
|
@@ -149,14 +155,14 @@ export const withdrawStreamInstruction = (amount, programId, { authority, recipi
|
|
|
149
155
|
const decodedData = { amount: amount.toArrayLike(Buffer, "le", 8) };
|
|
150
156
|
const encodeLength = Layout.withdrawStreamLayout.encode(decodedData, data);
|
|
151
157
|
data = data.slice(0, encodeLength);
|
|
152
|
-
data = Buffer.concat([Buffer.from(sha256.digest("global:withdraw")).slice(0, 8), data, Buffer.alloc(10)]);
|
|
158
|
+
data = Buffer.concat([Buffer.from(await sha256.digest("global:withdraw")).slice(0, 8), data, Buffer.alloc(10)]);
|
|
153
159
|
return new TransactionInstruction({
|
|
154
160
|
keys,
|
|
155
161
|
programId,
|
|
156
162
|
data,
|
|
157
163
|
});
|
|
158
164
|
};
|
|
159
|
-
export const updateStreamInstruction = (params, programId, { authority, metadata, withdrawor, systemProgram }) => {
|
|
165
|
+
export const updateStreamInstruction = async (params, programId, { authority, metadata, withdrawor, systemProgram }) => {
|
|
160
166
|
const keys = [
|
|
161
167
|
{ pubkey: authority, isSigner: true, isWritable: true },
|
|
162
168
|
{ pubkey: metadata, isSigner: false, isWritable: true },
|
|
@@ -171,14 +177,14 @@ export const updateStreamInstruction = (params, programId, { authority, metadata
|
|
|
171
177
|
};
|
|
172
178
|
const encodeLength = Layout.encodeUpdateStream(decodedData, data);
|
|
173
179
|
data = data.slice(0, encodeLength);
|
|
174
|
-
data = Buffer.concat([Buffer.from(sha256.digest("global:update")).slice(0, 8), data, Buffer.alloc(20)]);
|
|
180
|
+
data = Buffer.concat([Buffer.from(await sha256.digest("global:update")).slice(0, 8), data, Buffer.alloc(20)]);
|
|
175
181
|
return new TransactionInstruction({
|
|
176
182
|
keys: keys,
|
|
177
183
|
programId: programId,
|
|
178
184
|
data: data,
|
|
179
185
|
});
|
|
180
186
|
};
|
|
181
|
-
export const cancelStreamInstruction = (programId, { authority, sender, senderTokens, recipient, recipientTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, }) => {
|
|
187
|
+
export const cancelStreamInstruction = async (programId, { authority, sender, senderTokens, recipient, recipientTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, }) => {
|
|
182
188
|
const keys = [
|
|
183
189
|
{ pubkey: authority, isSigner: true, isWritable: false },
|
|
184
190
|
{ pubkey: sender, isSigner: false, isWritable: true },
|
|
@@ -198,14 +204,14 @@ export const cancelStreamInstruction = (programId, { authority, sender, senderTo
|
|
|
198
204
|
{ pubkey: mint, isSigner: false, isWritable: true },
|
|
199
205
|
{ pubkey: tokenProgram, isSigner: false, isWritable: false },
|
|
200
206
|
];
|
|
201
|
-
const data = Buffer.concat([Buffer.from(sha256.digest("global:cancel")).slice(0, 8), Buffer.alloc(10)]);
|
|
207
|
+
const data = Buffer.concat([Buffer.from(await sha256.digest("global:cancel")).slice(0, 8), Buffer.alloc(10)]);
|
|
202
208
|
return new TransactionInstruction({
|
|
203
209
|
keys,
|
|
204
210
|
programId,
|
|
205
211
|
data,
|
|
206
212
|
});
|
|
207
213
|
};
|
|
208
|
-
export const transferStreamInstruction = (programId, { authority, newRecipient, newRecipientTokens, metadata, mint, rent, tokenProgram, associatedTokenProgram, systemProgram, }) => {
|
|
214
|
+
export const transferStreamInstruction = async (programId, { authority, newRecipient, newRecipientTokens, metadata, mint, rent, tokenProgram, associatedTokenProgram, systemProgram, }) => {
|
|
209
215
|
const keys = [
|
|
210
216
|
{ pubkey: authority, isSigner: true, isWritable: true },
|
|
211
217
|
{ pubkey: newRecipient, isSigner: false, isWritable: true },
|
|
@@ -217,14 +223,17 @@ export const transferStreamInstruction = (programId, { authority, newRecipient,
|
|
|
217
223
|
{ pubkey: associatedTokenProgram, isSigner: false, isWritable: false },
|
|
218
224
|
{ pubkey: systemProgram, isSigner: false, isWritable: false },
|
|
219
225
|
];
|
|
220
|
-
const data = Buffer.concat([
|
|
226
|
+
const data = Buffer.concat([
|
|
227
|
+
Buffer.from(await sha256.digest("global:transfer_recipient")).slice(0, 8),
|
|
228
|
+
Buffer.alloc(10),
|
|
229
|
+
]);
|
|
221
230
|
return new TransactionInstruction({
|
|
222
231
|
keys,
|
|
223
232
|
programId,
|
|
224
233
|
data,
|
|
225
234
|
});
|
|
226
235
|
};
|
|
227
|
-
export const topupStreamInstruction = (amount, programId, { sender, senderTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, withdrawor, systemProgram, }) => {
|
|
236
|
+
export const topupStreamInstruction = async (amount, programId, { sender, senderTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, withdrawor, systemProgram, }) => {
|
|
228
237
|
const keys = [
|
|
229
238
|
{ pubkey: sender, isSigner: true, isWritable: true },
|
|
230
239
|
{ pubkey: senderTokens, isSigner: false, isWritable: true },
|
|
@@ -247,7 +256,7 @@ export const topupStreamInstruction = (amount, programId, { sender, senderTokens
|
|
|
247
256
|
const decodedData = { amount: amount.toArrayLike(Buffer, "le", 8) };
|
|
248
257
|
const encodeLength = Layout.topupStreamLayout.encode(decodedData, data);
|
|
249
258
|
data = data.slice(0, encodeLength);
|
|
250
|
-
data = Buffer.concat([Buffer.from(sha256.digest("global:topup")).slice(0, 8), data, Buffer.alloc(10)]);
|
|
259
|
+
data = Buffer.concat([Buffer.from(await sha256.digest("global:topup")).slice(0, 8), data, Buffer.alloc(10)]);
|
|
251
260
|
return new TransactionInstruction({
|
|
252
261
|
keys,
|
|
253
262
|
programId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamflow/stream",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.1",
|
|
4
4
|
"description": "JavaScript SDK to interact with Streamflow protocol.",
|
|
5
5
|
"homepage": "https://github.com/streamflow-finance/js-sdk/",
|
|
6
6
|
"main": "./dist/esm/index.js",
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"lint": "eslint --fix .",
|
|
43
43
|
"prepublishOnly": "pnpm run lint && pnpm run test run && pnpm run build"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "6828e48741b4abf46f4a8aae9d9512b4cb587e84",
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@streamflow/eslint-config": "7.1.
|
|
47
|
+
"@streamflow/eslint-config": "7.1.1",
|
|
48
48
|
"@types/bn.js": "5.1.1",
|
|
49
49
|
"@types/ethereum-checksum-address": "^0.0.0",
|
|
50
50
|
"date-fns": "2.28.0",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"@solana/spl-token": "0.4.9",
|
|
60
60
|
"@solana/wallet-adapter-base": "0.9.19",
|
|
61
61
|
"@solana/web3.js": "1.95.4",
|
|
62
|
-
"@streamflow/common": "7.1.
|
|
62
|
+
"@streamflow/common": "7.1.1",
|
|
63
63
|
"@suiet/wallet-kit": "0.2.22",
|
|
64
64
|
"aptos": "1.21.0",
|
|
65
65
|
"bn.js": "5.2.1",
|