Skip to content

QR login and Metamask transfers#715

Merged
feruzm merged 10 commits into
developfrom
mm-transfers
Mar 24, 2026
Merged

QR login and Metamask transfers#715
feruzm merged 10 commits into
developfrom
mm-transfers

Conversation

@feruzm
Copy link
Copy Markdown
Member

@feruzm feruzm commented Mar 23, 2026

Summary by CodeRabbit

  • New Features

    • External token transfer UI for ETH, BNB and SOL.
    • Mobile login via QR code (dialog + navbar entry).
  • Changes

    • Supported external wallet list shown in UI reduced to BTC, ETH, SOL, BNB.
    • Transfer action gated by wallet/linkage, account type and allowlist; opens transfer modal when allowed.
    • New i18n strings for transfer flow and mobile login across locales.
  • Removed

    • Seed-phrase wallet creation/validation flows and related seed-management UI.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 23, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Refactors external wallet support: removes seed-based wallet flows and APT/TON/TRON support; adds MetaMask-backed discovery, Hive Snap helpers, EVM/SOL transfer utilities, a new ExternalTransferDialog and useExternalTransfer mutation, MobileLogin QR dialog, dependency updates, and i18n adjustments across locales. (50 words)

Changes

Cohort / File(s) Summary
Dependencies & Packaging
apps/web/package.json, packages/wallets/package.json, packages/wallets/tsup.config.ts
Added @solana/web3.js to web; wallets package adds @wallet-standard/app & @solana/web3.js as peer/dev deps, replaces several @okxweb3/* libs with @scure/*, and updates tsup externals.
External Transfer UI
apps/web/src/features/wallet/external-transfer/external-transfer-dialog.tsx, apps/web/src/features/wallet/external-transfer/index.ts, apps/web/src/app/(dynamicPages)/profile/.../profile-wallet-token-actions.tsx
Added multi-step ExternalTransferDialog (ETH/BNB/SOL), transfer gating/canTransfer logic, modal wiring, and TransferableCurrency typing.
MetaMask / Wallet Utilities
packages/wallets/src/modules/wallets/utils/metamask-discovery.ts, .../metamask-evm-transfer.ts, .../metamask-sol-transfer.ts, apps/web/src/app/signup/wallet/_components/*, apps/web/src/app/wallet/setup-external/_components/setup-external-metamask.tsx
New MetaMask discovery and Hive Snap helpers; EVM and Solana transfer utilities; signup/setup components now delegate multichain discovery and Snap interactions to wallets package helpers.
Mobile QR Login
apps/web/src/features/shared/mobile-login-qr/mobile-login-qr-dialog.tsx, .../index.ts, apps/web/src/features/shared/navbar/sidebar/navbar-side-main-menu.tsx, apps/web/src/features/i18n/locales/en-US.json
Added MobileLoginQrDialog, barrel export, navbar menu item to open it, and new i18n strings for mobile login.
Removed Seed-Based Flows & Components
apps/web/src/app/wallet/setup-external/_components/setup-external-create.tsx, apps/web/src/features/wallet/components/*seed*, apps/web/src/features/wallet/components/wallet-token-address-item.tsx, related barrels
Deleted seed generation/validation/download UI, WalletTokenAddressItem, and removed related re-exports from barrels.
Wallet Mutations & Queries
packages/wallets/src/modules/wallets/mutations/use-wallet-create.ts, use-import-wallet.ts, queries/use-seed-phrase.ts, queries/use-hive-keys-query.ts, queries/use-wallets-cache-query.ts, mutations/private-api/create-account-with-wallets.ts, mutations/index.ts, queries/index.ts
Removed seed/import hooks and cache/hive-key queries; create-account-with-wallets now accepts optional hiveKeys/walletAddresses; added useExternalTransfer mutation.
Removed Chain Support (APT/TON/TRON)
packages/wallets/src/modules/wallets/enums/ecency-wallet-currency.ts, packages/wallets/src/modules/assets/external/..., apps/web/src/features/wallet/consts/*, apps/web/src/app/signup/wallet/consts/currencies-meta-data.ts, apps/web/src/features/trading-view/index.tsx, apps/web/src/specs/setup-any-spec.ts
Dropped APT/TON/TRON enum entries and related asset modules, token metadata/icons, trading symbols and tests; supported currencies consolidated to BTC, ETH, BNB, SOL.
Utilities Removed / Replaced & Tests
packages/wallets/src/modules/wallets/utils/{get-wallet,sign-*,build-external-transaction,encrypt-memo,decrypt-memo,delay,mnemonic-to-seed,...}, tests...
Deleted many OKX-based wallet instantiation, signing, broadcast, memo crypto, mnemonic/seed utilities and tests; added MetaMask-specific utilities and unit tests for EVM/SOL helpers.
i18n Updates
apps/web/src/features/i18n/locales/{...}.json (many locales)
Updated external-wallets labels/descriptions across locales to remove TRX/TON/APT mentions and show BTC, ETH, BNB, SOL only.
Barrels & Exports
apps/web/src/features/shared/mobile-login-qr/index.ts, apps/web/src/features/wallet/components/index.ts, packages/wallets/src/modules/wallets/utils/index.ts, apps/web/src/features/wallet/hooks/index.ts, apps/web/src/features/wallet/index.ts, packages/wallets/src/modules/wallets/mutations/index.ts, packages/wallets/src/modules/assets/external/index.ts
Adjusted barrel re-exports: added external-transfer and mobile-login-qr exports; removed many seed/legacy utility re-exports; updated utils exports to MetaMask-specific modules.

Sequence Diagram(s)

sequenceDiagram
  participant UI as User UI
  participant Dialog as ExternalTransferDialog
  participant MetaMask as MetaMask / Wallet Standard
  participant API as wallets package mutation
  participant Cache as React Query Cache

  UI->>Dialog: open(currency, username)
  Dialog->>MetaMask: discover/request accounts / installSnap
  MetaMask-->>Dialog: accounts / hive public keys
  Dialog->>Dialog: validate recipient & amount, estimate fee
  Dialog->>MetaMask: ensure chain, request sign/send or estimate
  MetaMask-->>Dialog: gas estimate / txHash
  Dialog->>API: useExternalTransfer.mutateAsync({ to, amount })
  API-->>Dialog: { txHash, currency }
  Dialog->>Cache: invalidate ["ecency-wallets","external-wallet-balance"]
  Dialog-->>UI: show success (explorer URL) or error
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Suggested labels

patch

Poem

🐰 I hopped through code and trimmed three vines,
MetaMask sings and QR light shines.
Four coins tidy, old seeds tucked away,
Dialogs hum, transfers now in play.
Hop, hop — a rabbit ships the day! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.71% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'QR login and Metamask transfers' clearly and concisely describes the main changes: it references two significant features added in this PR (QR-based mobile login and MetaMask transfer functionality).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mm-transfers

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/wallets/src/modules/wallets/utils/metamask-sol-transfer.ts`:
- Around line 90-96: The transfer currently wraps lamports with Number(lamports)
which converts the bigint returned by parseToLamports back to a Number and can
lose precision for large SOL amounts; update the Transaction.add call that uses
SystemProgram.transfer (with fromPubkey and toPubkey) to pass the lamports value
as a bigint directly (remove the Number(...) wrapper) so SystemProgram.transfer
receives the original bigint.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c7b38a99-64a5-4f68-ac4e-b63f93ab0b14

📥 Commits

Reviewing files that changed from the base of the PR and between cbeb445 and b26ca3e.

⛔ Files ignored due to path filters (7)
  • packages/wallets/dist/browser/index.d.ts is excluded by !**/dist/**
  • packages/wallets/dist/browser/index.js is excluded by !**/dist/**
  • packages/wallets/dist/browser/index.js.map is excluded by !**/dist/**, !**/*.map
  • packages/wallets/dist/node/index.cjs is excluded by !**/dist/**
  • packages/wallets/dist/node/index.cjs.map is excluded by !**/dist/**, !**/*.map
  • packages/wallets/dist/node/index.mjs is excluded by !**/dist/**
  • packages/wallets/dist/node/index.mjs.map is excluded by !**/dist/**, !**/*.map
