@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.
- 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 +280 -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/GuildProposalRef.tsx +285 -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 +140 -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,134 @@
|
|
|
1
|
+
import { isCompactReference, type ReferenceVariantProps } from "../presentation/variants";
|
|
2
|
+
import { CompactPill } from "../presentation/References";
|
|
3
|
+
import { StakingPoolDisplay as StakingPoolPresentation } from "../presentation/StakingPoolDisplay";
|
|
4
|
+
import { OnChainActionButton } from "../presentation/OnChainActionCard";
|
|
5
|
+
import React from "react";
|
|
6
|
+
import type {
|
|
7
|
+
ComponentSize,
|
|
8
|
+
StakingPool as StakingPoolType,
|
|
9
|
+
} from "../types/algorand";
|
|
10
|
+
import { SizeContainer } from "../ui/SizeContainer";
|
|
11
|
+
|
|
12
|
+
export interface StakingPoolProps extends ReferenceVariantProps {
|
|
13
|
+
data: StakingPoolType;
|
|
14
|
+
showEnterButton?: boolean;
|
|
15
|
+
size?: ComponentSize;
|
|
16
|
+
className?: string;
|
|
17
|
+
imageUrl?: string;
|
|
18
|
+
onEnter?: (pool: StakingPoolType) => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The deployed pool checks `nextEntryId + 1 <= maxEntries` before accepting a
|
|
23
|
+
* whole batch. With the one-based cursor, another batch is impossible once the
|
|
24
|
+
* current count reaches target - 1. A final accepted batch can exceed the target.
|
|
25
|
+
*/
|
|
26
|
+
function isEntryTargetClosed(
|
|
27
|
+
current: number,
|
|
28
|
+
currentRaw: string | undefined,
|
|
29
|
+
target: number | undefined,
|
|
30
|
+
targetRaw: string | undefined,
|
|
31
|
+
): boolean {
|
|
32
|
+
try {
|
|
33
|
+
const exactTarget =
|
|
34
|
+
targetRaw != null
|
|
35
|
+
? BigInt(targetRaw)
|
|
36
|
+
: target != null && Number.isSafeInteger(target)
|
|
37
|
+
? BigInt(target)
|
|
38
|
+
: undefined;
|
|
39
|
+
if (exactTarget == null || exactTarget === BigInt(0)) return false;
|
|
40
|
+
const exactCurrent =
|
|
41
|
+
currentRaw != null
|
|
42
|
+
? BigInt(currentRaw)
|
|
43
|
+
: Number.isSafeInteger(current)
|
|
44
|
+
? BigInt(current)
|
|
45
|
+
: undefined;
|
|
46
|
+
return exactCurrent != null && exactCurrent >= exactTarget - BigInt(1);
|
|
47
|
+
} catch {
|
|
48
|
+
return target != null && target > 0 && current >= target - 1;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function StakingPoolComponent({
|
|
53
|
+
data: pool,
|
|
54
|
+
showEnterButton = true,
|
|
55
|
+
size = "full",
|
|
56
|
+
className,
|
|
57
|
+
compact,
|
|
58
|
+
inline,
|
|
59
|
+
imageUrl,
|
|
60
|
+
onEnter,
|
|
61
|
+
}: StakingPoolProps) {
|
|
62
|
+
if (isCompactReference({ size, compact, inline })) return <CompactPill label={pool.title || `Staking Pool #${pool.id}`} inline={inline} />;
|
|
63
|
+
const signupsAvailable =
|
|
64
|
+
pool.status === "signups" ||
|
|
65
|
+
(pool.status === "active" && pool.allowLateSignups);
|
|
66
|
+
const entryCapacity =
|
|
67
|
+
pool.maxEntries != null &&
|
|
68
|
+
Number.isFinite(pool.maxEntries) &&
|
|
69
|
+
pool.maxEntries > 0
|
|
70
|
+
? pool.maxEntries
|
|
71
|
+
: undefined;
|
|
72
|
+
const entryTargetClosed = isEntryTargetClosed(
|
|
73
|
+
pool.entryCount,
|
|
74
|
+
pool.entryCountRaw,
|
|
75
|
+
entryCapacity,
|
|
76
|
+
pool.maxEntriesRaw,
|
|
77
|
+
);
|
|
78
|
+
const canEnter = signupsAvailable && !entryTargetClosed;
|
|
79
|
+
const reward = pool.rewards[0];
|
|
80
|
+
return (
|
|
81
|
+
<SizeContainer size={size} className={className}>
|
|
82
|
+
<StakingPoolPresentation
|
|
83
|
+
data={{
|
|
84
|
+
id: pool.id,
|
|
85
|
+
title: pool.title,
|
|
86
|
+
status: pool.status,
|
|
87
|
+
poolType: pool.stakingType,
|
|
88
|
+
creator: pool.creator,
|
|
89
|
+
signupTime: pool.signupTime,
|
|
90
|
+
startTime: pool.startTime,
|
|
91
|
+
endTime: pool.endTime,
|
|
92
|
+
allowLateSignups: pool.allowLateSignups,
|
|
93
|
+
maxEntries: pool.maxEntries,
|
|
94
|
+
entryCount: pool.entryCount,
|
|
95
|
+
totalStaked:
|
|
96
|
+
pool.totalStakedRaw ??
|
|
97
|
+
(pool.totalStaked == null ? undefined : String(pool.totalStaked)),
|
|
98
|
+
minimumStakeAmount:
|
|
99
|
+
pool.minimumStakeAmountRaw ?? String(pool.minimumStakeAmount),
|
|
100
|
+
stakeDecimals: pool.stakeDecimals,
|
|
101
|
+
stakeUnitName: pool.stakeUnitName,
|
|
102
|
+
stakeListName: pool.stakeKey?.name || undefined,
|
|
103
|
+
gateId: pool.gateAppId,
|
|
104
|
+
unrestricted: pool.unrestricted,
|
|
105
|
+
rewardCount: pool.rewards.length,
|
|
106
|
+
primaryReward: reward
|
|
107
|
+
? {
|
|
108
|
+
assetId: String(reward.asset.id),
|
|
109
|
+
name: reward.asset.name,
|
|
110
|
+
unitName: reward.asset.unitName,
|
|
111
|
+
decimals: reward.asset.decimals,
|
|
112
|
+
rateRaw: reward.rateRaw,
|
|
113
|
+
distribution: reward.distribution,
|
|
114
|
+
intervalSecondsRaw: reward.intervalRaw,
|
|
115
|
+
expirationSecondsRaw: reward.expirationRaw,
|
|
116
|
+
winnerCountRaw: reward.winnerCountRaw,
|
|
117
|
+
budgetRaw: reward.budgetRaw,
|
|
118
|
+
imageUrl: imageUrl ?? reward.asset.imageUrl,
|
|
119
|
+
}
|
|
120
|
+
: undefined,
|
|
121
|
+
}}
|
|
122
|
+
action={
|
|
123
|
+
// When the pool can't be joined, the card's time line says why.
|
|
124
|
+
showEnterButton && onEnter && canEnter ? (
|
|
125
|
+
<OnChainActionButton
|
|
126
|
+
label="Join pool"
|
|
127
|
+
onPress={() => onEnter(pool)}
|
|
128
|
+
/>
|
|
129
|
+
) : undefined
|
|
130
|
+
}
|
|
131
|
+
/>
|
|
132
|
+
</SizeContainer>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { isCompactReference, type ReferenceVariantProps } from "../presentation/variants";
|
|
2
|
+
import { CompactPill } from "../presentation/References";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import {
|
|
5
|
+
TradeOfferDisplay,
|
|
6
|
+
type TradeOfferDisplayProps,
|
|
7
|
+
} from "../presentation/TradeOfferDisplay";
|
|
8
|
+
import type { ComponentSize } from "../types/algorand";
|
|
9
|
+
import { SizeContainer } from "../ui/SizeContainer";
|
|
10
|
+
export interface TradeOfferProps extends TradeOfferDisplayProps, ReferenceVariantProps {
|
|
11
|
+
size?: ComponentSize;
|
|
12
|
+
className?: string;
|
|
13
|
+
showActions?: boolean;
|
|
14
|
+
currentUserAddress?: string;
|
|
15
|
+
}
|
|
16
|
+
export function TradeOfferComponent({
|
|
17
|
+
size = "full",
|
|
18
|
+
className,
|
|
19
|
+
compact,
|
|
20
|
+
inline,
|
|
21
|
+
data,
|
|
22
|
+
showActions = true,
|
|
23
|
+
currentUserAddress,
|
|
24
|
+
onAccept,
|
|
25
|
+
onReject,
|
|
26
|
+
...display
|
|
27
|
+
}: TradeOfferProps) {
|
|
28
|
+
if (isCompactReference({ size, compact, inline })) return <CompactPill label={`Trade #${data.id}`} inline={inline} />;
|
|
29
|
+
const canRespond =
|
|
30
|
+
showActions &&
|
|
31
|
+
!!currentUserAddress &&
|
|
32
|
+
data.recipients.includes(currentUserAddress) &&
|
|
33
|
+
Date.now() <= data.expiresAt.getTime();
|
|
34
|
+
const card = (
|
|
35
|
+
<TradeOfferDisplay
|
|
36
|
+
{...display}
|
|
37
|
+
data={data}
|
|
38
|
+
onAccept={canRespond ? onAccept : undefined}
|
|
39
|
+
onReject={canRespond ? onReject : undefined}
|
|
40
|
+
/>
|
|
41
|
+
);
|
|
42
|
+
return (
|
|
43
|
+
<SizeContainer size={size} className={className}>
|
|
44
|
+
{card}
|
|
45
|
+
</SizeContainer>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import React, { useCallback, useState } from 'react';
|
|
2
|
+
import { View, Text } from 'react-native';
|
|
3
|
+
import type { TradeOffer, ASA, AlgorandAccount } from '../types/algorand';
|
|
4
|
+
import { formatAddress, formatRelativeTime } from '../utils/format';
|
|
5
|
+
import { SearchSheet } from '../ui/SearchSheet';
|
|
6
|
+
|
|
7
|
+
function isASA(item: ASA | AlgorandAccount): item is ASA {
|
|
8
|
+
return 'unitName' in item;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function summarizeAssets(assets: (ASA | AlgorandAccount)[]): string {
|
|
12
|
+
const asas = assets.filter(isASA);
|
|
13
|
+
const accounts = assets.filter((a) => !isASA(a));
|
|
14
|
+
const parts: string[] = [];
|
|
15
|
+
if (asas.length > 0) parts.push(`${asas.length} asset${asas.length > 1 ? 's' : ''}`);
|
|
16
|
+
if (accounts.length > 0) parts.push(`${accounts.length} account${accounts.length > 1 ? 's' : ''}`);
|
|
17
|
+
return parts.join(', ') || 'Empty';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface TradeSearchProps {
|
|
21
|
+
data: TradeOffer[];
|
|
22
|
+
onSelect?: (offer: TradeOffer) => void;
|
|
23
|
+
placeholder?: string;
|
|
24
|
+
className?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function TradeSearch({
|
|
28
|
+
data,
|
|
29
|
+
onSelect,
|
|
30
|
+
placeholder = 'Search trade offers...',
|
|
31
|
+
className,
|
|
32
|
+
}: TradeSearchProps) {
|
|
33
|
+
const [selected, setSelected] = useState<TradeOffer | null>(null);
|
|
34
|
+
|
|
35
|
+
const handleSelect = useCallback(
|
|
36
|
+
(offer: TradeOffer) => {
|
|
37
|
+
setSelected(offer);
|
|
38
|
+
onSelect?.(offer);
|
|
39
|
+
},
|
|
40
|
+
[onSelect],
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const renderItem = useCallback(
|
|
44
|
+
(offer: TradeOffer) => {
|
|
45
|
+
const statusColor =
|
|
46
|
+
offer.status === 'pending'
|
|
47
|
+
? 'text-blue-400'
|
|
48
|
+
: offer.status === 'accepted'
|
|
49
|
+
? 'text-green-400'
|
|
50
|
+
: offer.status === 'rejected'
|
|
51
|
+
? 'text-red-400'
|
|
52
|
+
: 'text-zinc-400';
|
|
53
|
+
|
|
54
|
+
const statusBg =
|
|
55
|
+
offer.status === 'pending'
|
|
56
|
+
? 'bg-blue-500/20'
|
|
57
|
+
: offer.status === 'accepted'
|
|
58
|
+
? 'bg-green-500/20'
|
|
59
|
+
: offer.status === 'rejected'
|
|
60
|
+
? 'bg-red-500/20'
|
|
61
|
+
: 'bg-zinc-700';
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<View className="flex-row items-center gap-3">
|
|
65
|
+
<View className="w-8 h-8 rounded-lg bg-zinc-800 items-center justify-center">
|
|
66
|
+
<Text className="text-xs text-zinc-400">TR</Text>
|
|
67
|
+
</View>
|
|
68
|
+
<View className="flex-1">
|
|
69
|
+
<Text className="text-sm font-medium text-white" numberOfLines={1}>
|
|
70
|
+
{summarizeAssets(offer.offering)} for {summarizeAssets(offer.requesting)}
|
|
71
|
+
</Text>
|
|
72
|
+
<Text className="text-xs text-zinc-400">
|
|
73
|
+
From {formatAddress(offer.creator)} - {formatRelativeTime(offer.createdAt)}
|
|
74
|
+
</Text>
|
|
75
|
+
</View>
|
|
76
|
+
<View className={`px-2 py-0.5 rounded-full ${statusBg}`}>
|
|
77
|
+
<Text className={`text-xs font-medium ${statusColor}`}>
|
|
78
|
+
{offer.status.charAt(0).toUpperCase() + offer.status.slice(1)}
|
|
79
|
+
</Text>
|
|
80
|
+
</View>
|
|
81
|
+
</View>
|
|
82
|
+
);
|
|
83
|
+
},
|
|
84
|
+
[],
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<View className={className}>
|
|
89
|
+
<SearchSheet
|
|
90
|
+
data={data}
|
|
91
|
+
placeholder={placeholder}
|
|
92
|
+
onSelect={handleSelect}
|
|
93
|
+
renderItem={renderItem}
|
|
94
|
+
/>
|
|
95
|
+
{selected && (
|
|
96
|
+
<View className="mt-3 p-3 rounded-lg bg-zinc-800 border border-zinc-700">
|
|
97
|
+
<Text className="text-xs font-medium text-zinc-400 mb-1">Selected Trade</Text>
|
|
98
|
+
{renderItem(selected)}
|
|
99
|
+
</View>
|
|
100
|
+
)}
|
|
101
|
+
</View>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { isCompactReference, type ReferenceVariantProps } from "../presentation/variants";
|
|
2
|
+
import { CompactPill } from "../presentation/References";
|
|
3
|
+
import { formatAddress } from "../utils/format";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import {
|
|
6
|
+
TransactionDisplay,
|
|
7
|
+
type TransactionDisplayProps,
|
|
8
|
+
} from "../presentation/TransactionDisplay";
|
|
9
|
+
import type { ComponentSize } from "../types/algorand";
|
|
10
|
+
import { SizeContainer } from "../ui/SizeContainer";
|
|
11
|
+
export interface TransactionDetailsProps extends TransactionDisplayProps, ReferenceVariantProps {
|
|
12
|
+
size?: ComponentSize;
|
|
13
|
+
className?: string;
|
|
14
|
+
/** @deprecated The shared app layout does not render the legacy context section. */
|
|
15
|
+
showContext?: boolean;
|
|
16
|
+
/** @deprecated The shared app layout does not render the legacy fee section. */
|
|
17
|
+
showFee?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export function TransactionDetailsComponent({
|
|
20
|
+
size = "full",
|
|
21
|
+
className,
|
|
22
|
+
inline,
|
|
23
|
+
data,
|
|
24
|
+
showContext,
|
|
25
|
+
showFee,
|
|
26
|
+
...display
|
|
27
|
+
}: TransactionDetailsProps) {
|
|
28
|
+
if (isCompactReference({ size, compact: display.compact, inline })) return <CompactPill label={`TX ${formatAddress(data.id, 4)}`} inline={inline} />;
|
|
29
|
+
const card = <TransactionDisplay {...display} data={data} />;
|
|
30
|
+
return display.compact ? (
|
|
31
|
+
card
|
|
32
|
+
) : (
|
|
33
|
+
<SizeContainer size={size} className={className}>
|
|
34
|
+
{card}
|
|
35
|
+
</SizeContainer>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import React, { useCallback, useState } from 'react';
|
|
2
|
+
import { View, Text } from 'react-native';
|
|
3
|
+
import Svg, { Path } from 'react-native-svg';
|
|
4
|
+
import type { TransactionDetails } from '../types/algorand';
|
|
5
|
+
import { formatAddress, formatCurrency, formatRelativeTime } from '../utils/format';
|
|
6
|
+
import { SearchSheet } from '../ui/SearchSheet';
|
|
7
|
+
|
|
8
|
+
function CheckCircleIcon({ size = 12, color = '#34d399' }: { size?: number; color?: string }) {
|
|
9
|
+
return (
|
|
10
|
+
<Svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke={color} strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">
|
|
11
|
+
<Path d="M22 11.08V12a10 10 0 1 1-5.93-9.14" />
|
|
12
|
+
<Path d="m9 11 3 3L22 4" />
|
|
13
|
+
</Svg>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function ClockIcon({ size = 12, color = '#facc15' }: { size?: number; color?: string }) {
|
|
18
|
+
return (
|
|
19
|
+
<Svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke={color} strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">
|
|
20
|
+
<Path d="M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20Z" />
|
|
21
|
+
<Path d="M12 6v6l4 2" />
|
|
22
|
+
</Svg>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const TYPE_LABELS: Record<string, string> = {
|
|
27
|
+
payment: 'Payment',
|
|
28
|
+
'asset-transfer': 'Asset Transfer',
|
|
29
|
+
'application-call': 'App Call',
|
|
30
|
+
'asset-config': 'Asset Config',
|
|
31
|
+
'key-registration': 'Key Registration',
|
|
32
|
+
'asset-freeze': 'Asset Freeze',
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
interface TransactionSearchProps {
|
|
36
|
+
data: TransactionDetails[];
|
|
37
|
+
onSelect?: (transaction: TransactionDetails) => void;
|
|
38
|
+
placeholder?: string;
|
|
39
|
+
className?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function TransactionSearch({
|
|
43
|
+
data,
|
|
44
|
+
onSelect,
|
|
45
|
+
placeholder = 'Search transactions...',
|
|
46
|
+
className,
|
|
47
|
+
}: TransactionSearchProps) {
|
|
48
|
+
const [selected, setSelected] = useState<TransactionDetails | null>(null);
|
|
49
|
+
|
|
50
|
+
const handleSelect = useCallback(
|
|
51
|
+
(transaction: TransactionDetails) => {
|
|
52
|
+
setSelected(transaction);
|
|
53
|
+
onSelect?.(transaction);
|
|
54
|
+
},
|
|
55
|
+
[onSelect],
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const renderItem = useCallback(
|
|
59
|
+
(transaction: TransactionDetails) => (
|
|
60
|
+
<View className="flex-row items-center gap-3">
|
|
61
|
+
{transaction.confirmed ? (
|
|
62
|
+
<CheckCircleIcon size={16} color="#34d399" />
|
|
63
|
+
) : (
|
|
64
|
+
<ClockIcon size={16} color="#facc15" />
|
|
65
|
+
)}
|
|
66
|
+
<View className="flex-1">
|
|
67
|
+
<Text className="text-sm font-mono text-white" numberOfLines={1}>
|
|
68
|
+
{formatAddress(transaction.id)}
|
|
69
|
+
</Text>
|
|
70
|
+
<Text className="text-xs text-zinc-400">
|
|
71
|
+
{TYPE_LABELS[transaction.type] || 'Transaction'} - {formatRelativeTime(transaction.timestamp)}
|
|
72
|
+
</Text>
|
|
73
|
+
</View>
|
|
74
|
+
{transaction.amount !== undefined && (
|
|
75
|
+
<Text className="text-xs font-medium text-white">
|
|
76
|
+
{transaction.asset
|
|
77
|
+
? formatCurrency(transaction.amount, transaction.asset.unitName)
|
|
78
|
+
: formatCurrency(transaction.amount / 1_000_000, 'ALGO')}
|
|
79
|
+
</Text>
|
|
80
|
+
)}
|
|
81
|
+
</View>
|
|
82
|
+
),
|
|
83
|
+
[],
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<View className={className}>
|
|
88
|
+
<SearchSheet
|
|
89
|
+
data={data}
|
|
90
|
+
placeholder={placeholder}
|
|
91
|
+
onSelect={handleSelect}
|
|
92
|
+
renderItem={renderItem}
|
|
93
|
+
/>
|
|
94
|
+
{selected && (
|
|
95
|
+
<View className="mt-3 p-3 rounded-lg bg-zinc-800 border border-zinc-700">
|
|
96
|
+
<Text className="text-xs font-medium text-zinc-400 mb-1">Selected Transaction</Text>
|
|
97
|
+
{renderItem(selected)}
|
|
98
|
+
</View>
|
|
99
|
+
)}
|
|
100
|
+
</View>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* algomd-rn wrapper over `@akita-protocol/txn-graph-rn`'s `<TxnGraph>`.
|
|
3
|
+
*
|
|
4
|
+
* The library is transport- and resolver-agnostic. This wrapper pre-wires
|
|
5
|
+
* a `DataProvider` so consumers don't have to plumb one themselves — in
|
|
6
|
+
* the common case they pass a `QueryClient` + `AlgorandClient` and get a
|
|
7
|
+
* fully-resolved graph (unit names on asset pills, etc.).
|
|
8
|
+
*
|
|
9
|
+
* Advanced consumers can still pass a `dataProvider` prop directly to
|
|
10
|
+
* swap in their own resolver — useful when the app already has a Jotai
|
|
11
|
+
* store (lora's case) or a preloaded cache.
|
|
12
|
+
*
|
|
13
|
+
* If neither is supplied we wire a minimal stub provider so the graph
|
|
14
|
+
* renders with the passthrough-only defaults the library assumes. That
|
|
15
|
+
* keeps the demo-screen path in `akita-rn` simple (no cache wiring
|
|
16
|
+
* required to see the visual).
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import React from 'react'
|
|
20
|
+
import {
|
|
21
|
+
TxnGraph as BaseTransactionsGraph,
|
|
22
|
+
DataProvider,
|
|
23
|
+
type DataProviderApi,
|
|
24
|
+
type TxnGraphProps,
|
|
25
|
+
} from '@akita-protocol/txn-graph-rn'
|
|
26
|
+
|
|
27
|
+
export type TransactionsGraphProps = TxnGraphProps & {
|
|
28
|
+
/**
|
|
29
|
+
* Consumer-injected resolver. If omitted, a no-op stub is used that
|
|
30
|
+
* returns only the raw ids — asset pills render without unit names
|
|
31
|
+
* but the graph's layout and navigation are unaffected.
|
|
32
|
+
*
|
|
33
|
+
* Use `createAlgomdDataProvider({ queryClient, algorand })` from
|
|
34
|
+
* `@akita-protocol/algomd-rn/adapters` to get a react-query-backed resolver
|
|
35
|
+
* that shares its cache with the rest of algomd-rn's UI.
|
|
36
|
+
*/
|
|
37
|
+
dataProvider?: DataProviderApi
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Minimal stub — returns the raw identity fields only. The library's
|
|
42
|
+
* `AssetBadge` / `AccountNode` / node primitives degrade gracefully when
|
|
43
|
+
* the optional metadata fields are missing.
|
|
44
|
+
*/
|
|
45
|
+
const stubDataProvider: DataProviderApi = {
|
|
46
|
+
getAccountSummary: (address) => ({ address }),
|
|
47
|
+
getAssetSummary: (id) => ({ id, decimals: 0 }),
|
|
48
|
+
getApplicationSummary: (id) => ({ id }),
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function TransactionsGraph({
|
|
52
|
+
dataProvider,
|
|
53
|
+
...rest
|
|
54
|
+
}: TransactionsGraphProps) {
|
|
55
|
+
return (
|
|
56
|
+
<DataProvider api={dataProvider ?? stubDataProvider}>
|
|
57
|
+
<BaseTransactionsGraph {...rest} />
|
|
58
|
+
</DataProvider>
|
|
59
|
+
)
|
|
60
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Self-fetching display components (backward compatible — accept data or self-fetch props)
|
|
2
|
+
export { Account } from "./SelfFetching";
|
|
3
|
+
export { ASA } from "./SelfFetching";
|
|
4
|
+
export { Collection } from "./SelfFetching";
|
|
5
|
+
export { NFTListing } from "./SelfFetching";
|
|
6
|
+
export { NFDProfile } from "./SelfFetching";
|
|
7
|
+
export { TransactionDetails } from "./SelfFetching";
|
|
8
|
+
export { Poll } from "./SelfFetching";
|
|
9
|
+
export { RaffleListing } from "./SelfFetching";
|
|
10
|
+
export { StakingPool } from "./SelfFetching";
|
|
11
|
+
export type { StakingPoolSelfFetchProps } from "./SelfFetching";
|
|
12
|
+
export { AuctionListing } from "./SelfFetching";
|
|
13
|
+
export { TradeOffer } from "./SelfFetching";
|
|
14
|
+
export { DualStakePool, DualStakePoolComponent } from "./DualStakePool";
|
|
15
|
+
export type { DualStakePoolProps } from "./DualStakePool";
|
|
16
|
+
|
|
17
|
+
// Display-only components (no self-fetch, for internal/advanced use)
|
|
18
|
+
export { Account as AccountDisplay } from "./Account";
|
|
19
|
+
export { ASAComponent as ASADisplay } from "./ASA";
|
|
20
|
+
export { CollectionComponent as CollectionDisplay } from "./Collection";
|
|
21
|
+
export { NFTListingComponent as NFTListingDisplay } from "./NFTListing";
|
|
22
|
+
export { NFDProfileComponent as NFDProfileDisplay } from "./NFDProfile";
|
|
23
|
+
export { TransactionDetailsComponent as TransactionDetailsDisplay } from "./TransactionDetails";
|
|
24
|
+
export { PollComponent as PollDisplay } from "./Poll";
|
|
25
|
+
export { RaffleListingComponent as RaffleListingDisplay } from "./RaffleListing";
|
|
26
|
+
export { StakingPoolComponent as StakingPoolDisplay } from "./StakingPool";
|
|
27
|
+
export type { StakingPoolProps } from "./StakingPool";
|
|
28
|
+
export { AuctionListingComponent as AuctionListingDisplay } from "./AuctionListing";
|
|
29
|
+
export { TradeOfferComponent as TradeOfferDisplay } from "./TradeOffer";
|
|
30
|
+
export { DualStakePoolComponent as DualStakePoolDisplay } from "./DualStakePool";
|
|
31
|
+
|
|
32
|
+
// Search Components
|
|
33
|
+
export { AccountSearch } from "./AccountSearch";
|
|
34
|
+
export { ASASearch } from "./ASASearch";
|
|
35
|
+
export { NFTSearch } from "./NFTSearch";
|
|
36
|
+
export { NFDSearch } from "./NFDSearch";
|
|
37
|
+
export { TransactionSearch } from "./TransactionSearch";
|
|
38
|
+
export { PollSearch } from "./PollSearch";
|
|
39
|
+
export { TradeSearch } from "./TradeSearch";
|
|
40
|
+
|
|
41
|
+
// Visualizer wrapper (@akita-protocol/txn-graph-rn)
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2020 The Space Grotesk Project Authors (https://github.com/floriankarsten/space-grotesk)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
@font-face { font-family: 'spaceGroteskLight'; src: url('./SpaceGrotesk_300Light.ttf') format('truetype'); font-style: normal; font-weight: 400; font-display: block; }
|
|
2
|
+
@font-face { font-family: 'spaceGroteskRegular'; src: url('./SpaceGrotesk_400Regular.ttf') format('truetype'); font-style: normal; font-weight: 400; font-display: block; }
|
|
3
|
+
@font-face { font-family: 'spaceGroteskMedium'; src: url('./SpaceGrotesk_500Medium.ttf') format('truetype'); font-style: normal; font-weight: 400; font-display: block; }
|
|
4
|
+
@font-face { font-family: 'spaceGroteskSemiBold'; src: url('./SpaceGrotesk_600SemiBold.ttf') format('truetype'); font-style: normal; font-weight: 400; font-display: block; }
|
|
5
|
+
@font-face { font-family: 'spaceGroteskBold'; src: url('./SpaceGrotesk_700Bold.ttf') format('truetype'); font-style: normal; font-weight: 400; font-display: block; }
|
package/src/graph.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { useAlgorandClient, useIndexerClient } from "./useAlgorandClient";
|
|
2
|
+
export {
|
|
3
|
+
useAccountData,
|
|
4
|
+
useASAData,
|
|
5
|
+
useAssetCollection,
|
|
6
|
+
useAssetPriceHistory,
|
|
7
|
+
useAssetCirculatingSupply,
|
|
8
|
+
useCollectionData,
|
|
9
|
+
useTransactionData,
|
|
10
|
+
useNFDProfileData,
|
|
11
|
+
usePollData,
|
|
12
|
+
useRaffleData,
|
|
13
|
+
useStakingPoolData,
|
|
14
|
+
useAuctionData,
|
|
15
|
+
useNFTListingData,
|
|
16
|
+
useTradeOfferData,
|
|
17
|
+
} from "./useAlgomdData";
|