mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-02 12:14:09 +01: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>
This commit is contained in:
co-authored by
OmarHatem
parent
b92ccb5c0b
commit
7410daacff
+37
-19
@@ -525,19 +525,24 @@ import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:cw_core/wallet_credentials.dart';
|
||||
import 'package:cw_core/wallet_info.dart';
|
||||
import 'package:cw_core/wallet_service.dart';
|
||||
|
||||
""";
|
||||
const ethereumCWHeaders = """
|
||||
import 'package:cw_evm/evm_chain_formatter.dart';
|
||||
import 'package:cw_evm/evm_chain_mnemonics.dart';
|
||||
import 'package:cw_evm/evm_chain_transaction_credentials.dart';
|
||||
import 'package:cw_evm/evm_chain_transaction_info.dart';
|
||||
import 'package:cw_evm/evm_chain_transaction_priority.dart';
|
||||
import 'package:cw_evm/evm_chain_wallet_creation_credentials.dart';
|
||||
|
||||
import 'package:cw_ethereum/ethereum_client.dart';
|
||||
import 'package:cw_ethereum/ethereum_wallet.dart';
|
||||
import 'package:cw_ethereum/ethereum_wallet_service.dart';
|
||||
|
||||
import 'package:eth_sig_util/util/utils.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:web3dart/web3dart.dart';
|
||||
""";
|
||||
const ethereumCWHeaders = """
|
||||
import 'package:cw_ethereum/ethereum_formatter.dart';
|
||||
import 'package:cw_ethereum/ethereum_mnemonics.dart';
|
||||
import 'package:cw_ethereum/ethereum_transaction_credentials.dart';
|
||||
import 'package:cw_ethereum/ethereum_transaction_info.dart';
|
||||
import 'package:cw_ethereum/ethereum_wallet.dart';
|
||||
import 'package:cw_ethereum/ethereum_wallet_creation_credentials.dart';
|
||||
import 'package:cw_ethereum/ethereum_wallet_service.dart';
|
||||
import 'package:cw_ethereum/ethereum_transaction_priority.dart';
|
||||
|
||||
""";
|
||||
const ethereumCwPart = "part 'cw_ethereum.dart';";
|
||||
const ethereumContent = """
|
||||
@@ -612,19 +617,24 @@ import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:cw_core/wallet_credentials.dart';
|
||||
import 'package:cw_core/wallet_info.dart';
|
||||
import 'package:cw_core/wallet_service.dart';
|
||||
import 'package:eth_sig_util/util/utils.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:web3dart/web3dart.dart';
|
||||
|
||||
""";
|
||||
const polygonCWHeaders = """
|
||||
import 'package:cw_polygon/polygon_formatter.dart';
|
||||
import 'package:cw_polygon/polygon_transaction_credentials.dart';
|
||||
import 'package:cw_polygon/polygon_transaction_info.dart';
|
||||
import 'package:cw_evm/evm_chain_formatter.dart';
|
||||
import 'package:cw_evm/evm_chain_mnemonics.dart';
|
||||
import 'package:cw_evm/evm_chain_transaction_info.dart';
|
||||
import 'package:cw_evm/evm_chain_transaction_priority.dart';
|
||||
import 'package:cw_evm/evm_chain_transaction_credentials.dart';
|
||||
import 'package:cw_evm/evm_chain_wallet_creation_credentials.dart';
|
||||
|
||||
import 'package:cw_polygon/polygon_client.dart';
|
||||
import 'package:cw_polygon/polygon_wallet.dart';
|
||||
import 'package:cw_polygon/polygon_wallet_creation_credentials.dart';
|
||||
import 'package:cw_polygon/polygon_wallet_service.dart';
|
||||
import 'package:cw_polygon/polygon_transaction_priority.dart';
|
||||
import 'package:cw_ethereum/ethereum_mnemonics.dart';
|
||||
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:web3dart/web3dart.dart';
|
||||
import 'package:eth_sig_util/util/utils.dart';
|
||||
|
||||
""";
|
||||
const polygonCwPart = "part 'cw_polygon.dart';";
|
||||
const polygonContent = """
|
||||
@@ -924,6 +934,10 @@ Future<void> generatePubspec(
|
||||
cw_polygon:
|
||||
path: ./cw_polygon
|
||||
""";
|
||||
const cwEVM = """
|
||||
cw_evm:
|
||||
path: ./cw_evm
|
||||
""";
|
||||
final inputFile = File(pubspecOutputPath);
|
||||
final inputText = await inputFile.readAsString();
|
||||
final inputLines = inputText.split('\n');
|
||||
@@ -964,6 +978,10 @@ Future<void> generatePubspec(
|
||||
output += '\n$cwHaven';
|
||||
}
|
||||
|
||||
if (hasEthereum || hasPolygon) {
|
||||
output += '\n$cwEVM';
|
||||
}
|
||||
|
||||
final outputLines = output.split('\n');
|
||||
inputLines.insertAll(dependenciesIndex + 1, outputLines);
|
||||
final outputContent = inputLines.join('\n');
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'utils/secret_key.dart';
|
||||
import 'utils/utils.dart';
|
||||
|
||||
const configPath = 'tool/.secrets-config.json';
|
||||
const ethereumConfigPath = 'tool/.ethereum-secrets-config.json';
|
||||
const evmChainsConfigPath = 'tool/.evm-secrets-config.json';
|
||||
|
||||
Future<void> main(List<String> args) async => generateSecretsConfig(args);
|
||||
|
||||
@@ -17,7 +17,7 @@ Future<void> generateSecretsConfig(List<String> args) async {
|
||||
});
|
||||
|
||||
final configFile = File(configPath);
|
||||
final ethereumConfigFile = File(ethereumConfigPath);
|
||||
final evmChainsConfigFile = File(evmChainsConfigPath);
|
||||
final secrets = <String, dynamic>{};
|
||||
|
||||
secrets.addAll(extraInfo);
|
||||
@@ -49,7 +49,7 @@ Future<void> generateSecretsConfig(List<String> args) async {
|
||||
await configFile.writeAsString(secretsJson);
|
||||
|
||||
secrets.clear();
|
||||
SecretKey.ethereumSecrets.forEach((sec) {
|
||||
SecretKey.evmChainsSecrets.forEach((sec) {
|
||||
if (secrets[sec.name] != null) {
|
||||
return;
|
||||
}
|
||||
@@ -59,5 +59,5 @@ Future<void> generateSecretsConfig(List<String> args) async {
|
||||
|
||||
secretsJson = JsonEncoder.withIndent(' ').convert(secrets);
|
||||
|
||||
await ethereumConfigFile.writeAsString(secretsJson);
|
||||
await evmChainsConfigFile.writeAsString(secretsJson);
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ import 'utils/utils.dart';
|
||||
const configPath = 'tool/.secrets-config.json';
|
||||
const outputPath = 'lib/.secrets.g.dart';
|
||||
|
||||
const ethereumConfigPath = 'tool/.ethereum-secrets-config.json';
|
||||
const ethereumOutputPath = 'cw_ethereum/lib/.secrets.g.dart';
|
||||
const evmChainsConfigPath = 'tool/.evm-secrets-config.json';
|
||||
const evmChainsOutputPath = 'cw_evm/lib/.secrets.g.dart';
|
||||
|
||||
Future<void> main(List<String> args) async => importSecretsConfig();
|
||||
|
||||
@@ -15,11 +15,11 @@ Future<void> importSecretsConfig() async {
|
||||
final input = json.decode(File(configPath).readAsStringSync()) as Map<String, dynamic>;
|
||||
final output = input.keys.fold('', (String acc, String val) => acc + generateConst(val, input));
|
||||
|
||||
final ethereumOutputFile = File(ethereumOutputPath);
|
||||
final ethereumInput =
|
||||
json.decode(File(ethereumConfigPath).readAsStringSync()) as Map<String, dynamic>;
|
||||
final ethereumOutput = ethereumInput.keys
|
||||
.fold('', (String acc, String val) => acc + generateConst(val, ethereumInput));
|
||||
final evmChainsOutputFile = File(evmChainsOutputPath);
|
||||
final evmChainsInput =
|
||||
json.decode(File(evmChainsConfigPath).readAsStringSync()) as Map<String, dynamic>;
|
||||
final evmChainsOutput = evmChainsInput.keys
|
||||
.fold('', (String acc, String val) => acc + generateConst(val, evmChainsInput));
|
||||
|
||||
if (outputFile.existsSync()) {
|
||||
await outputFile.delete();
|
||||
@@ -27,9 +27,9 @@ Future<void> importSecretsConfig() async {
|
||||
|
||||
await outputFile.writeAsString(output);
|
||||
|
||||
if (ethereumOutputFile.existsSync()) {
|
||||
await ethereumOutputFile.delete();
|
||||
if (evmChainsOutputFile.existsSync()) {
|
||||
await evmChainsOutputFile.delete();
|
||||
}
|
||||
|
||||
await ethereumOutputFile.writeAsString(ethereumOutput);
|
||||
await evmChainsOutputFile.writeAsString(evmChainsOutput);
|
||||
}
|
||||
|
||||
@@ -36,10 +36,10 @@ class SecretKey {
|
||||
SecretKey('robinhoodApplicationId', () => ''),
|
||||
SecretKey('robinhoodCIdApiSecret', () => ''),
|
||||
SecretKey('walletConnectProjectId', () => ''),
|
||||
SecretKey('moralisApiKey', () => '')
|
||||
SecretKey('moralisApiKey', () => ''),
|
||||
];
|
||||
|
||||
static final ethereumSecrets = [
|
||||
static final evmChainsSecrets = [
|
||||
SecretKey('etherScanApiKey', () => ''),
|
||||
SecretKey('polygonScanApiKey', () => ''),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user