mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-26 06:08:40 +01:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user