@taskon/widget-react 0.0.1-beta.1 → 0.0.1-beta.3
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 +55 -16
- package/dist/CommunityTaskList.css +432 -628
- package/dist/EligibilityInfo.css +944 -431
- package/dist/PageBuilder.css +0 -2
- package/dist/Quest.css +460 -506
- package/dist/TaskOnProvider.css +15 -15
- package/dist/UserCenterWidget.css +0 -174
- package/dist/UserCenterWidget2.css +1119 -341
- package/dist/chunks/{CommunityTaskList-DoPGZsw1.js → CommunityTaskList-C9mPl_31.js} +923 -829
- package/dist/chunks/{EligibilityInfo-C7GZ2G5u.js → EligibilityInfo-DGBffKN8.js} +1137 -449
- package/dist/chunks/{LeaderboardWidget-CmYfDeHV.js → LeaderboardWidget-DPOQVXkT.js} +15 -10
- package/dist/chunks/{PageBuilder-Tmhf2GTS.js → PageBuilder-WCZvxL2j.js} +5 -5
- package/dist/chunks/{Quest-DKFZ-pPU.js → Quest-DjGH_8bx.js} +464 -314
- package/dist/chunks/{TaskOnProvider-BD6Vp2x8.js → TaskOnProvider-iannERG1.js} +2 -207
- package/dist/chunks/{ThemeProvider-wnSXrNQb.js → ThemeProvider-DNJqI2lD.js} +246 -54
- package/dist/chunks/UserCenterWidget-B0O-f_xl.js +8344 -0
- package/dist/chunks/{UserCenterWidget-BVw_IEEd.js → UserCenterWidget-CAhgp46j.js} +214 -1011
- package/dist/chunks/{WidgetShell-D_5OjvNZ.js → dynamic-import-helper-B2j_dZ4V.js} +607 -40
- package/dist/chunks/useToast-CaRkylKe.js +304 -0
- package/dist/chunks/{usercenter-ja-uu-XfVF9.js → usercenter-ja-B2465c1O.js} +4 -10
- package/dist/chunks/{usercenter-ko-DYgUOVzd.js → usercenter-ko-xAEYxqLg.js} +4 -10
- package/dist/community-task.d.ts +34 -3
- package/dist/community-task.js +1 -1
- package/dist/core.d.ts +40 -3
- package/dist/core.js +9 -10
- package/dist/dynamic-import-helper.css +186 -0
- package/dist/index.d.ts +207 -10
- package/dist/index.js +21 -19
- package/dist/leaderboard.d.ts +8 -1
- package/dist/leaderboard.js +2 -2
- package/dist/page-builder.js +1 -1
- package/dist/quest.d.ts +8 -2
- package/dist/quest.js +1 -1
- package/dist/user-center.d.ts +20 -136
- package/dist/user-center.js +19 -236
- package/package.json +7 -2
- package/dist/TipPopover.css +0 -210
- package/dist/WidgetShell.css +0 -182
- package/dist/chunks/TipPopover-BrW8jo71.js +0 -2926
- package/dist/chunks/UserCenterWidget-BE329iS7.js +0 -3546
- package/dist/chunks/dynamic-import-helper-DxEFwm31.js +0 -537
- package/dist/chunks/useToast-B-wyO5zL.js +0 -93
- package/dist/chunks/useWidgetLocale-JDelxtt8.js +0 -74
package/dist/user-center.d.ts
CHANGED
|
@@ -214,31 +214,6 @@ export declare interface FrozenAssetListProps {
|
|
|
214
214
|
onClose?: () => void;
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
-
/**
|
|
218
|
-
* 免 Gas 提现状态(扩展 WithdrawStatus)
|
|
219
|
-
*/
|
|
220
|
-
export declare type GasFreeWithdrawStatus = WithdrawStatus | "polling";
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* 免 Gas 提现 Token 项
|
|
224
|
-
*/
|
|
225
|
-
export declare interface GasFreeWithdrawTokenItem {
|
|
226
|
-
/** Token ID */
|
|
227
|
-
tokenId: number;
|
|
228
|
-
/** Token 符号 */
|
|
229
|
-
tokenSymbol: string;
|
|
230
|
-
/** Token 图标 */
|
|
231
|
-
tokenIcon: string;
|
|
232
|
-
/** Token 合约地址 */
|
|
233
|
-
tokenAddress: string;
|
|
234
|
-
/** 链标识 */
|
|
235
|
-
chain: string;
|
|
236
|
-
/** 链名称 */
|
|
237
|
-
chainLabel: string;
|
|
238
|
-
/** 提现金额(显示值) */
|
|
239
|
-
amount: string;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
217
|
export { getChainIcon }
|
|
243
218
|
|
|
244
219
|
export { getChainName }
|
|
@@ -399,11 +374,6 @@ export declare interface TabBarProps {
|
|
|
399
374
|
className?: string;
|
|
400
375
|
}
|
|
401
376
|
|
|
402
|
-
/**
|
|
403
|
-
* 将 Token 余额转换为免 Gas 提现项
|
|
404
|
-
*/
|
|
405
|
-
export declare function toGasFreeWithdrawItem(token: UserTokenBalanceListItem): GasFreeWithdrawTokenItem;
|
|
406
|
-
|
|
407
377
|
/**
|
|
408
378
|
* TokenAssetList 组件
|
|
409
379
|
*
|
|
@@ -418,7 +388,7 @@ export declare function toGasFreeWithdrawItem(token: UserTokenBalanceListItem):
|
|
|
418
388
|
* />
|
|
419
389
|
* ```
|
|
420
390
|
*/
|
|
421
|
-
export declare function TokenAssetList({ data, loading, error, messages, pendingWithdrawals, onWithdraw, }: TokenAssetListProps): default_2.ReactElement;
|
|
391
|
+
export declare function TokenAssetList({ data, loading, error, messages, pendingWithdrawals, onWithdraw, onViewFrozen, }: TokenAssetListProps): default_2.ReactElement;
|
|
422
392
|
|
|
423
393
|
/**
|
|
424
394
|
* TokenAssetList 属性
|
|
@@ -731,105 +701,6 @@ export declare interface UseFrozenAssetsResult {
|
|
|
731
701
|
canResend: (item: LockedTokenListItem) => boolean;
|
|
732
702
|
}
|
|
733
703
|
|
|
734
|
-
/**
|
|
735
|
-
* 免 Gas 提现状态机 Hook
|
|
736
|
-
*
|
|
737
|
-
* @param options - 配置选项
|
|
738
|
-
* @returns 提现状态和操作方法
|
|
739
|
-
*
|
|
740
|
-
* @example
|
|
741
|
-
* ```tsx
|
|
742
|
-
* const {
|
|
743
|
-
* status,
|
|
744
|
-
* tokens,
|
|
745
|
-
* gasFreeRemaining,
|
|
746
|
-
* initWithdraw,
|
|
747
|
-
* checkAndConnect,
|
|
748
|
-
* confirmWithdraw,
|
|
749
|
-
* cancelWithdraw,
|
|
750
|
-
* } = useGasFreeWithdraw({
|
|
751
|
-
* userAddress: user.bindAddress,
|
|
752
|
-
* onSuccess: (txHash) => console.log('提现成功:', txHash),
|
|
753
|
-
* });
|
|
754
|
-
*
|
|
755
|
-
* // 发起免 Gas 提现
|
|
756
|
-
* const handleWithdraw = async (token) => {
|
|
757
|
-
* initWithdraw(token);
|
|
758
|
-
* const canProceed = await checkAndConnect();
|
|
759
|
-
* if (canProceed && gasFreeRemaining > 0) {
|
|
760
|
-
* // 显示确认弹窗
|
|
761
|
-
* }
|
|
762
|
-
* };
|
|
763
|
-
*
|
|
764
|
-
* // 用户确认后
|
|
765
|
-
* await confirmWithdraw();
|
|
766
|
-
*
|
|
767
|
-
* // 轮询状态提示
|
|
768
|
-
* {status === 'polling' && (
|
|
769
|
-
* <div>Processing withdrawal via Gas Station...</div>
|
|
770
|
-
* )}
|
|
771
|
-
* ```
|
|
772
|
-
*/
|
|
773
|
-
export declare function useGasFreeWithdraw(options?: UseGasFreeWithdrawOptions): UseGasFreeWithdrawResult;
|
|
774
|
-
|
|
775
|
-
/**
|
|
776
|
-
* useGasFreeWithdraw Hook 配置选项
|
|
777
|
-
*/
|
|
778
|
-
export declare interface UseGasFreeWithdrawOptions {
|
|
779
|
-
/** 用户绑定的钱包地址(用于验证) */
|
|
780
|
-
userAddress?: string;
|
|
781
|
-
/** 提现完成回调 */
|
|
782
|
-
onSuccess?: (txHash: string) => void;
|
|
783
|
-
/** 提现取消回调 */
|
|
784
|
-
onCancel?: () => void;
|
|
785
|
-
/** 提现失败回调 */
|
|
786
|
-
onError?: (error: Error) => void;
|
|
787
|
-
/** 钱包连接成功回调 */
|
|
788
|
-
onConnect?: (address: string) => void;
|
|
789
|
-
/** 轮询间隔(毫秒,默认 3000) */
|
|
790
|
-
pollingInterval?: number;
|
|
791
|
-
/** 最大轮询次数(默认 100) */
|
|
792
|
-
maxPollingAttempts?: number;
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
/**
|
|
796
|
-
* useGasFreeWithdraw Hook 返回结果
|
|
797
|
-
*/
|
|
798
|
-
export declare interface UseGasFreeWithdrawResult {
|
|
799
|
-
/** 当前状态 */
|
|
800
|
-
status: GasFreeWithdrawStatus;
|
|
801
|
-
/** 待提现的 Token 列表 */
|
|
802
|
-
tokens: GasFreeWithdrawTokenItem[];
|
|
803
|
-
/** 错误信息 */
|
|
804
|
-
error: Error | null;
|
|
805
|
-
/** 错误类型 */
|
|
806
|
-
errorType: TxErrorType | null;
|
|
807
|
-
/** 交易哈希(成功后) */
|
|
808
|
-
txHash: string | null;
|
|
809
|
-
/** 免 Gas 提现剩余次数 */
|
|
810
|
-
gasFreeRemaining: number | null;
|
|
811
|
-
/** 链信息是否已加载 */
|
|
812
|
-
chainMapLoaded: boolean;
|
|
813
|
-
/** 正在获取免 Gas 次数 */
|
|
814
|
-
gasFreeFetching: boolean;
|
|
815
|
-
/** 已连接的钱包地址 */
|
|
816
|
-
connectedAddress: string | null;
|
|
817
|
-
/** 初始化提现(单个 Token) */
|
|
818
|
-
initWithdraw: (token: UserTokenBalanceListItem) => void;
|
|
819
|
-
/** 初始化批量提现 */
|
|
820
|
-
initBatchWithdraw: (tokens: UserTokenBalanceListItem[]) => void;
|
|
821
|
-
/** 检查钱包并连接(在确认前调用) */
|
|
822
|
-
checkAndConnect: () => Promise<boolean>;
|
|
823
|
-
/** 确认提现 */
|
|
824
|
-
confirmWithdraw: () => Promise<void>;
|
|
825
|
-
/** 取消提现 */
|
|
826
|
-
cancelWithdraw: () => void;
|
|
827
|
-
/** 重置状态 */
|
|
828
|
-
reset: () => void;
|
|
829
|
-
/** 刷新免 Gas 次数 */
|
|
830
|
-
refreshGasFreeTimes: (chain: string) => Promise<void>;
|
|
831
|
-
}
|
|
832
|
-
|
|
833
704
|
/**
|
|
834
705
|
* 获取用户 Identity 数据
|
|
835
706
|
*
|
|
@@ -1016,12 +887,6 @@ export declare interface UserCenterMessages {
|
|
|
1016
887
|
cancel: string;
|
|
1017
888
|
/** 关闭按钮 */
|
|
1018
889
|
close: string;
|
|
1019
|
-
/** 免 Gas 提现按钮 */
|
|
1020
|
-
gasFreeWithdraw: string;
|
|
1021
|
-
/** 免 Gas 提现剩余次数 */
|
|
1022
|
-
gasFreeRemaining: string;
|
|
1023
|
-
/** 通过 Gas Station 处理中 */
|
|
1024
|
-
pollingStatus: string;
|
|
1025
890
|
/** Detail 列标题 */
|
|
1026
891
|
columnDetail: string;
|
|
1027
892
|
/** Duration 列标题 */
|
|
@@ -1226,12 +1091,24 @@ export declare interface UserCenterMessages {
|
|
|
1226
1091
|
claimSuccess?: string;
|
|
1227
1092
|
/** Claim 失败 */
|
|
1228
1093
|
claimFailed?: string;
|
|
1094
|
+
/** 用户取消 Claim */
|
|
1095
|
+
claimCanceled?: string;
|
|
1229
1096
|
/** 查看交易 */
|
|
1230
1097
|
viewOnExplorer?: string;
|
|
1231
1098
|
/** Pending 交易标题 */
|
|
1232
1099
|
pendingTransaction?: string;
|
|
1233
1100
|
/** Pending 交易提示 */
|
|
1234
1101
|
pendingTxMessage?: string;
|
|
1102
|
+
/** Pending 标题(原版文案) */
|
|
1103
|
+
claimPendingTitle?: string;
|
|
1104
|
+
/** Pending 跳转区块浏览器提示 */
|
|
1105
|
+
claimPendingCheckExplorer?: string;
|
|
1106
|
+
/** Pending 哈希标签 */
|
|
1107
|
+
claimPendingHashLabel?: string;
|
|
1108
|
+
/** Claim Again 风险提示 */
|
|
1109
|
+
claimPendingClaimAgainWarn?: string;
|
|
1110
|
+
/** 重发时接收地址不可更改提示 */
|
|
1111
|
+
claimPendingReceiveAddressNoChange?: string;
|
|
1235
1112
|
/** 继续等待 */
|
|
1236
1113
|
continueWaiting?: string;
|
|
1237
1114
|
/** 重新 Claim */
|
|
@@ -1244,6 +1121,8 @@ export declare interface UserCenterMessages {
|
|
|
1244
1121
|
errorNetworkSwitch?: string;
|
|
1245
1122
|
/** Gas 不足错误 */
|
|
1246
1123
|
errorInsufficientGas?: string;
|
|
1124
|
+
/** 提现前未绑定钱包地址 */
|
|
1125
|
+
walletNotBind?: string;
|
|
1247
1126
|
}
|
|
1248
1127
|
|
|
1249
1128
|
/**
|
|
@@ -1275,6 +1154,11 @@ export declare interface UserCenterWidgetProps {
|
|
|
1275
1154
|
* Cloud config provides tab options, display settings, etc.
|
|
1276
1155
|
*/
|
|
1277
1156
|
widgetId?: number;
|
|
1157
|
+
/**
|
|
1158
|
+
* Manual theme mode override (highest priority when provided).
|
|
1159
|
+
* Recommended with dual + toggle cloud strategy.
|
|
1160
|
+
*/
|
|
1161
|
+
themeMode?: "light" | "dark" | "auto";
|
|
1278
1162
|
/** Widget 配置 */
|
|
1279
1163
|
config?: UserCenterConfig;
|
|
1280
1164
|
/** 默认选中的 Tab */
|
package/dist/user-center.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { A, a, b, U, u, g, h, d, e, f, c } from "./chunks/UserCenterWidget-
|
|
1
|
+
import { A, a, b, U, u, g, h, d, e, f, c } from "./chunks/UserCenterWidget-CAhgp46j.js";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { L as LoadingState, E as EmptyState, P as Pagination } from "./chunks/UserCenterWidget-
|
|
4
|
-
import { T,
|
|
5
|
-
import { formatLocalDate, formatTokenAmount as formatTokenAmount$1, RewardType,
|
|
3
|
+
import { L as LoadingState, E as EmptyState, P as Pagination } from "./chunks/UserCenterWidget-B0O-f_xl.js";
|
|
4
|
+
import { F, T, d as d2, f as f2, t, c as c2, u as u2, a as a2, b as b2 } from "./chunks/UserCenterWidget-B0O-f_xl.js";
|
|
5
|
+
import { formatLocalDate, formatTokenAmount as formatTokenAmount$1, RewardType, createUserCenterApi } from "@taskon/core";
|
|
6
6
|
import { getChainIcon, getChainName, getSocialIcon, toWei, truncateAddress } from "@taskon/core";
|
|
7
|
-
import { D as Dialog } from "./chunks/
|
|
8
|
-
import { B as Button, T as Table, u as usePagination } from "./chunks/dynamic-import-helper-DxEFwm31.js";
|
|
7
|
+
import { D as Dialog, B as Button } from "./chunks/dynamic-import-helper-B2j_dZ4V.js";
|
|
9
8
|
import { useState, useMemo, useCallback, useEffect } from "react";
|
|
10
|
-
import {
|
|
9
|
+
import { d as useTaskOnContext } from "./chunks/ThemeProvider-DNJqI2lD.js";
|
|
11
10
|
function getTabLabel(tab, messages) {
|
|
12
11
|
switch (tab) {
|
|
13
12
|
case "MyRewards":
|
|
@@ -38,7 +37,7 @@ function TabBar({
|
|
|
38
37
|
tab
|
|
39
38
|
)) });
|
|
40
39
|
}
|
|
41
|
-
function formatTime
|
|
40
|
+
function formatTime(timestamp) {
|
|
42
41
|
return formatLocalDate(timestamp);
|
|
43
42
|
}
|
|
44
43
|
function formatTokenAmount(amount) {
|
|
@@ -87,7 +86,7 @@ function TokenRow({ item, onClick }) {
|
|
|
87
86
|
] }),
|
|
88
87
|
/* @__PURE__ */ jsx("span", { className: "taskon-reward-detail__secondary", children: item.campaign_name })
|
|
89
88
|
] }),
|
|
90
|
-
/* @__PURE__ */ jsx("div", { className: "taskon-reward-detail__cell taskon-reward-detail__cell--time", children: formatTime
|
|
89
|
+
/* @__PURE__ */ jsx("div", { className: "taskon-reward-detail__cell taskon-reward-detail__cell--time", children: formatTime(item.reward_time) })
|
|
91
90
|
]
|
|
92
91
|
}
|
|
93
92
|
);
|
|
@@ -107,8 +106,8 @@ function NftRow({
|
|
|
107
106
|
{
|
|
108
107
|
type: "button",
|
|
109
108
|
className: "taskon-reward-detail__claimed-link",
|
|
110
|
-
onClick: (
|
|
111
|
-
|
|
109
|
+
onClick: (e2) => {
|
|
110
|
+
e2.stopPropagation();
|
|
112
111
|
onTxClick == null ? void 0 : onTxClick();
|
|
113
112
|
},
|
|
114
113
|
title: nftValue.tx_hash,
|
|
@@ -122,8 +121,8 @@ function NftRow({
|
|
|
122
121
|
{
|
|
123
122
|
type: "button",
|
|
124
123
|
className: "taskon-reward-detail__claim-btn",
|
|
125
|
-
onClick: (
|
|
126
|
-
|
|
124
|
+
onClick: (e2) => {
|
|
125
|
+
e2.stopPropagation();
|
|
127
126
|
onClaim == null ? void 0 : onClaim();
|
|
128
127
|
},
|
|
129
128
|
children: messages.claim
|
|
@@ -152,7 +151,7 @@ function NftRow({
|
|
|
152
151
|
/* @__PURE__ */ jsx("span", { className: "taskon-reward-detail__primary", children: nftValue.collection_name }),
|
|
153
152
|
/* @__PURE__ */ jsx("span", { className: "taskon-reward-detail__secondary", children: item.campaign_name })
|
|
154
153
|
] }),
|
|
155
|
-
/* @__PURE__ */ jsx("div", { className: "taskon-reward-detail__cell taskon-reward-detail__cell--time", children: formatTime
|
|
154
|
+
/* @__PURE__ */ jsx("div", { className: "taskon-reward-detail__cell taskon-reward-detail__cell--time", children: formatTime(item.reward_time) }),
|
|
156
155
|
/* @__PURE__ */ jsx("div", { className: "taskon-reward-detail__cell taskon-reward-detail__cell--action", children: renderNftAction() })
|
|
157
156
|
]
|
|
158
157
|
}
|
|
@@ -171,7 +170,7 @@ function SimpleRow({ item, onClick }) {
|
|
|
171
170
|
/* @__PURE__ */ jsx("span", { className: "taskon-reward-detail__primary", children: item.campaign_name }),
|
|
172
171
|
/* @__PURE__ */ jsx("span", { className: "taskon-reward-detail__secondary", children: item.campaign_type })
|
|
173
172
|
] }),
|
|
174
|
-
/* @__PURE__ */ jsx("div", { className: "taskon-reward-detail__cell taskon-reward-detail__cell--time", children: formatTime
|
|
173
|
+
/* @__PURE__ */ jsx("div", { className: "taskon-reward-detail__cell taskon-reward-detail__cell--time", children: formatTime(item.reward_time) })
|
|
175
174
|
]
|
|
176
175
|
}
|
|
177
176
|
);
|
|
@@ -235,7 +234,7 @@ function RewardDetailList({
|
|
|
235
234
|
loading && data.length > 0 && /* @__PURE__ */ jsx("div", { className: "taskon-reward-detail__loading-more", children: /* @__PURE__ */ jsx("div", { className: "taskon-user-center-loading__spinner" }) })
|
|
236
235
|
] });
|
|
237
236
|
}
|
|
238
|
-
function formatAmount
|
|
237
|
+
function formatAmount(amount) {
|
|
239
238
|
const num = parseFloat(amount);
|
|
240
239
|
if (isNaN(num) || num === 0) return "0";
|
|
241
240
|
return num.toLocaleString(void 0, { maximumFractionDigits: 6 });
|
|
@@ -344,7 +343,7 @@ function WithdrawModal({
|
|
|
344
343
|
/* @__PURE__ */ jsx("span", { className: "taskon-withdraw-modal__token-chain", children: token.chainLabel })
|
|
345
344
|
] })
|
|
346
345
|
] }),
|
|
347
|
-
/* @__PURE__ */ jsx("span", { className: "taskon-withdraw-modal__token-amount", children: formatAmount
|
|
346
|
+
/* @__PURE__ */ jsx("span", { className: "taskon-withdraw-modal__token-amount", children: formatAmount(token.amount) })
|
|
348
347
|
]
|
|
349
348
|
},
|
|
350
349
|
token.tokenId
|
|
@@ -376,220 +375,6 @@ function WithdrawModal({
|
|
|
376
375
|
}
|
|
377
376
|
);
|
|
378
377
|
}
|
|
379
|
-
function formatTime(timestamp) {
|
|
380
|
-
const date = new Date(timestamp);
|
|
381
|
-
return date.toLocaleDateString(void 0, {
|
|
382
|
-
year: "numeric",
|
|
383
|
-
month: "short",
|
|
384
|
-
day: "numeric",
|
|
385
|
-
hour: "2-digit",
|
|
386
|
-
minute: "2-digit"
|
|
387
|
-
});
|
|
388
|
-
}
|
|
389
|
-
function formatAmount(amount) {
|
|
390
|
-
const num = parseFloat(amount);
|
|
391
|
-
if (isNaN(num) || num === 0) return "0";
|
|
392
|
-
return num.toLocaleString(void 0, { maximumFractionDigits: 6 });
|
|
393
|
-
}
|
|
394
|
-
function getLockedTypeLabel(type, messages) {
|
|
395
|
-
switch (type) {
|
|
396
|
-
case "Campaign":
|
|
397
|
-
return messages.frozenTypeCampaign ?? "Campaign Locked";
|
|
398
|
-
case "Withdraw":
|
|
399
|
-
return messages.frozenTypeWithdraw ?? "Pending Withdrawal";
|
|
400
|
-
case "ReferralReward":
|
|
401
|
-
return messages.frozenTypeReferral ?? "Referral Locked";
|
|
402
|
-
case "Benefit":
|
|
403
|
-
return messages.frozenTypeBenefit ?? "Benefit Locked";
|
|
404
|
-
case "TgMiniApp":
|
|
405
|
-
return messages.frozenTypeTgMiniApp ?? "TG Mini App";
|
|
406
|
-
case "CommunityMilestone":
|
|
407
|
-
return messages.frozenTypeMilestone ?? "Milestone Locked";
|
|
408
|
-
default:
|
|
409
|
-
return type;
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
function FrozenAssetList({
|
|
413
|
-
data,
|
|
414
|
-
loading,
|
|
415
|
-
error,
|
|
416
|
-
pagination,
|
|
417
|
-
messages,
|
|
418
|
-
canResend,
|
|
419
|
-
onResend,
|
|
420
|
-
onClose
|
|
421
|
-
}) {
|
|
422
|
-
if (loading && data.length === 0) {
|
|
423
|
-
return /* @__PURE__ */ jsx(LoadingState, { message: messages.loading });
|
|
424
|
-
}
|
|
425
|
-
if (error && data.length === 0) {
|
|
426
|
-
return /* @__PURE__ */ jsx("div", { className: "taskon-user-center-error", children: /* @__PURE__ */ jsx("p", { className: "taskon-user-center-error__message", children: error.message }) });
|
|
427
|
-
}
|
|
428
|
-
if (!loading && data.length === 0) {
|
|
429
|
-
return /* @__PURE__ */ jsx(EmptyState, { message: messages.noData });
|
|
430
|
-
}
|
|
431
|
-
const columns = [
|
|
432
|
-
{
|
|
433
|
-
key: "locked_amount",
|
|
434
|
-
title: messages.columnAmount,
|
|
435
|
-
width: 120,
|
|
436
|
-
render: (_, row) => /* @__PURE__ */ jsx("span", { className: "taskon-frozen-assets__amount", children: formatAmount(row.locked_amount) })
|
|
437
|
-
},
|
|
438
|
-
{
|
|
439
|
-
key: "type",
|
|
440
|
-
title: messages.columnDetail,
|
|
441
|
-
render: (_, row) => /* @__PURE__ */ jsxs("div", { className: "taskon-frozen-assets__detail-cell", children: [
|
|
442
|
-
/* @__PURE__ */ jsx("span", { className: "taskon-frozen-assets__type", children: getLockedTypeLabel(row.type, messages) }),
|
|
443
|
-
row.campaign_name && /* @__PURE__ */ jsx("span", { className: "taskon-frozen-assets__campaign", children: row.campaign_name })
|
|
444
|
-
] })
|
|
445
|
-
},
|
|
446
|
-
{
|
|
447
|
-
key: "lock_time",
|
|
448
|
-
title: messages.columnTime,
|
|
449
|
-
width: 160,
|
|
450
|
-
render: (_, row) => /* @__PURE__ */ jsx("span", { className: "taskon-frozen-assets__time", children: formatTime(row.lock_time) })
|
|
451
|
-
},
|
|
452
|
-
{
|
|
453
|
-
key: "action",
|
|
454
|
-
title: messages.columnAction ?? "Action",
|
|
455
|
-
width: 100,
|
|
456
|
-
align: "right",
|
|
457
|
-
render: (_, row) => {
|
|
458
|
-
if (!canResend(row) || !onResend) return null;
|
|
459
|
-
return /* @__PURE__ */ jsx(
|
|
460
|
-
Button,
|
|
461
|
-
{
|
|
462
|
-
variant: "outline",
|
|
463
|
-
size: "small",
|
|
464
|
-
onClick: () => onResend(row),
|
|
465
|
-
className: "taskon-frozen-assets__resend-btn",
|
|
466
|
-
children: messages.resend
|
|
467
|
-
}
|
|
468
|
-
);
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
];
|
|
472
|
-
return /* @__PURE__ */ jsxs("div", { className: "taskon-frozen-assets", children: [
|
|
473
|
-
/* @__PURE__ */ jsxs("div", { className: "taskon-frozen-assets__header", children: [
|
|
474
|
-
/* @__PURE__ */ jsx("h3", { className: "taskon-frozen-assets__title", children: messages.frozenAssets }),
|
|
475
|
-
onClose && /* @__PURE__ */ jsx(
|
|
476
|
-
"button",
|
|
477
|
-
{
|
|
478
|
-
type: "button",
|
|
479
|
-
className: "taskon-frozen-assets__close",
|
|
480
|
-
onClick: onClose,
|
|
481
|
-
"aria-label": "Close",
|
|
482
|
-
children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "20", height: "20", children: /* @__PURE__ */ jsx("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) })
|
|
483
|
-
}
|
|
484
|
-
)
|
|
485
|
-
] }),
|
|
486
|
-
/* @__PURE__ */ jsx(
|
|
487
|
-
Table,
|
|
488
|
-
{
|
|
489
|
-
columns,
|
|
490
|
-
data,
|
|
491
|
-
rowConfig: {
|
|
492
|
-
getRowKey: (row, index) => `${row.lock_time}-${index}`
|
|
493
|
-
},
|
|
494
|
-
striped: true,
|
|
495
|
-
loading: loading && data.length > 0,
|
|
496
|
-
loadingText: messages.loading,
|
|
497
|
-
empty: {
|
|
498
|
-
title: messages.noData
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
),
|
|
502
|
-
pagination.totalPages > 1 && /* @__PURE__ */ jsx(
|
|
503
|
-
Pagination,
|
|
504
|
-
{
|
|
505
|
-
page: pagination.page,
|
|
506
|
-
totalPages: pagination.totalPages,
|
|
507
|
-
onPrevious: pagination.goToPrevious,
|
|
508
|
-
onNext: pagination.goToNext,
|
|
509
|
-
hasPrevious: pagination.hasPrevious,
|
|
510
|
-
hasNext: pagination.hasNext,
|
|
511
|
-
messages
|
|
512
|
-
}
|
|
513
|
-
)
|
|
514
|
-
] });
|
|
515
|
-
}
|
|
516
|
-
function useFrozenAssets(options) {
|
|
517
|
-
const { tokenId, pageSize = USER_CENTER_PAGE_SIZE, autoLoad = true } = options;
|
|
518
|
-
const { client } = useTaskOnContext();
|
|
519
|
-
const [data, setData] = useState([]);
|
|
520
|
-
const [total, setTotal] = useState(0);
|
|
521
|
-
const [loading, setLoading] = useState(false);
|
|
522
|
-
const [error, setError] = useState(null);
|
|
523
|
-
const api = useMemo(() => {
|
|
524
|
-
if (!client) return null;
|
|
525
|
-
return createUserCenterApi(client);
|
|
526
|
-
}, [client]);
|
|
527
|
-
const pagination = usePagination({
|
|
528
|
-
total,
|
|
529
|
-
pageSize,
|
|
530
|
-
initialPage: 1,
|
|
531
|
-
mode: "pagination"
|
|
532
|
-
});
|
|
533
|
-
const fetchData = useCallback(
|
|
534
|
-
async (pageNo) => {
|
|
535
|
-
if (!api) {
|
|
536
|
-
setError(new Error("TaskOn client not initialized"));
|
|
537
|
-
return;
|
|
538
|
-
}
|
|
539
|
-
if (!tokenId) {
|
|
540
|
-
setError(new Error("Token ID is required"));
|
|
541
|
-
return;
|
|
542
|
-
}
|
|
543
|
-
setLoading(true);
|
|
544
|
-
setError(null);
|
|
545
|
-
try {
|
|
546
|
-
const response = await api.getLockedTokenList({
|
|
547
|
-
token_id: tokenId,
|
|
548
|
-
page: {
|
|
549
|
-
page_no: pageNo - 1,
|
|
550
|
-
// API 使用 0-based 索引
|
|
551
|
-
size: pageSize
|
|
552
|
-
}
|
|
553
|
-
});
|
|
554
|
-
setData(response.data);
|
|
555
|
-
setTotal(response.total);
|
|
556
|
-
} catch (err) {
|
|
557
|
-
setError(
|
|
558
|
-
err instanceof Error ? err : new Error("Failed to fetch frozen assets")
|
|
559
|
-
);
|
|
560
|
-
} finally {
|
|
561
|
-
setLoading(false);
|
|
562
|
-
}
|
|
563
|
-
},
|
|
564
|
-
[api, tokenId, pageSize]
|
|
565
|
-
);
|
|
566
|
-
const refresh = useCallback(async () => {
|
|
567
|
-
pagination.goToPage(1);
|
|
568
|
-
await fetchData(1);
|
|
569
|
-
}, [fetchData, pagination]);
|
|
570
|
-
const canResend = useCallback((item) => {
|
|
571
|
-
return item.type === "Withdraw";
|
|
572
|
-
}, []);
|
|
573
|
-
useEffect(() => {
|
|
574
|
-
if (autoLoad && tokenId) {
|
|
575
|
-
fetchData(1);
|
|
576
|
-
}
|
|
577
|
-
}, [autoLoad, tokenId, fetchData]);
|
|
578
|
-
useEffect(() => {
|
|
579
|
-
if (pagination.page > 1) {
|
|
580
|
-
fetchData(pagination.page);
|
|
581
|
-
}
|
|
582
|
-
}, [pagination.page, fetchData]);
|
|
583
|
-
return {
|
|
584
|
-
data,
|
|
585
|
-
loading,
|
|
586
|
-
error,
|
|
587
|
-
total,
|
|
588
|
-
pagination,
|
|
589
|
-
refresh,
|
|
590
|
-
canResend
|
|
591
|
-
};
|
|
592
|
-
}
|
|
593
378
|
function calculateXpLevelData(userInfo) {
|
|
594
379
|
const xpPointsInfo = userInfo.points_list[0];
|
|
595
380
|
if (!xpPointsInfo) return null;
|
|
@@ -680,7 +465,7 @@ export {
|
|
|
680
465
|
a as AssetCard,
|
|
681
466
|
b as AssetCarousel,
|
|
682
467
|
EmptyState,
|
|
683
|
-
FrozenAssetList,
|
|
468
|
+
F as FrozenAssetList,
|
|
684
469
|
LoadingState,
|
|
685
470
|
Pagination,
|
|
686
471
|
RewardDetailList,
|
|
@@ -688,20 +473,18 @@ export {
|
|
|
688
473
|
T as TokenAssetList,
|
|
689
474
|
U as UserCenterWidget,
|
|
690
475
|
WithdrawModal,
|
|
691
|
-
|
|
476
|
+
d2 as buildRewardCards,
|
|
692
477
|
f2 as formatTokenAmount,
|
|
693
478
|
getChainIcon,
|
|
694
479
|
getChainName,
|
|
695
480
|
getSocialIcon,
|
|
696
|
-
d2 as toGasFreeWithdrawItem,
|
|
697
481
|
toWei,
|
|
698
482
|
t as toWithdrawItem,
|
|
699
483
|
truncateAddress,
|
|
700
484
|
u as useActivityHistory,
|
|
701
485
|
g as useBindWallet,
|
|
702
486
|
h as useDisableUnlink,
|
|
703
|
-
useFrozenAssets,
|
|
704
|
-
d as useGasFreeWithdraw,
|
|
487
|
+
d as useFrozenAssets,
|
|
705
488
|
e as useIdentityData,
|
|
706
489
|
c2 as usePointsHistory,
|
|
707
490
|
u2 as useRewardDetails,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taskon/widget-react",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.3",
|
|
4
4
|
"description": "TaskOn React Widget Library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -46,6 +46,9 @@
|
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "vite build",
|
|
48
48
|
"dev": "vite build --watch",
|
|
49
|
+
"test": "vitest run",
|
|
50
|
+
"test:watch": "vitest",
|
|
51
|
+
"test:coverage": "vitest run --coverage",
|
|
49
52
|
"lint": "eslint . --max-warnings 0",
|
|
50
53
|
"check-types": "tsc --noEmit",
|
|
51
54
|
"prepublishOnly": "node ../../scripts/prepublish.js && pnpm build",
|
|
@@ -67,6 +70,7 @@
|
|
|
67
70
|
"@types/react": "19.2.2",
|
|
68
71
|
"@types/react-dom": "19.2.2",
|
|
69
72
|
"@vitejs/plugin-react": "^4.5.2",
|
|
73
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
70
74
|
"eslint": "^9.39.1",
|
|
71
75
|
"ethers": "^6.0.0",
|
|
72
76
|
"react": "^19.2.0",
|
|
@@ -74,7 +78,8 @@
|
|
|
74
78
|
"typescript": "5.9.2",
|
|
75
79
|
"vite": "^6.3.5",
|
|
76
80
|
"vite-plugin-dts": "^4.5.4",
|
|
77
|
-
"vite-plugin-lib-inject-css": "^2.2.2"
|
|
81
|
+
"vite-plugin-lib-inject-css": "^2.2.2",
|
|
82
|
+
"vitest": "^4.0.18"
|
|
78
83
|
},
|
|
79
84
|
"peerDependencies": {
|
|
80
85
|
"@taskon/core": "^0.0.1",
|