@streamflow/stream 6.3.9 → 7.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.
- package/README.md +17 -18
- package/dist/{__tests__ → cjs/__tests__}/aptos/streamClient.spec.js +26 -25
- package/dist/cjs/__tests__/common/GenericStreamClient.spec.js +45 -0
- package/dist/{aptos → cjs/aptos}/StreamClient.js +20 -20
- package/dist/cjs/aptos/constants.js +28 -0
- package/dist/{aptos → cjs/aptos}/index.js +3 -3
- package/dist/{aptos → cjs/aptos}/types.js +23 -22
- package/dist/{aptos → cjs/aptos}/utils.js +2 -2
- package/dist/{common → cjs/common}/GenericStreamClient.js +19 -19
- package/dist/{common → cjs/common}/constants.js +2 -2
- package/dist/{common → cjs/common}/contractUtils.js +10 -10
- package/dist/{common → cjs/common}/utils.js +21 -28
- package/dist/{evm → cjs/evm}/StreamClient.js +33 -33
- package/dist/cjs/evm/constants.js +39 -0
- package/dist/{evm → cjs/evm}/index.js +8 -8
- package/dist/{evm → cjs/evm}/types.js +16 -16
- package/dist/{evm → cjs/evm}/utils.js +2 -2
- package/dist/{solana → cjs/solana}/StreamClient.js +80 -79
- package/dist/cjs/solana/constants.js +60 -0
- package/dist/cjs/solana/index.js +39 -0
- package/dist/{solana → cjs/solana}/instructions.js +33 -28
- package/dist/{solana → cjs/solana}/layout.js +2 -2
- package/dist/{solana → cjs/solana}/types.js +5 -5
- package/dist/{solana → cjs/solana}/utils.js +44 -33
- package/dist/{sui → cjs/sui}/StreamClient.js +26 -26
- package/dist/cjs/sui/constants.js +43 -0
- package/dist/{sui → cjs/sui}/index.js +5 -5
- package/dist/{sui → cjs/sui}/types.js +16 -16
- package/dist/{sui → cjs/sui}/utils.js +3 -3
- package/dist/esm/__tests__/aptos/streamClient.spec.js +106 -0
- package/dist/esm/__tests__/common/GenericStreamClient.spec.js +40 -0
- package/dist/{aptos → esm/aptos}/StreamClient.d.ts +3 -3
- package/dist/esm/aptos/StreamClient.js +226 -0
- package/dist/{aptos → esm/aptos}/constants.d.ts +1 -1
- package/dist/esm/aptos/constants.js +24 -0
- package/dist/{aptos → esm/aptos}/index.d.ts +1 -1
- package/dist/{sui/index.d.ts → esm/aptos/index.js} +1 -1
- package/dist/{aptos → esm/aptos}/types.d.ts +13 -13
- package/dist/esm/aptos/types.js +105 -0
- package/dist/esm/aptos/utils.js +30 -0
- package/dist/esm/aptos/wallet.js +33 -0
- package/dist/{common → esm/common}/BaseStreamClient.d.ts +1 -1
- package/dist/esm/common/BaseStreamClient.js +19 -0
- package/dist/{common → esm/common}/GenericStreamClient.d.ts +2 -2
- package/dist/esm/common/GenericStreamClient.js +101 -0
- package/dist/esm/common/constants.d.ts +3 -0
- package/dist/esm/common/constants.js +3 -0
- package/dist/{common → esm/common}/contractUtils.d.ts +15 -15
- package/dist/esm/common/contractUtils.js +42 -0
- package/dist/{common → esm/common}/types.d.ts +19 -19
- package/dist/esm/common/types.js +106 -0
- package/dist/{common → esm/common}/utils.d.ts +11 -12
- package/dist/esm/common/utils.js +56 -0
- package/dist/{evm → esm/evm}/StreamClient.d.ts +4 -4
- package/dist/esm/evm/StreamClient.js +237 -0
- package/dist/esm/evm/abi.js +1255 -0
- package/dist/{evm → esm/evm}/constants.d.ts +1 -1
- package/dist/esm/evm/constants.js +35 -0
- package/dist/esm/evm/ercAbi.js +222 -0
- package/dist/esm/evm/index.d.ts +5 -0
- package/dist/esm/evm/index.js +5 -0
- package/dist/{evm → esm/evm}/types.d.ts +38 -38
- package/dist/esm/evm/types.js +102 -0
- package/dist/esm/evm/utils.js +8 -0
- package/dist/esm/index.js +9 -0
- package/dist/{solana → esm/solana}/StreamClient.d.ts +4 -4
- package/dist/esm/solana/StreamClient.js +695 -0
- package/dist/{solana → esm/solana}/constants.d.ts +2 -0
- package/dist/esm/solana/constants.js +56 -0
- package/dist/esm/solana/index.d.ts +6 -0
- package/dist/esm/solana/index.js +6 -0
- package/dist/esm/solana/instructionTypes.js +1 -0
- package/dist/{solana → esm/solana}/instructions.d.ts +18 -18
- package/dist/esm/solana/instructions.js +257 -0
- package/dist/{solana → esm/solana}/layout.d.ts +2 -1
- package/dist/esm/solana/layout.js +155 -0
- package/dist/esm/solana/timelockIDL.js +420 -0
- package/dist/{solana → esm/solana}/types.d.ts +38 -37
- package/dist/esm/solana/types.js +101 -0
- package/dist/{solana → esm/solana}/utils.d.ts +4 -1
- package/dist/esm/solana/utils.js +123 -0
- package/dist/{sui → esm/sui}/StreamClient.d.ts +3 -3
- package/dist/esm/sui/StreamClient.js +403 -0
- package/dist/{sui → esm/sui}/constants.d.ts +1 -1
- package/dist/esm/sui/constants.js +39 -0
- package/dist/esm/sui/index.d.ts +4 -0
- package/dist/esm/sui/index.js +4 -0
- package/dist/{sui → esm/sui}/types.d.ts +13 -13
- package/dist/esm/sui/types.js +104 -0
- package/dist/{sui → esm/sui}/utils.d.ts +1 -1
- package/dist/esm/sui/utils.js +23 -0
- package/dist/{sui → esm/sui}/wallet.d.ts +1 -1
- package/dist/esm/sui/wallet.js +38 -0
- package/package.json +37 -35
- package/dist/__tests__/common/GenericStreamClient.spec.js +0 -44
- package/dist/aptos/constants.js +0 -28
- package/dist/common/constants.d.ts +0 -3
- package/dist/evm/constants.js +0 -39
- package/dist/evm/index.d.ts +0 -5
- package/dist/solana/constants.js +0 -59
- package/dist/solana/index.d.ts +0 -7
- package/dist/solana/index.js +0 -43
- package/dist/sui/constants.js +0 -43
- /package/dist/{aptos → cjs/aptos}/wallet.js +0 -0
- /package/dist/{common → cjs/common}/BaseStreamClient.js +0 -0
- /package/dist/{common → cjs/common}/types.js +0 -0
- /package/dist/{evm → cjs/evm}/abi.js +0 -0
- /package/dist/{evm → cjs/evm}/ercAbi.js +0 -0
- /package/dist/{index.js → cjs/index.js} +0 -0
- /package/dist/{solana → cjs/solana}/instructionTypes.js +0 -0
- /package/dist/{solana → cjs/solana}/timelockIDL.js +0 -0
- /package/dist/{sui → cjs/sui}/wallet.js +0 -0
- /package/dist/{__tests__ → esm/__tests__}/aptos/streamClient.spec.d.ts +0 -0
- /package/dist/{__tests__ → esm/__tests__}/common/GenericStreamClient.spec.d.ts +0 -0
- /package/dist/{aptos → esm/aptos}/utils.d.ts +0 -0
- /package/dist/{aptos → esm/aptos}/wallet.d.ts +0 -0
- /package/dist/{evm → esm/evm}/abi.d.ts +0 -0
- /package/dist/{evm → esm/evm}/ercAbi.d.ts +0 -0
- /package/dist/{evm → esm/evm}/utils.d.ts +0 -0
- /package/dist/{index.d.ts → esm/index.d.ts} +0 -0
- /package/dist/{solana → esm/solana}/instructionTypes.d.ts +0 -0
- /package/dist/{solana → esm/solana}/timelockIDL.d.ts +0 -0
package/README.md
CHANGED
|
@@ -22,8 +22,7 @@ API Documentation available here: [docs site →](https://streamflow-finance.git
|
|
|
22
22
|
Most common imports:
|
|
23
23
|
|
|
24
24
|
```javascript
|
|
25
|
-
import {
|
|
26
|
-
import { Types, GenericStreamClient, getBN, getNumberFromBN } from "@streamflow/stream";
|
|
25
|
+
import { Types, GenericStreamClient, getScaledBigNumber, getNumberFromBigNumber } from "@streamflow/stream";
|
|
27
26
|
```
|
|
28
27
|
|
|
29
28
|
_Check the SDK for other types and utility functions._
|
|
@@ -143,11 +142,11 @@ const createStreamParams: Types.ICreateStreamData = {
|
|
|
143
142
|
recipient: "4ih00075bKjVg000000tLdk4w42NyG3Mv0000dc0M00", // Recipient address.
|
|
144
143
|
tokenId: "DNw99999M7e24g99999999WJirKeZ5fQc6KY999999gK", // Token mint address.
|
|
145
144
|
start: 1643363040, // Timestamp (in seconds) when the stream/token vesting starts.
|
|
146
|
-
amount:
|
|
145
|
+
amount: getScaledBigNumber(100, 9), // depositing 100 tokens with 9 decimals mint.
|
|
147
146
|
period: 1, // Time step (period) in seconds per which the unlocking occurs.
|
|
148
147
|
cliff: 1643363160, // Vesting contract "cliff" timestamp in seconds.
|
|
149
|
-
cliffAmount:
|
|
150
|
-
amountPerPeriod:
|
|
148
|
+
cliffAmount: 10, // Amount unlocked at the "cliff" timestamp.
|
|
149
|
+
amountPerPeriod: getScaledBigNumber(5, 9), // Release rate: how many tokens are unlocked per each period.
|
|
151
150
|
name: "Transfer to Jane Doe.", // The stream name or subject.
|
|
152
151
|
canTopup: false, // setting to FALSE will effectively create a vesting contract.
|
|
153
152
|
canUpdateRate: false, // settings to TRUE allows sender to update amountPerPeriod
|
|
@@ -188,10 +187,10 @@ try {
|
|
|
188
187
|
const recipients = [
|
|
189
188
|
{
|
|
190
189
|
recipient: "4ih00075bKjVg000000tLdk4w42NyG3Mv0000dc0M00", // Solana recipient address.
|
|
191
|
-
amount:
|
|
190
|
+
amount: getScaledBgNumber(100, 9), // depositing 100 tokens with 9 decimals mint.
|
|
192
191
|
name: "January Payroll", // The stream name/subject.
|
|
193
|
-
cliffAmount:
|
|
194
|
-
amountPerPeriod:
|
|
192
|
+
cliffAmount: getScaledBgNumber(10, 9), // amount released on cliff for this recipient
|
|
193
|
+
amountPerPeriod: getScaledBgNumber(1, 9), //amount released every specified period epoch
|
|
195
194
|
},
|
|
196
195
|
];
|
|
197
196
|
const createStreamParams: Types.ICreateMultipleStreamData = {
|
|
@@ -253,7 +252,7 @@ interface ICreateResult {
|
|
|
253
252
|
```javascript
|
|
254
253
|
const withdrawStreamParams: Types.IWithdrawData = {
|
|
255
254
|
id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA", // Identifier of a stream to be withdrawn from.
|
|
256
|
-
amount:
|
|
255
|
+
amount: getScaledBgNumber(100, 9), // Requested amount to withdraw. If stream is completed, the whole amount will be withdrawn.
|
|
257
256
|
};
|
|
258
257
|
|
|
259
258
|
const solanaParams = {
|
|
@@ -284,7 +283,7 @@ try {
|
|
|
284
283
|
```javascript
|
|
285
284
|
const topupStreamParams: Types.ITopUpData = {
|
|
286
285
|
id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA", // Identifier of a stream to be topped up.
|
|
287
|
-
amount:
|
|
286
|
+
amount: getScaledBgNumber(100, 9), // Specified amount to topup (increases deposited amount).
|
|
288
287
|
};
|
|
289
288
|
|
|
290
289
|
const solanaParams = {
|
|
@@ -379,7 +378,7 @@ const updateStreamParams: Types.IUpdateData = {
|
|
|
379
378
|
id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA", // Identifier of a stream to update.
|
|
380
379
|
enableAutomaticWithdrawal: true, // [optional], allows to enable AW if it wasn't, disable is not possible
|
|
381
380
|
withdrawFrequency: 60, // [optional], allows to update withdrawal frequency, may result in additional AW fees
|
|
382
|
-
amountPerPeriod:
|
|
381
|
+
amountPerPeriod: getScaledBgNumber(10, 9), // [optional], allows to update release amount effective on next unlock
|
|
383
382
|
}
|
|
384
383
|
|
|
385
384
|
const solanaParams = {
|
|
@@ -424,8 +423,8 @@ const stream = await client.getOne({
|
|
|
424
423
|
id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA",
|
|
425
424
|
});
|
|
426
425
|
|
|
427
|
-
const unlocked = stream.unlocked(tsInSeconds); //
|
|
428
|
-
console.log(
|
|
426
|
+
const unlocked = stream.unlocked(tsInSeconds); // bignumber amount unlocked at the tsInSeconds
|
|
427
|
+
console.log(getNumberFromBigNumber(unlocked, 9));
|
|
429
428
|
```
|
|
430
429
|
|
|
431
430
|
- Note: unlocked amount is determined based on configuration set on creation, no dynamic data is involved.
|
|
@@ -436,8 +435,8 @@ console.log(getNumberFromBN(unlocked, 9));
|
|
|
436
435
|
const stream = await client.getOne({
|
|
437
436
|
id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA",
|
|
438
437
|
});
|
|
439
|
-
const withdrawn = stream.withdrawnAmount; //
|
|
440
|
-
console.log(
|
|
438
|
+
const withdrawn = stream.withdrawnAmount; // big number amount withdrawn already
|
|
439
|
+
console.log(getNumberFromBigNumber(wihtdrawn, 9));
|
|
441
440
|
const remaining = stream.remaining(9); // amount of remaining funds
|
|
442
441
|
console.log(remaining);
|
|
443
442
|
```
|
|
@@ -492,10 +491,10 @@ Streamflow protocol program IDs
|
|
|
492
491
|
| Testnet | 0xf1916c119a6c917d4b36f96ffc0443930745789f3126a716e05a62223c48993a |
|
|
493
492
|
| Mainnet | 0xa283fd6b45f1103176e7ae27e870c89df7c8783b15345e2b13faa81ec25c4fa6 |
|
|
494
493
|
|
|
495
|
-
**All
|
|
494
|
+
**All BigNumber amounts are denominated in their smallest units.**
|
|
496
495
|
|
|
497
496
|
E.g, if the amount is 1 SOL than this amount in lamports is `1000 \* 10^9 = 1_000_000_000.`
|
|
498
497
|
|
|
499
|
-
And `
|
|
498
|
+
And `BigNumber(1_000_000_000)` is used.
|
|
500
499
|
|
|
501
|
-
Use `
|
|
500
|
+
Use `getscaledBigNumber` and `getNumberFromBigNumber` utility functions for conversions between `BigNumber` and `Number` types.
|
|
@@ -50,46 +50,47 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
50
50
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
51
|
};
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
var
|
|
54
|
-
var
|
|
55
|
-
var
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
var bignumber_js_1 = require("bignumber.js");
|
|
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
|
-
|
|
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
|
|
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
|
|
74
|
-
beforeEach(function () {
|
|
75
|
-
instance = new
|
|
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 =
|
|
83
|
+
mockSigner = vitest_1.vi.fn();
|
|
83
84
|
mockWallet = {
|
|
84
85
|
signAndSubmitTransaction: mockSigner,
|
|
85
86
|
account: { address: "" },
|
|
86
87
|
};
|
|
87
88
|
mockRecipient = {
|
|
88
89
|
recipient: "0xtest",
|
|
89
|
-
amount:
|
|
90
|
+
amount: (0, bignumber_js_1.BigNumber)(1000),
|
|
90
91
|
name: "test name",
|
|
91
|
-
cliffAmount:
|
|
92
|
-
amountPerPeriod:
|
|
92
|
+
cliffAmount: 1,
|
|
93
|
+
amountPerPeriod: (0, bignumber_js_1.BigNumber)(1),
|
|
93
94
|
};
|
|
94
95
|
mockData = {
|
|
95
96
|
period: 100,
|
|
@@ -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
|
|
83
|
-
var
|
|
84
|
-
var
|
|
85
|
-
var
|
|
86
|
-
var
|
|
87
|
-
var
|
|
88
|
-
var
|
|
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 =
|
|
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 :
|
|
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
|
|
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
|
|
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 ?
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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,
|
|
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
|
-
}(
|
|
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
|
|
34
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(
|
|
35
|
-
Object.defineProperty(exports, "AptosStreamClient", { enumerable: true, get: function () { return __importDefault(
|
|
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"));
|
|
@@ -15,41 +15,42 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.Contract = void 0;
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
var
|
|
18
|
+
var bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
19
|
+
var buffer_1 = require("buffer");
|
|
20
|
+
var contractUtils_js_1 = require("../common/contractUtils.js");
|
|
21
|
+
var utils_js_1 = require("./utils.js");
|
|
22
|
+
var utils_js_2 = require("../common/utils.js");
|
|
22
23
|
var Contract = /** @class */ (function () {
|
|
23
24
|
function Contract(stream, tokenId) {
|
|
24
25
|
this.magic = 0;
|
|
25
26
|
this.version = 0;
|
|
26
27
|
this.createdAt = parseInt(stream.created);
|
|
27
|
-
this.withdrawnAmount =
|
|
28
|
+
this.withdrawnAmount = (0, bignumber_js_1.default)(stream.withdrawn);
|
|
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,
|
|
32
|
-
this.senderTokens = (0,
|
|
33
|
-
this.recipient = (0,
|
|
34
|
-
this.recipientTokens = (0,
|
|
32
|
+
this.sender = (0, utils_js_1.normalizeAptosAddress)(stream.sender);
|
|
33
|
+
this.senderTokens = (0, utils_js_1.normalizeAptosAddress)(stream.sender);
|
|
34
|
+
this.recipient = (0, utils_js_1.normalizeAptosAddress)(stream.recipient);
|
|
35
|
+
this.recipientTokens = (0, utils_js_1.normalizeAptosAddress)(stream.recipient);
|
|
35
36
|
this.mint = tokenId;
|
|
36
37
|
this.escrowTokens = "";
|
|
37
38
|
this.streamflowTreasury = "";
|
|
38
39
|
this.streamflowTreasuryTokens = "";
|
|
39
|
-
this.streamflowFeeTotal =
|
|
40
|
-
this.streamflowFeeWithdrawn =
|
|
40
|
+
this.streamflowFeeTotal = (0, bignumber_js_1.default)(0);
|
|
41
|
+
this.streamflowFeeWithdrawn = (0, bignumber_js_1.default)(0);
|
|
41
42
|
this.streamflowFeePercent = parseInt(stream.fees.streamflow_fee_percentage) / 10000;
|
|
42
|
-
this.partnerFeeTotal =
|
|
43
|
-
this.partnerFeeWithdrawn =
|
|
43
|
+
this.partnerFeeTotal = (0, bignumber_js_1.default)(0);
|
|
44
|
+
this.partnerFeeWithdrawn = (0, bignumber_js_1.default)(0);
|
|
44
45
|
this.partnerFeePercent = 0;
|
|
45
46
|
this.partner = "";
|
|
46
47
|
this.partnerTokens = "";
|
|
47
48
|
this.start = parseInt(stream.start);
|
|
48
|
-
this.depositedAmount =
|
|
49
|
+
this.depositedAmount = (0, bignumber_js_1.default)(stream.amount);
|
|
49
50
|
this.period = parseInt(stream.period);
|
|
50
|
-
this.amountPerPeriod =
|
|
51
|
+
this.amountPerPeriod = (0, bignumber_js_1.default)(stream.amount_per_period);
|
|
51
52
|
this.cliff = parseInt(stream.start);
|
|
52
|
-
this.cliffAmount =
|
|
53
|
+
this.cliffAmount = (0, bignumber_js_1.default)(stream.cliff_amount);
|
|
53
54
|
this.cancelableBySender = stream.meta.cancelable_by_sender;
|
|
54
55
|
this.cancelableByRecipient = stream.meta.cancelable_by_recipient;
|
|
55
56
|
this.automaticWithdrawal = stream.meta.automatic_withdrawal;
|
|
@@ -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
|
-
this.pauseCumulative =
|
|
65
|
+
this.pauseCumulative = (0, bignumber_js_1.default)(stream.pause_cumulative);
|
|
65
66
|
this.lastRateChangeTime = parseInt(stream.last_rate_change_time);
|
|
66
|
-
this.fundsUnlockedAtLastRateChange =
|
|
67
|
-
this.type = (0,
|
|
67
|
+
this.fundsUnlockedAtLastRateChange = (0, bignumber_js_1.default)(stream.funds_unlocked_at_last_rate_change);
|
|
68
|
+
this.type = (0, contractUtils_js_1.buildStreamType)(this);
|
|
68
69
|
}
|
|
69
70
|
Contract.prototype.unlocked = function (currentTimestamp) {
|
|
70
|
-
return (0,
|
|
71
|
+
return (0, contractUtils_js_1.calculateUnlockedAmount)(__assign(__assign({}, this), { currentTimestamp: currentTimestamp }));
|
|
71
72
|
};
|
|
72
73
|
Contract.prototype.remaining = function (decimals) {
|
|
73
|
-
return (0,
|
|
74
|
+
return (0, utils_js_2.getNumberFromBigNumber)(this.depositedAmount.minus(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
|
|
4
|
+
var constants_js_1 = require("./constants.js");
|
|
5
5
|
function extractAptosErrorCode(errorText) {
|
|
6
|
-
var match =
|
|
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
|
|
19
|
-
var
|
|
20
|
-
var
|
|
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
|
|
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
|
|
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
|
|
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
|
|
43
|
-
case
|
|
44
|
-
case
|
|
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
|
|
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,
|
|
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,
|
|
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 ?
|
|
72
|
-
return (0,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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
|
-
}(
|
|
127
|
+
}(BaseStreamClient_js_1.BaseStreamClient));
|
|
128
128
|
exports.default = GenericStreamClient;
|
|
@@ -4,6 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.WITHDRAW_AVAILABLE_AMOUNT = exports.BASE_FEE = void 0;
|
|
7
|
-
var
|
|
7
|
+
var bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
8
8
|
exports.BASE_FEE = 1009900; // Buffer to include usual fees when calculating stream amount
|
|
9
|
-
exports.WITHDRAW_AVAILABLE_AMOUNT =
|
|
9
|
+
exports.WITHDRAW_AVAILABLE_AMOUNT = (0, bignumber_js_1.default)("18446744073709551615"); // Magical number to withdraw all available amount from a Contract
|