-
Notifications
You must be signed in to change notification settings - Fork 52
feat(rn-cli-wallet): add multi-chain wallet import for TON, TRON, and SUI #371
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
… SUI Add import functionality for TON (secret key/seed), TRON (private key), and SUI (BIP39 mnemonic) wallets. Includes: - New wallet import functions for each chain with validation - SegmentedControl component for chain selection - Updated ImportWalletModal supporting all chains - Enhanced SecretPhrase screen displaying secrets for all chains - SUI balance support in WalletStore - Proper state management in SettingsStore Fixes toast notification z-index by moving Toast component after Navigator. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Claude finished @ignaciosantise's task in 1m 35s —— View job Code Review CompleteReviewed multi-chain wallet import implementation for TON, TRON, and SUI. Found 3 issue(s)Issue 1: Sensitive data displayed in plaintext error messagesID: importwalletmodal-error-plaintext-a7f2 Context:
Recommendation: Sanitize error messages before displaying: } catch (error: unknown) {
// Never display the actual input in error messages
Toast.show({
type: 'error',
text1: 'Import failed',
text2: error instanceof Error ? error.message : 'Invalid input format',
});
}Additionally, review wallet util files (TonWalletUtil.ts:59-61, TronWalletUtil.ts:53-55, SuiWalletUtil.ts:52) to ensure error messages don't include input values. Issue 2: Unencrypted storage of private keysID: tonwalletutil-storage-unencrypted-b4c9 Context:
Recommendation: While comments acknowledge this is for development, add explicit runtime warning: // After storage.setItem calls
if (__DEV__) {
console.warn(
'[SECURITY] Private keys stored unencrypted. Use secure enclave (Keychain/Keystore) in production'
);
}For production reference implementation, consider adding commented example using Issue 3: Missing input sanitization before validationID: importwalletmodal-input-sanitize-c2e1 Context:
Recommendation: Sanitize input before validation: const handleImport = async () => {
// Normalize: trim, remove newlines, collapse multiple spaces
const sanitized = input.trim().replace(/\s+/g, ' ');
if (!sanitized) {
Toast.show({
type: 'error',
text1: EMPTY_INPUT_ERROR[selectedChain],
});
return;
}
// Use sanitized input for all imports
const result = await loadTonWallet(sanitized);
// ...
}SummaryPR Scope: 11 files, 610 additions, 103 deletions - moderate size, acceptable. Overall Assessment: Implementation follows React Native patterns well with proper TypeScript usage, state management via Valtio, and good component structure. The SegmentedControl component is well-designed with smooth animations. Input validation for each chain format is comprehensive. Key Issues:
Recommendations:
|
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 adds multi-chain wallet import functionality for TON, TRON, and SUI blockchains to complement the existing EVM support. It introduces a new SegmentedControl component for chain selection, enhances the SecretPhrase screen to display secrets for all supported chains, and adds SUI balance tracking.
Changes:
- Added wallet import functions with chain-specific validation for TON (secret key/seed), TRON (private key), and SUI (BIP39 mnemonic)
- Created reusable SegmentedControl component with animated chain selection
- Enhanced SecretPhrase screen to display all chain secrets with copy functionality
- Added SUI balance support and updated WalletStore to handle optional addresses for all chains
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| wallets/rn_cli_wallet/src/utils/TonWalletUtil.ts | Added loadTonWallet function with validation for 128-char secret key or 64-char seed input |
| wallets/rn_cli_wallet/src/utils/TronWalletUtil.ts | Added loadTronWallet function with validation for 64-char hex private key input |
| wallets/rn_cli_wallet/src/utils/SuiWalletUtil.ts | Added loadSuiWallet function with BIP39 mnemonic validation |
| wallets/rn_cli_wallet/src/store/WalletStore.ts | Added SUI balance support and made eip155Address optional to support multi-chain scenarios |
| wallets/rn_cli_wallet/src/store/SettingsStore.ts | Added tonWallet and tronWallet state properties with corresponding setter methods |
| wallets/rn_cli_wallet/src/screens/Wallets/index.tsx | Added suiAddress handling for wallet balance fetching |
| wallets/rn_cli_wallet/src/screens/Wallets/components/TokenBalanceCard.tsx | Increased address truncation from 4 to 6 trailing characters |
| wallets/rn_cli_wallet/src/screens/Settings/index.tsx | Updated labels from "Secret phrases" to "Secret Keys & Phrases" and "Import EVM Wallet" to "Import Wallet" |
| wallets/rn_cli_wallet/src/screens/SecretPhrase/index.tsx | Redesigned to show secrets for all chains (EVM, SUI, TON, TRON) with individual copy buttons |
| wallets/rn_cli_wallet/src/modals/ImportWalletModal.tsx | Added multi-chain support with SegmentedControl, dynamic placeholders, and chain-specific validation |
| wallets/rn_cli_wallet/src/components/SegmentedControl.tsx | New component providing animated tab-style control for chain selection |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Add __DEV__ console warnings for unencrypted storage in wallet utils - Add whitespace normalization for user input in ImportWalletModal - Add defensive default case with LogStore error logging - Use reactive state from SettingsStore in SecretPhrase screen - Improve TON error message to include expected length info Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
Add wallet import functionality for TON (secret key/seed), TRON (private key), and SUI (BIP39 mnemonic) chains alongside existing EVM support. Implements a new SegmentedControl component for chain selection and enhances the SecretPhrase screen to display secrets for all supported chains. Also fixes toast notification z-index by repositioning it within the navigation stack.
Changes
Test Plan
🤖 Generated with Claude Code