@akita-protocol/algomd-rn 1.0.0-alpha.3 → 1.0.0-alpha.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akita-protocol/algomd-rn",
3
- "version": "1.0.0-alpha.3",
3
+ "version": "1.0.0-alpha.5",
4
4
  "main": "src/index.ts",
5
5
  "types": "src/index.ts",
6
6
  "react-native": "src/index.ts",
@@ -79,7 +79,7 @@
79
79
  "vite": "^6.4.3"
80
80
  },
81
81
  "dependencies": {
82
- "@akita-protocol/algomd-core": "1.0.0-alpha.3"
82
+ "@akita-protocol/algomd-core": "1.0.0-alpha.5"
83
83
  },
84
84
  "exports": {
85
85
  ".": "./src/index.ts",
@@ -2,6 +2,7 @@ import { isCompactReference, type ReferenceVariantProps } from "../presentation/
2
2
  import { CompactPill } from "../presentation/References";
3
3
  import { StakingPoolDisplay as StakingPoolPresentation } from "../presentation/StakingPoolDisplay";
4
4
  import { OnChainActionButton } from "../presentation/OnChainActionCard";
5
+ import { isCollectibleAsset } from "../presentation/gates";
5
6
  import React from "react";
6
7
  import type {
7
8
  ComponentSize,
@@ -76,7 +77,21 @@ export function StakingPoolComponent({
76
77
  pool.maxEntriesRaw,
77
78
  );
78
79
  const canEnter = signupsAvailable && !entryTargetClosed;
79
- const reward = pool.rewards[0];
80
+ const rewards = pool.rewards.map((item, index) => ({
81
+ assetId: String(item.asset.id),
82
+ name: item.asset.name,
83
+ unitName: item.asset.unitName,
84
+ decimals: item.asset.decimals,
85
+ rateRaw: item.rateRaw,
86
+ distribution: item.distribution,
87
+ intervalSecondsRaw: item.intervalRaw,
88
+ expirationSecondsRaw: item.expirationRaw,
89
+ winnerCountRaw: item.winnerCountRaw,
90
+ budgetRaw: item.budgetRaw,
91
+ // The `imageUrl` prop stands in for the first reward's art.
92
+ imageUrl: (index === 0 ? imageUrl : undefined) ?? item.asset.imageUrl,
93
+ collectible: isCollectibleAsset(item.asset),
94
+ }));
80
95
  return (
81
96
  <SizeContainer size={size} className={className}>
82
97
  <StakingPoolPresentation
@@ -103,24 +118,11 @@ export function StakingPoolComponent({
103
118
  gateId: pool.gateAppId,
104
119
  unrestricted: pool.unrestricted,
105
120
  rewardCount: pool.rewards.length,
106
- primaryReward: reward
107
- ? {
108
- assetId: String(reward.asset.id),
109
- name: reward.asset.name,
110
- unitName: reward.asset.unitName,
111
- decimals: reward.asset.decimals,
112
- rateRaw: reward.rateRaw,
113
- distribution: reward.distribution,
114
- intervalSecondsRaw: reward.intervalRaw,
115
- expirationSecondsRaw: reward.expirationRaw,
116
- winnerCountRaw: reward.winnerCountRaw,
117
- budgetRaw: reward.budgetRaw,
118
- imageUrl: imageUrl ?? reward.asset.imageUrl,
119
- }
120
- : undefined,
121
+ rewards,
122
+ primaryReward: rewards[0],
121
123
  }}
122
124
  action={
123
- // When the pool can't be joined, the card's time line says why.
125
+ // When the pool can't be joined, the card's status and time say why.
124
126
  showEnterButton && onEnter && canEnter ? (
125
127
  <OnChainActionButton
126
128
  label="Join pool"
@@ -9,6 +9,7 @@ import {
9
9
  EllipsisVerticalIcon,
10
10
  ArrowTopRightOnSquareIcon,
11
11
  Square2StackIcon,
12
+ OutlineDocumentTextIcon,
12
13
  } from "./icons";
13
14
  import * as Clipboard from "expo-clipboard";
14
15
  import * as Haptics from "expo-haptics";
@@ -60,6 +61,39 @@ const LABELS: Record<EntityType, string> = {
60
61
  tx: "Transaction",
61
62
  };
62
63
 
64
+ /** The AlgoMD tag Copy Embed copies and Quote starts a post with, or undefined when there is none. */
65
+ export function buildEmbed({
66
+ appId,
67
+ type = "application",
68
+ embedType,
69
+ embedProp,
70
+ embedValue,
71
+ }: Pick<ContractMenuProps, "appId" | "type" | "embedType" | "embedProp" | "embedValue">): string | undefined {
72
+ const componentName =
73
+ embedType ??
74
+ (type === "asset"
75
+ ? "ASA"
76
+ : type === "account"
77
+ ? "Account"
78
+ : type === "tx"
79
+ ? "Transaction"
80
+ : undefined);
81
+ if (!componentName) return undefined;
82
+
83
+ const idProp =
84
+ embedProp ??
85
+ (componentName === "NFDProfile"
86
+ ? "name"
87
+ : componentName === "DualStakePool"
88
+ ? "appId"
89
+ : type === "account"
90
+ ? "address"
91
+ : "id");
92
+ const value = embedValue ?? appId;
93
+ const compactProp = componentName === "Account" ? " compact" : "";
94
+ return `<${componentName} ${idProp}="${String(value)}"${compactProp} />`;
95
+ }
96
+
63
97
  export function ContractMenu({
64
98
  appId,
65
99
  type = "application",
@@ -94,40 +128,25 @@ export function ContractMenu({
94
128
  sheetRef.current?.dismiss();
95
129
  }, [appId]);
96
130
 
131
+ const embed = buildEmbed({ appId, type, embedType, embedProp, embedValue });
132
+
97
133
  const handleCopyEmbed = useCallback(() => {
98
- const componentName =
99
- embedType ??
100
- (type === "asset"
101
- ? "ASA"
102
- : type === "account"
103
- ? "Account"
104
- : type === "tx"
105
- ? "Transaction"
106
- : undefined);
107
- if (!componentName) return;
108
-
109
- const idProp =
110
- embedProp ??
111
- (componentName === "NFDProfile"
112
- ? "name"
113
- : componentName === "DualStakePool"
114
- ? "appId"
115
- : type === "account"
116
- ? "address"
117
- : "id");
118
- const value = embedValue ?? appId;
119
-
120
- const compactProp = componentName === "Account" ? " compact" : "";
121
- Clipboard.setStringAsync(
122
- `<${componentName} ${idProp}="${String(value)}"${compactProp} />`,
123
- );
134
+ if (!embed) return;
135
+ Clipboard.setStringAsync(embed);
124
136
  Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
125
137
  sheetRef.current?.dismiss();
126
- }, [appId, embedProp, embedType, embedValue, type]);
138
+ }, [embed]);
139
+
140
+ const { onQuoteEmbed } = presentation;
141
+ const handleQuote = useCallback(() => {
142
+ if (!embed || !onQuoteEmbed) return;
143
+ Haptics.selectionAsync();
144
+ sheetRef.current?.dismiss();
145
+ onQuoteEmbed(embed);
146
+ }, [embed, onQuoteEmbed]);
127
147
 
128
148
  const label = LABELS[type];
129
- const canCopyEmbed =
130
- !!embedType || type === "asset" || type === "account" || type === "tx";
149
+ const canCopyEmbed = !!embed;
131
150
 
132
151
  return (
133
152
  <>
@@ -234,6 +253,26 @@ export function ContractMenu({
234
253
  </View>
235
254
  </SquishyPressable>
236
255
  )}
256
+
257
+ {canCopyEmbed && onQuoteEmbed && (
258
+ <SquishyPressable onPress={handleQuote} pressedScale={0.98}>
259
+ <View
260
+ style={{
261
+ flexDirection: "row",
262
+ alignItems: "center",
263
+ gap: 12,
264
+ paddingVertical: 14,
265
+ paddingHorizontal: 8,
266
+ borderRadius: 12,
267
+ }}
268
+ >
269
+ <OutlineDocumentTextIcon size={18} color={theme.colors.text} />
270
+ <Text size="sm" weight="medium">
271
+ Quote
272
+ </Text>
273
+ </View>
274
+ </SquishyPressable>
275
+ )}
237
276
  </BottomSheetView>
238
277
  </AppPresentationProvider>
239
278
  </PortalProvider>
@@ -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 { Text } from "./runtime";
13
- import { useAppTheme } from "./runtime";
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 { AdaptiveImage } from "./AdaptiveImage";
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; when present it becomes the card's header. */
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
- data.maxEntries != null &&
266
- data.maxEntries > 0 &&
613
+ capacity != null &&
267
614
  data.entryCount != null &&
268
- data.entryCount >= data.maxEntries - 1;
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 = entryTargetClosed
274
- ? "Entries closed"
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
- : data.maxEntries != null && data.maxEntries > 0
280
- ? `${data.entryCount.toLocaleString()} of ${data.maxEntries.toLocaleString()} entries`
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 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"}`
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 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;
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 subtitle = [
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
- <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
- />
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
- <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>
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
- {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}
794
+ {action}
403
795
  </OnChainActionCard>
404
796
  );
405
797
  }
@@ -109,6 +109,11 @@ export interface AppPresentation {
109
109
  */
110
110
  applicationIcon?: (appId: string) => { Icon: React.ComponentType<{ size?: number; color?: string }>; color?: string } | undefined;
111
111
  onOpenNfd?: (name: string) => void;
112
+ /**
113
+ * Starts a new post that quotes an embed (e.g. `<ASA id="31566704" />`). Menus that offer
114
+ * Copy Embed also offer Quote when the host provides this.
115
+ */
116
+ onQuoteEmbed?: (embed: string) => void;
112
117
  onOpenCollection?: (id: string) => void;
113
118
  onOpenTransaction?: (txId: string) => void;
114
119
  /** Opens a contract reference (listing, auction, raffle, poll) in the host. */