@streamflow/stream 3.0.0-test.4 → 3.0.1-3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Stream.js CHANGED
@@ -84,11 +84,11 @@ var web3_js_1 = require("@solana/web3.js");
84
84
  var types_1 = require("./types");
85
85
  var utils_1 = require("./utils");
86
86
  var constants_1 = require("./constants");
87
- var idl_1 = __importDefault(require("./idl"));
87
+ var timelock_1 = __importDefault(require("./idl/timelock"));
88
88
  var encoder = new TextEncoder();
89
89
  var initProgram = function (connection, wallet, cluster) {
90
90
  var provider = new anchor_1.Provider(connection, wallet, {});
91
- return new anchor_1.Program(idl_1.default, constants_1.PROGRAM_ID[cluster], provider);
91
+ return new anchor_1.Program(timelock_1.default, constants_1.PROGRAM_ID[cluster], provider);
92
92
  };
93
93
  var Stream = /** @class */ (function () {
94
94
  function Stream() {
@@ -410,7 +410,7 @@ var Stream = /** @class */ (function () {
410
410
  if (!(escrow === null || escrow === void 0 ? void 0 : escrow.data)) {
411
411
  throw new Error("Couldn't get account info.");
412
412
  }
413
- return [2 /*return*/, (0, utils_1.formatDecodedStream)((0, utils_1.decodeStream)(escrow === null || escrow === void 0 ? void 0 : escrow.data))];
413
+ return [2 /*return*/, new types_1.Contract((0, utils_1.decodeStream)(escrow === null || escrow === void 0 ? void 0 : escrow.data))];
414
414
  }
415
415
  });
416
416
  });
