@streamflow/stream 3.0.17 → 3.0.18
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 +49 -0
- package/dist/aptos/StreamClient.js +362 -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 +24 -0
- package/dist/aptos/types.d.ts +145 -0
- package/dist/aptos/types.js +65 -0
- package/dist/common/BaseStreamClient.d.ts +11 -0
- package/dist/common/BaseStreamClient.js +9 -0
- package/dist/common/GenericStreamClient.d.ts +60 -0
- package/dist/common/GenericStreamClient.js +137 -0
- package/dist/common/types.d.ts +71 -0
- package/dist/common/types.js +28 -0
- package/dist/{utils.d.ts → common/utils.d.ts} +0 -4
- package/dist/common/utils.js +31 -0
- package/dist/index.d.ts +5 -6
- package/dist/index.js +19 -10
- package/dist/solana/StreamClient.d.ts +71 -0
- package/dist/{StreamClient.js → solana/StreamClient.js} +303 -396
- 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 +43 -0
- package/dist/solana/instructionTypes.d.ts +86 -0
- package/dist/solana/instructionTypes.js +2 -0
- package/dist/{instructions.d.ts → solana/instructions.d.ts} +8 -2
- package/dist/{instructions.js → solana/instructions.js} +55 -38
- package/dist/solana/layout.d.ts +27 -0
- package/dist/{layout.js → solana/layout.js} +65 -3
- 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 +271 -0
- package/package.json +1 -1
- package/dist/Stream.d.ts +0 -87
- package/dist/Stream.js +0 -503
- package/dist/StreamClient.d.ts +0 -146
- 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, default as SolanaStreamClient } 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,43 @@
|
|
|
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.SolanaStreamClient = 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
|
+
Object.defineProperty(exports, "SolanaStreamClient", { enumerable: true, get: function () { return __importDefault(StreamClient_1).default; } });
|
|
36
|
+
__exportStar(require("./utils"), exports);
|
|
37
|
+
__exportStar(require("./types"), exports);
|
|
38
|
+
__exportStar(require("./instructions"), exports);
|
|
39
|
+
exports.constants = __importStar(require("./constants"));
|
|
40
|
+
var timelockIDL_1 = require("./timelockIDL");
|
|
41
|
+
Object.defineProperty(exports, "timelockIDL", { enumerable: true, get: function () { return __importDefault(timelockIDL_1).default; } });
|
|
42
|
+
var bn_js_1 = require("bn.js");
|
|
43
|
+
Object.defineProperty(exports, "BN", { enumerable: true, get: function () { return __importDefault(bn_js_1).default; } });
|
|
@@ -0,0 +1,86 @@
|
|
|
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 IUpdateStreamLayout {
|
|
80
|
+
enable_automatic_withdrawal?: number;
|
|
81
|
+
withdraw_frequency?: Uint8Array;
|
|
82
|
+
amount_per_period?: Uint8Array;
|
|
83
|
+
}
|
|
84
|
+
export interface ITopupStreamLayout {
|
|
85
|
+
amount: Uint8Array;
|
|
86
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Connection, PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
2
2
|
import BN from "bn.js";
|
|
3
|
+
import { IUpdateData } from "../common/types";
|
|
3
4
|
interface CreateStreamData {
|
|
4
5
|
start: BN;
|
|
5
6
|
depositedAmount: BN;
|
|
@@ -84,6 +85,13 @@ interface WithdrawAccounts {
|
|
|
84
85
|
tokenProgram: PublicKey;
|
|
85
86
|
}
|
|
86
87
|
export declare const withdrawStreamInstruction: (amount: BN, programId: PublicKey, { authority, recipient, recipientTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, }: WithdrawAccounts) => TransactionInstruction;
|
|
88
|
+
interface UpdateAccounts {
|
|
89
|
+
authority: PublicKey;
|
|
90
|
+
metadata: PublicKey;
|
|
91
|
+
withdrawor: PublicKey;
|
|
92
|
+
systemProgram: PublicKey;
|
|
93
|
+
}
|
|
94
|
+
export declare const updateStreamInstruction: (params: IUpdateData, programId: PublicKey, { authority, metadata, withdrawor, systemProgram }: UpdateAccounts) => TransactionInstruction;
|
|
87
95
|
interface CancelAccounts {
|
|
88
96
|
authority: PublicKey;
|
|
89
97
|
sender: PublicKey;
|
|
@@ -127,7 +135,5 @@ interface TopupAccounts {
|
|
|
127
135
|
systemProgram: PublicKey;
|
|
128
136
|
}
|
|
129
137
|
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
138
|
export declare const prepareWrappedAccount: (connection: Connection, senderAddress: PublicKey, amount: BN) => Promise<TransactionInstruction[]>;
|
|
133
139
|
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.updateStreamInstruction = 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,
|
|
@@ -258,6 +253,38 @@ var withdrawStreamInstruction = function (amount, programId, _a) {
|
|
|
258
253
|
});
|
|
259
254
|
};
|
|
260
255
|
exports.withdrawStreamInstruction = withdrawStreamInstruction;
|
|
256
|
+
var updateStreamInstruction = function (params, programId, _a) {
|
|
257
|
+
var authority = _a.authority, metadata = _a.metadata, withdrawor = _a.withdrawor, systemProgram = _a.systemProgram;
|
|
258
|
+
var keys = [
|
|
259
|
+
{ pubkey: authority, isSigner: true, isWritable: true },
|
|
260
|
+
{ pubkey: metadata, isSigner: false, isWritable: true },
|
|
261
|
+
{ pubkey: withdrawor, isSigner: false, isWritable: true },
|
|
262
|
+
{ pubkey: systemProgram, isSigner: false, isWritable: false },
|
|
263
|
+
];
|
|
264
|
+
var data = buffer_1.Buffer.alloc(100);
|
|
265
|
+
var decodedData = {
|
|
266
|
+
enable_automatic_withdrawal: Number(params.enableAutomaticWithdrawal),
|
|
267
|
+
withdraw_frequency: params.withdrawFrequency
|
|
268
|
+
? params.withdrawFrequency.toArrayLike(buffer_1.Buffer, "le", 8)
|
|
269
|
+
: undefined,
|
|
270
|
+
amount_per_period: params.amountPerPeriod
|
|
271
|
+
? params.amountPerPeriod.toArrayLike(buffer_1.Buffer, "le", 8)
|
|
272
|
+
: undefined,
|
|
273
|
+
};
|
|
274
|
+
var encodeLength = Layout.encodeUpdateStream(decodedData, data);
|
|
275
|
+
data = data.slice(0, encodeLength);
|
|
276
|
+
data = buffer_1.Buffer.concat([
|
|
277
|
+
buffer_1.Buffer.from(js_sha256_1.sha256.digest("global:update")).slice(0, 8),
|
|
278
|
+
data,
|
|
279
|
+
buffer_1.Buffer.alloc(20),
|
|
280
|
+
]);
|
|
281
|
+
return new web3_js_1.TransactionInstruction({
|
|
282
|
+
keys: keys,
|
|
283
|
+
programId: programId,
|
|
284
|
+
data: data,
|
|
285
|
+
});
|
|
286
|
+
};
|
|
287
|
+
exports.updateStreamInstruction = updateStreamInstruction;
|
|
261
288
|
var cancelStreamInstruction = function (programId, _a) {
|
|
262
289
|
var authority = _a.authority, sender = _a.sender, senderTokens = _a.senderTokens, recipient = _a.recipient, recipientTokens = _a.recipientTokens, metadata = _a.metadata, escrowTokens = _a.escrowTokens, streamflowTreasury = _a.streamflowTreasury, streamflowTreasuryTokens = _a.streamflowTreasuryTokens, partner = _a.partner, partnerTokens = _a.partnerTokens, mint = _a.mint, tokenProgram = _a.tokenProgram;
|
|
263
290
|
var keys = [
|
|
@@ -341,7 +368,7 @@ var topupStreamInstruction = function (amount, programId, _a) {
|
|
|
341
368
|
data = buffer_1.Buffer.concat([
|
|
342
369
|
buffer_1.Buffer.from(js_sha256_1.sha256.digest("global:topup")).slice(0, 8),
|
|
343
370
|
data,
|
|
344
|
-
buffer_1.Buffer.alloc(10)
|
|
371
|
+
buffer_1.Buffer.alloc(10),
|
|
345
372
|
]);
|
|
346
373
|
return new web3_js_1.TransactionInstruction({
|
|
347
374
|
keys: keys,
|
|
@@ -350,22 +377,12 @@ var topupStreamInstruction = function (amount, programId, _a) {
|
|
|
350
377
|
});
|
|
351
378
|
};
|
|
352
379
|
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
380
|
var prepareWrappedAccount = function (connection, senderAddress, amount) { return __awaiter(void 0, void 0, void 0, function () {
|
|
364
381
|
var tokenAccount, accInfo, instructions;
|
|
365
382
|
var _a, _b;
|
|
366
383
|
return __generator(this, function (_c) {
|
|
367
384
|
switch (_c.label) {
|
|
368
|
-
case 0: return [4 /*yield*/,
|
|
385
|
+
case 0: return [4 /*yield*/, (0, spl_token_1.getAssociatedTokenAddress)(spl_token_1.NATIVE_MINT, senderAddress, true)];
|
|
369
386
|
case 1:
|
|
370
387
|
tokenAccount = _c.sent();
|
|
371
388
|
return [4 /*yield*/, connection.getParsedAccountInfo(tokenAccount)];
|
|
@@ -374,7 +391,7 @@ var prepareWrappedAccount = function (connection, senderAddress, amount) { retur
|
|
|
374
391
|
instructions = ((_b = (_a = accInfo.value) === null || _a === void 0 ? void 0 : _a.lamports) !== null && _b !== void 0 ? _b : 0) > 0
|
|
375
392
|
? []
|
|
376
393
|
: [
|
|
377
|
-
|
|
394
|
+
(0, spl_token_1.createAssociatedTokenAccountInstruction)(senderAddress, tokenAccount, senderAddress, spl_token_1.NATIVE_MINT),
|
|
378
395
|
];
|
|
379
396
|
return [2 /*return*/, __spreadArray(__spreadArray([], __read(instructions), false), [
|
|
380
397
|
web3_js_1.SystemProgram.transfer({
|
|
@@ -382,7 +399,7 @@ var prepareWrappedAccount = function (connection, senderAddress, amount) { retur
|
|
|
382
399
|
toPubkey: tokenAccount,
|
|
383
400
|
lamports: amount.mul(new bn_js_1.default(constants_1.BASE_FEE)).div(new bn_js_1.default(1000000)).toNumber(),
|
|
384
401
|
}),
|
|
385
|
-
(0,
|
|
402
|
+
(0, spl_token_1.createSyncNativeInstruction)(tokenAccount),
|
|
386
403
|
], false)];
|
|
387
404
|
}
|
|
388
405
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import * as BufferLayout from "@solana/buffer-layout";
|
|
3
|
+
import { ICreateStreamLayout, ICreateUncheckedStreamLayout, IStreamLayout, ITopupStreamLayout, IUpdateStreamLayout, IWithdrawStreamLayout } from "./instructionTypes";
|
|
4
|
+
/**
|
|
5
|
+
* Stream layout
|
|
6
|
+
*/
|
|
7
|
+
export declare const streamLayout: BufferLayout.Structure<IStreamLayout>;
|
|
8
|
+
/**
|
|
9
|
+
* Create stream instruction layout
|
|
10
|
+
*/
|
|
11
|
+
export declare const createStreamLayout: BufferLayout.Structure<ICreateStreamLayout>;
|
|
12
|
+
/**
|
|
13
|
+
* Create unchecked stream instruction layout
|
|
14
|
+
*/
|
|
15
|
+
export declare const createUncheckedStreamLayout: BufferLayout.Structure<ICreateUncheckedStreamLayout>;
|
|
16
|
+
/**
|
|
17
|
+
* Withdraw stream instruction layout
|
|
18
|
+
*/
|
|
19
|
+
export declare const withdrawStreamLayout: BufferLayout.Structure<IWithdrawStreamLayout>;
|
|
20
|
+
/**
|
|
21
|
+
* Encode stream instruction layout
|
|
22
|
+
*/
|
|
23
|
+
export declare const encodeUpdateStream: (values: IUpdateStreamLayout, data: Buffer) => number;
|
|
24
|
+
/**
|
|
25
|
+
* Topup stream instruction layout
|
|
26
|
+
*/
|
|
27
|
+
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
|
-
exports.topupStreamLayout = exports.withdrawStreamLayout = exports.createUncheckedStreamLayout = exports.createStreamLayout = exports.streamLayout = void 0;
|
|
4
|
-
var BufferLayout = require("buffer-layout");
|
|
26
|
+
exports.topupStreamLayout = exports.encodeUpdateStream = exports.withdrawStreamLayout = exports.createUncheckedStreamLayout = exports.createStreamLayout = exports.streamLayout = void 0;
|
|
27
|
+
var BufferLayout = __importStar(require("@solana/buffer-layout"));
|
|
5
28
|
/**
|
|
6
29
|
* Stream layout
|
|
7
30
|
*/
|
|
@@ -90,7 +113,46 @@ exports.createUncheckedStreamLayout = BufferLayout.struct([
|
|
|
90
113
|
* Withdraw stream instruction layout
|
|
91
114
|
*/
|
|
92
115
|
exports.withdrawStreamLayout = BufferLayout.struct([BufferLayout.blob(8, "amount")]);
|
|
116
|
+
/**
|
|
117
|
+
* Encode stream instruction layout
|
|
118
|
+
*/
|
|
119
|
+
var encodeUpdateStream = function (values, data) {
|
|
120
|
+
var _a, _b, _c;
|
|
121
|
+
var structs = [];
|
|
122
|
+
if (values.enable_automatic_withdrawal) {
|
|
123
|
+
structs.push(BufferLayout.u8("enable_automatic_withdrawal_exists"));
|
|
124
|
+
structs.push(BufferLayout.u8("enable_automatic_withdrawal"));
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
structs.push(BufferLayout.u8("enable_automatic_withdrawal_exists"));
|
|
128
|
+
}
|
|
129
|
+
if (values.withdraw_frequency) {
|
|
130
|
+
structs.push(BufferLayout.u8("withdraw_frequency_exists"));
|
|
131
|
+
structs.push(BufferLayout.blob(8, "withdraw_frequency"));
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
structs.push(BufferLayout.u8("withdraw_frequency_exists"));
|
|
135
|
+
}
|
|
136
|
+
if (values.amount_per_period) {
|
|
137
|
+
structs.push(BufferLayout.u8("amount_per_period_exists"));
|
|
138
|
+
structs.push(BufferLayout.blob(8, "amount_per_period"));
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
structs.push(BufferLayout.u8("amount_per_period_exists"));
|
|
142
|
+
}
|
|
143
|
+
return BufferLayout.struct(structs).encode({
|
|
144
|
+
enable_automatic_withdrawal_exists: values.enable_automatic_withdrawal ? 1 : 0,
|
|
145
|
+
enable_automatic_withdrawal: (_a = values.enable_automatic_withdrawal) !== null && _a !== void 0 ? _a : 0,
|
|
146
|
+
withdraw_frequency_exists: values.withdraw_frequency ? 1 : 0,
|
|
147
|
+
withdraw_frequency: (_b = values.withdraw_frequency) !== null && _b !== void 0 ? _b : 0,
|
|
148
|
+
amount_per_period_exists: values.amount_per_period ? 1 : 0,
|
|
149
|
+
amount_per_period: (_c = values.amount_per_period) !== null && _c !== void 0 ? _c : 0,
|
|
150
|
+
}, data);
|
|
151
|
+
};
|
|
152
|
+
exports.encodeUpdateStream = encodeUpdateStream;
|
|
93
153
|
/**
|
|
94
154
|
* Topup stream instruction layout
|
|
95
155
|
*/
|
|
96
|
-
exports.topupStreamLayout = BufferLayout.struct([
|
|
156
|
+
exports.topupStreamLayout = BufferLayout.struct([
|
|
157
|
+
BufferLayout.blob(8, "amount"),
|
|
158
|
+
]);
|
|
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;
|