@agg-build/ui 1.2.12 → 2.0.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/README.md +34 -1
- package/dist/{chunk-U55T5BPE.mjs → chunk-2UKDQ7WP.mjs} +44 -13
- package/dist/{chunk-X3KCFWXN.mjs → chunk-2ZS3BPSF.mjs} +1433 -1349
- package/dist/{chunk-IBOE7DRY.mjs → chunk-4CM4F4S6.mjs} +26 -27
- package/dist/{chunk-YSW4ULL5.mjs → chunk-HH7L3KLS.mjs} +1 -1
- package/dist/{chunk-3JXBOU24.mjs → chunk-R3U6YXSQ.mjs} +146 -81
- package/dist/{chunk-J6WELNCX.mjs → chunk-RF2EPYLN.mjs} +572 -181
- package/dist/{chunk-4WBQTUPW.mjs → chunk-RWOF44TC.mjs} +606 -324
- package/dist/events.js +2081 -1727
- package/dist/events.mjs +5 -3
- package/dist/index.js +4535 -3695
- package/dist/index.mjs +13 -9
- package/dist/modals.js +964 -899
- package/dist/modals.mjs +3 -3
- package/dist/pages.js +3945 -3123
- package/dist/pages.mjs +6 -6
- package/dist/primitives.js +1344 -1251
- package/dist/primitives.mjs +3 -1
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +1 -1
- package/dist/trading.js +828 -688
- package/dist/trading.mjs +4 -4
- package/dist/types/events/item/event-list-item-v2.utils.d.mts +28 -0
- package/dist/types/events/item/event-list-item-v2.utils.d.ts +28 -0
- package/dist/types/events/item/event-list-item.constants.d.mts +1 -1
- package/dist/types/events/item/event-list-item.constants.d.ts +1 -1
- package/dist/types/events/item/index.d.mts +4 -0
- package/dist/types/events/item/index.d.ts +4 -0
- package/dist/types/events/list/event-list.types.d.mts +2 -0
- package/dist/types/events/list/event-list.types.d.ts +2 -0
- package/dist/types/events/list/event-list.utils.d.mts +17 -2
- package/dist/types/events/list/event-list.utils.d.ts +17 -2
- package/dist/types/events/list/index.d.mts +1 -1
- package/dist/types/events/list/index.d.ts +1 -1
- package/dist/types/pages/home/home.types.d.mts +1 -0
- package/dist/types/pages/home/home.types.d.ts +1 -0
- package/dist/types/pages/user-profile/user-profile.types.d.mts +30 -4
- package/dist/types/pages/user-profile/user-profile.types.d.ts +30 -4
- package/dist/types/primitives/icon/index.d.mts +2 -1
- package/dist/types/primitives/icon/index.d.ts +2 -1
- package/dist/types/primitives/icon/registry.d.mts +4 -0
- package/dist/types/primitives/icon/registry.d.ts +4 -0
- package/dist/types/primitives/icon/svg/gift-bonus.d.mts +5 -0
- package/dist/types/primitives/icon/svg/gift-bonus.d.ts +5 -0
- package/dist/types/primitives/search/search.types.d.mts +2 -1
- package/dist/types/primitives/search/search.types.d.ts +2 -1
- package/dist/types/primitives/skeleton/index.d.mts +1 -1
- package/dist/types/primitives/skeleton/index.d.ts +1 -1
- package/dist/types/primitives/skeleton/skeleton.types.d.mts +4 -0
- package/dist/types/primitives/skeleton/skeleton.types.d.ts +4 -0
- package/dist/types/primitives/skeleton/views/event-list-skeleton-view.d.mts +1 -1
- package/dist/types/primitives/skeleton/views/event-list-skeleton-view.d.ts +1 -1
- package/dist/types/profile/tabs/accounts-wallets-tab.d.mts +1 -1
- package/dist/types/profile/tabs/accounts-wallets-tab.d.ts +1 -1
- package/dist/types/trading/place-order/index.d.mts +1 -1
- package/dist/types/trading/place-order/index.d.ts +1 -1
- package/dist/types/trading/place-order/index.place-order.types.d.mts +4 -1
- package/dist/types/trading/place-order/index.place-order.types.d.ts +4 -1
- package/dist/types/trading/place-order/index.place-order.utils.d.mts +2 -0
- package/dist/types/trading/place-order/index.place-order.utils.d.ts +2 -0
- package/package.json +3 -3
|
@@ -10,13 +10,13 @@ import {
|
|
|
10
10
|
isErrorWithStatus,
|
|
11
11
|
useEventListTabs,
|
|
12
12
|
useEventListTabsHeaderOverflow
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-RWOF44TC.mjs";
|
|
14
14
|
import {
|
|
15
15
|
DEPOSIT_MODAL_OPEN_EVENT,
|
|
16
16
|
PlaceOrder,
|
|
17
17
|
SettlementDetails,
|
|
18
18
|
WITHDRAW_MODAL_OPEN_EVENT
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-R3U6YXSQ.mjs";
|
|
20
20
|
import {
|
|
21
21
|
AggErrorBoundary,
|
|
22
22
|
Button,
|
|
@@ -44,11 +44,14 @@ import {
|
|
|
44
44
|
cn,
|
|
45
45
|
filterOpenEvents,
|
|
46
46
|
resolveTabVenus,
|
|
47
|
-
shortenAddress
|
|
48
|
-
|
|
47
|
+
shortenAddress,
|
|
48
|
+
sortCategoriesForNavigation,
|
|
49
|
+
useOptionalToast
|
|
50
|
+
} from "./chunk-2ZS3BPSF.mjs";
|
|
49
51
|
|
|
50
52
|
// src/pages/home/index.tsx
|
|
51
53
|
import {
|
|
54
|
+
getVisibleVenueIdsByConfig,
|
|
52
55
|
useAppConfig,
|
|
53
56
|
useCategories,
|
|
54
57
|
useEventListState,
|
|
@@ -57,7 +60,7 @@ import {
|
|
|
57
60
|
useSearch
|
|
58
61
|
} from "@agg-build/hooks";
|
|
59
62
|
import { VENUES } from "@agg-build/sdk";
|
|
60
|
-
import { useCallback as useCallback2, useEffect as useEffect3, useMemo, useRef as useRef3, useState as useState4 } from "react";
|
|
63
|
+
import { useCallback as useCallback2, useEffect as useEffect3, useMemo as useMemo2, useRef as useRef3, useState as useState4 } from "react";
|
|
61
64
|
|
|
62
65
|
// src/pages/event-market/index.tsx
|
|
63
66
|
import {
|
|
@@ -69,7 +72,7 @@ import {
|
|
|
69
72
|
useMidpoints
|
|
70
73
|
} from "@agg-build/hooks";
|
|
71
74
|
import * as Dialog from "@radix-ui/react-dialog";
|
|
72
|
-
import { useEffect, useRef, useState } from "react";
|
|
75
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
73
76
|
|
|
74
77
|
// src/pages/event-market/event-market.utils.ts
|
|
75
78
|
var EVENT_MARKET_PAGE_STICKY_HEADER_OFFSET_PX = 48;
|
|
@@ -167,7 +170,7 @@ var resolveMobileTradePlaceOrderClassNames = (classNames) => {
|
|
|
167
170
|
root: "rounded-t-agg-2xl rounded-b-none md:rounded-agg-2xl md:rounded-b-agg-2xl",
|
|
168
171
|
body: cn("flex h-full min-h-0 flex-col", classNames == null ? void 0 : classNames.tradeBody, classNames == null ? void 0 : classNames.mobileTradeBody),
|
|
169
172
|
content: cn(
|
|
170
|
-
"min-h-0 flex-1 overflow-y-auto overscroll-contain [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
|
|
173
|
+
"min-h-0 flex-1 overflow-y-auto overflow-x-hidden overscroll-contain [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
|
|
171
174
|
classNames == null ? void 0 : classNames.tradeContent,
|
|
172
175
|
classNames == null ? void 0 : classNames.mobileTradeContent
|
|
173
176
|
),
|
|
@@ -353,7 +356,7 @@ var EventMarketPageContent = ({
|
|
|
353
356
|
stickyOrderPanel,
|
|
354
357
|
resolvedClaim
|
|
355
358
|
}) => {
|
|
356
|
-
const eventTradingState = resolveEventTradingState(event);
|
|
359
|
+
const eventTradingState = useMemo(() => resolveEventTradingState(event), [event]);
|
|
357
360
|
const stickyOrderPanelState = resolveEventMarketPageStickyState({
|
|
358
361
|
stickyOrderPanel
|
|
359
362
|
});
|
|
@@ -369,7 +372,7 @@ var EventMarketPageContent = ({
|
|
|
369
372
|
(_a = setTradeSideRef.current) == null ? void 0 : _a.call(setTradeSideRef, TradeSide.Buy);
|
|
370
373
|
};
|
|
371
374
|
}, []);
|
|
372
|
-
if (!event
|
|
375
|
+
if (!event.venueMarkets.length) {
|
|
373
376
|
return /* @__PURE__ */ jsx(EventMarketPageUnavailableState, { ariaLabel });
|
|
374
377
|
}
|
|
375
378
|
return /* @__PURE__ */ jsxs(
|
|
@@ -549,6 +552,7 @@ var getDefaultEventSectionItems = (labels) => {
|
|
|
549
552
|
|
|
550
553
|
// src/pages/home/home.utils.ts
|
|
551
554
|
var resolveCategoryTabs = (categories, allCategoryTabLabel) => {
|
|
555
|
+
var _a;
|
|
552
556
|
const seenCategoryIds = /* @__PURE__ */ new Set();
|
|
553
557
|
const tabs = [
|
|
554
558
|
{
|
|
@@ -557,22 +561,31 @@ var resolveCategoryTabs = (categories, allCategoryTabLabel) => {
|
|
|
557
561
|
iconName: "arrow-trend-up"
|
|
558
562
|
}
|
|
559
563
|
];
|
|
564
|
+
const otherTabValues = /* @__PURE__ */ new Set();
|
|
560
565
|
const categoryTabs = [];
|
|
561
566
|
for (const category of categories) {
|
|
562
567
|
if (seenCategoryIds.has(category.id)) continue;
|
|
563
568
|
seenCategoryIds.add(category.id);
|
|
569
|
+
const label = (_a = category.displayName) != null ? _a : category.name.trim();
|
|
570
|
+
if (category.name.trim().toLowerCase() === "other") {
|
|
571
|
+
otherTabValues.add(category.id);
|
|
572
|
+
}
|
|
564
573
|
categoryTabs.push({
|
|
565
574
|
value: category.id,
|
|
566
|
-
label
|
|
575
|
+
label,
|
|
567
576
|
categoryIds: [category.id]
|
|
568
577
|
});
|
|
569
578
|
}
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
579
|
+
const sortedCategoryTabs = sortCategoriesForNavigation(
|
|
580
|
+
categoryTabs.map((tab) => __spreadProps(__spreadValues({}, tab), {
|
|
581
|
+
id: tab.value,
|
|
582
|
+
name: otherTabValues.has(tab.value) ? "other" : tab.label
|
|
583
|
+
}))
|
|
584
|
+
);
|
|
585
|
+
return [...tabs, ...sortedCategoryTabs.map((_b) => {
|
|
586
|
+
var _c = _b, { id: _id, name: _name } = _c, tab = __objRest(_c, ["id", "name"]);
|
|
587
|
+
return tab;
|
|
588
|
+
})];
|
|
576
589
|
};
|
|
577
590
|
var resolveInitialTabValue = (tabs, defaultActiveTab) => {
|
|
578
591
|
var _a, _b;
|
|
@@ -656,16 +669,14 @@ var HomeSearchResults = ({
|
|
|
656
669
|
const [activeVenueTabValue, setActiveVenueTabValue] = useState4("matched");
|
|
657
670
|
const eventListTabs = useEventListTabs();
|
|
658
671
|
const { headerRef, titleRef, shouldUseSelectOverflow } = useEventListTabsHeaderOverflow(eventListTabs);
|
|
659
|
-
const visibleVenues =
|
|
660
|
-
() => disabledVenues.length === 0 ? void 0 : VENUES
|
|
661
|
-
(v) => !disabledVenues.includes(v)
|
|
662
|
-
),
|
|
672
|
+
const visibleVenues = useMemo2(
|
|
673
|
+
() => disabledVenues.length === 0 ? void 0 : getVisibleVenueIdsByConfig(VENUES, disabledVenues),
|
|
663
674
|
[disabledVenues]
|
|
664
675
|
);
|
|
665
|
-
const activeVenueTab =
|
|
676
|
+
const activeVenueTab = useMemo2(() => {
|
|
666
677
|
return eventListTabs.find((tab) => tab.value === activeVenueTabValue);
|
|
667
678
|
}, [activeVenueTabValue, eventListTabs]);
|
|
668
|
-
const activeCategoryTab =
|
|
679
|
+
const activeCategoryTab = useMemo2(() => {
|
|
669
680
|
return resolvedTabs.find((tab) => tab.value === activeTabValue);
|
|
670
681
|
}, [activeTabValue, resolvedTabs]);
|
|
671
682
|
const activeVenues = resolveTabVenus(activeVenueTab, visibleVenues);
|
|
@@ -689,7 +700,7 @@ var HomeSearchResults = ({
|
|
|
689
700
|
// so debounced keystrokes don't pay reranker latency.
|
|
690
701
|
deep: true
|
|
691
702
|
});
|
|
692
|
-
const openEvents =
|
|
703
|
+
const openEvents = useMemo2(() => {
|
|
693
704
|
let filtered = filterOpenEvents(searchResults);
|
|
694
705
|
if (activeVenues == null ? void 0 : activeVenues.length) {
|
|
695
706
|
filtered = filtered.filter((e) => activeVenues.includes(e.venue));
|
|
@@ -775,7 +786,9 @@ var HomeSearchResults = ({
|
|
|
775
786
|
"div",
|
|
776
787
|
{
|
|
777
788
|
className: cn(
|
|
778
|
-
"agg-event-list-grid
|
|
789
|
+
"agg-event-list-grid",
|
|
790
|
+
"grid grid-cols-[repeat(auto-fill,minmax(240px,1fr))] md:grid-cols-[repeat(auto-fill,minmax(360px,1fr))] gap-4",
|
|
791
|
+
"transition-opacity duration-200",
|
|
779
792
|
"empty:hidden",
|
|
780
793
|
isPlaceholderData && "opacity-60"
|
|
781
794
|
),
|
|
@@ -785,7 +798,7 @@ var HomeSearchResults = ({
|
|
|
785
798
|
{
|
|
786
799
|
event,
|
|
787
800
|
classNames: {
|
|
788
|
-
root: "agg-event-list-item w-full min-w-0 max-w-none"
|
|
801
|
+
root: "agg-event-list-item w-full min-w-0! max-w-none justify-between!"
|
|
789
802
|
},
|
|
790
803
|
href: getEventHref == null ? void 0 : getEventHref(event),
|
|
791
804
|
onEventClick: (selectedEvent) => {
|
|
@@ -921,10 +934,10 @@ var HomePage = ({
|
|
|
921
934
|
limit: categoriesLimit,
|
|
922
935
|
enabled: !hasCustomTabs
|
|
923
936
|
});
|
|
924
|
-
const categoryTabs =
|
|
937
|
+
const categoryTabs = useMemo2(() => {
|
|
925
938
|
return resolveCategoryTabs(categories, resolvedAllCategoryTabLabel);
|
|
926
939
|
}, [categories, resolvedAllCategoryTabLabel]);
|
|
927
|
-
const resolvedTabs =
|
|
940
|
+
const resolvedTabs = useMemo2(() => {
|
|
928
941
|
if (hasCustomTabs && tabs) return tabs;
|
|
929
942
|
return categoryTabs;
|
|
930
943
|
}, [categoryTabs, hasCustomTabs, tabs]);
|
|
@@ -944,7 +957,7 @@ var HomePage = ({
|
|
|
944
957
|
return resolveInitialTabValue(resolvedTabs, defaultActiveTab);
|
|
945
958
|
});
|
|
946
959
|
}, [defaultActiveTab, resolvedTabs]);
|
|
947
|
-
const tabsItems =
|
|
960
|
+
const tabsItems = useMemo2(() => {
|
|
948
961
|
return resolvedTabs.map((tab) => {
|
|
949
962
|
const isActive = tab.value === activeTabValue;
|
|
950
963
|
return {
|
|
@@ -964,10 +977,10 @@ var HomePage = ({
|
|
|
964
977
|
};
|
|
965
978
|
});
|
|
966
979
|
}, [activeTabValue, resolvedTabs]);
|
|
967
|
-
const activeTab =
|
|
980
|
+
const activeTab = useMemo2(() => {
|
|
968
981
|
return resolvedTabs.find((tab) => tab.value === activeTabValue);
|
|
969
982
|
}, [activeTabValue, resolvedTabs]);
|
|
970
|
-
const resolvedSectionItems =
|
|
983
|
+
const resolvedSectionItems = useMemo2(() => {
|
|
971
984
|
var _a2, _b2, _c2;
|
|
972
985
|
if (activeTabValue === ALL_CATEGORIES_TAB_VALUE) {
|
|
973
986
|
return resolvedEventSectionItems;
|
|
@@ -987,9 +1000,24 @@ var HomePage = ({
|
|
|
987
1000
|
setActiveTabValue(value);
|
|
988
1001
|
_onTabChange == null ? void 0 : _onTabChange(value);
|
|
989
1002
|
};
|
|
1003
|
+
const handleCategoryRootChange = (categoryId) => {
|
|
1004
|
+
const nextTab = categoryId ? resolvedTabs.find(
|
|
1005
|
+
(tab) => {
|
|
1006
|
+
var _a2;
|
|
1007
|
+
return tab.value === categoryId || ((_a2 = tab.categoryIds) == null ? void 0 : _a2.includes(categoryId));
|
|
1008
|
+
}
|
|
1009
|
+
) : resolvedTabs.find((tab) => tab.value === ALL_CATEGORIES_TAB_VALUE);
|
|
1010
|
+
if (!nextTab) return;
|
|
1011
|
+
if (nextTab.value === activeTabValue) return;
|
|
1012
|
+
handleTabChange(nextTab.value);
|
|
1013
|
+
};
|
|
990
1014
|
const handleLogoClick = () => {
|
|
991
1015
|
onSearchChange == null ? void 0 : onSearchChange("");
|
|
992
1016
|
};
|
|
1017
|
+
const handleMobileSearchSelect = (_eventId, event) => {
|
|
1018
|
+
if (!event) return;
|
|
1019
|
+
handleSelectEvent(event);
|
|
1020
|
+
};
|
|
993
1021
|
const shouldRenderMobileSearch = isMobileSearchViewport && !resolvedSelectedEvent;
|
|
994
1022
|
const isScrollRestorationReady = !!snapshot && !isShowingAllResults && !resolvedSelectedEvent && ((_b = (_a = eventListStateRef.current) == null ? void 0 : _a.loadedPageCount) != null ? _b : 0) >= ((_c = snapshot.loadedPageCount) != null ? _c : 1);
|
|
995
1023
|
useScrollRestoration({
|
|
@@ -1012,7 +1040,7 @@ var HomePage = ({
|
|
|
1012
1040
|
{
|
|
1013
1041
|
className: cn(
|
|
1014
1042
|
"agg-page-header",
|
|
1015
|
-
"w-full bg-agg-secondary border-b border-agg-separator h-
|
|
1043
|
+
"w-full bg-agg-secondary border-b border-agg-separator h-14! md:h-15!",
|
|
1016
1044
|
classNames == null ? void 0 : classNames.header
|
|
1017
1045
|
),
|
|
1018
1046
|
children: /* @__PURE__ */ jsx2("div", { className: "mx-auto h-full w-full max-w-[1360px] px-6 lg:px-10", children: /* @__PURE__ */ jsx2(
|
|
@@ -1021,7 +1049,7 @@ var HomePage = ({
|
|
|
1021
1049
|
ariaLabel: labels.home.categoryTabsAria,
|
|
1022
1050
|
variant: "underline",
|
|
1023
1051
|
className: cn("w-full", classNames == null ? void 0 : classNames.tabs),
|
|
1024
|
-
classNames: { tabList: "!h-
|
|
1052
|
+
classNames: { tabList: "h-14! md:h-15!" },
|
|
1025
1053
|
items: tabsItems,
|
|
1026
1054
|
value: activeTabValue,
|
|
1027
1055
|
onChange: handleTabChange
|
|
@@ -1037,7 +1065,13 @@ var HomePage = ({
|
|
|
1037
1065
|
"pt-4 sm:pt-6 md:pt-8 pb-10"
|
|
1038
1066
|
),
|
|
1039
1067
|
children: [
|
|
1040
|
-
shouldRenderMobileSearch ? /* @__PURE__ */ jsx2("div", { className: "agg-page-mobile-search w-full
|
|
1068
|
+
shouldRenderMobileSearch ? /* @__PURE__ */ jsx2("div", { className: "agg-page-mobile-search w-full pb-5 md:hidden", children: /* @__PURE__ */ jsx2(
|
|
1069
|
+
Search,
|
|
1070
|
+
{
|
|
1071
|
+
onSelectEvent: handleMobileSearchSelect,
|
|
1072
|
+
onSeeAllEvents: onSeeAllEventsProp
|
|
1073
|
+
}
|
|
1074
|
+
) }) : null,
|
|
1041
1075
|
/* @__PURE__ */ jsx2(
|
|
1042
1076
|
"main",
|
|
1043
1077
|
{
|
|
@@ -1071,6 +1105,7 @@ var HomePage = ({
|
|
|
1071
1105
|
maxVisibleItems: eventSectionItem.maxVisibleItems,
|
|
1072
1106
|
search: (_b2 = eventSectionItem.search) != null ? _b2 : activeTab == null ? void 0 : activeTab.search,
|
|
1073
1107
|
categoryIds: (_c2 = eventSectionItem.categoryIds) != null ? _c2 : activeTab == null ? void 0 : activeTab.categoryIds,
|
|
1108
|
+
onCategoryRootChange: handleCategoryRootChange,
|
|
1074
1109
|
getEventHref,
|
|
1075
1110
|
getMarketHref,
|
|
1076
1111
|
onEventClick: (event) => {
|
|
@@ -1102,6 +1137,9 @@ import {
|
|
|
1102
1137
|
computeClosedPositionTotals,
|
|
1103
1138
|
executionKeys,
|
|
1104
1139
|
getWalletAddressFromUserProfile,
|
|
1140
|
+
invalidateBalanceQueries,
|
|
1141
|
+
invalidatePositionQueries,
|
|
1142
|
+
invalidateUserActivityQueries,
|
|
1105
1143
|
useAggAuthState,
|
|
1106
1144
|
useAggBalance,
|
|
1107
1145
|
useAggClient,
|
|
@@ -1116,7 +1154,7 @@ import {
|
|
|
1116
1154
|
useUserActivity
|
|
1117
1155
|
} from "@agg-build/hooks";
|
|
1118
1156
|
import { Venue } from "@agg-build/sdk";
|
|
1119
|
-
import { useCallback as useCallback3, useEffect as useEffect5, useMemo as
|
|
1157
|
+
import { useCallback as useCallback3, useEffect as useEffect5, useMemo as useMemo4, useRef as useRef5, useState as useState6 } from "react";
|
|
1120
1158
|
|
|
1121
1159
|
// src/pages/user-profile/chain-display.ts
|
|
1122
1160
|
var CHAIN_ID_TO_LABEL = {
|
|
@@ -1317,7 +1355,7 @@ AvailableBalanceCard.displayName = "AvailableBalanceCard";
|
|
|
1317
1355
|
|
|
1318
1356
|
// src/pages/user-profile/components/positions-activity.tsx
|
|
1319
1357
|
import { optimizedImageUrl as optimizedImageUrl2, useLabels as useLabels4 } from "@agg-build/hooks";
|
|
1320
|
-
import { Fragment as Fragment4, useEffect as useEffect4, useMemo as
|
|
1358
|
+
import { Fragment as Fragment4, useEffect as useEffect4, useMemo as useMemo3, useRef as useRef4, useState as useState5 } from "react";
|
|
1321
1359
|
|
|
1322
1360
|
// src/pages/user-profile/user-profile.constants.ts
|
|
1323
1361
|
var USER_PROFILE_TAB_POSITIONS = "positions";
|
|
@@ -1506,7 +1544,10 @@ var toPositionRowViewModel = (position, labels = defaultLabels) => {
|
|
|
1506
1544
|
percentLabel: formatSignedPercent(payoutPercent),
|
|
1507
1545
|
tone: getPositionTone(payoutPnl)
|
|
1508
1546
|
},
|
|
1509
|
-
|
|
1547
|
+
// "ineligible" winners (auto-settled venues like Hyperliquid, dust below
|
|
1548
|
+
// the redeem threshold) have no redeem path — a Claim button would only
|
|
1549
|
+
// error on click. Undefined closedClaimStatus keeps the legacy behavior.
|
|
1550
|
+
canClaim: positionStatus === "won_unclaimed" && position.closedClaimStatus !== "pending" && position.closedClaimStatus !== "ineligible"
|
|
1510
1551
|
};
|
|
1511
1552
|
};
|
|
1512
1553
|
|
|
@@ -1545,7 +1586,8 @@ var TRANSFER_ICON = {
|
|
|
1545
1586
|
withdrawal: "upload",
|
|
1546
1587
|
deposit: "download",
|
|
1547
1588
|
bridge: "arrows-to-dot",
|
|
1548
|
-
user_op: "wallet"
|
|
1589
|
+
user_op: "wallet",
|
|
1590
|
+
unknown: "info"
|
|
1549
1591
|
};
|
|
1550
1592
|
var TRANSFER_STATUS_VISUAL = {
|
|
1551
1593
|
completed: { icon: "badge-check-thin", iconClassName: "text-agg-muted-foreground" },
|
|
@@ -1558,6 +1600,9 @@ var resolveActivityStatus = (activity) => {
|
|
|
1558
1600
|
if (activity.status) return activity.status;
|
|
1559
1601
|
return "completed";
|
|
1560
1602
|
};
|
|
1603
|
+
var getStatusVisual = (activity) => {
|
|
1604
|
+
return TRANSFER_STATUS_VISUAL[resolveActivityStatus(activity)];
|
|
1605
|
+
};
|
|
1561
1606
|
var resolveToneClasses = (_activity) => {
|
|
1562
1607
|
return {
|
|
1563
1608
|
primary: "text-agg-foreground",
|
|
@@ -1647,20 +1692,54 @@ var TransferTypeCell = ({
|
|
|
1647
1692
|
}
|
|
1648
1693
|
)
|
|
1649
1694
|
] });
|
|
1650
|
-
var
|
|
1695
|
+
var RedeemTypeCell = ({
|
|
1651
1696
|
activity,
|
|
1652
1697
|
tone
|
|
1653
|
-
}) => /* @__PURE__ */ jsxs4(
|
|
1654
|
-
/* @__PURE__ */ jsx4(
|
|
1698
|
+
}) => /* @__PURE__ */ jsxs4("div", { className: "hidden w-[108px] shrink-0 items-center gap-3 sm:flex", children: [
|
|
1699
|
+
/* @__PURE__ */ jsx4(
|
|
1700
|
+
Icon,
|
|
1701
|
+
{
|
|
1702
|
+
name: "gift-bonus",
|
|
1703
|
+
size: "small",
|
|
1704
|
+
className: cn(
|
|
1705
|
+
"shrink-0 text-agg-foreground",
|
|
1706
|
+
activity.hasError || activity.errorMessage ? "text-agg-error!" : ""
|
|
1707
|
+
)
|
|
1708
|
+
}
|
|
1709
|
+
),
|
|
1710
|
+
/* @__PURE__ */ jsx4(
|
|
1711
|
+
"p",
|
|
1712
|
+
{
|
|
1713
|
+
className: cn(
|
|
1714
|
+
"agg-activity-type w-20 font-agg-sans text-agg-sm leading-agg-5 font-agg-normal",
|
|
1715
|
+
tone.primary,
|
|
1716
|
+
activity.hasError || activity.errorMessage ? "text-agg-error!" : ""
|
|
1717
|
+
),
|
|
1718
|
+
children: activity.type
|
|
1719
|
+
}
|
|
1720
|
+
)
|
|
1721
|
+
] });
|
|
1722
|
+
var OutcomeBadge = ({
|
|
1723
|
+
label,
|
|
1724
|
+
tone
|
|
1725
|
+
}) => {
|
|
1726
|
+
if (!label) return null;
|
|
1727
|
+
return /* @__PURE__ */ jsx4("span", { className: "agg-activity-outcome inline-flex items-center justify-center gap-1.5 rounded-full bg-agg-secondary-hover px-4 py-[6px]", children: /* @__PURE__ */ jsx4(
|
|
1655
1728
|
"span",
|
|
1656
1729
|
{
|
|
1657
1730
|
className: cn(
|
|
1658
1731
|
"font-agg-sans text-agg-sm leading-agg-5 font-agg-normal whitespace-nowrap",
|
|
1659
1732
|
tone.primary
|
|
1660
1733
|
),
|
|
1661
|
-
children:
|
|
1734
|
+
children: label
|
|
1662
1735
|
}
|
|
1663
|
-
) })
|
|
1736
|
+
) });
|
|
1737
|
+
};
|
|
1738
|
+
var TradeOutcomeShares = ({
|
|
1739
|
+
activity,
|
|
1740
|
+
tone
|
|
1741
|
+
}) => /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
1742
|
+
/* @__PURE__ */ jsx4(OutcomeBadge, { label: activity.outcomeLabel, tone }),
|
|
1664
1743
|
/* @__PURE__ */ jsx4(
|
|
1665
1744
|
"span",
|
|
1666
1745
|
{
|
|
@@ -1672,6 +1751,145 @@ var TradeOutcomeShares = ({
|
|
|
1672
1751
|
}
|
|
1673
1752
|
)
|
|
1674
1753
|
] });
|
|
1754
|
+
var RedeemRow = ({
|
|
1755
|
+
activity,
|
|
1756
|
+
className,
|
|
1757
|
+
onClick
|
|
1758
|
+
}) => {
|
|
1759
|
+
const tone = resolveToneClasses(activity);
|
|
1760
|
+
const statusVisual = getStatusVisual(activity);
|
|
1761
|
+
const activityStatus = resolveActivityStatus(activity);
|
|
1762
|
+
const shouldShowInlineStatus = activityStatus !== "completed";
|
|
1763
|
+
return /* @__PURE__ */ jsx4("button", { type: "button", className, onClick, children: /* @__PURE__ */ jsx4(
|
|
1764
|
+
ConditionalWrapper,
|
|
1765
|
+
{
|
|
1766
|
+
condition: !!activity.errorMessage,
|
|
1767
|
+
wrapper: (children) => /* @__PURE__ */ jsx4(
|
|
1768
|
+
Tooltip,
|
|
1769
|
+
{
|
|
1770
|
+
size: "medium",
|
|
1771
|
+
content: /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-4", children: [
|
|
1772
|
+
/* @__PURE__ */ jsx4(Icon, { name: "info", size: "small", className: "shrink-0 text-agg-error" }),
|
|
1773
|
+
/* @__PURE__ */ jsx4("p", { className: "font-agg-sans text-agg-sm font-agg-normal text-left", children: activity.errorMessage })
|
|
1774
|
+
] }),
|
|
1775
|
+
sideOffset: 4,
|
|
1776
|
+
children
|
|
1777
|
+
}
|
|
1778
|
+
),
|
|
1779
|
+
children: /* @__PURE__ */ jsxs4(
|
|
1780
|
+
"div",
|
|
1781
|
+
{
|
|
1782
|
+
className: cn(
|
|
1783
|
+
"flex w-full flex-col gap-3 text-left transition-colors sm:min-h-16 sm:flex-row sm:items-center",
|
|
1784
|
+
"relative z-10"
|
|
1785
|
+
),
|
|
1786
|
+
"data-status": activityStatus,
|
|
1787
|
+
children: [
|
|
1788
|
+
/* @__PURE__ */ jsx4(RedeemTypeCell, { activity, tone }),
|
|
1789
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex w-full items-center justify-between sm:hidden", children: [
|
|
1790
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-2", children: [
|
|
1791
|
+
/* @__PURE__ */ jsx4(
|
|
1792
|
+
Icon,
|
|
1793
|
+
{
|
|
1794
|
+
name: "gift-bonus",
|
|
1795
|
+
size: "small",
|
|
1796
|
+
className: cn(
|
|
1797
|
+
"shrink-0 text-agg-foreground",
|
|
1798
|
+
activity.hasError || activity.errorMessage ? "text-agg-error!" : ""
|
|
1799
|
+
)
|
|
1800
|
+
}
|
|
1801
|
+
),
|
|
1802
|
+
/* @__PURE__ */ jsx4(
|
|
1803
|
+
"p",
|
|
1804
|
+
{
|
|
1805
|
+
className: cn(
|
|
1806
|
+
"agg-activity-type font-agg-sans text-agg-sm leading-agg-5 font-agg-normal",
|
|
1807
|
+
tone.primary,
|
|
1808
|
+
activity.hasError || activity.errorMessage ? "text-agg-error!" : ""
|
|
1809
|
+
),
|
|
1810
|
+
children: activity.type
|
|
1811
|
+
}
|
|
1812
|
+
)
|
|
1813
|
+
] }),
|
|
1814
|
+
/* @__PURE__ */ jsx4(OutcomeBadge, { label: activity.outcomeLabel, tone })
|
|
1815
|
+
] }),
|
|
1816
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex w-full items-center justify-between sm:contents", children: [
|
|
1817
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex min-w-0 flex-1 items-center gap-3 sm:gap-4", children: [
|
|
1818
|
+
/* @__PURE__ */ jsx4("div", { className: "agg-activity-image flex h-10 w-10 shrink-0 items-center justify-center sm:h-15 sm:w-15", children: /* @__PURE__ */ jsx4(
|
|
1819
|
+
RemoteImage,
|
|
1820
|
+
{
|
|
1821
|
+
src: activity.thumbnailSrc,
|
|
1822
|
+
alt: "",
|
|
1823
|
+
className: "h-full w-full rounded-agg-sm object-cover sm:rounded-agg-lg",
|
|
1824
|
+
classNames: { placeholder: "rounded-agg-sm sm:rounded-agg-lg" }
|
|
1825
|
+
}
|
|
1826
|
+
) }),
|
|
1827
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex min-w-0 flex-1 flex-col justify-center gap-1 sm:gap-2", children: [
|
|
1828
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex min-w-0 items-center gap-2", children: [
|
|
1829
|
+
/* @__PURE__ */ jsx4(
|
|
1830
|
+
"p",
|
|
1831
|
+
{
|
|
1832
|
+
className: cn(
|
|
1833
|
+
"min-w-0 overflow-hidden text-ellipsis whitespace-nowrap font-agg-sans text-agg-sm leading-agg-5 font-agg-bold sm:text-agg-base sm:leading-agg-6",
|
|
1834
|
+
tone.primary
|
|
1835
|
+
),
|
|
1836
|
+
children: activity.title
|
|
1837
|
+
}
|
|
1838
|
+
),
|
|
1839
|
+
shouldShowInlineStatus ? statusVisual.spin ? /* @__PURE__ */ jsx4(
|
|
1840
|
+
LoadingIcon,
|
|
1841
|
+
{
|
|
1842
|
+
size: "small",
|
|
1843
|
+
className: cn("shrink-0", statusVisual.iconClassName)
|
|
1844
|
+
}
|
|
1845
|
+
) : /* @__PURE__ */ jsx4(
|
|
1846
|
+
Icon,
|
|
1847
|
+
{
|
|
1848
|
+
name: statusVisual.icon,
|
|
1849
|
+
size: "small",
|
|
1850
|
+
className: cn("shrink-0", statusVisual.iconClassName)
|
|
1851
|
+
}
|
|
1852
|
+
) : null
|
|
1853
|
+
] }),
|
|
1854
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex min-w-0 items-center gap-2 sm:gap-3", children: [
|
|
1855
|
+
/* @__PURE__ */ jsx4("div", { className: "hidden sm:block", children: /* @__PURE__ */ jsx4(OutcomeBadge, { label: activity.outcomeLabel, tone }) }),
|
|
1856
|
+
/* @__PURE__ */ jsx4(
|
|
1857
|
+
"p",
|
|
1858
|
+
{
|
|
1859
|
+
className: cn(
|
|
1860
|
+
"min-w-0 overflow-hidden text-ellipsis whitespace-nowrap font-agg-sans text-agg-sm leading-agg-5 font-agg-normal",
|
|
1861
|
+
tone.meta
|
|
1862
|
+
),
|
|
1863
|
+
children: activity.marketTitle
|
|
1864
|
+
}
|
|
1865
|
+
)
|
|
1866
|
+
] })
|
|
1867
|
+
] })
|
|
1868
|
+
] }),
|
|
1869
|
+
/* @__PURE__ */ jsx4(
|
|
1870
|
+
AmountTimeStack,
|
|
1871
|
+
{
|
|
1872
|
+
amountLabel: activity.amountLabel,
|
|
1873
|
+
timeLabel: activity.timeLabel,
|
|
1874
|
+
tone,
|
|
1875
|
+
mobile: true
|
|
1876
|
+
}
|
|
1877
|
+
)
|
|
1878
|
+
] }),
|
|
1879
|
+
/* @__PURE__ */ jsx4(
|
|
1880
|
+
AmountTimeStack,
|
|
1881
|
+
{
|
|
1882
|
+
amountLabel: activity.amountLabel,
|
|
1883
|
+
timeLabel: activity.timeLabel,
|
|
1884
|
+
tone
|
|
1885
|
+
}
|
|
1886
|
+
)
|
|
1887
|
+
]
|
|
1888
|
+
}
|
|
1889
|
+
)
|
|
1890
|
+
}
|
|
1891
|
+
) });
|
|
1892
|
+
};
|
|
1675
1893
|
var TradeRow = ({
|
|
1676
1894
|
activity,
|
|
1677
1895
|
className,
|
|
@@ -1776,9 +1994,9 @@ var TransferRow = ({
|
|
|
1776
1994
|
onClick
|
|
1777
1995
|
}) => {
|
|
1778
1996
|
const tone = resolveToneClasses(activity);
|
|
1779
|
-
const transferIconName = TRANSFER_ICON[activity.kind];
|
|
1780
1997
|
const transferStatus = resolveActivityStatus(activity);
|
|
1781
|
-
const
|
|
1998
|
+
const transferIconName = TRANSFER_ICON[activity.kind];
|
|
1999
|
+
const statusVisual = getStatusVisual(activity);
|
|
1782
2000
|
return /* @__PURE__ */ jsx4("button", { type: "button", className, onClick, children: /* @__PURE__ */ jsx4(
|
|
1783
2001
|
ConditionalWrapper,
|
|
1784
2002
|
{
|
|
@@ -1906,6 +2124,9 @@ var ActivityRow = ({ activity, href, onClick }) => {
|
|
|
1906
2124
|
if (activity.kind === "trade") {
|
|
1907
2125
|
return /* @__PURE__ */ jsx4(TradeRow, { activity, className: sharedClassName, href, onClick: handleClick });
|
|
1908
2126
|
}
|
|
2127
|
+
if (activity.kind === "redeem") {
|
|
2128
|
+
return /* @__PURE__ */ jsx4(RedeemRow, { activity, className: sharedClassName, onClick: handleClick });
|
|
2129
|
+
}
|
|
1909
2130
|
return /* @__PURE__ */ jsx4(TransferRow, { activity, className: sharedClassName, onClick: handleClick });
|
|
1910
2131
|
};
|
|
1911
2132
|
ActivityRow.displayName = "ActivityRow";
|
|
@@ -2305,7 +2526,7 @@ var PositionsActivity = ({
|
|
|
2305
2526
|
const isPositionsTab = activeTab === USER_PROFILE_TAB_POSITIONS;
|
|
2306
2527
|
const isActivityTab = activeTab === USER_PROFILE_TAB_ACTIVITY;
|
|
2307
2528
|
const isClosedPositionsFilter = isPositionsTab && positionFilter === "closed";
|
|
2308
|
-
const positionsForCurrentFilter =
|
|
2529
|
+
const positionsForCurrentFilter = useMemo3(() => {
|
|
2309
2530
|
if (positionFilter === "active") {
|
|
2310
2531
|
return activePositions.filter((position) => !locallyClaimedPositionIds.has(position.id));
|
|
2311
2532
|
}
|
|
@@ -2322,13 +2543,17 @@ var PositionsActivity = ({
|
|
|
2322
2543
|
}
|
|
2323
2544
|
return Array.from(byId.values());
|
|
2324
2545
|
}, [activePositions, closedPositions, locallyClaimedPositionIds, positionFilter]);
|
|
2325
|
-
const filteredPositions =
|
|
2546
|
+
const filteredPositions = useMemo3(() => {
|
|
2326
2547
|
if (!searchValue.trim()) return positionsForCurrentFilter;
|
|
2327
2548
|
const q = searchValue.toLowerCase();
|
|
2328
2549
|
return positionsForCurrentFilter.filter((p) => p.title.toLowerCase().includes(q));
|
|
2329
2550
|
}, [positionsForCurrentFilter, searchValue]);
|
|
2330
2551
|
const handleClaimPosition = (position) => __async(null, null, function* () {
|
|
2331
|
-
|
|
2552
|
+
try {
|
|
2553
|
+
yield onClaim == null ? void 0 : onClaim(position);
|
|
2554
|
+
} catch (e) {
|
|
2555
|
+
return;
|
|
2556
|
+
}
|
|
2332
2557
|
setLocallyClaimedPositionIds((prev) => {
|
|
2333
2558
|
const next = new Set(prev);
|
|
2334
2559
|
next.add(position.id);
|
|
@@ -2343,7 +2568,7 @@ var PositionsActivity = ({
|
|
|
2343
2568
|
const isLoadingMorePositions = positionFilter === "active" ? isLoadingMoreActivePositions : isLoadingMoreClosedPositions;
|
|
2344
2569
|
const loadMorePositions = positionFilter === "active" ? onLoadMoreActivePositions : onLoadMoreClosedPositions;
|
|
2345
2570
|
const filteredActivities = activities;
|
|
2346
|
-
const searchResults =
|
|
2571
|
+
const searchResults = useMemo3(() => {
|
|
2347
2572
|
if (!isPositionsTab || !searchValue.trim()) return [];
|
|
2348
2573
|
return filteredPositions.slice(0, 5).map((position) => ({
|
|
2349
2574
|
id: position.id,
|
|
@@ -3140,13 +3365,19 @@ var OPEN_ORDER_STATUSES = /* @__PURE__ */ new Set([
|
|
|
3140
3365
|
var SHOW_SOLD_POSITIONS = false;
|
|
3141
3366
|
var SOLD_POSITION_SHARES_THRESHOLD = 0.1;
|
|
3142
3367
|
var isOpenOrderStatus = (status) => OPEN_ORDER_STATUSES.has(status.toLowerCase());
|
|
3368
|
+
var shouldIncludeByShares = (position) => {
|
|
3369
|
+
if (SHOW_SOLD_POSITIONS) return true;
|
|
3370
|
+
if (typeof position.totalShares !== "number") return true;
|
|
3371
|
+
return position.totalShares >= SOLD_POSITION_SHARES_THRESHOLD;
|
|
3372
|
+
};
|
|
3143
3373
|
var getActivityErrorMessage = (item) => {
|
|
3144
3374
|
if (!("errorMessage" in item)) return null;
|
|
3145
3375
|
return typeof item.errorMessage === "string" ? item.errorMessage : null;
|
|
3146
3376
|
};
|
|
3147
3377
|
var hasActivityError = (item) => {
|
|
3378
|
+
var _a;
|
|
3148
3379
|
const errorMessage = getActivityErrorMessage(item);
|
|
3149
|
-
return item.status.toLowerCase() === "failed" || !!(errorMessage == null ? void 0 : errorMessage.trim());
|
|
3380
|
+
return ((_a = item.status) == null ? void 0 : _a.toLowerCase()) === "failed" || !!(errorMessage == null ? void 0 : errorMessage.trim());
|
|
3150
3381
|
};
|
|
3151
3382
|
var normalizeTradeStatus = (status) => {
|
|
3152
3383
|
const normalized = status.toLowerCase();
|
|
@@ -3182,17 +3413,52 @@ var normalizeDepositStatus = (status) => {
|
|
|
3182
3413
|
if (TRANSFER_CANCELED_STATUSES.has(normalized)) return "canceled";
|
|
3183
3414
|
return "completed";
|
|
3184
3415
|
};
|
|
3416
|
+
var normalizeRedeemStatus = (status) => {
|
|
3417
|
+
const normalized = status.toLowerCase();
|
|
3418
|
+
if (normalized === "pending" || normalized === "submitted") return "pending";
|
|
3419
|
+
if (normalized === "confirmed" || normalized === "completed") return "completed";
|
|
3420
|
+
if (TRANSFER_FAILED_STATUSES.has(normalized)) return "failed";
|
|
3421
|
+
if (TRANSFER_CANCELED_STATUSES.has(normalized)) return "canceled";
|
|
3422
|
+
return "completed";
|
|
3423
|
+
};
|
|
3424
|
+
var getDerivedRedeemStatus = (item) => {
|
|
3425
|
+
const legs = Array.isArray(item.legs) ? item.legs : [];
|
|
3426
|
+
const legStatuses = legs.map((leg) => leg.status.toLowerCase());
|
|
3427
|
+
if (legStatuses.length > 0 && legStatuses.every((status) => status === "confirmed")) {
|
|
3428
|
+
return "completed";
|
|
3429
|
+
}
|
|
3430
|
+
if (legStatuses.some((status) => TRANSFER_FAILED_STATUSES.has(status))) return "failed";
|
|
3431
|
+
if (legStatuses.some((status) => TRANSFER_CANCELED_STATUSES.has(status))) return "canceled";
|
|
3432
|
+
return normalizeRedeemStatus(item.status);
|
|
3433
|
+
};
|
|
3185
3434
|
var ZERO_AMOUNT_LABEL = "$0";
|
|
3186
3435
|
var isVisibleActivityItem = (item) => {
|
|
3187
3436
|
var _a;
|
|
3188
3437
|
if (item.type === "user_op" || item.type === "bridge") return false;
|
|
3189
3438
|
if (item.type === "trade") {
|
|
3190
|
-
|
|
3191
|
-
if (
|
|
3439
|
+
const tradeItem = item;
|
|
3440
|
+
if (isOpenOrderStatus(tradeItem.status)) return false;
|
|
3441
|
+
if (tradeItem.status.toLowerCase() === "failed" && ((_a = parseRawMicroValue(tradeItem.filledAmountRaw)) != null ? _a : 0) <= 0)
|
|
3192
3442
|
return false;
|
|
3193
3443
|
}
|
|
3194
3444
|
return true;
|
|
3195
3445
|
};
|
|
3446
|
+
var getRuntimeActivityId = (item, index) => {
|
|
3447
|
+
return typeof item.id === "string" && item.id.trim() ? item.id : `unknown-activity-${index}`;
|
|
3448
|
+
};
|
|
3449
|
+
var getRuntimeActivityType = (item) => {
|
|
3450
|
+
return typeof item.type === "string" && item.type.trim() ? item.type : "unknown";
|
|
3451
|
+
};
|
|
3452
|
+
var getRuntimeActivityCreatedAt = (item) => {
|
|
3453
|
+
return item.createdAt instanceof Date || typeof item.createdAt === "string" ? item.createdAt : /* @__PURE__ */ new Date();
|
|
3454
|
+
};
|
|
3455
|
+
var logUnknownActivityType = (item) => {
|
|
3456
|
+
if (process.env.NODE_ENV !== "development") return;
|
|
3457
|
+
console.warn("[UserProfilePage] Unsupported activity type", {
|
|
3458
|
+
type: getRuntimeActivityType(item),
|
|
3459
|
+
id: typeof item.id === "string" ? item.id : void 0
|
|
3460
|
+
});
|
|
3461
|
+
};
|
|
3196
3462
|
var isVisibleUserProfileActivity = (activity) => activity.kind !== "bridge";
|
|
3197
3463
|
var shouldFetchFullUserProfile = (userProfile) => {
|
|
3198
3464
|
var _a, _b, _c, _d;
|
|
@@ -3252,6 +3518,21 @@ var toTokenAmountLabel = ({
|
|
|
3252
3518
|
const prefix = sign != null ? sign : "";
|
|
3253
3519
|
return `${prefix}${formatTokenAmountTwoDecimals(amountRaw, tokenSymbol, chainId)} ${tokenSymbol}`;
|
|
3254
3520
|
};
|
|
3521
|
+
var toRedeemPayoutAmountLabel = (item) => {
|
|
3522
|
+
var _a, _b;
|
|
3523
|
+
const legs = Array.isArray(item.legs) ? item.legs : [];
|
|
3524
|
+
const firstLeg = legs[0];
|
|
3525
|
+
const tokenSymbol = (_a = firstLeg == null ? void 0 : firstLeg.payoutTokenSymbol) != null ? _a : "USDC";
|
|
3526
|
+
if (item.totalPayoutRaw != null) {
|
|
3527
|
+
return `+${formatScaledNumberTwoDecimals(item.totalPayoutRaw)} ${tokenSymbol}`;
|
|
3528
|
+
}
|
|
3529
|
+
return toTokenAmountLabel({
|
|
3530
|
+
amountRaw: (_b = firstLeg == null ? void 0 : firstLeg.payoutAmountRaw) != null ? _b : "0",
|
|
3531
|
+
tokenSymbol,
|
|
3532
|
+
chainId: firstLeg == null ? void 0 : firstLeg.chainId,
|
|
3533
|
+
sign: "+"
|
|
3534
|
+
});
|
|
3535
|
+
};
|
|
3255
3536
|
var POSITION_ROW_VENUE_ORDER = [
|
|
3256
3537
|
Venue.polymarket,
|
|
3257
3538
|
Venue.kalshi,
|
|
@@ -3278,6 +3559,10 @@ function buildVenueShareBreakdown(outcome) {
|
|
|
3278
3559
|
sharesLabel: `${twoDecimalNumberFormatter.format(row.size)} shares`
|
|
3279
3560
|
}));
|
|
3280
3561
|
}
|
|
3562
|
+
var toClaimError = (err) => {
|
|
3563
|
+
if (err instanceof Error) return err;
|
|
3564
|
+
return new Error(String(err));
|
|
3565
|
+
};
|
|
3281
3566
|
var UserProfilePage = ({
|
|
3282
3567
|
user,
|
|
3283
3568
|
balanceChainsOverride,
|
|
@@ -3335,17 +3620,22 @@ var UserProfilePage = ({
|
|
|
3335
3620
|
const balanceState = useAggBalance();
|
|
3336
3621
|
const client = useAggClient();
|
|
3337
3622
|
const labels = useLabels6();
|
|
3623
|
+
const claimNotificationLabels = labels.notifications.claim;
|
|
3624
|
+
const toastCtx = useOptionalToast();
|
|
3338
3625
|
const queryClient = useQueryClient();
|
|
3339
3626
|
const redeemMutation = useRedeem();
|
|
3340
3627
|
const [internalCancellingIds, setInternalCancellingIds] = useState6({});
|
|
3341
3628
|
const [activeRedeems, setActiveRedeems] = useState6({});
|
|
3629
|
+
const activeClaimKeysRef = useRef5(/* @__PURE__ */ new Set());
|
|
3630
|
+
const pendingClaimToastIdsRef = useRef5({});
|
|
3631
|
+
const submittedClaimToastKeysRef = useRef5(/* @__PURE__ */ new Set());
|
|
3342
3632
|
const [submittingClaimKeys, setSubmittingClaimKeys] = useState6({});
|
|
3343
|
-
const lifecycleInputs =
|
|
3633
|
+
const lifecycleInputs = useMemo4(
|
|
3344
3634
|
() => Object.values(activeRedeems),
|
|
3345
3635
|
[activeRedeems]
|
|
3346
3636
|
);
|
|
3347
3637
|
const lifecycleStates = useRedeemLifecycles(lifecycleInputs);
|
|
3348
|
-
const internalClaimingIds =
|
|
3638
|
+
const internalClaimingIds = useMemo4(() => {
|
|
3349
3639
|
const out = __spreadValues({}, submittingClaimKeys);
|
|
3350
3640
|
for (const [claimKey, active] of Object.entries(activeRedeems)) {
|
|
3351
3641
|
const state = lifecycleStates[active.redeemId];
|
|
@@ -3355,7 +3645,7 @@ var UserProfilePage = ({
|
|
|
3355
3645
|
}, [activeRedeems, lifecycleStates, submittingClaimKeys]);
|
|
3356
3646
|
const [profileUser, setProfileUser] = useState6(void 0);
|
|
3357
3647
|
const shouldUseHookData = !user;
|
|
3358
|
-
const connectedVenues =
|
|
3648
|
+
const connectedVenues = useMemo4(() => {
|
|
3359
3649
|
var _a;
|
|
3360
3650
|
if (!shouldUseHookData) return [];
|
|
3361
3651
|
const fromBalance = (_a = balanceState.connectedVenues) != null ? _a : [];
|
|
@@ -3414,17 +3704,83 @@ var UserProfilePage = ({
|
|
|
3414
3704
|
}),
|
|
3415
3705
|
[client, onCancelOrder, queryClient]
|
|
3416
3706
|
);
|
|
3707
|
+
const invalidateClaimUiState = useCallback3(() => {
|
|
3708
|
+
invalidateBalanceQueries(queryClient);
|
|
3709
|
+
invalidatePositionQueries(queryClient);
|
|
3710
|
+
queryClient.invalidateQueries({
|
|
3711
|
+
queryKey: executionKeys.claimablePositionsCount(),
|
|
3712
|
+
refetchType: "active"
|
|
3713
|
+
});
|
|
3714
|
+
invalidateUserActivityQueries(queryClient);
|
|
3715
|
+
}, [queryClient]);
|
|
3417
3716
|
const handleClaimPosition = useCallback3(
|
|
3418
3717
|
(position) => __async(null, null, function* () {
|
|
3419
3718
|
var _a, _b;
|
|
3420
|
-
|
|
3421
|
-
|
|
3719
|
+
const claimKey = (_a = position.marketId) != null ? _a : position.id;
|
|
3720
|
+
if (activeClaimKeysRef.current.has(claimKey) || (claimingPositionKeys == null ? void 0 : claimingPositionKeys[claimKey]) || internalClaimingIds[claimKey]) {
|
|
3422
3721
|
return;
|
|
3423
3722
|
}
|
|
3424
|
-
|
|
3425
|
-
if (venueMarketOutcomeIds.length === 0) return;
|
|
3426
|
-
const claimKey = (_b = position.marketId) != null ? _b : position.id;
|
|
3723
|
+
activeClaimKeysRef.current.add(claimKey);
|
|
3427
3724
|
setSubmittingClaimKeys((prev) => __spreadProps(__spreadValues({}, prev), { [claimKey]: true }));
|
|
3725
|
+
const pendingToastId = toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.pendingMessage, {
|
|
3726
|
+
title: claimNotificationLabels.pendingTitle,
|
|
3727
|
+
tone: "info"
|
|
3728
|
+
});
|
|
3729
|
+
if (pendingToastId != null) {
|
|
3730
|
+
pendingClaimToastIdsRef.current[claimKey] = pendingToastId;
|
|
3731
|
+
}
|
|
3732
|
+
if (onClaim) {
|
|
3733
|
+
try {
|
|
3734
|
+
yield onClaim(position);
|
|
3735
|
+
const pendingId = pendingClaimToastIdsRef.current[claimKey];
|
|
3736
|
+
if (pendingId != null) toastCtx == null ? void 0 : toastCtx.dismiss(pendingId);
|
|
3737
|
+
delete pendingClaimToastIdsRef.current[claimKey];
|
|
3738
|
+
toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.successMessage, {
|
|
3739
|
+
title: claimNotificationLabels.successTitle,
|
|
3740
|
+
tone: "success"
|
|
3741
|
+
});
|
|
3742
|
+
} catch (err) {
|
|
3743
|
+
const error = toClaimError(err);
|
|
3744
|
+
console.error("[UserProfilePage] redeem failed", error);
|
|
3745
|
+
const pendingId = pendingClaimToastIdsRef.current[claimKey];
|
|
3746
|
+
if (pendingId != null) toastCtx == null ? void 0 : toastCtx.dismiss(pendingId);
|
|
3747
|
+
delete pendingClaimToastIdsRef.current[claimKey];
|
|
3748
|
+
toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.failedMessage(error.message), {
|
|
3749
|
+
title: claimNotificationLabels.failedTitle,
|
|
3750
|
+
tone: "error"
|
|
3751
|
+
});
|
|
3752
|
+
onClaimSubmitError == null ? void 0 : onClaimSubmitError(claimKey, error);
|
|
3753
|
+
throw error;
|
|
3754
|
+
} finally {
|
|
3755
|
+
invalidateClaimUiState();
|
|
3756
|
+
activeClaimKeysRef.current.delete(claimKey);
|
|
3757
|
+
setSubmittingClaimKeys((prev) => {
|
|
3758
|
+
const _a2 = prev, { [claimKey]: _removed } = _a2, rest = __objRest(_a2, [__restKey(claimKey)]);
|
|
3759
|
+
return rest;
|
|
3760
|
+
});
|
|
3761
|
+
}
|
|
3762
|
+
return;
|
|
3763
|
+
}
|
|
3764
|
+
const venueMarketOutcomeIds = (_b = position.winningOutcomeIds) != null ? _b : [];
|
|
3765
|
+
if (venueMarketOutcomeIds.length === 0) {
|
|
3766
|
+
const error = new Error(claimNotificationLabels.missingOutcomeMessage);
|
|
3767
|
+
console.error("[UserProfilePage] redeem failed", error);
|
|
3768
|
+
const pendingId = pendingClaimToastIdsRef.current[claimKey];
|
|
3769
|
+
if (pendingId != null) toastCtx == null ? void 0 : toastCtx.dismiss(pendingId);
|
|
3770
|
+
delete pendingClaimToastIdsRef.current[claimKey];
|
|
3771
|
+
toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.failedMessage(error.message), {
|
|
3772
|
+
title: claimNotificationLabels.failedTitle,
|
|
3773
|
+
tone: "error"
|
|
3774
|
+
});
|
|
3775
|
+
onClaimSubmitError == null ? void 0 : onClaimSubmitError(claimKey, error);
|
|
3776
|
+
invalidateClaimUiState();
|
|
3777
|
+
activeClaimKeysRef.current.delete(claimKey);
|
|
3778
|
+
setSubmittingClaimKeys((prev) => {
|
|
3779
|
+
const _a2 = prev, { [claimKey]: _removed } = _a2, rest = __objRest(_a2, [__restKey(claimKey)]);
|
|
3780
|
+
return rest;
|
|
3781
|
+
});
|
|
3782
|
+
throw error;
|
|
3783
|
+
}
|
|
3428
3784
|
try {
|
|
3429
3785
|
const response = yield redeemMutation.mutateAsync({ venueMarketOutcomeIds });
|
|
3430
3786
|
const expectedOutcomeIds = [];
|
|
@@ -3443,6 +3799,16 @@ var UserProfilePage = ({
|
|
|
3443
3799
|
preFailedReasons[result.venueMarketOutcomeId] = result.reason;
|
|
3444
3800
|
}
|
|
3445
3801
|
}
|
|
3802
|
+
if (expectedOutcomeIds.length > 0) {
|
|
3803
|
+
const pendingId = pendingClaimToastIdsRef.current[claimKey];
|
|
3804
|
+
if (pendingId != null) toastCtx == null ? void 0 : toastCtx.dismiss(pendingId);
|
|
3805
|
+
delete pendingClaimToastIdsRef.current[claimKey];
|
|
3806
|
+
submittedClaimToastKeysRef.current.add(claimKey);
|
|
3807
|
+
toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.submittedMessage, {
|
|
3808
|
+
title: claimNotificationLabels.submittedTitle,
|
|
3809
|
+
tone: "success"
|
|
3810
|
+
});
|
|
3811
|
+
}
|
|
3446
3812
|
setActiveRedeems((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
3447
3813
|
[claimKey]: {
|
|
3448
3814
|
redeemId: response.redeemId,
|
|
@@ -3455,19 +3821,40 @@ var UserProfilePage = ({
|
|
|
3455
3821
|
}));
|
|
3456
3822
|
yield queryClient.invalidateQueries({ queryKey: ["current-user"] });
|
|
3457
3823
|
} catch (err) {
|
|
3458
|
-
|
|
3459
|
-
|
|
3824
|
+
const error = toClaimError(err);
|
|
3825
|
+
console.error("[UserProfilePage] redeem failed", error);
|
|
3826
|
+
const pendingId = pendingClaimToastIdsRef.current[claimKey];
|
|
3827
|
+
if (pendingId != null) toastCtx == null ? void 0 : toastCtx.dismiss(pendingId);
|
|
3828
|
+
delete pendingClaimToastIdsRef.current[claimKey];
|
|
3829
|
+
toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.failedMessage(error.message), {
|
|
3830
|
+
title: claimNotificationLabels.failedTitle,
|
|
3831
|
+
tone: "error"
|
|
3832
|
+
});
|
|
3833
|
+
onClaimSubmitError == null ? void 0 : onClaimSubmitError(claimKey, error);
|
|
3834
|
+
throw error;
|
|
3460
3835
|
} finally {
|
|
3836
|
+
activeClaimKeysRef.current.delete(claimKey);
|
|
3461
3837
|
setSubmittingClaimKeys((prev) => {
|
|
3462
3838
|
const _a2 = prev, { [claimKey]: _removed } = _a2, rest = __objRest(_a2, [__restKey(claimKey)]);
|
|
3463
3839
|
return rest;
|
|
3464
3840
|
});
|
|
3465
3841
|
}
|
|
3466
3842
|
}),
|
|
3467
|
-
[
|
|
3843
|
+
[
|
|
3844
|
+
claimingPositionKeys,
|
|
3845
|
+
claimNotificationLabels,
|
|
3846
|
+
invalidateClaimUiState,
|
|
3847
|
+
internalClaimingIds,
|
|
3848
|
+
onClaim,
|
|
3849
|
+
onClaimSubmitError,
|
|
3850
|
+
queryClient,
|
|
3851
|
+
redeemMutation,
|
|
3852
|
+
toastCtx
|
|
3853
|
+
]
|
|
3468
3854
|
);
|
|
3469
3855
|
const firedTerminalRef = useRef5({});
|
|
3470
3856
|
useEffect5(() => {
|
|
3857
|
+
var _a, _b;
|
|
3471
3858
|
for (const [claimKey, active] of Object.entries(activeRedeems)) {
|
|
3472
3859
|
const state = lifecycleStates[active.redeemId];
|
|
3473
3860
|
if (!state || !state.terminal) continue;
|
|
@@ -3478,17 +3865,46 @@ var UserProfilePage = ({
|
|
|
3478
3865
|
anyFailed: state.anyFailed,
|
|
3479
3866
|
errorMessage: state.errorMessage
|
|
3480
3867
|
});
|
|
3481
|
-
|
|
3482
|
-
void
|
|
3483
|
-
|
|
3484
|
-
|
|
3868
|
+
const pendingId = pendingClaimToastIdsRef.current[claimKey];
|
|
3869
|
+
if (pendingId != null) toastCtx == null ? void 0 : toastCtx.dismiss(pendingId);
|
|
3870
|
+
delete pendingClaimToastIdsRef.current[claimKey];
|
|
3871
|
+
if (state.allConfirmed) {
|
|
3872
|
+
if (!submittedClaimToastKeysRef.current.has(claimKey)) {
|
|
3873
|
+
toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.successMessage, {
|
|
3874
|
+
title: claimNotificationLabels.successTitle,
|
|
3875
|
+
tone: "success"
|
|
3876
|
+
});
|
|
3877
|
+
}
|
|
3878
|
+
} else if (state.anyFailed) {
|
|
3879
|
+
const hasConfirmedLeg = Object.values(state.legs).some((leg) => leg.status === "confirmed");
|
|
3880
|
+
if (hasConfirmedLeg) {
|
|
3881
|
+
toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.partialMessage((_a = state.errorMessage) != null ? _a : void 0), {
|
|
3882
|
+
title: claimNotificationLabels.partialTitle,
|
|
3883
|
+
tone: "warning"
|
|
3884
|
+
});
|
|
3885
|
+
} else {
|
|
3886
|
+
toastCtx == null ? void 0 : toastCtx.toast(claimNotificationLabels.failedMessage((_b = state.errorMessage) != null ? _b : void 0), {
|
|
3887
|
+
title: claimNotificationLabels.failedTitle,
|
|
3888
|
+
tone: "error"
|
|
3889
|
+
});
|
|
3890
|
+
}
|
|
3891
|
+
}
|
|
3892
|
+
submittedClaimToastKeysRef.current.delete(claimKey);
|
|
3893
|
+
invalidateClaimUiState();
|
|
3485
3894
|
delete firedTerminalRef.current[active.redeemId];
|
|
3486
3895
|
setActiveRedeems((prev) => {
|
|
3487
|
-
const
|
|
3896
|
+
const _a2 = prev, { [claimKey]: _removed } = _a2, rest = __objRest(_a2, [__restKey(claimKey)]);
|
|
3488
3897
|
return rest;
|
|
3489
3898
|
});
|
|
3490
3899
|
}
|
|
3491
|
-
}, [
|
|
3900
|
+
}, [
|
|
3901
|
+
activeRedeems,
|
|
3902
|
+
claimNotificationLabels,
|
|
3903
|
+
invalidateClaimUiState,
|
|
3904
|
+
lifecycleStates,
|
|
3905
|
+
onClaimResult,
|
|
3906
|
+
toastCtx
|
|
3907
|
+
]);
|
|
3492
3908
|
useEffect5(() => {
|
|
3493
3909
|
if (!shouldUseHookData || !isAuthenticated) {
|
|
3494
3910
|
setProfileUser(void 0);
|
|
@@ -3508,7 +3924,7 @@ var UserProfilePage = ({
|
|
|
3508
3924
|
isActive = false;
|
|
3509
3925
|
};
|
|
3510
3926
|
}, [client, currentUser, isAuthenticated, shouldUseHookData]);
|
|
3511
|
-
const resolvedUser =
|
|
3927
|
+
const resolvedUser = useMemo4(() => {
|
|
3512
3928
|
var _a, _b, _c, _d, _e, _f;
|
|
3513
3929
|
if (user) return user;
|
|
3514
3930
|
const fullUser = profileUser != null ? profileUser : currentUser;
|
|
@@ -3542,7 +3958,7 @@ var UserProfilePage = ({
|
|
|
3542
3958
|
socialHandle: normalizedTwitterHandle != null ? normalizedTwitterHandle : void 0
|
|
3543
3959
|
};
|
|
3544
3960
|
}, [connectedVenues, currentUser, profileUser, user]);
|
|
3545
|
-
const _resolvedVenueBalances =
|
|
3961
|
+
const _resolvedVenueBalances = useMemo4(() => {
|
|
3546
3962
|
if (_venueBalances) return _venueBalances;
|
|
3547
3963
|
return balanceState.balanceBreakdown.map((item) => ({
|
|
3548
3964
|
chain: item.label,
|
|
@@ -3550,7 +3966,7 @@ var UserProfilePage = ({
|
|
|
3550
3966
|
balanceLabel: formatUsd(item.balance)
|
|
3551
3967
|
}));
|
|
3552
3968
|
}, [_venueBalances, balanceState.balanceBreakdown]);
|
|
3553
|
-
const positionsValueLabel =
|
|
3969
|
+
const positionsValueLabel = useMemo4(() => {
|
|
3554
3970
|
var _a;
|
|
3555
3971
|
if (balance == null ? void 0 : balance.totalLabel) return balance.totalLabel;
|
|
3556
3972
|
const managed = balanceState.managedBalances;
|
|
@@ -3558,95 +3974,97 @@ var UserProfilePage = ({
|
|
|
3558
3974
|
const positionsValueTotal = positions.reduce((sum, p) => sum + (Number(p.balance) || 0), 0);
|
|
3559
3975
|
return formatUsd(positionsValueTotal);
|
|
3560
3976
|
}, [balance, balanceState]);
|
|
3561
|
-
const availableBalanceLabel =
|
|
3977
|
+
const availableBalanceLabel = useMemo4(() => {
|
|
3562
3978
|
var _a;
|
|
3563
3979
|
return formatUsd((_a = balanceState.totalBalance) != null ? _a : 0);
|
|
3564
3980
|
}, [balanceState.totalBalance]);
|
|
3565
3981
|
const isPositionsValueLoading = !(balance == null ? void 0 : balance.totalLabel) && balanceState.isLoading;
|
|
3566
3982
|
const isAvailableBalanceLoading = balanceState.isLoading;
|
|
3567
|
-
const resolvedActivities =
|
|
3983
|
+
const resolvedActivities = useMemo4(() => {
|
|
3568
3984
|
if (activities) return activities.filter(isVisibleUserProfileActivity);
|
|
3569
3985
|
const formatTime = isHydrated ? toRelativeTimeLabel : toAbsoluteTimeLabel;
|
|
3570
3986
|
const fullUser = profileUser != null ? profileUser : currentUser;
|
|
3571
3987
|
const connectedWalletAddresses = getConnectedWalletAccountAddresses(fullUser);
|
|
3572
|
-
return activityQuery.activities.filter(isVisibleActivityItem).map((item) => {
|
|
3573
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
3574
|
-
const timeLabel = formatTime(item
|
|
3988
|
+
return activityQuery.activities.filter(isVisibleActivityItem).map((item, index) => {
|
|
3989
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C;
|
|
3990
|
+
const timeLabel = formatTime(getRuntimeActivityCreatedAt(item));
|
|
3575
3991
|
if (item.type === "trade") {
|
|
3576
3992
|
const tradeItem = item;
|
|
3577
|
-
const sideLower =
|
|
3993
|
+
const sideLower = tradeItem.side.toLowerCase();
|
|
3578
3994
|
const type = sideLower === "sell" ? "Sell" : "Buy";
|
|
3579
|
-
const status = normalizeTradeStatus(
|
|
3580
|
-
const isFailed =
|
|
3581
|
-
const hasError = hasActivityError(
|
|
3995
|
+
const status = normalizeTradeStatus(tradeItem.status);
|
|
3996
|
+
const isFailed = tradeItem.status.toLowerCase() === "failed";
|
|
3997
|
+
const hasError = hasActivityError(tradeItem);
|
|
3582
3998
|
const eventId = (_b = (_a = tradeItem.venueMarket) == null ? void 0 : _a.venueEventId) != null ? _b : void 0;
|
|
3583
3999
|
const marketId = (_d = (_c = tradeItem.venueMarket) == null ? void 0 : _c.id) != null ? _d : void 0;
|
|
3584
4000
|
const marketQuestion = (_g = (_f = (_e = tradeItem.venueMarket) == null ? void 0 : _e.question) != null ? _f : tradeItem.marketQuestion) != null ? _g : "Market";
|
|
3585
4001
|
const outcomeLabel = (_l = (_k = (_j = (_h = tradeItem.venueMarketOutcome) == null ? void 0 : _h.title) != null ? _j : (_i = tradeItem.venueMarketOutcome) == null ? void 0 : _i.label) != null ? _k : tradeItem.outcomeLabel) != null ? _l : "";
|
|
3586
4002
|
return {
|
|
3587
4003
|
kind: "trade",
|
|
3588
|
-
id:
|
|
4004
|
+
id: tradeItem.id,
|
|
3589
4005
|
eventId,
|
|
3590
4006
|
marketId,
|
|
3591
4007
|
isFailed,
|
|
3592
4008
|
hasError,
|
|
3593
|
-
errorMessage: (_m =
|
|
4009
|
+
errorMessage: (_m = tradeItem.errorMessage) != null ? _m : void 0,
|
|
3594
4010
|
status,
|
|
3595
4011
|
type,
|
|
3596
4012
|
thumbnailSrc: toTradeThumbnailSrc(tradeItem, ordersQuery.orders),
|
|
3597
4013
|
title: marketQuestion,
|
|
3598
|
-
venue:
|
|
4014
|
+
venue: tradeItem.venue,
|
|
3599
4015
|
outcomeLabel,
|
|
3600
|
-
sharesLabel: isFailed ? "-" : `${formatTradeQuantityTwoDecimals(
|
|
4016
|
+
sharesLabel: isFailed ? "-" : `${formatTradeQuantityTwoDecimals(tradeItem.executionPrice, tradeItem.filledAmountRaw)} shares`,
|
|
3601
4017
|
amountLabel: isFailed ? "-" : toSignedAmountLabel(
|
|
3602
4018
|
sideLower === "sell" ? "+" : "-",
|
|
3603
|
-
|
|
3604
|
-
|
|
4019
|
+
tradeItem.executionPrice,
|
|
4020
|
+
tradeItem.filledAmountRaw
|
|
3605
4021
|
),
|
|
3606
4022
|
timeLabel
|
|
3607
4023
|
};
|
|
3608
4024
|
}
|
|
3609
4025
|
if (item.type === "withdrawal") {
|
|
3610
|
-
const
|
|
3611
|
-
const
|
|
4026
|
+
const withdrawalItem = item;
|
|
4027
|
+
const normalizedStatus = normalizeWithdrawalStatus(withdrawalItem.status);
|
|
4028
|
+
const timedOut = normalizedStatus === "pending" && isPendingTransferTimedOut(withdrawalItem.createdAt);
|
|
3612
4029
|
const status = timedOut ? "failed" : normalizedStatus;
|
|
3613
|
-
const errorMessage = timedOut ? PENDING_TRANSFER_TIMEOUT_ERROR_MESSAGE : (_n =
|
|
4030
|
+
const errorMessage = timedOut ? PENDING_TRANSFER_TIMEOUT_ERROR_MESSAGE : (_n = withdrawalItem.errorMessage) != null ? _n : void 0;
|
|
3614
4031
|
const isFailed = status === "failed";
|
|
3615
|
-
const hasError = timedOut || hasActivityError(
|
|
4032
|
+
const hasError = timedOut || hasActivityError(withdrawalItem);
|
|
3616
4033
|
const titleByStatus = labels.userProfile.activity.withdrawalStatusTitles;
|
|
3617
|
-
const settledWithdrawalAmountRaw = status === "completed" ? (_o =
|
|
4034
|
+
const settledWithdrawalAmountRaw = status === "completed" ? (_o = withdrawalItem.completedAmountRaw) != null ? _o : withdrawalItem.amountRaw : withdrawalItem.amountRaw;
|
|
3618
4035
|
const amountLabel = status === "failed" || status === "canceled" ? ZERO_AMOUNT_LABEL : toTokenAmountLabel({
|
|
3619
4036
|
amountRaw: settledWithdrawalAmountRaw,
|
|
3620
|
-
chainId:
|
|
3621
|
-
tokenSymbol:
|
|
4037
|
+
chainId: withdrawalItem.destinationChainId,
|
|
4038
|
+
tokenSymbol: withdrawalItem.tokenSymbol,
|
|
3622
4039
|
sign: "-"
|
|
3623
4040
|
});
|
|
3624
4041
|
return {
|
|
3625
4042
|
kind: "withdrawal",
|
|
3626
|
-
id:
|
|
4043
|
+
id: withdrawalItem.id,
|
|
3627
4044
|
isFailed,
|
|
3628
4045
|
hasError,
|
|
3629
4046
|
errorMessage,
|
|
3630
4047
|
status,
|
|
3631
4048
|
type: labels.userProfile.activity.withdrawalType,
|
|
3632
4049
|
title: titleByStatus[status],
|
|
3633
|
-
subtitleLabel: `to ${(_p = shortenAddress(
|
|
4050
|
+
subtitleLabel: `to ${(_p = shortenAddress(withdrawalItem.destinationAddress)) != null ? _p : withdrawalItem.destinationAddress} \xB7 ${formatChainIdLabel(withdrawalItem.destinationChainId)}`,
|
|
3634
4051
|
amountLabel,
|
|
3635
4052
|
timeLabel
|
|
3636
4053
|
};
|
|
3637
4054
|
}
|
|
3638
4055
|
if (item.type === "deposit") {
|
|
3639
|
-
const
|
|
3640
|
-
const
|
|
4056
|
+
const depositItem = item;
|
|
4057
|
+
const normalizedStatus = normalizeDepositStatus(depositItem.status);
|
|
4058
|
+
const timedOut = normalizedStatus === "pending" && isPendingTransferTimedOut(depositItem.createdAt);
|
|
3641
4059
|
const status = timedOut ? "failed" : normalizedStatus;
|
|
3642
|
-
const errorMessage = timedOut ? PENDING_TRANSFER_TIMEOUT_ERROR_MESSAGE : (_q = getActivityErrorMessage(
|
|
4060
|
+
const errorMessage = timedOut ? PENDING_TRANSFER_TIMEOUT_ERROR_MESSAGE : (_q = getActivityErrorMessage(depositItem)) != null ? _q : void 0;
|
|
3643
4061
|
const isFailed = status === "failed";
|
|
3644
|
-
const hasError = timedOut || hasActivityError(
|
|
4062
|
+
const hasError = timedOut || hasActivityError(depositItem);
|
|
3645
4063
|
const depositSource = resolveDepositActivitySource({
|
|
3646
|
-
fromAddress:
|
|
3647
|
-
chainId:
|
|
4064
|
+
fromAddress: depositItem.fromAddress,
|
|
4065
|
+
chainId: depositItem.chainId,
|
|
3648
4066
|
connectedWalletAddresses,
|
|
3649
|
-
depositAddress: depositAddressesQuery.getAddress(toNumericChainId(
|
|
4067
|
+
depositAddress: depositAddressesQuery.getAddress(toNumericChainId(depositItem.chainId))
|
|
3650
4068
|
});
|
|
3651
4069
|
const depositTitlesBySource = {
|
|
3652
4070
|
wallet: labels.userProfile.activity.depositStatusTitles.connectedWallet,
|
|
@@ -3654,29 +4072,64 @@ var UserProfilePage = ({
|
|
|
3654
4072
|
card: labels.userProfile.activity.depositStatusTitles.card
|
|
3655
4073
|
};
|
|
3656
4074
|
const amountLabel = status === "failed" || status === "canceled" ? ZERO_AMOUNT_LABEL : toTokenAmountLabel({
|
|
3657
|
-
amountRaw:
|
|
3658
|
-
chainId:
|
|
3659
|
-
tokenSymbol:
|
|
4075
|
+
amountRaw: depositItem.amountRaw,
|
|
4076
|
+
chainId: depositItem.chainId,
|
|
4077
|
+
tokenSymbol: depositItem.tokenSymbol,
|
|
3660
4078
|
sign: "+"
|
|
3661
4079
|
});
|
|
3662
4080
|
return {
|
|
3663
4081
|
kind: "deposit",
|
|
3664
|
-
id:
|
|
4082
|
+
id: depositItem.id,
|
|
3665
4083
|
isFailed,
|
|
3666
4084
|
hasError,
|
|
3667
4085
|
errorMessage,
|
|
3668
4086
|
status,
|
|
3669
4087
|
type: labels.userProfile.activity.depositType,
|
|
3670
4088
|
title: depositTitlesBySource[depositSource][status],
|
|
3671
|
-
subtitleLabel: `from ${(_r = shortenAddress(
|
|
4089
|
+
subtitleLabel: `from ${(_r = shortenAddress(depositItem.fromAddress)) != null ? _r : depositItem.fromAddress} \xB7 ${formatChainIdLabel(depositItem.chainId)}`,
|
|
3672
4090
|
amountLabel,
|
|
3673
4091
|
timeLabel,
|
|
3674
4092
|
depositSource,
|
|
3675
|
-
chainId:
|
|
4093
|
+
chainId: depositItem.chainId
|
|
3676
4094
|
};
|
|
3677
4095
|
}
|
|
3678
|
-
|
|
3679
|
-
|
|
4096
|
+
if (item.type === "redeem") {
|
|
4097
|
+
const redeemItem = item;
|
|
4098
|
+
const redeemLegs = Array.isArray(redeemItem.legs) ? redeemItem.legs : [];
|
|
4099
|
+
const firstLeg = redeemLegs[0];
|
|
4100
|
+
const status = getDerivedRedeemStatus(redeemItem);
|
|
4101
|
+
const firstLegErrorMessage = (_t = (_s = redeemLegs.find((leg) => typeof leg.errorMessage === "string" && leg.errorMessage)) == null ? void 0 : _s.errorMessage) != null ? _t : void 0;
|
|
4102
|
+
const errorMessage = (_u = getActivityErrorMessage(redeemItem)) != null ? _u : firstLegErrorMessage;
|
|
4103
|
+
const isFailed = status === "failed";
|
|
4104
|
+
const hasError = isFailed || !!(errorMessage == null ? void 0 : errorMessage.trim());
|
|
4105
|
+
const titleByStatus = labels.userProfile.activity.redeemStatusTitles;
|
|
4106
|
+
return {
|
|
4107
|
+
kind: "redeem",
|
|
4108
|
+
id: redeemItem.id,
|
|
4109
|
+
isFailed,
|
|
4110
|
+
hasError,
|
|
4111
|
+
errorMessage: errorMessage != null ? errorMessage : void 0,
|
|
4112
|
+
status,
|
|
4113
|
+
type: labels.userProfile.activity.redeemType,
|
|
4114
|
+
title: titleByStatus[status],
|
|
4115
|
+
thumbnailSrc: (_w = (_v = firstLeg == null ? void 0 : firstLeg.venueMarket) == null ? void 0 : _v.image) != null ? _w : fallbackThumbnailSrc,
|
|
4116
|
+
marketTitle: (_y = (_x = firstLeg == null ? void 0 : firstLeg.venueMarket) == null ? void 0 : _x.question) != null ? _y : "Market",
|
|
4117
|
+
outcomeLabel: (_C = (_B = (_z = firstLeg == null ? void 0 : firstLeg.venueMarketOutcome) == null ? void 0 : _z.title) != null ? _B : (_A = firstLeg == null ? void 0 : firstLeg.venueMarketOutcome) == null ? void 0 : _A.label) != null ? _C : "",
|
|
4118
|
+
amountLabel: status === "failed" || status === "canceled" ? ZERO_AMOUNT_LABEL : toRedeemPayoutAmountLabel(redeemItem),
|
|
4119
|
+
timeLabel
|
|
4120
|
+
};
|
|
4121
|
+
}
|
|
4122
|
+
logUnknownActivityType(item);
|
|
4123
|
+
return {
|
|
4124
|
+
kind: "unknown",
|
|
4125
|
+
id: getRuntimeActivityId(item, index),
|
|
4126
|
+
status: "completed",
|
|
4127
|
+
type: "Activity",
|
|
4128
|
+
title: "Unsupported activity",
|
|
4129
|
+
subtitleLabel: getRuntimeActivityType(item),
|
|
4130
|
+
amountLabel: ZERO_AMOUNT_LABEL,
|
|
4131
|
+
timeLabel
|
|
4132
|
+
};
|
|
3680
4133
|
});
|
|
3681
4134
|
}, [
|
|
3682
4135
|
activities,
|
|
@@ -3688,7 +4141,7 @@ var UserProfilePage = ({
|
|
|
3688
4141
|
ordersQuery.orders,
|
|
3689
4142
|
profileUser
|
|
3690
4143
|
]);
|
|
3691
|
-
const resolvedOpenOrders =
|
|
4144
|
+
const resolvedOpenOrders = useMemo4(() => {
|
|
3692
4145
|
if (openOrders) return openOrders;
|
|
3693
4146
|
return ordersQuery.orders.filter((order) => isOpenOrderStatus(order.status)).map((order) => {
|
|
3694
4147
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
@@ -3775,76 +4228,14 @@ var UserProfilePage = ({
|
|
|
3775
4228
|
},
|
|
3776
4229
|
[]
|
|
3777
4230
|
);
|
|
3778
|
-
const resolvedActivePositions =
|
|
3779
|
-
const
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
if (position.winner === true) {
|
|
3787
|
-
return position.closedClaimStatus === "redeemed" ? "closed" : "active";
|
|
3788
|
-
}
|
|
3789
|
-
if (position.winner === false) return "closed";
|
|
3790
|
-
if (position.marketStatus === "closed" || position.marketStatus === "resolved") {
|
|
3791
|
-
return "closed";
|
|
3792
|
-
}
|
|
3793
|
-
return "active";
|
|
3794
|
-
};
|
|
3795
|
-
const sourcePositions = activePositions || closedPositions ? [...activePositions != null ? activePositions : [], ...closedPositions != null ? closedPositions : []] : [
|
|
3796
|
-
...adaptPositionGroups(activePositionsQuery.positions),
|
|
3797
|
-
...adaptPositionGroups(closedPositionsQuery.positions)
|
|
3798
|
-
];
|
|
3799
|
-
const deduped = /* @__PURE__ */ new Map();
|
|
3800
|
-
for (const position of sourcePositions) {
|
|
3801
|
-
deduped.set(position.id, position);
|
|
3802
|
-
}
|
|
3803
|
-
return Array.from(deduped.values()).filter(
|
|
3804
|
-
(position) => shouldIncludeByShares(position) && classifyPosition(position) === "active"
|
|
3805
|
-
);
|
|
3806
|
-
}, [
|
|
3807
|
-
activePositions,
|
|
3808
|
-
activePositionsQuery.positions,
|
|
3809
|
-
adaptPositionGroups,
|
|
3810
|
-
closedPositions,
|
|
3811
|
-
closedPositionsQuery.positions
|
|
3812
|
-
]);
|
|
3813
|
-
const resolvedClosedPositions = useMemo3(() => {
|
|
3814
|
-
const shouldIncludeByShares = (position) => {
|
|
3815
|
-
if (SHOW_SOLD_POSITIONS) return true;
|
|
3816
|
-
if (typeof position.totalShares !== "number") return true;
|
|
3817
|
-
return position.totalShares >= SOLD_POSITION_SHARES_THRESHOLD;
|
|
3818
|
-
};
|
|
3819
|
-
const classifyPosition = (position) => {
|
|
3820
|
-
if (position.marketStatus === "open") return "active";
|
|
3821
|
-
if (position.winner === true) {
|
|
3822
|
-
return position.closedClaimStatus === "redeemed" ? "closed" : "active";
|
|
3823
|
-
}
|
|
3824
|
-
if (position.winner === false) return "closed";
|
|
3825
|
-
if (position.marketStatus === "closed" || position.marketStatus === "resolved") {
|
|
3826
|
-
return "closed";
|
|
3827
|
-
}
|
|
3828
|
-
return "active";
|
|
3829
|
-
};
|
|
3830
|
-
const sourcePositions = activePositions || closedPositions ? [...activePositions != null ? activePositions : [], ...closedPositions != null ? closedPositions : []] : [
|
|
3831
|
-
...adaptPositionGroups(activePositionsQuery.positions),
|
|
3832
|
-
...adaptPositionGroups(closedPositionsQuery.positions)
|
|
3833
|
-
];
|
|
3834
|
-
const deduped = /* @__PURE__ */ new Map();
|
|
3835
|
-
for (const position of sourcePositions) {
|
|
3836
|
-
deduped.set(position.id, position);
|
|
3837
|
-
}
|
|
3838
|
-
return Array.from(deduped.values()).filter(
|
|
3839
|
-
(position) => shouldIncludeByShares(position) && classifyPosition(position) === "closed"
|
|
3840
|
-
);
|
|
3841
|
-
}, [
|
|
3842
|
-
activePositions,
|
|
3843
|
-
activePositionsQuery.positions,
|
|
3844
|
-
adaptPositionGroups,
|
|
3845
|
-
closedPositions,
|
|
3846
|
-
closedPositionsQuery.positions
|
|
3847
|
-
]);
|
|
4231
|
+
const resolvedActivePositions = useMemo4(() => {
|
|
4232
|
+
const source = activePositions != null ? activePositions : adaptPositionGroups(activePositionsQuery.positions);
|
|
4233
|
+
return source.filter(shouldIncludeByShares);
|
|
4234
|
+
}, [activePositions, activePositionsQuery.positions, adaptPositionGroups]);
|
|
4235
|
+
const resolvedClosedPositions = useMemo4(() => {
|
|
4236
|
+
const source = closedPositions != null ? closedPositions : adaptPositionGroups(closedPositionsQuery.positions);
|
|
4237
|
+
return source.filter(shouldIncludeByShares);
|
|
4238
|
+
}, [closedPositions, closedPositionsQuery.positions, adaptPositionGroups]);
|
|
3848
4239
|
return /* @__PURE__ */ jsx11(AggErrorBoundary, { onError, children: /* @__PURE__ */ jsx11(
|
|
3849
4240
|
"section",
|
|
3850
4241
|
{
|