@streamflow/stream 3.0.16 → 4.0.0-Alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/aptos/streamClient.spec.d.ts +1 -0
- package/dist/__tests__/aptos/streamClient.spec.js +160 -0
- package/dist/aptos/StreamClient.d.ts +20 -0
- package/dist/aptos/StreamClient.js +297 -0
- package/dist/aptos/constants.d.ts +2 -0
- package/dist/aptos/constants.js +12 -0
- package/dist/aptos/index.d.ts +2 -0
- package/dist/aptos/index.js +23 -0
- package/dist/aptos/types.d.ts +10 -0
- package/dist/aptos/types.js +2 -0
- package/dist/common/StreamClient.d.ts +10 -0
- package/dist/common/StreamClient.js +9 -0
- package/dist/common/types.d.ts +61 -0
- package/dist/common/types.js +23 -0
- package/dist/{utils.d.ts → common/utils.d.ts} +0 -4
- package/dist/common/utils.js +31 -0
- package/dist/index.d.ts +4 -6
- package/dist/index.js +17 -13
- package/dist/{StreamClient.d.ts → solana/StreamClient.d.ts} +17 -17
- package/dist/{StreamClient.js → solana/StreamClient.js} +245 -309
- package/dist/{constants.d.ts → solana/constants.d.ts} +1 -1
- package/dist/{constants.js → solana/constants.js} +5 -5
- package/dist/solana/index.d.ts +7 -0
- package/dist/solana/index.js +42 -0
- package/dist/solana/instructionTypes.d.ts +81 -0
- package/dist/solana/instructionTypes.js +2 -0
- package/dist/{instructions.d.ts → solana/instructions.d.ts} +0 -2
- package/dist/{instructions.js → solana/instructions.js} +23 -38
- package/dist/solana/layout.d.ts +22 -0
- package/dist/{layout.js → solana/layout.js} +27 -2
- package/dist/{idl/timelock.d.ts → solana/timelockIDL.d.ts} +0 -0
- package/dist/{idl/timelock.js → solana/timelockIDL.js} +0 -0
- package/dist/{types.d.ts → solana/types.d.ts} +37 -34
- package/dist/{types.js → solana/types.js} +3 -20
- package/dist/solana/utils.d.ts +42 -0
- package/dist/solana/utils.js +269 -0
- package/package.json +24 -11
- package/dist/Stream.d.ts +0 -87
- package/dist/Stream.js +0 -503
- package/dist/__tests__/test_dependencies/airdrop/airdrop-request.d.ts +0 -3
- package/dist/__tests__/test_dependencies/airdrop/airdrop-request.js +0 -67
- package/dist/__tests__/test_dependencies/airdrop/airdrop.d.ts +0 -6
- package/dist/__tests__/test_dependencies/airdrop/airdrop.js +0 -215
- package/dist/__tests__/test_dependencies/constants/index.d.ts +0 -122
- package/dist/__tests__/test_dependencies/constants/index.js +0 -158
- package/dist/__tests__/test_dependencies/idl/airdrop.d.ts +0 -27
- package/dist/__tests__/test_dependencies/idl/airdrop.js +0 -171
- package/dist/layout.d.ts +0 -22
- package/dist/utils.js +0 -126
|
@@ -3,15 +3,15 @@ var _a;
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.BASE_FEE = exports.AIRDROP_AMOUNT = exports.AIRDROP_TEST_TOKEN = exports.FEE_ORACLE_PUBLIC_KEY = exports.WITHDRAWOR_PUBLIC_KEY = exports.STREAMFLOW_TREASURY_PUBLIC_KEY = exports.STREAMFLOW_DEVNET_PROGRAM_ID = exports.STREAMFLOW_PROGRAM_ID = exports.PROGRAM_ID = exports.STREAM_STRUCT_OFFSET_RECIPIENT = exports.STREAM_STRUCT_OFFSET_SENDER = exports.TX_FINALITY_CONFIRMED = void 0;
|
|
5
5
|
var web3_js_1 = require("@solana/web3.js");
|
|
6
|
-
var types_1 = require("
|
|
6
|
+
var types_1 = require("../common/types");
|
|
7
7
|
exports.TX_FINALITY_CONFIRMED = "confirmed";
|
|
8
8
|
exports.STREAM_STRUCT_OFFSET_SENDER = 49;
|
|
9
9
|
exports.STREAM_STRUCT_OFFSET_RECIPIENT = 113;
|
|
10
10
|
exports.PROGRAM_ID = (_a = {},
|
|
11
|
-
_a[types_1.
|
|
12
|
-
_a[types_1.
|
|
13
|
-
_a[types_1.
|
|
14
|
-
_a[types_1.
|
|
11
|
+
_a[types_1.ICluster.Devnet] = "HqDGZjaVRXJ9MGRQEw7qDc2rAr6iH1n1kAQdCZaCMfMZ",
|
|
12
|
+
_a[types_1.ICluster.Mainnet] = "strmRqUCoQUgGUan5YhzUZa6KqdzwX5L6FpUxfmKg5m",
|
|
13
|
+
_a[types_1.ICluster.Testnet] = "HqDGZjaVRXJ9MGRQEw7qDc2rAr6iH1n1kAQdCZaCMfMZ",
|
|
14
|
+
_a[types_1.ICluster.Local] = "HqDGZjaVRXJ9MGRQEw7qDc2rAr6iH1n1kAQdCZaCMfMZ",
|
|
15
15
|
_a);
|
|
16
16
|
exports.STREAMFLOW_PROGRAM_ID = "strmRqUCoQUgGUan5YhzUZa6KqdzwX5L6FpUxfmKg5m";
|
|
17
17
|
exports.STREAMFLOW_DEVNET_PROGRAM_ID = "FGjLaVo5zLGdzCxMo9gu9tXr1kzTToKd8C8K7YS5hNM1";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default } from "./StreamClient";
|
|
2
|
+
export * from "./utils";
|
|
3
|
+
export * from "./types";
|
|
4
|
+
export * from "./instructions";
|
|
5
|
+
export * as constants from "./constants";
|
|
6
|
+
export { default as timelockIDL } from "./timelockIDL";
|
|
7
|
+
export { default as BN } from "bn.js";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
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
|
+
});
|
|
18
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
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
|
+
};
|
|
28
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
29
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.BN = exports.timelockIDL = exports.constants = exports.default = void 0;
|
|
33
|
+
var StreamClient_1 = require("./StreamClient");
|
|
34
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(StreamClient_1).default; } });
|
|
35
|
+
__exportStar(require("./utils"), exports);
|
|
36
|
+
__exportStar(require("./types"), exports);
|
|
37
|
+
__exportStar(require("./instructions"), exports);
|
|
38
|
+
exports.constants = __importStar(require("./constants"));
|
|
39
|
+
var timelockIDL_1 = require("./timelockIDL");
|
|
40
|
+
Object.defineProperty(exports, "timelockIDL", { enumerable: true, get: function () { return __importDefault(timelockIDL_1).default; } });
|
|
41
|
+
var bn_js_1 = require("bn.js");
|
|
42
|
+
Object.defineProperty(exports, "BN", { enumerable: true, get: function () { return __importDefault(bn_js_1).default; } });
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export interface IStreamLayout {
|
|
2
|
+
magic: Uint8Array;
|
|
3
|
+
version: Uint8Array;
|
|
4
|
+
created_at: Uint8Array;
|
|
5
|
+
withdrawn_amount: Uint8Array;
|
|
6
|
+
canceled_at: Uint8Array;
|
|
7
|
+
end_time: Uint8Array;
|
|
8
|
+
last_withdrawn_at: Uint8Array;
|
|
9
|
+
sender: Uint8Array;
|
|
10
|
+
sender_tokens: Uint8Array;
|
|
11
|
+
recipient: Uint8Array;
|
|
12
|
+
recipient_tokens: Uint8Array;
|
|
13
|
+
mint: Uint8Array;
|
|
14
|
+
escrow_tokens: Uint8Array;
|
|
15
|
+
streamflow_treasury: Uint8Array;
|
|
16
|
+
streamflow_treasury_tokens: Uint8Array;
|
|
17
|
+
streamflow_fee_total: Uint8Array;
|
|
18
|
+
streamflow_fee_withdrawn: Uint8Array;
|
|
19
|
+
streamflow_fee_percent: number;
|
|
20
|
+
partner: Uint8Array;
|
|
21
|
+
partner_tokens: Uint8Array;
|
|
22
|
+
partner_fee_total: Uint8Array;
|
|
23
|
+
partner_fee_withdrawn: Uint8Array;
|
|
24
|
+
partner_fee_percent: number;
|
|
25
|
+
start_time: Uint8Array;
|
|
26
|
+
net_amount_deposited: Uint8Array;
|
|
27
|
+
period: Uint8Array;
|
|
28
|
+
amount_per_period: Uint8Array;
|
|
29
|
+
cliff: Uint8Array;
|
|
30
|
+
cliff_amount: Uint8Array;
|
|
31
|
+
cancelable_by_sender: number;
|
|
32
|
+
cancelable_by_recipient: number;
|
|
33
|
+
automatic_withdrawal: number;
|
|
34
|
+
transferable_by_sender: number;
|
|
35
|
+
transferable_by_recipient: number;
|
|
36
|
+
can_topup: number;
|
|
37
|
+
stream_name: Uint8Array;
|
|
38
|
+
withdraw_frequency: Uint8Array;
|
|
39
|
+
}
|
|
40
|
+
export interface ICreateStreamLayout {
|
|
41
|
+
start_time: Uint8Array;
|
|
42
|
+
net_amount_deposited: Uint8Array;
|
|
43
|
+
period: Uint8Array;
|
|
44
|
+
amount_per_period: Uint8Array;
|
|
45
|
+
cliff: Uint8Array;
|
|
46
|
+
cliff_amount: Uint8Array;
|
|
47
|
+
cancelable_by_sender: number;
|
|
48
|
+
cancelable_by_recipient: number;
|
|
49
|
+
automatic_withdrawal: number;
|
|
50
|
+
transferable_by_sender: number;
|
|
51
|
+
transferable_by_recipient: number;
|
|
52
|
+
can_topup: number;
|
|
53
|
+
stream_name: Uint8Array;
|
|
54
|
+
withdraw_frequency: Uint8Array;
|
|
55
|
+
}
|
|
56
|
+
export interface ICreateUncheckedStreamLayout {
|
|
57
|
+
start_time: Uint8Array;
|
|
58
|
+
net_amount_deposited: Uint8Array;
|
|
59
|
+
period: Uint8Array;
|
|
60
|
+
amount_per_period: Uint8Array;
|
|
61
|
+
cliff: Uint8Array;
|
|
62
|
+
cliff_amount: Uint8Array;
|
|
63
|
+
cancelable_by_sender: number;
|
|
64
|
+
cancelable_by_recipient: number;
|
|
65
|
+
automatic_withdrawal: number;
|
|
66
|
+
transferable_by_sender: number;
|
|
67
|
+
transferable_by_recipient: number;
|
|
68
|
+
can_topup: number;
|
|
69
|
+
stream_name: Uint8Array;
|
|
70
|
+
withdraw_frequency: Uint8Array;
|
|
71
|
+
recipient: Uint8Array;
|
|
72
|
+
partner: Uint8Array;
|
|
73
|
+
pausable: number;
|
|
74
|
+
can_update_rate: number;
|
|
75
|
+
}
|
|
76
|
+
export interface IWithdrawStreamLayout {
|
|
77
|
+
amount: Uint8Array;
|
|
78
|
+
}
|
|
79
|
+
export interface ITopupStreamLayout {
|
|
80
|
+
amount: Uint8Array;
|
|
81
|
+
}
|
|
@@ -127,7 +127,5 @@ interface TopupAccounts {
|
|
|
127
127
|
systemProgram: PublicKey;
|
|
128
128
|
}
|
|
129
129
|
export declare const topupStreamInstruction: (amount: BN, programId: PublicKey, { sender, senderTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, withdrawor, systemProgram, }: TopupAccounts) => TransactionInstruction;
|
|
130
|
-
export declare const syncNativeInstructionData: import("@solana/buffer-layout").Structure<any>;
|
|
131
|
-
export declare const createSyncNativeInstruction: (account: PublicKey) => TransactionInstruction;
|
|
132
130
|
export declare const prepareWrappedAccount: (connection: Connection, senderAddress: PublicKey, amount: BN) => Promise<TransactionInstruction[]>;
|
|
133
131
|
export {};
|
|
@@ -87,14 +87,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
87
87
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
88
88
|
};
|
|
89
89
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
90
|
-
exports.prepareWrappedAccount = exports.
|
|
90
|
+
exports.prepareWrappedAccount = exports.topupStreamInstruction = exports.transferStreamInstruction = exports.cancelStreamInstruction = exports.withdrawStreamInstruction = exports.createUncheckedStreamInstruction = exports.createStreamInstruction = void 0;
|
|
91
91
|
var buffer_1 = require("buffer");
|
|
92
92
|
var web3_js_1 = require("@solana/web3.js");
|
|
93
93
|
var bn_js_1 = __importDefault(require("bn.js"));
|
|
94
94
|
var js_sha256_1 = require("js-sha256");
|
|
95
|
-
var buffer_layout_1 = require("@solana/buffer-layout");
|
|
96
|
-
var Layout = __importStar(require("./layout"));
|
|
97
95
|
var spl_token_1 = require("@solana/spl-token");
|
|
96
|
+
var Layout = __importStar(require("./layout"));
|
|
98
97
|
var constants_1 = require("./constants");
|
|
99
98
|
var createStreamInstruction = function (data, programId, accounts) {
|
|
100
99
|
var keys = [
|
|
@@ -139,12 +138,12 @@ var createStreamInstruction = function (data, programId, accounts) {
|
|
|
139
138
|
amount_per_period: data.amountPerPeriod.toArrayLike(buffer_1.Buffer, "le", 8),
|
|
140
139
|
cliff: data.cliff.toArrayLike(buffer_1.Buffer, "le", 8),
|
|
141
140
|
cliff_amount: data.cliffAmount.toArrayLike(buffer_1.Buffer, "le", 8),
|
|
142
|
-
cancelable_by_sender: data.cancelableBySender,
|
|
143
|
-
cancelable_by_recipient: data.cancelableByRecipient,
|
|
144
|
-
automatic_withdrawal: data.automaticWithdrawal,
|
|
145
|
-
transferable_by_sender: data.transferableBySender,
|
|
146
|
-
transferable_by_recipient: data.transferableByRecipient,
|
|
147
|
-
can_topup: data.canTopup,
|
|
141
|
+
cancelable_by_sender: Number(data.cancelableBySender),
|
|
142
|
+
cancelable_by_recipient: Number(data.cancelableByRecipient),
|
|
143
|
+
automatic_withdrawal: Number(data.automaticWithdrawal),
|
|
144
|
+
transferable_by_sender: Number(data.transferableBySender),
|
|
145
|
+
transferable_by_recipient: Number(data.transferableByRecipient),
|
|
146
|
+
can_topup: Number(data.canTopup),
|
|
148
147
|
stream_name: streamNameBuffer,
|
|
149
148
|
withdraw_frequency: data.withdrawFrequency.toArrayLike(buffer_1.Buffer, "le", 8),
|
|
150
149
|
};
|
|
@@ -153,7 +152,7 @@ var createStreamInstruction = function (data, programId, accounts) {
|
|
|
153
152
|
bufferData = buffer_1.Buffer.concat([
|
|
154
153
|
buffer_1.Buffer.from(js_sha256_1.sha256.digest("global:create")).slice(0, 8),
|
|
155
154
|
bufferData,
|
|
156
|
-
buffer_1.Buffer.alloc(10)
|
|
155
|
+
buffer_1.Buffer.alloc(10),
|
|
157
156
|
]);
|
|
158
157
|
return new web3_js_1.TransactionInstruction({
|
|
159
158
|
keys: keys,
|
|
@@ -193,29 +192,25 @@ var createUncheckedStreamInstruction = function (data, programId, accounts) {
|
|
|
193
192
|
amount_per_period: data.amountPerPeriod.toArrayLike(buffer_1.Buffer, "le", 8),
|
|
194
193
|
cliff: data.cliff.toArrayLike(buffer_1.Buffer, "le", 8),
|
|
195
194
|
cliff_amount: data.cliffAmount.toArrayLike(buffer_1.Buffer, "le", 8),
|
|
196
|
-
cancelable_by_sender: data.cancelableBySender,
|
|
197
|
-
cancelable_by_recipient: data.cancelableByRecipient,
|
|
198
|
-
automatic_withdrawal: data.automaticWithdrawal,
|
|
199
|
-
transferable_by_sender: data.transferableBySender,
|
|
200
|
-
transferable_by_recipient: data.transferableByRecipient,
|
|
201
|
-
can_topup: data.canTopup,
|
|
195
|
+
cancelable_by_sender: Number(data.cancelableBySender),
|
|
196
|
+
cancelable_by_recipient: Number(data.cancelableByRecipient),
|
|
197
|
+
automatic_withdrawal: Number(data.automaticWithdrawal),
|
|
198
|
+
transferable_by_sender: Number(data.transferableBySender),
|
|
199
|
+
transferable_by_recipient: Number(data.transferableByRecipient),
|
|
200
|
+
can_topup: Number(data.canTopup),
|
|
202
201
|
stream_name: streamNameBuffer,
|
|
203
202
|
withdraw_frequency: data.withdrawFrequency.toArrayLike(buffer_1.Buffer, "le", 8),
|
|
204
203
|
recipient: data.recipient.toBuffer(),
|
|
205
204
|
partner: data.partner.toBuffer(),
|
|
206
|
-
pausable:
|
|
207
|
-
can_update_rate:
|
|
205
|
+
pausable: 1,
|
|
206
|
+
can_update_rate: 1,
|
|
208
207
|
};
|
|
209
208
|
var encodeLength = Layout.createUncheckedStreamLayout.encode(decodedData, bufferData);
|
|
210
209
|
bufferData = bufferData.slice(0, encodeLength);
|
|
211
210
|
var digest = accounts.payer
|
|
212
211
|
? js_sha256_1.sha256.digest("global:create_unchecked_with_payer")
|
|
213
212
|
: js_sha256_1.sha256.digest("global:create_unchecked");
|
|
214
|
-
bufferData = buffer_1.Buffer.concat([
|
|
215
|
-
buffer_1.Buffer.from(digest).slice(0, 8),
|
|
216
|
-
bufferData,
|
|
217
|
-
buffer_1.Buffer.alloc(10),
|
|
218
|
-
]);
|
|
213
|
+
bufferData = buffer_1.Buffer.concat([buffer_1.Buffer.from(digest).slice(0, 8), bufferData, buffer_1.Buffer.alloc(10)]);
|
|
219
214
|
return new web3_js_1.TransactionInstruction({
|
|
220
215
|
keys: keys,
|
|
221
216
|
programId: programId,
|
|
@@ -249,7 +244,7 @@ var withdrawStreamInstruction = function (amount, programId, _a) {
|
|
|
249
244
|
data = buffer_1.Buffer.concat([
|
|
250
245
|
buffer_1.Buffer.from(js_sha256_1.sha256.digest("global:withdraw")).slice(0, 8),
|
|
251
246
|
data,
|
|
252
|
-
buffer_1.Buffer.alloc(10)
|
|
247
|
+
buffer_1.Buffer.alloc(10),
|
|
253
248
|
]);
|
|
254
249
|
return new web3_js_1.TransactionInstruction({
|
|
255
250
|
keys: keys,
|
|
@@ -341,7 +336,7 @@ var topupStreamInstruction = function (amount, programId, _a) {
|
|
|
341
336
|
data = buffer_1.Buffer.concat([
|
|
342
337
|
buffer_1.Buffer.from(js_sha256_1.sha256.digest("global:topup")).slice(0, 8),
|
|
343
338
|
data,
|
|
344
|
-
buffer_1.Buffer.alloc(10)
|
|
339
|
+
buffer_1.Buffer.alloc(10),
|
|
345
340
|
]);
|
|
346
341
|
return new web3_js_1.TransactionInstruction({
|
|
347
342
|
keys: keys,
|
|
@@ -350,22 +345,12 @@ var topupStreamInstruction = function (amount, programId, _a) {
|
|
|
350
345
|
});
|
|
351
346
|
};
|
|
352
347
|
exports.topupStreamInstruction = topupStreamInstruction;
|
|
353
|
-
// TODO: Use native createSyncNativeInstruction after migrating to newer @solana/spl-token
|
|
354
|
-
var SyncNativeIndex = 17;
|
|
355
|
-
exports.syncNativeInstructionData = (0, buffer_layout_1.struct)([(0, buffer_layout_1.u8)('instruction')]);
|
|
356
|
-
var createSyncNativeInstruction = function (account) {
|
|
357
|
-
var keys = [{ pubkey: account, isSigner: false, isWritable: true }];
|
|
358
|
-
var data = buffer_1.Buffer.alloc(exports.syncNativeInstructionData.span);
|
|
359
|
-
exports.syncNativeInstructionData.encode({ instruction: SyncNativeIndex }, data);
|
|
360
|
-
return new web3_js_1.TransactionInstruction({ keys: keys, programId: spl_token_1.TOKEN_PROGRAM_ID, data: data });
|
|
361
|
-
};
|
|
362
|
-
exports.createSyncNativeInstruction = createSyncNativeInstruction;
|
|
363
348
|
var prepareWrappedAccount = function (connection, senderAddress, amount) { return __awaiter(void 0, void 0, void 0, function () {
|
|
364
349
|
var tokenAccount, accInfo, instructions;
|
|
365
350
|
var _a, _b;
|
|
366
351
|
return __generator(this, function (_c) {
|
|
367
352
|
switch (_c.label) {
|
|
368
|
-
case 0: return [4 /*yield*/,
|
|
353
|
+
case 0: return [4 /*yield*/, (0, spl_token_1.getAssociatedTokenAddress)(spl_token_1.NATIVE_MINT, senderAddress, true)];
|
|
369
354
|
case 1:
|
|
370
355
|
tokenAccount = _c.sent();
|
|
371
356
|
return [4 /*yield*/, connection.getParsedAccountInfo(tokenAccount)];
|
|
@@ -374,7 +359,7 @@ var prepareWrappedAccount = function (connection, senderAddress, amount) { retur
|
|
|
374
359
|
instructions = ((_b = (_a = accInfo.value) === null || _a === void 0 ? void 0 : _a.lamports) !== null && _b !== void 0 ? _b : 0) > 0
|
|
375
360
|
? []
|
|
376
361
|
: [
|
|
377
|
-
|
|
362
|
+
(0, spl_token_1.createAssociatedTokenAccountInstruction)(senderAddress, tokenAccount, senderAddress, spl_token_1.NATIVE_MINT),
|
|
378
363
|
];
|
|
379
364
|
return [2 /*return*/, __spreadArray(__spreadArray([], __read(instructions), false), [
|
|
380
365
|
web3_js_1.SystemProgram.transfer({
|
|
@@ -382,7 +367,7 @@ var prepareWrappedAccount = function (connection, senderAddress, amount) { retur
|
|
|
382
367
|
toPubkey: tokenAccount,
|
|
383
368
|
lamports: amount.mul(new bn_js_1.default(constants_1.BASE_FEE)).div(new bn_js_1.default(1000000)).toNumber(),
|
|
384
369
|
}),
|
|
385
|
-
(0,
|
|
370
|
+
(0, spl_token_1.createSyncNativeInstruction)(tokenAccount),
|
|
386
371
|
], false)];
|
|
387
372
|
}
|
|
388
373
|
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as BufferLayout from "@solana/buffer-layout";
|
|
2
|
+
import { ICreateStreamLayout, ICreateUncheckedStreamLayout, IStreamLayout, ITopupStreamLayout, IWithdrawStreamLayout } from "./instructionTypes";
|
|
3
|
+
/**
|
|
4
|
+
* Stream layout
|
|
5
|
+
*/
|
|
6
|
+
export declare const streamLayout: BufferLayout.Structure<IStreamLayout>;
|
|
7
|
+
/**
|
|
8
|
+
* Create stream instruction layout
|
|
9
|
+
*/
|
|
10
|
+
export declare const createStreamLayout: BufferLayout.Structure<ICreateStreamLayout>;
|
|
11
|
+
/**
|
|
12
|
+
* Create unchecked stream instruction layout
|
|
13
|
+
*/
|
|
14
|
+
export declare const createUncheckedStreamLayout: BufferLayout.Structure<ICreateUncheckedStreamLayout>;
|
|
15
|
+
/**
|
|
16
|
+
* Withdraw stream instruction layout
|
|
17
|
+
*/
|
|
18
|
+
export declare const withdrawStreamLayout: BufferLayout.Structure<IWithdrawStreamLayout>;
|
|
19
|
+
/**
|
|
20
|
+
* Topup stream instruction layout
|
|
21
|
+
*/
|
|
22
|
+
export declare const topupStreamLayout: BufferLayout.Structure<ITopupStreamLayout>;
|
|
@@ -1,7 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
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
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.topupStreamLayout = exports.withdrawStreamLayout = exports.createUncheckedStreamLayout = exports.createStreamLayout = exports.streamLayout = void 0;
|
|
4
|
-
var BufferLayout = require("buffer-layout");
|
|
27
|
+
var BufferLayout = __importStar(require("@solana/buffer-layout"));
|
|
5
28
|
/**
|
|
6
29
|
* Stream layout
|
|
7
30
|
*/
|
|
@@ -93,4 +116,6 @@ exports.withdrawStreamLayout = BufferLayout.struct([BufferLayout.blob(8, "amount
|
|
|
93
116
|
/**
|
|
94
117
|
* Topup stream instruction layout
|
|
95
118
|
*/
|
|
96
|
-
exports.topupStreamLayout = BufferLayout.struct([
|
|
119
|
+
exports.topupStreamLayout = BufferLayout.struct([
|
|
120
|
+
BufferLayout.blob(8, "amount"),
|
|
121
|
+
]);
|
|
File without changes
|
|
File without changes
|
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { AccountInfo, Connection, PublicKey, Keypair, TransactionSignature, TransactionInstruction } from "@solana/web3.js";
|
|
2
|
+
import { SignerWalletAdapter } from "@solana/wallet-adapter-base";
|
|
3
|
+
import { AccountInfo, Connection, PublicKey, Keypair, TransactionSignature, TransactionInstruction, Transaction } from "@solana/web3.js";
|
|
5
4
|
import BN from "bn.js";
|
|
5
|
+
import { IRecipient, StreamDirection, StreamType } from "../common/types";
|
|
6
6
|
export { WalletAdapterNetwork as Cluster } from "@solana/wallet-adapter-base";
|
|
7
|
-
export declare enum StreamDirection {
|
|
8
|
-
Outgoing = "outgoing",
|
|
9
|
-
Incoming = "incoming",
|
|
10
|
-
All = "all"
|
|
11
|
-
}
|
|
12
|
-
export declare enum StreamType {
|
|
13
|
-
Stream = "stream",
|
|
14
|
-
Vesting = "vesting",
|
|
15
|
-
All = "all"
|
|
16
|
-
}
|
|
17
7
|
export interface Account {
|
|
18
8
|
pubkey: PublicKey;
|
|
19
9
|
account: AccountInfo<Buffer>;
|
|
20
10
|
}
|
|
21
|
-
export
|
|
22
|
-
|
|
11
|
+
export interface ICreateStreamSolanaExt {
|
|
12
|
+
sender: SignerWalletAdapter | Keypair;
|
|
13
|
+
partner?: string | null;
|
|
14
|
+
isNative?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface IInteractStreamSolanaExt {
|
|
17
|
+
invoker: SignerWalletAdapter | Keypair;
|
|
18
|
+
}
|
|
19
|
+
export interface ITopUpStreamSolanaExt {
|
|
20
|
+
invoker: SignerWalletAdapter | Keypair;
|
|
21
|
+
isNative?: boolean;
|
|
23
22
|
}
|
|
24
|
-
export declare type ClusterExtended = WalletAdapterNetwork | LocalCluster;
|
|
25
23
|
export interface CreateStreamData {
|
|
26
24
|
recipient: string;
|
|
27
25
|
mint: string;
|
|
@@ -63,17 +61,16 @@ export interface CreateMultiData {
|
|
|
63
61
|
}
|
|
64
62
|
export interface CreateStreamParams extends CreateStreamData {
|
|
65
63
|
connection: Connection;
|
|
66
|
-
sender:
|
|
64
|
+
sender: SignerWalletAdapter;
|
|
67
65
|
partner?: string;
|
|
68
|
-
cluster?: ClusterExtended;
|
|
69
66
|
}
|
|
70
67
|
export interface CreateParams extends CreateStreamData {
|
|
71
|
-
sender:
|
|
68
|
+
sender: SignerWalletAdapter | Keypair;
|
|
72
69
|
partner?: string | null;
|
|
73
70
|
isNative?: boolean;
|
|
74
71
|
}
|
|
75
72
|
export interface CreateMultiParams extends CreateMultiData {
|
|
76
|
-
sender:
|
|
73
|
+
sender: SignerWalletAdapter | Keypair;
|
|
77
74
|
partner?: string | null;
|
|
78
75
|
isNative?: boolean;
|
|
79
76
|
}
|
|
@@ -83,11 +80,10 @@ export interface WithdrawStreamData {
|
|
|
83
80
|
}
|
|
84
81
|
export interface WithdrawStreamParams extends WithdrawStreamData {
|
|
85
82
|
connection: Connection;
|
|
86
|
-
invoker:
|
|
87
|
-
cluster?: ClusterExtended;
|
|
83
|
+
invoker: SignerWalletAdapter;
|
|
88
84
|
}
|
|
89
85
|
export interface WithdrawParams extends WithdrawStreamData {
|
|
90
|
-
invoker:
|
|
86
|
+
invoker: SignerWalletAdapter | Keypair;
|
|
91
87
|
}
|
|
92
88
|
export interface TopupStreamData {
|
|
93
89
|
id: string;
|
|
@@ -95,11 +91,10 @@ export interface TopupStreamData {
|
|
|
95
91
|
}
|
|
96
92
|
export interface TopupStreamParams extends TopupStreamData {
|
|
97
93
|
connection: Connection;
|
|
98
|
-
invoker:
|
|
99
|
-
cluster?: ClusterExtended;
|
|
94
|
+
invoker: SignerWalletAdapter;
|
|
100
95
|
}
|
|
101
96
|
export interface TopupParams extends TopupStreamData {
|
|
102
|
-
invoker:
|
|
97
|
+
invoker: SignerWalletAdapter | Keypair;
|
|
103
98
|
isNative?: boolean;
|
|
104
99
|
}
|
|
105
100
|
export interface CancelStreamData {
|
|
@@ -107,11 +102,10 @@ export interface CancelStreamData {
|
|
|
107
102
|
}
|
|
108
103
|
export interface CancelStreamParams extends CancelStreamData {
|
|
109
104
|
connection: Connection;
|
|
110
|
-
invoker:
|
|
111
|
-
cluster?: ClusterExtended;
|
|
105
|
+
invoker: SignerWalletAdapter;
|
|
112
106
|
}
|
|
113
107
|
export interface CancelParams extends CancelStreamData {
|
|
114
|
-
invoker:
|
|
108
|
+
invoker: SignerWalletAdapter | Keypair;
|
|
115
109
|
}
|
|
116
110
|
export interface TransferStreamData {
|
|
117
111
|
id: string;
|
|
@@ -119,11 +113,10 @@ export interface TransferStreamData {
|
|
|
119
113
|
}
|
|
120
114
|
export interface TransferStreamParams extends TransferStreamData {
|
|
121
115
|
connection: Connection;
|
|
122
|
-
invoker:
|
|
123
|
-
cluster?: ClusterExtended;
|
|
116
|
+
invoker: SignerWalletAdapter;
|
|
124
117
|
}
|
|
125
118
|
export interface TransferParams extends TransferStreamData {
|
|
126
|
-
invoker:
|
|
119
|
+
invoker: SignerWalletAdapter | Keypair;
|
|
127
120
|
}
|
|
128
121
|
export interface GetStreamParams {
|
|
129
122
|
connection: Connection;
|
|
@@ -134,7 +127,6 @@ export interface GetStreamsParams {
|
|
|
134
127
|
wallet: PublicKey;
|
|
135
128
|
type?: StreamType;
|
|
136
129
|
direction?: StreamDirection;
|
|
137
|
-
cluster?: ClusterExtended;
|
|
138
130
|
}
|
|
139
131
|
export interface GetAllParams {
|
|
140
132
|
wallet: PublicKey;
|
|
@@ -276,7 +268,7 @@ export interface CreateResponse extends TxResponse {
|
|
|
276
268
|
metadata: Keypair;
|
|
277
269
|
}
|
|
278
270
|
export interface MetadataRecipientHashMap {
|
|
279
|
-
[metadataPubKey: string]:
|
|
271
|
+
[metadataPubKey: string]: IRecipient;
|
|
280
272
|
}
|
|
281
273
|
export interface CreateMultiError {
|
|
282
274
|
recipient: string;
|
|
@@ -316,3 +308,14 @@ export interface CreateMultipleStreamsValues {
|
|
|
316
308
|
referral: string;
|
|
317
309
|
recipients: Recipient[];
|
|
318
310
|
}
|
|
311
|
+
export interface BatchItem {
|
|
312
|
+
recipient: string;
|
|
313
|
+
tx: Transaction;
|
|
314
|
+
}
|
|
315
|
+
export interface BatchItemSuccess extends BatchItem {
|
|
316
|
+
signature: string;
|
|
317
|
+
}
|
|
318
|
+
export interface BatchItemError extends BatchItem {
|
|
319
|
+
error: string;
|
|
320
|
+
}
|
|
321
|
+
export declare type BatchItemResult = BatchItemSuccess | BatchItemError;
|
|
@@ -3,27 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.TransferCancelOptions = exports.Contract = exports.
|
|
6
|
+
exports.TransferCancelOptions = exports.Contract = exports.Cluster = void 0;
|
|
7
7
|
var bn_js_1 = __importDefault(require("bn.js"));
|
|
8
|
-
var utils_1 = require("
|
|
8
|
+
var utils_1 = require("../common/utils");
|
|
9
9
|
var wallet_adapter_base_1 = require("@solana/wallet-adapter-base");
|
|
10
10
|
Object.defineProperty(exports, "Cluster", { enumerable: true, get: function () { return wallet_adapter_base_1.WalletAdapterNetwork; } });
|
|
11
|
-
var StreamDirection;
|
|
12
|
-
(function (StreamDirection) {
|
|
13
|
-
StreamDirection["Outgoing"] = "outgoing";
|
|
14
|
-
StreamDirection["Incoming"] = "incoming";
|
|
15
|
-
StreamDirection["All"] = "all";
|
|
16
|
-
})(StreamDirection = exports.StreamDirection || (exports.StreamDirection = {}));
|
|
17
|
-
var StreamType;
|
|
18
|
-
(function (StreamType) {
|
|
19
|
-
StreamType["Stream"] = "stream";
|
|
20
|
-
StreamType["Vesting"] = "vesting";
|
|
21
|
-
StreamType["All"] = "all";
|
|
22
|
-
})(StreamType = exports.StreamType || (exports.StreamType = {}));
|
|
23
|
-
var LocalCluster;
|
|
24
|
-
(function (LocalCluster) {
|
|
25
|
-
LocalCluster["Local"] = "local";
|
|
26
|
-
})(LocalCluster = exports.LocalCluster || (exports.LocalCluster = {}));
|
|
27
11
|
var Contract = /** @class */ (function () {
|
|
28
12
|
function Contract(stream) {
|
|
29
13
|
var _a;
|
|
@@ -41,8 +25,7 @@ var Contract = /** @class */ (function () {
|
|
|
41
25
|
this.mint = stream.mint.toBase58();
|
|
42
26
|
this.escrowTokens = stream.escrowTokens.toBase58();
|
|
43
27
|
this.streamflowTreasury = stream.streamflowTreasury.toBase58();
|
|
44
|
-
this.streamflowTreasuryTokens =
|
|
45
|
-
stream.streamflowTreasuryTokens.toBase58();
|
|
28
|
+
this.streamflowTreasuryTokens = stream.streamflowTreasuryTokens.toBase58();
|
|
46
29
|
this.streamflowFeeTotal = stream.streamflowFeeTotal;
|
|
47
30
|
this.streamflowFeeWithdrawn = stream.streamflowFeeWithdrawn;
|
|
48
31
|
this.streamflowFeePercent = stream.streamflowFeePercent.toNumber();
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { SignerWalletAdapter } from "@solana/wallet-adapter-base";
|
|
3
|
+
import { Connection, Keypair, PublicKey } from "@solana/web3.js";
|
|
4
|
+
import { Stream, DecodedStream, Account, BatchItem, BatchItemResult } from "./types";
|
|
5
|
+
export declare const decodeStream: (buf: Buffer) => DecodedStream;
|
|
6
|
+
export declare const formatDecodedStream: (stream: DecodedStream) => Stream;
|
|
7
|
+
/**
|
|
8
|
+
* Wrapper function for Solana web3 getProgramAccounts with slightly better call interface
|
|
9
|
+
* @param {Connection} connection - Solana web3 connection object.
|
|
10
|
+
* @param {PublicKey} wallet - PublicKey to compare against.
|
|
11
|
+
* @param {number} offset - Offset of bits of the PublicKey in the account binary.
|
|
12
|
+
* @param {PublicKey} programId - Solana program ID.
|
|
13
|
+
* @return {Promise<Account[]>} - Array of resulting accounts.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getProgramAccounts(connection: Connection, wallet: PublicKey, offset: number, programId: PublicKey): Promise<Account[]>;
|
|
16
|
+
/**
|
|
17
|
+
* Utility function to check if the transaction initiator is a KeyPair or a Wallet object
|
|
18
|
+
* @param {Keypair | SignerWalletAdapter} walletOrKeypair - Wallet or Keypair in question
|
|
19
|
+
* @return {boolean} - Returns true if parameter is a Wallet.
|
|
20
|
+
*/
|
|
21
|
+
export declare function isSignerWallet(walletOrKeypair: Keypair | SignerWalletAdapter): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Sign passed BatchItems with wallet request or KeyPair
|
|
24
|
+
* @param {Keypair | SignerWalletAdapter} sender - Wallet or Keypair of sendin account
|
|
25
|
+
* @param {BatchItem[]} items - Multiple recipient contracts split into separate items
|
|
26
|
+
* @return {BatchItem[]} - Returns items with signatures.
|
|
27
|
+
*/
|
|
28
|
+
export declare function signAllTransactionWithRecipients(sender: Keypair | SignerWalletAdapter, items: BatchItem[]): Promise<BatchItem[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Sign passed BatchItems with wallet request or KeyPair
|
|
31
|
+
* @param {Connection} connection - Solana web3 connection object.
|
|
32
|
+
* @param {BatchItem} batchItem - Signed transaction ready to be send.
|
|
33
|
+
* @return {Promise<BatchItemResult>} - Returns settled transaction item
|
|
34
|
+
*/
|
|
35
|
+
export declare function sendAndConfirmStreamRawTransaction(connection: Connection, batchItem: BatchItem): Promise<BatchItemResult>;
|
|
36
|
+
/**
|
|
37
|
+
* Shorthand call signature for getAssociatedTokenAddress, with allowance for address to be offCurve
|
|
38
|
+
* @param {PublicKey} mint - SPL token Mint address.
|
|
39
|
+
* @param {PublicKey} owner - Owner of the Associated Token Address
|
|
40
|
+
* @return {Promise<PublicKey>} - Associated Token Address
|
|
41
|
+
*/
|
|
42
|
+
export declare function ata(mint: PublicKey, owner: PublicKey): Promise<PublicKey>;
|