@streamflow/stream 3.0.18 → 3.0.19
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/Stream.d.ts +87 -0
- package/dist/Stream.js +503 -0
- package/dist/StreamClient.d.ts +146 -0
- package/dist/{solana/StreamClient.js → StreamClient.js} +397 -301
- package/dist/__tests__/test_dependencies/airdrop/airdrop-request.d.ts +3 -0
- package/dist/__tests__/test_dependencies/airdrop/airdrop-request.js +67 -0
- package/dist/__tests__/test_dependencies/airdrop/airdrop.d.ts +6 -0
- package/dist/__tests__/test_dependencies/airdrop/airdrop.js +215 -0
- package/dist/__tests__/test_dependencies/constants/index.d.ts +122 -0
- package/dist/__tests__/test_dependencies/constants/index.js +158 -0
- package/dist/__tests__/test_dependencies/idl/airdrop.d.ts +27 -0
- package/dist/__tests__/test_dependencies/idl/airdrop.js +171 -0
- package/dist/{solana/constants.d.ts → constants.d.ts} +1 -1
- package/dist/{solana/constants.js → constants.js} +5 -5
- package/dist/{solana/timelockIDL.d.ts → idl/timelock.d.ts} +0 -0
- package/dist/{solana/timelockIDL.js → idl/timelock.js} +0 -0
- package/dist/index.d.ts +6 -5
- package/dist/index.js +10 -19
- package/dist/{solana/instructions.d.ts → instructions.d.ts} +2 -8
- package/dist/{solana/instructions.js → instructions.js} +38 -55
- package/dist/layout.d.ts +22 -0
- package/dist/{solana/layout.js → layout.js} +3 -65
- package/dist/{solana/types.d.ts → types.d.ts} +34 -37
- package/dist/{solana/types.js → types.js} +20 -3
- package/dist/{common/utils.d.ts → utils.d.ts} +4 -0
- package/dist/utils.js +126 -0
- package/package.json +1 -1
- package/dist/__tests__/aptos/streamClient.spec.d.ts +0 -1
- package/dist/__tests__/aptos/streamClient.spec.js +0 -160
- package/dist/aptos/StreamClient.d.ts +0 -49
- package/dist/aptos/StreamClient.js +0 -362
- package/dist/aptos/constants.d.ts +0 -2
- package/dist/aptos/constants.js +0 -12
- package/dist/aptos/index.d.ts +0 -2
- package/dist/aptos/index.js +0 -24
- package/dist/aptos/types.d.ts +0 -145
- package/dist/aptos/types.js +0 -65
- package/dist/common/BaseStreamClient.d.ts +0 -11
- package/dist/common/BaseStreamClient.js +0 -9
- package/dist/common/GenericStreamClient.d.ts +0 -60
- package/dist/common/GenericStreamClient.js +0 -137
- package/dist/common/types.d.ts +0 -71
- package/dist/common/types.js +0 -28
- package/dist/common/utils.js +0 -31
- package/dist/solana/StreamClient.d.ts +0 -71
- package/dist/solana/index.d.ts +0 -7
- package/dist/solana/index.js +0 -43
- package/dist/solana/instructionTypes.d.ts +0 -86
- package/dist/solana/instructionTypes.js +0 -2
- package/dist/solana/layout.d.ts +0 -27
- package/dist/solana/utils.d.ts +0 -42
- package/dist/solana/utils.js +0 -271
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = {
|
|
4
|
+
version: "0.1.0",
|
|
5
|
+
name: "airdrop",
|
|
6
|
+
instructions: [
|
|
7
|
+
{
|
|
8
|
+
name: "initializeAirdrop",
|
|
9
|
+
accounts: [
|
|
10
|
+
{
|
|
11
|
+
name: "initializer",
|
|
12
|
+
isMut: false,
|
|
13
|
+
isSigner: true,
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: "initializerDepositTokenAccount",
|
|
17
|
+
isMut: true,
|
|
18
|
+
isSigner: false,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "airdropAccount",
|
|
22
|
+
isMut: true,
|
|
23
|
+
isSigner: true,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "airdropTokenAccount",
|
|
27
|
+
isMut: true,
|
|
28
|
+
isSigner: false,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "systemProgram",
|
|
32
|
+
isMut: false,
|
|
33
|
+
isSigner: false,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: "tokenProgram",
|
|
37
|
+
isMut: false,
|
|
38
|
+
isSigner: false,
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
args: [
|
|
42
|
+
{
|
|
43
|
+
name: "airdropAmount",
|
|
44
|
+
type: "u64",
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "withdrawAmount",
|
|
48
|
+
type: "u64",
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: "getAirdrop",
|
|
54
|
+
accounts: [
|
|
55
|
+
{
|
|
56
|
+
name: "taker",
|
|
57
|
+
isMut: false,
|
|
58
|
+
isSigner: true,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "takerReceiveTokenAccount",
|
|
62
|
+
isMut: true,
|
|
63
|
+
isSigner: false,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: "airdropAccount",
|
|
67
|
+
isMut: true,
|
|
68
|
+
isSigner: false,
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: "mint",
|
|
72
|
+
isMut: false,
|
|
73
|
+
isSigner: false,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: "airdropTokenAccount",
|
|
77
|
+
isMut: true,
|
|
78
|
+
isSigner: false,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: "pdaAccount",
|
|
82
|
+
isMut: false,
|
|
83
|
+
isSigner: false,
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "tokenProgram",
|
|
87
|
+
isMut: false,
|
|
88
|
+
isSigner: false,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: "associatedTokenProgram",
|
|
92
|
+
isMut: false,
|
|
93
|
+
isSigner: false,
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "systemProgram",
|
|
97
|
+
isMut: false,
|
|
98
|
+
isSigner: false,
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: "rent",
|
|
102
|
+
isMut: false,
|
|
103
|
+
isSigner: false,
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
args: [],
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: "cancelAirdrop",
|
|
110
|
+
accounts: [
|
|
111
|
+
{
|
|
112
|
+
name: "initializer",
|
|
113
|
+
isMut: true,
|
|
114
|
+
isSigner: true,
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: "initializerDepositTokenAccount",
|
|
118
|
+
isMut: true,
|
|
119
|
+
isSigner: false,
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: "pdaAccount",
|
|
123
|
+
isMut: false,
|
|
124
|
+
isSigner: false,
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: "airdropAccount",
|
|
128
|
+
isMut: true,
|
|
129
|
+
isSigner: false,
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
name: "airdropTokenAccount",
|
|
133
|
+
isMut: true,
|
|
134
|
+
isSigner: false,
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: "tokenProgram",
|
|
138
|
+
isMut: false,
|
|
139
|
+
isSigner: false,
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
args: [],
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
accounts: [
|
|
146
|
+
{
|
|
147
|
+
name: "AirdropAccount",
|
|
148
|
+
type: {
|
|
149
|
+
kind: "struct",
|
|
150
|
+
fields: [
|
|
151
|
+
{
|
|
152
|
+
name: "initializerKey",
|
|
153
|
+
type: "publicKey",
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: "initializerDepositTokenAccount",
|
|
157
|
+
type: "publicKey",
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
name: "airdropTokenAccount",
|
|
161
|
+
type: "publicKey",
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
name: "withdrawAmount",
|
|
165
|
+
type: "u64",
|
|
166
|
+
},
|
|
167
|
+
],
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
};
|
|
@@ -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("./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.Cluster.Devnet] = "HqDGZjaVRXJ9MGRQEw7qDc2rAr6iH1n1kAQdCZaCMfMZ",
|
|
12
|
+
_a[types_1.Cluster.Mainnet] = "strmRqUCoQUgGUan5YhzUZa6KqdzwX5L6FpUxfmKg5m",
|
|
13
|
+
_a[types_1.Cluster.Testnet] = "HqDGZjaVRXJ9MGRQEw7qDc2rAr6iH1n1kAQdCZaCMfMZ",
|
|
14
|
+
_a[types_1.LocalCluster.Local] = "HqDGZjaVRXJ9MGRQEw7qDc2rAr6iH1n1kAQdCZaCMfMZ",
|
|
15
15
|
_a);
|
|
16
16
|
exports.STREAMFLOW_PROGRAM_ID = "strmRqUCoQUgGUan5YhzUZa6KqdzwX5L6FpUxfmKg5m";
|
|
17
17
|
exports.STREAMFLOW_DEVNET_PROGRAM_ID = "FGjLaVo5zLGdzCxMo9gu9tXr1kzTToKd8C8K7YS5hNM1";
|
|
File without changes
|
|
File without changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export *
|
|
4
|
-
export * from "./
|
|
5
|
-
export
|
|
1
|
+
export { default } from "./Stream";
|
|
2
|
+
export { default as StreamClient } from "./StreamClient";
|
|
3
|
+
export * from "./utils";
|
|
4
|
+
export * from "./types";
|
|
5
|
+
export * from "./instructions";
|
|
6
|
+
export { default as BN } from "bn.js";
|
package/dist/index.js
CHANGED
|
@@ -10,18 +10,6 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
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
|
-
};
|
|
25
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
26
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
15
|
};
|
|
@@ -29,10 +17,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
29
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
18
|
};
|
|
31
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.
|
|
33
|
-
|
|
34
|
-
exports
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
20
|
+
exports.BN = exports.StreamClient = exports.default = void 0;
|
|
21
|
+
var Stream_1 = require("./Stream");
|
|
22
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(Stream_1).default; } });
|
|
23
|
+
var StreamClient_1 = require("./StreamClient");
|
|
24
|
+
Object.defineProperty(exports, "StreamClient", { enumerable: true, get: function () { return __importDefault(StreamClient_1).default; } });
|
|
25
|
+
__exportStar(require("./utils"), exports);
|
|
26
|
+
__exportStar(require("./types"), exports);
|
|
27
|
+
__exportStar(require("./instructions"), exports);
|
|
28
|
+
var bn_js_1 = require("bn.js");
|
|
29
|
+
Object.defineProperty(exports, "BN", { enumerable: true, get: function () { return __importDefault(bn_js_1).default; } });
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Connection, PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
2
2
|
import BN from "bn.js";
|
|
3
|
-
import { IUpdateData } from "../common/types";
|
|
4
3
|
interface CreateStreamData {
|
|
5
4
|
start: BN;
|
|
6
5
|
depositedAmount: BN;
|
|
@@ -85,13 +84,6 @@ interface WithdrawAccounts {
|
|
|
85
84
|
tokenProgram: PublicKey;
|
|
86
85
|
}
|
|
87
86
|
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;
|
|
95
87
|
interface CancelAccounts {
|
|
96
88
|
authority: PublicKey;
|
|
97
89
|
sender: PublicKey;
|
|
@@ -135,5 +127,7 @@ interface TopupAccounts {
|
|
|
135
127
|
systemProgram: PublicKey;
|
|
136
128
|
}
|
|
137
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;
|
|
138
132
|
export declare const prepareWrappedAccount: (connection: Connection, senderAddress: PublicKey, amount: BN) => Promise<TransactionInstruction[]>;
|
|
139
133
|
export {};
|
|
@@ -87,13 +87,14 @@ 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.createSyncNativeInstruction = exports.syncNativeInstructionData = 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
|
|
95
|
+
var buffer_layout_1 = require("@solana/buffer-layout");
|
|
96
96
|
var Layout = __importStar(require("./layout"));
|
|
97
|
+
var spl_token_1 = require("@solana/spl-token");
|
|
97
98
|
var constants_1 = require("./constants");
|
|
98
99
|
var createStreamInstruction = function (data, programId, accounts) {
|
|
99
100
|
var keys = [
|
|
@@ -138,12 +139,12 @@ var createStreamInstruction = function (data, programId, accounts) {
|
|
|
138
139
|
amount_per_period: data.amountPerPeriod.toArrayLike(buffer_1.Buffer, "le", 8),
|
|
139
140
|
cliff: data.cliff.toArrayLike(buffer_1.Buffer, "le", 8),
|
|
140
141
|
cliff_amount: data.cliffAmount.toArrayLike(buffer_1.Buffer, "le", 8),
|
|
141
|
-
cancelable_by_sender:
|
|
142
|
-
cancelable_by_recipient:
|
|
143
|
-
automatic_withdrawal:
|
|
144
|
-
transferable_by_sender:
|
|
145
|
-
transferable_by_recipient:
|
|
146
|
-
can_topup:
|
|
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,
|
|
147
148
|
stream_name: streamNameBuffer,
|
|
148
149
|
withdraw_frequency: data.withdrawFrequency.toArrayLike(buffer_1.Buffer, "le", 8),
|
|
149
150
|
};
|
|
@@ -152,7 +153,7 @@ var createStreamInstruction = function (data, programId, accounts) {
|
|
|
152
153
|
bufferData = buffer_1.Buffer.concat([
|
|
153
154
|
buffer_1.Buffer.from(js_sha256_1.sha256.digest("global:create")).slice(0, 8),
|
|
154
155
|
bufferData,
|
|
155
|
-
buffer_1.Buffer.alloc(10)
|
|
156
|
+
buffer_1.Buffer.alloc(10)
|
|
156
157
|
]);
|
|
157
158
|
return new web3_js_1.TransactionInstruction({
|
|
158
159
|
keys: keys,
|
|
@@ -192,25 +193,29 @@ var createUncheckedStreamInstruction = function (data, programId, accounts) {
|
|
|
192
193
|
amount_per_period: data.amountPerPeriod.toArrayLike(buffer_1.Buffer, "le", 8),
|
|
193
194
|
cliff: data.cliff.toArrayLike(buffer_1.Buffer, "le", 8),
|
|
194
195
|
cliff_amount: data.cliffAmount.toArrayLike(buffer_1.Buffer, "le", 8),
|
|
195
|
-
cancelable_by_sender:
|
|
196
|
-
cancelable_by_recipient:
|
|
197
|
-
automatic_withdrawal:
|
|
198
|
-
transferable_by_sender:
|
|
199
|
-
transferable_by_recipient:
|
|
200
|
-
can_topup:
|
|
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,
|
|
201
202
|
stream_name: streamNameBuffer,
|
|
202
203
|
withdraw_frequency: data.withdrawFrequency.toArrayLike(buffer_1.Buffer, "le", 8),
|
|
203
204
|
recipient: data.recipient.toBuffer(),
|
|
204
205
|
partner: data.partner.toBuffer(),
|
|
205
|
-
pausable: 1,
|
|
206
|
-
can_update_rate: 1,
|
|
206
|
+
pausable: buffer_1.Buffer.alloc(1),
|
|
207
|
+
can_update_rate: buffer_1.Buffer.alloc(1),
|
|
207
208
|
};
|
|
208
209
|
var encodeLength = Layout.createUncheckedStreamLayout.encode(decodedData, bufferData);
|
|
209
210
|
bufferData = bufferData.slice(0, encodeLength);
|
|
210
211
|
var digest = accounts.payer
|
|
211
212
|
? js_sha256_1.sha256.digest("global:create_unchecked_with_payer")
|
|
212
213
|
: js_sha256_1.sha256.digest("global:create_unchecked");
|
|
213
|
-
bufferData = buffer_1.Buffer.concat([
|
|
214
|
+
bufferData = buffer_1.Buffer.concat([
|
|
215
|
+
buffer_1.Buffer.from(digest).slice(0, 8),
|
|
216
|
+
bufferData,
|
|
217
|
+
buffer_1.Buffer.alloc(10),
|
|
218
|
+
]);
|
|
214
219
|
return new web3_js_1.TransactionInstruction({
|
|
215
220
|
keys: keys,
|
|
216
221
|
programId: programId,
|
|
@@ -244,7 +249,7 @@ var withdrawStreamInstruction = function (amount, programId, _a) {
|
|
|
244
249
|
data = buffer_1.Buffer.concat([
|
|
245
250
|
buffer_1.Buffer.from(js_sha256_1.sha256.digest("global:withdraw")).slice(0, 8),
|
|
246
251
|
data,
|
|
247
|
-
buffer_1.Buffer.alloc(10)
|
|
252
|
+
buffer_1.Buffer.alloc(10)
|
|
248
253
|
]);
|
|
249
254
|
return new web3_js_1.TransactionInstruction({
|
|
250
255
|
keys: keys,
|
|
@@ -253,38 +258,6 @@ var withdrawStreamInstruction = function (amount, programId, _a) {
|
|
|
253
258
|
});
|
|
254
259
|
};
|
|
255
260
|
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;
|
|
288
261
|
var cancelStreamInstruction = function (programId, _a) {
|
|
289
262
|
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;
|
|
290
263
|
var keys = [
|
|
@@ -368,7 +341,7 @@ var topupStreamInstruction = function (amount, programId, _a) {
|
|
|
368
341
|
data = buffer_1.Buffer.concat([
|
|
369
342
|
buffer_1.Buffer.from(js_sha256_1.sha256.digest("global:topup")).slice(0, 8),
|
|
370
343
|
data,
|
|
371
|
-
buffer_1.Buffer.alloc(10)
|
|
344
|
+
buffer_1.Buffer.alloc(10)
|
|
372
345
|
]);
|
|
373
346
|
return new web3_js_1.TransactionInstruction({
|
|
374
347
|
keys: keys,
|
|
@@ -377,12 +350,22 @@ var topupStreamInstruction = function (amount, programId, _a) {
|
|
|
377
350
|
});
|
|
378
351
|
};
|
|
379
352
|
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;
|
|
380
363
|
var prepareWrappedAccount = function (connection, senderAddress, amount) { return __awaiter(void 0, void 0, void 0, function () {
|
|
381
364
|
var tokenAccount, accInfo, instructions;
|
|
382
365
|
var _a, _b;
|
|
383
366
|
return __generator(this, function (_c) {
|
|
384
367
|
switch (_c.label) {
|
|
385
|
-
case 0: return [4 /*yield*/, (
|
|
368
|
+
case 0: return [4 /*yield*/, spl_token_1.Token.getAssociatedTokenAddress(spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, spl_token_1.TOKEN_PROGRAM_ID, spl_token_1.NATIVE_MINT, senderAddress, true)];
|
|
386
369
|
case 1:
|
|
387
370
|
tokenAccount = _c.sent();
|
|
388
371
|
return [4 /*yield*/, connection.getParsedAccountInfo(tokenAccount)];
|
|
@@ -391,7 +374,7 @@ var prepareWrappedAccount = function (connection, senderAddress, amount) { retur
|
|
|
391
374
|
instructions = ((_b = (_a = accInfo.value) === null || _a === void 0 ? void 0 : _a.lamports) !== null && _b !== void 0 ? _b : 0) > 0
|
|
392
375
|
? []
|
|
393
376
|
: [
|
|
394
|
-
(
|
|
377
|
+
spl_token_1.Token.createAssociatedTokenAccountInstruction(spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, spl_token_1.TOKEN_PROGRAM_ID, spl_token_1.NATIVE_MINT, tokenAccount, senderAddress, senderAddress),
|
|
395
378
|
];
|
|
396
379
|
return [2 /*return*/, __spreadArray(__spreadArray([], __read(instructions), false), [
|
|
397
380
|
web3_js_1.SystemProgram.transfer({
|
|
@@ -399,7 +382,7 @@ var prepareWrappedAccount = function (connection, senderAddress, amount) { retur
|
|
|
399
382
|
toPubkey: tokenAccount,
|
|
400
383
|
lamports: amount.mul(new bn_js_1.default(constants_1.BASE_FEE)).div(new bn_js_1.default(1000000)).toNumber(),
|
|
401
384
|
}),
|
|
402
|
-
(0,
|
|
385
|
+
(0, exports.createSyncNativeInstruction)(tokenAccount),
|
|
403
386
|
], false)];
|
|
404
387
|
}
|
|
405
388
|
});
|
package/dist/layout.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
declare const BufferLayout: any;
|
|
2
|
+
/**
|
|
3
|
+
* Stream layout
|
|
4
|
+
*/
|
|
5
|
+
export declare const streamLayout: typeof BufferLayout.Structure;
|
|
6
|
+
/**
|
|
7
|
+
* Create stream instruction layout
|
|
8
|
+
*/
|
|
9
|
+
export declare const createStreamLayout: typeof BufferLayout.Structure;
|
|
10
|
+
/**
|
|
11
|
+
* Create unchecked stream instruction layout
|
|
12
|
+
*/
|
|
13
|
+
export declare const createUncheckedStreamLayout: typeof BufferLayout.Structure;
|
|
14
|
+
/**
|
|
15
|
+
* Withdraw stream instruction layout
|
|
16
|
+
*/
|
|
17
|
+
export declare const withdrawStreamLayout: typeof BufferLayout.Structure;
|
|
18
|
+
/**
|
|
19
|
+
* Topup stream instruction layout
|
|
20
|
+
*/
|
|
21
|
+
export declare const topupStreamLayout: typeof BufferLayout.Structure;
|
|
22
|
+
export {};
|
|
@@ -1,30 +1,7 @@
|
|
|
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
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.topupStreamLayout = exports.
|
|
27
|
-
var BufferLayout =
|
|
3
|
+
exports.topupStreamLayout = exports.withdrawStreamLayout = exports.createUncheckedStreamLayout = exports.createStreamLayout = exports.streamLayout = void 0;
|
|
4
|
+
var BufferLayout = require("buffer-layout");
|
|
28
5
|
/**
|
|
29
6
|
* Stream layout
|
|
30
7
|
*/
|
|
@@ -113,46 +90,7 @@ exports.createUncheckedStreamLayout = BufferLayout.struct([
|
|
|
113
90
|
* Withdraw stream instruction layout
|
|
114
91
|
*/
|
|
115
92
|
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;
|
|
153
93
|
/**
|
|
154
94
|
* Topup stream instruction layout
|
|
155
95
|
*/
|
|
156
|
-
exports.topupStreamLayout = BufferLayout.struct([
|
|
157
|
-
BufferLayout.blob(8, "amount"),
|
|
158
|
-
]);
|
|
96
|
+
exports.topupStreamLayout = BufferLayout.struct([BufferLayout.blob(8, "amount")]);
|