@streamflow/stream 7.0.0-alpha.11 → 7.0.0-alpha.12
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 +15 -15
- package/dist/cjs/__tests__/aptos/streamClient.spec.js +4 -4
- package/dist/cjs/aptos/types.js +12 -12
- package/dist/cjs/common/constants.js +2 -2
- package/dist/cjs/common/contractUtils.js +6 -6
- package/dist/cjs/common/utils.js +22 -19
- package/dist/cjs/evm/StreamClient.js +7 -7
- package/dist/cjs/evm/types.js +12 -12
- package/dist/cjs/solana/StreamClient.js +17 -17
- package/dist/cjs/solana/instructions.js +18 -19
- package/dist/cjs/solana/types.js +1 -1
- package/dist/cjs/solana/utils.js +27 -34
- package/dist/cjs/sui/StreamClient.js +1 -1
- package/dist/cjs/sui/types.js +12 -12
- package/dist/esm/__tests__/aptos/streamClient.spec.js +4 -4
- package/dist/esm/aptos/types.d.ts +12 -12
- package/dist/esm/aptos/types.js +13 -13
- package/dist/esm/common/constants.d.ts +2 -2
- package/dist/esm/common/constants.js +2 -2
- package/dist/esm/common/contractUtils.d.ts +14 -14
- package/dist/esm/common/contractUtils.js +6 -6
- package/dist/esm/common/types.d.ts +19 -19
- 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 +12 -12
- package/dist/esm/evm/types.js +13 -13
- package/dist/esm/solana/StreamClient.js +17 -17
- package/dist/esm/solana/instructions.d.ts +17 -17
- package/dist/esm/solana/instructions.js +18 -19
- package/dist/esm/solana/types.d.ts +36 -36
- package/dist/esm/solana/types.js +2 -2
- package/dist/esm/solana/utils.d.ts +0 -2
- package/dist/esm/solana/utils.js +26 -32
- package/dist/esm/sui/StreamClient.js +1 -1
- package/dist/esm/sui/types.d.ts +12 -12
- package/dist/esm/sui/types.js +13 -13
- package/package.json +6 -5
package/dist/esm/solana/utils.js
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
import { PublicKey } from "@solana/web3.js";
|
|
2
2
|
import { executeTransaction, isSignerKeypair, isSignerWallet, } from "@streamflow/common/solana";
|
|
3
|
-
import
|
|
3
|
+
import BN from "bn.js";
|
|
4
4
|
import { streamLayout } from "./layout.js";
|
|
5
5
|
import { SOLANA_ERROR_MAP, SOLANA_ERROR_MATCH_REGEX } from "./constants.js";
|
|
6
6
|
const decoder = new TextDecoder("utf-8");
|
|
7
|
-
const
|
|
8
|
-
const toUInt8 = (uintArr) => new DataView(uintArr.buffer, uintArr.byteOffset, uintArr.byteLength).getUint8(0);
|
|
9
|
-
export const toBuffer = (bigNumber) => {
|
|
10
|
-
const dv = new DataView(new ArrayBuffer(8), 0);
|
|
11
|
-
dv.setBigUint64(0, BigInt(bigNumber.integerValue().toString()), true);
|
|
12
|
-
return Buffer.from(dv.buffer);
|
|
13
|
-
};
|
|
7
|
+
const LE = "le"; //little endian
|
|
14
8
|
export const decodeStream = (buf) => {
|
|
15
9
|
const raw = streamLayout.decode(buf);
|
|
16
10
|
return {
|
|
17
|
-
magic:
|
|
18
|
-
version:
|
|
19
|
-
createdAt:
|
|
20
|
-
withdrawnAmount:
|
|
21
|
-
canceledAt:
|
|
22
|
-
end:
|
|
23
|
-
lastWithdrawnAt:
|
|
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),
|
|
24
18
|
sender: new PublicKey(raw.sender),
|
|
25
19
|
senderTokens: new PublicKey(raw.sender_tokens),
|
|
26
20
|
recipient: new PublicKey(raw.recipient),
|
|
@@ -29,20 +23,20 @@ export const decodeStream = (buf) => {
|
|
|
29
23
|
escrowTokens: new PublicKey(raw.escrow_tokens),
|
|
30
24
|
streamflowTreasury: new PublicKey(raw.streamflow_treasury),
|
|
31
25
|
streamflowTreasuryTokens: new PublicKey(raw.streamflow_treasury_tokens),
|
|
32
|
-
streamflowFeeTotal:
|
|
33
|
-
streamflowFeeWithdrawn:
|
|
34
|
-
streamflowFeePercent:
|
|
35
|
-
partnerFeeTotal:
|
|
36
|
-
partnerFeeWithdrawn:
|
|
37
|
-
partnerFeePercent:
|
|
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),
|
|
38
32
|
partner: new PublicKey(raw.partner),
|
|
39
33
|
partnerTokens: new PublicKey(raw.partner_tokens),
|
|
40
|
-
start:
|
|
41
|
-
depositedAmount:
|
|
42
|
-
period:
|
|
43
|
-
amountPerPeriod:
|
|
44
|
-
cliff:
|
|
45
|
-
cliffAmount:
|
|
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),
|
|
46
40
|
cancelableBySender: Boolean(raw.cancelable_by_sender),
|
|
47
41
|
cancelableByRecipient: Boolean(raw.cancelable_by_recipient),
|
|
48
42
|
automaticWithdrawal: Boolean(raw.automatic_withdrawal),
|
|
@@ -50,12 +44,12 @@ export const decodeStream = (buf) => {
|
|
|
50
44
|
transferableByRecipient: Boolean(raw.transferable_by_recipient),
|
|
51
45
|
canTopup: Boolean(raw.can_topup),
|
|
52
46
|
name: decoder.decode(raw.stream_name),
|
|
53
|
-
withdrawFrequency:
|
|
47
|
+
withdrawFrequency: new BN(raw.withdraw_frequency, LE),
|
|
54
48
|
closed: Boolean(raw.closed),
|
|
55
|
-
currentPauseStart:
|
|
56
|
-
pauseCumulative:
|
|
57
|
-
lastRateChangeTime:
|
|
58
|
-
fundsUnlockedAtLastRateChange:
|
|
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),
|
|
59
53
|
};
|
|
60
54
|
};
|
|
61
55
|
/**
|
|
@@ -308,7 +308,7 @@ export default class SuiStreamClient extends BaseStreamClient {
|
|
|
308
308
|
let coins = await this.getAllCoins(walletAddress, multipleStreamData.tokenId);
|
|
309
309
|
const totalAmount = multipleStreamData.recipients
|
|
310
310
|
.map((recipiient) => recipiient.amount)
|
|
311
|
-
.reduce((prev, current) => current.
|
|
311
|
+
.reduce((prev, current) => current.add(prev));
|
|
312
312
|
const txb = new TransactionBlock();
|
|
313
313
|
const coinObject = this.splitCoinObjectForAmount(txb, totalAmount, multipleStreamData.tokenId, coins, totalFee);
|
|
314
314
|
coins = [coins[0]];
|
package/dist/esm/sui/types.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Keypair } from "@mysten/sui.js/cryptography";
|
|
|
2
2
|
import { WalletContextState } from "@suiet/wallet-kit";
|
|
3
3
|
import { TransactionBlock } from "@mysten/sui.js/transactions";
|
|
4
4
|
import { ExecuteTransactionRequestType, SuiTransactionBlockResponseOptions } from "@mysten/sui.js/client";
|
|
5
|
-
import
|
|
5
|
+
import BN from "bn.js";
|
|
6
6
|
import { Stream, StreamType } from "../common/types.js";
|
|
7
7
|
export interface ICreateStreamSuiExt {
|
|
8
8
|
senderWallet: WalletContextState | Keypair;
|
|
@@ -106,7 +106,7 @@ export declare class Contract implements Stream {
|
|
|
106
106
|
magic: number;
|
|
107
107
|
version: number;
|
|
108
108
|
createdAt: number;
|
|
109
|
-
withdrawnAmount:
|
|
109
|
+
withdrawnAmount: BN;
|
|
110
110
|
canceledAt: number;
|
|
111
111
|
end: number;
|
|
112
112
|
lastWithdrawnAt: number;
|
|
@@ -118,20 +118,20 @@ export declare class Contract implements Stream {
|
|
|
118
118
|
escrowTokens: string;
|
|
119
119
|
streamflowTreasury: string;
|
|
120
120
|
streamflowTreasuryTokens: string;
|
|
121
|
-
streamflowFeeTotal:
|
|
122
|
-
streamflowFeeWithdrawn:
|
|
121
|
+
streamflowFeeTotal: BN;
|
|
122
|
+
streamflowFeeWithdrawn: BN;
|
|
123
123
|
streamflowFeePercent: number;
|
|
124
|
-
partnerFeeTotal:
|
|
125
|
-
partnerFeeWithdrawn:
|
|
124
|
+
partnerFeeTotal: BN;
|
|
125
|
+
partnerFeeWithdrawn: BN;
|
|
126
126
|
partnerFeePercent: number;
|
|
127
127
|
partner: string;
|
|
128
128
|
partnerTokens: string;
|
|
129
129
|
start: number;
|
|
130
|
-
depositedAmount:
|
|
130
|
+
depositedAmount: BN;
|
|
131
131
|
period: number;
|
|
132
|
-
amountPerPeriod:
|
|
132
|
+
amountPerPeriod: BN;
|
|
133
133
|
cliff: number;
|
|
134
|
-
cliffAmount:
|
|
134
|
+
cliffAmount: BN;
|
|
135
135
|
cancelableBySender: boolean;
|
|
136
136
|
cancelableByRecipient: boolean;
|
|
137
137
|
automaticWithdrawal: boolean;
|
|
@@ -142,12 +142,12 @@ export declare class Contract implements Stream {
|
|
|
142
142
|
withdrawalFrequency: number;
|
|
143
143
|
closed: boolean;
|
|
144
144
|
currentPauseStart: number;
|
|
145
|
-
pauseCumulative:
|
|
145
|
+
pauseCumulative: BN;
|
|
146
146
|
lastRateChangeTime: number;
|
|
147
|
-
fundsUnlockedAtLastRateChange:
|
|
147
|
+
fundsUnlockedAtLastRateChange: BN;
|
|
148
148
|
type: StreamType;
|
|
149
149
|
constructor(stream: StreamResource, tokenId: string);
|
|
150
|
-
unlocked(currentTimestamp: number):
|
|
150
|
+
unlocked(currentTimestamp: number): BN;
|
|
151
151
|
remaining(decimals: number): number;
|
|
152
152
|
}
|
|
153
153
|
export interface SuiParsedError {
|
package/dist/esm/sui/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 Contract {
|
|
5
5
|
magic;
|
|
6
6
|
version;
|
|
@@ -51,7 +51,7 @@ export class Contract {
|
|
|
51
51
|
this.magic = 0;
|
|
52
52
|
this.version = parseInt(stream.version);
|
|
53
53
|
this.createdAt = parseInt(stream.created);
|
|
54
|
-
this.withdrawnAmount =
|
|
54
|
+
this.withdrawnAmount = new BN(stream.withdrawn);
|
|
55
55
|
this.canceledAt = parseInt(stream.canceled_at);
|
|
56
56
|
this.end = parseInt(stream.end);
|
|
57
57
|
this.lastWithdrawnAt = parseInt(stream.last_withdrawn_at);
|
|
@@ -63,20 +63,20 @@ export class Contract {
|
|
|
63
63
|
this.escrowTokens = "";
|
|
64
64
|
this.streamflowTreasury = "";
|
|
65
65
|
this.streamflowTreasuryTokens = "";
|
|
66
|
-
this.streamflowFeeTotal =
|
|
67
|
-
this.streamflowFeeWithdrawn =
|
|
66
|
+
this.streamflowFeeTotal = new BN(0);
|
|
67
|
+
this.streamflowFeeWithdrawn = new BN(0);
|
|
68
68
|
this.streamflowFeePercent = parseInt(fees.streamflow_fee_percentage) / 10000;
|
|
69
|
-
this.partnerFeeTotal =
|
|
70
|
-
this.partnerFeeWithdrawn =
|
|
69
|
+
this.partnerFeeTotal = new BN(0);
|
|
70
|
+
this.partnerFeeWithdrawn = new BN(0);
|
|
71
71
|
this.partnerFeePercent = parseInt(fees.partner_fee_percentage) / 10000;
|
|
72
72
|
this.partner = stream.partner;
|
|
73
73
|
this.partnerTokens = "";
|
|
74
74
|
this.start = parseInt(stream.start);
|
|
75
|
-
this.depositedAmount =
|
|
75
|
+
this.depositedAmount = new BN(stream.amount);
|
|
76
76
|
this.period = parseInt(stream.period);
|
|
77
|
-
this.amountPerPeriod =
|
|
77
|
+
this.amountPerPeriod = new BN(stream.amount_per_period);
|
|
78
78
|
this.cliff = parseInt(stream.start);
|
|
79
|
-
this.cliffAmount =
|
|
79
|
+
this.cliffAmount = new BN(stream.cliff_amount);
|
|
80
80
|
this.cancelableBySender = meta.cancelable_by_sender;
|
|
81
81
|
this.cancelableByRecipient = meta.cancelable_by_recipient;
|
|
82
82
|
this.automaticWithdrawal = meta.automatic_withdrawal;
|
|
@@ -87,9 +87,9 @@ export class Contract {
|
|
|
87
87
|
this.withdrawalFrequency = parseInt(meta.withdrawal_frequency);
|
|
88
88
|
this.closed = stream.closed;
|
|
89
89
|
this.currentPauseStart = parseInt(stream.current_pause_start);
|
|
90
|
-
this.pauseCumulative =
|
|
90
|
+
this.pauseCumulative = new BN(stream.pause_cumulative);
|
|
91
91
|
this.lastRateChangeTime = parseInt(stream.last_rate_change_time);
|
|
92
|
-
this.fundsUnlockedAtLastRateChange =
|
|
92
|
+
this.fundsUnlockedAtLastRateChange = new BN(stream.funds_unlocked_at_last_rate_change);
|
|
93
93
|
this.type = buildStreamType(this);
|
|
94
94
|
}
|
|
95
95
|
unlocked(currentTimestamp) {
|
|
@@ -99,6 +99,6 @@ export class Contract {
|
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
101
|
remaining(decimals) {
|
|
102
|
-
return
|
|
102
|
+
return getNumberFromBN(this.depositedAmount.sub(this.withdrawnAmount), decimals);
|
|
103
103
|
}
|
|
104
104
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamflow/stream",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.12",
|
|
4
4
|
"description": "JavaScript SDK to interact with Streamflow protocol.",
|
|
5
5
|
"homepage": "https://github.com/streamflow-finance/js-sdk/",
|
|
6
6
|
"main": "./dist/esm/index.js",
|
|
@@ -42,9 +42,10 @@
|
|
|
42
42
|
"lint": "eslint --fix .",
|
|
43
43
|
"prepublishOnly": "npm run lint && npm test && npm run build"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "7669dc9be1788d091991591bb69525f61767a437",
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@streamflow/eslint-config": "7.0.0-alpha.
|
|
47
|
+
"@streamflow/eslint-config": "7.0.0-alpha.12",
|
|
48
|
+
"@types/bn.js": "5.1.1",
|
|
48
49
|
"@types/ethereum-checksum-address": "^0.0.0",
|
|
49
50
|
"date-fns": "2.28.0",
|
|
50
51
|
"typescript": "^5.3.3"
|
|
@@ -57,10 +58,10 @@
|
|
|
57
58
|
"@solana/spl-token": "0.3.6",
|
|
58
59
|
"@solana/wallet-adapter-base": "0.9.19",
|
|
59
60
|
"@solana/web3.js": "1.90.2",
|
|
60
|
-
"@streamflow/common": "7.0.0-alpha.
|
|
61
|
+
"@streamflow/common": "7.0.0-alpha.12",
|
|
61
62
|
"@suiet/wallet-kit": "0.2.22",
|
|
62
63
|
"aptos": "1.21.0",
|
|
63
|
-
"
|
|
64
|
+
"bn.js": "5.2.1",
|
|
64
65
|
"borsh": "^2.0.0",
|
|
65
66
|
"bs58": "5.0.0",
|
|
66
67
|
"ethereum-checksum-address": "0.0.8",
|