@streamflow/stream 3.0.17 → 3.0.18

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.
Files changed (52) hide show
  1. package/dist/__tests__/aptos/streamClient.spec.d.ts +1 -0
  2. package/dist/__tests__/aptos/streamClient.spec.js +160 -0
  3. package/dist/aptos/StreamClient.d.ts +49 -0
  4. package/dist/aptos/StreamClient.js +362 -0
  5. package/dist/aptos/constants.d.ts +2 -0
  6. package/dist/aptos/constants.js +12 -0
  7. package/dist/aptos/index.d.ts +2 -0
  8. package/dist/aptos/index.js +24 -0
  9. package/dist/aptos/types.d.ts +145 -0
  10. package/dist/aptos/types.js +65 -0
  11. package/dist/common/BaseStreamClient.d.ts +11 -0
  12. package/dist/common/BaseStreamClient.js +9 -0
  13. package/dist/common/GenericStreamClient.d.ts +60 -0
  14. package/dist/common/GenericStreamClient.js +137 -0
  15. package/dist/common/types.d.ts +71 -0
  16. package/dist/common/types.js +28 -0
  17. package/dist/{utils.d.ts → common/utils.d.ts} +0 -4
  18. package/dist/common/utils.js +31 -0
  19. package/dist/index.d.ts +5 -6
  20. package/dist/index.js +19 -10
  21. package/dist/solana/StreamClient.d.ts +71 -0
  22. package/dist/{StreamClient.js → solana/StreamClient.js} +303 -396
  23. package/dist/{constants.d.ts → solana/constants.d.ts} +1 -1
  24. package/dist/{constants.js → solana/constants.js} +5 -5
  25. package/dist/solana/index.d.ts +7 -0
  26. package/dist/solana/index.js +43 -0
  27. package/dist/solana/instructionTypes.d.ts +86 -0
  28. package/dist/solana/instructionTypes.js +2 -0
  29. package/dist/{instructions.d.ts → solana/instructions.d.ts} +8 -2
  30. package/dist/{instructions.js → solana/instructions.js} +55 -38
  31. package/dist/solana/layout.d.ts +27 -0
  32. package/dist/{layout.js → solana/layout.js} +65 -3
  33. package/dist/{idl/timelock.d.ts → solana/timelockIDL.d.ts} +0 -0
  34. package/dist/{idl/timelock.js → solana/timelockIDL.js} +0 -0
  35. package/dist/{types.d.ts → solana/types.d.ts} +37 -34
  36. package/dist/{types.js → solana/types.js} +3 -20
  37. package/dist/solana/utils.d.ts +42 -0
  38. package/dist/solana/utils.js +271 -0
  39. package/package.json +1 -1
  40. package/dist/Stream.d.ts +0 -87
  41. package/dist/Stream.js +0 -503
  42. package/dist/StreamClient.d.ts +0 -146
  43. package/dist/__tests__/test_dependencies/airdrop/airdrop-request.d.ts +0 -3
  44. package/dist/__tests__/test_dependencies/airdrop/airdrop-request.js +0 -67
  45. package/dist/__tests__/test_dependencies/airdrop/airdrop.d.ts +0 -6
  46. package/dist/__tests__/test_dependencies/airdrop/airdrop.js +0 -215
  47. package/dist/__tests__/test_dependencies/constants/index.d.ts +0 -122
  48. package/dist/__tests__/test_dependencies/constants/index.js +0 -158
  49. package/dist/__tests__/test_dependencies/idl/airdrop.d.ts +0 -27
  50. package/dist/__tests__/test_dependencies/idl/airdrop.js +0 -171
  51. package/dist/layout.d.ts +0 -22
  52. package/dist/utils.js +0 -126
@@ -3,27 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.TransferCancelOptions = exports.Contract = exports.LocalCluster = exports.StreamType = exports.StreamDirection = exports.Cluster = void 0;
6
+ exports.TransferCancelOptions = exports.Contract = exports.Cluster = void 0;
7
7
  var bn_js_1 = __importDefault(require("bn.js"));
8
- var utils_1 = require("./utils");
8
+ var utils_1 = require("../common/utils");
9
9
  var wallet_adapter_base_1 = require("@solana/wallet-adapter-base");
