@streamflow/stream 4.0.0-Alpha.1 → 4.0.0-Alpha.2

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.
@@ -117,11 +117,11 @@ describe("AptosStreamClient", function () {
117
117
  delete callParam.arguments;
118
118
  args.shift();
119
119
  expect(args).toEqual([
120
- mockRecipient.amount,
120
+ mockRecipient.amount.toString(),
121
121
  100,
122
- mockRecipient.amountPerPeriod,
122
+ mockRecipient.amountPerPeriod.toString(),
123
123
  10,
124
- mockRecipient.cliffAmount,
124
+ mockRecipient.cliffAmount.toString(),
125
125
  true,
126
126
  false,
127
127
  false,
@@ -131,7 +131,7 @@ describe("AptosStreamClient", function () {
131
131
  false,
132
132
  false,
133
133
  10,
134
- "5354524d",
134
+ "test name",
135
135
  "0xtest",
136
136
  ]);
137
137
  expect(callParam).toEqual({
@@ -1,12 +1,12 @@
1
- import { GenericStreamClient } from "../common/StreamClient";
1
+ import { BaseStreamClient } from "../common/BaseStreamClient";
2
2
  import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateStreamData, ITopUpData, ITransferData, IWithdrawData } from "../common/types";
3
- import { ICreateStreamAptosExt, ITransactionAptosExt, ITransactionResult } from "./types";
4
- export default class AptosStreamClient extends GenericStreamClient {
3
+ import { ICreateStreamAptosExt, IMultiTransactionResult, ITransactionAptosExt, ITransactionResult } from "./types";
4
+ export default class AptosStreamClient extends BaseStreamClient {
5
5
  private programId;
6
6
  private maxGas;
7
- constructor(cluster: ICluster, maxGas?: string, programId?: string);
7
+ constructor(cluster?: ICluster, maxGas?: string, programId?: string);
8
8
  create(streamData: ICreateStreamData, { senderWallet }: ICreateStreamAptosExt): Promise<ITransactionResult>;
9
- createMultiple(multipleStreamData: ICreateMultipleStreamData, { senderWallet }: ICreateStreamAptosExt): Promise<ITransactionResult[]>;
9
+ createMultiple(multipleStreamData: ICreateMultipleStreamData, { senderWallet }: ICreateStreamAptosExt): Promise<IMultiTransactionResult>;
10
10
  withdraw(withdrawData: IWithdrawData, { senderWallet, tokenId }: ITransactionAptosExt): Promise<ITransactionResult>;
11
11
  cancel(cancelData: ICancelData, { senderWallet, tokenId }: ITransactionAptosExt): Promise<any>;
12
12
  transfer(transferData: ITransferData, { senderWallet, tokenId }: ITransactionAptosExt): Promise<any>;
@@ -50,65 +50,51 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
50
50
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
51
  }
52
52
  };
53
- var __values = (this && this.__values) || function(o) {
54
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
55
- if (m) return m.call(o);
56
- if (o && typeof o.length === "number") return {
57
- next: function () {
58
- if (o && i >= o.length) o = void 0;
59
- return { value: o && o[i++], done: !o };
60
- }
61
- };
62
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
63
- };
64
53
  Object.defineProperty(exports, "__esModule", { value: true });
65
54
  var aptos_1 = require("aptos");
66
- var StreamClient_1 = require("../common/StreamClient");
55
+ var BaseStreamClient_1 = require("../common/BaseStreamClient");
67
56
  var types_1 = require("../common/types");
68
57
  var constants_1 = require("./constants");
69
58
  var AptosStreamClient = /** @class */ (function (_super) {
70
59
  __extends(AptosStreamClient, _super);
71
60
  function AptosStreamClient(cluster, maxGas, programId) {
61
+ if (cluster === void 0) { cluster = types_1.ICluster.Mainnet; }
72
62
  if (maxGas === void 0) { maxGas = "10000"; }
73
63
  var _this = _super.call(this) || this;
74
- _this.programId = programId
75
- ? programId
76
- : constants_1.APTOS_PROGRAM_IDS[cluster] || constants_1.APTOS_PROGRAM_IDS[types_1.ICluster.Mainnet];
64
+ _this.programId = programId ? programId : constants_1.APTOS_PROGRAM_IDS[cluster];
77
65
  _this.maxGas = maxGas;
78
66
  return _this;
79
67
  }
80
68
  AptosStreamClient.prototype.create = function (streamData, _a) {
81
69
  var senderWallet = _a.senderWallet;
82
70
  return __awaiter(this, void 0, void 0, function () {
83
- var acc, seeds, strmEncoded, name, payload, hash;
71
+ var acc, seeds, payload, hash;
84
72
  return __generator(this, function (_b) {
85
73
  switch (_b.label) {
86
74
  case 0:
87
75
  acc = new aptos_1.AptosAccount();
88
76
  seeds = acc.address().hex();
89
- strmEncoded = new TextEncoder().encode("STRM");
90
- name = Buffer.from(strmEncoded).toString("hex");
91
77
  payload = {
92
78
  type: "create",
93
79
  function: "".concat(this.programId, "::protocol::create"),
94
80
  type_arguments: [streamData.tokenId],
95
81
  arguments: [
96
82
  seeds,
97
- streamData.amount,
83
+ streamData.amount.toString(),
98
84
  streamData.period,
99
- streamData.amountPerPeriod,
85
+ streamData.amountPerPeriod.toString(),
100
86
  streamData.start,
101
- streamData.cliffAmount,
87
+ streamData.cliffAmount.toString(),
102
88
  streamData.cancelableBySender,
103
89
  streamData.cancelableByRecipient,
104
90
  streamData.transferableBySender,
105
91
  streamData.transferableByRecipient,
106
92
  streamData.canTopup,
107
- streamData.canPause,
108
- streamData.canUpdateRate,
109
- streamData.automaticWithdrawal,
110
- streamData.withdrawalFrequency,
111
- name,
93
+ streamData.canPause || false,
94
+ streamData.canUpdateRate || false,
95
+ streamData.automaticWithdrawal || false,
96
+ streamData.withdrawalFrequency || 0,
97
+ streamData.name,
112
98
  streamData.recipient,
113
99
  ],
114
100
  };
@@ -121,43 +107,53 @@ var AptosStreamClient = /** @class */ (function (_super) {
121
107
  });
122
108
  };
123
109
  AptosStreamClient.prototype.createMultiple = function (multipleStreamData, _a) {
110
+ var _b;
124
111
  var senderWallet = _a.senderWallet;
125
112
  return __awaiter(this, void 0, void 0, function () {
126
- var payloads, ids, payloads_1, payloads_1_1, payload, hash, e_1_1;
127
- var e_1, _b;
113
+ var payloads, txs, metadatas, metadataToRecipient, errors, i, payload, recipient, hash, e_1, metadataId;
128
114
  return __generator(this, function (_c) {
129
115
  switch (_c.label) {
130
116
  case 0:
131
117
  payloads = this.generateMultiPayloads(multipleStreamData);
132
- ids = [];
118
+ txs = [];
119
+ metadatas = [];
120
+ metadataToRecipient = {};
121
+ errors = [];
122
+ i = 0;
133
123
  _c.label = 1;
134
124
  case 1:
135
- _c.trys.push([1, 6, 7, 8]);
136
- payloads_1 = __values(payloads), payloads_1_1 = payloads_1.next();
125
+ if (!(i < payloads.length)) return [3 /*break*/, 7];
126
+ payload = payloads[i];
127
+ recipient = multipleStreamData.recipients[i];
137
128
  _c.label = 2;
138
129
  case 2:
139
- if (!!payloads_1_1.done) return [3 /*break*/, 5];
140
- payload = payloads_1_1.value;
130
+ _c.trys.push([2, 4, 5, 6]);
141
131
  return [4 /*yield*/, senderWallet.signAndSubmitTransaction(payload)];
142
132
  case 3:
143
133
  hash = (_c.sent()).hash;
144
- ids.push({ txId: hash });
145
- _c.label = 4;
134
+ txs.push(hash);
135
+ return [3 /*break*/, 6];
146
136
  case 4:
147
- payloads_1_1 = payloads_1.next();
148
- return [3 /*break*/, 2];
149
- case 5: return [3 /*break*/, 8];
150
- case 6:
151
- e_1_1 = _c.sent();
152
- e_1 = { error: e_1_1 };
153
- return [3 /*break*/, 8];
154
- case 7:
155
- try {
156
- if (payloads_1_1 && !payloads_1_1.done && (_b = payloads_1.return)) _b.call(payloads_1);
157
- }
158
- finally { if (e_1) throw e_1.error; }
137
+ e_1 = _c.sent();
138
+ errors.push({
139
+ error: (_b = e_1 === null || e_1 === void 0 ? void 0 : e_1.toString()) !== null && _b !== void 0 ? _b : "Unkown error!",
140
+ recipient: recipient.recipient,
141
+ });
142
+ return [3 /*break*/, 6];
143
+ case 5:
144
+ metadataId = payload.arguments[0];
145
+ metadatas.push(metadataId);
146
+ metadataToRecipient[metadataId] = recipient;
159
147
  return [7 /*endfinally*/];
160
- case 8: return [2 /*return*/, ids];
148
+ case 6:
149
+ i++;
150
+ return [3 /*break*/, 1];
151
+ case 7: return [2 /*return*/, {
152
+ txs: txs,
153
+ metadatas: metadatas,
154
+ metadataToRecipient: metadataToRecipient,
155
+ errors: errors,
156
+ }];
161
157
  }
162
158
  });
163
159
  });
@@ -264,34 +260,32 @@ var AptosStreamClient = /** @class */ (function (_super) {
264
260
  return multipleStreamData.recipients.map(function (recipient) {
265
261
  var acc = new aptos_1.AptosAccount(); // Generate random address as seeds for derriving "escrow" account
266
262
  var seeds = acc.address().hex();
267
- var strmEncoded = new TextEncoder().encode("STRM");
268
- var name = Buffer.from(strmEncoded).toString("hex");
269
263
  return {
270
264
  type: "create",
271
265
  function: "".concat(_this.programId, "::protocol::create"),
272
266
  type_arguments: [multipleStreamData.tokenId],
273
267
  arguments: [
274
268
  seeds,
275
- recipient.amount,
269
+ recipient.amount.toString(),
276
270
  multipleStreamData.period,
277
- recipient.amountPerPeriod,
271
+ recipient.amountPerPeriod.toString(),
278
272
  multipleStreamData.start,
279
- recipient.cliffAmount,
273
+ recipient.cliffAmount.toString(),
280
274
  multipleStreamData.cancelableBySender,
281
275
  multipleStreamData.cancelableByRecipient,
282
276
  multipleStreamData.transferableBySender,
283
277
  multipleStreamData.transferableByRecipient,
284
278
  multipleStreamData.canTopup,
285
- multipleStreamData.canPause,
286
- multipleStreamData.canUpdateRate,
287
- multipleStreamData.automaticWithdrawal,
288
- multipleStreamData.withdrawalFrequency,
289
- name,
279
+ multipleStreamData.canPause || false,
280
+ multipleStreamData.canUpdateRate || false,
281
+ multipleStreamData.automaticWithdrawal || false,
282
+ multipleStreamData.withdrawalFrequency || 0,
283
+ recipient.name,
290
284
  recipient.recipient,
291
285
  ],
292
286
  };
293
287
  });
294
288
  };
295
289
  return AptosStreamClient;
296
- }(StreamClient_1.GenericStreamClient));
290
+ }(BaseStreamClient_1.BaseStreamClient));
297
291
  exports.default = AptosStreamClient;
@@ -5,8 +5,8 @@ exports.APTOS_PROGRAM_IDS = void 0;
5
5
  var types_1 = require("../common/types");
6
6
  exports.APTOS_PROGRAM_IDS = (_a = {},
7
7
  _a[types_1.ICluster.Mainnet] = "0x9009d93d52576bf9ac6dc6cf10b870610bcb316342fef6eff80662fbbfce51b0",
8
- _a[types_1.ICluster.Devnet] = "0x1dda724347d7776cb1817054eaf49d03cb6f58dae92c90d62edd5d3b90ba733c",
9
8
  // TODO: Add a correct programID for Test net
10
- _a[types_1.ICluster.Testnet] = "0x1dda724347d7776cb1817054eaf49d03cb6f58dae92c90d62edd5d3b90ba733c",
9
+ _a[types_1.ICluster.Devnet] = "0xc6737de143d91b2f99a7e490d4f8348fdfa3bdd1eb8737a27d0455f8a3625688",
10
+ _a[types_1.ICluster.Testnet] = "0xc6737de143d91b2f99a7e490d4f8348fdfa3bdd1eb8737a27d0455f8a3625688",
11
11
  _a[types_1.ICluster.Local] = "0x9009d93d52576bf9ac6dc6cf10b870610bcb316342fef6eff80662fbbfce51b0",
12
12
  _a);
@@ -1,10 +1,145 @@
1
1
  import { WalletContextState } from "@manahippo/aptos-wallet-adapter";
2
+ import BN from "bn.js";
3
+ import { IRecipient } from "../common/types";
2
4
  export interface ICreateStreamAptosExt {
3
5
  senderWallet: WalletContextState;
4
6
  }
7
+ declare type MetadataId = string;
8
+ export interface CreateMultiError {
9
+ recipient: string;
10
+ error: string;
11
+ }
12
+ export interface IMultiTransactionResult {
13
+ txs: string[];
14
+ metadatas: MetadataId[];
15
+ metadataToRecipient: Record<MetadataId, IRecipient>;
16
+ errors: CreateMultiError[];
17
+ }
5
18
  export interface ITransactionResult {
6
19
  txId: string;
7
20
  }
8
21
  export declare type ITransactionAptosExt = ICreateStreamAptosExt & {
9
22
  tokenId: string;
10
23
  };
24
+ export interface StreamResource {
25
+ amount: string;
26
+ amount_per_period: string;
27
+ canceled_at: string;
28
+ cliff_amount: string;
29
+ closed: boolean;
30
+ contract_signer_cap: {
31
+ account: string;
32
+ };
33
+ created: string;
34
+ current_pause_start: string;
35
+ end: string;
36
+ fees: {
37
+ streamflow_fee: string;
38
+ streamflow_fee_percentage: string;
39
+ streamflow_fee_withdrawn: string;
40
+ };
41
+ funds_unlocked_at_last_rate_change: string;
42
+ last_rate_change_time: string;
43
+ last_withdrawn_at: string;
44
+ meta: {
45
+ automatic_withdrawal: boolean;
46
+ can_topup: boolean;
47
+ can_update_rate: boolean;
48
+ cancelable_by_recipient: boolean;
49
+ cancelable_by_sender: boolean;
50
+ contract_name: string;
51
+ pausable: boolean;
52
+ transferable_by_recipient: boolean;
53
+ transferable_by_sender: boolean;
54
+ withdrawal_frequency: string;
55
+ };
56
+ pause_cumulative: string;
57
+ period: string;
58
+ recipient: string;
59
+ sender: string;
60
+ start: string;
61
+ withdrawn: string;
62
+ }
63
+ export interface Stream {
64
+ magic: number;
65
+ version: number;
66
+ createdAt: number;
67
+ withdrawnAmount: BN;
68
+ canceledAt: number;
69
+ end: number;
70
+ lastWithdrawnAt: number;
71
+ sender: string;
72
+ senderTokens: string;
73
+ recipient: string;
74
+ recipientTokens: string;
75
+ mint: string;
76
+ escrowTokens: string;
77
+ streamflowTreasury: string;
78
+ streamflowTreasuryTokens: string;
79
+ streamflowFeeTotal: BN;
80
+ streamflowFeeWithdrawn: BN;
81
+ streamflowFeePercent: number;
82
+ partnerFeeTotal: BN;
83
+ partnerFeeWithdrawn: BN;
84
+ partnerFeePercent: number;
85
+ partner: string;
86
+ partnerTokens: string;
87
+ start: number;
88
+ depositedAmount: BN;
89
+ period: number;
90
+ amountPerPeriod: BN;
91
+ cliff: number;
92
+ cliffAmount: BN;
93
+ cancelableBySender: boolean;
94
+ cancelableByRecipient: boolean;
95
+ automaticWithdrawal: boolean;
96
+ transferableBySender: boolean;
97
+ transferableByRecipient: boolean;
98
+ canTopup: boolean;
99
+ name: string;
100
+ withdrawalFrequency: number;
101
+ unlocked(currentTimestamp: number, decimals: number): number;
102
+ }
103
+ export declare class Contract implements Stream {
104
+ magic: number;
105
+ version: number;
106
+ createdAt: number;
107
+ withdrawnAmount: BN;
108
+ canceledAt: number;
109
+ end: number;
110
+ lastWithdrawnAt: number;
111
+ sender: string;
112
+ senderTokens: string;
113
+ recipient: string;
114
+ recipientTokens: string;
115
+ mint: string;
116
+ escrowTokens: string;
117
+ streamflowTreasury: string;
118
+ streamflowTreasuryTokens: string;
119
+ streamflowFeeTotal: BN;
120
+ streamflowFeeWithdrawn: BN;
121
+ streamflowFeePercent: number;
122
+ partnerFeeTotal: BN;
123
+ partnerFeeWithdrawn: BN;
124
+ partnerFeePercent: number;
125
+ partner: string;
126
+ partnerTokens: string;
127
+ start: number;
128
+ depositedAmount: BN;
129
+ period: number;
130
+ amountPerPeriod: BN;
131
+ cliff: number;
132
+ cliffAmount: BN;
133
+ cancelableBySender: boolean;
134
+ cancelableByRecipient: boolean;
135
+ automaticWithdrawal: boolean;
136
+ transferableBySender: boolean;
137
+ transferableByRecipient: boolean;
138
+ canTopup: boolean;
139
+ name: string;
140
+ withdrawalFrequency: number;
141
+ constructor(stream: StreamResource, tokenId: string);
142
+ unlocked(currentTimestamp: number, decimals: number): number;
143
+ remaining(decimals: number): number;
144
+ }
145
+ export {};
@@ -1,2 +1,65 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Contract = void 0;
7
+ var bn_js_1 = __importDefault(require("bn.js"));
8
+ var utils_1 = require("../common/utils");
9
+ var Contract = /** @class */ (function () {
10
+ function Contract(stream, tokenId) {
11
+ this.magic = 0;
12
+ this.version = 0;
13
+ this.createdAt = parseInt(stream.created);
14
+ this.withdrawnAmount = new bn_js_1.default(stream.withdrawn);
15
+ this.canceledAt = parseInt(stream.canceled_at);
16
+ this.end = parseInt(stream.end);
17
+ this.lastWithdrawnAt = parseInt(stream.last_withdrawn_at);
18
+ this.sender = stream.sender;
19
+ this.senderTokens = stream.sender;
20
+ this.recipient = stream.recipient;
21
+ this.recipientTokens = stream.recipient;
22
+ this.mint = tokenId;
23
+ this.escrowTokens = "";
24
+ this.streamflowTreasury = "";
25
+ this.streamflowTreasuryTokens = "";
26
+ this.streamflowFeeTotal = new bn_js_1.default(0);
27
+ this.streamflowFeeWithdrawn = new bn_js_1.default(0);
28
+ this.streamflowFeePercent = parseInt(stream.fees.streamflow_fee_percentage) / 10000;
29
+ this.partnerFeeTotal = new bn_js_1.default(0);
30
+ this.partnerFeeWithdrawn = new bn_js_1.default(0);
31
+ this.partnerFeePercent = 0;
32
+ this.partner = "";
33
+ this.partnerTokens = "";
34
+ this.start = parseInt(stream.start);
35
+ this.depositedAmount = new bn_js_1.default(stream.amount);
36
+ this.period = parseInt(stream.period);
37
+ this.amountPerPeriod = new bn_js_1.default(stream.amount_per_period);
38
+ this.cliff = parseInt(stream.start);
39
+ this.cliffAmount = new bn_js_1.default(stream.cliff_amount);
40
+ this.cancelableBySender = stream.meta.cancelable_by_sender;
41
+ this.cancelableByRecipient = stream.meta.cancelable_by_recipient;
42
+ this.automaticWithdrawal = stream.meta.automatic_withdrawal;
43
+ this.transferableBySender = stream.meta.transferable_by_sender;
44
+ this.transferableByRecipient = stream.meta.transferable_by_recipient;
45
+ this.canTopup = stream.meta.can_topup;
46
+ var name = stream.meta.contract_name.replace("0x", "");
47
+ this.name = Buffer.from(name, "hex").toString("utf8");
48
+ this.withdrawalFrequency = parseInt(stream.meta.withdrawal_frequency);
49
+ }
50
+ Contract.prototype.unlocked = function (currentTimestamp, decimals) {
51
+ var deposited = (0, utils_1.getNumberFromBN)(this.depositedAmount, decimals);
52
+ if (currentTimestamp < this.cliff)
53
+ return 0;
54
+ if (currentTimestamp > this.end)
55
+ return deposited;
56
+ var streamedBN = this.cliffAmount.add(new bn_js_1.default(Math.floor((currentTimestamp - this.cliff) / this.period)).mul(this.amountPerPeriod));
57
+ var streamed = (0, utils_1.getNumberFromBN)(streamedBN, decimals);
58
+ return streamed < deposited ? streamed : deposited;
59
+ };
60
+ Contract.prototype.remaining = function (decimals) {
61
+ return (0, utils_1.getNumberFromBN)(this.depositedAmount.sub(this.withdrawnAmount), decimals);
62
+ };
63
+ return Contract;
64
+ }());
65
+ exports.Contract = Contract;
@@ -1,5 +1,5 @@
1
1
  import { ICreateStreamData, ICreateMultipleStreamData, IWithdrawData, ICancelData, ITransferData, ITopUpData, IGetOneData } from "./types";
2
- export declare abstract class GenericStreamClient {
2
+ export declare abstract class BaseStreamClient {
3
3
  abstract create(streamData: ICreateStreamData, ...chainSpecificParams: any[]): Promise<any>;
4
4
  abstract createMultiple(multipleStreamData: ICreateMultipleStreamData, ...chainSpecificParams: any[]): Promise<any>;
5
5
  abstract withdraw(withdrawData: IWithdrawData, ...chainSpecificParams: any[]): Promise<any>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseStreamClient = void 0;
4
+ var BaseStreamClient = /** @class */ (function () {
5
+ function BaseStreamClient() {
6
+ }
7
+ return BaseStreamClient;
8
+ }());
9
+ exports.BaseStreamClient = BaseStreamClient;
@@ -0,0 +1,34 @@
1
+ import { Commitment, ConnectionConfig } from "@solana/web3.js";
2
+ import SolanaStreamClient from "../solana/StreamClient";
3
+ import AptosStreamClient from "../aptos/StreamClient";
4
+ import { BaseStreamClient } from "./BaseStreamClient";
5
+ import { ICancelData, IChain, ICluster, ICreateMultipleStreamData, ICreateStreamData, IGetOneData, ITopUpData, ITransferData, IWithdrawData } from "./types";
6
+ import { ICreateStreamSolanaExt, IInteractStreamSolanaExt, ITopUpStreamSolanaExt } from "../solana";
7
+ import { ICreateStreamAptosExt, ITransactionAptosExt } from "../aptos";
8
+ export interface SolanaStreamClientOptions {
9
+ chain: IChain.Solana;
10
+ clusterUrl: string;
11
+ commitment?: Commitment | ConnectionConfig;
12
+ cluster?: ICluster;
13
+ programId?: string;
14
+ }
15
+ export interface AptosStreamClientOptions {
16
+ chain: IChain.Aptos;
17
+ cluster?: ICluster;
18
+ programId?: string;
19
+ maxGas?: string;
20
+ }
21
+ declare type GenericStreamClientOptions = SolanaStreamClientOptions | AptosStreamClientOptions;
22
+ export default class GenericStreamClient extends BaseStreamClient {
23
+ nativeStreamClient: SolanaStreamClient | AptosStreamClient;
24
+ chain: IChain;
25
+ constructor(options: GenericStreamClientOptions);
26
+ create(streamData: ICreateStreamData, chainSpecificParams: ICreateStreamAptosExt | ICreateStreamSolanaExt): Promise<import("../solana").CreateResponse> | Promise<import("../aptos").ITransactionResult>;
27
+ createMultiple(multipleStreamData: ICreateMultipleStreamData, chainSpecificParams: ICreateStreamAptosExt | ICreateStreamSolanaExt): Promise<import("../solana").CreateMultiResponse> | Promise<import("../aptos").IMultiTransactionResult>;
28
+ withdraw(withdrawData: IWithdrawData, chainSpecificParams: ITransactionAptosExt | IInteractStreamSolanaExt): Promise<import("../solana").TxResponse> | Promise<import("../aptos").ITransactionResult>;
29
+ cancel(cancelData: ICancelData, chainSpecificParams: ITransactionAptosExt | IInteractStreamSolanaExt): Promise<any>;
30
+ transfer(transferData: ITransferData, chainSpecificParams: ITransactionAptosExt | IInteractStreamSolanaExt): Promise<any>;
31
+ topup(topupData: ITopUpData, chainSpecificParams: ITransactionAptosExt | ITopUpStreamSolanaExt): Promise<any>;
32
+ getOne(getOneData: IGetOneData): Promise<any>;
33
+ }
34
+ export {};
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ var StreamClient_1 = __importDefault(require("../solana/StreamClient"));
22
+ var StreamClient_2 = __importDefault(require("../aptos/StreamClient"));
23
+ var BaseStreamClient_1 = require("./BaseStreamClient");
24
+ var types_1 = require("./types");
25
+ var GenericStreamClient = /** @class */ (function (_super) {
26
+ __extends(GenericStreamClient, _super);
27
+ function GenericStreamClient(options) {
28
+ var _this = _super.call(this) || this;
29
+ _this.chain = options.chain;
30
+ if (options.chain === types_1.IChain.Solana) {
31
+ _this.nativeStreamClient = new StreamClient_1.default(options.clusterUrl, options.cluster, options.commitment, options.programId);
32
+ }
33
+ else {
34
+ _this.nativeStreamClient = new StreamClient_2.default(options.cluster, options.maxGas, options.programId);
35
+ }
36
+ return _this;
37
+ }
38
+ GenericStreamClient.prototype.create = function (streamData, chainSpecificParams) {
39
+ if (this.nativeStreamClient instanceof StreamClient_1.default) {
40
+ var params = chainSpecificParams;
41
+ return this.nativeStreamClient.create(streamData, params);
42
+ }
43
+ else {
44
+ var params = chainSpecificParams;
45
+ return this.nativeStreamClient.create(streamData, params);
46
+ }
47
+ };
48
+ GenericStreamClient.prototype.createMultiple = function (multipleStreamData, chainSpecificParams) {
49
+ if (this.nativeStreamClient instanceof StreamClient_1.default) {
50
+ var params = chainSpecificParams;
51
+ return this.nativeStreamClient.createMultiple(multipleStreamData, params);
52
+ }
53
+ else {
54
+ var params = chainSpecificParams;
55
+ return this.nativeStreamClient.createMultiple(multipleStreamData, params);
56
+ }
57
+ };
58
+ GenericStreamClient.prototype.withdraw = function (withdrawData, chainSpecificParams) {
59
+ if (this.nativeStreamClient instanceof StreamClient_1.default) {
60
+ var params = chainSpecificParams;
61
+ return this.nativeStreamClient.withdraw(withdrawData, params);
62
+ }
63
+ else {
64
+ var params = chainSpecificParams;
65
+ return this.nativeStreamClient.withdraw(withdrawData, params);
66
+ }
67
+ };
68
+ GenericStreamClient.prototype.cancel = function (cancelData, chainSpecificParams) {
69
+ if (this.nativeStreamClient instanceof StreamClient_1.default) {
70
+ var params = chainSpecificParams;
71
+ return this.nativeStreamClient.cancel(cancelData, params);
72
+ }
73
+ else {
74
+ var params = chainSpecificParams;
75
+ return this.nativeStreamClient.cancel(cancelData, params);
76
+ }
77
+ };
78
+ GenericStreamClient.prototype.transfer = function (transferData, chainSpecificParams) {
79
+ if (this.nativeStreamClient instanceof StreamClient_1.default) {
80
+ var params = chainSpecificParams;
81
+ return this.nativeStreamClient.transfer(transferData, params);
82
+ }
83
+ else {
84
+ var params = chainSpecificParams;
85
+ return this.nativeStreamClient.transfer(transferData, params);
86
+ }
87
+ };
88
+ GenericStreamClient.prototype.topup = function (topupData, chainSpecificParams) {
89
+ if (this.nativeStreamClient instanceof StreamClient_1.default) {
90
+ var params = chainSpecificParams;
91
+ return this.nativeStreamClient.topup(topupData, params);
92
+ }
93
+ else {
94
+ var params = chainSpecificParams;
95
+ return this.nativeStreamClient.topup(topupData, params);
96
+ }
97
+ };
98
+ GenericStreamClient.prototype.getOne = function (getOneData) {
99
+ return this.nativeStreamClient.getOne(getOneData);
100
+ };
101
+ return GenericStreamClient;
102
+ }(BaseStreamClient_1.BaseStreamClient));
103
+ exports.default = GenericStreamClient;
@@ -59,3 +59,7 @@ export declare enum StreamType {
59
59
  Vesting = "vesting",
60
60
  All = "all"
61
61
  }
62
+ export declare enum IChain {
63
+ Solana = "Solana",
64
+ Aptos = "Aptos"
65
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StreamType = exports.StreamDirection = exports.ICluster = void 0;
3
+ exports.IChain = exports.StreamType = exports.StreamDirection = exports.ICluster = void 0;
4
4
  // Utility types
5
5
  var ICluster;
6
6
  (function (ICluster) {
@@ -21,3 +21,8 @@ var StreamType;
21
21
  StreamType["Vesting"] = "vesting";
22
22
  StreamType["All"] = "all";
23
23
  })(StreamType = exports.StreamType || (exports.StreamType = {}));
24
+ var IChain;
25
+ (function (IChain) {
26
+ IChain["Solana"] = "Solana";
27
+ IChain["Aptos"] = "Aptos";
28
+ })(IChain = exports.IChain || (exports.IChain = {}));
package/dist/index.d.ts CHANGED
@@ -2,3 +2,4 @@ export * as StreamflowSolana from "./solana";
2
2
  export * as StreamflowAptos from "./aptos";
3
3
  export * as Types from "./common/types";
4
4
  export * from "./common/utils";
5
+ export { default as GenericStreamClient } from "./common/GenericStreamClient";
package/dist/index.js CHANGED
@@ -25,9 +25,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
26
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
27
  };
28
+ var __importDefault = (this && this.__importDefault) || function (mod) {
29
+ return (mod && mod.__esModule) ? mod : { "default": mod };
30
+ };
28
31
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.Types = exports.StreamflowAptos = exports.StreamflowSolana = void 0;
32
+ exports.GenericStreamClient = exports.Types = exports.StreamflowAptos = exports.StreamflowSolana = void 0;
30
33
  exports.StreamflowSolana = __importStar(require("./solana"));
31
34
  exports.StreamflowAptos = __importStar(require("./aptos"));
32
35
  exports.Types = __importStar(require("./common/types"));
33
36
  __exportStar(require("./common/utils"), exports);
37
+ var GenericStreamClient_1 = require("./common/GenericStreamClient");
38
+ Object.defineProperty(exports, "GenericStreamClient", { enumerable: true, get: function () { return __importDefault(GenericStreamClient_1).default; } });
@@ -1,8 +1,8 @@
1
1
  import { Connection, Commitment, ConnectionConfig } from "@solana/web3.js";
2
2
  import { Stream as StreamData, GetAllParams, CreateResponse, CreateMultiResponse, TxResponse, ICreateStreamSolanaExt, IInteractStreamSolanaExt, ITopUpStreamSolanaExt } from "./types";
3
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 {
4
+ import { BaseStreamClient } from "../common/BaseStreamClient";
5
+ export default class SolanaStreamClient extends BaseStreamClient {
6
6
  private connection;
7
7
  private programId;
8
8
  private commitment;
@@ -112,7 +112,7 @@ var utils_1 = require("./utils");
112
112
  var constants_1 = require("./constants");
113
113
  var instructions_1 = require("./instructions");
114
114
  var types_2 = require("../common/types");
115
- var StreamClient_1 = require("../common/StreamClient");
115
+ var BaseStreamClient_1 = require("../common/BaseStreamClient");
116
116
  var METADATA_ACC_SIZE = 1104;
117
117
  var SolanaStreamClient = /** @class */ (function (_super) {
118
118
  __extends(SolanaStreamClient, _super);
@@ -949,5 +949,5 @@ var SolanaStreamClient = /** @class */ (function (_super) {
949
949
  });
950
950
  };
951
951
  return SolanaStreamClient;
952
- }(StreamClient_1.GenericStreamClient));
952
+ }(BaseStreamClient_1.BaseStreamClient));
953
953
  exports.default = SolanaStreamClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamflow/stream",
3
- "version": "4.0.0-Alpha.1",
3
+ "version": "4.0.0-Alpha.2",
4
4
  "description": "JavaScript SDK to interact with Streamflow protocol.",
5
5
  "main": "dist/index.js",
6
6
  "homepage": "https://github.com/streamflow-finance/js-sdk/",
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GenericStreamClient = void 0;
4
- var GenericStreamClient = /** @class */ (function () {
5
- function GenericStreamClient() {
6
- }
7
- return GenericStreamClient;
8
- }());
9
- exports.GenericStreamClient = GenericStreamClient;