@streamflow/stream 7.0.0-alpha.3 → 7.0.0-alpha.6
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/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/types.js +17 -26
- 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 +1 -1
- package/dist/cjs/common/contractUtils.js +12 -13
- package/dist/cjs/common/utils.js +21 -66
- package/dist/cjs/evm/StreamClient.js +198 -456
- package/dist/cjs/evm/constants.js +19 -20
- package/dist/cjs/evm/types.js +14 -23
- package/dist/cjs/evm/utils.js +2 -2
- package/dist/cjs/solana/StreamClient.js +592 -1090
- package/dist/cjs/solana/constants.js +9 -10
- package/dist/cjs/solana/instructions.js +60 -65
- package/dist/cjs/solana/layout.js +7 -8
- package/dist/cjs/solana/types.js +14 -24
- package/dist/cjs/solana/utils.js +48 -136
- package/dist/cjs/sui/StreamClient.js +325 -571
- package/dist/cjs/sui/constants.js +19 -20
- package/dist/cjs/sui/types.js +17 -51
- package/dist/cjs/sui/utils.js +7 -7
- package/dist/cjs/sui/wallet.js +13 -63
- package/package.json +4 -4
|
@@ -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,52 +1,16 @@
|
|
|
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);
|
|
@@ -82,7 +46,7 @@ var Contract = /** @class */ (function () {
|
|
|
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);
|
|
@@ -91,12 +55,14 @@ var Contract = /** @class */ (function () {
|
|
|
91
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
|
-
|
|
58
|
+
unlocked(currentTimestamp) {
|
|
59
|
+
return (0, contractUtils_js_1.calculateUnlockedAmount)({
|
|
60
|
+
...this,
|
|
61
|
+
currentTimestamp,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
remaining(decimals) {
|
|
98
65
|
return (0, utils_js_1.getNumberFromBigNumber)(this.depositedAmount.minus(this.withdrawnAmount), decimals);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
}());
|
|
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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamflow/stream",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.6",
|
|
4
4
|
"description": "JavaScript SDK to interact with Streamflow protocol.",
|
|
5
5
|
"homepage": "https://github.com/streamflow-finance/js-sdk/",
|
|
6
6
|
"main": "./dist/esm/index.js",
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"lint": "eslint --fix .",
|
|
43
43
|
"prepublishOnly": "npm run lint && npm test && npm run build"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "f789b5ddcc3d6fb9b84beb0b16f63c6348bd37ab",
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@streamflow/eslint-config": "7.0.0-alpha.
|
|
47
|
+
"@streamflow/eslint-config": "7.0.0-alpha.6",
|
|
48
48
|
"@types/ethereum-checksum-address": "^0.0.0",
|
|
49
49
|
"date-fns": "2.28.0",
|
|
50
50
|
"typescript": "^5.3.3"
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@solana/spl-token": "0.3.6",
|
|
58
58
|
"@solana/wallet-adapter-base": "0.9.19",
|
|
59
59
|
"@solana/web3.js": "1.70.1",
|
|
60
|
-
"@streamflow/common": "7.0.0-alpha.
|
|
60
|
+
"@streamflow/common": "7.0.0-alpha.6",
|
|
61
61
|
"@suiet/wallet-kit": "0.2.22",
|
|
62
62
|
"aptos": "1.4.0",
|
|
63
63
|
"bignumber.js": "^9.1.2",
|