diff --git a/.github/workflows/unit-tests-on-pr.yml b/.github/workflows/unit-tests-on-pr.yml index 159034ca51..820dcb9b3e 100644 --- a/.github/workflows/unit-tests-on-pr.yml +++ b/.github/workflows/unit-tests-on-pr.yml @@ -8,7 +8,7 @@ on: jobs: unit_tests_: - runs-on: ubuntu-latest + runs-on: [self-hosted, Linux] timeout-minutes: 15 steps: diff --git a/app_build/build_config.json b/app_build/build_config.json index 2f102fa952..dd99aa334c 100644 --- a/app_build/build_config.json +++ b/app_build/build_config.json @@ -18,10 +18,11 @@ } }, "coins": { + "fetch_at_build_enabled": true, "update_commit_on_build": true, "bundled_coins_repo_commit": "b27db8e6e1c6a9264219fef8292811122538088a", "coins_repo_api_url": "https://api.github.com/repos/KomodoPlatform/coins", - "coins_repo_content_url": "https://raw.githubusercontent.com/KomodoPlatform/coins", + "coins_repo_content_url": "https://komodoplatform.github.io/coins", "coins_repo_branch": "master", "runtime_updates_enabled": true, "mapped_files": { diff --git a/lib/router/parsers/root_route_parser.dart b/lib/router/parsers/root_route_parser.dart index ed5ca51a8f..f46246480e 100644 --- a/lib/router/parsers/root_route_parser.dart +++ b/lib/router/parsers/root_route_parser.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:web_dex/app_config/app_config.dart'; +import 'package:web_dex/bloc/coins_bloc/coins_bloc.dart'; import 'package:web_dex/model/first_uri_segment.dart'; import 'package:web_dex/router/parsers/base_route_parser.dart'; import 'package:web_dex/router/parsers/bridge_route_parser.dart'; @@ -11,22 +12,26 @@ import 'package:web_dex/router/parsers/wallet_route_parser.dart'; import 'package:web_dex/router/routes.dart'; class RootRouteInformationParser extends RouteInformationParser { - final Map _parsers = { - firstUriSegment.wallet: walletRouteParser, - firstUriSegment.fiat: fiatRouteParser, - firstUriSegment.dex: dexRouteParser, - firstUriSegment.bridge: bridgeRouteParser, - firstUriSegment.nfts: nftRouteParser, - firstUriSegment.settings: settingsRouteParser, - }; + RootRouteInformationParser(this.coinsBloc); + + final CoinsBloc coinsBloc; + + Map get _parsers => { + firstUriSegment.wallet: WalletRouteParser(coinsBloc), + firstUriSegment.fiat: fiatRouteParser, + firstUriSegment.dex: dexRouteParser, + firstUriSegment.bridge: bridgeRouteParser, + firstUriSegment.nfts: nftRouteParser, + firstUriSegment.settings: settingsRouteParser, + }; @override Future parseRouteInformation( RouteInformation routeInformation) async { - final uri = Uri.parse(routeInformation.uri.path); - final BaseRouteParser parser = _getRoutParser(uri); + final BaseRouteParser parser = + _getRoutParser(Uri.parse(routeInformation.uri.path)); - return parser.getRoutePath(uri); + return parser.getRoutePath(routeInformation.uri); } @override @@ -35,8 +40,8 @@ class RootRouteInformationParser extends RouteInformationParser { } BaseRouteParser _getRoutParser(Uri uri) { - const defaultRouteParser = - kIsWalletOnly ? walletRouteParser : dexRouteParser; + final defaultRouteParser = + kIsWalletOnly ? _parsers[firstUriSegment.wallet]! : dexRouteParser; if (uri.pathSegments.isEmpty) return defaultRouteParser; return _parsers[uri.pathSegments.first] ?? defaultRouteParser; diff --git a/lib/shared/widgets/logout_popup.dart b/lib/shared/widgets/logout_popup.dart index 6b209b3f71..d457f46681 100644 --- a/lib/shared/widgets/logout_popup.dart +++ b/lib/shared/widgets/logout_popup.dart @@ -2,12 +2,11 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:web_dex/app_config/app_config.dart'; +import 'package:komodo_ui_kit/komodo_ui_kit.dart'; import 'package:web_dex/bloc/auth_bloc/auth_bloc.dart'; -import 'package:web_dex/bloc/auth_bloc/auth_bloc_event.dart'; -import 'package:web_dex/blocs/blocs.dart'; +import 'package:web_dex/bloc/coins_bloc/coins_bloc.dart'; import 'package:web_dex/generated/codegen_loader.g.dart'; import 'package:web_dex/model/wallet.dart'; -import 'package:komodo_ui_kit/komodo_ui_kit.dart'; class LogOutPopup extends StatelessWidget { const LogOutPopup({ @@ -20,56 +19,65 @@ class LogOutPopup extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( - constraints: const BoxConstraints(maxWidth: 300), - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: [ - SelectableText( - LocaleKeys.logoutPopupTitle.tr(), - style: const TextStyle( - fontSize: 18, - fontWeight: FontWeight.w700, - ), - ), - const SizedBox(height: 12), - if (currentWalletBloc.wallet?.config.type == WalletType.iguana) - SelectableText( - kIsWalletOnly - ? LocaleKeys.logoutPopupDescriptionWalletOnly.tr() - : LocaleKeys.logoutPopupDescription.tr(), - style: const TextStyle( - fontSize: 14, - fontWeight: FontWeight.w500, - ), - ), - const SizedBox(height: 25), - Row( + return BlocBuilder( + builder: (context, state) { + final currentWallet = state.currentUser?.wallet; + return Container( + constraints: const BoxConstraints(maxWidth: 300), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ - UiUnderlineTextButton( - key: const Key('popup-cancel-logout-button'), - width: 120, - height: 36, - text: LocaleKeys.cancel.tr(), - onPressed: onCancel, + SelectableText( + LocaleKeys.logoutPopupTitle.tr(), + style: const TextStyle( + fontSize: 18, + fontWeight: FontWeight.w700, + ), ), - const SizedBox(width: 12), - UiPrimaryButton( - key: const Key('popup-confirm-logout-button'), - width: 120, - height: 36, - text: LocaleKeys.logOut.tr(), - onPressed: () { - context.read().add(const AuthLogOutEvent()); - onConfirm(); - }, + const SizedBox(height: 12), + if (currentWallet?.config.type == WalletType.iguana) + SelectableText( + kIsWalletOnly + ? LocaleKeys.logoutPopupDescriptionWalletOnly.tr() + : LocaleKeys.logoutPopupDescription.tr(), + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.w500, + ), + ), + const SizedBox(height: 25), + Row( + mainAxisSize: MainAxisSize.min, + children: [ + UiUnderlineTextButton( + key: const Key('popup-cancel-logout-button'), + width: 120, + height: 36, + text: LocaleKeys.cancel.tr(), + onPressed: onCancel, + ), + const SizedBox(width: 12), + UiPrimaryButton( + key: const Key('popup-confirm-logout-button'), + width: 120, + height: 36, + text: LocaleKeys.logOut.tr(), + onPressed: () => _onConfirmLogout(context), + ), + ], ), ], ), - ], - ), + ); + }, ); } + + void _onConfirmLogout(BuildContext context) { + // stop listening to balance updates before logging out + context.read().add(CoinsSessionEnded()); + context.read().add(const AuthSignOutRequested()); + onConfirm(); + } } diff --git a/lib/views/settings/widgets/general_settings/general_settings.dart b/lib/views/settings/widgets/general_settings/general_settings.dart index 6928baa4e8..b9f9e2880a 100644 --- a/lib/views/settings/widgets/general_settings/general_settings.dart +++ b/lib/views/settings/widgets/general_settings/general_settings.dart @@ -6,6 +6,7 @@ import 'package:web_dex/shared/widgets/hidden_without_wallet.dart'; import 'package:web_dex/views/settings/widgets/general_settings/import_swaps.dart'; import 'package:web_dex/views/settings/widgets/general_settings/settings_download_logs.dart'; import 'package:web_dex/views/settings/widgets/general_settings/settings_manage_analytics.dart'; +import 'package:web_dex/views/settings/widgets/general_settings/settings_manage_test_coins.dart'; import 'package:web_dex/views/settings/widgets/general_settings/settings_manage_trading_bot.dart'; import 'package:web_dex/views/settings/widgets/general_settings/settings_reset_activated_coins.dart'; import 'package:web_dex/views/settings/widgets/general_settings/settings_theme_switcher.dart'; @@ -25,6 +26,8 @@ class GeneralSettings extends StatelessWidget { const SizedBox(height: 25), const SettingsManageAnalytics(), const SizedBox(height: 25), + const SettingsManageTestCoins(), + const SizedBox(height: 25), if (!kIsWalletOnly) const HiddenWithoutWallet( child: SettingsManageTradingBot(), diff --git a/packages/komodo_ui_kit/lib/src/images/coin_icon.dart b/packages/komodo_ui_kit/lib/src/images/coin_icon.dart index 57bcb448e3..4d729332ad 100644 --- a/packages/komodo_ui_kit/lib/src/images/coin_icon.dart +++ b/packages/komodo_ui_kit/lib/src/images/coin_icon.dart @@ -2,7 +2,8 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -const coinImagesFolder = 'coin_icons/png/'; +const coinImagesFolder = 'packages/komodo_defi_framework/assets/coin_icons/png/'; +// NB: ENSURE IT STAYS IN SYNC WITH MAIN PROJECT in `lib/src/utils/utils.dart`. const mediaCdnUrl = 'https://komodoplatform.github.io/coins/icons/'; final Map _assetExistenceCache = {};