How mavryk-network/mavryk-wallet works
This project is a browser extension for a cryptocurrency wallet—specifically for the Mavryk blockchain. Its primary purpose is to allow users to manage tokens, NFTs, and interface with decentralized applications (dApps) directly in their web browser. The project is built largely as a full-stack client-side application, with a rich React-based UI, a Redux (or similar) state management layer, extensive API integrations, and supporting libraries for blockchain communication, internationalization, and testing.
Major Components
• User Interface (UI) Layer – Represented by the “src/app” directory. This includes pages, atoms, molecules, and templates (e.g., various React components for wallet pages, modals, on-boarding, transactions, and notifications).
• State Management – The “src/store” directory contains Redux reducers, actions, epics, and selectors which manage the application state.
• Business Logic & API Integration – The “src/lib/apis” folder (and other related “src/lib” subdirectories) encapsulate logic for accessing blockchain API endpoints (for Mavryk, NFT management, dApps, and more), handling analytics, intercom, notifications, and even handling internationalization.
• Background and Content Scripts – Files such as “src/background.ts”, “src/content-scripts”, “src/popup.tsx”, “src/fullpage.tsx”, and “src/replaceAds.ts” indicate how the extension interacts with the browser context and injects content or provides background processing.
• Internationalization (i18n) Support – With dedicated scripts in “bin/i18n-*.js”, “src/lib/i18n”, and localized files under “public/_locales”, the project supports multiple languages.
• Testing and E2E – The “e2e” directory holds extensive end-to-end test scenarios (using feature files, page objects, step definitions, etc.) that validate the wallet’s functionality.
• Build and Configuration – Webpack configuration files (in “webpack”) and other config files (like “.babelrc”, “tsconfig.json”) are used to build and bundle the extension code for various browsers.
• Native & Platform-Specific Code – The “xcode” directory shows that there is a platform-specific component (likely for Safari or mobile integration) that integrates the extension via native wrappers.
Relationships and Interactions
• The UI components send user interactions to the state management layer (Redux store) which mediates data flow.
• State changes trigger business logic side-effects (using epics or hooks) that then invoke API calls in the “src/lib/apis” layer.
• API integrations communicate with external services (e.g., Mavryk blockchain nodes, NFT services, exchange rate providers, etc.) in order to fetch or post data.
• The background script and content scripts manage browser-specific integration and messaging between the web page and the extension’s UI.
• The build system (Webpack) compiles and bundles all of the above components, while the i18n modules and localization assets ensure multi-language support.
• Testing (e2e scripts) covers user flows and guarantees that interactions between the UI, store, and APIs work as expected.
Architectural Patterns & Design Principles
• Component-Based Architecture: The React-based UI is organized into reusable atoms, molecules, and templates.
• Separation of Concerns: The code is organized into distinct layers – UI, state management, business logic, and external integrations.
• Modularization: Library functions and utilities are isolated in “src/lib” (for analytics, ledger handling, notifications, etc.) so they can be unit-tested and reused throughout the application.
• Extensibility: The project includes modular handling for internationalization, testing, and deployment to multiple browsers (Chrome, Firefox, Opera).
• Messaging & Asynchronous Data Flow: Use of Redux epics or similar side-effect models for API integrations and background tasks.
Relevant Technologies and Frameworks
• React and React hooks for UI components.
• Redux (or a similar state management tool) for state handling.
• Webpack, Babel for building and bundling.
• TypeScript for typed development.
• E2E testing frameworks (likely Cucumber or a similar tool as indicated by “e2e/src/features”).
• APIs for blockchain interactions and external service integrations within “src/lib/apis”.
• i18n support using JSON files and helper libraries.
• Xcode-based native integration (for Safari or iOS environments) as seen in the “xcode” directory.