@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,40 @@
1
+ import { isCompactReference, type ReferenceVariantProps } from "../presentation/variants";
2
+ import { CompactPillWithImage } from "../presentation/References";
3
+ import React from "react";
4
+ import {
5
+ AuctionListingDisplay,
6
+ type AuctionListingDisplayProps,
7
+ } from "../presentation/AuctionListingDisplay";
8
+ import type { ComponentSize } from "../types/algorand";
9
+ import { SizeContainer } from "../ui/SizeContainer";
10
+ export interface AuctionListingProps extends AuctionListingDisplayProps, ReferenceVariantProps {
11
+ size?: ComponentSize;
12
+ className?: string;
13
+ showBidButton?: boolean;
14
+ }
15
+ export function AuctionListingComponent({
16
+ size = "full",
17
+ className,
18
+ compact,
19
+ inline,
20
+ data,
21
+ imageUrl,
22
+ showBidButton = true,
23
+ onBid,
24
+ ...display
25
+ }: AuctionListingProps) {
26
+ if (isCompactReference({ size, compact, inline })) return <CompactPillWithImage label={data.title} imageUrl={imageUrl ?? data.prizes[0]?.imageUrl} inline={inline} />;
27
+ const card = (
28
+ <AuctionListingDisplay
29
+ {...display}
30
+ data={data}
31
+ imageUrl={imageUrl ?? data.prizes[0]?.imageUrl}
32
+ onBid={showBidButton ? onBid : undefined}
33
+ />
34
+ );
35
+ return (
36
+ <SizeContainer size={size} className={className}>
37
+ {card}
38
+ </SizeContainer>
39
+ );
40
+ }
@@ -0,0 +1,42 @@
1
+ import { isCompactReference, type ReferenceVariantProps } from "../presentation/variants";
2
+ import { CompactPillWithImage } from "../presentation/References";
3
+ import React from "react";
4
+ import { CollectionDisplay } from "../presentation/CollectionDisplay";
5
+ import { SizeContainer } from "../ui/SizeContainer";
6
+ import type { Collection, ComponentSize } from "../types/algorand";
7
+ export interface CollectionComponentProps extends ReferenceVariantProps {
8
+ data: Collection;
9
+ compact?: boolean;
10
+ size?: ComponentSize;
11
+ className?: string;
12
+ imageUrl?: string;
13
+ onPress?: (collection: Collection) => void;
14
+ onClick?: (collection: Collection) => void;
15
+ }
16
+ export function CollectionComponent({
17
+ data,
18
+ size = "full",
19
+ className,
20
+ compact,
21
+ inline,
22
+ imageUrl,
23
+ onClick,
24
+ onPress = onClick,
25
+ }: CollectionComponentProps) {
26
+ if (isCompactReference({ size, compact, inline })) return <CompactPillWithImage label={data.name} imageUrl={imageUrl ?? data.avatarUrl} inline={inline} onPress={onPress ? () => onPress(data) : undefined} />;
27
+ const card = (
28
+ <CollectionDisplay
29
+ data={data}
30
+ compact={compact}
31
+ imageUrl={imageUrl}
32
+ onPress={onPress ? () => onPress(data) : undefined}
33
+ />
34
+ );
35
+ return compact ? (
36
+ card
37
+ ) : (
38
+ <SizeContainer size={size} className={className}>
39
+ {card}
40
+ </SizeContainer>
41
+ );
42
+ }
@@ -0,0 +1,244 @@
1
+ import { isCompactReference, type ReferenceVariantProps } from "../presentation/variants";
2
+ import { CompactPill } from "../presentation/References";
3
+ import { DualStakePoolDisplay as DualStakePoolPresentation } from "../presentation/DualStakePoolDisplay";
4
+ import React, { useMemo, useState } from "react";
5
+ import { Text } from "react-native";
6
+ import { useASAData } from "../hooks/useAlgomdData";
7
+ import type {
8
+ ASA,
9
+ ComponentSize,
10
+ DualStakeActionParams,
11
+ DualStakePool as DualStakePoolData,
12
+ } from "../types/algorand";
13
+ import { formatAssetAmount } from "../utils/format";
14
+ import { normalizeAppId } from "../utils/ids";
15
+ import { ErrorState } from "../ui/DataStates";
16
+ import { SizeContainer } from "../ui/SizeContainer";
17
+
18
+ const ALGO_ASSET: ASA = {
19
+ id: 0,
20
+ name: "Algo",
21
+ unitName: "ALGO",
22
+ total: 10_000_000_000_000_000,
23
+ decimals: 6,
24
+ defaultFrozen: false,
25
+ creator: "",
26
+ createdAt: new Date(0),
27
+ verified: true,
28
+ };
29
+
30
+ export interface DualStakePoolProps extends ReferenceVariantProps {
31
+ data?: DualStakePoolData;
32
+ id?: number | string;
33
+ appId?: number | string;
34
+ walletAppId?: number | string;
35
+ rewardAssetId?: number | string;
36
+ dualStakeAssetId?: number | string;
37
+ title?: string;
38
+ description?: string;
39
+ status?: DualStakePoolData["status"];
40
+ /** Legacy initial value applied to both action inputs. */
41
+ defaultAmount?: string;
42
+ defaultMintAmount?: string;
43
+ defaultRedeemAmount?: string;
44
+ rekeyBack?: boolean;
45
+ size?: ComponentSize;
46
+ className?: string;
47
+ disabled?: boolean;
48
+ onStake?: (params: DualStakeActionParams) => Promise<void> | void;
49
+ onExchange?: (params: DualStakeActionParams) => Promise<void> | void;
50
+ onMint?: (params: DualStakeActionParams) => Promise<void> | void;
51
+ onRedeem?: (params: DualStakeActionParams) => Promise<void> | void;
52
+ }
53
+
54
+ export function DualStakePoolComponent({
55
+ data,
56
+ id,
57
+ appId,
58
+ walletAppId,
59
+ rewardAssetId,
60
+ dualStakeAssetId,
61
+ title,
62
+ description,
63
+ status,
64
+ defaultAmount = "",
65
+ defaultMintAmount,
66
+ defaultRedeemAmount,
67
+ rekeyBack = true,
68
+ size = "full",
69
+ className,
70
+ compact,
71
+ inline,
72
+ disabled,
73
+ onStake,
74
+ onExchange,
75
+ onMint,
76
+ onRedeem,
77
+ }: DualStakePoolProps) {
78
+ const [mintAmount, setMintAmount] = useState(
79
+ defaultMintAmount ?? defaultAmount,
80
+ );
81
+ const [redeemAmount, setRedeemAmount] = useState(
82
+ defaultRedeemAmount ?? defaultAmount,
83
+ );
84
+ const [pending, setPending] = useState<"mint" | "redeem" | null>(null);
85
+ const [error, setError] = useState<string | null>(null);
86
+
87
+ const rewardQuery = useASAData(data?.rewardAsset ? undefined : rewardAssetId);
88
+ const dualStakeQuery = useASAData(
89
+ data?.dualStakeAsset ? undefined : dualStakeAssetId,
90
+ );
91
+
92
+ const stakeAsset = data?.stakeAsset ?? ALGO_ASSET;
93
+ const rewardAsset = data?.rewardAsset ?? rewardQuery.data;
94
+ const dualStakeAsset = data?.dualStakeAsset ?? dualStakeQuery.data;
95
+ const normalizedAppId = normalizeAppId(
96
+ data?.appId ?? data?.id ?? appId ?? id,
97
+ );
98
+ const normalizedWallet = normalizeAppId(walletAppId);
99
+ const mintAmountRaw = useMemo(
100
+ () => parseAssetAmount(mintAmount, stakeAsset.decimals),
101
+ [mintAmount, stakeAsset.decimals],
102
+ );
103
+ const redeemAmountRaw = useMemo(
104
+ () =>
105
+ dualStakeAsset
106
+ ? parseAssetAmount(redeemAmount, dualStakeAsset.decimals)
107
+ : BigInt(0),
108
+ [dualStakeAsset, redeemAmount],
109
+ );
110
+ const canUseWallet =
111
+ !disabled &&
112
+ normalizedAppId != null &&
113
+ normalizedWallet != null &&
114
+ normalizedWallet > 0;
115
+ const canMint = canUseWallet && mintAmountRaw > BigInt(0);
116
+ const canRedeem =
117
+ canUseWallet && !!dualStakeAsset && redeemAmountRaw > BigInt(0);
118
+ const displayStatus = data?.status ?? status ?? "unknown";
119
+ const statusIsActive = displayStatus === "active";
120
+
121
+ async function submit(action: "mint" | "redeem") {
122
+ const canonicalHandler = action === "mint" ? onMint : onRedeem;
123
+ const legacyHandler = action === "mint" ? onStake : onExchange;
124
+ const handler = canonicalHandler ?? legacyHandler;
125
+ const canSubmit = action === "mint" ? canMint : canRedeem;
126
+ const amount = action === "mint" ? mintAmountRaw : redeemAmountRaw;
127
+ if (
128
+ !handler ||
129
+ !canSubmit ||
130
+ normalizedWallet == null ||
131
+ normalizedAppId == null ||
132
+ pending
133
+ )
134
+ return;
135
+ setPending(action);
136
+ setError(null);
137
+ try {
138
+ await handler({
139
+ action:
140
+ canonicalHandler != null
141
+ ? action
142
+ : action === "mint"
143
+ ? "stake"
144
+ : "exchange",
145
+ wallet: normalizedWallet,
146
+ appId: normalizedAppId,
147
+ amount,
148
+ rekeyBack,
149
+ });
150
+ } catch (err) {
151
+ setError(err instanceof Error ? err.message : "Transaction failed");
152
+ } finally {
153
+ setPending(null);
154
+ }
155
+ }
156
+
157
+ if (isCompactReference({ size, compact, inline })) return <CompactPill label={data?.title ?? title ?? `Dual Stake #${normalizedAppId ?? appId ?? id ?? ""}`} inline={inline} />;
158
+
159
+ if (normalizedAppId == null) {
160
+ return (
161
+ <ErrorState
162
+ name="DualStakePool"
163
+ message="A valid id or appId is required"
164
+ />
165
+ );
166
+ }
167
+
168
+ return (
169
+ <SizeContainer size={size} className={className}>
170
+ <DualStakePoolPresentation
171
+ appId={String(normalizedAppId)}
172
+ title={data?.title ?? title ?? `Dual Stake #${normalizedAppId}`}
173
+ description={data?.description ?? description}
174
+ rewardAsset={{
175
+ label: rewardAsset?.unitName || rewardAsset?.name || "ASA",
176
+ subtitle: rewardAsset?.name || "Reward asset",
177
+ imageUrl: rewardAsset?.imageUrl,
178
+ loading: rewardQuery.isLoading,
179
+ }}
180
+ dualStakeAsset={
181
+ dualStakeAsset
182
+ ? {
183
+ label: dualStakeAsset.unitName || dualStakeAsset.name,
184
+ subtitle: dualStakeAsset.name,
185
+ imageUrl: dualStakeAsset.imageUrl,
186
+ }
187
+ : undefined
188
+ }
189
+ metadataState={
190
+ rewardQuery.isLoading || dualStakeQuery.isLoading
191
+ ? "loading"
192
+ : rewardQuery.error || dualStakeQuery.error
193
+ ? "error"
194
+ : "ready"
195
+ }
196
+ online={statusIsActive}
197
+ connected={canUseWallet}
198
+ canMint={canMint && !!(onMint ?? onStake) && !pending}
199
+ canRedeem={canRedeem && !!(onRedeem ?? onExchange) && !pending}
200
+ mintAmount={mintAmount}
201
+ redeemAmount={redeemAmount}
202
+ onMintAmountChange={setMintAmount}
203
+ onRedeemAmountChange={setRedeemAmount}
204
+ onMint={() => void submit("mint")}
205
+ onRedeem={() => void submit("redeem")}
206
+ submitting={!!pending}
207
+ stakedLabel={
208
+ data?.totalStaked != null
209
+ ? formatAssetAmount(data.totalStaked, 6)
210
+ : undefined
211
+ }
212
+ />
213
+ {error ? (
214
+ <Text
215
+ accessibilityRole="alert"
216
+ style={{ color: "#ef4444", marginTop: 8 }}
217
+ >
218
+ {error}
219
+ </Text>
220
+ ) : null}
221
+ </SizeContainer>
222
+ );
223
+ }
224
+
225
+ export const DualStakePool = DualStakePoolComponent;
226
+
227
+ function parseAssetAmount(value: string, decimals: number): bigint {
228
+ const trimmed = value.trim();
229
+ const safeDecimals = Number.isInteger(decimals)
230
+ ? Math.max(0, Math.min(19, decimals))
231
+ : 0;
232
+ const pattern =
233
+ safeDecimals === 0
234
+ ? /^\d+$/
235
+ : new RegExp(`^\\d*(?:\\.\\d{0,${safeDecimals}})?$`);
236
+ if (!pattern.test(trimmed) || trimmed === "" || trimmed === ".")
237
+ return BigInt(0);
238
+ const [whole = "0", fraction = ""] = trimmed.split(".");
239
+ const divisor = BigInt(10) ** BigInt(safeDecimals);
240
+ return (
241
+ BigInt(whole || "0") * divisor +
242
+ BigInt(fraction.padEnd(safeDecimals, "0").slice(0, safeDecimals) || "0")
243
+ );
244
+ }
@@ -0,0 +1,45 @@
1
+ import { isCompactReference, type ReferenceVariantProps } from "../presentation/variants";
2
+ import { CompactPillWithImage } from "../presentation/References";
3
+ import { useProfileDisplayPreferences, formatNfdName } from "../presentation/runtime";
4
+ import React from "react";
5
+ import {
6
+ NFDProfileDisplay,
7
+ type NFDProfileDisplayProps,
8
+ } from "../presentation/NFDProfileDisplay";
9
+ import type { ComponentSize } from "../types/algorand";
10
+ import { SizeContainer } from "../ui/SizeContainer";
11
+ export interface NFDProfileProps extends NFDProfileDisplayProps, ReferenceVariantProps {
12
+ size?: ComponentSize;
13
+ className?: string;
14
+ showBio?: boolean;
15
+ showProperties?: boolean;
16
+ }
17
+ export function NFDProfileComponent({
18
+ size = "full",
19
+ className,
20
+ data,
21
+ inline,
22
+ showBio = true,
23
+ showProperties = true,
24
+ ...display
25
+ }: NFDProfileProps) {
26
+ const { showNfdSuffix } = useProfileDisplayPreferences();
27
+ if (isCompactReference({ size, compact: display.compact, inline })) return <CompactPillWithImage label={formatNfdName(data.name, { showNfdSuffix })} imageUrl={data.avatar} inline={inline} onPress={display.onOpenProfile} />;
28
+ const card = (
29
+ <NFDProfileDisplay
30
+ {...display}
31
+ data={{
32
+ ...data,
33
+ bio: showBio ? data.bio : undefined,
34
+ properties: showProperties ? data.properties : {},
35
+ }}
36
+ />
37
+ );
38
+ return display.compact ? (
39
+ card
40
+ ) : (
41
+ <SizeContainer size={size} className={className}>
42
+ {card}
43
+ </SizeContainer>
44
+ );
45
+ }
@@ -0,0 +1,81 @@
1
+ import React, { useCallback, useState } from 'react';
2
+ import { View, Text } from 'react-native';
3
+ import { Image } from 'expo-image';
4
+ import Svg, { Path } from 'react-native-svg';
5
+ import type { NFDProfile } from '../types/algorand';
6
+ import { formatAddress } from '../utils/format';
7
+ import { SearchSheet } from '../ui/SearchSheet';
8
+
9
+ function VerifiedIcon({ size = 12, color = '#60a5fa' }: { size?: number; color?: string }) {
10
+ return (
11
+ <Svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke={color} strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">
12
+ <Path d="M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z" />
13
+ <Path d="m9 12 2 2 4-4" />
14
+ </Svg>
15
+ );
16
+ }
17
+
18
+ interface NFDSearchProps {
19
+ data: NFDProfile[];
20
+ onSelect?: (profile: NFDProfile) => void;
21
+ placeholder?: string;
22
+ className?: string;
23
+ }
24
+
25
+ export function NFDSearch({
26
+ data,
27
+ onSelect,
28
+ placeholder = 'Search NFD profiles...',
29
+ className,
30
+ }: NFDSearchProps) {
31
+ const [selected, setSelected] = useState<NFDProfile | null>(null);
32
+
33
+ const handleSelect = useCallback(
34
+ (profile: NFDProfile) => {
35
+ setSelected(profile);
36
+ onSelect?.(profile);
37
+ },
38
+ [onSelect],
39
+ );
40
+
41
+ const renderItem = useCallback(
42
+ (profile: NFDProfile) => (
43
+ <View className="flex-row items-center gap-3">
44
+ <View className="w-8 h-8 rounded-full bg-zinc-800 overflow-hidden items-center justify-center">
45
+ {profile.avatar ? (
46
+ <Image source={{ uri: profile.avatar }} style={{ width: 32, height: 32 }} contentFit="cover" />
47
+ ) : (
48
+ <Text className="text-xs text-zinc-400">NFD</Text>
49
+ )}
50
+ </View>
51
+ <View className="flex-1">
52
+ <View className="flex-row items-center gap-1">
53
+ <Text className="text-sm font-medium text-white" numberOfLines={1}>
54
+ {profile.name}
55
+ </Text>
56
+ {profile.verified && <VerifiedIcon />}
57
+ </View>
58
+ <Text className="text-xs text-zinc-400">{formatAddress(profile.address)}</Text>
59
+ </View>
60
+ </View>
61
+ ),
62
+ [],
63
+ );
64
+
65
+ return (
66
+ <View className={className}>
67
+ <SearchSheet
68
+ data={data}
69
+ placeholder={placeholder}
70
+ onSelect={handleSelect}
71
+ renderItem={renderItem}
72
+ />
73
+ {selected && (
74
+ <View className="mt-3 p-3 rounded-lg bg-zinc-800 border border-zinc-700">
75
+ <Text className="text-xs font-medium text-zinc-400 mb-1">Selected NFD</Text>
76
+ {renderItem(selected)}
77
+ </View>
78
+ )}
79
+ </View>
80
+ );
81
+ }
@@ -0,0 +1,73 @@
1
+ import { isCompactReference, type ReferenceVariantProps } from "../presentation/variants";
2
+ import { CompactPillWithImage } from "../presentation/References";
3
+ import { formatPrice } from "../presentation/format";
4
+ import { getAssetUnitName } from "../presentation/assetHelpers";
5
+ import React from "react";
6
+ import type {
7
+ NFTListing as NFTListingType,
8
+ ComponentSize,
9
+ } from "../types/algorand";
10
+ import { SizeContainer } from "../ui/SizeContainer";
11
+ import { NFTListingDisplay } from "../presentation/NFTListingDisplay";
12
+
13
+ export interface NFTListingProps extends ReferenceVariantProps {
14
+ data: NFTListingType;
15
+ showPurchaseButton?: boolean;
16
+ size?: ComponentSize;
17
+ className?: string;
18
+ imageUrl?: string;
19
+ priceAssetImageUrl?: string;
20
+ onPurchase?: (listing: NFTListingType) => void;
21
+ onFavorite?: (listing: NFTListingType) => void;
22
+ onPressCollectible?: () => void;
23
+ purchased?: boolean;
24
+ buyer?: string;
25
+ /** The signed-in account, so a listing reserved for them still offers the buy. */
26
+ viewerAddress?: string;
27
+ /** Whether the viewer passes the listing's gate; leave undefined when unchecked. */
28
+ gateEligible?: boolean;
29
+ /** Pass (true) or fail (false) for each gate rule, in the gate's rule order. */
30
+ gateResults?: boolean[];
31
+ }
32
+
33
+ /** Uses the display rendered by akita-rn's MDX renderer. */
34
+ export function NFTListingComponent({
35
+ data,
36
+ size = "full",
37
+ className,
38
+ compact,
39
+ inline,
40
+ imageUrl,
41
+ priceAssetImageUrl,
42
+ showPurchaseButton = true,
43
+ onPurchase,
44
+ onPressCollectible,
45
+ purchased = Boolean(data.buyer),
46
+ buyer = data.buyer,
47
+ viewerAddress,
48
+ gateEligible,
49
+ gateResults,
50
+ }: NFTListingProps) {
51
+ if (isCompactReference({ size, compact, inline })) {
52
+ const currency = data.currency || getAssetUnitName(data.priceAsset);
53
+ const name = data.isPrizeBox ? `Prize box (${data.prizeBox?.holdings.length ?? 0})` : data.nft.name;
54
+ const label = `${name} · ${formatPrice(data.price, data.priceAsset.decimals)} ${currency}`.trim();
55
+ return <CompactPillWithImage label={label} imageUrl={imageUrl ?? data.nft.imageUrl} inline={inline} onPress={onPressCollectible} />;
56
+ }
57
+ return (
58
+ <SizeContainer size={size} className={className}>
59
+ <NFTListingDisplay
60
+ data={data}
61
+ imageUrl={imageUrl ?? data.nft.imageUrl}
62
+ priceAssetImageUrl={priceAssetImageUrl}
63
+ onPressCollectible={onPressCollectible}
64
+ onPurchase={showPurchaseButton && !purchased ? onPurchase : undefined}
65
+ purchased={purchased}
66
+ buyer={buyer}
67
+ viewerAddress={viewerAddress}
68
+ gateEligible={gateEligible}
69
+ gateResults={gateResults}
70
+ />
71
+ </SizeContainer>
72
+ );
73
+ }
@@ -0,0 +1,68 @@
1
+ import React, { useCallback, useState } from 'react';
2
+ import { View, Text } from 'react-native';
3
+ import type { NFTListing } from '../types/algorand';
4
+ import { formatCurrency } from '../utils/format';
5
+ import { SearchSheet } from '../ui/SearchSheet';
6
+
7
+ interface NFTSearchProps {
8
+ data: NFTListing[];
9
+ onSelect?: (listing: NFTListing) => void;
10
+ placeholder?: string;
11
+ className?: string;
12
+ }
13
+
14
+ export function NFTSearch({
15
+ data,
16
+ onSelect,
17
+ placeholder = 'Search NFTs...',
18
+ className,
19
+ }: NFTSearchProps) {
20
+ const [selected, setSelected] = useState<NFTListing | null>(null);
21
+
22
+ const handleSelect = useCallback(
23
+ (listing: NFTListing) => {
24
+ setSelected(listing);
25
+ onSelect?.(listing);
26
+ },
27
+ [onSelect],
28
+ );
29
+
30
+ const renderItem = useCallback(
31
+ (listing: NFTListing) => (
32
+ <View className="flex-row items-center gap-3">
33
+ <View className="w-8 h-8 rounded-lg bg-zinc-800 items-center justify-center">
34
+ <Text className="text-xs text-zinc-400">NFT</Text>
35
+ </View>
36
+ <View className="flex-1">
37
+ <Text className="text-sm font-medium text-white" numberOfLines={1}>
38
+ {listing.nft.name}
39
+ </Text>
40
+ <Text className="text-xs text-zinc-400">
41
+ {listing.collection || `#${listing.nft.id}`}
42
+ </Text>
43
+ </View>
44
+ <Text className="text-xs font-medium text-white">
45
+ {formatCurrency(listing.price, listing.currency)}
46
+ </Text>
47
+ </View>
48
+ ),
49
+ [],
50
+ );
51
+
52
+ return (
53
+ <View className={className}>
54
+ <SearchSheet
55
+ data={data}
56
+ placeholder={placeholder}
57
+ onSelect={handleSelect}
58
+ renderItem={renderItem}
59
+ />
60
+ {selected && (
61
+ <View className="mt-3 p-3 rounded-lg bg-zinc-800 border border-zinc-700">
62
+ <Text className="text-xs font-medium text-zinc-400 mb-1">Selected NFT</Text>
63
+ {renderItem(selected)}
64
+ </View>
65
+ )}
66
+ </View>
67
+ );
68
+ }
@@ -0,0 +1,39 @@
1
+ import { isCompactReference, type ReferenceVariantProps } from "../presentation/variants";
2
+ import { CompactPill } from "../presentation/References";
3
+ import React from "react";
4
+ import {
5
+ PollDisplay,
6
+ type PollDisplayProps,
7
+ } from "../presentation/PollDisplay";
8
+ import type { ComponentSize } from "../types/algorand";
9
+ import { SizeContainer } from "../ui/SizeContainer";
10
+ export interface PollProps extends PollDisplayProps, ReferenceVariantProps {
11
+ size?: ComponentSize;
12
+ className?: string;
13
+ showVoteButton?: boolean;
14
+ }
15
+ export function PollComponent({
16
+ size = "full",
17
+ className,
18
+ inline,
19
+ data,
20
+ showVoteButton = true,
21
+ onVote,
22
+ ...display
23
+ }: PollProps) {
24
+ if (isCompactReference({ size, compact: display.compact, inline })) return <CompactPill label={data.question} inline={inline} />;
25
+ const card = (
26
+ <PollDisplay
27
+ {...display}
28
+ data={data}
29
+ onVote={showVoteButton ? onVote : undefined}
30
+ />
31
+ );
32
+ return display.compact ? (
33
+ card
34
+ ) : (
35
+ <SizeContainer size={size} className={className}>
36
+ {card}
37
+ </SizeContainer>
38
+ );
39
+ }