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 'dart:async';
|
2024-04-08 22:53:14 +00:00
|
|
|
import 'dart:convert';
|
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 'dart:developer';
|
|
|
|
|
|
|
|
import 'package:cw_core/crypto_currency.dart';
|
2024-05-05 01:44:50 +00:00
|
|
|
import 'package:cw_core/erc20_token.dart';
|
|
|
|
import 'package:cw_core/node.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_model.dart';
|
|
|
|
import 'package:cw_evm/evm_chain_transaction_priority.dart';
|
2024-05-05 01:44:50 +00:00
|
|
|
import 'package:cw_evm/evm_erc20_balance.dart';
|
|
|
|
import 'package:cw_evm/pending_evm_chain_transaction.dart';
|
2024-04-08 22:53:14 +00:00
|
|
|
import 'package:cw_evm/.secrets.g.dart' as secrets;
|
2024-07-20 23:04:22 +00:00
|
|
|
import 'package:flutter/foundation.dart';
|
2024-05-05 01:44:50 +00:00
|
|
|
import 'package:hex/hex.dart' as hex;
|
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:http/http.dart';
|
|
|
|
import 'package:web3dart/web3dart.dart';
|
2024-05-05 01:44:50 +00:00
|
|
|
|
|
|
|
import 'contract/erc20.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
|
|
|
|
|
|
|
abstract class EVMChainClient {
|
|
|
|
final httpClient = Client();
|
|
|
|
Web3Client? _client;
|
|
|
|
|
|
|
|
//! To be overridden by all child classes
|
|
|
|
|
|
|
|
int get chainId;
|
|
|
|
|
|
|
|
Future<List<EVMChainTransactionModel>> fetchTransactions(String address,
|
|
|
|
{String? contractAddress});
|
|
|
|
|
2024-03-29 18:54:59 +00:00
|
|
|
Future<List<EVMChainTransactionModel>> fetchInternalTransactions(String address);
|
|
|
|
|
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
|
|
|
Uint8List prepareSignedTransactionForSending(Uint8List signedTransaction);
|
|
|
|
|
|
|
|
//! Common methods across all child classes
|
|
|
|
|
|
|
|
bool connect(Node node) {
|
|
|
|
try {
|
|
|
|
_client = Web3Client(node.uri.toString(), httpClient);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
} catch (e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void setListeners(EthereumAddress userAddress, Function() onNewTransaction) async {
|
|
|
|
// _client?.pendingTransactions().listen((transactionHash) async {
|
|
|
|
// final transaction = await _client!.getTransactionByHash(transactionHash);
|
|
|
|
//
|
|
|
|
// if (transaction.from.hex == userAddress || transaction.to?.hex == userAddress) {
|
|
|
|
// onNewTransaction();
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<EtherAmount> getBalance(EthereumAddress address) async {
|
|
|
|
try {
|
|
|
|
return await _client!.getBalance(address);
|
|
|
|
} catch (_) {
|
|
|
|
return EtherAmount.zero();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<int> getGasUnitPrice() async {
|
|
|
|
try {
|
|
|
|
final gasPrice = await _client!.getGasPrice();
|
2024-07-20 23:04:22 +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 gasPrice.getInWei.toInt();
|
|
|
|
} catch (_) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-23 00:21:03 +00:00
|
|
|
Future<int?> getGasBaseFee() async {
|
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
|
|
|
try {
|
2024-07-20 23:04:22 +00:00
|
|
|
final blockInfo = await _client!.getBlockInformation(isContainFullObj: false);
|
|
|
|
final baseFee = blockInfo.baseFeePerGas;
|
|
|
|
|
2024-07-23 00:21:03 +00:00
|
|
|
return baseFee?.getInWei.toInt();
|
2024-07-20 23:04:22 +00:00
|
|
|
} catch (_) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<int> getEstimatedGas({
|
|
|
|
String? contractAddress,
|
|
|
|
required EthereumAddress toAddress,
|
|
|
|
required EthereumAddress senderAddress,
|
|
|
|
required EtherAmount value,
|
|
|
|
EtherAmount? gasPrice,
|
|
|
|
// EtherAmount? maxFeePerGas,
|
|
|
|
// EtherAmount? maxPriorityFeePerGas,
|
|
|
|
}) async {
|
|
|
|
try {
|
|
|
|
if (contractAddress == null) {
|
|
|
|
final estimatedGas = await _client!.estimateGas(
|
|
|
|
sender: senderAddress,
|
|
|
|
gasPrice: gasPrice,
|
|
|
|
to: toAddress,
|
|
|
|
value: value,
|
|
|
|
// maxPriorityFeePerGas: maxPriorityFeePerGas,
|
|
|
|
// maxFeePerGas: maxFeePerGas,
|
|
|
|
);
|
|
|
|
|
|
|
|
return estimatedGas.toInt();
|
|
|
|
} else {
|
|
|
|
final contract = DeployedContract(
|
|
|
|
ethereumContractAbi,
|
|
|
|
EthereumAddress.fromHex(contractAddress),
|
|
|
|
);
|
|
|
|
|
2024-07-23 00:21:03 +00:00
|
|
|
final transfer = contract.function('transfer');
|
2024-07-20 23:04:22 +00:00
|
|
|
|
2024-07-23 00:21:03 +00:00
|
|
|
// Estimate gas units
|
|
|
|
final gasEstimate = await _client!.estimateGas(
|
2024-07-20 23:04:22 +00:00
|
|
|
sender: senderAddress,
|
2024-07-23 00:21:03 +00:00
|
|
|
to: EthereumAddress.fromHex(contractAddress),
|
|
|
|
data: transfer.encodeCall([
|
2024-07-20 23:04:22 +00:00
|
|
|
toAddress,
|
|
|
|
value.getInWei,
|
|
|
|
]),
|
|
|
|
);
|
2024-07-23 00:21:03 +00:00
|
|
|
|
|
|
|
return gasEstimate.toInt();
|
2024-07-20 23:04:22 +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
|
|
|
} catch (_) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<PendingEVMChainTransaction> signTransaction({
|
2024-05-05 01:44:50 +00:00
|
|
|
required Credentials privateKey,
|
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
|
|
|
required String toAddress,
|
2024-03-29 18:55:29 +00:00
|
|
|
required BigInt amount,
|
2024-07-20 23:04:22 +00:00
|
|
|
required BigInt gas,
|
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
|
|
|
required EVMChainTransactionPriority priority,
|
|
|
|
required CryptoCurrency currency,
|
|
|
|
required int exponent,
|
|
|
|
String? contractAddress,
|
2024-03-28 12:41:11 +00:00
|
|
|
String? data,
|
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
|
|
|
}) async {
|
|
|
|
assert(currency == CryptoCurrency.eth ||
|
|
|
|
currency == CryptoCurrency.maticpoly ||
|
|
|
|
contractAddress != null);
|
|
|
|
|
2024-05-05 01:44:50 +00:00
|
|
|
bool isNativeToken = currency == CryptoCurrency.eth || currency == CryptoCurrency.maticpoly;
|
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
|
|
|
|
|
|
|
final Transaction transaction = createTransaction(
|
|
|
|
from: privateKey.address,
|
|
|
|
to: EthereumAddress.fromHex(toAddress),
|
|
|
|
maxPriorityFeePerGas: EtherAmount.fromInt(EtherUnit.gwei, priority.tip),
|
2024-05-05 01:44:50 +00:00
|
|
|
amount: isNativeToken ? EtherAmount.inWei(amount) : EtherAmount.zero(),
|
2024-03-28 12:41:11 +00:00
|
|
|
data: data != null ? hexToBytes(data) : null,
|
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
|
|
|
);
|
|
|
|
|
2024-05-05 01:44:50 +00:00
|
|
|
Uint8List signedTransaction;
|
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
|
|
|
|
|
|
|
final Function _sendTransaction;
|
|
|
|
|
2024-05-05 01:44:50 +00:00
|
|
|
if (isNativeToken) {
|
|
|
|
signedTransaction = await _client!.signTransaction(privateKey, transaction, chainId: chainId);
|
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
|
|
|
} else {
|
|
|
|
final erc20 = ERC20(
|
|
|
|
client: _client!,
|
|
|
|
address: EthereumAddress.fromHex(contractAddress!),
|
|
|
|
chainId: chainId,
|
|
|
|
);
|
|
|
|
|
2024-05-05 01:44:50 +00:00
|
|
|
signedTransaction = await erc20.transfer(
|
|
|
|
EthereumAddress.fromHex(toAddress),
|
|
|
|
amount,
|
|
|
|
credentials: privateKey,
|
|
|
|
transaction: transaction,
|
|
|
|
);
|
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
|
|
|
}
|
|
|
|
|
2024-05-05 01:44:50 +00:00
|
|
|
_sendTransaction = () async => await sendTransaction(signedTransaction);
|
|
|
|
|
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 PendingEVMChainTransaction(
|
|
|
|
signedTransaction: signedTransaction,
|
2024-03-29 18:55:29 +00:00
|
|
|
amount: amount.toString(),
|
2024-07-20 23:04:22 +00:00
|
|
|
fee: gas,
|
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
|
|
|
sendTransaction: _sendTransaction,
|
|
|
|
exponent: exponent,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Transaction createTransaction({
|
|
|
|
required EthereumAddress from,
|
|
|
|
required EthereumAddress to,
|
|
|
|
required EtherAmount amount,
|
|
|
|
EtherAmount? maxPriorityFeePerGas,
|
2024-03-28 12:41:11 +00:00
|
|
|
Uint8List? data,
|
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 Transaction(
|
|
|
|
from: from,
|
|
|
|
to: to,
|
|
|
|
maxPriorityFeePerGas: maxPriorityFeePerGas,
|
|
|
|
value: amount,
|
2024-03-28 12:41:11 +00:00
|
|
|
data: data,
|
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
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-05-05 01:44:50 +00:00
|
|
|
Future<String> sendTransaction(Uint8List signedTransaction) async {
|
|
|
|
return await _client!.sendRawTransaction(prepareSignedTransactionForSending(signedTransaction));
|
|
|
|
}
|
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 getTransactionDetails(String transactionHash) async {
|
|
|
|
// Wait for the transaction receipt to become available
|
|
|
|
TransactionReceipt? receipt;
|
|
|
|
while (receipt == null) {
|
|
|
|
receipt = await _client!.getTransactionReceipt(transactionHash);
|
|
|
|
await Future.delayed(const Duration(seconds: 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Print the receipt information
|
|
|
|
log('Transaction Hash: ${receipt.transactionHash}');
|
|
|
|
log('Block Hash: ${receipt.blockHash}');
|
|
|
|
log('Block Number: ${receipt.blockNumber}');
|
|
|
|
log('Gas Used: ${receipt.gasUsed}');
|
|
|
|
|
|
|
|
/*
|
|
|
|
Transaction Hash: [112, 244, 4, 238, 89, 199, 171, 191, 210, 236, 110, 42, 185, 202, 220, 21, 27, 132, 123, 221, 137, 90, 77, 13, 23, 43, 12, 230, 93, 63, 221, 116]
|
|
|
|
I/flutter ( 4474): Block Hash: [149, 44, 250, 119, 111, 104, 82, 98, 17, 89, 30, 190, 25, 44, 218, 118, 127, 189, 241, 35, 213, 106, 25, 95, 195, 37, 55, 131, 185, 180, 246, 200]
|
|
|
|
I/flutter ( 4474): Block Number: 17120242
|
|
|
|
I/flutter ( 4474): Gas Used: 21000
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Wait for the transaction receipt to become available
|
|
|
|
TransactionInformation? transactionInformation;
|
|
|
|
while (transactionInformation == null) {
|
|
|
|
log("********************************");
|
|
|
|
transactionInformation = await _client!.getTransactionByHash(transactionHash);
|
|
|
|
await Future.delayed(const Duration(seconds: 1));
|
|
|
|
}
|
|
|
|
// Print the receipt information
|
|
|
|
log('Transaction Hash: ${transactionInformation.hash}');
|
|
|
|
log('Block Hash: ${transactionInformation.blockHash}');
|
|
|
|
log('Block Number: ${transactionInformation.blockNumber}');
|
|
|
|
log('Gas Used: ${transactionInformation.gas}');
|
|
|
|
|
|
|
|
/*
|
|
|
|
Transaction Hash: 0x70f404ee59c7abbfd2ec6e2ab9cadc151b847bdd895a4d0d172b0ce65d3fdd74
|
|
|
|
I/flutter ( 4474): Block Hash: 0x952cfa776f68526211591ebe192cda767fbdf123d56a195fc3253783b9b4f6c8
|
|
|
|
I/flutter ( 4474): Block Number: 17120242
|
|
|
|
I/flutter ( 4474): Gas Used: 53000
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<EVMChainERC20Balance> fetchERC20Balances(
|
|
|
|
EthereumAddress userAddress, String contractAddress) async {
|
|
|
|
final erc20 = ERC20(address: EthereumAddress.fromHex(contractAddress), client: _client!);
|
|
|
|
final balance = await erc20.balanceOf(userAddress);
|
|
|
|
|
|
|
|
int exponent = (await erc20.decimals()).toInt();
|
|
|
|
|
|
|
|
return EVMChainERC20Balance(balance, exponent: exponent);
|
|
|
|
}
|
|
|
|
|
2024-04-08 22:53:14 +00:00
|
|
|
Future<Erc20Token?> getErc20Token(String contractAddress, String chainName) async {
|
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
|
|
|
try {
|
2024-04-08 22:53:14 +00:00
|
|
|
final uri = Uri.https(
|
|
|
|
'deep-index.moralis.io',
|
|
|
|
'/api/v2.2/erc20/metadata',
|
|
|
|
{
|
|
|
|
"chain": chainName,
|
|
|
|
"addresses": contractAddress,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
|
|
|
final response = await httpClient.get(
|
|
|
|
uri,
|
|
|
|
headers: {
|
|
|
|
"Accept": "application/json",
|
|
|
|
"X-API-Key": secrets.moralisApiKey,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
|
|
|
final decodedResponse = jsonDecode(response.body)[0] as Map<String, dynamic>;
|
|
|
|
|
2024-04-25 01:14:53 +00:00
|
|
|
final symbol = (decodedResponse['symbol'] ?? '') as String;
|
|
|
|
String filteredSymbol = symbol.replaceFirst(RegExp('^\\\$'), '');
|
|
|
|
|
2024-04-08 22:53:14 +00:00
|
|
|
final name = decodedResponse['name'] ?? '';
|
|
|
|
final decimal = decodedResponse['decimals'] ?? '0';
|
|
|
|
final iconPath = decodedResponse['logo'] ?? '';
|
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 Erc20Token(
|
|
|
|
name: name,
|
2024-04-25 01:14:53 +00:00
|
|
|
symbol: filteredSymbol,
|
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
|
|
|
contractAddress: contractAddress,
|
2024-04-08 22:53:14 +00:00
|
|
|
decimal: int.tryParse(decimal) ?? 0,
|
|
|
|
iconPath: iconPath,
|
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
|
|
|
);
|
|
|
|
} catch (e) {
|
2024-04-08 22:53:14 +00:00
|
|
|
try {
|
|
|
|
final erc20 = ERC20(address: EthereumAddress.fromHex(contractAddress), client: _client!);
|
|
|
|
final name = await erc20.name();
|
|
|
|
final symbol = await erc20.symbol();
|
|
|
|
final decimal = await erc20.decimals();
|
|
|
|
|
|
|
|
return Erc20Token(
|
|
|
|
name: name,
|
|
|
|
symbol: symbol,
|
|
|
|
contractAddress: contractAddress,
|
|
|
|
decimal: decimal.toInt(),
|
|
|
|
);
|
|
|
|
} catch (_) {}
|
|
|
|
|
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 null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-28 12:41:11 +00:00
|
|
|
Uint8List hexToBytes(String hexString) {
|
2024-04-08 22:53:14 +00:00
|
|
|
return Uint8List.fromList(
|
|
|
|
hex.HEX.decode(hexString.startsWith('0x') ? hexString.substring(2) : hexString));
|
2024-03-28 12:41:11 +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
|
|
|
void stop() {
|
|
|
|
_client?.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
Web3Client? getWeb3Client() {
|
|
|
|
return _client;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Future<int> _getDecimalPlacesForContract(DeployedContract contract) async {
|
|
|
|
// final String abi = await rootBundle.loadString("assets/abi_json/erc20_abi.json");
|
|
|
|
// final contractAbi = ContractAbi.fromJson(abi, "ERC20");
|
|
|
|
//
|
|
|
|
// final contract = DeployedContract(
|
|
|
|
// contractAbi,
|
|
|
|
// EthereumAddress.fromHex(_erc20Currencies[erc20Currency]!),
|
|
|
|
// );
|
|
|
|
// final decimalsFunction = contract.function('decimals');
|
|
|
|
// final decimals = await _client!.call(
|
|
|
|
// contract: contract,
|
|
|
|
// function: decimalsFunction,
|
|
|
|
// params: [],
|
|
|
|
// );
|
|
|
|
//
|
|
|
|
// int exponent = int.parse(decimals.first.toString());
|
|
|
|
// return exponent;
|
|
|
|
// }
|
|
|
|
}
|