@streamflow/stream 6.3.8 → 7.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 (121) hide show
  1. package/README.md +33 -1
  2. package/dist/{__tests__ → cjs/__tests__}/aptos/streamClient.spec.js +22 -21
  3. package/dist/cjs/__tests__/common/GenericStreamClient.spec.js +45 -0
  4. package/dist/{aptos → cjs/aptos}/StreamClient.js +20 -20
  5. package/dist/cjs/aptos/constants.js +28 -0
  6. package/dist/{aptos → cjs/aptos}/index.js +3 -3
  7. package/dist/{aptos → cjs/aptos}/types.js +12 -11
  8. package/dist/{aptos → cjs/aptos}/utils.js +2 -2
  9. package/dist/{common → cjs/common}/GenericStreamClient.js +19 -19
  10. package/dist/{common → cjs/common}/contractUtils.js +4 -4
  11. package/dist/{common → cjs/common}/utils.js +4 -6
  12. package/dist/{evm → cjs/evm}/StreamClient.js +29 -29
  13. package/dist/cjs/evm/constants.js +39 -0
  14. package/dist/{evm → cjs/evm}/index.js +8 -8
  15. package/dist/{evm → cjs/evm}/types.js +5 -5
  16. package/dist/{evm → cjs/evm}/utils.js +2 -2
  17. package/dist/{solana → cjs/solana}/StreamClient.js +73 -66
  18. package/dist/cjs/solana/constants.js +60 -0
  19. package/dist/cjs/solana/index.js +39 -0
  20. package/dist/{solana → cjs/solana}/instructions.js +20 -12
  21. package/dist/{solana → cjs/solana}/layout.js +8 -2
  22. package/dist/{solana → cjs/solana}/types.js +5 -5
  23. package/dist/{solana → cjs/solana}/utils.js +6 -6
  24. package/dist/{sui → cjs/sui}/StreamClient.js +25 -25
  25. package/dist/cjs/sui/constants.js +43 -0
  26. package/dist/{sui → cjs/sui}/index.js +5 -5
  27. package/dist/{sui → cjs/sui}/types.js +5 -5
  28. package/dist/{sui → cjs/sui}/utils.js +3 -3
  29. package/dist/esm/__tests__/aptos/streamClient.spec.js +106 -0
  30. package/dist/esm/__tests__/common/GenericStreamClient.spec.js +40 -0
  31. package/dist/{aptos → esm/aptos}/StreamClient.d.ts +3 -3
  32. package/dist/esm/aptos/StreamClient.js +226 -0
  33. package/dist/{aptos → esm/aptos}/constants.d.ts +1 -1
  34. package/dist/esm/aptos/constants.js +24 -0
  35. package/dist/{aptos → esm/aptos}/index.d.ts +1 -1
  36. package/dist/{sui/index.d.ts → esm/aptos/index.js} +1 -1
  37. package/dist/{aptos → esm/aptos}/types.d.ts +1 -1
  38. package/dist/esm/aptos/types.js +105 -0
  39. package/dist/esm/aptos/utils.js +30 -0
  40. package/dist/esm/aptos/wallet.js +33 -0
  41. package/dist/{common → esm/common}/BaseStreamClient.d.ts +1 -1
  42. package/dist/esm/common/BaseStreamClient.js +19 -0
  43. package/dist/{common → esm/common}/GenericStreamClient.d.ts +2 -2
  44. package/dist/esm/common/GenericStreamClient.js +101 -0
  45. package/dist/esm/common/constants.js +3 -0
  46. package/dist/{common → esm/common}/contractUtils.d.ts +1 -1
  47. package/dist/esm/common/contractUtils.js +42 -0
  48. package/dist/esm/common/types.js +106 -0
  49. package/dist/{common → esm/common}/utils.d.ts +0 -1
  50. package/dist/esm/common/utils.js +59 -0
  51. package/dist/{evm → esm/evm}/StreamClient.d.ts +2 -2
  52. package/dist/esm/evm/StreamClient.js +237 -0
  53. package/dist/esm/evm/abi.js +1255 -0
  54. package/dist/{evm → esm/evm}/constants.d.ts +1 -1
  55. package/dist/esm/evm/constants.js +35 -0
  56. package/dist/esm/evm/ercAbi.js +222 -0
  57. package/dist/esm/evm/index.d.ts +5 -0
  58. package/dist/esm/evm/index.js +5 -0
  59. package/dist/{evm → esm/evm}/types.d.ts +1 -1
  60. package/dist/esm/evm/types.js +102 -0
  61. package/dist/esm/evm/utils.js +8 -0
  62. package/dist/esm/index.js +9 -0
  63. package/dist/{solana → esm/solana}/StreamClient.d.ts +6 -6
  64. package/dist/esm/solana/StreamClient.js +695 -0
  65. package/dist/{solana → esm/solana}/constants.d.ts +2 -0
  66. package/dist/esm/solana/constants.js +56 -0
  67. package/dist/esm/solana/index.d.ts +6 -0
  68. package/dist/esm/solana/index.js +6 -0
  69. package/dist/esm/solana/instructionTypes.js +1 -0
  70. package/dist/{solana → esm/solana}/instructions.d.ts +5 -1
  71. package/dist/esm/solana/instructions.js +256 -0
  72. package/dist/{solana → esm/solana}/layout.d.ts +2 -1
  73. package/dist/esm/solana/layout.js +155 -0
  74. package/dist/esm/solana/timelockIDL.js +420 -0
  75. package/dist/{solana → esm/solana}/types.d.ts +2 -1
  76. package/dist/esm/solana/types.js +101 -0
  77. package/dist/{solana → esm/solana}/utils.d.ts +2 -1
  78. package/dist/esm/solana/utils.js +117 -0
  79. package/dist/{sui → esm/sui}/StreamClient.d.ts +3 -3
  80. package/dist/esm/sui/StreamClient.js +403 -0
  81. package/dist/{sui → esm/sui}/constants.d.ts +1 -1
  82. package/dist/esm/sui/constants.js +39 -0
  83. package/dist/esm/sui/index.d.ts +4 -0
  84. package/dist/esm/sui/index.js +4 -0
  85. package/dist/{sui → esm/sui}/types.d.ts +1 -1
  86. package/dist/esm/sui/types.js +104 -0
  87. package/dist/{sui → esm/sui}/utils.d.ts +1 -1
  88. package/dist/esm/sui/utils.js +23 -0
  89. package/dist/{sui → esm/sui}/wallet.d.ts +1 -1
  90. package/dist/esm/sui/wallet.js +38 -0
  91. package/package.json +36 -33
  92. package/dist/__tests__/common/GenericStreamClient.spec.js +0 -44
  93. package/dist/aptos/constants.js +0 -28
  94. package/dist/evm/constants.js +0 -39
  95. package/dist/evm/index.d.ts +0 -5
  96. package/dist/solana/constants.js +0 -59
  97. package/dist/solana/index.d.ts +0 -7
  98. package/dist/solana/index.js +0 -43
  99. package/dist/sui/constants.js +0 -43
  100. /package/dist/{aptos → cjs/aptos}/wallet.js +0 -0
  101. /package/dist/{common → cjs/common}/BaseStreamClient.js +0 -0
  102. /package/dist/{common → cjs/common}/constants.js +0 -0
  103. /package/dist/{common → cjs/common}/types.js +0 -0
  104. /package/dist/{evm → cjs/evm}/abi.js +0 -0
  105. /package/dist/{evm → cjs/evm}/ercAbi.js +0 -0
  106. /package/dist/{index.js → cjs/index.js} +0 -0
  107. /package/dist/{solana → cjs/solana}/instructionTypes.js +0 -0
  108. /package/dist/{solana → cjs/solana}/timelockIDL.js +0 -0
  109. /package/dist/{sui → cjs/sui}/wallet.js +0 -0
  110. /package/dist/{__tests__ → esm/__tests__}/aptos/streamClient.spec.d.ts +0 -0
  111. /package/dist/{__tests__ → esm/__tests__}/common/GenericStreamClient.spec.d.ts +0 -0
  112. /package/dist/{aptos → esm/aptos}/utils.d.ts +0 -0
  113. /package/dist/{aptos → esm/aptos}/wallet.d.ts +0 -0
  114. /package/dist/{common → esm/common}/constants.d.ts +0 -0
  115. /package/dist/{common → esm/common}/types.d.ts +0 -0
  116. /package/dist/{evm → esm/evm}/abi.d.ts +0 -0
  117. /package/dist/{evm → esm/evm}/ercAbi.d.ts +0 -0
  118. /package/dist/{evm → esm/evm}/utils.d.ts +0 -0
  119. /package/dist/{index.d.ts → esm/index.d.ts} +0 -0
  120. /package/dist/{solana → esm/solana}/instructionTypes.d.ts +0 -0
  121. /package/dist/{solana → esm/solana}/timelockIDL.d.ts +0 -0
