@streamflow/stream 5.5.0 → 5.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +5 -6
  3. package/package.json +5 -5
  4. package/dist/__tests__/aptos/streamClient.spec.d.ts +0 -1
  5. package/dist/__tests__/aptos/streamClient.spec.js +0 -161
  6. package/dist/aptos/StreamClient.d.ts +0 -50
  7. package/dist/aptos/StreamClient.js +0 -383
  8. package/dist/aptos/constants.d.ts +0 -2
  9. package/dist/aptos/constants.js +0 -12
  10. package/dist/aptos/index.d.ts +0 -2
  11. package/dist/aptos/index.js +0 -24
  12. package/dist/aptos/types.d.ts +0 -97
  13. package/dist/aptos/types.js +0 -76
  14. package/dist/aptos/wallet.d.ts +0 -9
  15. package/dist/aptos/wallet.js +0 -83
  16. package/dist/common/BaseStreamClient.d.ts +0 -12
  17. package/dist/common/BaseStreamClient.js +0 -9
  18. package/dist/common/GenericStreamClient.d.ts +0 -83
  19. package/dist/common/GenericStreamClient.js +0 -102
  20. package/dist/common/constants.d.ts +0 -1
  21. package/dist/common/constants.js +0 -4
  22. package/dist/common/contractUtils.d.ts +0 -47
  23. package/dist/common/contractUtils.js +0 -55
  24. package/dist/common/types.d.ts +0 -149
  25. package/dist/common/types.js +0 -33
  26. package/dist/common/utils.d.ts +0 -15
  27. package/dist/common/utils.js +0 -34
  28. package/dist/evm/StreamClient.d.ts +0 -29
  29. package/dist/evm/StreamClient.js +0 -456
  30. package/dist/evm/abi.d.ts +0 -111
  31. package/dist/evm/abi.js +0 -1257
  32. package/dist/evm/constants.d.ts +0 -4
  33. package/dist/evm/constants.js +0 -23
  34. package/dist/evm/ercAbi.d.ts +0 -39
  35. package/dist/evm/ercAbi.js +0 -224
  36. package/dist/evm/index.d.ts +0 -2
  37. package/dist/evm/index.js +0 -24
  38. package/dist/evm/types.d.ts +0 -93
  39. package/dist/evm/types.js +0 -75
  40. package/dist/index.d.ts +0 -8
  41. package/dist/index.js +0 -41
  42. package/dist/solana/StreamClient.d.ts +0 -71
  43. package/dist/solana/StreamClient.js +0 -923
  44. package/dist/solana/constants.d.ts +0 -18
  45. package/dist/solana/constants.js +0 -24
  46. package/dist/solana/index.d.ts +0 -7
  47. package/dist/solana/index.js +0 -43
  48. package/dist/solana/instructionTypes.d.ts +0 -96
  49. package/dist/solana/instructionTypes.js +0 -2
  50. package/dist/solana/instructions.d.ts +0 -139
  51. package/dist/solana/instructions.js +0 -407
  52. package/dist/solana/layout.d.ts +0 -27
  53. package/dist/solana/layout.js +0 -170
  54. package/dist/solana/timelockIDL.d.ts +0 -22
  55. package/dist/solana/timelockIDL.js +0 -422
  56. package/dist/solana/types.d.ts +0 -292
  57. package/dist/solana/types.js +0 -81
  58. package/dist/solana/utils.d.ts +0 -43
  59. package/dist/solana/utils.js +0 -283
  60. package/dist/sui/StreamClient.d.ts +0 -78
  61. package/dist/sui/StreamClient.js +0 -545
  62. package/dist/sui/constants.d.ts +0 -4
  63. package/dist/sui/constants.js +0 -24
  64. package/dist/sui/index.d.ts +0 -2
  65. package/dist/sui/index.js +0 -23
  66. package/dist/sui/types.d.ts +0 -131
  67. package/dist/sui/types.js +0 -102
  68. package/dist/sui/wallet.d.ts +0 -11
  69. package/dist/sui/wallet.js +0 -75
