@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.
@@ -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
- var types_js_1 = require("../common/types.js");
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 = (_a = {},
8
- _a[types_js_1.ICluster.Mainnet] = "0xe456a3a1d4e58e85b4b7175fabe6dae895b983f1379bb8948d6ec2f137b08a7b",
9
- _a[types_js_1.ICluster.Devnet] = "0x34dacd839e1758ebb70bdcd4e08f18fbfef5e2b96d9aa7ce2b4a71d96ca0df5a",
10
- _a[types_js_1.ICluster.Testnet] = "0x34dacd839e1758ebb70bdcd4e08f18fbfef5e2b96d9aa7ce2b4a71d96ca0df5a",
11
- _a[types_js_1.ICluster.Local] = "0x34dacd839e1758ebb70bdcd4e08f18fbfef5e2b96d9aa7ce2b4a71d96ca0df5a",
12
- _a);
13
- exports.SUI_CONFIG_IDS = (_b = {},
14
- _b[types_js_1.ICluster.Mainnet] = "0x6cf6760b64245b8d23ef57c28ddceb6adbd540a23a509fef29b82237da4ab87b",
15
- _b[types_js_1.ICluster.Devnet] = "0xd6c9f5074584f58074ce56e3c5cc436d82258ec3285f186a0d6438a60bacdbf8",
16
- _b[types_js_1.ICluster.Testnet] = "0xd6c9f5074584f58074ce56e3c5cc436d82258ec3285f186a0d6438a60bacdbf8",
17
- _b[types_js_1.ICluster.Local] = "0xd6c9f5074584f58074ce56e3c5cc436d82258ec3285f186a0d6438a60bacdbf8",
18
- _b);
19
- exports.SUI_FEE_TABLE_IDS = (_c = {},
20
- _c[types_js_1.ICluster.Mainnet] = "0xad9b75399632583fb9fcae6b5bcca34e6542ab3bedb630ecbd3f15cb1cc48dbe",
21
- _c[types_js_1.ICluster.Devnet] = "0x6057b093904c5bdfec1067d2b8a4dc35f65bcab03b3029ad716c4882b0f36078",
22
- _c[types_js_1.ICluster.Testnet] = "0x6057b093904c5bdfec1067d2b8a4dc35f65bcab03b3029ad716c4882b0f36078",
23
- _c[types_js_1.ICluster.Local] = "0x6057b093904c5bdfec1067d2b8a4dc35f65bcab03b3029ad716c4882b0f36078",
24
- _c);
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: {
@@ -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
- var bignumber_js_1 = __importDefault(require("bignumber.js"));
44
- var contractUtils_js_1 = require("../common/contractUtils.js");
45
- var utils_js_1 = require("../common/utils.js");
46
- var Contract = /** @class */ (function () {
47
- function Contract(stream, tokenId) {
48
- var meta = stream.meta.fields;
49
- var fees = stream.fees.fields;
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.apply(String, __spreadArray([], __read(meta.contract_name), false));
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
- Contract.prototype.unlocked = function (currentTimestamp) {
95
- return (0, contractUtils_js_1.calculateUnlockedAmount)(__assign(__assign({}, this), { currentTimestamp: currentTimestamp }));
96
- };
97
- Contract.prototype.remaining = function (decimals) {
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
- return Contract;
101
- }());
66
+ }
67
+ }
102
68
  exports.Contract = Contract;
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.extractSuiErrorInfo = void 0;
4
- var constants_js_1 = require("./constants.js");
4
+ const constants_js_1 = require("./constants.js");
5
5
  function extractSuiErrorInfo(errorText) {
6
- var error = { text: errorText };
7
- var match = constants_js_1.SUI_ERROR_MATCH_REGEX.exec(errorText);
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
- var moduleName = match[2];
12
- var errorCode = Number(match[4]);
13
- var errorName = constants_js_1.SUI_MODULE_ERROR_MAP[moduleName] ? constants_js_1.SUI_MODULE_ERROR_MAP[moduleName][errorCode] : undefined;
14
- var index = Number(match[5]);
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
  }
@@ -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
- var cryptography_1 = require("@mysten/sui.js/cryptography");
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
- var SuiWalletWrapper = /** @class */ (function () {
65
- function SuiWalletWrapper(wallet, client) {
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
- SuiWalletWrapper.prototype.signAndExecuteTransactionBlock = function (input) {
76
- return __awaiter(this, void 0, void 0, function () {
77
- return __generator(this, function (_a) {
78
- if (isSignerKeypair(this.wallet)) {
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
- return [2 /*return*/, this.wallet.signAndExecuteTransactionBlock(input)];
33
+ signer: this.wallet,
85
34
  });
86
- });
87
- };
88
- return SuiWalletWrapper;
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",
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": "1f0ce4ebcbbf9ac79f744a7ef232543b9e6d2a5b",
45
+ "gitHead": "f789b5ddcc3d6fb9b84beb0b16f63c6348bd37ab",
46
46
  "devDependencies": {
47
- "@streamflow/eslint-config": "7.0.0-alpha.3",
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.3",
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",