@streamflow/stream 5.0.1 → 5.2.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/dist/aptos/types.d.ts +2 -45
- package/dist/aptos/types.js +13 -1
- package/dist/common/BaseStreamClient.d.ts +1 -2
- package/dist/common/GenericStreamClient.d.ts +16 -11
- package/dist/common/GenericStreamClient.js +14 -56
- package/dist/common/constants.d.ts +1 -0
- package/dist/common/constants.js +4 -0
- package/dist/common/contractUtils.d.ts +27 -1
- package/dist/common/contractUtils.js +22 -2
- package/dist/common/types.d.ts +49 -2
- package/dist/common/types.js +3 -2
- package/dist/evm/StreamClient.d.ts +1 -2
- package/dist/evm/StreamClient.js +1 -1
- package/dist/evm/types.d.ts +2 -45
- package/dist/evm/types.js +13 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +4 -2
- package/dist/solana/StreamClient.d.ts +4 -4
- package/dist/solana/StreamClient.js +2 -4
- package/dist/solana/constants.d.ts +0 -1
- package/dist/solana/constants.js +1 -2
- package/dist/solana/instructions.js +1 -1
- package/dist/solana/types.d.ts +2 -46
- package/dist/solana/types.js +13 -1
- package/dist/solana/utils.d.ts +2 -1
- package/dist/solana/utils.js +2 -0
- package/dist/sui/StreamClient.d.ts +78 -0
- package/dist/sui/StreamClient.js +542 -0
- package/dist/sui/constants.d.ts +4 -0
- package/dist/sui/constants.js +23 -0
- package/dist/sui/index.d.ts +2 -0
- package/dist/sui/index.js +23 -0
- package/dist/sui/types.d.ts +138 -0
- package/dist/sui/types.js +164 -0
- package/package.json +4 -1
|
@@ -94,7 +94,7 @@ var bn_js_1 = __importDefault(require("bn.js"));
|
|
|
94
94
|
var js_sha256_1 = require("js-sha256");
|
|
95
95
|
var spl_token_1 = require("@solana/spl-token");
|
|
96
96
|
var Layout = __importStar(require("./layout"));
|
|
97
|
-
var constants_1 = require("
|
|
97
|
+
var constants_1 = require("../common/constants");
|
|
98
98
|
var createStreamInstruction = function (data, programId, accounts) {
|
|
99
99
|
var keys = [
|
|
100
100
|
{ pubkey: accounts.sender, isSigner: true, isWritable: true },
|
package/dist/solana/types.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { SignerWalletAdapter } from "@solana/wallet-adapter-base";
|
|
3
3
|
import { AccountInfo, Connection, PublicKey, Keypair, TransactionSignature, TransactionInstruction, Transaction } from "@solana/web3.js";
|
|
4
4
|
import BN from "bn.js";
|
|
5
|
-
import { IRecipient, StreamDirection, StreamType } from "../common/types";
|
|
5
|
+
import { IRecipient, Stream, StreamDirection, StreamType } from "../common/types";
|
|
6
6
|
export { WalletAdapterNetwork as Cluster } from "@solana/wallet-adapter-base";
|
|
7
7
|
export interface Account {
|
|
8
8
|
pubkey: PublicKey;
|
|
@@ -133,51 +133,6 @@ export interface GetAllParams {
|
|
|
133
133
|
type?: StreamType;
|
|
134
134
|
direction?: StreamDirection;
|
|
135
135
|
}
|
|
136
|
-
export interface Stream {
|
|
137
|
-
magic: number;
|
|
138
|
-
version: number;
|
|
139
|
-
createdAt: number;
|
|
140
|
-
withdrawnAmount: BN;
|
|
141
|
-
canceledAt: number;
|
|
142
|
-
end: number;
|
|
143
|
-
lastWithdrawnAt: number;
|
|
144
|
-
sender: string;
|
|
145
|
-
senderTokens: string;
|
|
146
|
-
recipient: string;
|
|
147
|
-
recipientTokens: string;
|
|
148
|
-
mint: string;
|
|
149
|
-
escrowTokens: string;
|
|
150
|
-
streamflowTreasury: string;
|
|
151
|
-
streamflowTreasuryTokens: string;
|
|
152
|
-
streamflowFeeTotal: BN;
|
|
153
|
-
streamflowFeeWithdrawn: BN;
|
|
154
|
-
streamflowFeePercent: number;
|
|
155
|
-
partnerFeeTotal: BN;
|
|
156
|
-
partnerFeeWithdrawn: BN;
|
|
157
|
-
partnerFeePercent: number;
|
|
158
|
-
partner: string;
|
|
159
|
-
partnerTokens: string;
|
|
160
|
-
start: number;
|
|
161
|
-
depositedAmount: BN;
|
|
162
|
-
period: number;
|
|
163
|
-
amountPerPeriod: BN;
|
|
164
|
-
cliff: number;
|
|
165
|
-
cliffAmount: BN;
|
|
166
|
-
cancelableBySender: boolean;
|
|
167
|
-
cancelableByRecipient: boolean;
|
|
168
|
-
automaticWithdrawal: boolean;
|
|
169
|
-
transferableBySender: boolean;
|
|
170
|
-
transferableByRecipient: boolean;
|
|
171
|
-
canTopup: boolean;
|
|
172
|
-
name: string;
|
|
173
|
-
withdrawalFrequency: number;
|
|
174
|
-
closed: boolean;
|
|
175
|
-
currentPauseStart: number;
|
|
176
|
-
pauseCumulative: BN;
|
|
177
|
-
lastRateChangeTime: number;
|
|
178
|
-
fundsUnlockedAtLastRateChange: BN;
|
|
179
|
-
unlocked(currentTimestamp: number): BN;
|
|
180
|
-
}
|
|
181
136
|
export declare class Contract implements Stream {
|
|
182
137
|
magic: number;
|
|
183
138
|
version: number;
|
|
@@ -221,6 +176,7 @@ export declare class Contract implements Stream {
|
|
|
221
176
|
pauseCumulative: BN;
|
|
222
177
|
lastRateChangeTime: number;
|
|
223
178
|
fundsUnlockedAtLastRateChange: BN;
|
|
179
|
+
type: StreamType;
|
|
224
180
|
constructor(stream: DecodedStream);
|
|
225
181
|
unlocked(currentTimestamp: number): BN;
|
|
226
182
|
remaining(decimals: number): number;
|
package/dist/solana/types.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
exports.TransferCancelOptions = exports.Contract = exports.Cluster = void 0;
|
|
4
15
|
var contractUtils_1 = require("../common/contractUtils");
|
|
@@ -50,9 +61,10 @@ var Contract = /** @class */ (function () {
|
|
|
50
61
|
this.pauseCumulative = stream.pauseCumulative;
|
|
51
62
|
this.lastRateChangeTime = stream.lastRateChangeTime.toNumber();
|
|
52
63
|
this.fundsUnlockedAtLastRateChange = stream.fundsUnlockedAtLastRateChange;
|
|
64
|
+
this.type = (0, contractUtils_1.buildStreamType)(this);
|
|
53
65
|
}
|
|
54
66
|
Contract.prototype.unlocked = function (currentTimestamp) {
|
|
55
|
-
return (0, contractUtils_1.calculateUnlockedAmount)(
|
|
67
|
+
return (0, contractUtils_1.calculateUnlockedAmount)(__assign(__assign({}, this), { currentTimestamp: currentTimestamp }));
|
|
56
68
|
};
|
|
57
69
|
Contract.prototype.remaining = function (decimals) {
|
|
58
70
|
return (0, utils_1.getNumberFromBN)(this.depositedAmount.sub(this.withdrawnAmount), decimals);
|
package/dist/solana/utils.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { SignerWalletAdapter } from "@solana/wallet-adapter-base";
|
|
3
3
|
import { Connection, Keypair, PublicKey } from "@solana/web3.js";
|
|
4
|
-
import {
|
|
4
|
+
import { DecodedStream, Account, BatchItem, BatchItemResult } from "./types";
|
|
5
|
+
import { Stream } from "../common/types";
|
|
5
6
|
export declare const decodeStream: (buf: Buffer) => DecodedStream;
|
|
6
7
|
export declare const formatDecodedStream: (stream: DecodedStream) => Stream;
|
|
7
8
|
/**
|
package/dist/solana/utils.js
CHANGED
|
@@ -56,6 +56,7 @@ var web3_js_1 = require("@solana/web3.js");
|
|
|
56
56
|
var bn_js_1 = __importDefault(require("bn.js"));
|
|
57
57
|
var bs58_1 = __importDefault(require("bs58"));
|
|
58
58
|
var layout_1 = require("./layout");
|
|
59
|
+
var contractUtils_1 = require("../common/contractUtils");
|
|
59
60
|
var decoder = new TextDecoder("utf-8");
|
|
60
61
|
var LE = "le"; //little endian
|
|
61
62
|
var decodeStream = function (buf) {
|
|
@@ -153,6 +154,7 @@ var formatDecodedStream = function (stream) {
|
|
|
153
154
|
pauseCumulative: stream.pauseCumulative,
|
|
154
155
|
lastRateChangeTime: stream.lastRateChangeTime.toNumber(),
|
|
155
156
|
fundsUnlockedAtLastRateChange: stream.fundsUnlockedAtLastRateChange,
|
|
157
|
+
type: (0, contractUtils_1.buildStreamType)(stream),
|
|
156
158
|
unlocked: function () {
|
|
157
159
|
return new bn_js_1.default(0);
|
|
158
160
|
},
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { BaseStreamClient } from "../common/BaseStreamClient";
|
|
2
|
+
import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetOneData, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData } from "../common/types";
|
|
3
|
+
import { Contract, ICreateStreamSuiExt, ITransactionSuiExt, ISuiIdParameters } from "./types";
|
|
4
|
+
export default class SuiStreamClient extends BaseStreamClient {
|
|
5
|
+
private programId;
|
|
6
|
+
private configId;
|
|
7
|
+
private feeTableId;
|
|
8
|
+
private client;
|
|
9
|
+
constructor(clusterUrl: string, cluster?: ICluster, ids?: ISuiIdParameters);
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new stream/vesting contract.
|
|
12
|
+
*/
|
|
13
|
+
create(streamData: ICreateStreamData, { senderWallet }: ICreateStreamSuiExt): Promise<ICreateResult>;
|
|
14
|
+
/**
|
|
15
|
+
* Creates multiple stream/vesting contracts.
|
|
16
|
+
* We don't chain transactions in one Block so that one failed transaction does not revert all others.
|
|
17
|
+
*/
|
|
18
|
+
createMultiple(multipleStreamData: ICreateMultipleStreamData, { senderWallet }: ICreateStreamSuiExt): Promise<IMultiTransactionResult>;
|
|
19
|
+
/**
|
|
20
|
+
* Attempts withdrawing from the specified stream.
|
|
21
|
+
*/
|
|
22
|
+
withdraw(withdrawData: IWithdrawData, { senderWallet, tokenId }: ITransactionSuiExt): Promise<ITransactionResult>;
|
|
23
|
+
/**
|
|
24
|
+
* Attempts canceling the specified stream.
|
|
25
|
+
*/
|
|
26
|
+
cancel(cancelData: ICancelData, { senderWallet, tokenId }: ITransactionSuiExt): Promise<ITransactionResult>;
|
|
27
|
+
/**
|
|
28
|
+
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
29
|
+
*/
|
|
30
|
+
transfer(transferData: ITransferData, { senderWallet, tokenId }: ITransactionSuiExt): Promise<ITransactionResult>;
|
|
31
|
+
/**
|
|
32
|
+
* Tops up stream account with specified amount.
|
|
33
|
+
*/
|
|
34
|
+
topup(topupData: ITopUpData, { senderWallet, tokenId }: ITransactionSuiExt): Promise<ITransactionResult>;
|
|
35
|
+
/**
|
|
36
|
+
* Fetch stream data by its id (address).
|
|
37
|
+
*/
|
|
38
|
+
getOne({ id }: IGetOneData): Promise<Contract>;
|
|
39
|
+
get(): Promise<[string, Contract][]>;
|
|
40
|
+
/**
|
|
41
|
+
* Attempts updating the stream auto withdrawal params and amount per period
|
|
42
|
+
*/
|
|
43
|
+
update(updateData: IUpdateData, { senderWallet, tokenId }: ITransactionSuiExt): Promise<ITransactionResult>;
|
|
44
|
+
/**
|
|
45
|
+
* Returns StreamClient protocol program ID.
|
|
46
|
+
*/
|
|
47
|
+
getProgramId(): string;
|
|
48
|
+
/**
|
|
49
|
+
* Utility function to generate Transaction Block to create streams
|
|
50
|
+
*/
|
|
51
|
+
private generateCreateTransactions;
|
|
52
|
+
/**
|
|
53
|
+
* Returns all coins owned by a Wallet
|
|
54
|
+
* @param walletAddress wallet address
|
|
55
|
+
* @param coinType coin type
|
|
56
|
+
* @returns Array of Coin Structs
|
|
57
|
+
*/
|
|
58
|
+
private getAllCoins;
|
|
59
|
+
/**
|
|
60
|
+
* Utility function to split Coin object and use splitted object for stream operations.
|
|
61
|
+
* We do it like thid to mitigate risk of Transaction reverting in case Stream is created for Sui Coin object.
|
|
62
|
+
* This way we can safely pass splitted Sui Coin object in Stream payload and use another object for gas/withdrawal fees.
|
|
63
|
+
* @param txb current transanction block
|
|
64
|
+
* @param amount minimal amount of coins requried
|
|
65
|
+
* @param coinType coin type
|
|
66
|
+
* @param coins array of owned coins of the same type
|
|
67
|
+
* @returns Coin Object to use in a Move Call
|
|
68
|
+
*/
|
|
69
|
+
private splitCoinObjectForAmount;
|
|
70
|
+
/**
|
|
71
|
+
* Return previously splitted Coin Object to owner and merge it to to rebate storage fees
|
|
72
|
+
* @param txb current transanction block
|
|
73
|
+
* @param coinType coin type
|
|
74
|
+
* @param coinObject splitted object
|
|
75
|
+
* @param coins array of objects used in
|
|
76
|
+
*/
|
|
77
|
+
private returnSplittedCoinObject;
|
|
78
|
+
}
|