@streamflow/stream 2.0.2-beta.24 → 2.0.2-test.11
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/{sdk.d.ts → Stream.d.ts} +27 -25
- package/dist/Stream.js +503 -0
- package/dist/StreamClient.d.ts +107 -0
- package/dist/{sdk.js → StreamClient.js} +252 -78
- package/dist/constants.d.ts +2 -1
- package/dist/constants.js +3 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +5 -3
- package/dist/types.d.ts +72 -3
- package/package.json +1 -1
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { web3 } from "@project-serum/anchor";
|
|
2
|
+
import { Commitment, ConnectionConfig } from "@solana/web3.js";
|
|
3
|
+
import { Stream as StreamData, CreateParams, CreateMultiParams, WithdrawParams, TopupParams, CancelParams, TransferParams, ClusterExtended, GetAllParams, CreateResponse, CreateMultiResponse, TxResponse } from "./types";
|
|
4
|
+
export default class StreamClient {
|
|
5
|
+
private connection;
|
|
6
|
+
private cluster;
|
|
7
|
+
private programId;
|
|
8
|
+
private commitment;
|
|
9
|
+
/**
|
|
10
|
+
* Create Stream instance
|
|
11
|
+
*/
|
|
12
|
+
constructor(clusterUrl: string, cluster?: ClusterExtended, commitment?: Commitment | ConnectionConfig);
|
|
13
|
+
getConnection(): web3.Connection;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new stream/vesting contract.
|
|
16
|
+
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
17
|
+
* @param {CreateParams} data
|
|
18
|
+
* @param {Wallet | Keypair} data.sender - Wallet signing the transaction. Its address should match the authorized wallet (sender) or transaction will fail.
|
|
19
|
+
* @param {string} data.recipient - Solana address of the recipient. Associated token account will be derived using this address and token mint address.
|
|
20
|
+
* @param {string} data.mint - SPL Token mint.
|
|
21
|
+
* @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
|
|
22
|
+
* @param {u64} data.depositedAmount - Initially deposited amount of tokens (in the smallest units).
|
|
23
|
+
* @param {number} data.period - Time step (period) in seconds per which the unlocking occurs.
|
|
24
|
+
* @param {number} data.cliff - Vesting contract "cliff" timestamp in seconds.
|
|
25
|
+
* @param {u64} data.cliffAmount - Amount unlocked at the "cliff".
|
|
26
|
+
* @param {u64} data.amountPerPeriod - Amount unlocked per each period.
|
|
27
|
+
* @param {string} data.name - Stream name/subject.
|
|
28
|
+
* @param {boolean} data.canTopup - TRUE for streams, FALSE for vesting contracts.
|
|
29
|
+
* @param {boolean} data.cancelableBySender - Whether or not sender can cancel the stream.
|
|
30
|
+
* @param {boolean} data.cancelableByRecipient - Whether or not recipient can cancel the stream.
|
|
31
|
+
* @param {boolean} data.transferableBySender - Whether or not sender can transfer the stream.
|
|
32
|
+
* @param {boolean} data.transferableByRecipient - Whether or not recipient can transfer the stream.
|
|
33
|
+
* @param {boolean} data.automaticWithdrawal - Whether or not a 3rd party can initiate withdraw in the name of recipient.
|
|
34
|
+
* @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.
|
|
35
|
+
* @param {string | null} [data.partner = null] - Partner's wallet address (optional).
|
|
36
|
+
*/
|
|
37
|
+
create({ sender, recipient, mint, start, depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, }: CreateParams): Promise<CreateResponse>;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a new stream/vesting contract.
|
|
40
|
+
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
41
|
+
* @param {CreateMultiParams} data
|
|
42
|
+
* @param {Wallet | Keypair} data.sender - Wallet signing the transaction. Its address should match the authorized wallet (sender) or transaction will fail.
|
|
43
|
+
* @param {MultiRecipient[]} data.recipientsData
|
|
44
|
+
* @param {string} data.mint - SPL Token mint.
|
|
45
|
+
* @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
|
|
46
|
+
* @param {number} data.period - Time step (period) in seconds per which the unlocking occurs.
|
|
47
|
+
* @param {number} data.cliff - Vesting contract "cliff" timestamp in seconds.
|
|
48
|
+
* @param {u64} data.cliffAmount - Amount unlocked at the "cliff".
|
|
49
|
+
* @param {u64} data.amountPerPeriod - Amount unlocked per each period.
|
|
50
|
+
* @param {boolean} data.canTopup - TRUE for streams, FALSE for vesting contracts.
|
|
51
|
+
* @param {boolean} data.cancelableBySender - Whether or not sender can cancel the stream.
|
|
52
|
+
* @param {boolean} data.cancelableByRecipient - Whether or not recipient can cancel the stream.
|
|
53
|
+
* @param {boolean} data.transferableBySender - Whether or not sender can transfer the stream.
|
|
54
|
+
* @param {boolean} data.transferableByRecipient - Whether or not recipient can transfer the stream.
|
|
55
|
+
* @param {boolean} data.automaticWithdrawal - Whether or not a 3rd party can initiate withdraw in the name of recipient.
|
|
56
|
+
* @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.
|
|
57
|
+
* @param {string | null} [data.partner = null] - Partner's wallet address (optional).
|
|
58
|
+
*/
|
|
59
|
+
createMultiple({ sender, recipientsData, mint, start, period, cliff, cliffAmount, amountPerPeriod, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, }: CreateMultiParams): Promise<CreateMultiResponse>;
|
|
60
|
+
/**
|
|
61
|
+
* Attempts withdrawal from the specified stream.
|
|
62
|
+
* @param {WithdrawParams} data
|
|
63
|
+
* @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (recipient) or transaction will fail.
|
|
64
|
+
* @param {string} data.id - Identifier of a stream (escrow account with metadata) to be withdrawn from.
|
|
65
|
+
* @param {u64} data.amount - Requested amount (in the smallest units) to withdraw (while streaming). If stream is completed, the whole amount will be withdrawn.
|
|
66
|
+
*/
|
|
67
|
+
withdraw({ invoker, id, amount, }: WithdrawParams): Promise<TxResponse>;
|
|
68
|
+
/**
|
|
69
|
+
* Attempts canceling the specified stream.
|
|
70
|
+
* @param {CancelParams} data
|
|
71
|
+
* @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (sender or recipient) or transaction will fail.
|
|
72
|
+
* @param {string} data.id - Identifier of a stream (escrow account with metadata) to be canceled.
|
|
73
|
+
*/
|
|
74
|
+
cancel({ invoker, id }: CancelParams): Promise<TxResponse>;
|
|
75
|
+
/**
|
|
76
|
+
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
77
|
+
* Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
|
|
78
|
+
* @param {TransferParams} data
|
|
79
|
+
* @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (sender or recipient) or transaction will fail.
|
|
80
|
+
* @param {string} data.id - Identifier of a stream (escrow account with metadata) to be transferred.
|
|
81
|
+
* @param {string} data.recipientId - Address of a new recipient.
|
|
82
|
+
*/
|
|
83
|
+
transfer({ invoker, id, recipientId, }: TransferParams): Promise<TxResponse>;
|
|
84
|
+
/**
|
|
85
|
+
* Tops up stream account deposited amount.
|
|
86
|
+
* @param {TopupParams} data
|
|
87
|
+
* @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match current stream sender or transaction will fail.
|
|
88
|
+
* @param {string} data.id - Identifier of a stream (escrow account with metadata) to be topped up.
|
|
89
|
+
* @param {u64} data.amount - Specified amount (in the smallest units) to topup (increases deposited amount).
|
|
90
|
+
*/
|
|
91
|
+
topup({ invoker, id, amount, }: TopupParams): Promise<TxResponse>;
|
|
92
|
+
/**
|
|
93
|
+
* Fetch stream data by its id (address).
|
|
94
|
+
* @param {string} id - Identifier of a stream that is fetched.
|
|
95
|
+
*/
|
|
96
|
+
getOne(id: string): Promise<StreamData>;
|
|
97
|
+
/**
|
|
98
|
+
* Fetch streams/contracts by providing direction.
|
|
99
|
+
* Streams are sorted by start time in ascending order.
|
|
100
|
+
* @param {GetAllParams} data
|
|
101
|
+
* @param {PublicKey} data.wallet - PublicKey of the wallet for which the streams/contracts are fetched.
|
|
102
|
+
* @param {StreamType} [data.type = StreamType.All] - It can be one of: stream, vesting, all.
|
|
103
|
+
* @param {StreamDirection} [data.direction = StreamDirection.All] - It can be one of: incoming, outgoing, all.
|
|
104
|
+
*/
|
|
105
|
+
get({ wallet, type, direction, }: GetAllParams): Promise<[string, StreamData][]>;
|
|
106
|
+
private sign;
|
|
107
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// Latest version of the SDK that does not use Anchor. It supports raw instructions.
|
|
2
3
|
var __assign = (this && this.__assign) || function () {
|
|
3
4
|
__assign = Object.assign || function(t) {
|
|
4
5
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -71,22 +72,32 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
71
72
|
}
|
|
72
73
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
73
74
|
};
|
|
75
|
+
var __values = (this && this.__values) || function(o) {
|
|
76
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
77
|
+
if (m) return m.call(o);
|
|
78
|
+
if (o && typeof o.length === "number") return {
|
|
79
|
+
next: function () {
|
|
80
|
+
if (o && i >= o.length) o = void 0;
|
|
81
|
+
return { value: o && o[i++], done: !o };
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
85
|
+
};
|
|
74
86
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
75
|
-
var anchor_1 = require("@project-serum/anchor");
|
|
76
87
|
var spl_token_1 = require("@solana/spl-token");
|
|
77
88
|
var buffer_1 = require("buffer");
|
|
89
|
+
var anchor_1 = require("@project-serum/anchor");
|
|
78
90
|
var spl_token_2 = require("@solana/spl-token");
|
|
79
91
|
var web3_js_1 = require("@solana/web3.js");
|
|
80
92
|
var types_1 = require("./types");
|
|
81
93
|
var utils_1 = require("./utils");
|
|
82
94
|
var constants_1 = require("./constants");
|
|
83
95
|
var instructions_1 = require("./instructions");
|
|
84
|
-
var
|
|
85
|
-
var Stream = /** @class */ (function () {
|
|
96
|
+
var StreamClient = /** @class */ (function () {
|
|
86
97
|
/**
|
|
87
98
|
* Create Stream instance
|
|
88
99
|
*/
|
|
89
|
-
function
|
|
100
|
+
function StreamClient(clusterUrl, cluster, commitment) {
|
|
90
101
|
if (cluster === void 0) { cluster = types_1.Cluster.Mainnet; }
|
|
91
102
|
if (commitment === void 0) { commitment = "confirmed"; }
|
|
92
103
|
this.commitment = commitment;
|
|
@@ -94,14 +105,14 @@ var Stream = /** @class */ (function () {
|
|
|
94
105
|
this.connection = new web3_js_1.Connection(clusterUrl, this.commitment);
|
|
95
106
|
this.programId = new web3_js_1.PublicKey(constants_1.PROGRAM_ID[cluster]);
|
|
96
107
|
}
|
|
97
|
-
|
|
108
|
+
StreamClient.prototype.getConnection = function () {
|
|
98
109
|
return this.connection;
|
|
99
110
|
};
|
|
100
111
|
/**
|
|
101
112
|
* Creates a new stream/vesting contract.
|
|
102
113
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
103
|
-
* @param {
|
|
104
|
-
* @param {Wallet} data.sender - Wallet signing the transaction. Its address should match the authorized wallet (sender) or transaction will fail.
|
|
114
|
+
* @param {CreateParams} data
|
|
115
|
+
* @param {Wallet | Keypair} data.sender - Wallet signing the transaction. Its address should match the authorized wallet (sender) or transaction will fail.
|
|
105
116
|
* @param {string} data.recipient - Solana address of the recipient. Associated token account will be derived using this address and token mint address.
|
|
106
117
|
* @param {string} data.mint - SPL Token mint.
|
|
107
118
|
* @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
|
|
@@ -117,38 +128,39 @@ var Stream = /** @class */ (function () {
|
|
|
117
128
|
* @param {boolean} data.transferableBySender - Whether or not sender can transfer the stream.
|
|
118
129
|
* @param {boolean} data.transferableByRecipient - Whether or not recipient can transfer the stream.
|
|
119
130
|
* @param {boolean} data.automaticWithdrawal - Whether or not a 3rd party can initiate withdraw in the name of recipient.
|
|
131
|
+
* @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.
|
|
120
132
|
* @param {string | null} [data.partner = null] - Partner's wallet address (optional).
|
|
121
133
|
*/
|
|
122
|
-
|
|
123
|
-
var sender = _a.sender, recipient = _a.recipient, mint = _a.mint, start = _a.start, depositedAmount = _a.depositedAmount, 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,
|
|
134
|
+
StreamClient.prototype.create = function (_a) {
|
|
135
|
+
var sender = _a.sender, recipient = _a.recipient, mint = _a.mint, start = _a.start, depositedAmount = _a.depositedAmount, 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, _b = _a.automaticWithdrawal, automaticWithdrawal = _b === void 0 ? false : _b, _c = _a.withdrawalFrequency, withdrawalFrequency = _c === void 0 ? 0 : _c, _d = _a.partner, partner = _d === void 0 ? null : _d;
|
|
124
136
|
return __awaiter(this, void 0, void 0, function () {
|
|
125
|
-
var ixs, mintPublicKey, recipientPublicKey, metadata,
|
|
126
|
-
var
|
|
127
|
-
return __generator(this, function (
|
|
128
|
-
switch (
|
|
137
|
+
var ixs, mintPublicKey, recipientPublicKey, metadata, _e, escrowTokens, senderTokens, recipientTokens, streamflowTreasuryTokens, partnerPublicKey, partnerTokens, commitment, hash, tx, signature;
|
|
138
|
+
var _f;
|
|
139
|
+
return __generator(this, function (_g) {
|
|
140
|
+
switch (_g.label) {
|
|
129
141
|
case 0:
|
|
130
142
|
ixs = [];
|
|
131
143
|
mintPublicKey = new web3_js_1.PublicKey(mint);
|
|
132
144
|
recipientPublicKey = new web3_js_1.PublicKey(recipient);
|
|
133
145
|
metadata = web3_js_1.Keypair.generate();
|
|
134
|
-
return [4 /*yield*/,
|
|
146
|
+
return [4 /*yield*/, web3_js_1.PublicKey.findProgramAddress([buffer_1.Buffer.from("strm"), metadata.publicKey.toBuffer()], this.programId)];
|
|
135
147
|
case 1:
|
|
136
|
-
|
|
148
|
+
_e = __read.apply(void 0, [_g.sent(), 1]), escrowTokens = _e[0];
|
|
137
149
|
return [4 /*yield*/, ata(mintPublicKey, sender.publicKey)];
|
|
138
150
|
case 2:
|
|
139
|
-
senderTokens =
|
|
151
|
+
senderTokens = _g.sent();
|
|
140
152
|
return [4 /*yield*/, ata(mintPublicKey, recipientPublicKey)];
|
|
141
153
|
case 3:
|
|
142
|
-
recipientTokens =
|
|
154
|
+
recipientTokens = _g.sent();
|
|
143
155
|
return [4 /*yield*/, ata(mintPublicKey, constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY)];
|
|
144
156
|
case 4:
|
|
145
|
-
streamflowTreasuryTokens =
|
|
157
|
+
streamflowTreasuryTokens = _g.sent();
|
|
146
158
|
partnerPublicKey = partner
|
|
147
159
|
? new web3_js_1.PublicKey(partner)
|
|
148
160
|
: constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY;
|
|
149
161
|
return [4 /*yield*/, ata(mintPublicKey, partnerPublicKey)];
|
|
150
162
|
case 5:
|
|
151
|
-
partnerTokens =
|
|
163
|
+
partnerTokens = _g.sent();
|
|
152
164
|
ixs.push((0, instructions_1.createStreamInstruction)({
|
|
153
165
|
start: new spl_token_1.u64(start),
|
|
154
166
|
depositedAmount: depositedAmount,
|
|
@@ -163,7 +175,7 @@ var Stream = /** @class */ (function () {
|
|
|
163
175
|
transferableByRecipient: transferableByRecipient,
|
|
164
176
|
canTopup: canTopup,
|
|
165
177
|
name: name,
|
|
166
|
-
withdrawFrequency: new spl_token_1.u64(period),
|
|
178
|
+
withdrawFrequency: new spl_token_1.u64(automaticWithdrawal ? withdrawalFrequency : period),
|
|
167
179
|
}, this.programId, {
|
|
168
180
|
sender: sender.publicKey,
|
|
169
181
|
senderTokens: senderTokens,
|
|
@@ -176,7 +188,7 @@ var Stream = /** @class */ (function () {
|
|
|
176
188
|
partner: partnerPublicKey,
|
|
177
189
|
partnerTokens: partnerTokens,
|
|
178
190
|
mint: new web3_js_1.PublicKey(mint),
|
|
179
|
-
feeOracle: constants_1.
|
|
191
|
+
feeOracle: constants_1.FEE_ORACLE_PUBLIC_KEY,
|
|
180
192
|
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
181
193
|
timelockProgram: this.programId,
|
|
182
194
|
tokenProgram: spl_token_2.TOKEN_PROGRAM_ID,
|
|
@@ -189,35 +201,189 @@ var Stream = /** @class */ (function () {
|
|
|
189
201
|
: this.commitment.commitment;
|
|
190
202
|
return [4 /*yield*/, this.connection.getRecentBlockhash(commitment)];
|
|
191
203
|
case 6:
|
|
192
|
-
hash =
|
|
193
|
-
tx = (
|
|
204
|
+
hash = _g.sent();
|
|
205
|
+
tx = (_f = new web3_js_1.Transaction({
|
|
194
206
|
feePayer: sender.publicKey,
|
|
195
207
|
recentBlockhash: hash.blockhash,
|
|
196
|
-
})).add.apply(
|
|
208
|
+
})).add.apply(_f, __spreadArray([], __read(ixs), false));
|
|
197
209
|
tx.partialSign(metadata);
|
|
198
|
-
return [4 /*yield*/,
|
|
210
|
+
return [4 /*yield*/, this.sign(sender, tx)];
|
|
199
211
|
case 7:
|
|
200
|
-
|
|
201
|
-
rawTx = tx.serialize();
|
|
202
|
-
return [4 /*yield*/, (0, web3_js_1.sendAndConfirmRawTransaction)(this.connection, rawTx)];
|
|
203
|
-
case 8:
|
|
204
|
-
signature = _d.sent();
|
|
212
|
+
signature = _g.sent();
|
|
205
213
|
return [2 /*return*/, { ixs: ixs, tx: signature, metadata: metadata }];
|
|
206
214
|
}
|
|
207
215
|
});
|
|
208
216
|
});
|
|
209
217
|
};
|
|
218
|
+
/**
|
|
219
|
+
* Creates a new stream/vesting contract.
|
|
220
|
+
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
221
|
+
* @param {CreateMultiParams} data
|
|
222
|
+
* @param {Wallet | Keypair} data.sender - Wallet signing the transaction. Its address should match the authorized wallet (sender) or transaction will fail.
|
|
223
|
+
* @param {MultiRecipient[]} data.recipientsData
|
|
224
|
+
* @param {string} data.mint - SPL Token mint.
|
|
225
|
+
* @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
|
|
226
|
+
* @param {number} data.period - Time step (period) in seconds per which the unlocking occurs.
|
|
227
|
+
* @param {number} data.cliff - Vesting contract "cliff" timestamp in seconds.
|
|
228
|
+
* @param {u64} data.cliffAmount - Amount unlocked at the "cliff".
|
|
229
|
+
* @param {u64} data.amountPerPeriod - Amount unlocked per each period.
|
|
230
|
+
* @param {boolean} data.canTopup - TRUE for streams, FALSE for vesting contracts.
|
|
231
|
+
* @param {boolean} data.cancelableBySender - Whether or not sender can cancel the stream.
|
|
232
|
+
* @param {boolean} data.cancelableByRecipient - Whether or not recipient can cancel the stream.
|
|
233
|
+
* @param {boolean} data.transferableBySender - Whether or not sender can transfer the stream.
|
|
234
|
+
* @param {boolean} data.transferableByRecipient - Whether or not recipient can transfer the stream.
|
|
235
|
+
* @param {boolean} data.automaticWithdrawal - Whether or not a 3rd party can initiate withdraw in the name of recipient.
|
|
236
|
+
* @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.
|
|
237
|
+
* @param {string | null} [data.partner = null] - Partner's wallet address (optional).
|
|
238
|
+
*/
|
|
239
|
+
StreamClient.prototype.createMultiple = function (_a) {
|
|
240
|
+
var sender = _a.sender, recipientsData = _a.recipientsData, mint = _a.mint, start = _a.start, period = _a.period, cliff = _a.cliff, cliffAmount = _a.cliffAmount, amountPerPeriod = _a.amountPerPeriod, canTopup = _a.canTopup, cancelableBySender = _a.cancelableBySender, cancelableByRecipient = _a.cancelableByRecipient, transferableBySender = _a.transferableBySender, transferableByRecipient = _a.transferableByRecipient, _b = _a.automaticWithdrawal, automaticWithdrawal = _b === void 0 ? false : _b, _c = _a.withdrawalFrequency, withdrawalFrequency = _c === void 0 ? 0 : _c, _d = _a.partner, partner = _d === void 0 ? null : _d;
|
|
241
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
242
|
+
var mintPublicKey, batch, commitment, recipientsData_1, recipientsData_1_1, recipient, ixs, recipientPublicKey, metadata, _e, escrowTokens, senderTokens, recipientTokens, streamflowTreasuryTokens, partnerPublicKey, partnerTokens, hash, tx, e_1_1, signed_batch, sigs, i, buf, signature;
|
|
243
|
+
var e_1, _f, _g;
|
|
244
|
+
return __generator(this, function (_h) {
|
|
245
|
+
switch (_h.label) {
|
|
246
|
+
case 0:
|
|
247
|
+
mintPublicKey = new web3_js_1.PublicKey(mint);
|
|
248
|
+
batch = [];
|
|
249
|
+
commitment = typeof this.commitment == "string"
|
|
250
|
+
? this.commitment
|
|
251
|
+
: this.commitment.commitment;
|
|
252
|
+
_h.label = 1;
|
|
253
|
+
case 1:
|
|
254
|
+
_h.trys.push([1, 11, 12, 13]);
|
|
255
|
+
recipientsData_1 = __values(recipientsData), recipientsData_1_1 = recipientsData_1.next();
|
|
256
|
+
_h.label = 2;
|
|
257
|
+
case 2:
|
|
258
|
+
if (!!recipientsData_1_1.done) return [3 /*break*/, 10];
|
|
259
|
+
recipient = recipientsData_1_1.value;
|
|
260
|
+
ixs = [];
|
|
261
|
+
recipientPublicKey = new web3_js_1.PublicKey(recipient.recipient);
|
|
262
|
+
metadata = web3_js_1.Keypair.generate();
|
|
263
|
+
return [4 /*yield*/, anchor_1.web3.PublicKey.findProgramAddress([buffer_1.Buffer.from("strm"), metadata.publicKey.toBuffer()], this.programId)];
|
|
264
|
+
case 3:
|
|
265
|
+
_e = __read.apply(void 0, [_h.sent(), 1]), escrowTokens = _e[0];
|
|
266
|
+
return [4 /*yield*/, ata(mintPublicKey, sender.publicKey)];
|
|
267
|
+
case 4:
|
|
268
|
+
senderTokens = _h.sent();
|
|
269
|
+
return [4 /*yield*/, ata(mintPublicKey, recipientPublicKey)];
|
|
270
|
+
case 5:
|
|
271
|
+
recipientTokens = _h.sent();
|
|
272
|
+
return [4 /*yield*/, ata(mintPublicKey, constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY)];
|
|
273
|
+
case 6:
|
|
274
|
+
streamflowTreasuryTokens = _h.sent();
|
|
275
|
+
partnerPublicKey = partner
|
|
276
|
+
? new web3_js_1.PublicKey(partner)
|
|
277
|
+
: constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY;
|
|
278
|
+
return [4 /*yield*/, ata(mintPublicKey, partnerPublicKey)];
|
|
279
|
+
case 7:
|
|
280
|
+
partnerTokens = _h.sent();
|
|
281
|
+
ixs.push((0, instructions_1.createStreamInstruction)({
|
|
282
|
+
start: new spl_token_1.u64(start),
|
|
283
|
+
depositedAmount: recipient.depositedAmount,
|
|
284
|
+
period: new spl_token_1.u64(period),
|
|
285
|
+
amountPerPeriod: amountPerPeriod,
|
|
286
|
+
cliff: new spl_token_1.u64(cliff),
|
|
287
|
+
cliffAmount: cliffAmount,
|
|
288
|
+
cancelableBySender: cancelableBySender,
|
|
289
|
+
cancelableByRecipient: cancelableByRecipient,
|
|
290
|
+
automaticWithdrawal: automaticWithdrawal,
|
|
291
|
+
transferableBySender: transferableBySender,
|
|
292
|
+
transferableByRecipient: transferableByRecipient,
|
|
293
|
+
canTopup: canTopup,
|
|
294
|
+
name: recipient.name,
|
|
295
|
+
withdrawFrequency: new spl_token_1.u64(automaticWithdrawal ? withdrawalFrequency : period),
|
|
296
|
+
}, this.programId, {
|
|
297
|
+
sender: sender.publicKey,
|
|
298
|
+
senderTokens: senderTokens,
|
|
299
|
+
recipient: new web3_js_1.PublicKey(recipient.recipient),
|
|
300
|
+
metadata: metadata.publicKey,
|
|
301
|
+
escrowTokens: escrowTokens,
|
|
302
|
+
recipientTokens: recipientTokens,
|
|
303
|
+
streamflowTreasury: constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY,
|
|
304
|
+
streamflowTreasuryTokens: streamflowTreasuryTokens,
|
|
305
|
+
partner: partnerPublicKey,
|
|
306
|
+
partnerTokens: partnerTokens,
|
|
307
|
+
mint: new web3_js_1.PublicKey(mint),
|
|
308
|
+
feeOracle: constants_1.FEE_ORACLE_PUBLIC_KEY,
|
|
309
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
310
|
+
timelockProgram: this.programId,
|
|
311
|
+
tokenProgram: spl_token_2.TOKEN_PROGRAM_ID,
|
|
312
|
+
associatedTokenProgram: spl_token_2.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
313
|
+
withdrawor: constants_1.WITHDRAWOR_PUBLIC_KEY,
|
|
314
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
315
|
+
}));
|
|
316
|
+
return [4 /*yield*/, this.connection.getRecentBlockhash(commitment)];
|
|
317
|
+
case 8:
|
|
318
|
+
hash = _h.sent();
|
|
319
|
+
tx = (_g = new web3_js_1.Transaction({
|
|
320
|
+
feePayer: sender.publicKey,
|
|
321
|
+
recentBlockhash: hash.blockhash,
|
|
322
|
+
})).add.apply(_g, __spreadArray([], __read(ixs), false));
|
|
323
|
+
tx.partialSign(metadata);
|
|
324
|
+
batch.push(tx);
|
|
325
|
+
_h.label = 9;
|
|
326
|
+
case 9:
|
|
327
|
+
recipientsData_1_1 = recipientsData_1.next();
|
|
328
|
+
return [3 /*break*/, 2];
|
|
329
|
+
case 10: return [3 /*break*/, 13];
|
|
330
|
+
case 11:
|
|
331
|
+
e_1_1 = _h.sent();
|
|
332
|
+
e_1 = { error: e_1_1 };
|
|
333
|
+
return [3 /*break*/, 13];
|
|
334
|
+
case 12:
|
|
335
|
+
try {
|
|
336
|
+
if (recipientsData_1_1 && !recipientsData_1_1.done && (_f = recipientsData_1.return)) _f.call(recipientsData_1);
|
|
337
|
+
}
|
|
338
|
+
finally { if (e_1) throw e_1.error; }
|
|
339
|
+
return [7 /*endfinally*/];
|
|
340
|
+
case 13:
|
|
341
|
+
if (!(sender instanceof web3_js_1.Keypair)) return [3 /*break*/, 14];
|
|
342
|
+
signed_batch = batch.map(function (t) {
|
|
343
|
+
t.partialSign(sender);
|
|
344
|
+
return t;
|
|
345
|
+
});
|
|
346
|
+
return [3 /*break*/, 17];
|
|
347
|
+
case 14:
|
|
348
|
+
if (!(sender === null || sender === void 0 ? void 0 : sender.signAllTransactions)) return [3 /*break*/, 16];
|
|
349
|
+
return [4 /*yield*/, sender.signAllTransactions(batch)];
|
|
350
|
+
case 15:
|
|
351
|
+
signed_batch = _h.sent();
|
|
352
|
+
return [3 /*break*/, 17];
|
|
353
|
+
case 16:
|
|
354
|
+
signed_batch = [];
|
|
355
|
+
_h.label = 17;
|
|
356
|
+
case 17:
|
|
357
|
+
sigs = [];
|
|
358
|
+
i = 0;
|
|
359
|
+
_h.label = 18;
|
|
360
|
+
case 18:
|
|
361
|
+
if (!(i < signed_batch.length)) return [3 /*break*/, 21];
|
|
362
|
+
buf = signed_batch[i].serialize();
|
|
363
|
+
return [4 /*yield*/, (0, web3_js_1.sendAndConfirmRawTransaction)(this.connection, buf)];
|
|
364
|
+
case 19:
|
|
365
|
+
signature = _h.sent();
|
|
366
|
+
sigs.push(signature);
|
|
367
|
+
_h.label = 20;
|
|
368
|
+
case 20:
|
|
369
|
+
i++;
|
|
370
|
+
return [3 /*break*/, 18];
|
|
371
|
+
case 21: return [2 /*return*/, { txs: sigs }];
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
});
|
|
375
|
+
};
|
|
210
376
|
/**
|
|
211
377
|
* Attempts withdrawal from the specified stream.
|
|
212
|
-
* @param {
|
|
213
|
-
* @param {Wallet} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (recipient) or transaction will fail.
|
|
378
|
+
* @param {WithdrawParams} data
|
|
379
|
+
* @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (recipient) or transaction will fail.
|
|
214
380
|
* @param {string} data.id - Identifier of a stream (escrow account with metadata) to be withdrawn from.
|
|
215
381
|
* @param {u64} data.amount - Requested amount (in the smallest units) to withdraw (while streaming). If stream is completed, the whole amount will be withdrawn.
|
|
216
382
|
*/
|
|
217
|
-
|
|
383
|
+
StreamClient.prototype.withdraw = function (_a) {
|
|
218
384
|
var invoker = _a.invoker, id = _a.id, amount = _a.amount;
|
|
219
385
|
return __awaiter(this, void 0, void 0, function () {
|
|
220
|
-
var ixs, streamPublicKey, escrow, data, streamflowTreasuryTokens, partnerTokens, commitment, hash, tx,
|
|
386
|
+
var ixs, streamPublicKey, escrow, data, streamflowTreasuryTokens, partnerTokens, commitment, hash, tx, signature;
|
|
221
387
|
var _b;
|
|
222
388
|
return __generator(this, function (_c) {
|
|
223
389
|
switch (_c.label) {
|
|
@@ -260,11 +426,8 @@ var Stream = /** @class */ (function () {
|
|
|
260
426
|
feePayer: invoker.publicKey,
|
|
261
427
|
recentBlockhash: hash.blockhash,
|
|
262
428
|
})).add.apply(_b, __spreadArray([], __read(ixs), false));
|
|
263
|
-
return [4 /*yield*/,
|
|
429
|
+
return [4 /*yield*/, this.sign(invoker, tx)];
|
|
264
430
|
case 5:
|
|
265
|
-
signedAndSerializedTx = (_c.sent()).serialize();
|
|
266
|
-
return [4 /*yield*/, (0, web3_js_1.sendAndConfirmRawTransaction)(this.connection, signedAndSerializedTx)];
|
|
267
|
-
case 6:
|
|
268
431
|
signature = _c.sent();
|
|
269
432
|
return [2 /*return*/, { ixs: ixs, tx: signature }];
|
|
270
433
|
}
|
|
@@ -273,14 +436,14 @@ var Stream = /** @class */ (function () {
|
|
|
273
436
|
};
|
|
274
437
|
/**
|
|
275
438
|
* Attempts canceling the specified stream.
|
|
276
|
-
* @param {
|
|
277
|
-
* @param {Wallet} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (sender or recipient) or transaction will fail.
|
|
439
|
+
* @param {CancelParams} data
|
|
440
|
+
* @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (sender or recipient) or transaction will fail.
|
|
278
441
|
* @param {string} data.id - Identifier of a stream (escrow account with metadata) to be canceled.
|
|
279
442
|
*/
|
|
280
|
-
|
|
443
|
+
StreamClient.prototype.cancel = function (_a) {
|
|
281
444
|
var invoker = _a.invoker, id = _a.id;
|
|
282
445
|
return __awaiter(this, void 0, void 0, function () {
|
|
283
|
-
var streamPublicKey, escrow_acc, data, streamflowTreasuryTokens, partnerTokens, ixs, commitment, hash, tx,
|
|
446
|
+
var streamPublicKey, escrow_acc, data, streamflowTreasuryTokens, partnerTokens, ixs, commitment, hash, tx, signature;
|
|
284
447
|
var _b;
|
|
285
448
|
return __generator(this, function (_c) {
|
|
286
449
|
switch (_c.label) {
|
|
@@ -325,12 +488,8 @@ var Stream = /** @class */ (function () {
|
|
|
325
488
|
feePayer: invoker.publicKey,
|
|
326
489
|
recentBlockhash: hash.blockhash,
|
|
327
490
|
})).add.apply(_b, __spreadArray([], __read(ixs), false));
|
|
328
|
-
return [4 /*yield*/,
|
|
491
|
+
return [4 /*yield*/, this.sign(invoker, tx)];
|
|
329
492
|
case 5:
|
|
330
|
-
_c.sent();
|
|
331
|
-
rawTx = tx.serialize();
|
|
332
|
-
return [4 /*yield*/, (0, web3_js_1.sendAndConfirmRawTransaction)(this.connection, rawTx)];
|
|
333
|
-
case 6:
|
|
334
493
|
signature = _c.sent();
|
|
335
494
|
return [2 /*return*/, { ixs: ixs, tx: signature }];
|
|
336
495
|
}
|
|
@@ -340,15 +499,15 @@ var Stream = /** @class */ (function () {
|
|
|
340
499
|
/**
|
|
341
500
|
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
342
501
|
* Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
|
|
343
|
-
* @param {
|
|
344
|
-
* @param {Wallet} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (sender or recipient) or transaction will fail.
|
|
502
|
+
* @param {TransferParams} data
|
|
503
|
+
* @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (sender or recipient) or transaction will fail.
|
|
345
504
|
* @param {string} data.id - Identifier of a stream (escrow account with metadata) to be transferred.
|
|
346
505
|
* @param {string} data.recipientId - Address of a new recipient.
|
|
347
506
|
*/
|
|
348
|
-
|
|
507
|
+
StreamClient.prototype.transfer = function (_a) {
|
|
349
508
|
var invoker = _a.invoker, id = _a.id, recipientId = _a.recipientId;
|
|
350
509
|
return __awaiter(this, void 0, void 0, function () {
|
|
351
|
-
var ixs, stream, newRecipient, escrow, mint, newRecipientTokens, commitment, hash, tx,
|
|
510
|
+
var ixs, stream, newRecipient, escrow, mint, newRecipientTokens, commitment, hash, tx, signature;
|
|
352
511
|
var _b;
|
|
353
512
|
return __generator(this, function (_c) {
|
|
354
513
|
switch (_c.label) {
|
|
@@ -375,7 +534,7 @@ var Stream = /** @class */ (function () {
|
|
|
375
534
|
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
376
535
|
tokenProgram: spl_token_2.TOKEN_PROGRAM_ID,
|
|
377
536
|
associatedTokenProgram: spl_token_2.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
378
|
-
systemProgram:
|
|
537
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
379
538
|
}));
|
|
380
539
|
commitment = typeof this.commitment == "string"
|
|
381
540
|
? this.commitment
|
|
@@ -387,12 +546,8 @@ var Stream = /** @class */ (function () {
|
|
|
387
546
|
feePayer: invoker.publicKey,
|
|
388
547
|
recentBlockhash: hash.blockhash,
|
|
389
548
|
})).add.apply(_b, __spreadArray([], __read(ixs), false));
|
|
390
|
-
return [4 /*yield*/,
|
|
549
|
+
return [4 /*yield*/, this.sign(invoker, tx)];
|
|
391
550
|
case 4:
|
|
392
|
-
_c.sent();
|
|
393
|
-
rawTx = tx.serialize();
|
|
394
|
-
return [4 /*yield*/, (0, web3_js_1.sendAndConfirmRawTransaction)(this.connection, rawTx)];
|
|
395
|
-
case 5:
|
|
396
551
|
signature = _c.sent();
|
|
397
552
|
return [2 /*return*/, { ixs: ixs, tx: signature }];
|
|
398
553
|
}
|
|
@@ -401,15 +556,15 @@ var Stream = /** @class */ (function () {
|
|
|
401
556
|
};
|
|
402
557
|
/**
|
|
403
558
|
* Tops up stream account deposited amount.
|
|
404
|
-
* @param {
|
|
405
|
-
* @param {Wallet} data.invoker - Wallet signing the transaction. It's address should match current stream sender or transaction will fail.
|
|
559
|
+
* @param {TopupParams} data
|
|
560
|
+
* @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match current stream sender or transaction will fail.
|
|
406
561
|
* @param {string} data.id - Identifier of a stream (escrow account with metadata) to be topped up.
|
|
407
562
|
* @param {u64} data.amount - Specified amount (in the smallest units) to topup (increases deposited amount).
|
|
408
563
|
*/
|
|
409
|
-
|
|
564
|
+
StreamClient.prototype.topup = function (_a) {
|
|
410
565
|
var invoker = _a.invoker, id = _a.id, amount = _a.amount;
|
|
411
566
|
return __awaiter(this, void 0, void 0, function () {
|
|
412
|
-
var ixs, streamPublicKey, escrow, _b, mint, partner, senderTokens, escrowTokens, streamflowTreasuryTokens, partnerTokens, commitment, hash, tx,
|
|
567
|
+
var ixs, streamPublicKey, escrow, _b, mint, partner, senderTokens, escrowTokens, streamflowTreasuryTokens, partnerTokens, commitment, hash, tx, signature;
|
|
413
568
|
var _c;
|
|
414
569
|
return __generator(this, function (_d) {
|
|
415
570
|
switch (_d.label) {
|
|
@@ -441,7 +596,7 @@ var Stream = /** @class */ (function () {
|
|
|
441
596
|
mint: mint,
|
|
442
597
|
tokenProgram: spl_token_2.TOKEN_PROGRAM_ID,
|
|
443
598
|
withdrawor: constants_1.WITHDRAWOR_PUBLIC_KEY,
|
|
444
|
-
systemProgram:
|
|
599
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
445
600
|
}));
|
|
446
601
|
commitment = typeof this.commitment == "string"
|
|
447
602
|
? this.commitment
|
|
@@ -453,11 +608,8 @@ var Stream = /** @class */ (function () {
|
|
|
453
608
|
feePayer: invoker.publicKey,
|
|
454
609
|
recentBlockhash: hash.blockhash,
|
|
455
610
|
})).add.apply(_c, __spreadArray([], __read(ixs), false));
|
|
456
|
-
return [4 /*yield*/,
|
|
611
|
+
return [4 /*yield*/, this.sign(invoker, tx)];
|
|
457
612
|
case 5:
|
|
458
|
-
signedAndSerializedTx = (_d.sent()).serialize();
|
|
459
|
-
return [4 /*yield*/, (0, web3_js_1.sendAndConfirmRawTransaction)(this.connection, signedAndSerializedTx)];
|
|
460
|
-
case 6:
|
|
461
613
|
signature = _d.sent();
|
|
462
614
|
return [2 /*return*/, { ixs: ixs, tx: signature }];
|
|
463
615
|
}
|
|
@@ -466,19 +618,16 @@ var Stream = /** @class */ (function () {
|
|
|
466
618
|
};
|
|
467
619
|
/**
|
|
468
620
|
* Fetch stream data by its id (address).
|
|
469
|
-
* @param {
|
|
470
|
-
* @param {Connection} data.connection - A connection to the cluster.
|
|
471
|
-
* @param {string} data.id - Identifier of a stream that is fetched.
|
|
621
|
+
* @param {string} id - Identifier of a stream that is fetched.
|
|
472
622
|
*/
|
|
473
|
-
|
|
474
|
-
var id = _a.id;
|
|
623
|
+
StreamClient.prototype.getOne = function (id) {
|
|
475
624
|
return __awaiter(this, void 0, void 0, function () {
|
|
476
625
|
var escrow;
|
|
477
|
-
return __generator(this, function (
|
|
478
|
-
switch (
|
|
626
|
+
return __generator(this, function (_a) {
|
|
627
|
+
switch (_a.label) {
|
|
479
628
|
case 0: return [4 /*yield*/, this.connection.getAccountInfo(new web3_js_1.PublicKey(id), constants_1.TX_FINALITY_CONFIRMED)];
|
|
480
629
|
case 1:
|
|
481
|
-
escrow =
|
|
630
|
+
escrow = _a.sent();
|
|
482
631
|
if (!(escrow === null || escrow === void 0 ? void 0 : escrow.data)) {
|
|
483
632
|
throw new Error("Couldn't get account info.");
|
|
484
633
|
}
|
|
@@ -490,12 +639,12 @@ var Stream = /** @class */ (function () {
|
|
|
490
639
|
/**
|
|
491
640
|
* Fetch streams/contracts by providing direction.
|
|
492
641
|
* Streams are sorted by start time in ascending order.
|
|
493
|
-
* @param {
|
|
642
|
+
* @param {GetAllParams} data
|
|
494
643
|
* @param {PublicKey} data.wallet - PublicKey of the wallet for which the streams/contracts are fetched.
|
|
495
644
|
* @param {StreamType} [data.type = StreamType.All] - It can be one of: stream, vesting, all.
|
|
496
645
|
* @param {StreamDirection} [data.direction = StreamDirection.All] - It can be one of: incoming, outgoing, all.
|
|
497
646
|
*/
|
|
498
|
-
|
|
647
|
+
StreamClient.prototype.get = function (_a) {
|
|
499
648
|
var wallet = _a.wallet, _b = _a.type, type = _b === void 0 ? types_1.StreamType.All : _b, _c = _a.direction, direction = _c === void 0 ? types_1.StreamDirection.All : _c;
|
|
500
649
|
return __awaiter(this, void 0, void 0, function () {
|
|
501
650
|
var accounts, outgoingAccounts, incomingAccounts, offset, streams, sortedStreams;
|
|
@@ -541,9 +690,34 @@ var Stream = /** @class */ (function () {
|
|
|
541
690
|
});
|
|
542
691
|
});
|
|
543
692
|
};
|
|
544
|
-
|
|
693
|
+
StreamClient.prototype.sign = function (invoker, tx) {
|
|
694
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
695
|
+
var rawTx, signature;
|
|
696
|
+
return __generator(this, function (_a) {
|
|
697
|
+
switch (_a.label) {
|
|
698
|
+
case 0:
|
|
699
|
+
if (!(invoker instanceof web3_js_1.Keypair)) return [3 /*break*/, 1];
|
|
700
|
+
tx.partialSign(invoker);
|
|
701
|
+
return [3 /*break*/, 3];
|
|
702
|
+
case 1:
|
|
703
|
+
if (!(invoker === null || invoker === void 0 ? void 0 : invoker.signTransaction)) return [3 /*break*/, 3];
|
|
704
|
+
return [4 /*yield*/, invoker.signTransaction(tx)];
|
|
705
|
+
case 2:
|
|
706
|
+
_a.sent();
|
|
707
|
+
_a.label = 3;
|
|
708
|
+
case 3:
|
|
709
|
+
rawTx = tx.serialize();
|
|
710
|
+
return [4 /*yield*/, (0, web3_js_1.sendAndConfirmRawTransaction)(this.connection, rawTx)];
|
|
711
|
+
case 4:
|
|
712
|
+
signature = _a.sent();
|
|
713
|
+
return [2 /*return*/, signature];
|
|
714
|
+
}
|
|
715
|
+
});
|
|
716
|
+
});
|
|
717
|
+
};
|
|
718
|
+
return StreamClient;
|
|
545
719
|
}());
|
|
546
|
-
exports.default =
|
|
720
|
+
exports.default = StreamClient;
|
|
547
721
|
function getProgramAccounts(connection, wallet, offset, cluster) {
|
|
548
722
|
if (cluster === void 0) { cluster = types_1.Cluster.Mainnet; }
|
|
549
723
|
return __awaiter(this, void 0, void 0, function () {
|