@akita-protocol/algomd-rn 0.0.0-stage → 1.0.0-alpha.1

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 (138) 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 +280 -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/GuildProposalRef.tsx +285 -0
  104. package/src/refs/HostRefs.tsx +82 -0
  105. package/src/refs/ListingRef.tsx +90 -0
  106. package/src/refs/NfdRef.tsx +96 -0
  107. package/src/refs/PollRef.tsx +120 -0
  108. package/src/refs/RaffleRef.tsx +101 -0
  109. package/src/refs/RewardRef.tsx +78 -0
  110. package/src/refs/StakingPoolRef.tsx +136 -0
  111. package/src/refs/SubscriptionRef.tsx +200 -0
  112. package/src/refs/TradeRef.tsx +100 -0
  113. package/src/refs/TransactionRef.tsx +156 -0
  114. package/src/refs/assetInfo.ts +49 -0
  115. package/src/refs/contractParts.tsx +159 -0
  116. package/src/refs/index.tsx +140 -0
  117. package/src/refs/primitives.tsx +588 -0
  118. package/src/refs/types.ts +13 -0
  119. package/src/types/algorand.ts +496 -0
  120. package/src/types/index.ts +1 -0
  121. package/src/ui/CopyButton.tsx +44 -0
  122. package/src/ui/DataStates.tsx +45 -0
  123. package/src/ui/ProgressBar.tsx +64 -0
  124. package/src/ui/SearchSheet.tsx +141 -0
  125. package/src/ui/SizeContainer.tsx +25 -0
  126. package/src/ui/StatusBadge.tsx +51 -0
  127. package/src/ui/index.ts +6 -0
  128. package/src/utils/algomdImageUrl.ts +20 -0
  129. package/src/utils/arc19.ts +120 -0
  130. package/src/utils/arc62.ts +246 -0
  131. package/src/utils/capacity.ts +26 -0
  132. package/src/utils/format.ts +181 -0
  133. package/src/utils/ids.ts +31 -0
  134. package/src/utils/index.ts +6 -0
  135. package/src/utils/nfdDisplay.ts +45 -0
  136. package/src/utils/search.ts +87 -0
  137. package/src/utils/stakingPool.ts +174 -0
  138. package/src/utils/stakingSnapshot.ts +132 -0
