From d8df9ab493ee5dc3a8f8e2a3f60c651fb2025134 Mon Sep 17 00:00:00 2001 From: L3odr0id Date: Fri, 9 Aug 2024 17:28:32 +0300 Subject: [PATCH 1/7] fix: Fixed error of parsing raw asset balance --- .../presentation/widgets/poscan_asset_balance_widget.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/features/wallet_screen/non_native_token_screen/presentation/widgets/poscan_asset_balance_widget.dart b/lib/features/wallet_screen/non_native_token_screen/presentation/widgets/poscan_asset_balance_widget.dart index 27b009f3..6f775389 100644 --- a/lib/features/wallet_screen/non_native_token_screen/presentation/widgets/poscan_asset_balance_widget.dart +++ b/lib/features/wallet_screen/non_native_token_screen/presentation/widgets/poscan_asset_balance_widget.dart @@ -21,7 +21,7 @@ class PoscanAssetBalanceWidget extends StatelessWidget { child: AssetBalanceText( balance: BalanceUtils.formattedBigInt( poscanAssetBalance != null - ? BigInt.parse(poscanAssetBalance!.balance) + ? poscanAssetBalance!.decodedRawBalance : BigInt.zero, int.parse(metadata.decimals), ), From a5633cfbcb6a31117daf04194b69cf0a1e36e20a Mon Sep 17 00:00:00 2001 From: L3odr0id Date: Wed, 14 Aug 2024 20:03:59 +0300 Subject: [PATCH 2/7] fix: Allowed to create an asset with zero decimals --- lib/core/utils/validators.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/utils/validators.dart b/lib/core/utils/validators.dart index 1d3fb241..e8f36ea1 100644 --- a/lib/core/utils/validators.dart +++ b/lib/core/utils/validators.dart @@ -36,7 +36,7 @@ class Validators { static String? onlyU8(final String? p0) { final res = int.tryParse(p0 ?? ''); - return res != null && res > 0 && res <= 255 ? null : 'error_u8'.tr(); + return res != null && res >= 0 && res <= 255 ? null : 'error_u8'.tr(); } static String? onlyBigInt(final String? p0) { From b2e49a19ede7c86ad58557cdbb169652e9369ea1 Mon Sep 17 00:00:00 2001 From: L3odr0id Date: Wed, 14 Aug 2024 20:06:56 +0300 Subject: [PATCH 3/7] refactor: Rename folders and change some texts --- assets/translations/en.json | 6 +- .../polkawallet/bloc/app_service_cubit.dart | 2 +- .../presentation/global_states_provider.dart | 2 +- .../data/asset_conversion_repository.dart | 9 +- .../asset_conversion/di_asset_conversion.dart | 4 +- .../add_liquidity_global_handler.dart | 2 +- .../entities/create_pool_global_handler.dart | 2 +- .../remove_liquidity_global_handler.dart | 2 +- .../entities/swap_asset_global_handler.dart | 2 +- .../domain/use_cases/add_liquidity.dart | 2 +- .../domain/use_cases/create_pool.dart | 2 +- .../domain/use_cases/remove_liquidity.dart | 2 +- .../domain/use_cases/swap_assets.dart | 2 +- .../bloc/pools_cubit.dart | 0 .../presentation/pools_page.dart | 6 +- .../presentation/pools_page_wrapper.dart | 0 .../presentation/widgets/pool_card.dart | 0 .../{swap_page => swap}/bloc/swap_cubit.dart | 9 +- .../bloc/swap_cubit.freezed.dart | 0 .../presentation/swap_page.dart | 12 +- .../presentation/swap_page_wrapper.dart | 4 +- .../widgets/asset_choice_chip.dart | 40 ++-- .../widgets/asset_select_card.dart | 9 +- .../swap_assets_notification_card.dart | 0 .../presentation/widgets/swap_info_text.dart | 2 +- .../data/poscan_remote_repository.dart | 2 + .../widgets/notification_card.dart | 2 +- .../open_pools/open_pools_button.dart | 2 +- lib/router/router.gr.dart | 226 +++++++++--------- pubspec.lock | 12 +- pubspec.yaml | 2 +- 31 files changed, 191 insertions(+), 176 deletions(-) rename lib/features/asset_conversion/ui/{pools_page => pools_list}/bloc/pools_cubit.dart (100%) rename lib/features/asset_conversion/ui/{pools_page => pools_list}/presentation/pools_page.dart (92%) rename lib/features/asset_conversion/ui/{pools_page => pools_list}/presentation/pools_page_wrapper.dart (100%) rename lib/features/asset_conversion/ui/{pools_page => pools_list}/presentation/widgets/pool_card.dart (100%) rename lib/features/asset_conversion/ui/{swap_page => swap}/bloc/swap_cubit.dart (96%) rename lib/features/asset_conversion/ui/{swap_page => swap}/bloc/swap_cubit.freezed.dart (100%) rename lib/features/asset_conversion/ui/{swap_page => swap}/presentation/swap_page.dart (89%) rename lib/features/asset_conversion/ui/{swap_page => swap}/presentation/swap_page_wrapper.dart (78%) rename lib/features/asset_conversion/ui/{swap_page => swap}/presentation/widgets/asset_choice_chip.dart (73%) rename lib/features/asset_conversion/ui/{swap_page => swap}/presentation/widgets/asset_select_card.dart (91%) rename lib/features/asset_conversion/ui/{swap_page => swap}/presentation/widgets/swap_assets_notification_card.dart (100%) rename lib/features/asset_conversion/ui/{swap_page => swap}/presentation/widgets/swap_info_text.dart (95%) diff --git a/assets/translations/en.json b/assets/translations/en.json index c2a0d058..25b00536 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -462,7 +462,7 @@ "set_metadata_label_name": "Name", "set_metadata_label_symbols": "Symbols", "set_metadata_label_decimals": "Decimals", - "error_u8": "Expected 0 < value < 255", + "error_u8": "Expected 0 <= value < 255", "set_metadata_notification_asset_id": "Asset id:", "show_all_assets_label": "Show all assets", @@ -486,8 +486,8 @@ "chain_status_recognized": "Recognized", "@2.15.2": {}, - "open_pools_label": "Pools", - "pools_page_appbar": "Pools", + "open_pools_label": "Liquidity pools", + "pools_page_appbar": "Liquidity pools", "pools_text": "Earn fees by providing liquidity.", "withdraw_button_label": "Withdraw", "deposit_button_label": "Deposit", diff --git a/lib/core/polkawallet/bloc/app_service_cubit.dart b/lib/core/polkawallet/bloc/app_service_cubit.dart index 9e27509f..a819274f 100644 --- a/lib/core/polkawallet/bloc/app_service_cubit.dart +++ b/lib/core/polkawallet/bloc/app_service_cubit.dart @@ -15,7 +15,7 @@ import 'package:threedpass/core/polkawallet/utils/balance_utils.dart'; import 'package:threedpass/core/polkawallet/utils/network_state_data_extension.dart'; import 'package:threedpass/core/polkawallet/utils/tx_update_event_logs_handler.dart'; import 'package:threedpass/features/accounts/domain/account_info.dart'; -import 'package:threedpass/features/asset_conversion/ui/pools_page/bloc/pools_cubit.dart'; +import 'package:threedpass/features/asset_conversion/ui/pools_list/bloc/pools_cubit.dart'; import 'package:threedpass/features/poscan_assets/bloc/poscan_assets_cubit.dart'; import 'package:threedpass/features/poscan_objects_query/bloc/poscan_objects_cubit.dart'; import 'package:threedpass/features/poscan_objects_query/data/poscan_local_repository.dart'; diff --git a/lib/features/app/presentation/global_states_provider.dart b/lib/features/app/presentation/global_states_provider.dart index d4678a01..00c6d9af 100644 --- a/lib/features/app/presentation/global_states_provider.dart +++ b/lib/features/app/presentation/global_states_provider.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_platform_widgets/flutter_platform_widgets.dart'; import 'package:threedpass/core/polkawallet/bloc/app_service_cubit.dart'; -import 'package:threedpass/features/asset_conversion/ui/pools_page/bloc/pools_cubit.dart'; +import 'package:threedpass/features/asset_conversion/ui/pools_list/bloc/pools_cubit.dart'; import 'package:threedpass/features/hashes_list/bloc/hashes_list_bloc.dart'; import 'package:threedpass/features/poscan_assets/bloc/poscan_assets_cubit.dart'; import 'package:threedpass/features/poscan_objects_query/bloc/poscan_objects_cubit.dart'; diff --git a/lib/features/asset_conversion/data/asset_conversion_repository.dart b/lib/features/asset_conversion/data/asset_conversion_repository.dart index fd61f8e7..11905dce 100644 --- a/lib/features/asset_conversion/data/asset_conversion_repository.dart +++ b/lib/features/asset_conversion/data/asset_conversion_repository.dart @@ -139,14 +139,14 @@ let res = await pools.getPoolReserves(api, m1, m2); return res; """; - logger.v('CODE ' + getPoolReserversFunc); + // logger.v('CODE ' + getPoolReserversFunc); final dynamic res = await basicJSCall( getPoolReserversFunc, polkawalletSdk.webView!.webInstance!.webViewController, ); - logger.v('call res: $res'); + logger.v('poolReserve res: $res'); // [10,530,015,434, 9,509,085,784] if (res == null) { @@ -173,7 +173,7 @@ return res; polkawalletSdk.webView!.webInstance!.webViewController, ); // [[[Native, {Asset: 4}], {lpToken: 0}]] - print(res); + logger.v('PoolsBasic res: $res'); res as List; final resT = res @@ -349,6 +349,9 @@ return res; polkawalletSdk.webView!.webInstance!.webViewController, ); // [[[Native, {Asset: 4}], {lpToken: 0}]] + logger.v( + 'callTokenServiceRoutine. tokenServiceCall: $tokenServiceCall res: $res', + ); if (res is String) { return Either.right(res); } else { diff --git a/lib/features/asset_conversion/di_asset_conversion.dart b/lib/features/asset_conversion/di_asset_conversion.dart index 2de61cf2..7829f2e8 100644 --- a/lib/features/asset_conversion/di_asset_conversion.dart +++ b/lib/features/asset_conversion/di_asset_conversion.dart @@ -16,9 +16,9 @@ import 'package:threedpass/features/asset_conversion/domain/use_cases/remove_liq import 'package:threedpass/features/asset_conversion/domain/use_cases/swap_assets.dart'; import 'package:threedpass/features/asset_conversion/ui/add_liquidity/bloc/add_liquidity_cubit.dart'; import 'package:threedpass/features/asset_conversion/ui/create_pool/bloc/create_pool_cubit.dart'; -import 'package:threedpass/features/asset_conversion/ui/pools_page/bloc/pools_cubit.dart'; +import 'package:threedpass/features/asset_conversion/ui/pools_list/bloc/pools_cubit.dart'; import 'package:threedpass/features/asset_conversion/ui/remove_liquidity/bloc/remove_liquidity_cubit.dart'; -import 'package:threedpass/features/asset_conversion/ui/swap_page/bloc/swap_cubit.dart'; +import 'package:threedpass/features/asset_conversion/ui/swap/bloc/swap_cubit.dart'; import 'package:threedpass/features/poscan_assets/bloc/poscan_assets_cubit.dart'; import 'package:threedpass/features/poscan_assets/data/poscan_assets_repository.dart'; import 'package:threedpass/features/wallet_screen/notifications_page/bloc/notifications_bloc.dart'; diff --git a/lib/features/asset_conversion/domain/entities/add_liquidity_global_handler.dart b/lib/features/asset_conversion/domain/entities/add_liquidity_global_handler.dart index 816c651d..37c8fb64 100644 --- a/lib/features/asset_conversion/domain/entities/add_liquidity_global_handler.dart +++ b/lib/features/asset_conversion/domain/entities/add_liquidity_global_handler.dart @@ -1,6 +1,6 @@ import 'package:threedpass/core/polkawallet/bloc/app_service_cubit.dart'; import 'package:threedpass/core/polkawallet/utils/extrinsic_status.dart'; -import 'package:threedpass/features/asset_conversion/ui/pools_page/bloc/pools_cubit.dart'; +import 'package:threedpass/features/asset_conversion/ui/pools_list/bloc/pools_cubit.dart'; import 'package:threedpass/features/wallet_screen/notifications_page/bloc/notifications_bloc.dart'; import 'package:threedpass/features/wallet_screen/notifications_page/utils/primitive_event_logs_handler.dart'; diff --git a/lib/features/asset_conversion/domain/entities/create_pool_global_handler.dart b/lib/features/asset_conversion/domain/entities/create_pool_global_handler.dart index b8b84ab7..f27121ab 100644 --- a/lib/features/asset_conversion/domain/entities/create_pool_global_handler.dart +++ b/lib/features/asset_conversion/domain/entities/create_pool_global_handler.dart @@ -1,6 +1,6 @@ import 'package:threedpass/core/polkawallet/bloc/app_service_cubit.dart'; import 'package:threedpass/core/polkawallet/utils/extrinsic_status.dart'; -import 'package:threedpass/features/asset_conversion/ui/pools_page/bloc/pools_cubit.dart'; +import 'package:threedpass/features/asset_conversion/ui/pools_list/bloc/pools_cubit.dart'; import 'package:threedpass/features/wallet_screen/notifications_page/bloc/notifications_bloc.dart'; import 'package:threedpass/features/wallet_screen/notifications_page/utils/primitive_event_logs_handler.dart'; diff --git a/lib/features/asset_conversion/domain/entities/remove_liquidity_global_handler.dart b/lib/features/asset_conversion/domain/entities/remove_liquidity_global_handler.dart index 386d179d..79314105 100644 --- a/lib/features/asset_conversion/domain/entities/remove_liquidity_global_handler.dart +++ b/lib/features/asset_conversion/domain/entities/remove_liquidity_global_handler.dart @@ -1,6 +1,6 @@ import 'package:threedpass/core/polkawallet/bloc/app_service_cubit.dart'; import 'package:threedpass/core/polkawallet/utils/extrinsic_status.dart'; -import 'package:threedpass/features/asset_conversion/ui/pools_page/bloc/pools_cubit.dart'; +import 'package:threedpass/features/asset_conversion/ui/pools_list/bloc/pools_cubit.dart'; import 'package:threedpass/features/wallet_screen/notifications_page/bloc/notifications_bloc.dart'; import 'package:threedpass/features/wallet_screen/notifications_page/utils/primitive_event_logs_handler.dart'; diff --git a/lib/features/asset_conversion/domain/entities/swap_asset_global_handler.dart b/lib/features/asset_conversion/domain/entities/swap_asset_global_handler.dart index 6495f059..657e044b 100644 --- a/lib/features/asset_conversion/domain/entities/swap_asset_global_handler.dart +++ b/lib/features/asset_conversion/domain/entities/swap_asset_global_handler.dart @@ -1,6 +1,6 @@ import 'package:threedpass/core/polkawallet/bloc/app_service_cubit.dart'; import 'package:threedpass/core/polkawallet/utils/extrinsic_status.dart'; -import 'package:threedpass/features/asset_conversion/ui/pools_page/bloc/pools_cubit.dart'; +import 'package:threedpass/features/asset_conversion/ui/pools_list/bloc/pools_cubit.dart'; import 'package:threedpass/features/poscan_assets/bloc/poscan_assets_cubit.dart'; import 'package:threedpass/features/wallet_screen/notifications_page/bloc/notifications_bloc.dart'; import 'package:threedpass/features/wallet_screen/notifications_page/utils/primitive_event_logs_handler.dart'; diff --git a/lib/features/asset_conversion/domain/use_cases/add_liquidity.dart b/lib/features/asset_conversion/domain/use_cases/add_liquidity.dart index b9ddc297..e845099f 100644 --- a/lib/features/asset_conversion/domain/use_cases/add_liquidity.dart +++ b/lib/features/asset_conversion/domain/use_cases/add_liquidity.dart @@ -7,7 +7,7 @@ import 'package:threedpass/core/polkawallet/utils/extrinsic_status.dart'; import 'package:threedpass/features/asset_conversion/data/asset_conversion_repository.dart'; import 'package:threedpass/features/asset_conversion/domain/entities/add_liquidity_global_handler.dart'; import 'package:threedpass/features/asset_conversion/domain/entities/basic_pool_entity.dart'; -import 'package:threedpass/features/asset_conversion/ui/pools_page/bloc/pools_cubit.dart'; +import 'package:threedpass/features/asset_conversion/ui/pools_list/bloc/pools_cubit.dart'; import 'package:threedpass/features/wallet_screen/notifications_page/bloc/notifications_bloc.dart'; class AddLiquidity extends UseCase { diff --git a/lib/features/asset_conversion/domain/use_cases/create_pool.dart b/lib/features/asset_conversion/domain/use_cases/create_pool.dart index 7035d8c8..38efefe3 100644 --- a/lib/features/asset_conversion/domain/use_cases/create_pool.dart +++ b/lib/features/asset_conversion/domain/use_cases/create_pool.dart @@ -6,7 +6,7 @@ import 'package:threedpass/core/polkawallet/utils/extrinsic_status.dart'; import 'package:threedpass/features/asset_conversion/data/asset_conversion_repository.dart'; import 'package:threedpass/features/asset_conversion/domain/entities/basic_pool_entity.dart'; import 'package:threedpass/features/asset_conversion/domain/entities/create_pool_global_handler.dart'; -import 'package:threedpass/features/asset_conversion/ui/pools_page/bloc/pools_cubit.dart'; +import 'package:threedpass/features/asset_conversion/ui/pools_list/bloc/pools_cubit.dart'; import 'package:threedpass/features/wallet_screen/notifications_page/bloc/notifications_bloc.dart'; class CreatePool extends UseCase { diff --git a/lib/features/asset_conversion/domain/use_cases/remove_liquidity.dart b/lib/features/asset_conversion/domain/use_cases/remove_liquidity.dart index 6a4ed29e..d7ad9fac 100644 --- a/lib/features/asset_conversion/domain/use_cases/remove_liquidity.dart +++ b/lib/features/asset_conversion/domain/use_cases/remove_liquidity.dart @@ -6,7 +6,7 @@ import 'package:threedpass/core/polkawallet/utils/extrinsic_status.dart'; import 'package:threedpass/features/asset_conversion/data/asset_conversion_repository.dart'; import 'package:threedpass/features/asset_conversion/domain/entities/basic_pool_entity.dart'; import 'package:threedpass/features/asset_conversion/domain/entities/remove_liquidity_global_handler.dart'; -import 'package:threedpass/features/asset_conversion/ui/pools_page/bloc/pools_cubit.dart'; +import 'package:threedpass/features/asset_conversion/ui/pools_list/bloc/pools_cubit.dart'; import 'package:threedpass/features/wallet_screen/notifications_page/bloc/notifications_bloc.dart'; class RemoveLiquidity extends UseCase { diff --git a/lib/features/asset_conversion/domain/use_cases/swap_assets.dart b/lib/features/asset_conversion/domain/use_cases/swap_assets.dart index baa5bfe9..aa50083e 100644 --- a/lib/features/asset_conversion/domain/use_cases/swap_assets.dart +++ b/lib/features/asset_conversion/domain/use_cases/swap_assets.dart @@ -7,7 +7,7 @@ import 'package:threedpass/features/asset_conversion/data/asset_conversion_repos import 'package:threedpass/features/asset_conversion/domain/entities/basic_pool_entity.dart'; import 'package:threedpass/features/asset_conversion/domain/entities/swap_asset_global_handler.dart'; import 'package:threedpass/features/asset_conversion/domain/entities/swap_method.dart'; -import 'package:threedpass/features/asset_conversion/ui/pools_page/bloc/pools_cubit.dart'; +import 'package:threedpass/features/asset_conversion/ui/pools_list/bloc/pools_cubit.dart'; import 'package:threedpass/features/poscan_assets/bloc/poscan_assets_cubit.dart'; import 'package:threedpass/features/wallet_screen/notifications_page/bloc/notifications_bloc.dart'; diff --git a/lib/features/asset_conversion/ui/pools_page/bloc/pools_cubit.dart b/lib/features/asset_conversion/ui/pools_list/bloc/pools_cubit.dart similarity index 100% rename from lib/features/asset_conversion/ui/pools_page/bloc/pools_cubit.dart rename to lib/features/asset_conversion/ui/pools_list/bloc/pools_cubit.dart diff --git a/lib/features/asset_conversion/ui/pools_page/presentation/pools_page.dart b/lib/features/asset_conversion/ui/pools_list/presentation/pools_page.dart similarity index 92% rename from lib/features/asset_conversion/ui/pools_page/presentation/pools_page.dart rename to lib/features/asset_conversion/ui/pools_list/presentation/pools_page.dart index 9003b13d..dba9cb18 100644 --- a/lib/features/asset_conversion/ui/pools_page/presentation/pools_page.dart +++ b/lib/features/asset_conversion/ui/pools_list/presentation/pools_page.dart @@ -10,8 +10,8 @@ import 'package:threedpass/core/widgets/layout/list_view_separated.dart'; import 'package:threedpass/core/widgets/other/padding_16.dart'; import 'package:threedpass/core/widgets/paddings.dart'; import 'package:threedpass/core/widgets/text/d3p_body_medium_text.dart'; -import 'package:threedpass/features/asset_conversion/ui/pools_page/bloc/pools_cubit.dart'; -import 'package:threedpass/features/asset_conversion/ui/pools_page/presentation/widgets/pool_card.dart'; +import 'package:threedpass/features/asset_conversion/ui/pools_list/bloc/pools_cubit.dart'; +import 'package:threedpass/features/asset_conversion/ui/pools_list/presentation/widgets/pool_card.dart'; import 'package:threedpass/router/router.gr.dart'; @RoutePage() @@ -60,7 +60,7 @@ class PoolsPage extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ - D3pBodyMediumText('pools_text'), + const D3pBodyMediumText('pools_text'), const H16(), ListViewSeparated( separator: const H16(), diff --git a/lib/features/asset_conversion/ui/pools_page/presentation/pools_page_wrapper.dart b/lib/features/asset_conversion/ui/pools_list/presentation/pools_page_wrapper.dart similarity index 100% rename from lib/features/asset_conversion/ui/pools_page/presentation/pools_page_wrapper.dart rename to lib/features/asset_conversion/ui/pools_list/presentation/pools_page_wrapper.dart diff --git a/lib/features/asset_conversion/ui/pools_page/presentation/widgets/pool_card.dart b/lib/features/asset_conversion/ui/pools_list/presentation/widgets/pool_card.dart similarity index 100% rename from lib/features/asset_conversion/ui/pools_page/presentation/widgets/pool_card.dart rename to lib/features/asset_conversion/ui/pools_list/presentation/widgets/pool_card.dart diff --git a/lib/features/asset_conversion/ui/swap_page/bloc/swap_cubit.dart b/lib/features/asset_conversion/ui/swap/bloc/swap_cubit.dart similarity index 96% rename from lib/features/asset_conversion/ui/swap_page/bloc/swap_cubit.dart rename to lib/features/asset_conversion/ui/swap/bloc/swap_cubit.dart index 47d3bcc8..3cc07fe1 100644 --- a/lib/features/asset_conversion/ui/swap_page/bloc/swap_cubit.dart +++ b/lib/features/asset_conversion/ui/swap/bloc/swap_cubit.dart @@ -15,7 +15,7 @@ import 'package:threedpass/features/asset_conversion/domain/entities/basic_pool_ import 'package:threedpass/features/asset_conversion/domain/entities/swap_method.dart'; import 'package:threedpass/features/asset_conversion/domain/use_cases/calc_swap_info.dart'; import 'package:threedpass/features/asset_conversion/domain/use_cases/swap_assets.dart'; -import 'package:threedpass/features/asset_conversion/ui/pools_page/bloc/pools_cubit.dart'; +import 'package:threedpass/features/asset_conversion/ui/pools_list/bloc/pools_cubit.dart'; import 'package:threedpass/features/poscan_assets/bloc/poscan_assets_cubit.dart'; import 'package:threedpass/features/poscan_assets/domain/entities/poscan_asset_metadata.dart'; @@ -117,9 +117,14 @@ class SwapCubit extends Cubit with ExtrinsicShowLoadingMixin { } void setFirstAsset(final PoolAssetField asset) { + logger.v( + 'Swap. setFirstAsset. isSelectedEqualToSecond:${asset == state.secondAsset} first:${state.firstAsset} second:${state.secondAsset}', + ); emit( state.copyWith( firstAsset: asset, + secondAsset: + asset == state.secondAsset ? state.firstAsset : state.secondAsset, // slippageValue: null, ), ); @@ -130,6 +135,8 @@ class SwapCubit extends Cubit with ExtrinsicShowLoadingMixin { void setSecondAsset(final PoolAssetField asset) { emit( state.copyWith( + firstAsset: + asset == state.firstAsset ? state.secondAsset : state.firstAsset, secondAsset: asset, // slippageValue: null, ), diff --git a/lib/features/asset_conversion/ui/swap_page/bloc/swap_cubit.freezed.dart b/lib/features/asset_conversion/ui/swap/bloc/swap_cubit.freezed.dart similarity index 100% rename from lib/features/asset_conversion/ui/swap_page/bloc/swap_cubit.freezed.dart rename to lib/features/asset_conversion/ui/swap/bloc/swap_cubit.freezed.dart diff --git a/lib/features/asset_conversion/ui/swap_page/presentation/swap_page.dart b/lib/features/asset_conversion/ui/swap/presentation/swap_page.dart similarity index 89% rename from lib/features/asset_conversion/ui/swap_page/presentation/swap_page.dart rename to lib/features/asset_conversion/ui/swap/presentation/swap_page.dart index 491a4320..618f9c99 100644 --- a/lib/features/asset_conversion/ui/swap_page/presentation/swap_page.dart +++ b/lib/features/asset_conversion/ui/swap/presentation/swap_page.dart @@ -6,10 +6,10 @@ import 'package:threedpass/core/widgets/input/switch_button.dart'; import 'package:threedpass/core/widgets/paddings.dart'; import 'package:threedpass/features/asset_conversion/domain/entities/basic_pool_entity.dart'; import 'package:threedpass/features/asset_conversion/domain/entities/swap_method.dart'; -import 'package:threedpass/features/asset_conversion/ui/pools_page/bloc/pools_cubit.dart'; -import 'package:threedpass/features/asset_conversion/ui/swap_page/bloc/swap_cubit.dart'; -import 'package:threedpass/features/asset_conversion/ui/swap_page/presentation/widgets/asset_select_card.dart'; -import 'package:threedpass/features/asset_conversion/ui/swap_page/presentation/widgets/swap_info_text.dart'; +import 'package:threedpass/features/asset_conversion/ui/pools_list/bloc/pools_cubit.dart'; +import 'package:threedpass/features/asset_conversion/ui/swap/bloc/swap_cubit.dart'; +import 'package:threedpass/features/asset_conversion/ui/swap/presentation/widgets/asset_select_card.dart'; +import 'package:threedpass/features/asset_conversion/ui/swap/presentation/widgets/swap_info_text.dart'; import 'package:threedpass/features/asset_conversion/ui/widgets/slippage_tolerance.dart'; import 'package:threedpass/features/other/choose_account/presentation/choose_account.dart'; import 'package:threedpass/features/other/some_form/some_form.dart'; @@ -58,7 +58,7 @@ class SwapPage extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ AssetSelectCard( - initialSelectionIndex: 0, + chosenItem: state.firstAsset, items: items, controller: swapCubit.firstAssetAmountController, isReadOnly: !isFirstTextFieldActive, @@ -77,7 +77,7 @@ class SwapPage extends StatelessWidget { ), const H4(), AssetSelectCard( - initialSelectionIndex: 1, + chosenItem: state.secondAsset, items: items, controller: swapCubit.secondAssetAmountController, isReadOnly: isFirstTextFieldActive, diff --git a/lib/features/asset_conversion/ui/swap_page/presentation/swap_page_wrapper.dart b/lib/features/asset_conversion/ui/swap/presentation/swap_page_wrapper.dart similarity index 78% rename from lib/features/asset_conversion/ui/swap_page/presentation/swap_page_wrapper.dart rename to lib/features/asset_conversion/ui/swap/presentation/swap_page_wrapper.dart index 5f04c62d..bd42eb93 100644 --- a/lib/features/asset_conversion/ui/swap_page/presentation/swap_page_wrapper.dart +++ b/lib/features/asset_conversion/ui/swap/presentation/swap_page_wrapper.dart @@ -2,8 +2,8 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:threedpass/features/asset_conversion/domain/entities/basic_pool_entity.dart'; -import 'package:threedpass/features/asset_conversion/ui/swap_page/bloc/swap_cubit.dart'; -import 'package:threedpass/features/asset_conversion/ui/swap_page/presentation/swap_page.dart'; +import 'package:threedpass/features/asset_conversion/ui/swap/bloc/swap_cubit.dart'; +import 'package:threedpass/features/asset_conversion/ui/swap/presentation/swap_page.dart'; import 'package:threedpass/setup.dart'; @RoutePage() diff --git a/lib/features/asset_conversion/ui/swap_page/presentation/widgets/asset_choice_chip.dart b/lib/features/asset_conversion/ui/swap/presentation/widgets/asset_choice_chip.dart similarity index 73% rename from lib/features/asset_conversion/ui/swap_page/presentation/widgets/asset_choice_chip.dart rename to lib/features/asset_conversion/ui/swap/presentation/widgets/asset_choice_chip.dart index 42f18fab..233efb5e 100644 --- a/lib/features/asset_conversion/ui/swap_page/presentation/widgets/asset_choice_chip.dart +++ b/lib/features/asset_conversion/ui/swap/presentation/widgets/asset_choice_chip.dart @@ -3,32 +3,34 @@ import 'package:threedpass/features/asset_conversion/domain/entities/basic_pool_ import 'package:threedpass/features/poscan_assets/ui/widgets/dropdown_asset_item.dart'; // https://github.com/flutter/flutter/issues/108683#issuecomment-2002177122 -class AssetChoiceChip extends StatefulWidget { +class AssetChoiceChip extends StatelessWidget { const AssetChoiceChip({ required this.menuItemList, - required this.initialSelectionIndex, + // required this.initialSelectionIndex, + required this.chosenItem, this.onSelected, super.key, }); final List<(PoolAssetField, Widget)> menuItemList; - final int initialSelectionIndex; + final PoolAssetField chosenItem; + // final int initialSelectionIndex; final void Function(PoolAssetField)? onSelected; - @override - State createState() => _ChipMenuState(); -} +// @override +// State createState() => _ChipMenuState(); +// } -class _ChipMenuState extends State { - late PoolAssetField selectedItem; +// class _ChipMenuState extends State { + // late PoolAssetField selectedItem; static const double menuButtonHeight = 48; - @override - void initState() { - super.initState(); - selectedItem = widget.menuItemList[widget.initialSelectionIndex].$1; - } + // @override + // void initState() { + // super.initState(); + // selectedItem = widget.menuItemList[widget.initialSelectionIndex].$1; + // } void onChipPressed(final MenuController controller) { if (controller.isOpen) { @@ -39,10 +41,10 @@ class _ChipMenuState extends State { } void onMenuItemPressed(final PoolAssetField rec) { - setState(() { - selectedItem = rec; - }); - widget.onSelected?.call(rec); + // setState(() { + // selectedItem = rec; + // }); + onSelected?.call(rec); } @override @@ -62,7 +64,7 @@ class _ChipMenuState extends State { showCheckmark: false, backgroundColor: Colors.green, label: DropdownAssetItem( - value: selectedItem, + value: chosenItem, prefixColor: Colors.white, mainColor: Colors.white, ), @@ -71,7 +73,7 @@ class _ChipMenuState extends State { ); }, menuChildren: [ - for (final rec in widget.menuItemList) + for (final rec in menuItemList) SizedBox( height: menuButtonHeight, child: MenuItemButton( diff --git a/lib/features/asset_conversion/ui/swap_page/presentation/widgets/asset_select_card.dart b/lib/features/asset_conversion/ui/swap/presentation/widgets/asset_select_card.dart similarity index 91% rename from lib/features/asset_conversion/ui/swap_page/presentation/widgets/asset_select_card.dart rename to lib/features/asset_conversion/ui/swap/presentation/widgets/asset_select_card.dart index 56dd2bf1..65bf30d5 100644 --- a/lib/features/asset_conversion/ui/swap_page/presentation/widgets/asset_select_card.dart +++ b/lib/features/asset_conversion/ui/swap/presentation/widgets/asset_select_card.dart @@ -3,22 +3,23 @@ import 'package:number_text_input_formatter/number_text_input_formatter.dart'; import 'package:threedpass/core/widgets/d3p_card.dart'; import 'package:threedpass/core/widgets/paddings.dart'; import 'package:threedpass/features/asset_conversion/domain/entities/basic_pool_entity.dart'; -import 'package:threedpass/features/asset_conversion/ui/swap_page/presentation/widgets/asset_choice_chip.dart'; +import 'package:threedpass/features/asset_conversion/ui/swap/presentation/widgets/asset_choice_chip.dart'; import 'package:threedpass/features/poscan_assets/ui/widgets/dropdown_asset_item.dart'; class AssetSelectCard extends StatelessWidget { final List items; - final int initialSelectionIndex; + // final int initialSelectionIndex; final TextEditingController controller; final bool isReadOnly; + final PoolAssetField chosenItem; final void Function(PoolAssetField) onSelected; const AssetSelectCard({ required this.items, - required this.initialSelectionIndex, required this.controller, required this.isReadOnly, required this.onSelected, + required this.chosenItem, super.key, }); @@ -32,8 +33,8 @@ class AssetSelectCard extends StatelessWidget { child: Row( children: [ AssetChoiceChip( + chosenItem: chosenItem, onSelected: onSelected, - initialSelectionIndex: initialSelectionIndex, menuItemList: items .map<(PoolAssetField, Widget)>( (final e) => ( diff --git a/lib/features/asset_conversion/ui/swap_page/presentation/widgets/swap_assets_notification_card.dart b/lib/features/asset_conversion/ui/swap/presentation/widgets/swap_assets_notification_card.dart similarity index 100% rename from lib/features/asset_conversion/ui/swap_page/presentation/widgets/swap_assets_notification_card.dart rename to lib/features/asset_conversion/ui/swap/presentation/widgets/swap_assets_notification_card.dart diff --git a/lib/features/asset_conversion/ui/swap_page/presentation/widgets/swap_info_text.dart b/lib/features/asset_conversion/ui/swap/presentation/widgets/swap_info_text.dart similarity index 95% rename from lib/features/asset_conversion/ui/swap_page/presentation/widgets/swap_info_text.dart rename to lib/features/asset_conversion/ui/swap/presentation/widgets/swap_info_text.dart index 08c6ef1a..6e32a5ce 100644 --- a/lib/features/asset_conversion/ui/swap_page/presentation/widgets/swap_info_text.dart +++ b/lib/features/asset_conversion/ui/swap/presentation/widgets/swap_info_text.dart @@ -3,7 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:threedpass/core/widgets/other/full_row_text.dart'; import 'package:threedpass/core/widgets/paddings.dart'; import 'package:threedpass/features/asset_conversion/domain/entities/swap_method.dart'; -import 'package:threedpass/features/asset_conversion/ui/swap_page/bloc/swap_cubit.dart'; +import 'package:threedpass/features/asset_conversion/ui/swap/bloc/swap_cubit.dart'; // TODO Make Expected and min/max values always have the same number of digits class SwapInfoText extends StatelessWidget { diff --git a/lib/features/poscan_objects_query/data/poscan_remote_repository.dart b/lib/features/poscan_objects_query/data/poscan_remote_repository.dart index 5c67405d..3d280237 100644 --- a/lib/features/poscan_objects_query/data/poscan_remote_repository.dart +++ b/lib/features/poscan_objects_query/data/poscan_remote_repository.dart @@ -27,6 +27,8 @@ class PoScanRemoteRepository { sendNullAsArg: false, ); + logger.v('Objects count on storage res:$res'); + final resStr = res.toString(); final maybeInt = int.tryParse(resStr); if (maybeInt != null) { diff --git a/lib/features/wallet_screen/notifications_page/presentation/widgets/notification_card.dart b/lib/features/wallet_screen/notifications_page/presentation/widgets/notification_card.dart index 4bb4726d..b66135cd 100644 --- a/lib/features/wallet_screen/notifications_page/presentation/widgets/notification_card.dart +++ b/lib/features/wallet_screen/notifications_page/presentation/widgets/notification_card.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:threedpass/features/asset_conversion/ui/add_liquidity/presentation/widgets/add_liquidity_notification_card.dart'; import 'package:threedpass/features/asset_conversion/ui/create_pool/presentation/widgets/create_pool_asset_card.dart'; import 'package:threedpass/features/asset_conversion/ui/remove_liquidity/presentation/widgets/remove_liquidity_notification_card.dart'; -import 'package:threedpass/features/asset_conversion/ui/swap_page/presentation/widgets/swap_assets_notification_card.dart'; +import 'package:threedpass/features/asset_conversion/ui/swap/presentation/widgets/swap_assets_notification_card.dart'; import 'package:threedpass/features/wallet_screen/notifications_page/bloc/notifications_bloc.dart'; import 'package:threedpass/features/wallet_screen/notifications_page/presentation/widgets/notfication_put_object.dart'; import 'package:threedpass/features/wallet_screen/notifications_page/presentation/widgets/notification_create_asset_card.dart'; diff --git a/lib/features/wallet_screen/open_pools/open_pools_button.dart b/lib/features/wallet_screen/open_pools/open_pools_button.dart index 494293bd..49c10f92 100644 --- a/lib/features/wallet_screen/open_pools/open_pools_button.dart +++ b/lib/features/wallet_screen/open_pools/open_pools_button.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:threedpass/core/widgets/buttons/secondary_button.dart'; import 'package:threedpass/core/widgets/other/padding_16.dart'; -import 'package:threedpass/features/asset_conversion/ui/pools_page/bloc/pools_cubit.dart'; +import 'package:threedpass/features/asset_conversion/ui/pools_list/bloc/pools_cubit.dart'; import 'package:threedpass/router/router.gr.dart'; class OpenPoolsButton extends StatelessWidget { diff --git a/lib/router/router.gr.dart b/lib/router/router.gr.dart index 4b6e22be..35c3e2ec 100644 --- a/lib/router/router.gr.dart +++ b/lib/router/router.gr.dart @@ -13,27 +13,27 @@ import 'package:flutter/material.dart' as _i67; import 'package:threedpass/core/widgets/default_loading_dialog.dart' as _i2; import 'package:threedpass/core/widgets/error_page.dart' as _i1; import 'package:threedpass/features/accounts/presentation/pages/create_account/create_account_credentials.dart' - as _i51; + as _i49; import 'package:threedpass/features/accounts/presentation/pages/create_account/create_account_from_object/create_account_from_object.dart' - as _i46; + as _i44; import 'package:threedpass/features/accounts/presentation/pages/create_account/create_account_info_page.dart' - as _i48; + as _i46; import 'package:threedpass/features/accounts/presentation/pages/create_account/create_account_loader.dart' - as _i53; + as _i51; import 'package:threedpass/features/accounts/presentation/pages/create_account/create_account_mnemonic_backup.dart' - as _i49; + as _i47; import 'package:threedpass/features/accounts/presentation/pages/create_account/create_account_mnemonic_confirm.dart' - as _i50; + as _i48; import 'package:threedpass/features/accounts/presentation/pages/create_account/create_account_type.dart' - as _i52; + as _i50; import 'package:threedpass/features/accounts/presentation/pages/create_account/create_account_wrapper.dart' - as _i45; + as _i43; import 'package:threedpass/features/accounts/presentation/pages/create_account/import_mnemonic_form.dart' - as _i47; + as _i45; import 'package:threedpass/features/accounts/presentation/pages/create_account/import_rawseed_form.dart' - as _i44; + as _i42; import 'package:threedpass/features/accounts/presentation/pages/no_stable_hash_dialog.dart' - as _i54; + as _i52; import 'package:threedpass/features/asset_conversion/domain/entities/basic_pool_entity.dart' as _i77; import 'package:threedpass/features/asset_conversion/domain/entities/pool_full_info.dart' @@ -41,15 +41,15 @@ import 'package:threedpass/features/asset_conversion/domain/entities/pool_full_i import 'package:threedpass/features/asset_conversion/ui/add_liquidity/presentation/add_liquidity_page_wrapper.dart' as _i39; import 'package:threedpass/features/asset_conversion/ui/create_pool/presentation/create_pool_page_wrapper.dart' - as _i43; -import 'package:threedpass/features/asset_conversion/ui/pools_page/presentation/pools_page.dart' - as _i42; -import 'package:threedpass/features/asset_conversion/ui/pools_page/presentation/pools_page_wrapper.dart' as _i41; +import 'package:threedpass/features/asset_conversion/ui/pools_list/presentation/pools_page.dart' + as _i65; +import 'package:threedpass/features/asset_conversion/ui/pools_list/presentation/pools_page_wrapper.dart' + as _i64; import 'package:threedpass/features/asset_conversion/ui/remove_liquidity/presentation/remove_liquidity_page_wrapper.dart' as _i40; -import 'package:threedpass/features/asset_conversion/ui/swap_page/presentation/swap_page_wrapper.dart' - as _i65; +import 'package:threedpass/features/asset_conversion/ui/swap/presentation/swap_page_wrapper.dart' + as _i63; import 'package:threedpass/features/compare_page/presentation/pages/compare_page_wrapper.dart' as _i3; import 'package:threedpass/features/explorer_page/explorer_page_wrapper.dart' @@ -107,25 +107,25 @@ import 'package:threedpass/features/scan_page/presentation/scan_page_wrapper.dar import 'package:threedpass/features/settings_page/domain/entities/global_settings.dart' as _i76; import 'package:threedpass/features/settings_page/presentation/settings_page.dart' - as _i56; + as _i54; import 'package:threedpass/features/settings_page/presentation/settings_sub_page/choose_algorithm_subpage.dart' - as _i62; + as _i60; import 'package:threedpass/features/settings_page/presentation/settings_sub_page/grid_size_subpage.dart' - as _i59; + as _i57; import 'package:threedpass/features/settings_page/presentation/settings_sub_page/pixel_ratio_subpage.dart' - as _i60; + as _i58; import 'package:threedpass/features/settings_page/presentation/settings_sub_page/sections_subpage.dart' - as _i57; + as _i55; import 'package:threedpass/features/settings_page/presentation/settings_sub_page/stable_hash_subpage.dart' - as _i63; + as _i61; import 'package:threedpass/features/settings_page/presentation/settings_sub_page/trans_bytes_subpage.dart' - as _i58; + as _i56; import 'package:threedpass/features/settings_page/presentation/settings_sub_page/wallet_node_subpage.dart' - as _i61; + as _i59; import 'package:threedpass/features/settings_page/router/empty_settings_route.dart' - as _i64; + as _i62; import 'package:threedpass/features/uploaded_object_page/uploaded_object_page.dart' - as _i55; + as _i53; import 'package:threedpass/features/wallet_screen/add_contact_page/add_contact_page.dart' as _i25; import 'package:threedpass/features/wallet_screen/add_contact_page/domain/entities/contact.dart' @@ -485,22 +485,10 @@ abstract class $RootRouter extends _i66.RootStackRouter { ), ); }, - PoolsRouteWrapper.name: (routeData) { - return _i66.AutoRoutePage( - routeData: routeData, - child: _i66.WrappedRoute(child: const _i41.PoolsPageWrapper()), - ); - }, - PoolsRoute.name: (routeData) { - return _i66.AutoRoutePage( - routeData: routeData, - child: const _i42.PoolsPage(), - ); - }, CreatePoolRouteWrapper.name: (routeData) { return _i66.AutoRoutePage( routeData: routeData, - child: const _i43.CreatePoolPageWrapper(), + child: const _i41.CreatePoolPageWrapper(), ); }, ImportRawseedFormRoute.name: (routeData) { @@ -508,19 +496,19 @@ abstract class $RootRouter extends _i66.RootStackRouter { orElse: () => const ImportRawseedFormRouteArgs()); return _i66.AutoRoutePage( routeData: routeData, - child: _i44.ImportRawseedFormPage(key: args.key), + child: _i42.ImportRawseedFormPage(key: args.key), ); }, CreateAccountRouteWrapper.name: (routeData) { return _i66.AutoRoutePage( routeData: routeData, - child: _i66.WrappedRoute(child: const _i45.CreateAccountPageWrapper()), + child: _i66.WrappedRoute(child: const _i43.CreateAccountPageWrapper()), ); }, CreateAccountFromObjectRoute.name: (routeData) { return _i66.AutoRoutePage( routeData: routeData, - child: const _i46.CreateAccountFromObjectPage(), + child: const _i44.CreateAccountFromObjectPage(), ); }, ImportMnemonicFormRoute.name: (routeData) { @@ -528,32 +516,32 @@ abstract class $RootRouter extends _i66.RootStackRouter { orElse: () => const ImportMnemonicFormRouteArgs()); return _i66.AutoRoutePage( routeData: routeData, - child: _i47.ImportMnemonicFormPage(key: args.key), + child: _i45.ImportMnemonicFormPage(key: args.key), ); }, CreateAccountInfoRoute.name: (routeData) { return _i66.AutoRoutePage( routeData: routeData, - child: const _i48.CreateAccountInfoPage(), + child: const _i46.CreateAccountInfoPage(), ); }, CreateAccountMnemonicBackupRoute.name: (routeData) { return _i66.AutoRoutePage( routeData: routeData, - child: const _i49.CreateAccountMnemonicBackupPage(), + child: const _i47.CreateAccountMnemonicBackupPage(), ); }, CreateAccountMnemonicConfirmRoute.name: (routeData) { return _i66.AutoRoutePage( routeData: routeData, - child: const _i50.CreateAccountMnemonicConfirmPage(), + child: const _i48.CreateAccountMnemonicConfirmPage(), ); }, CreateAccountCredentialsRoute.name: (routeData) { final args = routeData.argsAs(); return _i66.AutoRoutePage( routeData: routeData, - child: _i51.CreateAccountCredentialsPage( + child: _i49.CreateAccountCredentialsPage( appbarText: args.appbarText, key: args.key, ), @@ -562,26 +550,26 @@ abstract class $RootRouter extends _i66.RootStackRouter { CreateAccountTypeRoute.name: (routeData) { return _i66.AutoRoutePage( routeData: routeData, - child: const _i52.CreateAccountTypePage(), + child: const _i50.CreateAccountTypePage(), ); }, CreateAccountLoaderRoute.name: (routeData) { return _i66.AutoRoutePage( routeData: routeData, - child: const _i53.CreateAccountLoaderPage(), + child: const _i51.CreateAccountLoaderPage(), ); }, NoStableHashRoute.name: (routeData) { return _i66.AutoRoutePage( routeData: routeData, - child: const _i54.NoStableHashDialog(), + child: const _i52.NoStableHashDialog(), ); }, UploadedObjectRoute.name: (routeData) { final args = routeData.argsAs(); return _i66.AutoRoutePage( routeData: routeData, - child: _i55.UploadedObjectPage( + child: _i53.UploadedObjectPage( uploadedObject: args.uploadedObject, key: args.key, ), @@ -590,14 +578,14 @@ abstract class $RootRouter extends _i66.RootStackRouter { SettingsRoute.name: (routeData) { return _i66.AutoRoutePage( routeData: routeData, - child: const _i56.SettingsPage(), + child: const _i54.SettingsPage(), ); }, SectionsSubRoute.name: (routeData) { final args = routeData.argsAs(); return _i66.AutoRoutePage( routeData: routeData, - child: _i57.SectionsSubPage( + child: _i55.SectionsSubPage( initialState: args.initialState, key: args.key, ), @@ -607,7 +595,7 @@ abstract class $RootRouter extends _i66.RootStackRouter { final args = routeData.argsAs(); return _i66.AutoRoutePage( routeData: routeData, - child: _i58.TransBytesSubPage( + child: _i56.TransBytesSubPage( initialState: args.initialState, key: args.key, ), @@ -616,20 +604,20 @@ abstract class $RootRouter extends _i66.RootStackRouter { GridSizeSubRoute.name: (routeData) { return _i66.AutoRoutePage( routeData: routeData, - child: const _i59.GridSizeSubPage(), + child: const _i57.GridSizeSubPage(), ); }, PixelRatioSubRoute.name: (routeData) { return _i66.AutoRoutePage( routeData: routeData, - child: const _i60.PixelRatioSubPage(), + child: const _i58.PixelRatioSubPage(), ); }, WalletNodeSubRoute.name: (routeData) { final args = routeData.argsAs(); return _i66.AutoRoutePage( routeData: routeData, - child: _i61.WalletNodeSubPage( + child: _i59.WalletNodeSubPage( initialState: args.initialState, key: args.key, ), @@ -638,14 +626,14 @@ abstract class $RootRouter extends _i66.RootStackRouter { ChooseAlgorithmSubRoute.name: (routeData) { return _i66.AutoRoutePage( routeData: routeData, - child: const _i62.ChooseAlgorithmSubPage(), + child: const _i60.ChooseAlgorithmSubPage(), ); }, StableHashSubRoute.name: (routeData) { final args = routeData.argsAs(); return _i66.AutoRoutePage( routeData: routeData, - child: _i63.StableHashSubPage( + child: _i61.StableHashSubPage( initialState: args.initialState, key: args.key, ), @@ -654,19 +642,31 @@ abstract class $RootRouter extends _i66.RootStackRouter { SettingsWrapperRoute.name: (routeData) { return _i66.AutoRoutePage( routeData: routeData, - child: const _i64.EmptySettingsRoute(), + child: const _i62.EmptySettingsRoute(), ); }, SwapRouteWrapper.name: (routeData) { final args = routeData.argsAs(); return _i66.AutoRoutePage( routeData: routeData, - child: _i65.SwapPageWrapper( + child: _i63.SwapPageWrapper( poolAssets: args.poolAssets, key: args.key, ), ); }, + PoolsRouteWrapper.name: (routeData) { + return _i66.AutoRoutePage( + routeData: routeData, + child: _i66.WrappedRoute(child: const _i64.PoolsPageWrapper()), + ); + }, + PoolsRoute.name: (routeData) { + return _i66.AutoRoutePage( + routeData: routeData, + child: const _i65.PoolsPage(), + ); + }, }; } @@ -1686,35 +1686,7 @@ class RemoveLiquidityRouteWrapperArgs { } /// generated route for -/// [_i41.PoolsPageWrapper] -class PoolsRouteWrapper extends _i66.PageRouteInfo { - const PoolsRouteWrapper({List<_i66.PageRouteInfo>? children}) - : super( - PoolsRouteWrapper.name, - initialChildren: children, - ); - - static const String name = 'PoolsRouteWrapper'; - - static const _i66.PageInfo page = _i66.PageInfo(name); -} - -/// generated route for -/// [_i42.PoolsPage] -class PoolsRoute extends _i66.PageRouteInfo { - const PoolsRoute({List<_i66.PageRouteInfo>? children}) - : super( - PoolsRoute.name, - initialChildren: children, - ); - - static const String name = 'PoolsRoute'; - - static const _i66.PageInfo page = _i66.PageInfo(name); -} - -/// generated route for -/// [_i43.CreatePoolPageWrapper] +/// [_i41.CreatePoolPageWrapper] class CreatePoolRouteWrapper extends _i66.PageRouteInfo { const CreatePoolRouteWrapper({List<_i66.PageRouteInfo>? children}) : super( @@ -1728,7 +1700,7 @@ class CreatePoolRouteWrapper extends _i66.PageRouteInfo { } /// generated route for -/// [_i44.ImportRawseedFormPage] +/// [_i42.ImportRawseedFormPage] class ImportRawseedFormRoute extends _i66.PageRouteInfo { ImportRawseedFormRoute({ @@ -1758,7 +1730,7 @@ class ImportRawseedFormRouteArgs { } /// generated route for -/// [_i45.CreateAccountPageWrapper] +/// [_i43.CreateAccountPageWrapper] class CreateAccountRouteWrapper extends _i66.PageRouteInfo { const CreateAccountRouteWrapper({List<_i66.PageRouteInfo>? children}) : super( @@ -1772,7 +1744,7 @@ class CreateAccountRouteWrapper extends _i66.PageRouteInfo { } /// generated route for -/// [_i46.CreateAccountFromObjectPage] +/// [_i44.CreateAccountFromObjectPage] class CreateAccountFromObjectRoute extends _i66.PageRouteInfo { const CreateAccountFromObjectRoute({List<_i66.PageRouteInfo>? children}) : super( @@ -1786,7 +1758,7 @@ class CreateAccountFromObjectRoute extends _i66.PageRouteInfo { } /// generated route for -/// [_i47.ImportMnemonicFormPage] +/// [_i45.ImportMnemonicFormPage] class ImportMnemonicFormRoute extends _i66.PageRouteInfo { ImportMnemonicFormRoute({ @@ -1816,7 +1788,7 @@ class ImportMnemonicFormRouteArgs { } /// generated route for -/// [_i48.CreateAccountInfoPage] +/// [_i46.CreateAccountInfoPage] class CreateAccountInfoRoute extends _i66.PageRouteInfo { const CreateAccountInfoRoute({List<_i66.PageRouteInfo>? children}) : super( @@ -1830,7 +1802,7 @@ class CreateAccountInfoRoute extends _i66.PageRouteInfo { } /// generated route for -/// [_i49.CreateAccountMnemonicBackupPage] +/// [_i47.CreateAccountMnemonicBackupPage] class CreateAccountMnemonicBackupRoute extends _i66.PageRouteInfo { const CreateAccountMnemonicBackupRoute({List<_i66.PageRouteInfo>? children}) : super( @@ -1844,7 +1816,7 @@ class CreateAccountMnemonicBackupRoute extends _i66.PageRouteInfo { } /// generated route for -/// [_i50.CreateAccountMnemonicConfirmPage] +/// [_i48.CreateAccountMnemonicConfirmPage] class CreateAccountMnemonicConfirmRoute extends _i66.PageRouteInfo { const CreateAccountMnemonicConfirmRoute({List<_i66.PageRouteInfo>? children}) : super( @@ -1858,7 +1830,7 @@ class CreateAccountMnemonicConfirmRoute extends _i66.PageRouteInfo { } /// generated route for -/// [_i51.CreateAccountCredentialsPage] +/// [_i49.CreateAccountCredentialsPage] class CreateAccountCredentialsRoute extends _i66.PageRouteInfo { CreateAccountCredentialsRoute({ @@ -1897,7 +1869,7 @@ class CreateAccountCredentialsRouteArgs { } /// generated route for -/// [_i52.CreateAccountTypePage] +/// [_i50.CreateAccountTypePage] class CreateAccountTypeRoute extends _i66.PageRouteInfo { const CreateAccountTypeRoute({List<_i66.PageRouteInfo>? children}) : super( @@ -1911,7 +1883,7 @@ class CreateAccountTypeRoute extends _i66.PageRouteInfo { } /// generated route for -/// [_i53.CreateAccountLoaderPage] +/// [_i51.CreateAccountLoaderPage] class CreateAccountLoaderRoute extends _i66.PageRouteInfo { const CreateAccountLoaderRoute({List<_i66.PageRouteInfo>? children}) : super( @@ -1925,7 +1897,7 @@ class CreateAccountLoaderRoute extends _i66.PageRouteInfo { } /// generated route for -/// [_i54.NoStableHashDialog] +/// [_i52.NoStableHashDialog] class NoStableHashRoute extends _i66.PageRouteInfo { const NoStableHashRoute({List<_i66.PageRouteInfo>? children}) : super( @@ -1939,7 +1911,7 @@ class NoStableHashRoute extends _i66.PageRouteInfo { } /// generated route for -/// [_i55.UploadedObjectPage] +/// [_i53.UploadedObjectPage] class UploadedObjectRoute extends _i66.PageRouteInfo { UploadedObjectRoute({ required _i75.UploadedObject uploadedObject, @@ -1977,7 +1949,7 @@ class UploadedObjectRouteArgs { } /// generated route for -/// [_i56.SettingsPage] +/// [_i54.SettingsPage] class SettingsRoute extends _i66.PageRouteInfo { const SettingsRoute({List<_i66.PageRouteInfo>? children}) : super( @@ -1991,7 +1963,7 @@ class SettingsRoute extends _i66.PageRouteInfo { } /// generated route for -/// [_i57.SectionsSubPage] +/// [_i55.SectionsSubPage] class SectionsSubRoute extends _i66.PageRouteInfo { SectionsSubRoute({ required _i76.GlobalSettings initialState, @@ -2029,7 +2001,7 @@ class SectionsSubRouteArgs { } /// generated route for -/// [_i58.TransBytesSubPage] +/// [_i56.TransBytesSubPage] class TransBytesSubRoute extends _i66.PageRouteInfo { TransBytesSubRoute({ required _i76.GlobalSettings initialState, @@ -2067,7 +2039,7 @@ class TransBytesSubRouteArgs { } /// generated route for -/// [_i59.GridSizeSubPage] +/// [_i57.GridSizeSubPage] class GridSizeSubRoute extends _i66.PageRouteInfo { const GridSizeSubRoute({List<_i66.PageRouteInfo>? children}) : super( @@ -2081,7 +2053,7 @@ class GridSizeSubRoute extends _i66.PageRouteInfo { } /// generated route for -/// [_i60.PixelRatioSubPage] +/// [_i58.PixelRatioSubPage] class PixelRatioSubRoute extends _i66.PageRouteInfo { const PixelRatioSubRoute({List<_i66.PageRouteInfo>? children}) : super( @@ -2095,7 +2067,7 @@ class PixelRatioSubRoute extends _i66.PageRouteInfo { } /// generated route for -/// [_i61.WalletNodeSubPage] +/// [_i59.WalletNodeSubPage] class WalletNodeSubRoute extends _i66.PageRouteInfo { WalletNodeSubRoute({ required _i76.GlobalSettings initialState, @@ -2133,7 +2105,7 @@ class WalletNodeSubRouteArgs { } /// generated route for -/// [_i62.ChooseAlgorithmSubPage] +/// [_i60.ChooseAlgorithmSubPage] class ChooseAlgorithmSubRoute extends _i66.PageRouteInfo { const ChooseAlgorithmSubRoute({List<_i66.PageRouteInfo>? children}) : super( @@ -2147,7 +2119,7 @@ class ChooseAlgorithmSubRoute extends _i66.PageRouteInfo { } /// generated route for -/// [_i63.StableHashSubPage] +/// [_i61.StableHashSubPage] class StableHashSubRoute extends _i66.PageRouteInfo { StableHashSubRoute({ required _i76.GlobalSettings initialState, @@ -2185,7 +2157,7 @@ class StableHashSubRouteArgs { } /// generated route for -/// [_i64.EmptySettingsRoute] +/// [_i62.EmptySettingsRoute] class SettingsWrapperRoute extends _i66.PageRouteInfo { const SettingsWrapperRoute({List<_i66.PageRouteInfo>? children}) : super( @@ -2199,7 +2171,7 @@ class SettingsWrapperRoute extends _i66.PageRouteInfo { } /// generated route for -/// [_i65.SwapPageWrapper] +/// [_i63.SwapPageWrapper] class SwapRouteWrapper extends _i66.PageRouteInfo { SwapRouteWrapper({ required List<_i77.PoolAssetField> poolAssets, @@ -2235,3 +2207,31 @@ class SwapRouteWrapperArgs { return 'SwapRouteWrapperArgs{poolAssets: $poolAssets, key: $key}'; } } + +/// generated route for +/// [_i64.PoolsPageWrapper] +class PoolsRouteWrapper extends _i66.PageRouteInfo { + const PoolsRouteWrapper({List<_i66.PageRouteInfo>? children}) + : super( + PoolsRouteWrapper.name, + initialChildren: children, + ); + + static const String name = 'PoolsRouteWrapper'; + + static const _i66.PageInfo page = _i66.PageInfo(name); +} + +/// generated route for +/// [_i65.PoolsPage] +class PoolsRoute extends _i66.PageRouteInfo { + const PoolsRoute({List<_i66.PageRouteInfo>? children}) + : super( + PoolsRoute.name, + initialChildren: children, + ); + + static const String name = 'PoolsRoute'; + + static const _i66.PageInfo page = _i66.PageInfo(name); +} diff --git a/pubspec.lock b/pubspec.lock index 99930192..03617117 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -832,26 +832,26 @@ packages: dependency: "direct main" description: name: isar - sha256: aef9b9dd6ea4f5fca1f6fdc38e76010e4762cdb1400169d99a0b42e8f71e4f8a + sha256: "99165dadb2cf2329d3140198363a7e7bff9bbd441871898a87e26914d25cf1ea" url: "https://pub.dev" source: hosted - version: "3.1.0" + version: "3.1.0+1" isar_flutter_libs: dependency: "direct main" description: name: isar_flutter_libs - sha256: "8dcfb6889e68d9f0ad9980d77b3903782811645d848786e6ea6518ea6058e45d" + sha256: bc6768cc4b9c61aabff77152e7f33b4b17d2fc93134f7af1c3dd51500fe8d5e8 url: "https://pub.dev" source: hosted - version: "3.1.0" + version: "3.1.0+1" isar_generator: dependency: "direct dev" description: name: isar_generator - sha256: "3813ddc78bff4d8328a5026a1c7af80a8c688719bf6fba6ec4b56f8772c5b8bf" + sha256: "76c121e1295a30423604f2f819bc255bc79f852f3bc8743a24017df6068ad133" url: "https://pub.dev" source: hosted - version: "3.1.0" + version: "3.1.0+1" js: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index e0a9660d..91735ce5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ version: 2.16.0+41 environment: sdk: ">=3.0.6 <3.3.5" -isar_version: &isar_version 3.1.0 # define the version to be used +isar_version: &isar_version 3.1.0+1 # define the version to be used dependencies: flutter: From 66083674d80104189a3ffe3903a25b3d36d4fd21 Mon Sep 17 00:00:00 2001 From: L3odr0id Date: Wed, 14 Aug 2024 20:07:45 +0300 Subject: [PATCH 4/7] fix: Refresh objects explorer --- .../objects_list_page/objects_list_page.dart | 3 ++- .../presentation/reload_objects_icon_button.dart | 9 +-------- .../domain/entities/uploaded_object.g.dart | 2 +- .../wallet_screen/assets_page/widgets/buttons_panel.dart | 2 +- .../assets_page/widgets/objects_list/objects_list.dart | 5 +++++ .../widgets/objects_list/objects_list_header_full.dart | 1 - 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/features/explorer_page/objects_list_page/objects_list_page.dart b/lib/features/explorer_page/objects_list_page/objects_list_page.dart index 950dda56..41e674e0 100644 --- a/lib/features/explorer_page/objects_list_page/objects_list_page.dart +++ b/lib/features/explorer_page/objects_list_page/objects_list_page.dart @@ -47,7 +47,8 @@ class ObjectsListPage extends StatelessWidget { ), firstPageErrorIndicatorBuilder: (final context) => FirstPageExceptionIndicator( - onTryAgain: controller.refresh, + onTryAgain: () => + BlocProvider.of(context).refresh(), message: controller.error?.toString(), ), ), diff --git a/lib/features/explorer_page/objects_list_page/presentation/reload_objects_icon_button.dart b/lib/features/explorer_page/objects_list_page/presentation/reload_objects_icon_button.dart index 51b69d77..db424734 100644 --- a/lib/features/explorer_page/objects_list_page/presentation/reload_objects_icon_button.dart +++ b/lib/features/explorer_page/objects_list_page/presentation/reload_objects_icon_button.dart @@ -10,14 +10,7 @@ class ReloadObjectsIconButton extends StatelessWidget { Widget build(final BuildContext context) { return D3pIconButton( iconData: Icons.refresh, - onPressed: () => reloadCache(context), + onPressed: () => BlocProvider.of(context).refresh(), ); } - - Future reloadCache(final BuildContext context) async { - final bloc = BlocProvider.of(context); - - bloc.pagingController.refresh(); - // TODO Reload objects count - } } diff --git a/lib/features/poscan_objects_query/domain/entities/uploaded_object.g.dart b/lib/features/poscan_objects_query/domain/entities/uploaded_object.g.dart index 33ab4596..3c241229 100644 --- a/lib/features/poscan_objects_query/domain/entities/uploaded_object.g.dart +++ b/lib/features/poscan_objects_query/domain/entities/uploaded_object.g.dart @@ -117,7 +117,7 @@ const UploadedObjectSchema = CollectionSchema( getId: _uploadedObjectGetId, getLinks: _uploadedObjectGetLinks, attach: _uploadedObjectAttach, - version: '3.1.0', + version: '3.1.0+1', ); int _uploadedObjectEstimateSize( diff --git a/lib/features/wallet_screen/assets_page/widgets/buttons_panel.dart b/lib/features/wallet_screen/assets_page/widgets/buttons_panel.dart index 19523be9..ebe64f1d 100644 --- a/lib/features/wallet_screen/assets_page/widgets/buttons_panel.dart +++ b/lib/features/wallet_screen/assets_page/widgets/buttons_panel.dart @@ -5,7 +5,7 @@ import 'package:threedpass/core/polkawallet/bloc/app_service_cubit.dart'; import 'package:threedpass/core/polkawallet/utils/network_state_data_extension.dart'; import 'package:threedpass/core/widgets/buttons/elevated_button.dart'; import 'package:threedpass/core/widgets/other/padding_16.dart'; -import 'package:threedpass/features/asset_conversion/ui/pools_page/bloc/pools_cubit.dart'; +import 'package:threedpass/features/asset_conversion/ui/pools_list/bloc/pools_cubit.dart'; import 'package:threedpass/features/poscan_assets/bloc/poscan_assets_cubit.dart'; import 'package:threedpass/features/wallet_screen/assets_page/widgets/coin_transfer_button.dart'; import 'package:threedpass/features/wallet_screen/assets_page/widgets/recieve_button.dart'; diff --git a/lib/features/wallet_screen/assets_page/widgets/objects_list/objects_list.dart b/lib/features/wallet_screen/assets_page/widgets/objects_list/objects_list.dart index 1118f65a..008993c8 100644 --- a/lib/features/wallet_screen/assets_page/widgets/objects_list/objects_list.dart +++ b/lib/features/wallet_screen/assets_page/widgets/objects_list/objects_list.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:threedpass/core/polkawallet/app_service.dart'; +import 'package:threedpass/core/utils/logger.dart'; import 'package:threedpass/core/widgets/other/padding_16.dart'; import 'package:threedpass/core/widgets/paddings.dart'; import 'package:threedpass/core/widgets/progress_indicator/progress_indicator.dart'; @@ -41,6 +42,10 @@ class _State extends State { List? relatedObjects; Future loadUserObjects() async { + if (!mounted) { + logger.d('Called while not mounted.'); + return; + } final uploadedObjectsCubit = BlocProvider.of(context); final userObjects = await uploadedObjectsCubit .getUserObjects(widget.appService.keyring.current.address!); diff --git a/lib/features/wallet_screen/assets_page/widgets/objects_list/objects_list_header_full.dart b/lib/features/wallet_screen/assets_page/widgets/objects_list/objects_list_header_full.dart index 8ef2d525..eae682dc 100644 --- a/lib/features/wallet_screen/assets_page/widgets/objects_list/objects_list_header_full.dart +++ b/lib/features/wallet_screen/assets_page/widgets/objects_list/objects_list_header_full.dart @@ -14,7 +14,6 @@ class ObjectsListHeaderFull extends StatelessWidget { final objectsCubit = BlocProvider.of(context); final appServiceCubit = BlocProvider.of(context); - await objectsCubit.clear(); if (appServiceCubit.state.keyring.allAccounts.isNotEmpty) { await objectsCubit .downloadOwnerObjects(appServiceCubit.state.keyring.current); From 5275b718a63a6f790ccd13abe46848d56e7f1d36 Mon Sep 17 00:00:00 2001 From: L3odr0id Date: Wed, 14 Aug 2024 20:08:27 +0300 Subject: [PATCH 5/7] fix: PoscanAssetField parsing & AddLiquidity calc --- .../domain/entities/basic_pool_entity.dart | 9 ++- .../bloc/add_liquidity_cubit.dart | 74 +++++++++++++------ .../bloc/poscan_objects_cubit.dart | 54 ++++++++------ 3 files changed, 90 insertions(+), 47 deletions(-) diff --git a/lib/features/asset_conversion/domain/entities/basic_pool_entity.dart b/lib/features/asset_conversion/domain/entities/basic_pool_entity.dart index c5f46b10..e4aafe81 100644 --- a/lib/features/asset_conversion/domain/entities/basic_pool_entity.dart +++ b/lib/features/asset_conversion/domain/entities/basic_pool_entity.dart @@ -1,5 +1,7 @@ // ignore_for_file: avoid_dynamic_calls +import 'package:equatable/equatable.dart'; + class BasicPoolEntity { final PoolAssetField firstAsset; final PoolAssetField secondAsset; @@ -16,7 +18,7 @@ class BasicPoolEntity { ? const PoolAssetField(isNative: true, assetId: null) : PoolAssetField( isNative: false, - assetId: int.parse(json[0]['Asset'].toString()), + assetId: int.parse(json[0][0]['Asset'].toString()), ), secondAsset = json[0][1] == 'Native' ? const PoolAssetField(isNative: true, assetId: null) @@ -27,7 +29,7 @@ class BasicPoolEntity { lpTokenId = int.parse(json[1]['lpToken'].toString()); } -class PoolAssetField { +class PoolAssetField extends Equatable { final bool isNative; final int? assetId; @@ -39,4 +41,7 @@ class PoolAssetField { const PoolAssetField.native() : isNative = true, assetId = null; + + @override + List get props => [isNative, assetId]; } diff --git a/lib/features/asset_conversion/ui/add_liquidity/bloc/add_liquidity_cubit.dart b/lib/features/asset_conversion/ui/add_liquidity/bloc/add_liquidity_cubit.dart index 93fd40ec..bc437d8e 100644 --- a/lib/features/asset_conversion/ui/add_liquidity/bloc/add_liquidity_cubit.dart +++ b/lib/features/asset_conversion/ui/add_liquidity/bloc/add_liquidity_cubit.dart @@ -80,6 +80,8 @@ class AddLiquidityCubit extends Cubit // final amount1Min = TextEditingController(); // final amount2Min = TextEditingController(); + bool get areNullReserves => poolFullInfo.rawPoolReserve == null; + Rational get slippageRate { final slippage = int.parse(slippageController.text); return Rational.fromInt(100 - slippage, 100); @@ -89,32 +91,36 @@ class AddLiquidityCubit extends Cubit ? nativeDecimals : poscanAssetsCubit.state.metadata[asset1.assetId]!.idecimals; - Decimal get amount1Desired => Decimal.parse(amount1DesiredController.text) - .setDecimalsForUserInput(asset1Decimals); + Decimal? get amount1Desired => Decimal.tryParse(amount1DesiredController.text) + ?.setDecimalsForUserInput(asset1Decimals); int get asset2Decimals => asset2.isNative ? nativeDecimals : poscanAssetsCubit.state.metadata[asset2.assetId]!.idecimals; - Decimal get amount2Desired => Decimal.parse(amount2DesiredController.text) - .setDecimalsForUserInput(asset2Decimals); + Decimal? get amount2Desired => Decimal.tryParse(amount2DesiredController.text) + ?.setDecimalsForUserInput(asset2Decimals); Rational get amount2Optimal => quote( - amount1Desired, + amount1Desired!, poolFullInfo.rawPoolReserve!.balance1Decimal, poolFullInfo.rawPoolReserve!.balance2Decimal, ); Rational get amount1Optimal => quote( - amount2Desired, + amount2Desired!, poolFullInfo.rawPoolReserve!.balance2Decimal, poolFullInfo.rawPoolReserve!.balance1Decimal, ); - Rational get amount1MinAmount => amount1Desired.toRational() * slippageRate; - Rational get amount2MinAmount => amount2Desired.toRational() * slippageRate; + Rational? get amount1MinAmount => amount1Desired != null + ? amount1Desired!.toRational() * slippageRate + : null; + Rational? get amount2MinAmount => amount2Desired != null + ? amount2Desired!.toRational() * slippageRate + : null; - Either calcInfo() { + Either calcInfoForNotNullPool() { try { final slippage = int.tryParse(slippageController.text); if (slippage == null) { @@ -130,7 +136,7 @@ class AddLiquidityCubit extends Cubit } logger.v( - 'amount1optimal ${amount1Optimal.toDouble()} 1min: ${amount1MinAmount.toDouble()} amount2optimal ${amount2Optimal.toDouble()} 2min:${amount2MinAmount.toDouble()}', + 'amount1optimal ${amount1Optimal.toDouble()} 1min: ${amount1MinAmount!.toDouble()} amount2optimal ${amount2Optimal.toDouble()} 2min:${amount2MinAmount!.toDouble()}', ); String? error; @@ -142,20 +148,20 @@ class AddLiquidityCubit extends Cubit ? 'P3D' : poscanAssetsCubit.state.metadata[asset2.assetId]!.symbol; - if (amount2Optimal < amount2MinAmount) { + if (amount2Optimal < amount2MinAmount!) { error = 'ERROR: Asset $asset2Symbols deposit did not meet minimum'; } - if (amount1Optimal < amount1MinAmount) { + if (amount1Optimal < amount1MinAmount!) { error = 'ERROR: Asset $asset1Symbols deposit did not meet minimum'; } return Either.right( _AddLiquidityInfo( - asset1Desired: amount1Desired, - asset2Desired: amount2Desired, - asset1Min: amount1MinAmount, - asset2Min: amount2MinAmount, + asset1Desired: amount1Desired!, + asset2Desired: amount2Desired!, + asset1Min: amount1MinAmount!, + asset2Min: amount2MinAmount!, error: error, ), ); @@ -167,8 +173,10 @@ class AddLiquidityCubit extends Cubit void onFirstDesiredChanged() { try { - amount2DesiredController.text = - amount2Optimal.setDecimalsNToFixedString(asset2Decimals); + if (!areNullReserves) { + amount2DesiredController.text = + amount2Optimal.setDecimalsNToFixedString(asset2Decimals); + } setSlippageTolerance(); } on Object catch (e) { logger.v(e); @@ -177,8 +185,10 @@ class AddLiquidityCubit extends Cubit void onSecondDesiredChanged() { try { - amount1DesiredController.text = - amount1Optimal.setDecimalsNToFixedString(asset1Decimals); + if (!areNullReserves) { + amount1DesiredController.text = + amount1Optimal.setDecimalsNToFixedString(asset1Decimals); + } setSlippageTolerance(); } on Object catch (e) { logger.v(e); @@ -205,17 +215,35 @@ class AddLiquidityCubit extends Cubit emit( AddLiquidityState( - asset1Min: amount1MinAmount.setDecimalsNToFixedString(asset1Decimals), - asset2Min: amount2MinAmount.setDecimalsNToFixedString(asset2Decimals), + asset1Min: amount1MinAmount?.setDecimalsNToFixedString(asset1Decimals), + asset2Min: amount2MinAmount?.setDecimalsNToFixedString(asset2Decimals), ), ); } + Either calcInfoForNullPool() { + try { + return Either.right( + _AddLiquidityInfo( + asset1Desired: amount1Desired!, + asset2Desired: amount2Desired!, + asset1Min: amount1MinAmount!, + asset2Min: amount2MinAmount!, + error: null, + ), + ); + } on Object catch (e) { + logger.e(e); + return Either.left(BadDataFailure(e.toString())); + } + } + @override Future> callExtrinsic( final BuildContext context, ) async { - final info = calcInfo(); + final info = + areNullReserves ? calcInfoForNullPool() : calcInfoForNotNullPool(); if (info.value is _AddLiquidityInfo) { final infoT = info.value! as _AddLiquidityInfo; diff --git a/lib/features/poscan_objects_query/bloc/poscan_objects_cubit.dart b/lib/features/poscan_objects_query/bloc/poscan_objects_cubit.dart index 97c18d50..c485d111 100644 --- a/lib/features/poscan_objects_query/bloc/poscan_objects_cubit.dart +++ b/lib/features/poscan_objects_query/bloc/poscan_objects_cubit.dart @@ -71,33 +71,41 @@ class PoscanObjectsCubit extends Cubit { emit(state.copyWith(areOwnerObjectsLoading: false)); } - Future init() async { + Future setObjCount() async { final realCount = (await getObjCount.call(null)) .when(left: (final _) => null, right: (final realValue) => realValue); + if (realCount != state.storageCount) { + emit(state.copyWith(storageCount: realCount)); + } + } - if (realCount != null) { - pagingController.addPageRequestListener((final pageKey) async { - logger.v('GET OBJECT ID: $pageKey'); - - final objEither = await getUploadedObject.call(pageKey); - - objEither.when( - left: (final e) { - logger.e(e.cause ?? e.toString()); - }, - right: (final uploadedObject) { - if (pageKey == realCount - 1) { - pagingController.appendLastPage([uploadedObject]); - } else { - pagingController.appendPage([uploadedObject], pageKey + 1); - } - }, - ); - }); + Future pageRequestListener(final int pageKey) async { + logger.v('Request object id: $pageKey'); + + final objEither = await getUploadedObject.call(pageKey); + + objEither.when( + left: (final e) { + logger.e(e.cause ?? e.toString()); + }, + right: (final uploadedObject) { + final objectsLen = state.storageCount; + if (objectsLen != null && pageKey == objectsLen - 1) { + pagingController.appendLastPage([uploadedObject]); + } else { + pagingController.appendPage([uploadedObject], pageKey + 1); + } + }, + ); + } + + Future init() async { + await setObjCount(); + if (state.storageCount != null) { + pagingController.addPageRequestListener(pageRequestListener); emit( state.copyWith( - storageCount: realCount, isLoading: false, message: null, ), @@ -123,7 +131,9 @@ class PoscanObjectsCubit extends Cubit { return store.firstFullHashEqual(hashes); } - Future clear() async { + Future refresh() async { + logger.v('Explorer refresh is called'); + await setObjCount(); pagingController.refresh(); } } From befc2f74a3fd5a63c3e4796f943728550dcc792b Mon Sep 17 00:00:00 2001 From: L3odr0id Date: Thu, 15 Aug 2024 13:24:36 +0300 Subject: [PATCH 6/7] fix: Asset -> Asset swap --- .../presentation/widgets/preview_page_body.dart | 10 ++++++++-- pubspec.lock | 4 ++-- pubspec.yaml | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/features/preview_page/presentation/widgets/preview_page_body.dart b/lib/features/preview_page/presentation/widgets/preview_page_body.dart index d683baa3..f156e903 100644 --- a/lib/features/preview_page/presentation/widgets/preview_page_body.dart +++ b/lib/features/preview_page/presentation/widgets/preview_page_body.dart @@ -20,8 +20,8 @@ import 'package:threedpass/features/preview_page/presentation/widgets/top_hashes class PreviewPageBody extends StatelessWidget { const PreviewPageBody({ required this.previewPageCubitState, - final Key? key, - }) : super(key: key); + super.key, + }); final PreviewPageCubitState previewPageCubitState; @@ -39,6 +39,12 @@ class PreviewPageBody extends StatelessWidget { ObjectPreview( snapshot: previewPageCubitState.snapshot, ), + // Object3D( + // size: Size(MediaQuery.of(context).size.width, 250.0), + // zoom: 1.0, + // path: previewPageCubitState.snapshot.realPath, + // scale: 100, + // ), PreviewSaveButton( state: previewPageCubitState, ), diff --git a/pubspec.lock b/pubspec.lock index 03617117..699d7c58 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1120,8 +1120,8 @@ packages: dependency: "direct main" description: path: "." - ref: "7f67545e8c4a8e39d394348cc610c817b24aa408" - resolved-ref: "7f67545e8c4a8e39d394348cc610c817b24aa408" + ref: "45564145bc771e0d881401503a2726260e7902b0" + resolved-ref: "45564145bc771e0d881401503a2726260e7902b0" url: "https://github.com/L3odr0id/polkawallet_sdk.git" source: git version: "0.5.1" diff --git a/pubspec.yaml b/pubspec.yaml index 91735ce5..c5c929e7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -65,7 +65,7 @@ dependencies: # path: ../polkawallet_sdk git: url: https://github.com/L3odr0id/polkawallet_sdk.git - ref: 7f67545e8c4a8e39d394348cc610c817b24aa408 # release/0.5.1 # branch name + ref: 45564145bc771e0d881401503a2726260e7902b0 # release/0.5.1 # branch name decimal: ^2.3.3 rational: ^2.2.3 From 424a345d2f41b4ab4df6ddc816dc8ac690a22d2d Mon Sep 17 00:00:00 2001 From: L3odr0id Date: Thu, 15 Aug 2024 16:14:36 +0300 Subject: [PATCH 7/7] Version 2.16.1 --- android/app/build.gradle | 4 +++- pubspec.yaml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 1aeb7609..82bbe6bd 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -42,8 +42,10 @@ android { splits { abi { + enable true reset() - include "arm64-v8a" + include ("arm64-v8a", "x86", "x86_64", "armeabi-v7a") + it.universalApk = true } } diff --git a/pubspec.yaml b/pubspec.yaml index c5c929e7..9fb2eb31 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,7 +10,7 @@ publish_to: 'none' # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 2.16.0+41 +version: 2.16.1+42 environment: sdk: ">=3.0.6 <3.3.5"