@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,1048 @@
1
+ /**
2
+ * Self-fetching wrappers for algomd-rn display components.
3
+ *
4
+ * Each wrapper adds an optional self-fetch prop (appId, address, txId, etc.)
5
+ * alongside the existing `data` prop. If `data` is provided, it renders
6
+ * immediately. Otherwise, it fetches from algod via the hooks.
7
+ */
8
+
9
+ import React from "react";
10
+ import type { ReactNode } from "react";
11
+ import { isCompactReference, type ReferenceVariantProps } from "../presentation/variants";
12
+ import type { ComponentSize } from "../types/algorand";
13
+ import { LoadingSkeleton, ErrorState } from "../ui/DataStates";
14
+ import { normalizeAppId } from "../utils/ids";
15
+
16
+ // Display components (internal names)
17
+ import { Account as AccountDisplay } from "./Account";
18
+ import { ASAComponent } from "./ASA";
19
+ import { CollectionComponent } from "./Collection";
20
+ import { NFTListingComponent } from "./NFTListing";
21
+ import { NFDProfileComponent } from "./NFDProfile";
22
+ import { TransactionDetailsComponent } from "./TransactionDetails";
23
+ import { PollComponent } from "./Poll";
24
+ import { RaffleListingComponent } from "./RaffleListing";
25
+ import { StakingPoolComponent } from "./StakingPool";
26
+ import { AuctionListingComponent } from "./AuctionListing";
27
+ import { TradeOfferComponent } from "./TradeOffer";
28
+
29
+ // Hooks
30
+ import {
31
+ useAccountData,
32
+ useASAData,
33
+ useAssetCollection,
34
+ useAssetPriceHistory,
35
+ useAssetCirculatingSupply,
36
+ useCollectionData,
37
+ useTransactionData,
38
+ useNFDProfileData,
39
+ usePollData,
40
+ useRaffleData,
41
+ useStakingPoolData,
42
+ useAuctionData,
43
+ useNFTListingData,
44
+ useTradeOfferData,
45
+ } from "../hooks/useAlgomdData";
46
+
47
+ // Types
48
+ import type {
49
+ AlgorandAccount,
50
+ ASA as ASAType,
51
+ Collection as CollectionType,
52
+ NFTListing as NFTListingType,
53
+ NFDProfile as NFDProfileType,
54
+ TransactionDetails as TransactionDetailsType,
55
+ Poll as PollType,
56
+ RaffleListing as RaffleListingType,
57
+ StakingPool as StakingPoolType,
58
+ AuctionListing as AuctionListingType,
59
+ TradeOffer as TradeOfferType,
60
+ } from "../types/algorand";
61
+
62
+ // ---------------------------------------------------------------------------
63
+ // Shared fetcher wrapper
64
+ // ---------------------------------------------------------------------------
65
+
66
+ function FetcherWrapper({
67
+ name,
68
+ isLoading,
69
+ error,
70
+ data,
71
+ loadingFallback,
72
+ errorFallback,
73
+ children,
74
+ }: {
75
+ name: string;
76
+ isLoading: boolean;
77
+ error: Error | null;
78
+ data: unknown;
79
+ loadingFallback?: ReactNode;
80
+ errorFallback?: ReactNode;
81
+ children: ReactNode;
82
+ }) {
83
+ if (isLoading)
84
+ return <>{loadingFallback ?? <LoadingSkeleton name={name} />}</>;
85
+ if (error || !data)
86
+ return (
87
+ <>
88
+ {errorFallback ?? (
89
+ <ErrorState name={name} message={error?.message ?? "Not found"} />
90
+ )}
91
+ </>
92
+ );
93
+ return <>{children}</>;
94
+ }
95
+
96
+ // ---------------------------------------------------------------------------
97
+ // Collection
98
+ // ---------------------------------------------------------------------------
99
+
100
+ type CollectionSelfFetchProps = ReferenceVariantProps & {
101
+ data?: CollectionType;
102
+ id?: string | number;
103
+ collectionId?: string | number;
104
+ compact?: boolean;
105
+ size?: ComponentSize;
106
+ className?: string;
107
+ imageUrl?: string;
108
+ onPress?: (collection: CollectionType) => void;
109
+ loadingFallback?: ReactNode;
110
+ errorFallback?: ReactNode;
111
+ };
112
+
113
+ function CollectionFetcher({
114
+ collectionId,
115
+ ...rest
116
+ }: Omit<CollectionSelfFetchProps, "data"> & { collectionId: string | number }) {
117
+ const { data, isLoading, error } = useCollectionData(collectionId);
118
+ return (
119
+ <FetcherWrapper
120
+ name="Collection"
121
+ isLoading={isLoading}
122
+ error={error}
123
+ data={data}
124
+ loadingFallback={rest.loadingFallback}
125
+ errorFallback={rest.errorFallback}
126
+ >
127
+ {data && (
128
+ <CollectionComponent
129
+ data={data}
130
+ compact={rest.compact}
131
+ inline={rest.inline}
132
+ size={rest.size}
133
+ className={rest.className}
134
+ imageUrl={rest.imageUrl}
135
+ onPress={rest.onPress}
136
+ />
137
+ )}
138
+ </FetcherWrapper>
139
+ );
140
+ }
141
+
142
+ export function Collection(props: CollectionSelfFetchProps) {
143
+ const collectionId = props.collectionId ?? props.id;
144
+ if (props.data) {
145
+ return (
146
+ <CollectionComponent
147
+ data={props.data}
148
+ compact={props.compact}
149
+ inline={props.inline}
150
+ size={props.size}
151
+ className={props.className}
152
+ imageUrl={props.imageUrl}
153
+ onPress={props.onPress}
154
+ />
155
+ );
156
+ }
157
+ if (collectionId != null) {
158
+ return (
159
+ <CollectionFetcher
160
+ collectionId={collectionId}
161
+ compact={props.compact}
162
+ inline={props.inline}
163
+ size={props.size}
164
+ className={props.className}
165
+ imageUrl={props.imageUrl}
166
+ onPress={props.onPress}
167
+ loadingFallback={props.loadingFallback}
168
+ errorFallback={props.errorFallback}
169
+ />
170
+ );
171
+ }
172
+ return (
173
+ <ErrorState name="Collection" message="Either data or id is required" />
174
+ );
175
+ }
176
+
177
+ // ---------------------------------------------------------------------------
178
+ // Poll
179
+ // ---------------------------------------------------------------------------
180
+
181
+ type PollSelfFetchProps = ReferenceVariantProps & {
182
+ data?: PollType;
183
+ id?: number | string;
184
+ appId?: number | string;
185
+ showVoteButton?: boolean;
186
+ compact?: boolean;
187
+ size?: ComponentSize;
188
+ className?: string;
189
+ onVote?: (pollId: string, optionId: string) => void;
190
+ loadingFallback?: ReactNode;
191
+ errorFallback?: ReactNode;
192
+ };
193
+
194
+ function PollFetcher({
195
+ appId,
196
+ ...rest
197
+ }: Omit<PollSelfFetchProps, "data"> & { appId: number }) {
198
+ const { data, isLoading, error } = usePollData(appId);
199
+ return (
200
+ <FetcherWrapper
201
+ name="Poll"
202
+ isLoading={isLoading}
203
+ error={error}
204
+ data={data}
205
+ loadingFallback={rest.loadingFallback}
206
+ errorFallback={rest.errorFallback}
207
+ >
208
+ {data && (
209
+ <PollComponent
210
+ data={data}
211
+ showVoteButton={rest.showVoteButton}
212
+ compact={rest.compact}
213
+ inline={rest.inline}
214
+ size={rest.size}
215
+ className={rest.className}
216
+ onVote={rest.onVote}
217
+ />
218
+ )}
219
+ </FetcherWrapper>
220
+ );
221
+ }
222
+
223
+ export function Poll(props: PollSelfFetchProps) {
224
+ const appId = normalizeAppId(props.appId ?? props.id);
225
+ if (props.data)
226
+ return (
227
+ <PollComponent
228
+ data={props.data}
229
+ showVoteButton={props.showVoteButton}
230
+ compact={props.compact}
231
+ inline={props.inline}
232
+ size={props.size}
233
+ className={props.className}
234
+ onVote={props.onVote}
235
+ />
236
+ );
237
+ if (appId != null)
238
+ return (
239
+ <PollFetcher
240
+ appId={appId}
241
+ showVoteButton={props.showVoteButton}
242
+ compact={props.compact}
243
+ inline={props.inline}
244
+ size={props.size}
245
+ className={props.className}
246
+ onVote={props.onVote}
247
+ loadingFallback={props.loadingFallback}
248
+ errorFallback={props.errorFallback}
249
+ />
250
+ );
251
+ return <ErrorState name="Poll" message="Either data or appId is required" />;
252
+ }
253
+
254
+ // ---------------------------------------------------------------------------
255
+ // RaffleListing
256
+ // ---------------------------------------------------------------------------
257
+
258
+ type RaffleListingSelfFetchProps = ReferenceVariantProps & {
259
+ data?: RaffleListingType;
260
+ id?: number | string;
261
+ appId?: number | string;
262
+ showEntryButton?: boolean;
263
+ size?: ComponentSize;
264
+ className?: string;
265
+ imageUrl?: string;
266
+ onEnter?: (raffle: RaffleListingType) => void;
267
+ /** Whether the viewer passes the raffle's gate; leave undefined when unchecked. */
268
+ gateEligible?: boolean;
269
+ /** Pass (true) or fail (false) for each gate rule, in the gate's rule order. */
270
+ gateResults?: boolean[];
271
+ loadingFallback?: ReactNode;
272
+ errorFallback?: ReactNode;
273
+ };
274
+
275
+ function RaffleListingFetcher({
276
+ appId,
277
+ ...rest
278
+ }: Omit<RaffleListingSelfFetchProps, "data"> & { appId: number }) {
279
+ const { data, isLoading, error } = useRaffleData(appId);
280
+ return (
281
+ <FetcherWrapper
282
+ name="Raffle"
283
+ isLoading={isLoading}
284
+ error={error}
285
+ data={data}
286
+ loadingFallback={rest.loadingFallback}
287
+ errorFallback={rest.errorFallback}
288
+ >
289
+ {data && (
290
+ <RaffleListingComponent
291
+ data={data}
292
+ showEntryButton={rest.showEntryButton}
293
+ compact={rest.compact}
294
+ inline={rest.inline}
295
+ size={rest.size}
296
+ className={rest.className}
297
+ imageUrl={rest.imageUrl}
298
+ onEnter={rest.onEnter}
299
+ gateEligible={rest.gateEligible}
300
+ gateResults={rest.gateResults}
301
+ />
302
+ )}
303
+ </FetcherWrapper>
304
+ );
305
+ }
306
+
307
+ export function RaffleListing(props: RaffleListingSelfFetchProps) {
308
+ const appId = normalizeAppId(props.appId ?? props.id);
309
+ if (props.data)
310
+ return (
311
+ <RaffleListingComponent
312
+ data={props.data}
313
+ showEntryButton={props.showEntryButton}
314
+ compact={props.compact}
315
+ inline={props.inline}
316
+ size={props.size}
317
+ className={props.className}
318
+ imageUrl={props.imageUrl}
319
+ onEnter={props.onEnter}
320
+ gateEligible={props.gateEligible}
321
+ gateResults={props.gateResults}
322
+ />
323
+ );
324
+ if (appId != null)
325
+ return (
326
+ <RaffleListingFetcher
327
+ appId={appId}
328
+ showEntryButton={props.showEntryButton}
329
+ compact={props.compact}
330
+ inline={props.inline}
331
+ size={props.size}
332
+ className={props.className}
333
+ imageUrl={props.imageUrl}
334
+ onEnter={props.onEnter}
335
+ gateEligible={props.gateEligible}
336
+ gateResults={props.gateResults}
337
+ loadingFallback={props.loadingFallback}
338
+ errorFallback={props.errorFallback}
339
+ />
340
+ );
341
+ return (
342
+ <ErrorState name="Raffle" message="Either data or appId is required" />
343
+ );
344
+ }
345
+
346
+ // ---------------------------------------------------------------------------
347
+ // StakingPool
348
+ // ---------------------------------------------------------------------------
349
+
350
+ export type StakingPoolSelfFetchProps = ReferenceVariantProps & {
351
+ data?: StakingPoolType;
352
+ id?: number | string;
353
+ appId?: number | string;
354
+ showEnterButton?: boolean;
355
+ size?: ComponentSize;
356
+ className?: string;
357
+ imageUrl?: string;
358
+ onEnter?: (pool: StakingPoolType) => void;
359
+ loadingFallback?: ReactNode;
360
+ errorFallback?: ReactNode;
361
+ };
362
+
363
+ function StakingPoolFetcher({
364
+ appId,
365
+ ...rest
366
+ }: Omit<StakingPoolSelfFetchProps, "data"> & { appId: number }) {
367
+ const { data, isLoading, error } = useStakingPoolData(appId);
368
+ return (
369
+ <FetcherWrapper
370
+ name="Staking Pool"
371
+ isLoading={isLoading}
372
+ error={error}
373
+ data={data}
374
+ loadingFallback={rest.loadingFallback}
375
+ errorFallback={rest.errorFallback}
376
+ >
377
+ {data && (
378
+ <StakingPoolComponent
379
+ data={data}
380
+ showEnterButton={rest.showEnterButton}
381
+ compact={rest.compact}
382
+ inline={rest.inline}
383
+ size={rest.size}
384
+ className={rest.className}
385
+ imageUrl={rest.imageUrl}
386
+ onEnter={rest.onEnter}
387
+ />
388
+ )}
389
+ </FetcherWrapper>
390
+ );
391
+ }
392
+
393
+ export function StakingPool(props: StakingPoolSelfFetchProps) {
394
+ const appId = normalizeAppId(props.appId ?? props.id);
395
+ if (props.data)
396
+ return (
397
+ <StakingPoolComponent
398
+ data={props.data}
399
+ showEnterButton={props.showEnterButton}
400
+ compact={props.compact}
401
+ inline={props.inline}
402
+ size={props.size}
403
+ className={props.className}
404
+ imageUrl={props.imageUrl}
405
+ onEnter={props.onEnter}
406
+ />
407
+ );
408
+ if (appId != null)
409
+ return (
410
+ <StakingPoolFetcher
411
+ appId={appId}
412
+ showEnterButton={props.showEnterButton}
413
+ compact={props.compact}
414
+ inline={props.inline}
415
+ size={props.size}
416
+ className={props.className}
417
+ imageUrl={props.imageUrl}
418
+ onEnter={props.onEnter}
419
+ loadingFallback={props.loadingFallback}
420
+ errorFallback={props.errorFallback}
421
+ />
422
+ );
423
+ return (
424
+ <ErrorState
425
+ name="Staking Pool"
426
+ message="Either data or appId is required"
427
+ />
428
+ );
429
+ }
430
+
431
+ // ---------------------------------------------------------------------------
432
+ // AuctionListing
433
+ // ---------------------------------------------------------------------------
434
+
435
+ type AuctionListingSelfFetchProps = ReferenceVariantProps & {
436
+ data?: AuctionListingType;
437
+ id?: number | string;
438
+ appId?: number | string;
439
+ showBidButton?: boolean;
440
+ size?: ComponentSize;
441
+ className?: string;
442
+ imageUrl?: string;
443
+ onBid?: (auction: AuctionListingType) => void;
444
+ /** Whether the viewer passes the auction's gate; leave undefined when unchecked. */
445
+ gateEligible?: boolean;
446
+ /** Pass (true) or fail (false) for each gate rule, in the gate's rule order. */
447
+ gateResults?: boolean[];
448
+ loadingFallback?: ReactNode;
449
+ errorFallback?: ReactNode;
450
+ };
451
+
452
+ function AuctionListingFetcher({
453
+ appId,
454
+ ...rest
455
+ }: Omit<AuctionListingSelfFetchProps, "data"> & { appId: number }) {
456
+ const { data, isLoading, error } = useAuctionData(appId);
457
+ return (
458
+ <FetcherWrapper
459
+ name="Auction"
460
+ isLoading={isLoading}
461
+ error={error}
462
+ data={data}
463
+ loadingFallback={rest.loadingFallback}
464
+ errorFallback={rest.errorFallback}
465
+ >
466
+ {data && (
467
+ <AuctionListingComponent
468
+ data={data}
469
+ showBidButton={rest.showBidButton}
470
+ compact={rest.compact}
471
+ inline={rest.inline}
472
+ size={rest.size}
473
+ className={rest.className}
474
+ imageUrl={rest.imageUrl}
475
+ onBid={rest.onBid}
476
+ gateEligible={rest.gateEligible}
477
+ gateResults={rest.gateResults}
478
+ />
479
+ )}
480
+ </FetcherWrapper>
481
+ );
482
+ }
483
+
484
+ export function AuctionListing(props: AuctionListingSelfFetchProps) {
485
+ const appId = normalizeAppId(props.appId ?? props.id);
486
+ if (props.data)
487
+ return (
488
+ <AuctionListingComponent
489
+ data={props.data}
490
+ showBidButton={props.showBidButton}
491
+ compact={props.compact}
492
+ inline={props.inline}
493
+ size={props.size}
494
+ className={props.className}
495
+ imageUrl={props.imageUrl}
496
+ onBid={props.onBid}
497
+ gateEligible={props.gateEligible}
498
+ gateResults={props.gateResults}
499
+ />
500
+ );
501
+ if (appId != null)
502
+ return (
503
+ <AuctionListingFetcher
504
+ appId={appId}
505
+ showBidButton={props.showBidButton}
506
+ compact={props.compact}
507
+ inline={props.inline}
508
+ size={props.size}
509
+ className={props.className}
510
+ imageUrl={props.imageUrl}
511
+ onBid={props.onBid}
512
+ loadingFallback={props.loadingFallback}
513
+ errorFallback={props.errorFallback}
514
+ />
515
+ );
516
+ return (
517
+ <ErrorState name="Auction" message="Either data or appId is required" />
518
+ );
519
+ }
520
+
521
+ // ---------------------------------------------------------------------------
522
+ // NFTListing
523
+ // ---------------------------------------------------------------------------
524
+
525
+ type NFTListingSelfFetchProps = ReferenceVariantProps & {
526
+ onPressCollectible?: () => void;
527
+ data?: NFTListingType;
528
+ id?: number | string;
529
+ appId?: number | string;
530
+ showPurchaseButton?: boolean;
531
+ size?: ComponentSize;
532
+ className?: string;
533
+ imageUrl?: string;
534
+ onPurchase?: (listing: NFTListingType) => void;
535
+ onFavorite?: (listing: NFTListingType) => void;
536
+ /** The signed-in account, so a listing reserved for them still offers the buy. */
537
+ viewerAddress?: string;
538
+ /** Whether the viewer passes the listing's gate; leave undefined when unchecked. */
539
+ gateEligible?: boolean;
540
+ /** Pass (true) or fail (false) for each gate rule, in the gate's rule order. */
541
+ gateResults?: boolean[];
542
+ loadingFallback?: ReactNode;
543
+ errorFallback?: ReactNode;
544
+ };
545
+
546
+ function NFTListingFetcher({
547
+ appId,
548
+ ...rest
549
+ }: Omit<NFTListingSelfFetchProps, "data"> & { appId: number }) {
550
+ const { data, isLoading, error } = useNFTListingData(appId);
551
+ return (
552
+ <FetcherWrapper
553
+ name="NFT Listing"
554
+ isLoading={isLoading}
555
+ error={error}
556
+ data={data}
557
+ loadingFallback={rest.loadingFallback}
558
+ errorFallback={rest.errorFallback}
559
+ >
560
+ {data && (
561
+ <NFTListingComponent
562
+ data={data}
563
+ showPurchaseButton={rest.showPurchaseButton}
564
+ compact={rest.compact}
565
+ inline={rest.inline}
566
+ onPressCollectible={rest.onPressCollectible}
567
+ size={rest.size}
568
+ className={rest.className}
569
+ imageUrl={rest.imageUrl}
570
+ onPurchase={rest.onPurchase}
571
+ onFavorite={rest.onFavorite}
572
+ viewerAddress={rest.viewerAddress}
573
+ gateEligible={rest.gateEligible}
574
+ gateResults={rest.gateResults}
575
+ />
576
+ )}
577
+ </FetcherWrapper>
578
+ );
579
+ }
580
+
581
+ export function NFTListing(props: NFTListingSelfFetchProps) {
582
+ const appId = normalizeAppId(props.appId ?? props.id);
583
+ if (props.data)
584
+ return (
585
+ <NFTListingComponent
586
+ data={props.data}
587
+ showPurchaseButton={props.showPurchaseButton}
588
+ compact={props.compact}
589
+ inline={props.inline}
590
+ onPressCollectible={props.onPressCollectible}
591
+ size={props.size}
592
+ className={props.className}
593
+ imageUrl={props.imageUrl}
594
+ onPurchase={props.onPurchase}
595
+ onFavorite={props.onFavorite}
596
+ viewerAddress={props.viewerAddress}
597
+ gateEligible={props.gateEligible}
598
+ gateResults={props.gateResults}
599
+ />
600
+ );
601
+ if (appId != null)
602
+ return (
603
+ <NFTListingFetcher
604
+ appId={appId}
605
+ showPurchaseButton={props.showPurchaseButton}
606
+ compact={props.compact}
607
+ inline={props.inline}
608
+ onPressCollectible={props.onPressCollectible}
609
+ size={props.size}
610
+ className={props.className}
611
+ imageUrl={props.imageUrl}
612
+ onPurchase={props.onPurchase}
613
+ onFavorite={props.onFavorite}
614
+ viewerAddress={props.viewerAddress}
615
+ gateEligible={props.gateEligible}
616
+ gateResults={props.gateResults}
617
+ loadingFallback={props.loadingFallback}
618
+ errorFallback={props.errorFallback}
619
+ />
620
+ );
621
+ return (
622
+ <ErrorState name="NFT Listing" message="Either data or appId is required" />
623
+ );
624
+ }
625
+
626
+ // ---------------------------------------------------------------------------
627
+ // TradeOffer
628
+ // ---------------------------------------------------------------------------
629
+
630
+ type TradeOfferSelfFetchProps = ReferenceVariantProps & {
631
+ data?: TradeOfferType;
632
+ appId?: number;
633
+ offerId?: number;
634
+ showActions?: boolean;
635
+ size?: ComponentSize;
636
+ className?: string;
637
+ currentUserAddress?: string;
638
+ onAccept?: (offer: TradeOfferType) => void;
639
+ onReject?: (offer: TradeOfferType) => void;
640
+ loadingFallback?: ReactNode;
641
+ errorFallback?: ReactNode;
642
+ };
643
+
644
+ function TradeOfferFetcher({
645
+ appId,
646
+ offerId,
647
+ ...rest
648
+ }: Omit<TradeOfferSelfFetchProps, "data"> & {
649
+ appId: number;
650
+ offerId: number;
651
+ }) {
652
+ const { data, isLoading, error } = useTradeOfferData(appId, offerId);
653
+ return (
654
+ <FetcherWrapper
655
+ name="Trade Offer"
656
+ isLoading={isLoading}
657
+ error={error}
658
+ data={data}
659
+ loadingFallback={rest.loadingFallback}
660
+ errorFallback={rest.errorFallback}
661
+ >
662
+ {data && (
663
+ <TradeOfferComponent
664
+ data={data}
665
+ showActions={rest.showActions}
666
+ compact={rest.compact}
667
+ inline={rest.inline}
668
+ size={rest.size}
669
+ className={rest.className}
670
+ currentUserAddress={rest.currentUserAddress}
671
+ onAccept={rest.onAccept}
672
+ onReject={rest.onReject}
673
+ />
674
+ )}
675
+ </FetcherWrapper>
676
+ );
677
+ }
678
+
679
+ export function TradeOffer(props: TradeOfferSelfFetchProps) {
680
+ if (props.data)
681
+ return (
682
+ <TradeOfferComponent
683
+ data={props.data}
684
+ showActions={props.showActions}
685
+ compact={props.compact}
686
+ inline={props.inline}
687
+ size={props.size}
688
+ className={props.className}
689
+ currentUserAddress={props.currentUserAddress}
690
+ onAccept={props.onAccept}
691
+ onReject={props.onReject}
692
+ />
693
+ );
694
+ if (props.appId != null && props.offerId != null)
695
+ return (
696
+ <TradeOfferFetcher
697
+ appId={props.appId}
698
+ offerId={props.offerId}
699
+ showActions={props.showActions}
700
+ compact={props.compact}
701
+ inline={props.inline}
702
+ size={props.size}
703
+ className={props.className}
704
+ currentUserAddress={props.currentUserAddress}
705
+ onAccept={props.onAccept}
706
+ onReject={props.onReject}
707
+ loadingFallback={props.loadingFallback}
708
+ errorFallback={props.errorFallback}
709
+ />
710
+ );
711
+ return (
712
+ <ErrorState
713
+ name="Trade Offer"
714
+ message="Either data or (appId + offerId) is required"
715
+ />
716
+ );
717
+ }
718
+
719
+ // ---------------------------------------------------------------------------
720
+ // Account
721
+ // ---------------------------------------------------------------------------
722
+
723
+ type AccountSelfFetchProps = ReferenceVariantProps & {
724
+ data?: AlgorandAccount;
725
+ address?: string;
726
+ showAssets?: boolean;
727
+ showApps?: boolean;
728
+ compact?: boolean;
729
+ size?: ComponentSize;
730
+ className?: string;
731
+ onExternalLink?: (address: string) => void;
732
+ loadingFallback?: ReactNode;
733
+ errorFallback?: ReactNode;
734
+ };
735
+
736
+ function AccountFetcher({
737
+ address,
738
+ ...rest
739
+ }: Omit<AccountSelfFetchProps, "data"> & { address: string }) {
740
+ const { data, isLoading, error } = useAccountData(address);
741
+ return (
742
+ <FetcherWrapper
743
+ name="Account"
744
+ isLoading={isLoading}
745
+ error={error}
746
+ data={data}
747
+ loadingFallback={rest.loadingFallback}
748
+ errorFallback={rest.errorFallback}
749
+ >
750
+ {data && (
751
+ <AccountDisplay
752
+ data={data}
753
+ showAssets={rest.showAssets}
754
+ showApps={rest.showApps}
755
+ compact={rest.compact}
756
+ inline={rest.inline}
757
+ size={rest.size}
758
+ className={rest.className}
759
+ onExternalLink={rest.onExternalLink}
760
+ />
761
+ )}
762
+ </FetcherWrapper>
763
+ );
764
+ }
765
+
766
+ export function Account(props: AccountSelfFetchProps) {
767
+ if (props.data)
768
+ return (
769
+ <AccountDisplay
770
+ data={props.data}
771
+ showAssets={props.showAssets}
772
+ showApps={props.showApps}
773
+ compact={props.compact}
774
+ inline={props.inline}
775
+ size={props.size}
776
+ className={props.className}
777
+ onExternalLink={props.onExternalLink}
778
+ />
779
+ );
780
+ if (props.address)
781
+ return (
782
+ <AccountFetcher
783
+ address={props.address}
784
+ showAssets={props.showAssets}
785
+ showApps={props.showApps}
786
+ compact={props.compact}
787
+ inline={props.inline}
788
+ size={props.size}
789
+ className={props.className}
790
+ onExternalLink={props.onExternalLink}
791
+ loadingFallback={props.loadingFallback}
792
+ errorFallback={props.errorFallback}
793
+ />
794
+ );
795
+ return (
796
+ <ErrorState name="Account" message="Either data or address is required" />
797
+ );
798
+ }
799
+
800
+ // ---------------------------------------------------------------------------
801
+ // ASA
802
+ // ---------------------------------------------------------------------------
803
+
804
+ type ASASelfFetchProps = ReferenceVariantProps & {
805
+ onPress?: (asset: ASAType) => void;
806
+ data?: ASAType;
807
+ assetId?: number;
808
+ showDetails?: boolean;
809
+ compact?: boolean;
810
+ size?: ComponentSize;
811
+ className?: string;
812
+ imageUrl?: string;
813
+ loadingFallback?: ReactNode;
814
+ errorFallback?: ReactNode;
815
+ };
816
+
817
+ function ASAFetcher({
818
+ assetId,
819
+ ...rest
820
+ }: Omit<ASASelfFetchProps, "data"> & { assetId: number }) {
821
+ const { data: asset, isLoading, error } = useASAData(assetId);
822
+ // Cards add a collectible's collection and a token's sparkline; mentions need neither.
823
+ const card = !!asset && !isCompactReference({ size: rest.size ?? "full", compact: rest.compact, inline: rest.inline });
824
+ const collection = useAssetCollection(assetId, card && asset?.decimals === 0);
825
+ const history = useAssetPriceHistory(assetId, card && !!asset && asset.decimals > 0);
826
+ // Large token cards list the circulating supply; small ones fit a single row.
827
+ const large = card && rest.size !== "sm" && rest.size !== "md";
828
+ const circulating = useAssetCirculatingSupply(asset, large && !!asset && asset.decimals > 0);
829
+ const data = asset && {
830
+ ...asset,
831
+ collection: asset.collection ?? collection.data ?? undefined,
832
+ usdPriceHistory: asset.usdPriceHistory ?? history.data,
833
+ circulatingSupplyRaw: asset.circulatingSupplyRaw ?? circulating.data,
834
+ };
835
+ return (
836
+ <FetcherWrapper
837
+ name="ASA"
838
+ isLoading={isLoading}
839
+ error={error}
840
+ data={data}
841
+ loadingFallback={rest.loadingFallback}
842
+ errorFallback={rest.errorFallback}
843
+ >
844
+ {data && (
845
+ <ASAComponent
846
+ data={data}
847
+ showDetails={rest.showDetails}
848
+ compact={rest.compact}
849
+ inline={rest.inline}
850
+ onPress={rest.onPress}
851
+ size={rest.size}
852
+ className={rest.className}
853
+ imageUrl={rest.imageUrl}
854
+ />
855
+ )}
856
+ </FetcherWrapper>
857
+ );
858
+ }
859
+
860
+ export function ASA(props: ASASelfFetchProps) {
861
+ if (props.data)
862
+ return (
863
+ <ASAComponent
864
+ data={props.data}
865
+ showDetails={props.showDetails}
866
+ compact={props.compact}
867
+ inline={props.inline}
868
+ onPress={props.onPress}
869
+ size={props.size}
870
+ className={props.className}
871
+ imageUrl={props.imageUrl}
872
+ />
873
+ );
874
+ if (props.assetId != null)
875
+ return (
876
+ <ASAFetcher
877
+ assetId={props.assetId}
878
+ showDetails={props.showDetails}
879
+ compact={props.compact}
880
+ inline={props.inline}
881
+ onPress={props.onPress}
882
+ size={props.size}
883
+ className={props.className}
884
+ imageUrl={props.imageUrl}
885
+ loadingFallback={props.loadingFallback}
886
+ errorFallback={props.errorFallback}
887
+ />
888
+ );
889
+ return <ErrorState name="ASA" message="Either data or assetId is required" />;
890
+ }
891
+
892
+ // ---------------------------------------------------------------------------
893
+ // TransactionDetails
894
+ // ---------------------------------------------------------------------------
895
+
896
+ type TransactionDetailsSelfFetchProps = ReferenceVariantProps & {
897
+ data?: TransactionDetailsType;
898
+ txId?: string;
899
+ showContext?: boolean;
900
+ showFee?: boolean;
901
+ compact?: boolean;
902
+ size?: ComponentSize;
903
+ className?: string;
904
+ loadingFallback?: ReactNode;
905
+ errorFallback?: ReactNode;
906
+ };
907
+
908
+ function TransactionDetailsFetcher({
909
+ txId,
910
+ ...rest
911
+ }: Omit<TransactionDetailsSelfFetchProps, "data"> & { txId: string }) {
912
+ const { data, isLoading, error } = useTransactionData(txId);
913
+ return (
914
+ <FetcherWrapper
915
+ name="Transaction"
916
+ isLoading={isLoading}
917
+ error={error}
918
+ data={data}
919
+ loadingFallback={rest.loadingFallback}
920
+ errorFallback={rest.errorFallback}
921
+ >
922
+ {data && (
923
+ <TransactionDetailsComponent
924
+ data={data}
925
+ showContext={rest.showContext}
926
+ showFee={rest.showFee}
927
+ compact={rest.compact}
928
+ inline={rest.inline}
929
+ size={rest.size}
930
+ className={rest.className}
931
+ />
932
+ )}
933
+ </FetcherWrapper>
934
+ );
935
+ }
936
+
937
+ export function TransactionDetails(props: TransactionDetailsSelfFetchProps) {
938
+ if (props.data)
939
+ return (
940
+ <TransactionDetailsComponent
941
+ data={props.data}
942
+ showContext={props.showContext}
943
+ showFee={props.showFee}
944
+ compact={props.compact}
945
+ inline={props.inline}
946
+ size={props.size}
947
+ className={props.className}
948
+ />
949
+ );
950
+ if (props.txId)
951
+ return (
952
+ <TransactionDetailsFetcher
953
+ txId={props.txId}
954
+ showContext={props.showContext}
955
+ showFee={props.showFee}
956
+ compact={props.compact}
957
+ inline={props.inline}
958
+ size={props.size}
959
+ className={props.className}
960
+ loadingFallback={props.loadingFallback}
961
+ errorFallback={props.errorFallback}
962
+ />
963
+ );
964
+ return (
965
+ <ErrorState name="Transaction" message="Either data or txId is required" />
966
+ );
967
+ }
968
+
969
+ // ---------------------------------------------------------------------------
970
+ // NFDProfile
971
+ // ---------------------------------------------------------------------------
972
+
973
+ type NFDProfileSelfFetchProps = ReferenceVariantProps & {
974
+ onOpenProfile?: () => void;
975
+ data?: NFDProfileType;
976
+ name?: string;
977
+ showBio?: boolean;
978
+ showProperties?: boolean;
979
+ compact?: boolean;
980
+ size?: ComponentSize;
981
+ className?: string;
982
+ loadingFallback?: ReactNode;
983
+ errorFallback?: ReactNode;
984
+ };
985
+
986
+ function NFDProfileFetcher({
987
+ name,
988
+ ...rest
989
+ }: Omit<NFDProfileSelfFetchProps, "data"> & { name: string }) {
990
+ const { data, isLoading, error } = useNFDProfileData(name);
991
+ return (
992
+ <FetcherWrapper
993
+ name="NFD Profile"
994
+ isLoading={isLoading}
995
+ error={error}
996
+ data={data}
997
+ loadingFallback={rest.loadingFallback}
998
+ errorFallback={rest.errorFallback}
999
+ >
1000
+ {data && (
1001
+ <NFDProfileComponent
1002
+ data={data}
1003
+ showBio={rest.showBio}
1004
+ showProperties={rest.showProperties}
1005
+ compact={rest.compact}
1006
+ inline={rest.inline}
1007
+ onOpenProfile={rest.onOpenProfile}
1008
+ size={rest.size}
1009
+ className={rest.className}
1010
+ />
1011
+ )}
1012
+ </FetcherWrapper>
1013
+ );
1014
+ }
1015
+
1016
+ export function NFDProfile(props: NFDProfileSelfFetchProps) {
1017
+ if (props.data)
1018
+ return (
1019
+ <NFDProfileComponent
1020
+ data={props.data}
1021
+ showBio={props.showBio}
1022
+ showProperties={props.showProperties}
1023
+ compact={props.compact}
1024
+ inline={props.inline}
1025
+ onOpenProfile={props.onOpenProfile}
1026
+ size={props.size}
1027
+ className={props.className}
1028
+ />
1029
+ );
1030
+ if (props.name)
1031
+ return (
1032
+ <NFDProfileFetcher
1033
+ name={props.name}
1034
+ showBio={props.showBio}
1035
+ showProperties={props.showProperties}
1036
+ compact={props.compact}
1037
+ inline={props.inline}
1038
+ onOpenProfile={props.onOpenProfile}
1039
+ size={props.size}
1040
+ className={props.className}
1041
+ loadingFallback={props.loadingFallback}
1042
+ errorFallback={props.errorFallback}
1043
+ />
1044
+ );
1045
+ return (
1046
+ <ErrorState name="NFD Profile" message="Either data or name is required" />
1047
+ );
1048
+ }