@streamflow/stream 7.0.0-alpha.1 → 7.0.0-alpha.3
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 +17 -18
- package/dist/cjs/__tests__/aptos/streamClient.spec.js +4 -4
- package/dist/cjs/aptos/index.js +3 -3
- package/dist/cjs/aptos/types.js +18 -18
- package/dist/cjs/common/GenericStreamClient.js +8 -8
- package/dist/cjs/common/constants.js +2 -2
- package/dist/cjs/common/contractUtils.js +6 -6
- package/dist/cjs/common/utils.js +18 -23
- package/dist/cjs/evm/StreamClient.js +7 -7
- package/dist/cjs/evm/types.js +12 -12
- package/dist/cjs/index.js +10 -10
- package/dist/cjs/solana/StreamClient.js +17 -17
- package/dist/cjs/solana/instructions.js +19 -18
- package/dist/cjs/solana/types.js +1 -1
- package/dist/cjs/solana/utils.js +38 -27
- 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/index.d.ts +3 -3
- package/dist/esm/aptos/index.js +3 -3
- package/dist/esm/aptos/types.d.ts +12 -12
- package/dist/esm/aptos/types.js +13 -13
- package/dist/esm/common/GenericStreamClient.d.ts +4 -4
- package/dist/esm/common/GenericStreamClient.js +4 -4
- 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 +16 -19
- package/dist/esm/evm/StreamClient.d.ts +2 -2
- package/dist/esm/evm/StreamClient.js +7 -7
- package/dist/esm/evm/types.d.ts +37 -37
- package/dist/esm/evm/types.js +13 -13
- package/dist/esm/index.d.ts +9 -9
- package/dist/esm/index.js +9 -9
- package/dist/esm/solana/StreamClient.js +17 -17
- package/dist/esm/solana/instructions.d.ts +17 -17
- package/dist/esm/solana/instructions.js +19 -18
- package/dist/esm/solana/types.d.ts +36 -36
- package/dist/esm/solana/types.js +2 -2
- package/dist/esm/solana/utils.d.ts +2 -0
- package/dist/esm/solana/utils.js +32 -26
- 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 +5 -6
|
@@ -2,6 +2,7 @@ import { Buffer } from "buffer";
|
|
|
2
2
|
import { TransactionInstruction } from "@solana/web3.js";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
import * as Layout from "./layout.js";
|
|
5
|
+
import { toBuffer } from "./utils.js";
|
|
5
6
|
const hasher = () => createHash("sha256");
|
|
6
7
|
const sha256 = {
|
|
7
8
|
digest: (data) => new Uint8Array(hasher().update(data).digest()),
|
|
@@ -43,12 +44,12 @@ export const createStreamInstruction = (data, programId, accounts) => {
|
|
|
43
44
|
const encodedUIntArray = new TextEncoder().encode(data.name);
|
|
44
45
|
const streamNameBuffer = Buffer.alloc(64).fill(encodedUIntArray, 0, encodedUIntArray.byteLength);
|
|
45
46
|
const decodedData = {
|
|
46
|
-
start_time: data.start
|
|
47
|
-
net_amount_deposited: data.depositedAmount
|
|
48
|
-
period: data.period
|
|
49
|
-
amount_per_period: data.amountPerPeriod
|
|
50
|
-
cliff: data.cliff
|
|
51
|
-
cliff_amount: data.cliffAmount
|
|
47
|
+
start_time: toBuffer(data.start),
|
|
48
|
+
net_amount_deposited: toBuffer(data.depositedAmount),
|
|
49
|
+
period: toBuffer(data.period),
|
|
50
|
+
amount_per_period: toBuffer(data.amountPerPeriod),
|
|
51
|
+
cliff: toBuffer(data.cliff),
|
|
52
|
+
cliff_amount: toBuffer(data.cliffAmount),
|
|
52
53
|
cancelable_by_sender: Number(data.cancelableBySender),
|
|
53
54
|
cancelable_by_recipient: Number(data.cancelableByRecipient),
|
|
54
55
|
automatic_withdrawal: Number(data.automaticWithdrawal),
|
|
@@ -60,7 +61,7 @@ export const createStreamInstruction = (data, programId, accounts) => {
|
|
|
60
61
|
_can_update_rate_discriminator: 1,
|
|
61
62
|
pausable: Number(data.canPause),
|
|
62
63
|
stream_name: streamNameBuffer,
|
|
63
|
-
withdraw_frequency: data.withdrawFrequency
|
|
64
|
+
withdraw_frequency: toBuffer(data.withdrawFrequency),
|
|
64
65
|
};
|
|
65
66
|
const encodeLength = Layout.createStreamLayout.encode(decodedData, bufferData);
|
|
66
67
|
bufferData = bufferData.slice(0, encodeLength);
|
|
@@ -96,12 +97,12 @@ export const createUncheckedStreamInstruction = (data, programId, accounts) => {
|
|
|
96
97
|
const encodedUIntArray = new TextEncoder().encode(data.name);
|
|
97
98
|
const streamNameBuffer = Buffer.alloc(64).fill(encodedUIntArray, 0, encodedUIntArray.byteLength);
|
|
98
99
|
const decodedData = {
|
|
99
|
-
start_time: data.start
|
|
100
|
-
net_amount_deposited: data.depositedAmount
|
|
101
|
-
period: data.period
|
|
102
|
-
amount_per_period: data.amountPerPeriod
|
|
103
|
-
cliff: data.cliff
|
|
104
|
-
cliff_amount: data.cliffAmount
|
|
100
|
+
start_time: toBuffer(data.start),
|
|
101
|
+
net_amount_deposited: toBuffer(data.depositedAmount),
|
|
102
|
+
period: toBuffer(data.period),
|
|
103
|
+
amount_per_period: toBuffer(data.amountPerPeriod),
|
|
104
|
+
cliff: toBuffer(data.cliff),
|
|
105
|
+
cliff_amount: toBuffer(data.cliffAmount),
|
|
105
106
|
cancelable_by_sender: Number(data.cancelableBySender),
|
|
106
107
|
cancelable_by_recipient: Number(data.cancelableByRecipient),
|
|
107
108
|
automatic_withdrawal: Number(data.automaticWithdrawal),
|
|
@@ -109,7 +110,7 @@ export const createUncheckedStreamInstruction = (data, programId, accounts) => {
|
|
|
109
110
|
transferable_by_recipient: Number(data.transferableByRecipient),
|
|
110
111
|
can_topup: Number(data.canTopup),
|
|
111
112
|
stream_name: streamNameBuffer,
|
|
112
|
-
withdraw_frequency: data.withdrawFrequency
|
|
113
|
+
withdraw_frequency: toBuffer(data.withdrawFrequency),
|
|
113
114
|
recipient: data.recipient.toBuffer(),
|
|
114
115
|
partner: data.partner.toBuffer(),
|
|
115
116
|
pausable: Number(data.canPause),
|
|
@@ -146,7 +147,7 @@ export const withdrawStreamInstruction = (amount, programId, { authority, recipi
|
|
|
146
147
|
{ pubkey: tokenProgram, isSigner: false, isWritable: false },
|
|
147
148
|
];
|
|
148
149
|
let data = Buffer.alloc(Layout.withdrawStreamLayout.span);
|
|
149
|
-
const decodedData = { amount: amount
|
|
150
|
+
const decodedData = { amount: toBuffer(amount) };
|
|
150
151
|
const encodeLength = Layout.withdrawStreamLayout.encode(decodedData, data);
|
|
151
152
|
data = data.slice(0, encodeLength);
|
|
152
153
|
data = Buffer.concat([Buffer.from(sha256.digest("global:withdraw")).slice(0, 8), data, Buffer.alloc(10)]);
|
|
@@ -166,8 +167,8 @@ export const updateStreamInstruction = (params, programId, { authority, metadata
|
|
|
166
167
|
let data = Buffer.alloc(100);
|
|
167
168
|
const decodedData = {
|
|
168
169
|
enable_automatic_withdrawal: Number(params.enableAutomaticWithdrawal),
|
|
169
|
-
withdraw_frequency: params.withdrawFrequency ? params.withdrawFrequency
|
|
170
|
-
amount_per_period: params.amountPerPeriod ? params.amountPerPeriod
|
|
170
|
+
withdraw_frequency: params.withdrawFrequency ? toBuffer(params.withdrawFrequency) : undefined,
|
|
171
|
+
amount_per_period: params.amountPerPeriod ? toBuffer(params.amountPerPeriod) : undefined,
|
|
171
172
|
};
|
|
172
173
|
const encodeLength = Layout.encodeUpdateStream(decodedData, data);
|
|
173
174
|
data = data.slice(0, encodeLength);
|
|
@@ -244,7 +245,7 @@ export const topupStreamInstruction = (amount, programId, { sender, senderTokens
|
|
|
244
245
|
{ pubkey: systemProgram, isSigner: false, isWritable: false },
|
|
245
246
|
];
|
|
246
247
|
let data = Buffer.alloc(Layout.topupStreamLayout.span);
|
|
247
|
-
const decodedData = { amount: amount
|
|
248
|
+
const decodedData = { amount: toBuffer(amount) };
|
|
248
249
|
const encodeLength = Layout.topupStreamLayout.encode(decodedData, data);
|
|
249
250
|
data = data.slice(0, encodeLength);
|
|
250
251
|
data = Buffer.concat([Buffer.from(sha256.digest("global:topup")).slice(0, 8), data, Buffer.alloc(10)]);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { SignerWalletAdapter } from "@solana/wallet-adapter-base";
|
|
3
3
|
import { AccountInfo, PublicKey, Keypair, VersionedTransaction } from "@solana/web3.js";
|
|
4
4
|
import { ITransactionSolanaExt } from "@streamflow/common/solana";
|
|
5
|
-
import
|
|
5
|
+
import BigNumber from "bignumber.js";
|
|
6
6
|
import { IRecipient, Stream, StreamType } from "../common/types.js";
|
|
7
7
|
export interface Account {
|
|
8
8
|
pubkey: PublicKey;
|
|
@@ -28,7 +28,7 @@ export declare class Contract implements Stream {
|
|
|
28
28
|
magic: number;
|
|
29
29
|
version: number;
|
|
30
30
|
createdAt: number;
|
|
31
|
-
withdrawnAmount:
|
|
31
|
+
withdrawnAmount: BigNumber;
|
|
32
32
|
canceledAt: number;
|
|
33
33
|
end: number;
|
|
34
34
|
lastWithdrawnAt: number;
|
|
@@ -40,20 +40,20 @@ export declare class Contract implements Stream {
|
|
|
40
40
|
escrowTokens: string;
|
|
41
41
|
streamflowTreasury: string;
|
|
42
42
|
streamflowTreasuryTokens: string;
|
|
43
|
-
streamflowFeeTotal:
|
|
44
|
-
streamflowFeeWithdrawn:
|
|
43
|
+
streamflowFeeTotal: BigNumber;
|
|
44
|
+
streamflowFeeWithdrawn: BigNumber;
|
|
45
45
|
streamflowFeePercent: number;
|
|
46
|
-
partnerFeeTotal:
|
|
47
|
-
partnerFeeWithdrawn:
|
|
46
|
+
partnerFeeTotal: BigNumber;
|
|
47
|
+
partnerFeeWithdrawn: BigNumber;
|
|
48
48
|
partnerFeePercent: number;
|
|
49
49
|
partner: string;
|
|
50
50
|
partnerTokens: string;
|
|
51
51
|
start: number;
|
|
52
|
-
depositedAmount:
|
|
52
|
+
depositedAmount: BigNumber;
|
|
53
53
|
period: number;
|
|
54
|
-
amountPerPeriod:
|
|
54
|
+
amountPerPeriod: BigNumber;
|
|
55
55
|
cliff: number;
|
|
56
|
-
cliffAmount:
|
|
56
|
+
cliffAmount: BigNumber;
|
|
57
57
|
cancelableBySender: boolean;
|
|
58
58
|
cancelableByRecipient: boolean;
|
|
59
59
|
automaticWithdrawal: boolean;
|
|
@@ -64,22 +64,22 @@ export declare class Contract implements Stream {
|
|
|
64
64
|
withdrawalFrequency: number;
|
|
65
65
|
closed: boolean;
|
|
66
66
|
currentPauseStart: number;
|
|
67
|
-
pauseCumulative:
|
|
67
|
+
pauseCumulative: BigNumber;
|
|
68
68
|
lastRateChangeTime: number;
|
|
69
|
-
fundsUnlockedAtLastRateChange:
|
|
69
|
+
fundsUnlockedAtLastRateChange: BigNumber;
|
|
70
70
|
type: StreamType;
|
|
71
71
|
constructor(stream: DecodedStream);
|
|
72
|
-
unlocked(currentTimestamp: number):
|
|
72
|
+
unlocked(currentTimestamp: number): BigNumber;
|
|
73
73
|
remaining(decimals: number): number;
|
|
74
74
|
}
|
|
75
75
|
export interface DecodedStream {
|
|
76
|
-
magic:
|
|
77
|
-
version:
|
|
78
|
-
createdAt:
|
|
79
|
-
withdrawnAmount:
|
|
80
|
-
canceledAt:
|
|
81
|
-
end:
|
|
82
|
-
lastWithdrawnAt:
|
|
76
|
+
magic: BigNumber;
|
|
77
|
+
version: BigNumber;
|
|
78
|
+
createdAt: BigNumber;
|
|
79
|
+
withdrawnAmount: BigNumber;
|
|
80
|
+
canceledAt: BigNumber;
|
|
81
|
+
end: BigNumber;
|
|
82
|
+
lastWithdrawnAt: BigNumber;
|
|
83
83
|
sender: PublicKey;
|
|
84
84
|
senderTokens: PublicKey;
|
|
85
85
|
recipient: PublicKey;
|
|
@@ -88,20 +88,20 @@ export interface DecodedStream {
|
|
|
88
88
|
escrowTokens: PublicKey;
|
|
89
89
|
streamflowTreasury: PublicKey;
|
|
90
90
|
streamflowTreasuryTokens: PublicKey;
|
|
91
|
-
streamflowFeeTotal:
|
|
92
|
-
streamflowFeeWithdrawn:
|
|
93
|
-
streamflowFeePercent:
|
|
94
|
-
partnerFeeTotal:
|
|
95
|
-
partnerFeeWithdrawn:
|
|
96
|
-
partnerFeePercent:
|
|
91
|
+
streamflowFeeTotal: BigNumber;
|
|
92
|
+
streamflowFeeWithdrawn: BigNumber;
|
|
93
|
+
streamflowFeePercent: BigNumber;
|
|
94
|
+
partnerFeeTotal: BigNumber;
|
|
95
|
+
partnerFeeWithdrawn: BigNumber;
|
|
96
|
+
partnerFeePercent: BigNumber;
|
|
97
97
|
partner: PublicKey;
|
|
98
98
|
partnerTokens: PublicKey;
|
|
99
|
-
start:
|
|
100
|
-
depositedAmount:
|
|
101
|
-
period:
|
|
102
|
-
amountPerPeriod:
|
|
103
|
-
cliff:
|
|
104
|
-
cliffAmount:
|
|
99
|
+
start: BigNumber;
|
|
100
|
+
depositedAmount: BigNumber;
|
|
101
|
+
period: BigNumber;
|
|
102
|
+
amountPerPeriod: BigNumber;
|
|
103
|
+
cliff: BigNumber;
|
|
104
|
+
cliffAmount: BigNumber;
|
|
105
105
|
cancelableBySender: boolean;
|
|
106
106
|
cancelableByRecipient: boolean;
|
|
107
107
|
automaticWithdrawal: boolean;
|
|
@@ -109,12 +109,12 @@ export interface DecodedStream {
|
|
|
109
109
|
transferableByRecipient: boolean;
|
|
110
110
|
canTopup: boolean;
|
|
111
111
|
name: string;
|
|
112
|
-
withdrawFrequency:
|
|
112
|
+
withdrawFrequency: BigNumber;
|
|
113
113
|
closed: boolean;
|
|
114
|
-
currentPauseStart:
|
|
115
|
-
pauseCumulative:
|
|
116
|
-
lastRateChangeTime:
|
|
117
|
-
fundsUnlockedAtLastRateChange:
|
|
114
|
+
currentPauseStart: BigNumber;
|
|
115
|
+
pauseCumulative: BigNumber;
|
|
116
|
+
lastRateChangeTime: BigNumber;
|
|
117
|
+
fundsUnlockedAtLastRateChange: BigNumber;
|
|
118
118
|
}
|
|
119
119
|
export interface MetadataRecipientHashMap {
|
|
120
120
|
[metadataPubKey: string]: IRecipient;
|
package/dist/esm/solana/types.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { buildStreamType, calculateUnlockedAmount } from "../common/contractUtils.js";
|
|
2
|
-
import {
|
|
2
|
+
import { getNumberFromBigNumber } from "../common/utils.js";
|
|
3
3
|
export class Contract {
|
|
4
4
|
magic;
|
|
5
5
|
version;
|
|
@@ -96,6 +96,6 @@ export class Contract {
|
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
98
|
remaining(decimals) {
|
|
99
|
-
return
|
|
99
|
+
return getNumberFromBigNumber(this.depositedAmount.minus(this.withdrawnAmount), decimals);
|
|
100
100
|
}
|
|
101
101
|
}
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
import { SignerWalletAdapter } from "@solana/wallet-adapter-base";
|
|
3
3
|
import { Connection, Keypair } from "@solana/web3.js";
|
|
4
4
|
import { ConfirmationParams, ThrottleParams } from "@streamflow/common/solana";
|
|
5
|
+
import BigNumber from "bignumber.js";
|
|
5
6
|
import { DecodedStream, BatchItem, BatchItemResult } from "./types.js";
|
|
7
|
+
export declare const toBuffer: (bigNumber: BigNumber) => Buffer;
|
|
6
8
|
export declare const decodeStream: (buf: Buffer) => DecodedStream;
|
|
7
9
|
/**
|
|
8
10
|
* Sign passed BatchItems with wallet request or KeyPair
|
package/dist/esm/solana/utils.js
CHANGED
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
import { PublicKey } from "@solana/web3.js";
|
|
2
2
|
import { executeTransaction, isSignerKeypair, isSignerWallet, } from "@streamflow/common/solana";
|
|
3
|
-
import
|
|
3
|
+
import BigNumber from "bignumber.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
|
|
7
|
+
const toUInt64String = (uintArr) => new DataView(uintArr.buffer, uintArr.byteOffset, uintArr.byteLength).getBigUint64(0, true).toString();
|
|
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
|
+
};
|
|
8
14
|
export const decodeStream = (buf) => {
|
|
9
15
|
const raw = streamLayout.decode(buf);
|
|
10
16
|
return {
|
|
11
|
-
magic:
|
|
12
|
-
version:
|
|
13
|
-
createdAt:
|
|
14
|
-
withdrawnAmount:
|
|
15
|
-
canceledAt:
|
|
16
|
-
end:
|
|
17
|
-
lastWithdrawnAt:
|
|
17
|
+
magic: BigNumber(toUInt64String(raw.magic)),
|
|
18
|
+
version: BigNumber(toUInt8(raw.version)),
|
|
19
|
+
createdAt: BigNumber(toUInt64String(raw.created_at)),
|
|
20
|
+
withdrawnAmount: BigNumber(toUInt64String(raw.withdrawn_amount)),
|
|
21
|
+
canceledAt: BigNumber(toUInt64String(raw.canceled_at)),
|
|
22
|
+
end: BigNumber(toUInt64String(raw.end_time)),
|
|
23
|
+
lastWithdrawnAt: BigNumber(toUInt64String(raw.last_withdrawn_at)),
|
|
18
24
|
sender: new PublicKey(raw.sender),
|
|
19
25
|
senderTokens: new PublicKey(raw.sender_tokens),
|
|
20
26
|
recipient: new PublicKey(raw.recipient),
|
|
@@ -23,20 +29,20 @@ export const decodeStream = (buf) => {
|
|
|
23
29
|
escrowTokens: new PublicKey(raw.escrow_tokens),
|
|
24
30
|
streamflowTreasury: new PublicKey(raw.streamflow_treasury),
|
|
25
31
|
streamflowTreasuryTokens: new PublicKey(raw.streamflow_treasury_tokens),
|
|
26
|
-
streamflowFeeTotal:
|
|
27
|
-
streamflowFeeWithdrawn:
|
|
28
|
-
streamflowFeePercent:
|
|
29
|
-
partnerFeeTotal:
|
|
30
|
-
partnerFeeWithdrawn:
|
|
31
|
-
partnerFeePercent:
|
|
32
|
+
streamflowFeeTotal: BigNumber(toUInt64String(raw.streamflow_fee_total)),
|
|
33
|
+
streamflowFeeWithdrawn: BigNumber(toUInt64String(raw.streamflow_fee_withdrawn)),
|
|
34
|
+
streamflowFeePercent: BigNumber(raw.streamflow_fee_percent),
|
|
35
|
+
partnerFeeTotal: BigNumber(toUInt64String(raw.partner_fee_total)),
|
|
36
|
+
partnerFeeWithdrawn: BigNumber(toUInt64String(raw.partner_fee_withdrawn)),
|
|
37
|
+
partnerFeePercent: BigNumber(raw.partner_fee_percent),
|
|
32
38
|
partner: new PublicKey(raw.partner),
|
|
33
39
|
partnerTokens: new PublicKey(raw.partner_tokens),
|
|
34
|
-
start:
|
|
35
|
-
depositedAmount:
|
|
36
|
-
period:
|
|
37
|
-
amountPerPeriod:
|
|
38
|
-
cliff:
|
|
39
|
-
cliffAmount:
|
|
40
|
+
start: BigNumber(toUInt64String(raw.start_time)),
|
|
41
|
+
depositedAmount: BigNumber(toUInt64String(raw.net_amount_deposited)),
|
|
42
|
+
period: BigNumber(toUInt64String(raw.period)),
|
|
43
|
+
amountPerPeriod: BigNumber(toUInt64String(raw.amount_per_period)),
|
|
44
|
+
cliff: BigNumber(toUInt64String(raw.cliff)),
|
|
45
|
+
cliffAmount: BigNumber(toUInt64String(raw.cliff_amount)),
|
|
40
46
|
cancelableBySender: Boolean(raw.cancelable_by_sender),
|
|
41
47
|
cancelableByRecipient: Boolean(raw.cancelable_by_recipient),
|
|
42
48
|
automaticWithdrawal: Boolean(raw.automatic_withdrawal),
|
|
@@ -44,12 +50,12 @@ export const decodeStream = (buf) => {
|
|
|
44
50
|
transferableByRecipient: Boolean(raw.transferable_by_recipient),
|
|
45
51
|
canTopup: Boolean(raw.can_topup),
|
|
46
52
|
name: decoder.decode(raw.stream_name),
|
|
47
|
-
withdrawFrequency:
|
|
53
|
+
withdrawFrequency: BigNumber(toUInt64String(raw.withdraw_frequency)),
|
|
48
54
|
closed: Boolean(raw.closed),
|
|
49
|
-
currentPauseStart:
|
|
50
|
-
pauseCumulative:
|
|
51
|
-
lastRateChangeTime:
|
|
52
|
-
fundsUnlockedAtLastRateChange:
|
|
55
|
+
currentPauseStart: BigNumber(toUInt64String(raw.current_pause_start)),
|
|
56
|
+
pauseCumulative: BigNumber(toUInt64String(raw.pause_cumulative)),
|
|
57
|
+
lastRateChangeTime: BigNumber(toUInt64String(raw.last_rate_change_time)),
|
|
58
|
+
fundsUnlockedAtLastRateChange: BigNumber(toUInt64String(raw.funds_unlocked_at_last_rate_change)),
|
|
53
59
|
};
|
|
54
60
|
};
|
|
55
61
|
/**
|
|
@@ -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.plus(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 BigNumber from "bignumber.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: BigNumber;
|
|
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: BigNumber;
|
|
122
|
+
streamflowFeeWithdrawn: BigNumber;
|
|
123
123
|
streamflowFeePercent: number;
|
|
124
|
-
partnerFeeTotal:
|
|
125
|
-
partnerFeeWithdrawn:
|
|
124
|
+
partnerFeeTotal: BigNumber;
|
|
125
|
+
partnerFeeWithdrawn: BigNumber;
|
|
126
126
|
partnerFeePercent: number;
|
|
127
127
|
partner: string;
|
|
128
128
|
partnerTokens: string;
|
|
129
129
|
start: number;
|
|
130
|
-
depositedAmount:
|
|
130
|
+
depositedAmount: BigNumber;
|
|
131
131
|
period: number;
|
|
132
|
-
amountPerPeriod:
|
|
132
|
+
amountPerPeriod: BigNumber;
|
|
133
133
|
cliff: number;
|
|
134
|
-
cliffAmount:
|
|
134
|
+
cliffAmount: BigNumber;
|
|
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: BigNumber;
|
|
146
146
|
lastRateChangeTime: number;
|
|
147
|
-
fundsUnlockedAtLastRateChange:
|
|
147
|
+
fundsUnlockedAtLastRateChange: BigNumber;
|
|
148
148
|
type: StreamType;
|
|
149
149
|
constructor(stream: StreamResource, tokenId: string);
|
|
150
|
-
unlocked(currentTimestamp: number):
|
|
150
|
+
unlocked(currentTimestamp: number): BigNumber;
|
|
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 BigNumber from "bignumber.js";
|
|
2
2
|
import { buildStreamType, calculateUnlockedAmount } from "../common/contractUtils.js";
|
|
3
|
-
import {
|
|
3
|
+
import { getNumberFromBigNumber } 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 = BigNumber(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 = BigNumber(0);
|
|
67
|
+
this.streamflowFeeWithdrawn = BigNumber(0);
|
|
68
68
|
this.streamflowFeePercent = parseInt(fees.streamflow_fee_percentage) / 10000;
|
|
69
|
-
this.partnerFeeTotal =
|
|
70
|
-
this.partnerFeeWithdrawn =
|
|
69
|
+
this.partnerFeeTotal = BigNumber(0);
|
|
70
|
+
this.partnerFeeWithdrawn = BigNumber(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 = BigNumber(stream.amount);
|
|
76
76
|
this.period = parseInt(stream.period);
|
|
77
|
-
this.amountPerPeriod =
|
|
77
|
+
this.amountPerPeriod = BigNumber(stream.amount_per_period);
|
|
78
78
|
this.cliff = parseInt(stream.start);
|
|
79
|
-
this.cliffAmount =
|
|
79
|
+
this.cliffAmount = BigNumber(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 = BigNumber(stream.pause_cumulative);
|
|
91
91
|
this.lastRateChangeTime = parseInt(stream.last_rate_change_time);
|
|
92
|
-
this.fundsUnlockedAtLastRateChange =
|
|
92
|
+
this.fundsUnlockedAtLastRateChange = BigNumber(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 getNumberFromBigNumber(this.depositedAmount.minus(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.3",
|
|
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,10 +42,9 @@
|
|
|
42
42
|
"lint": "eslint --fix .",
|
|
43
43
|
"prepublishOnly": "npm run lint && npm test && npm run build"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "1f0ce4ebcbbf9ac79f744a7ef232543b9e6d2a5b",
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@streamflow/eslint-config": "7.0.0-alpha.
|
|
48
|
-
"@types/bn.js": "5.1.1",
|
|
47
|
+
"@streamflow/eslint-config": "7.0.0-alpha.3",
|
|
49
48
|
"@types/ethereum-checksum-address": "^0.0.0",
|
|
50
49
|
"date-fns": "2.28.0",
|
|
51
50
|
"typescript": "^5.3.3"
|
|
@@ -58,10 +57,10 @@
|
|
|
58
57
|
"@solana/spl-token": "0.3.6",
|
|
59
58
|
"@solana/wallet-adapter-base": "0.9.19",
|
|
60
59
|
"@solana/web3.js": "1.70.1",
|
|
61
|
-
"@streamflow/common": "7.0.0-alpha.
|
|
60
|
+
"@streamflow/common": "7.0.0-alpha.3",
|
|
62
61
|
"@suiet/wallet-kit": "0.2.22",
|
|
63
62
|
"aptos": "1.4.0",
|
|
64
|
-
"
|
|
63
|
+
"bignumber.js": "^9.1.2",
|
|
65
64
|
"borsh": "^2.0.0",
|
|
66
65
|
"bs58": "5.0.0",
|
|
67
66
|
"ethereum-checksum-address": "0.0.8",
|