@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,137 @@
|
|
|
1
|
+
import React, { Fragment } from "react";
|
|
2
|
+
import { Text as NativeText, View, type TextProps } from "react-native";
|
|
3
|
+
import { parseContent, type Ref as CoreRef, type Size } from "@akita-protocol/algomd-core";
|
|
4
|
+
import { useAlgomdClient } from "@akita-protocol/algomd-core/react";
|
|
5
|
+
import { AccountRef } from "./AccountRef";
|
|
6
|
+
import { ApplicationRef } from "./ApplicationRef";
|
|
7
|
+
import { AssetRef } from "./AssetRef";
|
|
8
|
+
import { AuctionRef } from "./AuctionRef";
|
|
9
|
+
import { CollectionRef } from "./CollectionRef";
|
|
10
|
+
import { ListingRef } from "./ListingRef";
|
|
11
|
+
import { NfdRef } from "./NfdRef";
|
|
12
|
+
import { PollRef } from "./PollRef";
|
|
13
|
+
import { RaffleRef } from "./RaffleRef";
|
|
14
|
+
import { TransactionRef } from "./TransactionRef";
|
|
15
|
+
import { StakingPoolRef } from "./StakingPoolRef";
|
|
16
|
+
import { RewardRef } from "./RewardRef";
|
|
17
|
+
import { SubscriptionRef } from "./SubscriptionRef";
|
|
18
|
+
import { TradeRef } from "./TradeRef";
|
|
19
|
+
import { DualStakeRef } from "./DualStakeRef";
|
|
20
|
+
import { PageCardRef, PageLinksProvider, PrivateContentRef, type PageLinks } from "./HostRefs";
|
|
21
|
+
import type { RefViewProps } from "./types";
|
|
22
|
+
|
|
23
|
+
export { AccountRef } from "./AccountRef";
|
|
24
|
+
export { AssetRef } from "./AssetRef";
|
|
25
|
+
export { ApplicationRef } from "./ApplicationRef";
|
|
26
|
+
export { NfdRef } from "./NfdRef";
|
|
27
|
+
export { CollectionRef } from "./CollectionRef";
|
|
28
|
+
export { ListingRef } from "./ListingRef";
|
|
29
|
+
export { AuctionRef } from "./AuctionRef";
|
|
30
|
+
export { RaffleRef } from "./RaffleRef";
|
|
31
|
+
export { PollRef } from "./PollRef";
|
|
32
|
+
export { TransactionRef, summarizeTransaction, type TxSummary } from "./TransactionRef";
|
|
33
|
+
export { StakingPoolRef } from "./StakingPoolRef";
|
|
34
|
+
export { RewardRef } from "./RewardRef";
|
|
35
|
+
export { SubscriptionRef } from "./SubscriptionRef";
|
|
36
|
+
export { TradeRef } from "./TradeRef";
|
|
37
|
+
export { DualStakeRef } from "./DualStakeRef";
|
|
38
|
+
export { PageCardRef, PageLinksProvider, PrivateContentRef, type PageLinks } from "./HostRefs";
|
|
39
|
+
export { useAssetInfo, useFormattedAmount, ALGO_ASSET, type AssetInfo } from "./assetInfo";
|
|
40
|
+
export { Amount, StatusChip, ProvenanceNote, useNow } from "./contractParts";
|
|
41
|
+
export * from "./primitives";
|
|
42
|
+
export type { RefViewProps } from "./types";
|
|
43
|
+
|
|
44
|
+
/** Views for kinds rebuilt on @akita-protocol/algomd-core. Other kinds go to `fallback`. */
|
|
45
|
+
export const REF_VIEWS: Record<string, React.ComponentType<RefViewProps>> = {
|
|
46
|
+
account: AccountRef,
|
|
47
|
+
asset: AssetRef,
|
|
48
|
+
application: ApplicationRef,
|
|
49
|
+
nfd: NfdRef,
|
|
50
|
+
collection: CollectionRef,
|
|
51
|
+
listing: ListingRef,
|
|
52
|
+
auction: AuctionRef,
|
|
53
|
+
raffle: RaffleRef,
|
|
54
|
+
poll: PollRef,
|
|
55
|
+
transaction: TransactionRef,
|
|
56
|
+
"staking-pool": StakingPoolRef,
|
|
57
|
+
reward: RewardRef,
|
|
58
|
+
subscription: SubscriptionRef,
|
|
59
|
+
trade: TradeRef,
|
|
60
|
+
"dual-stake": DualStakeRef,
|
|
61
|
+
"page-card": PageCardRef,
|
|
62
|
+
"private-content": PrivateContentRef,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export interface RefProps extends RefViewProps {
|
|
66
|
+
kind: string;
|
|
67
|
+
/** Renders kinds without a view here, e.g. the host's existing components during migration. */
|
|
68
|
+
fallback?: (ref: CoreRef & { size: Size }) => React.ReactNode;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* One reference: `<Ref kind="asset" id="31566704" size="inline" />`.
|
|
73
|
+
* Block sizes sit in a View, so they fill the width on the web too, where a
|
|
74
|
+
* host's plain block parent would otherwise shrink a pressable card to fit.
|
|
75
|
+
*/
|
|
76
|
+
export function Ref({ kind, fallback, ...props }: RefProps) {
|
|
77
|
+
const Component = REF_VIEWS[kind];
|
|
78
|
+
if (Component) {
|
|
79
|
+
return props.size === "inline" ? <Component {...props} /> : <View><Component {...props} /></View>;
|
|
80
|
+
}
|
|
81
|
+
return <>{fallback?.({ kind, id: props.id, params: props.params, size: props.size ?? "large" }) ?? null}</>;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface RefContentProps {
|
|
85
|
+
content: string;
|
|
86
|
+
/** Renders a run of plain text (markdown) with the inline refs that follow it. Defaults to a plain Text. */
|
|
87
|
+
renderText?: (children: React.ReactNode[], key: string) => React.ReactNode;
|
|
88
|
+
textProps?: TextProps;
|
|
89
|
+
/** Size for refs stored without one. Default `large`. */
|
|
90
|
+
defaultSize?: Size;
|
|
91
|
+
fallback?: RefProps["fallback"];
|
|
92
|
+
visible?: boolean;
|
|
93
|
+
/** Pages of this post, for page cards. */
|
|
94
|
+
pages?: PageLinks;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Renders AlgoMD content: text with inline refs flows as one Text run, and
|
|
99
|
+
* every other ref is its own block. Parsing uses the client's registry.
|
|
100
|
+
*/
|
|
101
|
+
export function RefContent({ content, renderText, textProps, defaultSize = "large", fallback, visible, pages }: RefContentProps) {
|
|
102
|
+
const client = useAlgomdClient();
|
|
103
|
+
const segments = parseContent(content, client.registry);
|
|
104
|
+
const out: React.ReactNode[] = [];
|
|
105
|
+
let run: React.ReactNode[] = [];
|
|
106
|
+
const flush = (key: string) => {
|
|
107
|
+
if (!run.length) return;
|
|
108
|
+
const children = run;
|
|
109
|
+
run = [];
|
|
110
|
+
out.push(renderText ? <Fragment key={key}>{renderText(children, key)}</Fragment> : <NativeText key={key} {...textProps}>{children}</NativeText>);
|
|
111
|
+
};
|
|
112
|
+
let afterBlock = false;
|
|
113
|
+
segments.forEach((s, i) => {
|
|
114
|
+
if (s.type === "text") {
|
|
115
|
+
// Blocks bring their own spacing; newlines next to them would add blank lines.
|
|
116
|
+
const next = segments[i + 1];
|
|
117
|
+
const beforeBlock = next?.type !== "text" && next !== undefined && (next.ref.size ?? defaultSize) !== "inline";
|
|
118
|
+
let text = afterBlock ? s.content.replace(/^\s*\n/, "") : s.content;
|
|
119
|
+
if (beforeBlock) text = text.replace(/\n\s*$/, "");
|
|
120
|
+
afterBlock = false;
|
|
121
|
+
if (text) run.push(text);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const size = s.ref.size ?? defaultSize;
|
|
125
|
+
const node = <Ref key={`r${i}`} kind={s.ref.kind} id={s.ref.id} params={s.ref.params} size={size} fallback={fallback} visible={visible} />;
|
|
126
|
+
if (size === "inline") {
|
|
127
|
+
afterBlock = false;
|
|
128
|
+
run.push(node);
|
|
129
|
+
} else {
|
|
130
|
+
afterBlock = true;
|
|
131
|
+
flush(`t${i}`);
|
|
132
|
+
out.push(<View key={`b${i}`} style={{ marginVertical: 6 }}>{node}</View>);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
flush("tail");
|
|
136
|
+
return pages ? <PageLinksProvider value={pages}>{out}</PageLinksProvider> : <>{out}</>;
|
|
137
|
+
}
|