@@ -0,0 +1,142 @@
1
+ import React from "react";
2
+ import { View } from "react-native";
3
+ import { formatAmount, type AssetData } from "@akita-protocol/algomd-core";
4
+ import { AdaptiveImage } from "../presentation/AdaptiveImage";
5
+ import { ContractMenu } from "../presentation/ContractMenu";
6
+ import { Text, useAppTheme, usePresentation } from "../presentation/runtime";
7
+ import { CircleStackIcon } from "../presentation/icons";
8
+ import { useAssetInfo } from "./assetInfo";
9
+ import { AccountRef, PersonRow } from "./AccountRef";
10
+ import {
11
+ Avatar,
12
+ Card,
13
+ CardHeader,
14
+ CardSkeleton,
15
+ DetailLine,
16
+ headerMedia,
17
+ InlinePill,
18
+ Note,
19
+ Row,
20
+ RowSkeleton,
21
+ Stat,
22
+ StatRow,
23
+ StatusBadge,
24
+ Title,
25
+ Unavailable,
26
+ useImageUrl,
27
+ } from "./primitives";
28
+ import type { RefViewProps } from "./types";
29
+
30
+ const label = (a: AssetData | undefined, id: string) => a?.unitName || a?.name || `ASA ${id}`;
31
+ const isCollectible = (a: AssetData) => a.decimals === 0 && a.total === "1";
32
+
33
+ /** An asset (ASA) at any size. */
34
+ export function AssetRef({ id, size = "large", onPress, visible }: RefViewProps) {
35
+ const presentation = usePresentation();
36
+ const { data, image, pending, error } = useAssetInfo(id, visible);
37
+ const press = onPress ?? (presentation.onOpenAsset ? () => presentation.onOpenAsset!(id) : undefined);
38
+ const name = label(data, id);
39
+
40
+ if (size === "inline") {
41
+ return (
42
+ <InlinePill
43
+ label={name}
44
+ dim={pending}
45
+ leading={<Avatar uri={image} size={16} shape="rounded" initial={name} />}
46
+ onPress={press}
47
+ accessibilityLabel={`Open ${name}`}
48
+ />
49
+ );
50
+ }
51
+
52
+ if (size === "small") {
53
+ if (pending) return <RowSkeleton shape="rounded" />;
54
+ if (!data) return <Unavailable size="small" label={`ASA ${id}`} Icon={CircleStackIcon} detail={error ? "Couldn't load this asset." : undefined} />;
55
+ return (
56
+ <Row
57
+ leading={<Avatar uri={image} size={36} shape="rounded" initial={name} />}
58
+ title={<Title>{data.name || name}</Title>}
59
+ subtitle={[data.unitName, id === "0" ? undefined : `ASA ${id}`].filter(Boolean).join(" · ")}
60
+ trailing={isCollectible(data) ? <StatusBadge label="NFT" /> : undefined}
61
+ onPress={press}
62
+ accessibilityLabel={`Open ${name}`}
63
+ />
64
+ );
65
+ }
66
+
67
+ return <AssetCard id={id} full={size === "full"} visible={visible} />;
68
+ }
69
+
70
+ function AssetCard({ id, full, visible }: { id: string; full: boolean; visible?: boolean }) {
71
+ const { theme } = useAppTheme();
72
+ const { data, image, media, pending, archived, error } = useAssetInfo(id, visible);
73
+ const hero = useImageUrl(image, 600);
74
+
75
+ if (pending) return <CardSkeleton media="rounded" blocks={1} full={full} />;
76
+ if (!data) return <Unavailable size={full ? "full" : "large"} label={`ASA ${id}`} Icon={CircleStackIcon} detail={error ? "Couldn't load this asset." : undefined} />;
77
+
78
+ const name = data.name || label(data, id);
79
+ const supply = formatAmount(data.total, data.decimals, { maxFraction: 2 });
80
+ const collectible = isCollectible(data);
81
+ const showHero = full && hero;
82
+ const url = data.url && /^https?:\/\//.test(data.url) ? data.url : undefined;
83
+
84
+ return (
85
+ <Card style={showHero ? { padding: 0, gap: 0 } : undefined}>
86
+ {showHero ? <AdaptiveImage uri={hero} assetId={id} maxHeight={360} /> : null}
87
+ <View style={{ gap: 16, padding: showHero ? 16 : 0 }}>
88
+ <CardHeader
89
+ media={showHero ? null : <Avatar uri={image} size={headerMedia(full)} shape="rounded" initial={name} />}
90
+ title={name}
91
+ full={full}
92
+ status={archived ? <StatusBadge label="Destroyed" tone="bad" /> : collectible ? <StatusBadge label="NFT" /> : undefined}
93
+ meta={[data.unitName, id === "0" ? "Native asset" : `ASA ${id}`].filter(Boolean).join(" · ")}
94
+ menu={id === "0" ? null : <ContractMenu appId={id} type="asset" embedType="ASA" />}
95
+ />
96
+
97
+ {collectible ? null : (
98
+ <StatRow>
99
+ <Stat label="Supply">{`${supply} ${data.unitName ?? ""}`.trim()}</Stat>
100
+ <Stat label="Decimals" align="right">{String(data.decimals)}</Stat>
101
+ </StatRow>
102
+ )}
103
+
104
+ {data.creator ? <PersonRow address={data.creator} role="Creator" visible={visible} /> : null}
105
+
106
+ {media?.metadataVerified === false ? <Note tone="bad">Its metadata does not match the hash stored on chain.</Note> : null}
107
+
108
+ {full && media?.description ? (
109
+ <Text size="sm" style={{ color: theme.colors.textDim }}>
110
+ {media.description}
111
+ </Text>
112
+ ) : null}
113
+
114
+ {full ? (
115
+ <View>
116
+ <Role label="Manager" address={data.manager} />
117
+ <Role label="Reserve" address={data.reserve} />
118
+ <Role label="Freeze" address={data.freeze} />
119
+ <Role label="Clawback" address={data.clawback} />
120
+ {collectible ? <DetailLine label="Supply">{supply}</DetailLine> : null}
121
+ {url ? <DetailLine label="Website">{url.replace(/^https?:\/\//, "")}</DetailLine> : null}
122
+ {media && media.standard !== "none" ? (
123
+ <DetailLine label="Metadata">
124
+ {media.standard === "arc3" || media.standard === "arc19"
125
+ ? `${media.standard.toUpperCase()}${media.metadataVerified ? " · verified" : ""}`
126
+ : media.standard.toUpperCase()}
127
+ </DetailLine>
128
+ ) : null}
129
+ </View>
130
+ ) : null}
131
+ </View>
132
+ </Card>
133
+ );
134
+ }
135
+
136
+ function Role({ label: roleLabel, address }: { label: string; address?: string }) {
137
+ return (
138
+ <DetailLine label={roleLabel}>
139
+ {address ? <AccountRef id={address} size="inline" /> : "None"}
140
+ </DetailLine>
141
+ );
142
+ }
@@ -0,0 +1,108 @@
1
+ import React from "react";
2
+ import { View } from "react-native";
3
+ import { formatRelativeTime, type AuctionData } from "@akita-protocol/algomd-core";
4
+ import { useAuction } from "@akita-protocol/algomd-core/react";
5
+ import { ContractMenu } from "../presentation/ContractMenu";
6
+ import { HandRaisedIcon } from "../presentation/icons";
7
+ import { usePresentation } from "../presentation/runtime";
8
+ import { AccountRef, PersonRow } from "./AccountRef";
9
+ import { useFormattedAmount } from "./assetInfo";
10
+ import { ActionButton, Amount, plural, PriceBlock, PrizeThumb, ProvenanceNote, StatusChip, timeLeft, useNow, usePrizeLabel } from "./contractParts";
11
+ import { Card, CardHeader, CardSkeleton, DetailLine, headerMedia, InlinePill, Inset, Note, Row, RowSkeleton, Section, Title, Unavailable } from "./primitives";
12
+ import type { RefViewProps } from "./types";
13
+
14
+ /** An auction: live state, or its final state and full bid history after deletion. */
15
+ export function AuctionRef({ id, size = "large", onPress, visible }: RefViewProps) {
16
+ const presentation = usePresentation();
17
+ const auction = useAuction(id, { visible });
18
+ const data = auction.data?.data as AuctionData | undefined;
19
+ const live = data?.status === "live" || data?.status === "upcoming";
20
+ const now = useNow(1000, live && size !== "inline");
21
+ const prizeName = usePrizeLabel(data?.prize, data?.isPrizeBox);
22
+ const hasBids = Number(data?.bidCount ?? 0) > 0;
23
+ const shown = useFormattedAmount(hasBids ? data?.highestBid : data?.startingBid, data?.bidAsset);
24
+ const press = onPress ?? (presentation.onOpenContract ? () => presentation.onOpenContract!("auction", id) : undefined);
25
+ const bid = presentation.actions?.bid;
26
+ const retry = auction.isError ? () => void auction.refetch() : undefined;
27
+
28
+ if (size === "inline") {
29
+ return (
30
+ <InlinePill
31
+ label={data ? `${prizeName} · ${shown}` : `Auction ${id}`}
32
+ dim={auction.isPending}
33
+ leading={data ? <PrizeThumb prize={data.prize} isPrizeBox={data.isPrizeBox} size={16} /> : null}
34
+ onPress={press}
35
+ />
36
+ );
37
+ }
38
+
39
+ if (size === "small") {
40
+ if (auction.isPending) return <RowSkeleton shape="rounded" />;
41
+ if (!data) return <Unavailable size="small" label={`Auction ${id}`} Icon={HandRaisedIcon} onRetry={retry} />;
42
+ const end = Number(data.endTimestamp);
43
+ return (
44
+ <Row
45
+ leading={<PrizeThumb prize={data.prize} isPrizeBox={data.isPrizeBox} size={40} />}
46
+ title={<Title>{prizeName}</Title>}
47
+ subtitle={`${hasBids ? (live ? "Highest bid" : "Won for") : "Starts at"} ${shown}${live ? ` · ends ${formatRelativeTime(end, now)}` : ""}`}
48
+ trailing={<StatusChip status={data.status} />}
49
+ onPress={press}
50
+ accessibilityLabel={`Open auction for ${prizeName}`}
51
+ />
52
+ );
53
+ }
54
+
55
+ const full = size === "full";
56
+ if (auction.isPending) return <CardSkeleton media="rounded" value blocks={1} action full={full} />;
57
+ if (!data) return <Unavailable size={size} label={`Auction ${id}`} Icon={HandRaisedIcon} onRetry={retry} />;
58
+ const allBids = data.bids ?? [];
59
+ const bids = allBids.slice(-10).reverse();
60
+
61
+ return (
62
+ <Card>
63
+ <CardHeader
64
+ media={<PrizeThumb prize={data.prize} isPrizeBox={data.isPrizeBox} size={headerMedia(full)} />}
65
+ title={prizeName}
66
+ full={full}
67
+ status={<StatusChip status={data.status} />}
68
+ meta={timeLeft(Number(data.endTimestamp), Number(data.startTimestamp), now)}
69
+ menu={<ContractMenu appId={id} type="application" embedType="AuctionListing" />}
70
+ />
71
+
72
+ <PriceBlock
73
+ label={hasBids ? (live ? "Highest bid" : "Winning bid") : "Starting bid"}
74
+ amount={hasBids ? data.highestBid : data.startingBid}
75
+ assetId={data.bidAsset}
76
+ caption={hasBids ? `${plural(data.bidCount, "bid")} from ${plural(data.uniqueBidders || 1, "bidder")}` : "No bids yet"}
77
+ live={data.status === "live"}
78
+ />
79
+
80
+ <View style={{ gap: 8 }}>
81
+ {data.highestBidder ? (
82
+ <PersonRow address={data.highestBidder} role={live ? "Leading" : "Winner"} roleTone={live ? undefined : "good"} visible={visible} />
83
+ ) : null}
84
+ {full || !data.highestBidder ? <PersonRow address={data.seller} role="Seller" visible={visible} /> : null}
85
+ {full && data.raffleWinner ? <PersonRow address={data.raffleWinner} role="Won the bid-fee raffle" visible={visible} /> : null}
86
+ </View>
87
+
88
+ {full && bids.length ? (
89
+ <Section label="Latest bids">
90
+ <Inset>
91
+ {bids.map((b, i) => (
92
+ <DetailLine key={`${b.round}-${i}`} label={i === 0 && live ? "Top" : `#${allBids.length - i}`}>
93
+ <View style={{ flexDirection: "row", alignItems: "center", flexWrap: "wrap", justifyContent: "flex-end", gap: 6 }}>
94
+ <AccountRef id={b.bidder} size="inline" />
95
+ <Amount amount={b.amount} assetId={data.bidAsset} size="xs" />
96
+ </View>
97
+ </DetailLine>
98
+ ))}
99
+ </Inset>
100
+ </Section>
101
+ ) : null}
102
+
103
+ <ProvenanceNote entity={auction.data} />
104
+ {data.status === "live" && bid ? <ActionButton label="Place a bid" onPress={() => bid(id)} /> : null}
105
+ {data.bidFee !== "0" && live ? <Note>Losing bids share a bid-fee raffle.</Note> : null}
106
+ </Card>
107
+ );
108
+ }
@@ -0,0 +1,70 @@
1
+ import React from "react";
2
+ import { View } from "react-native";
3
+ import { useCollection } from "@akita-protocol/algomd-core/react";
4
+ import { AdaptiveImage } from "../presentation/AdaptiveImage";
5
+ import { Squares2X2Icon } from "../presentation/icons";
6
+ import { Text, useAppTheme, usePresentation } from "../presentation/runtime";
7
+ import { useAssetInfo } from "./assetInfo";
8
+ import { Avatar, Card, CardHeader, CardSkeleton, headerMedia, InlinePill, Row, RowSkeleton, StatusBadge, Title, Unavailable, useImageUrl } from "./primitives";
9
+ import type { RefViewProps } from "./types";
10
+
11
+ /**
12
+ * An NFT collection. The record comes from a resolver; its avatar and banner
13
+ * are assets, so their images resolve and verify like any asset's.
14
+ */
15
+ export function CollectionRef({ id, size = "large", onPress, visible }: RefViewProps) {
16
+ const { theme } = useAppTheme();
17
+ const presentation = usePresentation();
18
+ const collection = useCollection(id, { visible });
19
+ const data = collection.data?.data;
20
+ const avatar = useAssetInfo(data?.avatarAssetId, visible);
21
+ const banner = useAssetInfo(size === "full" ? data?.bannerAssetId : undefined, visible);
22
+ const bannerUrl = useImageUrl(banner.image, 600);
23
+ const name = data?.name ?? "Collection";
24
+ const press = onPress ?? (presentation.onOpenCollection ? () => presentation.onOpenCollection!(id) : undefined);
25
+ const retry = collection.isError ? () => void collection.refetch() : undefined;
26
+
27
+ if (size === "inline") {
28
+ return <InlinePill label={name} dim={collection.isPending} leading={<Avatar uri={avatar.image} size={16} shape="rounded" initial={name} />} onPress={press} />;
29
+ }
30
+
31
+ if (size === "small") {
32
+ if (collection.isPending) return <RowSkeleton shape="rounded" />;
33
+ if (!data) return <Unavailable size="small" label="Collection" Icon={Squares2X2Icon} onRetry={retry} />;
34
+ return (
35
+ <Row
36
+ leading={<Avatar uri={avatar.image} size={36} shape="rounded" initial={name} />}
37
+ title={<Title>{name}</Title>}
38
+ subtitle={data.description}
39
+ trailing={data.explicit ? <StatusBadge label="Explicit" tone="warn" /> : undefined}
40
+ onPress={press}
41
+ accessibilityLabel={`Open ${name}`}
42
+ />
43
+ );
44
+ }
45
+
46
+ const full = size === "full";
47
+ if (collection.isPending) return <CardSkeleton media="rounded" full={full} blocks={0} />;
48
+ if (!data) return <Unavailable size={size} label="Collection" Icon={Squares2X2Icon} onRetry={retry} />;
49
+ const showBanner = full && bannerUrl;
50
+
51
+ return (
52
+ <Card style={showBanner ? { padding: 0, gap: 0 } : undefined}>
53
+ {showBanner ? <AdaptiveImage uri={bannerUrl} assetId={data.bannerAssetId} maxHeight={220} /> : null}
54
+ <View style={{ gap: 12, padding: showBanner ? 16 : 0 }}>
55
+ <CardHeader
56
+ media={<Avatar uri={avatar.image} size={headerMedia(full)} shape="rounded" initial={name} />}
57
+ title={name}
58
+ full={full}
59
+ status={data.explicit ? <StatusBadge label="Explicit" tone="warn" /> : undefined}
60
+ meta="Collection"
61
+ />
62
+ {data.description ? (
63
+ <Text size="sm" numberOfLines={full ? undefined : 3} style={{ color: theme.colors.textDim }}>
64
+ {data.description}
65
+ </Text>
66
+ ) : null}
67
+ </View>
68
+ </Card>
69
+ );
70
+ }
@@ -0,0 +1,88 @@
1
+ import React from "react";
2
+ import { View } from "react-native";
3
+ import { formatAlgo } from "@akita-protocol/algomd-core";
4
+ import { useDualStake } from "@akita-protocol/algomd-core/react";
5
+ import { ContractMenu } from "../presentation/ContractMenu";
6
+ import { BanknotesIcon } from "../presentation/icons";
7
+ import { useAppTheme, usePresentation } from "../presentation/runtime";
8
+ import { AssetRef } from "./AssetRef";
9
+ import { useAssetInfo, useFormattedAmount } from "./assetInfo";
10
+ import { ActionButton, PriceBlock, StatusChip } from "./contractParts";
11
+ import { Card, CardHeader, CardSkeleton, DetailLine, headerMedia, InlinePill, KindTile, Row, RowSkeleton, Stat, StatRow, Title, Unavailable } from "./primitives";
12
+ import type { RefViewProps } from "./types";
13
+
14
+ /** A dualSTAKE pool (an external contract): stake ALGO, earn ALGO and a paired asset. */
15
+ export function DualStakeRef({ id, size = "large", onPress, visible }: RefViewProps) {
16
+ const { theme } = useAppTheme();
17
+ const presentation = usePresentation();
18
+ const pool = useDualStake(id, { visible });
19
+ const data = pool.data?.data ?? undefined;
20
+ const paired = useFormattedAmount(data?.asaBalance, data?.pairedAssetId);
21
+ const pairedInfo = useAssetInfo(data?.pairedAssetId);
22
+ const mint = presentation.actions?.dualStakeMint;
23
+ const redeem = presentation.actions?.dualStakeRedeem;
24
+ const title = data?.name || `dualSTAKE ${id}`;
25
+ const retry = pool.isError ? () => void pool.refetch() : undefined;
26
+ const status = data?.isOnline === false ? "offline" : "online";
27
+
28
+ if (size === "inline") return <InlinePill label={title} dim={pool.isPending} leading={<BanknotesIcon size={12} color={theme.colors.primary} />} onPress={onPress} />;
29
+
30
+ if (size === "small") {
31
+ if (pool.isPending) return <RowSkeleton shape="rounded" />;
32
+ if (!data) return <Unavailable size="small" label={title} Icon={BanknotesIcon} onRetry={retry} />;
33
+ return (
34
+ <Row
35
+ leading={<KindTile Icon={BanknotesIcon} size={40} />}
36
+ title={<Title>{title}</Title>}
37
+ subtitle={data.staked ? `${formatAlgo(data.staked, { maxFraction: 0 })} ALGO staked` : undefined}
38
+ trailing={data.isOnline === false ? <StatusChip status="offline" /> : undefined}
39
+ onPress={onPress}
40
+ accessibilityLabel={`Open ${title}`}
41
+ />
42
+ );
43
+ }
44
+
45
+ const full = size === "full";
46
+ if (pool.isPending) return <CardSkeleton media="rounded" value blocks={1} action full={full} />;
47
+ if (!data) return <Unavailable size={size} label={title} Icon={BanknotesIcon} onRetry={retry} />;
48
+
49
+ return (
50
+ <Card>
51
+ <CardHeader
52
+ media={<KindTile Icon={BanknotesIcon} size={headerMedia(full)} />}
53
+ title={title}
54
+ full={full}
55
+ status={<StatusChip status={status} />}
56
+ meta={`Pool #${id}`}
57
+ menu={<ContractMenu appId={id} type="application" embedType="DualStakePool" />}
58
+ />
59
+ {data.staked ? <PriceBlock label="Total staked" amount={data.staked} assetId="0" /> : null}
60
+ <StatRow>
61
+ <Stat label="ALGO liquidity">{data.algoBalance ? formatAlgo(data.algoBalance, { maxFraction: 0 }) : "—"}</Stat>
62
+ <Stat label={`${pairedInfo.label} liquidity`} align="right">{data.asaBalance ? paired : "—"}</Stat>
63
+ </StatRow>
64
+ <View>
65
+ <DetailLine label="Also earns">
66
+ <AssetRef id={data.pairedAssetId} size="inline" />
67
+ </DetailLine>
68
+ <DetailLine label="You receive">
69
+ <AssetRef id={data.lstAssetId} size="inline" />
70
+ </DetailLine>
71
+ </View>
72
+ {mint || redeem ? (
73
+ <View style={{ flexDirection: "row", gap: 8 }}>
74
+ {mint ? (
75
+ <View style={{ flex: 1 }}>
76
+ <ActionButton label="Stake" onPress={() => mint(id)} />
77
+ </View>
78
+ ) : null}
79
+ {redeem ? (
80
+ <View style={{ flex: 1 }}>
81
+ <ActionButton label="Redeem" variant={mint ? "secondary" : "primary"} onPress={() => redeem(id)} />
82
+ </View>
83
+ ) : null}
84
+ </View>
85
+ ) : null}
86
+ </Card>
87
+ );
88
+ }