@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,21 @@
1
+ // Shared AlgoMD presentation. Edit this library source.
2
+ import React, { type ReactNode } from "react";
3
+ import Animated, {
4
+ Easing,
5
+ FadeInDown,
6
+ useReducedMotion,
7
+ } from "react-native-reanimated";
8
+
9
+ const ENTER = FadeInDown.duration(200)
10
+ .easing(Easing.bezier(0.215, 0.61, 0.355, 1).factory())
11
+ .withInitialValues({ opacity: 0, transform: [{ translateY: 8 }] });
12
+
13
+ /** Fades a card up 8px once when it mounts in the feed. Off under reduced motion. */
14
+ export function CardEntrance({ children }: { children: ReactNode }) {
15
+ const reduceMotion = useReducedMotion();
16
+ return (
17
+ <Animated.View entering={reduceMotion ? undefined : ENTER}>
18
+ {children}
19
+ </Animated.View>
20
+ );
21
+ }
@@ -0,0 +1,168 @@
1
+ import React from "react";
2
+ import { View, Image } from "react-native";
3
+ import { IdentityResolver, Text, useAppTheme } from "./runtime";
4
+ import { CubeIcon, ChevronRightIcon } from "./icons";
5
+ import { CompactPillWithImage, NavigableBlock } from "./References";
6
+ import { formatAddress } from "../utils/format";
7
+ import type { Collection } from "../types/algorand";
8
+ export interface CollectionDisplayProps {
9
+ data: Collection;
10
+ imageUrl?: string;
11
+ compact?: boolean;
12
+ onPress?: () => void;
13
+ }
14
+
15
+ /** "By [avatar] krby", or "… and 2 others" when several artists share the collection. */
16
+ function ArtistsLine({ artists }: { artists: readonly string[] }) {
17
+ const { theme } = useAppTheme();
18
+ const others = artists.length - 1;
19
+ return (
20
+ <IdentityResolver address={artists[0]}>
21
+ {(identity) => (
22
+ <View style={{ flexDirection: "row", alignItems: "center", gap: 5 }}>
23
+ <Text size="xs" style={{ color: theme.colors.textDim }}>
24
+ By
25
+ </Text>
26
+ {identity.avatarUrl ? (
27
+ <Image
28
+ source={{ uri: identity.avatarUrl }}
29
+ style={{ width: 16, height: 16, borderRadius: 8 }}
30
+ />
31
+ ) : null}
32
+ <Text size="xs" numberOfLines={1} style={{ color: theme.colors.textDim, flexShrink: 1 }}>
33
+ <Text size="xs" weight="medium" style={{ color: theme.colors.text }}>
34
+ {identity.name || formatAddress(artists[0])}
35
+ </Text>
36
+ {others > 0 ? ` and ${others} ${others === 1 ? "other" : "others"}` : ""}
37
+ </Text>
38
+ </View>
39
+ )}
40
+ </IdentityResolver>
41
+ );
42
+ }
43
+
44
+ export function CollectionDisplay({
45
+ data,
46
+ imageUrl = data.avatarUrl,
47
+ compact,
48
+ onPress,
49
+ }: CollectionDisplayProps) {
50
+ const { theme } = useAppTheme();
51
+ if (compact)
52
+ return (
53
+ <CompactPillWithImage
54
+ label={data.name}
55
+ imageUrl={imageUrl}
56
+ onPress={onPress}
57
+ />
58
+ );
59
+ const votes = Math.abs(data.voteCount || 0);
60
+ // A zero score says nothing; only show community votes once there are some.
61
+ const voteLabel = votes
62
+ ? `${data.isNegative ? "−" : "+"}${votes.toLocaleString()}`
63
+ : null;
64
+ const artists = data.artists?.filter(Boolean) ?? [];
65
+
66
+ return (
67
+ <NavigableBlock
68
+ accessibilityLabel={`Open ${data.name || "collection"}`}
69
+ onPress={onPress}
70
+ >
71
+ <View
72
+ style={{
73
+ alignItems: "center",
74
+ alignSelf: "stretch",
75
+ backgroundColor: theme.colors.accentBackground,
76
+ borderCurve: "continuous",
77
+ borderRadius: 20,
78
+ flexDirection: "row",
79
+ gap: 12,
80
+ padding: 16,
81
+ width: "100%",
82
+ }}
83
+ >
84
+ <View
85
+ style={{
86
+ alignItems: "center",
87
+ alignSelf: "flex-start",
88
+ backgroundColor: `${theme.colors.primary}14`,
89
+ borderCurve: "continuous",
90
+ borderRadius: 14,
91
+ height: 56,
92
+ justifyContent: "center",
93
+ overflow: "hidden",
94
+ width: 56,
95
+ }}
96
+ >
97
+ {imageUrl ? (
98
+ <Image
99
+ source={{ uri: imageUrl }}
100
+ style={{ height: 56, width: 56 }}
101
+ resizeMode="cover"
102
+ />
103
+ ) : (
104
+ <CubeIcon size={24} color={theme.colors.primary} />
105
+ )}
106
+ </View>
107
+ <View style={{ flex: 1, minWidth: 0, gap: 3 }}>
108
+ <View style={{ flexDirection: "row", alignItems: "center", gap: 6 }}>
109
+ <Text
110
+ size="sm"
111
+ weight="semiBold"
112
+ numberOfLines={1}
113
+ style={{ color: theme.colors.text, flexShrink: 1 }}
114
+ >
115
+ {data.name || data.id}
116
+ </Text>
117
+ {data.explicit ? (
118
+ <View
119
+ accessibilityLabel="Mature content"
120
+ style={{
121
+ borderColor: theme.colors.warningText,
122
+ borderRadius: 6,
123
+ borderWidth: 1,
124
+ flexShrink: 0,
125
+ paddingHorizontal: 5,
126
+ paddingVertical: 1,
127
+ }}
128
+ >
129
+ <Text size="xxs" weight="semiBold" style={{ color: theme.colors.warningText }}>
130
+ Mature
131
+ </Text>
132
+ </View>
133
+ ) : null}
134
+ <View style={{ flex: 1 }} />
135
+ {voteLabel ? (
136
+ <Text
137
+ size="xs"
138
+ weight="semiBold"
139
+ accessibilityLabel={`${data.isNegative ? "Minus" : "Plus"} ${votes} community votes`}
140
+ style={{
141
+ color: data.isNegative
142
+ ? theme.colors.textDim
143
+ : theme.colors.primary,
144
+ flexShrink: 0,
145
+ }}
146
+ >
147
+ {voteLabel}
148
+ </Text>
149
+ ) : null}
150
+ </View>
151
+ {artists.length ? <ArtistsLine artists={artists} /> : null}
152
+ {data.description ? (
153
+ <Text
154
+ size="xs"
155
+ numberOfLines={1}
156
+ style={{ color: theme.colors.textDim, marginTop: 2 }}
157
+ >
158
+ {data.description}
159
+ </Text>
160
+ ) : null}
161
+ </View>
162
+ {onPress ? (
163
+ <ChevronRightIcon size={18} color={theme.colors.textDim} />
164
+ ) : null}
165
+ </View>
166
+ </NavigableBlock>
167
+ );
168
+ }
@@ -0,0 +1,243 @@
1
+ import React, { useCallback, useEffect, useRef } from "react";
2
+ import { Pressable, View } from "react-native";
3
+ import {
4
+ BottomSheetModal,
5
+ BottomSheetBackdrop,
6
+ BottomSheetView,
7
+ } from "./sheets";
8
+ import {
9
+ EllipsisVerticalIcon,
10
+ ArrowTopRightOnSquareIcon,
11
+ Square2StackIcon,
12
+ } from "./icons";
13
+ import * as Clipboard from "expo-clipboard";
14
+ import * as Haptics from "expo-haptics";
15
+ import { Text } from "./runtime";
16
+ import { SquishyPressable } from "./SquishyPressable";
17
+ import {
18
+ useAppTheme,
19
+ usePresentation,
20
+ AppPresentationProvider,
21
+ useOpenExplorer,
22
+ } from "./runtime";
23
+ const DEFAULT_SPRING = {
24
+ damping: 70,
25
+ stiffness: 900,
26
+ mass: 2,
27
+ overshootClamping: false,
28
+ };
29
+
30
+ type EntityType = "application" | "asset" | "account" | "tx";
31
+ type EmbedType =
32
+ | "Account"
33
+ | "ASA"
34
+ | "AuctionListing"
35
+ | "DualStakePool"
36
+ | "NFTListing"
37
+ | "NFDProfile"
38
+ | "Poll"
39
+ | "RaffleListing"
40
+ | "StakingPool"
41
+ | "TradeOffer"
42
+ | "Transaction";
43
+
44
+ export interface ContractMenuProps {
45
+ appId: string | number;
46
+ /** Explorer entity type — determines the URL path segment. Default: "application" */
47
+ type?: EntityType;
48
+ /** AlgoMD component name for copying a pasteable embed tag. */
49
+ embedType?: EmbedType;
50
+ /** Override the copied prop name when it differs from the explorer entity ID. */
51
+ embedProp?: string;
52
+ /** Override the copied prop value, for example an NFD name. */
53
+ embedValue?: string | number;
54
+ }
55
+
56
+ const LABELS: Record<EntityType, string> = {
57
+ application: "Contract",
58
+ asset: "Asset",
59
+ account: "Account",
60
+ tx: "Transaction",
61
+ };
62
+
63
+ export function ContractMenu({
64
+ appId,
65
+ type = "application",
66
+ embedType,
67
+ embedProp,
68
+ embedValue,
69
+ }: ContractMenuProps) {
70
+ const { theme } = useAppTheme();
71
+ const presentation = usePresentation();
72
+ const PortalProvider =
73
+ presentation.components?.PortalProvider ?? React.Fragment;
74
+ const openExplorer = useOpenExplorer();
75
+ const sheetRef = useRef<BottomSheetModal>(null);
76
+ useEffect(() => {
77
+ const sheet = sheetRef.current;
78
+ return () => sheet?.dismiss();
79
+ }, []);
80
+
81
+ const handleOpen = useCallback(() => {
82
+ Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
83
+ sheetRef.current?.present();
84
+ }, []);
85
+
86
+ const handleViewExplorer = useCallback(() => {
87
+ sheetRef.current?.dismiss();
88
+ openExplorer(`${type}/${appId}`);
89
+ }, [type, appId, openExplorer]);
90
+
91
+ const handleCopyId = useCallback(() => {
92
+ Clipboard.setStringAsync(String(appId));
93
+ Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
94
+ sheetRef.current?.dismiss();
95
+ }, [appId]);
96
+
97
+ 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
+ );
124
+ Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
125
+ sheetRef.current?.dismiss();
126
+ }, [appId, embedProp, embedType, embedValue, type]);
127
+
128
+ const label = LABELS[type];
129
+ const canCopyEmbed =
130
+ !!embedType || type === "asset" || type === "account" || type === "tx";
131
+
132
+ return (
133
+ <>
134
+ <Pressable
135
+ accessibilityLabel={`More ${LABELS[type].toLowerCase()} actions`}
136
+ accessibilityRole="button"
137
+ onPress={handleOpen}
138
+ hitSlop={8}
139
+ >
140
+ <EllipsisVerticalIcon size={16} color={theme.colors.textDim} />
141
+ </Pressable>
142
+ <BottomSheetModal
143
+ ref={sheetRef}
144
+ enableDynamicSizing
145
+ backgroundStyle={{ backgroundColor: theme.colors.background }}
146
+ handleIndicatorStyle={{ backgroundColor: theme.colors.border }}
147
+ animationConfigs={DEFAULT_SPRING}
148
+ backdropComponent={(
149
+ props: React.ComponentProps<typeof BottomSheetBackdrop>,
150
+ ) => (
151
+ <BottomSheetBackdrop
152
+ {...props}
153
+ appearsOnIndex={0}
154
+ disappearsOnIndex={-1}
155
+ pressBehavior="close"
156
+ />
157
+ )}
158
+ >
159
+ <PortalProvider>
160
+ <AppPresentationProvider {...presentation}>
161
+ <BottomSheetView
162
+ style={{ paddingHorizontal: 16, paddingBottom: 40, gap: 2 }}
163
+ >
164
+ <Text
165
+ size="xs"
166
+ weight="semiBold"
167
+ style={{
168
+ color: theme.colors.textDim,
169
+ marginBottom: 8,
170
+ paddingHorizontal: 8,
171
+ }}
172
+ >
173
+ {label}
174
+ </Text>
175
+
176
+ <SquishyPressable
177
+ onPress={handleViewExplorer}
178
+ pressedScale={0.98}
179
+ >
180
+ <View
181
+ style={{
182
+ flexDirection: "row",
183
+ alignItems: "center",
184
+ gap: 12,
185
+ paddingVertical: 14,
186
+ paddingHorizontal: 8,
187
+ borderRadius: 12,
188
+ }}
189
+ >
190
+ <ArrowTopRightOnSquareIcon
191
+ size={18}
192
+ color={theme.colors.text}
193
+ />
194
+ <Text size="sm" weight="medium">
195
+ View on Explorer
196
+ </Text>
197
+ </View>
198
+ </SquishyPressable>
199
+
200
+ <SquishyPressable onPress={handleCopyId} pressedScale={0.98}>
201
+ <View
202
+ style={{
203
+ flexDirection: "row",
204
+ alignItems: "center",
205
+ gap: 12,
206
+ paddingVertical: 14,
207
+ paddingHorizontal: 8,
208
+ borderRadius: 12,
209
+ }}
210
+ >
211
+ <Square2StackIcon size={18} color={theme.colors.text} />
212
+ <Text size="sm" weight="medium">
213
+ Copy {label} ID
214
+ </Text>
215
+ </View>
216
+ </SquishyPressable>
217
+
218
+ {canCopyEmbed && (
219
+ <SquishyPressable onPress={handleCopyEmbed} pressedScale={0.98}>
220
+ <View
221
+ style={{
222
+ flexDirection: "row",
223
+ alignItems: "center",
224
+ gap: 12,
225
+ paddingVertical: 14,
226
+ paddingHorizontal: 8,
227
+ borderRadius: 12,
228
+ }}
229
+ >
230
+ <Square2StackIcon size={18} color={theme.colors.text} />
231
+ <Text size="sm" weight="medium">
232
+ Copy Embed
233
+ </Text>
234
+ </View>
235
+ </SquishyPressable>
236
+ )}
237
+ </BottomSheetView>
238
+ </AppPresentationProvider>
239
+ </PortalProvider>
240
+ </BottomSheetModal>
241
+ </>
242
+ );
243
+ }