@@ -454,7 +454,7 @@ var Stream = /** @class */ (function () {
454
454
  streams = {};
455
455
  accounts.forEach(function (account) {
456
456
  var _a;
457
- var decoded = (0, utils_1.formatDecodedStream)((0, utils_1.decodeStream)(account.account.data));
457
+ var decoded = new types_1.Contract((0, utils_1.decodeStream)(account.account.data));
458
458
  streams = __assign(__assign({}, streams), (_a = {}, _a[account.pubkey.toBase58()] = decoded, _a));
459
459
  });
460
460
  sortedStreams = Object.entries(streams).sort(function (_a, _b) {
@@ -9,8 +9,9 @@ export default class StreamClient {
9
9
  /**
10
10
  * Create Stream instance
11
11
  */
12
- constructor(clusterUrl: string, cluster?: ClusterExtended, commitment?: Commitment | ConnectionConfig);
12
+ constructor(clusterUrl: string, cluster?: ClusterExtended, commitment?: Commitment | ConnectionConfig, programId?: string);
13
13
  getConnection(): web3.Connection;
14
+ getProgramId(): string;
14
15
  /**
15
16
  * Creates a new stream/vesting contract.
16
17
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
@@ -32,9 +33,42 @@ export default class StreamClient {
32
33
  * @param {boolean} data.transferableByRecipient - Whether or not recipient can transfer the stream.
33
34
  * @param {boolean} data.automaticWithdrawal - Whether or not a 3rd party can initiate withdraw in the name of recipient.
34
35
  * @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.
36
+ * @param {boolean} [data.isNative = false] - When true Automatically wraps SOLs to WrappedSOL and creates wSOL stream
35
37
  * @param {string | null} [data.partner = null] - Partner's wallet address (optional).
36
38
  */
37
- create({ sender, recipient, mint, start, depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, }: CreateParams): Promise<CreateResponse>;
39
+ create({ sender, recipient, mint, start, depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, isNative, }: CreateParams): Promise<CreateResponse>;
40
+ /**
41
+ * Creates a new stream/vesting contract using unchecked instruction.
42
+ *
43
+ * Unchecked instruction differes from the regular in:
44
+ * - does not check for initialized associated token account (wallets with no control over their ATA should not be used
45
+ * as sender/recipient/partner or there are risks of funds being locked in the contract)
46
+ * - initialized contract PDA off chain
47
+ *
48
+ * If you are not sure if you should use create or create_unchecked, go for create to be safer.
49
+ *
50
+ * @param {CreateParams} data
51
+ * @param {Wallet | Keypair} data.sender - Wallet signing the transaction. Its address should match the authorized wallet (sender) or transaction will fail.
52
+ * @param {string} data.recipient - Solana address of the recipient. Associated token account will be derived using this address and token mint address.
53
+ * @param {string} data.mint - SPL Token mint.
54
+ * @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
55
+ * @param {BN} data.depositedAmount - Initially deposited amount of tokens (in the smallest units).
56
+ * @param {number} data.period - Time step (period) in seconds per which the unlocking occurs.
57
+ * @param {number} data.cliff - Vesting contract "cliff" timestamp in seconds.
58
+ * @param {BN} data.cliffAmount - Amount unlocked at the "cliff".
59
+ * @param {BN} data.amountPerPeriod - Amount unlocked per each period.
60
+ * @param {string} data.name - Stream name/subject.
61
+ * @param {boolean} data.canTopup - TRUE for streams, FALSE for vesting contracts.
62
+ * @param {boolean} data.cancelableBySender - Whether or not sender can cancel the stream.
63
+ * @param {boolean} data.cancelableByRecipient - Whether or not recipient can cancel the stream.
64
+ * @param {boolean} data.transferableBySender - Whether or not sender can transfer the stream.
65
+ * @param {boolean} data.transferableByRecipient - Whether or not recipient can transfer the stream.
66
+ * @param {boolean} data.automaticWithdrawal - Whether or not a 3rd party can initiate withdraw in the name of recipient.
67
+ * @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.
68
+ * @param {boolean} [data.isNative = false] - When true Automatically wraps SOLs to WrappedSOL and creates wSOL stream
69
+ * @param {string | null} [data.partner = null] - Partner's wallet address (optional).
70
+ */
71
+ createUnchecked({ sender, recipient, mint, start, depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, isNative, }: CreateParams): Promise<CreateResponse>;
38
72
  /**
39
73
  * Creates a new stream/vesting contract.
40
74
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
@@ -45,8 +79,6 @@ export default class StreamClient {
45
79
  * @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
46
80
  * @param {number} data.period - Time step (period) in seconds per which the unlocking occurs.
47
81
  * @param {number} data.cliff - Vesting contract "cliff" timestamp in seconds.
48
- * @param {BN} data.cliffAmount - Amount unlocked at the "cliff".
49
- * @param {BN} data.amountPerPeriod - Amount unlocked per each period.
50
82
  * @param {boolean} data.canTopup - TRUE for streams, FALSE for vesting contracts.
51
83
  * @param {boolean} data.cancelableBySender - Whether or not sender can cancel the stream.
52
84
  * @param {boolean} data.cancelableByRecipient - Whether or not recipient can cancel the stream.
@@ -54,9 +86,10 @@ export default class StreamClient {
54
86
  * @param {boolean} data.transferableByRecipient - Whether or not recipient can transfer the stream.
55
87
  * @param {boolean} data.automaticWithdrawal - Whether or not a 3rd party can initiate withdraw in the name of recipient.
56
88
  * @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.
89
+ * @param {boolean} [data.isNative = false] - When true Automatically wraps SOLs to WrappedSOL and creates wSOL stream
57
90
  * @param {string | null} [data.partner = null] - Partner's wallet address (optional).
58
91
  */
59
- createMultiple({ sender, recipientsData, mint, start, period, cliff, cliffAmount, amountPerPeriod, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, }: CreateMultiParams): Promise<CreateMultiResponse>;
92
+ createMultiple(data: CreateMultiParams): Promise<CreateMultiResponse>;
60
93
  /**
61
94
  * Attempts withdrawal from the specified stream.
62
95
  * @param {WithdrawParams} data
@@ -88,7 +121,7 @@ export default class StreamClient {
88
121
  * @param {string} data.id - Identifier of a stream (escrow account with metadata) to be topped up.
89
122
  * @param {BN} data.amount - Specified amount (in the smallest units) to topup (increases deposited amount).
90
123
  */
91
- topup({ invoker, id, amount, }: TopupParams): Promise<TxResponse>;
124
+ topup({ invoker, id, amount, isNative, }: TopupParams): Promise<TxResponse>;
92
125
  /**
93
126
  * Fetch stream data by its id (address).
94
127
  * @param {string} id - Identifier of a stream that is fetched.
@@ -104,4 +137,10 @@ export default class StreamClient {
104
137
  */
105
138
  get({ wallet, type, direction, }: GetAllParams): Promise<[string, StreamData][]>;
106
139
  private sign;
140
+ /**
141
+ * Forms instructions from params, creates a raw transaction and fetch recent blockhash.
142
+ * @param {MultiRecipient} recipient - Wallet sending stream to
143
+ * @param {CreateMultiParams} streamParams - Parameters of stream user wants to create.
144
+ */
145
+ private prepareStreamTransaction;
107
146
  }