@streamflow/stream 7.0.0-alpha.1 → 7.0.0-alpha.11
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 +65 -68
- package/dist/cjs/__tests__/aptos/streamClient.spec.js +83 -134
- package/dist/cjs/__tests__/common/GenericStreamClient.spec.js +9 -9
- package/dist/cjs/aptos/StreamClient.js +162 -367
- package/dist/cjs/aptos/constants.js +7 -8
- package/dist/cjs/aptos/index.js +3 -3
- package/dist/cjs/aptos/types.js +32 -41
- package/dist/cjs/aptos/utils.js +4 -4
- package/dist/cjs/aptos/wallet.js +20 -75
- package/dist/cjs/common/BaseStreamClient.js +11 -59
- package/dist/cjs/common/GenericStreamClient.js +46 -72
- package/dist/cjs/common/constants.js +2 -2
- package/dist/cjs/common/contractUtils.js +16 -17
- package/dist/cjs/common/utils.js +34 -84
- package/dist/cjs/evm/StreamClient.js +198 -456
- package/dist/cjs/evm/constants.js +19 -20
- package/dist/cjs/evm/types.js +25 -34
- package/dist/cjs/evm/utils.js +2 -2
- package/dist/cjs/index.js +10 -10
- package/dist/cjs/solana/StreamClient.js +608 -1090
- package/dist/cjs/solana/constants.js +16 -11
- package/dist/cjs/solana/instructions.js +76 -80
- package/dist/cjs/solana/layout.js +7 -8
- package/dist/cjs/solana/types.js +15 -25
- package/dist/cjs/solana/utils.js +77 -154
- package/dist/cjs/sui/StreamClient.js +325 -571
- package/dist/cjs/sui/constants.js +19 -20
- package/dist/cjs/sui/types.js +28 -62
- package/dist/cjs/sui/utils.js +7 -7
- package/dist/cjs/sui/wallet.js +13 -63
- package/dist/esm/__tests__/aptos/streamClient.spec.js +4 -4
- package/dist/esm/aptos/index.d.ts +3 -3
- package/dist/esm/aptos/index.js +3 -3
- package/dist/esm/aptos/types.d.ts +12 -12
- package/dist/esm/aptos/types.js +13 -13
- package/dist/esm/common/GenericStreamClient.d.ts +4 -4
- package/dist/esm/common/GenericStreamClient.js +4 -4
- package/dist/esm/common/constants.d.ts +2 -2
- package/dist/esm/common/constants.js +2 -2
- package/dist/esm/common/contractUtils.d.ts +14 -14
- package/dist/esm/common/contractUtils.js +6 -6
- package/dist/esm/common/types.d.ts +19 -19
- package/dist/esm/common/utils.d.ts +11 -11
- package/dist/esm/common/utils.js +16 -19
- package/dist/esm/evm/StreamClient.d.ts +2 -2
- package/dist/esm/evm/StreamClient.js +7 -7
- package/dist/esm/evm/types.d.ts +37 -37
- package/dist/esm/evm/types.js +13 -13
- package/dist/esm/index.d.ts +9 -9
- package/dist/esm/index.js +9 -9
- package/dist/esm/solana/StreamClient.d.ts +3 -1
- package/dist/esm/solana/StreamClient.js +38 -22
- package/dist/esm/solana/constants.d.ts +3 -0
- package/dist/esm/solana/constants.js +6 -0
- package/dist/esm/solana/instructions.d.ts +17 -17
- package/dist/esm/solana/instructions.js +19 -18
- package/dist/esm/solana/types.d.ts +41 -36
- package/dist/esm/solana/types.js +2 -2
- package/dist/esm/solana/utils.d.ts +2 -0
- package/dist/esm/solana/utils.js +32 -26
- package/dist/esm/sui/StreamClient.js +1 -1
- package/dist/esm/sui/types.d.ts +12 -12
- package/dist/esm/sui/types.js +13 -13
- package/package.json +10 -11
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a, _b, _c;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.SUI_MODULE_ERROR_MAP = exports.SUI_ERROR_MATCH_REGEX = exports.SUI_FEE_TABLE_IDS = exports.SUI_CONFIG_IDS = exports.SUI_PROGRAM_IDS = void 0;
|
|
5
|
-
|
|
4
|
+
const types_js_1 = require("../common/types.js");
|
|
6
5
|
// TODO: remove Devnet and Local addresses as they are not deployed, they are just a copy Testnet values
|
|
7
|
-
exports.SUI_PROGRAM_IDS =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
exports.SUI_CONFIG_IDS =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
exports.SUI_FEE_TABLE_IDS =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
6
|
+
exports.SUI_PROGRAM_IDS = {
|
|
7
|
+
[types_js_1.ICluster.Mainnet]: "0xe456a3a1d4e58e85b4b7175fabe6dae895b983f1379bb8948d6ec2f137b08a7b",
|
|
8
|
+
[types_js_1.ICluster.Devnet]: "0x34dacd839e1758ebb70bdcd4e08f18fbfef5e2b96d9aa7ce2b4a71d96ca0df5a",
|
|
9
|
+
[types_js_1.ICluster.Testnet]: "0x34dacd839e1758ebb70bdcd4e08f18fbfef5e2b96d9aa7ce2b4a71d96ca0df5a",
|
|
10
|
+
[types_js_1.ICluster.Local]: "0x34dacd839e1758ebb70bdcd4e08f18fbfef5e2b96d9aa7ce2b4a71d96ca0df5a",
|
|
11
|
+
};
|
|
12
|
+
exports.SUI_CONFIG_IDS = {
|
|
13
|
+
[types_js_1.ICluster.Mainnet]: "0x6cf6760b64245b8d23ef57c28ddceb6adbd540a23a509fef29b82237da4ab87b",
|
|
14
|
+
[types_js_1.ICluster.Devnet]: "0xd6c9f5074584f58074ce56e3c5cc436d82258ec3285f186a0d6438a60bacdbf8",
|
|
15
|
+
[types_js_1.ICluster.Testnet]: "0xd6c9f5074584f58074ce56e3c5cc436d82258ec3285f186a0d6438a60bacdbf8",
|
|
16
|
+
[types_js_1.ICluster.Local]: "0xd6c9f5074584f58074ce56e3c5cc436d82258ec3285f186a0d6438a60bacdbf8",
|
|
17
|
+
};
|
|
18
|
+
exports.SUI_FEE_TABLE_IDS = {
|
|
19
|
+
[types_js_1.ICluster.Mainnet]: "0xad9b75399632583fb9fcae6b5bcca34e6542ab3bedb630ecbd3f15cb1cc48dbe",
|
|
20
|
+
[types_js_1.ICluster.Devnet]: "0x6057b093904c5bdfec1067d2b8a4dc35f65bcab03b3029ad716c4882b0f36078",
|
|
21
|
+
[types_js_1.ICluster.Testnet]: "0x6057b093904c5bdfec1067d2b8a4dc35f65bcab03b3029ad716c4882b0f36078",
|
|
22
|
+
[types_js_1.ICluster.Local]: "0x6057b093904c5bdfec1067d2b8a4dc35f65bcab03b3029ad716c4882b0f36078",
|
|
23
|
+
};
|
|
25
24
|
exports.SUI_ERROR_MATCH_REGEX = /MoveAbort\(MoveLocation \{ module: ModuleId \{ address: (\w+), name: Identifier\("([\w_]+)"\) }, function: \d+, instruction: \d+, function_name: Some\("([\w_]+)"\) }, (\d+)\) in command (\d+)/;
|
|
26
25
|
exports.SUI_MODULE_ERROR_MAP = {
|
|
27
26
|
protocol: {
|
package/dist/cjs/sui/types.js
CHANGED
|
@@ -1,56 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
14
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
15
|
-
if (!m) return o;
|
|
16
|
-
var i = m.call(o), r, ar = [], e;
|
|
17
|
-
try {
|
|
18
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
19
|
-
}
|
|
20
|
-
catch (error) { e = { error: error }; }
|
|
21
|
-
finally {
|
|
22
|
-
try {
|
|
23
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
24
|
-
}
|
|
25
|
-
finally { if (e) throw e.error; }
|
|
26
|
-
}
|
|
27
|
-
return ar;
|
|
28
|
-
};
|
|
29
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
30
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
31
|
-
if (ar || !(i in from)) {
|
|
32
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
33
|
-
ar[i] = from[i];
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
37
|
-
};
|
|
38
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
4
|
};
|
|
41
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
6
|
exports.Contract = void 0;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
7
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
8
|
+
const contractUtils_js_1 = require("../common/contractUtils.js");
|
|
9
|
+
const utils_js_1 = require("../common/utils.js");
|
|
10
|
+
class Contract {
|
|
11
|
+
constructor(stream, tokenId) {
|
|
12
|
+
const meta = stream.meta.fields;
|
|
13
|
+
const fees = stream.fees.fields;
|
|
50
14
|
this.magic = 0;
|
|
51
15
|
this.version = parseInt(stream.version);
|
|
52
16
|
this.createdAt = parseInt(stream.created);
|
|
53
|
-
this.withdrawnAmount =
|
|
17
|
+
this.withdrawnAmount = (0, bignumber_js_1.default)(stream.withdrawn);
|
|
54
18
|
this.canceledAt = parseInt(stream.canceled_at);
|
|
55
19
|
this.end = parseInt(stream.end);
|
|
56
20
|
this.lastWithdrawnAt = parseInt(stream.last_withdrawn_at);
|
|
@@ -62,41 +26,43 @@ var Contract = /** @class */ (function () {
|
|
|
62
26
|
this.escrowTokens = "";
|
|
63
27
|
this.streamflowTreasury = "";
|
|
64
28
|
this.streamflowTreasuryTokens = "";
|
|
65
|
-
this.streamflowFeeTotal =
|
|
66
|
-
this.streamflowFeeWithdrawn =
|
|
29
|
+
this.streamflowFeeTotal = (0, bignumber_js_1.default)(0);
|
|
30
|
+
this.streamflowFeeWithdrawn = (0, bignumber_js_1.default)(0);
|
|
67
31
|
this.streamflowFeePercent = parseInt(fees.streamflow_fee_percentage) / 10000;
|
|
68
|
-
this.partnerFeeTotal =
|
|
69
|
-
this.partnerFeeWithdrawn =
|
|
32
|
+
this.partnerFeeTotal = (0, bignumber_js_1.default)(0);
|
|
33
|
+
this.partnerFeeWithdrawn = (0, bignumber_js_1.default)(0);
|
|
70
34
|
this.partnerFeePercent = parseInt(fees.partner_fee_percentage) / 10000;
|
|
71
35
|
this.partner = stream.partner;
|
|
72
36
|
this.partnerTokens = "";
|
|
73
37
|
this.start = parseInt(stream.start);
|
|
74
|
-
this.depositedAmount =
|
|
38
|
+
this.depositedAmount = (0, bignumber_js_1.default)(stream.amount);
|
|
75
39
|
this.period = parseInt(stream.period);
|
|
76
|
-
this.amountPerPeriod =
|
|
40
|
+
this.amountPerPeriod = (0, bignumber_js_1.default)(stream.amount_per_period);
|
|
77
41
|
this.cliff = parseInt(stream.start);
|
|
78
|
-
this.cliffAmount =
|
|
42
|
+
this.cliffAmount = (0, bignumber_js_1.default)(stream.cliff_amount);
|
|
79
43
|
this.cancelableBySender = meta.cancelable_by_sender;
|
|
80
44
|
this.cancelableByRecipient = meta.cancelable_by_recipient;
|
|
81
45
|
this.automaticWithdrawal = meta.automatic_withdrawal;
|
|
82
46
|
this.transferableBySender = meta.transferable_by_sender;
|
|
83
47
|
this.transferableByRecipient = meta.transferable_by_recipient;
|
|
84
48
|
this.canTopup = meta.can_topup;
|
|
85
|
-
this.name = String.fromCharCode
|
|
49
|
+
this.name = String.fromCharCode(...meta.contract_name);
|
|
86
50
|
this.withdrawalFrequency = parseInt(meta.withdrawal_frequency);
|
|
87
51
|
this.closed = stream.closed;
|
|
88
52
|
this.currentPauseStart = parseInt(stream.current_pause_start);
|
|
89
|
-
this.pauseCumulative =
|
|
53
|
+
this.pauseCumulative = (0, bignumber_js_1.default)(stream.pause_cumulative);
|
|
90
54
|
this.lastRateChangeTime = parseInt(stream.last_rate_change_time);
|
|
91
|
-
this.fundsUnlockedAtLastRateChange =
|
|
55
|
+
this.fundsUnlockedAtLastRateChange = (0, bignumber_js_1.default)(stream.funds_unlocked_at_last_rate_change);
|
|
92
56
|
this.type = (0, contractUtils_js_1.buildStreamType)(this);
|
|
93
57
|
}
|
|
94
|
-
|
|
95
|
-
return (0, contractUtils_js_1.calculateUnlockedAmount)(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
58
|
+
unlocked(currentTimestamp) {
|
|
59
|
+
return (0, contractUtils_js_1.calculateUnlockedAmount)({
|
|
60
|
+
...this,
|
|
61
|
+
currentTimestamp,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
remaining(decimals) {
|
|
65
|
+
return (0, utils_js_1.getNumberFromBigNumber)(this.depositedAmount.minus(this.withdrawnAmount), decimals);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
102
68
|
exports.Contract = Contract;
|
package/dist/cjs/sui/utils.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.extractSuiErrorInfo = void 0;
|
|
4
|
-
|
|
4
|
+
const constants_js_1 = require("./constants.js");
|
|
5
5
|
function extractSuiErrorInfo(errorText) {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const error = { text: errorText };
|
|
7
|
+
const match = constants_js_1.SUI_ERROR_MATCH_REGEX.exec(errorText);
|
|
8
8
|
if (!match) {
|
|
9
9
|
return error;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
const moduleName = match[2];
|
|
12
|
+
const errorCode = Number(match[4]);
|
|
13
|
+
const errorName = constants_js_1.SUI_MODULE_ERROR_MAP[moduleName] ? constants_js_1.SUI_MODULE_ERROR_MAP[moduleName][errorCode] : undefined;
|
|
14
|
+
const index = Number(match[5]);
|
|
15
15
|
if (index) {
|
|
16
16
|
error.index = index;
|
|
17
17
|
}
|
package/dist/cjs/sui/wallet.js
CHANGED
|
@@ -1,54 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
3
|
exports.SuiWalletWrapper = exports.isSignerKeypair = void 0;
|
|
51
|
-
|
|
4
|
+
const cryptography_1 = require("@mysten/sui.js/cryptography");
|
|
52
5
|
/**
|
|
53
6
|
* Utility function to check if the transaction initiator is a Wallet object
|
|
54
7
|
* @param {Keypair | WalletContextState} walletOrKeypair - Wallet or Keypair in question
|
|
@@ -61,8 +14,8 @@ function isSignerKeypair(walletOrKeypair) {
|
|
|
61
14
|
"export" in walletOrKeypair);
|
|
62
15
|
}
|
|
63
16
|
exports.isSignerKeypair = isSignerKeypair;
|
|
64
|
-
|
|
65
|
-
|
|
17
|
+
class SuiWalletWrapper {
|
|
18
|
+
constructor(wallet, client) {
|
|
66
19
|
this.client = client;
|
|
67
20
|
this.wallet = wallet;
|
|
68
21
|
if (isSignerKeypair(wallet)) {
|
|
@@ -72,19 +25,16 @@ var SuiWalletWrapper = /** @class */ (function () {
|
|
|
72
25
|
this.address = wallet.address;
|
|
73
26
|
}
|
|
74
27
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return
|
|
78
|
-
|
|
79
|
-
return [2 /*return*/, this.client.signAndExecuteTransactionBlock(__assign(__assign({}, input), {
|
|
80
|
-
// @ts-ignore
|
|
81
|
-
signer: this.wallet }))];
|
|
82
|
-
}
|
|
28
|
+
async signAndExecuteTransactionBlock(input) {
|
|
29
|
+
if (isSignerKeypair(this.wallet)) {
|
|
30
|
+
return this.client.signAndExecuteTransactionBlock({
|
|
31
|
+
...input,
|
|
83
32
|
// @ts-ignore
|
|
84
|
-
|
|
33
|
+
signer: this.wallet,
|
|
85
34
|
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
35
|
+
}
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
return this.wallet.signAndExecuteTransactionBlock(input);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
90
40
|
exports.SuiWalletWrapper = SuiWalletWrapper;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BigNumber } from "bignumber.js";
|
|
2
2
|
import { describe, expect, test, beforeEach, vi } from "vitest";
|
|
3
3
|
import AptosStreamClient from "../../aptos/StreamClient.js";
|
|
4
4
|
import { ICluster } from "../../common/types.js";
|
|
@@ -32,10 +32,10 @@ describe("AptosStreamClient", () => {
|
|
|
32
32
|
};
|
|
33
33
|
const mockRecipient = {
|
|
34
34
|
recipient: "0xtest",
|
|
35
|
-
amount:
|
|
35
|
+
amount: BigNumber(1000),
|
|
36
36
|
name: "test name",
|
|
37
|
-
cliffAmount:
|
|
38
|
-
amountPerPeriod:
|
|
37
|
+
cliffAmount: BigNumber(1),
|
|
38
|
+
amountPerPeriod: BigNumber(1),
|
|
39
39
|
};
|
|
40
40
|
const mockData = {
|
|
41
41
|
period: 100,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { default, default as AptosStreamClient } from "./StreamClient.js";
|
|
2
|
-
export * from "./utils";
|
|
3
|
-
export * from "./types";
|
|
4
|
-
export * as constants from "./constants";
|
|
2
|
+
export * from "./utils.js";
|
|
3
|
+
export * from "./types.js";
|
|
4
|
+
export * as constants from "./constants.js";
|
package/dist/esm/aptos/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { default, default as AptosStreamClient } from "./StreamClient.js";
|
|
2
|
-
export * from "./utils";
|
|
3
|
-
export * from "./types";
|
|
4
|
-
export * as constants from "./constants";
|
|
2
|
+
export * from "./utils.js";
|
|
3
|
+
export * from "./types.js";
|
|
4
|
+
export * as constants from "./constants.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AptosAccount } from "aptos";
|
|
2
2
|
import { WalletContextState } from "@manahippo/aptos-wallet-adapter";
|
|
3
|
-
import
|
|
3
|
+
import BigNumber from "bignumber.js";
|
|
4
4
|
import { Stream, StreamType } from "../common/types.js";
|
|
5
5
|
export interface ICreateStreamAptosExt {
|
|
6
6
|
senderWallet: WalletContextState | AptosAccount;
|
|
@@ -63,7 +63,7 @@ export declare class Contract implements Stream {
|
|
|
63
63
|
magic: number;
|
|
64
64
|
version: number;
|
|
65
65
|
createdAt: number;
|
|
66
|
-
withdrawnAmount:
|
|
66
|
+
withdrawnAmount: BigNumber;
|
|
67
67
|
canceledAt: number;
|
|
68
68
|
end: number;
|
|
69
69
|
lastWithdrawnAt: number;
|
|
@@ -75,20 +75,20 @@ export declare class Contract implements Stream {
|
|
|
75
75
|
escrowTokens: string;
|
|
76
76
|
streamflowTreasury: string;
|
|
77
77
|
streamflowTreasuryTokens: string;
|
|
78
|
-
streamflowFeeTotal:
|
|
79
|
-
streamflowFeeWithdrawn:
|
|
78
|
+
streamflowFeeTotal: BigNumber;
|
|
79
|
+
streamflowFeeWithdrawn: BigNumber;
|
|
80
80
|
streamflowFeePercent: number;
|
|
81
|
-
partnerFeeTotal:
|
|
82
|
-
partnerFeeWithdrawn:
|
|
81
|
+
partnerFeeTotal: BigNumber;
|
|
82
|
+
partnerFeeWithdrawn: BigNumber;
|
|
83
83
|
partnerFeePercent: number;
|
|
84
84
|
partner: string;
|
|
85
85
|
partnerTokens: string;
|
|
86
86
|
start: number;
|
|
87
|
-
depositedAmount:
|
|
87
|
+
depositedAmount: BigNumber;
|
|
88
88
|
period: number;
|
|
89
|
-
amountPerPeriod:
|
|
89
|
+
amountPerPeriod: BigNumber;
|
|
90
90
|
cliff: number;
|
|
91
|
-
cliffAmount:
|
|
91
|
+
cliffAmount: BigNumber;
|
|
92
92
|
cancelableBySender: boolean;
|
|
93
93
|
cancelableByRecipient: boolean;
|
|
94
94
|
automaticWithdrawal: boolean;
|
|
@@ -99,11 +99,11 @@ export declare class Contract implements Stream {
|
|
|
99
99
|
withdrawalFrequency: number;
|
|
100
100
|
closed: boolean;
|
|
101
101
|
currentPauseStart: number;
|
|
102
|
-
pauseCumulative:
|
|
102
|
+
pauseCumulative: BigNumber;
|
|
103
103
|
lastRateChangeTime: number;
|
|
104
|
-
fundsUnlockedAtLastRateChange:
|
|
104
|
+
fundsUnlockedAtLastRateChange: BigNumber;
|
|
105
105
|
type: StreamType;
|
|
106
106
|
constructor(stream: StreamResource, tokenId: string);
|
|
107
|
-
unlocked(currentTimestamp: number):
|
|
107
|
+
unlocked(currentTimestamp: number): BigNumber;
|
|
108
108
|
remaining(decimals: number): number;
|
|
109
109
|
}
|
package/dist/esm/aptos/types.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
2
|
import { Buffer } from "buffer";
|
|
3
3
|
import { buildStreamType, calculateUnlockedAmount } from "../common/contractUtils.js";
|
|
4
|
-
import { getNumberFromBN } from "../common/utils.js";
|
|
5
4
|
import { normalizeAptosAddress } from "./utils.js";
|
|
5
|
+
import { getNumberFromBigNumber } from "../common/utils.js";
|
|
6
6
|
export class Contract {
|
|
7
7
|
magic;
|
|
8
8
|
version;
|
|
@@ -51,7 +51,7 @@ export class Contract {
|
|
|
51
51
|
this.magic = 0;
|
|
52
52
|
this.version = 0;
|
|
53
53
|
this.createdAt = parseInt(stream.created);
|
|
54
|
-
this.withdrawnAmount =
|
|
54
|
+
this.withdrawnAmount = BigNumber(stream.withdrawn);
|
|
55
55
|
this.canceledAt = parseInt(stream.canceled_at);
|
|
56
56
|
this.end = parseInt(stream.end);
|
|
57
57
|
this.lastWithdrawnAt = parseInt(stream.last_withdrawn_at);
|
|
@@ -63,20 +63,20 @@ export class Contract {
|
|
|
63
63
|
this.escrowTokens = "";
|
|
64
64
|
this.streamflowTreasury = "";
|
|
65
65
|
this.streamflowTreasuryTokens = "";
|
|
66
|
-
this.streamflowFeeTotal =
|
|
67
|
-
this.streamflowFeeWithdrawn =
|
|
66
|
+
this.streamflowFeeTotal = BigNumber(0);
|
|
67
|
+
this.streamflowFeeWithdrawn = BigNumber(0);
|
|
68
68
|
this.streamflowFeePercent = parseInt(stream.fees.streamflow_fee_percentage) / 10000;
|
|
69
|
-
this.partnerFeeTotal =
|
|
70
|
-
this.partnerFeeWithdrawn =
|
|
69
|
+
this.partnerFeeTotal = BigNumber(0);
|
|
70
|
+
this.partnerFeeWithdrawn = BigNumber(0);
|
|
71
71
|
this.partnerFeePercent = 0;
|
|
72
72
|
this.partner = "";
|
|
73
73
|
this.partnerTokens = "";
|
|
74
74
|
this.start = parseInt(stream.start);
|
|
75
|
-
this.depositedAmount =
|
|
75
|
+
this.depositedAmount = BigNumber(stream.amount);
|
|
76
76
|
this.period = parseInt(stream.period);
|
|
77
|
-
this.amountPerPeriod =
|
|
77
|
+
this.amountPerPeriod = BigNumber(stream.amount_per_period);
|
|
78
78
|
this.cliff = parseInt(stream.start);
|
|
79
|
-
this.cliffAmount =
|
|
79
|
+
this.cliffAmount = BigNumber(stream.cliff_amount);
|
|
80
80
|
this.cancelableBySender = stream.meta.cancelable_by_sender;
|
|
81
81
|
this.cancelableByRecipient = stream.meta.cancelable_by_recipient;
|
|
82
82
|
this.automaticWithdrawal = stream.meta.automatic_withdrawal;
|
|
@@ -88,9 +88,9 @@ export class Contract {
|
|
|
88
88
|
this.withdrawalFrequency = parseInt(stream.meta.withdrawal_frequency);
|
|
89
89
|
this.closed = stream.closed;
|
|
90
90
|
this.currentPauseStart = parseInt(stream.current_pause_start);
|
|
91
|
-
this.pauseCumulative =
|
|
91
|
+
this.pauseCumulative = BigNumber(stream.pause_cumulative);
|
|
92
92
|
this.lastRateChangeTime = parseInt(stream.last_rate_change_time);
|
|
93
|
-
this.fundsUnlockedAtLastRateChange =
|
|
93
|
+
this.fundsUnlockedAtLastRateChange = BigNumber(stream.funds_unlocked_at_last_rate_change);
|
|
94
94
|
this.type = buildStreamType(this);
|
|
95
95
|
}
|
|
96
96
|
unlocked(currentTimestamp) {
|
|
@@ -100,6 +100,6 @@ export class Contract {
|
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
remaining(decimals) {
|
|
103
|
-
return
|
|
103
|
+
return getNumberFromBigNumber(this.depositedAmount.minus(this.withdrawnAmount), decimals);
|
|
104
104
|
}
|
|
105
105
|
}
|
|
@@ -3,10 +3,10 @@ import { Signer } from "ethers";
|
|
|
3
3
|
import PQueue from "p-queue";
|
|
4
4
|
import { BaseStreamClient } from "./BaseStreamClient.js";
|
|
5
5
|
import { ICancelData, IChain, ICluster, ICreateMultipleStreamData, ICreateStreamData, IGetOneData, ITopUpData, ITransferData, IUpdateData, IWithdrawData, ITransactionResult, IMultiTransactionResult, ICreateResult, IGetAllData, Stream, IFees, IGetFeesData } from "./types.js";
|
|
6
|
-
import { AptosStreamClient, ICreateStreamAptosExt, ITransactionAptosExt } from "../aptos";
|
|
7
|
-
import { EvmStreamClient } from "../evm";
|
|
8
|
-
import { SolanaStreamClient, ICreateStreamSolanaExt, IInteractStreamSolanaExt, ITopUpStreamSolanaExt } from "../solana";
|
|
9
|
-
import { ICreateStreamSuiExt, ITransactionSuiExt, ISuiIdParameters, SuiStreamClient } from "../sui";
|
|
6
|
+
import { AptosStreamClient, ICreateStreamAptosExt, ITransactionAptosExt } from "../aptos/index.js";
|
|
7
|
+
import { EvmStreamClient } from "../evm/index.js";
|
|
8
|
+
import { SolanaStreamClient, ICreateStreamSolanaExt, IInteractStreamSolanaExt, ITopUpStreamSolanaExt } from "../solana/index.js";
|
|
9
|
+
import { ICreateStreamSuiExt, ITransactionSuiExt, ISuiIdParameters, SuiStreamClient } from "../sui/index.js";
|
|
10
10
|
export interface SolanaStreamClientOptions {
|
|
11
11
|
chain: IChain.Solana;
|
|
12
12
|
clusterUrl: string;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BaseStreamClient } from "./BaseStreamClient.js";
|
|
2
2
|
import { IChain, } from "./types.js";
|
|
3
3
|
import { handleContractError } from "./utils.js";
|
|
4
|
-
import { AptosStreamClient } from "../aptos";
|
|
5
|
-
import { EvmStreamClient } from "../evm";
|
|
6
|
-
import { SolanaStreamClient } from "../solana";
|
|
7
|
-
import { SuiStreamClient } from "../sui";
|
|
4
|
+
import { AptosStreamClient } from "../aptos/index.js";
|
|
5
|
+
import { EvmStreamClient } from "../evm/index.js";
|
|
6
|
+
import { SolanaStreamClient, } from "../solana/index.js";
|
|
7
|
+
import { SuiStreamClient } from "../sui/index.js";
|
|
8
8
|
import { WITHDRAW_AVAILABLE_AMOUNT } from "./constants.js";
|
|
9
9
|
/** Generic Stream Client implementation that wrap Chain Client methods and enriches error messages if possible
|
|
10
10
|
* @property {StreamClientType} - Chain Client implementation
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
2
|
export declare const BASE_FEE = 1009900;
|
|
3
|
-
export declare const WITHDRAW_AVAILABLE_AMOUNT:
|
|
3
|
+
export declare const WITHDRAW_AVAILABLE_AMOUNT: BigNumber;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
2
|
export const BASE_FEE = 1009900; // Buffer to include usual fees when calculating stream amount
|
|
3
|
-
export const WITHDRAW_AVAILABLE_AMOUNT =
|
|
3
|
+
export const WITHDRAW_AVAILABLE_AMOUNT = BigNumber("18446744073709551615"); // Magical number to withdraw all available amount from a Contract
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
2
|
import { StreamType } from "./types.js";
|
|
3
3
|
interface ICalculateUnlockedAmount {
|
|
4
|
-
depositedAmount:
|
|
4
|
+
depositedAmount: BigNumber;
|
|
5
5
|
cliff: number;
|
|
6
|
-
cliffAmount:
|
|
6
|
+
cliffAmount: BigNumber;
|
|
7
7
|
end: number;
|
|
8
8
|
currentTimestamp: number;
|
|
9
9
|
lastRateChangeTime: number;
|
|
10
10
|
period: number;
|
|
11
|
-
amountPerPeriod:
|
|
12
|
-
fundsUnlockedAtLastRateChange:
|
|
11
|
+
amountPerPeriod: BigNumber;
|
|
12
|
+
fundsUnlockedAtLastRateChange: BigNumber;
|
|
13
13
|
}
|
|
14
|
-
export declare const calculateUnlockedAmount: ({ depositedAmount, cliff, cliffAmount, end, currentTimestamp, lastRateChangeTime, period, amountPerPeriod, fundsUnlockedAtLastRateChange, }: ICalculateUnlockedAmount) =>
|
|
14
|
+
export declare const calculateUnlockedAmount: ({ depositedAmount, cliff, cliffAmount, end, currentTimestamp, lastRateChangeTime, period, amountPerPeriod, fundsUnlockedAtLastRateChange, }: ICalculateUnlockedAmount) => BigNumber;
|
|
15
15
|
export declare const isCliffCloseToDepositedAmount: (streamData: {
|
|
16
|
-
depositedAmount:
|
|
17
|
-
cliffAmount:
|
|
16
|
+
depositedAmount: BigNumber;
|
|
17
|
+
cliffAmount: BigNumber;
|
|
18
18
|
}) => boolean;
|
|
19
19
|
export declare const isPayment: (streamData: {
|
|
20
20
|
canTopup: boolean;
|
|
21
21
|
}) => boolean;
|
|
22
22
|
export declare const isVesting: (streamData: {
|
|
23
23
|
canTopup: boolean;
|
|
24
|
-
depositedAmount:
|
|
25
|
-
cliffAmount:
|
|
24
|
+
depositedAmount: BigNumber;
|
|
25
|
+
cliffAmount: BigNumber;
|
|
26
26
|
}) => boolean;
|
|
27
27
|
export declare const isTokenLock: (streamData: {
|
|
28
28
|
canTopup: boolean;
|
|
@@ -31,8 +31,8 @@ export declare const isTokenLock: (streamData: {
|
|
|
31
31
|
cancelableByRecipient: boolean;
|
|
32
32
|
transferableBySender: boolean;
|
|
33
33
|
transferableByRecipient: boolean;
|
|
34
|
-
depositedAmount:
|
|
35
|
-
cliffAmount:
|
|
34
|
+
depositedAmount: BigNumber;
|
|
35
|
+
cliffAmount: BigNumber;
|
|
36
36
|
}) => boolean;
|
|
37
37
|
export declare const buildStreamType: (streamData: {
|
|
38
38
|
canTopup: boolean;
|
|
@@ -41,7 +41,7 @@ export declare const buildStreamType: (streamData: {
|
|
|
41
41
|
cancelableByRecipient: boolean;
|
|
42
42
|
transferableBySender: boolean;
|
|
43
43
|
transferableByRecipient: boolean;
|
|
44
|
-
depositedAmount:
|
|
45
|
-
cliffAmount:
|
|
44
|
+
depositedAmount: BigNumber;
|
|
45
|
+
cliffAmount: BigNumber;
|
|
46
46
|
}) => StreamType;
|
|
47
47
|
export {};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
2
|
import { StreamType } from "./types.js";
|
|
3
3
|
export const calculateUnlockedAmount = ({ depositedAmount, cliff, cliffAmount, end, currentTimestamp, lastRateChangeTime, period, amountPerPeriod, fundsUnlockedAtLastRateChange, }) => {
|
|
4
4
|
const deposited = depositedAmount;
|
|
5
5
|
if (currentTimestamp < cliff)
|
|
6
|
-
return
|
|
6
|
+
return BigNumber(0);
|
|
7
7
|
if (currentTimestamp > end)
|
|
8
8
|
return deposited;
|
|
9
9
|
const savedUnlockedFunds = lastRateChangeTime === 0 ? cliffAmount : fundsUnlockedAtLastRateChange;
|
|
10
10
|
const savedUnlockedFundsTime = lastRateChangeTime === 0 ? cliff : lastRateChangeTime;
|
|
11
|
-
const streamed =
|
|
12
|
-
.
|
|
13
|
-
.
|
|
11
|
+
const streamed = BigNumber(Math.floor((currentTimestamp - savedUnlockedFundsTime) / period))
|
|
12
|
+
.times(amountPerPeriod)
|
|
13
|
+
.plus(savedUnlockedFunds);
|
|
14
14
|
return streamed.lt(deposited) ? streamed : deposited;
|
|
15
15
|
};
|
|
16
16
|
export const isCliffCloseToDepositedAmount = (streamData) => {
|
|
17
|
-
return streamData.cliffAmount.gte(streamData.depositedAmount.
|
|
17
|
+
return streamData.cliffAmount.gte(streamData.depositedAmount.minus(BigNumber(1)));
|
|
18
18
|
};
|
|
19
19
|
export const isPayment = (streamData) => {
|
|
20
20
|
return streamData.canTopup;
|