mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-11-10 08:33:54 +01:00
* fix android CI * feat: Add Robinhood Chain, all major flows done. minor issue now is our providers don't support it yet as its still pretty early, two weeks from launch * feat: Add Robinhood Chain, all major flows done. minor issue now is our providers don't support it yet as its still pretty early, two weeks from launch * Cleanup * auto-reformat * fix ui issue and contact listing for tokens * fix: missing icons and crash for fee priority in settings * chore: cleanup * fixes from feedbacks * fix: review issues and sync to latest dev feat: switch history api to etherscan, add history toggle to privacy settings, exclude robETH from exchange pickers, skip tokens discovery for chains that moralis hasn't indexed, add tests * fix: address Robinhood review comments * fix: show Solana token icons in history * fix: address review comments and default Robinhood to PublicNode * fix: revert filter and refuse unmapped networks in provider --------- Co-authored-by: Robert Malikowski <malikowskirobert@gmail.com>
57 lines
2.0 KiB
Dart
57 lines
2.0 KiB
Dart
import "package:cw_core/erc20_token.dart";
|
|
import "package:cw_evm/tokens/arbitrum_tokens.dart";
|
|
import "package:cw_evm/tokens/base_tokens.dart";
|
|
import "package:cw_evm/tokens/bsc_tokens.dart";
|
|
import "package:cw_evm/tokens/ethereum_tokens.dart";
|
|
import "package:cw_evm/tokens/polygon_tokens.dart";
|
|
import "package:cw_evm/tokens/robinhood_tokens.dart";
|
|
|
|
/// Default ERC20 tokens for each EVM chain and utility methods for interacting with them
|
|
class EVMChainDefaultTokens {
|
|
static List<Erc20Token> getDefaultTokensByChainId(int chainId) => switch (chainId) {
|
|
1 => EthereumTokens.tokens,
|
|
137 => PolygonTokens.tokens,
|
|
8453 => BaseTokens.tokens,
|
|
42161 => ArbitrumTokens.tokens,
|
|
56 => BSCTokens.tokens,
|
|
4663 => RobinhoodTokens.tokens,
|
|
_ => [],
|
|
};
|
|
|
|
static List<String> getDefaultTokenAddresses(int chainId) =>
|
|
getDefaultTokensByChainId(chainId).map((token) => token.contractAddress).toList();
|
|
|
|
static List<String> getDefaultTokenSymbols(int chainId) =>
|
|
getDefaultTokensByChainId(chainId).map((token) => token.symbol.toUpperCase()).toList();
|
|
|
|
static final Map<int, Map<String, String>> _iconPathsByAddress = {};
|
|
|
|
static String? getDefaultIconPathByAddress(int chainId, String contractAddress) {
|
|
final iconPaths = _iconPathsByAddress.putIfAbsent(chainId, () {
|
|
final paths = <String, String>{};
|
|
|
|
for (final token in getDefaultTokensByChainId(chainId)) {
|
|
final iconPath = token.iconPath;
|
|
|
|
if (iconPath != null && iconPath.isNotEmpty) {
|
|
paths[token.contractAddress.toLowerCase()] = iconPath;
|
|
}
|
|
}
|
|
|
|
return paths;
|
|
});
|
|
|
|
return iconPaths[contractAddress.toLowerCase()];
|
|
}
|
|
|
|
static Set<String> getDefaultGroupsByAddress(int chainId, String contractAddress) {
|
|
for (final token in getDefaultTokensByChainId(chainId)) {
|
|
if (token.contractAddress.toLowerCase() == contractAddress.toLowerCase()) {
|
|
return token.groups;
|
|
}
|
|
}
|
|
|
|
return const {};
|
|
}
|
|
}
|