@streamflow/stream 7.5.3 → 8.0.0-alpha.p284.726ba98
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/cjs/BaseStreamClient-CQOC8m8V.d.cts +542 -0
- package/dist/cjs/aptos/index.cjs +456 -0
- package/dist/cjs/aptos/index.cjs.map +1 -0
- package/dist/cjs/aptos/index.d.cts +14 -0
- package/dist/cjs/evm/index.cjs +1915 -0
- package/dist/cjs/evm/index.cjs.map +1 -0
- package/dist/cjs/evm/index.d.cts +13 -0
- package/dist/cjs/index-CYu6i--S.d.cts +136 -0
- package/dist/cjs/index-DUVcpIhD.d.cts +203 -0
- package/dist/cjs/index-b7Qo5mCj.d.cts +664 -0
- package/dist/cjs/index-fNLnPKzv.d.cts +213 -0
- package/dist/cjs/index.cjs +7202 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +192 -0
- package/dist/cjs/solana/descriptor/streamflow_aligned_unlocks.cjs +4 -0
- package/dist/cjs/solana/descriptor/streamflow_aligned_unlocks.cjs.map +1 -0
- package/dist/cjs/solana/descriptor/streamflow_aligned_unlocks.d.cts +1234 -0
- package/dist/cjs/solana/index.cjs +3762 -0
- package/dist/cjs/solana/index.cjs.map +1 -0
- package/dist/cjs/solana/index.d.cts +17 -0
- package/dist/cjs/sui/index.cjs +1021 -0
- package/dist/cjs/sui/index.cjs.map +1 -0
- package/dist/cjs/sui/index.d.cts +13 -0
- package/dist/esm/BaseStreamClient-CQOC8m8V.d.ts +542 -0
- package/dist/esm/aptos/index.d.ts +14 -4
- package/dist/esm/aptos/index.js +443 -4
- package/dist/esm/aptos/index.js.map +1 -0
- package/dist/esm/evm/index.d.ts +13 -5
- package/dist/esm/evm/index.js +1902 -5
- package/dist/esm/evm/index.js.map +1 -0
- package/dist/esm/index-BEo0O2IG.d.ts +664 -0
- package/dist/esm/index-CWmb3-x9.d.ts +136 -0
- package/dist/esm/index-Cgv37xlG.d.ts +213 -0
- package/dist/esm/index-D6QYg8hn.d.ts +203 -0
- package/dist/esm/index.d.ts +192 -10
- package/dist/esm/index.js +7109 -10
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/solana/descriptor/idl/streamflow_aligned_unlocks.json +917 -1368
- package/dist/esm/solana/descriptor/streamflow_aligned_unlocks.d.ts +3 -1
- package/dist/esm/solana/descriptor/streamflow_aligned_unlocks.js +3 -1
- package/dist/esm/solana/descriptor/streamflow_aligned_unlocks.js.map +1 -0
- package/dist/esm/solana/index.d.ts +17 -7
- package/dist/esm/solana/index.js +3706 -7
- package/dist/esm/solana/index.js.map +1 -0
- package/dist/esm/sui/index.d.ts +13 -4
- package/dist/esm/sui/index.js +1011 -4
- package/dist/esm/sui/index.js.map +1 -0
- package/package.json +57 -27
- package/dist/cjs/__tests__/aptos/streamClient.spec.js +0 -111
- package/dist/cjs/__tests__/common/GenericStreamClient.spec.js +0 -45
- package/dist/cjs/aptos/StreamClient.js +0 -226
- package/dist/cjs/aptos/constants.js +0 -27
- package/dist/cjs/aptos/index.js +0 -38
- package/dist/cjs/aptos/types.js +0 -69
- package/dist/cjs/aptos/utils.js +0 -34
- package/dist/cjs/aptos/wallet.js +0 -34
- package/dist/cjs/common/BaseStreamClient.js +0 -23
- package/dist/cjs/common/GenericStreamClient.js +0 -102
- package/dist/cjs/common/constants.js +0 -10
- package/dist/cjs/common/contractUtils.js +0 -77
- package/dist/cjs/common/types.js +0 -141
- package/dist/cjs/common/utils.js +0 -69
- package/dist/cjs/evm/StreamClient.js +0 -238
- package/dist/cjs/evm/abi.js +0 -1257
- package/dist/cjs/evm/constants.js +0 -38
- package/dist/cjs/evm/ercAbi.js +0 -224
- package/dist/cjs/evm/index.js +0 -40
- package/dist/cjs/evm/types.js +0 -66
- package/dist/cjs/evm/utils.js +0 -11
- package/dist/cjs/index.js +0 -43
- package/dist/cjs/solana/StreamClient.js +0 -1042
- package/dist/cjs/solana/constants.js +0 -95
- package/dist/cjs/solana/descriptor/idl/streamflow_aligned_unlocks.json +0 -1437
- package/dist/cjs/solana/descriptor/streamflow_aligned_unlocks.js +0 -2
- package/dist/cjs/solana/index.js +0 -40
- package/dist/cjs/solana/instructionTypes.js +0 -2
- package/dist/cjs/solana/instructions.js +0 -298
- package/dist/cjs/solana/layout.js +0 -182
- package/dist/cjs/solana/lib/derive-accounts.js +0 -17
- package/dist/cjs/solana/lib/utils.js +0 -127
- package/dist/cjs/solana/timelockIDL.js +0 -422
- package/dist/cjs/solana/types.js +0 -93
- package/dist/cjs/sui/StreamClient.js +0 -416
- package/dist/cjs/sui/constants.js +0 -42
- package/dist/cjs/sui/index.js +0 -37
- package/dist/cjs/sui/types.js +0 -68
- package/dist/cjs/sui/utils.js +0 -46
- package/dist/cjs/sui/wallet.js +0 -40
- package/dist/esm/__tests__/aptos/streamClient.spec.d.ts +0 -1
- package/dist/esm/__tests__/aptos/streamClient.spec.js +0 -106
- package/dist/esm/__tests__/common/GenericStreamClient.spec.d.ts +0 -1
- package/dist/esm/__tests__/common/GenericStreamClient.spec.js +0 -40
- package/dist/esm/aptos/StreamClient.d.ts +0 -53
- package/dist/esm/aptos/StreamClient.js +0 -226
- package/dist/esm/aptos/constants.d.ts +0 -8
- package/dist/esm/aptos/constants.js +0 -24
- package/dist/esm/aptos/types.d.ts +0 -109
- package/dist/esm/aptos/types.js +0 -105
- package/dist/esm/aptos/utils.d.ts +0 -7
- package/dist/esm/aptos/utils.js +0 -30
- package/dist/esm/aptos/wallet.d.ts +0 -9
- package/dist/esm/aptos/wallet.js +0 -33
- package/dist/esm/common/BaseStreamClient.d.ts +0 -22
- package/dist/esm/common/BaseStreamClient.js +0 -19
- package/dist/esm/common/GenericStreamClient.d.ts +0 -72
- package/dist/esm/common/GenericStreamClient.js +0 -101
- package/dist/esm/common/constants.d.ts +0 -4
- package/dist/esm/common/constants.js +0 -4
- package/dist/esm/common/contractUtils.d.ts +0 -63
- package/dist/esm/common/contractUtils.js +0 -61
- package/dist/esm/common/types.d.ts +0 -353
- package/dist/esm/common/types.js +0 -135
- package/dist/esm/common/utils.d.ts +0 -32
- package/dist/esm/common/utils.js +0 -59
- package/dist/esm/evm/StreamClient.d.ts +0 -32
- package/dist/esm/evm/StreamClient.js +0 -237
- package/dist/esm/evm/abi.d.ts +0 -111
- package/dist/esm/evm/abi.js +0 -1255
- package/dist/esm/evm/constants.d.ts +0 -20
- package/dist/esm/evm/constants.js +0 -35
- package/dist/esm/evm/ercAbi.d.ts +0 -39
- package/dist/esm/evm/ercAbi.js +0 -222
- package/dist/esm/evm/types.d.ts +0 -98
- package/dist/esm/evm/types.js +0 -102
- package/dist/esm/evm/utils.d.ts +0 -1
- package/dist/esm/evm/utils.js +0 -8
- package/dist/esm/solana/StreamClient.d.ts +0 -150
- package/dist/esm/solana/StreamClient.js +0 -1017
- package/dist/esm/solana/constants.d.ts +0 -70
- package/dist/esm/solana/constants.js +0 -92
- package/dist/esm/solana/instructionTypes.d.ts +0 -101
- package/dist/esm/solana/instructionTypes.js +0 -1
- package/dist/esm/solana/instructions.d.ts +0 -142
- package/dist/esm/solana/instructions.js +0 -265
- package/dist/esm/solana/layout.d.ts +0 -27
- package/dist/esm/solana/layout.js +0 -155
- package/dist/esm/solana/lib/derive-accounts.d.ts +0 -4
- package/dist/esm/solana/lib/derive-accounts.js +0 -11
- package/dist/esm/solana/lib/utils.d.ts +0 -22
- package/dist/esm/solana/lib/utils.js +0 -117
- package/dist/esm/solana/timelockIDL.d.ts +0 -22
- package/dist/esm/solana/timelockIDL.js +0 -420
- package/dist/esm/solana/types.d.ts +0 -180
- package/dist/esm/solana/types.js +0 -142
- package/dist/esm/sui/StreamClient.d.ts +0 -82
- package/dist/esm/sui/StreamClient.js +0 -417
- package/dist/esm/sui/constants.d.ts +0 -10
- package/dist/esm/sui/constants.js +0 -39
- package/dist/esm/sui/types.d.ts +0 -167
- package/dist/esm/sui/types.js +0 -104
- package/dist/esm/sui/utils.d.ts +0 -11
- package/dist/esm/sui/utils.js +0 -39
- package/dist/esm/sui/wallet.d.ts +0 -17
- package/dist/esm/sui/wallet.js +0 -38
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as BufferLayout from "@solana/buffer-layout";
|
|
2
|
-
import { ICreateStreamLayout, ICreateUncheckedStreamLayout, IPartnerLayout, IStreamLayout, ITopupStreamLayout, IUpdateStreamLayout, IWithdrawStreamLayout } from "./instructionTypes.js";
|
|
3
|
-
/**
|
|
4
|
-
* Stream layout
|
|
5
|
-
*/
|
|
6
|
-
export declare const streamLayout: BufferLayout.Structure<IStreamLayout>;
|
|
7
|
-
export declare const partnerLayout: BufferLayout.Structure<IPartnerLayout>;
|
|
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,155 +0,0 @@
|
|
|
1
|
-
import * as BufferLayout from "@solana/buffer-layout";
|
|
2
|
-
import { CREATE_PARAMS_PADDING } from "./constants.js";
|
|
3
|
-
/**
|
|
4
|
-
* Stream layout
|
|
5
|
-
*/
|
|
6
|
-
export const streamLayout = BufferLayout.struct([
|
|
7
|
-
BufferLayout.blob(8, "magic"),
|
|
8
|
-
BufferLayout.blob(1, "version"),
|
|
9
|
-
BufferLayout.blob(8, "created_at"),
|
|
10
|
-
BufferLayout.blob(8, "withdrawn_amount"),
|
|
11
|
-
BufferLayout.blob(8, "canceled_at"),
|
|
12
|
-
BufferLayout.blob(8, "end_time"),
|
|
13
|
-
BufferLayout.blob(8, "last_withdrawn_at"),
|
|
14
|
-
BufferLayout.blob(32, "sender"),
|
|
15
|
-
BufferLayout.blob(32, "sender_tokens"),
|
|
16
|
-
BufferLayout.blob(32, "recipient"),
|
|
17
|
-
BufferLayout.blob(32, "recipient_tokens"),
|
|
18
|
-
BufferLayout.blob(32, "mint"),
|
|
19
|
-
BufferLayout.blob(32, "escrow_tokens"),
|
|
20
|
-
BufferLayout.blob(32, "streamflow_treasury"),
|
|
21
|
-
BufferLayout.blob(32, "streamflow_treasury_tokens"),
|
|
22
|
-
BufferLayout.blob(8, "streamflow_fee_total"),
|
|
23
|
-
BufferLayout.blob(8, "streamflow_fee_withdrawn"),
|
|
24
|
-
BufferLayout.f32("streamflow_fee_percent"),
|
|
25
|
-
BufferLayout.blob(32, "partner"),
|
|
26
|
-
BufferLayout.blob(32, "partner_tokens"),
|
|
27
|
-
BufferLayout.blob(8, "partner_fee_total"),
|
|
28
|
-
BufferLayout.blob(8, "partner_fee_withdrawn"),
|
|
29
|
-
BufferLayout.f32("partner_fee_percent"),
|
|
30
|
-
BufferLayout.blob(8, "start_time"),
|
|
31
|
-
BufferLayout.blob(8, "net_amount_deposited"),
|
|
32
|
-
BufferLayout.blob(8, "period"),
|
|
33
|
-
BufferLayout.blob(8, "amount_per_period"),
|
|
34
|
-
BufferLayout.blob(8, "cliff"),
|
|
35
|
-
BufferLayout.blob(8, "cliff_amount"),
|
|
36
|
-
BufferLayout.u8("cancelable_by_sender"),
|
|
37
|
-
BufferLayout.u8("cancelable_by_recipient"),
|
|
38
|
-
BufferLayout.u8("automatic_withdrawal"),
|
|
39
|
-
BufferLayout.u8("transferable_by_sender"),
|
|
40
|
-
BufferLayout.u8("transferable_by_recipient"),
|
|
41
|
-
BufferLayout.u8("can_topup"),
|
|
42
|
-
BufferLayout.blob(64, "stream_name"),
|
|
43
|
-
BufferLayout.blob(8, "withdraw_frequency"),
|
|
44
|
-
// Unused, kept for backward compatibility™
|
|
45
|
-
BufferLayout.blob(4, "ghost"),
|
|
46
|
-
BufferLayout.u8("pausable"),
|
|
47
|
-
BufferLayout.u8("can_update_rate"),
|
|
48
|
-
BufferLayout.blob(4, "create_stream_params_padding_length"),
|
|
49
|
-
BufferLayout.seq(BufferLayout.u8(), CREATE_PARAMS_PADDING, "create_params_padding"),
|
|
50
|
-
BufferLayout.u8("closed"),
|
|
51
|
-
BufferLayout.blob(8, "current_pause_start"),
|
|
52
|
-
BufferLayout.blob(8, "pause_cumulative"),
|
|
53
|
-
BufferLayout.blob(8, "last_rate_change_time"),
|
|
54
|
-
BufferLayout.blob(8, "funds_unlocked_at_last_rate_change"),
|
|
55
|
-
]);
|
|
56
|
-
export const partnerLayout = BufferLayout.struct([
|
|
57
|
-
BufferLayout.blob(32, "pubkey"),
|
|
58
|
-
BufferLayout.f32("partner_fee"),
|
|
59
|
-
BufferLayout.f32("strm_fee"),
|
|
60
|
-
]);
|
|
61
|
-
/**
|
|
62
|
-
* Create stream instruction layout
|
|
63
|
-
*/
|
|
64
|
-
export const createStreamLayout = BufferLayout.struct([
|
|
65
|
-
BufferLayout.blob(8, "start_time"),
|
|
66
|
-
BufferLayout.blob(8, "net_amount_deposited"),
|
|
67
|
-
BufferLayout.blob(8, "period"),
|
|
68
|
-
BufferLayout.blob(8, "amount_per_period"),
|
|
69
|
-
BufferLayout.blob(8, "cliff"),
|
|
70
|
-
BufferLayout.blob(8, "cliff_amount"),
|
|
71
|
-
BufferLayout.u8("cancelable_by_sender"),
|
|
72
|
-
BufferLayout.u8("cancelable_by_recipient"),
|
|
73
|
-
BufferLayout.u8("automatic_withdrawal"),
|
|
74
|
-
BufferLayout.u8("transferable_by_sender"),
|
|
75
|
-
BufferLayout.u8("transferable_by_recipient"),
|
|
76
|
-
BufferLayout.u8("can_topup"),
|
|
77
|
-
BufferLayout.blob(64, "stream_name"),
|
|
78
|
-
BufferLayout.blob(8, "withdraw_frequency"),
|
|
79
|
-
// discriminator for optional field
|
|
80
|
-
BufferLayout.u8("_pausable_discriminator"),
|
|
81
|
-
BufferLayout.u8("pausable"),
|
|
82
|
-
// discriminator for optional field
|
|
83
|
-
BufferLayout.u8("_can_update_rate_discriminator"),
|
|
84
|
-
BufferLayout.u8("can_update_rate"),
|
|
85
|
-
]);
|
|
86
|
-
/**
|
|
87
|
-
* Create unchecked stream instruction layout
|
|
88
|
-
*/
|
|
89
|
-
export const createUncheckedStreamLayout = BufferLayout.struct([
|
|
90
|
-
BufferLayout.blob(8, "start_time"),
|
|
91
|
-
BufferLayout.blob(8, "net_amount_deposited"),
|
|
92
|
-
BufferLayout.blob(8, "period"),
|
|
93
|
-
BufferLayout.blob(8, "amount_per_period"),
|
|
94
|
-
BufferLayout.blob(8, "cliff"),
|
|
95
|
-
BufferLayout.blob(8, "cliff_amount"),
|
|
96
|
-
BufferLayout.u8("cancelable_by_sender"),
|
|
97
|
-
BufferLayout.u8("cancelable_by_recipient"),
|
|
98
|
-
BufferLayout.u8("automatic_withdrawal"),
|
|
99
|
-
BufferLayout.u8("transferable_by_sender"),
|
|
100
|
-
BufferLayout.u8("transferable_by_recipient"),
|
|
101
|
-
BufferLayout.u8("can_topup"),
|
|
102
|
-
BufferLayout.blob(64, "stream_name"),
|
|
103
|
-
BufferLayout.blob(8, "withdraw_frequency"),
|
|
104
|
-
BufferLayout.blob(32, "recipient"),
|
|
105
|
-
BufferLayout.blob(32, "partner"),
|
|
106
|
-
BufferLayout.u8("pausable"),
|
|
107
|
-
BufferLayout.u8("can_update_rate"),
|
|
108
|
-
]);
|
|
109
|
-
/**
|
|
110
|
-
* Withdraw stream instruction layout
|
|
111
|
-
*/
|
|
112
|
-
export const withdrawStreamLayout = BufferLayout.struct([
|
|
113
|
-
BufferLayout.blob(8, "amount"),
|
|
114
|
-
]);
|
|
115
|
-
/**
|
|
116
|
-
* Encode stream instruction layout
|
|
117
|
-
*/
|
|
118
|
-
export const encodeUpdateStream = (values, data) => {
|
|
119
|
-
const structs = [];
|
|
120
|
-
if (values.enable_automatic_withdrawal) {
|
|
121
|
-
structs.push(BufferLayout.u8("enable_automatic_withdrawal_exists"));
|
|
122
|
-
structs.push(BufferLayout.u8("enable_automatic_withdrawal"));
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
structs.push(BufferLayout.u8("enable_automatic_withdrawal_exists"));
|
|
126
|
-
}
|
|
127
|
-
if (values.withdraw_frequency) {
|
|
128
|
-
structs.push(BufferLayout.u8("withdraw_frequency_exists"));
|
|
129
|
-
structs.push(BufferLayout.blob(8, "withdraw_frequency"));
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
structs.push(BufferLayout.u8("withdraw_frequency_exists"));
|
|
133
|
-
}
|
|
134
|
-
if (values.amount_per_period) {
|
|
135
|
-
structs.push(BufferLayout.u8("amount_per_period_exists"));
|
|
136
|
-
structs.push(BufferLayout.blob(8, "amount_per_period"));
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
structs.push(BufferLayout.u8("amount_per_period_exists"));
|
|
140
|
-
}
|
|
141
|
-
return BufferLayout.struct(structs).encode({
|
|
142
|
-
enable_automatic_withdrawal_exists: values.enable_automatic_withdrawal ? 1 : 0,
|
|
143
|
-
enable_automatic_withdrawal: values.enable_automatic_withdrawal ?? 0,
|
|
144
|
-
withdraw_frequency_exists: values.withdraw_frequency ? 1 : 0,
|
|
145
|
-
withdraw_frequency: values.withdraw_frequency ?? 0,
|
|
146
|
-
amount_per_period_exists: values.amount_per_period ? 1 : 0,
|
|
147
|
-
amount_per_period: values.amount_per_period ?? 0,
|
|
148
|
-
}, data);
|
|
149
|
-
};
|
|
150
|
-
/**
|
|
151
|
-
* Topup stream instruction layout
|
|
152
|
-
*/
|
|
153
|
-
export const topupStreamLayout = BufferLayout.struct([
|
|
154
|
-
BufferLayout.blob(8, "amount"),
|
|
155
|
-
]);
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { PublicKey } from "@solana/web3.js";
|
|
2
|
-
export declare const deriveContractPDA: (programId: PublicKey, streamMetadata: PublicKey) => PublicKey;
|
|
3
|
-
export declare const deriveEscrowPDA: (programId: PublicKey, streamMetadata: PublicKey) => PublicKey;
|
|
4
|
-
export declare const deriveTestOraclePDA: (programId: PublicKey, mint: PublicKey, creator: PublicKey) => PublicKey;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { PublicKey } from "@solana/web3.js";
|
|
2
|
-
import { CONTRACT_SEED, ESCROW_SEED, TEST_ORACLE_SEED } from "../constants.js";
|
|
3
|
-
export const deriveContractPDA = (programId, streamMetadata) => {
|
|
4
|
-
return PublicKey.findProgramAddressSync([CONTRACT_SEED, streamMetadata.toBuffer()], programId)[0];
|
|
5
|
-
};
|
|
6
|
-
export const deriveEscrowPDA = (programId, streamMetadata) => {
|
|
7
|
-
return PublicKey.findProgramAddressSync([ESCROW_SEED, streamMetadata.toBuffer()], programId)[0];
|
|
8
|
-
};
|
|
9
|
-
export const deriveTestOraclePDA = (programId, mint, creator) => {
|
|
10
|
-
return PublicKey.findProgramAddressSync([TEST_ORACLE_SEED, mint.toBuffer(), creator.toBuffer()], programId)[0];
|
|
11
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { SignerWalletAdapter } from "@solana/wallet-adapter-base";
|
|
2
|
-
import { Connection, Keypair } from "@solana/web3.js";
|
|
3
|
-
import { ConfirmationParams, ThrottleParams } from "@streamflow/common/solana";
|
|
4
|
-
import { DecodedStream, BatchItem, BatchItemResult } from "../types.js";
|
|
5
|
-
export declare const decodeStream: (buf: Buffer) => DecodedStream;
|
|
6
|
-
/**
|
|
7
|
-
* Sign passed BatchItems with wallet request or KeyPair
|
|
8
|
-
* @param {Keypair | SignerWalletAdapter} sender - Wallet or Keypair of sendin account
|
|
9
|
-
* @param {BatchItem[]} items - Multiple recipient contracts split into separate items
|
|
10
|
-
* @return {BatchItem[]} - Returns items with signatures.
|
|
11
|
-
*/
|
|
12
|
-
export declare function signAllTransactionWithRecipients(sender: Keypair | SignerWalletAdapter, items: BatchItem[]): Promise<BatchItem[]>;
|
|
13
|
-
/**
|
|
14
|
-
* Sign passed BatchItems with wallet request or KeyPair
|
|
15
|
-
* @param {Connection} connection - Solana web3 connection object.
|
|
16
|
-
* @param {BatchItem} batchItem - Signed transaction ready to be send.
|
|
17
|
-
* @param confirmationParams - Confirmation Params that will be used for execution
|
|
18
|
-
* @param throttleParams - rate or throttler instance to throttle TX sending - to not spam the blockchain too much
|
|
19
|
-
* @return {Promise<BatchItemResult>} - Returns settled transaction item
|
|
20
|
-
*/
|
|
21
|
-
export declare function sendAndConfirmStreamRawTransaction(connection: Connection, batchItem: BatchItem, confirmationParams: ConfirmationParams, throttleParams: ThrottleParams): Promise<BatchItemResult>;
|
|
22
|
-
export declare function extractSolanaErrorCode(errorText: string, logs?: string[]): string | null;
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { PublicKey } from "@solana/web3.js";
|
|
2
|
-
import { executeTransaction, isSignerKeypair, isSignerWallet, } from "@streamflow/common/solana";
|
|
3
|
-
import BN from "bn.js";
|
|
4
|
-
import { streamLayout } from "../layout.js";
|
|
5
|
-
import { SOLANA_ERROR_MAP, SOLANA_ERROR_MATCH_REGEX } from "../constants.js";
|
|
6
|
-
const decoder = new TextDecoder("utf-8");
|
|
7
|
-
const LE = "le"; //little endian
|
|
8
|
-
export const decodeStream = (buf) => {
|
|
9
|
-
const raw = streamLayout.decode(buf);
|
|
10
|
-
return {
|
|
11
|
-
magic: new BN(raw.magic, LE),
|
|
12
|
-
version: new BN(raw.version, LE),
|
|
13
|
-
createdAt: new BN(raw.created_at, LE),
|
|
14
|
-
withdrawnAmount: new BN(raw.withdrawn_amount, LE),
|
|
15
|
-
canceledAt: new BN(raw.canceled_at, LE),
|
|
16
|
-
end: new BN(raw.end_time, LE),
|
|
17
|
-
lastWithdrawnAt: new BN(raw.last_withdrawn_at, LE),
|
|
18
|
-
sender: new PublicKey(raw.sender),
|
|
19
|
-
senderTokens: new PublicKey(raw.sender_tokens),
|
|
20
|
-
recipient: new PublicKey(raw.recipient),
|
|
21
|
-
recipientTokens: new PublicKey(raw.recipient_tokens),
|
|
22
|
-
mint: new PublicKey(raw.mint),
|
|
23
|
-
escrowTokens: new PublicKey(raw.escrow_tokens),
|
|
24
|
-
streamflowTreasury: new PublicKey(raw.streamflow_treasury),
|
|
25
|
-
streamflowTreasuryTokens: new PublicKey(raw.streamflow_treasury_tokens),
|
|
26
|
-
streamflowFeeTotal: new BN(raw.streamflow_fee_total, LE),
|
|
27
|
-
streamflowFeeWithdrawn: new BN(raw.streamflow_fee_withdrawn, LE),
|
|
28
|
-
streamflowFeePercent: new BN(raw.streamflow_fee_percent, LE),
|
|
29
|
-
partnerFeeTotal: new BN(raw.partner_fee_total, LE),
|
|
30
|
-
partnerFeeWithdrawn: new BN(raw.partner_fee_withdrawn, LE),
|
|
31
|
-
partnerFeePercent: new BN(raw.partner_fee_percent, LE),
|
|
32
|
-
partner: new PublicKey(raw.partner),
|
|
33
|
-
partnerTokens: new PublicKey(raw.partner_tokens),
|
|
34
|
-
start: new BN(raw.start_time, LE),
|
|
35
|
-
depositedAmount: new BN(raw.net_amount_deposited, LE),
|
|
36
|
-
period: new BN(raw.period, LE),
|
|
37
|
-
amountPerPeriod: new BN(raw.amount_per_period, LE),
|
|
38
|
-
cliff: new BN(raw.cliff, LE),
|
|
39
|
-
cliffAmount: new BN(raw.cliff_amount, LE),
|
|
40
|
-
cancelableBySender: Boolean(raw.cancelable_by_sender),
|
|
41
|
-
cancelableByRecipient: Boolean(raw.cancelable_by_recipient),
|
|
42
|
-
automaticWithdrawal: Boolean(raw.automatic_withdrawal),
|
|
43
|
-
transferableBySender: Boolean(raw.transferable_by_sender),
|
|
44
|
-
transferableByRecipient: Boolean(raw.transferable_by_recipient),
|
|
45
|
-
canTopup: Boolean(raw.can_topup),
|
|
46
|
-
name: decoder.decode(raw.stream_name),
|
|
47
|
-
withdrawFrequency: new BN(raw.withdraw_frequency, LE),
|
|
48
|
-
closed: Boolean(raw.closed),
|
|
49
|
-
currentPauseStart: new BN(raw.current_pause_start, LE),
|
|
50
|
-
pauseCumulative: new BN(raw.pause_cumulative, LE),
|
|
51
|
-
lastRateChangeTime: new BN(raw.last_rate_change_time, LE),
|
|
52
|
-
fundsUnlockedAtLastRateChange: new BN(raw.funds_unlocked_at_last_rate_change, LE),
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* Sign passed BatchItems with wallet request or KeyPair
|
|
57
|
-
* @param {Keypair | SignerWalletAdapter} sender - Wallet or Keypair of sendin account
|
|
58
|
-
* @param {BatchItem[]} items - Multiple recipient contracts split into separate items
|
|
59
|
-
* @return {BatchItem[]} - Returns items with signatures.
|
|
60
|
-
*/
|
|
61
|
-
export async function signAllTransactionWithRecipients(sender, items) {
|
|
62
|
-
const isKeypair = isSignerKeypair(sender);
|
|
63
|
-
const isWallet = isSignerWallet(sender);
|
|
64
|
-
if (isKeypair) {
|
|
65
|
-
return items.map((t) => {
|
|
66
|
-
t.tx.sign([sender]);
|
|
67
|
-
return { tx: t.tx, recipient: t.recipient };
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
else if (isWallet) {
|
|
71
|
-
const signedTxs = await sender.signAllTransactions(items.map((t) => t.tx));
|
|
72
|
-
return items.map((item, index) => ({
|
|
73
|
-
...item,
|
|
74
|
-
tx: signedTxs[index],
|
|
75
|
-
}));
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
// If signer is not passed
|
|
79
|
-
return [];
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Sign passed BatchItems with wallet request or KeyPair
|
|
84
|
-
* @param {Connection} connection - Solana web3 connection object.
|
|
85
|
-
* @param {BatchItem} batchItem - Signed transaction ready to be send.
|
|
86
|
-
* @param confirmationParams - Confirmation Params that will be used for execution
|
|
87
|
-
* @param throttleParams - rate or throttler instance to throttle TX sending - to not spam the blockchain too much
|
|
88
|
-
* @return {Promise<BatchItemResult>} - Returns settled transaction item
|
|
89
|
-
*/
|
|
90
|
-
export async function sendAndConfirmStreamRawTransaction(connection, batchItem, confirmationParams, throttleParams) {
|
|
91
|
-
try {
|
|
92
|
-
const completedTxSignature = await executeTransaction(connection, batchItem.tx, confirmationParams, throttleParams);
|
|
93
|
-
return { ...batchItem, signature: completedTxSignature };
|
|
94
|
-
}
|
|
95
|
-
catch (error) {
|
|
96
|
-
throw {
|
|
97
|
-
recipient: batchItem.recipient,
|
|
98
|
-
error,
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
export function extractSolanaErrorCode(errorText, logs) {
|
|
103
|
-
let match = SOLANA_ERROR_MATCH_REGEX.exec(errorText);
|
|
104
|
-
if (!match && logs) {
|
|
105
|
-
for (const logLine of logs) {
|
|
106
|
-
match = SOLANA_ERROR_MATCH_REGEX.exec(logLine);
|
|
107
|
-
if (match !== null) {
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
if (!match) {
|
|
113
|
-
return null;
|
|
114
|
-
}
|
|
115
|
-
const errorCode = Number(match[1]);
|
|
116
|
-
return SOLANA_ERROR_MAP[errorCode] || null;
|
|
117
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
version: string;
|
|
3
|
-
name: string;
|
|
4
|
-
instructions: {
|
|
5
|
-
name: string;
|
|
6
|
-
accounts: {
|
|
7
|
-
name: string;
|
|
8
|
-
isMut: boolean;
|
|
9
|
-
isSigner: boolean;
|
|
10
|
-
}[];
|
|
11
|
-
args: ({
|
|
12
|
-
name: string;
|
|
13
|
-
type: string;
|
|
14
|
-
} | {
|
|
15
|
-
name: string;
|
|
16
|
-
type: {
|
|
17
|
-
array: (string | number)[];
|
|
18
|
-
};
|
|
19
|
-
})[];
|
|
20
|
-
}[];
|
|
21
|
-
};
|
|
22
|
-
export default _default;
|