Fix polygon issues

This commit is contained in:
OmarHatem 2023-12-04 23:05:50 +02:00
parent 6eb0706b77
commit f93e97a43c
9 changed files with 25 additions and 22 deletions

View file

@ -4,11 +4,11 @@ source ./app_env.sh cakewallet
cd ../.. && flutter pub get cd ../.. && flutter pub get
flutter packages pub run tool/generate_localization.dart flutter packages pub run tool/generate_localization.dart
cd cw_core && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd .. cd cw_core && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd ..
cd cw_monero && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd .. #cd cw_monero && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd ..
cd cw_bitcoin && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd .. #cd cw_bitcoin && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd ..
cd cw_haven && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd .. #cd cw_haven && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd ..
cd cw_ethereum && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd .. #cd cw_ethereum && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd ..
cd cw_nano && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd .. #cd cw_nano && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd ..
cd cw_bitcoin_cash && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd .. #cd cw_bitcoin_cash && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd ..
cd cw_polygon && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd .. cd cw_polygon && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd ..
flutter packages pub run build_runner build --delete-conflicting-outputs flutter packages pub run build_runner build --delete-conflicting-outputs

View file

@ -1,6 +1,6 @@
import 'dart:io'; import 'dart:io';
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:cw_core/file.dart' as file; import 'package:cw_core/utils/file.dart' as file;
import 'package:cake_backup/backup.dart' as cwb; import 'package:cake_backup/backup.dart' as cwb;
EncryptionFileUtils encryptionFileUtilsFor(bool direct) EncryptionFileUtils encryptionFileUtilsFor(bool direct)

View file

@ -1,8 +1,8 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:core'; import 'dart:core';
import 'package:cw_core/pathForWallet.dart'; import 'package:cw_core/pathForWallet.dart';
import 'package:cw_core/utils/file.dart';
import 'package:cw_core/wallet_info.dart'; import 'package:cw_core/wallet_info.dart';
import 'package:cw_ethereum/file.dart';
import 'package:cw_polygon/polygon_transaction_info.dart'; import 'package:cw_polygon/polygon_transaction_info.dart';
import 'package:mobx/mobx.dart'; import 'package:mobx/mobx.dart';
import 'package:cw_core/transaction_history.dart'; import 'package:cw_core/transaction_history.dart';

View file

@ -11,13 +11,13 @@ import 'package:cw_core/pending_transaction.dart';
import 'package:cw_core/sync_status.dart'; import 'package:cw_core/sync_status.dart';
import 'package:cw_core/transaction_direction.dart'; import 'package:cw_core/transaction_direction.dart';
import 'package:cw_core/transaction_priority.dart'; import 'package:cw_core/transaction_priority.dart';
import 'package:cw_core/utils/file.dart';
import 'package:cw_core/wallet_addresses.dart'; import 'package:cw_core/wallet_addresses.dart';
import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/wallet_base.dart';
import 'package:cw_core/wallet_info.dart'; import 'package:cw_core/wallet_info.dart';
import 'package:cw_ethereum/erc20_balance.dart'; import 'package:cw_ethereum/erc20_balance.dart';
import 'package:cw_ethereum/ethereum_formatter.dart'; import 'package:cw_ethereum/ethereum_formatter.dart';
import 'package:cw_ethereum/ethereum_transaction_model.dart'; import 'package:cw_ethereum/ethereum_transaction_model.dart';
import 'package:cw_ethereum/file.dart';
import 'package:cw_core/erc20_token.dart'; import 'package:cw_core/erc20_token.dart';
import 'package:cw_polygon/default_erc20_tokens.dart'; import 'package:cw_polygon/default_erc20_tokens.dart';
import 'package:cw_polygon/polygon_client.dart'; import 'package:cw_polygon/polygon_client.dart';
@ -532,6 +532,9 @@ abstract class PolygonWalletBase extends WalletBase<ERC20Balance,
} }
} }
@override
String get password => _password;
@override @override
String signMessage(String message, {String? address = null}) => bytesToHex( String signMessage(String message, {String? address = null}) => bytesToHex(
_polygonPrivateKey.signPersonalMessageToUint8List(ascii.encode(message))); _polygonPrivateKey.signPersonalMessageToUint8List(ascii.encode(message)));

View file

