@streamflow/stream 5.9.9 → 5.10.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/dist/aptos/index.d.ts +2 -0
- package/dist/aptos/index.js +15 -1
- package/dist/evm/index.d.ts +2 -0
- package/dist/evm/index.js +15 -1
- package/dist/solana/StreamClient.d.ts +0 -1
- package/dist/solana/StreamClient.js +9 -42
- package/dist/solana/types.d.ts +4 -0
- package/dist/solana/utils.d.ts +45 -3
- package/dist/solana/utils.js +187 -1
- package/dist/sui/index.d.ts +2 -0
- package/dist/sui/index.js +15 -1
- package/package.json +3 -3
package/dist/aptos/index.d.ts
CHANGED
package/dist/aptos/index.js
CHANGED
|
@@ -10,15 +10,29 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
13
18
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
19
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
20
|
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
16
28
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
29
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
30
|
};
|
|
19
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.AptosStreamClient = exports.default = void 0;
|
|
32
|
+
exports.constants = exports.AptosStreamClient = exports.default = void 0;
|
|
21
33
|
var StreamClient_1 = require("./StreamClient");
|
|
22
34
|
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(StreamClient_1).default; } });
|
|
23
35
|
Object.defineProperty(exports, "AptosStreamClient", { enumerable: true, get: function () { return __importDefault(StreamClient_1).default; } });
|
|
36
|
+
__exportStar(require("./utils"), exports);
|
|
24
37
|
__exportStar(require("./types"), exports);
|
|
38
|
+
exports.constants = __importStar(require("./constants"));
|
package/dist/evm/index.d.ts
CHANGED
package/dist/evm/index.js
CHANGED
|
@@ -10,15 +10,29 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
13
18
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
19
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
20
|
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
16
28
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
29
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
30
|
};
|
|
19
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.EvmStreamClient = exports.default = void 0;
|
|
32
|
+
exports.constants = exports.EvmStreamClient = exports.default = void 0;
|
|
21
33
|
var StreamClient_1 = require("./StreamClient");
|
|
22
34
|
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(StreamClient_1).default; } });
|
|
23
35
|
Object.defineProperty(exports, "EvmStreamClient", { enumerable: true, get: function () { return __importDefault(StreamClient_1).default; } });
|
|
36
|
+
__exportStar(require("./utils"), exports);
|
|
24
37
|
__exportStar(require("./types"), exports);
|
|
38
|
+
exports.constants = __importStar(require("./constants"));
|
|
@@ -59,7 +59,6 @@ export default class SolanaStreamClient extends BaseStreamClient {
|
|
|
59
59
|
* Streams are sorted by start time in ascending order.
|
|
60
60
|
*/
|
|
61
61
|
get({ address, type, direction, }: IGetAllData): Promise<[string, Stream][]>;
|
|
62
|
-
private sign;
|
|
63
62
|
/**
|
|
64
63
|
* Attempts updating the stream auto withdrawal params and amount per period
|
|
65
64
|
*/
|
|
@@ -127,7 +127,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
127
127
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
128
128
|
var bn_js_1 = __importDefault(require("bn.js"));
|
|
129
129
|
var buffer_1 = require("buffer");
|
|
130
|
-
var bs58_1 = __importDefault(require("bs58"));
|
|
131
130
|
var spl_token_1 = require("@solana/spl-token");
|
|
132
131
|
var web3_js_1 = require("@solana/web3.js");
|
|
133
132
|
var spl_token_2 = require("@solana/spl-token");
|
|
@@ -252,7 +251,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
252
251
|
if (metadata) {
|
|
253
252
|
tx.partialSign(metadata);
|
|
254
253
|
}
|
|
255
|
-
return [4 /*yield*/, this.
|
|
254
|
+
return [4 /*yield*/, (0, utils_1.signAndExecuteTransaction)(this.connection, sender, tx, hash)];
|
|
256
255
|
case 9:
|
|
257
256
|
signature = _k.sent();
|
|
258
257
|
return [2 /*return*/, { ixs: ixs, txId: signature, metadataId: metadataPubKey.toBase58() }];
|
|
@@ -353,7 +352,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
353
352
|
if (metadata) {
|
|
354
353
|
tx.partialSign(metadata);
|
|
355
354
|
}
|
|
356
|
-
return [4 /*yield*/, this.
|
|
355
|
+
return [4 /*yield*/, (0, utils_1.signAndExecuteTransaction)(this.connection, sender, tx, hash)];
|
|
357
356
|
case 7:
|
|
358
357
|
signature = _k.sent();
|
|
359
358
|
return [2 /*return*/, { ixs: ixs, txId: signature, metadataId: metadataPubKey.toBase58() }];
|
|
@@ -546,7 +545,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
546
545
|
blockhash: hash.blockhash,
|
|
547
546
|
lastValidBlockHeight: hash.lastValidBlockHeight,
|
|
548
547
|
})).add.apply(_c, __spreadArray([], __read(ixs), false));
|
|
549
|
-
return [4 /*yield*/, this.
|
|
548
|
+
return [4 /*yield*/, (0, utils_1.signAndExecuteTransaction)(this.connection, invoker, tx, hash)];
|
|
550
549
|
case 6:
|
|
551
550
|
signature = _d.sent();
|
|
552
551
|
return [2 /*return*/, { ixs: ixs, txId: signature }];
|
|
@@ -611,7 +610,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
611
610
|
blockhash: hash.blockhash,
|
|
612
611
|
lastValidBlockHeight: hash.lastValidBlockHeight,
|
|
613
612
|
})).add.apply(_c, __spreadArray([], __read(ixs), false));
|
|
614
|
-
return [4 /*yield*/, this.
|
|
613
|
+
return [4 /*yield*/, (0, utils_1.signAndExecuteTransaction)(this.connection, invoker, tx, hash)];
|
|
615
614
|
case 6:
|
|
616
615
|
signature = _d.sent();
|
|
617
616
|
return [2 /*return*/, { ixs: ixs, txId: signature }];
|
|
@@ -669,7 +668,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
669
668
|
blockhash: hash.blockhash,
|
|
670
669
|
lastValidBlockHeight: hash.lastValidBlockHeight,
|
|
671
670
|
})).add.apply(_c, __spreadArray([], __read(ixs), false));
|
|
672
|
-
return [4 /*yield*/, this.
|
|
671
|
+
return [4 /*yield*/, (0, utils_1.signAndExecuteTransaction)(this.connection, invoker, tx, hash)];
|
|
673
672
|
case 4:
|
|
674
673
|
signature = _d.sent();
|
|
675
674
|
return [2 /*return*/, { ixs: ixs, txId: signature }];
|
|
@@ -740,7 +739,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
740
739
|
blockhash: hash.blockhash,
|
|
741
740
|
lastValidBlockHeight: hash.lastValidBlockHeight,
|
|
742
741
|
})).add.apply(_e, __spreadArray(__spreadArray([], __read(nativeInstructions), false), __read(ixs), false));
|
|
743
|
-
return [4 /*yield*/, this.
|
|
742
|
+
return [4 /*yield*/, (0, utils_1.signAndExecuteTransaction)(this.connection, invoker, tx, hash)];
|
|
744
743
|
case 8:
|
|
745
744
|
signature = _f.sent();
|
|
746
745
|
return [2 /*return*/, { ixs: ixs, txId: signature }];
|
|
@@ -815,38 +814,6 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
815
814
|
});
|
|
816
815
|
});
|
|
817
816
|
};
|
|
818
|
-
SolanaStreamClient.prototype.sign = function (invoker, tx, hash) {
|
|
819
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
820
|
-
var signedTx, rawTx, confirmationStrategy, signature;
|
|
821
|
-
return __generator(this, function (_a) {
|
|
822
|
-
switch (_a.label) {
|
|
823
|
-
case 0:
|
|
824
|
-
if (!(0, utils_1.isSignerWallet)(invoker)) return [3 /*break*/, 2];
|
|
825
|
-
return [4 /*yield*/, invoker.signTransaction(tx)];
|
|
826
|
-
case 1:
|
|
827
|
-
signedTx = _a.sent();
|
|
828
|
-
return [3 /*break*/, 3];
|
|
829
|
-
case 2:
|
|
830
|
-
tx.partialSign(invoker);
|
|
831
|
-
signedTx = tx;
|
|
832
|
-
_a.label = 3;
|
|
833
|
-
case 3:
|
|
834
|
-
rawTx = signedTx.serialize();
|
|
835
|
-
if (!hash.lastValidBlockHeight || !signedTx.signature || !hash.blockhash)
|
|
836
|
-
throw Error("Error with transaction parameters.");
|
|
837
|
-
confirmationStrategy = {
|
|
838
|
-
lastValidBlockHeight: hash.lastValidBlockHeight,
|
|
839
|
-
signature: bs58_1.default.encode(signedTx.signature),
|
|
840
|
-
blockhash: hash.blockhash,
|
|
841
|
-
};
|
|
842
|
-
return [4 /*yield*/, (0, web3_js_1.sendAndConfirmRawTransaction)(this.connection, rawTx, confirmationStrategy)];
|
|
843
|
-
case 4:
|
|
844
|
-
signature = _a.sent();
|
|
845
|
-
return [2 /*return*/, signature];
|
|
846
|
-
}
|
|
847
|
-
});
|
|
848
|
-
});
|
|
849
|
-
};
|
|
850
817
|
/**
|
|
851
818
|
* Attempts updating the stream auto withdrawal params and amount per period
|
|
852
819
|
*/
|
|
@@ -882,7 +849,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
882
849
|
blockhash: hash.blockhash,
|
|
883
850
|
lastValidBlockHeight: hash.lastValidBlockHeight,
|
|
884
851
|
}).add(updateIx);
|
|
885
|
-
return [4 /*yield*/, this.
|
|
852
|
+
return [4 /*yield*/, (0, utils_1.signAndExecuteTransaction)(this.connection, invoker, tx, hash)];
|
|
886
853
|
case 3:
|
|
887
854
|
signature = _b.sent();
|
|
888
855
|
return [2 /*return*/, {
|
|
@@ -1047,10 +1014,10 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
1047
1014
|
response = _b.sent();
|
|
1048
1015
|
for (i = 0; i < response.length; i++) {
|
|
1049
1016
|
if (!response[i]) {
|
|
1050
|
-
ixs.push((0, spl_token_2.createAssociatedTokenAccountInstruction)(invoker.publicKey, accountArrays[i][1], accountArrays[i][0], data.mint
|
|
1017
|
+
ixs.push((0, spl_token_2.createAssociatedTokenAccountInstruction)(invoker.publicKey, accountArrays[i][1], accountArrays[i][0], data.mint));
|
|
1051
1018
|
}
|
|
1052
1019
|
}
|
|
1053
|
-
|
|
1020
|
+
return [2 /*return*/];
|
|
1054
1021
|
}
|
|
1055
1022
|
});
|
|
1056
1023
|
});
|
package/dist/solana/types.d.ts
CHANGED
|
@@ -302,4 +302,8 @@ export interface BatchItemSuccess extends BatchItem {
|
|
|
302
302
|
export interface BatchItemError extends BatchItem {
|
|
303
303
|
error: string;
|
|
304
304
|
}
|
|
305
|
+
export interface AtaParams {
|
|
306
|
+
mint: PublicKey;
|
|
307
|
+
owner: PublicKey;
|
|
308
|
+
}
|
|
305
309
|
export declare type BatchItemResult = BatchItemSuccess | BatchItemError;
|
package/dist/solana/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { SignerWalletAdapter } from "@solana/wallet-adapter-base";
|
|
3
|
-
import { Connection, Keypair, PublicKey } from "@solana/web3.js";
|
|
4
|
-
import { DecodedStream, Account, BatchItem, BatchItemResult } from "./types";
|
|
3
|
+
import { Connection, Keypair, PublicKey, Transaction, BlockhashWithExpiryBlockHeight } from "@solana/web3.js";
|
|
4
|
+
import { AtaParams, DecodedStream, Account, BatchItem, BatchItemResult } from "./types";
|
|
5
5
|
export declare const decodeStream: (buf: Buffer) => DecodedStream;
|
|
6
6
|
/**
|
|
7
7
|
* Wrapper function for Solana web3 getProgramAccounts with slightly better call interface
|
|
@@ -17,7 +17,14 @@ export declare function getProgramAccounts(connection: Connection, wallet: Publi
|
|
|
17
17
|
* @param {Keypair | SignerWalletAdapter} walletOrKeypair - Wallet or Keypair in question
|
|
18
18
|
* @return {boolean} - Returns true if parameter is a Wallet.
|
|
19
19
|
*/
|
|
20
|
-
export declare function isSignerWallet(walletOrKeypair: Keypair | SignerWalletAdapter):
|
|
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>;
|
|
21
28
|
/**
|
|
22
29
|
* Sign passed BatchItems with wallet request or KeyPair
|
|
23
30
|
* @param {Keypair | SignerWalletAdapter} sender - Wallet or Keypair of sendin account
|
|
@@ -25,6 +32,15 @@ export declare function isSignerWallet(walletOrKeypair: Keypair | SignerWalletAd
|
|
|
25
32
|
* @return {BatchItem[]} - Returns items with signatures.
|
|
26
33
|
*/
|
|
27
34
|
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>;
|
|
28
44
|
/**
|
|
29
45
|
* Sign passed BatchItems with wallet request or KeyPair
|
|
30
46
|
* @param {Connection} connection - Solana web3 connection object.
|
|
@@ -39,4 +55,30 @@ export declare function sendAndConfirmStreamRawTransaction(connection: Connectio
|
|
|
39
55
|
* @return {Promise<PublicKey>} - Associated Token Address
|
|
40
56
|
*/
|
|
41
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>;
|
|
42
84
|
export declare function extractSolanaErrorCode(errorText: string): string | null;
|
package/dist/solana/utils.js
CHANGED
|
@@ -46,11 +46,36 @@ 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
|
+
};
|
|
49
74
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
75
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
76
|
};
|
|
52
77
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
exports.extractSolanaErrorCode = exports.ata = exports.sendAndConfirmStreamRawTransaction = exports.signAllTransactionWithRecipients = exports.isSignerWallet = exports.getProgramAccounts = exports.decodeStream = void 0;
|
|
78
|
+
exports.extractSolanaErrorCode = exports.createAtaBatch = exports.generateCreateAtaBatchTx = exports.ataBatchExist = exports.ata = exports.sendAndConfirmStreamRawTransaction = exports.signAndExecuteTransaction = exports.signAllTransactionWithRecipients = exports.signTransaction = exports.isSignerKeypair = exports.isSignerWallet = exports.getProgramAccounts = exports.decodeStream = void 0;
|
|
54
79
|
var spl_token_1 = require("@solana/spl-token");
|
|
55
80
|
var web3_js_1 = require("@solana/web3.js");
|
|
56
81
|
var bn_js_1 = __importDefault(require("bn.js"));
|
|
@@ -151,6 +176,28 @@ function isSignerKeypair(walletOrKeypair) {
|
|
|
151
176
|
walletOrKeypair.constructor === web3_js_1.Keypair ||
|
|
152
177
|
walletOrKeypair.constructor.name === web3_js_1.Keypair.prototype.constructor.name);
|
|
153
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;
|
|
154
201
|
/**
|
|
155
202
|
* Sign passed BatchItems with wallet request or KeyPair
|
|
156
203
|
* @param {Keypair | SignerWalletAdapter} sender - Wallet or Keypair of sendin account
|
|
@@ -184,6 +231,39 @@ function signAllTransactionWithRecipients(sender, items) {
|
|
|
184
231
|
});
|
|
185
232
|
}
|
|
186
233
|
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;
|
|
187
267
|
/**
|
|
188
268
|
* Sign passed BatchItems with wallet request or KeyPair
|
|
189
269
|
* @param {Connection} connection - Solana web3 connection object.
|
|
@@ -233,6 +313,112 @@ function ata(mint, owner) {
|
|
|
233
313
|
return (0, spl_token_1.getAssociatedTokenAddress)(mint, owner, true);
|
|
234
314
|
}
|
|
235
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;
|
|
236
422
|
function extractSolanaErrorCode(errorText) {
|
|
237
423
|
var match = constants_1.SOLANA_ERROR_MATCH_REGEX.exec(errorText);
|
|
238
424
|
if (!match) {
|
package/dist/sui/index.d.ts
CHANGED
package/dist/sui/index.js
CHANGED
|
@@ -10,14 +10,28 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
13
18
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
19
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
20
|
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
16
28
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
29
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
30
|
};
|
|
19
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.SuiStreamClient = void 0;
|
|
32
|
+
exports.constants = exports.SuiStreamClient = void 0;
|
|
21
33
|
var StreamClient_1 = require("./StreamClient");
|
|
22
34
|
Object.defineProperty(exports, "SuiStreamClient", { enumerable: true, get: function () { return __importDefault(StreamClient_1).default; } });
|
|
35
|
+
__exportStar(require("./utils"), exports);
|
|
23
36
|
__exportStar(require("./types"), exports);
|
|
37
|
+
exports.constants = __importStar(require("./constants"));
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamflow/stream",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.10.0",
|
|
4
4
|
"description": "JavaScript SDK to interact with Streamflow protocol.",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
5
|
"homepage": "https://github.com/streamflow-finance/js-sdk/",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "rm -rf dist; tsc -p tsconfig.json",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"lint": "eslint .",
|
|
12
12
|
"prepublishOnly": "npm run lint && npm test && npm run build"
|
|
13
13
|
},
|
|
14
|
-
"gitHead": "
|
|
14
|
+
"gitHead": "8f74eb955ac19aa0cddfd4bb93ce00a5136b92a5",
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@types/bn.js": "5.1.1",
|
|
17
17
|
"@types/ethereum-checksum-address": "^0.0.0",
|