Skip to content

Commit

Permalink
Merge pull request #73 from 3Dpass/dev
Browse files Browse the repository at this point in the history
FEATURE: DEX. Version 2.16.0
  • Loading branch information
L3odr0id authored Aug 5, 2024
2 parents 3fc405f + 82b1066 commit 630a9f3
Show file tree
Hide file tree
Showing 165 changed files with 3,726 additions and 1,088 deletions.
36 changes: 20 additions & 16 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,22 @@ android {
}
}

buildTypes {
release {
resValue "string", "app_name", "3DPass"

println "Release properties"
}

debug {
applicationIdSuffix '.debug'
versionNameSuffix '-DEBUG'
resValue "string", "app_name", "3DPass debug"

println "Debug properties"
}
}

defaultConfig {
applicationId "com.threedpass.wallet"
minSdkVersion 24
Expand All @@ -56,27 +72,15 @@ android {
versionName flutterVersionName

multiDexEnabled true

if (System.getenv("KEYSTORE_PATH")) {
resValue "string", "app_name", "3DPass"

println "Release properties"
} else {
applicationIdSuffix '.debug'
versionNameSuffix '-DEBUG'
resValue "string", "app_name", "3DPass debug"

println "Debug properties"
}
}


signingConfigs {
release {
// keyAlias keystoreProperties['keyAlias']
// keyPassword keystoreProperties['keyPassword']
// storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
// storePassword keystoreProperties['storePassword']
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']

// if (System.getenv("KEYSTORE_PATH")){
// println("signingConfigs release")
Expand Down
27 changes: 18 additions & 9 deletions assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@
"existential_deposit_label": "existential deposit",
"existential_deposit_text": "The minimum amount thath an account should have to be deemed active.",
"estimated_transfer_fee": "Estimated transfer fee",
"keep_alive_label": "keep alive",
"keep_alive_text": "With the keep-alive option set, the account is protected agains removal due to low balances.",
"make_transfer_label": "Make transfer",
"error_wrong_amount": "A real number smaller than the avaliable balance was expected",
Expand Down Expand Up @@ -287,7 +286,6 @@

"@2.7.2":{
},
"choose_transfer_keep_alive": "Keep sender alive",
"transfer_keep_alive_help": "With the keep-alive option set, the account is protected against removal due to low balances.",

"@2.8.0":{
Expand Down Expand Up @@ -351,7 +349,7 @@
},
"poscan_putobject_choose_category": "Category",
"account_never_null": "Please choose an account",
"extrinsic_status": "Extrinsic:",
"extrinsic_status": "Status:",

"contacts_button_label": "Contacts",
"contacts_appbar_title": "My Contacts",
Expand Down Expand Up @@ -487,7 +485,7 @@
"snapshot_chain_status": "Chain status:",
"chain_status_recognized": "Recognized",

"@2.16.0": {},
"@2.15.2": {},
"open_pools_label": "Pools",
"pools_page_appbar": "Pools",
"pools_text": "Earn fees by providing liquidity.",
Expand All @@ -500,15 +498,26 @@
"create_pool_asset_choice_title": "Asset {}",
"add_liquidity_page_title": "Add liquidity",
"add_liquidity_page_choose_account_title": "Mint to",
"add_liquidity_page_amount_1_desired_label": "Amount 1 desired",
"add_liquidity_page_amount_2_desired_label": "Amount 2 desired",
"add_liquidity_page_amount_1_min_label" : "Amount 1 min",
"add_liquidity_page_amount_2_min_label" : "Amount 2 min",
"error_wrong_amount_bigint": "A big integer expected",
"error_wrong_amount_double": "Wrong input",
"remove_liquidity_page_title": "Remove liquidity",
"remove_liquidity_page_choose_account_title": "Withdraw to",
"amount_percentage_label": "Amount percentage",
"error_validation_max": "Max is {}",
"slippage_tolerance_label": "Slippage tolerance"
"slippage_tolerance_label": "Slippage tolerance",

"@2.16.0": {},
"add_liquidity_page_amount_desired_pattern": "Amount {} desired",
"add_liquidity_page_amount_min_pattern": "Amount {} min",
"swap_appbar_title": "Swap",
"keep_alive_switch_label": "Keep alive",
"swap_expected_output": "Expected output",
"swap_expected_input": "Expected input",
"swap_minimum_output": "Minimum output",
"swap_maximum_input": "Maximum input",
"add_liquidity_calculated_min":"Minimum {}",
"remove_liquidity_calculated_expected_out":"Expected output {}",
"remove_liquidity_calculated_minimum_out":"Minimum output {}",
"remove_liquidity_custom_percentage":"Custom percentage",
"error_validation_max_balance": "Your balance is {}"
}
22 changes: 8 additions & 14 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,10 @@ PODS:
- flutter_inappwebview/Core (0.0.1):
- Flutter
- OrderedSet (~> 5.0)
- flutter_keyboard_visibility (0.0.1):
- Flutter
- fluttertoast (0.0.2):
- Flutter
- Toast
- integration_test (0.0.1):
- isar_flutter_libs (1.0.0):
- Flutter
- OrderedSet (5.0.0)
- package_info_plus (0.4.5):
Expand Down Expand Up @@ -87,9 +85,8 @@ DEPENDENCIES:
- flutter_aes_ecb_pkcs5 (from `.symlinks/plugins/flutter_aes_ecb_pkcs5/ios`)
- flutter_gl (from `.symlinks/plugins/flutter_gl/ios`)
- flutter_inappwebview (from `.symlinks/plugins/flutter_inappwebview/ios`)
- flutter_keyboard_visibility (from `.symlinks/plugins/flutter_keyboard_visibility/ios`)
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
- integration_test (from `.symlinks/plugins/integration_test/ios`)
- isar_flutter_libs (from `.symlinks/plugins/isar_flutter_libs/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- share_plus (from `.symlinks/plugins/share_plus/ios`)
Expand Down Expand Up @@ -122,12 +119,10 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/flutter_gl/ios"
flutter_inappwebview:
:path: ".symlinks/plugins/flutter_inappwebview/ios"
flutter_keyboard_visibility:
:path: ".symlinks/plugins/flutter_keyboard_visibility/ios"
fluttertoast:
:path: ".symlinks/plugins/fluttertoast/ios"
integration_test:
:path: ".symlinks/plugins/integration_test/ios"
isar_flutter_libs:
:path: ".symlinks/plugins/isar_flutter_libs/ios"
package_info_plus:
:path: ".symlinks/plugins/package_info_plus/ios"
path_provider_foundation:
Expand All @@ -150,10 +145,9 @@ SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
flutter_aes_ecb_pkcs5: fb682a7bb13f29cfbb33f88f7e1ed2211eacf5db
flutter_gl: 5a5603f35db897697f064027864a32b15d0c421d
flutter_inappwebview: bfd58618f49dc62f2676de690fc6dcda1d6c3721
flutter_keyboard_visibility: 0339d06371254c3eb25eeb90ba8d17dca8f9c069
fluttertoast: fafc4fa4d01a6a9e4f772ecd190ffa525e9e2d9c
integration_test: 13825b8a9334a850581300559b8839134b124670
flutter_inappwebview: acd4fc0f012cefd09015000c241137d82f01ba62
fluttertoast: 31b00dabfa7fb7bacd9e7dbee580d7a2ff4bf265
isar_flutter_libs: b69f437aeab9c521821c3f376198c4371fa21073
OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c
package_info_plus: fd030dabf36271f146f1f3beacd48f564b0f17f7
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
Expand All @@ -168,4 +162,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3

COCOAPODS: 1.11.3
COCOAPODS: 1.15.2
7 changes: 7 additions & 0 deletions lib/core/polkawallet/bloc/app_service_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import 'package:threedpass/core/polkawallet/constants.dart';
import 'package:threedpass/core/polkawallet/plugins/d3p_core_plugin.dart';
import 'package:threedpass/core/polkawallet/plugins/d3p_live_net_plugin.dart';
import 'package:threedpass/core/polkawallet/plugins/d3p_test_net_plugin.dart';
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';
Expand Down Expand Up @@ -231,4 +233,9 @@ class AppServiceLoaderCubit extends Cubit<AppService> {

return true;
}

double get fastAvailableBalance => BalanceUtils.balanceToDouble(
state.chosenAccountBalance.value.availableBalance.toString(),
state.networkStateData.safeDecimals,
);
}
5 changes: 5 additions & 0 deletions lib/core/polkawallet/utils/decimal_set_decimals.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ import 'package:rational/rational.dart';

extension SetDecimals on Decimal {
Decimal setDecimalsForUserInput(final int decimals) {
// TODO Check here and in other places that user input fractional part has less numbers than actual asset decimals
return this * Decimal.fromBigInt(BigInt.from(10).pow(decimals));
}

Rational setDecimalsForRaw(final int decimals) {
return this / Decimal.fromBigInt(BigInt.from(10).pow(decimals));
}

bool hasCorrectDecimals(final int decimals) {
return scale <= decimals;
}
}
17 changes: 17 additions & 0 deletions lib/core/polkawallet/utils/rational_remove_decimals.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import 'package:decimal/decimal.dart';
import 'package:rational/rational.dart';

extension RemoveDecimals on Rational {
BigInt removeDecimals(final int decimals) {
return (this * Rational(BigInt.from(10).pow(decimals))).toBigInt();
}

Rational setDecimalsForRaw(final int decimals) {
return this /
Decimal.fromBigInt(BigInt.from(10).pow(decimals)).toRational();
}

String setDecimalsNToFixedString(final int decimals) {
return setDecimalsForRaw(decimals).toDouble().toStringAsFixed(decimals);
}
}
11 changes: 11 additions & 0 deletions lib/core/polkawallet/utils/safe_native_symbol.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import 'package:polkawallet_sdk/api/types/networkStateData.dart';

extension SafeNativeSymbol on NetworkStateData {
String? get safeNativeSymbol {
if (tokenSymbol?.isNotEmpty ?? false) {
return tokenSymbol!.first;
} else {
return null;
}
}
}
17 changes: 4 additions & 13 deletions lib/core/theme/d3p_elevated_button_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,13 @@ abstract class D3pElevatedButtonTheme {
static ElevatedButtonThemeData theme(final ThemeData t) {
return ElevatedButtonThemeData(
style: ElevatedButton.styleFrom(
backgroundColor: t.colorScheme.primary,
disabledBackgroundColor: t.cardColor,
disabledForegroundColor: t.colorScheme.onSurface.withOpacity(0.50),
backgroundColor: t.colorScheme.primary, // TODO Remove this
disabledBackgroundColor: t.cardColor, // TODO Remove this
disabledForegroundColor: D3pColors.disabled,
foregroundColor: t.colorScheme.onPrimary, // TODO Remove this
textStyle: t.customTextStyles.d3pFloatingButton,
padding:
const EdgeInsets.symmetric(horizontal: D3pThemeData.buttonPadding),
).copyWith(
foregroundColor: MaterialStateProperty.resolveWith(
(final states) {
if (states.contains(MaterialState.disabled)) {
return D3pColors.disabled;
} else {
return t.colorScheme.onPrimary;
}
},
),
),
);
}
Expand Down
5 changes: 5 additions & 0 deletions lib/core/theme/d3p_special_colors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,8 @@ extension NotificationCard on CustomColors {
? Colors.red.shade100
: Colors.red.shade900;
}

extension SwapPageColors on CustomColors {
Color get assetChoiceChipPrefixColor =>
brightness == Brightness.light ? Colors.black : D3pColors.disabled;
}
3 changes: 3 additions & 0 deletions lib/core/theme/d3p_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ class D3pThemeData {
static MaterialColor mainColor = Colors.green;
static const Color secondaryButtonBG = Color(0xFF6D9B83);

static final Color shimmerBaseColor = Colors.grey.shade400;
static final Color shimmerHighlightColor = Colors.grey.shade100;

static const double buttonHeight = 50;
static const double buttonPadding = 12;

Expand Down
1 change: 1 addition & 0 deletions lib/core/utils/extrinsic_show_loading_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ mixin ExtrinsicShowLoadingMixin {
}

final formKey = GlobalKey<FormState>();
final passwordController = TextEditingController();

Future<Either<Failure, void>> callExtrinsic(
final BuildContext context,
Expand Down
3 changes: 3 additions & 0 deletions lib/core/utils/pair.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
@Deprecated(
'Use tuples like (String, String). final List<(String, Widget?)> menuItemList;',
)
class Pair<L, R> {
final L left;
final R right;
Expand Down
11 changes: 11 additions & 0 deletions lib/core/utils/validators.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,15 @@ class Validators {
final res = double.tryParse(p0 ?? '');
return res != null && res > 0.0 ? null : 'error_wrong_amount_double'.tr();
}

static String? onlyFloatBalanceMax(final String? p0, final double max) {
final of = onlyFloat(p0);
if (of != null) {
return of;
}
if (double.parse(p0!) > max) {
return 'error_validation_max_balance'.tr(args: [max.toString()]);
}
return null;
}
}
7 changes: 4 additions & 3 deletions lib/core/widgets/buttons/elevated_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ class _ElevatedButtonChild extends StatelessWidget {
padding: EdgeInsets.only(right: padding),
child: Icon(iconData),
),
Text(
text,
),
if (text.isNotEmpty)
Text(
text,
),
],
);
}
Expand Down
30 changes: 10 additions & 20 deletions lib/core/widgets/input/switch_button.dart
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import 'package:flutter/material.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:threedpass/core/theme/d3p_special_styles.dart';
import 'package:threedpass/core/widgets/buttons/icon_button.dart';

class D3pSwitchButton extends StatelessWidget {
D3pSwitchButton({
required final bool initialValue,
const D3pSwitchButton({
required this.value,
required this.onChanged,
required this.text,
this.helpText,
final Key? key,
}) : switchValueNotifier = ValueNotifier<bool>(initialValue),
super(key: key);
super.key,
});

final void Function(bool)? onChanged;
final ValueNotifier<bool> switchValueNotifier;
final String text;
final String? helpText;
final bool value;

@override
Widget build(final BuildContext context) {
Expand All @@ -27,6 +25,7 @@ class D3pSwitchButton extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
text,
Expand All @@ -43,19 +42,10 @@ class D3pSwitchButton extends StatelessWidget {
),
],
),
ValueListenableBuilder(
valueListenable: switchValueNotifier,
builder: (final context, final hasError, final child) =>
PlatformSwitch(
value: switchValueNotifier.value,
// ignore: prefer-extracting-callbacks
onChanged: onChanged != null
? (final value) {
switchValueNotifier.value = value;
onChanged!(value);
}
: null,
),
Switch.adaptive(
value: value,
onChanged:
onChanged != null ? (final value) => onChanged!(value) : null,
),
],
);
Expand Down
Loading

0 comments on commit 630a9f3

Please sign in to comment.