Skip to content
26 changes: 14 additions & 12 deletions lib/app_config/app_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ const String assetsPath = 'assets';
const String coinsAssetsPath = 'packages/komodo_defi_framework/assets';

final Uri discordSupportChannelUrl = Uri.parse(
'https://discord.com/channels/412898016371015680/429676282196787200');
'https://discord.com/channels/412898016371015680/429676282196787200',
);
final Uri discordInviteUrl = Uri.parse('https://komodoplatform.com/discord');

/// Const to define if Bitrefill integration is enabled in the app.
Expand Down Expand Up @@ -92,6 +93,7 @@ Map<String, int> priorityCoinsAbbrMap = {

/// List of coins that are excluded from the list of coins displayed on the
/// coin lists (e.g. wallet page, coin selection dropdowns, etc.)
/// TODO: remove this list once zhltc and NFTs are fully supported in the SDK
const Set<String> excludedAssetList = {
'ADEXBSCT',
'ADEXBSC',
Expand Down Expand Up @@ -161,17 +163,17 @@ const List<String> appWalletOnlyAssetList = [
/// Coins that are enabled by default on restore from seed or registration.
/// This will not affect existing wallets.
List<String> get enabledByDefaultCoins => [
'KMD', // Always included (Komodo ecosystem)
'BTC-segwit', // Bitcoin (Rank 1, ~$2.21T market cap)
'ETH', // Ethereum (Rank 2, ~$335B market cap)
'BNB', // Binance Coin (Rank 5, ~$93B market cap)
'DOGE', // Dogecoin (Rank 9, ~$27.1B market cap)
'LTC-segwit', // Litecoin (popular, has segwit support)
'USDT-ERC20', // Tether on Ethereum (most common stablecoin)
'XRP-ERC20', // XRP (Rank 4, ~$145B market cap)
if (kDebugMode) 'DOC',
if (kDebugMode) 'MARTY',
];
'KMD', // Always included (Komodo ecosystem)
'BTC-segwit', // Bitcoin (Rank 1, ~$2.21T market cap)
'ETH', // Ethereum (Rank 2, ~$335B market cap)
'BNB', // Binance Coin (Rank 5, ~$93B market cap)
'DOGE', // Dogecoin (Rank 9, ~$27.1B market cap)
'LTC-segwit', // Litecoin (popular, has segwit support)
'USDT-ERC20', // Tether on Ethereum (most common stablecoin)
'XRP-ERC20', // XRP (Rank 4, ~$145B market cap)
if (kDebugMode) 'DOC',
if (kDebugMode) 'MARTY',
];

List<String> get coinsWithFaucet => ['RICK', 'MORTY', 'DOC', 'MARTY'];

Expand Down
43 changes: 26 additions & 17 deletions lib/bloc/coins_bloc/coins_repo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ class CoinsRepo {
/// **Parameters:**
/// - [assets]: List of assets to activate
/// - [notify]: Whether to broadcast state changes to listeners (default: true)
/// - [addToWalletMetadata]: Whether to add assets to wallet metadata (default: true)
/// - [maxRetryAttempts]: Maximum number of retry attempts (default: 30)
/// - [initialRetryDelay]: Initial delay between retries (default: 500ms)
/// - [maxRetryDelay]: Maximum delay between retries (default: 10s)
Expand All @@ -269,6 +270,7 @@ class CoinsRepo {
Future<void> activateAssetsSync(
List<Asset> assets, {
bool notify = true,
bool addToWalletMetadata = true,
int maxRetryAttempts = 30,
Duration initialRetryDelay = const Duration(milliseconds: 500),
Duration maxRetryDelay = const Duration(seconds: 10),
Expand All @@ -282,9 +284,12 @@ class CoinsRepo {
return;
}

// Add assets and their parents to wallet metadata before activating.
// This ensures that the wallet metadata is updated even if activation fails.
await _addAssetsToWalletMetdata(assets.map((asset) => asset.id));
if (addToWalletMetadata) {
// Ensure the wallet metadata is updated with the assets before activation
// This is to ensure that the wallet metadata is always in sync with the assets
// being activated, even if activation fails.
await _addAssetsToWalletMetdata(assets.map((asset) => asset.id));
}

Exception? lastActivationException;

Expand Down Expand Up @@ -391,6 +396,7 @@ class CoinsRepo {
/// **Parameters:**
/// - [coins]: List of coins to activate
/// - [notify]: Whether to broadcast state changes to listeners (default: true)
/// - [addToWalletMetadata]: Whether to add assets to wallet metadata (default: true)
/// - [maxRetryAttempts]: Maximum number of retry attempts (default: 30)
/// - [initialRetryDelay]: Initial delay between retries (default: 500ms)
/// - [maxRetryDelay]: Maximum delay between retries (default: 10s)
Expand All @@ -410,6 +416,7 @@ class CoinsRepo {
Future<void> activateCoinsSync(
List<Coin> coins, {
bool notify = true,
bool addToWalletMetadata = true,
int maxRetryAttempts = 30,
Duration initialRetryDelay = const Duration(milliseconds: 500),
Duration maxRetryDelay = const Duration(seconds: 10),
Expand All @@ -425,6 +432,7 @@ class CoinsRepo {
return activateAssetsSync(
assets,
notify: notify,
addToWalletMetadata: addToWalletMetadata,
maxRetryAttempts: maxRetryAttempts,
initialRetryDelay: initialRetryDelay,
maxRetryDelay: maxRetryDelay,
Expand Down Expand Up @@ -478,20 +486,21 @@ class CoinsRepo {
// Skip the deactivation step for now, as it results in "NoSuchCoin" errors
// when trying to re-enable the coin later in the same session.
// TODO: Revisit this and create an issue on KDF to track the problem.
// final deactivationTasks = [
// ...coins.map((coin) async {
// await _disableCoin(coin.id.id);
// if (notify) _broadcastAsset(coin.copyWith(state: CoinState.inactive));
// }),
// ...allChildCoins.map((child) async {
// await _disableCoin(child.id.id);
// if (notify) {
// _broadcastAsset(child.copyWith(state: CoinState.inactive));
// }
// }),
// ];
// await Future.wait(deactivationTasks);

final deactivationTasks = [
...coins.map((coin) async {
// await _disableCoin(coin.id.id);
if (notify) {
_broadcastAsset(coin.copyWith(state: CoinState.inactive));
}
}),
...allChildCoins.map((child) async {
// await _disableCoin(child.id.id);
if (notify) {
_broadcastAsset(child.copyWith(state: CoinState.inactive));
}
}),
];
await Future.wait(deactivationTasks);
await Future.wait([...parentCancelFutures, ...childCancelFutures]);
}

Expand Down
Loading
Loading