@streamflow/stream 5.10.3 → 5.11.0

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.
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
25
25
  function verb(n) { return function (v) { return step([n, v]); }; }
26
26
  function step(op) {
27
27
  if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
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
30
  if (y = 0, t) op = [op[0] & 2, t.value];
31
31
  switch (op[0]) {
@@ -17,7 +17,7 @@ export default class AptosStreamClient extends BaseStreamClient {
17
17
  /**
18
18
  * Attempts withdrawing from the specified stream.
19
19
  */
20
- withdraw(withdrawData: IWithdrawData, { senderWallet, tokenId }: ITransactionAptosExt): Promise<ITransactionResult>;
20
+ withdraw({ id, amount }: IWithdrawData, { senderWallet, tokenId }: ITransactionAptosExt): Promise<ITransactionResult>;
21
21
  /**
22
22
  * Attempts canceling the specified stream.
23
23
  */
@@ -40,7 +40,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
40
40
  function verb(n) { return function (v) { return step([n, v]); }; }
41
41
  function step(op) {
42
42
  if (f) throw new TypeError("Generator is already executing.");
43
- while (_) try {
43
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
44
44
  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;
45
45
  if (y = 0, t) op = [op[0] & 2, t.value];
46
46
  switch (op[0]) {
@@ -85,6 +85,7 @@ var constants_1 = require("./constants");
85
85
  var types_2 = require("./types");
86
86
  var wallet_1 = require("./wallet");
87
87
  var utils_1 = require("./utils");
88
+ var constants_2 = require("../common/constants");
88
89
  var AptosStreamClient = /** @class */ (function (_super) {
89
90
  __extends(AptosStreamClient, _super);
90
91
  function AptosStreamClient(clusterUrl, cluster, maxGas, programId) {
@@ -174,23 +175,24 @@ var AptosStreamClient = /** @class */ (function (_super) {
174
175
  /**
175
176
  * Attempts withdrawing from the specified stream.
176
177
  */
177
- AptosStreamClient.prototype.withdraw = function (withdrawData, _a) {
178
- var senderWallet = _a.senderWallet, tokenId = _a.tokenId;
178
+ AptosStreamClient.prototype.withdraw = function (_a, _b) {
179
+ var id = _a.id, _c = _a.amount, amount = _c === void 0 ? constants_2.WITHDRAW_AVAILABLE_AMOUNT : _c;
180
+ var senderWallet = _b.senderWallet, tokenId = _b.tokenId;
179
181
  return __awaiter(this, void 0, void 0, function () {
180
182
  var payload, wallet, hash;
181
- return __generator(this, function (_b) {
182
- switch (_b.label) {
183
+ return __generator(this, function (_d) {
184
+ switch (_d.label) {
183
185
  case 0:
184
186
  payload = {
185
187
  type: "withdraw",
186
188
  function: "".concat(this.programId, "::protocol::withdraw"),
187
189
  type_arguments: [tokenId],
188
- arguments: [withdrawData.id, withdrawData.amount.toString()],
190
+ arguments: [id, amount.toString()],
189
191
  };
190
192
  wallet = new wallet_1.AptosWalletWrapper(senderWallet, this.client);
191
193
  return [4 /*yield*/, wallet.signAndSubmitTransaction(payload)];
192
194
  case 1:
193
- hash = _b.sent();
195
+ hash = _d.sent();
194
196
  return [2 /*return*/, { ixs: [payload], txId: hash }];
195
197
  }
196
198
  });
@@ -5,7 +5,7 @@ import { Stream, StreamType } from "../common/types";
5
5
  export interface ICreateStreamAptosExt {
6
6
  senderWallet: WalletContextState | AptosAccount;
7
7
  }
8
- export declare type ITransactionAptosExt = ICreateStreamAptosExt & {
8
+ export type ITransactionAptosExt = ICreateStreamAptosExt & {
9
9
  tokenId: string;
10
10
  };
11
11
  export interface StreamResource {
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  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;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  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;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -34,17 +34,17 @@ export interface SuiStreamClientOptions {
34
34
  ids?: ISuiIdParameters;
35
35
  }
36
36
  /** Type referencing options for specific Chain Client */
37
- declare type StreamClientOptions<T extends IChain> = T extends IChain.Solana ? SolanaStreamClientOptions : T extends IChain.Aptos ? AptosStreamClientOptions : T extends IChain.Sui ? SuiStreamClientOptions : EvmStreamClientOptions;
37
+ type StreamClientOptions<T extends IChain> = T extends IChain.Solana ? SolanaStreamClientOptions : T extends IChain.Aptos ? AptosStreamClientOptions : T extends IChain.Sui ? SuiStreamClientOptions : EvmStreamClientOptions;
38
38
  /** Type referencing Chain Client implementation */
39
- declare type StreamClientType<T extends IChain> = T extends IChain.Solana ? SolanaStreamClient : T extends IChain.Aptos ? AptosStreamClient : T extends IChain.Sui ? SuiStreamClient : EvmStreamClient;
39
+ type StreamClientType<T extends IChain> = T extends IChain.Solana ? SolanaStreamClient : T extends IChain.Aptos ? AptosStreamClient : T extends IChain.Sui ? SuiStreamClient : EvmStreamClient;
40
40
  /** Type referencing additional parameters used by a Chain Client */
41
- declare type ChainSpecificParams<T, SolanaExt, AptosExt, SuiExt> = T extends SolanaStreamClient ? SolanaExt : T extends AptosStreamClient ? AptosExt : T extends SuiStreamClient ? SuiExt : undefined;
41
+ type ChainSpecificParams<T, SolanaExt, AptosExt, SuiExt> = T extends SolanaStreamClient ? SolanaExt : T extends AptosStreamClient ? AptosExt : T extends SuiStreamClient ? SuiExt : undefined;
42
42
  /** Type referencing additional parameters used on Create by a Chain Client */
43
- declare type CreateSpecificParams<T extends IChain> = ChainSpecificParams<StreamClientType<T>, ICreateStreamSolanaExt, ICreateStreamAptosExt, ICreateStreamSuiExt>;
43
+ type CreateSpecificParams<T extends IChain> = ChainSpecificParams<StreamClientType<T>, ICreateStreamSolanaExt, ICreateStreamAptosExt, ICreateStreamSuiExt>;
44
44
  /** Type referencing additional parameters used on Topup by a Chain Client */
45
- declare type TopupSpecificParams<T extends IChain> = ChainSpecificParams<StreamClientType<T>, ITopUpStreamSolanaExt, ITransactionAptosExt, ITransactionSuiExt>;
45
+ type TopupSpecificParams<T extends IChain> = ChainSpecificParams<StreamClientType<T>, ITopUpStreamSolanaExt, ITransactionAptosExt, ITransactionSuiExt>;
46
46
  /** Type referencing additional parameters used on other interactions by a Chain Client */
47
- declare type InteractSpecificParams<T extends IChain> = ChainSpecificParams<StreamClientType<T>, IInteractStreamSolanaExt, ITransactionAptosExt, ITransactionSuiExt>;
47
+ type InteractSpecificParams<T extends IChain> = ChainSpecificParams<StreamClientType<T>, IInteractStreamSolanaExt, ITransactionAptosExt, ITransactionSuiExt>;
48
48
  /** Generic Stream Client implementation that wrap Chain Client methods and enriches error messages if possible
49
49
  * @property {StreamClientType} - Chain Client implementation
50
50
  * @property {chain} - Chain
@@ -64,7 +64,7 @@ export default class GenericStreamClient<T extends IChain> extends BaseStreamCli
64
64
  /**
65
65
  * Attempts withdrawing from the specified stream.
66
66
  */
67
- withdraw(withdrawData: IWithdrawData, chainSpecificParams?: InteractSpecificParams<T>): Promise<ITransactionResult>;
67
+ withdraw({ id, amount }: IWithdrawData, chainSpecificParams?: InteractSpecificParams<T>): Promise<ITransactionResult>;
68
68
  /**
69
69
  * Attempts canceling the specified stream.
70
70
  */
@@ -22,6 +22,7 @@ var aptos_1 = require("../aptos");
22
22
  var evm_1 = require("../evm");
23
23
  var solana_1 = require("../solana");
24
24
  var sui_1 = require("../sui");
25
+ var constants_1 = require("./constants");
25
26
  /** Generic Stream Client implementation that wrap Chain Client methods and enriches error messages if possible
26
27
  * @property {StreamClientType} - Chain Client implementation
27
28
  * @property {chain} - Chain
@@ -65,9 +66,10 @@ var GenericStreamClient = /** @class */ (function (_super) {
65
66
  /**
66
67
  * Attempts withdrawing from the specified stream.
67
68
  */
68
- GenericStreamClient.prototype.withdraw = function (withdrawData, chainSpecificParams) {
69
+ GenericStreamClient.prototype.withdraw = function (_a, chainSpecificParams) {
69
70
  var _this = this;
70
- return (0, utils_1.handleContractError)(function () { return _this.nativeStreamClient.withdraw(withdrawData, chainSpecificParams); }, this.nativeStreamClient.extractErrorCode);
71
+ var id = _a.id, _b = _a.amount, amount = _b === void 0 ? constants_1.WITHDRAW_AVAILABLE_AMOUNT : _b;
72
+ return (0, utils_1.handleContractError)(function () { return _this.nativeStreamClient.withdraw({ id: id, amount: amount }, chainSpecificParams); }, this.nativeStreamClient.extractErrorCode);
71
73
  };
72
74
  /**
73
75
  * Attempts canceling the specified stream.
@@ -1 +1,3 @@
1
+ import BN from "bn.js";
1
2
  export declare const BASE_FEE = 1009900;
3
+ export declare const WITHDRAW_AVAILABLE_AMOUNT: BN;
@@ -1,4 +1,9 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BASE_FEE = void 0;
6
+ exports.WITHDRAW_AVAILABLE_AMOUNT = exports.BASE_FEE = void 0;
7
+ var bn_js_1 = __importDefault(require("bn.js"));
4
8
  exports.BASE_FEE = 1009900; // Buffer to include usual fees when calculating stream amount
9
+ exports.WITHDRAW_AVAILABLE_AMOUNT = new bn_js_1.default("18446744073709551615"); // Magical number to withdraw all available amount from a Contract
@@ -24,34 +24,29 @@ export interface IStreamConfig {
24
24
  canUpdateRate?: boolean;
25
25
  partner?: string;
26
26
  }
27
- export declare type ICreateStreamData = IStreamConfig & IRecipient;
28
- export declare type ICreateMultipleStreamData = IStreamConfig & {
27
+ export type ICreateStreamData = IStreamConfig & IRecipient;
28
+ export type ICreateMultipleStreamData = IStreamConfig & {
29
29
  recipients: IRecipient[];
30
30
  };
31
- export interface IWithdrawData {
31
+ export interface IInteractData {
32
32
  id: string;
33
- amount: BN;
34
33
  }
35
- export interface IUpdateData {
36
- id: string;
34
+ export interface IWithdrawData extends IInteractData {
35
+ amount?: BN;
36
+ }
37
+ export interface IUpdateData extends IInteractData {
37
38
  enableAutomaticWithdrawal?: boolean;
38
39
  withdrawFrequency?: BN;
39
40
  amountPerPeriod?: BN;
40
41
  }
41
- export interface ICancelData {
42
- id: string;
43
- }
44
- export interface ITransferData {
45
- id: string;
42
+ export type ICancelData = IInteractData;
43
+ export interface ITransferData extends IInteractData {
46
44
  newRecipient: string;
47
45
  }
48
- export interface ITopUpData {
49
- id: string;
46
+ export interface ITopUpData extends IInteractData {
50
47
  amount: BN;
51
48
  }
52
- export interface IGetOneData {
53
- id: string;
54
- }
49
+ export type IGetOneData = IInteractData;
55
50
  export interface IGetFeesData {
56
51
  address: string;
57
52
  }
@@ -65,7 +60,7 @@ export interface ICreateMultiError {
65
60
  error: string;
66
61
  contractErrorCode?: string;
67
62
  }
68
- declare type MetadataId = string;
63
+ type MetadataId = string;
69
64
  export interface ITransactionResult {
70
65
  ixs: (TransactionInstruction | Types.TransactionPayload)[];
71
66
  txId: string;
@@ -23,20 +23,20 @@ var ICluster;
23
23
  ICluster["Devnet"] = "devnet";
24
24
  ICluster["Testnet"] = "testnet";
25
25
  ICluster["Local"] = "local";
26
- })(ICluster = exports.ICluster || (exports.ICluster = {}));
26
+ })(ICluster || (exports.ICluster = ICluster = {}));
27
27
  var StreamDirection;
28
28
  (function (StreamDirection) {
29
29
  StreamDirection["Outgoing"] = "outgoing";
30
30
  StreamDirection["Incoming"] = "incoming";
31
31
  StreamDirection["All"] = "all";
32
- })(StreamDirection = exports.StreamDirection || (exports.StreamDirection = {}));
32
+ })(StreamDirection || (exports.StreamDirection = StreamDirection = {}));
33
33
  var StreamType;
34
34
  (function (StreamType) {
35
35
  StreamType["All"] = "all";
36
36
  StreamType["Payment"] = "payment";
37
37
  StreamType["Vesting"] = "vesting";
38
38
  StreamType["Lock"] = "lock";
39
- })(StreamType = exports.StreamType || (exports.StreamType = {}));
39
+ })(StreamType || (exports.StreamType = StreamType = {}));
40
40
  var IChain;
41
41
  (function (IChain) {
42
42
  IChain["Solana"] = "Solana";
@@ -45,7 +45,7 @@ var IChain;
45
45
  IChain["BNB"] = "BNB";
46
46
  IChain["Polygon"] = "Polygon";
47
47
  IChain["Sui"] = "Sui";
48
- })(IChain = exports.IChain || (exports.IChain = {}));
48
+ })(IChain || (exports.IChain = IChain = {}));
49
49
  /**
50
50
  * Error codes raised by all protocols except for Solana
51
51
  */
@@ -85,7 +85,7 @@ var ContractErrorCode;
85
85
  ContractErrorCode["ENOTPAUSED"] = "ENOTPAUSED";
86
86
  /** Aptos: user opt out from direct coin transfers feature and has not coin wallet registered */
87
87
  ContractErrorCode["ENO_RECIPIENT_COIN_ADDRESS"] = "ENO_RECIPIENT_COIN_ADDRESS";
88
- })(ContractErrorCode = exports.ContractErrorCode || (exports.ContractErrorCode = {}));
88
+ })(ContractErrorCode || (exports.ContractErrorCode = ContractErrorCode = {}));
89
89
  /**
90
90
  * Error codes raised by Solana protocol specifically
91
91
  */
@@ -137,7 +137,7 @@ var SolanaContractErrorCode;
137
137
  SolanaContractErrorCode["NotPaused"] = "NotPaused";
138
138
  /** Meta account is not rent exempt */
139
139
  SolanaContractErrorCode["MetadataNotRentExempt"] = "MetadataNotRentExempt";
140
- })(SolanaContractErrorCode = exports.SolanaContractErrorCode || (exports.SolanaContractErrorCode = {}));
140
+ })(SolanaContractErrorCode || (exports.SolanaContractErrorCode = SolanaContractErrorCode = {}));
141
141
  /**
142
142
  * Error wrapper for calls made to the contract on chain
143
143
  */
@@ -149,7 +149,7 @@ var ContractError = /** @class */ (function (_super) {
149
149
  * @param code extracted code from the error if managed to parse it
150
150
  */
151
151
  function ContractError(error, code) {
152
- var _this = _super.call(this, error.message) || this;
152
+ var _this = _super.call(this, error.message) || this; // Call the base class constructor with the error message
153
153
  _this.contractErrorCode = code !== null && code !== void 0 ? code : null;
154
154
  // Copy properties from the original error
155
155
  Object.setPrototypeOf(_this, ContractError.prototype);
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  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;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -11,7 +11,7 @@ export default class EvmStreamClient extends BaseStreamClient {
11
11
  constructor(clusterUrl: string, chain: IChain, signer: ethers.Signer, cluster?: ICluster, programId?: string);
12
12
  create(streamData: ICreateStreamData): Promise<ICreateResult>;
13
13
  createMultiple(multipleStreamData: ICreateMultipleStreamData): Promise<IMultiTransactionResult>;
14
- withdraw(withdrawData: IWithdrawData): Promise<ITransactionResult>;
14
+ withdraw({ id, amount, }: IWithdrawData): Promise<ITransactionResult>;
15
15
  cancel(cancelData: ICancelData): Promise<ITransactionResult>;
16
16
  transfer(transferData: ITransferData): Promise<ITransactionResult>;
17
17
  topup(topupData: ITopUpData): Promise<ITransactionResult>;
@@ -40,7 +40,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
40
40
  function verb(n) { return function (v) { return step([n, v]); }; }
41
41
  function step(op) {
42
42
  if (f) throw new TypeError("Generator is already executing.");
43
- while (_) try {
43
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
44
44
  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;
45
45
  if (y = 0, t) op = [op[0] & 2, t.value];
46
46
  switch (op[0]) {
@@ -226,14 +226,15 @@ var EvmStreamClient = /** @class */ (function (_super) {
226
226
  });
227
227
  });
228
228
  };
229
- EvmStreamClient.prototype.withdraw = function (withdrawData) {
229
+ EvmStreamClient.prototype.withdraw = function (_a) {
230
+ var id = _a.id, _b = _a.amount, amount = _b === void 0 ? constants_2.WITHDRAW_AVAILABLE_AMOUNT : _b;
230
231
  return __awaiter(this, void 0, void 0, function () {
231
232
  var result;
232
- return __generator(this, function (_a) {
233
- switch (_a.label) {
234
- case 0: return [4 /*yield*/, this.writeContract.withdraw(withdrawData.id, withdrawData.amount.toString())];
233
+ return __generator(this, function (_c) {
234
+ switch (_c.label) {
235
+ case 0: return [4 /*yield*/, this.writeContract.withdraw(id, amount.toString())];
235
236
  case 1:
236
- result = _a.sent();
237
+ result = _c.sent();
237
238
  return [2 /*return*/, {
238
239
  ixs: [],
239
240
  txId: result.hash,
@@ -1,5 +1,5 @@
1
- import { Connection, Commitment, ConnectionConfig } from "@solana/web3.js";
2
- import { ICreateStreamSolanaExt, IInteractStreamSolanaExt, ITopUpStreamSolanaExt } from "./types";
1
+ import { Connection, Keypair, PublicKey, TransactionInstruction, Commitment, ConnectionConfig } from "@solana/web3.js";
2
+ import { ICreateStreamSolanaExt, IInteractStreamSolanaExt, ITopUpStreamSolanaExt, ITransactionSolanaExt } from "./types";
3
3
  import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetAllData, IGetFeesData, IGetOneData, IFees, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData, Stream } from "../common/types";
4
4
  import { BaseStreamClient } from "../common/BaseStreamClient";
5
5
  export default class SolanaStreamClient extends BaseStreamClient {
@@ -11,12 +11,22 @@ export default class SolanaStreamClient extends BaseStreamClient {
11
11
  */
12
12
  constructor(clusterUrl: string, cluster?: ICluster, commitment?: Commitment | ConnectionConfig, programId?: string);
13
13
  getConnection(): Connection;
14
+ getCommitment(): Commitment | undefined;
14
15
  getProgramId(): string;
15
16
  /**
16
17
  * Creates a new stream/vesting contract.
17
18
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
18
19
  */
19
- create({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, }: ICreateStreamData, { sender, metadataPubKeys, isNative }: ICreateStreamSolanaExt): Promise<ICreateResult>;
20
+ create(data: ICreateStreamData, extensions: ICreateStreamSolanaExt): Promise<ICreateResult>;
21
+ /**
22
+ * Creates a new stream/vesting contract.
23
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
24
+ */
25
+ 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<{
26
+ ixs: TransactionInstruction[];
27
+ metadata: Keypair | undefined;
28
+ metadataPubKey: PublicKey;
29
+ }>;
20
30
  /**
21
31
  * Creates a new stream/vesting contract using unchecked instruction.
22
32
  *
@@ -27,7 +37,15 @@ export default class SolanaStreamClient extends BaseStreamClient {
27
37
  *
28
38
  * If you are not sure if you should use create or create_unchecked, go for create to be safer.
29
39
  */
30
- createUnchecked({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, }: ICreateStreamData, { sender, metadataPubKeys, isNative }: ICreateStreamSolanaExt): Promise<ICreateResult>;
40
+ createUnchecked(data: ICreateStreamData, extensions: ICreateStreamSolanaExt): Promise<ICreateResult>;
41
+ /**
42
+ * Create Transaction instructions for `createUnchecked`
43
+ */
44
+ 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<{
45
+ ixs: TransactionInstruction[];
46
+ metadata: Keypair | undefined;
47
+ metadataPubKey: PublicKey;
48
+ }>;
31
49
  /**
32
50
  * Creates multiple stream/vesting contracts.
33
51
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
@@ -37,19 +55,36 @@ export default class SolanaStreamClient extends BaseStreamClient {
37
55
  * Attempts withdrawing from the specified stream.
38
56
  */
39
57
  withdraw({ id, amount }: IWithdrawData, { invoker, checkTokenAccounts }: IInteractStreamSolanaExt): Promise<ITransactionResult>;
58
+ /**
59
+ * Creates Transaction Instructions for withdrawal
60
+ */
61
+ prepareWithdawInstructions({ id, amount }: IWithdrawData, { invoker, checkTokenAccounts, computePrice, computeLimit }: IInteractStreamSolanaExt): Promise<TransactionInstruction[]>;
40
62
  /**
41
63
  * Attempts canceling the specified stream.
42
64
  */
43
- cancel({ id }: ICancelData, { invoker, checkTokenAccounts }: IInteractStreamSolanaExt): Promise<ITransactionResult>;
65
+ cancel({ id }: ICancelData, extensions: IInteractStreamSolanaExt): Promise<ITransactionResult>;
66
+ /**
67
+ * Creates Transaction Instructions for cancel
68
+ */
69
+ prepareCancelInstructions({ id }: ICancelData, { invoker, checkTokenAccounts, computePrice, computeLimit }: IInteractStreamSolanaExt): Promise<TransactionInstruction[]>;
70
+ /**
71
+ * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
72
+ * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
73
+ */
74
+ transfer({ id, newRecipient }: ITransferData, extensions: IInteractStreamSolanaExt): Promise<ITransactionResult>;
44
75
  /**
45
76
  * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
46
77
  * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
47
78
  */
48
- transfer({ id, newRecipient: newRecipientString }: ITransferData, { invoker }: IInteractStreamSolanaExt): Promise<ITransactionResult>;
79
+ prepareTransferInstructions({ id, newRecipient }: ITransferData, { invoker, computePrice, computeLimit }: IInteractStreamSolanaExt): Promise<TransactionInstruction[]>;
49
80
  /**
50
81
  * Tops up stream account with specified amount.
51
82
  */
52
- topup({ id, amount }: ITopUpData, { invoker, isNative }: ITopUpStreamSolanaExt): Promise<ITransactionResult>;
83
+ topup({ id, amount }: ITopUpData, extensions: ITopUpStreamSolanaExt): Promise<ITransactionResult>;
84
+ /**
85
+ * Create Transaction instructions for topup
86
+ */
87
+ prepareTopupInstructions({ id, amount }: ITopUpData, { invoker, isNative, computePrice, computeLimit }: ITopUpStreamSolanaExt): Promise<TransactionInstruction[]>;
53
88
  /**
54
89
  * Fetch stream data by its id (address).
55
90
  */
@@ -62,7 +97,11 @@ export default class SolanaStreamClient extends BaseStreamClient {
62
97
  /**
63
98
  * Attempts updating the stream auto withdrawal params and amount per period
64
99
  */
65
- update(data: IUpdateData, { invoker }: IInteractStreamSolanaExt): Promise<ITransactionResult>;
100
+ update(data: IUpdateData, extensions: IInteractStreamSolanaExt): Promise<ITransactionResult>;
101
+ /**
102
+ * Create Transaction instructions for update
103
+ */
104
+ prepareUpdateInstructions(data: IUpdateData, { invoker, computePrice, computeLimit }: IInteractStreamSolanaExt): Promise<TransactionInstruction[]>;
66
105
  getFees({ address }: IGetFeesData): Promise<IFees | null>;
67
106
  getDefaultStreamflowFee(): Promise<number>;
68
107
  extractErrorCode(err: Error): string | null;
@@ -71,11 +110,17 @@ export default class SolanaStreamClient extends BaseStreamClient {
71
110
  */
72
111
  private prepareStreamInstructions;
73
112
  /**
74
- * Utility function that checks whether associated token accounts still exist and adds instructions to add them if not
113
+ * Create Base instructions for Solana
114
+ * - sets compute price if `computePrice` is provided
115
+ * - sets compute limit if `computeLimit` is provided
75
116
  */
76
- private checkAssociatedTokenAccounts;
117
+ prepareBaseInstructions({ computePrice, computeLimit, }: ITransactionSolanaExt): TransactionInstruction[];
77
118
  /**
78
119
  * Utility function to generate metadata for a Contract or return existing Pubkey
79
120
  */
80
121
  private getOrCreateStreamMetadata;
122
+ /**
123
+ * Utility function that checks whether associated token accounts still exist and adds instructions to add them if not
124
+ */
125
+ private checkAssociatedTokenAccounts;
81
126
  }