mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
Polygon-Wallet-fixes (#1222)
* fix: Fix issues surrounding polygon release * Add polygon generation command to pubspec script * Remove unnecesary cast * fix: Remove unneeded code * fix: Adjust workflow file to pick polygonScan apikey * fix: Issues noticed while testing * fix: Issues noticed while testing * fix: Transaction should reflect the token name * fix: Remove unused import * feat: Add alchemy node to default migration settings * Fix sending Polygon delay Remove alchemy node Minor Enhancements * Remove scrolling from multiple choices settings row and make them fill the whole space [skip ci] * Add USDT poly Add icon for USDC.e * Fix ERC20 tokens overriding old wallets Add USDC.e to exchange * - Remove unnecessary code - Minor Enhancements --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
co-authored by
Omar Hatem
parent
7ce387c130
commit
ef7762eaca
@@ -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
@@ -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';
|
||||
@@ -752,13 +751,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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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 '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user