@streamflow/stream 7.0.0-alpha.12 → 7.0.0-alpha.13
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 +10 -5
- package/dist/cjs/common/constants.js +2 -1
- package/dist/cjs/common/contractUtils.js +17 -1
- package/dist/cjs/common/types.js +30 -1
- package/dist/cjs/solana/StreamClient.js +244 -99
- 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/lib/derive-accounts.js +17 -0
- package/dist/cjs/solana/{utils.js → lib/utils.js} +2 -2
- package/dist/cjs/solana/types.js +25 -2
- package/dist/esm/aptos/types.d.ts +2 -2
- package/dist/esm/common/constants.d.ts +1 -0
- package/dist/esm/common/constants.js +1 -0
- package/dist/esm/common/contractUtils.d.ts +4 -1
- package/dist/esm/common/contractUtils.js +13 -0
- package/dist/esm/common/types.d.ts +104 -49
- package/dist/esm/common/types.js +29 -0
- package/dist/esm/evm/types.d.ts +2 -2
- package/dist/esm/solana/StreamClient.d.ts +20 -14
- package/dist/esm/solana/StreamClient.js +247 -101
- package/dist/esm/solana/constants.d.ts +14 -0
- 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/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 -1
- package/dist/esm/solana/{utils.js → lib/utils.js} +2 -2
- package/dist/esm/solana/types.d.ts +31 -3
- package/dist/esm/solana/types.js +30 -2
- package/dist/esm/sui/types.d.ts +2 -2
- package/package.json +5 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/esm/solana/index.js
CHANGED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
export declare const deriveContractPDA: (programId: PublicKey, streamMetadata: PublicKey) => PublicKey;
|
|
3
|
+
export declare const deriveEscrowPDA: (programId: PublicKey, streamMetadata: PublicKey) => PublicKey;
|
|
4
|
+
export declare const deriveTestOraclePDA: (programId: PublicKey, mint: PublicKey, creator: PublicKey) => PublicKey;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
import { CONTRACT_SEED, ESCROW_SEED, TEST_ORACLE_SEED } from "../constants";
|
|
3
|
+
export const deriveContractPDA = (programId, streamMetadata) => {
|
|
4
|
+
return PublicKey.findProgramAddressSync([CONTRACT_SEED, streamMetadata.toBuffer()], programId)[0];
|
|
5
|
+
};
|
|
6
|
+
export const deriveEscrowPDA = (programId, streamMetadata) => {
|
|
7
|
+
return PublicKey.findProgramAddressSync([ESCROW_SEED, streamMetadata.toBuffer()], programId)[0];
|
|
8
|
+
};
|
|
9
|
+
export const deriveTestOraclePDA = (programId, mint, creator) => {
|
|
10
|
+
return PublicKey.findProgramAddressSync([TEST_ORACLE_SEED, mint.toBuffer(), creator.toBuffer()], programId)[0];
|
|
11
|
+
};
|
|
@@ -2,7 +2,7 @@
|
|
|
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 { DecodedStream, BatchItem, BatchItemResult } from "
|
|
5
|
+
import { DecodedStream, BatchItem, BatchItemResult } from "../types.js";
|
|
6
6
|
export declare const decodeStream: (buf: Buffer) => DecodedStream;
|
|
7
7
|
/**
|
|
8
8
|
* Sign passed BatchItems with wallet request or KeyPair
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { PublicKey } from "@solana/web3.js";
|
|
2
2
|
import { executeTransaction, isSignerKeypair, isSignerWallet, } from "@streamflow/common/solana";
|
|
3
3
|
import BN from "bn.js";
|
|
4
|
-
import { streamLayout } from "
|
|
5
|
-
import { SOLANA_ERROR_MAP, SOLANA_ERROR_MATCH_REGEX } from "
|
|
4
|
+
import { streamLayout } from "../layout.js";
|
|
5
|
+
import { SOLANA_ERROR_MAP, SOLANA_ERROR_MATCH_REGEX } from "../constants.js";
|
|
6
6
|
const decoder = new TextDecoder("utf-8");
|
|
7
7
|
const LE = "le"; //little endian
|
|
8
8
|
export const decodeStream = (buf) => {
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { SignerWalletAdapter } from "@solana/wallet-adapter-base";
|
|
3
|
-
import { AccountInfo, PublicKey, Keypair, VersionedTransaction } from "@solana/web3.js";
|
|
3
|
+
import { AccountInfo, PublicKey, Keypair, VersionedTransaction, TransactionInstruction } from "@solana/web3.js";
|
|
4
4
|
import { ITransactionSolanaExt } from "@streamflow/common/solana";
|
|
5
5
|
import BN from "bn.js";
|
|
6
|
-
import {
|
|
6
|
+
import { type IdlTypes } from "@coral-xyz/anchor";
|
|
7
|
+
import { AlignedStream, IRecipient, LinearStream, OracleTypeName, StreamType } from "../common/types.js";
|
|
8
|
+
import { StreamflowAlignedUnlocks as AlignedUnlocksIDL } from "./descriptor/streamflow_aligned_unlocks.js";
|
|
9
|
+
export { IChain, ICluster, ContractError } from "@streamflow/common";
|
|
10
|
+
type AlignedUnlocksTypes = IdlTypes<AlignedUnlocksIDL>;
|
|
11
|
+
export type AlignedUnlocksContract = AlignedUnlocksTypes["contract"];
|
|
12
|
+
export type OracleType = AlignedUnlocksTypes["oracleType"];
|
|
13
|
+
export type TestOracle = AlignedUnlocksTypes["testOracle"];
|
|
14
|
+
export type CreateParams = AlignedUnlocksTypes["createParams"];
|
|
15
|
+
export type ChangeOracleParams = AlignedUnlocksTypes["changeOracleParams"];
|
|
16
|
+
export type CreateTestOracleParams = AlignedUnlocksTypes["createTestOracleParams"];
|
|
17
|
+
export type UpdateTestOracleParams = AlignedUnlocksTypes["updateTestOracleParams"];
|
|
7
18
|
export interface ISearchStreams {
|
|
8
19
|
mint?: string;
|
|
9
20
|
sender?: string;
|
|
@@ -29,7 +40,12 @@ export interface ITopUpStreamSolanaExt extends ITransactionSolanaExt {
|
|
|
29
40
|
invoker: SignerWalletAdapter | Keypair;
|
|
30
41
|
isNative?: boolean;
|
|
31
42
|
}
|
|
32
|
-
export
|
|
43
|
+
export interface ICreateStreamInstructions {
|
|
44
|
+
ixs: TransactionInstruction[];
|
|
45
|
+
metadata: Keypair | undefined;
|
|
46
|
+
metadataPubKey: PublicKey;
|
|
47
|
+
}
|
|
48
|
+
export declare class Contract implements LinearStream {
|
|
33
49
|
magic: number;
|
|
34
50
|
version: number;
|
|
35
51
|
createdAt: number;
|
|
@@ -73,10 +89,22 @@ export declare class Contract implements Stream {
|
|
|
73
89
|
lastRateChangeTime: number;
|
|
74
90
|
fundsUnlockedAtLastRateChange: BN;
|
|
75
91
|
type: StreamType;
|
|
92
|
+
isAligned?: boolean;
|
|
76
93
|
constructor(stream: DecodedStream);
|
|
77
94
|
unlocked(currentTimestamp: number): BN;
|
|
78
95
|
remaining(decimals: number): number;
|
|
79
96
|
}
|
|
97
|
+
export declare class AlignedContract extends Contract implements AlignedStream {
|
|
98
|
+
minPrice: number;
|
|
99
|
+
maxPrice: number;
|
|
100
|
+
minPercentage: number;
|
|
101
|
+
maxPercentage: number;
|
|
102
|
+
tickSize: number;
|
|
103
|
+
proxyAddress: string;
|
|
104
|
+
priceOracle: string | undefined;
|
|
105
|
+
oracleType: OracleTypeName;
|
|
106
|
+
constructor(stream: DecodedStream, alignedProxy: AlignedUnlocksContract);
|
|
107
|
+
}
|
|
80
108
|
export interface DecodedStream {
|
|
81
109
|
magic: BN;
|
|
82
110
|
version: BN;
|
package/dist/esm/solana/types.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { buildStreamType, calculateUnlockedAmount } from "../common/contractUtils.js";
|
|
1
|
+
import { buildStreamType, calculateUnlockedAmount, decodeEndTime } from "../common/contractUtils.js";
|
|
2
2
|
import { getNumberFromBN } from "../common/utils.js";
|
|
3
|
+
import { ALIGNED_PRECISION_FACTOR_POW } from "./constants.js";
|
|
4
|
+
export { IChain, ICluster, ContractError } from "@streamflow/common";
|
|
3
5
|
export class Contract {
|
|
4
6
|
magic;
|
|
5
7
|
version;
|
|
@@ -44,13 +46,15 @@ export class Contract {
|
|
|
44
46
|
lastRateChangeTime;
|
|
45
47
|
fundsUnlockedAtLastRateChange;
|
|
46
48
|
type;
|
|
49
|
+
isAligned;
|
|
47
50
|
constructor(stream) {
|
|
48
51
|
this.magic = stream.magic.toNumber();
|
|
49
52
|
this.version = stream.version.toNumber();
|
|
50
53
|
this.createdAt = stream.createdAt.toNumber();
|
|
51
54
|
this.withdrawnAmount = stream.withdrawnAmount;
|
|
52
55
|
this.canceledAt = stream.canceledAt.toNumber();
|
|
53
|
-
|
|
56
|
+
// for aligned contracts end time can be an invalid timeValue
|
|
57
|
+
this.end = decodeEndTime(stream.end);
|
|
54
58
|
this.lastWithdrawnAt = stream.lastWithdrawnAt.toNumber();
|
|
55
59
|
this.sender = stream.sender.toBase58();
|
|
56
60
|
this.senderTokens = stream.senderTokens.toBase58();
|
|
@@ -88,6 +92,7 @@ export class Contract {
|
|
|
88
92
|
this.lastRateChangeTime = stream.lastRateChangeTime.toNumber();
|
|
89
93
|
this.fundsUnlockedAtLastRateChange = stream.fundsUnlockedAtLastRateChange;
|
|
90
94
|
this.type = buildStreamType(this);
|
|
95
|
+
this.isAligned = false;
|
|
91
96
|
}
|
|
92
97
|
unlocked(currentTimestamp) {
|
|
93
98
|
return calculateUnlockedAmount({
|
|
@@ -99,3 +104,26 @@ export class Contract {
|
|
|
99
104
|
return getNumberFromBN(this.depositedAmount.sub(this.withdrawnAmount), decimals);
|
|
100
105
|
}
|
|
101
106
|
}
|
|
107
|
+
export class AlignedContract extends Contract {
|
|
108
|
+
minPrice;
|
|
109
|
+
maxPrice;
|
|
110
|
+
minPercentage;
|
|
111
|
+
maxPercentage;
|
|
112
|
+
tickSize;
|
|
113
|
+
proxyAddress;
|
|
114
|
+
priceOracle;
|
|
115
|
+
oracleType;
|
|
116
|
+
constructor(stream, alignedProxy) {
|
|
117
|
+
super(stream);
|
|
118
|
+
this.minPrice = getNumberFromBN(alignedProxy.minPrice, ALIGNED_PRECISION_FACTOR_POW);
|
|
119
|
+
this.maxPrice = getNumberFromBN(alignedProxy.maxPrice, ALIGNED_PRECISION_FACTOR_POW);
|
|
120
|
+
this.minPercentage = getNumberFromBN(alignedProxy.minPercentage, ALIGNED_PRECISION_FACTOR_POW);
|
|
121
|
+
this.maxPercentage = getNumberFromBN(alignedProxy.maxPercentage, ALIGNED_PRECISION_FACTOR_POW);
|
|
122
|
+
this.oracleType = (Object.keys(alignedProxy.priceOracleType).find((key) => !!key) || "none");
|
|
123
|
+
this.tickSize = alignedProxy.tickSize.toNumber();
|
|
124
|
+
this.priceOracle = this.oracleType === "none" ? undefined : alignedProxy.priceOracle.toBase58();
|
|
125
|
+
this.sender = alignedProxy.sender.toBase58();
|
|
126
|
+
this.canceledAt = alignedProxy.streamCanceledTime.toNumber();
|
|
127
|
+
this.proxyAddress = stream.sender.toBase58();
|
|
128
|
+
}
|
|
129
|
+
}
|
package/dist/esm/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, SuiTransactionBlockResponseOptions } from "@mysten/sui.js/client";
|
|
5
5
|
import BN from "bn.js";
|
|
6
|
-
import {
|
|
6
|
+
import { LinearStream, StreamType } from "../common/types.js";
|
|
7
7
|
export interface ICreateStreamSuiExt {
|
|
8
8
|
senderWallet: WalletContextState | Keypair;
|
|
9
9
|
}
|
|
@@ -102,7 +102,7 @@ export interface FeeValueResource {
|
|
|
102
102
|
};
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
|
-
export declare class Contract implements
|
|
105
|
+
export declare class Contract implements LinearStream {
|
|
106
106
|
magic: number;
|
|
107
107
|
version: number;
|
|
108
108
|
createdAt: number;
|
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.13",
|
|
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,15 +42,16 @@
|
|
|
42
42
|
"lint": "eslint --fix .",
|
|
43
43
|
"prepublishOnly": "npm run lint && npm test && npm run build"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "1fe1f2d828e28cfd9e842bb4dd47c9756a39404f",
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@streamflow/eslint-config": "7.0.0-alpha.
|
|
47
|
+
"@streamflow/eslint-config": "7.0.0-alpha.13",
|
|
48
48
|
"@types/bn.js": "5.1.1",
|
|
49
49
|
"@types/ethereum-checksum-address": "^0.0.0",
|
|
50
50
|
"date-fns": "2.28.0",
|
|
51
51
|
"typescript": "^5.3.3"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
+
"@coral-xyz/anchor": "^0.30.0",
|
|
54
55
|
"@coral-xyz/borsh": "0.30.1",
|
|
55
56
|
"@manahippo/aptos-wallet-adapter": "1.0.10",
|
|
56
57
|
"@mysten/sui.js": "0.54.1",
|
|
@@ -58,7 +59,7 @@
|
|
|
58
59
|
"@solana/spl-token": "0.3.6",
|
|
59
60
|
"@solana/wallet-adapter-base": "0.9.19",
|
|
60
61
|
"@solana/web3.js": "1.90.2",
|
|
61
|
-
"@streamflow/common": "7.0.0-alpha.
|
|
62
|
+
"@streamflow/common": "7.0.0-alpha.13",
|
|
62
63
|
"@suiet/wallet-kit": "0.2.22",
|
|
63
64
|
"aptos": "1.21.0",
|
|
64
65
|
"bn.js": "5.2.1",
|