diff --git a/cw_ethereum/lib/ethereum_client.dart b/cw_ethereum/lib/ethereum_client.dart index cb09f8f89..532eb2b99 100644 --- a/cw_ethereum/lib/ethereum_client.dart +++ b/cw_ethereum/lib/ethereum_client.dart @@ -6,7 +6,6 @@ import 'package:cw_ethereum/erc20_balance.dart'; import 'package:cw_core/erc20_token.dart'; import 'package:cw_ethereum/ethereum_transaction_model.dart'; import 'package:cw_ethereum/pending_ethereum_transaction.dart'; -import 'package:ens_dart/ens_dart.dart'; import 'package:flutter/services.dart'; import 'package:http/http.dart'; import 'package:web3dart/web3dart.dart'; diff --git a/lib/di.dart b/lib/di.dart index 97dd392c5..e069a966b 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -883,7 +883,7 @@ Future setup({ getIt.registerFactory(() => YatService()); getIt.registerFactory(() => AddressResolver( - yatService: getIt.get(), walletType: getIt.get().wallet!.type)); + yatService: getIt.get(), wallet: getIt.get().wallet!)); getIt.registerFactoryParam( (QrViewData viewData, _) => FullscreenQRPage(qrViewData: viewData)); diff --git a/lib/entities/ens_record.dart b/lib/entities/ens_record.dart index 28a129f1b..8cf62d79b 100644 --- a/lib/entities/ens_record.dart +++ b/lib/entities/ens_record.dart @@ -10,7 +10,7 @@ class EnsRecord { Web3Client? _client; if (wallet != null && wallet.type == WalletType.ethereum) { - _client = ethereum!.getWeb3Client(wallet) as Web3Client?; + _client = ethereum!.getWeb3Client(wallet); } if (_client == null) { diff --git a/lib/entities/parse_address_from_domain.dart b/lib/entities/parse_address_from_domain.dart index dcaee5815..515b9a2df 100644 --- a/lib/entities/parse_address_from_domain.dart +++ b/lib/entities/parse_address_from_domain.dart @@ -1,13 +1,10 @@ import 'package:cake_wallet/core/address_validator.dart'; import 'package:cake_wallet/core/yat_service.dart'; -import 'package:cake_wallet/di.dart'; import 'package:cake_wallet/entities/ens_record.dart'; import 'package:cake_wallet/entities/openalias_record.dart'; import 'package:cake_wallet/entities/parsed_address.dart'; import 'package:cake_wallet/entities/unstoppable_domain_address.dart'; import 'package:cake_wallet/entities/emoji_string_extension.dart'; -import 'package:cake_wallet/ethereum/ethereum.dart'; -import 'package:cake_wallet/store/app_store.dart'; import 'package:cake_wallet/twitter/twitter_api.dart'; import 'package:cw_core/crypto_currency.dart'; import 'package:cw_core/wallet_base.dart'; @@ -15,10 +12,11 @@ import 'package:cw_core/wallet_type.dart'; import 'package:cake_wallet/entities/fio_address_provider.dart'; class AddressResolver { - AddressResolver({required this.yatService, required this.walletType}); + AddressResolver({required this.yatService, required this.wallet}) : walletType = wallet.type; final YatService yatService; final WalletType walletType; + final WalletBase wallet; static const unstoppableDomains = [ 'crypto', @@ -102,7 +100,6 @@ class AddressResolver { } if (text.endsWith(".eth")) { - WalletBase? wallet = getIt.get().wallet!; final address = await EnsRecord.fetchEnsAddress(text, wallet: wallet); if (address.isNotEmpty && address != "0x0000000000000000000000000000000000000000") { return ParsedAddress.fetchEnsAddress(name: text, address: address); diff --git a/lib/ethereum/cw_ethereum.dart b/lib/ethereum/cw_ethereum.dart index eab6c26d3..74a298bf9 100644 --- a/lib/ethereum/cw_ethereum.dart +++ b/lib/ethereum/cw_ethereum.dart @@ -133,7 +133,7 @@ class CWEthereum extends Ethereum { } @override - dynamic getWeb3Client(WalletBase wallet) { + Web3Client? getWeb3Client(WalletBase wallet) { return (wallet as EthereumWallet).getWeb3Client(); } } diff --git a/tool/configure.dart b/tool/configure.dart index 1f9ddf1c6..e3a2efe35 100644 --- a/tool/configure.dart +++ b/tool/configure.dart @@ -467,7 +467,6 @@ Future generateEthereum(bool hasImplementation) async { final outputFile = File(ethereumOutputPath); const ethereumCommonHeaders = """ import 'package:cake_wallet/view_model/send/output.dart'; -import 'package:cw_core/crypto_amount_format.dart'; import 'package:cw_core/crypto_currency.dart'; import 'package:cw_core/erc20_token.dart'; import 'package:cw_core/output_info.dart'; @@ -478,6 +477,7 @@ import 'package:cw_core/wallet_credentials.dart'; import 'package:cw_core/wallet_info.dart'; import 'package:cw_core/wallet_service.dart'; import 'package:hive/hive.dart'; +import 'package:web3dart/web3dart.dart'; """; const ethereumCWHeaders = """ import 'package:cw_ethereum/ethereum_formatter.dart'; @@ -525,7 +525,7 @@ abstract class Ethereum { CryptoCurrency assetOfTransaction(WalletBase wallet, TransactionInfo transaction); void updateEtherscanUsageState(WalletBase wallet, bool isEnabled); - dynamic getWeb3Client(WalletBase wallet); + Web3Client? getWeb3Client(WalletBase wallet); } """;