@suilend/sui-fe-next 3.0.1 → 3.0.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.
|
@@ -56,18 +56,30 @@ export default function useFetchBalances() {
|
|
|
56
56
|
var suiGrpcClient = useSettingsContext().suiGrpcClient;
|
|
57
57
|
var address = useWalletContext().address;
|
|
58
58
|
var dataFetcher = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
59
|
-
var balancesMap,
|
|
59
|
+
var balancesMap, allBalances, cursor, hasNextPage, result, rawBalances, _i, rawBalances_1, rawBalance, totalBalance;
|
|
60
60
|
return __generator(this, function (_a) {
|
|
61
61
|
switch (_a.label) {
|
|
62
62
|
case 0:
|
|
63
63
|
balancesMap = {};
|
|
64
|
-
if (!address) return [3 /*break*/,
|
|
64
|
+
if (!address) return [3 /*break*/, 4];
|
|
65
|
+
allBalances = [];
|
|
66
|
+
cursor = null;
|
|
67
|
+
hasNextPage = true;
|
|
68
|
+
_a.label = 1;
|
|
69
|
+
case 1:
|
|
70
|
+
if (!hasNextPage) return [3 /*break*/, 3];
|
|
65
71
|
return [4 /*yield*/, suiGrpcClient.listBalances({
|
|
66
72
|
owner: address,
|
|
73
|
+
cursor: cursor,
|
|
67
74
|
})];
|
|
68
|
-
case
|
|
69
|
-
|
|
70
|
-
|
|
75
|
+
case 2:
|
|
76
|
+
result = _a.sent();
|
|
77
|
+
allBalances = allBalances.concat(result.balances);
|
|
78
|
+
cursor = result.cursor;
|
|
79
|
+
hasNextPage = result.hasNextPage;
|
|
80
|
+
return [3 /*break*/, 1];
|
|
81
|
+
case 3:
|
|
82
|
+
rawBalances = allBalances
|
|
71
83
|
.map(function (b) { return (__assign(__assign({}, b), { coinType: normalizeStructTag(b.coinType) })); })
|
|
72
84
|
.sort(function (a, b) { return (a.coinType < b.coinType ? -1 : 1); });
|
|
73
85
|
for (_i = 0, rawBalances_1 = rawBalances; _i < rawBalances_1.length; _i++) {
|
|
@@ -76,8 +88,8 @@ export default function useFetchBalances() {
|
|
|
76
88
|
if (totalBalance.gt(0))
|
|
77
89
|
balancesMap[rawBalance.coinType] = totalBalance;
|
|
78
90
|
}
|
|
79
|
-
_a.label =
|
|
80
|
-
case
|
|
91
|
+
_a.label = 4;
|
|
92
|
+
case 4: return [2 /*return*/, balancesMap];
|
|
81
93
|
}
|
|
82
94
|
});
|
|
83
95
|
}); };
|
|
@@ -47,30 +47,42 @@ var useRefreshOnBalancesChange = function (refresh) {
|
|
|
47
47
|
return;
|
|
48
48
|
previousBalancesRef.current = undefined;
|
|
49
49
|
var interval = setInterval(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
50
|
-
var
|
|
50
|
+
var allBalances, cursor, hasNextPage, result, err_1;
|
|
51
51
|
return __generator(this, function (_a) {
|
|
52
52
|
switch (_a.label) {
|
|
53
53
|
case 0:
|
|
54
|
-
_a.trys.push([0,
|
|
54
|
+
_a.trys.push([0, 6, , 7]);
|
|
55
|
+
allBalances = [];
|
|
56
|
+
cursor = null;
|
|
57
|
+
hasNextPage = true;
|
|
58
|
+
_a.label = 1;
|
|
59
|
+
case 1:
|
|
60
|
+
if (!hasNextPage) return [3 /*break*/, 3];
|
|
55
61
|
return [4 /*yield*/, suiGrpcClient.listBalances({
|
|
56
62
|
owner: address,
|
|
63
|
+
cursor: cursor,
|
|
57
64
|
})];
|
|
58
|
-
case 1:
|
|
59
|
-
balances = (_a.sent()).balances;
|
|
60
|
-
if (!(previousBalancesRef.current !== undefined &&
|
|
61
|
-
!isEqual(balances, previousBalancesRef.current))) return [3 /*break*/, 3];
|
|
62
|
-
return [4 /*yield*/, refresh()];
|
|
63
65
|
case 2:
|
|
64
|
-
_a.sent();
|
|
65
|
-
|
|
66
|
+
result = _a.sent();
|
|
67
|
+
allBalances = allBalances.concat(result.balances);
|
|
68
|
+
cursor = result.cursor;
|
|
69
|
+
hasNextPage = result.hasNextPage;
|
|
70
|
+
return [3 /*break*/, 1];
|
|
66
71
|
case 3:
|
|
67
|
-
previousBalancesRef.current
|
|
68
|
-
|
|
72
|
+
if (!(previousBalancesRef.current !== undefined &&
|
|
73
|
+
!isEqual(allBalances, previousBalancesRef.current))) return [3 /*break*/, 5];
|
|
74
|
+
return [4 /*yield*/, refresh()];
|
|
69
75
|
case 4:
|
|
76
|
+
_a.sent();
|
|
77
|
+
_a.label = 5;
|
|
78
|
+
case 5:
|
|
79
|
+
previousBalancesRef.current = allBalances;
|
|
80
|
+
return [3 /*break*/, 7];
|
|
81
|
+
case 6:
|
|
70
82
|
err_1 = _a.sent();
|
|
71
83
|
console.error(err_1);
|
|
72
|
-
return [3 /*break*/,
|
|
73
|
-
case
|
|
84
|
+
return [3 /*break*/, 7];
|
|
85
|
+
case 7: return [2 /*return*/];
|
|
74
86
|
}
|
|
75
87
|
});
|
|
76
88
|
}); }, 1000 * 5);
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@suilend/sui-fe-next","version":"3.0.
|
|
1
|
+
{"name":"@suilend/sui-fe-next","version":"3.0.2","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","@walletconnect/universal-provider":"2.21.1","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.15.0","@mysten/wallet-standard":"0.20.0","@suilend/sui-fe":"3.0.1"}}
|