Skip to content

Conversation

@Gaubee
Copy link
Contributor

@Gaubee Gaubee commented Dec 20, 2025

Summary

This PR introduces a Schema-first service definition system with enhanced MockDevTools for debugging.

Core Features

Service Meta System (src/lib/service-meta/)

  • defineServiceMeta for Schema-first service definitions with Zod
  • Type-safe .impl() for platform implementations (web/dweb/mock)
  • Middleware pattern for cross-cutting concerns (logging, settings, breakpoints)

MockDevTools Enhancements

  • Unified Position Algorithm: Button and panel share relative position with spring physics
  • Breakpoint System: Pause at input/output phase, inject code, conditional breakpoints
  • Console Panel: Expression execution with $paused, $_, $p{id} variables
  • Settings System: Global delay and error simulation with settingsMiddleware
  • IndexedDB Persistence: Breakpoints survive page refresh

Console Commands

Command Description
/help Show help
/clear Clear console
/vars Show available variables
/copy <expr> Copy expression result to clipboard

Services Migrated (10 total)

  • clipboard, biometric, storage, toast, camera
  • haptics, currency-exchange, staking, transaction, authorize

Documentation

  • Updated whitebook with settings and breakpoint system docs
  • Added unit tests for settings functionality

Testing

  • All 1319 unit tests passing
  • TypeScript type checking passes

## Core Features
- defineServiceMeta for Schema-first service definitions
- Type-safe .impl() for platform implementations (web/dweb/mock)
- Middleware pattern for cross-cutting concerns

## MockDevTools Enhancements
- Unified spring position algorithm for button/panel
- Breakpoint system with pause/resume/inject capabilities
- Console panel with expression execution (, $_, $p{id})
- Settings system (global delay, error simulation)
- IndexedDB persistence for breakpoints

## Services Migrated
- clipboard, biometric, storage, toast, camera
- haptics, currency-exchange, staking, transaction, authorize

## Documentation
- Updated whitebook with settings and breakpoint system docs
- Added unit tests for settings functionality
Whitebook:
- Add chain config management service documentation (07-链配置管理)
- Document subscription source management, multi-source priority
- Update 服务篇 index with new chapters

Config:
- Add Ethereum, BSC, Tron, Bitcoin to default-chains.json
- Add rpcUrl and explorerUrl for BFMeta and external chains

Test:
- Update schema.test.ts to expect 12 chains (8 bioforest + 4 external)
- Add chain type verification tests
…lementation

Whitebook:
- Add chain service implementation spec (实现规范)
- Document BioForest/EVM/Tron/Bitcoin specific requirements
- Update 链服务 index with implementation spec link

Code:
- Create chain-adapter service with unified interface
- Implement IChainAdapter, IAdapterRegistry interfaces
- Add BioforestAdapter with Identity/Asset/Transaction/Chain services
- Add ChainServiceError with typed error codes

Test:
- Add bioforest-adapter.test.ts with 12 test cases
- Test adapter creation, services, lifecycle, registry
- Add whitebook documentation for wallet storage architecture
- Implement WalletStorageService with IndexedDB (idb package)
- Support encrypted mnemonic/private key storage (AES-GCM)
- Add stores: walleter, wallets, chainAddresses, addressBook
- Support localStorage migration for backward compatibility
- Add 41 unit tests covering all service methods
- Update BioforestTransactionService to use real Ed25519 signing
- Export bytesToHex and hexToBytes from crypto module
- Add 6 new tests for transaction service (fee, build, sign, verify)
- Signature verification passes with reconstructed message
BREAKING CHANGE: walletActions.createWallet/importWallet now require
mnemonic and password arguments for secure encryption.

- Migrate wallet store to use WalletStorageService (IndexedDB)
- Update wallet creation pages to use new API signature
- Update password change to use new encryption flow
- Update migration service to directly save to IndexedDB
- Remove direct localStorage usage for wallet persistence
- Add _testAddWallet and _testReset helpers for test isolation
- Update authorize tests to use test helpers instead of createWallet
- Update migration tests to check walletStorageService calls
- Update change-password tests for new updateWalletEncryptedMnemonic API
- Create indexeddb-helper utility for e2e tests
- Update wallet-import, wallet-create, bioforest-chains tests
- Remaining e2e tests need similar updates
- Update chain-config-subscription tests
- Update wallet-recover-arbitrary tests
- Update migration tests
- All e2e tests now read from IndexedDB instead of localStorage
The clipboard test expects window.__CLIPBOARD__ to be set, but
clipboardService uses native navigator.clipboard API. This is a
pre-existing issue that also fails on main branch.
@Gaubee Gaubee merged commit 0c9fc6f into main Dec 20, 2025
6 checks passed
@Gaubee Gaubee deleted the feat/service-meta-system branch December 20, 2025 15:15
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