2024-01-10 16:08:12 +00:00
|
|
|
import 'package:ethereum_addresses/ethereum_addresses.dart';
|
2024-05-23 00:37:06 +00:00
|
|
|
import '../../../models/isar/models/blockchain_data/address.dart';
|
|
|
|
import '../../../models/node_model.dart';
|
|
|
|
import '../../../utilities/default_nodes.dart';
|
|
|
|
import '../../../utilities/enums/derive_path_type_enum.dart';
|
|
|
|
import '../crypto_currency.dart';
|
|
|
|
import '../intermediate/bip39_currency.dart';
|
2024-01-10 16:08:12 +00:00
|
|
|
|
|
|
|
class Ethereum extends Bip39Currency {
|
|
|
|
Ethereum(super.network) {
|
2024-05-15 21:20:45 +00:00
|
|
|
_idMain = "ethereum";
|
|
|
|
_uriScheme = "ethereum";
|
2024-01-10 16:08:12 +00:00
|
|
|
switch (network) {
|
|
|
|
case CryptoCurrencyNetwork.main:
|
2024-05-15 21:20:45 +00:00
|
|
|
_id = _idMain;
|
|
|
|
_name = "Ethereum";
|
|
|
|
_ticker = "ETH";
|
2024-01-10 16:08:12 +00:00
|
|
|
default:
|
|
|
|
throw Exception("Unsupported network: $network");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-15 21:20:45 +00:00
|
|
|
late final String _id;
|
|
|
|
@override
|
|
|
|
String get identifier => _id;
|
|
|
|
|
|
|
|
late final String _idMain;
|
|
|
|
@override
|
|
|
|
String get mainNetId => _idMain;
|
|
|
|
|
|
|
|
late final String _name;
|
|
|
|
@override
|
|
|
|
String get prettyName => _name;
|
|
|
|
|
|
|
|
late final String _uriScheme;
|
|
|
|
@override
|
|
|
|
String get uriScheme => _uriScheme;
|
|
|
|
|
|
|
|
late final String _ticker;
|
|
|
|
@override
|
|
|
|
String get ticker => _ticker;
|
|
|
|
|
2024-01-10 16:08:12 +00:00
|
|
|
int get gasLimit => 21000;
|
|
|
|
|
|
|
|
@override
|
|
|
|
bool get hasTokenSupport => true;
|
|
|
|
|
|
|
|
@override
|
2024-05-15 21:20:45 +00:00
|
|
|
NodeModel get defaultNode => NodeModel(
|
|
|
|
host: "https://eth.stackwallet.com",
|
|
|
|
port: 443,
|
|
|
|
name: DefaultNodes.defaultName,
|
|
|
|
id: DefaultNodes.buildId(this),
|
|
|
|
useSSL: true,
|
|
|
|
enabled: true,
|
|
|
|
coinName: identifier,
|
|
|
|
isFailover: true,
|
|
|
|
isDown: false,
|
|
|
|
);
|
2024-01-10 16:08:12 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
// Not used for eth
|
2024-05-15 21:20:45 +00:00
|
|
|
String get genesisHash => throw UnimplementedError("Not used for eth");
|
2024-01-10 16:08:12 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
int get minConfirms => 3;
|
|
|
|
|
|
|
|
@override
|
|
|
|
bool validateAddress(String address) {
|
|
|
|
return isValidEthereumAddress(address);
|
|
|
|
}
|
2024-04-17 18:04:10 +00:00
|
|
|
|
|
|
|
@override
|
2024-05-15 21:20:45 +00:00
|
|
|
int get defaultSeedPhraseLength => 12;
|
|
|
|
|
|
|
|
@override
|
|
|
|
int get fractionDigits => 18;
|
|
|
|
|
|
|
|
@override
|
|
|
|
bool get hasBuySupport => true;
|
|
|
|
|
|
|
|
@override
|
|
|
|
bool get hasMnemonicPassphraseSupport => true;
|
|
|
|
|
|
|
|
@override
|
|
|
|
List<int> get possibleMnemonicLengths => [defaultSeedPhraseLength, 24];
|
|
|
|
|
|
|
|
@override
|
|
|
|
AddressType get primaryAddressType => AddressType.ethereum;
|
|
|
|
|
|
|
|
@override
|
|
|
|
BigInt get satsPerCoin => BigInt.from(1000000000000000000);
|
|
|
|
|
|
|
|
@override
|
|
|
|
int get targetBlockTimeSeconds => 15;
|
|
|
|
|
|
|
|
@override
|
|
|
|
DerivePathType get primaryDerivePathType => DerivePathType.eth;
|
2024-04-17 18:04:10 +00:00
|
|
|
|
|
|
|
@override
|
2024-05-15 21:20:45 +00:00
|
|
|
Uri defaultBlockExplorer(String txid) {
|
|
|
|
switch (network) {
|
|
|
|
case CryptoCurrencyNetwork.main:
|
|
|
|
return Uri.parse("https://etherscan.io/tx/$txid");
|
|
|
|
default:
|
|
|
|
throw Exception(
|
|
|
|
"Unsupported network for defaultBlockExplorer(): $network",
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2024-01-10 16:08:12 +00:00
|
|
|
}
|