stack_wallet/lib/wallets/crypto_currency/coins/stellar.dart

140 lines
3.4 KiB
Dart
Raw Normal View History

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-11 23:18:58 +00:00
class Stellar extends Bip39Currency {
Stellar(super.network) {
2024-05-15 21:20:45 +00:00
_idMain = "stellar";
_uriScheme = "stellar";
2024-01-11 23:18:58 +00:00
switch (network) {
case CryptoCurrencyNetwork.main:
2024-05-15 21:20:45 +00:00
_id = _idMain;
_name = "Stellar";
_ticker = "XLM";
2024-01-11 23:18:58 +00:00
case CryptoCurrencyNetwork.test:
2024-05-15 21:20:45 +00:00
_id = "stellarTestnet";
_name = "tStellar";
_ticker = "tXLM";
2024-01-11 23:18:58 +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-11 23:18:58 +00:00
@override
int get minConfirms => 1;
2024-04-25 19:01:28 +00:00
@override
bool get torSupport => true;
2024-01-11 23:18:58 +00:00
@override
String get genesisHash => throw UnimplementedError(
"Not used for stellar",
);
@override
NodeModel get defaultNode {
switch (network) {
case CryptoCurrencyNetwork.main:
2024-05-15 21:20:45 +00:00
return NodeModel(
host: "https://horizon.stellar.org",
port: 443,
name: DefaultNodes.defaultName,
id: DefaultNodes.buildId(this),
useSSL: false,
enabled: true,
coinName: identifier,
isFailover: true,
isDown: false,
);
2024-01-11 23:18:58 +00:00
case CryptoCurrencyNetwork.test:
2024-05-15 21:20:45 +00:00
return NodeModel(
host: "https://horizon-testnet.stellar.org/",
port: 50022,
name: DefaultNodes.defaultName,
id: DefaultNodes.buildId(this),
useSSL: true,
enabled: true,
coinName: identifier,
isFailover: true,
isDown: false,
);
2024-01-11 23:18:58 +00:00
default:
throw Exception("Unsupported network");
}
}
@override
bool validateAddress(String address) =>
RegExp(r"^[G][A-Z0-9]{55}$").hasMatch(address);
@override
2024-05-15 21:20:45 +00:00
int get defaultSeedPhraseLength => 24;
@override
2024-05-15 21:20:45 +00:00
int get fractionDigits => 7;
@override
bool get hasBuySupport => false;
@override
bool get hasMnemonicPassphraseSupport => true;
@override
List<int> get possibleMnemonicLengths => [defaultSeedPhraseLength, 12];
@override
AddressType get primaryAddressType => AddressType.stellar;
@override
BigInt get satsPerCoin => BigInt.from(
10000000,
); // https://developers.stellar.org/docs/fundamentals-and-concepts/stellar-data-structures/assets#amount-precision
@override
int get targetBlockTimeSeconds => 5;
@override
DerivePathType get primaryDerivePathType => throw UnsupportedError(
2024-05-27 23:56:22 +00:00
"$runtimeType does not use bitcoin style derivation paths",
);
2024-05-15 21:20:45 +00:00
@override
Uri defaultBlockExplorer(String txid) {
switch (network) {
case CryptoCurrencyNetwork.main:
return Uri.parse("https://stellarchain.io/tx/$txid");
case CryptoCurrencyNetwork.test:
return Uri.parse("https://testnet.stellarchain.io/transactions/$txid");
default:
throw Exception(
"Unsupported network for defaultBlockExplorer(): $network",
);
}
}
2024-01-11 23:18:58 +00:00
}