2023-08-04 17:01:49 +00:00
|
|
|
import 'dart:convert';
|
|
|
|
|
2023-08-15 00:47:25 +00:00
|
|
|
import 'package:cw_core/cake_hive.dart';
|
CW-551-Refactor-EVM-Chains (#1256)
* feat: Create central package for EVM chains
* chore: Cleanup pubspec and add core evm dependencies
* feat: Replicated core evm chain files, time to start fixing the issues
* feat: Setup evm central package to handle all evm chains
* feat: Link up Polygon and Ethereum wallets to the centra evm package, fix bugs and issues, and optimze for better performance
* feat: Setup and adjust configs to reflect new evm configurations
* Remove unneeded file
* fix: Changes done while re-reviewing entire structure and refactor
* fix: Add evm chain wallet path to imports in configure file
* feat: Adjust implementation of parent class, remove unneeded files, remove windows, linux and mac directories, restructure the evm child classes
* fix: Make EVMChainWallet a central abstract class and adjust accordingly
* fix: Adjust transaction info, restructure EVMWalletChain to be an abstract, adjust external facing interfaces for polygon and ethereum, adjust configuration for ethereum and polygon in configure file
* fix: Testing issues
* fix: Add localization for nft tile and details page texts and add dashes for null responses
* fix: merge conflicts
* Minor fixes for building Monero.com
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
2024-01-30 18:01:48 +00:00
|
|
|
import 'package:cw_core/crypto_currency.dart';
|
|
|
|
import 'package:cw_core/erc20_token.dart';
|
2023-08-04 17:01:49 +00:00
|
|
|
import 'package:cw_core/pathForWallet.dart';
|
|
|
|
import 'package:cw_core/transaction_direction.dart';
|
|
|
|
import 'package:cw_core/wallet_info.dart';
|
2024-08-09 20:15:30 +00:00
|
|
|
import 'package:cw_core/wallet_keys_file.dart';
|
2023-12-13 14:03:07 +00:00
|
|
|
import 'package:cw_ethereum/default_ethereum_erc20_tokens.dart';
|
2023-08-04 17:01:49 +00:00
|
|
|
import 'package:cw_ethereum/ethereum_client.dart';
|
|
|
|
import 'package:cw_ethereum/ethereum_transaction_history.dart';
|
|
|
|
import 'package:cw_ethereum/ethereum_transaction_info.dart';
|
CW-551-Refactor-EVM-Chains (#1256)
* feat: Create central package for EVM chains
* chore: Cleanup pubspec and add core evm dependencies
* feat: Replicated core evm chain files, time to start fixing the issues
* feat: Setup evm central package to handle all evm chains
* feat: Link up Polygon and Ethereum wallets to the centra evm package, fix bugs and issues, and optimze for better performance
* feat: Setup and adjust configs to reflect new evm configurations
* Remove unneeded file
* fix: Changes done while re-reviewing entire structure and refactor
* fix: Add evm chain wallet path to imports in configure file
* feat: Adjust implementation of parent class, remove unneeded files, remove windows, linux and mac directories, restructure the evm child classes
* fix: Make EVMChainWallet a central abstract class and adjust accordingly
* fix: Adjust transaction info, restructure EVMWalletChain to be an abstract, adjust external facing interfaces for polygon and ethereum, adjust configuration for ethereum and polygon in configure file
* fix: Testing issues
* fix: Add localization for nft tile and details page texts and add dashes for null responses
* fix: merge conflicts
* Minor fixes for building Monero.com
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
2024-01-30 18:01:48 +00:00
|
|
|
import 'package:cw_evm/evm_chain_transaction_history.dart';
|
|
|
|
import 'package:cw_evm/evm_chain_transaction_info.dart';
|
|
|
|
import 'package:cw_evm/evm_chain_transaction_model.dart';
|
|
|
|
import 'package:cw_evm/evm_chain_wallet.dart';
|
|
|
|
import 'package:cw_evm/evm_erc20_balance.dart';
|
|
|
|
import 'package:cw_evm/file.dart';
|
|
|
|
|
|
|
|
class EthereumWallet extends EVMChainWallet {
|
|
|
|
EthereumWallet({
|
|
|
|
required super.client,
|
|
|
|
required super.password,
|
|
|
|
required super.walletInfo,
|
|
|
|
super.mnemonic,
|
|
|
|
super.initialBalance,
|
|
|
|
super.privateKey,
|
|
|
|
}) : super(nativeCurrency: CryptoCurrency.eth);
|
2023-08-04 17:01:49 +00:00
|
|
|
|
CW-551-Refactor-EVM-Chains (#1256)
* feat: Create central package for EVM chains
* chore: Cleanup pubspec and add core evm dependencies
* feat: Replicated core evm chain files, time to start fixing the issues
* feat: Setup evm central package to handle all evm chains
* feat: Link up Polygon and Ethereum wallets to the centra evm package, fix bugs and issues, and optimze for better performance
* feat: Setup and adjust configs to reflect new evm configurations
* Remove unneeded file
* fix: Changes done while re-reviewing entire structure and refactor
* fix: Add evm chain wallet path to imports in configure file
* feat: Adjust implementation of parent class, remove unneeded files, remove windows, linux and mac directories, restructure the evm child classes
* fix: Make EVMChainWallet a central abstract class and adjust accordingly
* fix: Adjust transaction info, restructure EVMWalletChain to be an abstract, adjust external facing interfaces for polygon and ethereum, adjust configuration for ethereum and polygon in configure file
* fix: Testing issues
* fix: Add localization for nft tile and details page texts and add dashes for null responses
* fix: merge conflicts
* Minor fixes for building Monero.com
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
2024-01-30 18:01:48 +00:00
|
|
|
@override
|
|
|
|
void addInitialTokens() {
|
|
|
|
final initialErc20Tokens = DefaultEthereumErc20Tokens().initialErc20Tokens;
|
2023-08-04 17:01:49 +00:00
|
|
|
|
CW-551-Refactor-EVM-Chains (#1256)
* feat: Create central package for EVM chains
* chore: Cleanup pubspec and add core evm dependencies
* feat: Replicated core evm chain files, time to start fixing the issues
* feat: Setup evm central package to handle all evm chains
* feat: Link up Polygon and Ethereum wallets to the centra evm package, fix bugs and issues, and optimze for better performance
* feat: Setup and adjust configs to reflect new evm configurations
* Remove unneeded file
* fix: Changes done while re-reviewing entire structure and refactor
* fix: Add evm chain wallet path to imports in configure file
* feat: Adjust implementation of parent class, remove unneeded files, remove windows, linux and mac directories, restructure the evm child classes
* fix: Make EVMChainWallet a central abstract class and adjust accordingly
* fix: Adjust transaction info, restructure EVMWalletChain to be an abstract, adjust external facing interfaces for polygon and ethereum, adjust configuration for ethereum and polygon in configure file
* fix: Testing issues
* fix: Add localization for nft tile and details page texts and add dashes for null responses
* fix: merge conflicts
* Minor fixes for building Monero.com
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
2024-01-30 18:01:48 +00:00
|
|
|
for (var token in initialErc20Tokens) {
|
|
|
|
evmChainErc20TokensBox.put(token.contractAddress, token);
|
2023-08-04 17:01:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
CW-551-Refactor-EVM-Chains (#1256)
* feat: Create central package for EVM chains
* chore: Cleanup pubspec and add core evm dependencies
* feat: Replicated core evm chain files, time to start fixing the issues
* feat: Setup evm central package to handle all evm chains
* feat: Link up Polygon and Ethereum wallets to the centra evm package, fix bugs and issues, and optimze for better performance
* feat: Setup and adjust configs to reflect new evm configurations
* Remove unneeded file
* fix: Changes done while re-reviewing entire structure and refactor
* fix: Add evm chain wallet path to imports in configure file
* feat: Adjust implementation of parent class, remove unneeded files, remove windows, linux and mac directories, restructure the evm child classes
* fix: Make EVMChainWallet a central abstract class and adjust accordingly
* fix: Adjust transaction info, restructure EVMWalletChain to be an abstract, adjust external facing interfaces for polygon and ethereum, adjust configuration for ethereum and polygon in configure file
* fix: Testing issues
* fix: Add localization for nft tile and details page texts and add dashes for null responses
* fix: merge conflicts
* Minor fixes for building Monero.com
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
2024-01-30 18:01:48 +00:00
|
|
|
Future<bool> checkIfScanProviderIsEnabled() async {
|
|
|
|
bool isEtherscanEnabled = (await sharedPrefs.future).getBool("use_etherscan") ?? true;
|
|
|
|
return isEtherscanEnabled;
|
|
|
|
}
|
2023-08-04 17:01:49 +00:00
|
|
|
|
|
|
|
@override
|
CW-551-Refactor-EVM-Chains (#1256)
* feat: Create central package for EVM chains
* chore: Cleanup pubspec and add core evm dependencies
* feat: Replicated core evm chain files, time to start fixing the issues
* feat: Setup evm central package to handle all evm chains
* feat: Link up Polygon and Ethereum wallets to the centra evm package, fix bugs and issues, and optimze for better performance
* feat: Setup and adjust configs to reflect new evm configurations
* Remove unneeded file
* fix: Changes done while re-reviewing entire structure and refactor
* fix: Add evm chain wallet path to imports in configure file
* feat: Adjust implementation of parent class, remove unneeded files, remove windows, linux and mac directories, restructure the evm child classes
* fix: Make EVMChainWallet a central abstract class and adjust accordingly
* fix: Adjust transaction info, restructure EVMWalletChain to be an abstract, adjust external facing interfaces for polygon and ethereum, adjust configuration for ethereum and polygon in configure file
* fix: Testing issues
* fix: Add localization for nft tile and details page texts and add dashes for null responses
* fix: merge conflicts
* Minor fixes for building Monero.com
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
2024-01-30 18:01:48 +00:00
|
|
|
Future<void> initErc20TokensBox() async {
|
|
|
|
// This is for ethereum wallets,
|
|
|
|
// Other wallets would override and initialize their respective boxes with their boxNames.
|
2023-12-30 15:28:33 +00:00
|
|
|
await movePreviousErc20BoxConfigsToNewBox();
|
2023-08-04 17:01:49 +00:00
|
|
|
}
|
|
|
|
|
2023-12-30 15:28:33 +00:00
|
|
|
/// Majorly for backward compatibility for previous configs that have been set.
|
|
|
|
Future<void> movePreviousErc20BoxConfigsToNewBox() async {
|
|
|
|
// Opens a box specific to this wallet
|
CW-551-Refactor-EVM-Chains (#1256)
* feat: Create central package for EVM chains
* chore: Cleanup pubspec and add core evm dependencies
* feat: Replicated core evm chain files, time to start fixing the issues
* feat: Setup evm central package to handle all evm chains
* feat: Link up Polygon and Ethereum wallets to the centra evm package, fix bugs and issues, and optimze for better performance
* feat: Setup and adjust configs to reflect new evm configurations
* Remove unneeded file
* fix: Changes done while re-reviewing entire structure and refactor
* fix: Add evm chain wallet path to imports in configure file
* feat: Adjust implementation of parent class, remove unneeded files, remove windows, linux and mac directories, restructure the evm child classes
* fix: Make EVMChainWallet a central abstract class and adjust accordingly
* fix: Adjust transaction info, restructure EVMWalletChain to be an abstract, adjust external facing interfaces for polygon and ethereum, adjust configuration for ethereum and polygon in configure file
* fix: Testing issues
* fix: Add localization for nft tile and details page texts and add dashes for null responses
* fix: merge conflicts
* Minor fixes for building Monero.com
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
2024-01-30 18:01:48 +00:00
|
|
|
evmChainErc20TokensBox = await CakeHive.openBox<Erc20Token>(
|
2023-12-30 15:28:33 +00:00
|
|
|
"${walletInfo.name.replaceAll(" ", "_")}_${Erc20Token.ethereumBoxName}");
|
|
|
|
|
|
|
|
//Open the previous token configs box
|
|
|
|
erc20TokensBox = await CakeHive.openBox<Erc20Token>(Erc20Token.boxName);
|
|
|
|
|
|
|
|
// Check if it's empty, if it is, we stop the flow and return.
|
|
|
|
if (erc20TokensBox.isEmpty) {
|
|
|
|
// If it's empty, but the new wallet specific box is also empty,
|
|
|
|
// we load the initial tokens to the new box.
|
CW-551-Refactor-EVM-Chains (#1256)
* feat: Create central package for EVM chains
* chore: Cleanup pubspec and add core evm dependencies
* feat: Replicated core evm chain files, time to start fixing the issues
* feat: Setup evm central package to handle all evm chains
* feat: Link up Polygon and Ethereum wallets to the centra evm package, fix bugs and issues, and optimze for better performance
* feat: Setup and adjust configs to reflect new evm configurations
* Remove unneeded file
* fix: Changes done while re-reviewing entire structure and refactor
* fix: Add evm chain wallet path to imports in configure file
* feat: Adjust implementation of parent class, remove unneeded files, remove windows, linux and mac directories, restructure the evm child classes
* fix: Make EVMChainWallet a central abstract class and adjust accordingly
* fix: Adjust transaction info, restructure EVMWalletChain to be an abstract, adjust external facing interfaces for polygon and ethereum, adjust configuration for ethereum and polygon in configure file
* fix: Testing issues
* fix: Add localization for nft tile and details page texts and add dashes for null responses
* fix: merge conflicts
* Minor fixes for building Monero.com
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
2024-01-30 18:01:48 +00:00
|
|
|
if (evmChainErc20TokensBox.isEmpty) addInitialTokens();
|
2023-12-30 15:28:33 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
final allValues = erc20TokensBox.values.toList();
|
|
|
|
|
|
|
|
// Clear and delete the old token box
|
|
|
|
await erc20TokensBox.clear();
|
|
|
|
await erc20TokensBox.deleteFromDisk();
|
|
|
|
|
|
|
|
// Add all the previous tokens with configs to the new box
|
CW-551-Refactor-EVM-Chains (#1256)
* feat: Create central package for EVM chains
* chore: Cleanup pubspec and add core evm dependencies
* feat: Replicated core evm chain files, time to start fixing the issues
* feat: Setup evm central package to handle all evm chains
* feat: Link up Polygon and Ethereum wallets to the centra evm package, fix bugs and issues, and optimze for better performance
* feat: Setup and adjust configs to reflect new evm configurations
* Remove unneeded file
* fix: Changes done while re-reviewing entire structure and refactor
* fix: Add evm chain wallet path to imports in configure file
* feat: Adjust implementation of parent class, remove unneeded files, remove windows, linux and mac directories, restructure the evm child classes
* fix: Make EVMChainWallet a central abstract class and adjust accordingly
* fix: Adjust transaction info, restructure EVMWalletChain to be an abstract, adjust external facing interfaces for polygon and ethereum, adjust configuration for ethereum and polygon in configure file
* fix: Testing issues
* fix: Add localization for nft tile and details page texts and add dashes for null responses
* fix: merge conflicts
* Minor fixes for building Monero.com
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
2024-01-30 18:01:48 +00:00
|
|
|
evmChainErc20TokensBox.addAll(allValues);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
EVMChainTransactionInfo getTransactionInfo(
|
|
|
|
EVMChainTransactionModel transactionModel, String address) {
|
|
|
|
final model = EthereumTransactionInfo(
|
|
|
|
id: transactionModel.hash,
|
|
|
|
height: transactionModel.blockNumber,
|
|
|
|
ethAmount: transactionModel.amount,
|
|
|
|
direction: transactionModel.from == address
|
|
|
|
? TransactionDirection.outgoing
|
|
|
|
: TransactionDirection.incoming,
|
|
|
|
isPending: false,
|
|
|
|
date: transactionModel.date,
|
|
|
|
confirmations: transactionModel.confirmations,
|
|
|
|
ethFee: BigInt.from(transactionModel.gasUsed) * transactionModel.gasPrice,
|
|
|
|
exponent: transactionModel.tokenDecimal ?? 18,
|
|
|
|
tokenSymbol: transactionModel.tokenSymbol ?? "ETH",
|
|
|
|
to: transactionModel.to,
|
|
|
|
from: transactionModel.from,
|
2024-06-20 23:13:12 +00:00
|
|
|
evmSignatureName: transactionModel.evmSignatureName,
|
2023-08-04 17:01:49 +00:00
|
|
|
);
|
CW-551-Refactor-EVM-Chains (#1256)
* feat: Create central package for EVM chains
* chore: Cleanup pubspec and add core evm dependencies
* feat: Replicated core evm chain files, time to start fixing the issues
* feat: Setup evm central package to handle all evm chains
* feat: Link up Polygon and Ethereum wallets to the centra evm package, fix bugs and issues, and optimze for better performance
* feat: Setup and adjust configs to reflect new evm configurations
* Remove unneeded file
* fix: Changes done while re-reviewing entire structure and refactor
* fix: Add evm chain wallet path to imports in configure file
* feat: Adjust implementation of parent class, remove unneeded files, remove windows, linux and mac directories, restructure the evm child classes
* fix: Make EVMChainWallet a central abstract class and adjust accordingly
* fix: Adjust transaction info, restructure EVMWalletChain to be an abstract, adjust external facing interfaces for polygon and ethereum, adjust configuration for ethereum and polygon in configure file
* fix: Testing issues
* fix: Add localization for nft tile and details page texts and add dashes for null responses
* fix: merge conflicts
* Minor fixes for building Monero.com
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
2024-01-30 18:01:48 +00:00
|
|
|
return model;
|
2023-08-04 17:01:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
CW-551-Refactor-EVM-Chains (#1256)
* feat: Create central package for EVM chains
* chore: Cleanup pubspec and add core evm dependencies
* feat: Replicated core evm chain files, time to start fixing the issues
* feat: Setup evm central package to handle all evm chains
* feat: Link up Polygon and Ethereum wallets to the centra evm package, fix bugs and issues, and optimze for better performance
* feat: Setup and adjust configs to reflect new evm configurations
* Remove unneeded file
* fix: Changes done while re-reviewing entire structure and refactor
* fix: Add evm chain wallet path to imports in configure file
* feat: Adjust implementation of parent class, remove unneeded files, remove windows, linux and mac directories, restructure the evm child classes
* fix: Make EVMChainWallet a central abstract class and adjust accordingly
* fix: Adjust transaction info, restructure EVMWalletChain to be an abstract, adjust external facing interfaces for polygon and ethereum, adjust configuration for ethereum and polygon in configure file
* fix: Testing issues
* fix: Add localization for nft tile and details page texts and add dashes for null responses
* fix: merge conflicts
* Minor fixes for building Monero.com
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
2024-01-30 18:01:48 +00:00
|
|
|
String getTransactionHistoryFileName() => 'transactions.json';
|
2023-08-04 17:01:49 +00:00
|
|
|
|
|
|
|
@override
|
CW-551-Refactor-EVM-Chains (#1256)
* feat: Create central package for EVM chains
* chore: Cleanup pubspec and add core evm dependencies
* feat: Replicated core evm chain files, time to start fixing the issues
* feat: Setup evm central package to handle all evm chains
* feat: Link up Polygon and Ethereum wallets to the centra evm package, fix bugs and issues, and optimze for better performance
* feat: Setup and adjust configs to reflect new evm configurations
* Remove unneeded file
* fix: Changes done while re-reviewing entire structure and refactor
* fix: Add evm chain wallet path to imports in configure file
* feat: Adjust implementation of parent class, remove unneeded files, remove windows, linux and mac directories, restructure the evm child classes
* fix: Make EVMChainWallet a central abstract class and adjust accordingly
* fix: Adjust transaction info, restructure EVMWalletChain to be an abstract, adjust external facing interfaces for polygon and ethereum, adjust configuration for ethereum and polygon in configure file
* fix: Testing issues
* fix: Add localization for nft tile and details page texts and add dashes for null responses
* fix: merge conflicts
* Minor fixes for building Monero.com
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
2024-01-30 18:01:48 +00:00
|
|
|
Erc20Token createNewErc20TokenObject(Erc20Token token, String? iconPath) {
|
|
|
|
return Erc20Token(
|
|
|
|
name: token.name,
|
|
|
|
symbol: token.symbol,
|
|
|
|
contractAddress: token.contractAddress,
|
|
|
|
decimal: token.decimal,
|
|
|
|
enabled: token.enabled,
|
|
|
|
tag: token.tag ?? "ETH",
|
|
|
|
iconPath: iconPath,
|
|
|
|
);
|
2023-08-04 17:01:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
CW-551-Refactor-EVM-Chains (#1256)
* feat: Create central package for EVM chains
* chore: Cleanup pubspec and add core evm dependencies
* feat: Replicated core evm chain files, time to start fixing the issues
* feat: Setup evm central package to handle all evm chains
* feat: Link up Polygon and Ethereum wallets to the centra evm package, fix bugs and issues, and optimze for better performance
* feat: Setup and adjust configs to reflect new evm configurations
* Remove unneeded file
* fix: Changes done while re-reviewing entire structure and refactor
* fix: Add evm chain wallet path to imports in configure file
* feat: Adjust implementation of parent class, remove unneeded files, remove windows, linux and mac directories, restructure the evm child classes
* fix: Make EVMChainWallet a central abstract class and adjust accordingly
* fix: Adjust transaction info, restructure EVMWalletChain to be an abstract, adjust external facing interfaces for polygon and ethereum, adjust configuration for ethereum and polygon in configure file
* fix: Testing issues
* fix: Add localization for nft tile and details page texts and add dashes for null responses
* fix: merge conflicts
* Minor fixes for building Monero.com
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
2024-01-30 18:01:48 +00:00
|
|
|
EVMChainTransactionHistory setUpTransactionHistory(WalletInfo walletInfo, String password) {
|
|
|
|
return EthereumTransactionHistory(walletInfo: walletInfo, password: password);
|
2023-08-04 17:01:49 +00:00
|
|
|
}
|
|
|
|
|
CW-551-Refactor-EVM-Chains (#1256)
* feat: Create central package for EVM chains
* chore: Cleanup pubspec and add core evm dependencies
* feat: Replicated core evm chain files, time to start fixing the issues
* feat: Setup evm central package to handle all evm chains
* feat: Link up Polygon and Ethereum wallets to the centra evm package, fix bugs and issues, and optimze for better performance
* feat: Setup and adjust configs to reflect new evm configurations
* Remove unneeded file
* fix: Changes done while re-reviewing entire structure and refactor
* fix: Add evm chain wallet path to imports in configure file
* feat: Adjust implementation of parent class, remove unneeded files, remove windows, linux and mac directories, restructure the evm child classes
* fix: Make EVMChainWallet a central abstract class and adjust accordingly
* fix: Adjust transaction info, restructure EVMWalletChain to be an abstract, adjust external facing interfaces for polygon and ethereum, adjust configuration for ethereum and polygon in configure file
* fix: Testing issues
* fix: Add localization for nft tile and details page texts and add dashes for null responses
* fix: merge conflicts
* Minor fixes for building Monero.com
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
2024-01-30 18:01:48 +00:00
|
|
|
static Future<EthereumWallet> open(
|
|
|
|
{required String name, required String password, required WalletInfo walletInfo}) async {
|
2024-08-09 20:15:30 +00:00
|
|
|
final hasKeysFile = await WalletKeysFile.hasKeysFile(name, walletInfo.type);
|
2023-08-04 17:01:49 +00:00
|
|
|
final path = await pathForWallet(name: name, type: walletInfo.type);
|
2024-08-09 20:15:30 +00:00
|
|
|
|
|
|
|
Map<String, dynamic>? data;
|
|
|
|
try {
|
|
|
|
final jsonSource = await read(path: path, password: password);
|
|
|
|
|
|
|
|
data = json.decode(jsonSource) as Map<String, dynamic>;
|
|
|
|
} catch (e) {
|
|
|
|
if (!hasKeysFile) rethrow;
|
|
|
|
}
|
|
|
|
|
|
|
|
final balance = EVMChainERC20Balance.fromJSON(data?['balance'] as String) ??
|
CW-551-Refactor-EVM-Chains (#1256)
* feat: Create central package for EVM chains
* chore: Cleanup pubspec and add core evm dependencies
* feat: Replicated core evm chain files, time to start fixing the issues
* feat: Setup evm central package to handle all evm chains
* feat: Link up Polygon and Ethereum wallets to the centra evm package, fix bugs and issues, and optimze for better performance
* feat: Setup and adjust configs to reflect new evm configurations
* Remove unneeded file
* fix: Changes done while re-reviewing entire structure and refactor
* fix: Add evm chain wallet path to imports in configure file
* feat: Adjust implementation of parent class, remove unneeded files, remove windows, linux and mac directories, restructure the evm child classes
* fix: Make EVMChainWallet a central abstract class and adjust accordingly
* fix: Adjust transaction info, restructure EVMWalletChain to be an abstract, adjust external facing interfaces for polygon and ethereum, adjust configuration for ethereum and polygon in configure file
* fix: Testing issues
* fix: Add localization for nft tile and details page texts and add dashes for null responses
* fix: merge conflicts
* Minor fixes for building Monero.com
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
2024-01-30 18:01:48 +00:00
|
|
|
EVMChainERC20Balance(BigInt.zero);
|
2023-08-04 17:01:49 +00:00
|
|
|
|
2024-08-09 20:15:30 +00:00
|
|
|
final WalletKeysData keysData;
|
|
|
|
// Migrate wallet from the old scheme to then new .keys file scheme
|
|
|
|
if (!hasKeysFile) {
|
|
|
|
final mnemonic = data!['mnemonic'] as String?;
|
|
|
|
final privateKey = data['private_key'] as String?;
|
|
|
|
|
|
|
|
keysData = WalletKeysData(mnemonic: mnemonic, privateKey: privateKey);
|
|
|
|
} else {
|
|
|
|
keysData = await WalletKeysFile.readKeysFile(name, walletInfo.type, password);
|
|
|
|
}
|
|
|
|
|
2023-08-04 17:01:49 +00:00
|
|
|
return EthereumWallet(
|
|
|
|
walletInfo: walletInfo,
|
|
|
|
password: password,
|
2024-08-09 20:15:30 +00:00
|
|
|
mnemonic: keysData.mnemonic,
|
|
|
|
privateKey: keysData.privateKey,
|
2023-08-04 17:01:49 +00:00
|
|
|
initialBalance: balance,
|
CW-551-Refactor-EVM-Chains (#1256)
* feat: Create central package for EVM chains
* chore: Cleanup pubspec and add core evm dependencies
* feat: Replicated core evm chain files, time to start fixing the issues
* feat: Setup evm central package to handle all evm chains
* feat: Link up Polygon and Ethereum wallets to the centra evm package, fix bugs and issues, and optimze for better performance
* feat: Setup and adjust configs to reflect new evm configurations
* Remove unneeded file
* fix: Changes done while re-reviewing entire structure and refactor
* fix: Add evm chain wallet path to imports in configure file
* feat: Adjust implementation of parent class, remove unneeded files, remove windows, linux and mac directories, restructure the evm child classes
* fix: Make EVMChainWallet a central abstract class and adjust accordingly
* fix: Adjust transaction info, restructure EVMWalletChain to be an abstract, adjust external facing interfaces for polygon and ethereum, adjust configuration for ethereum and polygon in configure file
* fix: Testing issues
* fix: Add localization for nft tile and details page texts and add dashes for null responses
* fix: merge conflicts
* Minor fixes for building Monero.com
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
2024-01-30 18:01:48 +00:00
|
|
|
client: EthereumClient(),
|
2023-08-04 17:01:49 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|