10
10
  Object.defineProperty(exports, "Cluster", { enumerable: true, get: function () { return wallet_adapter_base_1.WalletAdapterNetwork; } });
11
- var StreamDirection;
12
- (function (StreamDirection) {
13
- StreamDirection["Outgoing"] = "outgoing";
14
- StreamDirection["Incoming"] = "incoming";
15
- StreamDirection["All"] = "all";
16
- })(StreamDirection = exports.StreamDirection || (exports.StreamDirection = {}));
17
- var StreamType;
18
- (function (StreamType) {
19
- StreamType["Stream"] = "stream";
20
- StreamType["Vesting"] = "vesting";
21
- StreamType["All"] = "all";
22
- })(StreamType = exports.StreamType || (exports.StreamType = {}));
23
- var LocalCluster;
24
- (function (LocalCluster) {
25
- LocalCluster["Local"] = "local";
26
- })(LocalCluster = exports.LocalCluster || (exports.LocalCluster = {}));
27
11
  var Contract = /** @class */ (function () {
28
12
  function Contract(stream) {
29
13
  var _a;
@@ -41,8 +25,7 @@ var Contract = /** @class */ (function () {
41
25
  this.mint = stream.mint.toBase58();
42
26
  this.escrowTokens = stream.escrowTokens.toBase58();
43
27
  this.streamflowTreasury = stream.streamflowTreasury.toBase58();
44
- this.streamflowTreasuryTokens =
45
- stream.streamflowTreasuryTokens.toBase58();
28
+ this.streamflowTreasuryTokens = stream.streamflowTreasuryTokens.toBase58();
46
29
  this.streamflowFeeTotal = stream.streamflowFeeTotal;
47
30
  this.streamflowFeeWithdrawn = stream.streamflowFeeWithdrawn;
48
31
  this.streamflowFeePercent = stream.streamflowFeePercent.toNumber();
@@ -0,0 +1,42 @@
1
+ /// <reference types="node" />
2
+ import { SignerWalletAdapter } from "@solana/wallet-adapter-base";
3
+ import { Connection, Keypair, PublicKey } from "@solana/web3.js";
4
+ import { Stream, DecodedStream, Account, BatchItem, BatchItemResult } from "./types";
5
+ export declare const decodeStream: (buf: Buffer) => DecodedStream;
6
+ export declare const formatDecodedStream: (stream: DecodedStream) => Stream;
7
+ /**
8
+ * Wrapper function for Solana web3 getProgramAccounts with slightly better call interface
9
+ * @param {Connection} connection - Solana web3 connection object.
10
+ * @param {PublicKey} wallet - PublicKey to compare against.
11
+ * @param {number} offset - Offset of bits of the PublicKey in the account binary.
12
+ * @param {PublicKey} programId - Solana program ID.
13
+ * @return {Promise<Account[]>} - Array of resulting accounts.
14
+ */
15
+ export declare function getProgramAccounts(connection: Connection, wallet: PublicKey, offset: number, programId: PublicKey): Promise<Account[]>;
16
+ /**
17
+ * Utility function to check if the transaction initiator is a KeyPair or a Wallet object
18
+ * @param {Keypair | SignerWalletAdapter} walletOrKeypair - Wallet or Keypair in question
19
+ * @return {boolean} - Returns true if parameter is a Wallet.
20
+ */
21
+ export declare function isSignerWallet(walletOrKeypair: Keypair | SignerWalletAdapter): boolean;
22
+ /**
23
+ * Sign passed BatchItems with wallet request or KeyPair
24
+ * @param {Keypair | SignerWalletAdapter} sender - Wallet or Keypair of sendin account
25
+ * @param {BatchItem[]} items - Multiple recipient contracts split into separate items
26
+ * @return {BatchItem[]} - Returns items with signatures.
27
+ */
28
+ export declare function signAllTransactionWithRecipients(sender: Keypair | SignerWalletAdapter, items: BatchItem[]): Promise<BatchItem[]>;
29
+ /**
30
+ * Sign passed BatchItems with wallet request or KeyPair
31
+ * @param {Connection} connection - Solana web3 connection object.
32
+ * @param {BatchItem} batchItem - Signed transaction ready to be send.
33
+ * @return {Promise<BatchItemResult>} - Returns settled transaction item
34
+ */
35
+ export declare function sendAndConfirmStreamRawTransaction(connection: Connection, batchItem: BatchItem): Promise<BatchItemResult>;
36
+ /**
37
+ * Shorthand call signature for getAssociatedTokenAddress, with allowance for address to be offCurve
38
+ * @param {PublicKey} mint - SPL token Mint address.
39
+ * @param {PublicKey} owner - Owner of the Associated Token Address
40
+ * @return {Promise<PublicKey>} - Associated Token Address
41
+ */
42
+ export declare function ata(mint: PublicKey, owner: PublicKey): Promise<PublicKey>;
@@ -0,0 +1,271 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (_) try {
29
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ var __importDefault = (this && this.__importDefault) || function (mod) {
50
+ return (mod && mod.__esModule) ? mod : { "default": mod };
51
+ };
52
+ Object.defineProperty(exports, "__esModule", { value: true });
53
+ exports.ata = exports.sendAndConfirmStreamRawTransaction = exports.signAllTransactionWithRecipients = exports.isSignerWallet = exports.getProgramAccounts = exports.formatDecodedStream = exports.decodeStream = void 0;
54
+ var spl_token_1 = require("@solana/spl-token");
55
+ var web3_js_1 = require("@solana/web3.js");
56
+ var bn_js_1 = __importDefault(require("bn.js"));
57
+ var bs58_1 = __importDefault(require("bs58"));
58
+ var layout_1 = require("./layout");
59
+ var decoder = new TextDecoder("utf-8");
60
+ var LE = "le"; //little endian
61
+ var decodeStream = function (buf) {
62
+ var raw = layout_1.streamLayout.decode(buf);
63
+ return {
64
+ magic: new bn_js_1.default(raw.magic, LE),
65
+ version: new bn_js_1.default(raw.version, LE),
66
+ createdAt: new bn_js_1.default(raw.created_at, LE),
67
+ withdrawnAmount: new bn_js_1.default(raw.withdrawn_amount, LE),
68
+ canceledAt: new bn_js_1.default(raw.canceled_at, LE),
69
+ end: new bn_js_1.default(raw.end_time, LE),
70
+ lastWithdrawnAt: new bn_js_1.default(raw.last_withdrawn_at, LE),
71
+ sender: new web3_js_1.PublicKey(raw.sender),
72
+ senderTokens: new web3_js_1.PublicKey(raw.sender_tokens),
73
+ recipient: new web3_js_1.PublicKey(raw.recipient),
74
+ recipientTokens: new web3_js_1.PublicKey(raw.recipient_tokens),
75
+ mint: new web3_js_1.PublicKey(raw.mint),
76
+ escrowTokens: new web3_js_1.PublicKey(raw.escrow_tokens),
77
+ streamflowTreasury: new web3_js_1.PublicKey(raw.streamflow_treasury),
78
+ streamflowTreasuryTokens: new web3_js_1.PublicKey(raw.streamflow_treasury_tokens),
79
+ streamflowFeeTotal: new bn_js_1.default(raw.streamflow_fee_total, LE),
80
+ streamflowFeeWithdrawn: new bn_js_1.default(raw.streamflow_fee_withdrawn, LE),
81
+ streamflowFeePercent: new bn_js_1.default(raw.streamflow_fee_percent, LE),
82
+ partnerFeeTotal: new bn_js_1.default(raw.partner_fee_total, LE),
83
+ partnerFeeWithdrawn: new bn_js_1.default(raw.partner_fee_withdrawn, LE),
84
+ partnerFeePercent: new bn_js_1.default(raw.partner_fee_percent, LE),
85
+ partner: new web3_js_1.PublicKey(raw.partner),
86
+ partnerTokens: new web3_js_1.PublicKey(raw.partner_tokens),
87
+ start: new bn_js_1.default(raw.start_time, LE),
88
+ depositedAmount: new bn_js_1.default(raw.net_amount_deposited, LE),
89
+ period: new bn_js_1.default(raw.period, LE),
90
+ amountPerPeriod: new bn_js_1.default(raw.amount_per_period, LE),
91
+ cliff: new bn_js_1.default(raw.cliff, LE),
92
+ cliffAmount: new bn_js_1.default(raw.cliff_amount, LE),
93
+ cancelableBySender: Boolean(raw.cancelable_by_sender),
94
+ cancelableByRecipient: Boolean(raw.cancelable_by_recipient),
95
+ automaticWithdrawal: Boolean(raw.automatic_withdrawal),
96
+ transferableBySender: Boolean(raw.transferable_by_sender),
97
+ transferableByRecipient: Boolean(raw.transferable_by_recipient),
98
+ canTopup: Boolean(raw.can_topup),
99
+ name: decoder.decode(raw.stream_name),
100
+ withdrawFrequency: new bn_js_1.default(raw.withdraw_frequency, LE),
101
+ };
102
+ };
103
+ exports.decodeStream = decodeStream;
104
+ // DeprecationWarning: This object will be deprecated starting from the version 4.0.0. Use
105
+ // types/Contract instead
106
+ var formatDecodedStream = function (stream) {
107
+ var _a;
108
+ var resp = {
109
+ magic: stream.magic.toNumber(),
110
+ version: stream.version.toNumber(),
111
+ createdAt: stream.createdAt.toNumber(),
112
+ withdrawnAmount: stream.withdrawnAmount,
113
+ canceledAt: stream.canceledAt.toNumber(),
114
+ end: stream.end.toNumber(),
115
+ lastWithdrawnAt: stream.lastWithdrawnAt.toNumber(),
116
+ sender: stream.sender.toBase58(),
117
+ senderTokens: stream.senderTokens.toBase58(),
118
+ recipient: stream.recipient.toBase58(),
119
+ recipientTokens: stream.recipientTokens.toBase58(),
120
+ mint: stream.mint.toBase58(),
121
+ escrowTokens: stream.escrowTokens.toBase58(),
122
+ streamflowTreasury: stream.streamflowTreasury.toBase58(),
123
+ streamflowTreasuryTokens: stream.streamflowTreasuryTokens.toBase58(),
124
+ streamflowFeeTotal: stream.streamflowFeeTotal,
125
+ streamflowFeeWithdrawn: stream.streamflowFeeWithdrawn,
126
+ streamflowFeePercent: stream.streamflowFeePercent.toNumber(),
127
+ partnerFeeTotal: stream.partnerFeeTotal,
128
+ partnerFeeWithdrawn: stream.partnerFeeWithdrawn,
129
+ partnerFeePercent: stream.partnerFeePercent.toNumber(),
130
+ partner: stream.partner.toBase58(),
131
+ partnerTokens: (_a = stream.partnerTokens) === null || _a === void 0 ? void 0 : _a.toBase58(),
132
+ start: stream.start.toNumber(),
133
+ depositedAmount: stream.depositedAmount,
134
+ period: stream.period.toNumber(),
135
+ amountPerPeriod: stream.amountPerPeriod,
136
+ cliff: stream.cliff.toNumber(),
137
+ cliffAmount: stream.cliffAmount,
138
+ cancelableBySender: stream.cancelableBySender,
139
+ cancelableByRecipient: stream.cancelableByRecipient,
140
+ automaticWithdrawal: stream.automaticWithdrawal,
141
+ transferableBySender: stream.transferableBySender,
142
+ transferableByRecipient: stream.transferableByRecipient,
143
+ canTopup: stream.canTopup,
144
+ name: stream.name,
145
+ withdrawalFrequency: stream.withdrawFrequency.toNumber(),
146
+ unlocked: function () {
147
+ return 0;
148
+ },
149
+ withdrawn: function () {
150
+ return new bn_js_1.default(0);
151
+ }, //phantom method to preserve partial support of this object
152
+ };
153
+ return resp;
154
+ };
155
+ exports.formatDecodedStream = formatDecodedStream;
156
+ /**
157
+ * Wrapper function for Solana web3 getProgramAccounts with slightly better call interface
158
+ * @param {Connection} connection - Solana web3 connection object.
159
+ * @param {PublicKey} wallet - PublicKey to compare against.
160
+ * @param {number} offset - Offset of bits of the PublicKey in the account binary.
161
+ * @param {PublicKey} programId - Solana program ID.
162
+ * @return {Promise<Account[]>} - Array of resulting accounts.
163
+ */
164
+ function getProgramAccounts(connection, wallet, offset, programId) {
165
+ return __awaiter(this, void 0, void 0, function () {
166
+ return __generator(this, function (_a) {
167
+ return [2 /*return*/, connection === null || connection === void 0 ? void 0 : connection.getProgramAccounts(programId, {
168
+ filters: [
169
+ {
170
+ memcmp: {
171
+ offset: offset,
172
+ bytes: wallet.toBase58(),
173
+ },
174
+ },
175
+ ],
176
+ })];
177
+ });
178
+ });
179
+ }
180
+ exports.getProgramAccounts = getProgramAccounts;
181
+ /**
182
+ * Utility function to check if the transaction initiator is a KeyPair or a Wallet object
183
+ * @param {Keypair | SignerWalletAdapter} walletOrKeypair - Wallet or Keypair in question
184
+ * @return {boolean} - Returns true if parameter is a Wallet.
185
+ */
186
+ function isSignerWallet(walletOrKeypair) {
187
+ return walletOrKeypair.signTransaction !== undefined;
188
+ }
189
+ exports.isSignerWallet = isSignerWallet;
190
+ /**
191
+ * Sign passed BatchItems with wallet request or KeyPair
192
+ * @param {Keypair | SignerWalletAdapter} sender - Wallet or Keypair of sendin account
193
+ * @param {BatchItem[]} items - Multiple recipient contracts split into separate items
194
+ * @return {BatchItem[]} - Returns items with signatures.
195
+ */
196
+ function signAllTransactionWithRecipients(sender, items) {
197
+ return __awaiter(this, void 0, void 0, function () {
198
+ var isKeypair, isWallet, signedTxs_1;
199
+ return __generator(this, function (_a) {
200
+ switch (_a.label) {
201
+ case 0:
202
+ isKeypair = sender instanceof web3_js_1.Keypair;
203
+ isWallet = isSignerWallet(sender);
204
+ if (!isKeypair) return [3 /*break*/, 1];
205
+ return [2 /*return*/, items.map(function (t) {
206
+ t.tx.partialSign(sender);
207
+ return { tx: t.tx, recipient: t.recipient };
208
+ })];
209
+ case 1:
210
+ if (!isWallet) return [3 /*break*/, 3];
211
+ return [4 /*yield*/, sender.signAllTransactions(items.map(function (t) { return t.tx; }))];
212
+ case 2:
213
+ signedTxs_1 = _a.sent();
214
+ return [2 /*return*/, items.map(function (item, index) { return (__assign(__assign({}, item), { tx: signedTxs_1[index] })); })];
215
+ case 3:
216
+ // If signer is not passed
217
+ return [2 /*return*/, []];
218
+ }
219
+ });
220
+ });
221
+ }
222
+ exports.signAllTransactionWithRecipients = signAllTransactionWithRecipients;
223
+ /**
224
+ * Sign passed BatchItems with wallet request or KeyPair
225
+ * @param {Connection} connection - Solana web3 connection object.
226
+ * @param {BatchItem} batchItem - Signed transaction ready to be send.
227
+ * @return {Promise<BatchItemResult>} - Returns settled transaction item
228
+ */
229
+ function sendAndConfirmStreamRawTransaction(connection, batchItem) {
230
+ var _a, _b;
231
+ return __awaiter(this, void 0, void 0, function () {
232
+ var rawTx, _c, lastValidBlockHeight, signature, recentBlockhash, confirmationStrategy, completedTxSignature, error_1;
233
+ return __generator(this, function (_d) {
234
+ switch (_d.label) {
235
+ case 0:
236
+ _d.trys.push([0, 2, , 3]);
237
+ rawTx = batchItem.tx.serialize();
238
+ _c = batchItem.tx, lastValidBlockHeight = _c.lastValidBlockHeight, signature = _c.signature, recentBlockhash = _c.recentBlockhash;
239
+ if (!lastValidBlockHeight || !signature || !recentBlockhash)
240
+ throw { recipient: batchItem.recipient, error: "no recent blockhash" };
241
+ confirmationStrategy = {
242
+ lastValidBlockHeight: lastValidBlockHeight,
243
+ signature: bs58_1.default.encode(signature),
244
+ blockhash: recentBlockhash,
245
+ };
246
+ return [4 /*yield*/, (0, web3_js_1.sendAndConfirmRawTransaction)(connection, rawTx, confirmationStrategy, { skipPreflight: true })];
247
+ case 1:
248
+ completedTxSignature = _d.sent();
249
+ return [2 /*return*/, __assign(__assign({}, batchItem), { signature: completedTxSignature })];
250
+ case 2:
251
+ error_1 = _d.sent();
252
+ throw {
253
+ recipient: batchItem.recipient,
254
+ error: (_b = (_a = error_1 === null || error_1 === void 0 ? void 0 : error_1.error) !== null && _a !== void 0 ? _a : error_1 === null || error_1 === void 0 ? void 0 : error_1.message) !== null && _b !== void 0 ? _b : error_1.toString(),
255
+ };
256
+ case 3: return [2 /*return*/];
257
+ }
258
+ });
259
+ });
260
+ }
261
+ exports.sendAndConfirmStreamRawTransaction = sendAndConfirmStreamRawTransaction;
262
+ /**
263
+ * Shorthand call signature for getAssociatedTokenAddress, with allowance for address to be offCurve
264
+ * @param {PublicKey} mint - SPL token Mint address.
265
+ * @param {PublicKey} owner - Owner of the Associated Token Address
266
+ * @return {Promise<PublicKey>} - Associated Token Address
267
+ */
268
+ function ata(mint, owner) {
269
+ return (0, spl_token_1.getAssociatedTokenAddress)(mint, owner, true);
270
+ }
271
+ exports.ata = ata;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamflow/stream",
3
- "version": "3.0.17",
3
+ "version": "3.0.18",
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/",
package/dist/Stream.d.ts DELETED
@@ -1,87 +0,0 @@
1
- import { Stream as StreamData, GetStreamsParams, CreateStreamParams, CreateStreamResponse, WithdrawStreamParams, CancelStreamParams, TransactionResponse, TopupStreamParams, TransferStreamParams, GetStreamParams } from "./types";
2
- export default class Stream {
3
- /**
4
- * Creates a new stream/vesting contract.
5
- * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
6
- * @param {CreateStreamParams} data
7
- * @param {Connection} data.connection - A connection to the cluster.
8
- * @param {Wallet} data.sender - Wallet signing the transaction. Its address should match the authorized wallet (sender) or transaction will fail.
9
- * @param {string} data.recipient - Solana address of the recipient. Associated token account will be derived using this address and token mint address.
10
- * @param {string} data.mint - SPL Token mint.
11
- * @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
12
- * @param {BN} data.depositedAmount - Initially deposited amount of tokens (in the smallest units).
13
- * @param {number} data.period - Time step (period) in seconds per which the unlocking occurs.
14
- * @param {number} data.cliff - Vesting contract "cliff" timestamp in seconds.
15
- * @param {BN} data.cliffAmount - Amount unlocked at the "cliff".
16
- * @param {BN} data.amountPerPeriod - Amount unlocked per each period.
17
- * @param {string} data.name - Stream name/subject.
18
- * @param {boolean} data.canTopup - TRUE for streams, FALSE for vesting contracts.
19
- * @param {boolean} data.cancelableBySender - Whether or not sender can cancel the stream.
20
- * @param {boolean} data.cancelableByRecipient - Whether or not recipient can cancel the stream.
21
- * @param {boolean} data.transferableBySender - Whether or not sender can transfer the stream.
22
- * @param {boolean} data.transferableByRecipient - Whether or not recipient can transfer the stream.
23
- * @param {boolean} [data.automaticWithdrawal = false] - Whether or not a 3rd party can initiate withdraw in the name of recipient.
24
- * @param {number} [data.withdrawalFrequency = 0] - Relevant when automatic withdrawal is enabled. If greater than 0 our withdrawor will take care of withdrawals. If equal to 0 our withdrawor will skip, but everyone else can initiate withdrawals.
25
- * @param {string | null} [data.partner = null] - Partner's wallet address (optional).
26
- * @param {ClusterExtended} [data.cluster = Cluster.Mainnet] - Cluster: devnet, mainnet-beta, testnet or local (optional).
27
- */
28
- static create({ connection, sender, recipient, mint, start, depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, cluster, }: CreateStreamParams): Promise<CreateStreamResponse>;
29
- /**
30
- * Attempts withdrawal from the specified stream.
31
- * @param {WithdrawStreamParams} data
32
- * @param {Connection} data.connection - A connection to the cluster.
33
- * @param {Wallet} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (recipient) or transaction will fail.
34
- * @param {string} data.id - Identifier of a stream (escrow account with metadata) to be withdrawn from.
35
- * @param {BN} data.amount - Requested amount (in the smallest units) to withdraw (while streaming). If stream is completed, the whole amount will be withdrawn.
36
- * @param {ClusterExtended} [data.cluster = Cluster.Mainnet] - Cluster: devnet, mainnet-beta, testnet or local (optional).
37
- */
38
- static withdraw({ connection, invoker, id, amount, cluster, }: WithdrawStreamParams): Promise<TransactionResponse>;
39
- /**
40
- * Attempts canceling the specified stream.
41
- * @param {CancelStreamParams} data
42
- * @param {Connection} data.connection - A connection to the cluster.
43
- * @param {Wallet} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (sender or recipient) or transaction will fail.
44
- * @param {string} data.id - Identifier of a stream (escrow account with metadata) to be canceled.
45
- * @param {ClusterExtended} [data.cluster = Cluster.Mainnet] - Cluster: devnet, mainnet-beta, testnet or local (optional).
46
- */
47
- static cancel({ connection, invoker, id, cluster, }: CancelStreamParams): Promise<TransactionResponse>;
48
- /**
49
- * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
50
- * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
51
- * @param {TransferStreamParams} data
52
- * @param {Connection} data.connection - A connection to the cluster.
53
- * @param {Wallet} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (sender or recipient) or transaction will fail.
54
- * @param {string} data.id - Identifier of a stream (escrow account with metadata) to be transferred.
55
- * @param {string} data.recipientId - Address of a new recipient.
56
- * @param {ClusterExtended} [data.cluster = Cluster.Mainnet] - Cluster: devnet, mainnet-beta, testnet or local (optional).
57
- */
58
- static transfer({ connection, invoker, id, recipientId, cluster, }: TransferStreamParams): Promise<TransactionResponse>;
59
- /**
60
- * Tops up stream account deposited amount.
61
- * @param {TopupStreamParams} data
62
- * @param {Connection} data.connection - A connection to the cluster.
63
- * @param {Wallet} data.invoker - Wallet signing the transaction. It's address should match current stream sender or transaction will fail.
64
- * @param {string} data.id - Identifier of a stream (escrow account with metadata) to be topped up.
65
- * @param {BN} data.amount - Specified amount (in the smallest units) to topup (increases deposited amount).
66
- * @param {ClusterExtended} [data.cluster = Cluster.Mainnet] - Cluster: devnet, mainnet-beta, testnet or local (optional).
67
- */
68
- static topup({ connection, invoker, id, amount, cluster, }: TopupStreamParams): Promise<TransactionResponse>;
69
- /**
70
- * Fetch stream data by its id (address).
71
- * @param {GetStreamParams} data
72
- * @param {Connection} data.connection - A connection to the cluster.
73
- * @param {string} data.id - Identifier of a stream that is fetched.
74
- */
75
- static getOne({ connection, id, }: GetStreamParams): Promise<StreamData>;
76
- /**
77
- * Fetch streams/contracts by providing direction.
78
- * Streams are sorted by start time in ascending order.
79
- * @param {GetStreamsParams} data
80
- * @param {Connection} data.connection - A connection to the cluster.
81
- * @param {PublicKey} data.wallet - PublicKey of the wallet for which the streams/contracts are fetched.
82
- * @param {StreamType} [data.type = StreamType.All] - It can be one of: stream, vesting, all.
83
- * @param {StreamDirection} [data.direction = StreamDirection.All] - It can be one of: incoming, outgoing, all.
84
- * @param {ClusterExtended} [data.cluster = Cluster.Mainnet] - Cluster: devnet, mainnet-beta, testnet or local (optional).
85
- */
86
- static get({ connection, wallet, type, direction, cluster, }: GetStreamsParams): Promise<[string, StreamData][]>;
87
- }