📒 Files selected for processing (4)
  • apps/web/src/features/i18n/locales/en-US.json
  • packages/wallets/src/modules/wallets/utils/metamask-discovery.ts
  • packages/wallets/src/modules/wallets/utils/metamask-sol-transfer.spec.ts
  • packages/wallets/src/modules/wallets/utils/metamask-sol-transfer.ts
✅ Files skipped from review due to trivial changes (2)
  • packages/wallets/src/modules/wallets/utils/metamask-sol-transfer.spec.ts
  • apps/web/src/features/i18n/locales/en-US.json

Comment thread packages/wallets/src/modules/wallets/utils/metamask-sol-transfer.ts
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/wallets/src/modules/wallets/utils/metamask-sol-transfer.ts`:
- Around line 22-23: The current logic silently truncates fractional SOL beyond
9 decimals by using slice(0, 9); change it to reject over-precision instead:
before padding, check if fraction.length > 9 and if any character after the 9th
is not '0' (i.e., non-zero precision) then throw an error (e.g., "amount has
more than 9 decimal places"); if the extra digits are all zeros you may allow
it, otherwise keep the existing behavior of computing BigInt(whole) *
LAMPORTS_PER_SOL + BigInt(paddedFraction) using paddedFraction created from
fraction.padEnd(9, "0"). Ensure this validation is applied where paddedFraction,
fraction, whole, and LAMPORTS_PER_SOL are used so transfers with over-precision
fail fast instead of being truncated.
- Around line 44-55: Change the loose any types to the proper interfaces from
`@wallet-standard/base`: import Wallet and WalletAccount and update
getMetaMaskSolanaWallet's signature to return Promise<Wallet>, change the find
callback parameter from (w: any) to (w: Wallet), and replace other any usages
for accounts to WalletAccount; for the feature checks/calls (e.g.,
w.features["standard:connect"] and w.features["solana:signAndSendTransaction"])
cast or assert w.features to the appropriate feature interfaces before invoking
their methods so TypeScript knows the methods exist.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 68e6d467-8da1-4008-8241-d7a94a10aa96

📥 Commits

Reviewing files that changed from the base of the PR and between b26ca3e and 172cc68.

⛔ Files ignored due to path filters (6)
  • packages/wallets/dist/browser/index.js is excluded by !**/dist/**
  • packages/wallets/dist/browser/index.js.map is excluded by !**/dist/**, !**/*.map
  • packages/wallets/dist/node/index.cjs is excluded by !**/dist/**
  • packages/wallets/dist/node/index.cjs.map is excluded by !**/dist/**, !**/*.map
  • packages/wallets/dist/node/index.mjs is excluded by !**/dist/**
  • packages/wallets/dist/node/index.mjs.map is excluded by !**/dist/**, !**/*.map
📒 Files selected for processing (1)
  • packages/wallets/src/modules/wallets/utils/metamask-sol-transfer.ts

Comment thread packages/wallets/src/modules/wallets/utils/metamask-sol-transfer.ts
Comment on lines +44 to +55
async function getMetaMaskSolanaWallet(): Promise<any> {
const { getWallets } = await import("@wallet-standard/app");
const walletsApi = getWallets();
const wallets = walletsApi.get();

// Only select a MetaMask wallet that supports Solana signing
const mmWallet = wallets.find(
(w: any) =>
w.name.toLowerCase().includes("metamask") &&
w.features["standard:connect"] &&
w.features["solana:signAndSendTransaction"]
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Verify strict-mode tsconfig presence
fd 'tsconfig.*json' -t f | xargs -r rg -n '"strict"\s*:\s*true'

# Verify remaining any-typed usages in this file
rg -n '\bany\b' packages/wallets/src/modules/wallets/utils/metamask-sol-transfer.ts

Repository: ecency/vision-next

Length of output: 741


🏁 Script executed:

cat -n packages/wallets/src/modules/wallets/utils/metamask-sol-transfer.ts

Repository: ecency/vision-next

Length of output: 5016


🏁 Script executed:

# Check if wallet-standard provides type definitions
fd -t f '@wallet-standard' packages/wallets | head -20

Repository: ecency/vision-next

Length of output: 44


🏁 Script executed:

# Check package.json for wallet-standard dependency and versions
rg -A 5 '"@wallet-standard' packages/wallets/package.json

Repository: ecency/vision-next

Length of output: 483


🏁 Script executed:

# Check if `@wallet-standard/app` has type definitions available
fd -t f 'wallet-standard' packages/wallets/node_modules 2>/dev/null | head -20

Repository: ecency/vision-next

Length of output: 44


🏁 Script executed:

# Check if TypeScript types are available for `@wallet-standard/app`
# Look in the package dependencies or lock file
rg -i '@wallet-standard' pnpm-lock.yaml | head -20

Repository: ecency/vision-next

Length of output: 291


🌐 Web query:

@wallet-standard/app TypeScript type definitions wallet interface

💡 Result:

The @wallet-standard/app package provides TypeScript type definitions and functions for applications to interact with wallets implementing the Wallet Standard. It primarily exports the getWallets function, which returns a Wallets API for managing registered wallets. Key interfaces and types from the package (in lib/types/wallets.d.ts): export interface Wallets { get: readonly Wallet[]; on(event: 'change', listener: => void): => void; register(...wallets: Wallet[]): => void; } The Wallet interface is defined in @wallet-standard/base: export interface Wallet { readonly version: WalletVersion; // e.g., '1.0.0' readonly name: string; readonly icon: WalletIcon; // data URI for image readonly chains: readonly string[]; // chain identifiers readonly features: Record<string, unknown>; // feature objects readonly accounts: readonly WalletAccount[]; } export interface WalletAccount { readonly address: string; readonly publicKey: ReadonlyUint8Array; readonly chains: readonly string[]; readonly features: Record<string, unknown>; readonly label?: string; readonly icon?: WalletIcon; } Usage example: import { getWallets } from '@wallet-standard/app'; const wallets = getWallets; const walletList = wallets.get; This package helps dApps detect, list, and interact with standard-compliant wallets via window events like 'wallet-standard:app-ready' and 'wallet-standard:register-wallet'. Latest version: 1.1.0 (Oct 2024). Source: https://github.com/wallet-standard/wallet-standard/tree/master/packages/core/app

Citations:


Import Wallet and WalletAccount from @wallet-standard/base instead of using any.

The code uses any in strict-mode code at lines 44, 51, 71, 75, and 108, which violates the coding guideline that "all new code should include proper types." The @wallet-standard/base package already exports typed interfaces for these shapes—import and use Wallet and WalletAccount directly:

  • Line 44: Return type should be Promise<Wallet>
  • Line 51: Parameter type should be Wallet
  • Line 75: Parameter type should be WalletAccount
  • Lines 71 and 108: For feature methods, cast features with specific interfaces (the features property is Record<string, unknown>, so feature-specific interfaces are still needed for method calls)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/wallets/src/modules/wallets/utils/metamask-sol-transfer.ts` around
lines 44 - 55, Change the loose any types to the proper interfaces from
`@wallet-standard/base`: import Wallet and WalletAccount and update
getMetaMaskSolanaWallet's signature to return Promise<Wallet>, change the find
callback parameter from (w: any) to (w: Wallet), and replace other any usages
for accounts to WalletAccount; for the feature checks/calls (e.g.,
w.features["standard:connect"] and w.features["solana:signAndSendTransaction"])
cast or assert w.features to the appropriate feature interfaces before invoking
their methods so TypeScript knows the methods exist.

@feruzm feruzm added the major Breaking changes (1.0.0 → 2.0.0), add this only if any packages/ have major changes in current PR label Mar 24, 2026
@feruzm feruzm merged commit 8cbae64 into develop Mar 24, 2026
@feruzm feruzm deleted the mm-transfers branch March 24, 2026 11:33
@coderabbitai coderabbitai Bot mentioned this pull request Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

major Breaking changes (1.0.0 → 2.0.0), add this only if any packages/ have major changes in current PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant