mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-11-13 09:04:09 +01:00
Cw 78 ethereum (#862)
* Add initial flow for ethereum * Add initial create Eth wallet flow * Complete Ethereum wallet creation flow * Fix web3dart versioning issue * Add primary receive address extracted from private key * Implement open wallet functionality * Implement restore wallet from seed functionality * Fixate web3dart version as higher versions cause some issues * Add Initial Transaction priorities for eth Add estimated gas price * Rename priority value to tip * Re-order wallet types * Change ethereum node Fix connection issues * Fix estimating gas for priority * Add case for ethereum to fetch it's seeds * Add case for ethereum to request node * Fix Exchange screen initial pairs * Add initial send transaction flow * Add missing configure for ethereum class * Add Eth address initial setup * Fix Private key for Ethereum wallets * Change sign/send transaction flow * - Fix Conflicts with main - Remove unused function from Haven configure.dart * Add build command for ethereum package * Add missing Node list file to pubspec * - Fix balance display - Fix parsing of Ethereum amount - Add more Ethereum Nodes * - Fix extracting Ethereum Private key from seeds - Integrate signing/sending transaction with the send view model * - Update and Fix Conflicts with main * Add Balances for ERC20 tokens * Fix conflicts with main * Add erc20 abi json * Add send erc20 tokens initial function * add missing getHeightByDate in Haven * Allow contacts and wallets from the same tag * Add Shiba Inu icon * Add send ERC-20 tokens initial flow * Add missing import in generated file * Add initial approach for transaction sending for ERC-20 tokens * Refactor signing/sending transactions * Add initial flow for transactions subscription * Refactor signing/sending transactions * Add home settings icon * Fix conflicts with main * Initial flow for home settings * Add logic flow for adding erc20 tokens * Fix initial UI * Finalize UI for Tokens * Integrate UI with Ethereum flow * Add "Enable/Disable" feature for ERC20 tokens * Add initial Erc20 tokens * Add Sorting and Pin Native Token features * Fix price sorting * Sort tokens list as well when Sort criteria changes * - Improve sorting balances flow - Add initial add token from search bar flow * Fix Accounts Popup UI * Fix Pin native token * Fix Enabling/Disabling tokens Fix sorting by fiat once app is opened Improve token availability mechanism * Fix deleting token Fix renaming tokens * Fix issue with search * Add more tokens * - Fix scroll issue - Add ERC20 tokens placeholder image in picker * - Separate and organize default erc20 tokens - Fix scrolling - Add token placeholder images in picker - Sort disabled tokens alphabetically * Change BNB token initial availability * Fix Conflicts with main * Fix Conflicts with main * Add Verse ERC20 token to the initial tokens list * Add rename wallet to Ethereum * Integrate EtherScan API for fetching address transactions Generate Ethereum specific secrets in Ethereum package * Adjust transactions fiat price for ERC20 tokens * Free Up GitHub Actions Ubuntu Runner Disk Space * Free Up GitHub Actions Ubuntu Runner Disk space (trial 2) * Fix Transaction Fee display * Save transaction history * Enhance loading time for erc20 tokens transactions * Minor Fixes and Enhancements * Fix sending erc20 fix block explorer issue * Fix int overflow * Fix transaction amount conversions * Minor: `slow` -> `Slow` * Update build guide * Fix fetching fiat rate taking a lot of time by only fetching enabled tokens only and making the API calls in parallel not sequential * Update transactions on a periodic basis * For fee, use ETH spot price, not ERC-20 spot price * Add Etherscan History privacy option to enable/disable Etherscan API * Show estimated fee amounts in the send screen * fix send fiat fields parsing issue * Fix transactions estimated fee less than actual fee * handle balance sorting when balance is disabled Handle empty transactions list * Fix Delete Ethereum wallet Fix balance < 0.01 * Fix Decimal place for Ethereum amount Fix sending amount issue * Change words count * Remove balance hint and Full balance row from Ethereum wallets * support changing the asset type in send templates * Fix Templates for ERC tokens issues * Fix conflicts in send templates * Disable batch sending in Ethereum * Fix Fee calculation with different priorities * Fix Conflicts with main * Add offline error to ignored exceptions --------- Co-authored-by: Justin Ehrenhofer <justin.ehrenhofer@gmail.com>
This commit is contained in:
co-authored by
Justin Ehrenhofer
parent
4120394121
commit
3ce4000dcf
@@ -11,6 +11,8 @@ CryptoCurrency currencyForWalletType(WalletType type) {
|
||||
return CryptoCurrency.ltc;
|
||||
case WalletType.haven:
|
||||
return CryptoCurrency.xhv;
|
||||
case WalletType.ethereum:
|
||||
return CryptoCurrency.eth;
|
||||
default:
|
||||
throw Exception('Unexpected wallet type: ${type.toString()} for CryptoCurrency currencyForWalletType');
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
part 'erc20_token.g.dart';
|
||||
|
||||
@HiveType(typeId: Erc20Token.typeId)
|
||||
class Erc20Token extends CryptoCurrency with HiveObjectMixin {
|
||||
@HiveField(0)
|
||||
final String name;
|
||||
@HiveField(1)
|
||||
final String symbol;
|
||||
@HiveField(2)
|
||||
final String contractAddress;
|
||||
@HiveField(3)
|
||||
final int decimal;
|
||||
@HiveField(4, defaultValue: true)
|
||||
bool _enabled;
|
||||
@HiveField(5)
|
||||
final String? iconPath;
|
||||
|
||||
bool get enabled => _enabled;
|
||||
|
||||
set enabled(bool value) => _enabled = value;
|
||||
|
||||
Erc20Token({
|
||||
required this.name,
|
||||
required this.symbol,
|
||||
required this.contractAddress,
|
||||
required this.decimal,
|
||||
bool enabled = true,
|
||||
this.iconPath,
|
||||
}) : _enabled = enabled,
|
||||
super(
|
||||
name: symbol.toLowerCase(),
|
||||
title: symbol.toUpperCase(),
|
||||
fullName: name,
|
||||
tag: "ETH",
|
||||
iconPath: iconPath,
|
||||
);
|
||||
|
||||
Erc20Token.copyWith(Erc20Token other, String? icon)
|
||||
: this.name = other.name,
|
||||
this.symbol = other.symbol,
|
||||
this.contractAddress = other.contractAddress,
|
||||
this.decimal = other.decimal,
|
||||
this._enabled = other.enabled,
|
||||
this.iconPath = icon,
|
||||
super(
|
||||
name: other.name,
|
||||
title: other.symbol.toUpperCase(),
|
||||
fullName: other.name,
|
||||
tag: "ETH",
|
||||
iconPath: icon,
|
||||
);
|
||||
|
||||
static const typeId = 12;
|
||||
static const boxName = 'Erc20Tokens';
|
||||
|
||||
@override
|
||||
bool operator ==(other) => other is Erc20Token && other.contractAddress == contractAddress;
|
||||
|
||||
@override
|
||||
int get hashCode => contractAddress.hashCode;
|
||||
}
|
||||
+18
-1
@@ -75,6 +75,8 @@ class Node extends HiveObject with Keyable {
|
||||
return createUriFromElectrumAddress(uriRaw);
|
||||
case WalletType.haven:
|
||||
return Uri.http(uriRaw, '');
|
||||
case WalletType.ethereum:
|
||||
return Uri.https(uriRaw, '');
|
||||
default:
|
||||
throw Exception('Unexpected type ${type.toString()} for Node uri');
|
||||
}
|
||||
@@ -124,6 +126,8 @@ class Node extends HiveObject with Keyable {
|
||||
return requestElectrumServer();
|
||||
case WalletType.haven:
|
||||
return requestMoneroNode();
|
||||
case WalletType.ethereum:
|
||||
return requestElectrumServer();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -166,7 +170,7 @@ class Node extends HiveObject with Keyable {
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> requestNodeWithProxy(String proxy) async {
|
||||
|
||||
@@ -193,4 +197,17 @@ class Node extends HiveObject with Keyable {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> requestEthereumServer() async {
|
||||
try {
|
||||
final response = await http.get(
|
||||
uri,
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
);
|
||||
|
||||
return response.statusCode >= 200 && response.statusCode < 300;
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,4 +75,6 @@ abstract class WalletBase<
|
||||
Future<void>? updateBalance();
|
||||
|
||||
void setExceptionHandler(void Function(FlutterErrorDetails) onError) => null;
|
||||
|
||||
Future<void> renameWalletFiles(String newWalletName);
|
||||
}
|
||||
|
||||
@@ -18,5 +18,5 @@ abstract class WalletService<N extends WalletCredentials,
|
||||
|
||||
Future<void> remove(String wallet);
|
||||
|
||||
Future<void> rename(String name, String password, String newName);
|
||||
Future<void> rename(String currentName, String password, String newName);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ const walletTypes = [
|
||||
WalletType.monero,
|
||||
WalletType.bitcoin,
|
||||
WalletType.litecoin,
|
||||
WalletType.haven
|
||||
WalletType.haven,
|
||||
WalletType.ethereum,
|
||||
];
|
||||
const walletTypeTypeId = 5;
|
||||
|
||||
@@ -27,6 +28,9 @@ enum WalletType {
|
||||
|
||||
@HiveField(4)
|
||||
haven,
|
||||
|
||||
@HiveField(5)
|
||||
ethereum,
|
||||
}
|
||||
|
||||
int serializeToInt(WalletType type) {
|
||||
@@ -39,6 +43,8 @@ int serializeToInt(WalletType type) {
|
||||
return 2;
|
||||
case WalletType.haven:
|
||||
return 3;
|
||||
case WalletType.ethereum:
|
||||
return 4;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
@@ -54,6 +60,8 @@ WalletType deserializeFromInt(int raw) {
|
||||
return WalletType.litecoin;
|
||||
case 3:
|
||||
return WalletType.haven;
|
||||
case 4:
|
||||
return WalletType.ethereum;
|
||||
default:
|
||||
throw Exception('Unexpected token: $raw for WalletType deserializeFromInt');
|
||||
}
|
||||
@@ -69,6 +77,8 @@ String walletTypeToString(WalletType type) {
|
||||
return 'Litecoin';
|
||||
case WalletType.haven:
|
||||
return 'Haven';
|
||||
case WalletType.ethereum:
|
||||
return 'Ethereum';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
@@ -84,6 +94,8 @@ String walletTypeToDisplayName(WalletType type) {
|
||||
return 'Litecoin (LTC)';
|
||||
case WalletType.haven:
|
||||
return 'Haven (XHV)';
|
||||
case WalletType.ethereum:
|
||||
return 'Ethereum (ETH)';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
@@ -99,6 +111,8 @@ CryptoCurrency walletTypeToCryptoCurrency(WalletType type) {
|
||||
return CryptoCurrency.ltc;
|
||||
case WalletType.haven:
|
||||
return CryptoCurrency.xhv;
|
||||
case WalletType.ethereum:
|
||||
return CryptoCurrency.eth;
|
||||
default:
|
||||
throw Exception('Unexpected wallet type: ${type.toString()} for CryptoCurrency walletTypeToCryptoCurrency');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user