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

120 lines
2.8 KiB
Dart
Raw Normal View History

2024-03-21 19:38:59 +00:00
import 'package:solana/solana.dart';
2024-05-27 23:56:22 +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-03-20 00:50:42 +00:00
class Solana extends Bip39Currency {
Solana(super.network) {
2024-05-15 21:20:45 +00:00
_idMain = "solana";
_uriScheme = "solana";
2024-03-20 00:50:42 +00:00
switch (network) {
case CryptoCurrencyNetwork.main:
2024-05-15 21:20:45 +00:00
_id = _idMain;
_name = "Solana";
_ticker = "SOL";
2024-03-20 00:50:42 +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-03-20 00:50:42 +00:00
@override
NodeModel get defaultNode {
switch (network) {
case CryptoCurrencyNetwork.main:
return NodeModel(
2024-04-25 19:00:44 +00:00
host:
"https://api.mainnet-beta.solana.com/", // TODO: Change this to stack wallet one
2024-03-20 00:50:42 +00:00
port: 443,
name: DefaultNodes.defaultName,
2024-05-15 21:20:45 +00:00
id: DefaultNodes.buildId(this),
2024-03-20 00:50:42 +00:00
useSSL: true,
enabled: true,
2024-05-15 21:20:45 +00:00
coinName: identifier,
2024-03-20 00:50:42 +00:00
isFailover: true,
isDown: false,
);
default:
throw Exception("Unsupported network: $network");
}
}
@override
int get minConfirms => 21;
2024-04-25 19:00:44 +00:00
@override
bool get torSupport => true;
2024-03-20 00:50:42 +00:00
@override
bool validateAddress(String address) {
2024-04-25 19:00:44 +00:00
return isPointOnEd25519Curve(
2024-05-27 23:56:22 +00:00
Ed25519HDPublicKey.fromBase58(address).toByteArray(),
);
2024-03-20 00:50:42 +00:00
}
@override
String get genesisHash => throw UnimplementedError();
2024-05-03 15:33:59 +00:00
@override
2024-05-15 21:20:45 +00:00
int get defaultSeedPhraseLength => 12;
@override
int get fractionDigits => 9;
@override
bool get hasBuySupport => false;
@override
bool get hasMnemonicPassphraseSupport => false;
2024-05-03 15:33:59 +00:00
@override
2024-05-15 21:20:45 +00:00
List<int> get possibleMnemonicLengths => [defaultSeedPhraseLength, 24];
@override
AddressType get primaryAddressType => AddressType.solana;
@override
BigInt get satsPerCoin => BigInt.from(1000000000);
@override
int get targetBlockTimeSeconds => 1;
@override
DerivePathType get primaryDerivePathType => DerivePathType.solana;
@override
Uri defaultBlockExplorer(String txid) {
switch (network) {
case CryptoCurrencyNetwork.main:
return Uri.parse("https://explorer.solana.com/tx/$txid");
default:
throw Exception(
"Unsupported network for defaultBlockExplorer(): $network",
);
}
}
2024-04-25 19:00:44 +00:00
}