Files
hash-wallet/lib/reactions/wallet_connect.dart
T
David AdegokeandGitHub 308de0389d CW-1368: Add Binance Smart Chain (#2836)
* feat: Add Binance Smart Chain support to wallet types and EVM chain registry

* feat: Add BSC node list and support in wallet type and chain ID mappings

* feat: Add BSC default tokens and update evm utility functions

* feat: Integrate BSC support in node settings and management

* feat: Add BSC support to config scripts and wallet type generation

* feat: Add BSC support to EVM chain ID and switcher

* feat: Extend BSC support in wallet utilities and chain type checks

* feat: Add BSC support to different wallet functions

* feat: Add BSCURI class and implement for uri handling

* feat: Update Android and iOS configurations to support BSC URL schemes

* feat: Add BSC support to different functionalities and settings

* refactor: Update wallet type name from'Binance Smart Chain' to BNB Smart Chain

* feat: Add switcher icon and updates token utils

* Review fixes

* More changes to BSC name, wallet listing and images

* Add more default tokens
2026-02-05 13:48:26 +01:00

125 lines
3.2 KiB
Dart

import 'package:cake_wallet/src/screens/wallet_connect/services/chain_service/eth/evm_chain_id.dart';
import 'package:cake_wallet/src/screens/wallet_connect/services/chain_service/eth/evm_supported_methods.dart';
import 'package:cake_wallet/src/screens/wallet_connect/services/chain_service/solana/solana_chain_id.dart';
import 'package:cake_wallet/src/screens/wallet_connect/services/chain_service/solana/solana_supported_methods.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:cake_wallet/evm/evm.dart';
bool isEVMCompatibleChain(WalletType walletType) {
switch (walletType) {
case WalletType.polygon:
case WalletType.ethereum:
case WalletType.base:
case WalletType.arbitrum:
case WalletType.bsc:
return true;
default:
return false;
}
}
// Blink Protection is supported on Ethereum and Base chains
bool canSupportBlinkProtection(int? chainId) {
if (chainId == null) return false;
return chainId == 1 || chainId == 8453;
}
bool isNFTACtivatedChain(WalletType walletType, int? chainId) {
if (chainId != null) {
switch (chainId) {
case 1:
case 8453:
case 137:
case 42161:
case 56:
return true;
default:
return false;
}
}
switch (walletType) {
case WalletType.solana:
return true;
default:
return false;
}
}
bool isWalletConnectCompatibleChain(WalletType walletType) {
switch (walletType) {
case WalletType.solana:
case WalletType.polygon:
case WalletType.ethereum:
case WalletType.base:
case WalletType.arbitrum:
case WalletType.bsc:
return true;
default:
return false;
}
}
String getChainNameSpaceAndIdBasedOnWalletType(WalletType walletType, {int? chainId}) {
if (chainId != null) {
return evm!.getCaip2ByChainId(chainId);
}
switch (walletType) {
case WalletType.ethereum:
return EVMChainId.ethereum.chain();
case WalletType.polygon:
return EVMChainId.polygon.chain();
case WalletType.base:
return EVMChainId.base.chain();
case WalletType.arbitrum:
return EVMChainId.arbitrum.chain();
case WalletType.bsc:
return EVMChainId.bsc.chain();
case WalletType.solana:
return SolanaChainId.mainnet.chain();
default:
return '';
}
}
List<String> getChainSupportedMethodsOnWalletType(WalletType walletType) {
switch (walletType) {
case WalletType.ethereum:
case WalletType.polygon:
case WalletType.base:
case WalletType.arbitrum:
case WalletType.bsc:
return EVMSupportedMethods.values.map((e) => e.name).toList();
case WalletType.solana:
return SolanaSupportedMethods.values.map((e) => e.name).toList();
default:
return [];
}
}
String getChainNameBasedOnWalletType(WalletType walletType, {int? chainId}) {
if (walletType == WalletType.solana) {
return 'mainnet';
}
if (chainId != null) {
return evm!.getChainNameByChainId(chainId);
}
return evm!.getChainNameByWalletType(walletType);
}
String getTokenNameBasedOnWalletType(WalletType walletType, {int? chainId}) {
if (walletType == WalletType.solana) {
return 'SOL';
}
if (chainId != null) {
return evm!.getTokenNameByChainId(chainId);
}
return evm!.getTokenNameByWalletType(walletType);
}