@streamflow/stream 5.1.0 → 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 -1
- package/dist/aptos/types.js +1 -0
- package/dist/common/contractUtils.d.ts +14 -0
- package/dist/common/contractUtils.js +20 -1
- package/dist/common/types.d.ts +5 -3
- package/dist/common/types.js +3 -2
- package/dist/evm/types.d.ts +2 -1
- package/dist/evm/types.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/solana/StreamClient.js +2 -4
- package/dist/solana/types.d.ts +1 -0
- package/dist/solana/types.js +1 -0
- package/dist/solana/utils.js +2 -0
- package/dist/sui/types.d.ts +2 -1
- package/dist/sui/types.js +1 -0
- package/package.json +1 -1
package/dist/aptos/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WalletContextState } from "@manahippo/aptos-wallet-adapter";
|
|
2
2
|
import BN from "bn.js";
|
|
3
|
-
import { Stream } from "../common/types";
|
|
3
|
+
import { Stream, StreamType } from "../common/types";
|
|
4
4
|
export interface ICreateStreamAptosExt {
|
|
5
5
|
senderWallet: WalletContextState;
|
|
6
6
|
}
|
|
@@ -89,6 +89,7 @@ export declare class Contract implements Stream {
|
|
|
89
89
|
pauseCumulative: BN;
|
|
90
90
|
lastRateChangeTime: number;
|
|
91
91
|
fundsUnlockedAtLastRateChange: BN;
|
|
92
|
+
type: StreamType;
|
|
92
93
|
constructor(stream: StreamResource, tokenId: string);
|
|
93
94
|
unlocked(currentTimestamp: number): BN;
|
|
94
95
|
remaining(decimals: number): number;
|
package/dist/aptos/types.js
CHANGED
|
@@ -63,6 +63,7 @@ var Contract = /** @class */ (function () {
|
|
|
63
63
|
this.pauseCumulative = new bn_js_1.default(stream.pause_cumulative);
|
|
64
64
|
this.lastRateChangeTime = parseInt(stream.last_rate_change_time);
|
|
65
65
|
this.fundsUnlockedAtLastRateChange = new bn_js_1.default(stream.funds_unlocked_at_last_rate_change);
|
|
66
|
+
this.type = (0, contractUtils_1.buildStreamType)(this);
|
|
66
67
|
}
|
|
67
68
|
Contract.prototype.unlocked = function (currentTimestamp) {
|
|
68
69
|
return (0, contractUtils_1.calculateUnlockedAmount)(__assign(__assign({}, this), { currentTimestamp: currentTimestamp }));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import BN from "bn.js";
|
|
2
|
+
import { StreamType } from "./types";
|
|
2
3
|
interface ICalculateUnlockedAmount {
|
|
3
4
|
depositedAmount: BN;
|
|
4
5
|
cliff: number;
|
|
@@ -11,4 +12,17 @@ interface ICalculateUnlockedAmount {
|
|
|
11
12
|
fundsUnlockedAtLastRateChange: BN;
|
|
12
13
|
}
|
|
13
14
|
export declare const calculateUnlockedAmount: ({ depositedAmount, cliff, cliffAmount, end, currentTimestamp, lastRateChangeTime, period, amountPerPeriod, fundsUnlockedAtLastRateChange, }: ICalculateUnlockedAmount) => BN;
|
|
15
|
+
export declare const isPayment: (streamData: {
|
|
16
|
+
canTopup: boolean;
|
|
17
|
+
}) => boolean;
|
|
18
|
+
export declare const isTokenLock: (streamData: {
|
|
19
|
+
canTopup: boolean;
|
|
20
|
+
depositedAmount: BN;
|
|
21
|
+
cliffAmount: BN;
|
|
22
|
+
}) => boolean;
|
|
23
|
+
export declare const buildStreamType: (streamData: {
|
|
24
|
+
canTopup: boolean;
|
|
25
|
+
depositedAmount: BN;
|
|
26
|
+
cliffAmount: BN;
|
|
27
|
+
}) => StreamType;
|
|
14
28
|
export {};
|
|
@@ -3,8 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.calculateUnlockedAmount = void 0;
|
|
6
|
+
exports.buildStreamType = exports.isTokenLock = exports.isPayment = exports.calculateUnlockedAmount = void 0;
|
|
7
7
|
var bn_js_1 = __importDefault(require("bn.js"));
|
|
8
|
+
var types_1 = require("./types");
|
|
8
9
|
var calculateUnlockedAmount = function (_a) {
|
|
9
10
|
var depositedAmount = _a.depositedAmount, cliff = _a.cliff, cliffAmount = _a.cliffAmount, end = _a.end, currentTimestamp = _a.currentTimestamp, lastRateChangeTime = _a.lastRateChangeTime, period = _a.period, amountPerPeriod = _a.amountPerPeriod, fundsUnlockedAtLastRateChange = _a.fundsUnlockedAtLastRateChange;
|
|
10
11
|
var deposited = depositedAmount;
|
|
@@ -20,3 +21,21 @@ var calculateUnlockedAmount = function (_a) {
|
|
|
20
21
|
return streamed.lt(deposited) ? streamed : deposited;
|
|
21
22
|
};
|
|
22
23
|
exports.calculateUnlockedAmount = calculateUnlockedAmount;
|
|
24
|
+
var isPayment = function (streamData) {
|
|
25
|
+
return streamData.canTopup;
|
|
26
|
+
};
|
|
27
|
+
exports.isPayment = isPayment;
|
|
28
|
+
var isTokenLock = function (streamData) {
|
|
29
|
+
return (!streamData.canTopup && streamData.cliffAmount.gte(streamData.depositedAmount.sub(new bn_js_1.default("1"))));
|
|
30
|
+
};
|
|
31
|
+
exports.isTokenLock = isTokenLock;
|
|
32
|
+
var buildStreamType = function (streamData) {
|
|
33
|
+
if ((0, exports.isPayment)(streamData)) {
|
|
34
|
+
return types_1.StreamType.Payment;
|
|
35
|
+
}
|
|
36
|
+
if ((0, exports.isTokenLock)(streamData)) {
|
|
37
|
+
return types_1.StreamType.Lock;
|
|
38
|
+
}
|
|
39
|
+
return types_1.StreamType.Vesting;
|
|
40
|
+
};
|
|
41
|
+
exports.buildStreamType = buildStreamType;
|
package/dist/common/types.d.ts
CHANGED
|
@@ -87,9 +87,10 @@ export declare enum StreamDirection {
|
|
|
87
87
|
All = "all"
|
|
88
88
|
}
|
|
89
89
|
export declare enum StreamType {
|
|
90
|
-
|
|
90
|
+
All = "all",
|
|
91
|
+
Payment = "payment",
|
|
91
92
|
Vesting = "vesting",
|
|
92
|
-
|
|
93
|
+
Lock = "lock"
|
|
93
94
|
}
|
|
94
95
|
export declare enum IChain {
|
|
95
96
|
Solana = "Solana",
|
|
@@ -142,6 +143,7 @@ export interface Stream {
|
|
|
142
143
|
pauseCumulative: BN;
|
|
143
144
|
lastRateChangeTime: number;
|
|
144
145
|
fundsUnlockedAtLastRateChange: BN;
|
|
145
|
-
|
|
146
|
+
type: StreamType;
|
|
147
|
+
unlocked(currentTimestamp: number): BN;
|
|
146
148
|
}
|
|
147
149
|
export {};
|
package/dist/common/types.js
CHANGED
|
@@ -17,9 +17,10 @@ var StreamDirection;
|
|
|
17
17
|
})(StreamDirection = exports.StreamDirection || (exports.StreamDirection = {}));
|
|
18
18
|
var StreamType;
|
|
19
19
|
(function (StreamType) {
|
|
20
|
-
StreamType["Stream"] = "stream";
|
|
21
|
-
StreamType["Vesting"] = "vesting";
|
|
22
20
|
StreamType["All"] = "all";
|
|
21
|
+
StreamType["Payment"] = "payment";
|
|
22
|
+
StreamType["Vesting"] = "vesting";
|
|
23
|
+
StreamType["Lock"] = "lock";
|
|
23
24
|
})(StreamType = exports.StreamType || (exports.StreamType = {}));
|
|
24
25
|
var IChain;
|
|
25
26
|
(function (IChain) {
|
package/dist/evm/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import BN from "bn.js";
|
|
2
2
|
import { BigNumber } from "ethers";
|
|
3
|
-
import { Stream } from "../common/types";
|
|
3
|
+
import { Stream, StreamType } from "../common/types";
|
|
4
4
|
export interface StreamAbiResult {
|
|
5
5
|
amount: BigNumber;
|
|
6
6
|
amount_per_period: BigNumber;
|
|
@@ -86,6 +86,7 @@ export declare class EvmContract implements Stream {
|
|
|
86
86
|
pauseCumulative: BN;
|
|
87
87
|
lastRateChangeTime: number;
|
|
88
88
|
fundsUnlockedAtLastRateChange: BN;
|
|
89
|
+
type: StreamType;
|
|
89
90
|
constructor(stream: StreamAbiResult);
|
|
90
91
|
unlocked(currentTimestamp: number): BN;
|
|
91
92
|
remaining(decimals: number): number;
|
package/dist/evm/types.js
CHANGED
|
@@ -62,6 +62,7 @@ var EvmContract = /** @class */ (function () {
|
|
|
62
62
|
this.pauseCumulative = new bn_js_1.default(stream.pause_cumulative.toString());
|
|
63
63
|
this.lastRateChangeTime = stream.last_rate_change_time.toNumber();
|
|
64
64
|
this.fundsUnlockedAtLastRateChange = new bn_js_1.default(stream.funds_unlocked_at_last_rate_change.toString());
|
|
65
|
+
this.type = (0, contractUtils_1.buildStreamType)(this);
|
|
65
66
|
}
|
|
66
67
|
EvmContract.prototype.unlocked = function (currentTimestamp) {
|
|
67
68
|
return (0, contractUtils_1.calculateUnlockedAmount)(__assign(__assign({}, this), { currentTimestamp: currentTimestamp }));
|
package/dist/index.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ export * as StreamflowSolana from "./solana";
|
|
|
4
4
|
export * as StreamflowSui from "./sui";
|
|
5
5
|
export * as Types from "./common/types";
|
|
6
6
|
export * from "./common/utils";
|
|
7
|
+
export * from "./common/constants";
|
|
7
8
|
export { default as GenericStreamClient } from "./common/GenericStreamClient";
|
package/dist/index.js
CHANGED
|
@@ -36,5 +36,6 @@ exports.StreamflowSolana = __importStar(require("./solana"));
|
|
|
36
36
|
exports.StreamflowSui = __importStar(require("./sui"));
|
|
37
37
|
exports.Types = __importStar(require("./common/types"));
|
|
38
38
|
__exportStar(require("./common/utils"), exports);
|
|
39
|
+
__exportStar(require("./common/constants"), exports);
|
|
39
40
|
var GenericStreamClient_1 = require("./common/GenericStreamClient");
|
|
40
41
|
Object.defineProperty(exports, "GenericStreamClient", { enumerable: true, get: function () { return __importDefault(GenericStreamClient_1).default; } });
|
|
@@ -748,13 +748,11 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
748
748
|
sortedStreams = Object.entries(streams).sort(function (_a, _b) {
|
|
749
749
|
var _c = __read(_a, 2), stream1 = _c[1];
|
|
750
750
|
var _d = __read(_b, 2), stream2 = _d[1];
|
|
751
|
-
return stream2.
|
|
751
|
+
return stream2.start - stream1.start;
|
|
752
752
|
});
|
|
753
753
|
if (type === "all")
|
|
754
754
|
return [2 /*return*/, sortedStreams];
|
|
755
|
-
return [2 /*return*/, type ===
|
|
756
|
-
? sortedStreams.filter(function (stream) { return stream[1].canTopup; })
|
|
757
|
-
: sortedStreams.filter(function (stream) { return !stream[1].canTopup; })];
|
|
755
|
+
return [2 /*return*/, sortedStreams.filter(function (stream) { return stream[1].type === type; })];
|
|
758
756
|
}
|
|
759
757
|
});
|
|
760
758
|
});
|
package/dist/solana/types.d.ts
CHANGED
|
@@ -176,6 +176,7 @@ export declare class Contract implements Stream {
|
|
|
176
176
|
pauseCumulative: BN;
|
|
177
177
|
lastRateChangeTime: number;
|
|
178
178
|
fundsUnlockedAtLastRateChange: BN;
|
|
179
|
+
type: StreamType;
|
|
179
180
|
constructor(stream: DecodedStream);
|
|
180
181
|
unlocked(currentTimestamp: number): BN;
|
|
181
182
|
remaining(decimals: number): number;
|
package/dist/solana/types.js
CHANGED
|
@@ -61,6 +61,7 @@ var Contract = /** @class */ (function () {
|
|
|
61
61
|
this.pauseCumulative = stream.pauseCumulative;
|
|
62
62
|
this.lastRateChangeTime = stream.lastRateChangeTime.toNumber();
|
|
63
63
|
this.fundsUnlockedAtLastRateChange = stream.fundsUnlockedAtLastRateChange;
|
|
64
|
+
this.type = (0, contractUtils_1.buildStreamType)(this);
|
|
64
65
|
}
|
|
65
66
|
Contract.prototype.unlocked = function (currentTimestamp) {
|
|
66
67
|
return (0, contractUtils_1.calculateUnlockedAmount)(__assign(__assign({}, this), { currentTimestamp: currentTimestamp }));
|
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
|
},
|
package/dist/sui/types.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { WalletContextState } from "@suiet/wallet-kit";
|
|
|
3
3
|
import { TransactionBlock } from "@mysten/sui.js/transactions";
|
|
4
4
|
import { ExecuteTransactionRequestType, SuiClient, SuiTransactionBlockResponse, SuiTransactionBlockResponseOptions } from "@mysten/sui.js/client";
|
|
5
5
|
import BN from "bn.js";
|
|
6
|
-
import { Stream } from "../common/types";
|
|
6
|
+
import { Stream, StreamType } from "../common/types";
|
|
7
7
|
export interface ICreateStreamSuiExt {
|
|
8
8
|
senderWallet: WalletContextState | Keypair;
|
|
9
9
|
}
|
|
@@ -119,6 +119,7 @@ export declare class Contract implements Stream {
|
|
|
119
119
|
pauseCumulative: BN;
|
|
120
120
|
lastRateChangeTime: number;
|
|
121
121
|
fundsUnlockedAtLastRateChange: BN;
|
|
122
|
+
type: StreamType;
|
|
122
123
|
constructor(stream: StreamResource, tokenId: string);
|
|
123
124
|
unlocked(currentTimestamp: number): BN;
|
|
124
125
|
remaining(decimals: number): number;
|
package/dist/sui/types.js
CHANGED
|
@@ -127,6 +127,7 @@ var Contract = /** @class */ (function () {
|
|
|
127
127
|
this.pauseCumulative = new bn_js_1.default(stream.pause_cumulative);
|
|
128
128
|
this.lastRateChangeTime = parseInt(stream.last_rate_change_time);
|
|
129
129
|
this.fundsUnlockedAtLastRateChange = new bn_js_1.default(stream.funds_unlocked_at_last_rate_change);
|
|
130
|
+
this.type = (0, contractUtils_1.buildStreamType)(this);
|
|
130
131
|
}
|
|
131
132
|
Contract.prototype.unlocked = function (currentTimestamp) {
|
|
132
133
|
return (0, contractUtils_1.calculateUnlockedAmount)(__assign(__assign({}, this), { currentTimestamp: currentTimestamp }));
|
package/package.json
CHANGED