-
Notifications
You must be signed in to change notification settings - Fork 0
feat(miniapps/forge): 锻造小程序后端 API 集成 #143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Add API types for COT Recharge (types.ts) - Add API client and service layer (client.ts, recharge.ts) - Add helper functions for message encoding (helpers.ts) - Create React hooks: - useRechargeConfig: fetch and parse forge options - useForge: handle forge flow (sign external tx, sign internal msg, submit) - useContractPool: fetch pool statistics - useRechargeRecords: fetch transaction records - Update App.tsx to use real API: - Load config from backend on mount - Support dynamic token selection from config - Show processing steps during forge - Display order ID on success - Update tests to mock API calls
- Remove unused imports (ExternalChainName, motion, React) - Use self-closing tags for empty div elements - Add vite-env.d.ts for ImportMeta.env types - Update i18n translations for forge functionality - Fix i18n tests for new translation keys
- Add useTranslation hook - Replace hardcoded Chinese strings with t() calls - Add getChainName helper using translations - Initialize i18n in tests
Unit tests: - useRechargeConfig hook (config fetching, parsing, error handling) - useForge hook (forge flow, step transitions, error states) - API helpers (encoding functions, message creation) Storybook tests: - App.stories.tsx with interactive play functions - ConnectStep, SwapStep, TokenPicker, LoadingState, ErrorState stories E2E tests: - Updated ui.spec.ts with 9 comprehensive test cases - Full forge flow, error handling, navigation, token selection - Updated i18n helpers for forge-specific text patterns
171f94d to
729b9b2
Compare
- Fixed mock API URL pattern to match actual endpoint (/recharge/support) - Updated all story play functions to wait for button to be enabled - Button is disabled until forgeOptions loads, causing CI failures
729b9b2 to
e9d86d8
Compare
Gaubee
added a commit
that referenced
this pull request
Dec 30, 2025
P0 高风险修复: - Teleport: signTransData 改用 signedTx.data(RLP encoded rawTx)而非 signature - Forge: 添加 bio_getPublicKey API 框架(含回退机制) P1 中风险修复: - Forge E2E mock: 使用正确的 endpoint 路径 /cot/recharge/support 和 /cot/recharge/V2 - Forge API config: 改为 fail-fast 策略,未配置 VITE_COT_API_BASE_URL 时报错 P2 改进: - Teleport types.ts: 添加 @bnqkl 包使用说明注释 详细变更: - packages/bio-sdk: 添加 bio_getPublicKey 方法定义 - src/services/ecosystem: 添加 handleGetPublicKey handler(待完整实现) - miniapps/forge: useForge 调用 bio_getPublicKey,失败时回退到 address - miniapps/forge: 更新测试以包含新的 API 调用 - miniapps/teleport: 修正 signTransData 数据源并添加说明注释
Gaubee
added a commit
that referenced
this pull request
Dec 30, 2025
* fix(miniapps): 修复 PR #142/#143 review 发现的问题 P0 高风险修复: - Teleport: signTransData 改用 signedTx.data(RLP encoded rawTx)而非 signature - Forge: 添加 bio_getPublicKey API 框架(含回退机制) P1 中风险修复: - Forge E2E mock: 使用正确的 endpoint 路径 /cot/recharge/support 和 /cot/recharge/V2 - Forge API config: 改为 fail-fast 策略,未配置 VITE_COT_API_BASE_URL 时报错 P2 改进: - Teleport types.ts: 添加 @bnqkl 包使用说明注释 详细变更: - packages/bio-sdk: 添加 bio_getPublicKey 方法定义 - src/services/ecosystem: 添加 handleGetPublicKey handler(待完整实现) - miniapps/forge: useForge 调用 bio_getPublicKey,失败时回退到 address - miniapps/forge: 更新测试以包含新的 API 调用 - miniapps/teleport: 修正 signTransData 数据源并添加说明注释 * feat(bio-sdk): bio_signMessage 返回 { signature, publicKey } - SignatureAuthService.handleMessageSign 返回 SignatureResult - SigningConfirmJob 发送 signature + publicKey - bio_signMessage/bio_signTypedData 返回新格式 - useForge 直接使用 signResult.publicKey(hex 格式) - 移除 bio_getPublicKey 回退逻辑(不再需要) publicKey 为 hex 编码的 32 字节公钥(BioForest Ed25519) * fix(miniapps): E2E 测试修复 + i18n 初始化 - forge: 添加 i18n 导入到 main.tsx - forge: 修复 E2E mock (fetch 拦截 + 选择器优化) - forge: 添加 E2E 测试用 API base URL - teleport: 修复 E2E mock (使用 addInitScript) - teleport: 优化资产选择器和确认页面选择器 E2E 测试结果: - Forge: 9/9 通过 - Teleport: 8/8 通过
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
概述
实现锻造(Forge)小程序的完整后端 API 集成,将现有 Demo UI 连接到 COT Recharge API 后端。
主要变更
API 层
src/api/types.ts- COT Recharge API 完整类型定义src/api/config.ts- API 端点配置src/api/client.ts- HTTP 客户端封装src/api/recharge.ts- 充值 API 服务src/api/helpers.ts- 消息编码辅助函数React Hooks
useRechargeConfig- 获取并解析锻造选项配置useForge- 多步骤锻造流程(外链签名 → 内链签名 → 提交)useContractPool- 获取池统计信息useRechargeRecords- 获取交易记录UI 集成
App.tsx使用真实 API 数据测试覆盖
待确认事项
以下参数需要与后端确认:
https://api.eth-metaverse.com)signTransData格式要求 (0x 前缀? hex/base64?)publicKey编码格式 (hex/base58?)测试
相关研究
详见
.chat/research-miniapp-锻造-backend.md