@akita-protocol/algomd-rn 1.0.0-alpha.0 → 1.0.0-alpha.10
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 +1 -1
- package/package.json +7 -7
- package/src/adapters/txn-graph.ts +2 -1
- package/src/components/StakingPool.tsx +19 -17
- package/src/fonts/Allo_300Light.ttf +0 -0
- package/src/fonts/Allo_400Regular.ttf +0 -0
- package/src/fonts/Allo_500Medium.ttf +0 -0
- package/src/fonts/Allo_600SemiBold.ttf +0 -0
- package/src/fonts/Allo_700Bold.ttf +0 -0
- package/src/fonts/OFL.txt +93 -93
- package/src/fonts/README.md +17 -0
- package/src/fonts/app.css +5 -5
- package/src/hooks/useAlgomdData.ts +5 -4
- package/src/hooks/useAlgorandClient.ts +12 -10
- package/src/index.ts +1 -1
- package/src/presentation/ContractMenu.tsx +68 -29
- package/src/presentation/StakingPoolDisplay.tsx +489 -97
- package/src/presentation/icons.tsx +108 -1
- package/src/presentation/pluginColors.ts +1 -0
- package/src/presentation/runtime.tsx +43 -0
- package/src/presentation/textTheme.ts +5 -5
- package/src/refs/AccountRef.tsx +24 -10
- package/src/refs/GuildActions.tsx +925 -0
- package/src/refs/GuildProposalRef.tsx +312 -0
- package/src/refs/SubscriptionRef.tsx +6 -13
- package/src/refs/index.tsx +4 -0
- package/src/refs/primitives.tsx +51 -19
- package/src/fonts/SpaceGrotesk_300Light.ttf +0 -0
- package/src/fonts/SpaceGrotesk_400Regular.ttf +0 -0
- package/src/fonts/SpaceGrotesk_500Medium.ttf +0 -0
- package/src/fonts/SpaceGrotesk_600SemiBold.ttf +0 -0
- package/src/fonts/SpaceGrotesk_700Bold.ttf +0 -0
|
@@ -1,26 +1,36 @@
|
|
|
1
1
|
// Shared AlgoMD presentation, migrated from akita-rn. Edit this library source.
|
|
2
|
-
import React, { useEffect, useState } from "react";
|
|
2
|
+
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
3
3
|
import { Image, Pressable, StyleSheet, View } from "react-native";
|
|
4
|
+
import * as Haptics from "expo-haptics";
|
|
4
5
|
import {
|
|
6
|
+
BottomSheetModal,
|
|
7
|
+
BottomSheetBackdrop,
|
|
8
|
+
BottomSheetScrollView,
|
|
9
|
+
} from "./sheets";
|
|
10
|
+
import {
|
|
11
|
+
ChevronRightIcon,
|
|
5
12
|
OutlineArrowPathIcon as ArrowPathIcon,
|
|
6
13
|
StakingPoolIcon,
|
|
7
14
|
} from "./icons";
|
|
8
15
|
import { formatShortDistance, isShortDistanceDate } from "./format";
|
|
9
16
|
import { PLUGIN_COLORS } from "./pluginColors";
|
|
10
|
-
import { useIsAssetSubject } from "./subject";
|
|
11
17
|
|
|
12
|
-
import {
|
|
13
|
-
|
|
18
|
+
import {
|
|
19
|
+
AppPresentationProvider,
|
|
20
|
+
Text,
|
|
21
|
+
useAppTheme,
|
|
22
|
+
usePresentation,
|
|
23
|
+
} from "./runtime";
|
|
14
24
|
|
|
15
25
|
import { ContractMenu } from "./ContractMenu";
|
|
16
26
|
import { formatAtomicAmount } from "./format";
|
|
17
27
|
import {
|
|
18
28
|
OnChainActionCard,
|
|
19
|
-
OnChainActionHeader,
|
|
20
29
|
OnChainMetric,
|
|
21
30
|
OnChainMetricGrid,
|
|
22
31
|
} from "./OnChainActionCard";
|
|
23
|
-
import {
|
|
32
|
+
import { ProgressBar } from "./ProgressBar";
|
|
33
|
+
import { StatusBadge } from "./StatusBadge";
|
|
24
34
|
|
|
25
35
|
export type StakingPoolStatus =
|
|
26
36
|
| "draft"
|
|
@@ -44,8 +54,10 @@ export interface StakingPoolRewardDisplayData {
|
|
|
44
54
|
winnerCountRaw?: string;
|
|
45
55
|
/** Reward asset still reserved for this reward, in base units. */
|
|
46
56
|
budgetRaw?: string;
|
|
47
|
-
/** Reward asset art
|
|
57
|
+
/** Reward asset art: a token's icon or a collectible's picture. */
|
|
48
58
|
imageUrl?: string;
|
|
59
|
+
/** One of a kind or a small edition: named by its title, with square art. */
|
|
60
|
+
collectible?: boolean;
|
|
49
61
|
}
|
|
50
62
|
|
|
51
63
|
export interface StakingPoolDisplayData {
|
|
@@ -71,6 +83,8 @@ export interface StakingPoolDisplayData {
|
|
|
71
83
|
unrestricted?: boolean;
|
|
72
84
|
finalized?: boolean;
|
|
73
85
|
rewardCount?: number;
|
|
86
|
+
/** Every reward, in reward order. Defaults to just the primary reward. */
|
|
87
|
+
rewards?: StakingPoolRewardDisplayData[];
|
|
74
88
|
primaryReward?: StakingPoolRewardDisplayData;
|
|
75
89
|
}
|
|
76
90
|
|
|
@@ -243,6 +257,339 @@ export function stakingPoolTimerLabel(
|
|
|
243
257
|
}
|
|
244
258
|
}
|
|
245
259
|
|
|
260
|
+
const MAX_REWARD_ICONS = 4;
|
|
261
|
+
const REWARD_ICON_SIZE = 40;
|
|
262
|
+
|
|
263
|
+
/** What the status pill says. A pool that is open but full says so instead. */
|
|
264
|
+
function statusBadgeFor(
|
|
265
|
+
status: StakingPoolStatus,
|
|
266
|
+
entryTargetClosed: boolean,
|
|
267
|
+
): { label: string; variant: "success" | "warning" | "info" | "neutral" } | undefined {
|
|
268
|
+
if (entryTargetClosed) return { label: "Entries closed", variant: "neutral" };
|
|
269
|
+
switch (status) {
|
|
270
|
+
case "signups":
|
|
271
|
+
return { label: "Sign-ups open", variant: "info" };
|
|
272
|
+
case "active":
|
|
273
|
+
return { label: "Active", variant: "success" };
|
|
274
|
+
case "upcoming":
|
|
275
|
+
return { label: "Upcoming", variant: "neutral" };
|
|
276
|
+
case "ended":
|
|
277
|
+
case "final":
|
|
278
|
+
return { label: "Ended", variant: "neutral" };
|
|
279
|
+
case "draft":
|
|
280
|
+
return { label: "Draft", variant: "warning" };
|
|
281
|
+
default:
|
|
282
|
+
return undefined;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
const SHEET_SPRING = {
|
|
287
|
+
damping: 70,
|
|
288
|
+
stiffness: 900,
|
|
289
|
+
mass: 2,
|
|
290
|
+
overshootClamping: false,
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
/** "2,500 AKTA"; a single collectible goes by its title, not "1 PUP". */
|
|
294
|
+
function rewardValueLabel(reward: StakingPoolRewardDisplayData): string {
|
|
295
|
+
const amount = formatStakeAmount(reward.rateRaw, reward.decimals);
|
|
296
|
+
if (reward.collectible && reward.name) {
|
|
297
|
+
return amount === "1" ? reward.name : `${amount} × ${reward.name}`;
|
|
298
|
+
}
|
|
299
|
+
const unit =
|
|
300
|
+
reward.unitName || reward.name || (reward.assetId ? `#${reward.assetId}` : "");
|
|
301
|
+
return `${amount} ${unit}`.trim();
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/** "Shared evenly every week · 5,000 AKTA left". */
|
|
305
|
+
function rewardTermsLabel(reward: StakingPoolRewardDisplayData): string {
|
|
306
|
+
return [
|
|
307
|
+
[rewardSplitLabel(reward), cycleLabel(reward.intervalSecondsRaw)]
|
|
308
|
+
.filter(Boolean)
|
|
309
|
+
.join(" "),
|
|
310
|
+
budgetLabel(reward),
|
|
311
|
+
]
|
|
312
|
+
.filter(Boolean)
|
|
313
|
+
.join(" · ");
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/** One reward's picture: a token's round icon, or a collectible's art in a rounded square. */
|
|
317
|
+
function RewardArt({
|
|
318
|
+
reward,
|
|
319
|
+
size,
|
|
320
|
+
ring,
|
|
321
|
+
}: {
|
|
322
|
+
reward: StakingPoolRewardDisplayData;
|
|
323
|
+
size: number;
|
|
324
|
+
/** Outline colour, so overlapped art reads as separate pieces. */
|
|
325
|
+
ring?: string;
|
|
326
|
+
}) {
|
|
327
|
+
const { theme } = useAppTheme();
|
|
328
|
+
const color = PLUGIN_COLORS.StakingPool;
|
|
329
|
+
const border = ring ? 2 : 0;
|
|
330
|
+
return (
|
|
331
|
+
<View
|
|
332
|
+
style={{
|
|
333
|
+
alignItems: "center",
|
|
334
|
+
backgroundColor: reward.imageUrl ? theme.colors.background : `${color}1f`,
|
|
335
|
+
borderColor: ring,
|
|
336
|
+
// Collectible art is cropped to a rounded square so it isn't cut to a circle.
|
|
337
|
+
borderRadius: reward.collectible ? Math.round(size * 0.27) : size / 2,
|
|
338
|
+
borderWidth: border,
|
|
339
|
+
height: size,
|
|
340
|
+
justifyContent: "center",
|
|
341
|
+
overflow: "hidden",
|
|
342
|
+
width: size,
|
|
343
|
+
}}
|
|
344
|
+
>
|
|
345
|
+
{reward.imageUrl ? (
|
|
346
|
+
<Image
|
|
347
|
+
source={{ uri: reward.imageUrl }}
|
|
348
|
+
accessibilityLabel={reward.name}
|
|
349
|
+
style={{ width: size - border * 2, height: size - border * 2 }}
|
|
350
|
+
/>
|
|
351
|
+
) : (
|
|
352
|
+
<StakingPoolIcon size={Math.round(size * 0.45)} color={color} />
|
|
353
|
+
)}
|
|
354
|
+
</View>
|
|
355
|
+
);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/** The pool's reward art, overlapped: one piece per distinct reward asset. */
|
|
359
|
+
function RewardArtStack({
|
|
360
|
+
rewards,
|
|
361
|
+
ring,
|
|
362
|
+
}: {
|
|
363
|
+
rewards: StakingPoolRewardDisplayData[];
|
|
364
|
+
ring: string;
|
|
365
|
+
}) {
|
|
366
|
+
const { theme } = useAppTheme();
|
|
367
|
+
const distinct = rewards.filter(
|
|
368
|
+
(item, index) =>
|
|
369
|
+
!item.assetId ||
|
|
370
|
+
rewards.findIndex((other) => other.assetId === item.assetId) === index,
|
|
371
|
+
);
|
|
372
|
+
const shown = distinct.slice(0, MAX_REWARD_ICONS);
|
|
373
|
+
const more = distinct.length - shown.length;
|
|
374
|
+
return (
|
|
375
|
+
<View style={{ alignItems: "center", flexDirection: "row" }}>
|
|
376
|
+
{shown.map((reward, index) => (
|
|
377
|
+
<View
|
|
378
|
+
key={`${reward.assetId ?? ""}-${index}`}
|
|
379
|
+
style={{
|
|
380
|
+
marginLeft: index
|
|
381
|
+
? reward.collectible || shown[index - 1].collectible
|
|
382
|
+
? -8
|
|
383
|
+
: -12
|
|
384
|
+
: 0,
|
|
385
|
+
}}
|
|
386
|
+
>
|
|
387
|
+
<RewardArt reward={reward} size={REWARD_ICON_SIZE} ring={ring} />
|
|
388
|
+
</View>
|
|
389
|
+
))}
|
|
390
|
+
{more > 0 ? (
|
|
391
|
+
<Text
|
|
392
|
+
size="xxs"
|
|
393
|
+
weight="bold"
|
|
394
|
+
style={{ color: theme.colors.textDim, marginLeft: 6 }}
|
|
395
|
+
>
|
|
396
|
+
+{more}
|
|
397
|
+
</Text>
|
|
398
|
+
) : null}
|
|
399
|
+
</View>
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/** Every reward a pool pays, one row each, for the rewards sheet. */
|
|
404
|
+
function RewardList({
|
|
405
|
+
rewards,
|
|
406
|
+
count,
|
|
407
|
+
}: {
|
|
408
|
+
rewards: StakingPoolRewardDisplayData[];
|
|
409
|
+
count: number;
|
|
410
|
+
}) {
|
|
411
|
+
const { theme } = useAppTheme();
|
|
412
|
+
const unlisted = count - rewards.length;
|
|
413
|
+
return (
|
|
414
|
+
<View style={{ gap: 6 }}>
|
|
415
|
+
<View style={{ gap: 4 }}>
|
|
416
|
+
<Text size="md" weight="bold">
|
|
417
|
+
{`${count.toLocaleString()} rewards`}
|
|
418
|
+
</Text>
|
|
419
|
+
<Text size="xs" style={{ color: theme.colors.textDim }}>
|
|
420
|
+
What this pool pays the people who join it.
|
|
421
|
+
</Text>
|
|
422
|
+
</View>
|
|
423
|
+
{rewards.map((reward, index) => {
|
|
424
|
+
const value = rewardValueLabel(reward);
|
|
425
|
+
const terms = rewardTermsLabel(reward);
|
|
426
|
+
return (
|
|
427
|
+
<View
|
|
428
|
+
key={`${reward.assetId ?? ""}-${index}`}
|
|
429
|
+
accessible
|
|
430
|
+
accessibilityLabel={`${value}, ${terms}`}
|
|
431
|
+
style={{
|
|
432
|
+
alignItems: "center",
|
|
433
|
+
flexDirection: "row",
|
|
434
|
+
gap: 12,
|
|
435
|
+
paddingVertical: 8,
|
|
436
|
+
}}
|
|
437
|
+
>
|
|
438
|
+
<RewardArt reward={reward} size={REWARD_ICON_SIZE} />
|
|
439
|
+
<View style={{ flex: 1, gap: 2 }}>
|
|
440
|
+
<Text size="sm" weight="semiBold" numberOfLines={2}>
|
|
441
|
+
{value}
|
|
442
|
+
</Text>
|
|
443
|
+
<Text
|
|
444
|
+
size="xxs"
|
|
445
|
+
numberOfLines={2}
|
|
446
|
+
style={{ color: theme.colors.textDim }}
|
|
447
|
+
>
|
|
448
|
+
{terms}
|
|
449
|
+
</Text>
|
|
450
|
+
</View>
|
|
451
|
+
</View>
|
|
452
|
+
);
|
|
453
|
+
})}
|
|
454
|
+
{unlisted > 0 ? (
|
|
455
|
+
<Text size="xs" style={{ color: theme.colors.textDim }}>
|
|
456
|
+
{`And ${unlisted.toLocaleString()} more.`}
|
|
457
|
+
</Text>
|
|
458
|
+
) : null}
|
|
459
|
+
</View>
|
|
460
|
+
);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* What the pool pays, as one row: the reward art and its words side by side. One
|
|
465
|
+
* reward is spelled out. Several are counted, and the row opens the full list in a
|
|
466
|
+
* bottom sheet, the same way a gate's requirements open.
|
|
467
|
+
*/
|
|
468
|
+
function PoolRewards({
|
|
469
|
+
rewards,
|
|
470
|
+
count,
|
|
471
|
+
ring,
|
|
472
|
+
dimmed,
|
|
473
|
+
}: {
|
|
474
|
+
rewards: StakingPoolRewardDisplayData[];
|
|
475
|
+
count: number;
|
|
476
|
+
ring: string;
|
|
477
|
+
dimmed: boolean;
|
|
478
|
+
}) {
|
|
479
|
+
const { theme } = useAppTheme();
|
|
480
|
+
const presentation = usePresentation();
|
|
481
|
+
const PortalProvider =
|
|
482
|
+
presentation.components?.PortalProvider ?? React.Fragment;
|
|
483
|
+
const sheetRef = useRef<BottomSheetModal>(null);
|
|
484
|
+
useEffect(() => {
|
|
485
|
+
const sheet = sheetRef.current;
|
|
486
|
+
return () => sheet?.dismiss();
|
|
487
|
+
}, []);
|
|
488
|
+
const open = useCallback(() => {
|
|
489
|
+
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
|
|
490
|
+
sheetRef.current?.present();
|
|
491
|
+
}, []);
|
|
492
|
+
const several = count > 1;
|
|
493
|
+
const first = rewards[0];
|
|
494
|
+
const names = [
|
|
495
|
+
...new Set(
|
|
496
|
+
rewards
|
|
497
|
+
.map((reward) =>
|
|
498
|
+
reward.collectible ? reward.name : reward.unitName || reward.name,
|
|
499
|
+
)
|
|
500
|
+
.filter((name): name is string => !!name),
|
|
501
|
+
),
|
|
502
|
+
];
|
|
503
|
+
const title = several
|
|
504
|
+
? `${count.toLocaleString()} rewards`
|
|
505
|
+
: rewardValueLabel(first);
|
|
506
|
+
const detail = several
|
|
507
|
+
? names.length > 2
|
|
508
|
+
? `${names.slice(0, 2).join(", ")} and ${names.length - 2} more`
|
|
509
|
+
: names.join(" and ")
|
|
510
|
+
: rewardTermsLabel(first);
|
|
511
|
+
const row = (
|
|
512
|
+
<View
|
|
513
|
+
style={{
|
|
514
|
+
alignItems: "center",
|
|
515
|
+
flexDirection: "row",
|
|
516
|
+
gap: 10,
|
|
517
|
+
opacity: dimmed ? 0.6 : 1,
|
|
518
|
+
}}
|
|
519
|
+
>
|
|
520
|
+
<RewardArtStack rewards={rewards} ring={ring} />
|
|
521
|
+
<View style={{ flex: 1, gap: 1, minWidth: 0 }}>
|
|
522
|
+
<Text size="sm" weight="semiBold" numberOfLines={1}>
|
|
523
|
+
{title}
|
|
524
|
+
</Text>
|
|
525
|
+
{detail ? (
|
|
526
|
+
<Text
|
|
527
|
+
size="xxs"
|
|
528
|
+
numberOfLines={several ? 1 : 2}
|
|
529
|
+
style={{ color: theme.colors.textDim }}
|
|
530
|
+
>
|
|
531
|
+
{detail}
|
|
532
|
+
</Text>
|
|
533
|
+
) : null}
|
|
534
|
+
</View>
|
|
535
|
+
{several ? (
|
|
536
|
+
<ChevronRightIcon size={16} color={theme.colors.textDim} />
|
|
537
|
+
) : null}
|
|
538
|
+
</View>
|
|
539
|
+
);
|
|
540
|
+
if (!several) {
|
|
541
|
+
return (
|
|
542
|
+
<View accessible accessibilityLabel={`Reward: ${title}, ${detail}`}>
|
|
543
|
+
{row}
|
|
544
|
+
</View>
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
return (
|
|
548
|
+
<>
|
|
549
|
+
<Pressable
|
|
550
|
+
accessibilityRole="button"
|
|
551
|
+
accessibilityLabel={`${title}: ${detail}`}
|
|
552
|
+
accessibilityHint="Shows every reward"
|
|
553
|
+
onPress={open}
|
|
554
|
+
style={({ pressed }) => (pressed ? { opacity: 0.7 } : null)}
|
|
555
|
+
>
|
|
556
|
+
{row}
|
|
557
|
+
</Pressable>
|
|
558
|
+
<BottomSheetModal
|
|
559
|
+
ref={sheetRef}
|
|
560
|
+
enableDynamicSizing
|
|
561
|
+
backgroundStyle={{ backgroundColor: theme.colors.background }}
|
|
562
|
+
handleIndicatorStyle={{ backgroundColor: theme.colors.border }}
|
|
563
|
+
animationConfigs={SHEET_SPRING}
|
|
564
|
+
backdropComponent={(
|
|
565
|
+
props: React.ComponentProps<typeof BottomSheetBackdrop>,
|
|
566
|
+
) => (
|
|
567
|
+
<BottomSheetBackdrop
|
|
568
|
+
{...props}
|
|
569
|
+
appearsOnIndex={0}
|
|
570
|
+
disappearsOnIndex={-1}
|
|
571
|
+
pressBehavior="close"
|
|
572
|
+
/>
|
|
573
|
+
)}
|
|
574
|
+
>
|
|
575
|
+
<PortalProvider>
|
|
576
|
+
<AppPresentationProvider {...presentation}>
|
|
577
|
+
<BottomSheetScrollView
|
|
578
|
+
contentContainerStyle={{
|
|
579
|
+
paddingHorizontal: 20,
|
|
580
|
+
paddingTop: 4,
|
|
581
|
+
paddingBottom: 40,
|
|
582
|
+
}}
|
|
583
|
+
>
|
|
584
|
+
<RewardList rewards={rewards} count={count} />
|
|
585
|
+
</BottomSheetScrollView>
|
|
586
|
+
</AppPresentationProvider>
|
|
587
|
+
</PortalProvider>
|
|
588
|
+
</BottomSheetModal>
|
|
589
|
+
</>
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
|
|
246
593
|
export function StakingPoolDisplay({
|
|
247
594
|
data,
|
|
248
595
|
notice,
|
|
@@ -252,58 +599,48 @@ export function StakingPoolDisplay({
|
|
|
252
599
|
const { theme } = useAppTheme();
|
|
253
600
|
const poolColor = PLUGIN_COLORS.StakingPool;
|
|
254
601
|
const reward = data.primaryReward;
|
|
255
|
-
// On the reward's own page its art is already shown above.
|
|
256
|
-
const onSubjectPage = useIsAssetSubject(reward?.assetId);
|
|
257
602
|
const live =
|
|
258
603
|
data.status === "upcoming" ||
|
|
259
604
|
data.status === "signups" ||
|
|
260
605
|
data.status === "active";
|
|
606
|
+
const over = data.status === "ended" || data.status === "final";
|
|
261
607
|
const now = useNow(live);
|
|
608
|
+
const capacity =
|
|
609
|
+
data.maxEntries != null && data.maxEntries > 0 ? data.maxEntries : undefined;
|
|
262
610
|
const entryTargetClosed =
|
|
263
611
|
(data.status === "signups" ||
|
|
264
612
|
(data.status === "active" && data.allowLateSignups === true)) &&
|
|
265
|
-
|
|
266
|
-
data.maxEntries > 0 &&
|
|
613
|
+
capacity != null &&
|
|
267
614
|
data.entryCount != null &&
|
|
268
|
-
data.entryCount >=
|
|
615
|
+
data.entryCount >= capacity - 1;
|
|
269
616
|
const endingSoon =
|
|
270
617
|
data.status === "active" &&
|
|
271
618
|
!!data.endTime &&
|
|
272
619
|
data.endTime.getTime() - now < 60 * 60 * 1000;
|
|
273
|
-
const timerLabel =
|
|
274
|
-
|
|
275
|
-
: stakingPoolTimerLabel(data, now);
|
|
620
|
+
const timerLabel = stakingPoolTimerLabel(data, now);
|
|
621
|
+
const status = statusBadgeFor(data.status, entryTargetClosed);
|
|
276
622
|
const entries =
|
|
277
623
|
data.entryCount == null
|
|
278
624
|
? undefined
|
|
279
|
-
:
|
|
280
|
-
? `${data.entryCount.toLocaleString()} of ${
|
|
625
|
+
: capacity != null
|
|
626
|
+
? `${data.entryCount.toLocaleString()} of ${capacity.toLocaleString()} entries`
|
|
281
627
|
: `${data.entryCount.toLocaleString()} ${data.entryCount === 1 ? "entry" : "entries"}`;
|
|
628
|
+
const filled =
|
|
629
|
+
capacity != null && data.entryCount != null
|
|
630
|
+
? Math.min(1, data.entryCount / capacity)
|
|
631
|
+
: undefined;
|
|
282
632
|
const stakeFigure = stakeFigureFor(data);
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
const moreRewards =
|
|
290
|
-
data.rewardCount && data.rewardCount > 1
|
|
291
|
-
? `+${data.rewardCount - 1} more ${data.rewardCount === 2 ? "reward" : "rewards"}`
|
|
633
|
+
const totalStaked =
|
|
634
|
+
data.stakeDecimals != null &&
|
|
635
|
+
data.totalStaked &&
|
|
636
|
+
/^\d+$/.test(data.totalStaked) &&
|
|
637
|
+
BigInt(data.totalStaked) > BigInt(0)
|
|
638
|
+
? `${formatStakeAmount(data.totalStaked, data.stakeDecimals)} ${data.stakeUnitName ?? ""}`.trim()
|
|
292
639
|
: undefined;
|
|
293
|
-
const
|
|
294
|
-
const
|
|
295
|
-
? [
|
|
296
|
-
[rewardSplitLabel(reward), cycleLabel(reward.intervalSecondsRaw)]
|
|
297
|
-
.filter(Boolean)
|
|
298
|
-
.join(" "),
|
|
299
|
-
budgetLeft,
|
|
300
|
-
moreRewards,
|
|
301
|
-
]
|
|
302
|
-
.filter(Boolean)
|
|
303
|
-
.join(" · ")
|
|
304
|
-
: undefined;
|
|
640
|
+
const rewards = data.rewards ?? (reward ? [reward] : []);
|
|
641
|
+
const rewardTotal = Math.max(data.rewardCount ?? 0, rewards.length);
|
|
305
642
|
// Say who can join only when the pool says so; unknown stays unsaid.
|
|
306
|
-
const
|
|
643
|
+
const terms = [
|
|
307
644
|
poolTypeLabel(data.poolType),
|
|
308
645
|
data.unrestricted === true
|
|
309
646
|
? "Open to anyone"
|
|
@@ -314,52 +651,125 @@ export function StakingPoolDisplay({
|
|
|
314
651
|
.filter(Boolean)
|
|
315
652
|
.join(" · ");
|
|
316
653
|
|
|
654
|
+
// Read top to bottom: what it is and whether it is open, what it pays (art and
|
|
655
|
+
// words side by side), how full it is, the terms, then the way in.
|
|
317
656
|
return (
|
|
318
657
|
<OnChainActionCard
|
|
319
|
-
accessibilityLabel={[data.title, "staking pool", timerLabel]
|
|
658
|
+
accessibilityLabel={[data.title, "staking pool", status?.label, timerLabel]
|
|
320
659
|
.filter(Boolean)
|
|
321
660
|
.join(", ")}
|
|
322
661
|
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
662
|
>
|
|
335
|
-
<
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
663
|
+
<View style={{ gap: 2 }}>
|
|
664
|
+
<View style={{ alignItems: "center", flexDirection: "row", gap: 8 }}>
|
|
665
|
+
<View
|
|
666
|
+
style={{
|
|
667
|
+
alignItems: "center",
|
|
668
|
+
flex: 1,
|
|
669
|
+
flexDirection: "row",
|
|
670
|
+
gap: 4,
|
|
671
|
+
minWidth: 0,
|
|
672
|
+
}}
|
|
673
|
+
>
|
|
674
|
+
<StakingPoolIcon size={13} color={poolColor} />
|
|
675
|
+
<Text
|
|
676
|
+
size="xxs"
|
|
677
|
+
weight="semiBold"
|
|
678
|
+
style={{
|
|
679
|
+
color: poolColor,
|
|
680
|
+
letterSpacing: 0.6,
|
|
681
|
+
textTransform: "uppercase",
|
|
682
|
+
}}
|
|
683
|
+
>
|
|
684
|
+
Staking pool
|
|
685
|
+
</Text>
|
|
686
|
+
</View>
|
|
687
|
+
{status ? (
|
|
688
|
+
<StatusBadge label={status.label} variant={status.variant} />
|
|
689
|
+
) : null}
|
|
690
|
+
<ContractMenu appId={data.id} embedType="StakingPool" />
|
|
691
|
+
</View>
|
|
692
|
+
<Text
|
|
693
|
+
accessibilityRole="header"
|
|
694
|
+
size="md"
|
|
695
|
+
weight="semiBold"
|
|
696
|
+
numberOfLines={2}
|
|
697
|
+
style={over ? { color: theme.colors.textDim } : undefined}
|
|
698
|
+
>
|
|
699
|
+
{data.title}
|
|
700
|
+
</Text>
|
|
701
|
+
<View style={{ flexDirection: "row", flexWrap: "wrap" }}>
|
|
702
|
+
<Text size="xs" style={{ color: theme.colors.textDim }}>
|
|
703
|
+
{timerLabel ? `${terms} · ` : terms}
|
|
704
|
+
</Text>
|
|
705
|
+
{timerLabel ? (
|
|
706
|
+
<Text
|
|
707
|
+
size="xs"
|
|
708
|
+
weight={endingSoon ? "semiBold" : undefined}
|
|
709
|
+
accessibilityLiveRegion="polite"
|
|
710
|
+
style={{
|
|
711
|
+
color: endingSoon
|
|
712
|
+
? (theme.colors.secondary ?? theme.colors.primary)
|
|
713
|
+
: theme.colors.textDim,
|
|
714
|
+
}}
|
|
715
|
+
>
|
|
716
|
+
{timerLabel}
|
|
717
|
+
</Text>
|
|
718
|
+
) : null}
|
|
719
|
+
</View>
|
|
720
|
+
</View>
|
|
343
721
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
722
|
+
{rewards.length ? (
|
|
723
|
+
<PoolRewards
|
|
724
|
+
rewards={rewards}
|
|
725
|
+
count={rewardTotal}
|
|
726
|
+
ring={theme.colors.accentBackground}
|
|
727
|
+
dimmed={over}
|
|
728
|
+
/>
|
|
729
|
+
) : null}
|
|
730
|
+
|
|
731
|
+
{entries ? (
|
|
732
|
+
<View style={{ gap: 8 }}>
|
|
733
|
+
<View
|
|
734
|
+
style={{
|
|
735
|
+
alignItems: "baseline",
|
|
736
|
+
flexDirection: "row",
|
|
737
|
+
gap: 8,
|
|
738
|
+
justifyContent: "space-between",
|
|
739
|
+
}}
|
|
740
|
+
>
|
|
741
|
+
<Text size="xs" weight="semiBold">
|
|
742
|
+
{entries}
|
|
743
|
+
</Text>
|
|
744
|
+
{filled != null ? (
|
|
745
|
+
<Text size="xs" style={{ color: theme.colors.textDim }}>
|
|
746
|
+
{filled >= 1 ? "Full" : `${Math.floor(filled * 100)}%`}
|
|
747
|
+
</Text>
|
|
748
|
+
) : null}
|
|
749
|
+
</View>
|
|
750
|
+
{filled != null ? (
|
|
751
|
+
<ProgressBar
|
|
752
|
+
progress={
|
|
753
|
+
data.entryCount ? Math.max(filled, 0.02) : 0
|
|
754
|
+
}
|
|
755
|
+
height={6}
|
|
756
|
+
color={over ? theme.colors.textDim : theme.colors.primary}
|
|
757
|
+
trackColor={`${theme.colors.textDim}26`}
|
|
758
|
+
/>
|
|
759
|
+
) : null}
|
|
760
|
+
</View>
|
|
761
|
+
) : null}
|
|
762
|
+
|
|
763
|
+
{stakeFigure || totalStaked ? (
|
|
764
|
+
<OnChainMetricGrid>
|
|
765
|
+
{stakeFigure ? (
|
|
766
|
+
<OnChainMetric label={stakeFigure.label} value={stakeFigure.value} />
|
|
767
|
+
) : null}
|
|
768
|
+
{totalStaked ? (
|
|
769
|
+
<OnChainMetric label="Total staked" value={totalStaked} />
|
|
770
|
+
) : null}
|
|
771
|
+
</OnChainMetricGrid>
|
|
772
|
+
) : null}
|
|
363
773
|
|
|
364
774
|
{notice ? (
|
|
365
775
|
<View style={[styles.notice, { backgroundColor: `${theme.colors.warning}12` }]}>
|
|
@@ -381,25 +791,7 @@ export function StakingPoolDisplay({
|
|
|
381
791
|
) : null}
|
|
382
792
|
</View>
|
|
383
793
|
) : null}
|
|
384
|
-
{
|
|
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}
|
|
794
|
+
{action}
|
|
403
795
|
</OnChainActionCard>
|
|
404
796
|
);
|
|
405
797
|
}
|