@streamflow/stream 6.3.8 → 6.4.2
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 +49 -1
- package/dist/solana/StreamClient.d.ts +5 -3
- package/dist/solana/StreamClient.js +47 -6
- package/dist/solana/constants.d.ts +3 -0
- package/dist/solana/constants.js +7 -1
- package/dist/solana/instructions.d.ts +4 -0
- package/dist/solana/instructions.js +6 -2
- package/dist/solana/layout.js +6 -0
- package/dist/solana/types.d.ts +5 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -150,6 +150,7 @@ const createStreamParams: Types.ICreateStreamData = {
|
|
|
150
150
|
amountPerPeriod: getBN(5, 9), // Release rate: how many tokens are unlocked per each period.
|
|
151
151
|
name: "Transfer to Jane Doe.", // The stream name or subject.
|
|
152
152
|
canTopup: false, // setting to FALSE will effectively create a vesting contract.
|
|
153
|
+
canUpdateRate: false, // settings to TRUE allows sender to update amountPerPeriod
|
|
153
154
|
cancelableBySender: true, // Whether or not sender can cancel the stream.
|
|
154
155
|
cancelableByRecipient: false, // Whether or not recipient can cancel the stream.
|
|
155
156
|
transferableBySender: true, // Whether or not sender can transfer the stream.
|
|
@@ -161,7 +162,7 @@ const createStreamParams: Types.ICreateStreamData = {
|
|
|
161
162
|
|
|
162
163
|
const solanaParams = {
|
|
163
164
|
sender: wallet, // SignerWalletAdapter or Keypair of Sender account
|
|
164
|
-
isNative: // [optional] [WILL CREATE A wSOL STREAM] Wether Stream or Vesting should be paid with Solana native token or not
|
|
165
|
+
isNative: false // [optional] [WILL CREATE A wSOL STREAM] Wether Stream or Vesting should be paid with Solana native token or not
|
|
165
166
|
};
|
|
166
167
|
|
|
167
168
|
const aptosParams = {
|
|
@@ -371,6 +372,37 @@ try {
|
|
|
371
372
|
}
|
|
372
373
|
```
|
|
373
374
|
|
|
375
|
+
## Update a stream
|
|
376
|
+
|
|
377
|
+
```javascript
|
|
378
|
+
const updateStreamParams: Types.IUpdateData = {
|
|
379
|
+
id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA", // Identifier of a stream to update.
|
|
380
|
+
enableAutomaticWithdrawal: true, // [optional], allows to enable AW if it wasn't, disable is not possible
|
|
381
|
+
withdrawFrequency: 60, // [optional], allows to update withdrawal frequency, may result in additional AW fees
|
|
382
|
+
amountPerPeriod: getBN(10, 9), // [optional], allows to update release amount effective on next unlock
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
const solanaParams = {
|
|
386
|
+
invoker: wallet, // SignerWalletAdapter or Keypair signing the transaction
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
const aptosParams = {
|
|
390
|
+
senderWallet: wallet, // AptosWalletAdapter Wallet of wallet signing the transaction
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
const suiParams = {
|
|
394
|
+
senderWallet: wallet, // WalletContextState | Keypair
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
const ethereumParams = undefined;
|
|
398
|
+
|
|
399
|
+
try {
|
|
400
|
+
const { ixs, tx } = await client.update(updateStreamParams, solanaParams);
|
|
401
|
+
} catch (exception) {
|
|
402
|
+
// handle exception
|
|
403
|
+
}
|
|
404
|
+
```
|
|
405
|
+
|
|
374
406
|
## Get one stream by its ID
|
|
375
407
|
|
|
376
408
|
```javascript
|
|
@@ -426,6 +458,22 @@ try {
|
|
|
426
458
|
}
|
|
427
459
|
```
|
|
428
460
|
|
|
461
|
+
## Search Solana Streams
|
|
462
|
+
|
|
463
|
+
Solana RPC is pretty rich in what data it can allow to filter by, so we expose a separate `searchStreams` method on `SolanaStreamClient`:
|
|
464
|
+
|
|
465
|
+
```javascript
|
|
466
|
+
// All parameters are optional, so in theory you can just fetch all Streams
|
|
467
|
+
const params = {
|
|
468
|
+
mint: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",
|
|
469
|
+
sender: "AKp8CxGbhsrsEsCFUtx7e3MWyW7SWi1uuSqv6N4BEohJ",
|
|
470
|
+
recipient: "9mqcpDjCHCPmttJp2t477oJ71NdAvJeSus8BcCrrvwy5",
|
|
471
|
+
}
|
|
472
|
+
// nativeStreamClient is exposed on a GenericStreamClient, you can also use SolanaStreamClient directly
|
|
473
|
+
// Return an Array of objects {publicKey: PublicKey, account: Stream}
|
|
474
|
+
const streams = await client.nativeStreamClient.searchStreams(params);
|
|
475
|
+
```
|
|
476
|
+
|
|
429
477
|
## Handling errors
|
|
430
478
|
|
|
431
479
|
`GenericStreamClient` wraps all errors when making on-chain calls with `ContractError` error class:
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import PQueue from "p-queue";
|
|
2
2
|
import { Connection, Keypair, PublicKey, TransactionInstruction, Commitment, ConnectionConfig } from "@solana/web3.js";
|
|
3
|
-
import {
|
|
3
|
+
import { IProgramAccount } from "@streamflow/common/solana";
|
|
4
|
+
import { ICreateStreamSolanaExt, IInteractStreamSolanaExt, ITopUpStreamSolanaExt, ISearchStreams } from "./types";
|
|
4
5
|
import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetAllData, IGetFeesData, IGetOneData, IFees, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData, Stream } from "../common/types";
|
|
5
6
|
import { BaseStreamClient } from "../common/BaseStreamClient";
|
|
6
7
|
export default class SolanaStreamClient extends BaseStreamClient {
|
|
@@ -24,7 +25,7 @@ export default class SolanaStreamClient extends BaseStreamClient {
|
|
|
24
25
|
* Creates a new stream/vesting contract.
|
|
25
26
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
26
27
|
*/
|
|
27
|
-
prepareCreateInstructions({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, }: ICreateStreamData, { sender, metadataPubKeys, isNative, computePrice, computeLimit }: ICreateStreamSolanaExt): Promise<{
|
|
28
|
+
prepareCreateInstructions({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canPause, canUpdateRate, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, }: ICreateStreamData, { sender, metadataPubKeys, isNative, computePrice, computeLimit }: ICreateStreamSolanaExt): Promise<{
|
|
28
29
|
ixs: TransactionInstruction[];
|
|
29
30
|
metadata: Keypair | undefined;
|
|
30
31
|
metadataPubKey: PublicKey;
|
|
@@ -43,7 +44,7 @@ export default class SolanaStreamClient extends BaseStreamClient {
|
|
|
43
44
|
/**
|
|
44
45
|
* Create Transaction instructions for `createUnchecked`
|
|
45
46
|
*/
|
|
46
|
-
prepareCreateUncheckedInstructions({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, }: ICreateStreamData, { sender, metadataPubKeys, isNative, computePrice, computeLimit }: ICreateStreamSolanaExt): Promise<{
|
|
47
|
+
prepareCreateUncheckedInstructions({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, canUpdateRate, canPause, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, }: ICreateStreamData, { sender, metadataPubKeys, isNative, computePrice, computeLimit }: ICreateStreamSolanaExt): Promise<{
|
|
47
48
|
ixs: TransactionInstruction[];
|
|
48
49
|
metadata: Keypair | undefined;
|
|
49
50
|
metadataPubKey: PublicKey;
|
|
@@ -96,6 +97,7 @@ export default class SolanaStreamClient extends BaseStreamClient {
|
|
|
96
97
|
* Streams are sorted by start time in ascending order.
|
|
97
98
|
*/
|
|
98
99
|
get({ address, type, direction, }: IGetAllData): Promise<[string, Stream][]>;
|
|
100
|
+
searchStreams(data: ISearchStreams): Promise<IProgramAccount<Stream>[]>;
|
|
99
101
|
/**
|
|
100
102
|
* Attempts updating the stream auto withdrawal params and amount per period
|
|
101
103
|
*/
|
|
@@ -198,7 +198,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
198
198
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
199
199
|
*/
|
|
200
200
|
SolanaStreamClient.prototype.prepareCreateInstructions = function (_a, _b) {
|
|
201
|
-
var recipient = _a.recipient, mint = _a.tokenId, start = _a.start, depositedAmount = _a.amount, period = _a.period, cliff = _a.cliff, cliffAmount = _a.cliffAmount, amountPerPeriod = _a.amountPerPeriod, name = _a.name, canTopup = _a.canTopup, cancelableBySender = _a.cancelableBySender, cancelableByRecipient = _a.cancelableByRecipient, transferableBySender = _a.transferableBySender, transferableByRecipient = _a.transferableByRecipient, _c = _a.automaticWithdrawal, automaticWithdrawal = _c === void 0 ? false : _c, _d = _a.withdrawalFrequency, withdrawalFrequency = _d === void 0 ? 0 : _d, partner = _a.partner;
|
|
201
|
+
var recipient = _a.recipient, mint = _a.tokenId, start = _a.start, depositedAmount = _a.amount, period = _a.period, cliff = _a.cliff, cliffAmount = _a.cliffAmount, amountPerPeriod = _a.amountPerPeriod, name = _a.name, canPause = _a.canPause, canUpdateRate = _a.canUpdateRate, canTopup = _a.canTopup, cancelableBySender = _a.cancelableBySender, cancelableByRecipient = _a.cancelableByRecipient, transferableBySender = _a.transferableBySender, transferableByRecipient = _a.transferableByRecipient, _c = _a.automaticWithdrawal, automaticWithdrawal = _c === void 0 ? false : _c, _d = _a.withdrawalFrequency, withdrawalFrequency = _d === void 0 ? 0 : _d, partner = _a.partner;
|
|
202
202
|
var sender = _b.sender, metadataPubKeys = _b.metadataPubKeys, _e = _b.isNative, isNative = _e === void 0 ? false : _e, computePrice = _b.computePrice, computeLimit = _b.computeLimit;
|
|
203
203
|
return __awaiter(this, void 0, void 0, function () {
|
|
204
204
|
var ixs, mintPublicKey, recipientPublicKey, _f, metadata, metadataPubKey, _g, escrowTokens, tokenProgramId, senderTokens, recipientTokens, streamflowTreasuryTokens, partnerPublicKey, partnerTokens, totalFee, totalAmount, _h, _j, _k, _l;
|
|
@@ -228,7 +228,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
228
228
|
return [4 /*yield*/, (0, solana_1.ata)(mintPublicKey, constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY, tokenProgramId)];
|
|
229
229
|
case 4:
|
|
230
230
|
streamflowTreasuryTokens = _m.sent();
|
|
231
|
-
partnerPublicKey = partner ? new web3_js_1.PublicKey(partner) : constants_1.
|
|
231
|
+
partnerPublicKey = partner ? new web3_js_1.PublicKey(partner) : constants_1.WITHDRAWOR_PUBLIC_KEY;
|
|
232
232
|
return [4 /*yield*/, (0, solana_1.ata)(mintPublicKey, partnerPublicKey, tokenProgramId)];
|
|
233
233
|
case 5:
|
|
234
234
|
partnerTokens = _m.sent();
|
|
@@ -260,6 +260,8 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
260
260
|
transferableBySender: transferableBySender,
|
|
261
261
|
transferableByRecipient: transferableByRecipient,
|
|
262
262
|
canTopup: canTopup,
|
|
263
|
+
canUpdateRate: !!canUpdateRate,
|
|
264
|
+
canPause: !!canPause,
|
|
263
265
|
name: name,
|
|
264
266
|
withdrawFrequency: new bn_js_1.default(automaticWithdrawal ? withdrawalFrequency : period),
|
|
265
267
|
}, this.programId, {
|
|
@@ -324,7 +326,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
324
326
|
* Create Transaction instructions for `createUnchecked`
|
|
325
327
|
*/
|
|
326
328
|
SolanaStreamClient.prototype.prepareCreateUncheckedInstructions = function (_a, _b) {
|
|
327
|
-
var recipient = _a.recipient, mint = _a.tokenId, start = _a.start, depositedAmount = _a.amount, period = _a.period, cliff = _a.cliff, cliffAmount = _a.cliffAmount, amountPerPeriod = _a.amountPerPeriod, name = _a.name, canTopup = _a.canTopup, cancelableBySender = _a.cancelableBySender, cancelableByRecipient = _a.cancelableByRecipient, transferableBySender = _a.transferableBySender, transferableByRecipient = _a.transferableByRecipient, _c = _a.automaticWithdrawal, automaticWithdrawal = _c === void 0 ? false : _c, _d = _a.withdrawalFrequency, withdrawalFrequency = _d === void 0 ? 0 : _d, partner = _a.partner;
|
|
329
|
+
var recipient = _a.recipient, mint = _a.tokenId, start = _a.start, depositedAmount = _a.amount, period = _a.period, cliff = _a.cliff, cliffAmount = _a.cliffAmount, amountPerPeriod = _a.amountPerPeriod, name = _a.name, canTopup = _a.canTopup, canUpdateRate = _a.canUpdateRate, canPause = _a.canPause, cancelableBySender = _a.cancelableBySender, cancelableByRecipient = _a.cancelableByRecipient, transferableBySender = _a.transferableBySender, transferableByRecipient = _a.transferableByRecipient, _c = _a.automaticWithdrawal, automaticWithdrawal = _c === void 0 ? false : _c, _d = _a.withdrawalFrequency, withdrawalFrequency = _d === void 0 ? 0 : _d, partner = _a.partner;
|
|
328
330
|
var sender = _b.sender, metadataPubKeys = _b.metadataPubKeys, _e = _b.isNative, isNative = _e === void 0 ? false : _e, computePrice = _b.computePrice, computeLimit = _b.computeLimit;
|
|
329
331
|
return __awaiter(this, void 0, void 0, function () {
|
|
330
332
|
var mintPublicKey, recipientPublicKey, _f, metadata, metadataPubKey, rentToExempt, createMetadataInstruction, _g, escrowTokens, tokenProgramId, senderTokens, partnerPublicKey, ixs, totalFee, totalAmount, _h, _j, _k, _l, createInstruction;
|
|
@@ -354,7 +356,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
354
356
|
return [4 /*yield*/, (0, solana_1.ata)(mintPublicKey, sender.publicKey, tokenProgramId)];
|
|
355
357
|
case 3:
|
|
356
358
|
senderTokens = _m.sent();
|
|
357
|
-
partnerPublicKey = partner ? new web3_js_1.PublicKey(partner) : constants_1.
|
|
359
|
+
partnerPublicKey = partner ? new web3_js_1.PublicKey(partner) : constants_1.WITHDRAWOR_PUBLIC_KEY;
|
|
358
360
|
ixs = (0, solana_1.prepareBaseInstructions)(this.connection, {
|
|
359
361
|
computePrice: computePrice,
|
|
360
362
|
computeLimit: computeLimit,
|
|
@@ -385,6 +387,8 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
385
387
|
transferableBySender: transferableBySender,
|
|
386
388
|
transferableByRecipient: transferableByRecipient,
|
|
387
389
|
canTopup: canTopup,
|
|
390
|
+
canUpdateRate: !!canUpdateRate,
|
|
391
|
+
canPause: !!canPause,
|
|
388
392
|
name: name,
|
|
389
393
|
withdrawFrequency: new bn_js_1.default(automaticWithdrawal ? withdrawalFrequency : period),
|
|
390
394
|
recipient: recipientPublicKey,
|
|
@@ -981,6 +985,41 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
981
985
|
});
|
|
982
986
|
});
|
|
983
987
|
};
|
|
988
|
+
SolanaStreamClient.prototype.searchStreams = function (data) {
|
|
989
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
990
|
+
var filters, accounts;
|
|
991
|
+
return __generator(this, function (_a) {
|
|
992
|
+
switch (_a.label) {
|
|
993
|
+
case 0:
|
|
994
|
+
filters = Object.entries(data)
|
|
995
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
996
|
+
.filter(function (_a) {
|
|
997
|
+
var _b = __read(_a, 2), _ = _b[0], value = _b[1];
|
|
998
|
+
return value;
|
|
999
|
+
}) // Only keep entries where the value is truthy
|
|
1000
|
+
.map(function (_a) {
|
|
1001
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
1002
|
+
return ({
|
|
1003
|
+
memcmp: {
|
|
1004
|
+
offset: constants_1.STREAM_STRUCT_OFFSETS[key],
|
|
1005
|
+
bytes: value,
|
|
1006
|
+
},
|
|
1007
|
+
});
|
|
1008
|
+
});
|
|
1009
|
+
return [4 /*yield*/, this.connection.getProgramAccounts(this.programId, { filters: filters })];
|
|
1010
|
+
case 1:
|
|
1011
|
+
accounts = _a.sent();
|
|
1012
|
+
return [2 /*return*/, accounts.map(function (_a) {
|
|
1013
|
+
var pubkey = _a.pubkey, account = _a.account;
|
|
1014
|
+
return ({
|
|
1015
|
+
publicKey: pubkey,
|
|
1016
|
+
account: new types_1.Contract((0, utils_1.decodeStream)(account.data)),
|
|
1017
|
+
});
|
|
1018
|
+
})];
|
|
1019
|
+
}
|
|
1020
|
+
});
|
|
1021
|
+
});
|
|
1022
|
+
};
|
|
984
1023
|
/**
|
|
985
1024
|
* Attempts updating the stream auto withdrawal params and amount per period
|
|
986
1025
|
*/
|
|
@@ -1089,11 +1128,11 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
1089
1128
|
*/
|
|
1090
1129
|
SolanaStreamClient.prototype.prepareStreamInstructions = function (recipient, streamParams, extParams) {
|
|
1091
1130
|
return __awaiter(this, void 0, void 0, function () {
|
|
1092
|
-
var mint, start, period, cliff, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, _a, automaticWithdrawal, _b, withdrawalFrequency, partner, sender, metadataPubKeys, computeLimit, computePrice, ixs, recipientPublicKey, mintPublicKey, _c, metadata, metadataPubKey, _d, escrowTokens, tokenProgramId, senderTokens, recipientTokens, streamflowTreasuryTokens, partnerPublicKey, partnerTokens;
|
|
1131
|
+
var mint, start, period, cliff, canTopup, canUpdateRate, canPause, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, _a, automaticWithdrawal, _b, withdrawalFrequency, partner, sender, metadataPubKeys, computeLimit, computePrice, ixs, recipientPublicKey, mintPublicKey, _c, metadata, metadataPubKey, _d, escrowTokens, tokenProgramId, senderTokens, recipientTokens, streamflowTreasuryTokens, partnerPublicKey, partnerTokens;
|
|
1093
1132
|
return __generator(this, function (_e) {
|
|
1094
1133
|
switch (_e.label) {
|
|
1095
1134
|
case 0:
|
|
1096
|
-
mint = streamParams.tokenId, start = streamParams.start, period = streamParams.period, cliff = streamParams.cliff, canTopup = streamParams.canTopup, cancelableBySender = streamParams.cancelableBySender, cancelableByRecipient = streamParams.cancelableByRecipient, transferableBySender = streamParams.transferableBySender, transferableByRecipient = streamParams.transferableByRecipient, _a = streamParams.automaticWithdrawal, automaticWithdrawal = _a === void 0 ? false : _a, _b = streamParams.withdrawalFrequency, withdrawalFrequency = _b === void 0 ? 0 : _b, partner = streamParams.partner;
|
|
1135
|
+
mint = streamParams.tokenId, start = streamParams.start, period = streamParams.period, cliff = streamParams.cliff, canTopup = streamParams.canTopup, canUpdateRate = streamParams.canUpdateRate, canPause = streamParams.canPause, cancelableBySender = streamParams.cancelableBySender, cancelableByRecipient = streamParams.cancelableByRecipient, transferableBySender = streamParams.transferableBySender, transferableByRecipient = streamParams.transferableByRecipient, _a = streamParams.automaticWithdrawal, automaticWithdrawal = _a === void 0 ? false : _a, _b = streamParams.withdrawalFrequency, withdrawalFrequency = _b === void 0 ? 0 : _b, partner = streamParams.partner;
|
|
1097
1136
|
sender = extParams.sender, metadataPubKeys = extParams.metadataPubKeys, computeLimit = extParams.computeLimit, computePrice = extParams.computePrice;
|
|
1098
1137
|
if (!sender.publicKey) {
|
|
1099
1138
|
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
@@ -1135,6 +1174,8 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
1135
1174
|
transferableBySender: transferableBySender,
|
|
1136
1175
|
transferableByRecipient: transferableByRecipient,
|
|
1137
1176
|
canTopup: canTopup,
|
|
1177
|
+
canUpdateRate: !!canUpdateRate,
|
|
1178
|
+
canPause: !!canPause,
|
|
1138
1179
|
name: recipient.name,
|
|
1139
1180
|
withdrawFrequency: new bn_js_1.default(automaticWithdrawal ? withdrawalFrequency : period),
|
|
1140
1181
|
}, this.programId, {
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
import { ISearchStreams } from "./types";
|
|
2
3
|
export declare const TX_FINALITY_CONFIRMED = "confirmed";
|
|
3
4
|
export declare const STREAM_STRUCT_OFFSET_SENDER = 49;
|
|
4
5
|
export declare const STREAM_STRUCT_OFFSET_RECIPIENT = 113;
|
|
6
|
+
export declare const STREAM_STRUCT_OFFSET_MINT = 177;
|
|
7
|
+
export declare const STREAM_STRUCT_OFFSETS: Record<keyof ISearchStreams, number>;
|
|
5
8
|
export declare const CREATE_PARAMS_PADDING = 126;
|
|
6
9
|
export declare const PROGRAM_ID: {
|
|
7
10
|
devnet: string;
|
package/dist/solana/constants.js
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
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.PROGRAM_ID = exports.CREATE_PARAMS_PADDING = exports.STREAM_STRUCT_OFFSET_RECIPIENT = exports.STREAM_STRUCT_OFFSET_SENDER = exports.TX_FINALITY_CONFIRMED = void 0;
|
|
4
|
+
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.PROGRAM_ID = exports.CREATE_PARAMS_PADDING = exports.STREAM_STRUCT_OFFSETS = exports.STREAM_STRUCT_OFFSET_MINT = exports.STREAM_STRUCT_OFFSET_RECIPIENT = exports.STREAM_STRUCT_OFFSET_SENDER = exports.TX_FINALITY_CONFIRMED = void 0;
|
|
5
5
|
var web3_js_1 = require("@solana/web3.js");
|
|
6
6
|
var types_1 = require("../common/types");
|
|
7
7
|
exports.TX_FINALITY_CONFIRMED = "confirmed";
|
|
8
8
|
exports.STREAM_STRUCT_OFFSET_SENDER = 49;
|
|
9
9
|
exports.STREAM_STRUCT_OFFSET_RECIPIENT = 113;
|
|
10
|
+
exports.STREAM_STRUCT_OFFSET_MINT = 177;
|
|
11
|
+
exports.STREAM_STRUCT_OFFSETS = {
|
|
12
|
+
mint: exports.STREAM_STRUCT_OFFSET_MINT,
|
|
13
|
+
recipient: exports.STREAM_STRUCT_OFFSET_RECIPIENT,
|
|
14
|
+
sender: exports.STREAM_STRUCT_OFFSET_SENDER,
|
|
15
|
+
};
|
|
10
16
|
// Defined: https://github.com/streamflow-finance/protocol/blob/main/programs/protocol/src/state.rs#L25
|
|
11
17
|
exports.CREATE_PARAMS_PADDING = 126;
|
|
12
18
|
exports.PROGRAM_ID = (_a = {},
|
|
@@ -14,6 +14,8 @@ interface CreateStreamData {
|
|
|
14
14
|
transferableBySender: boolean;
|
|
15
15
|
transferableByRecipient: boolean;
|
|
16
16
|
canTopup: boolean;
|
|
17
|
+
canUpdateRate: boolean;
|
|
18
|
+
canPause: boolean;
|
|
17
19
|
name: string;
|
|
18
20
|
withdrawFrequency: BN;
|
|
19
21
|
}
|
|
@@ -51,6 +53,8 @@ interface CreateUncheckedStreamData {
|
|
|
51
53
|
transferableBySender: boolean;
|
|
52
54
|
transferableByRecipient: boolean;
|
|
53
55
|
canTopup: boolean;
|
|
56
|
+
canUpdateRate: boolean;
|
|
57
|
+
canPause: boolean;
|
|
54
58
|
name: string;
|
|
55
59
|
withdrawFrequency: BN;
|
|
56
60
|
recipient: PublicKey;
|
|
@@ -77,6 +77,10 @@ var createStreamInstruction = function (data, programId, accounts) {
|
|
|
77
77
|
transferable_by_sender: Number(data.transferableBySender),
|
|
78
78
|
transferable_by_recipient: Number(data.transferableByRecipient),
|
|
79
79
|
can_topup: Number(data.canTopup),
|
|
80
|
+
_pausable_discriminator: 1,
|
|
81
|
+
can_update_rate: Number(data.canUpdateRate),
|
|
82
|
+
_can_update_rate_discriminator: 1,
|
|
83
|
+
pausable: Number(data.canPause),
|
|
80
84
|
stream_name: streamNameBuffer,
|
|
81
85
|
withdraw_frequency: data.withdrawFrequency.toArrayLike(buffer_1.Buffer, "le", 8),
|
|
82
86
|
};
|
|
@@ -131,8 +135,8 @@ var createUncheckedStreamInstruction = function (data, programId, accounts) {
|
|
|
131
135
|
withdraw_frequency: data.withdrawFrequency.toArrayLike(buffer_1.Buffer, "le", 8),
|
|
132
136
|
recipient: data.recipient.toBuffer(),
|
|
133
137
|
partner: data.partner.toBuffer(),
|
|
134
|
-
pausable:
|
|
135
|
-
can_update_rate:
|
|
138
|
+
pausable: Number(data.canPause),
|
|
139
|
+
can_update_rate: Number(data.canUpdateRate),
|
|
136
140
|
};
|
|
137
141
|
var encodeLength = Layout.createUncheckedStreamLayout.encode(decodedData, bufferData);
|
|
138
142
|
bufferData = bufferData.slice(0, encodeLength);
|
package/dist/solana/layout.js
CHANGED
|
@@ -102,6 +102,12 @@ exports.createStreamLayout = BufferLayout.struct([
|
|
|
102
102
|
BufferLayout.u8("can_topup"),
|
|
103
103
|
BufferLayout.blob(64, "stream_name"),
|
|
104
104
|
BufferLayout.blob(8, "withdraw_frequency"),
|
|
105
|
+
// discriminator for optional field
|
|
106
|
+
BufferLayout.u8("_pausable_discriminator"),
|
|
107
|
+
BufferLayout.u8("pausable"),
|
|
108
|
+
// discriminator for optional field
|
|
109
|
+
BufferLayout.u8("_can_update_rate_discriminator"),
|
|
110
|
+
BufferLayout.u8("can_update_rate"),
|
|
105
111
|
]);
|
|
106
112
|
/**
|
|
107
113
|
* Create unchecked stream instruction layout
|
package/dist/solana/types.d.ts
CHANGED
|
@@ -3,6 +3,11 @@ import { AccountInfo, PublicKey, Keypair, VersionedTransaction } from "@solana/w
|
|
|
3
3
|
import { ITransactionSolanaExt } from "@streamflow/common/solana";
|
|
4
4
|
import BN from "bn.js";
|
|
5
5
|
import { IRecipient, Stream, StreamType } from "../common/types";
|
|
6
|
+
export interface ISearchStreams {
|
|
7
|
+
mint?: string;
|
|
8
|
+
sender?: string;
|
|
9
|
+
recipient?: string;
|
|
10
|
+
}
|
|
6
11
|
export interface Account {
|
|
7
12
|
pubkey: PublicKey;
|
|
8
13
|
account: AccountInfo<Buffer>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamflow/stream",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.4.2",
|
|
4
4
|
"description": "JavaScript SDK to interact with Streamflow protocol.",
|
|
5
5
|
"homepage": "https://github.com/streamflow-finance/js-sdk/",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"lint": "eslint --fix .",
|
|
36
36
|
"prepublishOnly": "npm run lint && npm test && npm run build"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "1c317073936ec2e6da6dee0d5a33cdb1e50f6776",
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@streamflow/eslint-config": "6.
|
|
40
|
+
"@streamflow/eslint-config": "6.4.2",
|
|
41
41
|
"@types/bn.js": "5.1.1",
|
|
42
42
|
"@types/ethereum-checksum-address": "^0.0.0",
|
|
43
43
|
"@types/jest": "29.2.4",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@solana/spl-token": "0.3.6",
|
|
55
55
|
"@solana/wallet-adapter-base": "0.9.19",
|
|
56
56
|
"@solana/web3.js": "1.70.1",
|
|
57
|
-
"@streamflow/common": "6.
|
|
57
|
+
"@streamflow/common": "6.4.2",
|
|
58
58
|
"@suiet/wallet-kit": "0.2.22",
|
|
59
59
|
"aptos": "1.4.0",
|
|
60
60
|
"bn.js": "5.2.1",
|