Skip to content

Conversation

@BitHighlander
Copy link
Collaborator

* Please fill in the required items.

Priority*

  • High: This PR needs to be merged first for other tasks.
  • Middle: This PR should be merged quickly to prevent conflicts due to common changes. (default)
  • Low: This PR does not affect other tasks, so it can be merged later.

Purpose of the PR*

Changes*

How to check the feature

Reference

BitHighlander and others added 18 commits September 2, 2025 18:26
…dling

**Chain Switching Per EIP-3326:**
- Split wallet_switchEthereumChain (existing chains only, returns 4902 if unknown)
- Split wallet_addEthereumChain (adds new chains with full RPC details)
- Return proper error code 4902 when chain not found
- dApps now correctly prompted to add unknown chains

**Comprehensive Error Handling:**
- All errors use proper ProviderRpcError with standard codes
  - 4001: Invalid parameters
  - 4902: Unrecognized/unsupported chain
  - 4900: Wallet initialization or configuration errors
- Enhanced logging for debugging chain operations
- Clear error messages instead of generic "Unexpected error"

**RPC Failover System:**
- Try all available RPC endpoints until one works
- 5-second timeout per RPC attempt
- Track failed RPCs with 1-minute cooldown to avoid retrying broken endpoints
- Auto-switch to working RPC and save as primary
- Handles rate limiting and RPC outages gracefully

**URL Sanitization:**
- Trim whitespace from all URLs (rpcUrls, explorer, etc.)
- Clean URLs when adding new chains AND loading from storage
- Auto-fix corrupted stored data on next use
- Filter out empty URLs from providers array
- Fixes "unsupported protocol  https" errors from malformed URLs

**Critical Fixes:**
- Fixed eth_chainId to return hex format (0xe) instead of decimal (14)
  - Was causing infinite refresh loops in dApps
- Fixed TypeScript type narrowing in content script
- Added missing variable in devtools panel
- Added handler for INJECTION_SUCCESS message

**Helper Functions:**
- switchToProvider() - Centralized provider switching with URL cleaning
- getProvider() - Multi-RPC failover with health checking
- Validates required fields (caip, networkId) before saving
- Consistent asset context updates across all operations

Tested with Flare Network (chain ID 14) - successfully adds custom chain,
switches networks, and maintains connection with RPC failover.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Fixed "Buffer is not defined" error during xpub to ypub conversion
in the background script. The @pioneer-platform/pioneer-coins module
uses Node.js Buffer API which requires polyfilling for browsers.

Changes:
- Added buffer package dependency
- Updated Vite config with Buffer alias and global define
- Injected Buffer polyfill at background script entry point

Resolves xpub conversion failures for wrapped segwit Bitcoin addresses.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
CRITICAL FIX: This resolves transactions being signed with wrong address

Root Cause:
1. Pioneer SDK's signTx expects TWO parameters: signTx(caip, unsignedTx)
2. Code was calling it with ONE object parameter: signTx({ caip, unsignedTx })
3. chainId was being passed as number (1) instead of hex string ('0x1')

Impact:
- Transactions were signed with wrong address (0xc6Ff068Ca10F9697F665c97af998F51E8c7C2395)
  instead of connected address (0x141D9959cAe3853b035000490C03991eB70Fc4aC)
- RPC would reject with "insufficient funds" because wrong account had 0 balance
- Error manifested as generic "didn't sign right" from Pioneer SDK

Changes:
- Convert chainId from number to hex string before signing
- Call signTx with correct two-parameter signature: signTx(caip, txForSigning)

Related Files:
- See projects/pioneer/e2e/transfers/e2e-transfer-suite/SIGNING_API_DOCUMENTATION.md
  for comprehensive Pioneer SDK signTx documentation

🤖 Generated with Claude Code
…uides

Documents critical pain points encountered during Ethereum transaction signing:

New Documentation:
- docs/TROUBLESHOOTING.md: Detailed debugging guide for transaction issues
- docs/PIONEER_SDK_INTEGRATION.md: Best practices and pitfalls for Pioneer SDK

Key Topics Covered:
1. Transaction signed with wrong address (root cause: malformed SDK calls)
2. Build cache issues and verification strategies
3. ChainId format requirements (hex string vs number)
4. Pubkey context management
5. Generic error messages and debugging strategies
6. Data structure validation and type safety
7. Best practices for SDK integration
8. Testing strategies and prevention techniques

Pain Points Documented:
- Type definitions don't match implementation
- Silent failures with vague error messages
- Context management complexities
- Format requirements not enforced by types
- Multi-step debugging required for simple issues

Prevention Strategies:
- Validation before SDK calls
- Verification after operations
- Comprehensive logging patterns
- Wrapper functions for safety
- Integration test examples

These guides should significantly reduce debugging time for future developers
working with Pioneer SDK integration.

🤖 Generated with Claude Code
…lor accents

- Convert Tokens component to dark mode theme with whiteAlpha colors
- Add scrollable container (400px max height) with custom styled scrollbar
- Implement dynamic color generation based on token icon URL hash
- Add gradient border effects that reveal on hover
- Enhance visual feedback with glow shadows and lift animations
- Update IconWithFallback component for dark theme consistency

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Implemented a full-featured custom token management system with:
- Custom token storage with CAIP-19 compliance
- Add/remove custom tokens with validation
- Token search and filtering across native and custom tokens
- Enhanced token list UI with balance display and color accents
- Dark mode support with theme-aware styling
- Background service integration for token state management
- Transfer flow updates for custom token support
- Asset detail view improvements

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Implemented comprehensive loading improvements for better user experience:

**Token List Loading Indicators**:
- Added per-token loading state when clicking assets
- Spinner replaces icon during asset context switch
- "Loading..." text feedback
- Disabled interaction during load (opacity 0.6, cursor wait)
- 2s fallback timeout for loading state cleanup

**Asset Page Loading Experience**:
- Replaced simple spinner with skeleton UI
- Shows structural placeholder (icon, text, buttons)
- Provides visual feedback of page structure while loading
- Better perceived performance with skeleton screens

**Performance Optimizations**:
- Non-blocking transaction history fetch (parallel)
- Improved loading flow between components
- Better visual feedback during data fetching

These changes address slow perceived performance when navigating between
assets by providing immediate visual feedback and clear loading states.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution. We will check and reply to you as soon as possible.

@BitHighlander BitHighlander merged commit 29d76dd into master Oct 29, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants