@streamflow/stream 7.5.3 → 8.0.0-alpha.p287.39c8818
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 +7189 -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 +3749 -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 +7096 -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 +3693 -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,70 +0,0 @@
|
|
|
1
|
-
import { PublicKey } from "@solana/web3.js";
|
|
2
|
-
import { Buffer } from "buffer";
|
|
3
|
-
import { ISearchStreams } from "./types.js";
|
|
4
|
-
export declare const TX_FINALITY_CONFIRMED = "confirmed";
|
|
5
|
-
export declare const ORIGINAL_CONTRACT_SENDER_OFFSET = 9;
|
|
6
|
-
export declare const STREAM_STRUCT_OFFSET_SENDER = 49;
|
|
7
|
-
export declare const STREAM_STRUCT_OFFSET_RECIPIENT = 113;
|
|
8
|
-
export declare const STREAM_STRUCT_OFFSET_MINT = 177;
|
|
9
|
-
export declare const STREAM_STRUCT_OFFSET_CLOSED = 671;
|
|
10
|
-
export declare const ALIGNED_PRECISION_FACTOR_POW = 9;
|
|
11
|
-
export declare const STREAM_STRUCT_OFFSETS: Record<keyof ISearchStreams, number>;
|
|
12
|
-
export declare const CREATE_PARAMS_PADDING = 126;
|
|
13
|
-
export declare const PROGRAM_ID: {
|
|
14
|
-
devnet: string;
|
|
15
|
-
mainnet: string;
|
|
16
|
-
testnet: string;
|
|
17
|
-
local: string;
|
|
18
|
-
};
|
|
19
|
-
export declare const ALIGNED_UNLOCKS_PROGRAM_ID: {
|
|
20
|
-
devnet: string;
|
|
21
|
-
mainnet: string;
|
|
22
|
-
testnet: string;
|
|
23
|
-
local: string;
|
|
24
|
-
};
|
|
25
|
-
export declare const ALIGNED_COMPUTE_LIMIT = 300000;
|
|
26
|
-
export declare const CONTRACT_DISCRIMINATOR: number[];
|
|
27
|
-
export declare const TEST_ORACLE_DISCRIMINATOR: number[];
|
|
28
|
-
export declare const CONTRACT_SEED: Buffer;
|
|
29
|
-
export declare const ESCROW_SEED: Buffer;
|
|
30
|
-
export declare const TEST_ORACLE_SEED: Buffer;
|
|
31
|
-
export declare const PARTNER_ORACLE_PROGRAM_ID = "pardpVtPjC8nLj1Dwncew62mUzfChdCX1EaoZe8oCAa";
|
|
32
|
-
export declare const STREAMFLOW_TREASURY_PUBLIC_KEY: PublicKey;
|
|
33
|
-
export declare const WITHDRAWOR_PUBLIC_KEY: PublicKey;
|
|
34
|
-
export declare const FEE_ORACLE_PUBLIC_KEY: PublicKey;
|
|
35
|
-
export declare const AIRDROP_TEST_TOKEN = "Gssm3vfi8s65R31SBdmQRq6cKeYojGgup7whkw4VCiQj";
|
|
36
|
-
export declare const FEES_METADATA_SEED: Buffer;
|
|
37
|
-
export declare const DEFAULT_STREAMFLOW_FEE = 0.99;
|
|
38
|
-
export declare const AIRDROP_AMOUNT = 1;
|
|
39
|
-
export declare const PARTNER_SCHEMA: {
|
|
40
|
-
struct: {
|
|
41
|
-
pubkey: {
|
|
42
|
-
array: {
|
|
43
|
-
type: string;
|
|
44
|
-
len: number;
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
partner_fee: string;
|
|
48
|
-
strm_fee: string;
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
export declare const PARTNERS_SCHEMA: {
|
|
52
|
-
array: {
|
|
53
|
-
type: {
|
|
54
|
-
struct: {
|
|
55
|
-
pubkey: {
|
|
56
|
-
array: {
|
|
57
|
-
type: string;
|
|
58
|
-
len: number;
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
partner_fee: string;
|
|
62
|
-
strm_fee: string;
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
export declare const SOLANA_ERROR_MATCH_REGEX: RegExp;
|
|
68
|
-
export declare const SOLANA_ERROR_MAP: {
|
|
69
|
-
[key: number]: string;
|
|
70
|
-
};
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { PublicKey } from "@solana/web3.js";
|
|
2
|
-
import { Buffer } from "buffer";
|
|
3
|
-
import { ICluster, SolanaContractErrorCode, SolanaAlignedProxyErrorCode } from "../common/types.js";
|
|
4
|
-
export const TX_FINALITY_CONFIRMED = "confirmed";
|
|
5
|
-
export const ORIGINAL_CONTRACT_SENDER_OFFSET = 9;
|
|
6
|
-
export const STREAM_STRUCT_OFFSET_SENDER = 49;
|
|
7
|
-
export const STREAM_STRUCT_OFFSET_RECIPIENT = 113;
|
|
8
|
-
export const STREAM_STRUCT_OFFSET_MINT = 177;
|
|
9
|
-
export const STREAM_STRUCT_OFFSET_CLOSED = 671;
|
|
10
|
-
export const ALIGNED_PRECISION_FACTOR_POW = 9;
|
|
11
|
-
export const STREAM_STRUCT_OFFSETS = {
|
|
12
|
-
mint: STREAM_STRUCT_OFFSET_MINT,
|
|
13
|
-
recipient: STREAM_STRUCT_OFFSET_RECIPIENT,
|
|
14
|
-
sender: STREAM_STRUCT_OFFSET_SENDER,
|
|
15
|
-
closed: STREAM_STRUCT_OFFSET_CLOSED,
|
|
16
|
-
};
|
|
17
|
-
// Defined: https://github.com/streamflow-finance/protocol/blob/main/programs/protocol/src/state.rs#L25
|
|
18
|
-
export const CREATE_PARAMS_PADDING = 126;
|
|
19
|
-
export const PROGRAM_ID = {
|
|
20
|
-
[ICluster.Devnet]: "HqDGZjaVRXJ9MGRQEw7qDc2rAr6iH1n1kAQdCZaCMfMZ",
|
|
21
|
-
[ICluster.Mainnet]: "strmRqUCoQUgGUan5YhzUZa6KqdzwX5L6FpUxfmKg5m",
|
|
22
|
-
[ICluster.Testnet]: "HqDGZjaVRXJ9MGRQEw7qDc2rAr6iH1n1kAQdCZaCMfMZ",
|
|
23
|
-
[ICluster.Local]: "HqDGZjaVRXJ9MGRQEw7qDc2rAr6iH1n1kAQdCZaCMfMZ",
|
|
24
|
-
};
|
|
25
|
-
export const ALIGNED_UNLOCKS_PROGRAM_ID = {
|
|
26
|
-
[ICluster.Devnet]: "aSTRM2NKoKxNnkmLWk9sz3k74gKBk9t7bpPrTGxMszH",
|
|
27
|
-
[ICluster.Mainnet]: "aSTRM2NKoKxNnkmLWk9sz3k74gKBk9t7bpPrTGxMszH",
|
|
28
|
-
[ICluster.Testnet]: "aSTRM2NKoKxNnkmLWk9sz3k74gKBk9t7bpPrTGxMszH",
|
|
29
|
-
[ICluster.Local]: "aSTRM2NKoKxNnkmLWk9sz3k74gKBk9t7bpPrTGxMszH",
|
|
30
|
-
};
|
|
31
|
-
// Aligned Unlocks Program transactions require a higher comput limit
|
|
32
|
-
export const ALIGNED_COMPUTE_LIMIT = 300000;
|
|
33
|
-
export const CONTRACT_DISCRIMINATOR = [172, 138, 115, 242, 121, 67, 183, 26];
|
|
34
|
-
export const TEST_ORACLE_DISCRIMINATOR = [198, 49, 63, 134, 232, 251, 168, 28];
|
|
35
|
-
export const CONTRACT_SEED = Buffer.from("contract", "utf-8");
|
|
36
|
-
export const ESCROW_SEED = Buffer.from("strm", "utf-8");
|
|
37
|
-
export const TEST_ORACLE_SEED = Buffer.from("test-oracle", "utf-8");
|
|
38
|
-
export const PARTNER_ORACLE_PROGRAM_ID = "pardpVtPjC8nLj1Dwncew62mUzfChdCX1EaoZe8oCAa";
|
|
39
|
-
export const STREAMFLOW_TREASURY_PUBLIC_KEY = new PublicKey("5SEpbdjFK5FxwTvfsGMXVQTD2v4M2c5tyRTxhdsPkgDw");
|
|
40
|
-
export const WITHDRAWOR_PUBLIC_KEY = new PublicKey("wdrwhnCv4pzW8beKsbPa4S2UDZrXenjg16KJdKSpb5u");
|
|
41
|
-
export const FEE_ORACLE_PUBLIC_KEY = new PublicKey("B743wFVk2pCYhV91cn287e1xY7f1vt4gdY48hhNiuQmT");
|
|
42
|
-
export const AIRDROP_TEST_TOKEN = "Gssm3vfi8s65R31SBdmQRq6cKeYojGgup7whkw4VCiQj";
|
|
43
|
-
export const FEES_METADATA_SEED = Buffer.from("strm_fees");
|
|
44
|
-
export const DEFAULT_STREAMFLOW_FEE = 0.99;
|
|
45
|
-
export const AIRDROP_AMOUNT = 1; // 1 SOL is the cap on the testnet
|
|
46
|
-
export const PARTNER_SCHEMA = {
|
|
47
|
-
struct: {
|
|
48
|
-
pubkey: { array: { type: "u8", len: 32 } },
|
|
49
|
-
partner_fee: "f32",
|
|
50
|
-
strm_fee: "f32",
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
export const PARTNERS_SCHEMA = { array: { type: PARTNER_SCHEMA } };
|
|
54
|
-
export const SOLANA_ERROR_MATCH_REGEX = /custom program error: (0x\d{2})/;
|
|
55
|
-
export const SOLANA_ERROR_MAP = {
|
|
56
|
-
0x60: SolanaContractErrorCode.AccountsNotWritable,
|
|
57
|
-
0x61: SolanaContractErrorCode.InvalidMetadata,
|
|
58
|
-
0x62: SolanaContractErrorCode.InvalidMetadataAccount,
|
|
59
|
-
0x63: SolanaContractErrorCode.MetadataAccountMismatch,
|
|
60
|
-
0x64: SolanaContractErrorCode.InvalidEscrowAccount,
|
|
61
|
-
0x65: SolanaContractErrorCode.NotAssociated,
|
|
62
|
-
0x66: SolanaContractErrorCode.MintMismatch,
|
|
63
|
-
0x67: SolanaContractErrorCode.TransferNotAllowed,
|
|
64
|
-
0x68: SolanaContractErrorCode.ContractClosed,
|
|
65
|
-
0x69: SolanaContractErrorCode.InvalidTreasury,
|
|
66
|
-
0x70: SolanaContractErrorCode.InvalidTimestamps,
|
|
67
|
-
0x71: SolanaContractErrorCode.InvalidDepositConfiguration,
|
|
68
|
-
0x72: SolanaContractErrorCode.AmountIsZero,
|
|
69
|
-
0x73: SolanaContractErrorCode.AmountMoreThanAvailable,
|
|
70
|
-
0x74: SolanaContractErrorCode.AmountAvailableIsZero,
|
|
71
|
-
0x80: SolanaContractErrorCode.ArithmeticError,
|
|
72
|
-
0x81: SolanaContractErrorCode.InvalidMetadataSize,
|
|
73
|
-
0x82: SolanaContractErrorCode.UninitializedMetadata,
|
|
74
|
-
0x83: SolanaContractErrorCode.Unauthorized,
|
|
75
|
-
0x84: SolanaContractErrorCode.SelfTransfer,
|
|
76
|
-
0x85: SolanaContractErrorCode.AlreadyPaused,
|
|
77
|
-
0x86: SolanaContractErrorCode.NotPaused,
|
|
78
|
-
0x87: SolanaContractErrorCode.MetadataNotRentExempt,
|
|
79
|
-
0x1770: SolanaAlignedProxyErrorCode.Unauthorized,
|
|
80
|
-
0x1771: SolanaAlignedProxyErrorCode.ArithmeticError,
|
|
81
|
-
0x1772: SolanaAlignedProxyErrorCode.UnsupportedTokenExtensions,
|
|
82
|
-
0x1773: SolanaAlignedProxyErrorCode.PeriodTooShort,
|
|
83
|
-
0x1774: SolanaAlignedProxyErrorCode.InvalidTickSize,
|
|
84
|
-
0x1775: SolanaAlignedProxyErrorCode.InvalidPercentageBoundaries,
|
|
85
|
-
0x1776: SolanaAlignedProxyErrorCode.InvalidPriceBoundaries,
|
|
86
|
-
0x1777: SolanaAlignedProxyErrorCode.UnsupportedOracle,
|
|
87
|
-
0x1778: SolanaAlignedProxyErrorCode.InvalidOracleAccount,
|
|
88
|
-
0x1779: SolanaAlignedProxyErrorCode.InvalidOraclePrice,
|
|
89
|
-
0x177a: SolanaAlignedProxyErrorCode.InvalidStreamMetadata,
|
|
90
|
-
0x177b: SolanaAlignedProxyErrorCode.AmountAlreadyUpdated,
|
|
91
|
-
0x177c: SolanaAlignedProxyErrorCode.AllFundsUnlocked,
|
|
92
|
-
};
|
|
@@ -1,101 +0,0 @@
|
|
|
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
|
-
ghost: Uint8Array;
|
|
40
|
-
pausable: number;
|
|
41
|
-
can_update_rate: number;
|
|
42
|
-
create_params_padding_length: number;
|
|
43
|
-
create_params_padding: number[];
|
|
44
|
-
closed: number;
|
|
45
|
-
current_pause_start: Uint8Array;
|
|
46
|
-
pause_cumulative: Uint8Array;
|
|
47
|
-
last_rate_change_time: Uint8Array;
|
|
48
|
-
funds_unlocked_at_last_rate_change: Uint8Array;
|
|
49
|
-
}
|
|
50
|
-
export interface ICreateStreamLayout {
|
|
51
|
-
start_time: Uint8Array;
|
|
52
|
-
net_amount_deposited: Uint8Array;
|
|
53
|
-
period: Uint8Array;
|
|
54
|
-
amount_per_period: Uint8Array;
|
|
55
|
-
cliff: Uint8Array;
|
|
56
|
-
cliff_amount: Uint8Array;
|
|
57
|
-
cancelable_by_sender: number;
|
|
58
|
-
cancelable_by_recipient: number;
|
|
59
|
-
automatic_withdrawal: number;
|
|
60
|
-
transferable_by_sender: number;
|
|
61
|
-
transferable_by_recipient: number;
|
|
62
|
-
can_topup: number;
|
|
63
|
-
stream_name: Uint8Array;
|
|
64
|
-
withdraw_frequency: Uint8Array;
|
|
65
|
-
}
|
|
66
|
-
export interface ICreateUncheckedStreamLayout {
|
|
67
|
-
start_time: Uint8Array;
|
|
68
|
-
net_amount_deposited: Uint8Array;
|
|
69
|
-
period: Uint8Array;
|
|
70
|
-
amount_per_period: Uint8Array;
|
|
71
|
-
cliff: Uint8Array;
|
|
72
|
-
cliff_amount: Uint8Array;
|
|
73
|
-
cancelable_by_sender: number;
|
|
74
|
-
cancelable_by_recipient: number;
|
|
75
|
-
automatic_withdrawal: number;
|
|
76
|
-
transferable_by_sender: number;
|
|
77
|
-
transferable_by_recipient: number;
|
|
78
|
-
can_topup: number;
|
|
79
|
-
stream_name: Uint8Array;
|
|
80
|
-
withdraw_frequency: Uint8Array;
|
|
81
|
-
recipient: Uint8Array;
|
|
82
|
-
partner: Uint8Array;
|
|
83
|
-
pausable: number;
|
|
84
|
-
can_update_rate: number;
|
|
85
|
-
}
|
|
86
|
-
export interface IWithdrawStreamLayout {
|
|
87
|
-
amount: Uint8Array;
|
|
88
|
-
}
|
|
89
|
-
export interface IUpdateStreamLayout {
|
|
90
|
-
enable_automatic_withdrawal?: number;
|
|
91
|
-
withdraw_frequency?: Uint8Array;
|
|
92
|
-
amount_per_period?: Uint8Array;
|
|
93
|
-
}
|
|
94
|
-
export interface ITopupStreamLayout {
|
|
95
|
-
amount: Uint8Array;
|
|
96
|
-
}
|
|
97
|
-
export interface IPartnerLayout {
|
|
98
|
-
pubkey: Uint8Array;
|
|
99
|
-
partner_fee: number;
|
|
100
|
-
strm_fee: number;
|
|
101
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
2
|
-
import BN from "bn.js";
|
|
3
|
-
import { IUpdateData } from "../common/types.js";
|
|
4
|
-
interface CreateStreamData {
|
|
5
|
-
start: BN;
|
|
6
|
-
depositedAmount: BN;
|
|
7
|
-
period: BN;
|
|
8
|
-
amountPerPeriod: BN;
|
|
9
|
-
cliff: BN;
|
|
10
|
-
cliffAmount: BN;
|
|
11
|
-
cancelableBySender: boolean;
|
|
12
|
-
cancelableByRecipient: boolean;
|
|
13
|
-
automaticWithdrawal: boolean;
|
|
14
|
-
transferableBySender: boolean;
|
|
15
|
-
transferableByRecipient: boolean;
|
|
16
|
-
canTopup: boolean;
|
|
17
|
-
canUpdateRate: boolean;
|
|
18
|
-
canPause: boolean;
|
|
19
|
-
name: string;
|
|
20
|
-
withdrawFrequency: BN;
|
|
21
|
-
}
|
|
22
|
-
interface CreateStreamAccounts {
|
|
23
|
-
sender: PublicKey;
|
|
24
|
-
senderTokens: PublicKey;
|
|
25
|
-
recipient: PublicKey;
|
|
26
|
-
recipientTokens: PublicKey;
|
|
27
|
-
metadata: PublicKey;
|
|
28
|
-
escrowTokens: PublicKey;
|
|
29
|
-
streamflowTreasury: PublicKey;
|
|
30
|
-
streamflowTreasuryTokens: PublicKey;
|
|
31
|
-
partner: PublicKey;
|
|
32
|
-
partnerTokens: PublicKey;
|
|
33
|
-
mint: PublicKey;
|
|
34
|
-
feeOracle: PublicKey;
|
|
35
|
-
rent: PublicKey;
|
|
36
|
-
timelockProgram: PublicKey;
|
|
37
|
-
tokenProgram: PublicKey;
|
|
38
|
-
associatedTokenProgram: PublicKey;
|
|
39
|
-
withdrawor: PublicKey;
|
|
40
|
-
systemProgram: PublicKey;
|
|
41
|
-
}
|
|
42
|
-
export declare const createStreamInstruction: (data: CreateStreamData, programId: PublicKey, accounts: CreateStreamAccounts) => Promise<TransactionInstruction>;
|
|
43
|
-
interface CreateUncheckedStreamData {
|
|
44
|
-
start: BN;
|
|
45
|
-
depositedAmount: BN;
|
|
46
|
-
period: BN;
|
|
47
|
-
amountPerPeriod: BN;
|
|
48
|
-
cliff: BN;
|
|
49
|
-
cliffAmount: BN;
|
|
50
|
-
cancelableBySender: boolean;
|
|
51
|
-
cancelableByRecipient: boolean;
|
|
52
|
-
automaticWithdrawal: boolean;
|
|
53
|
-
transferableBySender: boolean;
|
|
54
|
-
transferableByRecipient: boolean;
|
|
55
|
-
canTopup: boolean;
|
|
56
|
-
canUpdateRate: boolean;
|
|
57
|
-
canPause: boolean;
|
|
58
|
-
name: string;
|
|
59
|
-
withdrawFrequency: BN;
|
|
60
|
-
recipient: PublicKey;
|
|
61
|
-
partner: PublicKey;
|
|
62
|
-
}
|
|
63
|
-
interface CreateUncheckedStreamAccounts {
|
|
64
|
-
payer?: PublicKey;
|
|
65
|
-
sender: PublicKey;
|
|
66
|
-
senderTokens: PublicKey;
|
|
67
|
-
metadata: PublicKey;
|
|
68
|
-
escrowTokens: PublicKey;
|
|
69
|
-
mint: PublicKey;
|
|
70
|
-
feeOracle: PublicKey;
|
|
71
|
-
rent: PublicKey;
|
|
72
|
-
timelockProgram: PublicKey;
|
|
73
|
-
tokenProgram: PublicKey;
|
|
74
|
-
withdrawor: PublicKey;
|
|
75
|
-
systemProgram: PublicKey;
|
|
76
|
-
}
|
|
77
|
-
export declare const createUncheckedStreamInstruction: (data: CreateUncheckedStreamData, programId: PublicKey, accounts: CreateUncheckedStreamAccounts) => Promise<TransactionInstruction>;
|
|
78
|
-
interface WithdrawAccounts {
|
|
79
|
-
authority: PublicKey;
|
|
80
|
-
recipient: PublicKey;
|
|
81
|
-
recipientTokens: PublicKey;
|
|
82
|
-
metadata: PublicKey;
|
|
83
|
-
escrowTokens: PublicKey;
|
|
84
|
-
streamflowTreasury: PublicKey;
|
|
85
|
-
streamflowTreasuryTokens: PublicKey;
|
|
86
|
-
partner: PublicKey;
|
|
87
|
-
partnerTokens: PublicKey;
|
|
88
|
-
mint: PublicKey;
|
|
89
|
-
tokenProgram: PublicKey;
|
|
90
|
-
}
|
|
91
|
-
export declare const withdrawStreamInstruction: (amount: BN, programId: PublicKey, { authority, recipient, recipientTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, }: WithdrawAccounts) => Promise<TransactionInstruction>;
|
|
92
|
-
interface UpdateAccounts {
|
|
93
|
-
authority: PublicKey;
|
|
94
|
-
metadata: PublicKey;
|
|
95
|
-
withdrawor: PublicKey;
|
|
96
|
-
systemProgram: PublicKey;
|
|
97
|
-
}
|
|
98
|
-
export declare const updateStreamInstruction: (params: IUpdateData, programId: PublicKey, { authority, metadata, withdrawor, systemProgram }: UpdateAccounts) => Promise<TransactionInstruction>;
|
|
99
|
-
interface CancelAccounts {
|
|
100
|
-
authority: PublicKey;
|
|
101
|
-
sender: PublicKey;
|
|
102
|
-
senderTokens: PublicKey;
|
|
103
|
-
recipient: PublicKey;
|
|
104
|
-
recipientTokens: PublicKey;
|
|
105
|
-
metadata: PublicKey;
|
|
106
|
-
escrowTokens: PublicKey;
|
|
107
|
-
streamflowTreasury: PublicKey;
|
|
108
|
-
streamflowTreasuryTokens: PublicKey;
|
|
109
|
-
partner: PublicKey;
|
|
110
|
-
partnerTokens: PublicKey;
|
|
111
|
-
mint: PublicKey;
|
|
112
|
-
tokenProgram: PublicKey;
|
|
113
|
-
}
|
|
114
|
-
export declare const cancelStreamInstruction: (programId: PublicKey, { authority, sender, senderTokens, recipient, recipientTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, }: CancelAccounts) => Promise<TransactionInstruction>;
|
|
115
|
-
interface TransferAccounts {
|
|
116
|
-
authority: PublicKey;
|
|
117
|
-
newRecipient: PublicKey;
|
|
118
|
-
newRecipientTokens: PublicKey;
|
|
119
|
-
metadata: PublicKey;
|
|
120
|
-
mint: PublicKey;
|
|
121
|
-
rent: PublicKey;
|
|
122
|
-
tokenProgram: PublicKey;
|
|
123
|
-
associatedTokenProgram: PublicKey;
|
|
124
|
-
systemProgram: PublicKey;
|
|
125
|
-
}
|
|
126
|
-
export declare const transferStreamInstruction: (programId: PublicKey, { authority, newRecipient, newRecipientTokens, metadata, mint, rent, tokenProgram, associatedTokenProgram, systemProgram, }: TransferAccounts) => Promise<TransactionInstruction>;
|
|
127
|
-
interface TopupAccounts {
|
|
128
|
-
sender: PublicKey;
|
|
129
|
-
senderTokens: PublicKey;
|
|
130
|
-
metadata: PublicKey;
|
|
131
|
-
escrowTokens: PublicKey;
|
|
132
|
-
streamflowTreasury: PublicKey;
|
|
133
|
-
streamflowTreasuryTokens: PublicKey;
|
|
134
|
-
partner: PublicKey;
|
|
135
|
-
partnerTokens: PublicKey;
|
|
136
|
-
mint: PublicKey;
|
|
137
|
-
tokenProgram: PublicKey;
|
|
138
|
-
withdrawor: PublicKey;
|
|
139
|
-
systemProgram: PublicKey;
|
|
140
|
-
}
|
|
141
|
-
export declare const topupStreamInstruction: (amount: BN, programId: PublicKey, { sender, senderTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, withdrawor, systemProgram, }: TopupAccounts) => Promise<TransactionInstruction>;
|
|
142
|
-
export {};
|
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
import { Buffer } from "buffer";
|
|
2
|
-
import { TransactionInstruction } from "@solana/web3.js";
|
|
3
|
-
import * as Layout from "./layout.js";
|
|
4
|
-
const sha256 = {
|
|
5
|
-
digest: async (data) => {
|
|
6
|
-
const dataBuffer = new TextEncoder().encode(data);
|
|
7
|
-
const hashBuffer = await globalThis.crypto.subtle.digest("SHA-256", dataBuffer);
|
|
8
|
-
return new Uint8Array(hashBuffer);
|
|
9
|
-
},
|
|
10
|
-
};
|
|
11
|
-
export const createStreamInstruction = async (data, programId, accounts) => {
|
|
12
|
-
const keys = [
|
|
13
|
-
{ pubkey: accounts.sender, isSigner: true, isWritable: true },
|
|
14
|
-
{ pubkey: accounts.senderTokens, isSigner: false, isWritable: true },
|
|
15
|
-
{ pubkey: accounts.recipient, isSigner: false, isWritable: true },
|
|
16
|
-
{ pubkey: accounts.metadata, isSigner: true, isWritable: true },
|
|
17
|
-
{ pubkey: accounts.escrowTokens, isSigner: false, isWritable: true },
|
|
18
|
-
{ pubkey: accounts.recipientTokens, isSigner: false, isWritable: true },
|
|
19
|
-
{
|
|
20
|
-
pubkey: accounts.streamflowTreasury,
|
|
21
|
-
isSigner: false,
|
|
22
|
-
isWritable: true,
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
pubkey: accounts.streamflowTreasuryTokens,
|
|
26
|
-
isSigner: false,
|
|
27
|
-
isWritable: true,
|
|
28
|
-
},
|
|
29
|
-
{ pubkey: accounts.withdrawor, isSigner: false, isWritable: true },
|
|
30
|
-
{ pubkey: accounts.partner, isSigner: false, isWritable: true },
|
|
31
|
-
{ pubkey: accounts.partnerTokens, isSigner: false, isWritable: true },
|
|
32
|
-
{ pubkey: accounts.mint, isSigner: false, isWritable: false },
|
|
33
|
-
{ pubkey: accounts.feeOracle, isSigner: false, isWritable: false },
|
|
34
|
-
{ pubkey: accounts.rent, isSigner: false, isWritable: false },
|
|
35
|
-
{ pubkey: accounts.timelockProgram, isSigner: false, isWritable: false },
|
|
36
|
-
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
|
37
|
-
{
|
|
38
|
-
pubkey: accounts.associatedTokenProgram,
|
|
39
|
-
isSigner: false,
|
|
40
|
-
isWritable: false,
|
|
41
|
-
},
|
|
42
|
-
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
|
|
43
|
-
];
|
|
44
|
-
let bufferData = Buffer.alloc(Layout.createStreamLayout.span);
|
|
45
|
-
const encodedUIntArray = new TextEncoder().encode(data.name);
|
|
46
|
-
const streamNameBuffer = Buffer.alloc(64).fill(encodedUIntArray, 0, encodedUIntArray.byteLength);
|
|
47
|
-
const decodedData = {
|
|
48
|
-
start_time: data.start.toArrayLike(Buffer, "le", 8),
|
|
49
|
-
net_amount_deposited: data.depositedAmount.toArrayLike(Buffer, "le", 8),
|
|
50
|
-
period: data.period.toArrayLike(Buffer, "le", 8),
|
|
51
|
-
amount_per_period: data.amountPerPeriod.toArrayLike(Buffer, "le", 8),
|
|
52
|
-
cliff: data.cliff.toArrayLike(Buffer, "le", 8),
|
|
53
|
-
cliff_amount: data.cliffAmount.toArrayLike(Buffer, "le", 8),
|
|
54
|
-
cancelable_by_sender: Number(data.cancelableBySender),
|
|
55
|
-
cancelable_by_recipient: Number(data.cancelableByRecipient),
|
|
56
|
-
automatic_withdrawal: Number(data.automaticWithdrawal),
|
|
57
|
-
transferable_by_sender: Number(data.transferableBySender),
|
|
58
|
-
transferable_by_recipient: Number(data.transferableByRecipient),
|
|
59
|
-
can_topup: Number(data.canTopup),
|
|
60
|
-
_pausable_discriminator: 1,
|
|
61
|
-
can_update_rate: Number(data.canUpdateRate),
|
|
62
|
-
_can_update_rate_discriminator: 1,
|
|
63
|
-
pausable: Number(data.canPause),
|
|
64
|
-
stream_name: streamNameBuffer,
|
|
65
|
-
withdraw_frequency: data.withdrawFrequency.toArrayLike(Buffer, "le", 8),
|
|
66
|
-
};
|
|
67
|
-
const encodeLength = Layout.createStreamLayout.encode(decodedData, bufferData);
|
|
68
|
-
bufferData = bufferData.slice(0, encodeLength);
|
|
69
|
-
bufferData = Buffer.concat([
|
|
70
|
-
Buffer.from(await sha256.digest("global:create")).slice(0, 8),
|
|
71
|
-
bufferData,
|
|
72
|
-
Buffer.alloc(10),
|
|
73
|
-
]);
|
|
74
|
-
return new TransactionInstruction({
|
|
75
|
-
keys,
|
|
76
|
-
programId,
|
|
77
|
-
data: bufferData,
|
|
78
|
-
});
|
|
79
|
-
};
|
|
80
|
-
export const createUncheckedStreamInstruction = async (data, programId, accounts) => {
|
|
81
|
-
const keys = [
|
|
82
|
-
{ pubkey: accounts.sender, isSigner: true, isWritable: true },
|
|
83
|
-
{ pubkey: accounts.senderTokens, isSigner: false, isWritable: true },
|
|
84
|
-
{ pubkey: accounts.metadata, isSigner: false, isWritable: true },
|
|
85
|
-
{ pubkey: accounts.escrowTokens, isSigner: false, isWritable: true },
|
|
86
|
-
{ pubkey: accounts.withdrawor, isSigner: false, isWritable: true },
|
|
87
|
-
{ pubkey: accounts.mint, isSigner: false, isWritable: false },
|
|
88
|
-
{ pubkey: accounts.feeOracle, isSigner: false, isWritable: false },
|
|
89
|
-
{ pubkey: accounts.rent, isSigner: false, isWritable: false },
|
|
90
|
-
{ pubkey: accounts.timelockProgram, isSigner: false, isWritable: false },
|
|
91
|
-
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
|
92
|
-
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
|
|
93
|
-
];
|
|
94
|
-
if (accounts.payer) {
|
|
95
|
-
keys.unshift({
|
|
96
|
-
pubkey: accounts.payer,
|
|
97
|
-
isSigner: true,
|
|
98
|
-
isWritable: true,
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
let bufferData = Buffer.alloc(Layout.createUncheckedStreamLayout.span);
|
|
102
|
-
const encodedUIntArray = new TextEncoder().encode(data.name);
|
|
103
|
-
const streamNameBuffer = Buffer.alloc(64).fill(encodedUIntArray, 0, encodedUIntArray.byteLength);
|
|
104
|
-
const decodedData = {
|
|
105
|
-
start_time: data.start.toArrayLike(Buffer, "le", 8),
|
|
106
|
-
net_amount_deposited: data.depositedAmount.toArrayLike(Buffer, "le", 8),
|
|
107
|
-
period: data.period.toArrayLike(Buffer, "le", 8),
|
|
108
|
-
amount_per_period: data.amountPerPeriod.toArrayLike(Buffer, "le", 8),
|
|
109
|
-
cliff: data.cliff.toArrayLike(Buffer, "le", 8),
|
|
110
|
-
cliff_amount: data.cliffAmount.toArrayLike(Buffer, "le", 8),
|
|
111
|
-
cancelable_by_sender: Number(data.cancelableBySender),
|
|
112
|
-
cancelable_by_recipient: Number(data.cancelableByRecipient),
|
|
113
|
-
automatic_withdrawal: Number(data.automaticWithdrawal),
|
|
114
|
-
transferable_by_sender: Number(data.transferableBySender),
|
|
115
|
-
transferable_by_recipient: Number(data.transferableByRecipient),
|
|
116
|
-
can_topup: Number(data.canTopup),
|
|
117
|
-
stream_name: streamNameBuffer,
|
|
118
|
-
withdraw_frequency: data.withdrawFrequency.toArrayLike(Buffer, "le", 8),
|
|
119
|
-
recipient: data.recipient.toBuffer(),
|
|
120
|
-
partner: data.partner.toBuffer(),
|
|
121
|
-
pausable: Number(data.canPause),
|
|
122
|
-
can_update_rate: Number(data.canUpdateRate),
|
|
123
|
-
};
|
|
124
|
-
const encodeLength = Layout.createUncheckedStreamLayout.encode(decodedData, bufferData);
|
|
125
|
-
bufferData = bufferData.slice(0, encodeLength);
|
|
126
|
-
const digest = accounts.payer
|
|
127
|
-
? await sha256.digest("global:create_unchecked_with_payer")
|
|
128
|
-
: await sha256.digest("global:create_unchecked");
|
|
129
|
-
bufferData = Buffer.concat([Buffer.from(digest).slice(0, 8), bufferData, Buffer.alloc(10)]);
|
|
130
|
-
return new TransactionInstruction({
|
|
131
|
-
keys,
|
|
132
|
-
programId,
|
|
133
|
-
data: bufferData,
|
|
134
|
-
});
|
|
135
|
-
};
|
|
136
|
-
export const withdrawStreamInstruction = async (amount, programId, { authority, recipient, recipientTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, }) => {
|
|
137
|
-
const keys = [
|
|
138
|
-
{ pubkey: authority, isSigner: true, isWritable: true },
|
|
139
|
-
{ pubkey: recipient, isSigner: false, isWritable: true },
|
|
140
|
-
{ pubkey: recipientTokens, isSigner: false, isWritable: true },
|
|
141
|
-
{ pubkey: metadata, isSigner: false, isWritable: true },
|
|
142
|
-
{ pubkey: escrowTokens, isSigner: false, isWritable: true },
|
|
143
|
-
{
|
|
144
|
-
pubkey: streamflowTreasury,
|
|
145
|
-
isSigner: false,
|
|
146
|
-
isWritable: true,
|
|
147
|
-
},
|
|
148
|
-
{ pubkey: streamflowTreasuryTokens, isSigner: false, isWritable: true },
|
|
149
|
-
{ pubkey: partner, isSigner: false, isWritable: true },
|
|
150
|
-
{ pubkey: partnerTokens, isSigner: false, isWritable: true },
|
|
151
|
-
{ pubkey: mint, isSigner: false, isWritable: true },
|
|
152
|
-
{ pubkey: tokenProgram, isSigner: false, isWritable: false },
|
|
153
|
-
];
|
|
154
|
-
let data = Buffer.alloc(Layout.withdrawStreamLayout.span);
|
|
155
|
-
const decodedData = { amount: amount.toArrayLike(Buffer, "le", 8) };
|
|
156
|
-
const encodeLength = Layout.withdrawStreamLayout.encode(decodedData, data);
|
|
157
|
-
data = data.slice(0, encodeLength);
|
|
158
|
-
data = Buffer.concat([Buffer.from(await sha256.digest("global:withdraw")).slice(0, 8), data, Buffer.alloc(10)]);
|
|
159
|
-
return new TransactionInstruction({
|
|
160
|
-
keys,
|
|
161
|
-
programId,
|
|
162
|
-
data,
|
|
163
|
-
});
|
|
164
|
-
};
|
|
165
|
-
export const updateStreamInstruction = async (params, programId, { authority, metadata, withdrawor, systemProgram }) => {
|
|
166
|
-
const keys = [
|
|
167
|
-
{ pubkey: authority, isSigner: true, isWritable: true },
|
|
168
|
-
{ pubkey: metadata, isSigner: false, isWritable: true },
|
|
169
|
-
{ pubkey: withdrawor, isSigner: false, isWritable: true },
|
|
170
|
-
{ pubkey: systemProgram, isSigner: false, isWritable: false },
|
|
171
|
-
];
|
|
172
|
-
let data = Buffer.alloc(100);
|
|
173
|
-
const decodedData = {
|
|
174
|
-
enable_automatic_withdrawal: Number(params.enableAutomaticWithdrawal),
|
|
175
|
-
withdraw_frequency: params.withdrawFrequency ? params.withdrawFrequency.toArrayLike(Buffer, "le", 8) : undefined,
|
|
176
|
-
amount_per_period: params.amountPerPeriod ? params.amountPerPeriod.toArrayLike(Buffer, "le", 8) : undefined,
|
|
177
|
-
};
|
|
178
|
-
const encodeLength = Layout.encodeUpdateStream(decodedData, data);
|
|
179
|
-
data = data.slice(0, encodeLength);
|
|
180
|
-
data = Buffer.concat([Buffer.from(await sha256.digest("global:update")).slice(0, 8), data, Buffer.alloc(20)]);
|
|
181
|
-
return new TransactionInstruction({
|
|
182
|
-
keys: keys,
|
|
183
|
-
programId: programId,
|
|
184
|
-
data: data,
|
|
185
|
-
});
|
|
186
|
-
};
|
|
187
|
-
export const cancelStreamInstruction = async (programId, { authority, sender, senderTokens, recipient, recipientTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, }) => {
|
|
188
|
-
const keys = [
|
|
189
|
-
{ pubkey: authority, isSigner: true, isWritable: false },
|
|
190
|
-
{ pubkey: sender, isSigner: false, isWritable: true },
|
|
191
|
-
{ pubkey: senderTokens, isSigner: false, isWritable: true },
|
|
192
|
-
{ pubkey: recipient, isSigner: false, isWritable: true },
|
|
193
|
-
{ pubkey: recipientTokens, isSigner: false, isWritable: true },
|
|
194
|
-
{ pubkey: metadata, isSigner: false, isWritable: true },
|
|
195
|
-
{ pubkey: escrowTokens, isSigner: false, isWritable: true },
|
|
196
|
-
{
|
|
197
|
-
pubkey: streamflowTreasury,
|
|
198
|
-
isSigner: false,
|
|
199
|
-
isWritable: true,
|
|
200
|
-
},
|
|
201
|
-
{ pubkey: streamflowTreasuryTokens, isSigner: false, isWritable: true },
|
|
202
|
-
{ pubkey: partner, isSigner: false, isWritable: true },
|
|
203
|
-
{ pubkey: partnerTokens, isSigner: false, isWritable: true },
|
|
204
|
-
{ pubkey: mint, isSigner: false, isWritable: true },
|
|
205
|
-
{ pubkey: tokenProgram, isSigner: false, isWritable: false },
|
|
206
|
-
];
|
|
207
|
-
const data = Buffer.concat([Buffer.from(await sha256.digest("global:cancel")).slice(0, 8), Buffer.alloc(10)]);
|
|
208
|
-
return new TransactionInstruction({
|
|
209
|
-
keys,
|
|
210
|
-
programId,
|
|
211
|
-
data,
|
|
212
|
-
});
|
|
213
|
-
};
|
|
214
|
-
export const transferStreamInstruction = async (programId, { authority, newRecipient, newRecipientTokens, metadata, mint, rent, tokenProgram, associatedTokenProgram, systemProgram, }) => {
|
|
215
|
-
const keys = [
|
|
216
|
-
{ pubkey: authority, isSigner: true, isWritable: true },
|
|
217
|
-
{ pubkey: newRecipient, isSigner: false, isWritable: true },
|
|
218
|
-
{ pubkey: newRecipientTokens, isSigner: false, isWritable: true },
|
|
219
|
-
{ pubkey: metadata, isSigner: false, isWritable: true },
|
|
220
|
-
{ pubkey: mint, isSigner: false, isWritable: false },
|
|
221
|
-
{ pubkey: rent, isSigner: false, isWritable: false },
|
|
222
|
-
{ pubkey: tokenProgram, isSigner: false, isWritable: false },
|
|
223
|
-
{ pubkey: associatedTokenProgram, isSigner: false, isWritable: false },
|
|
224
|
-
{ pubkey: systemProgram, isSigner: false, isWritable: false },
|
|
225
|
-
];
|
|
226
|
-
const data = Buffer.concat([
|
|
227
|
-
Buffer.from(await sha256.digest("global:transfer_recipient")).slice(0, 8),
|
|
228
|
-
Buffer.alloc(10),
|
|
229
|
-
]);
|
|
230
|
-
return new TransactionInstruction({
|
|
231
|
-
keys,
|
|
232
|
-
programId,
|
|
233
|
-
data,
|
|
234
|
-
});
|
|
235
|
-
};
|
|
236
|
-
export const topupStreamInstruction = async (amount, programId, { sender, senderTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, withdrawor, systemProgram, }) => {
|
|
237
|
-
const keys = [
|
|
238
|
-
{ pubkey: sender, isSigner: true, isWritable: true },
|
|
239
|
-
{ pubkey: senderTokens, isSigner: false, isWritable: true },
|
|
240
|
-
{ pubkey: metadata, isSigner: false, isWritable: true },
|
|
241
|
-
{ pubkey: escrowTokens, isSigner: false, isWritable: true },
|
|
242
|
-
{
|
|
243
|
-
pubkey: streamflowTreasury,
|
|
244
|
-
isSigner: false,
|
|
245
|
-
isWritable: true,
|
|
246
|
-
},
|
|
247
|
-
{ pubkey: streamflowTreasuryTokens, isSigner: false, isWritable: true },
|
|
248
|
-
{ pubkey: withdrawor, isSigner: false, isWritable: true },
|
|
249
|
-
{ pubkey: partner, isSigner: false, isWritable: true },
|
|
250
|
-
{ pubkey: partnerTokens, isSigner: false, isWritable: true },
|
|
251
|
-
{ pubkey: mint, isSigner: false, isWritable: false },
|
|
252
|
-
{ pubkey: tokenProgram, isSigner: false, isWritable: false },
|
|
253
|
-
{ pubkey: systemProgram, isSigner: false, isWritable: false },
|
|
254
|
-
];
|
|
255
|
-
let data = Buffer.alloc(Layout.topupStreamLayout.span);
|
|
256
|
-
const decodedData = { amount: amount.toArrayLike(Buffer, "le", 8) };
|
|
257
|
-
const encodeLength = Layout.topupStreamLayout.encode(decodedData, data);
|
|
258
|
-
data = data.slice(0, encodeLength);
|
|
259
|
-
data = Buffer.concat([Buffer.from(await sha256.digest("global:topup")).slice(0, 8), data, Buffer.alloc(10)]);
|
|
260
|
-
return new TransactionInstruction({
|
|
261
|
-
keys,
|
|
262
|
-
programId,
|
|
263
|
-
data,
|
|
264
|
-
});
|
|
265
|
-
};
|