Files
hash-wallet/cw_evm/lib/evm_chain_client_factory.dart
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

40 lines
1.2 KiB
Dart

import 'package:cw_evm/clients/arbitrum_client.dart';
import 'package:cw_evm/clients/base_client.dart';
import 'package:cw_evm/clients/bsc_client.dart';
import 'package:cw_evm/clients/ethereum_client.dart';
import 'package:cw_evm/clients/polygon_client.dart';
import 'package:cw_evm/clients/evm_chain_client.dart';
import 'package:cw_evm/evm_chain_registry.dart';
/// Factory to create appropriate EVMChainClient based on chainId
class EVMChainClientFactory {
static final EvmChainRegistry _registry = EvmChainRegistry();
/// Create an EVMChainClient for the given chainId
///
/// Throws an exception if chainId is not registered
static EVMChainClient createClient(int chainId) {
final config = _registry.getChainConfig(chainId);
if (config == null) {
throw Exception('Chain config not found for chainId: $chainId');
}
// Check if chain needs custom client
switch (chainId) {
case 1:
return EthereumClient();
case 137:
return PolygonClient();
case 8453:
return BaseClient();
case 42161:
return ArbitrumClient();
case 56:
return BSCClient();
default:
return EVMChainClient(chainId: chainId);
}
}
}