@streamflow/stream 3.0.16 → 4.0.0-Alpha.1

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.
Files changed (49) hide show
  1. package/dist/__tests__/aptos/streamClient.spec.d.ts +1 -0
  2. package/dist/__tests__/aptos/streamClient.spec.js +160 -0
  3. package/dist/aptos/StreamClient.d.ts +20 -0
  4. package/dist/aptos/StreamClient.js +297 -0
  5. package/dist/aptos/constants.d.ts +2 -0
  6. package/dist/aptos/constants.js +12 -0
  7. package/dist/aptos/index.d.ts +2 -0
  8. package/dist/aptos/index.js +23 -0
  9. package/dist/aptos/types.d.ts +10 -0
  10. package/dist/aptos/types.js +2 -0
  11. package/dist/common/StreamClient.d.ts +10 -0
  12. package/dist/common/StreamClient.js +9 -0
  13. package/dist/common/types.d.ts +61 -0
  14. package/dist/common/types.js +23 -0
  15. package/dist/{utils.d.ts → common/utils.d.ts} +0 -4
  16. package/dist/common/utils.js +31 -0
  17. package/dist/index.d.ts +4 -6
  18. package/dist/index.js +17 -13
  19. package/dist/{StreamClient.d.ts → solana/StreamClient.d.ts} +17 -17
  20. package/dist/{StreamClient.js → solana/StreamClient.js} +245 -309
  21. package/dist/{constants.d.ts → solana/constants.d.ts} +1 -1
  22. package/dist/{constants.js → solana/constants.js} +5 -5
  23. package/dist/solana/index.d.ts +7 -0
  24. package/dist/solana/index.js +42 -0
  25. package/dist/solana/instructionTypes.d.ts +81 -0
  26. package/dist/solana/instructionTypes.js +2 -0
  27. package/dist/{instructions.d.ts → solana/instructions.d.ts} +0 -2
  28. package/dist/{instructions.js → solana/instructions.js} +23 -38
  29. package/dist/solana/layout.d.ts +22 -0
  30. package/dist/{layout.js → solana/layout.js} +27 -2
  31. package/dist/{idl/timelock.d.ts → solana/timelockIDL.d.ts} +0 -0
  32. package/dist/{idl/timelock.js → solana/timelockIDL.js} +0 -0
  33. package/dist/{types.d.ts → solana/types.d.ts} +37 -34
  34. package/dist/{types.js → solana/types.js} +3 -20
  35. package/dist/solana/utils.d.ts +42 -0
  36. package/dist/solana/utils.js +269 -0
  37. package/package.json +24 -11
  38. package/dist/Stream.d.ts +0 -87
  39. package/dist/Stream.js +0 -503
  40. package/dist/__tests__/test_dependencies/airdrop/airdrop-request.d.ts +0 -3
  41. package/dist/__tests__/test_dependencies/airdrop/airdrop-request.js +0 -67
  42. package/dist/__tests__/test_dependencies/airdrop/airdrop.d.ts +0 -6
  43. package/dist/__tests__/test_dependencies/airdrop/airdrop.js +0 -215
  44. package/dist/__tests__/test_dependencies/constants/index.d.ts +0 -122
  45. package/dist/__tests__/test_dependencies/constants/index.js +0 -158
  46. package/dist/__tests__/test_dependencies/idl/airdrop.d.ts +0 -27
  47. package/dist/__tests__/test_dependencies/idl/airdrop.js +0 -171
  48. package/dist/layout.d.ts +0 -22
  49. package/dist/utils.js +0 -126
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getNumberFromBN = exports.getBN = void 0;
7
+ var bn_js_1 = __importDefault(require("bn.js"));
8
+ /**
9
+ * Used for conversion of token amounts to their Big Number representation.
10
+ * Get Big Number representation in the smallest units from the same value in the highest units.
11
+ * @param {number} value - Number of tokens you want to convert to its BN representation.
12
+ * @param {number} decimals - Number of decimals the token has.
13
+ */
14
+ var getBN = function (value, decimals) {
15
+ return value > (Math.pow(2, 53) - 1) / Math.pow(10, decimals)
16
+ ? new bn_js_1.default(value).mul(new bn_js_1.default(Math.pow(10, decimals)))
17
+ : new bn_js_1.default(value * Math.pow(10, decimals));
18
+ };
19
+ exports.getBN = getBN;
20
+ /**
21
+ * Used for token amounts conversion from their Big Number representation to number.
22
+ * Get value in the highest units from BN representation of the same value in the smallest units.
23
+ * @param {BN} value - Big Number representation of value in the smallest units.
24
+ * @param {number} decimals - Number of decimals the token has.
25
+ */
26
+ var getNumberFromBN = function (value, decimals) {
27
+ return value.gt(new bn_js_1.default(Math.pow(2, 53) - 1))
28
+ ? value.div(new bn_js_1.default(Math.pow(10, decimals))).toNumber()
29
+ : value.toNumber() / Math.pow(10, decimals);
30
+ };
31
+ exports.getNumberFromBN = getNumberFromBN;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,4 @@
1
- export { default } from "./Stream";
2
- export { default as StreamClient } from "./StreamClient";
3
- export * from "./utils";
4
- export * from "./types";
5
- export * from "./instructions";
6
- export { default as BN } from "bn.js";
1
+ export * as StreamflowSolana from "./solana";
2
+ export * as StreamflowAptos from "./aptos";
3
+ export * as Types from "./common/types";
4
+ export * from "./common/utils";
package/dist/index.js CHANGED
@@ -10,20 +10,24 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
10
10
  if (k2 === undefined) k2 = k;
