@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.
- package/README.md +137 -2
- package/package.json +118 -3
- package/src/adapters/index.ts +4 -0
- package/src/adapters/txn-graph.ts +138 -0
- package/src/components/ASA.tsx +38 -0
- package/src/components/ASASearch.tsx +79 -0
- package/src/components/Account.tsx +42 -0
- package/src/components/AccountSearch.tsx +75 -0
- package/src/components/AuctionListing.tsx +40 -0
- package/src/components/Collection.tsx +42 -0
- package/src/components/DualStakePool.tsx +244 -0
- package/src/components/NFDProfile.tsx +45 -0
- package/src/components/NFDSearch.tsx +81 -0
- package/src/components/NFTListing.tsx +73 -0
- package/src/components/NFTSearch.tsx +68 -0
- package/src/components/Poll.tsx +39 -0
- package/src/components/PollSearch.tsx +79 -0
- package/src/components/PrizeBoxBundle.tsx +1 -0
- package/src/components/RaffleListing.tsx +40 -0
- package/src/components/SelfFetching.tsx +1048 -0
- package/src/components/StakingPool.tsx +134 -0
- package/src/components/TradeOffer.tsx +47 -0
- package/src/components/TradeSearch.tsx +103 -0
- package/src/components/TransactionDetails.tsx +37 -0
- package/src/components/TransactionSearch.tsx +102 -0
- package/src/components/TransactionsGraph.tsx +60 -0
- package/src/components/index.ts +41 -0
- package/src/fonts/OFL.txt +93 -0
- package/src/fonts/SpaceGrotesk_300Light.ttf +0 -0
- package/src/fonts/SpaceGrotesk_400Regular.ttf +0 -0
- package/src/fonts/SpaceGrotesk_500Medium.ttf +0 -0
- package/src/fonts/SpaceGrotesk_600SemiBold.ttf +0 -0
- package/src/fonts/SpaceGrotesk_700Bold.ttf +0 -0
- package/src/fonts/app.css +5 -0
- package/src/graph.ts +3 -0
- package/src/hooks/index.ts +17 -0
- package/src/hooks/useAlgomdData.ts +1539 -0
- package/src/hooks/useAlgorandClient.ts +54 -0
- package/src/index.ts +147 -0
- package/src/presentation/ASADisplay.tsx +380 -0
- package/src/presentation/AccountDisplay.tsx +132 -0
- package/src/presentation/AccountMentionInline.tsx +38 -0
- package/src/presentation/AccountMentionText.tsx +80 -0
- package/src/presentation/AdaptiveImage.tsx +314 -0
- package/src/presentation/AssetMention.tsx +87 -0
- package/src/presentation/AuctionListingDisplay.tsx +428 -0
- package/src/presentation/BundleContents.tsx +228 -0
- package/src/presentation/CardContainer.tsx +61 -0
- package/src/presentation/CardEntrance.tsx +21 -0
- package/src/presentation/CollectionDisplay.tsx +168 -0
- package/src/presentation/ContractMenu.tsx +243 -0
- package/src/presentation/DualStakePoolDisplay.tsx +335 -0
- package/src/presentation/Embeds.tsx +300 -0
- package/src/presentation/GateRequirements.tsx +334 -0
- package/src/presentation/HEROICONS-LICENSE.txt +21 -0
- package/src/presentation/NFDProfileDisplay.tsx +194 -0
- package/src/presentation/NFTListingDisplay.tsx +284 -0
- package/src/presentation/OnChainActionCard.tsx +557 -0
- package/src/presentation/PollDisplay.tsx +222 -0
- package/src/presentation/PrizeBoxBundleDisplay.tsx +103 -0
- package/src/presentation/PrizeBoxMedia.tsx +46 -0
- package/src/presentation/PrizePreview.tsx +296 -0
- package/src/presentation/ProgressBar.tsx +50 -0
- package/src/presentation/RaffleListingDisplay.tsx +399 -0
- package/src/presentation/References.tsx +310 -0
- package/src/presentation/ReservedNotice.tsx +73 -0
- package/src/presentation/ResultsPanel.tsx +241 -0
- package/src/presentation/Sparkline.tsx +70 -0
- package/src/presentation/SquishyPressable.tsx +145 -0
- package/src/presentation/StakingPoolDisplay.tsx +419 -0
- package/src/presentation/StatusBadge.tsx +56 -0
- package/src/presentation/TradeOfferDisplay.tsx +275 -0
- package/src/presentation/TransactionDisplay.tsx +262 -0
- package/src/presentation/WinnerBadge.tsx +58 -0
- package/src/presentation/assetHelpers.ts +36 -0
- package/src/presentation/assets.ts +7 -0
- package/src/presentation/explorer.ts +95 -0
- package/src/presentation/format.ts +90 -0
- package/src/presentation/gates.ts +100 -0
- package/src/presentation/icons.tsx +1178 -0
- package/src/presentation/identity.tsx +175 -0
- package/src/presentation/index.ts +88 -0
- package/src/presentation/media.ts +70 -0
- package/src/presentation/pluginColors.ts +8 -0
- package/src/presentation/runtime.tsx +268 -0
- package/src/presentation/sheets.tsx +7 -0
- package/src/presentation/subject.tsx +31 -0
- package/src/presentation/textTheme.ts +17 -0
- package/src/presentation/themes.json +158 -0
- package/src/presentation/variants.ts +14 -0
- package/src/provider/AlgomdProvider.tsx +45 -0
- package/src/provider/context.ts +18 -0
- package/src/provider/imageResolver.ts +12 -0
- package/src/provider/index.ts +5 -0
- package/src/provider/networks.ts +23 -0
- package/src/provider/types.ts +29 -0
- package/src/refs/AccountRef.tsx +226 -0
- package/src/refs/ApplicationRef.tsx +72 -0
- package/src/refs/AssetRef.tsx +142 -0
- package/src/refs/AuctionRef.tsx +108 -0
- package/src/refs/CollectionRef.tsx +70 -0
- package/src/refs/DualStakeRef.tsx +88 -0
- package/src/refs/HostRefs.tsx +82 -0
- package/src/refs/ListingRef.tsx +90 -0
- package/src/refs/NfdRef.tsx +96 -0
- package/src/refs/PollRef.tsx +120 -0
- package/src/refs/RaffleRef.tsx +101 -0
- package/src/refs/RewardRef.tsx +78 -0
- package/src/refs/StakingPoolRef.tsx +136 -0
- package/src/refs/SubscriptionRef.tsx +200 -0
- package/src/refs/TradeRef.tsx +100 -0
- package/src/refs/TransactionRef.tsx +156 -0
- package/src/refs/assetInfo.ts +49 -0
- package/src/refs/contractParts.tsx +159 -0
- package/src/refs/index.tsx +137 -0
- package/src/refs/primitives.tsx +588 -0
- package/src/refs/types.ts +13 -0
- package/src/types/algorand.ts +496 -0
- package/src/types/index.ts +1 -0
- package/src/ui/CopyButton.tsx +44 -0
- package/src/ui/DataStates.tsx +45 -0
- package/src/ui/ProgressBar.tsx +64 -0
- package/src/ui/SearchSheet.tsx +141 -0
- package/src/ui/SizeContainer.tsx +25 -0
- package/src/ui/StatusBadge.tsx +51 -0
- package/src/ui/index.ts +6 -0
- package/src/utils/algomdImageUrl.ts +20 -0
- package/src/utils/arc19.ts +120 -0
- package/src/utils/arc62.ts +246 -0
- package/src/utils/capacity.ts +26 -0
- package/src/utils/format.ts +181 -0
- package/src/utils/ids.ts +31 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/nfdDisplay.ts +45 -0
- package/src/utils/search.ts +87 -0
- package/src/utils/stakingPool.ts +174 -0
- package/src/utils/stakingSnapshot.ts +132 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Shared AlgoMD presentation, migrated from akita-rn. Edit this library source.
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { View } from "react-native";
|
|
4
|
+
import { useAppTheme } from "./runtime";
|
|
5
|
+
|
|
6
|
+
export interface ProgressBarProps {
|
|
7
|
+
/** Progress value between 0 and 1 */
|
|
8
|
+
progress: number;
|
|
9
|
+
/** Height in pixels. Defaults to 8 */
|
|
10
|
+
height?: number;
|
|
11
|
+
/** Fill color. Falls back to theme primary */
|
|
12
|
+
color?: string;
|
|
13
|
+
/** Background color. Falls back to theme border */
|
|
14
|
+
trackColor?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function ProgressBar({
|
|
18
|
+
progress,
|
|
19
|
+
height = 8,
|
|
20
|
+
color,
|
|
21
|
+
trackColor,
|
|
22
|
+
}: ProgressBarProps) {
|
|
23
|
+
const { theme } = useAppTheme();
|
|
24
|
+
const clampedProgress = Math.max(0, Math.min(1, progress));
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<View
|
|
28
|
+
style={{
|
|
29
|
+
height,
|
|
30
|
+
backgroundColor: trackColor ?? theme.colors.border,
|
|
31
|
+
borderRadius: height / 2,
|
|
32
|
+
overflow: "hidden",
|
|
33
|
+
}}
|
|
34
|
+
>
|
|
35
|
+
{clampedProgress > 0 && (
|
|
36
|
+
<View
|
|
37
|
+
style={{
|
|
38
|
+
position: "absolute",
|
|
39
|
+
top: 0,
|
|
40
|
+
left: 0,
|
|
41
|
+
bottom: 0,
|
|
42
|
+
width: `${clampedProgress * 100}%`,
|
|
43
|
+
backgroundColor: color ?? theme.colors.primary,
|
|
44
|
+
borderRadius: height / 2,
|
|
45
|
+
}}
|
|
46
|
+
/>
|
|
47
|
+
)}
|
|
48
|
+
</View>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
// Shared AlgoMD presentation, migrated from akita-rn. Edit this library source.
|
|
2
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { Image, View } from "react-native";
|
|
4
|
+
import * as Haptics from "expo-haptics";
|
|
5
|
+
import { CheckBadgeIcon, RaffleIcon, TicketIcon } from "./icons";
|
|
6
|
+
import {
|
|
7
|
+
BundleContentsButton,
|
|
8
|
+
PrizeBoxHoldingsMedia,
|
|
9
|
+
type BundleSheetHandle,
|
|
10
|
+
} from "./BundleContents";
|
|
11
|
+
import { GateNotice } from "./GateRequirements";
|
|
12
|
+
import { ResultPending, ResultWinner, ResultsPanel } from "./ResultsPanel";
|
|
13
|
+
import { PLUGIN_COLORS } from "./pluginColors";
|
|
14
|
+
|
|
15
|
+
import type { RaffleListing as RaffleListingType } from "../types/algorand";
|
|
16
|
+
import { formatNumber } from "../utils/format";
|
|
17
|
+
import { Text, useAppTheme } from "./runtime";
|
|
18
|
+
import {
|
|
19
|
+
AdaptiveImage,
|
|
20
|
+
ImagePlaceholder,
|
|
21
|
+
useImageBudget,
|
|
22
|
+
} from "./AdaptiveImage";
|
|
23
|
+
import { ContractMenu } from "./ContractMenu";
|
|
24
|
+
import {
|
|
25
|
+
OnChainActionButton,
|
|
26
|
+
OnChainActionCard,
|
|
27
|
+
OnChainActionHeader,
|
|
28
|
+
OnChainActionNotice,
|
|
29
|
+
OnChainMetric,
|
|
30
|
+
OnChainMetricGrid,
|
|
31
|
+
} from "./OnChainActionCard";
|
|
32
|
+
import { useIsAssetSubject } from "./subject";
|
|
33
|
+
import { PrizePreview } from "./PrizePreview";
|
|
34
|
+
import { getAssetIconSource, getAssetUnitName } from "./assetHelpers";
|
|
35
|
+
import {
|
|
36
|
+
formatAtomicAmount,
|
|
37
|
+
formatShortDistance,
|
|
38
|
+
isShortDistanceDate,
|
|
39
|
+
} from "./format";
|
|
40
|
+
|
|
41
|
+
type CorrectedRaffleData = RaffleListingType & {
|
|
42
|
+
isPrizeBox?: boolean;
|
|
43
|
+
prizeBoxAppId?: string;
|
|
44
|
+
/** Unique participating wallets. */
|
|
45
|
+
participantCount?: number;
|
|
46
|
+
/** Total ticket weight committed across all wallets. */
|
|
47
|
+
totalTicketWeight?: number;
|
|
48
|
+
totalTicketWeightRaw?: string;
|
|
49
|
+
/** Per-wallet entry bounds. */
|
|
50
|
+
minTickets?: number;
|
|
51
|
+
minTicketsRaw?: string;
|
|
52
|
+
maxTickets?: number;
|
|
53
|
+
maxTicketsRaw?: string;
|
|
54
|
+
isSnapshot?: boolean;
|
|
55
|
+
authenticityBadge?: boolean;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export interface RaffleListingDisplayProps {
|
|
59
|
+
data: RaffleListingType;
|
|
60
|
+
imageUrl?: string;
|
|
61
|
+
prizeImageUrls?: (string | undefined)[];
|
|
62
|
+
entryAssetImageUrl?: string;
|
|
63
|
+
entryUnavailable?: boolean;
|
|
64
|
+
notice?: string;
|
|
65
|
+
onRetry?: () => void;
|
|
66
|
+
onEnter?: (raffle: RaffleListingType) => void;
|
|
67
|
+
/** Whether the viewer passes the raffle's gate; leave undefined when unchecked. */
|
|
68
|
+
gateEligible?: boolean;
|
|
69
|
+
/** Pass (true) or fail (false) for each gate rule, in the gate's rule order. */
|
|
70
|
+
gateResults?: boolean[];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const NON_IMAGE_HEIGHT = 244;
|
|
74
|
+
|
|
75
|
+
function baseUnitLabel(
|
|
76
|
+
raw: string | number | undefined,
|
|
77
|
+
decimals: number,
|
|
78
|
+
unitName: string,
|
|
79
|
+
): string {
|
|
80
|
+
if (raw == null) return "Not indexed";
|
|
81
|
+
const value = String(raw);
|
|
82
|
+
if (!/^\d+$/.test(value)) return "Not indexed";
|
|
83
|
+
const amount = formatAtomicAmount(value, decimals);
|
|
84
|
+
return amount ? `${amount} ${unitName}`.trim() : "Not indexed";
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** The entry minimum as the headline, the per-wallet cap underneath, so neither truncates. */
|
|
88
|
+
export function walletRangeLabel(
|
|
89
|
+
minTickets: string | number | undefined,
|
|
90
|
+
maxTickets: string | number | undefined,
|
|
91
|
+
decimals: number,
|
|
92
|
+
unitName: string,
|
|
93
|
+
): { value: string; secondary?: string } {
|
|
94
|
+
const min = baseUnitLabel(minTickets, decimals, unitName);
|
|
95
|
+
const max = baseUnitLabel(maxTickets, decimals, unitName);
|
|
96
|
+
if (min === "Not indexed" && max === "Not indexed")
|
|
97
|
+
return { value: "Not indexed" };
|
|
98
|
+
if (max === "Not indexed") return { value: `From ${min}` };
|
|
99
|
+
if (min === "Not indexed" || min === max) return { value: max };
|
|
100
|
+
// A 1-base-unit minimum is "no minimum"; leading with it would truncate to noise.
|
|
101
|
+
if (/^[01]$/.test(String(minTickets ?? "")))
|
|
102
|
+
return { value: `Up to ${max}`, secondary: "Any amount per wallet" };
|
|
103
|
+
return { value: `From ${min}`, secondary: `Up to ${max} per wallet` };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** "Starts in 3h", "Ends in 2d", "Ended 5m": the shorthand a post's timestamp uses. */
|
|
107
|
+
export function raffleTimerLabel(
|
|
108
|
+
data: Pick<RaffleListingType, "status" | "startTime" | "endTime">,
|
|
109
|
+
nowMs = Date.now(),
|
|
110
|
+
): string {
|
|
111
|
+
const at = (date: Date, lead: string) => {
|
|
112
|
+
const short = formatShortDistance(date, nowMs);
|
|
113
|
+
if (short === "now") return `${lead} now`;
|
|
114
|
+
return isShortDistanceDate(date, nowMs)
|
|
115
|
+
? `${lead} ${short}`
|
|
116
|
+
: `${lead} in ${short}`;
|
|
117
|
+
};
|
|
118
|
+
if (data.status === "upcoming") return at(data.startTime, "Starts");
|
|
119
|
+
if (data.status === "active") return at(data.endTime, "Ends");
|
|
120
|
+
const short = formatShortDistance(data.endTime, nowMs);
|
|
121
|
+
return short === "now" ? "Ended now" : `Ended ${short}`;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Re-renders on a timer so a countdown stays current; stops once nothing changes. */
|
|
125
|
+
function useNow(live: boolean): number {
|
|
126
|
+
const [now, setNow] = useState(() => Date.now());
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
if (!live) return;
|
|
129
|
+
const id = setInterval(() => setNow(Date.now()), 30_000);
|
|
130
|
+
return () => clearInterval(id);
|
|
131
|
+
}, [live]);
|
|
132
|
+
return now;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function RaffleListingDisplay({
|
|
136
|
+
data,
|
|
137
|
+
imageUrl,
|
|
138
|
+
prizeImageUrls,
|
|
139
|
+
entryAssetImageUrl,
|
|
140
|
+
entryUnavailable,
|
|
141
|
+
notice,
|
|
142
|
+
onRetry,
|
|
143
|
+
onEnter,
|
|
144
|
+
gateEligible,
|
|
145
|
+
gateResults,
|
|
146
|
+
}: RaffleListingDisplayProps) {
|
|
147
|
+
const { theme } = useAppTheme();
|
|
148
|
+
const corrected = data as CorrectedRaffleData;
|
|
149
|
+
const prize = data.prizes.length === 1 ? data.prizes[0] : undefined;
|
|
150
|
+
// On the prize's own page its art and name are already shown above.
|
|
151
|
+
const onSubjectPage = useIsAssetSubject(
|
|
152
|
+
!corrected.isPrizeBox && prize ? prize.id : undefined,
|
|
153
|
+
);
|
|
154
|
+
const isActive = data.status === "active";
|
|
155
|
+
const isOver = data.status === "ended" || data.status === "claimed";
|
|
156
|
+
const now = useNow(!isOver);
|
|
157
|
+
const endingSoon = isActive && data.endTime.getTime() - now < 60 * 60 * 1000;
|
|
158
|
+
const timerLabel = raffleTimerLabel(data, now);
|
|
159
|
+
const entryUnit = data.entryAsset ? getAssetUnitName(data.entryAsset) : "";
|
|
160
|
+
const entryIcon = data.entryAsset
|
|
161
|
+
? getAssetIconSource(data.entryAsset, entryAssetImageUrl)
|
|
162
|
+
: undefined;
|
|
163
|
+
const maxImageHeight = useImageBudget(NON_IMAGE_HEIGHT);
|
|
164
|
+
const participantCount = corrected.participantCount ?? data.entryCount;
|
|
165
|
+
// Legacy package data incorrectly exposed maxTickets as `ticketCount`; do not
|
|
166
|
+
// present it as sold/remaining or total committed when corrected data is absent.
|
|
167
|
+
const totalCommitted =
|
|
168
|
+
corrected.totalTicketWeightRaw ?? corrected.totalTicketWeight;
|
|
169
|
+
const entryDecimals = data.entryAsset?.decimals ?? 6;
|
|
170
|
+
const winner = data.winner;
|
|
171
|
+
const drawStatus = data.drawStatus ?? (winner ? "won" : "drawing");
|
|
172
|
+
const holdings = corrected.isPrizeBox ? (data.prizeBox?.holdings ?? []) : [];
|
|
173
|
+
const boxSheet = useRef<BundleSheetHandle>(null);
|
|
174
|
+
const itemCount = holdings.length || data.prizes.length;
|
|
175
|
+
// Raffles have no title of their own: name the prize, like a listing does.
|
|
176
|
+
const title = corrected.isPrizeBox
|
|
177
|
+
? `Prize box · ${itemCount || "multiple"} ${itemCount === 1 ? "item" : "items"}`
|
|
178
|
+
: prize
|
|
179
|
+
? prize.name
|
|
180
|
+
: data.prizes.length > 1
|
|
181
|
+
? `${data.prizes.length} prizes`
|
|
182
|
+
: data.title;
|
|
183
|
+
const verified =
|
|
184
|
+
!corrected.isPrizeBox &&
|
|
185
|
+
!!prize &&
|
|
186
|
+
(corrected.authenticityBadge || prize.verified);
|
|
187
|
+
const entryRange = walletRangeLabel(
|
|
188
|
+
corrected.minTicketsRaw ?? corrected.minTickets,
|
|
189
|
+
corrected.maxTicketsRaw ?? corrected.maxTickets,
|
|
190
|
+
entryDecimals,
|
|
191
|
+
entryUnit,
|
|
192
|
+
);
|
|
193
|
+
const potLabel = baseUnitLabel(totalCommitted, entryDecimals, entryUnit);
|
|
194
|
+
const entrantsLabel = corrected.isSnapshot
|
|
195
|
+
? "Not indexed"
|
|
196
|
+
: `${formatNumber(participantCount, 0)} ${participantCount === 1 ? "entrant" : "entrants"}`;
|
|
197
|
+
// Per-rule results settle eligibility when the host didn't pass it directly.
|
|
198
|
+
const gatePassed =
|
|
199
|
+
gateEligible ??
|
|
200
|
+
(gateResults?.length && gateResults.length === data.gating?.rules?.length
|
|
201
|
+
? gateResults.every(Boolean)
|
|
202
|
+
: undefined);
|
|
203
|
+
const canEnter = !!onEnter && (isActive || data.status === "upcoming");
|
|
204
|
+
const raffleColor = PLUGIN_COLORS.Raffle;
|
|
205
|
+
|
|
206
|
+
const media = corrected.isPrizeBox ? (
|
|
207
|
+
<PrizeBoxHoldingsMedia
|
|
208
|
+
holdings={holdings}
|
|
209
|
+
onPress={() => boxSheet.current?.present()}
|
|
210
|
+
appId={corrected.prizeBoxAppId}
|
|
211
|
+
maxHeight={maxImageHeight}
|
|
212
|
+
/>
|
|
213
|
+
) : data.prizes.length > 1 ? (
|
|
214
|
+
<PrizePreview prizes={data.prizes} imageUrls={prizeImageUrls} />
|
|
215
|
+
) : imageUrl ? (
|
|
216
|
+
<AdaptiveImage
|
|
217
|
+
uri={imageUrl}
|
|
218
|
+
assetId={prize?.id}
|
|
219
|
+
maxHeight={maxImageHeight}
|
|
220
|
+
borderRadiusTop={0}
|
|
221
|
+
fill
|
|
222
|
+
/>
|
|
223
|
+
) : (
|
|
224
|
+
<ImagePlaceholder
|
|
225
|
+
assetId={prize?.id}
|
|
226
|
+
maxHeight={maxImageHeight}
|
|
227
|
+
borderRadiusTop={0}
|
|
228
|
+
fill
|
|
229
|
+
/>
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
const entryAssetIcon = entryIcon ? (
|
|
233
|
+
<Image
|
|
234
|
+
source={entryIcon}
|
|
235
|
+
style={{ width: 16, height: 16, borderRadius: 8 }}
|
|
236
|
+
/>
|
|
237
|
+
) : null;
|
|
238
|
+
const smallEntryAssetIcon = entryIcon ? (
|
|
239
|
+
<Image
|
|
240
|
+
source={entryIcon}
|
|
241
|
+
style={{ width: 14, height: 14, borderRadius: 7 }}
|
|
242
|
+
/>
|
|
243
|
+
) : null;
|
|
244
|
+
|
|
245
|
+
const timer = (
|
|
246
|
+
<Text
|
|
247
|
+
size="xs"
|
|
248
|
+
weight="semiBold"
|
|
249
|
+
accessibilityLiveRegion="polite"
|
|
250
|
+
style={{
|
|
251
|
+
color: endingSoon
|
|
252
|
+
? (theme.colors.secondary ?? theme.colors.primary)
|
|
253
|
+
: theme.colors.textDim,
|
|
254
|
+
}}
|
|
255
|
+
>
|
|
256
|
+
{timerLabel}
|
|
257
|
+
</Text>
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
const enterButton = (
|
|
261
|
+
<View style={{ flexDirection: "row" }}>
|
|
262
|
+
<OnChainActionButton
|
|
263
|
+
accessibilityLabel={`Enter the raffle for ${title}`}
|
|
264
|
+
label="Enter raffle"
|
|
265
|
+
disabled={!isActive}
|
|
266
|
+
onPress={() => {
|
|
267
|
+
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Medium);
|
|
268
|
+
onEnter?.(data);
|
|
269
|
+
}}
|
|
270
|
+
/>
|
|
271
|
+
</View>
|
|
272
|
+
);
|
|
273
|
+
|
|
274
|
+
return (
|
|
275
|
+
<OnChainActionCard
|
|
276
|
+
accessibilityLabel={`Raffle for ${title}, ${timerLabel}`}
|
|
277
|
+
media={onSubjectPage ? undefined : media}
|
|
278
|
+
testID={`raffle-card-${data.id}`}
|
|
279
|
+
>
|
|
280
|
+
{onSubjectPage ? (
|
|
281
|
+
// On the prize's own page the name and art are already shown above.
|
|
282
|
+
<OnChainActionHeader
|
|
283
|
+
title="Raffle"
|
|
284
|
+
titleColor={raffleColor}
|
|
285
|
+
titleIcon={<RaffleIcon size={18} color={raffleColor} />}
|
|
286
|
+
menu={<ContractMenu appId={data.id} embedType="RaffleListing" />}
|
|
287
|
+
/>
|
|
288
|
+
) : (
|
|
289
|
+
<OnChainActionHeader
|
|
290
|
+
eyebrow="Raffle"
|
|
291
|
+
eyebrowColor={raffleColor}
|
|
292
|
+
eyebrowIcon={<RaffleIcon size={13} color={raffleColor} />}
|
|
293
|
+
title={title}
|
|
294
|
+
titleAccessory={
|
|
295
|
+
verified ? (
|
|
296
|
+
<CheckBadgeIcon size={18} color={theme.colors.primary} />
|
|
297
|
+
) : null
|
|
298
|
+
}
|
|
299
|
+
menu={<ContractMenu appId={data.id} embedType="RaffleListing" />}
|
|
300
|
+
/>
|
|
301
|
+
)}
|
|
302
|
+
|
|
303
|
+
{holdings.length ? <BundleContentsButton holdings={holdings} sheetRef={boxSheet} /> : null}
|
|
304
|
+
|
|
305
|
+
{isOver && (winner || participantCount > 0) ? null : (
|
|
306
|
+
<OnChainMetricGrid>
|
|
307
|
+
<OnChainMetric
|
|
308
|
+
valueIcon={entryAssetIcon}
|
|
309
|
+
label="Entry"
|
|
310
|
+
value={entryRange.value}
|
|
311
|
+
secondary={entryRange.secondary}
|
|
312
|
+
/>
|
|
313
|
+
<OnChainMetric
|
|
314
|
+
valueIcon={entryAssetIcon}
|
|
315
|
+
label="Pot"
|
|
316
|
+
value={potLabel}
|
|
317
|
+
secondary={entrantsLabel}
|
|
318
|
+
/>
|
|
319
|
+
</OnChainMetricGrid>
|
|
320
|
+
)}
|
|
321
|
+
|
|
322
|
+
{notice ? (
|
|
323
|
+
<OnChainActionNotice detail={notice} onRetry={onRetry} />
|
|
324
|
+
) : null}
|
|
325
|
+
|
|
326
|
+
{isOver ? (
|
|
327
|
+
<>
|
|
328
|
+
{timer}
|
|
329
|
+
{winner ? (
|
|
330
|
+
<ResultsPanel>
|
|
331
|
+
<ResultWinner
|
|
332
|
+
address={winner}
|
|
333
|
+
label="Won the raffle"
|
|
334
|
+
glyph="ticket"
|
|
335
|
+
accent={raffleColor}
|
|
336
|
+
amountCaption={data.prizeClaimed ? "Claimed" : undefined}
|
|
337
|
+
/>
|
|
338
|
+
</ResultsPanel>
|
|
339
|
+
) : participantCount > 0 ? (
|
|
340
|
+
<ResultsPanel>
|
|
341
|
+
<ResultPending
|
|
342
|
+
title={
|
|
343
|
+
drawStatus === "waiting"
|
|
344
|
+
? "Not drawn yet"
|
|
345
|
+
: "Drawing now"
|
|
346
|
+
}
|
|
347
|
+
detail="Takes a few rounds"
|
|
348
|
+
accent={raffleColor}
|
|
349
|
+
icon={<TicketIcon size={16} color={raffleColor} />}
|
|
350
|
+
amount={potLabel}
|
|
351
|
+
amountIcon={smallEntryAssetIcon}
|
|
352
|
+
amountCaption={entrantsLabel}
|
|
353
|
+
/>
|
|
354
|
+
</ResultsPanel>
|
|
355
|
+
) : null}
|
|
356
|
+
</>
|
|
357
|
+
) : canEnter && data.gating && gatePassed === false ? (
|
|
358
|
+
<>
|
|
359
|
+
{timer}
|
|
360
|
+
<GateNotice
|
|
361
|
+
gating={data.gating}
|
|
362
|
+
action="enter"
|
|
363
|
+
eligible={false}
|
|
364
|
+
results={gateResults}
|
|
365
|
+
/>
|
|
366
|
+
</>
|
|
367
|
+
) : canEnter ? (
|
|
368
|
+
<>
|
|
369
|
+
{data.gating ? (
|
|
370
|
+
<GateNotice
|
|
371
|
+
gating={data.gating}
|
|
372
|
+
action="enter"
|
|
373
|
+
eligible={gatePassed}
|
|
374
|
+
results={gateResults}
|
|
375
|
+
/>
|
|
376
|
+
) : null}
|
|
377
|
+
<View style={{ gap: 8 }}>
|
|
378
|
+
{timer}
|
|
379
|
+
{enterButton}
|
|
380
|
+
</View>
|
|
381
|
+
</>
|
|
382
|
+
) : isActive && entryUnavailable ? (
|
|
383
|
+
<View style={{ gap: 8 }}>
|
|
384
|
+
{timer}
|
|
385
|
+
<View style={{ flexDirection: "row" }}>
|
|
386
|
+
<OnChainActionButton
|
|
387
|
+
label="Entry terms unavailable"
|
|
388
|
+
disabled
|
|
389
|
+
onPress={() => undefined}
|
|
390
|
+
variant="secondary"
|
|
391
|
+
/>
|
|
392
|
+
</View>
|
|
393
|
+
</View>
|
|
394
|
+
) : (
|
|
395
|
+
timer
|
|
396
|
+
)}
|
|
397
|
+
</OnChainActionCard>
|
|
398
|
+
);
|
|
399
|
+
}
|