@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
package/README.md CHANGED
@@ -1,3 +1,138 @@
1
- # Temporary Holding Version
1
+ # AlgoMD React Native component workshop
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Develop the React Native and web libraries against the same inputs, then verify real reads and transactions on LocalNet.
4
+
5
+ ## LocalNet component viewer
6
+
7
+ ```sh
8
+ pnpm viewer:start
9
+ ```
10
+
11
+ Open [the component viewer](http://localhost:6010). It starts both Storybooks, brings up the Akita infrastructure, and creates or resumes a dataset with generated Akita artwork stored in local IPFS. It reuses the main app's deployment script for a missing universe and preserves an existing deployment/database on ordinary starts.
12
+
13
+ Choose any of the 21 components to compare the native and web renderers. **Visual fixture** provides editable shared JSON; **Live LocalNet** reads actual records and submits votes, bids, raffle entries, purchases, staking entries, and test payments using a funded local account. Confirmed changes refresh both previews. **New dataset** creates new contracts and assets without resetting the chain.
14
+
15
+ ```sh
16
+ pnpm viewer # viewer + Storybooks, without setup or seeding
17
+ pnpm viewer:setup # infrastructure + resumable seed, then exit
18
+ pnpm viewer:typecheck
19
+ pnpm test:viewer # requires the viewer/infra; creates and transacts on a fresh dataset
20
+ ```
21
+
22
+ See [viewer setup and coverage](viewer/README.md) for prerequisites, data sources, MDX exports, and current trade/DualStake limitations.
23
+
24
+ ## Open the workshop
25
+
26
+ Use Node 22 and pnpm 10. Keep these checkouts beside each other: `algomd-rn`, `algomd-web`, and `akita-rn`. The graph component also uses `experiments/txn-graph/packages/rn` and `packages/web` (local dependencies in these checkouts).
27
+
28
+ ```sh
29
+ pnpm --dir ../experiments/txn-graph install
30
+ pnpm install
31
+ npm --prefix ../algomd-web install
32
+ pnpm storybook:both
33
+ ```
34
+
35
+ - **Compare both renderers:** http://localhost:6006/parity.html
36
+ - **React Native in the browser:** http://localhost:6006
37
+ - **Web:** http://localhost:6007
38
+
39
+ The comparison page selects the same component/state at 320, 390, 768, or 1280 pixels. Open either Controls link to edit data, sizes, and component props. Source changes hot reload. Controls are temporary; persist fixtures in `storybook/fixtures/index.ts`, or save a custom story. Generated scenario files are owned by `scripts/generate-stories.mjs`; put custom stories in a separate file so regeneration cannot overwrite them.
40
+
41
+ ## Native app baseline
42
+
43
+ The app's eleven custom displays, collection and page-link layouts, private-content states, placeholders, and shared cards, image sizing, identity rows, badges, menus, formatting, compact references, and snapshot states now live in `algomd-rn/src/presentation`. The old app display paths only re-export this public API. **Edit the library**, then run `pnpm parity:sync` to generate the web implementation. `pnpm parity:check` detects both generated web drift and restored app display forks when the app checkout is available.
44
+
45
+ `AlgomdPresentationProvider` injects theme, text, gradients, identity resolution/badges, explorer links, and profile navigation. The app's `AlgomdPresentation.tsx` connects its existing hooks and services; its wallet and data controllers still supply the displays' action callbacks. Standalone previews use the same bundled theme, icons, fonts, layout, and formatting with fixture identities. Native menus use Gorhom bottom sheets; web supplies a DOM sheet with the same content and actions. Native press feedback uses the app's spring; the DOM adapter uses a CSS transition. Device gestures still need on-device review.
46
+
47
+ The app keeps data fetching, wallet signing, bid/raffle amount sheets, cost disclosures, routing, and private-content decryption. Those controllers pass data and callbacks into shared presentations. `AlgomdPresentation.tsx` also registers the shared image caches with the app's identity-clear lifecycle. The old `displays/*` and migrated `shared/*` modules contain exports only; the ownership check rejects local rendering in those modules or in the MDX wrapper.
48
+
49
+ Size selects a presentation as well as a width. For the twelve entity components, `size="sm"` uses the app's compact reference. Account and ASA use the avatar/image pills shared with the app's editor; `inline` selects a text-only reference safe to nest inside native Text. `compact={false}` explicitly keeps a card even at the small width. Medium and large constrain card width, so they can look alike in a narrow viewport. Fullscreen Account and ASA enable held assets and asset details. Searches, the transaction graph, and prize boxes have one presentation and appear once per renderer in the viewer.
50
+
51
+ The main app currently links `@akita-protocol/algomd-rn` to `../algomd-rn`. Metro watches that source and resolves native peer dependencies from the app so there is only one React Native and query runtime. App TypeScript paths follow the same peer resolution. Keep the local link while developing these checkouts together; publishing the library and updating the app dependency is a separate release step.
52
+
53
+ Page links, locked/unlocked content, placeholders, snapshots, loading, and inline identities have additional controls and stories under **References / App embeds**. The older `showApps`, `showContext`, and `showFee` props are deprecated because those extra sections are absent from the app layout.
54
+
55
+ Browser previews bundle the app's Space Grotesk fonts. Native hosts must register the five `spaceGrotesk*` families shown in `examples/native/.rnstorybook/preview.tsx`; the main app already does this.
56
+
57
+ ## Coverage and keeping the platforms aligned
58
+
59
+ The shared catalog covers Account, ASA, Collection, NFDProfile, TransactionDetails, NFTListing, Poll, RaffleListing, AuctionListing, TradeOffer, DualStakePool, StakingPool, and PrizeBoxBundle. States include sizes, gating, upcoming/ended/claimed, zero votes, full pools, disconnected wallets, invalid amounts, errors, and loading. Both platforms also include all seven search components, TransactionsGraph, and the UI helpers. Extra scenarios cover compact cards, asset details, hidden actions, missing images, all transaction types, and staking/reward variants.
60
+
61
+ Both implementations import the **same fixture objects**, including dates, addresses, asset decimals, and exact uint64 amounts. Mock previews use a fixed clock, inline images, and action spies. Live services are prohibited by the mock browser tests. Fixtures and preview dependencies are development-only and are excluded from the published library's `files` list.
62
+
63
+ When changing a shared component:
64
+
65
+ 1. Update the shared fixture or scenario generator and run `pnpm storybook:generate` if needed.
66
+ 2. Edit `algomd-rn/src/presentation` for display layouts or `src/components` for public prop/data adapters and action controllers. `pnpm storybook:both` automatically syncs source changes into the web DOM components. Outside that command, run `pnpm parity:sync`. Generated web files identify their native source; browser adapters live in `algomd-web/src/presentation/platform.tsx`, `sheets.tsx`, `SquishyPressable.tsx`, and `src/ui`. Review the pair at phone and desktop widths.
67
+ 3. Run both Storybook type checks, then `pnpm test:parity` for source drift, direct image comparisons, searches, and callback checks. Run `pnpm test:visual` for stored baseline regressions as well.
68
+ 4. Review intentional screenshot changes before accepting them with `pnpm test:visual:update`.
69
+
70
+ ```sh
71
+ pnpm compile
72
+ pnpm storybook:typecheck
73
+ npm --prefix ../algomd-web run storybook:typecheck
74
+ pnpm exec playwright install chromium
75
+ pnpm test:visual
76
+ pnpm exec playwright show-report
77
+ ```
78
+
79
+ Tests build both catalogs and use isolated static servers on 6106/6107 so hot reload cannot corrupt screenshots. They check every mock story at 390 and 1280 pixels, reject runtime errors/live requests, require matching shared story IDs, and exercise marketplace actions, clipboard, all seven search/selection flows, graph controls, poll voting, and dual-stake callback contracts (including different ALGO/LST decimals), plus actual progress fill geometry and color. Baseline files are included for Chromium on macOS. Use a macOS runner with the locked Playwright version when running them in CI.
80
+
81
+ Direct parity tests compare the **current native and web screenshots to each other**, including open search sheets and selected results. They require zero differing pixels after antialiasing/color comparison (0.1 threshold). Transformed graph SVG text uses a 0.2 color threshold and permits at most 32 differing pixels, strictly inside text bounds, for Chromium glyph rounding; graph shapes and controls have no allowance. Updating saved baselines cannot approve a mismatch between platforms. The source check also fails when a generated web component differs from its RN source. These checks run the actual RN components through React Native Web in Chromium; device font rasterization, touch gestures, and native modules still need the Expo/device pass below.
82
+
83
+ ## On-device Storybook
84
+
85
+ A separate Expo SDK 57 app uses the same native stories and library source. It owns its native dependencies so the library's browser tooling cannot change the Akita app's runtime.
86
+
87
+ ```sh
88
+ pnpm --dir examples/native install
89
+ pnpm storybook:native
90
+ # Or:
91
+ pnpm --dir examples/native ios
92
+ pnpm --dir examples/native android
93
+ ```
94
+
95
+ Use a compatible Expo Go build or development build. The iOS JavaScript/Hermes export can be checked without a simulator:
96
+
97
+ ```sh
98
+ pnpm --dir examples/native export:ios
99
+ ```
100
+
101
+ Browser-only interaction stories live in `storybook/browser`; native stories are in `storybook/stories`. Actual device gestures, clipboard, haptics, and image decoding still need on-device review. Set `EXPO_PUBLIC_LOCALNET_HOST` to your computer's LAN address for a phone, or `10.0.2.2` for an Android emulator. The iOS simulator can use `localhost`.
102
+
103
+ ## LocalNet
104
+
105
+ The main app's `scripts/setup-localnet.sh` remains the deployment and seed entry point. This workshop calls it and asks `scripts/mock-init.ts` to export the IDs used by its MDX posts. Only public addresses and IDs are exported; mnemonics and API credentials never go into stories or the manifest.
106
+
107
+ ```sh
108
+ pnpm localnet:setup # calls akita-rn; skips chain reset
109
+ pnpm localnet:setup --reset # explicitly opts into the main script's chain reset
110
+ pnpm localnet:setup --skip-universe # reuse an existing deployment
111
+ pnpm localnet:seed # seed component entities and their MDX posts
112
+ pnpm localnet:check
113
+ pnpm test:localnet
114
+ ```
115
+
116
+ The wrapper opts into `ALGOMD_SEED_ONLY=1`: the main script creates the funded accounts, assets, component contracts, and MDX posts, then skips unrelated community/reaction generation and the DAO community posting grant. The normal main-app setup is unchanged when that flag is absent. Set `ALGOMD_SEED_ONLY=0` to request the full seed.
117
+
118
+ The existing main setup script rebuilds/reinitializes its development backend database even with `--skip-reset`; that flag preserves the chain only. `localnet:seed` creates additional local accounts/assets/contracts/posts. Use `localnet:import /path/to/manifest.json` when reusing IDs, rather than reseeding.
119
+
120
+ `storybook/localnet.generated.json` is ignored and is bootstrapped automatically. Both Storybooks consume the same file. The `LocalNet / Seeded MDX embeds` story uses the real data-fetching components; web additionally exercises the MDX parser. IDs can also be edited with Controls. Live stories do not use the mock clock or screenshot baselines. The native preview explicitly configures the SDK network, as the main app does. Web LocalNet reads overlay on-chain state over gateway metadata so partially indexed creation rows cannot display zero prices or missing dates.
121
+
122
+ The original main-app seed covers account, ASA, poll, raffle, auction, and listing. The component viewer above adds staking, prize boxes, generated artwork, local collection/NFD index fixtures, and live transaction actions. Its dataset is separate from `storybook/localnet.generated.json` so either workflow can be used independently.
123
+
124
+ ### Test wallet functionality in the main app
125
+
126
+ ```sh
127
+ pnpm mainapp:dev
128
+ ```
129
+
130
+ This sets `ALGOMD_SOURCE=1` for the main app's Metro process so `@akita-protocol/algomd-rn` resolves to this checkout. The local package link also enables source resolution without this flag. The main app supplies wallet connection, signing, transaction sheets, and post rendering; Storybook action spies only verify callback inputs. Select LocalNet in the main app and use its existing funded development account. `AKITA_RN_DIR` can point at another main-app checkout; `ALGOMD_SOURCE_DIR` overrides the source location relative to that app.
131
+
132
+ ### Full main-app seed limitations
133
+
134
+ The normal full setup currently stops in `akita-sc/projects/akita-sc/scripts/install-dao-social-caller.ts` because its KMD fallback calls `account.address.equals`, but the installed SDK returns a string. Deployment and backend startup succeeded before this step. The workshop's component mode skips that unrelated grant and stops after creating the MDX posts. The full seed also hit a node socket failure during community posting after creating the component fixtures. These failures do not affect the passing component LocalNet read checks; they remain issues in the full-app seed.
135
+
136
+ ## Build notes
137
+
138
+ Storybook uses the official React Native Web Vite framework, with NativeWind and the Reanimated Babel plugin. `.storybook/reanimated-vite.ts` makes Reanimated 4.2's optional CommonJS web-style imports static for Vite; it uses real RNW style functions and does not mock animations. See [Storybook's framework guide](https://storybook.js.org/docs/get-started/frameworks/react-native-web-vite) and [the upstream Reanimated issue](https://github.com/software-mansion/react-native-reanimated/issues/6775).
package/package.json CHANGED
@@ -1,6 +1,121 @@
1
1
  {
2
2
  "name": "@akita-protocol/algomd-rn",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.0.0-alpha.1",
4
+ "main": "src/index.ts",
5
+ "types": "src/index.ts",
6
+ "react-native": "src/index.ts",
7
+ "files": [
8
+ "src/"
9
+ ],
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "peerDependencies": {
14
+ "@akita-protocol/sdk": ">=1.4.12",
15
+ "@akita-protocol/txn-graph-rn": ">=0.2.1",
16
+ "@algorandfoundation/algokit-utils": ">=10.0.0-beta.1",
17
+ "@gorhom/bottom-sheet": ">=5.0.0",
18
+ "@shopify/flash-list": ">=2.0.0",
19
+ "@tanstack/react-query": ">=5",
20
+ "algosdk": ">=3.0.0",
21
+ "clsx": ">=2.0.0",
22
+ "expo-clipboard": ">=8.0.0",
23
+ "expo-haptics": ">=15.0.0",
24
+ "expo-image": ">=3.0.0",
25
+ "expo-linking": ">=8.0.0",
26
+ "nativewind": ">=4.0.0",
27
+ "react": ">=19.0.0",
28
+ "react-native": ">=0.81.0",
29
+ "react-native-gesture-handler": ">=2.0.0",
30
+ "react-native-reanimated": ">=4.0.0",
31
+ "react-native-svg": ">=15.0.0"
32
+ },
33
+ "peerDependenciesMeta": {
34
+ "@akita-protocol/txn-graph-rn": {
35
+ "optional": true
36
+ },
37
+ "@akita-protocol/sdk": {
38
+ "optional": true
39
+ }
40
+ },
41
+ "devDependencies": {
42
+ "@akita-protocol/sdk": "1.4.12",
43
+ "@algorandfoundation/algokit-utils": "10.0.0-beta.1",
44
+ "@gorhom/bottom-sheet": "^5.2.14",
45
+ "@playwright/test": "^1.63.0",
46
+ "@storybook/addon-a11y": "10.6.0",
47
+ "@storybook/addon-docs": "10.6.0",
48
+ "@storybook/react": "10.6.0",
49
+ "@storybook/react-native-web-vite": "10.6.0",
50
+ "@tanstack/react-query": "^5.96.2",
51
+ "@types/node": "^22.20.2",
52
+ "@types/pixelmatch": "^7.1.0",
53
+ "@types/pngjs": "^6.0.5",
54
+ "@types/react": "^19.1.0",
55
+ "algosdk": "^3.6.0",
56
+ "autoprefixer": "^10.5.6",
57
+ "buffer": "^6.0.3",
58
+ "esbuild": "^0.25.12",
59
+ "expo-clipboard": "^57.0.0",
60
+ "expo-haptics": "^57.0.0",
61
+ "expo-image": "^57.0.3",
62
+ "expo-linking": "^57.0.0",
63
+ "mockdate": "^3.0.5",
64
+ "pixelmatch": "^7.2.0",
65
+ "pngjs": "^7.0.0",
66
+ "postcss": "^8.5.28",
67
+ "react": "19.2.4",
68
+ "react-dom": "19.2.4",
69
+ "react-native": "0.86.2",
70
+ "react-native-css-interop": "0.2.2",
71
+ "react-native-reanimated": "~4.5.5",
72
+ "react-native-svg": "15.15.4",
73
+ "react-native-web": "^0.21.2",
74
+ "react-native-worklets": "0.10.4",
75
+ "storybook": "10.6.0",
76
+ "tailwindcss": "^3.4.19",
77
+ "tsx": "^4.23.13",
78
+ "typescript": "~5.9.2",
79
+ "vite": "^6.4.3"
80
+ },
81
+ "dependencies": {
82
+ "@akita-protocol/algomd-core": "1.0.0-alpha.1"
83
+ },
84
+ "exports": {
85
+ ".": "./src/index.ts",
86
+ "./graph": "./src/graph.ts",
87
+ "./package.json": "./package.json"
88
+ },
89
+ "scripts": {
90
+ "compile": "tsc --noEmit -p . --pretty",
91
+ "lint": "eslint src/ --fix",
92
+ "storybook": "storybook dev -p 6006 --no-open",
93
+ "storybook:build": "storybook build",
94
+ "storybook:typecheck": "tsc --noEmit -p tsconfig.storybook.json",
95
+ "storybook:generate": "node scripts/generate-stories.mjs",
96
+ "storybook:both": "node scripts/storybook-both.mjs",
97
+ "test:visual": "pnpm storybook:build:both && playwright test",
98
+ "test:visual:update": "pnpm storybook:build:both && playwright test --update-snapshots=all",
99
+ "localnet:setup": "node scripts/localnet.mjs setup",
100
+ "localnet:check": "node scripts/localnet.mjs check",
101
+ "localnet:import": "node scripts/localnet.mjs import",
102
+ "prestorybook": "node scripts/localnet.mjs prepare",
103
+ "prestorybook:build": "node scripts/localnet.mjs prepare",
104
+ "prestorybook:typecheck": "node scripts/localnet.mjs prepare",
105
+ "storybook:native": "pnpm --dir examples/native start",
106
+ "storybook:build:both": "pnpm parity:check && pnpm storybook:build && pnpm --dir ../web run storybook:build",
107
+ "localnet:seed": "node scripts/localnet.mjs seed",
108
+ "mainapp:dev": "node scripts/mainapp-dev.mjs",
109
+ "test:localnet": "pnpm localnet:check && pnpm storybook:build:both && ALGOMD_LOCALNET=1 playwright test localnet.spec.ts",
110
+ "parity:sync": "node scripts/sync-web-components.mjs",
111
+ "parity:check": "node scripts/check-app-presentation.mjs && node scripts/sync-web-components.mjs --check",
112
+ "test:parity": "pnpm parity:check && pnpm storybook:build:both && playwright test cross-renderer.spec.ts parity.spec.ts behavior.spec.ts search-parity.spec.ts menu-parity.spec.ts",
113
+ "viewer": "node scripts/generate-viewer-story.mjs && tsx scripts/viewer/server.ts",
114
+ "viewer:setup": "node scripts/generate-viewer-story.mjs && tsx scripts/viewer/server.ts --setup-only",
115
+ "viewer:typecheck": "tsc -p tsconfig.viewer.json",
116
+ "viewer:start": "node scripts/generate-viewer-story.mjs && tsx scripts/viewer/server.ts --setup",
117
+ "test:unit": "tsx --test tests/unit/*.test.ts",
118
+ "test:viewer": "ALGOMD_LOCALNET=1 ALGOMD_VIEWER_HTTP=1 tsx --test tests/viewer/localnet.test.ts",
119
+ "app:check": "node scripts/check-app-presentation.mjs"
120
+ }
6
121
  }
@@ -0,0 +1,4 @@
1
+ export {
2
+ createAlgomdDataProvider,
3
+ type CreateAlgomdDataProviderOptions,
4
+ } from './txn-graph'
@@ -0,0 +1,138 @@
1
+ /**
2
+ * React-query-backed `DataProviderApi` for `@akita-protocol/txn-graph-rn`.
3
+ *
4
+ * Keys cache entries the same way algomd-rn's own hooks do
5
+ * (`['algomd', <network>, <kind>, <id>]`) so resolution for the graph and
6
+ * resolution for surrounding `<ASA>` / `<Account>` components both hit
7
+ * a single cache line per entity.
8
+ *
9
+ * The caller hands us a `QueryClient` (usually the same one wired into
10
+ * `AlgomdProvider`) + an `AlgorandClient` (from `useAlgorandClient`).
11
+ * The returned `DataProviderApi` is a plain object — safe to memoize
12
+ * and hand straight to `<DataProvider api={...}>`.
13
+ */
14
+
15
+ import type { QueryClient } from "@tanstack/react-query";
16
+ import type { AlgorandClient } from "@algorandfoundation/algokit-utils";
17
+ import type {
18
+ AccountSummary,
19
+ ApplicationSummary,
20
+ AssetSummary,
21
+ DataProviderApi,
22
+ } from "@akita-protocol/txn-graph-rn";
23
+ import type { ASA as ASAType } from "../types/algorand";
24
+ import type { AlgomdNetwork } from "../provider/types";
25
+
26
+ export type CreateAlgomdDataProviderOptions = {
27
+ queryClient: QueryClient;
28
+ algorand: AlgorandClient;
29
+ /** Network cache namespace. Defaults to mainnet, matching AlgomdProvider. */
30
+ network?: AlgomdNetwork;
31
+ /** Cache staleness in ms. Defaults to 60s — matches algomd-rn's hooks. */
32
+ staleTime?: number;
33
+ };
34
+
35
+ /**
36
+ * Resolve an ASA's algod details the same way `useASAData` does. We
37
+ * intentionally mirror its `queryKey` + mapping so a `useASAData` call
38
+ * and the graph's asset resolver share a single cache entry.
39
+ */
40
+ async function fetchASAForGraph(
41
+ algorand: AlgorandClient,
42
+ assetId: number | bigint,
43
+ ): Promise<ASAType> {
44
+ if (Number(assetId) === 0) {
45
+ return {
46
+ id: 0,
47
+ name: "Algo",
48
+ unitName: "ALGO",
49
+ total: 10_000_000_000_000_000,
50
+ totalRaw: "10000000000000000",
51
+ decimals: 6,
52
+ defaultFrozen: false,
53
+ creator: "",
54
+ createdAt: new Date(0),
55
+ verified: true,
56
+ };
57
+ }
58
+ try {
59
+ const info = await algorand.client.algod.assetById(BigInt(assetId));
60
+ const p = info.params;
61
+ return {
62
+ id: Number(assetId),
63
+ name: p.name ?? `Asset #${assetId}`,
64
+ unitName: p.unitName ?? "",
65
+ total: Number(p.total),
66
+ totalRaw: p.total.toString(),
67
+ decimals: Number(p.decimals),
68
+ defaultFrozen: p.defaultFrozen ?? false,
69
+ url: p.url,
70
+ reserve: p.reserve,
71
+ manager: p.manager,
72
+ freeze: p.freeze,
73
+ clawback: p.clawback,
74
+ creator: p.creator ?? "",
75
+ createdAt: new Date(),
76
+ verified: false,
77
+ };
78
+ } catch {
79
+ return {
80
+ id: Number(assetId),
81
+ name: `Asset #${assetId}`,
82
+ unitName: "",
83
+ total: 0,
84
+ decimals: 0,
85
+ defaultFrozen: false,
86
+ creator: "",
87
+ createdAt: new Date(),
88
+ verified: false,
89
+ };
90
+ }
91
+ }
92
+
93
+ export function createAlgomdDataProvider(
94
+ opts: CreateAlgomdDataProviderOptions,
95
+ ): DataProviderApi {
96
+ const {
97
+ queryClient,
98
+ algorand,
99
+ network = "mainnet",
100
+ staleTime = 60_000,
101
+ } = opts;
102
+
103
+ return {
104
+ async getAssetSummary(id) {
105
+ const numericId = Number(id);
106
+ const asa = await queryClient.fetchQuery<ASAType>({
107
+ queryKey: ["algomd", network, "asa", numericId],
108
+ queryFn: () => fetchASAForGraph(algorand, numericId),
109
+ staleTime,
110
+ });
111
+ const summary: AssetSummary = {
112
+ id,
113
+ unitName: asa.unitName || undefined,
114
+ name: asa.name || undefined,
115
+ decimals: asa.decimals,
116
+ iconUrl: asa.imageUrl,
117
+ };
118
+ return summary;
119
+ },
120
+
121
+ async getAccountSummary(address) {
122
+ // We don't fetch account info just to render the node — that's a
123
+ // heavy algod call for what's usually just an address pill. The
124
+ // consumer can override this resolver if they want NFD names or
125
+ // on-chain balance read out.
126
+ const summary: AccountSummary = { address };
127
+ return summary;
128
+ },
129
+
130
+ async getApplicationSummary(id) {
131
+ // Same story — the graph just needs `{ id, name? }`. Consumers
132
+ // wiring the adapter to a richer app-registry should override
133
+ // this resolver.
134
+ const summary: ApplicationSummary = { id };
135
+ return summary;
136
+ },
137
+ };
138
+ }
@@ -0,0 +1,38 @@
1
+ import React from "react";
2
+ import { ASADisplay, type ASADisplayProps } from "../presentation/ASADisplay";
3
+ import type { ComponentSize } from "../types/algorand";
4
+ import { SizeContainer } from "../ui/SizeContainer";
5
+ import { AssetMention } from "../presentation/AssetMention";
6
+ import { CompactPillWithImage } from "../presentation/References";
7
+ import { isCompactReference, type ReferenceVariantProps } from "../presentation/variants";
8
+ export interface ASAProps extends ASADisplayProps, ReferenceVariantProps {
9
+ size?: ComponentSize;
10
+ className?: string;
11
+ onPress?: (asset: ASADisplayProps["data"]) => void;
12
+ }
13
+ export function ASAComponent({
14
+ size = "full",
15
+ className,
16
+ data,
17
+ imageUrl,
18
+ inline,
19
+ onPress,
20
+ ...display
21
+ }: ASAProps) {
22
+ if (isCompactReference({ size, compact: display.compact, inline })) {
23
+ const label = data.unitName || data.name;
24
+ const open = onPress ? () => onPress(data) : undefined;
25
+ return inline ? <CompactPillWithImage label={label} inline onPress={open} />
26
+ : <AssetMention label={label} imageUrl={imageUrl ?? data.imageUrl} onPress={open} />;
27
+ }
28
+ const card = (
29
+ <ASADisplay {...display} compact={false} dense={size === "sm" || size === "md"} showDetails={size === "fullscreen" || display.showDetails} data={data} imageUrl={imageUrl ?? data.imageUrl} />
30
+ );
31
+ return display.compact ? (
32
+ card
33
+ ) : (
34
+ <SizeContainer size={size} className={className}>
35
+ {card}
36
+ </SizeContainer>
37
+ );
38
+ }
@@ -0,0 +1,79 @@
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 { ASA } from '../types/algorand';
5
+ import { SearchSheet } from '../ui/SearchSheet';
6
+
7
+ function ShieldIcon({ size = 12, color = '#60a5fa' }: { size?: number; color?: string }) {
8
+ return (
9
+ <Svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke={color} strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">
10
+ <Path d="M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z" />
11
+ </Svg>
12
+ );
13
+ }
14
+
15
+ interface ASASearchProps {
16
+ data: ASA[];
17
+ onSelect?: (asset: ASA) => void;
18
+ placeholder?: string;
19
+ className?: string;
20
+ }
21
+
22
+ export function ASASearch({
23
+ data,
24
+ onSelect,
25
+ placeholder = 'Search assets...',
26
+ className,
27
+ }: ASASearchProps) {
28
+ const [selected, setSelected] = useState<ASA | null>(null);
29
+
30
+ const handleSelect = useCallback(
31
+ (asset: ASA) => {
32
+ setSelected(asset);
33
+ onSelect?.(asset);
34
+ },
35
+ [onSelect],
36
+ );
37
+
38
+ const renderItem = useCallback(
39
+ (asset: ASA) => (
40
+ <View className="flex-row items-center gap-3">
41
+ <View className="w-8 h-8 rounded-lg bg-zinc-800 items-center justify-center">
42
+ <Text className="text-xs text-zinc-400">{asset.unitName.slice(0, 2)}</Text>
43
+ </View>
44
+ <View className="flex-1">
45
+ <View className="flex-row items-center gap-1">
46
+ <Text className="text-sm font-medium text-white" numberOfLines={1}>
47
+ {asset.name}
48
+ </Text>
49
+ {asset.verified && <ShieldIcon />}
50
+ </View>
51
+ <Text className="text-xs text-zinc-400">
52
+ {asset.unitName} - #{asset.id}
53
+ </Text>
54
+ </View>
55
+ {asset.price !== undefined && (
56
+ <Text className="text-xs text-zinc-300">${asset.price}</Text>
57
+ )}
58
+ </View>
59
+ ),
60
+ [],
61
+ );
62
+
63
+ return (
64
+ <View className={className}>
65
+ <SearchSheet
66
+ data={data}
67
+ placeholder={placeholder}
68
+ onSelect={handleSelect}
69
+ renderItem={renderItem}
70
+ />
71
+ {selected && (
72
+ <View className="mt-3 p-3 rounded-lg bg-zinc-800 border border-zinc-700">
73
+ <Text className="text-xs font-medium text-zinc-400 mb-1">Selected Asset</Text>
74
+ {renderItem(selected)}
75
+ </View>
76
+ )}
77
+ </View>
78
+ );
79
+ }
@@ -0,0 +1,42 @@
1
+ import React from "react";
2
+ import {
3
+ AccountDisplay,
4
+ type AccountDisplayProps,
5
+ } from "../presentation/AccountDisplay";
6
+ import type { ComponentSize } from "../types/algorand";
7
+ import { SizeContainer } from "../ui/SizeContainer";
8
+ import { NavigableBlock } from "../presentation/References";
9
+ import { AccountMentionText } from "../presentation/AccountMentionText";
10
+ import { AccountMentionInline } from "../presentation/AccountMentionInline";
11
+ import { isCompactReference, type ReferenceVariantProps } from "../presentation/variants";
12
+ export interface AccountProps extends AccountDisplayProps, ReferenceVariantProps {
13
+ size?: ComponentSize;
14
+ className?: string;
15
+ /** @deprecated The shared app layout does not include an applications list. */
16
+ showApps?: boolean;
17
+ }
18
+ export function Account({
19
+ size = "full",
20
+ className,
21
+ data,
22
+ showApps,
23
+ inline,
24
+ ...display
25
+ }: AccountProps) {
26
+ if (isCompactReference({ size, compact: display.compact, inline })) {
27
+ return inline ? <AccountMentionInline address={data.address} onPress={display.onExternalLink} />
28
+ : <AccountMentionText address={data.address} onPress={display.onExternalLink} />;
29
+ }
30
+ const card = (
31
+ <NavigableBlock accessibilityLabel={`Open ${data.address}`} onPress={display.onExternalLink ? () => display.onExternalLink?.(data.address) : undefined}>
32
+ <AccountDisplay {...display} compact={false} showAssets={size === "fullscreen" || size === "lg" || display.showAssets} data={data} />
33
+ </NavigableBlock>
34
+ );
35
+ return display.compact ? (
36
+ card
37
+ ) : (
38
+ <SizeContainer size={size} className={className}>
39
+ {card}
40
+ </SizeContainer>
41
+ );
42
+ }
@@ -0,0 +1,75 @@
1
+ import React, { useCallback, useState } from 'react';
2
+ import { View, Text } from 'react-native';
3
+ import Svg, { Circle as SvgCircle } from 'react-native-svg';
4
+ import type { AlgorandAccount } from '../types/algorand';
5
+ import { formatAddress } from '../utils/format';
6
+ import { SearchSheet } from '../ui/SearchSheet';
7
+
8
+ function OnlineIndicator({ isOnline }: { isOnline: boolean }) {
9
+ return (
10
+ <Svg width={8} height={8} viewBox="0 0 8 8">
11
+ <SvgCircle cx="4" cy="4" r="4" fill={isOnline ? '#34d399' : '#71717a'} />
12
+ </Svg>
13
+ );
14
+ }
15
+
16
+ interface AccountSearchProps {
17
+ data: AlgorandAccount[];
18
+ onSelect?: (account: AlgorandAccount) => void;
19
+ placeholder?: string;
20
+ className?: string;
21
+ }
22
+
23
+ export function AccountSearch({
24
+ data,
25
+ onSelect,
26
+ placeholder = 'Search accounts...',
27
+ className,
28
+ }: AccountSearchProps) {
29
+ const [selected, setSelected] = useState<AlgorandAccount | null>(null);
30
+
31
+ const handleSelect = useCallback(
32
+ (account: AlgorandAccount) => {
33
+ setSelected(account);
34
+ onSelect?.(account);
35
+ },
36
+ [onSelect],
37
+ );
38
+
39
+ const renderItem = useCallback(
40
+ (account: AlgorandAccount) => (
41
+ <View className="flex-row items-center gap-3">
42
+ <View className="w-8 h-8 rounded-full bg-zinc-800 items-center justify-center">
43
+ <Text className="text-xs text-zinc-400">AC</Text>
44
+ </View>
45
+ <View className="flex-1">
46
+ <Text className="text-sm font-mono font-medium text-white" numberOfLines={1}>
47
+ {formatAddress(account.address)}
48
+ </Text>
49
+ <Text className="text-xs text-zinc-400">
50
+ {account.balance / 1_000_000} ALGO - {account.assets.length} assets
51
+ </Text>
52
+ </View>
53
+ <OnlineIndicator isOnline={account.isOnline} />
54
+ </View>
55
+ ),
56
+ [],
57
+ );
58
+
59
+ return (
60
+ <View className={className}>
61
+ <SearchSheet
62
+ data={data}
63
+ placeholder={placeholder}
64
+ onSelect={handleSelect}
65
+ renderItem={renderItem}
66
+ />
67
+ {selected && (
68
+ <View className="mt-3 p-3 rounded-lg bg-zinc-800 border border-zinc-700">
69
+ <Text className="text-xs font-medium text-zinc-400 mb-1">Selected Account</Text>
70
+ {renderItem(selected)}
71
+ </View>
72
+ )}
73
+ </View>
74
+ );
75
+ }