11
11
  o[k2] = m[k];
12
12
  }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
13
25
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
26
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
27
  };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
28
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.BN = exports.StreamClient = exports.default = void 0;
21
- var Stream_1 = require("./Stream");
22
- Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(Stream_1).default; } });
23
- var StreamClient_1 = require("./StreamClient");
24
- Object.defineProperty(exports, "StreamClient", { enumerable: true, get: function () { return __importDefault(StreamClient_1).default; } });
25
- __exportStar(require("./utils"), exports);
26
- __exportStar(require("./types"), exports);
27
- __exportStar(require("./instructions"), exports);
28
- var bn_js_1 = require("bn.js");
29
- Object.defineProperty(exports, "BN", { enumerable: true, get: function () { return __importDefault(bn_js_1).default; } });
29
+ exports.Types = exports.StreamflowAptos = exports.StreamflowSolana = void 0;
30
+ exports.StreamflowSolana = __importStar(require("./solana"));
31
+ exports.StreamflowAptos = __importStar(require("./aptos"));
32
+ exports.Types = __importStar(require("./common/types"));
33
+ __exportStar(require("./common/utils"), exports);
@@ -1,22 +1,22 @@
1
- import { web3 } from "@project-serum/anchor";
2
- import { Commitment, ConnectionConfig } from "@solana/web3.js";
3
- import { Stream as StreamData, CreateParams, CreateMultiParams, WithdrawParams, TopupParams, CancelParams, TransferParams, ClusterExtended, GetAllParams, CreateResponse, CreateMultiResponse, TxResponse } from "./types";
4
- export default class StreamClient {
1
+ import { Connection, Commitment, ConnectionConfig } from "@solana/web3.js";
2
+ import { Stream as StreamData, GetAllParams, CreateResponse, CreateMultiResponse, TxResponse, ICreateStreamSolanaExt, IInteractStreamSolanaExt, ITopUpStreamSolanaExt } from "./types";
3
+ import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateStreamData, IGetOneData, ITopUpData, ITransferData, IWithdrawData } from "../common/types";
4
+ import { GenericStreamClient } from "../common/StreamClient";
5
+ export default class SolanaStreamClient extends GenericStreamClient {
5
6
  private connection;
6
- private cluster;
7
7
  private programId;
8
8
  private commitment;
9
9
  /**
10
10
  * Create Stream instance
11
11
  */
12
- constructor(clusterUrl: string, cluster?: ClusterExtended, commitment?: Commitment | ConnectionConfig, programId?: string);
13
- getConnection(): web3.Connection;
12
+ constructor(clusterUrl: string, cluster?: ICluster, commitment?: Commitment | ConnectionConfig, programId?: string);
13
+ getConnection(): Connection;
14
14
  getProgramId(): string;
15
15
  /**
16
16
  * Creates a new stream/vesting contract.
17
17
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
18
18
  * @param {CreateParams} data
19
- * @param {Wallet | Keypair} data.sender - Wallet signing the transaction. Its address should match the authorized wallet (sender) or transaction will fail.
19
+ * @param {WalletAdapter | Keypair} data.sender - Wallet signing the transaction. Its address should match the authorized wallet (sender) or transaction will fail.
20
20
  * @param {string} data.recipient - Solana address of the recipient. Associated token account will be derived using this address and token mint address.
21
21
  * @param {string} data.mint - SPL Token mint.
22
22
  * @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
@@ -36,7 +36,7 @@ export default class StreamClient {
36
36
  * @param {boolean} [data.isNative = false] - When true Automatically wraps SOLs to WrappedSOL and creates wSOL stream
37
37
  * @param {string | null} [data.partner = null] - Partner's wallet address (optional).
38
38
  */
39
- create({ sender, recipient, mint, start, depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, isNative, }: CreateParams): Promise<CreateResponse>;
39
+ create({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, }: ICreateStreamData, { sender, partner, isNative }: ICreateStreamSolanaExt): Promise<CreateResponse>;
40
40
  /**
41
41
  * Creates a new stream/vesting contract using unchecked instruction.
42
42
  *
@@ -66,9 +66,9 @@ export default class StreamClient {
66
66
  * @param {boolean} data.automaticWithdrawal - Whether or not a 3rd party can initiate withdraw in the name of recipient.
67
67
  * @param {number} [data.withdrawalFrequency = 0] - Relevant when automatic withdrawal is enabled. If greater than 0 our withdrawor will take care of withdrawals. If equal to 0 our withdrawor will skip, but everyone else can initiate withdrawals.
68
68
  * @param {boolean} [data.isNative = false] - When true Automatically wraps SOLs to WrappedSOL and creates wSOL stream
69
- * @param {string | null} [data.partner = null] - Partner's wallet address (optional).
69
+ * @param {string | null} [data.partner = null] - Partner's wallet address (optional).
70
70
  */
71
- createUnchecked({ sender, recipient, mint, start, depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, isNative, }: CreateParams): Promise<CreateResponse>;
71
+ createUnchecked({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, }: ICreateStreamData, { sender, partner, isNative }: ICreateStreamSolanaExt): Promise<CreateResponse>;
72
72
  /**
73
73
  * Creates a new stream/vesting contract.
74
74
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
@@ -89,7 +89,7 @@ export default class StreamClient {
89
89
  * @param {boolean} [data.isNative = false] - When true Automatically wraps SOLs to WrappedSOL and creates wSOL stream
90
90
  * @param {string | null} [data.partner = null] - Partner's wallet address (optional).
91
91
  */
92
- createMultiple(data: CreateMultiParams): Promise<CreateMultiResponse>;
92
+ createMultiple(data: ICreateMultipleStreamData, { sender, partner, isNative }: ICreateStreamSolanaExt): Promise<CreateMultiResponse>;
93
93
  /**
94
94
  * Attempts withdrawal from the specified stream.
95
95
  * @param {WithdrawParams} data
@@ -97,14 +97,14 @@ export default class StreamClient {
97
97
  * @param {string} data.id - Identifier of a stream (escrow account with metadata) to be withdrawn from.
98
98
  * @param {BN} data.amount - Requested amount (in the smallest units) to withdraw (while streaming). If stream is completed, the whole amount will be withdrawn.
99
99
  */
100
- withdraw({ invoker, id, amount, }: WithdrawParams): Promise<TxResponse>;
100
+ withdraw({ id, amount }: IWithdrawData, { invoker }: IInteractStreamSolanaExt): Promise<TxResponse>;
101
101
  /**
102
102
  * Attempts canceling the specified stream.
103
103
  * @param {CancelParams} data
104
104
  * @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (sender or recipient) or transaction will fail.
105
105
  * @param {string} data.id - Identifier of a stream (escrow account with metadata) to be canceled.
106
106
  */
107
- cancel({ invoker, id }: CancelParams): Promise<TxResponse>;
107
+ cancel({ id }: ICancelData, { invoker }: IInteractStreamSolanaExt): Promise<TxResponse>;
108
108
  /**
109
109
  * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
110
110
  * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
@@ -113,7 +113,7 @@ export default class StreamClient {
113
113
  * @param {string} data.id - Identifier of a stream (escrow account with metadata) to be transferred.
114
114
  * @param {string} data.recipientId - Address of a new recipient.
115
115
  */
116
- transfer({ invoker, id, recipientId, }: TransferParams): Promise<TxResponse>;
116
+ transfer({ id, newRecipient: newRecipientString }: ITransferData, { invoker }: IInteractStreamSolanaExt): Promise<TxResponse>;
117
117
  /**
118
118
  * Tops up stream account deposited amount.
119
119
  * @param {TopupParams} data
@@ -121,12 +121,12 @@ export default class StreamClient {
121
121
  * @param {string} data.id - Identifier of a stream (escrow account with metadata) to be topped up.
122
122
  * @param {BN} data.amount - Specified amount (in the smallest units) to topup (increases deposited amount).
123
123
  */
124
- topup({ invoker, id, amount, isNative, }: TopupParams): Promise<TxResponse>;
124
+ topup({ id, amount }: ITopUpData, { invoker, isNative }: ITopUpStreamSolanaExt): Promise<TxResponse>;
125
125
  /**
126
126
  * Fetch stream data by its id (address).
127
127
  * @param {string} id - Identifier of a stream that is fetched.
128
128
  */
129
- getOne(id: string): Promise<StreamData>;
129
+ getOne({ id }: IGetOneData): Promise<StreamData>;
130
130
  /**
131
131
  * Fetch streams/contracts by providing direction.
132
132
  * Streams are sorted by start time in ascending order.