mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-24 20:49:28 +00:00
b3d579c24a
* chore: Initial setup for polygon package * feat: Add polygon node urls * feat: Add Polygon(MATIC) wallet WIP * feat: Add Polygon(MATIC) wallet WIP * feat: Add Polygon MATIC wallet [skip ci] * fix: Issue with create/restore wallet for polygon * feat: Add erc20 tokens for polygon * feat: Adding Polygon MATIC Wallet * fix: Add build command for polygon to workflow file to fix failing action * fix: Switch evm to not display additional balance * chore: Sync with remote * fix: Revert change to inject app script * feat: Add polygon erc20 tokens * feat: Increase migration version * fix: Restore from QR address validator fix * fix: Adjust wallet connect connection flow to adapt to wallet type * fix: Make wallet fetch nfts based on the current wallet type * fix: Make wallet fetch nfts based on the current wallet type * fix: Try fetching transactions with moralis * fix: Requested review changes * fix: Error creating new wallet * fix: Revert script * fix: Exclude spam NFTs from nft listing API response * Update default_erc20_tokens.dart * replace matic with matic poly * Add polygon wallet scheme to app links * style: reformat default_settings_migration.dart * minor enhancement * fix using different wallet function for setting the transaction priorities * fix: Add chain to calls * Add USDC.e to initial coins * Add other default polygon node * Use Polygon scan some UI fixes * Add polygon scan api key to secrets generation code --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
52 lines
1.6 KiB
Dart
52 lines
1.6 KiB
Dart
import 'package:cake_wallet/ethereum/ethereum.dart';
|
|
import 'package:cake_wallet/polygon/polygon.dart';
|
|
import 'package:cw_core/wallet_base.dart';
|
|
import 'package:cw_core/wallet_type.dart';
|
|
import 'package:ens_dart/ens_dart.dart';
|
|
import 'package:http/http.dart';
|
|
import 'package:web3dart/web3dart.dart';
|
|
|
|
class EnsRecord {
|
|
static Future<String> fetchEnsAddress(String name, {WalletBase? wallet}) async {
|
|
Web3Client? _client;
|
|
|
|
if (wallet != null && wallet.type == WalletType.ethereum) {
|
|
_client = ethereum!.getWeb3Client(wallet);
|
|
}
|
|
|
|
if (wallet != null && wallet.type == WalletType.polygon) {
|
|
_client = polygon!.getWeb3Client(wallet);
|
|
}
|
|
|
|
if (_client == null) {
|
|
_client = Web3Client("https://ethereum.publicnode.com", Client());
|
|
}
|
|
|
|
try {
|
|
final ens = Ens(client: _client);
|
|
|
|
if (wallet != null) {
|
|
switch (wallet.type) {
|
|
case WalletType.monero:
|
|
return await ens.withName(name).getCoinAddress(CoinType.XMR);
|
|
case WalletType.bitcoin:
|
|
return await ens.withName(name).getCoinAddress(CoinType.BTC);
|
|
case WalletType.litecoin:
|
|
return await ens.withName(name).getCoinAddress(CoinType.LTC);
|
|
case WalletType.haven:
|
|
return await ens.withName(name).getCoinAddress(CoinType.XHV);
|
|
case WalletType.ethereum:
|
|
case WalletType.polygon:
|
|
default:
|
|
return (await ens.withName(name).getAddress()).hex;
|
|
}
|
|
}
|
|
|
|
final addr = await ens.withName(name).getAddress();
|
|
return addr.hex;
|
|
} catch (e) {
|
|
print(e);
|
|
return "";
|
|
}
|
|
}
|
|
}
|