-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/exchange #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR restructures the repo into a pnpm workspace monorepo (client + separate Foundry contracts) and adds a new DEX feature set plus supporting UI, hooks, and documentation.
Changes:
- Convert the repo into a workspace with
client/as the primary pnpm package and update CI/Pages build paths accordingly. - Add DEX-related contracts scaffolding (Foundry config, deploy script, Uniswap V3 interfaces) and client-side DEX integration utilities (ABIs, token configs, swap quote/history hooks).
- Expand the client app with new routes/layout/components, export/import utilities, and improved upload/history UX.
Reviewed changes
Copilot reviewed 51 out of 145 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.json | Switch TS project references to the new client/ composite project. |
| scripts/superpowers.sh | Add a helper script to invoke Codex “superpowers” skills. |
| scripts/skills.sh | Add a helper script to run the skills CLI via pnpm. |
| scripts/install-superpowers.sh | Add script to clone/update obra/superpowers into .codex/. |
| pnpm-workspace.yaml | Define pnpm workspace packages (client). |
| package.json | Convert root to a workspace wrapper and delegate scripts to anamnesis-client. |
| docs/exchange/solidity-development-guide.md | Add Solidity development/deployment guide documentation. |
| docs/exchange/README.md | Add DEX quickstart and high-level docs. |
| contracts/src/interfaces/ISwapRouter.sol | Add Uniswap V3 SwapRouter interface. |
| contracts/src/interfaces/IQuoter.sol | Add Uniswap V3 Quoter interface. |
| contracts/script/Deploy.s.sol | Add Foundry deployment script for MultiHopSwapper. |
| contracts/package.json | Add contracts scripts for build/test/deploy via Foundry. |
| contracts/foundry.toml | Add Foundry configuration (rpc endpoints + etherscan config). |
| client/vite.config.ts | Add Vite config for client/ and set GH Pages base path. |
| client/tsconfig.tsbuildinfo | Add TS build cache artifact (should likely not be committed). |
| client/tsconfig.node.json | Add TS config for Vite config/build tooling. |
| client/tsconfig.json | Add composite TS project setup for the client. |
| client/tsconfig.app.json | Adjust TS app config paths/baseUrl usage. |
| client/src/types/global.d.ts | Add global window type extensions for wallet integrations. |
| client/src/routes/upload.tsx | Add upload route wrapper using AppLayout. |
| client/src/routes/settings.tsx | Add settings route wrapper using AppLayout. |
| client/src/routes/home.tsx | Add home route wrapper using AppLayout. |
| client/src/routes/dex.tsx | Add DEX route wrapper using AppLayout. |
| client/src/routes/dashboard.tsx | Add dashboard route wrapper using AppLayout. |
| client/src/routes/account.tsx | Add account route wrapper using AppLayout. |
| client/src/root.tsx | Add top-level layout + DB init + COI service worker inclusion. |
| client/src/providers.tsx | Add Wagmi/RainbowKit/React-Query + app wallet provider composition. |
| client/src/pages/Settings.tsx | Adjust settings page layout spacing. |
| client/src/pages/Dashboard.tsx | Adjust dashboard page layout spacing. |
| client/src/pages/Account.tsx | Adjust account page layout spacing. |
| client/src/lib/wallet-export.ts | Add wallet key/mnemonic export helpers and download util. |
| client/src/lib/vault-export.ts | Add vault export/import for SQLite-backed data. |
| client/src/lib/utils.ts | Add shared UI helpers (cn, file size formatting, address shortening). |
| client/src/lib/types.ts | Add unified type definitions for wallet/vault/upload records. |
| client/src/lib/sui-token-config.ts | Add Sui token list and formatting helper. |
| client/src/lib/solana-token-config.ts | Add Solana token list and formatting helper. |
| client/src/lib/manifest-updater.ts | Add delayed/batched manifest update scheduling logic. |
| client/src/lib/crypto.ts | Add libsodium/webcrypto key derivation + encryption helpers. |
| client/src/lib/contracts/token-config.ts | Add supported ERC20 metadata + token amount parse/format helpers. |
| client/src/lib/contracts/multi-hop-swapper-abi.ts | Add ABI constants for swapper + ERC20. |
| client/src/lib/contracts/addresses.ts | Add contract/token address configuration constants. |
| client/src/lib/compression.ts | Add gzip compression utilities and compression heuristics. |
| client/src/lib/balance.ts | Add multi-chain balance fetchers (ETH/SOL/SUI/AR/BTC). |
| client/src/i18n/locales/zh.json | Add DEX + token holdings translations (ZH). |
| client/src/i18n/locales/zh-HK.json | Add DEX translations (ZH-HK). |
| client/src/i18n/locales/en.json | Add DEX + token holdings translations (EN). |
| client/src/i18n/config.ts | Add i18next setup + supported language helpers. |
| client/src/hooks/use-wallet-manager.ts | Add backwards-compatible alias hook for wallet provider. |
| client/src/hooks/use-transaction-history.ts | Add localStorage + on-chain log-based swap transaction history. |
| client/src/hooks/use-token-balance.ts | Add ERC20 token balance hooks (single + multi-token). |
| client/src/hooks/use-token-approval.ts | Add ERC20 allowance/approval hooks. |
| client/src/hooks/use-swap-quote.ts | Add swap quote hook calling contract getOptimalRoute. |
| client/src/hooks/use-file-sync.ts | Update file sync behavior to use direct tag-based querying. |
| client/src/entry.client.tsx | Add /dex route wiring for React Router. |
| client/src/components/upload/UploadWarning.tsx | Add upload warning UI component. |
| client/src/components/upload/UploadOptions.tsx | Add encryption/compression option UI component. |
| client/src/components/upload/UploadButton.tsx | Add upload CTA button component. |
| client/src/components/upload/FileUploadSection.tsx | Add file picker/dropzone wrapper component. |
| client/src/components/upload/FeeEstimate.tsx | Add detailed fee estimate UI component. |
| client/src/components/upload/ArweaveFeeInfo.tsx | Add fee info card with external calculator link. |
| client/src/components/ui/tabs.tsx | Add Radix-based Tabs UI wrapper. |
| client/src/components/ui/sonner.tsx | Add Sonner Toaster wrapper with icon theming. |
| client/src/components/ui/select.tsx | Add Radix-based Select UI wrapper. |
| client/src/components/ui/label.tsx | Add Radix-based Label UI wrapper. |
| client/src/components/ui/input.tsx | Add styled input component. |
| client/src/components/ui/file-input.tsx | Add styled file input component. |
| client/src/components/ui/dialog.tsx | Add Radix-based dialog component wrappers. |
| client/src/components/ui/checkbox.tsx | Add Radix-based checkbox component wrapper. |
| client/src/components/ui/card.tsx | Add card component with variants. |
| client/src/components/ui/button.tsx | Add button component with variants. |
| client/src/components/loading-fallback.tsx | Add a hydrate/loading fallback component. |
| client/src/components/layout/Navbar.tsx | Add DEX nav entry and related icon usage. |
| client/src/components/layout/NavLogo.tsx | Add navbar logo component. |
| client/src/components/layout/NavDivider.tsx | Add nav divider component. |
| client/src/components/layout/MobileNav.tsx | Add mobile navigation component. |
| client/src/components/layout/DesktopNav.tsx | Add desktop navigation component. |
| client/src/components/layout/AppLayout.tsx | Add shared app layout wrapper (nav/footer/toaster). |
| client/src/components/layout/AccountButton.tsx | Add account status button with multi-chain wallet states. |
| client/src/components/language-switcher.tsx | Add language switcher based on Radix Select. |
| client/src/components/icons.tsx | Add inline SVG icons for multiple chains. |
| client/src/components/history-table/utils.ts | Add history-table formatting helpers. |
| client/src/components/history-table/transaction-tags.ts | Add Arweave tag decoding + metadata extraction helpers. |
| client/src/components/history-table/download-handler.ts | Add main file download/decrypt/decompress handler flow. |
| client/src/components/history-table/download-data.ts | Add gateway/SDK download logic with error suppression and checks. |
| client/src/components/account/UnlockForm.tsx | Add unlock form component UI. |
| client/src/components/account/SensitiveInfoDialog.tsx | Add private key/mnemonic reveal + download dialog. |
| client/src/components/account/BalanceDisplay.tsx | Add balance display/toggle component. |
| client/src/components/account/AccountList.tsx | Add account list rendering with balance controls. |
| client/src/components/account/AccountCard.tsx | Add token balances integration for supported chains. |
| client/public/favicon.ico | Add favicon asset (currently SVG content). |
| client/public/coi-serviceworker.min.js | Add COOP/COEP service worker script for cross-origin isolation. |
| client/public/assets/sqlite3-worker1.mjs | Add sqlite3 worker module asset. |
| client/public/assets/sqlite3-worker1.js | Add sqlite3 worker script asset. |
| client/public/assets/sqlite3-worker1-promiser.mjs | Add sqlite3 worker promiser (module) asset. |
| client/public/assets/sqlite3-worker1-promiser.js | Add sqlite3 worker promiser (script) asset. |
| client/public/assets/sqlite3-worker1-promiser-bundler-friendly.mjs | Add bundler-friendly sqlite3 worker promiser module. |
| client/public/assets/sqlite3-worker1-bundler-friendly.mjs | Add bundler-friendly sqlite3 worker module. |
| client/package.json | Move app dependencies/scripts into client/ package. |
| client/index.html | Add client HTML entrypoint + loading shell + serviceworker include. |
| client/components.json | Add shadcn/ui config for component generation. |
| client/.prettierignore | Add client-specific prettier ignore rules. |
| MONOREPO.md | Add documentation describing monorepo layout and workflows. |
| .prettierignore | Expand ignore patterns and exclude Foundry contracts from prettier. |
| .oxlintrc.json | Update lint ignore patterns for monorepo layout. |
| .gitignore | Expand ignores for workspace, Foundry outputs, and Codex tooling. |
| .github/workflows/deploy.yml | Update Pages deploy to use client/dist. |
| .github/workflows/ci.yml | Update formatting/typecheck/build verification for monorepo paths. |
| .codex/AGENTS.md | Add Codex “superpowers” tooling instructions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1 @@ | |||
| {"fileNames":[],"fileInfos":[],"root":[],"options":{"composite":true},"version":"5.9.3"} | |||
Copilot
AI
Jan 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tsconfig.tsbuildinfo is a generated build artifact (TypeScript incremental build cache) and generally shouldn’t be committed. Add it to .gitignore (e.g. **/*.tsbuildinfo) and remove this file from the repo to avoid noisy diffs and stale cache issues.
| export function formatSolanaTokenAmount( | ||
| amount: bigint, | ||
| decimals: number, | ||
| displayDecimals = 4, | ||
| ): string { | ||
| if (amount === 0n) return "0" | ||
|
|
||
| const divisor = BigInt(10 ** decimals) | ||
| const whole = amount / divisor | ||
| const fraction = amount % divisor |
Copilot
AI
Jan 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatSolanaTokenAmount computes divisor using BigInt(10 ** decimals), which can be wrong when decimals is large due to JS number precision limits. Use bigint exponentiation (e.g., 10n ** BigInt(decimals)) to ensure correct formatting.
| export function formatSuiTokenAmount( | ||
| amount: bigint, | ||
| decimals: number, | ||
| displayDecimals = 4, | ||
| ): string { | ||
| if (amount === 0n) return "0" | ||
|
|
||
| const divisor = BigInt(10 ** decimals) | ||
| const whole = amount / divisor | ||
| const fraction = amount % divisor | ||
|
|
Copilot
AI
Jan 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatSuiTokenAmount computes divisor using BigInt(10 ** decimals), which can be incorrect for larger decimals because 10 ** decimals is a JS number. Use bigint exponentiation (e.g., 10n ** BigInt(decimals)) to avoid precision loss.
| SOL: "0xD31a59c85aE9D8edEFeC411D448f90d4b0d81299" as Address, | ||
| AR: "0x4fadc7a98f2dc96510e42dd1a74141eeae0c1543" as Address, | ||
| PUMP: "0x89570eBeB055b3319f00A361809e2B5b297f78f7" as Address, | ||
| V2EX: "0x9raUVuzeWUk53co63M4WXLWPWE4Xc6Lpn7RS9dnkpump" as Address, // TODO: Fix invalid address format in contract | ||
| SUI: "0x0b275cfB78b7F8Ffc9D1e66fBa5e7F61Db2c3F20" as Address, | ||
| } as const |
Copilot
AI
Jan 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TOKEN_ADDRESSES.V2EX is not a valid EVM address (non-hex characters) but is asserted as Address. Any viem/wagmi calls using this value can throw at runtime. Replace it with a real deployed token address or remove/disable this token until a valid address exists (e.g., use 0x000...000 placeholder and exclude it from supported token lists).
| ): string { | ||
| if (amount === 0n) return "0" | ||
|
|
||
| const divisor = BigInt(10 ** decimals) | ||
| const whole = amount / divisor | ||
| const fraction = amount % divisor | ||
|
|
Copilot
AI
Jan 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatTokenAmount computes divisor via BigInt(10 ** decimals). For typical ERC-20 decimals (e.g. 18), 10 ** decimals exceeds JS’s safe integer range and can be imprecise, causing incorrect formatting. Use bigint exponentiation instead (e.g., 10n ** BigInt(decimals)).
| export function parseTokenAmount(input: string, decimals: number): bigint { | ||
| if (!input || input === "" || isNaN(parseFloat(input))) { | ||
| return 0n | ||
| } | ||
|
|
||
| // Handle scientific notation | ||
| const num = parseFloat(input) | ||
| if (!Number.isFinite(num) || num < 0) { | ||
| return 0n | ||
| } | ||
|
|
||
| // Split into whole and fractional parts | ||
| const [whole = "0", fraction = ""] = input.split(".") | ||
|
|
||
| // Pad or trim fraction to match decimals | ||
| const paddedFraction = fraction.padEnd(decimals, "0").slice(0, decimals) | ||
|
|
||
| // Combine and convert to bigint | ||
| const combined = whole + paddedFraction | ||
| return BigInt(combined) | ||
| } |
Copilot
AI
Jan 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parseTokenAmount says it handles scientific notation, but it still uses the original input string to build combined. Inputs like "1e-6" will produce an invalid bigint string and throw. Normalize input to a non-scientific decimal string (or use the parsed num to generate the scaled integer) before constructing the bigint.
| if (!isUnlocked || !["ethereum", "solana", "sui"].includes(chain)) return null | ||
|
|
||
| const nonZeroBalances = balances.filter((b) => b.balance > 0n) | ||
| const totalTokens = balances.length |
Copilot
AI
Jan 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused variable totalTokens.
| const [outputAmount, setOutputAmount] = useState<string>("") | ||
| const [quote, setQuote] = useState<any>(null) | ||
| const [gasPrice, setGasPrice] = useState<string>("") | ||
| const [gasEstimate, setGasEstimate] = useState<bigint>(0n) |
Copilot
AI
Jan 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused variable setGasEstimate.
client/src/pages/Dex.tsx
Outdated
| swapState, | ||
| outputAmount, | ||
| quote, | ||
| inputBalance, |
Copilot
AI
Jan 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused variable inputBalance.
client/src/pages/Dex.tsx
Outdated
| inputBalance, | ||
| formattedBalance, | ||
| hasInsufficientBalance, | ||
| needsApproval, |
Copilot
AI
Jan 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused variable needsApproval.
No description provided.