@streamflow/stream 5.9.0 → 5.9.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.
|
@@ -36,11 +36,11 @@ export default class SolanaStreamClient extends BaseStreamClient {
|
|
|
36
36
|
/**
|
|
37
37
|
* Attempts withdrawing from the specified stream.
|
|
38
38
|
*/
|
|
39
|
-
withdraw({ id, amount }: IWithdrawData, { invoker }: IInteractStreamSolanaExt): Promise<ITransactionResult>;
|
|
39
|
+
withdraw({ id, amount }: IWithdrawData, { invoker, checkTokenAccounts }: IInteractStreamSolanaExt): Promise<ITransactionResult>;
|
|
40
40
|
/**
|
|
41
41
|
* Attempts canceling the specified stream.
|
|
42
42
|
*/
|
|
43
|
-
cancel({ id }: ICancelData, { invoker }: IInteractStreamSolanaExt): Promise<ITransactionResult>;
|
|
43
|
+
cancel({ id }: ICancelData, { invoker, checkTokenAccounts }: IInteractStreamSolanaExt): Promise<ITransactionResult>;
|
|
44
44
|
/**
|
|
45
45
|
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
46
46
|
* Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
|
|
@@ -72,9 +72,9 @@ export default class SolanaStreamClient extends BaseStreamClient {
|
|
|
72
72
|
*/
|
|
73
73
|
private prepareStreamTransaction;
|
|
74
74
|
/**
|
|
75
|
-
* Utility function that checks whether associated token
|
|
75
|
+
* Utility function that checks whether associated token accounts still exist and adds instructions to add them if not
|
|
76
76
|
*/
|
|
77
|
-
private
|
|
77
|
+
private checkAssociatedTokenAccounts;
|
|
78
78
|
/**
|
|
79
79
|
* Utility function to generate metadata for a Contract or return existing Pubkey
|
|
80
80
|
*/
|
|
@@ -496,7 +496,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
496
496
|
*/
|
|
497
497
|
SolanaStreamClient.prototype.withdraw = function (_a, _b) {
|
|
498
498
|
var id = _a.id, amount = _a.amount;
|
|
499
|
-
var invoker = _b.invoker;
|
|
499
|
+
var invoker = _b.invoker, checkTokenAccounts = _b.checkTokenAccounts;
|
|
500
500
|
return __awaiter(this, void 0, void 0, function () {
|
|
501
501
|
var ixs, streamPublicKey, escrow, data, streamflowTreasuryTokens, partnerTokens, commitment, hash, tx, signature;
|
|
502
502
|
var _c;
|
|
@@ -521,7 +521,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
521
521
|
return [4 /*yield*/, (0, utils_1.ata)(data.mint, data.partner)];
|
|
522
522
|
case 3:
|
|
523
523
|
partnerTokens = _d.sent();
|
|
524
|
-
return [4 /*yield*/, this.
|
|
524
|
+
return [4 /*yield*/, this.checkAssociatedTokenAccounts(data, { invoker: invoker, checkTokenAccounts: checkTokenAccounts }, ixs)];
|
|
525
525
|
case 4:
|
|
526
526
|
_d.sent();
|
|
527
527
|
ixs.push((0, instructions_1.withdrawStreamInstruction)(amount, this.programId, {
|
|
@@ -559,7 +559,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
559
559
|
*/
|
|
560
560
|
SolanaStreamClient.prototype.cancel = function (_a, _b) {
|
|
561
561
|
var id = _a.id;
|
|
562
|
-
var invoker = _b.invoker;
|
|
562
|
+
var invoker = _b.invoker, checkTokenAccounts = _b.checkTokenAccounts;
|
|
563
563
|
return __awaiter(this, void 0, void 0, function () {
|
|
564
564
|
var streamPublicKey, escrowAcc, data, streamflowTreasuryTokens, partnerTokens, ixs, commitment, hash, tx, signature;
|
|
565
565
|
var _c;
|
|
@@ -584,7 +584,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
584
584
|
case 3:
|
|
585
585
|
partnerTokens = _d.sent();
|
|
586
586
|
ixs = [];
|
|
587
|
-
return [4 /*yield*/, this.
|
|
587
|
+
return [4 /*yield*/, this.checkAssociatedTokenAccounts(data, { invoker: invoker, checkTokenAccounts: checkTokenAccounts }, ixs)];
|
|
588
588
|
case 4:
|
|
589
589
|
_d.sent();
|
|
590
590
|
ixs.push((0, instructions_1.cancelStreamInstruction)(this.programId, {
|
|
@@ -1017,19 +1017,38 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
1017
1017
|
});
|
|
1018
1018
|
};
|
|
1019
1019
|
/**
|
|
1020
|
-
* Utility function that checks whether associated token
|
|
1020
|
+
* Utility function that checks whether associated token accounts still exist and adds instructions to add them if not
|
|
1021
1021
|
*/
|
|
1022
|
-
SolanaStreamClient.prototype.
|
|
1023
|
-
var invoker = _a.invoker;
|
|
1022
|
+
SolanaStreamClient.prototype.checkAssociatedTokenAccounts = function (data, _a, ixs) {
|
|
1023
|
+
var invoker = _a.invoker, checkTokenAccounts = _a.checkTokenAccounts;
|
|
1024
1024
|
return __awaiter(this, void 0, void 0, function () {
|
|
1025
|
-
var
|
|
1025
|
+
var checkedKeys, accountArrays, response, i;
|
|
1026
1026
|
return __generator(this, function (_b) {
|
|
1027
1027
|
switch (_b.label) {
|
|
1028
|
-
case 0:
|
|
1028
|
+
case 0:
|
|
1029
|
+
if (!checkTokenAccounts) {
|
|
1030
|
+
return [2 /*return*/];
|
|
1031
|
+
}
|
|
1032
|
+
checkedKeys = new Set();
|
|
1033
|
+
accountArrays = [
|
|
1034
|
+
[data.sender, data.senderTokens],
|
|
1035
|
+
[data.recipient, data.recipientTokens],
|
|
1036
|
+
[data.partner, data.partnerTokens],
|
|
1037
|
+
[data.streamflowTreasury, data.streamflowTreasuryTokens],
|
|
1038
|
+
].filter(function (value) {
|
|
1039
|
+
if (checkedKeys.has(value[1])) {
|
|
1040
|
+
return false;
|
|
1041
|
+
}
|
|
1042
|
+
checkedKeys.add(value[1]);
|
|
1043
|
+
return true;
|
|
1044
|
+
});
|
|
1045
|
+
return [4 /*yield*/, this.connection.getMultipleAccountsInfo(accountArrays.map(function (item) { return item[1]; }))];
|
|
1029
1046
|
case 1:
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1047
|
+
response = _b.sent();
|
|
1048
|
+
for (i = 0; i < response.length; i++) {
|
|
1049
|
+
if (!response[i]) {
|
|
1050
|
+
ixs.push((0, spl_token_2.createAssociatedTokenAccountInstruction)(invoker.publicKey, accountArrays[i][0], accountArrays[i][1], data.mint, spl_token_1.TOKEN_PROGRAM_ID, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID));
|
|
1051
|
+
}
|
|
1033
1052
|
}
|
|
1034
1053
|
return [2 /*return*/];
|
|
1035
1054
|
}
|
package/dist/solana/types.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export interface ICreateStreamSolanaExt {
|
|
|
16
16
|
}
|
|
17
17
|
export interface IInteractStreamSolanaExt {
|
|
18
18
|
invoker: SignerWalletAdapter | Keypair;
|
|
19
|
+
checkTokenAccounts?: boolean;
|
|
19
20
|
}
|
|
20
21
|
export interface ITopUpStreamSolanaExt {
|
|
21
22
|
invoker: SignerWalletAdapter | Keypair;
|
|
@@ -280,9 +281,15 @@ export interface CreateMultipleStreamsValues {
|
|
|
280
281
|
referral: string;
|
|
281
282
|
recipients: Recipient[];
|
|
282
283
|
}
|
|
283
|
-
export interface
|
|
284
|
+
export interface CheckAssociatedTokenAccountsData {
|
|
285
|
+
sender: PublicKey;
|
|
286
|
+
senderTokens: PublicKey;
|
|
284
287
|
recipient: PublicKey;
|
|
285
288
|
recipientTokens: PublicKey;
|
|
289
|
+
partner: PublicKey;
|
|
290
|
+
partnerTokens: PublicKey;
|
|
291
|
+
streamflowTreasury: PublicKey;
|
|
292
|
+
streamflowTreasuryTokens: PublicKey;
|
|
286
293
|
mint: PublicKey;
|
|
287
294
|
}
|
|
288
295
|
export interface BatchItem {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamflow/stream",
|
|
3
|
-
"version": "5.9.
|
|
3
|
+
"version": "5.9.2",
|
|
4
4
|
"description": "JavaScript SDK to interact with Streamflow protocol.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"homepage": "https://github.com/streamflow-finance/js-sdk/",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"lint": "eslint .",
|
|
12
12
|
"prepublishOnly": "npm run lint && npm test && npm run build"
|
|
13
13
|
},
|
|
14
|
-
"gitHead": "
|
|
14
|
+
"gitHead": "73797834c52f3e651e4e8874886c8e4b67e5f2af",
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@types/bn.js": "5.1.1",
|
|
17
17
|
"@types/ethereum-checksum-address": "^0.0.0",
|