@streamflow/stream 7.0.0-alpha.9 → 7.0.0
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/README.md +22 -17
- package/dist/cjs/__tests__/aptos/streamClient.spec.js +4 -4
- package/dist/cjs/aptos/types.js +12 -12
- package/dist/cjs/aptos/utils.js +2 -3
- package/dist/cjs/common/constants.js +4 -3
- package/dist/cjs/common/contractUtils.js +23 -7
- package/dist/cjs/common/types.js +30 -1
- package/dist/cjs/common/utils.js +23 -20
- package/dist/cjs/evm/StreamClient.js +7 -7
- package/dist/cjs/evm/types.js +12 -12
- package/dist/cjs/evm/utils.js +1 -2
- package/dist/cjs/solana/StreamClient.js +303 -152
- package/dist/cjs/solana/constants.js +29 -1
- package/dist/cjs/solana/descriptor/idl/streamflow_aligned_unlocks.json +1471 -0
- package/dist/cjs/solana/descriptor/streamflow_aligned_unlocks.js +2 -0
- package/dist/cjs/solana/index.js +2 -1
- package/dist/cjs/solana/instructions.js +18 -19
- package/dist/cjs/solana/lib/derive-accounts.js +17 -0
- package/dist/cjs/solana/{utils.js → lib/utils.js} +32 -39
- package/dist/cjs/solana/types.js +26 -3
- package/dist/cjs/sui/StreamClient.js +1 -1
- package/dist/cjs/sui/types.js +12 -12
- package/dist/cjs/sui/utils.js +1 -2
- package/dist/cjs/sui/wallet.js +2 -2
- package/dist/esm/__tests__/aptos/streamClient.spec.js +4 -4
- package/dist/esm/aptos/types.d.ts +14 -14
- package/dist/esm/aptos/types.js +13 -13
- package/dist/esm/common/constants.d.ts +3 -2
- package/dist/esm/common/constants.js +3 -2
- package/dist/esm/common/contractUtils.d.ts +18 -15
- package/dist/esm/common/contractUtils.js +19 -6
- package/dist/esm/common/types.d.ts +112 -57
- package/dist/esm/common/types.js +29 -0
- package/dist/esm/common/utils.d.ts +11 -11
- package/dist/esm/common/utils.js +19 -16
- package/dist/esm/evm/StreamClient.d.ts +2 -2
- package/dist/esm/evm/StreamClient.js +7 -7
- package/dist/esm/evm/types.d.ts +14 -14
- package/dist/esm/evm/types.js +13 -13
- package/dist/esm/solana/StreamClient.d.ts +22 -16
- package/dist/esm/solana/StreamClient.js +306 -154
- package/dist/esm/solana/constants.d.ts +14 -1
- package/dist/esm/solana/constants.js +29 -1
- package/dist/esm/solana/descriptor/idl/streamflow_aligned_unlocks.json +1471 -0
- package/dist/esm/solana/descriptor/streamflow_aligned_unlocks.d.ts +1272 -0
- package/dist/esm/solana/descriptor/streamflow_aligned_unlocks.js +1 -0
- package/dist/esm/solana/index.d.ts +2 -1
- package/dist/esm/solana/index.js +2 -1
- package/dist/esm/solana/instructions.d.ts +17 -17
- package/dist/esm/solana/instructions.js +18 -19
- package/dist/esm/solana/layout.d.ts +0 -1
- package/dist/esm/solana/lib/derive-accounts.d.ts +4 -0
- package/dist/esm/solana/lib/derive-accounts.js +11 -0
- package/dist/esm/solana/{utils.d.ts → lib/utils.d.ts} +1 -4
- package/dist/esm/solana/{utils.js → lib/utils.js} +28 -34
- package/dist/esm/solana/types.d.ts +67 -40
- package/dist/esm/solana/types.js +32 -4
- package/dist/esm/sui/StreamClient.js +1 -1
- package/dist/esm/sui/types.d.ts +14 -14
- package/dist/esm/sui/types.js +13 -13
- package/package.json +11 -9
package/dist/esm/evm/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import BN from "bn.js";
|
|
2
2
|
import { buildStreamType, calculateUnlockedAmount } from "../common/contractUtils.js";
|
|
3
|
-
import {
|
|
3
|
+
import { getNumberFromBN } from "../common/utils.js";
|
|
4
4
|
export class EvmContract {
|
|
5
5
|
magic;
|
|
6
6
|
version;
|
|
@@ -49,7 +49,7 @@ export class EvmContract {
|
|
|
49
49
|
this.magic = 0;
|
|
50
50
|
this.version = 0;
|
|
51
51
|
this.createdAt = stream.created.toNumber();
|
|
52
|
-
this.withdrawnAmount =
|
|
52
|
+
this.withdrawnAmount = new BN(stream.withdrawn.toString());
|
|
53
53
|
this.canceledAt = stream.canceled_at.toNumber();
|
|
54
54
|
this.end = stream.end.toNumber();
|
|
55
55
|
this.lastWithdrawnAt = stream.last_withdrawn_at.toNumber();
|
|
@@ -61,20 +61,20 @@ export class EvmContract {
|
|
|
61
61
|
this.escrowTokens = "";
|
|
62
62
|
this.streamflowTreasury = "";
|
|
63
63
|
this.streamflowTreasuryTokens = "";
|
|
64
|
-
this.streamflowFeeTotal =
|
|
65
|
-
this.streamflowFeeWithdrawn =
|
|
64
|
+
this.streamflowFeeTotal = new BN(stream.fees.streamflow_fee.toString());
|
|
65
|
+
this.streamflowFeeWithdrawn = new BN(stream.fees.streamflow_fee_withdrawn.toString());
|
|
66
66
|
this.streamflowFeePercent = stream.fees.streamflow_fee_percentage.toNumber() / 10000;
|
|
67
|
-
this.partnerFeeTotal =
|
|
68
|
-
this.partnerFeeWithdrawn =
|
|
67
|
+
this.partnerFeeTotal = new BN(0);
|
|
68
|
+
this.partnerFeeWithdrawn = new BN(0);
|
|
69
69
|
this.partnerFeePercent = 0;
|
|
70
70
|
this.partner = "";
|
|
71
71
|
this.partnerTokens = "";
|
|
72
72
|
this.start = stream.start.toNumber();
|
|
73
|
-
this.depositedAmount =
|
|
73
|
+
this.depositedAmount = new BN(stream.amount.toString());
|
|
74
74
|
this.period = stream.period.toNumber();
|
|
75
|
-
this.amountPerPeriod =
|
|
75
|
+
this.amountPerPeriod = new BN(stream.amount_per_period.toString());
|
|
76
76
|
this.cliff = stream.start.toNumber();
|
|
77
|
-
this.cliffAmount =
|
|
77
|
+
this.cliffAmount = new BN(stream.cliff_amount.toString());
|
|
78
78
|
this.cancelableBySender = stream.meta.cancelable_by_sender;
|
|
79
79
|
this.cancelableByRecipient = stream.meta.cancelable_by_recipient;
|
|
80
80
|
this.automaticWithdrawal = stream.meta.automatic_withdrawal;
|
|
@@ -85,9 +85,9 @@ export class EvmContract {
|
|
|
85
85
|
this.withdrawalFrequency = stream.meta.withdrawal_frequency.toNumber();
|
|
86
86
|
this.closed = stream.closed;
|
|
87
87
|
this.currentPauseStart = stream.current_pause_start.toNumber();
|
|
88
|
-
this.pauseCumulative =
|
|
88
|
+
this.pauseCumulative = new BN(stream.pause_cumulative.toString());
|
|
89
89
|
this.lastRateChangeTime = stream.last_rate_change_time.toNumber();
|
|
90
|
-
this.fundsUnlockedAtLastRateChange =
|
|
90
|
+
this.fundsUnlockedAtLastRateChange = new BN(stream.funds_unlocked_at_last_rate_change.toString());
|
|
91
91
|
this.type = buildStreamType(this);
|
|
92
92
|
}
|
|
93
93
|
unlocked(currentTimestamp) {
|
|
@@ -97,6 +97,6 @@ export class EvmContract {
|
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
99
|
remaining(decimals) {
|
|
100
|
-
return
|
|
100
|
+
return getNumberFromBN(this.depositedAmount.sub(this.withdrawnAmount), decimals);
|
|
101
101
|
}
|
|
102
102
|
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import PQueue from "p-queue";
|
|
2
2
|
import { Connection, Keypair, PublicKey, TransactionInstruction, Commitment, ConnectionConfig } from "@solana/web3.js";
|
|
3
3
|
import { IProgramAccount } from "@streamflow/common/solana";
|
|
4
|
-
import { ICreateStreamSolanaExt, IInteractStreamSolanaExt, ITopUpStreamSolanaExt, ISearchStreams } from "./types.js";
|
|
5
|
-
import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetAllData, IGetFeesData, IGetOneData, IFees, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData, Stream } from "../common/types.js";
|
|
4
|
+
import { ICreateStreamSolanaExt, IInteractStreamSolanaExt, ITopUpStreamSolanaExt, ISearchStreams, ICreateStreamInstructions } from "./types.js";
|
|
5
|
+
import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetAllData, IGetFeesData, IGetOneData, IFees, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData, Stream, ICreateAlignedStreamData } from "../common/types.js";
|
|
6
6
|
import { BaseStreamClient } from "../common/BaseStreamClient.js";
|
|
7
7
|
export declare class SolanaStreamClient extends BaseStreamClient {
|
|
8
8
|
private connection;
|
|
9
9
|
private programId;
|
|
10
10
|
private commitment;
|
|
11
11
|
private sendThrottler;
|
|
12
|
+
private alignedProxyProgram;
|
|
12
13
|
/**
|
|
13
14
|
* Create Stream instance
|
|
14
15
|
*/
|
|
@@ -21,15 +22,13 @@ export declare class SolanaStreamClient extends BaseStreamClient {
|
|
|
21
22
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
22
23
|
*/
|
|
23
24
|
create(data: ICreateStreamData, extParams: ICreateStreamSolanaExt): Promise<ICreateResult>;
|
|
25
|
+
prepareCreateInstructions(streamParams: ICreateStreamData, extParams: ICreateStreamSolanaExt): Promise<ICreateStreamInstructions>;
|
|
26
|
+
prepareCreateAlignedUnlockInstructions(streamParams: ICreateAlignedStreamData, extParams: ICreateStreamSolanaExt): Promise<ICreateStreamInstructions>;
|
|
24
27
|
/**
|
|
25
28
|
* Creates a new stream/vesting contract.
|
|
26
29
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
27
30
|
*/
|
|
28
|
-
|
|
29
|
-
ixs: TransactionInstruction[];
|
|
30
|
-
metadata: Keypair | undefined;
|
|
31
|
-
metadataPubKey: PublicKey;
|
|
32
|
-
}>;
|
|
31
|
+
prepareCreateStreamInstructions({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canPause, canUpdateRate, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, }: ICreateStreamData, { sender, metadataPubKeys, isNative, computePrice, computeLimit }: ICreateStreamSolanaExt): Promise<ICreateStreamInstructions>;
|
|
33
32
|
/**
|
|
34
33
|
* Creates a new stream/vesting contract using unchecked instruction.
|
|
35
34
|
*
|
|
@@ -53,7 +52,7 @@ export declare class SolanaStreamClient extends BaseStreamClient {
|
|
|
53
52
|
* Creates multiple stream/vesting contracts.
|
|
54
53
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
55
54
|
*/
|
|
56
|
-
createMultiple(data: ICreateMultipleStreamData,
|
|
55
|
+
createMultiple(data: ICreateMultipleStreamData, extParams: ICreateStreamSolanaExt): Promise<IMultiTransactionResult>;
|
|
57
56
|
/**
|
|
58
57
|
* Attempts withdrawing from the specified stream.
|
|
59
58
|
*/
|
|
@@ -65,11 +64,13 @@ export declare class SolanaStreamClient extends BaseStreamClient {
|
|
|
65
64
|
/**
|
|
66
65
|
* Attempts canceling the specified stream.
|
|
67
66
|
*/
|
|
68
|
-
cancel(
|
|
67
|
+
cancel(cancelData: ICancelData, extParams: IInteractStreamSolanaExt): Promise<ITransactionResult>;
|
|
68
|
+
prepareCancelInstructions(cancelData: ICancelData, extParams: IInteractStreamSolanaExt): Promise<TransactionInstruction[]>;
|
|
69
|
+
prepareCancelAlignedUnlockInstructions({ id }: ICancelData, { invoker, checkTokenAccounts, computePrice, computeLimit }: IInteractStreamSolanaExt): Promise<TransactionInstruction[]>;
|
|
69
70
|
/**
|
|
70
71
|
* Creates Transaction Instructions for cancel
|
|
71
72
|
*/
|
|
72
|
-
|
|
73
|
+
prepareCancelStreamInstructions({ id }: ICancelData, { invoker, checkTokenAccounts, computePrice, computeLimit }: IInteractStreamSolanaExt): Promise<TransactionInstruction[]>;
|
|
73
74
|
/**
|
|
74
75
|
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
75
76
|
* Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
|
|
@@ -92,6 +93,11 @@ export declare class SolanaStreamClient extends BaseStreamClient {
|
|
|
92
93
|
* Fetch stream data by its id (address).
|
|
93
94
|
*/
|
|
94
95
|
getOne({ id }: IGetOneData): Promise<Stream>;
|
|
96
|
+
/**
|
|
97
|
+
* Fetch all aligned outgoing streams/contracts by the provided public key.
|
|
98
|
+
*/
|
|
99
|
+
private getOutgoingAlignedStreams;
|
|
100
|
+
private getIncomingAlignedStreams;
|
|
95
101
|
/**
|
|
96
102
|
* Fetch streams/contracts by providing direction.
|
|
97
103
|
* Streams are sorted by start time in ascending order.
|
|
@@ -109,16 +115,16 @@ export declare class SolanaStreamClient extends BaseStreamClient {
|
|
|
109
115
|
getFees({ address }: IGetFeesData): Promise<IFees | null>;
|
|
110
116
|
getDefaultStreamflowFee(): Promise<number>;
|
|
111
117
|
extractErrorCode(err: Error): string | null;
|
|
112
|
-
/**
|
|
113
|
-
* Forms instructions from params, creates a raw transaction and fetch recent blockhash.
|
|
114
|
-
*/
|
|
115
|
-
private prepareStreamInstructions;
|
|
116
118
|
/**
|
|
117
119
|
* Utility function to generate metadata for a Contract or return existing Pubkey
|
|
118
120
|
*/
|
|
119
121
|
private getOrCreateStreamMetadata;
|
|
120
122
|
/**
|
|
121
|
-
* Utility function that checks whether associated
|
|
123
|
+
* Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
|
|
124
|
+
*/
|
|
125
|
+
private isAlignedUnlock;
|
|
126
|
+
/**
|
|
127
|
+
* Returns insrtuctions for creating associated token accounts for the provided owners
|
|
122
128
|
*/
|
|
123
|
-
private
|
|
129
|
+
private getCreateATAInstructions;
|
|
124
130
|
}
|