fix: anypay (#3507)

* fix android CI

* fix: handle the parser seeing chainless QRs in the old flow as belonging to the current wallet, causing the error jack reported

* fix: handle network switch when anypay is interrupted mid flow and currency is changed
This commit is contained in:
David Adegoke
2026-08-12 01:14:39 +02:00
committed by GitHub
parent 3a71f6ad33
commit 414b2eadee
7 changed files with 490 additions and 52 deletions
+32
View File
@@ -8,6 +8,7 @@ import 'package:cw_core/currency_for_wallet_type.dart';
import 'package:cw_core/erc20_token.dart';
import 'package:cw_core/spl_token.dart';
import 'package:cw_core/tron_token.dart';
import "package:cw_core/utils/print_verbose.dart";
import 'package:cw_core/wallet_base.dart';
import 'package:cw_core/wallet_info.dart';
import 'package:cw_core/wallet_type.dart';
@@ -163,6 +164,37 @@ class TokenUtilities {
return null;
}
static Future<int?> findEvmChainIdForContract(
String contractAddress, {
int? excludingChainId,
}) async {
if (evm == null || contractAddress.isEmpty) {
return null;
}
try {
for (final chain in evm!.getAllChains()) {
if (chain.chainId == excludingChainId) {
continue;
}
final walletType = evm!.getWalletTypeByChainId(chain.chainId);
if (walletType == null) {
continue;
}
final token = await findTokenByAddress(walletType: walletType, address: contractAddress);
if (token != null) {
return chain.chainId;
}
}
} catch (e) {
printV("findEvmChainIdForContract failed: $e");
}
return null;
}
static Future<Box<Erc20Token>> _openEvmTokensBoxFor(WalletInfo walletInfo) async {
final walletKey = walletInfo.name.replaceAll(' ', '_');
final boxName = _getErc20TokensBoxName(walletKey, walletInfo.type);