@akita-protocol/algomd-rn 0.0.0-stage → 1.0.0-alpha.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.
Files changed (137) hide show
  1. package/README.md +137 -2
  2. package/package.json +118 -3
  3. package/src/adapters/index.ts +4 -0
  4. package/src/adapters/txn-graph.ts +138 -0
  5. package/src/components/ASA.tsx +38 -0
  6. package/src/components/ASASearch.tsx +79 -0
  7. package/src/components/Account.tsx +42 -0
  8. package/src/components/AccountSearch.tsx +75 -0
  9. package/src/components/AuctionListing.tsx +40 -0
  10. package/src/components/Collection.tsx +42 -0
  11. package/src/components/DualStakePool.tsx +244 -0
  12. package/src/components/NFDProfile.tsx +45 -0
  13. package/src/components/NFDSearch.tsx +81 -0
  14. package/src/components/NFTListing.tsx +73 -0
  15. package/src/components/NFTSearch.tsx +68 -0
  16. package/src/components/Poll.tsx +39 -0
  17. package/src/components/PollSearch.tsx +79 -0
  18. package/src/components/PrizeBoxBundle.tsx +1 -0
  19. package/src/components/RaffleListing.tsx +40 -0
  20. package/src/components/SelfFetching.tsx +1048 -0
  21. package/src/components/StakingPool.tsx +134 -0
  22. package/src/components/TradeOffer.tsx +47 -0
  23. package/src/components/TradeSearch.tsx +103 -0
  24. package/src/components/TransactionDetails.tsx +37 -0
  25. package/src/components/TransactionSearch.tsx +102 -0
  26. package/src/components/TransactionsGraph.tsx +60 -0
  27. package/src/components/index.ts +41 -0
  28. package/src/fonts/OFL.txt +93 -0
  29. package/src/fonts/SpaceGrotesk_300Light.ttf +0 -0
  30. package/src/fonts/SpaceGrotesk_400Regular.ttf +0 -0
  31. package/src/fonts/SpaceGrotesk_500Medium.ttf +0 -0
  32. package/src/fonts/SpaceGrotesk_600SemiBold.ttf +0 -0
  33. package/src/fonts/SpaceGrotesk_700Bold.ttf +0 -0
  34. package/src/fonts/app.css +5 -0
  35. package/src/graph.ts +3 -0
  36. package/src/hooks/index.ts +17 -0
  37. package/src/hooks/useAlgomdData.ts +1539 -0
  38. package/src/hooks/useAlgorandClient.ts +54 -0
  39. package/src/index.ts +147 -0
  40. package/src/presentation/ASADisplay.tsx +380 -0
  41. package/src/presentation/AccountDisplay.tsx +132 -0
  42. package/src/presentation/AccountMentionInline.tsx +38 -0
  43. package/src/presentation/AccountMentionText.tsx +80 -0
  44. package/src/presentation/AdaptiveImage.tsx +314 -0
  45. package/src/presentation/AssetMention.tsx +87 -0
  46. package/src/presentation/AuctionListingDisplay.tsx +428 -0
  47. package/src/presentation/BundleContents.tsx +228 -0
  48. package/src/presentation/CardContainer.tsx +61 -0
  49. package/src/presentation/CardEntrance.tsx +21 -0
  50. package/src/presentation/CollectionDisplay.tsx +168 -0
  51. package/src/presentation/ContractMenu.tsx +243 -0
  52. package/src/presentation/DualStakePoolDisplay.tsx +335 -0
  53. package/src/presentation/Embeds.tsx +300 -0
  54. package/src/presentation/GateRequirements.tsx +334 -0
  55. package/src/presentation/HEROICONS-LICENSE.txt +21 -0
  56. package/src/presentation/NFDProfileDisplay.tsx +194 -0
  57. package/src/presentation/NFTListingDisplay.tsx +284 -0
  58. package/src/presentation/OnChainActionCard.tsx +557 -0
  59. package/src/presentation/PollDisplay.tsx +222 -0
  60. package/src/presentation/PrizeBoxBundleDisplay.tsx +103 -0
  61. package/src/presentation/PrizeBoxMedia.tsx +46 -0
  62. package/src/presentation/PrizePreview.tsx +296 -0
  63. package/src/presentation/ProgressBar.tsx +50 -0
  64. package/src/presentation/RaffleListingDisplay.tsx +399 -0
  65. package/src/presentation/References.tsx +310 -0
  66. package/src/presentation/ReservedNotice.tsx +73 -0
  67. package/src/presentation/ResultsPanel.tsx +241 -0
  68. package/src/presentation/Sparkline.tsx +70 -0
  69. package/src/presentation/SquishyPressable.tsx +145 -0
  70. package/src/presentation/StakingPoolDisplay.tsx +419 -0
  71. package/src/presentation/StatusBadge.tsx +56 -0
  72. package/src/presentation/TradeOfferDisplay.tsx +275 -0
  73. package/src/presentation/TransactionDisplay.tsx +262 -0
  74. package/src/presentation/WinnerBadge.tsx +58 -0
  75. package/src/presentation/assetHelpers.ts +36 -0
  76. package/src/presentation/assets.ts +7 -0
  77. package/src/presentation/explorer.ts +95 -0
  78. package/src/presentation/format.ts +90 -0
  79. package/src/presentation/gates.ts +100 -0
  80. package/src/presentation/icons.tsx +1178 -0
  81. package/src/presentation/identity.tsx +175 -0
  82. package/src/presentation/index.ts +88 -0
  83. package/src/presentation/media.ts +70 -0
  84. package/src/presentation/pluginColors.ts +8 -0
  85. package/src/presentation/runtime.tsx +268 -0
  86. package/src/presentation/sheets.tsx +7 -0
  87. package/src/presentation/subject.tsx +31 -0
  88. package/src/presentation/textTheme.ts +17 -0
  89. package/src/presentation/themes.json +158 -0
  90. package/src/presentation/variants.ts +14 -0
  91. package/src/provider/AlgomdProvider.tsx +45 -0
  92. package/src/provider/context.ts +18 -0
  93. package/src/provider/imageResolver.ts +12 -0
  94. package/src/provider/index.ts +5 -0
  95. package/src/provider/networks.ts +23 -0
  96. package/src/provider/types.ts +29 -0
  97. package/src/refs/AccountRef.tsx +226 -0
  98. package/src/refs/ApplicationRef.tsx +72 -0
  99. package/src/refs/AssetRef.tsx +142 -0
  100. package/src/refs/AuctionRef.tsx +108 -0
  101. package/src/refs/CollectionRef.tsx +70 -0
  102. package/src/refs/DualStakeRef.tsx +88 -0
  103. package/src/refs/HostRefs.tsx +82 -0
  104. package/src/refs/ListingRef.tsx +90 -0
  105. package/src/refs/NfdRef.tsx +96 -0
  106. package/src/refs/PollRef.tsx +120 -0
  107. package/src/refs/RaffleRef.tsx +101 -0
  108. package/src/refs/RewardRef.tsx +78 -0
  109. package/src/refs/StakingPoolRef.tsx +136 -0
  110. package/src/refs/SubscriptionRef.tsx +200 -0
  111. package/src/refs/TradeRef.tsx +100 -0
  112. package/src/refs/TransactionRef.tsx +156 -0
  113. package/src/refs/assetInfo.ts +49 -0
  114. package/src/refs/contractParts.tsx +159 -0
  115. package/src/refs/index.tsx +137 -0
  116. package/src/refs/primitives.tsx +588 -0
  117. package/src/refs/types.ts +13 -0
  118. package/src/types/algorand.ts +496 -0
  119. package/src/types/index.ts +1 -0
  120. package/src/ui/CopyButton.tsx +44 -0
  121. package/src/ui/DataStates.tsx +45 -0
  122. package/src/ui/ProgressBar.tsx +64 -0
  123. package/src/ui/SearchSheet.tsx +141 -0
  124. package/src/ui/SizeContainer.tsx +25 -0
  125. package/src/ui/StatusBadge.tsx +51 -0
  126. package/src/ui/index.ts +6 -0
  127. package/src/utils/algomdImageUrl.ts +20 -0
  128. package/src/utils/arc19.ts +120 -0
  129. package/src/utils/arc62.ts +246 -0
  130. package/src/utils/capacity.ts +26 -0
  131. package/src/utils/format.ts +181 -0
  132. package/src/utils/ids.ts +31 -0
  133. package/src/utils/index.ts +6 -0
  134. package/src/utils/nfdDisplay.ts +45 -0
  135. package/src/utils/search.ts +87 -0
  136. package/src/utils/stakingPool.ts +174 -0
  137. package/src/utils/stakingSnapshot.ts +132 -0
