Skip to content

fix(ecosystem): implement bio_getBalance and resolve miniapp icon URLs - #212

Merged
Gaubee merged 16 commits into
mainfrom
fix/miniapp-balance-and-icon
Jan 11, 2026
Merged

Gaubee merged 16 commits into
mainfrom
fix/miniapp-balance-and-icon

Conversation

@Gaubee

@Gaubee Gaubee commented Jan 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

修复小程序生态系统的多个问题,采用TDD方法验证。

Changes

1. 实现 bio_getBalance 实际余额查询

  • 之前返回硬编码 '0'
  • 现在通过 bioforest-sdk 的 getAccountBalance 查询真实余额
  • 添加 9 个单元测试覆盖

2. 修复小程序图标URL解析

  • 相对路径 (如 icon.svg) 现在正确解析为绝对URL
  • 基于小程序的 baseUrl 进行解析

3. 修复 bio_closeSplashScreen 竞态条件

  • 问题:React useEffect 运行前,iframe 已调用方法
  • 修复:模块加载时自动初始化 handlers,带双重初始化保护

4. 修复 Forge API 配置

  • 默认 URL 从 bf-meta.org (404) 改为 bfmeta.info

Testing

单元测试 (21 passed)

  • wallet-handlers.test.ts: 9 tests for bio_getBalance
  • bridge.test.ts: 12 tests for permission validation

E2E测试 (9 passed)

  • Forge 小程序启动并显示连接按钮 ✅
  • Forge 点击连接触发钱包流程 ✅
  • Forge 启动无 Method not found 错误 ✅
  • 小程序权限集成测试 ✅

Files Changed

File Changes
src/services/ecosystem/handlers/wallet.ts Implement bio_getBalance
src/services/ecosystem/bridge.ts Resolve relative icon URLs
src/services/ecosystem/provider.ts Auto-init handlers at module load
miniapps/forge/src/api/config.ts Fix API base URL
e2e/forge-auth.mock.spec.ts New E2E tests
src/services/ecosystem/__tests__/wallet-handlers.test.ts New unit tests

Gaubee added 16 commits January 11, 2026 01:26
- Implement actual balance query in bio_getBalance handler using bioforest-sdk
- Resolve relative miniapp icon URLs to absolute based on miniapp's base URL
- Add TDD tests for bio_getBalance handler with mock dependencies

Fixes: miniapp balance shows '0', miniapp icon not rendering in sheets
Fixes race condition where miniapp calls bio_closeSplashScreen before
React useEffect runs initBioProvider(). Now handlers are registered
at module import time with double-init protection.
- Test Forge miniapp launches without bio_closeSplashScreen error
- Test connect button is visible after launch
- Skip full authorization test (requires backend API)
The default API URL was pointing to bf-meta.org which returns 404.
Fixed to use bfmeta.info which has the recharge/support endpoint.
…ain ID

1. Add BFMCHAIN/BFCHAIN -> bfmeta/bfchain mapping in normalizeChainId
2. Migrate SigningConfirmJob, MiniappTransferConfirmJob, MiniappSignTransactionJob
   to use MiniappSheetHeader for consistent styling
- Create eslint-plugin-file-component-constraints package
- Enforce MiniappSheetHeader usage in Miniapp*.tsx sheet files
- Migrate MiniappDestroyConfirmJob to use MiniappSheetHeader
- Configure plugin in .oxlintrc.json with jsPlugins
- bio_requestAccounts now passes appName/appIcon to wallet picker
- bio_selectAccount now passes appName/appIcon to wallet picker
- bio_pickWallet now passes appName/appIcon to wallet picker

This fixes the 'unknown DApp' header display in authorization sheets.
…sses

- Remove chain switching button from swap step (must go back to re-authorize)
- Display full addresses with break-all styling instead of truncated
- Update WalletPickerJob comments to document BFMCHAIN support
…straints

- Change from relative path to workspace:* dependency
- This fixes oxlint failing in subdirectories (miniapps/forge)
Miniapps need this dependency since oxlint may look up parent configs.
Ensures eslint-plugin-file-component-constraints is built before lint runs.
Replace Chinese text queries with data-testid for better test stability.
@Gaubee
Gaubee merged commit f24e843 into main Jan 11, 2026
5 checks passed
@Gaubee
Gaubee deleted the fix/miniapp-balance-and-icon branch January 11, 2026 08:53
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.

1 participant