Overview
The@subwallet/extension-koni-ui package contains the complete user interface implementation for SubWallet Extension. Built with React 18 and styled-components, it provides a modern, responsive wallet interface for managing accounts, tokens, NFTs, staking, and dApp connections.
Purpose and Responsibilities
- UI Components: Comprehensive component library for wallet functionality
- State Management: Redux integration with React hooks for global state
- Routing: React Router-based navigation for the extension popup
- View Rendering: Entry point creation for extension pages
- User Interactions: Forms, confirmations, and user input handling
- Multi-chain UI: Interface for interacting with Substrate, EVM, and other chains
- WalletConnect UI: User interface for WalletConnect sessions and requests
Key Exports
Fromsrc/index.ts:
createView
Utility function that creates a React application view for extension pages:- React 18 root creation
- Suspense wrapping for lazy loading
- Preload style application
- Backup reminder initialization
Popup
Main popup component that serves as the entry point for the extension’s primary interface.Directory Structure
Key Features
Multi-Page Structure
The popup is organized into major sections:- Home: Dashboard showing balances, tokens, NFTs, and crowdloans
- Account: Account details, QR codes, and account management
- Transaction: Send tokens, transfer NFTs, cross-chain transfers
- Confirmations: Transaction signing and approval flows
- Settings: General settings, security, networks, and advanced options
- WalletConnect: Session management and dApp connection requests
- Keyring: Create account, import seed, attach accounts
Custom Hooks
Extensive collection of React hooks for:- Balance queries (
useBalance,useGetBalance) - Chain information (
useChainInfo,useGetChainAssets) - Transaction operations (
useTransaction,useHandleSubmitTransaction) - Account management (
useAccountInfo,useGetAccountByAddress) - NFT data (
useNft,useGetNftCollection) - Staking (
useYieldPosition,useGetStakingReward)
Component Library
Built on@subwallet/react-ui with custom extensions:
- Account selectors and displays
- Token and NFT lists
- Transaction forms and confirmations
- Modal dialogs and alerts
- Loading states and skeletons
- Charts and data visualizations
- QR code generation and scanning
Dependencies
Key UI dependencies:- React Ecosystem:
react@18,react-dom@18,react-router-dom@6 - State Management:
@reduxjs/toolkit,react-redux,redux-persist - UI Library:
@subwallet/react-ui,styled-components - Icons:
@fortawesome/react-fontawesome,phosphor-react - Forms:
rc-input,react-select,react-dropzone - Utilities:
classnames,copy-to-clipboard,file-saver - QR Code:
react-qr-code,react-qr-reader - Markdown:
react-markdown,rehype-raw - Extension Packages:
@subwallet/extension-base,@subwallet/extension-inject
Integration in Architecture
The UI package:- Communicates with background services via message passing (see
messaging/directory) - Consumes types and utilities from
extension-base - Manages local UI state with Redux while syncing with background state
- Renders in multiple contexts: popup, fullscreen tabs, and notification windows
Styling and Theming
Usesstyled-components with a centralized theme system:
- Dark and light themes
- Responsive layouts
- Custom color schemes
- Typography system
Internationalization
Supports multiple languages throughi18next and react-i18next:
Usage Example
Development Notes
- Built with TypeScript for type safety
- Uses React 18 features including Suspense and concurrent rendering
- Implements code splitting for performance
- Follows atomic design principles for component organization
- Uses React hooks exclusively (no class components)
Related Packages
- extension-base - Core services and business logic
- extension-inject - Injection types
- extension-dapp - dApp integration