| 1 | import 'package:cw_core/crypto_currency.dart'; |
| 2 | |
| 3 | /// Immutable configuration for an EVM chain |
| 4 | class ChainConfig { |
| 5 | final int chainId; |
| 6 | final String name; |
| 7 | final String shortCode; |
| 8 | final String caip2; // e.g., "eip155:1" |
| 9 | final CryptoCurrency nativeCurrency; |
| 10 | final ChainCapabilities capabilities; |
| 11 | final List<String> defaultRpcEndpoints; |
| 12 | final List<String> explorerUrls; |
| 13 | final FeeModel feeModel; |
| 14 | |
| 15 | const ChainConfig({ |
| 16 | required this.chainId, |
| 17 | required this.name, |
| 18 | required this.shortCode, |
| 19 | required this.caip2, |
| 20 | required this.nativeCurrency, |
| 21 | required this.capabilities, |
| 22 | required this.defaultRpcEndpoints, |
| 23 | required this.explorerUrls, |
| 24 | required this.feeModel, |
| 25 | }); |
| 26 | } |
| 27 | |
| 28 | /// Capabilities supported by an EVM chain |
| 29 | class ChainCapabilities { |
| 30 | final bool supportsERC20; |
| 31 | final bool supportsEIP1559; |
| 32 | final bool supportsInternalTx; |
| 33 | final bool supportsSubscriptions; |
| 34 | final bool supportsENS; |
| 35 | |
| 36 | const ChainCapabilities({ |
| 37 | required this.supportsERC20, |
| 38 | required this.supportsEIP1559, |
| 39 | required this.supportsInternalTx, |
| 40 | required this.supportsSubscriptions, |
| 41 | required this.supportsENS, |
| 42 | }); |
| 43 | } |
| 44 | |
| 45 | /// Fee model type for EVM chains |
| 46 | enum FeeType { |
| 47 | legacy, |
| 48 | eip1559, |
| 49 | } |
| 50 | |
| 51 | /// Fee model configuration for an EVM chain |
| 52 | class FeeModel { |
| 53 | final FeeType type; |
| 54 | final int defaultGasLimit; |
| 55 | final int? maxPriorityFee; |
| 56 | |
| 57 | const FeeModel({ |
| 58 | required this.type, |
| 59 | required this.defaultGasLimit, |
| 60 | this.maxPriorityFee, |
| 61 | }); |
| 62 | } |