@suilend/sui-fe-next 3.0.9 → 3.1.0

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/lib/toasts.jsx CHANGED
@@ -1,49 +1,41 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
1
  import BigNumber from "bignumber.js";
13
2
  import { toast as sonnerToast } from "sonner";
14
3
  import { TOAST_DURATION_MS, TX_TOAST_DURATION as TX_TOAST_DURATION_MS, formatToken, } from "@suilend/sui-fe";
15
- var onDismiss = function (callback) {
16
- for (var i = 0; i < 10; i++)
4
+ const onDismiss = (callback) => {
5
+ for (let i = 0; i < 10; i++)
17
6
  sonnerToast.dismiss();
18
- setTimeout(function () {
7
+ setTimeout(() => {
19
8
  callback();
20
9
  }, 250);
21
10
  };
22
- export var showSuccessToast = function (title, data, isTxn) {
11
+ export const showSuccessToast = (title, data, isTxn) => {
23
12
  console.log(title, data);
24
- onDismiss(function () {
25
- return sonnerToast.success(title, __assign(__assign({}, (data || {})), { duration: isTxn ? TX_TOAST_DURATION_MS : TOAST_DURATION_MS }));
26
- });
13
+ onDismiss(() => sonnerToast.success(title, {
14
+ ...(data || {}),
15
+ duration: isTxn ? TX_TOAST_DURATION_MS : TOAST_DURATION_MS,
16
+ }));
27
17
  };
28
- export var showInfoToast = function (title, data) {
18
+ export const showInfoToast = (title, data) => {
29
19
  console.log(title, data);
30
- onDismiss(function () {
31
- return sonnerToast.info(title, __assign(__assign({}, (data || {})), { duration: TOAST_DURATION_MS }));
32
- });
20
+ onDismiss(() => sonnerToast.info(title, {
21
+ ...(data || {}),
22
+ duration: TOAST_DURATION_MS,
23
+ }));
33
24
  };
34
- export var showWarningToast = function (title, data) {
25
+ export const showWarningToast = (title, data) => {
35
26
  console.warn(title, data);
36
- onDismiss(function () {
37
- return sonnerToast.warning(title, __assign(__assign({}, (data || {})), { duration: TOAST_DURATION_MS }));
38
- });
27
+ onDismiss(() => sonnerToast.warning(title, {
28
+ ...(data || {}),
29
+ duration: TOAST_DURATION_MS,
30
+ }));
39
31
  };
40
- export var showErrorToast = function (title, err, data, isTxn) {
32
+ export const showErrorToast = (title, err, data, isTxn) => {
41
33
  console.error(err);
42
- var description = (err === null || err === void 0 ? void 0 : err.message) || "An unknown error occurred";
34
+ let description = err?.message || "An unknown error occurred";
43
35
  // RPC errors
44
36
  if (description.toLowerCase().includes("Invalid u256 value".toLowerCase()))
45
37
  return;
46
- var RPC_ERROR_PATTERNS = [
38
+ const RPC_ERROR_PATTERNS = [
47
39
  "failed to fetch",
48
40
  "networkerror",
49
41
  "network request failed",
@@ -56,27 +48,27 @@ export var showErrorToast = function (title, err, data, isTxn) {
56
48
  "etimedout",
57
49
  "err_network",
58
50
  ];
59
- if (RPC_ERROR_PATTERNS.some(function (pattern) {
60
- return description.toLowerCase().includes(pattern);
61
- })) {
51
+ if (RPC_ERROR_PATTERNS.some((pattern) => description.toLowerCase().includes(pattern))) {
62
52
  description = "Try switching RPC provider in Settings";
63
53
  }
64
54
  // Insufficient SUI balance to pay for gas
65
55
  if (description.toLowerCase().includes("Balance of gas object".toLowerCase())) {
66
- var match = description.match(/Balance of gas object (\d+) is lower than the needed amount: (\d+)/);
56
+ const match = description.match(/Balance of gas object (\d+) is lower than the needed amount: (\d+)/);
67
57
  if (match) {
68
- var balanceRaw = match[1], neededAmountRaw = match[2];
69
- description = "Insufficient SUI balance to pay for gas. Balance: ".concat(formatToken(new BigNumber(balanceRaw).div(Math.pow(10, 9)), { dp: 9, trimTrailingZeros: true }), " SUI. Required: ").concat(formatToken(new BigNumber(neededAmountRaw).div(Math.pow(10, 9)), { dp: 9, trimTrailingZeros: true }), " SUI");
58
+ const [, balanceRaw, neededAmountRaw] = match;
59
+ description = `Insufficient SUI balance to pay for gas. Balance: ${formatToken(new BigNumber(balanceRaw).div(10 ** 9), { dp: 9, trimTrailingZeros: true })} SUI. Required: ${formatToken(new BigNumber(neededAmountRaw).div(10 ** 9), { dp: 9, trimTrailingZeros: true })} SUI`;
70
60
  }
71
61
  }
72
62
  // Ledger
73
63
  if (description.toLowerCase() ===
74
64
  "Make sure the Sui app is open on your device.".toLowerCase()) {
75
- description = "".concat(description.slice(0, -1), " and set 'Using a Ledger' to ON in Settings.");
65
+ description = `${description.slice(0, -1)} and set 'Using a Ledger' to ON in Settings.`;
76
66
  }
77
67
  if (description[0].toLowerCase() === description[0])
78
- description = "".concat(description[0].toUpperCase()).concat(description.slice(1));
79
- onDismiss(function () {
80
- return sonnerToast.error(title, __assign(__assign({}, (data || {})), { description: description, duration: isTxn ? TX_TOAST_DURATION_MS : TOAST_DURATION_MS }));
81
- });
68
+ description = `${description[0].toUpperCase()}${description.slice(1)}`;
69
+ onDismiss(() => sonnerToast.error(title, {
70
+ ...(data || {}),
71
+ description,
72
+ duration: isTxn ? TX_TOAST_DURATION_MS : TOAST_DURATION_MS,
73
+ }));
82
74
  };
package/lib/track.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import mixpanel from "mixpanel-browser";
2
- var track = function (eventName, properties) {
3
- var projectToken = process.env.NEXT_PUBLIC_MIXPANEL_PROJECT_TOKEN;
2
+ const track = (eventName, properties) => {
3
+ const projectToken = process.env.NEXT_PUBLIC_MIXPANEL_PROJECT_TOKEN;
4
4
  if (!projectToken)
5
5
  return;
6
6
  try {
7
- setTimeout(function () {
7
+ setTimeout(() => {
8
8
  mixpanel.track(eventName, properties);
9
9
  }, 250);
10
10
  }
package/package.json CHANGED
@@ -1 +1,85 @@
1
- {"name":"@suilend/sui-fe-next","version":"3.0.9","private":false,"description":"A collection of TypeScript frontend components and hooks","author":"Suilend","license":"MIT","main":"./index.js","exports":{".":"./index.js","./contexts/WalletContext":"./contexts/WalletContext.jsx","./contexts/SettingsContext":"./contexts/SettingsContext.jsx","./contexts":"./contexts/index.js","./fetchers":"./fetchers/index.js","./fetchers/useFetchBalances":"./fetchers/useFetchBalances.js","./hooks/useRefreshOnBalancesChange":"./hooks/useRefreshOnBalancesChange.js","./hooks/useLedgerHashDialog":"./hooks/useLedgerHashDialog.js","./hooks/useIsAndroid":"./hooks/useIsAndroid.jsx","./hooks/useCoinMetadataMap":"./hooks/useCoinMetadataMap.js","./hooks":"./hooks/index.js","./hooks/useIsTouchscreen":"./hooks/useIsTouchscreen.jsx","./hooks/useIsiOS":"./hooks/useIsiOS.jsx","./hooks/keypair":"./hooks/keypair.js","./lib/track":"./lib/track.js","./lib":"./lib/index.js","./lib/router":"./lib/router.js","./lib/toasts":"./lib/toasts.jsx","./lib/connector":"./lib/connector.js"},"types":"./index.js","scripts":{"build":"rm -rf ./dist && bun tsc","eslint":"eslint --fix src/","prettier":"prettier --write src/","lint":"bun eslint && bun prettier && bun tsc --noEmit","release":"bun run build && bun ./release.js && cd ./dist && npm publish --access public"},"repository":{"type":"git","url":"git+https://github.com/suilend/sui-fe.git"},"bugs":{"url":"https://github.com/suilend/sui-fe/issues"},"dependencies":{"@reown/appkit":"^1.8.10","@reown/appkit-common":"^1.8.10","@reown/appkit-universal-connector":"^1.8.10","@tanstack/react-query":"^5.60.2","@wallet-standard/app":"^1.1.0","bignumber.js":"^9.1.2","launchdarkly-react-client-sdk":"^3.6.0","lodash":"^4.17.21","mixpanel-browser":"^2.72.0","next":"^15.0.3","react":"18.3.1","react-dom":"18.3.1","react-responsive":"^10.0.0","sonner":"1.4.41","swr":"^2.2.5","tailwind-merge":"^2.5.4","usehooks-ts":"^3.1.1"},"devDependencies":{"@tsconfig/next":"^2.0.3","@types/lodash":"^4.17.13","@types/node":"^22.9.0","@types/react":"^18.3.12","@types/react-dom":"^18.3.1","@typescript-eslint/eslint-plugin":"^8.14.0","@typescript-eslint/parser":"^8.14.0","eslint":"^9.14.0","eslint-config-next":"^15.0.3","eslint-config-prettier":"^9.1.0","eslint-plugin-import":"^2.31.0","eslint-plugin-prettier":"^5.2.1","prettier":"^3.3.3","ts-node":"^10.9.2","typescript":"^5.6.3"},"peerDependencies":{"@mysten/dapp-kit-core":"1.3.0","@mysten/dapp-kit-react":"2.0.1","@mysten/sui":"2.17.0","@mysten/wallet-standard":"0.20.0","@suilend/sui-fe":"3.0.14"}}
1
+ {
2
+ "name": "@suilend/sui-fe-next",
3
+ "version": "3.1.0",
4
+ "private": false,
5
+ "description": "A collection of TypeScript frontend libraries for Next.js",
6
+ "author": "Suilend",
7
+ "license": "MIT",
8
+ "type": "module",
9
+ "sideEffects": false,
10
+ "main": "./index.js",
11
+ "types": "./index.d.ts",
12
+ "exports": {
13
+ ".": "./index.js",
14
+ "./contexts/SettingsContext": "./contexts/SettingsContext.jsx",
15
+ "./contexts/WalletContext": "./contexts/WalletContext.jsx",
16
+ "./contexts": "./contexts/index.js",
17
+ "./fetchers": "./fetchers/index.js",
18
+ "./fetchers/useFetchBalances": "./fetchers/useFetchBalances.js",
19
+ "./hooks": "./hooks/index.js",
20
+ "./hooks/keypair": "./hooks/keypair.js",
21
+ "./hooks/useCoinMetadataMap": "./hooks/useCoinMetadataMap.js",
22
+ "./hooks/useIsAndroid": "./hooks/useIsAndroid.jsx",
23
+ "./hooks/useIsTouchscreen": "./hooks/useIsTouchscreen.jsx",
24
+ "./hooks/useIsiOS": "./hooks/useIsiOS.jsx",
25
+ "./hooks/useLedgerHashDialog": "./hooks/useLedgerHashDialog.js",
26
+ "./hooks/useRefreshOnBalancesChange": "./hooks/useRefreshOnBalancesChange.js",
27
+ "./lib/connector": "./lib/connector.js",
28
+ "./lib": "./lib/index.js",
29
+ "./lib/router": "./lib/router.js",
30
+ "./lib/toasts": "./lib/toasts.jsx",
31
+ "./lib/track": "./lib/track.js"
32
+ },
33
+ "scripts": {
34
+ "build": "rm -rf ./dist ./tsconfig.tsbuildinfo && tsc",
35
+ "typecheck": "tsgo --noEmit",
36
+ "lint": "eslint . --fix",
37
+ "lint:ci": "eslint .",
38
+ "format": "prettier --write ./src/**/*.{ts,tsx}",
39
+ "clear": "rm -rf .turbo && rm -rf dist && rm -rf tsconfig.tsbuildinfo && rm -rf node_modules",
40
+ "release": "yarn build && node ../../scripts/prepare-npm-dist.mjs && cd ./dist && npm publish --access public"
41
+ },
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "git+https://github.com/fireflyprotocol/perpetual-ui.git",
45
+ "directory": "packages/sui-fe-next"
46
+ },
47
+ "dependencies": {
48
+ "@reown/appkit-universal-connector": "1.8.10",
49
+ "@suilend/sui-fe": "^3.0.14",
50
+ "bignumber.js": "9.3.1",
51
+ "launchdarkly-react-client-sdk": "3.9.2",
52
+ "lodash": "4.18.1",
53
+ "mixpanel-browser": "2.81.0",
54
+ "react-responsive": "10.0.1",
55
+ "sonner": "1.4.41",
56
+ "swr": "2.4.2",
57
+ "tailwind-merge": "2.6.1",
58
+ "usehooks-ts": "3.1.1"
59
+ },
60
+ "devDependencies": {
61
+ "@bluefin/eslint-config": "*",
62
+ "@tsconfig/next": "2.0.6",
63
+ "@types/lodash": "4.17.16",
64
+ "@types/mixpanel-browser": "2.60.0",
65
+ "@types/node": "20.17.46",
66
+ "@types/react": "19.2.14",
67
+ "@types/react-dom": "19.2.3",
68
+ "@typescript/native-preview": "7.0.0-dev.20260421.2",
69
+ "eslint": "9.25.1",
70
+ "globals": "15.15.0",
71
+ "next": "15.5.18",
72
+ "prettier": "3.5.3",
73
+ "typescript": "6.0.3",
74
+ "typescript-eslint": "8.31.0"
75
+ },
76
+ "peerDependencies": {
77
+ "@mysten/dapp-kit-core": ">=1.3.0",
78
+ "@mysten/dapp-kit-react": ">=2.0.1",
79
+ "@mysten/sui": ">=2.17.0 <3",
80
+ "@mysten/wallet-standard": ">=0.20.0",
81
+ "next": ">=15",
82
+ "react": "19.2.3",
83
+ "react-dom": "19.2.3"
84
+ }
85
+ }