Repository navigation
fix(transfer): 修复确认转账按钮无响应和交易历史不加载 - #103
Merged
Merged
Conversation
…firmJob The pendingCallback was being cleared before it was called, causing the confirm button to do nothing. Fixed by saving the reference first. Bug: clicking 'confirm transfer' button had no effect
API returns { success, result: { trs: [...] } } but code was reading
result.trs (undefined) instead of result.result.trs.
This caused transaction history to always be empty.
All BioForest APIs return { success: boolean, result: T } format.
Fixed parsing in:
- chain-service.ts: getBlockHeight, getGasPrice, healthCheck
- transaction-service.ts: getTransactionHistory (lastblock call)
Root cause: Did not study legacy wallet-base SDK which auto-unwraps
the { success, result } wrapper in WalletFetch._handleResThen()
…tus, getTransaction API parsing
All methods were incorrectly parsing { data: {...} } instead of { success, result: {...} }
- Add bioforest-api.test.ts with 19 tests covering all API methods
- Mock fetch to verify { success, result } response format parsing
- Test ChainService: getBlockHeight, getGasPrice, healthCheck
- Test TransactionService: getTransactionHistory, getTransactionStatus, getTransaction, broadcastTransaction
- Test AssetService: getNativeBalance, getTokenBalances
- Fix getGasPrice to return default on success=false instead of throwing
- Add 'BioForest 转账完整流程验证' test suite - Test verifies: form fill -> confirm sheet -> password input - Fix mock transactions format (add height, correct structure) - Add data-testid to PasswordConfirmJob and TransferConfirmJob - Update bioforest-mock.ts to match real API response format
核心修复: - TransferConfirmJob: 保存 callback 引用后再清除,避免 null 调用 - transaction-service: 修复 API 响应解析 (result.result.xxx) - chain-service: 修复 healthCheck/getBlockHeight/getGasPrice 解析 - transaction-service: 使用 SDK 计算真实最小手续费 测试新增: - bioforest-full-flow.spec.ts: 完整钱包导入+转账流程 e2e 测试 - bioforest-api.test.ts: 19 个 API 解析单元测试 (已在之前提交) - .env.example + .gitignore: 支持本地测试密钥配置 测试结果: - 单元测试: 19/19 通过 - E2E 测试: bioforest-transfer 19/19 通过 - E2E 测试: bioforest-full-flow 4/13 通过 (9 个需要状态共享改进)
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
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.
问题根因
没有仔细研究 legacy wallet-base SDK。原始
WalletFetch在响应处理中自动解包{ success, result }结构:所以原始代码可以直接
const { trs } = await _fetch.post<{ trs: [...] }>()。而我们直接用fetch(),需要手动解包。修复内容
Bug 1: 确认转账按钮无响应
pendingCallback在调用前被清除。修复:先保存引用。Bug 2: 交易历史不加载
result.trs→result.result.trsBug 3: 区块高度/手续费获取失败
chain-service.ts中所有 API 响应解析都错误:data.data.xxx→json.result.xxx教训