@@ -1,81 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.TransferCancelOptions = exports.Contract = exports.Cluster = void 0;
15
- var contractUtils_1 = require("../common/contractUtils");
16
- var utils_1 = require("../common/utils");
17
- var wallet_adapter_base_1 = require("@solana/wallet-adapter-base");
18
- Object.defineProperty(exports, "Cluster", { enumerable: true, get: function () { return wallet_adapter_base_1.WalletAdapterNetwork; } });
19
- var Contract = /** @class */ (function () {
20
- function Contract(stream) {
21
- var _a;
22
- this.magic = stream.magic.toNumber();
23
- this.version = stream.version.toNumber();
24
- this.createdAt = stream.createdAt.toNumber();
25
- this.withdrawnAmount = stream.withdrawnAmount;
26
- this.canceledAt = stream.canceledAt.toNumber();
27
- this.end = stream.end.toNumber();
28
- this.lastWithdrawnAt = stream.lastWithdrawnAt.toNumber();
29
- this.sender = stream.sender.toBase58();
30
- this.senderTokens = stream.senderTokens.toBase58();
31
- this.recipient = stream.recipient.toBase58();
32
- this.recipientTokens = stream.recipientTokens.toBase58();
33
- this.mint = stream.mint.toBase58();
34
- this.escrowTokens = stream.escrowTokens.toBase58();
35
- this.streamflowTreasury = stream.streamflowTreasury.toBase58();
36
- this.streamflowTreasuryTokens = stream.streamflowTreasuryTokens.toBase58();
37
- this.streamflowFeeTotal = stream.streamflowFeeTotal;
38
- this.streamflowFeeWithdrawn = stream.streamflowFeeWithdrawn;
39
- this.streamflowFeePercent = stream.streamflowFeePercent.toNumber();
40
- this.partnerFeeTotal = stream.partnerFeeTotal;
41
- this.partnerFeeWithdrawn = stream.partnerFeeWithdrawn;
42
- this.partnerFeePercent = stream.partnerFeePercent.toNumber();
43
- this.partner = stream.partner.toBase58();
44
- this.partnerTokens = (_a = stream.partnerTokens) === null || _a === void 0 ? void 0 : _a.toBase58();
45
- this.start = stream.start.toNumber();
46
- this.depositedAmount = stream.depositedAmount;
47
- this.period = stream.period.toNumber();
48
- this.amountPerPeriod = stream.amountPerPeriod;
49
- this.cliff = stream.cliff.toNumber();
50
- this.cliffAmount = stream.cliffAmount;
51
- this.cancelableBySender = stream.cancelableBySender;
52
- this.cancelableByRecipient = stream.cancelableByRecipient;
53
- this.automaticWithdrawal = stream.automaticWithdrawal;
54
- this.transferableBySender = stream.transferableBySender;
55
- this.transferableByRecipient = stream.transferableByRecipient;
56
- this.canTopup = stream.canTopup;
57
- this.name = stream.name;
58
- this.withdrawalFrequency = stream.withdrawFrequency.toNumber();
59
- this.closed = stream.closed;
60
- this.currentPauseStart = stream.currentPauseStart.toNumber();
61
- this.pauseCumulative = stream.pauseCumulative;
62
- this.lastRateChangeTime = stream.lastRateChangeTime.toNumber();
63
- this.fundsUnlockedAtLastRateChange = stream.fundsUnlockedAtLastRateChange;
64
- this.type = (0, contractUtils_1.buildStreamType)(this);
65
- }
66
- Contract.prototype.unlocked = function (currentTimestamp) {
67
- return (0, contractUtils_1.calculateUnlockedAmount)(__assign(__assign({}, this), { currentTimestamp: currentTimestamp }));
68
- };
69
- Contract.prototype.remaining = function (decimals) {
70
- return (0, utils_1.getNumberFromBN)(this.depositedAmount.sub(this.withdrawnAmount), decimals);
71
- };
72
- return Contract;
73
- }());
74
- exports.Contract = Contract;
75
- var TransferCancelOptions;
76
- (function (TransferCancelOptions) {
77
- TransferCancelOptions["Recipient"] = "recipient";
78
- TransferCancelOptions["Sender"] = "sender";
79
- TransferCancelOptions["Both"] = "both";
80
- TransferCancelOptions["Neither"] = "neither";
81
- })(TransferCancelOptions = exports.TransferCancelOptions || (exports.TransferCancelOptions = {}));
@@ -1,43 +0,0 @@
1
- /// <reference types="node" />
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";
5
- import { Stream } from "../common/types";
6
- export declare const decodeStream: (buf: Buffer) => DecodedStream;
7
- export declare const formatDecodedStream: (stream: DecodedStream) => Stream;
8
- /**
9
- * Wrapper function for Solana web3 getProgramAccounts with slightly better call interface
10
- * @param {Connection} connection - Solana web3 connection object.
11
- * @param {PublicKey} wallet - PublicKey to compare against.
12
- * @param {number} offset - Offset of bits of the PublicKey in the account binary.
13
- * @param {PublicKey} programId - Solana program ID.
14
- * @return {Promise<Account[]>} - Array of resulting accounts.
15
- */
16
- export declare function getProgramAccounts(connection: Connection, wallet: PublicKey, offset: number, programId: PublicKey): Promise<Account[]>;
17
- /**
18
- * Utility function to check if the transaction initiator is a KeyPair or a Wallet object
19
- * @param {Keypair | SignerWalletAdapter} walletOrKeypair - Wallet or Keypair in question
20
- * @return {boolean} - Returns true if parameter is a Wallet.
21
- */
22
- export declare function isSignerWallet(walletOrKeypair: Keypair | SignerWalletAdapter): boolean;
23
- /**
24
- * Sign passed BatchItems with wallet request or KeyPair
25
- * @param {Keypair | SignerWalletAdapter} sender - Wallet or Keypair of sendin account
26
- * @param {BatchItem[]} items - Multiple recipient contracts split into separate items
27
- * @return {BatchItem[]} - Returns items with signatures.
28
- */
29
- export declare function signAllTransactionWithRecipients(sender: Keypair | SignerWalletAdapter, items: BatchItem[]): Promise<BatchItem[]>;
30
- /**
31
- * Sign passed BatchItems with wallet request or KeyPair
32
- * @param {Connection} connection - Solana web3 connection object.
33
- * @param {BatchItem} batchItem - Signed transaction ready to be send.
34
- * @return {Promise<BatchItemResult>} - Returns settled transaction item
35
- */
36
- export declare function sendAndConfirmStreamRawTransaction(connection: Connection, batchItem: BatchItem): Promise<BatchItemResult>;
37
- /**
38
- * Shorthand call signature for getAssociatedTokenAddress, with allowance for address to be offCurve
39
- * @param {PublicKey} mint - SPL token Mint address.
40
- * @param {PublicKey} owner - Owner of the Associated Token Address
41
- * @return {Promise<PublicKey>} - Associated Token Address
42
- */
43
- export declare function ata(mint: PublicKey, owner: PublicKey): Promise<PublicKey>;
@@ -1,283 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
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
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
- var __importDefault = (this && this.__importDefault) || function (mod) {
50
- return (mod && mod.__esModule) ? mod : { "default": mod };
51
- };
52
- Object.defineProperty(exports, "__esModule", { value: true });
53
- exports.ata = exports.sendAndConfirmStreamRawTransaction = exports.signAllTransactionWithRecipients = exports.isSignerWallet = exports.getProgramAccounts = exports.formatDecodedStream = exports.decodeStream = void 0;
54
- var spl_token_1 = require("@solana/spl-token");
55
- var web3_js_1 = require("@solana/web3.js");
56
- var bn_js_1 = __importDefault(require("bn.js"));
57
- var bs58_1 = __importDefault(require("bs58"));
58
- var layout_1 = require("./layout");
59
- var contractUtils_1 = require("../common/contractUtils");
60
- var decoder = new TextDecoder("utf-8");
61
- var LE = "le"; //little endian
62
- var decodeStream = function (buf) {
63
- var raw = layout_1.streamLayout.decode(buf);
64
- return {
65
- magic: new bn_js_1.default(raw.magic, LE),
66
- version: new bn_js_1.default(raw.version, LE),
67
- createdAt: new bn_js_1.default(raw.created_at, LE),
68
- withdrawnAmount: new bn_js_1.default(raw.withdrawn_amount, LE),
69
- canceledAt: new bn_js_1.default(raw.canceled_at, LE),
70
- end: new bn_js_1.default(raw.end_time, LE),
71
- lastWithdrawnAt: new bn_js_1.default(raw.last_withdrawn_at, LE),
72
- sender: new web3_js_1.PublicKey(raw.sender),
73
- senderTokens: new web3_js_1.PublicKey(raw.sender_tokens),
74
- recipient: new web3_js_1.PublicKey(raw.recipient),
75
- recipientTokens: new web3_js_1.PublicKey(raw.recipient_tokens),
76
- mint: new web3_js_1.PublicKey(raw.mint),
77
- escrowTokens: new web3_js_1.PublicKey(raw.escrow_tokens),
78
- streamflowTreasury: new web3_js_1.PublicKey(raw.streamflow_treasury),
79
- streamflowTreasuryTokens: new web3_js_1.PublicKey(raw.streamflow_treasury_tokens),
80
- streamflowFeeTotal: new bn_js_1.default(raw.streamflow_fee_total, LE),
81
- streamflowFeeWithdrawn: new bn_js_1.default(raw.streamflow_fee_withdrawn, LE),
82
- streamflowFeePercent: new bn_js_1.default(raw.streamflow_fee_percent, LE),
83
- partnerFeeTotal: new bn_js_1.default(raw.partner_fee_total, LE),
84
- partnerFeeWithdrawn: new bn_js_1.default(raw.partner_fee_withdrawn, LE),
85
- partnerFeePercent: new bn_js_1.default(raw.partner_fee_percent, LE),
86
- partner: new web3_js_1.PublicKey(raw.partner),
87
- partnerTokens: new web3_js_1.PublicKey(raw.partner_tokens),
88
- start: new bn_js_1.default(raw.start_time, LE),
89
- depositedAmount: new bn_js_1.default(raw.net_amount_deposited, LE),
90
- period: new bn_js_1.default(raw.period, LE),
91
- amountPerPeriod: new bn_js_1.default(raw.amount_per_period, LE),
92
- cliff: new bn_js_1.default(raw.cliff, LE),
93
- cliffAmount: new bn_js_1.default(raw.cliff_amount, LE),
94
- cancelableBySender: Boolean(raw.cancelable_by_sender),
95
- cancelableByRecipient: Boolean(raw.cancelable_by_recipient),
96
- automaticWithdrawal: Boolean(raw.automatic_withdrawal),
97
- transferableBySender: Boolean(raw.transferable_by_sender),
98
- transferableByRecipient: Boolean(raw.transferable_by_recipient),
99
- canTopup: Boolean(raw.can_topup),
100
- name: decoder.decode(raw.stream_name),
101
- withdrawFrequency: new bn_js_1.default(raw.withdraw_frequency, LE),
102
- closed: Boolean(raw.closed),
103
- currentPauseStart: new bn_js_1.default(raw.current_pause_start, LE),
104
- pauseCumulative: new bn_js_1.default(raw.pause_cumulative, LE),
105
- lastRateChangeTime: new bn_js_1.default(raw.last_rate_change_time, LE),
106
- fundsUnlockedAtLastRateChange: new bn_js_1.default(raw.funds_unlocked_at_last_rate_change, LE),
107
- };
108
- };
109
- exports.decodeStream = decodeStream;
110
- // DeprecationWarning: This object will be deprecated starting from the version 4.0.0. Use
111
- // types/Contract instead
112
- var formatDecodedStream = function (stream) {
113
- var _a;
114
- var resp = {
115
- magic: stream.magic.toNumber(),
116
- version: stream.version.toNumber(),
117
- createdAt: stream.createdAt.toNumber(),
118
- withdrawnAmount: stream.withdrawnAmount,
119
- canceledAt: stream.canceledAt.toNumber(),
120
- end: stream.end.toNumber(),
121
- lastWithdrawnAt: stream.lastWithdrawnAt.toNumber(),
122
- sender: stream.sender.toBase58(),
123
- senderTokens: stream.senderTokens.toBase58(),
124
- recipient: stream.recipient.toBase58(),
125
- recipientTokens: stream.recipientTokens.toBase58(),
126
- mint: stream.mint.toBase58(),
127
- escrowTokens: stream.escrowTokens.toBase58(),
128
- streamflowTreasury: stream.streamflowTreasury.toBase58(),
129
- streamflowTreasuryTokens: stream.streamflowTreasuryTokens.toBase58(),
130
- streamflowFeeTotal: stream.streamflowFeeTotal,
131
- streamflowFeeWithdrawn: stream.streamflowFeeWithdrawn,
132
- streamflowFeePercent: stream.streamflowFeePercent.toNumber(),
133
- partnerFeeTotal: stream.partnerFeeTotal,
134
- partnerFeeWithdrawn: stream.partnerFeeWithdrawn,
135
- partnerFeePercent: stream.partnerFeePercent.toNumber(),
136
- partner: stream.partner.toBase58(),
137
- partnerTokens: (_a = stream.partnerTokens) === null || _a === void 0 ? void 0 : _a.toBase58(),
138
- start: stream.start.toNumber(),
139
- depositedAmount: stream.depositedAmount,
140
- period: stream.period.toNumber(),
141
- amountPerPeriod: stream.amountPerPeriod,
142
- cliff: stream.cliff.toNumber(),
143
- cliffAmount: stream.cliffAmount,
144
- cancelableBySender: stream.cancelableBySender,
145
- cancelableByRecipient: stream.cancelableByRecipient,
146
- automaticWithdrawal: stream.automaticWithdrawal,
147
- transferableBySender: stream.transferableBySender,
148
- transferableByRecipient: stream.transferableByRecipient,
149
- canTopup: stream.canTopup,
150
- name: stream.name,
151
- withdrawalFrequency: stream.withdrawFrequency.toNumber(),
152
- closed: stream.closed,
153
- currentPauseStart: stream.currentPauseStart.toNumber(),
154
- pauseCumulative: stream.pauseCumulative,
155
- lastRateChangeTime: stream.lastRateChangeTime.toNumber(),
156
- fundsUnlockedAtLastRateChange: stream.fundsUnlockedAtLastRateChange,
157
- type: (0, contractUtils_1.buildStreamType)(stream),
158
- unlocked: function () {
159
- return new bn_js_1.default(0);
160
- },
161
- withdrawn: function () {
162
- return new bn_js_1.default(0);
163
- }, //phantom method to preserve partial support of this object
164
- };
165
- return resp;
166
- };
167
- exports.formatDecodedStream = formatDecodedStream;
168
- /**
169
- * Wrapper function for Solana web3 getProgramAccounts with slightly better call interface
170
- * @param {Connection} connection - Solana web3 connection object.
171
- * @param {PublicKey} wallet - PublicKey to compare against.
172
- * @param {number} offset - Offset of bits of the PublicKey in the account binary.
173
- * @param {PublicKey} programId - Solana program ID.
174
- * @return {Promise<Account[]>} - Array of resulting accounts.
175
- */
176
- function getProgramAccounts(connection, wallet, offset, programId) {
177
- return __awaiter(this, void 0, void 0, function () {
178
- return __generator(this, function (_a) {
179
- return [2 /*return*/, connection === null || connection === void 0 ? void 0 : connection.getProgramAccounts(programId, {
180
- filters: [
181
- {
182
- memcmp: {
183
- offset: offset,
184
- bytes: wallet.toBase58(),
185
- },
186
- },
187
- ],
188
- })];
189
- });
190
- });
191
- }
192
- exports.getProgramAccounts = getProgramAccounts;
193
- /**
194
- * Utility function to check if the transaction initiator is a KeyPair or a Wallet object
195
- * @param {Keypair | SignerWalletAdapter} walletOrKeypair - Wallet or Keypair in question
196
- * @return {boolean} - Returns true if parameter is a Wallet.
197
- */
198
- function isSignerWallet(walletOrKeypair) {
199
- return walletOrKeypair.signTransaction !== undefined;
200
- }
201
- exports.isSignerWallet = isSignerWallet;
202
- /**
203
- * Sign passed BatchItems with wallet request or KeyPair
204
- * @param {Keypair | SignerWalletAdapter} sender - Wallet or Keypair of sendin account
205
- * @param {BatchItem[]} items - Multiple recipient contracts split into separate items
206
- * @return {BatchItem[]} - Returns items with signatures.
207
- */
208
- function signAllTransactionWithRecipients(sender, items) {
209
- return __awaiter(this, void 0, void 0, function () {
210
- var isKeypair, isWallet, signedTxs_1;
211
- return __generator(this, function (_a) {
212
- switch (_a.label) {
213
- case 0:
214
- isKeypair = sender instanceof web3_js_1.Keypair;
215
- isWallet = isSignerWallet(sender);
216
- if (!isKeypair) return [3 /*break*/, 1];
217
- return [2 /*return*/, items.map(function (t) {
218
- t.tx.partialSign(sender);
219
- return { tx: t.tx, recipient: t.recipient };
220
- })];
221
- case 1:
222
- if (!isWallet) return [3 /*break*/, 3];
223
- return [4 /*yield*/, sender.signAllTransactions(items.map(function (t) { return t.tx; }))];
224
- case 2:
225
- signedTxs_1 = _a.sent();
226
- return [2 /*return*/, items.map(function (item, index) { return (__assign(__assign({}, item), { tx: signedTxs_1[index] })); })];
227
- case 3:
228
- // If signer is not passed
229
- return [2 /*return*/, []];
230
- }
231
- });
232
- });
233
- }
234
- exports.signAllTransactionWithRecipients = signAllTransactionWithRecipients;
235
- /**
236
- * Sign passed BatchItems with wallet request or KeyPair
237
- * @param {Connection} connection - Solana web3 connection object.
238
- * @param {BatchItem} batchItem - Signed transaction ready to be send.
239
- * @return {Promise<BatchItemResult>} - Returns settled transaction item
240
- */
241
- function sendAndConfirmStreamRawTransaction(connection, batchItem) {
242
- var _a, _b;
243
- return __awaiter(this, void 0, void 0, function () {
244
- var rawTx, _c, lastValidBlockHeight, signature, recentBlockhash, confirmationStrategy, completedTxSignature, error_1;
245
- return __generator(this, function (_d) {
246
- switch (_d.label) {
247
- case 0:
248
- _d.trys.push([0, 2, , 3]);
249
- rawTx = batchItem.tx.serialize();
250
- _c = batchItem.tx, lastValidBlockHeight = _c.lastValidBlockHeight, signature = _c.signature, recentBlockhash = _c.recentBlockhash;
251
- if (!lastValidBlockHeight || !signature || !recentBlockhash)
252
- throw { recipient: batchItem.recipient, error: "no recent blockhash" };
253
- confirmationStrategy = {
254
- lastValidBlockHeight: lastValidBlockHeight,
255
- signature: bs58_1.default.encode(signature),
256
- blockhash: recentBlockhash,
257
- };
258
- return [4 /*yield*/, (0, web3_js_1.sendAndConfirmRawTransaction)(connection, rawTx, confirmationStrategy)];
259
- case 1:
260
- completedTxSignature = _d.sent();
261
- return [2 /*return*/, __assign(__assign({}, batchItem), { signature: completedTxSignature })];
262
- case 2:
263
- error_1 = _d.sent();
264
- throw {
265
- recipient: batchItem.recipient,
266
- error: (_b = (_a = error_1 === null || error_1 === void 0 ? void 0 : error_1.error) !== null && _a !== void 0 ? _a : error_1 === null || error_1 === void 0 ? void 0 : error_1.message) !== null && _b !== void 0 ? _b : error_1.toString(),
267
- };
268
- case 3: return [2 /*return*/];
269
- }
270
- });
271
- });
272
- }
273
- exports.sendAndConfirmStreamRawTransaction = sendAndConfirmStreamRawTransaction;
274
- /**
275
- * Shorthand call signature for getAssociatedTokenAddress, with allowance for address to be offCurve
276
- * @param {PublicKey} mint - SPL token Mint address.
277
- * @param {PublicKey} owner - Owner of the Associated Token Address
278
- * @return {Promise<PublicKey>} - Associated Token Address
279
- */
280
- function ata(mint, owner) {
281
- return (0, spl_token_1.getAssociatedTokenAddress)(mint, owner, true);
282
- }
283
- exports.ata = ata;
@@ -1,78 +0,0 @@
1
- import { BaseStreamClient } from "../common/BaseStreamClient";
2
- import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetOneData, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData } from "../common/types";
3
- import { Contract, ICreateStreamSuiExt, ITransactionSuiExt, ISuiIdParameters } from "./types";
4
- export default class SuiStreamClient extends BaseStreamClient {
5
- private programId;
6
- private configId;
7
- private feeTableId;
8
- private client;
9
- constructor(clusterUrl: string, cluster?: ICluster, ids?: ISuiIdParameters);
10
- /**
11
- * Creates a new stream/vesting contract.
12
- */
13
- create(streamData: ICreateStreamData, { senderWallet }: ICreateStreamSuiExt): Promise<ICreateResult>;
14
- /**
15
- * Creates multiple stream/vesting contracts.
16
- * We don't chain transactions in one Block so that one failed transaction does not revert all others.
17
- */
18
- createMultiple(multipleStreamData: ICreateMultipleStreamData, { senderWallet }: ICreateStreamSuiExt): Promise<IMultiTransactionResult>;
19
- /**
20
- * Attempts withdrawing from the specified stream.
21
- */
22
- withdraw(withdrawData: IWithdrawData, { senderWallet, tokenId }: ITransactionSuiExt): Promise<ITransactionResult>;
23
- /**
24
- * Attempts canceling the specified stream.
25
- */
26
- cancel(cancelData: ICancelData, { senderWallet, tokenId }: ITransactionSuiExt): Promise<ITransactionResult>;
27
- /**
28
- * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
29
- */
30
- transfer(transferData: ITransferData, { senderWallet, tokenId }: ITransactionSuiExt): Promise<ITransactionResult>;
31
- /**
32
- * Tops up stream account with specified amount.
33
- */
34
- topup(topupData: ITopUpData, { senderWallet, tokenId }: ITransactionSuiExt): Promise<ITransactionResult>;
35
- /**
36
- * Fetch stream data by its id (address).
37
- */
38
- getOne({ id }: IGetOneData): Promise<Contract>;
39
- get(): Promise<[string, Contract][]>;
40
- /**
41
- * Attempts updating the stream auto withdrawal params and amount per period
42
- */
43
- update(updateData: IUpdateData, { senderWallet, tokenId }: ITransactionSuiExt): Promise<ITransactionResult>;
44
- /**
45
- * Returns StreamClient protocol program ID.
46
- */
47
- getProgramId(): string;
48
- /**
49
- * Utility function to generate Transaction Block to create streams
50
- */
51
- private generateCreateTransactions;
52
- /**
53
- * Returns all coins owned by a Wallet
54
- * @param walletAddress wallet address
55
- * @param coinType coin type
56
- * @returns Array of Coin Structs
57
- */
58
- private getAllCoins;
59
- /**
60
- * Utility function to split Coin object and use splitted object for stream operations.
61
- * We do it like thid to mitigate risk of Transaction reverting in case Stream is created for Sui Coin object.
62
- * This way we can safely pass splitted Sui Coin object in Stream payload and use another object for gas/withdrawal fees.
63
- * @param txb current transanction block
64
- * @param amount minimal amount of coins requried
65
- * @param coinType coin type
66
- * @param coins array of owned coins of the same type
67
- * @returns Coin Object to use in a Move Call
68
- */
69
- private splitCoinObjectForAmount;
70
- /**
71
- * Return previously splitted Coin Object to owner and merge it to to rebate storage fees
72
- * @param txb current transanction block
73
- * @param coinType coin type
74
- * @param coinObject splitted object
75
- * @param coins array of objects used in
76
- */
77
- private returnSplittedCoinObject;
78
- }