@taskon/widget-react 0.0.1-beta.6 → 0.0.1-beta.7
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 +48 -43
- package/dist/EligibilityInfo.css +2 -33
- package/dist/TaskOnProvider.css +287 -0
- package/dist/ThemeProvider.css +227 -0
- package/dist/UserCenterWidget2.css +32 -290
- package/dist/WidgetShell.css +0 -227
- package/dist/chunks/{CommunityTaskList-Hde2OKHH.js → CommunityTaskList-D0uVD8wD.js} +37 -58
- package/dist/chunks/{EligibilityInfo-BV0Z2TgY.js → EligibilityInfo-Cf6hx9-a.js} +17 -209
- package/dist/chunks/{LeaderboardWidget-BNGRD5Bu.js → LeaderboardWidget-DyoiiNS6.js} +10 -9
- package/dist/chunks/{PageBuilder-C5DSHiW9.js → PageBuilder-DoAFPm6-.js} +5 -5
- package/dist/chunks/{Quest-DG9zfXJo.js → Quest-ySZlYd4u.js} +6 -11
- package/dist/chunks/TaskOnProvider-CxtFIs3n.js +2072 -0
- package/dist/chunks/{WidgetShell-D7yC894Y.js → ThemeProvider-CulHkqqY.js} +1354 -617
- package/dist/chunks/UserCenterWidget-BJsc_GSZ.js +3246 -0
- package/dist/chunks/{UserCenterWidget-D5ttw4hO.js → UserCenterWidget-STq8kpV4.js} +162 -365
- package/dist/chunks/WidgetShell-8xn-Jivw.js +659 -0
- package/dist/chunks/useIsMobile-D6Ybur-6.js +30 -0
- package/dist/chunks/useToast-BGJhd3BX.js +93 -0
- package/dist/community-task.js +1 -1
- package/dist/core.d.ts +9 -15
- package/dist/core.js +3 -3
- package/dist/index.d.ts +64 -15
- package/dist/index.js +15 -10
- package/dist/leaderboard.js +1 -1
- package/dist/page-builder.js +1 -1
- package/dist/quest.js +1 -1
- package/dist/user-center.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/TaskOnProvider-BhamHIyY.js +0 -1260
- package/dist/chunks/ThemeProvider-mXLdLSkq.js +0 -1397
- package/dist/chunks/UserCenterWidget-jDO5zTN1.js +0 -3297
- package/dist/chunks/useToast-CaRkylKe.js +0 -304
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import React__default, { isValidElement, cloneElement, Fragment as Fragment$1,
|
|
2
|
+
import React__default, { isValidElement, cloneElement, Fragment as Fragment$1, useContext, useState, useRef, useMemo, useCallback, forwardRef, useEffect, useImperativeHandle } from "react";
|
|
3
3
|
import { createUserApi, ChainType, parseTitleExpress, getTxExplorerUrl, RewardType, UserIdentityType, SnsType, createQuestApi, isUnauthorizedError, ErrorCode, ApiError, createCommonApi, powIcon, contractInteractiveIcon, getSwapDexTitleExpress, EligibilityTemplateId, UserEligibleStatus } from "@taskon/core";
|
|
4
|
-
import { u as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { D as Dialog } from "./WidgetShell-D7yC894Y.js";
|
|
4
|
+
import { R as Root2, h as Trigger, i as Portal, C as Content2, j as Arrow2, k as useChainMap, l as useNftClaim, m as ClaimNftDialog, n as enMessages$2, o as PendingTxDialog, p as TipPopover, a as useBindSocialAccount, u as useUserCenterLocale, c as useTokenAssets, d as useRewardDetails, e as usePointsHistory, L as LoadingState, T as TokenRewardContent, g as PointsList, E as EmptyState, N as NftRewardContent, W as WithdrawForm } from "./UserCenterWidget-STq8kpV4.js";
|
|
5
|
+
import { w as TaskOnContext, D as Dialog, E as useTaskOnPortalContainer, c as useTranslation, e as createLocaleLoader, u as useTaskOnAuth } from "./ThemeProvider-CulHkqqY.js";
|
|
6
|
+
import { u as useWallet, c as useToast } from "./useToast-BGJhd3BX.js";
|
|
8
7
|
import '../EligibilityInfo.css';const SLOT_TOKEN_PREFIX = "__TASKON_I18NT_SLOT_";
|
|
9
8
|
const SLOT_TOKEN_SUFFIX = "__";
|
|
10
9
|
const SLOT_TOKEN_REGEXP = /__TASKON_I18NT_SLOT_([A-Za-z0-9_]+)__/g;
|
|
@@ -83,26 +82,6 @@ function I18nT({
|
|
|
83
82
|
}
|
|
84
83
|
return /* @__PURE__ */ jsx(WrapperElement, { children: content2 });
|
|
85
84
|
}
|
|
86
|
-
function detectEthereumProvider() {
|
|
87
|
-
if (typeof window === "undefined") return false;
|
|
88
|
-
return Boolean(window.ethereum);
|
|
89
|
-
}
|
|
90
|
-
function getProvider() {
|
|
91
|
-
if (typeof window === "undefined") return null;
|
|
92
|
-
return window.ethereum || null;
|
|
93
|
-
}
|
|
94
|
-
function useInjectedProvider() {
|
|
95
|
-
const isMobile = useIsMobile();
|
|
96
|
-
const hasEthereumProvider = detectEthereumProvider();
|
|
97
|
-
const isDapp = useMemo(() => {
|
|
98
|
-
return isMobile && hasEthereumProvider;
|
|
99
|
-
}, [isMobile, hasEthereumProvider]);
|
|
100
|
-
return {
|
|
101
|
-
hasEthereumProvider,
|
|
102
|
-
isDapp,
|
|
103
|
-
getEthereumProvider: getProvider
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
85
|
const BIND_TEXT = "Confirm to BIND this wallet address.";
|
|
107
86
|
const BIND_NOTE = "This signature is for confirmation only.";
|
|
108
87
|
function getBindSignText(address, nonce) {
|
|
@@ -114,8 +93,7 @@ Note:${BIND_NOTE}`;
|
|
|
114
93
|
function useBindWallet({
|
|
115
94
|
chainType,
|
|
116
95
|
onSuccess,
|
|
117
|
-
onFailed
|
|
118
|
-
onNeedWalletDialog
|
|
96
|
+
onFailed
|
|
119
97
|
}) {
|
|
120
98
|
const context = useContext(TaskOnContext);
|
|
121
99
|
const client = (context == null ? void 0 : context.client) ?? null;
|
|
@@ -123,8 +101,6 @@ function useBindWallet({
|
|
|
123
101
|
const refreshUserInfo = context == null ? void 0 : context.refreshUserInfo;
|
|
124
102
|
const wallet = useWallet();
|
|
125
103
|
const { evmAdapter, connectEvm, signEvmMessage } = wallet;
|
|
126
|
-
const { isDapp, getEthereumProvider } = useInjectedProvider();
|
|
127
|
-
const isMobile = useIsMobile();
|
|
128
104
|
const [isBinding, setIsBinding] = useState(false);
|
|
129
105
|
const bindWaitResolveRef = useRef(null);
|
|
130
106
|
const userApi = useMemo(() => {
|
|
@@ -132,9 +108,8 @@ function useBindWallet({
|
|
|
132
108
|
return createUserApi(client);
|
|
133
109
|
}, [client]);
|
|
134
110
|
const hasAdapter = useMemo(() => {
|
|
135
|
-
if (chainType !== ChainType.evm) return false;
|
|
136
111
|
return evmAdapter !== null;
|
|
137
|
-
}, [
|
|
112
|
+
}, [evmAdapter]);
|
|
138
113
|
const isBound = useMemo(() => {
|
|
139
114
|
if (!chainType || !(userInfo == null ? void 0 : userInfo.address)) return false;
|
|
140
115
|
return userInfo.address.some((item) => item.chain_type === chainType);
|
|
@@ -151,28 +126,6 @@ function useBindWallet({
|
|
|
151
126
|
(_a = bindWaitResolveRef.current) == null ? void 0 : _a.call(bindWaitResolveRef, false);
|
|
152
127
|
bindWaitResolveRef.current = null;
|
|
153
128
|
}, [onFailed]);
|
|
154
|
-
const connectAndSignWithInjected = useCallback(
|
|
155
|
-
async (nonce) => {
|
|
156
|
-
const provider = getEthereumProvider();
|
|
157
|
-
if (!provider) return null;
|
|
158
|
-
try {
|
|
159
|
-
const accounts = await provider.request({
|
|
160
|
-
method: "eth_requestAccounts"
|
|
161
|
-
});
|
|
162
|
-
const address = accounts[0];
|
|
163
|
-
if (!address) return null;
|
|
164
|
-
const message = getBindSignText(address, nonce);
|
|
165
|
-
const signature = await provider.request({
|
|
166
|
-
method: "personal_sign",
|
|
167
|
-
params: [message, address]
|
|
168
|
-
});
|
|
169
|
-
return { address, signature };
|
|
170
|
-
} catch {
|
|
171
|
-
return null;
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
[getEthereumProvider]
|
|
175
|
-
);
|
|
176
129
|
const bindWithAdapter = useCallback(async () => {
|
|
177
130
|
var _a, _b;
|
|
178
131
|
if (!userApi) {
|
|
@@ -217,7 +170,6 @@ function useBindWallet({
|
|
|
217
170
|
}
|
|
218
171
|
}, [userApi, connectEvm, signEvmMessage, refreshUserInfo, handleSuccess, handleFailed]);
|
|
219
172
|
const bindIfNeed = useCallback(async (targetChainType) => {
|
|
220
|
-
var _a, _b;
|
|
221
173
|
const effectiveChainType = targetChainType || chainType;
|
|
222
174
|
if (effectiveChainType && (userInfo == null ? void 0 : userInfo.address)) {
|
|
223
175
|
const alreadyBound = userInfo.address.some((item) => item.chain_type === effectiveChainType);
|
|
@@ -238,106 +190,21 @@ function useBindWallet({
|
|
|
238
190
|
await handleSuccess();
|
|
239
191
|
return;
|
|
240
192
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
if (effectiveHasAdapter) {
|
|
244
|
-
await bindWithAdapter();
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
onNeedWalletDialog == null ? void 0 : onNeedWalletDialog();
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
if (!isDapp) {
|
|
251
|
-
onNeedWalletDialog == null ? void 0 : onNeedWalletDialog();
|
|
193
|
+
if (!hasAdapter) {
|
|
194
|
+
handleFailed("No wallet adapter available");
|
|
252
195
|
return;
|
|
253
196
|
}
|
|
254
|
-
|
|
255
|
-
try {
|
|
256
|
-
const nonce = await userApi.requestChallenge("AddressBind");
|
|
257
|
-
const result = await connectAndSignWithInjected(nonce);
|
|
258
|
-
if (!result) {
|
|
259
|
-
handleFailed("Failed to connect wallet");
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
const { address, signature } = result;
|
|
263
|
-
const bindResult = await userApi.bindAddress({
|
|
264
|
-
address,
|
|
265
|
-
nonce,
|
|
266
|
-
sig: signature,
|
|
267
|
-
chain_type: ChainType.evm
|
|
268
|
-
});
|
|
269
|
-
if (bindResult.result) {
|
|
270
|
-
await (refreshUserInfo == null ? void 0 : refreshUserInfo());
|
|
271
|
-
await handleSuccess();
|
|
272
|
-
} else {
|
|
273
|
-
handleFailed("This wallet address is already bound to another account");
|
|
274
|
-
}
|
|
275
|
-
} catch (e) {
|
|
276
|
-
const error = e;
|
|
277
|
-
if (((_a = error.message) == null ? void 0 : _a.includes("rejected")) || ((_b = error.message) == null ? void 0 : _b.includes("denied"))) {
|
|
278
|
-
handleFailed("User rejected the request");
|
|
279
|
-
} else {
|
|
280
|
-
handleFailed(error.message || "Failed to bind wallet");
|
|
281
|
-
}
|
|
282
|
-
} finally {
|
|
283
|
-
setIsBinding(false);
|
|
284
|
-
}
|
|
197
|
+
await bindWithAdapter();
|
|
285
198
|
}, [
|
|
286
199
|
chainType,
|
|
287
200
|
userInfo,
|
|
288
|
-
|
|
289
|
-
isMobile,
|
|
290
|
-
isDapp,
|
|
201
|
+
hasAdapter,
|
|
291
202
|
context,
|
|
292
203
|
userApi,
|
|
293
204
|
bindWithAdapter,
|
|
294
|
-
connectAndSignWithInjected,
|
|
295
|
-
refreshUserInfo,
|
|
296
205
|
handleSuccess,
|
|
297
|
-
handleFailed
|
|
298
|
-
onNeedWalletDialog
|
|
206
|
+
handleFailed
|
|
299
207
|
]);
|
|
300
|
-
const bindWithProvider = useCallback(async (address, provider) => {
|
|
301
|
-
var _a, _b;
|
|
302
|
-
if (!userApi) {
|
|
303
|
-
handleFailed("User API not initialized");
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
setIsBinding(true);
|
|
307
|
-
try {
|
|
308
|
-
const nonce = await userApi.requestChallenge("AddressBind");
|
|
309
|
-
const message = getBindSignText(address, nonce);
|
|
310
|
-
const signature = await provider.request({
|
|
311
|
-
method: "personal_sign",
|
|
312
|
-
params: [message, address]
|
|
313
|
-
});
|
|
314
|
-
if (!signature) {
|
|
315
|
-
handleFailed("Signature cancelled");
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
const bindResult = await userApi.bindAddress({
|
|
319
|
-
address,
|
|
320
|
-
nonce,
|
|
321
|
-
sig: signature,
|
|
322
|
-
chain_type: ChainType.evm
|
|
323
|
-
});
|
|
324
|
-
if (bindResult.result) {
|
|
325
|
-
await (refreshUserInfo == null ? void 0 : refreshUserInfo());
|
|
326
|
-
await handleSuccess();
|
|
327
|
-
} else {
|
|
328
|
-
handleFailed("This wallet address is already bound to another account");
|
|
329
|
-
}
|
|
330
|
-
} catch (e) {
|
|
331
|
-
const error = e;
|
|
332
|
-
if (((_a = error.message) == null ? void 0 : _a.includes("rejected")) || ((_b = error.message) == null ? void 0 : _b.includes("denied"))) {
|
|
333
|
-
handleFailed("User rejected the request");
|
|
334
|
-
} else {
|
|
335
|
-
handleFailed(error.message || "Failed to bind wallet");
|
|
336
|
-
}
|
|
337
|
-
} finally {
|
|
338
|
-
setIsBinding(false);
|
|
339
|
-
}
|
|
340
|
-
}, [userApi, refreshUserInfo, handleSuccess, handleFailed]);
|
|
341
208
|
const bindAndWait = useCallback(async (targetChainType) => {
|
|
342
209
|
const effectiveChainType = targetChainType || chainType;
|
|
343
210
|
if (effectiveChainType && (userInfo == null ? void 0 : userInfo.address)) {
|
|
@@ -355,20 +222,17 @@ function useBindWallet({
|
|
|
355
222
|
if (!context || !userApi) {
|
|
356
223
|
return true;
|
|
357
224
|
}
|
|
358
|
-
|
|
359
|
-
if (!canHandleInternally) {
|
|
360
|
-
onNeedWalletDialog == null ? void 0 : onNeedWalletDialog();
|
|
225
|
+
if (!hasAdapter) {
|
|
361
226
|
return false;
|
|
362
227
|
}
|
|
363
228
|
return new Promise((resolve) => {
|
|
364
229
|
bindWaitResolveRef.current = resolve;
|
|
365
230
|
bindIfNeed();
|
|
366
231
|
});
|
|
367
|
-
}, [chainType, userInfo, context, userApi,
|
|
232
|
+
}, [chainType, userInfo, context, userApi, hasAdapter, bindIfNeed]);
|
|
368
233
|
return {
|
|
369
234
|
bindIfNeed,
|
|
370
235
|
bindAndWait,
|
|
371
|
-
bindWithProvider,
|
|
372
236
|
isBinding,
|
|
373
237
|
isBound,
|
|
374
238
|
hasAdapter
|
|
@@ -452,7 +316,7 @@ function ConfirmNoticeDialog({
|
|
|
452
316
|
closeOnOverlayClick,
|
|
453
317
|
closeOnEscapeKey,
|
|
454
318
|
maxWidth,
|
|
455
|
-
contentClassName
|
|
319
|
+
contentClassName,
|
|
456
320
|
children: /* @__PURE__ */ jsxs(
|
|
457
321
|
"div",
|
|
458
322
|
{
|
|
@@ -1939,16 +1803,12 @@ function useNftClaimFlow(options) {
|
|
|
1939
1803
|
targetType,
|
|
1940
1804
|
onClaimSuccess,
|
|
1941
1805
|
onClaimError,
|
|
1942
|
-
onWalletError,
|
|
1943
1806
|
messages
|
|
1944
1807
|
} = options;
|
|
1945
|
-
const { toast } = useToast();
|
|
1946
1808
|
const { chainMap } = useChainMap();
|
|
1947
1809
|
const [isClaimDialogOpen, setIsClaimDialogOpen] = useState(false);
|
|
1948
|
-
const [isWalletDialogOpen, setIsWalletDialogOpen] = useState(false);
|
|
1949
1810
|
const [isPendingDialogOpen, setIsPendingDialogOpen] = useState(false);
|
|
1950
1811
|
const [pendingTxDialogState, setPendingTxDialogState] = useState(null);
|
|
1951
|
-
const [pendingWalletClaimTarget, setPendingWalletClaimTarget] = useState(null);
|
|
1952
1812
|
const pendingDecisionResolverRef = useRef(null);
|
|
1953
1813
|
const resolvePendingDecision = useCallback((claimAgain) => {
|
|
1954
1814
|
const resolver = pendingDecisionResolverRef.current;
|
|
@@ -1991,10 +1851,6 @@ function useNftClaimFlow(options) {
|
|
|
1991
1851
|
return new Promise((resolve) => {
|
|
1992
1852
|
pendingDecisionResolverRef.current = resolve;
|
|
1993
1853
|
});
|
|
1994
|
-
},
|
|
1995
|
-
onNeedWalletDialog: () => {
|
|
1996
|
-
setIsClaimDialogOpen(false);
|
|
1997
|
-
setIsWalletDialogOpen(true);
|
|
1998
1854
|
}
|
|
1999
1855
|
});
|
|
2000
1856
|
const claimExplorerUrl = useMemo(() => {
|
|
@@ -2032,7 +1888,6 @@ function useNftClaimFlow(options) {
|
|
|
2032
1888
|
sourceReward: reward2,
|
|
2033
1889
|
sourceLayer: targetLayer
|
|
2034
1890
|
};
|
|
2035
|
-
setPendingWalletClaimTarget(target);
|
|
2036
1891
|
setIsClaimDialogOpen(true);
|
|
2037
1892
|
await claimNft(target);
|
|
2038
1893
|
},
|
|
@@ -2044,40 +1899,9 @@ function useNftClaimFlow(options) {
|
|
|
2044
1899
|
},
|
|
2045
1900
|
[]
|
|
2046
1901
|
);
|
|
2047
|
-
const handleWalletConnect = useCallback(
|
|
2048
|
-
async (address, provider) => {
|
|
2049
|
-
const target = pendingWalletClaimTarget ?? (claimingNft == null ? void 0 : claimingNft.item);
|
|
2050
|
-
if (!target) {
|
|
2051
|
-
throw new Error("No pending NFT claim target found");
|
|
2052
|
-
}
|
|
2053
|
-
if (!provider || typeof provider.request !== "function") {
|
|
2054
|
-
throw new Error("Invalid wallet provider");
|
|
2055
|
-
}
|
|
2056
|
-
const popupAdapter = createEthereumAdapterFromProvider(
|
|
2057
|
-
provider,
|
|
2058
|
-
{
|
|
2059
|
-
address
|
|
2060
|
-
}
|
|
2061
|
-
);
|
|
2062
|
-
setIsWalletDialogOpen(false);
|
|
2063
|
-
setIsClaimDialogOpen(true);
|
|
2064
|
-
await claimNft(target, popupAdapter);
|
|
2065
|
-
},
|
|
2066
|
-
[pendingWalletClaimTarget, claimingNft, claimNft]
|
|
2067
|
-
);
|
|
2068
|
-
const handleWalletError = useCallback(
|
|
2069
|
-
(errorMessage) => {
|
|
2070
|
-
onWalletError == null ? void 0 : onWalletError(errorMessage);
|
|
2071
|
-
if (!onWalletError) {
|
|
2072
|
-
toast.error(errorMessage);
|
|
2073
|
-
}
|
|
2074
|
-
},
|
|
2075
|
-
[onWalletError, toast]
|
|
2076
|
-
);
|
|
2077
1902
|
const handlePendingContinueWaiting = useCallback(() => {
|
|
2078
1903
|
setIsPendingDialogOpen(false);
|
|
2079
1904
|
setPendingTxDialogState(null);
|
|
2080
|
-
setPendingWalletClaimTarget(null);
|
|
2081
1905
|
resetClaim();
|
|
2082
1906
|
resolvePendingDecision(false);
|
|
2083
1907
|
}, [resetClaim, resolvePendingDecision]);
|
|
@@ -2091,7 +1915,6 @@ function useNftClaimFlow(options) {
|
|
|
2091
1915
|
setIsClaimDialogOpen(false);
|
|
2092
1916
|
setTimeout(() => {
|
|
2093
1917
|
resetClaim();
|
|
2094
|
-
setPendingWalletClaimTarget(null);
|
|
2095
1918
|
}, 200);
|
|
2096
1919
|
}, [resetClaim]);
|
|
2097
1920
|
const handleRetryClaim = useCallback(() => {
|
|
@@ -2099,7 +1922,6 @@ function useNftClaimFlow(options) {
|
|
|
2099
1922
|
return;
|
|
2100
1923
|
}
|
|
2101
1924
|
resetClaim();
|
|
2102
|
-
setPendingWalletClaimTarget(claimingNft.item);
|
|
2103
1925
|
void claimNft(claimingNft.item);
|
|
2104
1926
|
}, [claimingNft, resetClaim, claimNft]);
|
|
2105
1927
|
const isClaiming = useMemo(() => {
|
|
@@ -2140,15 +1962,6 @@ function useNftClaimFlow(options) {
|
|
|
2140
1962
|
receiveAddress: pendingTxDialogState == null ? void 0 : pendingTxDialogState.receiveAddress,
|
|
2141
1963
|
messages: (messages == null ? void 0 : messages.pendingDialog) ?? DEFAULT_PENDING_DIALOG_MESSAGES
|
|
2142
1964
|
}
|
|
2143
|
-
),
|
|
2144
|
-
/* @__PURE__ */ jsx(
|
|
2145
|
-
BindWalletDialog,
|
|
2146
|
-
{
|
|
2147
|
-
open: isWalletDialogOpen,
|
|
2148
|
-
onOpenChange: setIsWalletDialogOpen,
|
|
2149
|
-
onConnect: handleWalletConnect,
|
|
2150
|
-
onError: handleWalletError
|
|
2151
|
-
}
|
|
2152
1965
|
)
|
|
2153
1966
|
] });
|
|
2154
1967
|
}, [
|
|
@@ -2165,10 +1978,7 @@ function useNftClaimFlow(options) {
|
|
|
2165
1978
|
handlePendingContinueWaiting,
|
|
2166
1979
|
handlePendingClaimAgain,
|
|
2167
1980
|
pendingTxDialogState,
|
|
2168
|
-
pendingExplorerUrl
|
|
2169
|
-
isWalletDialogOpen,
|
|
2170
|
-
handleWalletConnect,
|
|
2171
|
-
handleWalletError
|
|
1981
|
+
pendingExplorerUrl
|
|
2172
1982
|
]);
|
|
2173
1983
|
return {
|
|
2174
1984
|
claimNftReward,
|
|
@@ -2782,8 +2592,7 @@ function useTaskSubmit({
|
|
|
2782
2592
|
onSuccess,
|
|
2783
2593
|
onError,
|
|
2784
2594
|
onCampaignIneligibility,
|
|
2785
|
-
onVerifyFailedNotice
|
|
2786
|
-
onNeedWalletDialog
|
|
2595
|
+
onVerifyFailedNotice
|
|
2787
2596
|
}) {
|
|
2788
2597
|
const context = useContext(TaskOnContext);
|
|
2789
2598
|
const client = (context == null ? void 0 : context.client) ?? null;
|
|
@@ -2890,8 +2699,7 @@ ${notice.message}`, 1e4);
|
|
|
2890
2699
|
onFailed: (err) => {
|
|
2891
2700
|
setError(err);
|
|
2892
2701
|
onError == null ? void 0 : onError(err);
|
|
2893
|
-
}
|
|
2894
|
-
onNeedWalletDialog
|
|
2702
|
+
}
|
|
2895
2703
|
});
|
|
2896
2704
|
const isSnsBindingRequired = needsSnsBinding && !isSnsBound;
|
|
2897
2705
|
const isWalletBindingRequired = needsWalletBinding && !isWalletBound;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState, useCallback, useEffect, useMemo } from "react";
|
|
3
3
|
import { createLeaderboardApi, LeaderboardContentType, formatRankRange, RewardsDistributeType, formatRewardText, calculatePrizePool, RewardType, LeaderboardTableColumn, truncateAddress, isAllTimeResponse, isCampaignResponse } from "@taskon/core";
|
|
4
|
-
import { h as useTaskOnContext, c as useTranslation, e as createLocaleLoader } from "./ThemeProvider-
|
|
5
|
-
import { B as Button, T as Table, P as Pagination,
|
|
4
|
+
import { h as useTaskOnContext, c as useTranslation, e as createLocaleLoader, D as Dialog } from "./ThemeProvider-CulHkqqY.js";
|
|
5
|
+
import { B as Button, T as Table, P as Pagination, u as useResolvedWidgetConfig, W as WidgetShell, a as usePagination } from "./WidgetShell-8xn-Jivw.js";
|
|
6
6
|
import '../LeaderboardWidget.css';function useLeaderboard(options) {
|
|
7
7
|
const { client } = useTaskOnContext();
|
|
8
8
|
const [data, setData] = useState(null);
|
|
@@ -513,16 +513,17 @@ function LeaderboardHeader({
|
|
|
513
513
|
}) {
|
|
514
514
|
const { t } = useLeaderboardLocale();
|
|
515
515
|
const isSprint = tabConfig.type === LeaderboardContentType.LeaderboardSprint;
|
|
516
|
+
const sprintRewardSummary = isSprint ? rewardSummary ?? null : null;
|
|
516
517
|
const eventStatus = getEventStatus(tabConfig.startTime, tabConfig.endTime, t);
|
|
517
518
|
const hasTimeRange = tabConfig.startTime && tabConfig.endTime;
|
|
518
519
|
const hasParticipants = typeof participantsCount === "number";
|
|
519
|
-
const
|
|
520
|
-
const
|
|
521
|
-
if (!
|
|
520
|
+
const shouldShowInfo = Boolean(showTitle && (eventStatus || hasTimeRange || hasParticipants));
|
|
521
|
+
const shouldShowRewardInfo = sprintRewardSummary !== null;
|
|
522
|
+
if (!shouldShowInfo && !shouldShowRewardInfo) {
|
|
522
523
|
return null;
|
|
523
524
|
}
|
|
524
525
|
return /* @__PURE__ */ jsxs("div", { className: `taskon-leaderboard-header ${className}`, children: [
|
|
525
|
-
|
|
526
|
+
shouldShowInfo && /* @__PURE__ */ jsxs("div", { className: "taskon-leaderboard-header__info", children: [
|
|
526
527
|
eventStatus && /* @__PURE__ */ jsx(
|
|
527
528
|
"span",
|
|
528
529
|
{
|
|
@@ -537,15 +538,15 @@ function LeaderboardHeader({
|
|
|
537
538
|
/* @__PURE__ */ jsx("span", { className: "taskon-leaderboard-header__participants-value", children: participantsCount.toLocaleString() })
|
|
538
539
|
] })
|
|
539
540
|
] }),
|
|
540
|
-
|
|
541
|
+
shouldShowRewardInfo && /* @__PURE__ */ jsxs("div", { className: "taskon-leaderboard-header__reward-info", children: [
|
|
541
542
|
/* @__PURE__ */ jsxs("div", { className: "taskon-leaderboard-header__reward-item", children: [
|
|
542
543
|
/* @__PURE__ */ jsx("span", { className: "taskon-leaderboard-header__reward-label", children: t("prize_pool") }),
|
|
543
|
-
/* @__PURE__ */ jsx("span", { className: "taskon-leaderboard-header__reward-value", children:
|
|
544
|
+
/* @__PURE__ */ jsx("span", { className: "taskon-leaderboard-header__reward-value", children: sprintRewardSummary.prizePool || t("no_data") })
|
|
544
545
|
] }),
|
|
545
546
|
/* @__PURE__ */ jsx("div", { className: "taskon-leaderboard-header__reward-separator" }),
|
|
546
547
|
/* @__PURE__ */ jsxs("div", { className: "taskon-leaderboard-header__reward-item", children: [
|
|
547
548
|
/* @__PURE__ */ jsx("span", { className: "taskon-leaderboard-header__reward-label", children: t("total_winners") }),
|
|
548
|
-
/* @__PURE__ */ jsx("span", { className: "taskon-leaderboard-header__reward-value", children:
|
|
549
|
+
/* @__PURE__ */ jsx("span", { className: "taskon-leaderboard-header__reward-value", children: sprintRewardSummary.totalWinners })
|
|
549
550
|
] }),
|
|
550
551
|
onOpenRewardRules && /* @__PURE__ */ jsx(
|
|
551
552
|
Button,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useState, useEffect, useMemo, useRef } from "react";
|
|
3
3
|
import { DEFAULT_PAGE_BUILDER_CONFIG, createPageBuilderApi, parsePageBuilderConfig, SectionLayoutType, WidgetTypeEnum, SECTION_LAYOUT_RATIOS } from "@taskon/core";
|
|
4
|
-
import { Q as QuestWidget } from "./Quest-
|
|
5
|
-
import { C as CommunityTaskList } from "./CommunityTaskList-
|
|
6
|
-
import { L as LeaderboardWidget } from "./LeaderboardWidget-
|
|
7
|
-
import { U as UserCenterWidget } from "./UserCenterWidget-
|
|
8
|
-
import { h as useTaskOnContext } from "./ThemeProvider-
|
|
4
|
+
import { Q as QuestWidget } from "./Quest-ySZlYd4u.js";
|
|
5
|
+
import { C as CommunityTaskList } from "./CommunityTaskList-D0uVD8wD.js";
|
|
6
|
+
import { L as LeaderboardWidget } from "./LeaderboardWidget-DyoiiNS6.js";
|
|
7
|
+
import { U as UserCenterWidget } from "./UserCenterWidget-BJsc_GSZ.js";
|
|
8
|
+
import { h as useTaskOnContext } from "./ThemeProvider-CulHkqqY.js";
|
|
9
9
|
import '../PageBuilder.css';function usePageBuilderConfig(pageId, localConfig) {
|
|
10
10
|
const { client } = useTaskOnContext();
|
|
11
11
|
const [config, setConfig] = useState(
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import React__default, { useState, useMemo, useCallback, useEffect, useRef } from "react";
|
|
3
3
|
import { RewardType, UserEligibleStatus, EligibilityTemplateId, SnsType, ChainType, QuestAutomaticallyWinnerDrawType, QuestWinnerDrawType, QuestWinnerRangeType, createQuestApi, QuestRewardsDistributeType, QuestRewardType, createLeaderboardApi, MediaType, RewardDistributedByType, ApiError, ErrorCode, CampaignType } from "@taskon/core";
|
|
4
|
-
import {
|
|
5
|
-
import { d as useTaskWidgetLocale, b as TaskItem, e as useQuestLocale, I as I18nT, f as EligibilityList, g as getDefaultExportFromCjs, s as sanitizeHtml, R as RewardModuleDialog, h as ConfirmNoticeDialog, u as useBindWallet, a as useNftClaimFlow, E as EligibilityInfo, B as BlindBoxDialog } from "./EligibilityInfo-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { R as Root2,
|
|
4
|
+
import { D as Dialog, E as useTaskOnPortalContainer, h as useTaskOnContext } from "./ThemeProvider-CulHkqqY.js";
|
|
5
|
+
import { d as useTaskWidgetLocale, b as TaskItem, e as useQuestLocale, I as I18nT, f as EligibilityList, g as getDefaultExportFromCjs, s as sanitizeHtml, R as RewardModuleDialog, h as ConfirmNoticeDialog, u as useBindWallet, a as useNftClaimFlow, E as EligibilityInfo, B as BlindBoxDialog } from "./EligibilityInfo-Cf6hx9-a.js";
|
|
6
|
+
import { B as Button, T as Table, P as Pagination, u as useResolvedWidgetConfig, W as WidgetShell } from "./WidgetShell-8xn-Jivw.js";
|
|
7
|
+
import { c as useToast } from "./useToast-BGJhd3BX.js";
|
|
8
|
+
import { R as Root2, h as Trigger, i as Portal, C as Content2, q as InfoIcon, j as Arrow2, p as TipPopover, a as useBindSocialAccount } from "./UserCenterWidget-STq8kpV4.js";
|
|
9
9
|
import '../Quest.css';function ButtonTabs({
|
|
10
10
|
items,
|
|
11
11
|
activeKey,
|
|
@@ -8544,9 +8544,7 @@ function QuestWidgetInner(props) {
|
|
|
8544
8544
|
const { bindAndWait: bindChainAndWait } = useBindWallet({
|
|
8545
8545
|
onFailed: (error2) => {
|
|
8546
8546
|
toast.error(error2);
|
|
8547
|
-
}
|
|
8548
|
-
// 当没有 adapter 时触发外部弹窗(如果配置了的话)
|
|
8549
|
-
onNeedWalletDialog: onConnectWallet
|
|
8547
|
+
}
|
|
8550
8548
|
});
|
|
8551
8549
|
const {
|
|
8552
8550
|
data: campaign,
|
|
@@ -8601,9 +8599,6 @@ function QuestWidgetInner(props) {
|
|
|
8601
8599
|
},
|
|
8602
8600
|
onClaimError: (error2) => {
|
|
8603
8601
|
toast.error(error2.message || t("failed_claim_nft"));
|
|
8604
|
-
},
|
|
8605
|
-
onWalletError: (errorMessage) => {
|
|
8606
|
-
toast.error(errorMessage);
|
|
8607
8602
|
}
|
|
8608
8603
|
});
|
|
8609
8604
|
const handleQuestClaimNft = useCallback(
|