package/README.md CHANGED
@@ -150,6 +150,7 @@ const createStreamParams: Types.ICreateStreamData = {
150
150
  amountPerPeriod: getBN(5, 9), // Release rate: how many tokens are unlocked per each period.
151
151
  name: "Transfer to Jane Doe.", // The stream name or subject.
152
152
  canTopup: false, // setting to FALSE will effectively create a vesting contract.
153
+ canUpdateRate: false, // settings to TRUE allows sender to update amountPerPeriod
153
154
  cancelableBySender: true, // Whether or not sender can cancel the stream.
154
155
  cancelableByRecipient: false, // Whether or not recipient can cancel the stream.
155
156
  transferableBySender: true, // Whether or not sender can transfer the stream.
@@ -161,7 +162,7 @@ const createStreamParams: Types.ICreateStreamData = {
161
162
 
162
163
  const solanaParams = {
163
164
  sender: wallet, // SignerWalletAdapter or Keypair of Sender account
164
- isNative: // [optional] [WILL CREATE A wSOL STREAM] Wether Stream or Vesting should be paid with Solana native token or not
165
+ isNative: false // [optional] [WILL CREATE A wSOL STREAM] Wether Stream or Vesting should be paid with Solana native token or not
165
166
  };
166
167
 
167
168
  const aptosParams = {
@@ -371,6 +372,37 @@ try {
371
372
  }
372
373
  ```
373
374
 
375
+ ## Update a stream
376
+
377
+ ```javascript
378
+ const updateStreamParams: Types.IUpdateData = {
379
+ id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA", // Identifier of a stream to update.
380
+ enableAutomaticWithdrawal: true, // [optional], allows to enable AW if it wasn't, disable is not possible
381
+ withdrawFrequency: 60, // [optional], allows to update withdrawal frequency, may result in additional AW fees
382
+ amountPerPeriod: getBN(10, 9), // [optional], allows to update release amount effective on next unlock
383
+ }
384
+
385
+ const solanaParams = {
386
+ invoker: wallet, // SignerWalletAdapter or Keypair signing the transaction
387
+ };
388
+
389
+ const aptosParams = {
390
+ senderWallet: wallet, // AptosWalletAdapter Wallet of wallet signing the transaction
391
+ };
392
+
393
+ const suiParams = {
394
+ senderWallet: wallet, // WalletContextState | Keypair
395
+ };
396
+
397
+ const ethereumParams = undefined;
398
+
399
+ try {
400
+ const { ixs, tx } = await client.update(updateStreamParams, solanaParams);
401
+ } catch (exception) {
402
+ // handle exception
403
+ }
404
+ ```
405
+
374
406
  ## Get one stream by its ID
375
407
 
376
408
  ```javascript
@@ -51,35 +51,36 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
51
51
  };
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
53
  var bn_js_1 = require("bn.js");
54
- var StreamClient_1 = __importDefault(require("../../aptos/StreamClient"));
55
- var types_1 = require("../../common/types");
56
- describe("AptosStreamClient", function () {
57
- describe("init", function () {
58
- it("should successfully create AptosStreamInstance", function () {
59
- var instance = new StreamClient_1.default(types_1.ICluster.Devnet);
60
- expect(instance).toBeInstanceOf(StreamClient_1.default);
54
+ var vitest_1 = require("vitest");
55
+ var StreamClient_js_1 = __importDefault(require("../../aptos/StreamClient.js"));
56
+ var types_js_1 = require("../../common/types.js");
57
+ (0, vitest_1.describe)("AptosStreamClient", function () {
58
+ (0, vitest_1.describe)("init", function () {
59
+ (0, vitest_1.test)("should successfully create AptosStreamInstance", function () {
60
+ var instance = new StreamClient_js_1.default(types_js_1.ICluster.Devnet);
61
+ (0, vitest_1.expect)(instance).toBeInstanceOf(StreamClient_js_1.default);
61
62
  });
62
- it("should correctly set passed params", function () {
63
+ (0, vitest_1.test)("should correctly set passed params", function () {
63
64
  var pid = "PID";
64
65
  var gas = "30";
65
- var instance = new StreamClient_1.default("https://cluster", types_1.ICluster.Devnet, gas, pid);
66
- expect(instance.getMaxGas()).toEqual({ max_gas_amount: gas });
67
- expect(instance.getProgramId()).toBe(pid);
66
+ var instance = new StreamClient_js_1.default("https://cluster", types_js_1.ICluster.Devnet, gas, pid);
67
+ (0, vitest_1.expect)(instance.getMaxGas()).toEqual({ max_gas_amount: gas });
68
+ (0, vitest_1.expect)(instance.getProgramId()).toBe(pid);
68
69
  });
69
70
  });
70
- describe("create", function () {
71
+ (0, vitest_1.describe)("create", function () {
71
72
  var pid = "PID";
72
73
  var gas = "30";
73
- var instance = new StreamClient_1.default("https://cluster", types_1.ICluster.Devnet, gas, pid);
74
- beforeEach(function () {
75
- instance = new StreamClient_1.default("https://cluster", types_1.ICluster.Devnet, gas, pid);
74
+ var instance = new StreamClient_js_1.default("https://cluster", types_js_1.ICluster.Devnet, gas, pid);
75
+ (0, vitest_1.beforeEach)(function () {
76
+ instance = new StreamClient_js_1.default("https://cluster", types_js_1.ICluster.Devnet, gas, pid);
76
77
  });
77
- test("should create a stream with passed parameters", function () { return __awaiter(void 0, void 0, void 0, function () {
78
+ (0, vitest_1.test)("should create a stream with passed parameters", function () { return __awaiter(void 0, void 0, void 0, function () {
78
79
  var mockSigner, mockWallet, mockRecipient, mockData, mockReturn, result, callParam, args;
79
80
  return __generator(this, function (_a) {
80
81
  switch (_a.label) {
81
82
  case 0:
82
- mockSigner = jest.fn();
83
+ mockSigner = vitest_1.vi.fn();
83
84
  mockWallet = {
84
85
  signAndSubmitTransaction: mockSigner,
85
86
  account: { address: "" },
@@ -112,12 +113,12 @@ describe("AptosStreamClient", function () {
112
113
  case 1:
113
114
  result = _a.sent();
114
115
  // Assert
115
- expect(mockSigner).toHaveBeenCalledTimes(1);
116
+ (0, vitest_1.expect)(mockSigner).toHaveBeenCalledTimes(1);
116
117
  callParam = mockSigner.mock.calls[0][0];
117
118
  args = callParam.arguments;
118
119
  delete callParam.arguments;
119
120
  args.shift();
120
- expect(args).toEqual([
121
+ (0, vitest_1.expect)(args).toEqual([
121
122
  mockRecipient.amount.toString(),
122
123
  100,
123
124
  mockRecipient.amountPerPeriod.toString(),
@@ -135,12 +136,12 @@ describe("AptosStreamClient", function () {
135
136
  "test name",
136
137
  "0xtest",
137
138
  ]);
138
- expect(callParam).toEqual({
139
+ (0, vitest_1.expect)(callParam).toEqual({
139
140
  function: "PID::protocol::create",
140
141
  type: "create",
141
142
  type_arguments: ["0xtest::token::Token"],
142
143
  });
143
- expect(result.txId).toEqual(mockReturn);
144
+ (0, vitest_1.expect)(result.txId).toEqual(mockReturn);
144
145
  return [2 /*return*/];
145
146
  }
146
147
  });
@@ -0,0 +1,45 @@
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
+ var ethers_1 = require("ethers");
7
+ var vitest_1 = require("vitest");
8
+ var index_js_1 = require("../../index.js");
9
+ var GenericStreamClient_js_1 = __importDefault(require("../../common/GenericStreamClient.js"));
10
+ var types_js_1 = require("../../common/types.js");
11
+ (0, vitest_1.describe)("GenericStreamClient", function () {
12
+ vitest_1.describe.each([
13
+ {
14
+ chain: types_js_1.IChain.Aptos,
15
+ cluster: types_js_1.ICluster.Devnet,
16
+ clusterUrl: "https://cluster",
17
+ expected: index_js_1.StreamflowAptos.AptosStreamClient,
18
+ },
19
+ {
20
+ chain: types_js_1.IChain.Solana,
21
+ cluster: types_js_1.ICluster.Devnet,
22
+ clusterUrl: "https://cluster",
23
+ expected: index_js_1.StreamflowSolana.SolanaStreamClient,
24
+ },
25
+ {
26
+ chain: types_js_1.IChain.Ethereum,
27
+ cluster: types_js_1.ICluster.Devnet,
28
+ clusterUrl: "https://cluster",
29
+ signer: ethers_1.Wallet.createRandom(),
30
+ expected: index_js_1.StreamflowEVM.EvmStreamClient,
31
+ },
32
+ {
33
+ chain: types_js_1.IChain.Sui,
34
+ cluster: types_js_1.ICluster.Devnet,
35
+ clusterUrl: "https://cluster",
36
+ expected: index_js_1.StreamflowSui.SuiStreamClient,
37
+ },
38
+ ])(".init($chain)", function (config) {
39
+ (0, vitest_1.test)("should successfully create GenericStreamClient instance", function () {
40
+ var instance = new GenericStreamClient_js_1.default(config);
41
+ (0, vitest_1.expect)(instance).toBeInstanceOf(GenericStreamClient_js_1.default);
42
+ (0, vitest_1.expect)(instance.nativeStreamClient).toBeInstanceOf(config.expected);
43
+ });
44
+ });
45
+ });
@@ -79,20 +79,20 @@ var __read = (this && this.__read) || function (o, n) {
79
79
  };
80
80
  Object.defineProperty(exports, "__esModule", { value: true });
81
81
  var aptos_1 = require("aptos");
82
- var BaseStreamClient_1 = require("../common/BaseStreamClient");
83
- var types_1 = require("../common/types");
84
- var constants_1 = require("./constants");
85
- var types_2 = require("./types");
86
- var wallet_1 = require("./wallet");
87
- var utils_1 = require("./utils");
88
- var constants_2 = require("../common/constants");
82
+ var BaseStreamClient_js_1 = require("../common/BaseStreamClient.js");
83
+ var types_js_1 = require("../common/types.js");
84
+ var constants_js_1 = require("./constants.js");
85
+ var types_js_2 = require("./types.js");
86
+ var wallet_js_1 = require("./wallet.js");
87
+ var utils_js_1 = require("./utils.js");
88
+ var constants_js_2 = require("../common/constants.js");
89
89
  var AptosStreamClient = /** @class */ (function (_super) {
90
90
  __extends(AptosStreamClient, _super);
91
91
  function AptosStreamClient(clusterUrl, cluster, maxGas, programId) {
92
- if (cluster === void 0) { cluster = types_1.ICluster.Mainnet; }
92
+ if (cluster === void 0) { cluster = types_js_1.ICluster.Mainnet; }
93
93
  if (maxGas === void 0) { maxGas = "10000"; }
94
94
  var _this = _super.call(this) || this;
95
- _this.programId = programId ? programId : constants_1.APTOS_PROGRAM_IDS[cluster];
95
+ _this.programId = programId ? programId : constants_js_1.APTOS_PROGRAM_IDS[cluster];
96
96
  _this.maxGas = maxGas;
97
97
  _this.client = new aptos_1.AptosClient(clusterUrl);
98
98
  return _this;
@@ -107,7 +107,7 @@ var AptosStreamClient = /** @class */ (function (_super) {
107
107
  return __generator(this, function (_c) {
108
108
  switch (_c.label) {
109
109
  case 0:
110
- wallet = new wallet_1.AptosWalletWrapper(senderWallet, this.client);
110
+ wallet = new wallet_js_1.AptosWalletWrapper(senderWallet, this.client);
111
111
  _b = __read(this.generateMultiPayloads(__assign(__assign({}, streamData), { recipients: [__assign({}, streamData)] }), wallet)[0], 2), metadataId = _b[0], payload = _b[1];
112
112
  return [4 /*yield*/, wallet.signAndSubmitTransaction(payload)];
113
113
  case 1:
@@ -128,7 +128,7 @@ var AptosStreamClient = /** @class */ (function (_super) {
128
128
  return __generator(this, function (_d) {
129
129
  switch (_d.label) {
130
130
  case 0:
131
- wallet = new wallet_1.AptosWalletWrapper(senderWallet, this.client);
131
+ wallet = new wallet_js_1.AptosWalletWrapper(senderWallet, this.client);
132
132
  payloads = this.generateMultiPayloads(multipleStreamData, wallet);
133
133
  txs = [];
134
134
  metadatas = [];
@@ -176,7 +176,7 @@ var AptosStreamClient = /** @class */ (function (_super) {
176
176
  * Attempts withdrawing from the specified stream.
177
177
  */
178
178
  AptosStreamClient.prototype.withdraw = function (_a, _b) {
179
- var id = _a.id, _c = _a.amount, amount = _c === void 0 ? constants_2.WITHDRAW_AVAILABLE_AMOUNT : _c;
179
+ var id = _a.id, _c = _a.amount, amount = _c === void 0 ? constants_js_2.WITHDRAW_AVAILABLE_AMOUNT : _c;
180
180
  var senderWallet = _b.senderWallet, tokenId = _b.tokenId;
181
181
  return __awaiter(this, void 0, void 0, function () {
182
182
  var payload, wallet, hash;
@@ -189,7 +189,7 @@ var AptosStreamClient = /** @class */ (function (_super) {
189
189
  type_arguments: [tokenId],
190
190
  arguments: [id, amount.toString()],
191
191
  };
192
- wallet = new wallet_1.AptosWalletWrapper(senderWallet, this.client);
192
+ wallet = new wallet_js_1.AptosWalletWrapper(senderWallet, this.client);
193
193
  return [4 /*yield*/, wallet.signAndSubmitTransaction(payload)];
194
194
  case 1:
195
195
  hash = _d.sent();
@@ -214,7 +214,7 @@ var AptosStreamClient = /** @class */ (function (_super) {
214
214
  type_arguments: [tokenId],
215
215
  arguments: [cancelData.id],
216
216
  };
217
- wallet = new wallet_1.AptosWalletWrapper(senderWallet, this.client);
217
+ wallet = new wallet_js_1.AptosWalletWrapper(senderWallet, this.client);
218
218
  return [4 /*yield*/, wallet.signAndSubmitTransaction(payload)];
219
219
  case 1:
220
220
  hash = _b.sent();
@@ -239,7 +239,7 @@ var AptosStreamClient = /** @class */ (function (_super) {
239
239
  type_arguments: [tokenId],
240
240
  arguments: [transferData.id, transferData.newRecipient],
241
241
  };
242
- wallet = new wallet_1.AptosWalletWrapper(senderWallet, this.client);
242
+ wallet = new wallet_js_1.AptosWalletWrapper(senderWallet, this.client);
243
243
  return [4 /*yield*/, wallet.signAndSubmitTransaction(payload)];
244
244
  case 1:
245
245
  hash = _b.sent();
@@ -264,7 +264,7 @@ var AptosStreamClient = /** @class */ (function (_super) {
264
264
  type_arguments: [tokenId],
265
265
  arguments: [topupData.id, topupData.amount.toString()],
266
266
  };
267
- wallet = new wallet_1.AptosWalletWrapper(senderWallet, this.client);
267
+ wallet = new wallet_js_1.AptosWalletWrapper(senderWallet, this.client);
268
268
  return [4 /*yield*/, wallet.signAndSubmitTransaction(payload)];
269
269
  case 1:
270
270
  hash = _b.sent();
@@ -293,7 +293,7 @@ var AptosStreamClient = /** @class */ (function (_super) {
293
293
  tokenIdMatch = contract.type.match(/0x[0-9a-f]+::protocol::Contract<(.*)>/);
294
294
  tokenId = (_b = tokenIdMatch === null || tokenIdMatch === void 0 ? void 0 : tokenIdMatch[1]) !== null && _b !== void 0 ? _b : "";
295
295
  data = contract.data;
296
- return [2 /*return*/, new types_2.Contract(data, tokenId)];
296
+ return [2 /*return*/, new types_js_2.Contract(data, tokenId)];
297
297
  }
298
298
  });
299
299
  });
@@ -315,7 +315,7 @@ var AptosStreamClient = /** @class */ (function (_super) {
315
315
  return __generator(this, function (_b) {
316
316
  switch (_b.label) {
317
317
  case 0:
318
- wallet = new wallet_1.AptosWalletWrapper(senderWallet, this.client);
318
+ wallet = new wallet_js_1.AptosWalletWrapper(senderWallet, this.client);
319
319
  payload = {
320
320
  type: "update",
321
321
  function: "".concat(this.programId, "::protocol::update"),
@@ -375,7 +375,7 @@ var AptosStreamClient = /** @class */ (function (_super) {
375
375
  };
376
376
  AptosStreamClient.prototype.extractErrorCode = function (err) {
377
377
  var _a;
378
- return (0, utils_1.extractAptosErrorCode)((_a = err.toString()) !== null && _a !== void 0 ? _a : "Unknown error!");
378
+ return (0, utils_js_1.extractAptosErrorCode)((_a = err.toString()) !== null && _a !== void 0 ? _a : "Unknown error!");
379
379
  };
380
380
  /**
381
381
  * Returns StreamClient protocol program ID.
@@ -427,5 +427,5 @@ var AptosStreamClient = /** @class */ (function (_super) {
427
427
  });
428
428
  };
429
429
  return AptosStreamClient;
430
- }(BaseStreamClient_1.BaseStreamClient));
430
+ }(BaseStreamClient_js_1.BaseStreamClient));
431
431
  exports.default = AptosStreamClient;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.APTOS_MODULE_ERROR_MAP = exports.APTOS_ERROR_MATCH_REGEX = exports.APTOS_PROGRAM_IDS = void 0;
5
+ var types_js_1 = require("../common/types.js");
6
+ exports.APTOS_PROGRAM_IDS = (_a = {},
7
+ _a[types_js_1.ICluster.Mainnet] = "0x9009d93d52576bf9ac6dc6cf10b870610bcb316342fef6eff80662fbbfce51b0",
8
+ // TODO: Add a correct programID for Test net
9
+ _a[types_js_1.ICluster.Devnet] = "0xc6737de143d91b2f99a7e490d4f8348fdfa3bdd1eb8737a27d0455f8a3625688",
10
+ _a[types_js_1.ICluster.Testnet] = "0xc6737de143d91b2f99a7e490d4f8348fdfa3bdd1eb8737a27d0455f8a3625688",
11
+ _a[types_js_1.ICluster.Local] = "0x9009d93d52576bf9ac6dc6cf10b870610bcb316342fef6eff80662fbbfce51b0",
12
+ _a);
13
+ exports.APTOS_ERROR_MATCH_REGEX = /Move abort in [a-z0-9]+::([^:]+): ([A-Z_]+)/;
14
+ exports.APTOS_MODULE_ERROR_MAP = {
15
+ protocol: {
16
+ 1: types_js_1.ContractErrorCode.ECONTRACT_NOT_INIT,
17
+ 2: types_js_1.ContractErrorCode.EBAD_AMOUNT,
18
+ 3: types_js_1.ContractErrorCode.ENO_PERMISSIONS,
19
+ 4: types_js_1.ContractErrorCode.EBADINPUT,
20
+ 5: types_js_1.ContractErrorCode.ECLOSED,
21
+ 6: types_js_1.ContractErrorCode.EBAD_INPUT_AMOUNT_PER_PERIOD,
22
+ 8: types_js_1.ContractErrorCode.EBAD_INPUT_UPDATE_RATE,
23
+ 9: types_js_1.ContractErrorCode.EBAD_INPUT_CLIFF_AMOUNT,
24
+ 10: types_js_1.ContractErrorCode.EBAD_INPUT_PERIOD,
25
+ 11: types_js_1.ContractErrorCode.EBAD_INPUT_START,
26
+ 12: types_js_1.ContractErrorCode.ENO_RECIPIENT_COIN_ADDRESS,
27
+ },
28
+ };
@@ -30,9 +30,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
30
30
  };
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
32
  exports.constants = exports.AptosStreamClient = exports.default = void 0;
33
- var StreamClient_1 = require("./StreamClient");
34
- Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(StreamClient_1).default; } });
35
- Object.defineProperty(exports, "AptosStreamClient", { enumerable: true, get: function () { return __importDefault(StreamClient_1).default; } });
33
+ var StreamClient_js_1 = require("./StreamClient.js");
34
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(StreamClient_js_1).default; } });
35
+ Object.defineProperty(exports, "AptosStreamClient", { enumerable: true, get: function () { return __importDefault(StreamClient_js_1).default; } });
36
36
  __exportStar(require("./utils"), exports);
37
37
  __exportStar(require("./types"), exports);
38
38
  exports.constants = __importStar(require("./constants"));
@@ -16,9 +16,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.Contract = void 0;
18
18
  var bn_js_1 = __importDefault(require("bn.js"));
19
- var contractUtils_1 = require("../common/contractUtils");
20
- var utils_1 = require("../common/utils");
21
- var utils_2 = require("./utils");
19
+ var buffer_1 = require("buffer");
20
+ var contractUtils_js_1 = require("../common/contractUtils.js");
21
+ var utils_js_1 = require("../common/utils.js");
22
+ var utils_js_2 = require("./utils.js");
22
23
  var Contract = /** @class */ (function () {
23
24
  function Contract(stream, tokenId) {
24
25
  this.magic = 0;
@@ -28,10 +29,10 @@ var Contract = /** @class */ (function () {
28
29
  this.canceledAt = parseInt(stream.canceled_at);
29
30
  this.end = parseInt(stream.end);
30
31
  this.lastWithdrawnAt = parseInt(stream.last_withdrawn_at);
31
- this.sender = (0, utils_2.normalizeAptosAddress)(stream.sender);
32
- this.senderTokens = (0, utils_2.normalizeAptosAddress)(stream.sender);
33
- this.recipient = (0, utils_2.normalizeAptosAddress)(stream.recipient);
34
- this.recipientTokens = (0, utils_2.normalizeAptosAddress)(stream.recipient);
32
+ this.sender = (0, utils_js_2.normalizeAptosAddress)(stream.sender);
33
+ this.senderTokens = (0, utils_js_2.normalizeAptosAddress)(stream.sender);
34
+ this.recipient = (0, utils_js_2.normalizeAptosAddress)(stream.recipient);
35
+ this.recipientTokens = (0, utils_js_2.normalizeAptosAddress)(stream.recipient);
35
36
  this.mint = tokenId;
36
37
  this.escrowTokens = "";
37
38
  this.streamflowTreasury = "";
@@ -57,20 +58,20 @@ var Contract = /** @class */ (function () {
57
58
  this.transferableByRecipient = stream.meta.transferable_by_recipient;
58
59
  this.canTopup = stream.meta.can_topup;
59
60
  var name = stream.meta.contract_name.replace("0x", "");
60
- this.name = Buffer.from(name, "hex").toString("utf8");
61
+ this.name = buffer_1.Buffer.from(name, "hex").toString("utf8");
61
62
  this.withdrawalFrequency = parseInt(stream.meta.withdrawal_frequency);
62
63
  this.closed = stream.closed;
63
64
  this.currentPauseStart = parseInt(stream.current_pause_start);
64
65
  this.pauseCumulative = new bn_js_1.default(stream.pause_cumulative);
65
66
  this.lastRateChangeTime = parseInt(stream.last_rate_change_time);
66
67
  this.fundsUnlockedAtLastRateChange = new bn_js_1.default(stream.funds_unlocked_at_last_rate_change);
67
- this.type = (0, contractUtils_1.buildStreamType)(this);
68
+ this.type = (0, contractUtils_js_1.buildStreamType)(this);
68
69
  }
69
70
  Contract.prototype.unlocked = function (currentTimestamp) {
70
- return (0, contractUtils_1.calculateUnlockedAmount)(__assign(__assign({}, this), { currentTimestamp: currentTimestamp }));
71
+ return (0, contractUtils_js_1.calculateUnlockedAmount)(__assign(__assign({}, this), { currentTimestamp: currentTimestamp }));
71
72
  };
72
73
  Contract.prototype.remaining = function (decimals) {
73
- return (0, utils_1.getNumberFromBN)(this.depositedAmount.sub(this.withdrawnAmount), decimals);
74
+ return (0, utils_js_1.getNumberFromBN)(this.depositedAmount.sub(this.withdrawnAmount), decimals);
74
75
  };
75
76
  return Contract;
76
77
  }());
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeAptosAddress = exports.extractAptosErrorCode = void 0;
4
- var constants_1 = require("./constants");
4
+ var constants_js_1 = require("./constants.js");
5
5
  function extractAptosErrorCode(errorText) {
6
- var match = constants_1.APTOS_ERROR_MATCH_REGEX.exec(errorText);
6
+ var match = constants_js_1.APTOS_ERROR_MATCH_REGEX.exec(errorText);
7
7
  if (!match) {
8
8
  return null;
9
9
  }
@@ -15,14 +15,14 @@ var __extends = (this && this.__extends) || (function () {
15
15
  };
16
16
  })();
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- var BaseStreamClient_1 = require("./BaseStreamClient");
19
- var types_1 = require("./types");
20
- var utils_1 = require("./utils");
18
+ var BaseStreamClient_js_1 = require("./BaseStreamClient.js");
19
+ var types_js_1 = require("./types.js");
20
+ var utils_js_1 = require("./utils.js");
21
21
  var aptos_1 = require("../aptos");
22
22
  var evm_1 = require("../evm");
23
23
  var solana_1 = require("../solana");
24
24
  var sui_1 = require("../sui");
25
- var constants_1 = require("./constants");
25
+ var constants_js_1 = require("./constants.js");
26
26
  /** Generic Stream Client implementation that wrap Chain Client methods and enriches error messages if possible
27
27
  * @property {StreamClientType} - Chain Client implementation
28
28
  * @property {chain} - Chain
@@ -33,18 +33,18 @@ var GenericStreamClient = /** @class */ (function (_super) {
33
33
  var _this = _super.call(this) || this;
34
34
  _this.chain = options.chain;
35
35
  switch (options.chain) {
36
- case types_1.IChain.Solana:
36
+ case types_js_1.IChain.Solana:
37
37
  _this.nativeStreamClient = new solana_1.SolanaStreamClient(options.clusterUrl, options.cluster, options.commitment, options.programId, options.sendRate, options.sendThrottler);
38
38
  break;
39
- case types_1.IChain.Aptos:
39
+ case types_js_1.IChain.Aptos:
40
40
  _this.nativeStreamClient = new aptos_1.AptosStreamClient(options.clusterUrl, options.cluster, options.maxGas, options.programId);
41
41
  break;
42
- case types_1.IChain.BNB:
43
- case types_1.IChain.Ethereum:
44
- case types_1.IChain.Polygon:
42
+ case types_js_1.IChain.BNB:
43
+ case types_js_1.IChain.Ethereum:
44
+ case types_js_1.IChain.Polygon:
45
45
  _this.nativeStreamClient = new evm_1.EvmStreamClient(options.clusterUrl, options.chain, options.signer, options.cluster, options.programId);
46
46
  break;
47
- case types_1.IChain.Sui:
47
+ case types_js_1.IChain.Sui:
48
48
  _this.nativeStreamClient = new sui_1.SuiStreamClient(options.clusterUrl, options.cluster, options.ids);
49
49
  }
50
50
  return _this;
@@ -54,43 +54,43 @@ var GenericStreamClient = /** @class */ (function (_super) {
54
54
  */
55
55
  GenericStreamClient.prototype.create = function (streamData, chainSpecificParams) {
56
56
  var _this = this;
57
- return (0, utils_1.handleContractError)(function () { return _this.nativeStreamClient.create(streamData, chainSpecificParams); }, this.nativeStreamClient.extractErrorCode);
57
+ return (0, utils_js_1.handleContractError)(function () { return _this.nativeStreamClient.create(streamData, chainSpecificParams); }, this.nativeStreamClient.extractErrorCode);
58
58
  };
59
59
  /**
60
60
  * Creates multiple stream/vesting contracts.
61
61
  */
62
62
  GenericStreamClient.prototype.createMultiple = function (multipleStreamData, chainSpecificParams) {
63
63
  var _this = this;
64
- return (0, utils_1.handleContractError)(function () { return _this.nativeStreamClient.createMultiple(multipleStreamData, chainSpecificParams); }, this.nativeStreamClient.extractErrorCode);
64
+ return (0, utils_js_1.handleContractError)(function () { return _this.nativeStreamClient.createMultiple(multipleStreamData, chainSpecificParams); }, this.nativeStreamClient.extractErrorCode);
65
65
  };
66
66
  /**
67
67
  * Attempts withdrawing from the specified stream.
68
68
  */
69
69
  GenericStreamClient.prototype.withdraw = function (_a, chainSpecificParams) {
70
70
  var _this = this;
71
- var id = _a.id, _b = _a.amount, amount = _b === void 0 ? constants_1.WITHDRAW_AVAILABLE_AMOUNT : _b;
72
- return (0, utils_1.handleContractError)(function () { return _this.nativeStreamClient.withdraw({ id: id, amount: amount }, chainSpecificParams); }, this.nativeStreamClient.extractErrorCode);
71
+ var id = _a.id, _b = _a.amount, amount = _b === void 0 ? constants_js_1.WITHDRAW_AVAILABLE_AMOUNT : _b;
72
+ return (0, utils_js_1.handleContractError)(function () { return _this.nativeStreamClient.withdraw({ id: id, amount: amount }, chainSpecificParams); }, this.nativeStreamClient.extractErrorCode);
73
73
  };
74
74
  /**
75
75
  * Attempts canceling the specified stream.
76
76
  */
77
77
  GenericStreamClient.prototype.cancel = function (cancelData, chainSpecificParams) {
78
78
  var _this = this;
79
- return (0, utils_1.handleContractError)(function () { return _this.nativeStreamClient.cancel(cancelData, chainSpecificParams); }, this.nativeStreamClient.extractErrorCode);
79
+ return (0, utils_js_1.handleContractError)(function () { return _this.nativeStreamClient.cancel(cancelData, chainSpecificParams); }, this.nativeStreamClient.extractErrorCode);
80
80
  };
81
81
  /**
82
82
  * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
83
83
  */
84
84
  GenericStreamClient.prototype.transfer = function (transferData, chainSpecificParams) {
85
85
  var _this = this;
86
- return (0, utils_1.handleContractError)(function () { return _this.nativeStreamClient.transfer(transferData, chainSpecificParams); }, this.nativeStreamClient.extractErrorCode);
86
+ return (0, utils_js_1.handleContractError)(function () { return _this.nativeStreamClient.transfer(transferData, chainSpecificParams); }, this.nativeStreamClient.extractErrorCode);
87
87
  };
88
88
  /**
89
89
  * Tops up stream account with specified amount.
90
90
  */
91
91
  GenericStreamClient.prototype.topup = function (topupData, chainSpecificParams) {
92
92
  var _this = this;
93
- return (0, utils_1.handleContractError)(function () { return _this.nativeStreamClient.topup(topupData, chainSpecificParams); }, this.nativeStreamClient.extractErrorCode);
93
+ return (0, utils_js_1.handleContractError)(function () { return _this.nativeStreamClient.topup(topupData, chainSpecificParams); }, this.nativeStreamClient.extractErrorCode);
94
94
  };
95
95
  /**
96
96
  * Fetch stream data by its id (address).
@@ -109,7 +109,7 @@ var GenericStreamClient = /** @class */ (function (_super) {
109
109
  */
110
110
  GenericStreamClient.prototype.update = function (updateData, chainSpecificParams) {
111
111
  var _this = this;
112
- return (0, utils_1.handleContractError)(function () { return _this.nativeStreamClient.update(updateData, chainSpecificParams); }, this.nativeStreamClient.extractErrorCode);
112
+ return (0, utils_js_1.handleContractError)(function () { return _this.nativeStreamClient.update(updateData, chainSpecificParams); }, this.nativeStreamClient.extractErrorCode);
113
113
  };
114
114
  /**
115
115
  * Returns streamflow and partner fees for the specific wallet in %
@@ -124,5 +124,5 @@ var GenericStreamClient = /** @class */ (function (_super) {
124
124
  return this.nativeStreamClient.getDefaultStreamflowFee();
125
125
  };
126
126
  return GenericStreamClient;
127
- }(BaseStreamClient_1.BaseStreamClient));
127
+ }(BaseStreamClient_js_1.BaseStreamClient));
128
128
  exports.default = GenericStreamClient;
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.buildStreamType = exports.isTokenLock = exports.isVesting = exports.isPayment = exports.isCliffCloseToDepositedAmount = exports.calculateUnlockedAmount = void 0;
7
7
  var bn_js_1 = __importDefault(require("bn.js"));
8
- var types_1 = require("./types");
8
+ var types_js_1 = require("./types.js");
9
9
  var calculateUnlockedAmount = function (_a) {
10
10
  var depositedAmount = _a.depositedAmount, cliff = _a.cliff, cliffAmount = _a.cliffAmount, end = _a.end, currentTimestamp = _a.currentTimestamp, lastRateChangeTime = _a.lastRateChangeTime, period = _a.period, amountPerPeriod = _a.amountPerPeriod, fundsUnlockedAtLastRateChange = _a.fundsUnlockedAtLastRateChange;
11
11
  var deposited = depositedAmount;
@@ -45,11 +45,11 @@ var isTokenLock = function (streamData) {
45
45
  exports.isTokenLock = isTokenLock;
46
46
  var buildStreamType = function (streamData) {
47
47
  if ((0, exports.isVesting)(streamData)) {
48
- return types_1.StreamType.Vesting;
48
+ return types_js_1.StreamType.Vesting;
49
49
  }
50
50
  if ((0, exports.isTokenLock)(streamData)) {
51
- return types_1.StreamType.Lock;
51
+ return types_js_1.StreamType.Lock;
52
52
  }
53
- return types_1.StreamType.Payment;
53
+ return types_js_1.StreamType.Payment;
54
54
  };
55
55
  exports.buildStreamType = buildStreamType;
@@ -39,9 +39,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
39
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
40
  };
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.normalizeAptosAddress = exports.handleContractError = exports.calculateTotalAmountToDeposit = exports.getNumberFromBN = exports.getBN = void 0;
42
+ exports.handleContractError = exports.calculateTotalAmountToDeposit = exports.getNumberFromBN = exports.getBN = void 0;
43
43
  var bn_js_1 = __importDefault(require("bn.js"));
44
- var types_1 = require("./types");
44
+ var types_js_1 = require("./types.js");
45
45
  var FEE_PRECISION = 4;
46
46
  var FEE_NORMALIZER = Math.pow(10, FEE_PRECISION);
47
47
  var FEE_MULTIPLIER = new bn_js_1.default(Math.pow(10, 6));
@@ -103,9 +103,9 @@ function handleContractError(func, callback) {
103
103
  err_1 = _a.sent();
104
104
  if (err_1 instanceof Error) {
105
105
  if (callback) {
106
- throw new types_1.ContractError(err_1, callback(err_1));
106
+ throw new types_js_1.ContractError(err_1, callback(err_1));
107
107
  }
108
- throw new types_1.ContractError(err_1);
108
+ throw new types_js_1.ContractError(err_1);
109
109
  }
110
110
  throw err_1;
111
111
  case 3: return [2 /*return*/];
@@ -114,5 +114,3 @@ function handleContractError(func, callback) {
114
114
  });
115
115
  }
116
116
  exports.handleContractError = handleContractError;
117
- var utils_1 = require("../aptos/utils");
118
- Object.defineProperty(exports, "normalizeAptosAddress", { enumerable: true, get: function () { return utils_1.normalizeAptosAddress; } });