@@ -0,0 +1,145 @@
1
+ // Shared AlgoMD presentation. Edit this library source.
2
+ import React from "react";
3
+ import {
4
+ Pressable,
5
+ PressableProps,
6
+ StyleProp,
7
+ ViewStyle,
8
+ GestureResponderEvent,
9
+ StyleSheet,
10
+ } from "react-native";
11
+ import Animated, {
12
+ useAnimatedStyle,
13
+ useSharedValue,
14
+ withSpring,
15
+ withTiming,
16
+ WithSpringConfig,
17
+ WithTimingConfig,
18
+ AnimatedProps,
19
+ } from "react-native-reanimated";
20
+
21
+ type ViewStyleTransform = NonNullable<ViewStyle["transform"]>;
22
+ type TransformEntry =
23
+ ViewStyleTransform extends ReadonlyArray<infer Item> ? Item : never;
24
+
25
+ export interface SquishyPressableProps extends PressableProps {
26
+ /** Tailwind classes (nativewind) applied to the animated container */
27
+ className?: string;
28
+ /** container class names */
29
+ containerClassName?: string;
30
+ /** Style applied to the animated container (wrapping the Pressable) */
31
+ containerStyle?: StyleProp<ViewStyle>;
32
+ /** ScaleX value when pressed. Defaults to 0.9 */
33
+ pressedScale?: number;
34
+ /** Animation type for press feedback. Defaults to "spring" */
35
+ animation?: "spring" | "timing";
36
+ /** Timing animation configuration */
37
+ timingConfig?: WithTimingConfig;
38
+ /** Spring animation configuration */
39
+ springConfig?: WithSpringConfig;
40
+ /** Layout animation for smooth size transitions */
41
+ layout?: AnimatedProps<ViewStyle>["layout"];
42
+ }
43
+
44
+ export function SquishyPressable(props: SquishyPressableProps) {
45
+ const {
46
+ children,
47
+ className,
48
+ containerClassName,
49
+ containerStyle,
50
+ pressedScale = 0.9,
51
+ animation = "spring",
52
+ timingConfig,
53
+ springConfig,
54
+ layout,
55
+ onPressIn,
56
+ onPressOut,
57
+ disabled,
58
+ ...rest
59
+ } = props;
60
+
61
+ const scale = useSharedValue(1);
62
+
63
+ const flattenedContainerStyle = React.useMemo(() => {
64
+ const flattened = StyleSheet.flatten(containerStyle);
65
+ return flattened ? (flattened as ViewStyle) : undefined;
66
+ }, [containerStyle]);
67
+
68
+ const baseTransforms = React.useMemo<TransformEntry[]>(() => {
69
+ const transform = flattenedContainerStyle?.transform;
70
+
71
+ if (!transform) {
72
+ return [];
73
+ }
74
+
75
+ const list = Array.isArray(transform) ? transform : [transform];
76
+
77
+ return list.map((entry) => ({ ...entry })) as TransformEntry[];
78
+ }, [flattenedContainerStyle]);
79
+
80
+ const containerTransforms = useSharedValue<TransformEntry[]>(baseTransforms);
81
+
82
+ React.useEffect(() => {
83
+ containerTransforms.value = baseTransforms;
84
+ }, [baseTransforms, containerTransforms]);
85
+
86
+ const containerStyleWithoutTransform = React.useMemo(() => {
87
+ if (!flattenedContainerStyle) {
88
+ return undefined;
89
+ }
90
+
91
+ const { transform: _ignoredTransform, ...rest } = flattenedContainerStyle;
92
+
93
+ return Object.keys(rest).length ? (rest as ViewStyle) : undefined;
94
+ }, [flattenedContainerStyle]);
95
+
96
+ const animatedStyle = useAnimatedStyle(() => {
97
+ const transforms = containerTransforms.value.length
98
+ ? [...containerTransforms.value, { scale: scale.value }]
99
+ : [{ scale: scale.value }];
100
+
101
+ return {
102
+ transform: transforms as ViewStyleTransform,
103
+ };
104
+ });
105
+
106
+ function animateTo(value: number) {
107
+ scale.value =
108
+ animation === "timing"
109
+ ? withTiming(value, timingConfig)
110
+ : withSpring(value, springConfig);
111
+ }
112
+
113
+ function handlePressIn(event: GestureResponderEvent) {
114
+ if (!disabled) animateTo(pressedScale);
115
+ onPressIn?.(event);
116
+ }
117
+
118
+ function handlePressOut(event: GestureResponderEvent) {
119
+ animateTo(1);
120
+ onPressOut?.(event);
121
+ }
122
+
123
+ return (
124
+ <Animated.View
125
+ className={containerClassName}
126
+ style={[containerStyleWithoutTransform, animatedStyle]}
127
+ layout={layout}
128
+ >
129
+ <Pressable
130
+ accessibilityRole="button"
131
+ className={className}
132
+ disabled={disabled}
133
+ onPressIn={handlePressIn}
134
+ onPressOut={handlePressOut}
135
+ {...rest}
136
+ >
137
+ {(state) =>
138
+ typeof children === "function" ? (children as any)(state) : children
139
+ }
140
+ </Pressable>
141
+ </Animated.View>
142
+ );
143
+ }
144
+
145
+ export default SquishyPressable;
@@ -0,0 +1,419 @@
1
+ // Shared AlgoMD presentation, migrated from akita-rn. Edit this library source.
2
+ import React, { useEffect, useState } from "react";
3
+ import { Image, Pressable, StyleSheet, View } from "react-native";
4
+ import {
5
+ OutlineArrowPathIcon as ArrowPathIcon,
6
+ StakingPoolIcon,
7
+ } from "./icons";
8
+ import { formatShortDistance, isShortDistanceDate } from "./format";
9
+ import { PLUGIN_COLORS } from "./pluginColors";
10
+ import { useIsAssetSubject } from "./subject";
11
+
12
+ import { Text } from "./runtime";
13
+ import { useAppTheme } from "./runtime";
14
+
15
+ import { ContractMenu } from "./ContractMenu";
16
+ import { formatAtomicAmount } from "./format";
17
+ import {
18
+ OnChainActionCard,
19
+ OnChainActionHeader,
20
+ OnChainMetric,
21
+ OnChainMetricGrid,
22
+ } from "./OnChainActionCard";
23
+ import { AdaptiveImage } from "./AdaptiveImage";
24
+
25
+ export type StakingPoolStatus =
26
+ | "draft"
27
+ | "upcoming"
28
+ | "signups"
29
+ | "active"
30
+ | "ended"
31
+ | "final"
32
+ | "unknown";
33
+
34
+ export interface StakingPoolRewardDisplayData {
35
+ assetId?: string;
36
+ name?: string;
37
+ unitName?: string;
38
+ decimals?: number;
39
+ amountRaw?: string;
40
+ rateRaw?: string;
41
+ distribution?: "percentage" | "flat" | "even" | "shuffle" | string;
42
+ intervalSecondsRaw?: string;
43
+ expirationSecondsRaw?: string;
44
+ winnerCountRaw?: string;
45
+ /** Reward asset still reserved for this reward, in base units. */
46
+ budgetRaw?: string;
47
+ /** Reward asset art; when present it becomes the card's header. */
48
+ imageUrl?: string;
49
+ }
50
+
51
+ export interface StakingPoolDisplayData {
52
+ id: string;
53
+ title: string;
54
+ status: StakingPoolStatus;
55
+ poolType?: string;
56
+ creator?: string;
57
+ signupTime?: Date;
58
+ startTime?: Date;
59
+ endTime?: Date;
60
+ allowLateSignups?: boolean;
61
+ maxEntries?: number;
62
+ entryCount?: number;
63
+ totalStaked?: string;
64
+ minimumStakeAmount?: string;
65
+ /** The staked asset's decimals; set only when the pool takes a single, known asset. */
66
+ stakeDecimals?: number;
67
+ stakeUnitName?: string;
68
+ /** The name of the asset list the pool takes stakes from. */
69
+ stakeListName?: string;
70
+ gateId?: number;
71
+ unrestricted?: boolean;
72
+ finalized?: boolean;
73
+ rewardCount?: number;
74
+ primaryReward?: StakingPoolRewardDisplayData;
75
+ }
76
+
77
+ export interface StakingPoolDisplayProps {
78
+ data: StakingPoolDisplayData;
79
+ notice?: string;
80
+ onRetry?: () => void;
81
+ action?: React.ReactNode;
82
+ }
83
+
84
+ /** Re-renders every 30s while the schedule can still change. */
85
+ function useNow(live: boolean): number {
86
+ const [now, setNow] = useState(() => Date.now());
87
+ useEffect(() => {
88
+ if (!live) return;
89
+ const id = setInterval(() => setNow(Date.now()), 30_000);
90
+ return () => clearInterval(id);
91
+ }, [live]);
92
+ return now;
93
+ }
94
+
95
+ function formatStakeAmount(
96
+ value: string | undefined,
97
+ decimals?: number,
98
+ ): string {
99
+ if (!value || !/^\d+$/.test(value)) return "Not set";
100
+ return formatAtomicAmount(value, decimals ?? 0) ?? "Not set";
101
+ }
102
+
103
+ function poolTypeLabel(value?: string): string {
104
+ switch (value?.toLowerCase()) {
105
+ case "heartbeat":
106
+ return "Heartbeat";
107
+ case "soft":
108
+ return "Soft stake";
109
+ case "hard":
110
+ return "Hard stake";
111
+ case "lock":
112
+ case "locked":
113
+ return "Locked stake";
114
+ case "none":
115
+ return "No stake";
116
+ default:
117
+ return value || "Staking";
118
+ }
119
+ }
120
+
121
+ function formatDurationSeconds(value?: string): string | undefined {
122
+ if (!value || !/^\d+$/.test(value)) return undefined;
123
+ const seconds = BigInt(value);
124
+ const week = 7n * 24n * 60n * 60n;
125
+ const day = 24n * 60n * 60n;
126
+ const hour = 60n * 60n;
127
+ if (seconds > 0n && seconds % week === 0n) {
128
+ const count = seconds / week;
129
+ return `${count} ${count === 1n ? "week" : "weeks"}`;
130
+ }
131
+ if (seconds > 0n && seconds % day === 0n) {
132
+ const count = seconds / day;
133
+ return `${count} ${count === 1n ? "day" : "days"}`;
134
+ }
135
+ if (seconds > 0n && seconds % hour === 0n) {
136
+ const count = seconds / hour;
137
+ return `${count} ${count === 1n ? "hour" : "hours"}`;
138
+ }
139
+ return `${seconds.toLocaleString()} sec`;
140
+ }
141
+
142
+ /** How the reward is split, in a few words. */
143
+ function rewardSplitLabel(reward: StakingPoolRewardDisplayData): string {
144
+ switch (reward.distribution?.toLowerCase()) {
145
+ case "flat":
146
+ return "Each entry";
147
+ case "even":
148
+ return "Shared evenly";
149
+ case "shuffle": {
150
+ const winners =
151
+ reward.winnerCountRaw && /^\d+$/.test(reward.winnerCountRaw)
152
+ ? BigInt(reward.winnerCountRaw)
153
+ : undefined;
154
+ if (winners == null) return "Random winners";
155
+ return `${winners.toLocaleString()} random ${winners === BigInt(1) ? "winner" : "winners"}`;
156
+ }
157
+ case "percentage":
158
+ return "By stake share";
159
+ default:
160
+ return "Shared";
161
+ }
162
+ }
163
+
164
+ /** "every week", or nothing when the cycle isn't a whole hour, day or week. */
165
+ function cycleLabel(value?: string): string | undefined {
166
+ const duration = formatDurationSeconds(value);
167
+ if (!duration || duration.endsWith("sec")) return undefined;
168
+ return duration.startsWith("1 ") ? `every ${duration.slice(2)}` : `every ${duration}`;
169
+ }
170
+
171
+ /** "5,000 AKTA left", "Out of rewards", or nothing for pools without budgets. */
172
+ function budgetLabel(reward: StakingPoolRewardDisplayData): string | undefined {
173
+ if (!reward.budgetRaw || !/^\d+$/.test(reward.budgetRaw)) return undefined;
174
+ if (BigInt(reward.budgetRaw) === BigInt(0)) return "Out of rewards";
175
+ const amount = formatAtomicAmount(reward.budgetRaw, reward.decimals ?? 0);
176
+ return amount ? `${amount} ${reward.unitName ?? ""}`.trim() + " left" : undefined;
177
+ }
178
+
179
+ /**
180
+ * What to stake. The minimum is in the staked asset's base units, so it's shown with
181
+ * that asset's decimals when the pool takes one known asset. A list can mix decimals,
182
+ * so then the card names the list and the join sheet shows each asset's minimum.
183
+ * No-stake pools weigh every entry the same and have nothing to show.
184
+ */
185
+ function stakeFigureFor(
186
+ data: StakingPoolDisplayData,
187
+ ): { label: string; value: string } | undefined {
188
+ if (data.poolType?.toLowerCase() === "none") return undefined;
189
+ const raw = data.minimumStakeAmount;
190
+ const minimum = raw && /^\d+$/.test(raw) ? BigInt(raw) : undefined;
191
+ if (data.stakeDecimals != null) {
192
+ if (minimum == null || minimum <= BigInt(1)) {
193
+ return {
194
+ label: "Stake",
195
+ value: data.stakeUnitName ? `Any amount of ${data.stakeUnitName}` : "Any amount",
196
+ };
197
+ }
198
+ return {
199
+ label: "Minimum stake",
200
+ value: `${formatStakeAmount(raw, data.stakeDecimals)} ${data.stakeUnitName ?? ""}`.trim(),
201
+ };
202
+ }
203
+ return {
204
+ label: "Stake",
205
+ value: data.stakeListName ? `From ${data.stakeListName}` : "Any listed asset",
206
+ };
207
+ }
208
+
209
+ /** One short line for the pool's schedule, like the auction and raffle cards. */
210
+ export function stakingPoolTimerLabel(
211
+ data: Pick<
212
+ StakingPoolDisplayData,
213
+ "status" | "signupTime" | "startTime" | "endTime" | "allowLateSignups"
214
+ >,
215
+ nowMs = Date.now(),
216
+ ): string | undefined {
217
+ const until = (verb: string, date?: Date) => {
218
+ if (!date) return undefined;
219
+ const at = formatShortDistance(date, nowMs);
220
+ if (at === "now") return `${verb} now`;
221
+ return isShortDistanceDate(date, nowMs) ? `${verb} ${at}` : `${verb} in ${at}`;
222
+ };
223
+ switch (data.status) {
224
+ case "upcoming":
225
+ return data.signupTime
226
+ ? until("Signups open", data.signupTime)
227
+ : until("Starts", data.startTime);
228
+ case "signups":
229
+ return until("Starts", data.startTime);
230
+ case "active":
231
+ // A perpetual pool has no end until its creator ends it.
232
+ return data.endTime ? until("Ends", data.endTime) : "No end date";
233
+ case "ended":
234
+ case "final": {
235
+ if (!data.endTime) return "Ended";
236
+ const at = formatShortDistance(data.endTime, nowMs);
237
+ return at === "now" ? "Ended now" : `Ended ${at}`;
238
+ }
239
+ case "draft":
240
+ return "Not open yet";
241
+ default:
242
+ return undefined;
243
+ }
244
+ }
245
+
246
+ export function StakingPoolDisplay({
247
+ data,
248
+ notice,
249
+ onRetry,
250
+ action,
251
+ }: StakingPoolDisplayProps) {
252
+ const { theme } = useAppTheme();
253
+ const poolColor = PLUGIN_COLORS.StakingPool;
254
+ const reward = data.primaryReward;
255
+ // On the reward's own page its art is already shown above.
256
+ const onSubjectPage = useIsAssetSubject(reward?.assetId);
257
+ const live =
258
+ data.status === "upcoming" ||
259
+ data.status === "signups" ||
260
+ data.status === "active";
261
+ const now = useNow(live);
262
+ const entryTargetClosed =
263
+ (data.status === "signups" ||
264
+ (data.status === "active" && data.allowLateSignups === true)) &&
265
+ data.maxEntries != null &&
266
+ data.maxEntries > 0 &&
267
+ data.entryCount != null &&
268
+ data.entryCount >= data.maxEntries - 1;
269
+ const endingSoon =
270
+ data.status === "active" &&
271
+ !!data.endTime &&
272
+ data.endTime.getTime() - now < 60 * 60 * 1000;
273
+ const timerLabel = entryTargetClosed
274
+ ? "Entries closed"
275
+ : stakingPoolTimerLabel(data, now);
276
+ const entries =
277
+ data.entryCount == null
278
+ ? undefined
279
+ : data.maxEntries != null && data.maxEntries > 0
280
+ ? `${data.entryCount.toLocaleString()} of ${data.maxEntries.toLocaleString()} entries`
281
+ : `${data.entryCount.toLocaleString()} ${data.entryCount === 1 ? "entry" : "entries"}`;
282
+ const stakeFigure = stakeFigureFor(data);
283
+ const rewardIcon = reward?.imageUrl ? (
284
+ <Image
285
+ source={{ uri: reward.imageUrl }}
286
+ style={{ width: 16, height: 16, borderRadius: 8 }}
287
+ />
288
+ ) : null;
289
+ const moreRewards =
290
+ data.rewardCount && data.rewardCount > 1
291
+ ? `+${data.rewardCount - 1} more ${data.rewardCount === 2 ? "reward" : "rewards"}`
292
+ : undefined;
293
+ const budgetLeft = reward ? budgetLabel(reward) : undefined;
294
+ const rewardDetail = reward
295
+ ? [
296
+ [rewardSplitLabel(reward), cycleLabel(reward.intervalSecondsRaw)]
297
+ .filter(Boolean)
298
+ .join(" "),
299
+ budgetLeft,
300
+ moreRewards,
301
+ ]
302
+ .filter(Boolean)
303
+ .join(" · ")
304
+ : undefined;
305
+ // Say who can join only when the pool says so; unknown stays unsaid.
306
+ const subtitle = [
307
+ poolTypeLabel(data.poolType),
308
+ data.unrestricted === true
309
+ ? "Open to anyone"
310
+ : data.gateId != null && data.gateId > 0
311
+ ? "Gated"
312
+ : null,
313
+ ]
314
+ .filter(Boolean)
315
+ .join(" · ");
316
+
317
+ return (
318
+ <OnChainActionCard
319
+ accessibilityLabel={[data.title, "staking pool", timerLabel]
320
+ .filter(Boolean)
321
+ .join(", ")}
322
+ testID={`staking-pool-card-${data.id}`}
323
+ media={
324
+ reward?.imageUrl && !onSubjectPage ? (
325
+ <AdaptiveImage
326
+ uri={reward.imageUrl}
327
+ assetId={reward.assetId}
328
+ maxHeight={220}
329
+ borderRadiusTop={0}
330
+ fill
331
+ />
332
+ ) : undefined
333
+ }
334
+ >
335
+ <OnChainActionHeader
336
+ eyebrow="Staking pool"
337
+ eyebrowColor={poolColor}
338
+ eyebrowIcon={<StakingPoolIcon size={13} color={poolColor} />}
339
+ title={data.title}
340
+ subtitle={subtitle}
341
+ menu={<ContractMenu appId={data.id} embedType="StakingPool" />}
342
+ />
343
+
344
+ <OnChainMetricGrid>
345
+ {reward ? (
346
+ <OnChainMetric
347
+ label="Reward"
348
+ valueIcon={rewardIcon}
349
+ value={`${formatStakeAmount(reward.rateRaw, reward.decimals)} ${reward.unitName || ""}`.trim()}
350
+ secondary={rewardDetail}
351
+ />
352
+ ) : null}
353
+ {stakeFigure ? (
354
+ <OnChainMetric
355
+ label={stakeFigure.label}
356
+ value={stakeFigure.value}
357
+ secondary={entries}
358
+ />
359
+ ) : (
360
+ <OnChainMetric label="Entries" value={entries ?? "Not indexed"} />
361
+ )}
362
+ </OnChainMetricGrid>
363
+
364
+ {notice ? (
365
+ <View style={[styles.notice, { backgroundColor: `${theme.colors.warning}12` }]}>
366
+ <Text
367
+ size="xxs"
368
+ style={[styles.flexOne, { color: theme.colors.warningText }]}
369
+ >
370
+ {notice}
371
+ </Text>
372
+ {onRetry ? (
373
+ <Pressable
374
+ accessibilityLabel="Refresh staking pool state"
375
+ accessibilityRole="button"
376
+ onPress={onRetry}
377
+ hitSlop={8}
378
+ >
379
+ <ArrowPathIcon size={16} color={theme.colors.warningText} />
380
+ </Pressable>
381
+ ) : null}
382
+ </View>
383
+ ) : null}
384
+ {timerLabel || action ? (
385
+ <View style={{ gap: 8 }}>
386
+ {timerLabel ? (
387
+ <Text
388
+ size="xs"
389
+ weight="semiBold"
390
+ accessibilityLiveRegion="polite"
391
+ style={{
392
+ color: endingSoon
393
+ ? (theme.colors.secondary ?? theme.colors.primary)
394
+ : theme.colors.textDim,
395
+ }}
396
+ >
397
+ {timerLabel}
398
+ </Text>
399
+ ) : null}
400
+ {action}
401
+ </View>
402
+ ) : null}
403
+ </OnChainActionCard>
404
+ );
405
+ }
406
+
407
+ const styles = StyleSheet.create({
408
+ flexOne: {
409
+ flex: 1,
410
+ },
411
+ notice: {
412
+ alignItems: "center",
413
+ borderCurve: "continuous",
414
+ borderRadius: 10,
415
+ flexDirection: "row",
416
+ gap: 8,
417
+ padding: 9,
418
+ },
419
+ });
@@ -0,0 +1,56 @@
1
+ // Shared AlgoMD presentation, migrated from akita-rn. Edit this library source.
2
+ import React from "react";
3
+ import { View } from "react-native";
4
+ import { Text } from "./runtime";
5
+ import { useAppTheme } from "./runtime";
6
+
7
+ type BadgeVariant = "success" | "error" | "warning" | "info" | "neutral";
8
+
9
+ export interface StatusBadgeProps {
10
+ label: string;
11
+ variant?: BadgeVariant;
12
+ /** Opaque dark fill, for badges that sit on top of artwork. */
13
+ solid?: boolean;
14
+ }
15
+
16
+ export function StatusBadge({
17
+ label,
18
+ variant = "neutral",
19
+ solid,
20
+ }: StatusBadgeProps) {
21
+ const { theme } = useAppTheme();
22
+
23
+ const colors: Record<BadgeVariant, { bg: string; text: string }> = {
24
+ success: { bg: `${theme.colors.success}20`, text: theme.colors.success },
25
+ error: { bg: `${theme.colors.error}20`, text: theme.colors.error },
26
+ warning: {
27
+ bg: `${theme.colors.warning}20`,
28
+ text: theme.colors.warningText,
29
+ },
30
+ info: {
31
+ bg: `${theme.colors.secondary ?? theme.colors.primary}20`,
32
+ text: theme.colors.secondary ?? theme.colors.primary,
33
+ },
34
+ neutral: { bg: `${theme.colors.textDim}15`, text: theme.colors.textDim },
35
+ };
36
+
37
+ const c = colors[variant];
38
+
39
+ return (
40
+ <View
41
+ style={{
42
+ alignItems: "center",
43
+ alignSelf: "flex-start",
44
+ backgroundColor: solid ? "rgba(9, 9, 11, 0.72)" : c.bg,
45
+ borderRadius: 999,
46
+ flexDirection: "row",
47
+ paddingHorizontal: 10,
48
+ paddingVertical: 4,
49
+ }}
50
+ >
51
+ <Text size="xxs" weight="semiBold" style={{ color: c.text }}>
52
+ {label}
53
+ </Text>
54
+ </View>
55
+ );
56
+ }