refactor: Switch preference to moralis when fetching token data for newly added token; allows us get the token iconpath (#3149)

David Adegoke committed Apr 1, 2026 at 11:13 UTC a22935a474b9a5109dff010ccde845ffa76d961c
2 files changed +6 -8
cw_evm/lib/clients/evm_chain_client.dart
+3 -6
@@ -90,7 +90,6 @@ class EVMChainClient {
90 if (totalNet < BigInt.zero) {
91 mergedMap[key]!['from'] = address;
92 } else {
93 -
93 mergedMap[key]!['to'] = address;
94 mergedMap[key]!['from'] = '';
95 }
@@ -118,7 +117,6 @@ class EVMChainClient {
117 }
118 }
119
121 -
120 BigInt getNetFlow(Map<String, dynamic> txData, String address) {
121 final val = BigInt.parse(txData['value'] ?? '0');
122 final isIncoming = txData['to']?.toLowerCase() == address.toLowerCase();
@@ -129,7 +127,6 @@ class EVMChainClient {
127 return BigInt.zero;
128 }
129
132 -
130 Future<List<EVMChainTransactionModel>> fetchInternalTransactions(String address) async {
131 try {
132 if (secrets.etherScanApiKey.isEmpty) {
@@ -544,16 +541,16 @@ class EVMChainClient {
541
542 Future<Erc20Token?> getErc20Token(String contractAddress, String chainName) async {
543 try {
547 - final token = await getErcTokenInfoFromNode(contractAddress, chainName);
544 + final token = await getErc20TokenFromMoralis(contractAddress, chainName);
545
546 if (token == null || token.name.isEmpty || token.symbol.isEmpty) {
550 - return await getErc20TokenFromMoralis(contractAddress, chainName);
547 + return await getErcTokenInfoFromNode(contractAddress, chainName);
548 }
549
550 return token;
551 } catch (e) {
552 try {
556 - return await getErc20TokenFromMoralis(contractAddress, chainName);
553 + return await getErcTokenInfoFromNode(contractAddress, chainName);
554 } catch (e) {
555 return null;
556 }
lib/src/widgets/picker.dart
+3 -2
@@ -3,6 +3,7 @@
3 import 'dart:math';
4
5 import 'package:cake_wallet/entities/seed_type.dart';
6 +import 'package:cake_wallet/src/widgets/cake_image_widget.dart';
7 import 'package:cake_wallet/src/widgets/search_bar_widget.dart';
8 import 'package:cake_wallet/themes/core/theme_extension.dart';
9 import 'package:cake_wallet/utils/responsive_layout_util.dart';
@@ -497,8 +498,8 @@ class _PickerState<Item> extends State<Picker<Item>> {
498 Widget? _getItemIcon(Item item) {
499 if (item is Currency) {
500 if (item.iconPath != null) {
500 - return Image.asset(
501 - item.iconPath!,
501 + return CakeImageWidget(
502 + imageUrl: item.iconPath!,
503 height: 20.0,
504 width: 20.0,
505 );