Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# First-party
sdk/

# Miscellaneous
*.class
*.log
Expand Down
34 changes: 25 additions & 9 deletions app_theme/lib/src/dark/theme_global_dark.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ ThemeData get themeGlobalDark {
SnackBarThemeData snackBarThemeLight() => const SnackBarThemeData(
elevation: 12.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(4))),
borderRadius: BorderRadius.all(Radius.circular(4)),
),
actionTextColor: Colors.green,
behavior: SnackBarBehavior.floating,
);
Expand All @@ -32,16 +33,29 @@ ThemeData get themeGlobalDark {

final TextTheme textTheme = TextTheme(
headlineMedium: const TextStyle(
fontSize: 16, fontWeight: FontWeight.w700, color: textColor),
fontSize: 16,
fontWeight: FontWeight.w700,
color: textColor,
),
headlineSmall: const TextStyle(
fontSize: 40, fontWeight: FontWeight.w700, color: textColor),
fontSize: 40,
fontWeight: FontWeight.w700,
color: textColor,
),
titleLarge: const TextStyle(
fontSize: 26.0, color: textColor, fontWeight: FontWeight.w700),
fontSize: 26.0,
color: textColor,
fontWeight: FontWeight.w700,
),
titleSmall: const TextStyle(fontSize: 18.0, color: textColor),
bodyMedium: const TextStyle(
fontSize: 16.0, color: textColor, fontWeight: FontWeight.w300),
fontSize: 16.0,
color: textColor,
fontWeight: FontWeight.w300,
),
labelLarge: const TextStyle(fontSize: 16.0, color: textColor),
bodyLarge: TextStyle(fontSize: 14.0, color: textColor.withValues(alpha: 0.5)),
bodyLarge:
TextStyle(fontSize: 14.0, color: textColor.withValues(alpha: 0.5)),
bodySmall: TextStyle(
fontSize: 12.0,
color: textColor.withValues(alpha: 0.8),
Expand Down Expand Up @@ -80,7 +94,8 @@ ThemeData get themeGlobalDark {
snackBarTheme: snackBarThemeLight(),
textSelectionTheme: TextSelectionThemeData(
cursorColor: const Color.fromRGBO(57, 161, 238, 1),
selectionColor: const Color.fromRGBO(57, 161, 238, 1).withValues(alpha: 0.3),
selectionColor:
const Color.fromRGBO(57, 161, 238, 1).withValues(alpha: 0.3),
selectionHandleColor: const Color.fromRGBO(57, 161, 238, 1),
),
inputDecorationTheme: InputDecorationTheme(
Expand Down Expand Up @@ -157,8 +172,9 @@ ThemeData get themeGlobalDark {
),
textTheme: textTheme,
scrollbarTheme: ScrollbarThemeData(
thumbColor:
WidgetStateProperty.all<Color?>(colorScheme.primary.withValues(alpha: 0.8)),
thumbColor: WidgetStateProperty.all<Color?>(
colorScheme.primary.withValues(alpha: 0.8),
),
),
bottomNavigationBarTheme: BottomNavigationBarThemeData(
// remove icons shift
Expand Down
2 changes: 1 addition & 1 deletion assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@
"missingDerivationPath": "Missing derivation path configuration",
"protocolNotSupported": "Protocol does not support multiple addresses",
"derivationModeNotSupported": "Current wallet mode does not support multiple addresses",
"hdWalletModeSwitchTitle": "HD Wallet?",
"hdWalletModeSwitchTitle": "Multi-address Wallet?",
"hdWalletModeSwitchSubtitle": "Enabling HD wallet allows you to create multiple addresses for each coin. However, your addresses and balances will change. You can easily switch between the modes when logging in.",
"hdWalletModeSwitchTooltip": "HD wallets require a valid BIP39 seed phrase.",
"noActiveWallet": "No active wallet - please sign in first",
Expand Down
7 changes: 7 additions & 0 deletions lib/app_config/app_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ const String coinsAssetsPath = 'packages/komodo_defi_framework/assets';
// TODO: Remove this flag after the feature is finalized
const bool isBitrefillIntegrationEnabled = false;

/// Const to define if trading is enabled in the app. Trading is only permitted
/// with test coins for development purposes while the regulatory compliance
/// framework is being developed.
///
///! You are solely responsible for any losses/damage that may occur. Komodo
///! Platform does not condone the use of this app for trading purposes and
///! unequivocally forbids it.
const bool kIsWalletOnly = !kDebugMode;

const Duration kPerformanceLogInterval = Duration(minutes: 1);
Expand Down
15 changes: 9 additions & 6 deletions lib/bloc/app_bloc_root.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ import 'package:web_dex/shared/widgets/coin_icon.dart';

class AppBlocRoot extends StatelessWidget {
const AppBlocRoot({
Key? key,
required this.storedPrefs,
required this.komodoDefiSdk,
super.key,
});

final StoredSettings storedPrefs;
Expand Down Expand Up @@ -135,6 +135,7 @@ class AppBlocRoot extends StatelessWidget {
demoMode: performanceMode,
coinsRepository: coinsRepository,
mm2Api: mm2Api,
sdk: komodoDefiSdk,
);

final portfolioGrowthRepo = PortfolioGrowthRepository.withDefaults(
Expand All @@ -143,6 +144,7 @@ class AppBlocRoot extends StatelessWidget {
demoMode: performanceMode,
coinsRepository: coinsRepository,
mm2Api: mm2Api,
sdk: komodoDefiSdk,
);

_clearCachesIfPerformanceModeChanged(
Expand All @@ -158,10 +160,11 @@ class AppBlocRoot extends StatelessWidget {
return MultiRepositoryProvider(
providers: [
RepositoryProvider(
create: (_) => NftsRepo(
api: mm2Api.nft,
coinsRepo: coinsRepository,
)),
create: (_) => NftsRepo(
api: mm2Api.nft,
coinsRepo: coinsRepository,
),
),
RepositoryProvider(create: (_) => tradingEntitiesBloc),
RepositoryProvider(create: (_) => dexRepository),
RepositoryProvider(
Expand Down Expand Up @@ -219,7 +222,7 @@ class AppBlocRoot extends StatelessWidget {
),
BlocProvider<TransactionHistoryBloc>(
create: (BuildContext ctx) => TransactionHistoryBloc(
repo: transactionsRepo,
sdk: komodoDefiSdk,
),
),
BlocProvider<SettingsBloc>(
Expand Down
14 changes: 9 additions & 5 deletions lib/bloc/bridge_form/bridge_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class BridgeRepository {
final KomodoDefiSdk _kdfSdk;
final CoinsRepo _coinsRepository;

Future<CoinsByTicker?> getSellCoins( CoinsByTicker? tickers) async {
Future<CoinsByTicker?> getSellCoins(CoinsByTicker? tickers) async {
if (tickers == null) return null;

final List<OrderBookDepth>? depths = await _getDepths(tickers);
Expand All @@ -26,9 +26,11 @@ class BridgeRepository {
tickers.entries.fold({}, (previousValue, entry) {
final List<Coin> coins = previousValue[entry.key] ?? [];
final List<OrderBookDepth> tickerDepths = depths
.where((depth) =>
(abbr2Ticker(depth.source.abbr) == entry.key) &&
(abbr2Ticker(depth.target.abbr) == entry.key))
.where(
(depth) =>
(abbr2Ticker(depth.source.abbr) == entry.key) &&
(abbr2Ticker(depth.target.abbr) == entry.key),
)
.toList();

if (tickerDepths.isEmpty) return previousValue;
Expand Down Expand Up @@ -66,7 +68,9 @@ class BridgeRepository {
return multiProtocolCoins;
} else {
return removeTokensWithEmptyOrderbook(
multiProtocolCoins, orderBookDepths);
multiProtocolCoins,
orderBookDepths,
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/bloc/cex_market_data/charts.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'dart:math';

import 'package:komodo_defi_types/types.dart';
import 'package:komodo_defi_types/komodo_defi_types.dart';

typedef ChartData = List<Point<double>>;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:http/http.dart';
import 'package:komodo_cex_market_data/komodo_cex_market_data.dart';
import 'package:komodo_defi_sdk/komodo_defi_sdk.dart';
import 'package:komodo_persistence_layer/komodo_persistence_layer.dart';
import 'package:web_dex/bloc/cex_market_data/mockup/generator.dart';
import 'package:web_dex/bloc/cex_market_data/mockup/mock_transaction_history_repository.dart';
Expand All @@ -25,6 +26,7 @@ class MockPortfolioGrowthRepository extends PortfolioGrowthRepository {
required this.performanceMode,
required CoinsRepo coinsRepository,
required Mm2Api mm2Api,
required KomodoDefiSdk sdk,
}) : super(
cexRepository: BinanceRepository(
binanceProvider: const BinanceProvider(),
Expand All @@ -34,6 +36,7 @@ class MockPortfolioGrowthRepository extends PortfolioGrowthRepository {
client: Client(),
performanceMode: performanceMode,
demoDataGenerator: DemoDataCache.withDefaults(),
sdk: sdk,
),
cacheProvider: HiveLazyBoxProvider<String, GraphCache>(
name: GraphType.balanceGrowth.tableName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class MockTransactionHistoryRepo extends TransactionHistoryRepo {
required Client client,
required this.performanceMode,
required this.demoDataGenerator,
}) : super();
required super.sdk,
});

// TODO: SDK Port needed, not sure about this part
Future<List<Transaction>> fetchTransactions(Coin coin) async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:math';
import 'package:hive/hive.dart';
import 'package:komodo_cex_market_data/komodo_cex_market_data.dart' as cex;
import 'package:komodo_cex_market_data/komodo_cex_market_data.dart';
import 'package:komodo_defi_sdk/komodo_defi_sdk.dart';
import 'package:komodo_persistence_layer/komodo_persistence_layer.dart';
import 'package:web_dex/bloc/cex_market_data/charts.dart';
import 'package:web_dex/bloc/cex_market_data/mockup/mock_portfolio_growth_repository.dart';
Expand All @@ -12,7 +13,7 @@ import 'package:web_dex/bloc/cex_market_data/models/models.dart';
import 'package:web_dex/bloc/coins_bloc/coins_repo.dart';
import 'package:web_dex/bloc/transaction_history/transaction_history_repo.dart';
import 'package:web_dex/mm2/mm2_api/mm2_api.dart';
import 'package:komodo_defi_types/types.dart';
import 'package:komodo_defi_types/komodo_defi_types.dart';
import 'package:web_dex/model/coin.dart';

/// A repository for fetching the growth chart for the portfolio and coins.
Expand All @@ -36,13 +37,15 @@ class PortfolioGrowthRepository {
required cex.CexRepository cexRepository,
required CoinsRepo coinsRepository,
required Mm2Api mm2Api,
required KomodoDefiSdk sdk,
PerformanceMode? demoMode,
}) {
if (demoMode != null) {
return MockPortfolioGrowthRepository.withDefaults(
performanceMode: demoMode,
coinsRepository: coinsRepository,
mm2Api: mm2Api,
sdk: sdk,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ enum PriceChartPeriod {
return '1M';
case PriceChartPeriod.oneYear:
return '1Y';
}
}
}

String get intervalString {
Expand All @@ -35,6 +35,6 @@ enum PriceChartPeriod {
return '1M';
case PriceChartPeriod.oneYear:
return '1y';
}
}
}
}
4 changes: 2 additions & 2 deletions lib/bloc/cex_market_data/price_chart/models/time_period.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ enum TimePeriod {
return '1M';
case TimePeriod.oneYear:
return '1Y';
}
}
}

Duration get duration {
Expand All @@ -35,6 +35,6 @@ enum TimePeriod {
return const Duration(days: 30);
case TimePeriod.oneYear:
return const Duration(days: 365);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:http/http.dart';
import 'package:komodo_cex_market_data/komodo_cex_market_data.dart';
import 'package:komodo_defi_sdk/komodo_defi_sdk.dart';
import 'package:komodo_persistence_layer/komodo_persistence_layer.dart';
import 'package:web_dex/bloc/cex_market_data/mockup/generator.dart';
import 'package:web_dex/bloc/cex_market_data/mockup/mock_transaction_history_repository.dart';
Expand All @@ -26,6 +27,7 @@ class MockProfitLossRepository extends ProfitLossRepository {
required PerformanceMode performanceMode,
required CoinsRepo coinsRepository,
required Mm2Api mm2Api,
required KomodoDefiSdk sdk,
String cacheTableName = 'mock_profit_loss',
}) {
return MockProfitLossRepository(
Expand All @@ -40,6 +42,7 @@ class MockProfitLossRepository extends ProfitLossRepository {
client: Client(),
performanceMode: performanceMode,
demoDataGenerator: DemoDataCache.withDefaults(),
sdk: sdk,
),
profitLossCalculator: RealisedProfitLossCalculator(
BinanceRepository(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:komodo_defi_types/types.dart';
import 'package:komodo_defi_types/komodo_defi_types.dart';

extension ProfitLossTransactionExtension on Transaction {
/// The total amount of the coin transferred in the transaction as a double.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:web_dex/bloc/cex_market_data/profit_loss/models/fiat_value.dart';
import 'package:komodo_defi_types/types.dart';
import 'package:komodo_defi_types/komodo_defi_types.dart';

class PriceStampedTransaction extends Transaction {
final FiatValue fiatValue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:equatable/equatable.dart';
import 'package:web_dex/bloc/cex_market_data/profit_loss/models/fiat_value.dart';
import 'package:web_dex/bloc/cex_market_data/profit_loss/extensions/profit_loss_transaction_extension.dart';
import 'package:komodo_defi_types/types.dart';
import 'package:komodo_defi_types/komodo_defi_types.dart';

/// Represents a profit/loss for a specific coin.
class ProfitLoss extends Equatable {
Expand Down
11 changes: 6 additions & 5 deletions lib/bloc/cex_market_data/profit_loss/profit_loss_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,14 @@ class ProfitLossBloc extends Bloc<ProfitLossEvent, ProfitLossState> {
useCache: useCache,
);

profitLosses.removeRange(
0,
profitLosses.indexOf(
profitLosses.firstWhere((element) => element.profitLoss != 0),
),
final startIndex = profitLosses.indexOf(
profitLosses.firstWhere((element) => element.profitLoss != 0),
);

if (startIndex == -1) {
profitLosses.removeRange(0, startIndex);
}

return profitLosses.toChartData();
} catch (e) {
logger.log(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:komodo_cex_market_data/komodo_cex_market_data.dart';
import 'package:web_dex/bloc/cex_market_data/profit_loss/extensions/profit_loss_transaction_extension.dart';
import 'package:web_dex/bloc/cex_market_data/profit_loss/models/price_stamped_transaction.dart';
import 'package:web_dex/bloc/cex_market_data/profit_loss/models/profit_loss.dart';
import 'package:komodo_defi_types/types.dart';
import 'package:komodo_defi_types/komodo_defi_types.dart';

class ProfitLossCalculator {
ProfitLossCalculator(this._cexRepository);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'dart:math';
import 'package:hive/hive.dart';
import 'package:komodo_cex_market_data/komodo_cex_market_data.dart' as cex;
import 'package:komodo_cex_market_data/komodo_cex_market_data.dart';
import 'package:komodo_defi_sdk/komodo_defi_sdk.dart';
import 'package:komodo_persistence_layer/komodo_persistence_layer.dart';
import 'package:web_dex/bloc/cex_market_data/charts.dart';
import 'package:web_dex/bloc/cex_market_data/mockup/performance_mode.dart';
Expand Down Expand Up @@ -57,6 +58,7 @@ class ProfitLossRepository {
required cex.CexRepository cexRepository,
required CoinsRepo coinsRepository,
required Mm2Api mm2Api,
required KomodoDefiSdk sdk,
PerformanceMode? demoMode,
}) {
if (demoMode != null) {
Expand All @@ -65,6 +67,7 @@ class ProfitLossRepository {
coinsRepository: coinsRepository,
cacheTableName: 'mock_${cacheTableName}_${demoMode.name}',
mm2Api: mm2Api,
sdk: sdk,
);
}

Expand Down
Loading