Skip to content

fix(providers): align WalletAPI schemas with actual response format - #174

Merged
Gaubee merged 2 commits into
mainfrom
fix/api-walletapi-174
Jan 6, 2026
Merged

Gaubee merged 2 commits into
mainfrom
fix/api-walletapi-174

Conversation

@Gaubee

@Gaubee Gaubee commented Jan 6, 2026

Copy link
Copy Markdown
Contributor

问题

根据 spec 调查,WalletAPI 实际返回的格式与代码中的 Schema 不匹配:

ETH WalletAPI

  • Balance API: 返回 {success: true, result: "236..."} 而不是直接返回字符串
  • History API: 返回 {success: true, result: {status: "1", result: [...]}} 而不是 {status, result}

Tron WalletAPI

  • Balance API: 返回 {success: true, result: "..."} 而不是直接返回字符串

Etherscan Provider

  • 缺少 Balance 和 Amount 的导入

修复内容

  1. ethwallet-provider.ts: 更新 WalletApiBalanceSchema 和 WalletApiHistorySchema 以处理 {success, result} 包装
  2. tronwallet-provider.ts: 更新 WalletApiBalanceSchema 以处理 {success, result} 包装
  3. etherscan-provider.ts: 添加缺失的 Balance 和 Amount 导入
  4. 测试文件: 更新 mock 数据以匹配实际 API 响应格式

其他发现

  • BSC WalletAPI: 代码正确,API 返回 NOTOK 表示没有交易是预期行为
  • BTC WalletAPI: 404 错误会触发 fallback 到 mempool provider,这是正确的行为
  • PublicNode RPC: 不支持交易历史是预期的(只支持余额查询)

测试

所有 100 个 provider 测试通过。

Gaubee added 2 commits January 7, 2026 00:35
- ETH WalletAPI: Update schemas to handle {success, result} wrapper
  - Balance: {success: boolean, result: string}
  - History: {success: boolean, result: {status, result: [...]}}

- Tron WalletAPI: Update balance schema for {success, result} wrapper
  - Balance: {success: boolean, result: string}

- Etherscan: Add missing Balance and Amount imports

All 100 provider tests pass.
@Gaubee
Gaubee merged commit f8d4adf into main Jan 6, 2026
5 checks passed
@Gaubee
Gaubee deleted the fix/api-walletapi-174 branch January 6, 2026 16:49
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