fix(mobile-app): always fetch deposit address from server in deposit_service
Remove local storage cache priority to avoid returning wrong address after account switching. Always fetch from server API to ensure the address belongs to the currently logged-in user. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
04545c86a5
commit
99b2b10ba0
|
|
@ -90,31 +90,15 @@ class DepositService {
|
||||||
|
|
||||||
/// 获取充值地址
|
/// 获取充值地址
|
||||||
///
|
///
|
||||||
/// 优先从本地存储获取,如果没有则从服务器获取
|
/// 始终从服务器获取,确保返回当前登录用户的正确地址
|
||||||
|
/// 不使用本地缓存,避免切换账号后显示错误的地址
|
||||||
/// 返回用户的 KAVA 和 BSC 充值地址
|
/// 返回用户的 KAVA 和 BSC 充值地址
|
||||||
Future<DepositAddressResponse> getDepositAddresses() async {
|
Future<DepositAddressResponse> getDepositAddresses() async {
|
||||||
try {
|
try {
|
||||||
debugPrint('获取充值地址...');
|
debugPrint('获取充值地址...');
|
||||||
|
|
||||||
// 先尝试从本地存储读取
|
// 始终从服务器获取,确保是当前用户的地址
|
||||||
final kavaAddress = await _secureStorage.read(key: StorageKeys.walletAddressKava);
|
debugPrint('从服务器获取钱包地址...');
|
||||||
final bscAddress = await _secureStorage.read(key: StorageKeys.walletAddressBsc);
|
|
||||||
final dstAddress = await _secureStorage.read(key: StorageKeys.walletAddressDst);
|
|
||||||
|
|
||||||
if (kavaAddress != null && kavaAddress.isNotEmpty &&
|
|
||||||
bscAddress != null && bscAddress.isNotEmpty &&
|
|
||||||
dstAddress != null && dstAddress.isNotEmpty) {
|
|
||||||
debugPrint('从本地存储获取充值地址: kava=$kavaAddress, bsc=$bscAddress, dst=$dstAddress');
|
|
||||||
return DepositAddressResponse(
|
|
||||||
kavaAddress: kavaAddress,
|
|
||||||
bscAddress: bscAddress,
|
|
||||||
dstAddress: dstAddress,
|
|
||||||
isValid: true,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 本地没有,从服务器获取
|
|
||||||
debugPrint('本地无缓存,从服务器获取钱包地址...');
|
|
||||||
final response = await _apiClient.get('/user/wallet');
|
final response = await _apiClient.get('/user/wallet');
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue