@streamflow/stream 5.10.3 → 6.0.0-alpha.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.
- package/README.md +0 -2
- package/dist/__tests__/aptos/streamClient.spec.js +1 -1
- package/dist/__tests__/common/GenericStreamClient.spec.js +6 -6
- package/dist/aptos/StreamClient.js +1 -1
- package/dist/aptos/types.d.ts +1 -1
- package/dist/aptos/wallet.js +1 -1
- package/dist/common/BaseStreamClient.js +1 -1
- package/dist/common/GenericStreamClient.d.ts +6 -6
- package/dist/common/types.d.ts +4 -30
- package/dist/common/types.js +9 -59
- package/dist/common/utils.js +2 -4
- package/dist/evm/StreamClient.js +5 -4
- package/dist/evm/index.d.ts +1 -0
- package/dist/evm/index.js +3 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -2
- package/dist/solana/StreamClient.js +61 -66
- package/dist/solana/constants.d.ts +0 -1
- package/dist/solana/constants.js +5 -1
- package/dist/solana/instructions.d.ts +1 -2
- package/dist/solana/instructions.js +9 -125
- package/dist/solana/layout.d.ts +0 -1
- package/dist/solana/layout.js +3 -1
- package/dist/solana/types.d.ts +7 -27
- package/dist/solana/types.js +1 -1
- package/dist/solana/utils.d.ts +2 -67
- package/dist/solana/utils.js +5 -245
- package/dist/sui/StreamClient.js +7 -13
- package/dist/sui/utils.js +1 -3
- package/dist/sui/wallet.d.ts +6 -0
- package/dist/sui/wallet.js +19 -5
- package/package.json +33 -13
package/dist/solana/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { SignerWalletAdapter } from "@solana/wallet-adapter-base";
|
|
3
|
-
import { AccountInfo, Connection, PublicKey, Keypair, TransactionSignature,
|
|
2
|
+
import { AccountInfo, Connection, PublicKey, Keypair, TransactionSignature, Transaction } from "@solana/web3.js";
|
|
3
|
+
import { TransactionResponse, TxResponse } from "@streamflow/common/solana";
|
|
4
4
|
import BN from "bn.js";
|
|
5
5
|
import { IRecipient, Stream, StreamDirection, StreamType } from "../common/types";
|
|
6
6
|
export { WalletAdapterNetwork as Cluster } from "@solana/wallet-adapter-base";
|
|
@@ -8,11 +8,13 @@ export interface Account {
|
|
|
8
8
|
pubkey: PublicKey;
|
|
9
9
|
account: AccountInfo<Buffer>;
|
|
10
10
|
}
|
|
11
|
-
export interface
|
|
11
|
+
export interface ICreateSolanaExt {
|
|
12
12
|
sender: SignerWalletAdapter | Keypair;
|
|
13
|
+
isNative?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface ICreateStreamSolanaExt extends ICreateSolanaExt {
|
|
13
16
|
metadataPubKeys?: PublicKey[];
|
|
14
17
|
partner?: string | null;
|
|
15
|
-
isNative?: boolean;
|
|
16
18
|
}
|
|
17
19
|
export interface IInteractStreamSolanaExt {
|
|
18
20
|
invoker: SignerWalletAdapter | Keypair;
|
|
@@ -227,16 +229,9 @@ export interface DecodedStream {
|
|
|
227
229
|
lastRateChangeTime: BN;
|
|
228
230
|
fundsUnlockedAtLastRateChange: BN;
|
|
229
231
|
}
|
|
230
|
-
export interface TransactionResponse {
|
|
231
|
-
tx: TransactionSignature;
|
|
232
|
-
}
|
|
233
232
|
export interface CreateStreamResponse extends TransactionResponse {
|
|
234
233
|
id: string;
|
|
235
234
|
}
|
|
236
|
-
export interface TxResponse {
|
|
237
|
-
ixs: TransactionInstruction[];
|
|
238
|
-
tx: TransactionSignature;
|
|
239
|
-
}
|
|
240
235
|
export interface CreateResponse extends TxResponse {
|
|
241
236
|
metadata: Keypair;
|
|
242
237
|
}
|
|
@@ -281,17 +276,6 @@ export interface CreateMultipleStreamsValues {
|
|
|
281
276
|
referral: string;
|
|
282
277
|
recipients: Recipient[];
|
|
283
278
|
}
|
|
284
|
-
export interface CheckAssociatedTokenAccountsData {
|
|
285
|
-
sender: PublicKey;
|
|
286
|
-
senderTokens: PublicKey;
|
|
287
|
-
recipient: PublicKey;
|
|
288
|
-
recipientTokens: PublicKey;
|
|
289
|
-
partner: PublicKey;
|
|
290
|
-
partnerTokens: PublicKey;
|
|
291
|
-
streamflowTreasury: PublicKey;
|
|
292
|
-
streamflowTreasuryTokens: PublicKey;
|
|
293
|
-
mint: PublicKey;
|
|
294
|
-
}
|
|
295
279
|
export interface BatchItem {
|
|
296
280
|
recipient: string;
|
|
297
281
|
tx: Transaction;
|
|
@@ -302,8 +286,4 @@ export interface BatchItemSuccess extends BatchItem {
|
|
|
302
286
|
export interface BatchItemError extends BatchItem {
|
|
303
287
|
error: string;
|
|
304
288
|
}
|
|
305
|
-
export
|
|
306
|
-
mint: PublicKey;
|
|
307
|
-
owner: PublicKey;
|
|
308
|
-
}
|
|
309
|
-
export declare type BatchItemResult = BatchItemSuccess | BatchItemError;
|
|
289
|
+
export type BatchItemResult = BatchItemSuccess | BatchItemError;
|
package/dist/solana/types.js
CHANGED
|
@@ -78,4 +78,4 @@ var TransferCancelOptions;
|
|
|
78
78
|
TransferCancelOptions["Sender"] = "sender";
|
|
79
79
|
TransferCancelOptions["Both"] = "both";
|
|
80
80
|
TransferCancelOptions["Neither"] = "neither";
|
|
81
|
-
})(TransferCancelOptions
|
|
81
|
+
})(TransferCancelOptions || (exports.TransferCancelOptions = TransferCancelOptions = {}));
|
package/dist/solana/utils.d.ts
CHANGED
|
@@ -1,30 +1,7 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { SignerWalletAdapter } from "@solana/wallet-adapter-base";
|
|
3
|
-
import { Connection, Keypair
|
|
4
|
-
import {
|
|
2
|
+
import { Connection, Keypair } from "@solana/web3.js";
|
|
3
|
+
import { DecodedStream, BatchItem, BatchItemResult } from "./types";
|
|
5
4
|
export declare const decodeStream: (buf: Buffer) => DecodedStream;
|
|
6
|
-
/**
|
|
7
|
-
* Wrapper function for Solana web3 getProgramAccounts with slightly better call interface
|
|
8
|
-
* @param {Connection} connection - Solana web3 connection object.
|
|
9
|
-
* @param {PublicKey} wallet - PublicKey to compare against.
|
|
10
|
-
* @param {number} offset - Offset of bits of the PublicKey in the account binary.
|
|
11
|
-
* @param {PublicKey} programId - Solana program ID.
|
|
12
|
-
* @return {Promise<Account[]>} - Array of resulting accounts.
|
|
13
|
-
*/
|
|
14
|
-
export declare function getProgramAccounts(connection: Connection, wallet: PublicKey, offset: number, programId: PublicKey): Promise<Account[]>;
|
|
15
|
-
/**
|
|
16
|
-
* Utility function to check if the transaction initiator is a Wallet object
|
|
17
|
-
* @param {Keypair | SignerWalletAdapter} walletOrKeypair - Wallet or Keypair in question
|
|
18
|
-
* @return {boolean} - Returns true if parameter is a Wallet.
|
|
19
|
-
*/
|
|
20
|
-
export declare function isSignerWallet(walletOrKeypair: Keypair | SignerWalletAdapter): walletOrKeypair is SignerWalletAdapter;
|
|
21
|
-
/**
|
|
22
|
-
* Utility function to check if the transaction initiator a Keypair object, tries to mitigate version mismatch issues
|
|
23
|
-
* @param walletOrKeypair {Keypair | SignerWalletAdapter} walletOrKeypair - Wallet or Keypair in question
|
|
24
|
-
* @returns {boolean} - Returns true if parameter is a Keypair.
|
|
25
|
-
*/
|
|
26
|
-
export declare function isSignerKeypair(walletOrKeypair: Keypair | SignerWalletAdapter): walletOrKeypair is Keypair;
|
|
27
|
-
export declare function signTransaction(invoker: Keypair | SignerWalletAdapter, tx: Transaction): Promise<Transaction>;
|
|
28
5
|
/**
|
|
29
6
|
* Sign passed BatchItems with wallet request or KeyPair
|
|
30
7
|
* @param {Keypair | SignerWalletAdapter} sender - Wallet or Keypair of sendin account
|
|
@@ -32,15 +9,6 @@ export declare function signTransaction(invoker: Keypair | SignerWalletAdapter,
|
|
|
32
9
|
* @return {BatchItem[]} - Returns items with signatures.
|
|
33
10
|
*/
|
|
34
11
|
export declare function signAllTransactionWithRecipients(sender: Keypair | SignerWalletAdapter, items: BatchItem[]): Promise<BatchItem[]>;
|
|
35
|
-
/**
|
|
36
|
-
* Signs, sends and confirms Transaction
|
|
37
|
-
* @param connection - Solana client connection
|
|
38
|
-
* @param invoker - Keypair used as signer
|
|
39
|
-
* @param tx - Transaction instance
|
|
40
|
-
* @param hash - blockhash information, the same hash should be used in the Transaction
|
|
41
|
-
* @returns Transaction signature
|
|
42
|
-
*/
|
|
43
|
-
export declare function signAndExecuteTransaction(connection: Connection, invoker: Keypair | SignerWalletAdapter, tx: Transaction, hash: BlockhashWithExpiryBlockHeight): Promise<string>;
|
|
44
12
|
/**
|
|
45
13
|
* Sign passed BatchItems with wallet request or KeyPair
|
|
46
14
|
* @param {Connection} connection - Solana web3 connection object.
|
|
@@ -48,37 +16,4 @@ export declare function signAndExecuteTransaction(connection: Connection, invoke
|
|
|
48
16
|
* @return {Promise<BatchItemResult>} - Returns settled transaction item
|
|
49
17
|
*/
|
|
50
18
|
export declare function sendAndConfirmStreamRawTransaction(connection: Connection, batchItem: BatchItem): Promise<BatchItemResult>;
|
|
51
|
-
/**
|
|
52
|
-
* Shorthand call signature for getAssociatedTokenAddress, with allowance for address to be offCurve
|
|
53
|
-
* @param {PublicKey} mint - SPL token Mint address.
|
|
54
|
-
* @param {PublicKey} owner - Owner of the Associated Token Address
|
|
55
|
-
* @return {Promise<PublicKey>} - Associated Token Address
|
|
56
|
-
*/
|
|
57
|
-
export declare function ata(mint: PublicKey, owner: PublicKey): Promise<PublicKey>;
|
|
58
|
-
/**
|
|
59
|
-
* Function that checks whether ATA exists for each provided owner
|
|
60
|
-
* @param connection - Solana client connection
|
|
61
|
-
* @param paramsBatch - Array of Params for an each ATA account: {mint, owner}
|
|
62
|
-
* @returns Array of boolean where each members corresponds to owners member
|
|
63
|
-
*/
|
|
64
|
-
export declare function ataBatchExist(connection: Connection, paramsBatch: AtaParams[]): Promise<boolean[]>;
|
|
65
|
-
/**
|
|
66
|
-
* Generates a Transaction to create ATA for an array of owners
|
|
67
|
-
* @param connection - Solana client connection
|
|
68
|
-
* @param payer - Transaction invoker, should be a signer
|
|
69
|
-
* @param coparamsBatchnfigs - Array of Params for an each ATA account: {mint, owner}
|
|
70
|
-
* @returns Unsigned Transaction with create ATA instructions
|
|
71
|
-
*/
|
|
72
|
-
export declare function generateCreateAtaBatchTx(connection: Connection, payer: PublicKey, paramsBatch: AtaParams[]): Promise<{
|
|
73
|
-
tx: Transaction;
|
|
74
|
-
hash: BlockhashWithExpiryBlockHeight;
|
|
75
|
-
}>;
|
|
76
|
-
/**
|
|
77
|
-
* Creates ATA for an array of owners
|
|
78
|
-
* @param connection - Solana client connection
|
|
79
|
-
* @param invoker - Transaction invoker and payer
|
|
80
|
-
* @param paramsBatch - Array of Params for an each ATA account: {mint, owner}
|
|
81
|
-
* @returns Transaction signature
|
|
82
|
-
*/
|
|
83
|
-
export declare function createAtaBatch(connection: Connection, invoker: Keypair | SignerWalletAdapter, paramsBatch: AtaParams[]): Promise<string>;
|
|
84
19
|
export declare function extractSolanaErrorCode(errorText: string): string | null;
|
package/dist/solana/utils.js
CHANGED
|
@@ -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]) {
|
|
@@ -46,38 +46,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
46
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
50
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
51
|
-
if (!m) return o;
|
|
52
|
-
var i = m.call(o), r, ar = [], e;
|
|
53
|
-
try {
|
|
54
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
55
|
-
}
|
|
56
|
-
catch (error) { e = { error: error }; }
|
|
57
|
-
finally {
|
|
58
|
-
try {
|
|
59
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
60
|
-
}
|
|
61
|
-
finally { if (e) throw e.error; }
|
|
62
|
-
}
|
|
63
|
-
return ar;
|
|
64
|
-
};
|
|
65
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
66
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
67
|
-
if (ar || !(i in from)) {
|
|
68
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
69
|
-
ar[i] = from[i];
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
73
|
-
};
|
|
74
49
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
75
50
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
76
51
|
};
|
|
77
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
78
|
-
exports.extractSolanaErrorCode = exports.
|
|
79
|
-
var spl_token_1 = require("@solana/spl-token");
|
|
53
|
+
exports.extractSolanaErrorCode = exports.sendAndConfirmStreamRawTransaction = exports.signAllTransactionWithRecipients = exports.decodeStream = void 0;
|
|
80
54
|
var web3_js_1 = require("@solana/web3.js");
|
|
55
|
+
var solana_1 = require("@streamflow/common/solana");
|
|
81
56
|
var bn_js_1 = __importDefault(require("bn.js"));
|
|
82
57
|
var bs58_1 = __importDefault(require("bs58"));
|
|
83
58
|
var layout_1 = require("./layout");
|
|
@@ -132,72 +107,6 @@ var decodeStream = function (buf) {
|
|
|
132
107
|
};
|
|
133
108
|
};
|
|
134
109
|
exports.decodeStream = decodeStream;
|
|
135
|
-
/**
|
|
136
|
-
* Wrapper function for Solana web3 getProgramAccounts with slightly better call interface
|
|
137
|
-
* @param {Connection} connection - Solana web3 connection object.
|
|
138
|
-
* @param {PublicKey} wallet - PublicKey to compare against.
|
|
139
|
-
* @param {number} offset - Offset of bits of the PublicKey in the account binary.
|
|
140
|
-
* @param {PublicKey} programId - Solana program ID.
|
|
141
|
-
* @return {Promise<Account[]>} - Array of resulting accounts.
|
|
142
|
-
*/
|
|
143
|
-
function getProgramAccounts(connection, wallet, offset, programId) {
|
|
144
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
145
|
-
return __generator(this, function (_a) {
|
|
146
|
-
return [2 /*return*/, connection === null || connection === void 0 ? void 0 : connection.getProgramAccounts(programId, {
|
|
147
|
-
filters: [
|
|
148
|
-
{
|
|
149
|
-
memcmp: {
|
|
150
|
-
offset: offset,
|
|
151
|
-
bytes: wallet.toBase58(),
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
],
|
|
155
|
-
})];
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
exports.getProgramAccounts = getProgramAccounts;
|
|
160
|
-
/**
|
|
161
|
-
* Utility function to check if the transaction initiator is a Wallet object
|
|
162
|
-
* @param {Keypair | SignerWalletAdapter} walletOrKeypair - Wallet or Keypair in question
|
|
163
|
-
* @return {boolean} - Returns true if parameter is a Wallet.
|
|
164
|
-
*/
|
|
165
|
-
function isSignerWallet(walletOrKeypair) {
|
|
166
|
-
return walletOrKeypair.signTransaction !== undefined;
|
|
167
|
-
}
|
|
168
|
-
exports.isSignerWallet = isSignerWallet;
|
|
169
|
-
/**
|
|
170
|
-
* Utility function to check if the transaction initiator a Keypair object, tries to mitigate version mismatch issues
|
|
171
|
-
* @param walletOrKeypair {Keypair | SignerWalletAdapter} walletOrKeypair - Wallet or Keypair in question
|
|
172
|
-
* @returns {boolean} - Returns true if parameter is a Keypair.
|
|
173
|
-
*/
|
|
174
|
-
function isSignerKeypair(walletOrKeypair) {
|
|
175
|
-
return (walletOrKeypair instanceof web3_js_1.Keypair ||
|
|
176
|
-
walletOrKeypair.constructor === web3_js_1.Keypair ||
|
|
177
|
-
walletOrKeypair.constructor.name === web3_js_1.Keypair.prototype.constructor.name);
|
|
178
|
-
}
|
|
179
|
-
exports.isSignerKeypair = isSignerKeypair;
|
|
180
|
-
function signTransaction(invoker, tx) {
|
|
181
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
182
|
-
var signedTx;
|
|
183
|
-
return __generator(this, function (_a) {
|
|
184
|
-
switch (_a.label) {
|
|
185
|
-
case 0:
|
|
186
|
-
if (!isSignerWallet(invoker)) return [3 /*break*/, 2];
|
|
187
|
-
return [4 /*yield*/, invoker.signTransaction(tx)];
|
|
188
|
-
case 1:
|
|
189
|
-
signedTx = _a.sent();
|
|
190
|
-
return [3 /*break*/, 3];
|
|
191
|
-
case 2:
|
|
192
|
-
tx.partialSign(invoker);
|
|
193
|
-
signedTx = tx;
|
|
194
|
-
_a.label = 3;
|
|
195
|
-
case 3: return [2 /*return*/, signedTx];
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
exports.signTransaction = signTransaction;
|
|
201
110
|
/**
|
|
202
111
|
* Sign passed BatchItems with wallet request or KeyPair
|
|
203
112
|
* @param {Keypair | SignerWalletAdapter} sender - Wallet or Keypair of sendin account
|
|
@@ -210,8 +119,8 @@ function signAllTransactionWithRecipients(sender, items) {
|
|
|
210
119
|
return __generator(this, function (_a) {
|
|
211
120
|
switch (_a.label) {
|
|
212
121
|
case 0:
|
|
213
|
-
isKeypair = isSignerKeypair(sender);
|
|
214
|
-
isWallet = isSignerWallet(sender);
|
|
122
|
+
isKeypair = (0, solana_1.isSignerKeypair)(sender);
|
|
123
|
+
isWallet = (0, solana_1.isSignerWallet)(sender);
|
|
215
124
|
if (!isKeypair) return [3 /*break*/, 1];
|
|
216
125
|
return [2 /*return*/, items.map(function (t) {
|
|
217
126
|
t.tx.partialSign(sender);
|
|
@@ -231,39 +140,6 @@ function signAllTransactionWithRecipients(sender, items) {
|
|
|
231
140
|
});
|
|
232
141
|
}
|
|
233
142
|
exports.signAllTransactionWithRecipients = signAllTransactionWithRecipients;
|
|
234
|
-
/**
|
|
235
|
-
* Signs, sends and confirms Transaction
|
|
236
|
-
* @param connection - Solana client connection
|
|
237
|
-
* @param invoker - Keypair used as signer
|
|
238
|
-
* @param tx - Transaction instance
|
|
239
|
-
* @param hash - blockhash information, the same hash should be used in the Transaction
|
|
240
|
-
* @returns Transaction signature
|
|
241
|
-
*/
|
|
242
|
-
function signAndExecuteTransaction(connection, invoker, tx, hash) {
|
|
243
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
244
|
-
var signedTx, rawTx, confirmationStrategy, signature;
|
|
245
|
-
return __generator(this, function (_a) {
|
|
246
|
-
switch (_a.label) {
|
|
247
|
-
case 0: return [4 /*yield*/, signTransaction(invoker, tx)];
|
|
248
|
-
case 1:
|
|
249
|
-
signedTx = _a.sent();
|
|
250
|
-
rawTx = signedTx.serialize();
|
|
251
|
-
if (!hash.lastValidBlockHeight || !signedTx.signature || !hash.blockhash)
|
|
252
|
-
throw Error("Error with transaction parameters.");
|
|
253
|
-
confirmationStrategy = {
|
|
254
|
-
lastValidBlockHeight: hash.lastValidBlockHeight,
|
|
255
|
-
signature: bs58_1.default.encode(signedTx.signature),
|
|
256
|
-
blockhash: hash.blockhash,
|
|
257
|
-
};
|
|
258
|
-
return [4 /*yield*/, (0, web3_js_1.sendAndConfirmRawTransaction)(connection, rawTx, confirmationStrategy)];
|
|
259
|
-
case 2:
|
|
260
|
-
signature = _a.sent();
|
|
261
|
-
return [2 /*return*/, signature];
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
exports.signAndExecuteTransaction = signAndExecuteTransaction;
|
|
267
143
|
/**
|
|
268
144
|
* Sign passed BatchItems with wallet request or KeyPair
|
|
269
145
|
* @param {Connection} connection - Solana web3 connection object.
|
|
@@ -303,122 +179,6 @@ function sendAndConfirmStreamRawTransaction(connection, batchItem) {
|
|
|
303
179
|
});
|
|
304
180
|
}
|
|
305
181
|
exports.sendAndConfirmStreamRawTransaction = sendAndConfirmStreamRawTransaction;
|
|
306
|
-
/**
|
|
307
|
-
* Shorthand call signature for getAssociatedTokenAddress, with allowance for address to be offCurve
|
|
308
|
-
* @param {PublicKey} mint - SPL token Mint address.
|
|
309
|
-
* @param {PublicKey} owner - Owner of the Associated Token Address
|
|
310
|
-
* @return {Promise<PublicKey>} - Associated Token Address
|
|
311
|
-
*/
|
|
312
|
-
function ata(mint, owner) {
|
|
313
|
-
return (0, spl_token_1.getAssociatedTokenAddress)(mint, owner, true);
|
|
314
|
-
}
|
|
315
|
-
exports.ata = ata;
|
|
316
|
-
/**
|
|
317
|
-
* Function that checks whether ATA exists for each provided owner
|
|
318
|
-
* @param connection - Solana client connection
|
|
319
|
-
* @param paramsBatch - Array of Params for an each ATA account: {mint, owner}
|
|
320
|
-
* @returns Array of boolean where each members corresponds to owners member
|
|
321
|
-
*/
|
|
322
|
-
function ataBatchExist(connection, paramsBatch) {
|
|
323
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
324
|
-
var tokenAccounts, response;
|
|
325
|
-
var _this = this;
|
|
326
|
-
return __generator(this, function (_a) {
|
|
327
|
-
switch (_a.label) {
|
|
328
|
-
case 0: return [4 /*yield*/, Promise.all(paramsBatch.map(function (_a) {
|
|
329
|
-
var mint = _a.mint, owner = _a.owner;
|
|
330
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
331
|
-
var pubkey;
|
|
332
|
-
return __generator(this, function (_b) {
|
|
333
|
-
switch (_b.label) {
|
|
334
|
-
case 0: return [4 /*yield*/, ata(mint, owner)];
|
|
335
|
-
case 1:
|
|
336
|
-
pubkey = _b.sent();
|
|
337
|
-
return [2 /*return*/, pubkey];
|
|
338
|
-
}
|
|
339
|
-
});
|
|
340
|
-
});
|
|
341
|
-
}))];
|
|
342
|
-
case 1:
|
|
343
|
-
tokenAccounts = _a.sent();
|
|
344
|
-
return [4 /*yield*/, connection.getMultipleAccountsInfo(tokenAccounts)];
|
|
345
|
-
case 2:
|
|
346
|
-
response = _a.sent();
|
|
347
|
-
return [2 /*return*/, response.map(function (accInfo) { return !!accInfo; })];
|
|
348
|
-
}
|
|
349
|
-
});
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
exports.ataBatchExist = ataBatchExist;
|
|
353
|
-
/**
|
|
354
|
-
* Generates a Transaction to create ATA for an array of owners
|
|
355
|
-
* @param connection - Solana client connection
|
|
356
|
-
* @param payer - Transaction invoker, should be a signer
|
|
357
|
-
* @param coparamsBatchnfigs - Array of Params for an each ATA account: {mint, owner}
|
|
358
|
-
* @returns Unsigned Transaction with create ATA instructions
|
|
359
|
-
*/
|
|
360
|
-
function generateCreateAtaBatchTx(connection, payer, paramsBatch) {
|
|
361
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
362
|
-
var ixs, hash, tx;
|
|
363
|
-
var _a;
|
|
364
|
-
var _this = this;
|
|
365
|
-
return __generator(this, function (_b) {
|
|
366
|
-
switch (_b.label) {
|
|
367
|
-
case 0: return [4 /*yield*/, Promise.all(paramsBatch.map(function (_a) {
|
|
368
|
-
var mint = _a.mint, owner = _a.owner;
|
|
369
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
370
|
-
var _b, _c;
|
|
371
|
-
return __generator(this, function (_d) {
|
|
372
|
-
switch (_d.label) {
|
|
373
|
-
case 0:
|
|
374
|
-
_b = spl_token_1.createAssociatedTokenAccountInstruction;
|
|
375
|
-
_c = [payer];
|
|
376
|
-
return [4 /*yield*/, ata(mint, owner)];
|
|
377
|
-
case 1: return [2 /*return*/, _b.apply(void 0, _c.concat([_d.sent(), owner, mint]))];
|
|
378
|
-
}
|
|
379
|
-
});
|
|
380
|
-
});
|
|
381
|
-
}))];
|
|
382
|
-
case 1:
|
|
383
|
-
ixs = _b.sent();
|
|
384
|
-
return [4 /*yield*/, connection.getLatestBlockhash()];
|
|
385
|
-
case 2:
|
|
386
|
-
hash = _b.sent();
|
|
387
|
-
tx = (_a = new web3_js_1.Transaction({
|
|
388
|
-
feePayer: payer,
|
|
389
|
-
blockhash: hash.blockhash,
|
|
390
|
-
lastValidBlockHeight: hash.lastValidBlockHeight,
|
|
391
|
-
})).add.apply(_a, __spreadArray([], __read(ixs), false));
|
|
392
|
-
return [2 /*return*/, { tx: tx, hash: hash }];
|
|
393
|
-
}
|
|
394
|
-
});
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
exports.generateCreateAtaBatchTx = generateCreateAtaBatchTx;
|
|
398
|
-
/**
|
|
399
|
-
* Creates ATA for an array of owners
|
|
400
|
-
* @param connection - Solana client connection
|
|
401
|
-
* @param invoker - Transaction invoker and payer
|
|
402
|
-
* @param paramsBatch - Array of Params for an each ATA account: {mint, owner}
|
|
403
|
-
* @returns Transaction signature
|
|
404
|
-
*/
|
|
405
|
-
function createAtaBatch(connection, invoker, paramsBatch) {
|
|
406
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
407
|
-
var _a, tx, hash, signature;
|
|
408
|
-
return __generator(this, function (_b) {
|
|
409
|
-
switch (_b.label) {
|
|
410
|
-
case 0: return [4 /*yield*/, generateCreateAtaBatchTx(connection, invoker.publicKey, paramsBatch)];
|
|
411
|
-
case 1:
|
|
412
|
-
_a = _b.sent(), tx = _a.tx, hash = _a.hash;
|
|
413
|
-
return [4 /*yield*/, signAndExecuteTransaction(connection, invoker, tx, hash)];
|
|
414
|
-
case 2:
|
|
415
|
-
signature = _b.sent();
|
|
416
|
-
return [2 /*return*/, signature];
|
|
417
|
-
}
|
|
418
|
-
});
|
|
419
|
-
});
|
|
420
|
-
}
|
|
421
|
-
exports.createAtaBatch = createAtaBatch;
|
|
422
182
|
function extractSolanaErrorCode(errorText) {
|
|
423
183
|
var match = constants_1.SOLANA_ERROR_MATCH_REGEX.exec(errorText);
|
|
424
184
|
if (!match) {
|
package/dist/sui/StreamClient.js
CHANGED
|
@@ -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]) {
|
|
@@ -120,7 +120,9 @@ var SuiStreamClient = /** @class */ (function (_super) {
|
|
|
120
120
|
switch (_e.label) {
|
|
121
121
|
case 0:
|
|
122
122
|
wallet = new wallet_1.SuiWalletWrapper(senderWallet, this.client);
|
|
123
|
-
return [4 /*yield*/, this.getTotalFee({
|
|
123
|
+
return [4 /*yield*/, this.getTotalFee({
|
|
124
|
+
address: (_b = streamData.partner) !== null && _b !== void 0 ? _b : wallet.address,
|
|
125
|
+
})];
|
|
124
126
|
case 1:
|
|
125
127
|
totalFee = _e.sent();
|
|
126
128
|
return [4 /*yield*/, this.generateCreateBlock(wallet.address, __assign(__assign({}, streamData), { recipients: [__assign({}, streamData)] }), totalFee)];
|
|
@@ -270,11 +272,7 @@ var SuiStreamClient = /** @class */ (function (_super) {
|
|
|
270
272
|
txb.moveCall({
|
|
271
273
|
target: "".concat(this.programId, "::protocol::cancel"),
|
|
272
274
|
typeArguments: [tokenId],
|
|
273
|
-
arguments: [
|
|
274
|
-
txb.object(cancelData.id),
|
|
275
|
-
txb.object(this.configId),
|
|
276
|
-
txb.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
277
|
-
],
|
|
275
|
+
arguments: [txb.object(cancelData.id), txb.object(this.configId), txb.object(utils_1.SUI_CLOCK_OBJECT_ID)],
|
|
278
276
|
});
|
|
279
277
|
return [4 /*yield*/, wallet.signAndExecuteTransactionBlock({
|
|
280
278
|
transactionBlock: txb,
|
|
@@ -420,12 +418,8 @@ var SuiStreamClient = /** @class */ (function (_super) {
|
|
|
420
418
|
txb.object(this.configId),
|
|
421
419
|
txb.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
422
420
|
txb.gas,
|
|
423
|
-
txb.pure(updateData.enableAutomaticWithdrawal !== undefined
|
|
424
|
-
|
|
425
|
-
: [], "vector<bool>"),
|
|
426
|
-
txb.pure(updateData.withdrawFrequency !== undefined
|
|
427
|
-
? [updateData.withdrawFrequency.toString()]
|
|
428
|
-
: [], "vector<u64>"),
|
|
421
|
+
txb.pure(updateData.enableAutomaticWithdrawal !== undefined ? [updateData.enableAutomaticWithdrawal] : [], "vector<bool>"),
|
|
422
|
+
txb.pure(updateData.withdrawFrequency !== undefined ? [updateData.withdrawFrequency.toString()] : [], "vector<u64>"),
|
|
429
423
|
txb.pure(updateData.amountPerPeriod !== undefined ? [updateData.amountPerPeriod.toString()] : [], "vector<u64>"),
|
|
430
424
|
],
|
|
431
425
|
});
|
package/dist/sui/utils.js
CHANGED
|
@@ -10,9 +10,7 @@ function extractSuiErrorInfo(errorText) {
|
|
|
10
10
|
}
|
|
11
11
|
var moduleName = match[2];
|
|
12
12
|
var errorCode = Number(match[4]);
|
|
13
|
-
var errorName = constants_1.SUI_MODULE_ERROR_MAP[moduleName]
|
|
14
|
-
? constants_1.SUI_MODULE_ERROR_MAP[moduleName][errorCode]
|
|
15
|
-
: undefined;
|
|
13
|
+
var errorName = constants_1.SUI_MODULE_ERROR_MAP[moduleName] ? constants_1.SUI_MODULE_ERROR_MAP[moduleName][errorCode] : undefined;
|
|
16
14
|
var index = Number(match[5]);
|
|
17
15
|
if (index) {
|
|
18
16
|
error.index = index;
|
package/dist/sui/wallet.d.ts
CHANGED
|
@@ -2,6 +2,12 @@ import { Keypair } from "@mysten/sui.js/cryptography";
|
|
|
2
2
|
import { WalletContextState } from "@suiet/wallet-kit";
|
|
3
3
|
import { SuiClient, SuiTransactionBlockResponse } from "@mysten/sui.js/client";
|
|
4
4
|
import { SuiSignAndExecuteTransactionBlockInput } from "./types";
|
|
5
|
+
/**
|
|
6
|
+
* Utility function to check if the transaction initiator is a Wallet object
|
|
7
|
+
* @param {Keypair | SignerWalletAdapter} walletOrKeypair - Wallet or Keypair in question
|
|
8
|
+
* @return {boolean} - Returns true if parameter is a Wallet.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isSignerKeypair(walletOrKeypair: Keypair | WalletContextState): walletOrKeypair is Keypair;
|
|
5
11
|
export declare class SuiWalletWrapper<T extends WalletContextState | Keypair> {
|
|
6
12
|
wallet: T;
|
|
7
13
|
address: string;
|
package/dist/sui/wallet.js
CHANGED
|
@@ -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]) {
|
|
@@ -47,13 +47,24 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.SuiWalletWrapper = void 0;
|
|
50
|
+
exports.SuiWalletWrapper = exports.isSignerKeypair = void 0;
|
|
51
51
|
var cryptography_1 = require("@mysten/sui.js/cryptography");
|
|
52
|
+
/**
|
|
53
|
+
* Utility function to check if the transaction initiator is a Wallet object
|
|
54
|
+
* @param {Keypair | SignerWalletAdapter} walletOrKeypair - Wallet or Keypair in question
|
|
55
|
+
* @return {boolean} - Returns true if parameter is a Wallet.
|
|
56
|
+
*/
|
|
57
|
+
function isSignerKeypair(walletOrKeypair) {
|
|
58
|
+
return (walletOrKeypair instanceof cryptography_1.Keypair ||
|
|
59
|
+
walletOrKeypair.constructor === cryptography_1.Keypair ||
|
|
60
|
+
walletOrKeypair.constructor.name === cryptography_1.Keypair.prototype.constructor.name);
|
|
61
|
+
}
|
|
62
|
+
exports.isSignerKeypair = isSignerKeypair;
|
|
52
63
|
var SuiWalletWrapper = /** @class */ (function () {
|
|
53
64
|
function SuiWalletWrapper(wallet, client) {
|
|
54
65
|
this.client = client;
|
|
55
66
|
this.wallet = wallet;
|
|
56
|
-
if (wallet
|
|
67
|
+
if (isSignerKeypair(wallet)) {
|
|
57
68
|
this.address = wallet.toSuiAddress();
|
|
58
69
|
}
|
|
59
70
|
else {
|
|
@@ -63,9 +74,12 @@ var SuiWalletWrapper = /** @class */ (function () {
|
|
|
63
74
|
SuiWalletWrapper.prototype.signAndExecuteTransactionBlock = function (input) {
|
|
64
75
|
return __awaiter(this, void 0, void 0, function () {
|
|
65
76
|
return __generator(this, function (_a) {
|
|
66
|
-
if (this.wallet
|
|
67
|
-
return [2 /*return*/, this.client.signAndExecuteTransactionBlock(__assign(__assign({}, input), {
|
|
77
|
+
if (isSignerKeypair(this.wallet)) {
|
|
78
|
+
return [2 /*return*/, this.client.signAndExecuteTransactionBlock(__assign(__assign({}, input), {
|
|
79
|
+
// @ts-ignore
|
|
80
|
+
signer: this.wallet }))];
|
|
68
81
|
}
|
|
82
|
+
// @ts-ignore
|
|
69
83
|
return [2 /*return*/, this.wallet.signAndExecuteTransactionBlock(input)];
|
|
70
84
|
});
|
|
71
85
|
});
|
package/package.json
CHANGED
|
@@ -1,41 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamflow/stream",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0-alpha.0",
|
|
4
4
|
"description": "JavaScript SDK to interact with Streamflow protocol.",
|
|
5
5
|
"homepage": "https://github.com/streamflow-finance/js-sdk/",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./dist/index.js",
|
|
10
|
+
"./aptos": "./dist/aptos/index.js",
|
|
11
|
+
"./evm": "./dist/evm/index.js",
|
|
12
|
+
"./solana": "./dist/solana/index.js",
|
|
13
|
+
"./sui": "./dist/sui/index.js"
|
|
14
|
+
},
|
|
15
|
+
"typesVersions": {
|
|
16
|
+
"*": {
|
|
17
|
+
"aptos": [
|
|
18
|
+
"dist/aptos/index.d.ts"
|
|
19
|
+
],
|
|
20
|
+
"evm": [
|
|
21
|
+
"dist/evm/index.d.ts"
|
|
22
|
+
],
|
|
23
|
+
"solana": [
|
|
24
|
+
"dist/solana/index.d.ts"
|
|
25
|
+
],
|
|
26
|
+
"sui": [
|
|
27
|
+
"dist/sui/index.d.ts"
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
},
|
|
8
31
|
"scripts": {
|
|
9
32
|
"build": "rm -rf dist; tsc -p tsconfig.json",
|
|
33
|
+
"pack": "pnpm build && pnpm pack",
|
|
10
34
|
"test": "jest .",
|
|
11
|
-
"lint": "eslint .",
|
|
35
|
+
"lint": "eslint --fix .",
|
|
12
36
|
"prepublishOnly": "npm run lint && npm test && npm run build"
|
|
13
37
|
},
|
|
14
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "5b1627a35ea628cf51c8b271db049211975302d1",
|
|
15
39
|
"devDependencies": {
|
|
40
|
+
"@streamflow/eslint-config": "6.0.0-alpha.0",
|
|
16
41
|
"@types/bn.js": "5.1.1",
|
|
17
42
|
"@types/ethereum-checksum-address": "^0.0.0",
|
|
18
43
|
"@types/jest": "29.2.4",
|
|
19
44
|
"date-fns": "2.28.0",
|
|
20
|
-
"eslint": "8.29.0",
|
|
21
|
-
"eslint-config-airbnb-typescript": "17.0.0",
|
|
22
|
-
"eslint-config-prettier": "8.5.0",
|
|
23
|
-
"eslint-plugin-jest": "27.1.6",
|
|
24
|
-
"eslint-plugin-prettier": "4.2.1",
|
|
25
45
|
"jest": "29.3.1",
|
|
26
|
-
"prettier": "2.8.1",
|
|
27
46
|
"ts-jest": "29.0.3",
|
|
28
|
-
"typescript": "
|
|
47
|
+
"typescript": "^5.3.3"
|
|
29
48
|
},
|
|
30
49
|
"dependencies": {
|
|
50
|
+
"@coral-xyz/borsh": "^0.29.0",
|
|
31
51
|
"@manahippo/aptos-wallet-adapter": "1.0.6",
|
|
32
|
-
"@mysten/sui.js": "^0.
|
|
33
|
-
"@mysten/wallet-standard": "^0.6.0",
|
|
52
|
+
"@mysten/sui.js": "^0.45.1",
|
|
34
53
|
"@solana/buffer-layout": "4.0.1 ",
|
|
35
54
|
"@solana/spl-token": "0.3.6",
|
|
36
55
|
"@solana/wallet-adapter-base": "0.9.19",
|
|
37
56
|
"@solana/web3.js": "1.70.1",
|
|
38
|
-
"@
|
|
57
|
+
"@streamflow/common": "6.0.0-alpha.0",
|
|
58
|
+
"@suiet/wallet-kit": "0.2.22",
|
|
39
59
|
"aptos": "1.4.0",
|
|
40
60
|
"bn.js": "5.2.1",
|
|
41
61
|
"borsh": "^2.0.0",
|