Merge branch 'main' into CW-529-Modify-2FA-introduction-screens

This commit is contained in:
Serhii
2023-12-13 17:44:42 +02:00
64 changed files with 404 additions and 335 deletions
+4
View File
@@ -32,6 +32,8 @@ class AddressValidator extends TextValidator {
return '[0-9a-zA-Z_]';
case CryptoCurrency.usdc:
case CryptoCurrency.usdcpoly:
case CryptoCurrency.usdtPoly:
case CryptoCurrency.usdcEPoly:
case CryptoCurrency.ape:
case CryptoCurrency.avaxc:
case CryptoCurrency.eth:
@@ -141,6 +143,8 @@ class AddressValidator extends TextValidator {
return [42];
case CryptoCurrency.eth:
case CryptoCurrency.usdcpoly:
case CryptoCurrency.usdtPoly:
case CryptoCurrency.usdcEPoly:
case CryptoCurrency.mana:
case CryptoCurrency.matic:
case CryptoCurrency.maticpoly:
@@ -285,10 +285,12 @@ class EvmChainServiceImpl implements ChainService {
}
String _convertToReadable(Map<String, dynamic> data) {
final tokenName = getTokenNameBasedOnWalletType(appStore.wallet!.type);
String gas = int.parse((data['gas'] as String).substring(2), radix: 16).toString();
String value = data['value'] != null
? (int.parse((data['value'] as String).substring(2), radix: 16) / 1e18).toString() + ' ETH'
: '0 ETH';
? (int.parse((data['value'] as String).substring(2), radix: 16) / 1e18).toString() +
' $tokenName'
: '0 $tokenName';
String from = data['from'] as String;
String to = data['to'] as String;
+1 -8
View File
@@ -19,7 +19,6 @@ import 'package:cake_wallet/ionia/ionia_anypay.dart';
import 'package:cake_wallet/ionia/ionia_gift_card.dart';
import 'package:cake_wallet/ionia/ionia_tip.dart';
import 'package:cake_wallet/polygon/polygon.dart';
import 'package:cake_wallet/reactions/wallet_connect.dart';
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/src/screens/anonpay_details/anonpay_details_page.dart';
import 'package:cake_wallet/src/screens/buy/buy_options_page.dart';
@@ -756,13 +755,7 @@ Future<void> setup({
return PowNodeListViewModel(_powNodeSource, appStore);
});
getIt.registerFactory(() {
final wallet = getIt.get<AppStore>().wallet;
return ConnectionSyncPage(
getIt.get<DashboardViewModel>(),
isEVMCompatibleChain(wallet!.type) ? getIt.get<Web3WalletService>() : null,
);
});
getIt.registerFactory(() => ConnectionSyncPage(getIt.get<DashboardViewModel>()));
getIt.registerFactory(
() => SecurityBackupPage(getIt.get<SecuritySettingsViewModel>(), getIt.get<AuthService>()));
@@ -1,6 +1,5 @@
import 'dart:io' show Directory, File, Platform;
import 'package:cake_wallet/bitcoin/bitcoin.dart';
import 'package:cake_wallet/entities/encrypt.dart';
import 'package:cake_wallet/entities/exchange_api_mode.dart';
import 'package:cw_core/pathForWallet.dart';
import 'package:cake_wallet/entities/secret_store_key.dart';
@@ -186,7 +185,6 @@ Future<void> defaultSettingsMigration(
case 25:
await rewriteSecureStoragePin(secureStorage: secureStorage);
break;
default:
break;
}
+3 -4
View File
@@ -85,8 +85,7 @@ Future<List<Node>> loadDefaultEthereumNodes() async {
}
Future<List<Node>> loadBitcoinCashElectrumServerList() async {
final serverListRaw =
await rootBundle.loadString('assets/bitcoin_cash_electrum_server_list.yml');
final serverListRaw = await rootBundle.loadString('assets/bitcoin_cash_electrum_server_list.yml');
final loadedServerList = loadYaml(serverListRaw) as YamlList;
final serverList = <Node>[];
@@ -141,6 +140,7 @@ Future<List<Node>> loadDefaultPolygonNodes() async {
for (final raw in loadedNodes) {
if (raw is Map) {
final node = Node.fromMap(Map<String, Object>.from(raw));
node.type = WalletType.polygon;
nodes.add(node);
}
@@ -159,7 +159,6 @@ Future<void> resetToDefault(Box<Node> nodeSource) async {
final nanoNodes = await loadDefaultNanoNodes();
final polygonNodes = await loadDefaultPolygonNodes();
final nodes = moneroNodes +
bitcoinElectrumServerList +
litecoinElectrumServerList +
@@ -178,4 +177,4 @@ Future<void> resetPowToDefault(Box<Node> powNodeSource) async {
final nodes = nanoPowNodes;
await powNodeSource.clear();
await powNodeSource.addAll(nodes);
}
}
@@ -159,8 +159,8 @@ class SideShiftExchangeProvider extends ExchangeProvider {
url = apiBaseUrl + orderPath + '/fixed';
} else {
url = apiBaseUrl + orderPath + '/variable';
body["depositCoin"] = request.fromCurrency.title.toLowerCase();
body["settleCoin"] = request.toCurrency.title.toLowerCase();
body["depositCoin"] = _normalizeCurrency(request.fromCurrency);
body["settleCoin"] = _normalizeCurrency(request.toCurrency);
body["settleNetwork"] = _networkFor(request.toCurrency);
body["depositNetwork"] = _networkFor(request.fromCurrency);
}
@@ -248,8 +248,8 @@ class SideShiftExchangeProvider extends ExchangeProvider {
final url = apiBaseUrl + quotePath;
final headers = {'Content-Type': 'application/json'};
final body = {
'depositCoin': request.fromCurrency.title.toLowerCase(),
'settleCoin': request.toCurrency.title.toLowerCase(),
'depositCoin': _normalizeCurrency(request.fromCurrency),
'settleCoin': _normalizeCurrency(request.toCurrency),
'affiliateId': affiliateId,
'settleAmount': request.toAmount,
'settleNetwork': _networkFor(request.toCurrency),
@@ -274,6 +274,15 @@ class SideShiftExchangeProvider extends ExchangeProvider {
return responseJSON['id'] as String;
}
String _normalizeCurrency(CryptoCurrency currency) {
switch (currency) {
case CryptoCurrency.usdcEPoly:
return 'usdc';
default:
return currency.title.toLowerCase();
}
}
String _networkFor(CryptoCurrency currency) =>
currency.tag != null ? _normalizeTag(currency.tag!) : 'mainnet';
@@ -222,6 +222,10 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
return 'usdttrc20';
case CryptoCurrency.usdcpoly:
return 'usdcpoly';
case CryptoCurrency.usdtPoly:
return 'usdtpoly';
case CryptoCurrency.usdcEPoly:
return 'usdcepoly';
case CryptoCurrency.usdcsol:
return 'usdcspl';
case CryptoCurrency.matic:
@@ -271,6 +271,8 @@ class TrocadorExchangeProvider extends ExchangeProvider {
case CryptoCurrency.maticpoly:
return 'Mainnet';
case CryptoCurrency.usdcpoly:
case CryptoCurrency.usdtPoly:
case CryptoCurrency.usdcEPoly:
return 'MATIC';
case CryptoCurrency.zec:
return 'Mainnet';
@@ -283,6 +285,8 @@ class TrocadorExchangeProvider extends ExchangeProvider {
switch (currency) {
case CryptoCurrency.zec:
return 'zec';
case CryptoCurrency.usdcEPoly:
return 'usdce';
default:
return currency.title.toLowerCase();
}
+11
View File
@@ -44,3 +44,14 @@ String getChainNameBasedOnWalletType(WalletType walletType) {
return '';
}
}
String getTokenNameBasedOnWalletType(WalletType walletType) {
switch (walletType) {
case WalletType.ethereum:
return 'ETH';
case WalletType.polygon:
return 'MATIC';
default:
return '';
}
}
@@ -135,6 +135,7 @@ class ContactListPage extends BasePage {
await showBar<void>(context, S.of(context).copied_to_clipboard);
}
},
behavior: HitTestBehavior.opaque,
child: Container(
padding: const EdgeInsets.only(top: 16, bottom: 16, right: 24),
child: Row(
@@ -8,6 +8,7 @@ import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/screens/settings/widgets/settings_picker_cell.dart';
import 'package:cake_wallet/src/screens/settings/widgets/settings_switcher_cell.dart';
import 'package:cake_wallet/themes/extensions/address_theme.dart';
import 'package:cake_wallet/themes/extensions/cake_text_theme.dart';
import 'package:cake_wallet/themes/extensions/menu_theme.dart';
import 'package:cake_wallet/themes/extensions/picker_theme.dart';
import 'package:cake_wallet/view_model/dashboard/home_settings_view_model.dart';
@@ -91,7 +92,7 @@ class HomeSettingsPage extends BasePage {
fillColor: Theme.of(context).cardColor,
child: Icon(
Icons.add,
color: Theme.of(context).dialogTheme.backgroundColor,
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
size: 22.0,
),
padding: EdgeInsets.all(12),
@@ -18,6 +18,7 @@ class HomeScreenAccountWidget extends StatelessWidget {
context: context,
builder: (_) => getIt.get<MoneroAccountListPage>());
},
behavior: HitTestBehavior.opaque,
child: Container(
height: 100.0,
child: Row(
+2 -2
View File
@@ -176,7 +176,7 @@ class RootState extends State<Root> with WidgetsBindingObserver {
);
launchUri = null;
} else {
_nonETHWalletErrorToast(S.current.switchToETHWallet);
_nonETHWalletErrorToast(S.current.switchToEVMCompatibleWallet);
}
}
@@ -206,7 +206,7 @@ class RootState extends State<Root> with WidgetsBindingObserver {
String? _getRouteToGo() {
if (isWalletConnectLink) {
if (isEVMCompatibleChain(widget.appStore.wallet!.type)) {
_nonETHWalletErrorToast(S.current.switchToETHWallet);
_nonETHWalletErrorToast(S.current.switchToEVMCompatibleWallet);
return null;
}
return Routes.walletConnectConnectionsListing;
@@ -1,4 +1,3 @@
import 'package:cake_wallet/core/wallet_connect/web3wallet_service.dart';
import 'package:cake_wallet/reactions/wallet_connect.dart';
import 'package:cake_wallet/src/screens/settings/widgets/settings_cell_with_arrow.dart';
import 'package:cake_wallet/src/screens/settings/widgets/settings_picker_cell.dart';
@@ -18,12 +17,11 @@ import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
class ConnectionSyncPage extends BasePage {
ConnectionSyncPage(this.dashboardViewModel, this.web3walletService);
ConnectionSyncPage(this.dashboardViewModel);
@override
String get title => S.current.connection_sync;
final Web3WalletService? web3walletService;
final DashboardViewModel dashboardViewModel;
@override
@@ -76,7 +76,7 @@ class DisplaySettingsPage extends BasePage {
},
),
if (responsiveLayoutUtil.shouldRenderMobileUI && DeviceInfo.instance.isMobile)
SettingsThemeChoicesCell(_displaySettingsViewModel),
Semantics(label: S.current.color_theme, child: SettingsThemeChoicesCell(_displaySettingsViewModel)),
],
),
);
@@ -31,42 +31,43 @@ class SettingsChoicesCell extends StatelessWidget {
),
const SizedBox(height: 24),
Center(
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
color: Theme.of(context).extension<AddressTheme>()!.actionButtonColor,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: choicesListItem.items.map((dynamic e) {
final isSelected = choicesListItem.selectedItem == e;
return GestureDetector(
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
color: Theme.of(context).extension<AddressTheme>()!.actionButtonColor,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: choicesListItem.items.map((dynamic e) {
final isSelected = choicesListItem.selectedItem == e;
return Expanded(
child: GestureDetector(
onTap: () {
choicesListItem.onItemSelected.call(e);
},
child: Container(
padding: EdgeInsets.symmetric(horizontal: 32, vertical: 8),
padding: EdgeInsets.symmetric(vertical: 8),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
color: isSelected
? Theme.of(context).primaryColor
: null,
),
child: Text(
choicesListItem.displayItem.call(e),
style: TextStyle(
color: isSelected
? Colors.white
: Theme.of(context).extension<CakeTextTheme>()!.secondaryTextColor,
fontWeight: isSelected ? FontWeight.w700 : FontWeight.normal,
child: Center(
child: Text(
choicesListItem.displayItem.call(e),
style: TextStyle(
color: isSelected
? Colors.white
: Theme.of(context).extension<CakeTextTheme>()!.secondaryTextColor,
fontWeight: isSelected ? FontWeight.w700 : FontWeight.normal,
),
),
),
),
);
}).toList(),
),
),
);
}).toList(),
),
),
),
@@ -54,57 +54,61 @@ class SettingsThemeChoicesCell extends StatelessWidget {
return Padding(
padding: EdgeInsets.all(5),
child: GestureDetector(
onTap: () {
_displaySettingsViewModel.setTheme(e);
},
child: Container(
padding: EdgeInsets.all(5),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(cellRadius),
border: isSelected
? Border.all(
color: Theme.of(context).primaryColor)
: null,
color: Theme.of(context)
.extension<CakeTextTheme>()!
.secondaryTextColor
.withOpacity(
currentTheme.brightness == Brightness.light
? 0.1
: 0.3),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: EdgeInsets.symmetric(
horizontal: cellWidth, vertical: cellHeight),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(cellRadius),
bottomLeft: Radius.circular(cellRadius)),
color: e.themeData.primaryColor,
child: Semantics(
label: e.toString(),
selected: isSelected,
child: GestureDetector(
onTap: () {
_displaySettingsViewModel.setTheme(e);
},
child: Container(
padding: EdgeInsets.all(5),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(cellRadius),
border: isSelected
? Border.all(
color: Theme.of(context).primaryColor)
: null,
color: Theme.of(context)
.extension<CakeTextTheme>()!
.secondaryTextColor
.withOpacity(
currentTheme.brightness == Brightness.light
? 0.1
: 0.3),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: EdgeInsets.symmetric(
horizontal: cellWidth, vertical: cellHeight),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(cellRadius),
bottomLeft: Radius.circular(cellRadius)),
color: e.themeData.primaryColor,
),
),
),
Container(
padding: EdgeInsets.symmetric(
horizontal: cellWidth, vertical: cellHeight),
decoration: BoxDecoration(
color: e.themeData.colorScheme.background,
Container(
padding: EdgeInsets.symmetric(
horizontal: cellWidth, vertical: cellHeight),
decoration: BoxDecoration(
color: e.themeData.colorScheme.background,
),
),
),
Container(
padding: EdgeInsets.symmetric(
horizontal: cellWidth, vertical: cellHeight),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topRight: Radius.circular(cellRadius),
bottomRight: Radius.circular(cellRadius)),
color: e.themeData.cardColor,
Container(
padding: EdgeInsets.symmetric(
horizontal: cellWidth, vertical: cellHeight),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topRight: Radius.circular(cellRadius),
bottomRight: Radius.circular(cellRadius)),
color: e.themeData.cardColor,
),
),
),
],
],
),
),
),
),
+22 -18
View File
@@ -14,25 +14,29 @@ class StandardSwitch extends StatefulWidget {
class StandardSwitchState extends State<StandardSwitch> {
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: widget.onTaped,
child: AnimatedContainer(
padding: EdgeInsets.only(left: 2.0, right: 2.0),
alignment: widget.value ? Alignment.centerRight : Alignment.centerLeft,
duration: Duration(milliseconds: 250),
width: 50,
height: 28,
decoration: BoxDecoration(
color: widget.value
? Theme.of(context).primaryColor
: Theme.of(context).disabledColor,
borderRadius: BorderRadius.all(Radius.circular(14.0))),
child: Container(
width: 24.0,
height: 24.0,
return Semantics(
toggled: widget.value,
child: GestureDetector(
onTap: widget.onTaped,
child: AnimatedContainer(
padding: EdgeInsets.only(left: 2.0, right: 2.0),
alignment: widget.value ? Alignment.centerRight : Alignment.centerLeft,
duration: Duration(milliseconds: 250),
width: 50,
height: 28,
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle),
color: widget.value
? Theme.of(context).primaryColor
: Theme.of(context).disabledColor,
borderRadius: BorderRadius.all(Radius.circular(14.0))),
child: Container(
width: 24.0,
height: 24.0,
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle),
),
),
),
);
@@ -91,6 +91,9 @@ abstract class ContactListViewModelBase with Store {
walletContacts.where((element) => _isValidForCurrency(element)).toList();
bool _isValidForCurrency(ContactBase element) {
return _currency == null || element.type == _currency || element.type.title == _currency!.tag;
return _currency == null ||
element.type == _currency ||
element.type.title == _currency!.tag ||
element.type.tag == _currency!.tag;
}
}