@ -1,13 +1,11 @@
import 'dart:io' show Directory, File, Platform; import 'dart:io' show Directory, File, Platform;
import 'package:cake_wallet/bitcoin/bitcoin.dart'; 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:cake_wallet/entities/exchange_api_mode.dart';
import 'package:cw_core/pathForWallet.dart'; import 'package:cw_core/pathForWallet.dart';
import 'package:cake_wallet/entities/secret_store_key.dart'; import 'package:cake_wallet/entities/secret_store_key.dart';
import 'package:cake_wallet/core/secure_storage.dart'; import 'package:cake_wallet/core/secure_storage.dart';
import 'package:cw_core/root_dir.dart'; import 'package:cw_core/root_dir.dart';
import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
import 'package:path_provider/path_provider.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:cake_wallet/entities/preferences_key.dart'; import 'package:cake_wallet/entities/preferences_key.dart';
import 'package:cw_core/wallet_type.dart'; import 'package:cw_core/wallet_type.dart';
@ -381,7 +379,7 @@ Node getMoneroDefaultNode({required Box<Node> nodes}) {
} }
} }
Future<void> rewriteSecureStoragePin({required FlutterSecureStorage secureStorage}) async { Future<void> rewriteSecureStoragePin({required SecureStorage secureStorage}) async {
// the bug only affects ios/mac: // the bug only affects ios/mac:
if (!Platform.isIOS && !Platform.isMacOS) { if (!Platform.isIOS && !Platform.isMacOS) {
return; return;
@ -407,8 +405,9 @@ Future<void> rewriteSecureStoragePin({required FlutterSecureStorage secureStorag
await secureStorage.write( await secureStorage.write(
key: keyForPinCode, key: keyForPinCode,
value: encodedPin, value: encodedPin,
iOptions: IOSOptions(accessibility: KeychainAccessibility.first_unlock), // TODO: find a way to add those with the generated secure storage
mOptions: MacOsOptions(accessibility: KeychainAccessibility.first_unlock), // iOptions: IOSOptions(accessibility: KeychainAccessibility.first_unlock),
// mOptions: MacOsOptions(accessibility: KeychainAccessibility.first_unlock),
); );
} }
@ -431,7 +430,7 @@ Future<void> changeLitecoinCurrentElectrumServerToDefault(
Future<void> changeBitcoinCashCurrentNodeToDefault( Future<void> changeBitcoinCashCurrentNodeToDefault(
{required SharedPreferences sharedPreferences, required Box<Node> nodes}) async { {required SharedPreferences sharedPreferences, required Box<Node> nodes}) async {
final server = getBitcoinCashDefaultElectrumServer(nodes: nodes); final server = getBitcoinCashDefaultElectrumServer(nodes: nodes);
final serverId = server?.key as int ?? 0; final serverId = server?.key as int? ?? 0;
await sharedPreferences.setInt(PreferencesKey.currentBitcoinCashNodeIdKey, serverId); await sharedPreferences.setInt(PreferencesKey.currentBitcoinCashNodeIdKey, serverId);
} }

View file

@ -4,15 +4,16 @@ class CWPolygon extends Polygon {
@override @override
List<String> getPolygonWordList(String language) => EthereumMnemonics.englishWordlist; List<String> getPolygonWordList(String language) => EthereumMnemonics.englishWordlist;
WalletService createPolygonWalletService(Box<WalletInfo> walletInfoSource) => WalletService createPolygonWalletService(Box<WalletInfo> walletInfoSource, bool isDirect) =>
PolygonWalletService(walletInfoSource); PolygonWalletService(walletInfoSource);
@override @override
WalletCredentials createPolygonNewWalletCredentials({ WalletCredentials createPolygonNewWalletCredentials({
required String name, required String name,
WalletInfo? walletInfo, WalletInfo? walletInfo,
String? password
}) => }) =>
PolygonNewWalletCredentials(name: name, walletInfo: walletInfo); PolygonNewWalletCredentials(name: name, walletInfo: walletInfo, password: password);
@override @override
WalletCredentials createPolygonRestoreWalletFromSeedCredentials({ WalletCredentials createPolygonRestoreWalletFromSeedCredentials({

View file

@ -13,7 +13,7 @@ CONFIG_ARGS=""
case $APP_LINUX_TYPE in case $APP_LINUX_TYPE in
$CAKEWALLET) $CAKEWALLET)
CONFIG_ARGS="--monero --bitcoin --ethereum --nano --excludeFlutterSecureStorage";; CONFIG_ARGS="--monero --bitcoin --ethereum --nano --bitcoinCash --excludeFlutterSecureStorage";;
esac esac
cp -rf pubspec_description.yaml pubspec.yaml cp -rf pubspec_description.yaml pubspec.yaml

View file

@ -14,8 +14,8 @@ if [ -n "$1" ]; then
fi fi
CAKEWALLET_NAME="Cake Wallet" CAKEWALLET_NAME="Cake Wallet"
CAKEWALLET_VERSION="1.1.5" CAKEWALLET_VERSION="1.2.0"
CAKEWALLET_BUILD_NUMBER=9 CAKEWALLET_BUILD_NUMBER=10
if ! [[ " ${TYPES[*]} " =~ " ${APP_LINUX_TYPE} " ]]; then if ! [[ " ${TYPES[*]} " =~ " ${APP_LINUX_TYPE} " ]]; then
echo "Wrong app type." echo "Wrong app type."

View file

@ -612,8 +612,8 @@ import 'package:cw_ethereum/ethereum_mnemonics.dart';
const polygonContent = """ const polygonContent = """
abstract class Polygon { abstract class Polygon {
List<String> getPolygonWordList(String language); List<String> getPolygonWordList(String language);
WalletService createPolygonWalletService(Box<WalletInfo> walletInfoSource); WalletService createPolygonWalletService(Box<WalletInfo> walletInfoSource, bool isDirect);
WalletCredentials createPolygonNewWalletCredentials({required String name, WalletInfo? walletInfo}); WalletCredentials createPolygonNewWalletCredentials({required String name, WalletInfo? walletInfo, String? password});
WalletCredentials createPolygonRestoreWalletFromSeedCredentials({required String name, required String mnemonic, required String password}); WalletCredentials createPolygonRestoreWalletFromSeedCredentials({required String name, required String mnemonic, required String password});
WalletCredentials createPolygonRestoreWalletFromPrivateKey({required String name, required String privateKey, required String password}); WalletCredentials createPolygonRestoreWalletFromPrivateKey({required String name, required String privateKey, required String password});
String getAddress(WalletBase wallet); String getAddress(WalletBase wallet);